Version 4 (modified by 12 years ago) ( diff ) | ,
---|
#include "TROOT.h" #include "TApplication.h" #include "TObjArray.h" #include "TLorentzVector.h" #include "ExRootAnalysis/ExRootFactory.h" #include "ExRootAnalysis/ExRootAnalysis.h" #include "ExRootAnalysis/ExRootCandidate.h" void ConvertEvent(ExRootFactory *factory, TObjArray *outputArray); int main() { // Declaration of variables ExRootConfReader *confReader; ExRootAnalysis *modularDelphes; ExRootFactory *factory; TObjArray *outputArray; gROOT->SetBatch(); int appargc = 1; char *appargv[] = {appName}; TApplication app(appName, &appargc, appargv); try { // Initialization confReader = new ExRootConfReader; confReader->ReadFile("delphes_card.tcl"); modularDelphes = new ExRootAnalysis("Delphes"); modularDelphes->SetConfReader(confReader); modularDelphes->SetTreeWriter(treeWriter); factory = modularDelphes->GetFactory(); outputArray = modularDelphes->NewArray("candidates"); modularDelphes->InitTask(); // Event loop while(ReadEvent()) { modularDelphes->Clear(); ConvertEvent(factory, outputArray); modularDelphes->ProcessTask(); ReadResults(modularDelphes); } // Finalisation modularDelphes->FinishTask(); delete modularDelphes; delete confReader; } catch(runtime_error &e) { if(outputFile) delete outputFile; cerr << "** ERROR: " << e.what() << endl; return 1; } } void ConvertEvent(ExRootFactory *factory, TObjArray *outputArray) { ExRootCandidate *candidate; TLorentzVector candidateMomentum, candidatePosition; Int_t pid, status; Double_t px, py, pz, e, m; Double_t x, y, z, t; while(ReadParticle()) { if(status == 1) { candidate = factory->NewCandidate(); candidate->SetType(pid); candidateMomentum.SetPxPyPzE(px, py, pz, e); candidate->SetMomentum(candidateMomentum); candidatePosition.SetXYZT(x, y, z, t); candidate->SetPosition(candidatePosition); outputArray->Add(candidate); } } }
Note:
See TracWiki
for help on using the wiki.