#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("photon_pt", "P_{T}(#gamma)", 100, 0.0, 500.0); histPhotonE[nfile]= new TH1F("photon_energy", "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(); histPhotonPT[1]->SetLineColor(kBlack); histPhotonPT[1]->Draw("same"); legend1->AddEntry(histPhotonPT[0],"Signal","f"); legend1->AddEntry(histPhotonPT[1],"Background","f"); legend1->Draw(); c2->cd(); histPhotonE[0]->SetLineColor(kRed); histPhotonE[0]->Draw(); histPhotonE[1]->SetLineColor(kBlack); histPhotonE[1]->Draw("same"); legend2->AddEntry(histPhotonE[0],"Signal","f"); legend2->AddEntry(histPhotonE[1],"Background","f"); legend2->Draw(); }