| 57 | == Analyzing Delphes' Output == |
| 58 | |
| 59 | Delphes' output can be analyzed with the ROOT data analysis framework. |
| 60 | |
| 61 | === Simple analysis using TTree::Draw === |
| 62 | |
| 63 | Start ROOT and load Delphes' shared library: |
| 64 | {{{ |
| 65 | root |
| 66 | gSystem->Load("libDelphes"); |
| 67 | }}} |
| 68 | |
| 69 | Open ROOT tree file and do some basic analysis using Draw or TBrowser: |
| 70 | {{{ |
| 71 | TFile::Open("delphes_output.root"); |
| 72 | Delphes->Draw("Electron.PT"); |
| 73 | TBrowser browser; |
| 74 | }}} |
| 75 | |
| 76 | Note 1: Delphes - tree name, it can be learnt e.g. from TBrowser |
| 77 | |
| 78 | Note 2: Electron - branch name; PT - variable (leaf) of this branch |
| 79 | |
| 80 | Complete description of all branches can be found at [wiki:WorkBook/RootTreeDescription] |
| 81 | |
| 82 | |
| 83 | === Macro-based analysis === |
| 84 | |
| 85 | Delphes/examples directory contains a basic ROOT analysis macro called Example1.C. |
| 86 | This ROOT analysis macro consists of histogram booking, event loop (histogram filling), |
| 87 | histogram display. |
| 88 | |
| 89 | Here are commands to run this macro: |
| 90 | {{{ |
| 91 | root |
| 92 | gSystem->Load("libDelphes"); |
| 93 | .X examples/Example1.C("delphes_output.root"); |
| 94 | }}} |
| 95 | |
| 96 | And here is the full source code of this macro: |
| 97 | {{{ |
| 98 | void Example1(const char *inputFile) |
| 99 | { |
| 100 | // Create chain of root trees |
| 101 | TChain chain("Delphes"); |
| 102 | chain.Add(inputFile); |
| 103 | |
| 104 | // Create object of class ExRootTreeReader |
| 105 | ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); |
| 106 | Long64_t numberOfEntries = treeReader->GetEntries(); |
| 107 | |
| 108 | // Get pointers to branches used in this analysis |
| 109 | TClonesArray *branchJet = treeReader->UseBranch("Jet"); |
| 110 | TClonesArray *branchElectron = treeReader->UseBranch("Electron"); |
| 111 | |
| 112 | // Book histograms |
| 113 | TH1 *histJetPT = new TH1F("jet_pt", "jet P_{T}", 100, 0.0, 100.0); |
| 114 | TH1 *histMass = new TH1F("mass", "M_{inv}(e_{1}, e_{2})", 100, 40.0, 140.0); |
| 115 | |
| 116 | // Loop over all events |
| 117 | for(Int_t entry = 0; entry < numberOfEntries; ++entry) |
| 118 | { |
| 119 | |
| 120 | // Load selected branches with data from specified event |
| 121 | treeReader->ReadEntry(entry); |
| 122 | |
| 123 | // If event contains at least 1 jet |
| 124 | if(branchJet->GetEntries() > 0) |
| 125 | { |
| 126 | |
| 127 | // Take first jet |
| 128 | TRootJet *jet = (TRootJet*) branchJet->At(0); |
| 129 | |
| 130 | // Plot jet transverse momentum |
| 131 | histJetPT->Fill(jet->PT); |
| 132 | |
| 133 | // Print jet transverse momentum |
| 134 | cout << jet->PT << endl; |
| 135 | } |
| 136 | |
| 137 | TRootElectron *elec1, *elec2; |
| 138 | TLorentzVector vec1, vec2; |
| 139 | |
| 140 | // If event contains at least 2 electrons |
| 141 | if(branchElectron->GetEntries() > 1) |
| 142 | { |
| 143 | |
| 144 | // Take first two electrons |
| 145 | elec1 = (TRootElectron *) branchElectron->At(0); |
| 146 | elec2 = (TRootElectron *) branchElectron->At(1); |
| 147 | |
| 148 | // Create two 4-vectors for the electrons |
| 149 | vec1.SetPtEtaPhiM(elec1->PT, elec1->Eta, elec1->Phi, 0.0); |
| 150 | vec2.SetPtEtaPhiM(elec2->PT, elec2->Eta, elec2->Phi, 0.0); |
| 151 | |
| 152 | // Plot their invariant mass |
| 153 | histMass->Fill((vec1 + vec2).M()); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | // Show resulting histograms |
| 158 | histJetPT->Draw(); |
| 159 | histMass->Draw(); |
| 160 | } |
| 161 | }}} |
| 162 | |
| 163 | === More advanced macro-based analysis === |
| 164 | |
| 165 | Delphes/examples directory contains a ROOT macro called Example2.C demonstrating how to use class ExRootTreeReader to |
| 166 | access data and class ExRootResult to manage histograms booking and output. |
| 167 | |
| 168 | Here are commands to run this macro: |
| 169 | {{{ |
| 170 | root |
| 171 | gSystem->Load("libDelphes"); |
| 172 | .X examples/Example2.C("delphes_output.root"); |
| 173 | }}} |
| 174 | |
| 175 | |
| 176 | |