Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • readers/DelphesROOT.cpp

    r94083e7 r341014c  
    1818
    1919#include <algorithm>
     20#include <iostream>
     21#include <memory>
     22#include <sstream>
    2023#include <stdexcept>
    21 #include <iostream>
    22 #include <sstream>
    23 #include <memory>
    2424
    2525#include <map>
    2626#include <vector>
    2727
    28 #include <stdlib.h>
    2928#include <signal.h>
    3029#include <stdio.h>
    31 
     30#include <stdlib.h>
     31
     32#include "TApplication.h"
    3233#include "TROOT.h"
    33 #include "TApplication.h"
    34 
     34
     35#include "TClonesArray.h"
     36#include "TDatabasePDG.h"
    3537#include "TFile.h"
    36 #include "TClonesArray.h"
     38#include "TLorentzVector.h"
    3739#include "TObjArray.h"
     40#include "TParticlePDG.h"
    3841#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
    4543#include "classes/DelphesClasses.h"
    4644#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"
    4851#include "ExRootAnalysis/ExRootTreeWriter.h"
    49 #include "ExRootAnalysis/ExRootTreeReader.h"
    50 #include "ExRootAnalysis/ExRootTreeBranch.h"
    51 #include "ExRootAnalysis/ExRootProgressBar.h"
    52 
    53 
    5452
    5553using namespace std;
    5654
    5755//---------------------------------------------------------------------------
    58 
    5956
    6057//---------------------------------------------------------------------------
     
    9491  if(argc < 4)
    9592  {
    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;
    9796    cout << " config_file - configuration file in Tcl format," << endl;
    9897    cout << " output_file - output file in ROOT format," << endl;
     
    122121
    123122    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
    124    
     123
    125124    confReader = new ExRootConfReader;
    126125    confReader->ReadFile(argv[1]);
     
    129128    modularDelphes->SetConfReader(confReader);
    130129    modularDelphes->SetTreeWriter(treeWriter);
    131    
     130
    132131    TChain *chain = new TChain("Delphes");
    133    
     132
    134133    factory = modularDelphes->GetFactory();
    135134    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
     
    145144      chain->Add(argv[i]);
    146145      ExRootTreeReader *treeReader = new ExRootTreeReader(chain);
    147      
     146
    148147      inputFile = TFile::Open(argv[i]);
    149148
     
    153152        throw runtime_error(message.str());
    154153      }
    155      
     154
    156155      numberOfEvents = treeReader->GetEntries();
    157       TClonesArray *branchParticle   = treeReader->UseBranch("Particle");
     156      TClonesArray *branchParticle = treeReader->UseBranch("Particle");
    158157      TClonesArray *branchHepMCEvent = treeReader->UseBranch("Event");
    159      
     158
    160159      if(numberOfEvents <= 0) continue;
    161160
     
    169168      for(Int_t entry = 0; entry < numberOfEvents && !interrupted; ++entry)
    170169      {
    171    
     170
    172171        treeReader->ReadEntry(entry);
    173172
    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);
    177176        element = static_cast<HepMCEvent *>(branchEvent->NewEntry());
    178        
     177
    179178        element->Number = eventCounter;
    180179
     
    197196        element->ProcTime = eve->ProcTime;
    198197
    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);
    203202          candidate = factory->NewCandidate();
    204203
    205204          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
    208207          candidate->PID = gen->PID;
    209208          candidate->Status = gen->Status;
    210      
     209
    211210          candidate->M1 = gen->M1;
    212211          candidate->M2 = gen->M2;
     
    216215
    217216          candidate->Charge = gen->Charge;
    218           candidate->Mass   = gen->Mass;
    219    
     217          candidate->Mass = gen->Mass;
     218
    220219          allParticleOutputArray->Add(candidate);
    221  
     220
    222221          pdgCode = TMath::Abs(gen->PID);
    223222
     
    231230          }
    232231        }
    233        
     232
    234233        modularDelphes->ProcessTask();
    235234
     
    242241        ++eventCounter;
    243242      }
    244  
     243
    245244      progressBar.Update(eventCounter, eventCounter, kTRUE);
    246245      progressBar.Finish();
    247246
    248247      inputFile->Close();
    249    
     248
    250249      delete treeReader;
    251      
    252250    }
    253251
     
    262260    delete outputFile;
    263261    delete chain;
    264    
     262
    265263    return 0;
    266264  }
Note: See TracChangeset for help on using the changeset viewer.