Changeset fbb617b in git
- Timestamp:
- Dec 14, 2014, 12:06:59 AM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- cf1ff2c
- Parents:
- 57e1804
- Location:
- examples
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/Example1.C
r57e1804 rfbb617b 2 2 Simple macro showing how to access branches from the delphes output root file, 3 3 loop over events, and plot simple quantities such as the jet pt and the di-electron invariant 4 mass. 4 mass. 5 5 6 6 root -l examples/Example1.C'("delphes_output.root")' … … 16 16 TChain chain("Delphes"); 17 17 chain.Add(inputFile); 18 18 19 19 // Create object of class ExRootTreeReader 20 20 ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); 21 21 Long64_t numberOfEntries = treeReader->GetEntries(); 22 22 23 23 // Get pointers to branches used in this analysis 24 24 TClonesArray *branchJet = treeReader->UseBranch("Jet"); 25 25 TClonesArray *branchElectron = treeReader->UseBranch("Electron"); 26 26 27 27 // Book histograms 28 28 TH1 *histJetPT = new TH1F("jet_pt", "jet P_{T}", 100, 0.0, 100.0); … … 34 34 // Load selected branches with data from specified event 35 35 treeReader->ReadEntry(entry); 36 36 37 37 // If event contains at least 1 jet 38 38 if(branchJet->GetEntries() > 0) … … 40 40 // Take first jet 41 41 Jet *jet = (Jet*) branchJet->At(0); 42 42 43 43 // Plot jet transverse momentum 44 44 histJetPT->Fill(jet->PT); 45 45 46 46 // Print jet transverse momentum 47 47 cout << "Jet pt: "<<jet->PT << endl; -
examples/Example1.cpp
r57e1804 rfbb617b 2 2 * Delphes: a framework for fast simulation of a generic collider experiment 3 3 * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium 4 * 4 * 5 5 * This program is free software: you can redistribute it and/or modify 6 6 * it under the terms of the GNU General Public License as published by 7 7 * the Free Software Foundation, either version 3 of the License, or 8 8 * (at your option) any later version. 9 * 9 * 10 10 * This program is distributed in the hope that it will be useful, 11 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 * GNU General Public License for more details. 14 * 14 * 15 15 * You should have received a copy of the GNU General Public License 16 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. … … 73 73 //------------------------------------------------------------------------------ 74 74 75 // Here you call your macro's main function 75 // Here you call your macro's main function 76 76 77 77 Example1(inputFile); -
examples/Example1.py
r57e1804 rfbb617b 38 38 # Take first jet 39 39 jet = branchJet.At(0) 40 40 41 41 # Plot jet transverse momentum 42 42 histJetPT.Fill(jet.PT) 43 43 44 44 # Print jet transverse momentum 45 45 print jet.PT -
examples/Example2.C
r57e1804 rfbb617b 1 1 /* 2 2 Simple macro showing how to access branches from the delphes output root file, 3 loop over events, store histograms in a root file and print them as image files. 3 loop over events, store histograms in a root file and print them as image files. 4 4 5 5 root -l examples/Example2.C'("delphes_output.root")' -
examples/Example3.C
r57e1804 rfbb617b 1 1 /* 2 2 This macro shows how to access the particle-level reference for reconstructed objects. 3 It is also shown how to loop over the jet constituents. 3 It is also shown how to loop over the jet constituents. 4 4 5 5 root -l examples/Example3.C'("delphes_output.root")' … … 182 182 } 183 183 184 // cout<<"-- New event -- "<<endl;184 // cout << "-- New event -- " << endl; 185 185 186 186 // Loop over all jets in event … … 191 191 momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0); 192 192 193 // cout<<"Looping over jet constituents. Jet pt: "<<jet->PT<<", eta: "<<jet->Eta<<", phi: "<<jet->Phi<<endl;193 // cout<<"Looping over jet constituents. Jet pt: "<<jet->PT<<", eta: "<<jet->Eta<<", phi: "<<jet->Phi<<endl; 194 194 195 195 // Loop over all jet's constituents … … 204 204 { 205 205 particle = (GenParticle*) object; 206 // cout << " GenPart pt: " << particle->PT << ", eta: " << particle->Eta << ", phi: " << particle->Phi << endl;206 // cout << " GenPart pt: " << particle->PT << ", eta: " << particle->Eta << ", phi: " << particle->Phi << endl; 207 207 momentum += particle->P4(); 208 208 } … … 210 210 { 211 211 track = (Track*) object; 212 // cout << " Track pt: " << track->PT << ", eta: " << track->Eta << ", phi: " << track->Phi << endl;212 // cout << " Track pt: " << track->PT << ", eta: " << track->Eta << ", phi: " << track->Phi << endl; 213 213 momentum += track->P4(); 214 214 } … … 216 216 { 217 217 tower = (Tower*) object; 218 // cout << " Tower pt: " << tower->ET << ", eta: " << tower->Eta << ", phi: " << tower->Phi << endl;218 // cout << " Tower pt: " << tower->ET << ", eta: " << tower->Eta << ", phi: " << tower->Phi << endl; 219 219 momentum += tower->P4(); 220 220 } -
examples/Example4.C
r57e1804 rfbb617b 1 1 /* 2 2 3 This macro shows how to compute jet energy scale. 3 This macro shows how to compute jet energy scale. 4 4 root -l examples/Example4.C'("delphes_output.root", "plots.root")' 5 5 6 The output rootfile contains the pT(MC)/pT(Reco) distributions for various pT(Reco) and |eta| bins.7 The peak value of such distribution is interpreted as the jet energy correction to be applied for that given pT(Reco), |eta| bin. 6 The output ROOT file contains the pT(MC)/pT(Reco) distributions for various pT(Reco) and |eta| bins. 7 The peak value of such distribution is interpreted as the jet energy correction to be applied for that given pT(Reco), |eta| bin. 8 8 9 9 This can be done by modifying the "ScaleFormula" input parameter to the JetEnergyScale module in the delphes_card_XXX.tcl … … 15 15 16 16 set ScaleFormula { sqrt(3.0 - 0.1*(abs(eta)))^2 / pt + 1.0 ) } 17 18 17 18 19 19 or a binned function: 20 21 22 set ScaleFormula { (abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 20.0 && pt <= 50.0) * (1.10) + \23 (abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 50.0 && pt <= 100.0) * (1.05) + \24 (abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 100.0) * (1.00) + \25 (abs(eta) > 2.5 && abs(eta) <= 5.0) * (pt > 20.0 && pt <= 50.0) * (1.10) + \26 (abs(eta) > 2.5 && abs(eta) <= 5.0) * (pt > 50.0 && pt <= 100.0) * (1.05) + \20 21 22 set ScaleFormula {(abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 20.0 && pt <= 50.0) * (1.10) + 23 (abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 50.0 && pt <= 100.0) * (1.05) + 24 (abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 100.0) * (1.00) + 25 (abs(eta) > 2.5 && abs(eta) <= 5.0) * (pt > 20.0 && pt <= 50.0) * (1.10) + 26 (abs(eta) > 2.5 && abs(eta) <= 5.0) * (pt > 50.0 && pt <= 100.0) * (1.05) + 27 27 (abs(eta) > 2.5 && abs(eta) <= 5.0) * (pt > 100.0) * (1.00)} 28 28 … … 31 31 32 32 33 33 34 34 */ 35 35 … … 39 39 { 40 40 TH1 *fJetPT; 41 41 42 42 TH1 *fJetRes_Pt_20_50_Eta_0_25; 43 43 TH1 *fJetRes_Pt_20_50_Eta_25_5; … … 72 72 "jet_pt", "p_{T}^{jet}", 73 73 "p_{T}^{jet} GeV/c", "number of jets", 74 100, 0.0, 1000.0); 75 74 100, 0.0, 1000.0); 75 76 76 plots->fJetRes_Pt_20_50_Eta_0_25 = result->AddHist1D( 77 77 "jet_delta_pt_20_50_cen", "p_{T}^{truth,parton}/p_{T}^{jet} , 20 < p_{T} < 50 , 0 < | #eta | < 2.5 ", … … 144 144 145 145 plots->fJetRes_Pt_500_inf_Eta_25_5->SetStats(); 146 146 147 147 148 148 } … … 166 166 TLorentzVector JetMom, GenJetMom, BestGenJetMom; 167 167 168 Float_t Dr; 168 Float_t Dr; 169 169 Float_t pt, eta; 170 170 Long64_t entry; … … 178 178 treeReader->ReadEntry(entry); 179 179 // cout<<"-- New event -- "<<endl; 180 180 181 181 if(entry%500 == 0) cout << "Event number: "<< entry <<endl; 182 182 183 183 // Loop over all reconstructed jets in event 184 184 for(i = 0; i < branchJet->GetEntriesFast(); ++i) 185 185 { 186 186 187 187 jet = (Jet*) branchJet->At(i); 188 188 JetMom = jet-> P4(); 189 189 190 190 plots->fJetPT->Fill(JetMom.Pt()); 191 191 192 192 Dr = 999; 193 193 194 194 // Loop over all hard partons in event 195 195 for(j = 0; j < branchParticle->GetEntriesFast(); ++j) 196 196 { 197 197 198 198 part = (GenParticle*) branchParticle->At(j); 199 199 200 200 GenJetMom = part -> P4(); 201 201 202 202 //this is simply to avoid warnings from initial state particle having infite rapidity ... 203 203 if(GenJetMom.Px() == 0 && GenJetMom.Py() == 0) continue; 204 204 205 205 //take the closest parton candidate 206 206 if( GenJetMom.DeltaR(JetMom) < Dr ) … … 208 208 Dr = GenJetMom.DeltaR(JetMom); 209 209 BestGenJetMom = GenJetMom; 210 } 211 210 } 211 212 212 } 213 213 214 if(Dr < 0.3) 214 if(Dr < 0.3) 215 215 { 216 216 pt = JetMom.Pt(); 217 217 eta = TMath::Abs(JetMom.Eta()); 218 219 218 219 220 220 if( pt > 20.0 && pt < 50.0 && eta > 0.0 && eta < 2.5 ) plots -> fJetRes_Pt_20_50_Eta_0_25->Fill(BestGenJetMom.Pt()/JetMom.Pt()); 221 221 if( pt > 20.0 && pt < 50.0 && eta > 2.5 && eta < 5.0 ) plots -> fJetRes_Pt_20_50_Eta_25_5->Fill(BestGenJetMom.Pt()/JetMom.Pt()); 222 222 223 223 if( pt > 50.0 && pt < 100.0 && eta > 0.0 && eta < 2.5 ) plots -> fJetRes_Pt_50_100_Eta_0_25->Fill(BestGenJetMom.Pt()/JetMom.Pt()); 224 224 if( pt > 50.0 && pt < 100.0 && eta > 2.5 && eta < 5.0 ) plots -> fJetRes_Pt_50_100_Eta_25_5->Fill(BestGenJetMom.Pt()/JetMom.Pt()); 225 225 226 226 if( pt > 100.0 && pt < 200.0 && eta > 0.0 && eta < 2.5 ) plots -> fJetRes_Pt_100_200_Eta_0_25->Fill(BestGenJetMom.Pt()/JetMom.Pt()); 227 227 if( pt > 100.0 && pt < 200.0 && eta > 2.5 && eta < 5.0 ) plots -> fJetRes_Pt_100_200_Eta_25_5->Fill(BestGenJetMom.Pt()/JetMom.Pt()); 228 228 229 229 if( pt > 200.0 && pt < 500.0 && eta > 0.0 && eta < 2.5 ) plots -> fJetRes_Pt_200_500_Eta_0_25->Fill(BestGenJetMom.Pt()/JetMom.Pt()); 230 230 if( pt > 200.0 && pt < 500.0 && eta > 2.5 && eta < 5.0 ) plots -> fJetRes_Pt_200_500_Eta_25_5->Fill(BestGenJetMom.Pt()/JetMom.Pt()); 231 231 232 232 if( pt > 500.0 && eta > 0.0 && eta < 2.5 ) plots -> fJetRes_Pt_500_inf_Eta_0_25->Fill(BestGenJetMom.Pt()/JetMom.Pt()); 233 233 if( pt > 500.0 && eta > 2.5 && eta < 5.0 ) plots -> fJetRes_Pt_500_inf_Eta_25_5->Fill(BestGenJetMom.Pt()/JetMom.Pt()); 234 235 234 235 236 236 } 237 238 239 } 237 238 239 } 240 240 } 241 241 }
Note:
See TracChangeset
for help on using the changeset viewer.