#ifdef __CLING__ R__LOAD_LIBRARY(libDelphes) #include "classes/DelphesClasses.h" #include "external/ExRootAnalysis/ExRootTreeReader.h" #endif //------------------------------------------------------------------------------ void SampleMacro(const char *inputFile0,const char *inputFile1){ gSystem->Load("libDelphes"); TCanvas *c1 = new TCanvas("Photon PT"); TCanvas *c2 = new TCanvas("Photon E"); TH1 *histPhotonPT[2]; TH1 *histPhotonE [2]; TLegend *legend1 = new TLegend(0.2,0.2,0.4,0.33); TLegend *legend2 = new TLegend(0.2,0.2,0.4,0.33); for(int nfile=0; nfile<2; nfile++){ const char *inputFile; if(nfile==0){inputFile = inputFile0;} if(nfile==1){inputFile = inputFile1;} // Create chain of root trees TChain chain("Delphes"); chain.Add(inputFile); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *branchPhoton = treeReader->UseBranch("Photon"); // Book histograms histPhotonPT[nfile] = new TH1F(TString::Format("photon_pt_%d", nfile), "P_{T}(#gamma)", 100, 0.0, 500.0); histPhotonE[nfile]= new TH1F(TString::Format("photon_energy_%d", nfile), "E(#gamma)", 100, 0.0, 500.0); // histPhotonPT[nfile]->SetStats(1); Photon *photon; MissingET *misset; // Loop over all events for(Int_t entry = 0; entry < numberOfEntries; ++entry) { // Load selected branches with data from specified event treeReader->ReadEntry(entry); // If event contains at least 1 photon if(branchPhoton->GetEntries() > 0) { // Take first photon photon = (Photon*) branchPhoton->At(0); histPhotonPT[nfile]->Fill(photon->PT); histPhotonE[nfile]->Fill(photon->E); } } }// number loop // histPhotonPT[0]->SetStats(1); // histPhotonPT[1]->SetStats(1); c1->SetLogy(); c1->SetTickx(); c1->SetTicky(); c1->SetGrid(); c2->SetLogy(); c2->SetTickx(); c2->SetTicky(); c2->SetGrid(); c1->cd(); histPhotonPT[0]->SetLineColor(kRed); histPhotonPT[0]->Draw(); c1->Modified(); c1->Update(); TPaveStats *statSig1 =(TPaveStats*)c1->GetPrimitive("stats"); //For Signal statistics if (statSig1 == NULL) { cout << "*******Signal-stats is nullptr!*******" << endl; } else { statSig1->SetName("Signal"); statSig1->SetY1NDC(.6); statSig1->SetY2NDC(0.75); statSig1->SetTextColor(kRed);} histPhotonPT[1]->SetLineColor(kBlack); histPhotonPT[1]->Draw("sames"); c1->Modified(); c1->Update(); TPaveStats *statBG = (TPaveStats*)c1->FindObject("stats"); //For Background statistics if (statBG == NULL) { cout << "*******Background-stats is nullptr!*******" << endl; } else { statBG->SetName("Background"); statBG->SetY1NDC(.45); statBG->SetY2NDC(.65); statBG->SetTextColor(kBlack);} c1->Modified(); c1->Update(); legend1->AddEntry(histPhotonPT[0],"Signal","f"); legend1->AddEntry(histPhotonPT[1],"Background","f"); legend1->Draw(); c2->cd(); histPhotonE[0]->SetLineColor(kRed); histPhotonE[0]->Draw(); c2->Modified(); c2->Update(); TPaveStats *statSig2 =(TPaveStats*)c2->GetPrimitive("stats"); //For Signal statistics if (statSig2 == NULL) { cout << "*******Signal-stats is nullptr!*******" << endl; } else { statSig2->SetName("Signal"); statSig2->SetY1NDC(.6); statSig2->SetY2NDC(0.75); statSig2->SetTextColor(kRed);} c2->Modified(); c2->Update(); histPhotonE[1]->SetLineColor(kBlack); histPhotonE[1]->Draw("sames"); c2->Modified(); c2->Update(); legend2->AddEntry(histPhotonE[0],"Signal","f"); legend2->AddEntry(histPhotonE[1],"Background","f"); legend2->Draw(); }