//_____________________________________________________________________________ void ProofSimple::Begin(TTree * /*tree*/) { // The Begin() function is called at the start of the query. // When running with PROOF Begin() is only called on the client. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); Ssiz_t iopt = kNPOS; // Histos array if (fInput->FindObject("ProofSimple_NHist")) { TParameter<Long_t> *p = dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist")); fNhist = (p) ? (Int_t) p->GetVal() : fNhist; } else if ((iopt = option.Index("nhist=")) != kNPOS) { TString s; Ssiz_t from = iopt + strlen("nhist="); if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi(); } if (fNhist < 1) { Abort("fNhist must be > 0! Hint: proof->SetParameter(\"ProofSimple_NHist\"," " (Long_t) <nhist>)", kAbortProcess); return; } if (fInput->FindObject("ProofSimple_NHist3")) { TParameter<Long_t> *p = dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist3")); fNhist3 = (p) ? (Int_t) p->GetVal() : fNhist3; } else if ((iopt = option.Index("nhist3=")) != kNPOS) { TString s; Ssiz_t from = iopt + strlen("nhist3="); if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist3 = s.Atoi(); } // Ntuple TNamed *nm = dynamic_cast<TNamed *>(fInput->FindObject("ProofSimple_Ntuple")); if (nm) { // Title is in the form // merge merge via file // |<fout> location of the output file if merge // |retrieve retrieve to client machine // dataset create a dataset // |<dsname> dataset name (default: dataset_ntuple) // |plot for a final plot // <empty> or other keep in memory fHasNtuple = 1; TString ontp(nm->GetTitle()); if (ontp.Contains("|plot") || ontp == "plot") { fPlotNtuple = kTRUE; ontp.ReplaceAll("|plot", ""); if (ontp == "plot") ontp = ""; } if (ontp.BeginsWith("dataset")) fHasNtuple = 2; } }
//_____________________________________________________________________________ Bool_t ProofSimple::Process(Long64_t entry) { // The Process() function is called for each entry in the tree (or possibly // keyed object in the case of PROOF) to be processed. The entry argument // specifies which entry in the currently loaded tree is to be processed. // It can be passed to either ProofSimple::GetEntry() or TBranch::GetEntry() // to read either all or the required parts of the data. When processing // keyed objects with PROOF, the object is already loaded and is available // via the fObject pointer. // // This function should contain the "body" of the analysis. It can contain // simple or elaborate selection criteria, run algorithms on the data // of the event and typically fill histograms. // // The processing can be stopped by calling Abort(). // // Use fStatus to set the return value of TTree::Process(). // // The return value is currently not used. for (Int_t i=0; i < fNhist; i++) { if (fRandom && fHist[i]) { Double_t x = fRandom->Gaus(0.,1.); fHist[i]->Fill(x); } } for (Int_t i=0; i < fNhist3; i++) { if (fRandom && fHist3[i]) { Double_t x = fRandom->Gaus(0.,1.); fHist3[i]->Fill(x,x,x); } } if (fHLab && fRandom) { TSortedList sortl; Float_t rr[10]; fRandom->RndmArray(10, rr); for (Int_t i=0; i < 10; i++) { sortl.Add(new TParameter<Int_t>(TString::Format("%f",rr[i]), i)); } TIter nxe(&sortl); TParameter<Int_t> *pi = 0; while ((pi = (TParameter<Int_t> *) nxe())) { fHLab->Fill(TString::Format("hl%d", pi->GetVal()), pi->GetVal()); } } if (fNtp) FillNtuple(entry); return kTRUE; }
//_____________________________________________________________________________ void ProofEventProc::SlaveBegin(TTree * /*tree*/) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); // How much to read fFullRead = kFALSE; TNamed *nm = 0; if (fInput) { if ((nm = dynamic_cast<TNamed *>(fInput->FindObject("ProofEventProc_Read")))) { if (!strcmp(nm->GetTitle(), "readall")) fFullRead = kTRUE; } } if (!nm) { // Check option if (option == "readall") fFullRead = kTRUE; } Info("SlaveBegin", "'%s' reading", (fFullRead ? "full" : "optimized")); fPtHist = new TH1F("pt_dist","p_{T} Distribution",100,0,5); fPtHist->SetDirectory(0); fPtHist->GetXaxis()->SetTitle("p_{T}"); fPtHist->GetYaxis()->SetTitle("dN/p_{T}dp_{T}"); fOutput->Add(fPtHist); fPzHist = new TH1F("pz_dist","p_{Z} Distribution",100,0,5.); fPzHist->SetDirectory(0); fPzHist->GetXaxis()->SetTitle("p_{Z}"); fPzHist->GetYaxis()->SetTitle("dN/dp_{Z}"); fOutput->Add(fPzHist); fPxPyHist = new TH2F("px_py","p_{X} vs p_{Y} Distribution",100,-5.,5.,100,-5.,5.); fPxPyHist->SetDirectory(0); fPxPyHist->GetXaxis()->SetTitle("p_{X}"); fPxPyHist->GetYaxis()->SetTitle("p_{Y}"); fOutput->Add(fPxPyHist); // Abort test, if any TParameter<Int_t> *pi = 0; if (fInput) pi = dynamic_cast<TParameter<Int_t> *>(fInput->FindObject("ProofEventProc_TestAbort")); if (pi) fTestAbort = pi->GetVal(); if (fTestAbort < -1 || fTestAbort > 1) { Info("SlaveBegin", "unsupported value for the abort test: %d not in [-1,1] - ignore", fTestAbort); fTestAbort = -1; } else if (fTestAbort > -1) { Info("SlaveBegin", "running abort test: %d", fTestAbort); } if (fTestAbort == 0) Abort("Test abortion during init", kAbortProcess); }
//_____________________________________________________________________________ void ProofSimpleFile::Begin(TTree * /*tree*/) { // The Begin() function is called at the start of the query. // When running with PROOF Begin() is only called on the client. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); // Number of histograms (needed in terminate) if (fInput->FindObject("ProofSimpleFile_NHist")) { TParameter<Long_t> *p = dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimpleFile_NHist")); fNhist = (p) ? (Int_t) p->GetVal() : fNhist; } else if ((iopt = option.Index("nhist=")) != kNPOS) { TString s; Ssiz_t from = iopt + strlen("nhist="); if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi(); } }
//_____________________________________________________________________________ void ProofAux::SlaveBegin(TTree * /*tree*/) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); // Determine the action type fAction = GetAction(fInput); // Get the number of events TParameter<Long64_t> *a = (TParameter<Long64_t> *) fInput->FindObject("ProofAux_NEvents"); if (a) fNEvents = a->GetVal(); // Create lists fMainList = new TList; if (gProofServ) fMainList->SetName(TString::Format("MainList-%s", gProofServ->GetOrdinal())); fFriendList = new TList; if (gProofServ) fFriendList->SetName(TString::Format("FriendList-%s", gProofServ->GetOrdinal())); }
//_____________________________________________________________________________ void ProofSimpleFile::SlaveBegin(TTree * /*tree*/) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); // Number of histograms (needed in terminate) Ssiz_t iopt = kNPOS; if (fInput->FindObject("ProofSimpleFile_NHist")) { TParameter<Long_t> *p = dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimpleFile_NHist")); fNhist = (p) ? (Int_t) p->GetVal() : fNhist; } else if ((iopt = option.Index("nhist=")) != kNPOS) { TString s; Ssiz_t from = iopt + strlen("nhist="); if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi(); } // The file for merging fProofFile = new TProofOutputFile("SimpleFile.root", "M"); TNamed *out = (TNamed *) fInput->FindObject("PROOF_OUTPUTFILE"); if (out) fProofFile->SetOutputFileName(out->GetTitle()); TDirectory *savedir = gDirectory; fFile = fProofFile->OpenFile("RECREATE"); if (fFile && fFile->IsZombie()) SafeDelete(fFile); savedir->cd(); // Cannot continue if (!fFile) { TString amsg = TString::Format("ProofSimpleFile::SlaveBegin: could not create '%s':" " instance is invalid!", fProofFile->GetName()); Abort(amsg, kAbortProcess); return; } // Histos arrays if (CreateHistoArrays() != 0) { Abort("ProofSimpleFile::SlaveBegin: could not create histograms", kAbortProcess); return; } // Create directory if (!(fFileDir = fFile->mkdir("blue"))) { Abort("ProofSimpleFile::SlaveBegin: could not create directory 'blue' in file!", kAbortProcess); return; } // Create the histograms for (Int_t i=0; i < fNhist; i++) { fHistTop[i] = new TH1F(Form("ht%d",i), Form("ht%d",i), 100, -3., 3.); fHistTop[i]->SetFillColor(kRed); fHistTop[i]->SetDirectory(fFile); fHistDir[i] = new TH1F(Form("hd%d",i), Form("hd%d",i), 100, -3., 3.); fHistDir[i]->SetFillColor(kBlue); fHistDir[i]->SetDirectory(fFileDir); } // Set random seed fRandom = new TRandom3(0); }
//_____________________________________________________________________________ void ProofEventProc::CheckRanges() { // Check the processed event ranges when there is enough information // The result is added to the output list // Must be something in output if (!fOutput || (fOutput && fOutput->GetSize() <= 0)) return; // Create the result object and add it to the list TNamed *nout = new TNamed("Range_Check", "OK"); fOutput->Add(nout); // Get info to check from the input list if (!fInput || (fInput && fInput->GetSize() <= 0)) { nout->SetTitle("No input list"); return; } TNamed *ffst = dynamic_cast<TNamed *>(fInput->FindObject("Range_First_File")); if (!ffst) { nout->SetTitle("No first file"); return; } TNamed *flst = dynamic_cast<TNamed *>(fInput->FindObject("Range_Last_File")); if (!flst) { nout->SetTitle("No last file"); return; } TParameter<Int_t> *fnum = dynamic_cast<TParameter<Int_t> *>(fInput->FindObject("Range_Num_Files")); if (!fnum) { nout->SetTitle("No number of files"); return; } // Check first file TString fn(ffst->GetTitle()), sfst(ffst->GetTitle()); Ssiz_t ifst = fn.Index("?fst="); if (ifst == kNPOS) { nout->SetTitle("No first entry information in first file name"); return; } fn.Remove(ifst); sfst.Remove(0, ifst + sizeof("?fst=") - 1); if (!sfst.IsDigit()) { nout->SetTitle("Badly formatted first entry information in first file name"); return; } Long64_t fst = (Long64_t) sfst.Atoi(); ProcFileElements *pfef = dynamic_cast<ProcFileElements *>(fOutput->FindObject(fn)); if (!pfef) { nout->SetTitle("ProcFileElements for first file not found in the output list"); return; } if (pfef->GetFirst() != fst) { TString t = TString::Format("First entry differs {found: %lld, expected: %lld}", pfef->GetFirst(), fst); nout->SetTitle(t.Data()); return; } // Check last file fn = flst->GetTitle(); TString slst(flst->GetTitle()); Ssiz_t ilst = fn.Index("?lst="); if (ilst == kNPOS) { nout->SetTitle("No last entry information in last file name"); return; } fn.Remove(ilst); slst.Remove(0, ilst + sizeof("?lst=") - 1); if (!slst.IsDigit()) { nout->SetTitle("Badly formatted last entry information in last file name"); return; } Long64_t lst = (Long64_t) slst.Atoi(); ProcFileElements *pfel = dynamic_cast<ProcFileElements *>(fOutput->FindObject(fn)); if (!pfel) { nout->SetTitle("ProcFileElements for last file not found in the output list"); return; } if (pfel->GetLast() != lst) { nout->SetTitle("Last entry differs"); return; } // Check Number of files Int_t nproc = 0; TIter nxo(fOutput); TObject *o = 0; while ((o = nxo())) { if (dynamic_cast<ProcFileElements *>(o)) nproc++; } if (fnum->GetVal() != nproc) { nout->SetTitle("Number of processed files differs"); return; } }
int main(int argc, char* argv[]) { TFile f1("/cmshome/fpreiato/GammaJet/CMSSW_7_4_14/src/JetMETCorrections/GammaJetFilter/analysis/PrescaleWeighting/MC_ptPhot_scaled.root"); TH1D *h_mc = (TH1D*)f1.Get("h_mc"); TFile f2("/cmshome/fpreiato/GammaJet/CMSSW_7_4_14/src/JetMETCorrections/GammaJetFilter/analysis/tuples/Data/PhotonJet_SinglePhoton__Run2015D_2015-12-04_alphacut030_NoPrescale_PFlowAK4chs.root"); TTree* PhotonTree_data = (TTree*) f2.Get("photon"); uint64_t totalEvents_data = PhotonTree_data->GetEntries(); cout<< totalEvents_data << endl; double lumi = -1; TParameter<double>* dLumi = static_cast<TParameter<double>*>(f2.Get("analysis/luminosity")); lumi = dLumi->GetVal(); cout<< "lumi " << lumi<< endl; h_mc->Scale(lumi); /////////////////////////////////////////////////////////////////// double arraybins[7] = {40, 60, 85,100,130,175,5000}; TH1D *h_data = new TH1D("h_data", "h_data", 6, arraybins); //loop for (uint64_t i = 0; i < totalEvents_data; i++) { // for (uint64_t i = 0; i < 10000; i++) { if(i == 0 || i % 5000 == 0) cout<< "Events processed "<< i <<endl; PhotonTree_data->GetEntry(i); float ptPhot; PhotonTree_data->SetBranchAddress("pt",&ptPhot); h_data -> Fill(ptPhot); } TCanvas *c1 = new TCanvas("c1","c1",800,800); c1->SetLogy(); h_mc-> SetLineColor(kBlue); h_data -> SetLineColor(kRed); h_mc -> Draw(); h_data -> Draw("same"); c1-> SaveAs("Plot/Distributions.png"); /////////////////////////////////////////////////// //calcolo rapporto TH1D *h_ratio = (TH1D*)h_mc->Clone("h_ratio"); h_ratio->Divide(h_data); TCanvas *c2 = new TCanvas("c2","c2",800,800); c2->SetLogx(); h_ratio -> Draw(); c2-> SaveAs("Plot/Ratio.png"); ///////////////////////////////////////////////////////////////////////// TH1D *h_data_reweighted = new TH1D("h_data_reweighted", "data reweighted", 6, arraybins); for (uint64_t i = 0; i < totalEvents_data; i++) { // for (uint64_t i = 0; i < 10000; i++) { if(i == 0 || i % 5000 == 0) cout<< "Events processed "<< i <<endl; PhotonTree_data->GetEntry(i); float ptPhot; PhotonTree_data->SetBranchAddress("pt",&ptPhot); int bin; if(ptPhot >=40 && ptPhot <60) bin =1; if(ptPhot >=60 && ptPhot <85) bin =2; if(ptPhot >=85 && ptPhot <100) bin =3; if(ptPhot >=100 && ptPhot <130) bin =4; if(ptPhot >=130 && ptPhot <175) bin =5; if(ptPhot >=175 && ptPhot <=5000) bin =6; double Prescale = h_ratio->GetBinContent(bin); // cout<< "prescale applicato " << Prescale <<endl; h_data_reweighted -> Fill(ptPhot, Prescale); } TCanvas *c3 = new TCanvas("c3","c3",800,800); c3->SetLogy(); // c3->SetLogx(); h_mc -> SetLineColor(kBlue); h_data_reweighted -> SetLineColor(kRed); h_data_reweighted -> Draw(); h_mc -> Draw("same"); c3-> SaveAs("Plot/Data_reweighted.png"); TFile f_new("Prescale_ReReco_alphacut030_07Dic2015_GJet_plus_QCD.root", "recreate"); h_mc -> Write(); h_data->Write(); h_ratio -> Write(); h_data_reweighted->Write(); f_new.Close(); }//main
int main(int argc, char* argv[]) { if (argc != 7 && argc != 8) { std::cout << "USAGE: ./draw_vs_npv [data_dataset] [mc_SIGNAL_dataset] [mc_BG_dataset] [recoType] [jetAlgo] [norm ('LUMI' or 'SHAPE')] [flags=\"\"]" << std::endl; exit(23); } gROOT->SetBatch(); std::string data_dataset(argv[1]); std::string mc_photonjet(argv[2]); std::string mc_QCD(argv[3]); std::string recoType(argv[4]); std::string jetAlgo(argv[5]); std::string norm(argv[6]); if (norm != "LUMI" && norm != "SHAPE") { std::cout << "'" << norm << "' normalization not implemented yet." << std::endl; std::cout << "Only 'LUMI' and 'SHAPE' currently supported." << std::endl; std::cout << "Exiting." << std::endl; exit(9811); } std::string flags = ""; if (argc == 8) { std::string flags_str(argv[7]); flags = flags_str; } std::string algoType; if (recoType == "calo") { algoType = jetAlgo; } else { algoType = recoType + jetAlgo; } if (recoType == "jpt" && jetAlgo == "akt4") { algoType = "jptak4"; } jetAlgo = (jetAlgo == "ak4") ? "AK4" : "AK8"; recoType = (recoType == "pf") ? "PFlow" : "Calo"; std::string postFix = recoType + jetAlgo; postFix += "chs"; //Float_t etamax = 3.; //bool sameEvents = false; //until njets histos have no overflows... or maybe use GetEntries instead of integral? drawBase* db = new drawBase("PhotonJet", recoType, jetAlgo, OUTPUT_GRAPHS); db->set_pdf_aussi((bool)false); db->set_flags(flags); db->set_isCMSArticle(false); std::cout << "flags set." << std::endl; TString dataFileName; if (flags.length() > 0) { dataFileName = TString::Format("PhotonJet_%s_%s_%s.root", data_dataset.c_str(), postFix.c_str(), flags.c_str()); } else { dataFileName = TString::Format("PhotonJet_%s_%s.root", data_dataset.c_str(), postFix.c_str()); } TFile* dataFile = TFile::Open(dataFileName); if (dataFile) { std::cout << "Opened data file '" << dataFileName << "'." << std::endl; db->add_dataFile(dataFile, data_dataset); } TString mc1FileName; if (flags.length() > 0) { mc1FileName = TString::Format("PhotonJet_%s_%s_%s.root", mc_photonjet.c_str(), postFix.c_str(), flags.c_str()); } else { mc1FileName = TString::Format("PhotonJet_%s_%s.root", mc_photonjet.c_str(), postFix.c_str()); } TFile* mcPhotonJetFile = TFile::Open(mc1FileName); std::cout << "Opened mc file '" << mc1FileName << "'." << std::endl; if (mcPhotonJetFile) { db->add_mcFile(mcPhotonJetFile, mc_photonjet, "#gamma + jets MC", BALANCING); } if (mc_QCD != "") { TString mc2FileName; if (flags.length() > 0) { mc2FileName = TString::Format("PhotonJet_%s_%s_%s.root", mc_QCD.c_str(), postFix.c_str(), flags.c_str()); } else { mc2FileName = TString::Format("PhotonJet_%s_%s.root", mc_QCD.c_str(), postFix.c_str()); } TFile* mcQCDFile = TFile::Open(mc2FileName); std::cout << "Opened mc file '" << mc2FileName << "'." << std::endl; if (mcQCDFile && mc_QCD != mc_photonjet) { db->add_mcFile(mcQCDFile, mc_QCD, "QCD MC", MPF); } } // MC should already be normalized to a lumi of 1 pb-1 // Read luminosity double dLumi = 1e6; if (dataFile) { TParameter<double>* lumi = static_cast<TParameter<double>*>(dataFile->Get("analysis/luminosity")); dLumi = lumi->GetVal(); } std::cout<< "Lumi "<< dLumi << std::endl; // db->set_lumi(dLumi * 1e-6); db->set_lumi(dLumi); if (norm == "LUMI") { db->set_lumiNormalization(); } else { db->set_shapeNormalization(); } db->setFolder("analysis"); std::string outputDir = "PhotonJetPlots_" + db->get_fullSuffix() + "/vs_npv"; db->set_outputdir(outputDir); bool log = true; gErrorIgnoreLevel = kWarning; db->setOutputGraphs(OUTPUT_GRAPHS); VertexBinning vertexBinning; std::vector<std::pair<int, int> > vertexBins = vertexBinning.getBinning(); EtaBinning etaBinning; size_t etaBinningSize = etaBinning.size(); db->set_rebin(2); db->setFolder("analysis/vertex"); for (size_t i = 0; i < etaBinningSize; i++) { db->set_legendTitle(etaBinning.getBinTitle(i)); TString responseName = TString::Format("resp_balancing_%s", etaBinning.getBinName(i).c_str()); db->drawHisto_vs_vertex(vertexBins, responseName.Data(), "Balancing Response", "", "Events", log); // Raw jets //responseName = TString::Format("resp_balancing_raw_%s", etaBinning.getBinName(i).c_str()); //db->drawHisto_vs_vertex(ptBins, responseName.Data(), "Balancing Response (raw jets)", "", "Events", log); responseName = TString::Format("resp_mpf_%s", etaBinning.getBinName(i).c_str()); db->drawHisto_vs_vertex(vertexBins, responseName.Data(), "MPF Response", "", "Events", log); // Raw jets //responseName = TString::Format("resp_mpf_raw_%s", etaBinning.getBinName(i).c_str()); //db->drawHisto_vs_vertex(ptBins, responseName.Data(), "MPF Response (raw ME_{T})", "", "Events", log); } // Special case eta < 1.3 db->set_legendTitle("|#eta| < 1.3"); db->drawHisto_vs_vertex(vertexBins, "resp_balancing_eta0013", "Balancing Response", "", "Events", log); //db->drawHisto_vs_pt(ptBins, "resp_balancing_raw_eta013", "Balancing Response (raw jets)", "", "Events", log); db->drawHisto_vs_vertex(vertexBins, "resp_mpf_eta0013", "MPF Response", "", "Events", log); //db->drawHisto_vs_vertex(ptBins, "resp_mpf_raw_eta013", "MPF Response (raw ME_{T})", "", "Events", log); delete db; db = NULL; return 0; }
// ---------------------------------------------------------------------- void moduleSummary(const char *dirName = "", const char *module_type) { printf("\nmoduleSummary> Starting ...\n"); nChips = 16; startChip = 0; if ( !strcmp(module_type,"a") ) { nChips = 8; startChip = 0; } if ( !strcmp(module_type,"b") ) { nChips = 8; startChip = 8; } sprintf(fname, "%s/%s", dirName, fileName); inputFile = fopen(fname, "r"); if (!inputFile) { printf("\nmoduleSummary> ----> COULD NOT FIND %s IN DIRECTORY %s\n", fileName, dirName); printf("moduleSummary> ----> Aborting execution of moduleSummaryPage.C ... \n\n", fileName, dirName); break; } sprintf(fname, "%s/%s", dirName, adFileName); inputFile = fopen(fname, "r"); if (!inputFile) { sprintf(adFileName,"%s", fileName); } else { printf("moduleSummary> ----> found separate address decoding file: %s\n", adFileName); fclose (inputFile); } sprintf(fname, "%s/../../macros/criteria.dat", dirName); if ( !readCriteria(fname) ) { printf("\nmoduleSummary> ----> COULD NOT READ GRADING CRITERIA !!!\n"); printf("moduleSummary> ----> Aborting execution of moduleSummaryPage.C ... \n\n", fileName, dirName); break; } TFile *f = new TFile(Form("%s/%s", dirName, fileName)); gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetOptStat(0); gStyle->SetTitle(0); gStyle->SetStatFont(132); gStyle->SetTextFont(132); gStyle->SetLabelFont(132, "X"); gStyle->SetLabelFont(132, "Y"); gStyle->SetLabelSize(0.08, "X"); gStyle->SetLabelSize(0.08, "Y"); gStyle->SetTitleSize(0.08, "X"); gStyle->SetTitleSize(0.08, "Y"); gStyle->SetNdivisions(10, "X"); gStyle->SetNdivisions(8, "Y"); gStyle->SetTitleFont(132); gROOT->ForceStyle(); tl = new TLatex; tl->SetNDC(kTRUE); tl->SetTextSize(0.1); ts = new TLatex; ts->SetNDC(kTRUE); ts->SetTextSize(0.09); line = new TLine; line->SetLineColor(kRed); line->SetLineStyle(kDashed); box = new TBox; box->SetFillColor(3); box->SetFillStyle(3004); c1 = new TCanvas("c1", "", 900, 700); c1->Clear(); c1->Divide(1,4); int EColor[6] = { 4, 8, 6, 1 }; int EMarkerStyle[10] = { 4, 25, 26, 23, 21, 27, 28, 20, 30, 29 }; TH2D *mThreshold = new TH2D("mThreshold", "", 416, 0., 416., 160, 0., 160.); TH2D *mBumps = new TH2D("mBumps", "", 416, 0., 416., 160, 0., 160.); TH2D *mAddr = new TH2D("mAddr", "", 416, 0., 416., 160, 0., 160.); double mThresholdmin(0.), mThresholdmax(255.); const int nfit = 4; TString fitNames[] = {TString("Noise"), TString("Vcal Thr. Width"), TString("Rel. Gain Width"), TString("Pedestal Spread")}; float limitB[] = { noiseB, trimmingB, gainB, pedestalB }; // limit for grading float limitC[] = { noiseC, trimmingC, gainC, pedestalC }; // limit for grading float max[] = { noiseB + 100., trimmingB + 100., gainB + 0.05, pedestalB + 1000. }; // scaling of histogram TH1D *fit[nfit]; TH1D *fitEntries[nfit]; for(int ifit = 0; ifit < nfit; ++ifit) { fit[ifit] = new TH1D(Form("%s", fitNames[ifit].Data()),"", nChips, float(startChip), float(startChip+nChips)); fitEntries[ifit] = new TH1D(Form("n%s", fitNames[ifit].Data()),"", nChips, float(startChip), float(startChip+nChips)); fit[ifit]->SetLineColor(EColor[ifit]); fit[ifit]->SetMarkerColor(EColor[ifit]); fit[ifit]->SetMarkerStyle(EMarkerStyle[ifit]); fit[ifit]->SetMarkerSize(0.5); } for (int i = startChip; i < startChip+nChips; i++) { addVcalThreshold(dirName, i, mThreshold); } for (int i = startChip; i < startChip+nChips; i++) { addChip("vcals_xtalk", i, mBumps); } TFile *f1 = new TFile(Form("%s/%s", dirName, adFileName)); for (int i = startChip; i < startChip+nChips; i++) { addChip("AddressDecoding", i, mAddr);} if ( nChips < 16 && startChip == 0 ) { for (int i = 8; i < nChips+8; i++) { removeChip(i, mThreshold, -99); } for (int i = 8; i < nChips+8; i++) { removeChip(i, mBumps, -99); } for (int i = 8; i < nChips+8; i++) { removeChip(i, mAddr, -99); } } if ( nChips < 16 && startChip == 8 ) { for (int i = 0; i < nChips; i++) { removeChip(i, mThreshold, -99); } for (int i = 0; i < nChips; i++) { removeChip(i, mBumps, -99); } for (int i = 0; i < nChips; i++) { removeChip(i, mAddr, -99); } } TString noslash(dirName); noslash.ReplaceAll("/", ""); noslash.ReplaceAll("..", ""); c1->cd(1); if ( mThreshold->GetMaximum() < mThresholdmax ) { mThresholdmax = mThreshold->GetMaximum(); } if ( mThreshold->GetMinimum() > mThresholdmin ) { mThresholdmin = mThreshold->GetMinimum(); } mThreshold->GetZaxis()->SetRangeUser(mThresholdmin,mThresholdmax); mThreshold->DrawCopy("colz"); tl->DrawLatex(0.1, 0.92, "Vcal threshold"); tl->DrawLatex(0.75, 0.92, Form("%s",noslash.Data())); if ( nChips < 16 && startChip == 0 ) { box->SetFillColor(29); box->DrawBox( 0, 0, 416, 80); } if ( nChips < 16 && startChip == 8 ) { box->SetFillColor(29); box->DrawBox( 0, 80, 416, 160); } c1->cd(2); mBumps->SetMaximum(2.); mBumps->SetMinimum(-2.); mBumps->DrawCopy("colz"); tl->DrawLatex(0.1, 0.92, "Bump bonding map"); if ( nChips < 16 && startChip == 0 ) { box->SetFillColor(29); box->DrawBox( 0, 0, 416, 80); } if ( nChips < 16 && startChip == 8 ) { box->SetFillColor(29); box->DrawBox( 0, 80, 416, 160); } c1_3->Divide(3,1); c1_3->cd(1); gPad->SetBottomMargin(0.2); gPad->SetLogy(1); gPad->SetLeftMargin(0.20); gPad->SetRightMargin(0.01); float V, A; float x_V[250], y_A[250]; int i(0); float iv100(0.); float iv150(0.); float iv150_17(0.); float iv100_17(0.); float variation(0.); float variation_17(0.); FILE *ivFile, *sumWrite, *sumRead, *gradWrite; sprintf(fname, "%s/iv.dat", dirName); ivFile = fopen(fname, "r"); if (!ivFile) { printf("moduleSummary> !!!!!!!!! ----> Could not open file %s to read data\n", fname); } else { fclose(ivFile); ifstream is(fname); char buffer[200]; while (is.getline(buffer, 200, '\n')) { // check that line starts with a number if (buffer[0] != '1' && buffer[0] != '2' && buffer[0] != '3' && buffer[0] != '4' && buffer[0] != '5' && buffer[0] != '6' && buffer[0] != '7' && buffer[0] != '8' && buffer[0] != '9' ) {continue;} sscanf(buffer, "%e %e", &V, &A); x_V[i] = V; y_A[i] = 1e6*A; if ( i > 0 ) { // check that voltage is increasing & find current at 150 V if ( x_V[i] < x_V[i-1] ) { continue; } if ( x_V[i] >= 100. && x_V[i-1] <= 100. ) { iv100 = y_A[i-1] + (100. - x_V[i-1])*(y_A[i] - y_A[i-1])/(x_V[i] - x_V[i-1]); } if ( x_V[i] >= 150. && x_V[i-1] <= 150. ) { iv150 = y_A[i-1] + (150. - x_V[i-1])*(y_A[i] - y_A[i-1])/(x_V[i] - x_V[i-1]); } } i++; } if ( iv100 != 0. ) { variation = iv150/iv100; } else { variation = 0; } if ( i > 0 ) { TGraph *g1 = new TGraph(i,x_V,y_A); g1->Draw("aC"); g1->SetTitle(""); g1->SetLineColor(4); g1->SetLineWidth(2); g1->GetXaxis()->SetTitle("Voltage [V]"); g1->GetYaxis()->SetTitle("Current [#muA]"); g1->GetYaxis()->SetDecimals(); g1->GetYaxis()->SetTitleOffset(1.2); g1->GetYaxis()->CenterTitle(); tl->DrawLatex(0.2, 0.92, "I-V-Curve"); ts->DrawLatex(0.25, 0.78, Form("I(150 V) = %.2f #muA", iv150)); ts->DrawLatex(0.25, 0.65, Form("I_{150}/I_{100} = %.2f ", variation)); } } char mod[20] = noslash.Data(), waf[20] = "", test[20] = "",tmon[20], trim[20], ph[20], cycl[20]; int tday; int dp(0), dm(0), db(0), dt(0), da(0); int root(0), a(0), b(0), c(0); int badRocs[3] = {0, 0, 0}; char iv; float voltage, current; float temp, tempSigma, sollTemp; float cyclMean, cyclSigma; char string[1000]; c1_3->cd(2); sprintf(fname, "%s/summaryTest.txt", dirName); sumRead = fopen(fname, "r"); if (!sumRead) { printf("\nmoduleSummary> !!!!!!!!! ----> File %s does not exist yet...\n", fname); printf("moduleSummary> !!!!!!!!! ----> Module summary not complete!\n\n"); } else { fgets(string, 200, sumRead); // fscanf(sumRead, "%s %s", string, mod); fscanf(sumRead, "%s %s %s %s", string, string, waf, test); fscanf(sumRead, "%s %i %i %i %i %i", string, &dp, &dm, &db, &dt, &da); fscanf(sumRead, "%s %s %s %s %s %i %i %i", string, string, string, string, string, &a, &b, &c); badRocs[0]=a; badRocs[1]=b; badRocs[2]=c; fscanf(sumRead, "%s %s %i", string, string, &root); fscanf(sumRead, "%s %s %s %s %s %i %s %s", string, string, string, string, tmon, &tday, string, string); fgets(string, 200, sumRead); fscanf(sumRead, "%s %s", string, trim); fgets(string, 200, sumRead); fscanf(sumRead, "%s %s", string, ph); fgets(string, 200, sumRead); fscanf(sumRead, "%s %f %f %s %f", string, &temp, &tempSigma, string, &sollTemp); fscanf(sumRead, "%s %s %s %f %f", string, string, cycl, &cyclMean, &cyclSigma); fclose(sumRead); tl->SetTextSize(0.09); tl->SetTextFont(22); double y = 0.92; tl->DrawLatex(0.01, y, Form("Test Summary of %s %s", waf, test)); tl->SetTextFont(132); tl->SetTextSize(0.09); y -= 0.16; tl->DrawLatex(0.01, y, "ROCs > 1% defects: "); tl->DrawLatex(0.5, y, Form("%i", badRocs[0])); y -= 0.12; tl->DrawLatex(0.01, y, Form("Dead Pixel: ")); tl->DrawLatex(0.5, y, Form("%i", dp)); y -= 0.11; tl->DrawLatex(0.01, y, "Mask Defects: "); tl->DrawLatex(0.5, y, Form("%i", dm)); y -= 0.11; tl->DrawLatex(0.01, y, "Dead Bumps: "); tl->DrawLatex(0.5, y, Form("%i", db)); y -= 0.11; tl->DrawLatex(0.01, y, "Dead Trimbits: "); tl->DrawLatex(0.5, y, Form("%i", dt)); y -= 0.11; tl->DrawLatex(0.01, y, "Address Probl: "); tl->DrawLatex(0.5, y, Form("%i", da)); y = 0.76; tl->DrawLatex(0.72, y, Form("Tested on:")); y -= 0.11; tl->DrawLatex(0.72, y, "Temp. [^{o}C]: "); y -= 0.11; tl->DrawLatex(0.72, y, "Trim / phCal: "); y -= 0.11; tl->DrawLatex(0.72, y, "Therm. cycl.: "); y -= 0.11; tl->DrawLatex(0.72, y, "TBM1: "); y -= 0.11; tl->DrawLatex(0.72, y, "TBM2: "); c1_3->cd(3); y = 0.76; tl->DrawLatex(0.01, y, Form("%s %i", tmon, tday)); y -= 0.11; tl->DrawLatex(0.01, y, Form("%.1f +- %.1f", temp, tempSigma)); y -= 0.11; tl->DrawLatex(0.01, y, Form("%s / %s", trim, ph)); y -= 0.11; tl->DrawLatex(0.01, y, Form("%s", cycl)); } int result; int tbm1(1), tbm2(1); TParameter<int>* par; y -= 0.11; par = (TParameter<int>*)f->Get("TBM1"); if (par) { tbm1 = par->GetVal(); if (tbm1 == 0) tl->DrawLatex(0.01, y, "ok"); else tl->DrawLatex(0.01, y, Form("Err%i", tbm1)); } y -= 0.11; par = (TParameter<int>*)f->Get("TBM2"); if (par) { tbm2 = par->GetVal(); if (tbm2 == 0) tl->DrawLatex(0.01, y, "ok"); else tl->DrawLatex(0.01, y, Form("Err%i", tbm2)); } // Convert current to currents at room temperature double Tk = 273.15; double egap = 1.12; double kB = 8.617343E-5; double tTest; // tTest = temp; // --> averaged temperature tTest = sollTemp; double expnt = egap*(1/(Tk+tTest) - 1/(Tk+17))/(2*kB); double fctr = (Tk+17)*(Tk+17)/((Tk+tTest)*(Tk+tTest)); iv150_17 = iv150*fctr*TMath::Exp(expnt); iv100_17 = iv100*fctr*TMath::Exp(expnt); if ( iv100_17 != 0 ) variation_17 = iv150_17/iv100_17; printf("\nmoduleSummary> converted I(150 V, %.0f C) = %.4f to I(150 V, 17 C) = %.4f \n", tTest, iv150, iv150_17); printf("moduleSummary> converted I(100 V, %.0f C) = %.4f to I(100 V, 17 C) = %.4f \n\n", tTest, iv100, iv100_17); if ( iv150_17 != 0 ) { c1_3->cd(3); y = 0.32; tl->DrawLatex(0.25, y, "I(150 V) [T = 17 ^{o}C]"); tl->DrawLatex(0.72, y, Form("%.2f #muA", iv150_17)); c1_3->cd(2); } if ( iv100_17 != 0 ) { c1_3->cd(3); y = 0.21; tl->DrawLatex(0.25, y, "I_{150}/I_{100} [T = 17 ^{o}C]"); tl->DrawLatex(0.72, y, Form("%.2f", variation_17)); c1_3->cd(2); } sprintf(fname, "%s/summaryTest.txt", dirName); sumWrite = fopen(fname, "a"); fputs(Form("TBM1 %i\n", tbm1), sumWrite); fputs(Form("TBM2 %i\n", tbm2), sumWrite); fputs(Form("I 150 %f \n", iv150_17), sumWrite); fputs(Form("I150/I100 %f \n", variation_17), sumWrite); fputs(Form("iv datapoints %i \n", i), sumWrite); // c1->cd(4); // mAddr->DrawCopy("colz"); // mAddr->SetMaximum(1.); // mAddr->SetMinimum(0.); // tl->DrawLatex(0.1, 0.92, "Address decoding map"); c1_4->Divide(4,1); qualification(dirName, fit, fitEntries); for (int i = 0; i < 4; i++) { // makePlot(TH1 *h, const char *title, int pad, double Ymin, double Ymax, double Ylimit) makePlot(fit[i], fitNames[i].Data(), i+1, 0, max[i], limitB[i], limitC[i]); } int grad(0); FILE *missingData; sprintf(fname, "%s/comment_3.txt", dirName); missingData = fopen(fname, "r"); if ( missingData ) { printf("\nmoduleSummary> !!!!!!!!! ----> Found file for missing data: comment_3.txt => GRADE C!\n\n"); grad = 3; fclose(missingData); } else { grad = grading(badRocs, iv150_17, variation_17, fit, fitEntries, limitB, limitC, test); } c1_3->cd(3); tl->SetTextSize(0.09); tl->SetTextFont(22); if (grad == 1) { tl->DrawLatex(0.6, 0.92, "GRADE: A"); fputs("Grade A\n", sumWrite); } if (grad == 2) { tl->DrawLatex(0.6, 0.92, "GRADE: B"); fputs("Grade B\n", sumWrite); } if (grad == 3) { tl->DrawLatex(0.6, 0.92, "GRADE: C"); fputs("Grade C\n", sumWrite); } sprintf(fname, "%s/gradingTest.txt", dirName); gradWrite = fopen(fname, "a"); if (!gradWrite) { printf("\nmoduleSummary> !!!!!!!!! ----> File %s does not exist yet...\n", fname); printf("moduleSummary> !!!!!!!!! ----> Grading data could not be written to file!\n\n"); } else { fputs(Form("Noise %i %i\n", fitsProblemB[0], fitsProblemC[0]), gradWrite); fputs(Form("VcalThrWidth %i %i\n", fitsProblemB[1], fitsProblemC[1]), gradWrite); fputs(Form("RelGainWidth %i %i\n", fitsProblemB[2], fitsProblemC[2]), gradWrite); fputs(Form("PedSpread %i %i\n", fitsProblemB[3], fitsProblemC[3]), gradWrite); fputs(Form("I150V %i %i\n", currentProblemB, currentProblemC), gradWrite); fputs(Form("Iratio %i 0\n", slopeProblemB), gradWrite); } c1->SaveAs(Form("%s/moduleSummary_%s%s.ps", dirName, waf, test)); c1->SaveAs(Form("%s/%s%s.gif", dirName, waf, test)); printf("\nmoduleSummary> ................................................ finished\n"); }
int main(int argc, char* argv[]) { if (argc != 7 && argc != 8) { std::cout << "USAGE: ./drawPhotonJet [data_dataset] [mc_SIGNAL_dataset] [mc_BG_dataset] [recoType] [jetAlgo]" << std::endl; exit(23); } setPrettyStyle(); std::string data_dataset(argv[1]); std::string mc_photonjet(argv[2]); std::string mc_QCD(argv[3]); std::string recoType(argv[4]); std::string jetAlgo(argv[5]); std::string algoType; if (recoType == "calo") { algoType = jetAlgo; } else { algoType = recoType + jetAlgo; } if (recoType == "jpt" && jetAlgo == "akt5") { algoType = "jptak5"; } std::string flags = ""; jetAlgo = (jetAlgo == "ak5") ? "AK5" : "AK7"; recoType = (recoType == "pf") ? "PFlow" : "Calo"; std::string postFix = recoType + jetAlgo; postFix += "chs"; TString dataFileName; if (flags.length() > 0) { dataFileName = TString::Format("PhotonJet_%s_%s_%s.root", data_dataset.c_str(), postFix.c_str(), flags.c_str()); } else { dataFileName = TString::Format("PhotonJet_%s_%s.root", data_dataset.c_str(), postFix.c_str()); } TFile* dataFile = TFile::Open(dataFileName); std::cout << "Opened data file '" << dataFileName << "'." << std::endl; //db->add_dataFile(dataFile, data_dataset); TString mc1FileName; if (flags.length() > 0) { mc1FileName = TString::Format("PhotonJet_%s_%s_%s.root", mc_photonjet.c_str(), postFix.c_str(), flags.c_str()); } else { mc1FileName = TString::Format("PhotonJet_%s_%s.root", mc_photonjet.c_str(), postFix.c_str()); } TFile* mcPhotonJetFile = TFile::Open(mc1FileName); std::cout << "Opened mc file '" << mc1FileName << "'." << std::endl; if (mcPhotonJetFile) { //db->add_mcFile(mcPhotonJetFile, mc_photonjet, "#gamma+jet MC", 46); } if (mc_QCD != "") { TString mc2FileName; if (flags.length() > 0) { mc2FileName = TString::Format("PhotonJet_%s_%s_%s.root", mc_QCD.c_str(), postFix.c_str(), flags.c_str()); } else { mc2FileName = TString::Format("PhotonJet_%s_%s.root", mc_QCD.c_str(), postFix.c_str()); } TFile* mcQCDFile = TFile::Open(mc2FileName); std::cout << "Opened mc file '" << mc2FileName << "'." << std::endl; if (mcQCDFile && mc_QCD != mc_photonjet) { //db->add_mcFile(mcQCDFile, mc_QCD, "QCD MC", 38); } } // Create output directory mkdir("plots", 0755); TString directoryName = ""; if (mc_QCD.length() == 0) directoryName = TString::Format("plots/%s_vs_%s_%s", data_dataset.c_str(), mc_photonjet.c_str(), postFix.c_str()); else directoryName = TString::Format("plots/%s_vs_%s_plus_%s_%s", data_dataset.c_str(), mc_photonjet.c_str(), mc_QCD.c_str(), postFix.c_str()); mkdir(directoryName, 0755); directoryName = TString::Format("%s/extrapolation", directoryName.Data()); mkdir(directoryName, 0755); TParameter<double>* pLumi = static_cast<TParameter<double>*>(dataFile->Get("analysis/luminosity")); double lumi = pLumi->GetVal() * 1e-9; //bool log = true; gErrorIgnoreLevel = kWarning; EtaBinning etaBinning; size_t etaBinningSize = etaBinning.size(); TString rootFolder = "analysis/new_extrapolation"; for (size_t i = 0; i < etaBinningSize; i++) { const std::string& etaName = etaBinning.getBinName(i); std::cout << "Processing " << etaName << std::endl; TString responseName = TString::Format("%s/extrap_resp_balancing_%s_graph", rootFolder.Data(), etaName.c_str()); TString outputName = TString::Format("%s/extrap_resp_balancing_%s.pdf", directoryName.Data(), etaName.c_str()); TGraphErrors* data = (TGraphErrors*) dataFile->Get(responseName); TGraphErrors* mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawGraphs(data, mc, "Balancing", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", etaBinning.getBinTitle(i), lumi, outputName.Data()); // Raw jets responseName = TString::Format("%s/extrap_resp_balancing_raw_%s_graph", rootFolder.Data(), etaName.c_str()); outputName = TString::Format("%s/extrap_resp_balancing_raw_%s.pdf", directoryName.Data(), etaName.c_str()); data = (TGraphErrors*) dataFile->Get(responseName); mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawGraphs(data, mc, "Balancing", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw jets)", etaBinning.getBinTitle(i), lumi, outputName.Data()); responseName = TString::Format("%s/extrap_resp_mpf_%s_graph", rootFolder.Data(), etaName.c_str()); outputName = TString::Format("%s/extrap_resp_mpf_%s.pdf", directoryName.Data(), etaName.c_str()); data = (TGraphErrors*) dataFile->Get(responseName); mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawGraphs(data, mc, "MPF", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", etaBinning.getBinTitle(i), lumi, outputName.Data()); // Raw jets responseName = TString::Format("%s/extrap_resp_mpf_raw_%s_graph", rootFolder.Data(), etaName.c_str()); outputName = TString::Format("%s/extrap_resp_mpf_raw_%s.pdf", directoryName.Data(), etaName.c_str()); data = (TGraphErrors*) dataFile->Get(responseName); mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawGraphs(data, mc, "MPF", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw #slashed{E_{t}})", etaBinning.getBinTitle(i), lumi, outputName.Data()); } // Special case eta < 1.3 { const std::string& etaName = "eta013"; std::cout << "Processing " << etaName << std::endl; TString responseName = TString::Format("%s/extrap_resp_balancing_%s_graph", rootFolder.Data(), etaName.c_str()); TString outputName = TString::Format("%s/extrap_resp_balancing_%s.pdf", directoryName.Data(), etaName.c_str()); TGraphErrors* data = (TGraphErrors*) dataFile->Get(responseName); TGraphErrors* mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawGraphs(data, mc, "Balancing", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", "#eta #leq 1.3", lumi, outputName.Data()); // Raw jets responseName = TString::Format("%s/extrap_resp_balancing_raw_%s_graph", rootFolder.Data(), etaName.c_str()); outputName = TString::Format("%s/extrap_resp_balancing_raw_%s.pdf", directoryName.Data(), etaName.c_str()); data = (TGraphErrors*) dataFile->Get(responseName); mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawGraphs(data, mc, "Balancing", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw jets)", "#eta #leq 1.3", lumi, outputName.Data()); responseName = TString::Format("%s/extrap_resp_mpf_%s_graph", rootFolder.Data(), etaName.c_str()); outputName = TString::Format("%s/extrap_resp_mpf_%s.pdf", directoryName.Data(), etaName.c_str()); data = (TGraphErrors*) dataFile->Get(responseName); mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawGraphs(data, mc, "MPF", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", "#eta #leq 1.3", lumi, outputName.Data()); // Raw jets responseName = TString::Format("%s/extrap_resp_mpf_raw_%s_graph", rootFolder.Data(), etaName.c_str()); outputName = TString::Format("%s/extrap_resp_mpf_raw_%s.pdf", directoryName.Data(), etaName.c_str()); data = (TGraphErrors*) dataFile->Get(responseName); mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawGraphs(data, mc, "MPF", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw #slashed{E_{t}})", "#eta #leq 1.3", lumi, outputName.Data()); } //db->set_legendTitle("|#eta| < 1.3"); //db->drawHisto_vs_pt(ptBins, "resp_mpf_eta013", "MPF Response", "", "Events", log); //db->drawHisto_vs_pt(ptBins, "resp_mpf_raw_eta013", "MPF Response (raw ME_{T})", "", "Events", log); for (size_t i = 0; i < etaBinningSize; i++) { const std::string& etaName = etaBinning.getBinName(i); std::cout << "Processing " << etaName << std::endl; TString responseName = TString::Format("%s/extrap_resp_balancing_%s_graph", rootFolder.Data(), etaName.c_str()); TString outputName = TString::Format("%s/extrap_resp_combined_%s", directoryName.Data(), etaName.c_str()); TGraphErrors* balancingData = (TGraphErrors*) dataFile->Get(responseName); TGraphErrors* balancingMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName); responseName = TString::Format("%s/extrap_resp_mpf_%s_graph", rootFolder.Data(), etaName.c_str()); TGraphErrors* mpfData = (TGraphErrors*) dataFile->Get(responseName); TGraphErrors* mpfMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawCombinedGraphs(balancingData, balancingMC, mpfData, mpfMC, "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", etaBinning.getBinTitle(i), lumi, outputName.Data()); responseName = TString::Format("%s/extrap_resp_balancing_raw_%s_graph", rootFolder.Data(), etaName.c_str()); outputName = TString::Format("%s/extrap_resp_combined_raw_%s", directoryName.Data(), etaName.c_str()); balancingData = (TGraphErrors*) dataFile->Get(responseName); balancingMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName); responseName = TString::Format("%s/extrap_resp_mpf_raw_%s_graph", rootFolder.Data(), etaName.c_str()); mpfData = (TGraphErrors*) dataFile->Get(responseName); mpfMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawCombinedGraphs(balancingData, balancingMC, mpfData, mpfMC, "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw objects)", etaBinning.getBinTitle(i), lumi, outputName.Data()); } // Eta < 1.3 { const std::string& etaName = "eta013"; std::cout << "Processing " << etaName << std::endl; TString responseName = TString::Format("%s/extrap_resp_balancing_%s_graph", rootFolder.Data(), etaName.c_str()); TString outputName = TString::Format("%s/extrap_resp_combined_%s", directoryName.Data(), etaName.c_str()); TGraphErrors* balancingData = (TGraphErrors*) dataFile->Get(responseName); TGraphErrors* balancingMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName); responseName = TString::Format("%s/extrap_resp_mpf_%s_graph", rootFolder.Data(), etaName.c_str()); TGraphErrors* mpfData = (TGraphErrors*) dataFile->Get(responseName); TGraphErrors* mpfMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawCombinedGraphs(balancingData, balancingMC, mpfData, mpfMC, "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", "#eta #leq 1.3", lumi, outputName.Data()); responseName = TString::Format("%s/extrap_resp_balancing_raw_%s_graph", rootFolder.Data(), etaName.c_str()); outputName = TString::Format("%s/extrap_resp_combined_raw_%s", directoryName.Data(), etaName.c_str()); balancingData = (TGraphErrors*) dataFile->Get(responseName); balancingMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName); responseName = TString::Format("%s/extrap_resp_mpf_raw_%s_graph", rootFolder.Data(), etaName.c_str()); mpfData = (TGraphErrors*) dataFile->Get(responseName); mpfMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName); drawCombinedGraphs(balancingData, balancingMC, mpfData, mpfMC, "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw objects)", "#eta #leq 1.3", lumi, outputName.Data()); } return 0; }
//_____________________________________________________________________________ void ProofSimple::SlaveBegin(TTree * /*tree*/) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); Ssiz_t iopt = kNPOS; // Histos array if (fInput->FindObject("ProofSimple_NHist")) { TParameter<Long_t> *p = dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist")); fNhist = (p) ? (Int_t) p->GetVal() : fNhist; } else if ((iopt = option.Index("nhist=")) != kNPOS) { TString s; Ssiz_t from = iopt + strlen("nhist="); if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi(); } if (fNhist < 1) { Abort("fNhist must be > 0! Hint: proof->SetParameter(\"ProofSimple_NHist\"," " (Long_t) <nhist>)", kAbortProcess); return; } fHist = new TH1F*[fNhist]; TString hn; // Create the histogram for (Int_t i=0; i < fNhist; i++) { hn.Form("h%d",i); fHist[i] = new TH1F(hn.Data(), hn.Data(), 100, -3., 3.); fHist[i]->SetFillColor(kRed); fOutput->Add(fHist[i]); } // 3D Histos array if (fInput->FindObject("ProofSimple_NHist3")) { TParameter<Long_t> *p = dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist3")); fNhist3 = (p) ? (Int_t) p->GetVal() : fNhist3; } else if ((iopt = option.Index("nhist3=")) != kNPOS) { TString s; Ssiz_t from = iopt + strlen("nhist3="); if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist3 = s.Atoi(); } if (fNhist3 > 0) { fHist3 = new TH3F*[fNhist3]; Info("Begin", "%d 3D histograms requested", fNhist3); // Create the 3D histogram for (Int_t i=0; i < fNhist3; i++) { hn.Form("h%d_3d",i); fHist3[i] = new TH3F(hn.Data(), hn.Data(), 100, -3., 3., 100, -3., 3., 100, -3., 3.); fOutput->Add(fHist3[i]); } } // Histo with labels if (fInput->FindObject("ProofSimple_TestLabelMerging")) { fHLab = new TH1F("hlab", "Test merging of histograms with automatic labels", 10, 0., 10.); fOutput->Add(fHLab); } // Ntuple TNamed *nm = dynamic_cast<TNamed *>(fInput->FindObject("ProofSimple_Ntuple")); if (nm) { // Title is in the form // merge merge via file // |<fout> location of the output file if merge // |retrieve retrieve to client machine // dataset create a dataset // |<dsname> dataset name (default: dataset_ntuple) // |plot for a final plot // <empty> or other keep in memory fHasNtuple = 1; TString ontp(nm->GetTitle()); if (ontp.Contains("|plot") || ontp == "plot") { fPlotNtuple = kTRUE; ontp.ReplaceAll("|plot", ""); if (ontp == "plot") ontp = ""; } TString locfn("SimpleNtuple.root"); if (ontp.BeginsWith("merge")) { ontp.Replace(0,5,""); fProofFile = new TProofOutputFile(locfn, "M"); TString fn; Ssiz_t iret = ontp.Index("|retrieve"); if (iret != kNPOS) { fProofFile->SetRetrieve(kTRUE); TString rettag("|retrieve"); if ((iret = ontp.Index("|retrieve=")) != kNPOS) { rettag += "="; fn = ontp(iret + rettag.Length(), ontp.Length() - iret - rettag.Length()); if ((iret = fn.Index('|')) != kNPOS) fn.Remove(iret); rettag += fn; } ontp.ReplaceAll(rettag, ""); } Ssiz_t iof = ontp.Index('|'); if (iof != kNPOS) ontp.Remove(0, iof + 1); if (!ontp.IsNull()) { fProofFile->SetOutputFileName(ontp.Data()); if (fn.IsNull()) fn = gSystem->BaseName(TUrl(ontp.Data(), kTRUE).GetFile()); } if (fn.IsNull()) fn = locfn; // This will be the final file on the client, the case there is one fProofFile->SetTitle(fn); } else if (ontp.BeginsWith("dataset")) { ontp.Replace(0,7,""); Ssiz_t iof = ontp.Index("|"); if (iof != kNPOS) ontp.Remove(0, iof + 1); TString dsname = (!ontp.IsNull()) ? ontp.Data() : "dataset_ntuple"; UInt_t opt = TProofOutputFile::kRegister | TProofOutputFile::kOverwrite | TProofOutputFile::kVerify; fProofFile = new TProofOutputFile("SimpleNtuple.root", TProofOutputFile::kDataset, opt, dsname.Data()); fHasNtuple = 2; } else if (!ontp.IsNull()) { Warning("SlaveBegin", "ntuple options unknown: ignored (%s)", ontp.Data()); } // Open the file, if required if (fProofFile) { // Open the file fFile = fProofFile->OpenFile("RECREATE"); if (fFile && fFile->IsZombie()) SafeDelete(fFile); // Cannot continue if (!fFile) { Info("SlaveBegin", "could not create '%s': instance is invalid!", fProofFile->GetName()); return; } } // Now we create the ntuple fNtp = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i"); // File resident, if required if (fFile) { fNtp->SetDirectory(fFile); fNtp->AutoSave(); } else { fOutput->Add(fNtp); } } // Set random seed fRandom = new TRandom3(0); }
void macro_MakeQcdClosureTest() { // parameters ////////////////////////////////////////////////////////////// //TFile input("./emuSpec_19619pb-1.root", "open"); TFile input("test_19619pb-1.root", "open"); input.cd(); TParameter<float> *lumi = (TParameter<float> *)input.Get("lumi"); const int nBins = 75; const bool usePu = 1; const bool useWeight = 1; const int qcdEst = 1; // estimation method of QCD contribution. none(0), from SS spectrum(1), from fake rate(2) int eRegion = 2; // electron region EB(0), EE(1), EB+EE(2) bool plotSign[3]; plotSign[0] = 1; // all plotSign[1] = 1; // SS same sign plotSign[2] = 1; // OS opposite sign bool plotType[2]; plotType[0] = 1; // emu spectrum plotType[1] = 1; // cumulative emu spectrum const bool plotPull = 0; // plot (data-bkg)/bkg const bool plotPullBelowSpec = 0; // plot (data-bkg)/bkg below spectrum const bool logPlotX = 0; const bool logPlotY = 1; const bool prelim = 1; const bool groupedPlot = 0; const bool overflowBin = 1; float xRangeMin = 60.; float xRangeMax = 1200.; //float xRangeMin = 0.; //float xRangeMax = 1500.; float yRangeMin[6] = {0.002, 0.002, 0.002, 0.4, 0.4, 0.4}; float yRangeMax[6] = {30, 10, 30, 3000, 1000, 3000}; float yRangeMinRatio[3] = {-0.7, -0.7, -0.7}; float yRangeMaxRatio[3] = {0.7, 0.7, 0.7}; float fitMin = xRangeMin; float fitMax = 1100.; // set to highest bin with a data point float xRangeMinRatio = fitMin; float xRangeMaxRatio = fitMax; // output file formats const bool savePull = 0; const bool saveSpec = 0; const bool saveCumSpec = 0; const bool saveAsPdf = 0; const bool saveAsPng = 1; const bool saveAsRoot = 0; const char *fileNameExtra = ""; //const char *fileNameExtra = "madgraphTTbar_"; const char *plotDir = "./plottemp/"; // plot style int wjetColour= TColor::GetColor("#ffd324"); int jetBkgColour = TColor::GetColor("#ffff66"); int font = 42; //62 //////////////////////////////////////////////////////////////////////////// // systematic errors float systErrLumi = ((TParameter<float> *)input.Get("systErrLumi"))->GetVal(); systErrLumi = 0.; // since we normalize to the Z peak float systErrEff = ((TParameter<float> *)input.Get("systErrEff"))->GetVal(); // muon err & ele err THashList *systErrMCs = (THashList *)input.Get("systErrMCs"); vector<float> systErrMC; systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcTtbar"))->GetVal()); // NNLO ttbar //systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcTtbar700to1000"))->GetVal()); // NLO ttbar700to1000 //systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcTtbar1000up"))->GetVal()); // NLO ttbar1000up systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcDyTauTau"))->GetVal()); //z->tt systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcWW"))->GetVal()); //WW systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcWZ"))->GetVal()); //WZ systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcZZ"))->GetVal()); //ZZ systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcTW"))->GetVal()); //tW systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcDyMuMu"))->GetVal()); //Z->mm systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcDyEE"))->GetVal()); //Z->ee if (qcdEst == 2) systErrMC.push_back(0.4); // qcd error else systErrMC.push_back(((TParameter<float> *)systErrMCs->FindObject("systErrMcWJets"))->GetVal()); //WJets // to keep the histogram when the file is closed TH1::AddDirectory(kFALSE); TH1::SetDefaultSumw2(kTRUE); TString histoSign[3] = {"", "SS_", "OS_"}; TString xAxisTitle[3] = {"m(e#mu)", "m(e^{#pm}#mu^{#pm})", "m(e^{#pm}#mu^{#mp})"}; TString nameSuffix[2] = {"", "cumul"}; TString titleSuffix[2] = {"", " - Cumulative"}; vector<TH1F *> emuMass_wjets; vector<TH1F *> emuMass_qcd; vector<TH1F *> emuMass_qcdFromFake; // define the binning vector<float> binning; if (logPlotX) { //for (float bin = 0.; bin < 100.; bin += 5.) // binning.push_back(bin); for (float bin = 0.; bin < 200.; bin += 10.) binning.push_back(bin); for (float bin = 200.; bin < 400.; bin += 20.) binning.push_back(bin); for (float bin = 400.; bin < 500.; bin += 25.) binning.push_back(bin); for (float bin = 500.; bin <= 620.; bin += 40.) binning.push_back(bin); binning.push_back(670.); binning.push_back(720.); binning.push_back(780.); binning.push_back(840.); binning.push_back(920.); binning.push_back(1000.); binning.push_back(1100.); binning.push_back(1220.); binning.push_back(1380.); binning.push_back(1500.); } else { //for (float bin = 0.; bin <= 1500.; bin += 20.) // binning.push_back(bin); for (float bin = 0.; bin < 200.; bin += 20.) binning.push_back(bin); for (float bin = 200.; bin < 400.; bin += 40.) binning.push_back(bin); for (float bin = 400.; bin < 700.; bin += 50.) binning.push_back(bin); for (float bin = 700.; bin < 1000.; bin += 75.) binning.push_back(bin); for (float bin = 1000.; bin < 1200.; bin += 100.) binning.push_back(bin); for (float bin = 1200.; bin <= 1500.; bin += 150.) binning.push_back(bin); } THashList *mcWeights = (THashList *)input.Get("mcWeights"); TParameter<float> *mcWeight = (TParameter<float> *)mcWeights->FindObject("ttbar"); TParameter<float> *mcWeight700to1000 = (TParameter<float> *)mcWeights->FindObject("ttbar700to1000"); TParameter<float> *mcWeight1000up = (TParameter<float> *)mcWeights->FindObject("ttbar1000up"); float totMcWeight = 1.; // determine qcd contribution TH1F *qcdContrib; TH1F *ssData = MakeHistoFromBranch(&input, "emuTree_data", "mass", SS, eRegion, "", 0., 0., binning, 0x100); TH1F *ssBg = MakeHistoFromBranch(&input, "emuTree_ttbar", "mass", SS, eRegion, "genMTtbar", 0., 700., binning, 0x1DF); totMcWeight = 1. / (1 / mcWeight->GetVal() + 1 / mcWeight700to1000->GetVal()); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ttbar", "mass", SS, eRegion, "genMTtbar", 700., 1000., binning, 0x19F), totMcWeight); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ttbar700to1000", "mass", SS, eRegion, "genMTtbar", 700., 1000., binning, 0x19F), totMcWeight); totMcWeight = 1. / (1 / mcWeight->GetVal() + 1 / mcWeight1000up->GetVal()); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ttbar", "mass", SS, eRegion, "genMTtbar", 1000., 1000000000., binning, 0x19F), totMcWeight); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ttbar1000up", "mass", SS, eRegion, "genMTtbar", 1000., 1000000000., binning, 0x19F), totMcWeight); //TH1F *ssBg = MakeHistoFromBranch(&input, "emuTree_ttbar", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF); //TH1F *ssBg = MakeHistoFromBranch(&input, "emuTree_ttbarto2l", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ztautau", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_ww", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_wz", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_zz", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_tw", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_zmumu", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_zee", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); ssBg->Add(MakeHistoFromBranch(&input, "emuTree_wjets", "mass", SS, eRegion, "", 0., 0., binning, 0x1DF)); qcdContrib = (TH1F *)ssData->Clone("qcdContrib_SS"); qcdContrib->Add(ssBg, -1); for (int i = 0; i < qcdContrib->GetNbinsX() + 2; ++i) { if (qcdContrib->GetBinContent(i) < 0) qcdContrib->SetBinContent(i, 0.); } cout << "expected SS QCD events: " << ssData->Integral() - ssBg->Integral() << endl; cout << "derived SS QCD events: " << qcdContrib->Integral() << endl; cout << "scale factor: " << (ssData->Integral() - ssBg->Integral()) / qcdContrib->Integral()<< endl; qcdContrib->Scale((ssData->Integral() - ssBg->Integral()) / qcdContrib->Integral()); // loop over full spectrum, SS and OS for (int k = 0; k < 3; ++k) { // loop to get normal and cumulated spectrum for (unsigned int j = 0; j < 2; ++j) { input.cd(); bool normToBin = true; if (j > 0) normToBin = false; if (k == 2) k = -1; // make the histograms emuMass_wjets.push_back(MakeHistoFromBranch(&input, "emuTree_wjets", "mass", k, eRegion, "", 0., 0., binning, 0x1DF, normToBin)); if (k == -1) k = 2; emuMass_wjets.back()->SetName("emuMass_" + histoSign[k] + "wjets" + nameSuffix[j]); // qcd contribution if (k == 2) k = -1; emuMass_qcdFromFake.push_back((TH1F *)MakeHistoFromBranch(&input, "frEmuTree_data", "mass", k, eRegion, "", 0., 0., binning, 0x300)); emuMass_qcd.push_back((TH1F *)qcdContrib->Clone("emuMass_" + histoSign[k] + "qcd")); if (k == ALL) emuMass_qcd.back()->Scale(2.); // normalize to bin width if (j < 1) { for (int i = 1; i < emuMass_qcd.back()->GetNbinsX() + 1; ++i) { emuMass_qcd.back()->SetBinContent(i, emuMass_qcd.back()->GetBinContent(i) / emuMass_qcd.back()->GetBinWidth(i)); emuMass_qcd.back()->SetBinError(i, emuMass_qcd.back()->GetBinError(i) / emuMass_qcd.back()->GetBinWidth(i)); emuMass_qcdFromFake.back()->SetBinContent(i, emuMass_qcdFromFake.back()->GetBinContent(i) / emuMass_qcdFromFake.back()->GetBinWidth(i)); emuMass_qcdFromFake.back()->SetBinError(i, emuMass_qcdFromFake.back()->GetBinError(i) / emuMass_qcdFromFake.back()->GetBinWidth(i)); } } if (k == -1) k = 2; // add overflow in last bin if (j == 0 && overflowBin) { emuMass_wjets.back()->SetBinContent(emuMass_wjets.back()->GetNbinsX(), emuMass_wjets.back()->GetBinContent(emuMass_wjets.back()->GetNbinsX()) + emuMass_wjets.back()->GetBinContent(emuMass_wjets.back()->GetNbinsX() + 1)); emuMass_qcd.back()->SetBinContent(emuMass_qcd.back()->GetNbinsX(), emuMass_qcd.back()->GetBinContent(emuMass_qcd.back()->GetNbinsX()) + emuMass_qcd.back()->GetBinContent(emuMass_qcd.back()->GetNbinsX() + 1)); emuMass_qcdFromFake.back()->SetBinContent(emuMass_qcdFromFake.back()->GetNbinsX(), emuMass_qcdFromFake.back()->GetBinContent(emuMass_qcdFromFake.back()->GetNbinsX()) + emuMass_qcdFromFake.back()->GetBinContent(emuMass_qcdFromFake.back()->GetNbinsX() + 1)); } // integrate from the right side if (j == 1) { // loop over bins double error; for (int i = 1; i < nBins + 1; ++i) { emuMass_wjets.back()->SetBinContent(i, emuMass_wjets.back()->IntegralAndError(i, nBins, error)); emuMass_wjets.back()->SetBinError(i, error); emuMass_qcd.back()->SetBinContent(i, emuMass_qcd.back()->IntegralAndError(i, nBins, error)); emuMass_qcd.back()->SetBinError(i, error); emuMass_qcdFromFake.back()->SetBinContent(i, emuMass_qcdFromFake.back()->IntegralAndError(i, nBins, error)); emuMass_qcdFromFake.back()->SetBinError(i, error); } } if (!plotSign[k]) continue; if (!plotType[j]) continue; TCanvas *emuPlot; TPad *specPad; if (plotPullBelowSpec && j == 0) { emuPlot = new TCanvas("emuPlot" + histoSign[k] + nameSuffix[j], "emu Spectrum" + titleSuffix[j], 100, 100, 900, 900); specPad = new TPad("specPad" + histoSign[k] + nameSuffix[j], "emu Spectrum" + titleSuffix[j], 0., 0.33, 1., 1.); specPad->SetBottomMargin(0.06); } else { emuPlot = new TCanvas("emuPlot" + histoSign[k] + nameSuffix[j], "emu Spectrum" + titleSuffix[j], 100, 100, 900, 600); specPad = new TPad("specPad" + histoSign[k] + nameSuffix[j], "emu Spectrum" + titleSuffix[j], 0., 0., 1., 1.); specPad->SetBottomMargin(0.12); } specPad->SetBorderMode(0); specPad->SetBorderSize(2); specPad->SetFrameBorderMode(0); specPad->SetFillColor(0); specPad->SetFrameFillColor(0); if (logPlotX) specPad->SetLogx(); if (logPlotY) specPad->SetLogy(); specPad->SetLeftMargin(0.11); specPad->SetRightMargin(0.09); specPad->SetTopMargin(0.08); specPad->SetTickx(1); specPad->SetTicky(1); specPad->Draw(); specPad->cd(); gStyle->SetTitleFont(font); gStyle->SetLabelFont(font); gStyle->SetLegendFont(font); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetTitleXOffset(1.); gStyle->SetTitleYOffset(1.3); gPad->SetTicks(1, 1); // make a histogram stack with the bg THStack *bgStack = new THStack("bgStack" + histoSign[k] + nameSuffix[j], "Invariant Mass" + titleSuffix[j]); bgStack->Add(emuMass_qcd.back()); bgStack->Add(emuMass_wjets.back()); // plot spectrum emuMass_wjets.back()->SetFillColor(wjetColour); emuMass_wjets.back()->SetMarkerColor(wjetColour); emuMass_wjets.back()->SetLineColor(kBlack); emuMass_wjets.back()->SetLineWidth(2); //emuMass_wjets.back()->Draw("HISTsames"); emuMass_qcd.back()->SetFillColor(jetBkgColour); emuMass_qcd.back()->SetMarkerColor(jetBkgColour); emuMass_qcd.back()->SetLineColor(kBlack); emuMass_qcd.back()->SetLineWidth(2); //emuMass_qcd.back()->Draw("HISTsames"); bgStack->Draw("hist"); emuMass_qcdFromFake.back()->SetLineColor(kRed); emuMass_qcdFromFake.back()->SetLineWidth(2); emuMass_qcdFromFake.back()->Draw("esame"); if (plotPullBelowSpec && j == 0) { bgStack->GetXaxis()->SetTitle(""); } else { bgStack->GetXaxis()->SetTitle(xAxisTitle[k] + " [GeV]"); } bgStack->GetXaxis()->SetTitleFont(font); bgStack->GetXaxis()->SetTitleSize(0.047); bgStack->GetXaxis()->SetTitleOffset(0.9); bgStack->GetXaxis()->SetLabelFont(font); bgStack->GetXaxis()->SetLabelSize(0.05); bgStack->GetXaxis()->SetMoreLogLabels(); bgStack->GetXaxis()->SetNoExponent(); //bgStack->GetXaxis()->SetRangeUser(xRangeMin, xRangeMax); bgStack->GetXaxis()->SetLimits(xRangeMin, xRangeMax); if (j == 1) bgStack->GetYaxis()->SetTitle("Events #geq " + xAxisTitle[k]); else bgStack->GetYaxis()->SetTitle("Events / GeV"); bgStack->GetYaxis()->SetTitleFont(font); bgStack->GetYaxis()->SetTitleSize(0.047); bgStack->GetYaxis()->SetTitleOffset(1.1); bgStack->GetYaxis()->SetLabelFont(font); bgStack->GetYaxis()->SetLabelSize(0.05); bgStack->SetMinimum(yRangeMin[k + j * 3]); bgStack->SetMaximum(yRangeMax[k + j * 3]); // redraw axis emuMass_qcd.back()->Draw("sameaxis"); // legend and labels TLegend legend(0.710, 0.646, 0.901, 0.885); legend.SetTextFont(font); legend.SetTextSize(0.03); legend.SetBorderSize(0); legend.SetLineColor(1); legend.SetLineStyle(1); legend.SetLineWidth(1); legend.SetFillColor(19); legend.SetFillStyle(0); legend.AddEntry(emuMass_wjets.back(), "W+jets (MC)" ,"F"); legend.AddEntry(emuMass_qcd.back(), "jets (SS data)" ,"F"); legend.AddEntry(emuMass_qcdFromFake.back(), "jets (Fake Rate)" ,"le"); legend.DrawClone("sames"); TLatex *tex = new TLatex(); tex->SetNDC(); tex->SetTextFont(font); tex->SetLineWidth(2); tex->SetTextSize(0.042); if (prelim) tex->DrawLatex(0.325, 0.853, "CMS Preliminary, 8 TeV, 19.6 fb^{-1}"); else tex->DrawLatex(0.405, 0.853, "CMS, 8 TeV, 19.6 fb^{-1}"); if (eRegion == 0) tex->DrawLatex(0.325, 0.775, "e in barrel"); if (eRegion == 1) tex->DrawLatex(0.325, 0.775, "e in endcap"); // safe in various file formats stringstream sStream; if (!plotPullBelowSpec || j > 0) { sStream << plotDir << "qcdClosureTestSpec"; if (k == 0) sStream << "_"; sStream << histoSign[k]; if (eRegion == 0) sStream << "EB_"; if (eRegion == 1) sStream << "EE_"; sStream << fileNameExtra << nameSuffix[j]; if (j > 0) sStream << "_"; if (groupedPlot) sStream << "grouped_"; if (!logPlotY) sStream << "lin_"; sStream << lumi->GetVal() << "pb-1"; TString saveFileName = sStream.str(); if ((j == 0 && saveSpec) || (j > 0 && saveCumSpec)) { if (saveAsPdf) emuPlot->Print(saveFileName + ".pdf", "pdf"); if (saveAsPng) emuPlot->Print(saveFileName + ".png", "png"); if (saveAsRoot) emuPlot->Print(saveFileName + ".root", "root"); } } } // end loop over normal or cumulated } // end loop over full, SS and OS // generate one object containing everything vector<vector<TH1F *> > emuMasses; emuMasses.push_back(emuMass_wjets); emuMasses.push_back(emuMass_qcd); // // define groups of MC samples // vector<bool> ttLikeSamples(6, true); // vector<bool> contamSamples(6, false); // contamSamples.push_back(true); // Zmm // contamSamples.push_back(true); // Zee // contamSamples.push_back(true); // WJets or QCD // vector<bool> contamSamplesNoQcd(contamSamples); // vector<bool> allSamples(9, true); // vector<bool> onlyQCD(emuMasses.size() - 1, false); // if (qcdEst > 0) { // onlyQCD.back() = true; // if (qcdEst != 2) { // allSamples.push_back(true); // contamSamples.push_back(true); // contamSamplesNoQcd.push_back(false); // systErrMC.push_back(0.); // QCD error will be calculated later // } else { // contamSamplesNoQcd.back() = false; // } // } // vector<bool> allSamplesNoQcd(allSamples); // if (qcdEst > 0) allSamplesNoQcd.back() = false; // unsigned int qcdInd = onlyQCD.size(); // unsigned int qcdErrInd = qcdInd - 1; // // // calculate rate of syst errors // float systErrLuEff = sqrt(systErrLumi*systErrLumi + systErrEff*systErrEff); // vector<float> systErrMCLuEff; // for (unsigned int it = 0; it < systErrMC.size(); ++it) // systErrMCLuEff.push_back(sqrt(systErrMC[it]*systErrMC[it] + systErrLuEff*systErrLuEff)); // // bool calcQcdErr = false; // if (qcdEst == 1) calcQcdErr = true; // // //cout << "qcdInd " << qcdInd << ", emuMasses.size() " << emuMasses.size() << ", systErrMC.size() " << systErrMC.size() // // << ", systErrMCLuEff.size() " << systErrMCLuEff.size() << ", allSamples.size() " << allSamples.size() // // << ", allSamplesNoQcd.size() " << allSamplesNoQcd.size() << ", contamSamplesNoQcd.size() " << contamSamplesNoQcd.size() // // << ", contamSamples.size() " << contamSamples.size() << ", onlyQCD.size() " << onlyQCD.size() << endl; // //for (unsigned int sIt = 0; sIt < emuMasses.size() - 1; ++sIt) { // // cout << "allSamples " << allSamples[sIt] << ", allSamplesNoQcd " << allSamplesNoQcd[sIt] // // << ", contamSamples " << contamSamples[sIt] << ", contamSamplesNoQcd " << contamSamplesNoQcd[sIt] // // << ", onlyQCD " << onlyQCD[sIt] << ", systErrMC " << systErrMC[sIt] << ", systErrMCLuEff " << systErrMCLuEff[sIt] << endl; // //} // // // define special bins corresponding to specific masses // int bin60 = emuMass_data.at(ALL)->FindBin(60.); // int bin120 = emuMass_data.at(ALL)->FindBin(120.); // int bin200 = emuMass_data.at(ALL)->FindBin(200.); // int bin400 = emuMass_data.at(ALL)->FindBin(400.); // int bin500 = emuMass_data.at(ALL)->FindBin(500.); // // vector<const char *> sampleNames; // sampleNames.push_back("data "); // sampleNames.push_back("ttbar "); // sampleNames.push_back("Ztautau"); // sampleNames.push_back("WW "); // sampleNames.push_back("WZ "); // sampleNames.push_back("ZZ "); // sampleNames.push_back("tW "); // sampleNames.push_back("Zmumu "); // sampleNames.push_back("Zee "); // if (qcdEst != 2) sampleNames.push_back("WJets "); // if (qcdEst > 0) sampleNames.push_back("QCD "); // // // write numbers // cout << endl; // cout << "-----------------------------------------------------------------------------------------------------------" << endl; // cout << "HEEP - TIGHT MU Lumi = " << lumi->GetVal() << "pb-1" << endl; // //cout << " e pT EB > " << bar_et << "GeV/c" << endl; // //cout << " e pT EE > " << end_et << "GeV/c" << endl; // //cout << " mu pT > " << muon_et << "GeV/c" << endl; // //cout << " mu |eta| < " << muon_etaMax << endl; // cout << endl; // cout << "Systematic errors" << endl; // cout << " Luminosity: " << systErrLumi * 100 << "%" << endl; // cout << " Efficiency: " << systErrEff * 100 << "%" << endl; // cout << " ttbar: " << systErrMC[TTBAR-1] * 100 << "%" << endl; // cout << " Z->tautau: " << systErrMC[ZTT-1] * 100 << "%" << endl; // cout << " WW: " << systErrMC[WW-1] * 100 << "%" << endl; // cout << " WZ: " << systErrMC[WZ-1] * 100 << "%" << endl; // cout << " ZZ: " << systErrMC[ZZ-1] * 100 << "%" << endl; // cout << " tW, tbarW: " << systErrMC[TW-1] * 100 << "%" << endl; // cout << " Z->mumu: " << systErrMC[ZMM-1] * 100 << "%" << endl; // cout << " Z->ee: " << systErrMC[ZEE-1] * 100 << "%" << endl; // if (qcdEst != 2) cout << " W+Jets: " << systErrMC[WJET-1] * 100 << "%" << endl; // else cout << " QCD: " << systErrMC.back() * 100 << "%" << endl; // cout << "-----------------------------------------------------------------------------------------------------------" << endl; // for (unsigned int signIt = 1; signIt < 6; signIt += 2) { // if (signIt == 3) cout << "-SS--------------------------------------------------------------------------------------------------------" << endl; // if (signIt == 5) cout << "-OS--------------------------------------------------------------------------------------------------------" << endl; // cout << "-----------------------------------------------------------------------------------------------------------------------------------------" << endl; // cout << "M_emu | > 60GeV/c^2 | > 120GeV/c^2 | > 200GeV/c^2 | > 400GeV/c^2 |" << endl; // cout << "-----------------------------------------------------------------------------------------------------------------------------------------" << endl; // // printf("nb data | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) |\n", // emuMass_data.at(signIt)->GetBinContent(bin60), sqrt(emuMass_data.at(signIt)->GetBinContent(bin60)), // emuMass_data.at(signIt)->GetBinContent(bin120), sqrt(emuMass_data.at(signIt)->GetBinContent(bin120)), // emuMass_data.at(signIt)->GetBinContent(bin200), sqrt(emuMass_data.at(signIt)->GetBinContent(bin200)), // emuMass_data.at(signIt)->GetBinContent(bin400), sqrt(emuMass_data.at(signIt)->GetBinContent(bin400))); // cout << "----------------------------------------------------------------------------------------------------------------------------------------" << endl; // for (unsigned int sampleIt = 1; sampleIt < sampleNames.size(); ++sampleIt) { // if (sampleIt == 7) cout << "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" << endl; // if (qcdEst == 1 && sampleIt == sampleNames.size() - 1) { // printf("nb %7s | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", sampleNames[sampleIt], // emuMass_qcd.at(signIt)->GetBinContent(bin60), emuMass_qcd.at(signIt)->GetBinContent(bin60) * CalcSSQcdErr(emuMasses, systErrMCLuEff, bin60), // emuMass_qcd.at(signIt)->GetBinContent(bin120), emuMass_qcd.at(signIt)->GetBinContent(bin120) * CalcSSQcdErr(emuMasses, systErrMCLuEff, bin120), // emuMass_qcd.at(signIt)->GetBinContent(bin200), emuMass_qcd.at(signIt)->GetBinContent(bin200) * CalcSSQcdErr(emuMasses, systErrMCLuEff, bin200), // emuMass_qcd.at(signIt)->GetBinContent(bin400), emuMass_qcd.at(signIt)->GetBinContent(bin400) * CalcSSQcdErr(emuMasses, systErrMCLuEff, bin400)); // } else { // printf("nb %7s | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", sampleNames[sampleIt], // emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin60), emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin60) * systErrMCLuEff[sampleIt-1], // emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin120), emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin120) * systErrMCLuEff[sampleIt-1], // emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin200), emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin200) * systErrMCLuEff[sampleIt-1], // emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin400), emuMasses.at(sampleIt).at(signIt)->GetBinContent(bin400) * systErrMCLuEff[sampleIt-1]); // } // } // cout << endl; // cout << "----------------------------------------------------------------------------------------------------------------------------------------" << endl; // printf("TOT ttlike | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, ttLikeSamples, signIt, bin60), CalcSystErr(emuMasses, systErrMCLuEff, ttLikeSamples, signIt, bin60), // CalcBgSum(emuMasses, ttLikeSamples, signIt, bin120), CalcSystErr(emuMasses, systErrMCLuEff, ttLikeSamples, signIt, bin120), // CalcBgSum(emuMasses, ttLikeSamples, signIt, bin200), CalcSystErr(emuMasses, systErrMCLuEff, ttLikeSamples, signIt, bin200), // CalcBgSum(emuMasses, ttLikeSamples, signIt, bin400), CalcSystErr(emuMasses, systErrMCLuEff, ttLikeSamples, signIt, bin400)); // printf("TOT contam | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, contamSamples, signIt, bin60), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, contamSamples, signIt, bin60, -1, calcQcdErr), // CalcBgSum(emuMasses, contamSamples, signIt, bin120), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, contamSamples, signIt, bin120, -1, calcQcdErr), // CalcBgSum(emuMasses, contamSamples, signIt, bin200), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, contamSamples, signIt, bin200, -1, calcQcdErr), // CalcBgSum(emuMasses, contamSamples, signIt, bin400), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, contamSamples, signIt, bin400, -1, calcQcdErr)); // cout << "----------------------------------------------------------------------------------------------------------------------------------------" << endl; // // printf("TOT Bkg | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, allSamples, signIt, bin60), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin60, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin120), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin120, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin200), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin200, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin400), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin400, -1, calcQcdErr)); // cout << "----------------------------------------------------------------------------------------------------------------------------------------" << endl; // cout << endl << endl; // } // cout << endl; // // cout << "--Without adding QCD contribution:--------------------------------------------------------------------------------------------------------" << endl; // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // cout << "M_emu | > 60GeV/c^2 | > 120GeV/c^2 | > 200GeV/c^2 | > 400GeV/c^2 |" << endl; // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // for (unsigned int signIt = 1; signIt < 6; signIt += 2) { // if (signIt == 3) cout << "-SS-------------------------------------------------------------------------------------------------------------------------------------" << endl; // if (signIt == 5) cout << "-OS-------------------------------------------------------------------------------------------------------------------------------------" << endl; // printf("nb data | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) |\n", // emuMasses.at(DATA).at(signIt)->GetBinContent(bin60), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin60)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin120), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin120)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin200), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin200)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin400), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin400))); // printf("nb MC | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, allSamplesNoQcd, signIt, bin60), CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, signIt, bin60), // CalcBgSum(emuMasses, allSamplesNoQcd, signIt, bin120), CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, signIt, bin120), // CalcBgSum(emuMasses, allSamplesNoQcd, signIt, bin200), CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, signIt, bin200), // CalcBgSum(emuMasses, allSamplesNoQcd, signIt, bin400), CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, signIt, bin400)); // } // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // // if (qcdEst == 1) { // //systErrMC.back() = 2 * sqrt(emuMasses.at(DATA).at(SS)->Integral() + pow(CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, SS, 1), 2)) / emuMasses.at(qcdInd).at(ALL)->Integral(); // //systErrMC.back() = CalcSystErr(emuMasses, systErrMCLuEff, allSamplesNoQcd, SSCUM, 1) / emuMass_qcd.at(SSCUM)->GetBinContent(1); // //systErrMCLuEff.back() = systErrMC[qcdErrInd]; // // cout << endl; // cout << "---QCD events from SS spectrum:----------------------------------------------------------------------------------------------------------------------------------" << endl; // cout << "-----------------------------------------------------------------------------------------------------------------------------------------------------------------" << endl; // printf("nb QCD SS+OS | %9.3f +- %8.3f (%.1f%%) (syst) | %9.3f +- %8.3f (%.1f%%) (syst) | %9.3f +- %8.3f (%.1f%%) (syst) | %9.3f +- %8.3f (%.1f%%) (syst) |\n", // emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin60), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin60, -1, calcQcdErr), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin60, -1, calcQcdErr) / emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin60), // emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin120), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin120, -1, calcQcdErr), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin120, -1, calcQcdErr) / emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin120), // emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin200), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin200, -1, calcQcdErr), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin200, -1, calcQcdErr) / emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin200), // emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin400), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin400, -1, calcQcdErr), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin400, -1, calcQcdErr) / emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin400)); // printf("%% of total MC | %7.3f%% +- %7.3f%% (syst) | %7.3f%% +- %7.3f%% (syst) | %7.3f%% +- %7.3f%% (syst) | %7.3f%% +- %7.3f%% (syst) |\n", // 100 * emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin60) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin60), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin60, -1, calcQcdErr) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin60), // 100 * emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin120) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin120), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin120, -1, calcQcdErr) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin120), // 100 * emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin200) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin200), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin200, -1, calcQcdErr) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin200), // 100 * emuMasses.at(qcdInd).at(ALLCUM)->GetBinContent(bin400) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin400), // 100 * CalcSystErrWithQCD(emuMasses, systErrMCLuEff, onlyQCD, ALLCUM, bin400, -1, calcQcdErr) / CalcBgSum(emuMasses, allSamplesNoQcd, ALLCUM, bin400)); // cout << "-----------------------------------------------------------------------------------------------------------------------------------------------------------------" << endl; // } // // // top up bg contribution with qcd // if (qcdEst > 0) { // cout << endl; // cout << "--After adding QCD contribution:----------------------------------------------------------------------------------------------------------" << endl; // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // cout << "M_emu | > 60GeV/c^2 | > 120GeV/c^2 | > 200GeV/c^2 | > 400GeV/c^2 |" << endl; // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // for (unsigned int signIt = 1; signIt < 6; signIt += 2) { // if (signIt == 3) cout << "-SS-------------------------------------------------------------------------------------------------------------------------------------" << endl; // if (signIt == 5) cout << "-OS-------------------------------------------------------------------------------------------------------------------------------------" << endl; // printf("nb data | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) |\n", // emuMasses.at(DATA).at(signIt)->GetBinContent(bin60), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin60)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin120), sqrt((emuMasses.at(DATA).at(signIt))->GetBinContent(bin120)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin200), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin200)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin400), sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin400))); // printf("nb MC | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, allSamples, signIt, bin60), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin60, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin120), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin120, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin200), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin200, -1, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin400), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin400, -1, calcQcdErr)); // } // cout << "------------------------------------------------------------------------------------------------------------------------------------------" << endl; // } // // cout << endl; // cout << "-----------------------------------------------------------------------------------------------------------" << endl; // cout << "M_emu | 60 - 120GeV/c^2 | 120 - 200GeV/c^2 | 200 - 400GeV/c^2 |" << endl; // cout << "-----------------------------------------------------------------------------------------------------------" << endl; // for (unsigned int signIt = 1; signIt < 6; signIt += 2) { // printf("nb data | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) | %5.0f +- %-.3f (stat) |\n", // emuMasses.at(DATA).at(signIt)->GetBinContent(bin60) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin120), // sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin60) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin120)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin120) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin200), // sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin120) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin200)), // emuMasses.at(DATA).at(signIt)->GetBinContent(bin200) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin400), // sqrt(emuMasses.at(DATA).at(signIt)->GetBinContent(bin200) - emuMasses.at(DATA).at(signIt)->GetBinContent(bin400))); // printf("nb MC | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) | %9.3f +- %8.3f (syst) |\n", // CalcBgSum(emuMasses, allSamples, signIt, bin60, bin120), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin60, bin120, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin120, bin200), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin120, bin200, calcQcdErr), // CalcBgSum(emuMasses, allSamples, signIt, bin200, bin400), CalcSystErrWithQCD(emuMasses, systErrMCLuEff, allSamples, signIt, bin200, bin400, calcQcdErr)); // cout << "-----------------------------------------------------------------------------------------------------------" << endl; // } }