本文整理汇总了C++中TCanvas::Clone方法的典型用法代码示例。如果您正苦于以下问题:C++ TCanvas::Clone方法的具体用法?C++ TCanvas::Clone怎么用?C++ TCanvas::Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCanvas
的用法示例。
在下文中一共展示了TCanvas::Clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractObjectFromFile
TList* extractObjectFromFile(const char* fileName, const char* name)
{
TList* objects = new TList();
TFile file(fileName);
gROOT->cd();
TList* keyList = file.GetListOfKeys();
for (int i = 0; i < keyList->GetSize(); ++i) {
TKey* key = static_cast<TKey*>(keyList->At(i));
std::cout<< key->GetName()<< std::endl;
if (!strcmp(key->GetName(), name)) {
objects->Add(key->ReadObj()->Clone());
} else if (!strcmp(key->GetClassName(), "TCanvas")) {
TCanvas* canvas = static_cast<TCanvas*>(key->ReadObj());
if (!strcmp(canvas->GetName(), name))
objects->Add(canvas->Clone());
TList* objectsFromPad = extractObjectFromPad(canvas, name);
for (int j = 0; j < objectsFromPad->GetSize(); ++j)
objects->Add(objectsFromPad->At(j));
}
}
file.Close();
return objects;
}
示例2: TnPDrawMass_for_B
//.........这里部分代码省略.........
tmp1->cd();
TString title;
title = "J/#psi " + Cat3 + " Efficiency Heavy Ion TnP Result (" + middle_name2 + ")";
TLatex fitInfo;
fitInfo.SetTextAlign(13);
fitInfo.SetTextSize(0.05);
fitInfo.DrawLatex(0.05,0.95, title);
fitInfo.DrawLatex(0.05,0.90, data_set);
fitInfo.SetTextSize(0.04);
fitInfo.DrawLatex(0.05,0.80, "FitFunction Condition");
fitInfo.SetTextSize(0.03);
if(Mode_ == 1) {
fitInfo.DrawLatex(0.1,0.60,"CBShape::signal(mass, mean[3.1,3.0,3.2], sigma[0.05,0.01,0.1], alpha[1.0, 0.2, 2.0], n[2, 0.5, 100.])");
fitInfo.DrawLatex(0.1,0.55,"Exponential::backgroundPass(mass, lp[0,-5,5])");
fitInfo.DrawLatex(0.1,0.50,"Exponential::backgroundFail(mass, lf[0,-5,5])");
} else if(Mode_ == 2) {
fitInfo.DrawLatex(0.1,0.70,"Gaussian::G1(mass, mean, sigma1[0.15,0.05,0.25])");
fitInfo.DrawLatex(0.1,0.65,"Gaussian::G2(mass, mean, sigma2[0.02,0.01,0.1])");
fitInfo.DrawLatex(0.1,0.60,"SUM::signal(coef[0.1,0,1]*G1,G2)");
fitInfo.DrawLatex(0.1,0.55,"Chebychev::backgroundPass(mass, {cPass[0,-0.5,0.5], cPass2[0,-0.5,0.5]})");
fitInfo.DrawLatex(0.1,0.50,"Chebychev::backgroundFail(mass, {cFail[0,-0.5,0.5], cFail2[0,-0.5,0.5]})");
} else {
fitInfo.DrawLatex(0.1,0.60,"CBShape::signal(mass, mean[3.1,3.0,3.2], sigma[0.05,0.01,0.1], alpha[1.0, 0.2, 3.0], n[1, 1.0, 100.])");
fitInfo.DrawLatex(0.1,0.55,"Chebychev::backgroundPass(mass, {cPass[0,-0.5,0.5], cPass2[0,-0.5,0.5]})");
fitInfo.DrawLatex(0.1,0.50,"Chebychev::backgroundFail(mass, {cFail[0,-0.5,0.5], cFail2[0,-0.5,0.5]})");
}
fitInfo.SetTextSize(0.04);
fitInfo.DrawLatex(0.05,0.40,"Bin Information");
fitInfo.SetTextSize(0.03);
fitInfo.DrawLatex(0.1,0.30,"#eta : -2.4,-1.97,-1.72,-1.47,-1.22,-0.97,-0.72,0.47,0.22,0.03,0.28,0.53,0.78,1.03,1.46");
fitInfo.DrawLatex(0.1,0.25,"p_{T} [GeV/c] : 6.5,7.5,8.5,9.5,11,14,30");
c1 = (TCanvas *)tmp1->Clone();
c1->Print(outname_mid);
c1->Print(outfile_);
TString mid_title = "Centrality : (" + middle_name2 + ")";
TString leg_title = Cat2 + " " + Cat3 + " Efficiency (" + middle_name2 + ")";
if(Mode < 1) {
// pt
for(int j = 0; j < ptBins; j++) {
cout<<" dir_pt : "<<dir_pt<<", ptbins : "<<ptbins[j]<<", dir_suffix : "<<dir_suffix<<endl;
TString tot_dir = dir_pt + ptbins[j] + dir_suffix;
f->cd(tot_dir);
cout<<" tot_dir : "<<tot_dir<<endl;
TDirectory *root_dir = gDirectory;
TIter rootnextkey( root_dir->GetListOfKeys() );
root_dir->cd();
TKey *rootkey;
TCanvas *ctmp = new TCanvas();
ctmp->cd();
TLatex l;
l.SetTextAlign(13);
l.SetTextSize(0.06);
l.DrawLatex(0.1,0.8,mid_title);
l.DrawLatex(0.1,0.6,"Bin : ");
l.SetTextSize(0.04);
l.DrawLatex(0.1,0.5,tot_dir);
ctmp->Update();
c1 = (TCanvas *)ctmp->Clone();
c1->Print(outname_mid);
c1->Print(outfile_);
示例3: TnPDrawMass_test_5eta5
void TnPDrawMass_test_5eta5()
{
char *infile;
//char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/mc/out/gputEveryCut_mc_allDirection_v24_nominalCond_5etaBins_cutG_all_2G_v1.root";
//char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/mc/out/gputEveryCut_mc_allDirection_v24_nominalCond_5etaBins_cutG_all_Multi_v1.root";
//char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/mc/out/gputEveryCut_mc_allDirection_v24_nominalCond_5etaBins_cutG_all_PAMu7_v1.root";
//char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/mc/out/gputEveryCut_mc_allDirection_v24_nominalCond_5etaBins_cutG_all_merge_v1.root";
//char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/mc/out/gputEveryCut_mc_allDirection_v24_nominalCond_5etaBins_cutG_all_narrow_v1.root";
char *files = "/afs/cern.ch/work/g/goni/cms760pre4/src/test_TNP/TnP/data/outputEveryCut_data_allDirection_v24_nominalCond_5etaBins_cutG_all_nominal_v8_oldeta.root";
TString outname_in, outname_mid, outname_out;
TString middle_name, middle_name2;
gROOT->SetStyle("Plain");
gStyle->SetOptStat(0);
gStyle->SetTitle(0);
gStyle->SetPaperSize(20,26);
TCanvas *c1 = new TCanvas();
Int_t type = 112;
TString out1 = outfile_ + "[";
c1->SetLogy();
c1->Print(out1);
infile = files;
TFile *f = new TFile(infile);
outname_in = "Jpsi_" + Cat1 + "_" + Cat2 + "_Mass_" + middle_name + ".ps[";
outname_mid = "Jpsi_" + Cat1 + "_" + Cat2 + "_Mass_" + middle_name + ".ps";
outname_out = "Jpsi_" + Cat1 + "_" + Cat2 + "_Mass_" + middle_name + ".ps]";
cout<<" Out Name : "<<outname_in<<" "<<outname_mid<<" "<<outname_in<<endl;
TString tot_dir; //dir_suffix;
//TString ptbins[ptBins] = {"pt_bin0_", "pt_bin1_", "pt_bin2_", "pt_bin3_", "pt_bin4_",
// "pt_bin5_", "pt_bin6_", "pt_bin7_", "pt_bin8_",};//1
//TString ptbins1[ptBins1] = {"3.3 - 3.8 GeV", "3.8 - 4.3 GeV", "4.3 - 5 GeV", "5 - 6 GeV", "6 - 7 GeV",
// "7 - 8 GeV", "8 - 10 GeV", "10 - 13 GeV", "13 - 30 GeV"};//1
TString dir_pt[ptBins] = {"tpTree/ptBin_eta5_0/", "tpTree/ptBin_eta5_1/", "tpTree/ptBin_eta5_2/", "tpTree/ptBin_eta5_3/", "tpTree/ptBin_eta5_4/", "tpTree/ptBin_eta5_5/", "tpTree/ptBin_eta5_6/", "tpTree/ptBin_eta5_7/"};//5
TString ptbins1[ptBins1] = {"1.3 - 1.6 GeV", "1.6 - 1.8 GeV", "1.8 - 2.0 GeV", "2.0 - 2.6 GeV", "2.6 - 3.4 GeV", "3.4 - 4.8 GeV", "4.8 -6.0 GeV", "6.0 - 30 GeV"};//5
//TString ptbins[ptBins] = {"pt_bin0_", "pt_bin1_", "pt_bin2_", "pt_bin3_", "pt_bin4_",
// "pt_bin5_", "pt_bin6_", "pt_bin7_", "pt_bin8_", "pt_bin9_"};//3
//TString ptbins1[ptBins1] = {"0 - 3.3 GeV", "3.3 - 3.8 GeV", "3.8 - 4.3 GeV", "4.3 - 5 GeV", "5 -6 GeV",
// "6 - 7 GeV", "7 - 8 GeV", "8 - 10 GeV", "10 - 13 GeV", "13 - 30 GeV"};//3
//TString ptbins[ptBins] = {"pt_bin0_", "pt_bin1_", "pt_bin2_", "pt_bin3_", "pt_bin4_",
// "pt_bin5_", "pt_bin6_", "pt_bin7_", "pt_bin8_", "pt_bin9_"};//4
//TString ptbins1[ptBins1] = {"0 - 3.3 GeV", "3.3 - 3.8 GeV", "3.8 - 4.3 GeV", "4.3 - 5 GeV", "5 -6 GeV",
// "6 - 7 GeV", "7 - 8 GeV", "8 - 10 GeV", "10 - 13 GeV", "13 - 30 GeV"};//4
//TString ptbins[ptBins] = {"pt_bin0_", "pt_bin1_", "pt_bin2_", "pt_bin3_", "pt_bin4_",
// "pt_bin5_", "pt_bin6_", "pt_bin7_", "pt_bin8_", "pt_bin9_"};//5
//TString ptbins1[ptBins1] = {"0 - 3.3 GeV", "3.3 - 3.8 GeV", "3.8 - 4.3 GeV", "4.3 - 5 GeV", "5 -6 GeV",
// "6 - 7 GeV", "7 - 8 GeV", "8 - 10 GeV", "10 - 13 GeV", "13 - 30 GeV"};//5
//dir_pt = "tpTree/ptBin_eta1/";
//dir_pt = "tpTree/ptBin_eta3/";
//dir_pt = "tpTree/ptBin_eta3/";
//dir_pt = "tpTree/ptBin_eta5/";
//dir_pt = "tpTree/ptBin_eta5/";
//dir_suffix = "_cbGaussPlusPoly1";
//dir_suffix = "_cbGaussPlusPoly4";
TString dir_suffix[ptBins]= {"_cbGaussPlusExpo5_0","_cbGaussPlusExpo5_1","_cbGaussPlusExpo5_2","_cbGaussPlusExpo5_3","_cbGaussPlusExpo5_4","_cbGaussPlusExpo5_5", "_cbGaussPlusExpo5_6", "_cbGaussPlusExpo5_7"};
//dir_suffix = "_GaussPlusExpo";
//dir_suffix = "_twoGaussPlusExpo";
gStyle->SetPaperSize(20,26);
c1->Print(outname_in);
int cnt = 0;
TCanvas *tmp1 = new TCanvas();
tmp1->cd();
TString title;
title = "J/#psi Efficiency Heavy Ion TnP Result (" + middle_name2 + ")";
c1 = (TCanvas *)tmp1->Clone();
c1->Print(outname_mid);
c1->Print(outfile_);
TString mid_title = "Centrality : (" + middle_name2 + ")";
TString leg_title = Cat2 + " Efficiency (" + middle_name2 + ")";
// pt
for(int j = 0; j < ptBins; j++){
//TString tot_dir = dir_pt + "abseta_bin0__event_PrimaryVertex_z_bin0__" + ptbins[j] + "_tag_eta_bin0__tag_pt_bin0__Acc_JPsi_pass__Calo_pass__tag_PAMu3_standard_pass_" + dir_suffix;
TString tot_dir = dir_pt[j] + "abseta_bin0__event_PrimaryVertex_z_bin0__pt_bin0__tag_eta_bin0__tag_pt_bin0__Acc_JPsiG_pass__Calo_pass__tag_PAMu3_standard_pass_" + dir_suffix[j];//2G,PAMu3,merge
//TString tot_dir = dir_pt + "abseta_bin0__event_PrimaryVertex_z_bin0__" + ptbins[j] + "_tag_eta_bin0__tag_pt_bin0__Acc_JPsiG_pass__Calo_pass__tag_PAMu7_standard_pass_" + dir_suffix;//PAMu7
//TString tot_dir = dir_pt + "abseta_bin0__event_PrimaryVertex_z_bin0__pair_probeMultiplicity_bin0__" + ptbins[j] + "_tag_eta_bin0__tag_pt_bin0__Acc_JPsiG_pass__Calo_pass__tag_PAMu3_standard_pass_" + dir_suffix;//multi
//TString tot_dir = dir_pt + "abseta_bin0__event_PrimaryVertex_z_bin0__" + ptbins[j] + "_tag_eta_bin0__tag_pt_bin0__Acc_JPsi_pass__Calo_pass__tag_PAMu3_standard_pass_" + dir_suffix;//merge
//
f->cd(tot_dir);
//.........这里部分代码省略.........
示例4: getRatio
TCanvas* getRatio(TString plotName, int verbose, TString outputFile){
// ============================
// Set Root Style
// ============================
TStyle myStyle("HHStyle","HHStyle");
setHHStyle(myStyle);
TGaxis::SetMaxDigits(2);
myStyle.cd();
gROOT->SetStyle("HHStyle");
// draw data uncertainties as bands
bool bands=true;
// compare current with old result
bool compare=false;
TString oldResult="/afs/naf.desy.de/group/cms/scratch/tophh/tmp/OldCombination/";
// open file
TFile* file = TFile::Open(outputFile, "READ");
// dont associate new objects with file to be able to close it in the end
gROOT->cd();
// get canvas for chosen cross section
TCanvas* canvas = (TCanvas*)(file->Get("finalXSec/"+plotName+"Norm")->Clone());
// GET DATA: with final errors from canvas
TGraphAsymmErrors* dataRaw = (TGraphAsymmErrors*)canvas->GetPrimitive("dataTotalError");
TGraphAsymmErrors* dataStat = (TGraphAsymmErrors*)canvas->GetPrimitive("dataStatError");
// GET DATA: create rebinned histo
std::map< TString, std::vector<double> > binning_ = makeVariableBinning();
int Nbins = std::abs(binning_[plotName][binning_[plotName].size()-1]-binning_[plotName][0])*100;
if(plotName.Contains("topY")) Nbins/=10;
if(verbose>1) std::cout << Nbins << std::endl;
TH1F* datatemp= new TH1F("data"+plotName, "data"+plotName, Nbins, binning_[plotName][0], binning_[plotName][binning_[plotName].size()-1]);
reBinTH1F(*datatemp, binning_[plotName], 0);
// GET DATA: refill TGraphAsymmErrors to rebinned histo
for(int bin=1; bin<=datatemp->GetNbinsX(); ++bin){
if(verbose>1){
std::cout << "bin: " << bin << std::endl;
std::cout << dataRaw->GetY()[bin];
}
datatemp->SetBinContent(bin, dataRaw->GetY()[bin]);
double err=dataRaw->GetErrorYhigh(bin);
if(err<dataRaw->GetErrorYlow(bin)) err=dataRaw->GetErrorYlow(bin);
if(verbose>1) std::cout << " +- " << err << std::endl;
datatemp->SetBinError(bin, err);
}
// GET DATA: delete empty bins
TH1F* data=killEmptyBins((TH1F*)datatemp->Clone(), verbose);
data->GetXaxis()->SetTitle(xSecLabelName(plotName));
if(verbose>1){
for(int bin=1; bin<=data->GetNbinsX(); ++bin){
std::cout << "bin: " << bin << std::endl;
std::cout << data->GetBinContent(bin) << " +- " << data->GetBinError(bin) << std::endl;
}
}
// GET THEORY: binned curves from canvas
TH1F* plotNNLO = (TH1F*)canvas->GetPrimitive(plotName+"nnlo" );
TH1F* plotMadGraph = (TH1F*)canvas->GetPrimitive(plotName );
TH1F* plotmcatnlo = (TH1F*)canvas->GetPrimitive(plotName+"[email protected]");
if(!plotmcatnlo) plotmcatnlo = (TH1F*)canvas->GetPrimitive(plotName+"[email protected]");
TGraphAsymmErrors* plotmcatnloerror = (TGraphAsymmErrors*)canvas->GetPrimitive(plotName+"[email protected]");
TH1F* plotpowheg = (TH1F*)canvas->GetPrimitive(plotName+"POWHEG");
TH1F* plotpowhegherwig = (TH1F*)canvas->GetPrimitive(plotName+"POWHEGHERWIG");
std::vector<TH1F*>hist_;
// GET THEORY: delete empty bins
// a) peturbative QCD
TH1F* finalNNLO=0;
if(plotNNLO ){
// delete empty bins
TH1F* tempNNLO=killEmptyBins(plotNNLO, verbose);
std::cout << tempNNLO->GetName() << std::endl;
// delete bins put of range
int Nnnlobins = std::abs(binning_[plotName][binning_[plotName].size()-1]-binning_[plotName][0])*10;
finalNNLO=new TH1F(tempNNLO->GetName(),tempNNLO->GetTitle(), Nnnlobins, binning_[plotName][0], binning_[plotName][binning_[plotName].size()-1]);
reBinTH1F(*finalNNLO, binning_[plotName], 0);
for(int bin=0; bin<=tempNNLO->GetNbinsX()+1; ++bin){
double binlowedge=tempNNLO->GetBinLowEdge(bin);
if(plotName.Contains("topPt")&&binlowedge==1.) binlowedge=0.;
//std::cout << "binlowedge: " << binlowedge << std::endl;
for(int binf=0; binf<=finalNNLO->GetNbinsX()+1; ++binf){
//std::cout << "scanlowedge: " << finalNNLO->GetBinLowEdge(binf) << std::endl;
if(binlowedge==finalNNLO->GetBinLowEdge(binf)){
//std::cout << "fits!" << std::endl;
finalNNLO->SetBinContent(binf, tempNNLO->GetBinContent(bin)) ;
finalNNLO->SetBinError(binf, tempNNLO->GetBinError(bin));
}
}
}
}
// b) [email protected] errorbands
if(plotmcatnloerror&&plotmcatnlo){
TH1F* plotmcatnloerror1 =(TH1F*)((killEmptyBins(plotmcatnlo, verbose))->Clone((TString)plotmcatnloerror->GetName()+"Up"));
TH1F* plotmcatnloerror2 =(TH1F*)((killEmptyBins(plotmcatnlo, verbose))->Clone((TString)plotmcatnloerror->GetName()+"Dn"));
for(int p=0; p<plotmcatnloerror->GetN(); ++p){
plotmcatnloerror1->SetBinContent(p, plotmcatnloerror->GetErrorYhigh(p)+plotmcatnloerror->GetY()[p]);
plotmcatnloerror2->SetBinContent(p, plotmcatnloerror->GetY()[p]-plotmcatnloerror->GetErrorYlow(p));
}
plotmcatnloerror1->SetLineStyle(1);
plotmcatnloerror2->SetLineStyle(1);
hist_.push_back( killEmptyBins(plotmcatnloerror1, verbose) );
//.........这里部分代码省略.........
示例5: EstimateBg_76X
//.........这里部分代码省略.........
printf("\\topcaption{Estimated Standard Model background yields in ABCD regions. A, B is in the sideband, C and D is the signal band, D is the signal region.\\label{tab:SMBkgEstimate}}\n");
printf("\\begin{tabular}{lrrrrrrrr}\n");
}
TFile *f = TFile::Open(filename.c_str());
for (size_t iMethod = 0; iMethod<4; ++iMethod) if (!(iMethod==0&&samples[0].size()==0)){
// Print Top row for each method
if (latex) {
if (iMethod==0) {
printf("\\hline\n");
printf("Method 2 & A & B & C & D = B*C/A & D obs. & Ratio pred./obs. & Pull & KS test\\\\\n");
} else if (iMethod==1){
printf("\\hline\n");
printf("Method 1 & A & B & C & D = B*C/A & D obs. & Ratio pred./obs. & Pull & KS test\\\\\n");
}
printf("\\hline\n");
} else {
std::stringstream r_sb_cut;
if (R_CUT_LOW==0) r_sb_cut<<"R<"<<R_CUT;
else r_sb_cut<<R_CUT_LOW<<"<R<"<<R_CUT;
const char* prime = ABCD_prime ? "'" : "";
//if (iMethod==0) printf("| *Sample* | *A (DPhi>2.8, SB)* | *B (DPhi<2.8, SB)* | *C (DPhi>2.8, Sig.B.)* | - | *D = B*C/A pred.* | *D (DPhi<2.8, Sig.B.) obs.* | *Ratio pred./obs.* |\n");
//else if (iMethod==1) printf("| *Sample* | *A (R<%1.1f, SB)* | *B (R>%1.1f, SB)* | *C (R<%1.1f, Sig.B.)* | *D = B (R fit, SB) * C/A pred.* | *D = B*C/A pred.* | *D (R>%1.1f, Sig.B.) obs.* | *Ratio pred./obs.* | \n", R_CUT, R_CUT, R_CUT, R_CUT);
if (iMethod==0) printf("| *Sample* | *A (DPhi>%1.1f, %s)* | *B (DPhi<%1.1f, %s)* | *C (DPhi>%1.1f, R>0.4)* | *D = B*C/A pred.* | *D (DPhi<%1.1f, R>0.4) obs.* | *Ratio pred./obs.* | *Pull (pred-obs)/error* | *KS test* |\n", DPHI_CUT, r_sb_cut.str().c_str(), DPHI_CUT, r_sb_cut.str().c_str(), DPHI_CUT, DPHI_CUT);
else if (iMethod==1) printf("| *Sample* | *A%s (%s, <2 tag)* | *B%s (R>%1.1f, <2 tag)* | *C%s (%s, 2 tag)* | *D%s = B%s*C%s/A%s pred.* | *D%s (R>%1.1f, 2 tag) obs.* | *Ratio pred./obs.* | *Pull (pred-obs)/error* | *KS test* |\n", prime, r_sb_cut.str().c_str(), prime, R_CUT, prime, r_sb_cut.str().c_str(), prime, prime, prime, prime, prime, R_CUT);
}
TH1D *h_side_sum, *h_signal_sum;
for (size_t iSample = 0; iSample<samples[iMethod].size(); ++iSample) {
std::string canname =
iMethod==0 ? std::string("DPhiBins")+(ABCD_prime ? "/RBins_0To1HadTop_" : "/RBins_2HadTop_")+samples[iMethod][iSample] :
iMethod==1 ? std::string("RFine/Tau32Cuts_")+(ABCD_prime ? "Fail" : "Pass")+"DPhiCut_"+samples[iMethod][iSample] :
iMethod==2 ? std::string("RFine/Tau32Cuts_")+(ABCD_prime ? "Fail" : "Pass")+"DPhiCut_Background" :
iMethod==3 ? std::string("RFine/Tau32Cuts_")+(ABCD_prime ? "Fail" : "Pass")+"DPhiCut_"+samples[iMethod][iSample] : "";
TCanvas *can = (TCanvas*)(f->Get(canname.c_str()));
can = (TCanvas*)can->Clone();
can->Draw();
TH1D *h_side = (TH1D*)can->GetListOfPrimitives()->At(i_h_side[iMethod]);
TH1D *h_signal = (TH1D*)can->GetListOfPrimitives()->At(i_h_signal[iMethod]);
// Simulate different cross section by scaling a certain background
if (iMethod==1) {
TH1D *h_side_temp_scaled = (TH1D*)h_side->Clone(); h_side_temp_scaled->Scale(scale_factors[iSample]);
TH1D *h_signal_temp_scaled = (TH1D*)h_signal->Clone(); h_signal_temp_scaled->Scale(scale_factors[iSample]);
if (iSample==0) {
h_side_sum = h_side_temp_scaled;
h_signal_sum = h_signal_temp_scaled;
} else {
h_side_sum->Add(h_side_temp_scaled);
h_signal_sum->Add(h_signal_temp_scaled);
}
} else if (iMethod==2) {
h_side = h_side_sum;
h_signal = h_signal_sum;
}
TH1D *h_pred =(TH1D*)h_side->Clone();
if (iMethod!=0&&rebin>1) { h_side->Rebin(rebin); h_signal->Rebin(rebin); h_pred->Rebin(rebin); }
TLegend *leg = (TLegend*)can->GetListOfPrimitives()->At(can->GetListOfPrimitives()->GetEntries()-1);
leg->SetX1(0.35); leg->SetX2(0.65); leg->SetY1(0.6);
// Add ratio plot
int y1 = 350;
int y2 = 150;
int mid2 = 10;
can->Divide(1,2);
// Pad 1 (80+500+20 x 40+500)
TVirtualPad* p = can->cd(1);
p->SetPad(0,(y2+60+mid2)/(y1+y2+100.0+mid2),1,1);
p->SetTopMargin(40.0/(y1+40));