Print

Print


Commit in lcio/src/cpp on rio_v00-00
CMakeLists.txt+2-11.22.2.4 -> 1.22.2.5
include/IMPL/LCEventImpl.h+21.19.8.2 -> 1.19.8.3
include/IOIMPL/LCFactory.h+4-21.3.2.1 -> 1.3.2.2
include/RIO/RIOLCCollectionHandler.h+104-571.1.2.1 -> 1.1.2.2
           /RIOReader.h+2-21.1.2.2 -> 1.1.2.3
include/UTIL/LCIOTypeInfo.h+20-421.2 -> 1.2.12.1
src/IMPL/LCEventImpl.cc+21-81.24 -> 1.24.8.1
        /MCParticleImpl.cc+11.29 -> 1.29.6.1
src/IOIMPL/LCFactory.cc+40-101.3.2.1 -> 1.3.2.2
src/RIO/RIOReader.cc+42-741.1.2.3 -> 1.1.2.4
       /RIOWriter.cc+16-161.1.2.1 -> 1.1.2.2
+254-212
11 modified files
switched to store LCCollectionVecs (vector<LCObject*>)
introduced $LCIO_IO_TYPE={'ss','sr','rs','rr'} for selection SIO/RIO Reader/Writer
bug fix in LCIOTypeInfo: moved specializations into .cc file
status: simjob and anajob work for rootio/DST01-06_ppr004_bbcsdu.slcio (not for simjob!?)

lcio/src/cpp
CMakeLists.txt 1.22.2.4 -> 1.22.2.5
diff -u -r1.22.2.4 -r1.22.2.5
--- CMakeLists.txt	15 Sep 2009 08:06:22 -0000	1.22.2.4
+++ CMakeLists.txt	15 Sep 2009 15:45:00 -0000	1.22.2.5
@@ -119,6 +119,7 @@
   ./src/UTIL/CellIDEncoder.cc
   ./src/UTIL/CollectionParameterMap.cc
   ./src/UTIL/PIDHandler.cc
+  ./src/UTIL/LCIOTypeInfo.cc
 )
 
 
@@ -173,7 +174,7 @@
     OUTPUT_NAME lcio
 )
 
-TARGET_LINK_LIBRARIES( lib_LCIO ${ROOT_LIBRARIES} )
+# - needed for apple ??? ---  TARGET_LINK_LIBRARIES( lib_LCIO ${ROOT_LIBRARIES} )
 TARGET_LINK_LIBRARIES( lib_LCIO lib_SIO )
 TARGET_LINK_LIBRARIES( lib_LCIOF77 lib_LCIO )
 

lcio/src/cpp/include/IMPL
LCEventImpl.h 1.19.8.2 -> 1.19.8.3
diff -u -r1.19.8.2 -r1.19.8.3
--- LCEventImpl.h	15 Sep 2009 08:06:22 -0000	1.19.8.2
+++ LCEventImpl.h	15 Sep 2009 15:45:00 -0000	1.19.8.3
@@ -65,6 +65,8 @@
      */
     virtual const std::vector<std::string>  * getCollectionNames() const;
     
+    virtual const std::vector<std::string>  * getCollectionNames(bool refresh) const;
+
     /** Returns the collection for the given name.
      *
      * @throws DataNotAvailableException

lcio/src/cpp/include/IOIMPL
LCFactory.h 1.3.2.1 -> 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- LCFactory.h	14 Sep 2009 13:50:48 -0000	1.3.2.1
+++ LCFactory.h	15 Sep 2009 15:45:00 -0000	1.3.2.2
@@ -46,8 +46,10 @@
 
 
   private:
-  
-    static LCFactory * _me ;
+    
+    //    static LCFactory * _me ;
+    char  _readerType ;
+    char  _writerType ;
 
   }; // class
 } // namespace IOIMPL

lcio/src/cpp/include/RIO
RIOLCCollectionHandler.h 1.1.2.1 -> 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- RIOLCCollectionHandler.h	14 Sep 2009 13:50:48 -0000	1.1.2.1
+++ RIOLCCollectionHandler.h	15 Sep 2009 15:45:00 -0000	1.1.2.2
@@ -5,9 +5,11 @@
 #include "EVENT/LCEvent.h"
 
 #include "IMPL/LCCollectionVec.h"
-#include "UTIL/LCTypedVector.h"
+
+#include "UTIL/LCIOTypeInfo.h" //fixme: LCIOTypeInfo should not be in UTIL !?
 
 #include "TTree.h"
+#include <vector>
 
 
 namespace RIO{
@@ -20,7 +22,7 @@
     
     virtual void toBranch( const EVENT::LCEvent* evt )=0 ;
     
-    virtual void fromBranch( EVENT::LCEvent* evt )=0 ;
+    virtual void fromBranch( EVENT::LCEvent* evt , int entryID )=0 ;
     
   } ;
   
@@ -29,63 +31,65 @@
   /** Branch handler class for (typed) LCCollections.
    */
   
-  template <typename T>
+  //  template <typename T>
   class RIOLCCollectionHandler : public RIOBranchHandler{
     
   protected:
     
     std::string _name ;
-    std::vector<T*>* _tv  ;
-    IMPL::LCParametersImpl* _params ;
+    std::string _type ;
+    
+    //     std::vector<T*>* _tv  ;
+    //     IMPL::LCParametersImpl* _params ;
+    
+    TBranch* _br ;
+    IMPL::LCCollectionVec* _tv ;
+    
     
   public: 
     
     /** C'tor.
      */
-    RIOLCCollectionHandler(const char* name,  TTree* tree ) : 
-
-      _name(name) {
+    RIOLCCollectionHandler(const std::string& name, const std::string& type,  TTree* tree ) : 
+      _name(name),
+      _type(type) {
       
-       std::cout << "  RIOLCCollectionHandler( " << name << ", " << tree << ")" << std::endl ;
-
-      _tv = new std::vector<T*> ;      
-
-      TBranch* br = (TBranch*) tree->GetBranch( name ) ;
+      std::cout << "  RIOLCCollectionHandler( " << name << ", " << tree << ")" << std::endl ;
+      
+      //      _tv = 0 ; //IMPL::LCCollectionVec ; // new std::vector<T*> ;      
+      _tv = new IMPL::LCCollectionVec( type  )  ;
       
-      if( br != 0 ){  // branch allready exists -> update/append  mode 
+      _br = (TBranch*) tree->GetBranch( _name.c_str() ) ;
+      
+      if( _br != 0 ){  // branch allready exists -> update/append  mode 
 	
-	br->SetAddress( &_tv ) ;
+	_br->SetAddress( &_tv ) ;
 	
       } else {
 	
 	//FIXME: make split level and 'record size' parameters ....
-	tree->Branch( name  , &_tv, 16000, 2 );
+	tree->Branch( _name.c_str()  , &_tv, 16000, 2 );
       }
       
-
-      _params = 0 ; //new IMPL::LCParametersImpl ;
       
-      std::string pName(name) ; 
-
-      pName += "_param" ;
-
-      br = (TBranch*) tree->GetBranch( pName.c_str() ) ;
+      //       _params = 0 ; //new IMPL::LCParametersImpl ;
       
-      if( br != 0 ){  // branch allready exists -> update/append  mode 
-	
-	br->SetAddress( &_params ) ;
-	
-      } else {
-	
-	//FIXME: make split level and 'record size' parameters ....
-	tree->Branch( pName.c_str()  , &_params, 16000, 2 );
-      }
+      //       std::string pName(name) ; 
+      
+      //       pName += "_param" ;
+      
+      //       br = (TBranch*) tree->GetBranch( pName.c_str() ) ;
+      
+      //       if( br != 0 ){  // branch allready exists -> update/append  mode 
+      
+      // 	br->SetAddress( &_params ) ;
+      
+      //       } else {
+      
+      // 	//FIXME: make split level and 'record size' parameters ....
+      // 	tree->Branch( pName.c_str()  , &_params, 16000, 2 );
+      //       }
       
-
-
-
-
-
 
     }
     
@@ -93,49 +97,92 @@
 
     virtual void toBranch( const EVENT::LCEvent* evt ){
       
-      _tv->clear() ;
+//       _tv->clear() ;
       
-      try{
+//       try{
 	
-	EVENT::LCCollection* col =  evt->getCollection( _name ) ;
+// 	EVENT::LCCollection* col =  evt->getCollection( _name ) ;
 	
-	int n = col->getNumberOfElements() ;
+// 	int n = col->getNumberOfElements() ;
 	
-	_tv->resize( n ) ;
+// 	_tv->resize( n ) ;
 	
-	for( int i=0; i<n ; ++i){
+// 	for( int i=0; i<n ; ++i){
 	  
-	  (*_tv)[i] = dynamic_cast<T*>( col->getElementAt(i) )  ;
-	}
+// 	  (*_tv)[i] = dynamic_cast<T*>( col->getElementAt(i) )  ;
+// 	}
 	
 
-	IMPL::LCParametersImpl* lcp =  dynamic_cast<IMPL::LCParametersImpl*> ( & col->parameters() ) ; 
-	_params = lcp ;
+// 	IMPL::LCParametersImpl* lcp =  dynamic_cast<IMPL::LCParametersImpl*> ( & col->parameters() ) ; 
+// 	_params = lcp ;
+
 
+// 	//FIXME: we also need to add the collection flags to the meta data branch ...
 
-	//FIXME: we also need to add the collection flags to the meta data branch ...
 
+//       } catch(const lcio::DataNotAvailableException& e){
 
+// 	_tv->resize( 0 ) ;
+	
+// 	std::cout << "  collection not found : " << _name << std::endl ;
+//       }    
+
+      try{
+	
+	EVENT::LCCollection* col =  evt->getCollection( _name ) ;
+	
+	_tv = dynamic_cast<IMPL::LCCollectionVec*> ( col ) ;
+	
       } catch(const lcio::DataNotAvailableException& e){
 
-	_tv->resize( 0 ) ;
+	_tv = new IMPL::LCCollectionVec( _type ) ;
 	
 	std::cout << "  collection not found : " << _name << std::endl ;
       }    
       
       
-      //    std::cout << "  size of _tv " << _tv->size()  << " for " << _name  << std::endl ;
-      
     }
     
     
-    virtual void fromBranch( EVENT::LCEvent* evt ){
+    virtual void fromBranch( EVENT::LCEvent* evt , int entryID){
+      
+//       // read branch (if requested) from file and add collection to the event
+// // 	IMPL::LCParametersImpl* lcp =  dynamic_cast<IMPL::LCParametersImpl*> ( & col->parameters() ) ; 
+// // 	_params = lcp ;
+	
+// 	IMPL::LCCollectionVec* col = new IMPL::LCCollectionVec( UTIL::lctypename<T>()  ) ;
+	
+// 	int n = _tv->size() ;
+
+// 	col->resize( n ) ;
+
+
+// 	for(int i=0 ; i < n ; ++i ) {
+
+// 	  col->operator[](i) = _tv->operator[](i) ;
+// 	}
+
+
+//        	//	col->parameters() = _params ;
+
+// 	evt->addCollection( col ,  _name ) ;
+
+
+      int nbyte = _br->GetEntry( entryID );
+     
+
+      std::cout << "  read " << nbyte << " bytes from branch : " << _name << " of type " << _type << std::endl ;
+
+      try{
+	
+	evt->addCollection( _tv ,  _name ) ;
+	
+      } catch(const lcio::EventException& e){
+	// collection allready added
+      }    
+      
+    }
       
-      // read branch (if requested) from file and add collection to the event
-    }    
-    
-    
-    
     virtual ~RIOLCCollectionHandler() { 
       
       delete _tv ;

lcio/src/cpp/include/RIO
RIOReader.h 1.1.2.2 -> 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- RIOReader.h	14 Sep 2009 16:22:10 -0000	1.1.2.2
+++ RIOReader.h	15 Sep 2009 15:45:00 -0000	1.1.2.3
@@ -28,7 +28,7 @@
   /** Concrete implementation of LCWriter using ROOT I/O.
    * 
    * @author gaede
-   * @version $Id: RIOReader.h,v 1.1.2.2 2009/09/14 16:22:10 gaede Exp $
+   * @version $Id: RIOReader.h,v 1.1.2.3 2009/09/15 15:45:00 gaede Exp $
    */
   class RIOReader : public IO::LCReader {
     
@@ -150,7 +150,7 @@
 
   protected:
 
-    void setUpHandlers( const EVENT::LCEvent * evt ) ;
+    void setUpHandlers( const IMPL::LCEventImpl * evt ) ;
     //    void readRecord() throw (IO::IOException , IO::EndOfDataException , std::exception) ;
 
 

lcio/src/cpp/include/UTIL
LCIOTypeInfo.h 1.2 -> 1.2.12.1
diff -u -r1.2 -r1.2.12.1
--- LCIOTypeInfo.h	21 Sep 2006 06:10:39 -0000	1.2
+++ LCIOTypeInfo.h	15 Sep 2009 15:45:00 -0000	1.2.12.1
@@ -47,24 +47,24 @@
 
   // specializations for all known LCObject subclasses 
   // - yes this is not OO at its best ...
-  template<> const char* lctypename<EVENT::MCParticle>() { return EVENT::LCIO::MCPARTICLE ; }
-  template<> const char* lctypename<EVENT::SimCalorimeterHit>() { return EVENT::LCIO::SIMCALORIMETERHIT ; }
-  template<> const char* lctypename<EVENT::CalorimeterHit>() { return EVENT::LCIO::CALORIMETERHIT ; }
-  template<> const char* lctypename<EVENT::RawCalorimeterHit>() { return EVENT::LCIO::RAWCALORIMETERHIT ; }
-  template<> const char* lctypename<EVENT::SimTrackerHit>() { return EVENT::LCIO::SIMTRACKERHIT ; }
-  template<> const char* lctypename<EVENT::TrackerRawData>() { return EVENT::LCIO::TRACKERRAWDATA ; }
-  template<> const char* lctypename<EVENT::TrackerData>() { return EVENT::LCIO::TRACKERDATA ; }
-  template<> const char* lctypename<EVENT::TrackerPulse>() { return EVENT::LCIO::TRACKERPULSE ; }
-  template<> const char* lctypename<EVENT::TrackerHit>() { return EVENT::LCIO::TRACKERHIT ; }
-  template<> const char* lctypename<EVENT::LCStrVec>() { return EVENT::LCIO::LCSTRVEC ; }
-  template<> const char* lctypename<EVENT::LCFloatVec>() { return EVENT::LCIO::LCFLOATVEC ; }
-  template<> const char* lctypename<EVENT::LCIntVec>() { return EVENT::LCIO::LCINTVEC ; }
-  template<> const char* lctypename<EVENT::Track>() { return EVENT::LCIO::TRACK ; }
-  template<> const char* lctypename<EVENT::Cluster>() { return EVENT::LCIO::CLUSTER ; }
-  template<> const char* lctypename<EVENT::ReconstructedParticle>() { return EVENT::LCIO::RECONSTRUCTEDPARTICLE ; }
-  template<> const char* lctypename<EVENT::LCRelation>() { return EVENT::LCIO::LCRELATION ; }
-  template<> const char* lctypename<EVENT::LCGenericObject>() { return EVENT::LCIO::LCGENERICOBJECT ; }
-  template<> const char* lctypename<EVENT::Vertex>() { return EVENT::LCIO::VERTEX ; }
+  template<> const char* lctypename<EVENT::MCParticle>() ; 
+  template<> const char* lctypename<EVENT::SimCalorimeterHit>() ; 
+  template<> const char* lctypename<EVENT::CalorimeterHit>()   ;  
+  template<> const char* lctypename<EVENT::RawCalorimeterHit>()  ;
+  template<> const char* lctypename<EVENT::SimTrackerHit>()    ;  
+  template<> const char* lctypename<EVENT::TrackerRawData>()  ;   
+  template<> const char* lctypename<EVENT::TrackerData>()  ;      
+  template<> const char* lctypename<EVENT::TrackerPulse>() ; 
+  template<> const char* lctypename<EVENT::TrackerHit>() ; 
+  template<> const char* lctypename<EVENT::LCStrVec>()  ;
+  template<> const char* lctypename<EVENT::LCFloatVec>() ; 
+  template<> const char* lctypename<EVENT::LCIntVec>()  ;
+  template<> const char* lctypename<EVENT::Track>()  ;
+  template<> const char* lctypename<EVENT::Cluster>()  ;
+  template<> const char* lctypename<EVENT::ReconstructedParticle>()  ;
+  template<> const char* lctypename<EVENT::LCRelation>()  ;
+  template<> const char* lctypename<EVENT::LCGenericObject>()  ;
+  template<> const char* lctypename<EVENT::Vertex>()  ;
   
   
   /** Template that returns the LCIO type name as used in the LCCollctions (and files) based on 
@@ -83,30 +83,8 @@
    *  LCObject* obj = new McParticle ; <br>
    *  std::cout << lctypename( obj ) << std::endl ; <br>
    */
-  template<> const char* lctypename<EVENT::LCObject>(const EVENT::LCObject* o) { 
-    
-    if( dynamic_cast<const EVENT::MCParticle*>(o) != 0 ) return  lctypename<EVENT::MCParticle>() ;
-    
-    if( dynamic_cast<const EVENT::SimCalorimeterHit*>(o) != 0 ) return  lctypename<EVENT::SimCalorimeterHit>() ;
-    if( dynamic_cast<const EVENT::CalorimeterHit*>(o) != 0 ) return   lctypename<EVENT::CalorimeterHit>() ;
-    if( dynamic_cast<const EVENT::RawCalorimeterHit*>(o) != 0 ) return   lctypename<EVENT::RawCalorimeterHit>() ;
-    if( dynamic_cast<const EVENT::SimTrackerHit*>(o) != 0 ) return   lctypename<EVENT::SimTrackerHit>() ;
-    if( dynamic_cast<const EVENT::TrackerRawData*>(o) != 0 ) return   lctypename<EVENT::TrackerRawData>() ;
-    if( dynamic_cast<const EVENT::TrackerData*>(o) != 0 ) return   lctypename<EVENT::TrackerData>() ;
-    if( dynamic_cast<const EVENT::TrackerPulse*>(o) != 0 ) return   lctypename<EVENT::TrackerPulse>() ;
-    if( dynamic_cast<const EVENT::TrackerHit*>(o) != 0 ) return   lctypename<EVENT::TrackerHit>() ;
-    if( dynamic_cast<const EVENT::LCStrVec*>(o) != 0 ) return   lctypename<EVENT::LCStrVec>() ;
-    if( dynamic_cast<const EVENT::LCFloatVec*>(o) != 0 ) return   lctypename<EVENT::LCFloatVec>() ;
-    if( dynamic_cast<const EVENT::LCIntVec*>(o) != 0 ) return   lctypename<EVENT::LCIntVec>() ;
-    if( dynamic_cast<const EVENT::Track*>(o) != 0 ) return   lctypename<EVENT::Track>() ;
-    if( dynamic_cast<const EVENT::Cluster*>(o) != 0 ) return   lctypename<EVENT::Cluster>() ;
-    if( dynamic_cast<const EVENT::ReconstructedParticle*>(o) != 0 ) return   lctypename<EVENT::ReconstructedParticle>() ;
-    if( dynamic_cast<const EVENT::LCRelation*>(o) != 0 ) return   lctypename<EVENT::LCRelation>() ;
-    if( dynamic_cast<const EVENT::LCGenericObject*>(o) != 0 ) return   lctypename<EVENT::LCGenericObject>() ;
-    if( dynamic_cast<const EVENT::Vertex*>(o) != 0 ) return   lctypename<EVENT::Vertex>() ;
-    
-    return "UNKNOWN" ;
-  }
+  template<> const char* lctypename<EVENT::LCObject>(const EVENT::LCObject* o) ;
+
 
 
 

lcio/src/cpp/src/IMPL
LCEventImpl.cc 1.24 -> 1.24.8.1
diff -u -r1.24 -r1.24.8.1
--- LCEventImpl.cc	23 Nov 2007 15:55:34 -0000	1.24
+++ LCEventImpl.cc	15 Sep 2009 15:45:00 -0000	1.24.8.1
@@ -84,14 +84,22 @@
    
 const std::vector<std::string>* LCEventImpl::getCollectionNames() const {
 
-  // return pointer to updated vector _colNames 
-  typedef LCCollectionMap::const_iterator LCI ;
-  
-  _colNames.clear() ;
+  return getCollectionNames( true ) ;
+}
+const std::vector<std::string>* LCEventImpl::getCollectionNames(bool refresh) const {
 
-  for ( LCI i=_colMap.begin() ; i != _colMap.end() ; i++ ){
-    _colNames.push_back( i->first  ) ; 
+  if( refresh ) {
+
+    // return pointer to updated vector _colNames 
+    typedef LCCollectionMap::const_iterator LCI ;
+    
+    _colNames.clear() ;
+    
+    for ( LCI i=_colMap.begin() ; i != _colMap.end() ; i++ ){
+      _colNames.push_back( i->first  ) ; 
+    }
   }
+
   return &_colNames ;
 }
 
@@ -144,10 +152,15 @@
   }
       
   // check if name exists
-  if( _colMap.find( name ) != _colMap.end() )
+  if( _colMap.find( name ) != _colMap.end() ) {
+    
     
+    LCCollection* old =  _colMap.find( name )->second ;
+    
+    std::string type = old->getTypeName()  ;
     throw EventException( std::string("LCEventImpl::addCollection() name already exists: "
-				      +name) ) ; 
+				      +name+" with type "+type) ) ; 
+  }
   // check if col != 0
   if( col == 0  )
 

lcio/src/cpp/src/IMPL
MCParticleImpl.cc 1.29 -> 1.29.6.1
diff -u -r1.29 -r1.29.6.1
--- MCParticleImpl.cc	28 May 2008 14:02:09 -0000	1.29
+++ MCParticleImpl.cc	15 Sep 2009 15:45:00 -0000	1.29.6.1
@@ -57,6 +57,7 @@
 
 
   MCParticleImpl::~MCParticleImpl(){
+    //    std::cout << " MCParticleImpl::~MCParticleImpl() - id: " << id() <<std::endl ;
     // no dynamic variables
     //    delete [] _readDaughters ;
 //     for(MCParticlePVec::iterator iter = _daughters.begin();iter != _daughters.end() ;iter++){

lcio/src/cpp/src/IOIMPL
LCFactory.cc 1.3.2.1 -> 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- LCFactory.cc	14 Sep 2009 13:50:48 -0000	1.3.2.1
+++ LCFactory.cc	15 Sep 2009 15:45:00 -0000	1.3.2.2
@@ -18,38 +18,68 @@
 
 namespace IOIMPL{
 
-  LCFactory* LCFactory::_me = 0 ;
+//   LCFactory* LCFactory::_me = 0 ;
   
   
   LCFactory::LCFactory() {  
+
+    // for now get I/O type from $LCIO_IO_TYPE
+    // one of "ss","sr","rs","rr" 
+    // i.e. SIOReader/SIOWriter, SIOReader/RIOWriter, ...
+
+    char* t = getenv("LCIO_IO_TYPE");
+
+    if( t==0 ) 
+      t = "ss" ;
+
+    _readerType = t[0] ;
+    _writerType = t[1] ;
+
   }
   
 
   LCFactory* LCFactory::getInstance() { 
 
-    if( !_me ) _me = new LCFactory ;
-    return _me ;
+    static LCFactory _me ;
+    //    if( !_me ) _me = new LCFactory ;
+
+    return &_me ;
   }
   
 
   LCFactory::~LCFactory() { 
-    delete _me ;
+    //    delete _me ;
   }
   
   LCWriter * LCFactory::createLCWriter() { 
     
     // the reason for having this class
     // so far we just create SIO objects
-
-    //    return new SIO::SIOWriter ;
-    return new RIO::RIOWriter ;
+    
+    switch(_writerType ) {
+      
+    case 'r':
+      return new RIO::RIOWriter ;
+      break ;
+      
+    default :
+      return new SIO::SIOWriter ;
+    }
+    
   }
   
   LCReader * LCFactory::createLCReader(int lcReaderFlag) {
+    
+    switch(_readerType ) {
+
+    case 'r':
+      return new RIO::RIOReader( lcReaderFlag );
+      break;
+
+    default :
+      return new SIO::SIOReader( lcReaderFlag ) ;
+    }
 
-    // so far we just create SIO objects
-    //    return new SIO::SIOReader( lcReaderFlag );
-   return new RIO::RIOReader( lcReaderFlag );
   }
   
   

lcio/src/cpp/src/RIO
RIOReader.cc 1.1.2.3 -> 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- RIOReader.cc	15 Sep 2009 08:06:22 -0000	1.1.2.3
+++ RIOReader.cc	15 Sep 2009 15:45:00 -0000	1.1.2.4
@@ -31,8 +31,11 @@
  
 namespace RIO {
 
-  //#define DEBUG 1
+
+#define DEBUG 1
   
+
+
   RIOReader::RIOReader( int lcReaderFlag ) :
     _file(0),
     _tree(0),
@@ -217,88 +220,47 @@
     return _runImpl ;
   }
   
-  void RIOReader::setUpHandlers(const LCEvent * evt){
+  void RIOReader::setUpHandlers(const LCEventImpl * evt){
 
-    if( !_haveBranches ) {
-      
+    if( !_haveBranches ) {  // only for first event ....
 
-//       // first we create a branch for the event (header) 
-//       TBranch* br = (TBranch*) _tree->GetBranch( "LCEvent" ) ;
-//       if( br != 0 ){  // branch allready exists -> update/append  mode 
-// 	  br->SetAddress( &_evtImpl ) ;
-//       } else {
-// 	//FIXME: make split level and 'record size' parameters ....
-// 	_tree->Branch( "LCEvent"  , &_evtImpl , 16000, 2 );
-//       }
 
-      // loop over all collections in first event ...
+      _haveBranches = true ;
+
       typedef std::vector< std::string > StrVec ; 
 
-      const StrVec* strVec = evt->getCollectionNames() ;
+      const StrVec* strVec = evt->getCollectionNames(false) ;
 
       for(  StrVec::const_iterator name = strVec->begin() ; name != strVec->end() ; name++){
 	
-	LCCollection* col = evt->getCollection( *name ) ;
-	
-	const LCParameters&  params =  col->getParameters()  ;
-	std::string typeName = col->getTypeName() ;
-
-	std::cout << " registering collection " << *name << " of " <<  typeName <<  std::endl ;
+// 	LCCollection* col = evt->getCollection( *name ) ;
+// 	const LCParameters&  params =  col->getParameters()  ;
+// 	std::string typeName = col->getTypeName() ;
 
+	std::string typeName("YetUnknown") ;
 
-	//FIXME: these should be held by  a singleton handler manager (registry) 
-	if( typeName == LCIO::MCPARTICLE ){
-
-	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::MCParticle>(name->c_str() ,_tree) ) ;	  
-	}      
-	if( typeName == LCIO::SIMCALORIMETERHIT ){
+	std::cout << " registering collection " << *name << " of " <<  typeName <<  std::endl ;
 
-	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::SimCalorimeterHit>(name->c_str() ,_tree) ) ;	  
-	}      
-	if( typeName == LCIO::SIMTRACKERHIT ){
+// 	//FIXME: these should be held by  a singleton handler manager (registry) 
+// 	if( typeName == LCIO::MCPARTICLE ){
+// 	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::MCParticle>(name->c_str() ,_tree) ) ;	  
+// 	}      
+// 	if( typeName == LCIO::SIMCALORIMETERHIT ){
+// 	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::SimCalorimeterHit>(name->c_str() ,_tree) ) ;
+// 	}      
+// 	if( typeName == LCIO::SIMTRACKERHIT ){
+// 	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::SimTrackerHit>(name->c_str() ,_tree) ) ;	  
+// 	}      
+// 	// ToDo:  add all other LCIO types ....
 
-	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::SimTrackerHit>(name->c_str() ,_tree) ) ;	  
-	}      
 	
+// 	if( *name == "MCParticlesSkimmed" )
 
-	// ToDo:  add all other LCIO types ....
+	  _branches.push_back(  new RIO::RIOLCCollectionHandler( *name, typeName   , _tree) ) ;	
 
       }
 
-      _haveBranches = true ;
     }
-//     // use event *_evtP to setup the block readers from header information ....
-//     const std::vector<std::string>* strVec = (*_evtP)->getCollectionNames() ;
-//     for( std::vector<std::string>::const_iterator name = strVec->begin() ; name != strVec->end() ; name++){
-      
-//       const LCCollection* col = (*_evtP)->getCollection( *name ) ;
-
-
-//       // check if block handler exists in manager
-//       RIOCollectionHandler* ch = dynamic_cast<RIOCollectionHandler*> 
-// 	( RIO_blockManager::get( name->c_str() )  ) ;
-      
-//       // if not, create a new block handler
-//       if( ch == 0 ) {
-	
-// 	// create collection handler for event
-// 	try{
-// 	  ch =  new RIOCollectionHandler( *name, col->getTypeName() , _evtP )  ;
-// 	  // calls   RIO_blockManager::add( ch )  in the c'tor !
-// 	}
-// 	catch(Exception& ex){   // unsuported type !
-// 	  delete ch ;
-// 	  ch =  0 ;
-// 	}
-
-//       }
-//       // else { // handler already exists
-//       if( ch != 0 )
-// 	ch->setEvent( _evtP ) ; 
-//       //      }
-//     }
-
-
   }
 
 
@@ -310,7 +272,7 @@
 
   LCEvent* RIOReader::readNextEvent(int accessMode) throw (IOException, std::exception ) {
 
-//     if( _evtImpl != 0 ) 
+//     if( _evtImpl != 0 )   // memory handling in ROOT I/O ? 
 //       delete _evtImpl ;
     
 
@@ -339,28 +301,34 @@
 	return 0 ; // EOF ?
       }
 
+#ifdef DEBUG
+      typedef std::vector< std::string > StrVec ; 
+
+      const StrVec& strVec = *( _evtImpl->getCollectionNames(false) ) ;
+
       std::cout << " tentry : " << tentry 
 		<< " _entry " << _entry  
 		<< "  eventnum " << _evtImpl->getEventNumber()  
-		<< " ncols: " << _evtImpl->getCollectionNames()->size() 
+		<< " ncols: " << strVec.size() 
 		<< " nbyte: " << nbyte
 		<< " _evtImpl " << _evtImpl  
 		<< std::endl ;
 
-      typedef std::vector< std::string > StrVec ; 
-
-      const StrVec* strVec = _evtImpl->getCollectionNames() ;
-
-      for(  StrVec::const_iterator name = strVec->begin() ; name != strVec->end() ; name++){
+      for(  StrVec::const_iterator name = strVec.begin() ; name != strVec.end() ; name++){
 	std::cout << " collection: " << *name << std::endl ;
       }
-      
+#endif      
+
       if( !_haveBranches ) {
 
 	setUpHandlers( _evtImpl ) ;
       }    
 
-    
+      for( BranchVector::iterator it=_branches.begin() ; it!=_branches.end() ; ++it){
+	
+	(*it)->fromBranch( _evtImpl , tentry ) ;
+      }
+      
     
     //------------------------------------------------------
 

lcio/src/cpp/src/RIO
RIOWriter.cc 1.1.2.1 -> 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- RIOWriter.cc	14 Sep 2009 13:50:48 -0000	1.1.2.1
+++ RIOWriter.cc	15 Sep 2009 15:45:00 -0000	1.1.2.2
@@ -21,7 +21,8 @@
 
 #include <cstring>
 
-#define ROOTIO_FILE_EXTENSION ".lcio.root"
+//#define ROOTIO_FILE_EXTENSION ".lcio.root"
+#define ROOTIO_FILE_EXTENSION ".rlcio"
 
 #include "TFile.h"
 #include "TTree.h"
@@ -65,8 +66,6 @@
     // if the file exists we throw an exception
     _file = new TFile( rioFilename.c_str() , "NEW");    
 
-    bool _haveBranches ; 
-
     if( _file->IsOpen() ){ 
 
       _file->Close() ;      
@@ -114,7 +113,7 @@
     //  				      + stream_name  )) ;
         
     
-    unsigned int  status = 0  ;
+    //    unsigned int  status = 0  ;
 
 
     //    std::cout << " ******** open ( " << filename << ", " << writeMode << ") "  << std::endl ;
@@ -238,25 +237,26 @@
 	
 	LCCollection* col = evt->getCollection( *name ) ;
 	
-	const LCParameters&  params =  col->getParameters()  ;
+	//	const LCParameters&  params =  col->getParameters()  ;
 	std::string typeName = col->getTypeName() ;
 
 	std::cout << " registering collection " << *name << " of " <<  typeName <<  std::endl ;
 
+	_branches.push_back(  new RIO::RIOLCCollectionHandler( *name, typeName, _tree) ) ;	 
+
+// 	//FIXME: these should be held by  a singleton handler manager (registry) 
+// 	if( typeName == LCIO::MCPARTICLE ){
 
-	//FIXME: these should be held by  a singleton handler manager (registry) 
-	if( typeName == LCIO::MCPARTICLE ){
+// 	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::MCParticle>(name->c_str() ,_tree) ) ;	  
+// 	}      
+// 	if( typeName == LCIO::SIMCALORIMETERHIT ){
 
-	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::MCParticle>(name->c_str() ,_tree) ) ;	  
-	}      
-	if( typeName == LCIO::SIMCALORIMETERHIT ){
-
-	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::SimCalorimeterHit>(name->c_str() ,_tree) ) ;	  
-	}      
-	if( typeName == LCIO::SIMTRACKERHIT ){
+// 	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::SimCalorimeterHit>(name->c_str() ,_tree) ) ;	  
+// 	}      
+// 	if( typeName == LCIO::SIMTRACKERHIT ){
 
-	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::SimTrackerHit>(name->c_str() ,_tree) ) ;	  
-	}      
+// 	  _branches.push_back(  new RIO::RIOLCCollectionHandler<EVENT::SimTrackerHit>(name->c_str() ,_tree) ) ;	  
+// 	}      
 	
 
 	// ToDo:  add all other LCIO types ....
CVSspam 0.2.8