00001
00002
00003
00004 #ifndef __CINT__
00005 #include "IO/LCReader.h"
00006 #include "IOIMPL/LCFactory.h"
00007 #include "EVENT/MCParticle.h"
00008 #include "EVENT/LCCollection.h"
00009 #include "IMPL/LCEventImpl.h"
00010 #include "UTIL/LCTOOLS.h"
00011 #endif
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 void readEventTree(const char* FILEN) {
00023
00024
00025 delete gROOT->GetListOfFiles()->FindObject( FILEN );
00026 delete gROOT->GetListOfCanvases()->FindObject("c1");
00027
00028 if (!TClassTable::GetDict("IMPL::ReconstructedParticleImpl")) {
00029 unsigned res ;
00030
00031 res = gSystem->Load("$LCIO/lib/liblcio.so");
00032 res = gSystem->Load("$LCIO/lib/liblcioDict.so");
00033 }
00034
00035
00036 std::cout << " loaded LCIO library and dictionary ... " << std::endl ;
00037
00038
00039
00040
00041 TFile* f = new TFile( FILEN, "READ") ;
00042 if (!f) { return; }
00043
00044 TTree *t; f->GetObject("LCIO",t);
00045
00046 IMPL::LCEventImpl* evt=0 ;
00047 TBranch* bevt = t->GetBranch("LCEvent") ;
00048
00049 if( bevt ){
00050
00051 bevt->SetAddress( &evt ) ;
00052
00053 } else {
00054
00055 std::cout << " --- branch 'LCEvent' not found ;-( " << std::endl ;
00056 }
00057
00058
00059
00060
00061 TH1F* h_mcpEner = new TH1F("h_mcpEner","MCParticles E(GeV) ", 100, 0. , 100. ) ;
00062
00063 std::string mcpName("MCParticlesSkimmed") ;
00064
00065
00066 int nEvents = 0 ;
00067
00068 int nevt = t->GetEntries();
00069
00070 for (Int_t i = 0; i < nevt ; i++) {
00071
00072 Long64_t tentry = t->LoadTree(i);
00073
00074 int nbyte = bevt->GetEntry(tentry);
00075
00076
00077
00078
00079
00080
00081 UTIL::LCTOOLS::dumpEvent( evt ) ;
00082
00083
00084 EVENT::LCCollection* col = evt->getCollection( mcpName ) ;
00085
00086 int nMcp = col->getNumberOfElements() ;
00087 for( int j = 0 ; j < nMcp ; ++j ) {
00088
00089 EVENT::MCParticle* mcp = (EVENT::MCParticle*) col->getElementAt(j) ;
00090
00091 h_mcpEner->Fill( mcp->getEnergy() ) ;
00092
00093 }
00094
00095 nEvents ++ ;
00096
00097 }
00098
00099
00100
00101 std::cout << std::endl
00102 << " " << nEvents
00103 << " events read from file: "
00104 << FILEN << std::endl ;
00105
00106
00107
00108
00109
00110
00111
00112 TCanvas *c1 = new TCanvas("c1","LCIO root example",200,10,700,500);
00113
00114 c1->cd(1) ;
00115 h_mcpEner->Draw();
00116
00117 }