#include "IO/LCReader.h"
#include "IOIMPL/LCFactory.h"
#include "IMPL/LCCollectionVec.h"
#include "IMPL/MCParticleImpl.h"
#include "EVENT/LCEvent.h"
#include "UTIL/LCTOOLS.h"
#include <vector>
Include dependency graph for writeEventTree.C:
Go to the source code of this file.
Functions | |
void | writeEventTree (const char *FILEN) |
void writeEventTree | ( | const char * | FILEN | ) |
Example script for testing the ROOT LCIO dictionary.
writeEventTree: reads *.slcio file and creates a ROOT tree with one branch that hold the complete event
Definition at line 20 of file writeEventTree.C.
00020 { 00021 00022 //just in case this script is executed multiple times 00023 delete gROOT->GetListOfFiles()->FindObject( FILEN ); 00024 delete gROOT->GetListOfCanvases()->FindObject("c1"); 00025 00026 if (!TClassTable::GetDict("IMPL::ReconstructedParticleImpl")) { 00027 unsigned res ; 00028 00029 res = gSystem->Load("$LCIO/lib/liblcio.so"); 00030 res = gSystem->Load("$LCIO/lib/liblcioDict.so"); 00031 } 00032 00033 00034 //--- create a ROOT file, a tree and a branch ... 00035 00036 TFile* file = new TFile( "lcioEventTree.root" , "RECREATE"); 00037 00038 TTree* tree = new TTree( "LCIO" , "lcio event data tree"); 00039 00040 std::string treeName("LCEvent") ; 00041 00042 00043 IMPL::LCEventImpl* treeEvt=0 ; 00044 00045 std::string type("IMPL::LCEventImpl") ; 00046 00047 TBranch* mcpBranch = tree->Branch( treeName.c_str(), 00048 type.c_str(), 00049 (void*) &treeEvt, 00050 1024, // record size 00051 199 // split level 00052 ); 00053 00054 00055 std::cout << " loaded LCIO library and dictionary ... " << std::endl ; 00056 00057 int nEvents = 0 ; 00058 00059 int maxEvt = 10000 ; 00060 00061 IO::LCReader* lcReader = IOIMPL::LCFactory::getInstance()->createLCReader() ; 00062 00063 lcReader->open( FILEN ) ; 00064 00065 00066 //----------- the event loop ----------- 00067 while( (evt = lcReader->readNextEvent()) != 0 && nEvents < maxEvt ) { 00068 00069 if( nEvents < 3 ) // only dump first 3 events 00070 UTIL::LCTOOLS::dumpEvent( evt ) ; 00071 00072 nEvents ++ ; 00073 00074 00075 treeEvt = (IMPL::LCEventImpl*) evt ; 00076 00077 00078 tree->Fill() ; 00079 00080 } 00081 // -------- end of event loop ----------- 00082 00083 file->Write() ; 00084 file->Close() ; 00085 00086 delete file ; 00087 00088 00089 std::cout << std::endl 00090 << " " << nEvents 00091 << " events read from file: " 00092 << FILEN << std::endl ; 00093 00094 00095 lcReader->close() ; 00096 00097 delete lcReader ; 00098 }