/* Simple macro showing how to access branches from the delphes output root file, loop over events, and plot simple quantities such as the jet pt and the di-electron invariant mass. root -l examples/Example1.C'("delphes_output.root")' */ //------------------------------------------------------------------------------ #include #include void Example1(const char *inputFile) { gSystem->Load("libDelphes"); // 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 *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchElectron = treeReader->UseBranch("Electron"); // Book histograms TH1 *histJetPT = new TH1F("jet_pt", "jet P_{T}", 100, 0.0, 100.0); TH1 *histMass = new TH1F("mass", "M_{inv}(e_{1}, e_{2})", 100, 40.0, 140.0); // 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 jet if(branchJet->GetEntries() > 0) { // Take first jet Jet *jet = (Jet*) branchJet->At(0); // Plot jet transverse momentum histJetPT->Fill(jet->PT); // Print jet transverse momentum cout << "Jet pt: "<PT << endl; } Electron *elec1, *elec2; // If event contains at least 2 electrons if(branchElectron->GetEntries() > 1) { // Take first two electrons elec1 = (Electron *) branchElectron->At(0); elec2 = (Electron *) branchElectron->At(1); // Plot their invariant mass histMass->Fill(((elec1->P4()) + (elec2->P4())).M()); } } // Show resulting histograms histJetPT->Draw(); histMass->Draw(); }