Extracting signal shapes from templates / plot pdf

Hello,

i am trying to extract the signal shapes from templates i have created and plot them (i.e. superimpose them) so that I can compare them one with each other.
I am posting below my code:

void ExtractTemplates()
{
  gROOT->ForceStyle();
  gROOT->SetStyle("Plain");
  gStyle->SetOptStat(000);
 
  RooMsgService::instance().setSilentMode(kTRUE);
  RooMsgService::instance().setStreamStatus(0,kFALSE);
  RooMsgService::instance().setStreamStatus(1,kFALSE);
  
// first file i want to exctract shape from
  TFile *fTemplates1 = TFile::Open("templates1.root");
  RooWorkspace *wTemplates = (RooWorkspace*)fTemplates1->Get("w");

// second file i want to extract shape from
 TFile *fTemplates2 = TFile::Open("templates2.root");
  RooWorkspace *wTemplates = (RooWorkspace*)fTemplates2->Get("w");

  //this is the pdf i want to extract &  plot (same name in all template.root files)
 //so i want to get ttbar_pdf from every template and superimpose it on a new plot in the end
 RooAbsPdf *pdf_signal = (RooAbsPdf*)wTemplates->pdf("ttbar_pdf");
 
  RooPlot *frame = pdf_signal->frame();
  pdf_signal->plotOn(frame);
  //frame->Draw();

  TCanvas *can = new TCanvas("Fitted_Nttbar",900,600);
  frame->SetMinimum(0.1);
  frame->GetYaxis()->SetNdivisions(505);
  frame->GetXaxis()->SetTitle("");
  frame->GetXaxis()->SetLabelSize(0.0);
  frame->Draw(); 

}

I can’t figure out how to proceed though in order to finally plot the pdf
any help would be very much appreciated :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.