- Timestamp:
- Jun 3, 2015, 8:55:11 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 8d200a6
- Parents:
- 986d9d5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
readers/DelphesPythia8.cpp
r986d9d5 rcd616b9 20 20 #include <iostream> 21 21 #include <sstream> 22 #include <string> 22 23 23 24 #include <signal.h> … … 38 39 #include "classes/DelphesClasses.h" 39 40 #include "classes/DelphesFactory.h" 41 #include "classes/DelphesLHEFReader.h" 40 42 41 43 #include "ExRootAnalysis/ExRootTreeWriter.h" … … 149 151 char appName[] = "DelphesPythia8"; 150 152 stringstream message; 153 FILE *inputFile = 0; 151 154 TFile *outputFile = 0; 152 155 TStopwatch readStopWatch, procStopWatch; 153 156 ExRootTreeWriter *treeWriter = 0; 154 157 ExRootTreeBranch *branchEvent = 0; 158 ExRootTreeBranch *branchEventLHEF = 0, *branchRwgtLHEF = 0; 155 159 ExRootConfReader *confReader = 0; 156 160 Delphes *modularDelphes = 0; 157 161 DelphesFactory *factory = 0; 158 162 TObjArray *stableParticleOutputArray = 0, *allParticleOutputArray = 0, *partonOutputArray = 0; 163 TObjArray *stableParticleOutputArrayLHEF = 0, *allParticleOutputArrayLHEF = 0, *partonOutputArrayLHEF = 0; 164 DelphesLHEFReader *reader = 0; 159 165 Long64_t eventCounter, errorCounter; 160 166 Long64_t numberOfEvents, timesAllowErrors; … … 207 213 modularDelphes->InitTask(); 208 214 209 // Initialize pythia215 // Initialize Pythia 210 216 pythia = new Pythia8::Pythia; 211 217 … … 221 227 numberOfEvents = pythia->mode("Main:numberOfEvents"); 222 228 timesAllowErrors = pythia->mode("Main:timesAllowErrors"); 229 230 inputFile = fopen(pythia->word("Beams:LHEF").c_str(), "r"); 231 if(inputFile) 232 { 233 reader = new DelphesLHEFReader; 234 reader->SetInputFile(inputFile); 235 236 branchEventLHEF = treeWriter->NewBranch("EventLHEF", LHEFEvent::Class()); 237 branchRwgtLHEF = treeWriter->NewBranch("RwgtLHEF", Weight::Class()); 238 239 allParticleOutputArrayLHEF = modularDelphes->ExportArray("allParticlesLHEF"); 240 stableParticleOutputArrayLHEF = modularDelphes->ExportArray("stableParticlesLHEF"); 241 partonOutputArrayLHEF = modularDelphes->ExportArray("partonsLHEF"); 242 } 223 243 224 244 pythia->init(); … … 234 254 for(eventCounter = 0; eventCounter < numberOfEvents && !interrupted; ++eventCounter) 235 255 { 256 while(reader && reader->ReadBlock(factory, allParticleOutputArrayLHEF, 257 stableParticleOutputArrayLHEF, partonOutputArrayLHEF) && !reader->EventReady()); 258 236 259 if(!pythia->next()) 237 260 { 238 261 // If failure because reached end of file then exit event loop 239 if 262 if(pythia->info.atEndOfFile()) 240 263 { 241 264 cerr << "Aborted since reached end of Les Houches Event File" << endl; … … 244 267 245 268 // First few failures write off as "acceptable" errors, then quit 246 if (++errorCounter < timesAllowErrors) continue; 247 cerr << "Event generation aborted prematurely, owing to error!" << endl; 248 break; 269 if(++errorCounter > timesAllowErrors) 270 { 271 cerr << "Event generation aborted prematurely, owing to error!" << endl; 272 break; 273 } 274 275 modularDelphes->Clear(); 276 reader->Clear(); 277 continue; 249 278 } 250 279 … … 258 287 procStopWatch.Stop(); 259 288 289 if(reader) 290 { 291 reader->AnalyzeEvent(branchEventLHEF, eventCounter, &readStopWatch, &procStopWatch); 292 reader->AnalyzeRwgt(branchRwgtLHEF); 293 } 294 260 295 treeWriter->Fill(); 261 296 262 297 treeWriter->Clear(); 263 298 modularDelphes->Clear(); 299 if(reader) reader->Clear(); 264 300 265 301 readStopWatch.Start(); … … 277 313 cout << "** Exiting..." << endl; 278 314 315 delete reader; 279 316 delete pythia; 280 317 delete modularDelphes;
Note:
See TracChangeset
for help on using the changeset viewer.