Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • readers/DelphesROOT.cpp

    r341014c r94083e7  
    1818
    1919#include <algorithm>
     20#include <stdexcept>
    2021#include <iostream>
     22#include <sstream>
    2123#include <memory>
    22 #include <sstream>
    23 #include <stdexcept>
    2424
    2525#include <map>
    2626#include <vector>
    2727
     28#include <stdlib.h>
    2829#include <signal.h>
    2930#include <stdio.h>
    30 #include <stdlib.h>
    31 
     31
     32#include "TROOT.h"
    3233#include "TApplication.h"
    33 #include "TROOT.h"
    34 
     34
     35#include "TFile.h"
    3536#include "TClonesArray.h"
     37#include "TObjArray.h"
     38#include "TStopwatch.h"
    3639#include "TDatabasePDG.h"
    37 #include "TFile.h"
     40#include "TParticlePDG.h"
    3841#include "TLorentzVector.h"
    39 #include "TObjArray.h"
    40 #include "TParticlePDG.h"
    41 #include "TStopwatch.h"
    42 
     42
     43#include "modules/Delphes.h"
     44#include "classes/DelphesStream.h"
    4345#include "classes/DelphesClasses.h"
    4446#include "classes/DelphesFactory.h"
    45 #include "classes/DelphesStream.h"
    46 #include "modules/Delphes.h"
    47 
     47
     48#include "ExRootAnalysis/ExRootTreeWriter.h"
     49#include "ExRootAnalysis/ExRootTreeReader.h"
     50#include "ExRootAnalysis/ExRootTreeBranch.h"
    4851#include "ExRootAnalysis/ExRootProgressBar.h"
    49 #include "ExRootAnalysis/ExRootTreeBranch.h"
    50 #include "ExRootAnalysis/ExRootTreeReader.h"
    51 #include "ExRootAnalysis/ExRootTreeWriter.h"
     52
     53
    5254
    5355using namespace std;
    5456
    5557//---------------------------------------------------------------------------
     58
    5659
    5760//---------------------------------------------------------------------------
     
    9194  if(argc < 4)
    9295  {
    93     cout << " Usage: " << appName << " config_file"
    94          << " output_file"
    95          << " input_file(s)" << endl;
     96    cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl;
    9697    cout << " config_file - configuration file in Tcl format," << endl;
    9798    cout << " output_file - output file in ROOT format," << endl;
     
    121122
    122123    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
    123 
     124   
    124125    confReader = new ExRootConfReader;
    125126    confReader->ReadFile(argv[1]);
     
    128129    modularDelphes->SetConfReader(confReader);
    129130    modularDelphes->SetTreeWriter(treeWriter);
    130 
     131   
    131132    TChain *chain = new TChain("Delphes");
    132 
     133   
    133134    factory = modularDelphes->GetFactory();
    134135    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
     
    144145      chain->Add(argv[i]);
    145146      ExRootTreeReader *treeReader = new ExRootTreeReader(chain);
    146 
     147     
    147148      inputFile = TFile::Open(argv[i]);
    148149
     
    152153        throw runtime_error(message.str());
    153154      }
    154 
     155     
    155156      numberOfEvents = treeReader->GetEntries();
    156       TClonesArray *branchParticle = treeReader->UseBranch("Particle");
     157      TClonesArray *branchParticle   = treeReader->UseBranch("Particle");
    157158      TClonesArray *branchHepMCEvent = treeReader->UseBranch("Event");
    158 
     159     
    159160      if(numberOfEvents <= 0) continue;
    160161
     
    168169      for(Int_t entry = 0; entry < numberOfEvents && !interrupted; ++entry)
    169170      {
    170 
     171   
    171172        treeReader->ReadEntry(entry);
    172173
    173         // -- TBC need also to include event weights --
    174 
    175         eve = (HepMCEvent *)branchHepMCEvent->At(0);
     174        // -- TBC need also to include event weights -- 
     175       
     176        eve = (HepMCEvent*) branchHepMCEvent->At(0);
    176177        element = static_cast<HepMCEvent *>(branchEvent->NewEntry());
    177 
     178       
    178179        element->Number = eventCounter;
    179180
     
    196197        element->ProcTime = eve->ProcTime;
    197198
    198         for(Int_t j = 0; j < branchParticle->GetEntriesFast(); j++)
    199         {
    200 
    201           gen = (GenParticle *)branchParticle->At(j);
     199        for(Int_t j=0; j < branchParticle->GetEntriesFast(); j++)
     200        {     
     201         
     202          gen = (GenParticle*) branchParticle->At(j);     
    202203          candidate = factory->NewCandidate();
    203204
    204205          candidate->Momentum = gen->P4();
    205           candidate->Position.SetXYZT(gen->X, gen->Y, gen->Z, gen->T * 1.0E3 * c_light);
    206 
     206          candidate->Position.SetXYZT(gen->X, gen->Y, gen->Z, gen->T*1.0E3*c_light);
     207         
    207208          candidate->PID = gen->PID;
    208209          candidate->Status = gen->Status;
    209 
     210     
    210211          candidate->M1 = gen->M1;
    211212          candidate->M2 = gen->M2;
     
    215216
    216217          candidate->Charge = gen->Charge;
    217           candidate->Mass = gen->Mass;
    218 
     218          candidate->Mass   = gen->Mass;
     219   
    219220          allParticleOutputArray->Add(candidate);
    220 
     221 
    221222          pdgCode = TMath::Abs(gen->PID);
    222223
     
    230231          }
    231232        }
    232 
     233       
    233234        modularDelphes->ProcessTask();
    234235
     
    241242        ++eventCounter;
    242243      }
    243 
     244 
    244245      progressBar.Update(eventCounter, eventCounter, kTRUE);
    245246      progressBar.Finish();
    246247
    247248      inputFile->Close();
    248 
     249   
    249250      delete treeReader;
     251     
    250252    }
    251253
     
    260262    delete outputFile;
    261263    delete chain;
    262 
     264   
    263265    return 0;
    264266  }
Note: See TracChangeset for help on using the changeset viewer.