Changes in readers/DelphesROOT.cpp [94083e7:341014c] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
readers/DelphesROOT.cpp
r94083e7 r341014c 18 18 19 19 #include <algorithm> 20 #include <iostream> 21 #include <memory> 22 #include <sstream> 20 23 #include <stdexcept> 21 #include <iostream>22 #include <sstream>23 #include <memory>24 24 25 25 #include <map> 26 26 #include <vector> 27 27 28 #include <stdlib.h>29 28 #include <signal.h> 30 29 #include <stdio.h> 31 30 #include <stdlib.h> 31 32 #include "TApplication.h" 32 33 #include "TROOT.h" 33 #include "TApplication.h" 34 34 35 #include "TClonesArray.h" 36 #include "TDatabasePDG.h" 35 37 #include "TFile.h" 36 #include "T ClonesArray.h"38 #include "TLorentzVector.h" 37 39 #include "TObjArray.h" 40 #include "TParticlePDG.h" 38 41 #include "TStopwatch.h" 39 #include "TDatabasePDG.h" 40 #include "TParticlePDG.h" 41 #include "TLorentzVector.h" 42 43 #include "modules/Delphes.h" 44 #include "classes/DelphesStream.h" 42 45 43 #include "classes/DelphesClasses.h" 46 44 #include "classes/DelphesFactory.h" 47 45 #include "classes/DelphesStream.h" 46 #include "modules/Delphes.h" 47 48 #include "ExRootAnalysis/ExRootProgressBar.h" 49 #include "ExRootAnalysis/ExRootTreeBranch.h" 50 #include "ExRootAnalysis/ExRootTreeReader.h" 48 51 #include "ExRootAnalysis/ExRootTreeWriter.h" 49 #include "ExRootAnalysis/ExRootTreeReader.h"50 #include "ExRootAnalysis/ExRootTreeBranch.h"51 #include "ExRootAnalysis/ExRootProgressBar.h"52 53 54 52 55 53 using namespace std; 56 54 57 55 //--------------------------------------------------------------------------- 58 59 56 60 57 //--------------------------------------------------------------------------- … … 94 91 if(argc < 4) 95 92 { 96 cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl; 93 cout << " Usage: " << appName << " config_file" 94 << " output_file" 95 << " input_file(s)" << endl; 97 96 cout << " config_file - configuration file in Tcl format," << endl; 98 97 cout << " output_file - output file in ROOT format," << endl; … … 122 121 123 122 branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class()); 124 123 125 124 confReader = new ExRootConfReader; 126 125 confReader->ReadFile(argv[1]); … … 129 128 modularDelphes->SetConfReader(confReader); 130 129 modularDelphes->SetTreeWriter(treeWriter); 131 130 132 131 TChain *chain = new TChain("Delphes"); 133 132 134 133 factory = modularDelphes->GetFactory(); 135 134 allParticleOutputArray = modularDelphes->ExportArray("allParticles"); … … 145 144 chain->Add(argv[i]); 146 145 ExRootTreeReader *treeReader = new ExRootTreeReader(chain); 147 146 148 147 inputFile = TFile::Open(argv[i]); 149 148 … … 153 152 throw runtime_error(message.str()); 154 153 } 155 154 156 155 numberOfEvents = treeReader->GetEntries(); 157 TClonesArray *branchParticle 156 TClonesArray *branchParticle = treeReader->UseBranch("Particle"); 158 157 TClonesArray *branchHepMCEvent = treeReader->UseBranch("Event"); 159 158 160 159 if(numberOfEvents <= 0) continue; 161 160 … … 169 168 for(Int_t entry = 0; entry < numberOfEvents && !interrupted; ++entry) 170 169 { 171 170 172 171 treeReader->ReadEntry(entry); 173 172 174 // -- TBC need also to include event weights -- 175 176 eve = (HepMCEvent *)branchHepMCEvent->At(0);173 // -- TBC need also to include event weights -- 174 175 eve = (HepMCEvent *)branchHepMCEvent->At(0); 177 176 element = static_cast<HepMCEvent *>(branchEvent->NewEntry()); 178 177 179 178 element->Number = eventCounter; 180 179 … … 197 196 element->ProcTime = eve->ProcTime; 198 197 199 for(Int_t j =0; j < branchParticle->GetEntriesFast(); j++)200 { 201 202 gen = (GenParticle *) branchParticle->At(j);198 for(Int_t j = 0; j < branchParticle->GetEntriesFast(); j++) 199 { 200 201 gen = (GenParticle *)branchParticle->At(j); 203 202 candidate = factory->NewCandidate(); 204 203 205 204 candidate->Momentum = gen->P4(); 206 candidate->Position.SetXYZT(gen->X, gen->Y, gen->Z, gen->T *1.0E3*c_light);207 205 candidate->Position.SetXYZT(gen->X, gen->Y, gen->Z, gen->T * 1.0E3 * c_light); 206 208 207 candidate->PID = gen->PID; 209 208 candidate->Status = gen->Status; 210 209 211 210 candidate->M1 = gen->M1; 212 211 candidate->M2 = gen->M2; … … 216 215 217 216 candidate->Charge = gen->Charge; 218 candidate->Mass 219 217 candidate->Mass = gen->Mass; 218 220 219 allParticleOutputArray->Add(candidate); 221 220 222 221 pdgCode = TMath::Abs(gen->PID); 223 222 … … 231 230 } 232 231 } 233 232 234 233 modularDelphes->ProcessTask(); 235 234 … … 242 241 ++eventCounter; 243 242 } 244 243 245 244 progressBar.Update(eventCounter, eventCounter, kTRUE); 246 245 progressBar.Finish(); 247 246 248 247 inputFile->Close(); 249 248 250 249 delete treeReader; 251 252 250 } 253 251 … … 262 260 delete outputFile; 263 261 delete chain; 264 262 265 263 return 0; 266 264 }
Note:
See TracChangeset
for help on using the changeset viewer.