void printYields( DrawBase* db, const std::string& suffix, bool doUL ) { std::string yieldsFileName = db->get_outputdir() + "/yields_" + suffix + ".txt"; cout << "Preparing file with yields: " << yieldsFileName << endl; ofstream yieldsFile(yieldsFileName.c_str()); float xMin = 250.; // chiara, to be changed with mass float xMax = 350.; std::vector<TH1D*> histos = db->get_lastHistos_mc(); int binXmin = histos[0]->FindBin(xMin); int binXmax = histos[0]->FindBin(xMax) -1; std::cout << "Considering binXmin = " << binXmin << ", binXmax = " << binXmax << std::endl; bool foundSignal = false; float signal = 0.; float totalBG = 0.; float totalBG_ave = 0.; yieldsFile << std::endl << "Yields: " << std::endl; for( unsigned int ii=0; ii<histos.size(); ++ii ) { yieldsFile << db->get_mcFile(ii).datasetName << " " << histos[ii]->Integral(binXmin, binXmax) << std::endl; if( db->get_mcFile(ii).datasetName != "Radion" ) { totalBG += histos[ii]->Integral(binXmin, binXmax); totalBG_ave += histos[ii]->Integral(1, histos[ii]->GetNbinsX()); } else { foundSignal = true; signal = histos[ii]->Integral(binXmin, binXmax); } } totalBG_ave *= (100.)/(histos[0]->GetXaxis()->GetXmax()-histos[0]->GetXaxis()->GetXmin()); yieldsFile << "Total BG: " << totalBG << " (averaged: " << totalBG_ave << ")" << std::endl; yieldsFile << "Total Signal: " << signal << std::endl; float signal_xsec = 0.000271; // chiara, this is for 300 GeV Radion float total_signal = signal_xsec*db->get_lumi(); float effS = signal/total_signal; yieldsFile << "Signal efficiency: " << effS << std::endl; if( !foundSignal ) std::cout << "WARNING!!! DIDN'T FIND SIGNAL!" << std::endl; if( doUL && foundSignal ) { float ul = CLA( db->get_lumi(), 0., effS, 0., totalBG, 0. ); float ul_bgave = CLA( db->get_lumi(), 0., effS, 0., totalBG_ave, 0. ); yieldsFile << std::endl << "No error on BG:" << std::endl; yieldsFile << "UL: " << ul << " (average BG): " << ul_bgave << std::endl; yieldsFile << "UL/SM: " << ul/signal_xsec << " (average BG): " << ul_bgave/signal_xsec << std::endl; // float ul_bgerr = CLA( db->get_lumi(), 0., effS, 0., totalBG, 0.05*totalBG ); // yieldsFile << std::endl << "5\% error on BG:" << std::endl; // yieldsFile << "UL: " << ul_bgerr << std::endl; // yieldsFile << "UL/SM: " << ul_bgerr/signal_xsec << std::endl; } }
int main( int argc, char* argv[] ) { std::string sel = "optsel3"; if( argc>1 ) { std::string sel_tmp(argv[1]); sel = sel_tmp; } std::string suffix = sel + "_TCHE_ALL.root"; //std::string dataFileName = = "ttZTrilepton_DATA_Run2011_FULL_" + suffix; //TFile* dataFile = TFile::Open(dataFileName.c_str()); std::string ttZFileName = "TTZTrilepton_TTZ_TuneZ2_7TeV-madgraphCMSSW42xPUv3_spadhi_" + suffix; TFile* ttZFile = TFile::Open(ttZFileName.c_str()); //TTree* signalTree = (TTree*)ttZFile->Get("tree_passedEvents"); std::string ttWFileName = "TTZTrilepton_TTW_TuneZ2_7TeV-madgraphCMSSW42xPUv2_spadhi_" + suffix; TFile* ttWFile = TFile::Open(ttWFileName.c_str()); //std::string mcZJetsFile = "ttZTrilepton_DYJetsToLL_TuneZ2_M-50_7TeV-madgraph-tauola_Fall11_" + suffix; //std::string mcTTbarFile = "ttZTrilepton_TTJ_Fall11_highstat_" + suffix; //std::string mcVVFile = "ttZTrilepton_VV_Summer11_" + suffix; //std::string mcttWFile = "ttZTrilepton_ttW_TuneZ2_7TeV-madgraphCMSSW42xPUv2_spadhi_" + suffix; //bgTree->Add(dyTreeName.c_str()); //bgTree->Add(ttTreeName.c_str()); //bgTree->Add(dibosonTreeName.c_str()); std::string dir = "TTZTrileptonPlots_DATA_Run2011_FULL_" + sel + "_TCHE_ALL/"; std::string yieldFileName = dir + "yields.txt"; std::string datacardName = dir + "datacard.txt"; ifstream yieldsFile(yieldFileName.c_str()); ifstream datacard(datacardName.c_str()); std::cout << "-> Opened yield file '" << yieldFileName << "'." << std::endl; std::string channel; std::string obs_str; std::string s_str, ttZ_str, ttW_str, b_pred_str, b_pred_err_str; bool found = false; while( yieldsFile.good() ) { yieldsFile >> channel >> obs_str >> s_str >> ttZ_str >> ttW_str >> b_pred_str >> b_pred_err_str; if( channel == "Total" ) found = true; } if( !found ) { std::cout << "There must be a problem. Didn't find total." << std::endl; exit(3431); } int obs = atoi(obs_str.c_str()); float s = atof(s_str.c_str()); float ttZ = atof(ttZ_str.c_str()); float ttW = atof(ttW_str.c_str()); float b_pred = atof(b_pred_str.c_str()); float b_pred_err = atof(b_pred_err_str.c_str()); // go get the syst on signal from datacard: std::cout << "-> Opened datacard file '" << datacardName << "'." << std::endl; bool go = false; //float lumiSystDOWN = 0.; //float lumiSystUP = 0.; float totalSignalSystDOWN = 0.; float totalSignalSystUP = 0.; float totalBGSystDOWN = 0.; float totalBGSystUP = 0.; while( datacard.good() ) { if( !go ) { char line[500]; datacard.getline( line, 500 ); TString line_tstr(line); if( (line_tstr.BeginsWith("#syst")) ) go=true; } else { std::string systName, shape, systSignal, systBG; datacard >> systName >> shape >> systSignal >> systBG; std::pair<float, float> pair_systSignal = getSystFromString(systSignal); std::pair<float, float> pair_systBG = getSystFromString(systBG); float systSignalDOWN = pair_systSignal.first; float systSignalUP = pair_systSignal.second; float systBGDOWN = pair_systBG.first; float systBGUP = pair_systBG.second; // last line reads zeroes dont know why if( systSignalDOWN==0. && systSignalUP==0. && systBGDOWN==0. && systBGUP==0. ) continue; systSignalDOWN = (systSignalDOWN>0.) ? fabs( 1.-systSignalDOWN ) : 0.; systSignalUP = (systSignalUP>0.) ? fabs( 1.-systSignalUP ) : 0.; systBGDOWN = (systBGDOWN>0.) ? fabs( 1.-systBGDOWN ) : 0.; systBGUP = (systBGUP>0.) ? fabs( 1.-systBGUP ) : 0.; totalBGSystDOWN += systBGDOWN*systBGDOWN; totalBGSystUP += systBGUP*systBGUP; totalSignalSystDOWN += systSignalDOWN*systSignalDOWN; totalSignalSystUP += systSignalUP*systSignalUP; std::cout << systName << " " << systSignalDOWN << " " << systSignalUP << " " << systBGDOWN << " " << systBGUP << std::endl; } } if( !go ) { std::cout << "Didn't find systematics in datacard!" << std::endl; exit(135); } totalBGSystDOWN = sqrt(totalBGSystDOWN); totalBGSystUP = sqrt(totalBGSystUP); totalSignalSystDOWN = sqrt(totalSignalSystDOWN); totalSignalSystUP = sqrt(totalSignalSystUP); std::cout << "totalBGSystDOWN : " << totalBGSystDOWN << std::endl; std::cout << "totalBGSystUP : " << totalBGSystUP << std::endl; std::cout << "totalSignalSystDOWN : " << totalSignalSystDOWN << std::endl; std::cout << "totalSignalSystUP : " << totalSignalSystUP << std::endl; // stat error on observed: double obs_plus, obs_minus; RooHistError::instance().getPoissonInterval(obs,obs_minus,obs_plus,1.); double obs_errPlus = obs_plus-obs; double obs_errMinus = obs-obs_minus; std::cout << "observed poissonian interval: " << obs_minus << "-" << obs_plus << std::endl; float ZBi = StatTools::computeZBi( s+b_pred, b_pred, b_pred_err ); float ZBi_obs = StatTools::computeZBi( obs, b_pred, b_pred_err ); float obs_ttV = obs - b_pred; TH1D* h1_nCounter_ttZ = (TH1D*)ttZFile->Get("nCounter"); float nTotal_ttZ = h1_nCounter_ttZ->GetBinContent(1); TH1D* h1_nCounter_ttW = (TH1D*)ttWFile->Get("nCounter"); float nTotal_ttW = h1_nCounter_ttW->GetBinContent(1); float lumi_pb = 4980.; float crossSection_ttZ = 0.139; float crossSection_ttW = 0.169; //float crossSection_ttW = 0.1633; float crossSection_ttV = crossSection_ttZ+crossSection_ttW; float n_passed_ttZ = nTotal_ttZ*ttZ/(crossSection_ttZ*lumi_pb); float eff_ttZ = n_passed_ttZ/nTotal_ttZ; float n_passed_ttW = nTotal_ttW*ttW/(crossSection_ttW*lumi_pb); float eff_ttW = n_passed_ttW/nTotal_ttW; float eff_ttV = ( crossSection_ttZ*eff_ttZ + crossSection_ttW*eff_ttW ) / ( crossSection_ttZ + crossSection_ttW ); std::cout << "n_passed_ttZ: " << n_passed_ttZ << " (eff: " << eff_ttZ*100. << "% /BR: " << eff_ttZ*100./(2.*0.22*0.67*0.06) << "%)" << std::endl; std::cout << "n_passed_ttW: " << n_passed_ttW << " (eff: " << eff_ttW*100. << "% /BR: " << eff_ttW*100./(0.22*0.22*0.67) << "%)" << std::endl; std::cout << "eff_ttV: " << eff_ttV*100. << " %" << std::endl; float crossSectionObs_ttZ = obs_ttV / ( lumi_pb*eff_ttZ ); float crossSectionObs_ttV = obs_ttV / ( lumi_pb*eff_ttV ); float xsecErr_ttZ_stat_plus = obs_errPlus / ( lumi_pb*eff_ttZ ); float xsecErr_ttZ_stat_minus = obs_errMinus / ( lumi_pb*eff_ttZ ); float xsecErr_ttV_stat_plus = obs_errPlus / ( lumi_pb*eff_ttV ); float xsecErr_ttV_stat_minus = obs_errMinus / ( lumi_pb*eff_ttV ); // xsec = obs_ttV / ( lumi*eff ) // signal syst are on lumi and eff // so err(eff) -> err(xsec) = obs_ttV/( lumi*eff*eff ) * err(eff) = xsec*err(eff)/eff // so err(lumi) -> err(xsec) = obs_ttV/( lumi*lumi*eff ) * err(lumi) = xsec*err(lumi)/lumi // total error is xsec*(quadrature sum of all relative errors) float xsecErr_ttZ_systSignal_plus = crossSection_ttZ*(totalSignalSystUP); float xsecErr_ttZ_systSignal_minus = crossSection_ttZ*(totalSignalSystDOWN); float xsecErr_ttV_systSignal_plus = crossSection_ttV*(totalSignalSystUP); float xsecErr_ttV_systSignal_minus = crossSection_ttV*(totalSignalSystDOWN); // background systematics instead affect the numerator: // xsec = ( obs - BG ) / ( lumi*eff ) // so err(BG) -> err(xsec) = err(BG) / ( lumi*eff ) float xsecErr_ttZ_systBG_plus = totalBGSystUP * b_pred / ( lumi_pb*eff_ttZ ); float xsecErr_ttZ_systBG_minus = totalBGSystDOWN * b_pred / ( lumi_pb*eff_ttZ ); float xsecErr_ttV_systBG_plus = totalBGSystUP * b_pred / ( lumi_pb*eff_ttV ); float xsecErr_ttV_systBG_minus = totalBGSystDOWN * b_pred / ( lumi_pb*eff_ttV ); float xsecErr_ttZ_syst_plus = sqrt( xsecErr_ttZ_systSignal_plus *xsecErr_ttZ_systSignal_plus + xsecErr_ttZ_systBG_plus *xsecErr_ttZ_systBG_plus ); float xsecErr_ttZ_syst_minus = sqrt( xsecErr_ttZ_systSignal_minus*xsecErr_ttZ_systSignal_minus + xsecErr_ttZ_systBG_minus*xsecErr_ttZ_systBG_minus ); float xsecErr_ttV_syst_plus = sqrt( xsecErr_ttV_systSignal_plus *xsecErr_ttV_systSignal_plus + xsecErr_ttV_systBG_plus *xsecErr_ttV_systBG_plus ); float xsecErr_ttV_syst_minus = sqrt( xsecErr_ttV_systSignal_minus*xsecErr_ttV_systSignal_minus + xsecErr_ttV_systBG_minus*xsecErr_ttV_systBG_minus ); float xsecErr_ttZ_tot_plus = sqrt( xsecErr_ttZ_stat_plus *xsecErr_ttZ_stat_plus + xsecErr_ttZ_syst_plus *xsecErr_ttZ_syst_plus ); float xsecErr_ttZ_tot_minus = sqrt( xsecErr_ttZ_stat_minus*xsecErr_ttZ_stat_minus + xsecErr_ttZ_syst_minus*xsecErr_ttZ_syst_minus ); float xsecErr_ttV_tot_plus = sqrt( xsecErr_ttV_stat_plus *xsecErr_ttV_stat_plus + xsecErr_ttV_syst_plus *xsecErr_ttV_syst_plus ); float xsecErr_ttV_tot_minus = sqrt( xsecErr_ttV_stat_minus*xsecErr_ttV_stat_minus + xsecErr_ttV_syst_minus*xsecErr_ttV_syst_minus ); std::cout << std::endl << std::endl << std::endl; std::cout << "=========================================" << std::endl; std::cout << std::endl; std::cout << " Expected BG: " << b_pred << " +- " << b_pred_err << std::endl; std::cout << " Expected Signal: " << s << " (eff=" << eff_ttZ*100./(2.*0.06*0.22*0.67) << "%)" << std::endl; std::cout << " Expected B+S: " << s+b_pred << std::endl; std::cout << " ZBi (expected): " << ZBi << std::endl; std::cout << " Observed Events: " << obs << std::endl; std::cout << " ZBi (observed): " << ZBi_obs << std::endl; std::cout << " Observed Signal (BG subtracted): " << obs_ttV << std::endl; std::cout << " Expected ttZ Cross Section: " << crossSection_ttZ << " pb" << std::endl; std::cout << " Measured ttZ Cross Section: " << std::endl; std::cout << " " << crossSectionObs_ttZ << " +" << xsecErr_ttZ_stat_plus << "/-" << xsecErr_ttZ_stat_minus << " (stat) +" << xsecErr_ttZ_syst_plus << "/-" << xsecErr_ttZ_syst_minus << " (syst) pb" << std::endl; std::cout << " " << crossSectionObs_ttZ << " +" << xsecErr_ttZ_tot_plus << "/-" << xsecErr_ttZ_tot_minus << " pb" << std::endl; std::cout << " Expected ttV Cross Section: " << crossSection_ttV << " pb" << std::endl; std::cout << " Measured ttV Cross Section: " << std::endl; std::cout << " " << crossSectionObs_ttV << " +" << xsecErr_ttV_stat_plus << "/-" << xsecErr_ttV_stat_minus << " (stat) +" << xsecErr_ttV_syst_plus << "/-" << xsecErr_ttV_syst_minus << " (syst) pb" << std::endl; std::cout << " " << crossSectionObs_ttV << " +" << xsecErr_ttV_tot_plus << "/-" << xsecErr_ttV_tot_minus << " pb" << std::endl; std::cout << std::endl; std::cout << "=========================================" << std::endl; std::cout << std::endl; return 0; }
int main() { float massWindow = 0.5; for( ; massWindow<8; massWindow+=0.5 ) { char yieldsFileName_char[1000]; if( massWindow<1. ) sprintf( yieldsFileName_char, "../THq_plots/THq_postSync/THqPlots_MConly_sel4_CSV_CtMinusOne/yields_lept_LD_0%.0f.txt", 10.*massWindow ); else sprintf( yieldsFileName_char, "../THq_plots/THq_postSync/THqPlots_MConly_sel4_CSV_CtMinusOne/yields_lept_LD_%.0f.txt", 10.*massWindow ); std::ifstream yieldsFile(yieldsFileName_char); float signal; float bg_SMH; bool found_signal=false; bool found_bgSMH=false; while( yieldsFile.good() && !yieldsFile.eof() ) { std::string thisline; getline( yieldsFile, thisline ); TString thisline_tstr(thisline); if( thisline_tstr.BeginsWith("Total signal: ") ) { float signal2; sscanf( thisline.c_str(), "Total signal: %f w/o SMH: %f", &signal, &signal2 ); found_signal = true; } else if( thisline_tstr.BeginsWith("Total SMH BG under peak:") ) { sscanf( thisline.c_str(), "Total SMH BG under peak: %f", &bg_SMH ); found_bgSMH = true; } } //while yields file if( !found_signal ) { std::cout << "Didn't find signal in file: " << yieldsFileName_char << std::endl; exit(33); } if( !found_bgSMH ) { std::cout << "Didn't find bgSMH in file: " << yieldsFileName_char << std::endl; exit(35); } float k_BG = massWindow*2./70.; char datacardName[300]; if( massWindow<1. ) sprintf(datacardName, "datacard_realistic_0%.0fGeV.txt", massWindow*10.); else sprintf(datacardName, "datacard_realistic_%.0fGeV.txt", massWindow*10.); std::ofstream datacard(datacardName); datacard << "imax 1" << std::endl; datacard << "jmax 2 " << std::endl; datacard << "kmax *" << std::endl; datacard << " " << std::endl; datacard << " " << std::endl; datacard << "bin 1" << std::endl; datacard << "observation 0" << std::endl; datacard << "" << std::endl; datacard << " " << std::endl; datacard << "bin 1 1 1" << std::endl; datacard << "process s b bSMH" << std::endl; datacard << "process 0 1 2" << std::endl; datacard << "rate " << signal << " 0. " << bg_SMH << std::endl; datacard << " " << std::endl; datacard << " " << std::endl; datacard << "#syst " << std::endl; datacard << "bg_lept gmN 0 - " << k_BG << " -" << std::endl; datacard << "syst_smh lnN - - 1.2" << std::endl; datacard.close(); } //for mass windows return 0; }
void drawChannelYieldPlot( DrawBase* db, const std::string& selType, const std::string& bTaggerType, float lumi_fb, const std::string& saveName, std::string additionalCuts ) { if( additionalCuts!="" ) additionalCuts += " && "; // and now lepton channel definitions: std::string sel_mmm = "eventWeight*( " + additionalCuts + " isMZllSignalRegion && leptType==0 && leptType3==0)"; std::string sel_mme = "eventWeight*( " + additionalCuts + " isMZllSignalRegion && leptType==0 && leptType3==1)"; std::string sel_eem = "eventWeight*( " + additionalCuts + " isMZllSignalRegion && leptType==1 && leptType3==0)"; std::string sel_eee = "eventWeight*( " + additionalCuts + " isMZllSignalRegion && leptType==1 && leptType3==1)"; TLegend* legend = new TLegend( 0.6, 0.57, 0.92, 0.9 ); legend->SetFillColor(0); legend->SetTextSize(0.042); THStack* stackMC = new THStack(); std::vector<TH1D*> vh1_yields_mc; std::string yieldsFileName = "yields_"+selType; if( saveName!= "" ) yieldsFileName = yieldsFileName + "_" + saveName; yieldsFileName = yieldsFileName +"_"+bTaggerType+".txt"; ofstream yieldsFile(yieldsFileName.c_str()); yieldsFile << "------------------------" << std::endl; yieldsFile << "Yields @ " << lumi_fb << " fb-1" << std::endl; yieldsFile << "------------------------" << std::endl; yieldsFile << std::endl; yieldsFile << " (mm)m \t(mm)e \t(ee)m \t(ee)e \tTotal" << std::endl << std::endl; float s_mmm = 0.; float s_mme = 0.; float s_eem = 0.; float s_eee = 0.; float s = 0.; float b_mmm = 0.; float b_mme = 0.; float b_eem = 0.; float b_eee = 0.; float b = 0.; for( unsigned i=0; i<db->get_mcFiles().size(); ++i) { // reverse order: int iMC = db->get_mcFiles().size()-i-1; TTree* tree_mc = (TTree*)(db->get_mcFile(iMC).file->Get("tree_passedEvents")); TH1D* h1_mc_mmm = new TH1D("mc_mmm", "", 100, 0., 10000.); TH1D* h1_mc_mme = new TH1D("mc_mme", "", 100, 0., 10000.); TH1D* h1_mc_eem = new TH1D("mc_eem", "", 100, 0., 10000.); TH1D* h1_mc_eee = new TH1D("mc_eee", "", 100, 0., 10000.); tree_mc->Project("mc_mmm", "ptZll", sel_mmm.c_str()); tree_mc->Project("mc_mme", "ptZll", sel_mme.c_str()); tree_mc->Project("mc_eem", "ptZll", sel_eem.c_str()); tree_mc->Project("mc_eee", "ptZll", sel_eee.c_str()); float mmm = lumi_fb*1000.*h1_mc_mmm->Integral(); float mme = lumi_fb*1000.*h1_mc_mme->Integral(); float eem = lumi_fb*1000.*h1_mc_eem->Integral(); float eee = lumi_fb*1000.*h1_mc_eee->Integral(); float total = mmm + mme + eem + eee; char hname[100]; sprintf( hname, "yields_mc_%d", iMC); TH1D* h1_yields_mc = new TH1D(hname, "", 4, 0., 4.); h1_yields_mc->SetBinContent( 1, mmm ); h1_yields_mc->SetBinContent( 2, mme ); h1_yields_mc->SetBinContent( 3, eem ); h1_yields_mc->SetBinContent( 4, eee ); h1_yields_mc->SetFillColor( db->get_mcFile(iMC).fillColor ); vh1_yields_mc.push_back( (TH1D*)h1_yields_mc ); stackMC->Add(h1_yields_mc, "HISTO"); if( db->get_mcFiles()[iMC].legendName=="t#bar{t} + Z" ) { s_mmm += mmm; s_mme += mme; s_eem += eem; s_eee += eee; s += total; } else { yieldsFile << db->get_mcFiles()[iMC].legendName; for( unsigned ichar=0; ichar<20-db->get_mcFiles()[iMC].legendName.size(); ++ichar ) yieldsFile << " "; yieldsFile << Form("%.4f \t %.4f \t %.4f \t %.4f \t %.4f", mmm, mme, eem, eee, total) << std::endl; b_mmm += mmm; b_mme += mme; b_eem += eem; b_eee += eee; b += total; } delete h1_mc_mmm; delete h1_mc_mme; delete h1_mc_eem; delete h1_mc_eee; } yieldsFile << "Total BG " << Form("%.4f \t %.4f \t %.4f \t %.4f \t %.4f", b_mmm, b_mme, b_eem, b_eee, b) << std::endl; yieldsFile << std::endl; yieldsFile << "Signal " << Form("%.4f \t %.4f \t %.4f \t %.4f \t %.4f", s_mmm, s_mme, s_eem, s_eee, s) << std::endl; yieldsFile << "s / b " << Form("%.4f \t %.4f \t %.4f \t %.4f \t %.4f", s_mmm/b_mmm, s_mme/b_mme, s_eem/b_eem, s_eee/b_eee, s/b) << std::endl; yieldsFile << "s / sqrt(b) " << Form("%.4f \t %.4f \t %.4f \t %.4f \t %.4f", s_mmm/sqrt(b_mmm), s_mme/sqrt(b_mme), s_eem/sqrt(b_eem), s_eee/sqrt(b_eee), s/sqrt(b)) << std::endl; yieldsFile.close(); for( unsigned i=0; i<db->get_mcFiles().size(); ++i) { int inverseIndex = db->get_mcFiles().size()-i-1; if( vh1_yields_mc[inverseIndex]->Integral()>0 ) legend->AddEntry( vh1_yields_mc[inverseIndex], db->get_mcFile(i).legendName.c_str(), "F" ); } float yMax = stackMC->GetMaximum(); yMax *= 2.2; TH2D* h2_axes = new TH2D("axes", "", 4, 0., 4., 10, 0., yMax); h2_axes->GetXaxis()->SetLabelSize(0.085); h2_axes->GetXaxis()->SetBinLabel(1, "(#mu#mu)#mu"); h2_axes->GetXaxis()->SetBinLabel(2, "(#mu#mu)e"); h2_axes->GetXaxis()->SetBinLabel(3, "(ee)#mu"); h2_axes->GetXaxis()->SetBinLabel(4, "(ee)e"); h2_axes->SetYTitle("Events"); TPaveText* label_sqrt = db->get_labelSqrt(); TCanvas* c1 = new TCanvas("c1", "", 600, 600); c1->cd(); h2_axes->Draw(); stackMC->Draw("histo same"); legend->Draw("same"); label_sqrt->Draw("same"); gPad->RedrawAxis(); char canvasName[500]; if( saveName!="" ) sprintf( canvasName, "%s/channelYields_%s.eps", db->get_outputdir().c_str(), saveName.c_str() ); else sprintf( canvasName, "%s/channelYields.eps", db->get_outputdir().c_str() ); c1->SaveAs(canvasName); delete c1; delete h2_axes; for( unsigned i=0; i<vh1_yields_mc.size(); ++i ) delete vh1_yields_mc[vh1_yields_mc.size()-i-1]; }