#ifdef __CLING__ R__LOAD_LIBRARY(libDelphes) #include "classes/DelphesClasses.h" #include "external/ExRootAnalysis/ExRootTreeReader.h" #endif #define Lumi 100 //------------------------------------------------------------------------------ void Plot(const char *inputFile0, const char *inputFile1){ gSystem->Load("libDelphes"); TCanvas *c1 = new TCanvas("Lepton_PT"); // THStack *zPT= new THStack("hs","test stacked histograms"); TH1 *histPhotonPT[2]; Double_t sigW = (1.36*Lumi)/50000; Double_t bgW = (2.45*Lumi)/50000; Double_t weight[2] = {bgW, sigW}; //Book Legend TLegend *legend1 = new TLegend(0.4,0.2,0.7,0.33); const char *inputFiles[2] = {inputFile0, inputFile1}; for(int nfile=0; nfile<2; nfile++){ // Create chain of root trees TChain chain("Delphes"); chain.Add(inputFiles[nfile]); // 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"); //Edited // Book histograms histPhotonPT[nfile] = new TH1F(TString::Format("zboson_pt_%d", nfile), "(Z-boson)", 100, 0.0, 500.0); // zPT->Add(histZbosonPT[nfile]); histPhotonPT[nfile]->SetLineWidth(2); histPhotonPT[nfile]->SetStats(0); histPhotonPT[nfile]->GetXaxis()->SetTitle("MP_{Z}(GeV)"); histPhotonPT[nfile]->GetYaxis()->SetTitle("Number of Events"); Photon *photon; // Loop over all events for(Int_t entry = 0; entry < numberOfEntries; ++entry) { // Load selected branches with data from specified event treeReader->ReadEntry(entry); if(branchPhoton->GetEntries() > 0) { // Take first photon photon = (Photon*) branchPhoton->At(0); histPhotonPT[nfile]->Fill(photon->PT, weight[nfile]); } } } // c1->SetLogy(); c1->SetTickx(); c1->SetTicky(); c1->SetGrid(); c1->cd(); histPhotonPT[0]->SetLineColor(kBlack); histPhotonPT[1]->SetLineColor(kRed); histPhotonPT[0]->Draw(); histPhotonPT[1]->Draw("sames"); // zPT->Draw(); legend1->AddEntry(histPhotonPT[0], "Background","f"); legend1->AddEntry(histPhotonPT[1], "SP-Type","f"); legend1->SetTextSize(0.031); legend1->Draw(); }