diff --git a/UtilityApps/src/next_event_lcio.cpp b/UtilityApps/src/next_event_lcio.cpp index 43b024de22438fdb25cbcadd81ae8fa401ad361d..e5648e40a18d6bdccd42a13f7e7ec5f72c883fc0 100644 --- a/UtilityApps/src/next_event_lcio.cpp +++ b/UtilityApps/src/next_event_lcio.cpp @@ -23,123 +23,123 @@ using namespace lcio; template <class T> TEveElement* createPointSet( lcio::LCCollection* col, const std::string& name, unsigned color=kMagenta, unsigned size=1, unsigned style=4 ) ; - //===================================================================================== - - /**Helper class for printing LCIO objects from TEve - */ - template <class T> - class LCIOTObject : public TObject{ - const T* _obj ; - LCIOTObject() {} - public: - LCIOTObject( const T* o) : _obj(o) {} - void Print() { - std::cout << *_obj ; - } - } ; +//===================================================================================== + +/**Helper class for printing LCIO objects from TEve + */ +template <class T> +class LCIOTObject : public TObject{ + const T* _obj ; + LCIOTObject() {} +public: + LCIOTObject( const T* o) : _obj(o) {} + void Print() { + std::cout << *_obj ; + } +} ; - void next_event(){ +void next_event(){ - static int count = 1 ; + static int count = 1 ; - static LCReader* rdr = 0 ; + static LCReader* rdr = 0 ; - std::string lcioFileName = "teve_infile.slcio" ; + std::string lcioFileName = "teve_infile.slcio" ; - if( rdr == 0 ){ - rdr = LCFactory::getInstance()->createLCReader() ; - rdr->open( lcioFileName ) ; - } + if( rdr == 0 ){ + rdr = LCFactory::getInstance()->createLCReader() ; + rdr->open( lcioFileName ) ; + } - std::cout << " next_event_lcio called ..." << std::endl ; + std::cout << " next_event_lcio called ..." << std::endl ; - TEveElementList* tevent = (TEveElementList* ) gEve->GetCurrentEvent() ; + TEveElementList* tevent = (TEveElementList* ) gEve->GetCurrentEvent() ; - if( tevent ) - tevent->DestroyElements() ; + if( tevent ) + tevent->DestroyElements() ; - LCEvent* evt = rdr->readNextEvent() ; + LCEvent* evt = rdr->readNextEvent() ; - if( evt != 0 ){ + if( evt != 0 ){ - const std::vector< std::string >& colNames = * evt->getCollectionNames() ; + const std::vector< std::string >& colNames = * evt->getCollectionNames() ; - for(unsigned icol=0, ncol = colNames.size() ; icol < ncol ; ++icol ){ + for(unsigned icol=0, ncol = colNames.size() ; icol < ncol ; ++icol ){ - LCCollection* col = evt->getCollection( colNames[ icol ] ) ; + LCCollection* col = evt->getCollection( colNames[ icol ] ) ; - std::cout << " **** reading collection " << colNames[ icol ] << std::endl ; + std::cout << " **** reading collection " << colNames[ icol ] << std::endl ; - if( col->getTypeName() == LCIO::SIMTRACKERHIT ){ + if( col->getTypeName() == LCIO::SIMTRACKERHIT ){ - MultiView::instance()->ImportEvent( createPointSet<EVENT::SimTrackerHit>( col , colNames[ icol ] , kMagenta+2 , 1 , 4 ) ) ; - } - else if( col->getTypeName() == LCIO::SIMCALORIMETERHIT ){ + MultiView::instance()->ImportEvent( createPointSet<EVENT::SimTrackerHit>( col , colNames[ icol ] , kMagenta+2 , 1 , 4 ) ) ; + } + else if( col->getTypeName() == LCIO::SIMCALORIMETERHIT ){ - MultiView::instance()->ImportEvent( createPointSet<EVENT::SimCalorimeterHit>( col , colNames[ icol ] , kMagenta+4 , 1 , 4 ) ) ; - } - else if( col->getTypeName() == LCIO::TRACKERHIT ){ + MultiView::instance()->ImportEvent( createPointSet<EVENT::SimCalorimeterHit>( col , colNames[ icol ] , kMagenta+4 , 1 , 4 ) ) ; + } + else if( col->getTypeName() == LCIO::TRACKERHIT ){ - MultiView::instance()->ImportEvent( createPointSet<EVENT::TrackerHit>( col , colNames[ icol ] , kBlue+2 , 1 , 4 ) ) ; - } - else if( col->getTypeName() == LCIO::CALORIMETERHIT ){ + MultiView::instance()->ImportEvent( createPointSet<EVENT::TrackerHit>( col , colNames[ icol ] , kBlue+2 , 1 , 4 ) ) ; + } + else if( col->getTypeName() == LCIO::CALORIMETERHIT ){ - MultiView::instance()->ImportEvent( createPointSet<EVENT::CalorimeterHit>( col , colNames[ icol ] , kBlue+4 , 1 , 4 ) ) ; - } - + MultiView::instance()->ImportEvent( createPointSet<EVENT::CalorimeterHit>( col , colNames[ icol ] , kBlue+4 , 1 , 4 ) ) ; } + + } - } else{ + } else{ - std::cout << "WARNING: can't read LCEvent from input file ! " << std::endl ; - } + std::cout << "WARNING: can't read LCEvent from input file ! " << std::endl ; + } - gEve->Redraw3D(); + gEve->Redraw3D(); - count += 3 ; - } + count += 3 ; +} - //===================================================================================== - template <class T> - TEveElement* createPointSet( lcio::LCCollection* col, const std::string& name, unsigned color, unsigned size, unsigned style ) { +//===================================================================================== +template <class T> +TEveElement* createPointSet( lcio::LCCollection* col, const std::string& name, unsigned color, unsigned size, unsigned style ) { - TEvePointSet* ps = new TEvePointSet( name.c_str() ); - ps->SetOwnIds(kTRUE); + TEvePointSet* ps = new TEvePointSet( name.c_str() ); + ps->SetOwnIds(kTRUE); - int nHit = col->getNumberOfElements() ; + int nHit = col->getNumberOfElements() ; - for( int i=0 ; i< nHit ; ++i ){ + for( int i=0 ; i< nHit ; ++i ){ - T* hit = (T*) col->getElementAt( i ) ; + T* hit = (T*) col->getElementAt( i ) ; - double pos[3] = { hit->getPosition()[0], hit->getPosition()[1] , hit->getPosition()[2] } ; - // pos[0] = hit->getPosition()[0] ; - // pos[1] = hit->getPosition()[1] ; - // pos[2] = hit->getPosition()[2] ; + double pos[3] = { hit->getPosition()[0], hit->getPosition()[1] , hit->getPosition()[2] } ; + // pos[0] = hit->getPosition()[0] ; + // pos[1] = hit->getPosition()[1] ; + // pos[2] = hit->getPosition()[2] ; - ps->SetNextPoint( pos[0]*tgeo::mm , pos[1]*tgeo::mm, pos[2]*tgeo::mm ); + ps->SetNextPoint( pos[0]*tgeo::mm , pos[1]*tgeo::mm, pos[2]*tgeo::mm ); - int id[2] ; - id[0] = hit->getCellID0() ; - id[1] = hit->getCellID1() ; + int id[2] ; + id[0] = hit->getCellID0() ; + id[1] = hit->getCellID1() ; - ps->SetPointIntIds( id ) ; - // does work for the point itself ... - // ps->SetSourceObject( new LCIOTObject<T>( hit ) ) ; - } + ps->SetPointIntIds( id ) ; + // does work for the point itself ... + // ps->SetSourceObject( new LCIOTObject<T>( hit ) ) ; + } - ps->SetMarkerColor( color ) ; - ps->SetMarkerSize( size ); - ps->SetMarkerStyle( style ); + ps->SetMarkerColor( color ) ; + ps->SetMarkerSize( size ); + ps->SetMarkerStyle( style ); - return ps; + return ps; - } - //===================================================================================== +} +//=====================================================================================