int Table::operator == (Object &tblobj) { char *a; if (strcmp (a=tblobj.Type (), Type ())) // Type check return 0; Table *tblptr = (Table *) &tblobj; if (tblptr->Nelem () == nelem) // Count check { Object *b; for (int i = 0; i < nelem; i++) if (*(b=tblptr->Get (i)) != *(Get(i))) // Elementwise check return 0; } else return 0; return 1; }
int main (int argc, char *argv[]) { loadBDTSignalRegions(); loadCnCSignalRegions(); printBoxedMessage("Starting plot generation"); // #################### // ## Init tools ## // #################### // Create a sonic Screwdriver SonicScrewdriver screwdriver; // ######################################################### // ## Create ProcessClasses (and associated datasets) ## // ######################################################### screwdriver.AddProcessClass("1ltop", "1l top", "background", kRed-7); screwdriver.AddProcessClass("ttbar_2l", "t#bar{t} #rightarrow l^{+}l^{-}", "background", kCyan-3); screwdriver.AddProcessClass("W+jets", "W+jets", "background", kOrange-2); screwdriver.AddProcessClass("rare", "rare", "background", kMagenta-5); screwdriver.AddProcessClass("data", "data", "data", COLORPLOT_BLACK); // ########################## // ## Create Regions ## // ########################## string globalTag = argv[1]; string globalLabel = argv[2]; vector<string> signalRegionsTagList; vector<string> signalRegionsLabelList; for (int i = 3 ; i < argc ; i++) { signalRegionsTagList.push_back(argv[i]); string label = signalRegionLabel(argv[i],"root"); replace(label, "BDT T2tt-", "BDT "); replace(label, "BDT T2bw025-", "BDT "); replace(label, "BDT T2bw050-", "BDT "); replace(label, "BDT T2bw075-", "BDT "); replace(label, "T2tt, ", "" ); replace(label, "T2bw x=0.25, ", "" ); replace(label, "T2bw x=0.50, ", "" ); replace(label, "T2bw x=0.75, ", "" ); signalRegionsLabelList.push_back(label); } for (unsigned int i = 0 ; i < signalRegionsTagList.size() ; i++) { screwdriver.AddRegion(signalRegionsTagList[i], signalRegionsLabelList[i], 0); } // ########################## // ## Create Channels ## // ########################## screwdriver.AddChannel("signalRegion_MTpeak", globalLabel+";Preselection;M_{T} peak", 0); screwdriver.AddChannel("signalRegion_MTtail", globalLabel+";Preselection;M_{T} tail", 0); screwdriver.AddChannel("0btag_MTpeak", globalLabel+";0 b-tag Control Region;M_{T} peak", 0); screwdriver.AddChannel("0btag_MTtail", globalLabel+";0 b-tag Control Region;M_{T} tail", 0); screwdriver.AddChannel("reversedVeto_MTpeak", globalLabel+";Reversed veto Control Region;M_{T} peak", 0); screwdriver.AddChannel("reversedVeto_MTtail", globalLabel+";Reversed veto Control Region;M_{T} tail", 0); screwdriver.AddChannel("2leptons", globalLabel+";2 leptons Control Region;No M_{T} cut", 0); screwdriver.AddChannel("2leptons_MTpeak", globalLabel+";2 leptons Control Region;M_{T} peak", 0); screwdriver.AddChannel("2leptons_MTtail", globalLabel+";2 leptons Control Region;M_{T} tail", 0); // ######################## // ## Create Figures ## // ######################## screwdriver.AddFigurePerProcess("yield","Yield", "logY"); // ######################################## // ## Create histograms and ## // ## schedule type of plots to produce ## // ######################################## // Schedule plots screwdriver.SchedulePlots("1DDataMCComparisonFigure"); // Config plots screwdriver.SetGlobalStringOption("1DStackFigurePerProcess", "includeSignal", "stack"); screwdriver.SetGlobalFloatOption ("1DStackFigurePerProcess", "factorSignal", 1.0 ); screwdriver.SetGlobalStringOption("Plot", "infoTopRight", "CMS Internal"); screwdriver.SetGlobalStringOption("Plot", "infoTopLeft", "#sqrt{s} = 8 TeV, L = 19.5 fb^{-1}"); screwdriver.SetGlobalBoolOption("Plot", "exportPdf", true); screwdriver.SetGlobalBoolOption("Plot", "exportEps", false); screwdriver.SetGlobalBoolOption("Plot", "exportPng", false); // ######################### // ## Set the figures ## // ######################### // Loop on the signal regions and set the figure values... for (unsigned int i = 0 ; i < signalRegionsTagList.size() ; i++) { // Read input tables Table rawYields = Table(string("./results/latest/prediction/rawYieldTables/")+signalRegionsTagList[i]+".tab"); Table scaleFactors = Table(string("./results/latest/prediction/scaleFactors/") +signalRegionsTagList[i]+".tab"); Table tableMTtailCorrection = Table("./results/latest/MTtailCorrection/SF_MTtail.tab"); Figure SF_pre = scaleFactors.Get("value","SF_pre"); Figure SF_post = scaleFactors.Get("value","SF_post"); Figure SF_0btag = scaleFactors.Get("value","SF_0btag"); Figure SF_vetopeak = scaleFactors.Get("value","SF_vetopeak"); string signalRegionTag_ = signalRegionsTagList[i]; if (findSubstring(signalRegionTag_,"BDT")) { size_t pos; pos = signalRegionTag_.find("_low"); if (pos != string::npos) signalRegionTag_ = signalRegionTag_.substr(0,pos); pos = signalRegionTag_.find("_medium"); if (pos != string::npos) signalRegionTag_ = signalRegionTag_.substr(0,pos); pos = signalRegionTag_.find("_high"); if (pos != string::npos) signalRegionTag_ = signalRegionTag_.substr(0,pos); } Figure SF_MTtail_Wjets = tableMTtailCorrection.Get("SFR_Wjets",signalRegionTag_); Figure SF_MTtail_1ltop = tableMTtailCorrection.Get("SFR_1ltop",signalRegionTag_); screwdriver.SetFigure("yield", "1ltop", signalRegionsTagList[i], "signalRegion_MTpeak", rawYields.Get("signalRegion_MTpeak","1ltop" ) * SF_post); screwdriver.SetFigure("yield", "ttbar_2l", signalRegionsTagList[i], "signalRegion_MTpeak", rawYields.Get("signalRegion_MTpeak","ttbar_2l") * SF_pre ); screwdriver.SetFigure("yield", "W+jets", signalRegionsTagList[i], "signalRegion_MTpeak", rawYields.Get("signalRegion_MTpeak","W+jets" ) * SF_post); screwdriver.SetFigure("yield", "rare", signalRegionsTagList[i], "signalRegion_MTpeak", rawYields.Get("signalRegion_MTpeak","rare" )); screwdriver.SetFigure("yield", "data", signalRegionsTagList[i], "signalRegion_MTpeak", rawYields.Get("signalRegion_MTpeak","data" )); screwdriver.SetFigure("yield", "1ltop", signalRegionsTagList[i], "signalRegion_MTtail", rawYields.Get("signalRegion_MTtail","1ltop" ) * SF_post * SF_MTtail_1ltop); screwdriver.SetFigure("yield", "ttbar_2l", signalRegionsTagList[i], "signalRegion_MTtail", rawYields.Get("signalRegion_MTtail","ttbar_2l") * SF_pre ); screwdriver.SetFigure("yield", "W+jets", signalRegionsTagList[i], "signalRegion_MTtail", rawYields.Get("signalRegion_MTtail","W+jets" ) * SF_post * SF_MTtail_Wjets); screwdriver.SetFigure("yield", "rare", signalRegionsTagList[i], "signalRegion_MTtail", rawYields.Get("signalRegion_MTtail","rare" )); screwdriver.SetFigure("yield", "data", signalRegionsTagList[i], "signalRegion_MTtail", rawYields.Get("signalRegion_MTtail","data" )); screwdriver.SetFigure("yield", "1ltop", signalRegionsTagList[i], "0btag_MTpeak", rawYields.Get("0btag_MTpeak","1ltop" ) * SF_0btag); screwdriver.SetFigure("yield", "ttbar_2l", signalRegionsTagList[i], "0btag_MTpeak", rawYields.Get("0btag_MTpeak","ttbar_2l")); screwdriver.SetFigure("yield", "W+jets", signalRegionsTagList[i], "0btag_MTpeak", rawYields.Get("0btag_MTpeak","W+jets" ) * SF_0btag); screwdriver.SetFigure("yield", "rare", signalRegionsTagList[i], "0btag_MTpeak", rawYields.Get("0btag_MTpeak","rare" )); screwdriver.SetFigure("yield", "data", signalRegionsTagList[i], "0btag_MTpeak", rawYields.Get("0btag_MTpeak","data" )); screwdriver.SetFigure("yield", "1ltop", signalRegionsTagList[i], "0btag_MTtail", rawYields.Get("0btag_MTtail","1ltop" ) * SF_0btag * SF_MTtail_1ltop); screwdriver.SetFigure("yield", "ttbar_2l", signalRegionsTagList[i], "0btag_MTtail", rawYields.Get("0btag_MTtail","ttbar_2l")); screwdriver.SetFigure("yield", "W+jets", signalRegionsTagList[i], "0btag_MTtail", rawYields.Get("0btag_MTtail","W+jets" ) * SF_0btag * SF_MTtail_Wjets); screwdriver.SetFigure("yield", "rare", signalRegionsTagList[i], "0btag_MTtail", rawYields.Get("0btag_MTtail","rare" )); screwdriver.SetFigure("yield", "data", signalRegionsTagList[i], "0btag_MTtail", rawYields.Get("0btag_MTtail","data" )); screwdriver.SetFigure("yield", "1ltop", signalRegionsTagList[i], "reversedVeto_MTpeak", rawYields.Get("reversedVeto_MTpeak","1ltop" ) * SF_vetopeak); screwdriver.SetFigure("yield", "ttbar_2l", signalRegionsTagList[i], "reversedVeto_MTpeak", rawYields.Get("reversedVeto_MTpeak","ttbar_2l") * SF_pre ); screwdriver.SetFigure("yield", "W+jets", signalRegionsTagList[i], "reversedVeto_MTpeak", rawYields.Get("reversedVeto_MTpeak","W+jets" ) * SF_vetopeak); screwdriver.SetFigure("yield", "rare", signalRegionsTagList[i], "reversedVeto_MTpeak", rawYields.Get("reversedVeto_MTpeak","rare" )); screwdriver.SetFigure("yield", "data", signalRegionsTagList[i], "reversedVeto_MTpeak", rawYields.Get("reversedVeto_MTpeak","data" )); screwdriver.SetFigure("yield", "1ltop", signalRegionsTagList[i], "reversedVeto_MTtail", rawYields.Get("reversedVeto_MTtail","1ltop" ) * SF_vetopeak * SF_MTtail_1ltop); screwdriver.SetFigure("yield", "ttbar_2l", signalRegionsTagList[i], "reversedVeto_MTtail", rawYields.Get("reversedVeto_MTtail","ttbar_2l") * SF_pre ); screwdriver.SetFigure("yield", "W+jets", signalRegionsTagList[i], "reversedVeto_MTtail", rawYields.Get("reversedVeto_MTtail","W+jets" ) * SF_vetopeak * SF_MTtail_Wjets); screwdriver.SetFigure("yield", "rare", signalRegionsTagList[i], "reversedVeto_MTtail", rawYields.Get("reversedVeto_MTtail","rare" )); screwdriver.SetFigure("yield", "data", signalRegionsTagList[i], "reversedVeto_MTtail", rawYields.Get("reversedVeto_MTtail","data" )); screwdriver.SetFigure("yield", "1ltop", signalRegionsTagList[i], "2leptons_MTpeak", rawYields.Get("2leptons_MTpeak","1ltop" )); screwdriver.SetFigure("yield", "ttbar_2l", signalRegionsTagList[i], "2leptons_MTpeak", rawYields.Get("2leptons_MTpeak","ttbar_2l")); screwdriver.SetFigure("yield", "W+jets", signalRegionsTagList[i], "2leptons_MTpeak", rawYields.Get("2leptons_MTpeak","W+jets" )); screwdriver.SetFigure("yield", "rare", signalRegionsTagList[i], "2leptons_MTpeak", rawYields.Get("2leptons_MTpeak","rare" )); screwdriver.SetFigure("yield", "data", signalRegionsTagList[i], "2leptons_MTpeak", rawYields.Get("2leptons_MTpeak","data" )); screwdriver.SetFigure("yield", "1ltop", signalRegionsTagList[i], "2leptons_MTtail", rawYields.Get("2leptons_MTtail","1ltop" )); screwdriver.SetFigure("yield", "ttbar_2l", signalRegionsTagList[i], "2leptons_MTtail", rawYields.Get("2leptons_MTtail","ttbar_2l")); screwdriver.SetFigure("yield", "W+jets", signalRegionsTagList[i], "2leptons_MTtail", rawYields.Get("2leptons_MTtail","W+jets" )); screwdriver.SetFigure("yield", "rare", signalRegionsTagList[i], "2leptons_MTtail", rawYields.Get("2leptons_MTtail","rare" )); screwdriver.SetFigure("yield", "data", signalRegionsTagList[i], "2leptons_MTtail", rawYields.Get("2leptons_MTtail","data" )); screwdriver.SetFigure("yield", "1ltop", signalRegionsTagList[i], "2leptons", rawYields.Get("2leptons","1ltop" )); screwdriver.SetFigure("yield", "ttbar_2l", signalRegionsTagList[i], "2leptons", rawYields.Get("2leptons","ttbar_2l")); screwdriver.SetFigure("yield", "W+jets", signalRegionsTagList[i], "2leptons", rawYields.Get("2leptons","W+jets" )); screwdriver.SetFigure("yield", "rare", signalRegionsTagList[i], "2leptons", rawYields.Get("2leptons","rare" )); screwdriver.SetFigure("yield", "data", signalRegionsTagList[i], "2leptons", rawYields.Get("2leptons","data" )); } // ############################## // ## Make and write plots ## // ############################## cout << endl; cout << " > Making plots..." << endl; screwdriver.MakePlots(); cout << " > Saving plots..." << endl; screwdriver.WritePlots("./results/latest/summaryPlots/yields/"+globalTag+"/"); printBoxedMessage("Plot generation completed"); // ############################# // ## Post-plotting tests ## // ############################# printBoxedMessage("Program done."); return (0); }
int main (int argc, char *argv[]) { printBoxedMessage("Starting plot generation"); // #################### // ## Init tools ## // #################### // Create a sonic Screwdriver SonicScrewdriver screwdriver; // ########################## // ## Create Variables ## // ########################## screwdriver.AddVariable("MT", "M_{T}", "GeV", 40,0,400, &(myEvent.MT), "logY"); // ######################################################### // ## Create ProcessClasses (and associated datasets) ## // ######################################################### screwdriver.AddProcessClass("1ltop", "1l top", "background",kRed-7); #ifdef USING_TTBAR_POWHEG screwdriver.AddDataset("ttbar_powheg", "1ltop", 0, 0); #endif #ifdef USING_TTBAR_MADGRAPH screwdriver.AddDataset("ttbar_madgraph_1l", "1ltop", 0, 0); #endif //screwdriver.AddDataset("ttbar_madgraph_scaledown", "1ltop", 0, 0); //screwdriver.AddDataset("ttbar_madgraph_scaleup", "1ltop", 0, 0); //screwdriver.AddDataset("ttbar_madgraph_matchingdown", "1ltop", 0, 0); //screwdriver.AddDataset("ttbar_madgraph_matchingup", "1ltop", 0, 0); //screwdriver.AddDataset("ttbar_madgraph_mass166-5", "1ltop", 0, 0); //screwdriver.AddDataset("ttbar_madgraph_mass178-5", "1ltop", 0, 0); screwdriver.AddDataset("singleTop_st", "1ltop", 0, 0); screwdriver.AddProcessClass("ttbar_2l", "t#bar{t} #rightarrow l^{+}l^{-}", "background",kCyan-3); #ifdef USING_TTBAR_MADGRAPH screwdriver.AddDataset("ttbar_madgraph_2l", "ttbar_2l", 0, 0); #endif screwdriver.AddProcessClass("W+jets", "W+jets", "background",kOrange-2); screwdriver.AddDataset("W+jets", "W+jets", 0, 0); screwdriver.AddProcessClass("rare", "rare", "background",kMagenta-5); screwdriver.AddDataset("rare", "rare", 0, 0); screwdriver.AddProcessClass("data", "data", "data",COLORPLOT_BLACK); screwdriver.AddDataset("SingleElec", "data", 0, 0); screwdriver.AddDataset("SingleMuon", "data", 0, 0); screwdriver.AddDataset("DoubleElec", "data", 0, 0); screwdriver.AddDataset("DoubleMuon", "data", 0, 0); screwdriver.AddDataset("MuEl", "data", 0, 0); // ########################## // ## Create Regions ## // ########################## screwdriver.AddRegion("0btag_noMTCut", "Preselection;0 b-tag Control Region, no M_{T} cut", &goesIn0BtagControlRegion ); // ########################## // ## Create Channels ## // ########################## screwdriver.AddChannel("singleLepton", "e/#mu-channels", &goesInSingleLeptonChannel); // ######################################## // ## Create histograms and ## // ## schedule type of plots to produce ## // ######################################## // Create histograms screwdriver.Create1DHistos(); // Schedule plots screwdriver.SchedulePlots("1DDataMCComparison"); // Config plots screwdriver.SetGlobalStringOption("DataMCComparison", "includeSignal", "stack"); screwdriver.SetGlobalFloatOption ("DataMCComparison", "factorSignal", 1.0 ); screwdriver.SetGlobalStringOption("Plot", "infoTopRight", "CMS Preliminary"); screwdriver.SetGlobalStringOption("Plot", "infoTopLeft", "#sqrt{s} = 8 TeV, L = 19.5 fb^{-1}"); screwdriver.SetGlobalBoolOption("Plot", "exportPdf", true); screwdriver.SetGlobalBoolOption("Plot", "exportEps", false); screwdriver.SetGlobalBoolOption("Plot", "exportPng", false); // ######################################## // ## Run over the datasets ## // ######################################## vector<string> datasetsList; screwdriver.GetDatasetList(&datasetsList); cout << " > Reading datasets... " << endl; cout << endl; Table scaleFactors = Table("../prediction/scaleFactors/preselection.tab"); Figure SF_pre = scaleFactors.Get("value","SF_pre"); Figure SF_post = scaleFactors.Get("value","SF_post"); Figure SF_0btag = scaleFactors.Get("value","SF_0btag"); Figure SF_vetopeak = scaleFactors.Get("value","SF_vetopeak"); Figure SF_MTtail_1ltop = scaleFactors.Get("value","SF_MTtail_1ltop"); Figure SF_MTtail_Wjets = scaleFactors.Get("value","SF_MTtail_Wjets"); for (unsigned int d = 0 ; d < datasetsList.size() ; d++) { string currentDataset = datasetsList[d]; string currentProcessClass = screwdriver.GetProcessClass(currentDataset); sampleName = currentDataset; sampleType = screwdriver.GetProcessClassType(currentProcessClass); // Open the tree TFile f((string(FOLDER_BABYTUPLES)+currentDataset+".root").c_str()); TTree* theTree = (TTree*) f.Get("babyTuple"); intermediatePointers pointers; InitializeBranchesForReading(theTree,&myEvent,&pointers); myEvent.mStop = -1; myEvent.mNeutralino = -1; // ######################################## // ## Run over the events ## // ######################################## bool ttbarDatasetToBeSplitted = false; if (findSubstring(currentDataset,"ttbar") && (currentDataset != "ttbar_madgraph_1l") && (currentDataset != "ttbar_madgraph_2l")) ttbarDatasetToBeSplitted = true; int nEntries = theTree->GetEntries(); for (int i = 0 ; i < nEntries ; i++) { if (i % (nEntries / 50) == 0) printProgressBar(i,nEntries,currentDataset); // Get the i-th entry ReadEvent(theTree,i,&pointers,&myEvent); float weight = getWeight(); // Split 1-lepton ttbar and 2-lepton ttbar string currentProcessClass_ = currentProcessClass; if (ttbarDatasetToBeSplitted && (myEvent.numberOfGenLepton == 2)) currentProcessClass_ = "ttbar_2l"; if (myEvent.MT > 100) { if (currentProcessClass_ == "1ltop" ) weight *= SF_MTtail_1ltop.value(); else if (currentProcessClass_ == "W+jets") weight *= SF_MTtail_Wjets.value(); } screwdriver.AutoFillProcessClass(currentProcessClass_,weight); } printProgressBar(nEntries,nEntries,currentDataset); cout << endl; f.Close(); } // ############################# // ## Apply scale factors ## // ############################# screwdriver.ApplyScaleFactor("W+jets", "0btag_noMTCut", "singleLepton", SF_0btag); screwdriver.ApplyScaleFactor("1ltop", "0btag_noMTCut", "singleLepton", SF_0btag); // ################################### // ## Make plots and write them ## // ################################### cout << endl; cout << " > Making plots..." << endl; screwdriver.MakePlots(); cout << " > Saving plots..." << endl; screwdriver.WritePlots("./plots/fullMTwithSFRinTail/"); printBoxedMessage("Plot generation completed"); // ############################# // ## Post-plotting tests ## // ############################# printBoxedMessage("Program done."); return (0); }
backgroundEstimation::backgroundEstimation(string signalRegionLabel_) { signalRegionLabel = signalRegionLabel_; // ######################## // # Read raw MC yields # // ######################## rawYieldTable = Table("rawYieldTables/"+signalRegionLabel+".tab"); secondLeptonInAcceptanceYieldTable = Table("secondLeptonInAcceptance/"+signalRegionLabel+".tab"); // ################################################################### // # Initialize the table containing the raw mc and the prediction # // ################################################################### vector<string> predictionTableColumns = { "raw_mc", "prediction" }; predictionTable = Table(predictionTableColumns, processesTagList); // Raw MC Figure N1ltop_mc = rawYieldTable.Get("signalRegion_MTtail","1ltop" ); Figure N2ltop_mc = rawYieldTable.Get("signalRegion_MTtail","ttbar_2l"); Figure Nwjets_mc = rawYieldTable.Get("signalRegion_MTtail","W+jets" ); Figure Nrare_mc = rawYieldTable.Get("signalRegion_MTtail","rare" ); Figure NSumBkg_mc = N1ltop_mc+N2ltop_mc+Nwjets_mc+Nrare_mc; predictionTable.Set("raw_mc","1ltop", N1ltop_mc ); predictionTable.Set("raw_mc","ttbar_2l", N2ltop_mc ); predictionTable.Set("raw_mc","W+jets", Nwjets_mc ); predictionTable.Set("raw_mc","rare", Nrare_mc ); predictionTable.Set("raw_mc","totalSM", NSumBkg_mc); // ###################################################### // # Initialize the table containing the scale factors # // ###################################################### vector<string> dummy = { "value" }; scaleFactorTable = Table(dummy,scaleFactorsTagList); // #################################### // # Read results from other modules # // #################################### #ifdef USING_CR4_AND_CR5_CHECKS_FROM_LOOSENED_SIGNAL_REGIONS // Read the uncertainty from CR4 CR5 modeling checks Table temporaryTable; if (findSubstring(signalRegionLabel,"BDT")) temporaryTable = Table("../checkCR4CR5modeling/results/uncertainties_BDT.tab"); else temporaryTable = Table("../checkCR4CR5modeling/results/uncertainties_CnC.tab"); ttll_CR4CR5ModelingUncertainty = temporaryTable.Get("value",signalRegionLabel).error(); #else ttll_CR4CR5ModelingUncertainty = PLACEHOLDER_CR4_CR5_MODELING_UNCERTAINTY; #endif ttll_nJetsModelingUncertainty = DILEPTON_TTBAR_JET_MULTIPLICITY_MODELING_UNCERTAINTY; // ################################################################## // # Initialize the table containing the systematic uncertainties # // ################################################################## vector<string> uncertainties = { "absolute", "relative" }; systematicsUncertainties = Table(uncertainties, systematicsTagList); // Reset the systematics flags ResetSystematics(); }