Commit in lcio on rio_v00-00
rootio/ToDo.txt+21.1.2.4 -> 1.1.2.5
src/cpp/CMakeLists.txt+1-11.22.2.8 -> 1.22.2.9
src/cpp/include/IMPL/AccessChecked.h+3-21.6.12.1 -> 1.6.12.2
                    /LCCollectionVec.h+118-371.11.20.3 -> 1.11.20.4
                    /LCParametersImpl.h+4-31.2.20.1 -> 1.2.20.2
src/cpp/include/RIO/RIO.h+3-21.1.2.3 -> 1.1.2.4
                   /RIOLCCollectionHandler.h+10-11.1.2.4 -> 1.1.2.5
                   /rootio_templates.h+131.1.2.4 -> 1.1.2.5
src/cpp/src/EXAMPLE/copyfix.cc+41.4.20.1 -> 1.4.20.2
src/cpp/src/IMPL/LCCollectionVec.cc+29-241.12.20.2 -> 1.12.20.3
src/cpp/src/RIO/RIOWriter.cc+6-21.1.2.7 -> 1.1.2.8
+193-72
11 modified files
made LCCollectionVec typedef of new template LCCollectionTVec 

lcio/rootio
ToDo.txt 1.1.2.4 -> 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- ToDo.txt	27 Nov 2009 16:06:32 -0000	1.1.2.4
+++ ToDo.txt	1 Dec 2009 11:11:03 -0000	1.1.2.5
@@ -38,5 +38,7 @@
   - make LCCollection branches subbranches of LCEvent 
 
 
+  - don't flush at the end of writing the event - rather use 'autosave' feature
+    TTree::SetAutoSave()
 
 

lcio/src/cpp
CMakeLists.txt 1.22.2.8 -> 1.22.2.9
diff -u -r1.22.2.8 -r1.22.2.9
--- CMakeLists.txt	26 Nov 2009 14:23:29 -0000	1.22.2.8
+++ CMakeLists.txt	1 Dec 2009 11:11:03 -0000	1.22.2.9
@@ -350,12 +350,12 @@
     INCLUDE_DIRECTORIES( "${CMAKE_CURRENT_SOURCE_DIR}" )
     
     ADD_LIBRARY( lib_LCIODICT ${dict_lib_srcs} ${LCIO_RIO_SRCS} )
-    #ADD_LIBRARY( lib_LCIO ${LCIO_RIO_SRCS} )
     INSTALL( TARGETS lib_LCIODICT DESTINATION lib )
  
 
    IF( APPLE )
      SET( ROOT_DICT_LINK_FLAGS "-single_module -undefined dynamic_lookup -bind_at_load")
+     ADD_LIBRARY( lib_LCIO ${LCIO_RIO_SRCS} )
    ELSE( APPLE )
      SET( ROOT_DICT_LINK_FLAGS " " )
    ENDIF( APPLE )

lcio/src/cpp/include/IMPL
AccessChecked.h 1.6.12.1 -> 1.6.12.2
diff -u -r1.6.12.1 -r1.6.12.2
--- AccessChecked.h	20 Nov 2009 15:12:04 -0000	1.6.12.1
+++ AccessChecked.h	1 Dec 2009 11:11:03 -0000	1.6.12.2
@@ -7,7 +7,7 @@
 namespace IMPL {
   
   class  LCEventImpl ;
-  class  LCCollectionVec ;
+  //  class  LCCollectionVec ;
 
   /** Controls access to objects.
    * 
@@ -17,7 +17,8 @@
   class AccessChecked {
     
     friend class LCEventImpl ;     
-    friend class LCCollectionVec ; 
+    //    friend class LCCollectionVec ; 
+    template <typename T> friend class LCCollectionTVec ; 
     
   public:
     AccessChecked() ;

lcio/src/cpp/include/IMPL
LCCollectionVec.h 1.11.20.3 -> 1.11.20.4
diff -u -r1.11.20.3 -r1.11.20.4
--- LCCollectionVec.h	26 Nov 2009 14:24:31 -0000	1.11.20.3
+++ LCCollectionVec.h	1 Dec 2009 11:11:03 -0000	1.11.20.4
@@ -8,58 +8,81 @@
 #include "EVENT/LCObject.h"
 #include "AccessChecked.h"
 #include "LCParametersImpl.h"
+#include "EVENT/LCIO.h"
+#include "LCIOTypes.h"
+
+#include <iostream>
 
-//#include "LCIO.h"
 
 namespace IMPL {
   
-  //  typedef std::vector<EVENT::LCObject*> LCObjectVec ;
-
   /** Implementation of the LCCollection using (inheriting from) an STL vector
    *  of LCObjects.
    * 
    * @author gaede 
-   * @version $Id: LCCollectionVec.h,v 1.11.20.3 2009/11/26 14:24:31 gaede Exp $
+   * @version $Id: LCCollectionVec.h,v 1.11.20.4 2009/12/01 11:11:03 gaede Exp $
    * @see LCObject
    * @see LCCollection
    */
-  class LCCollectionVec : public EVENT::LCCollection, public AccessChecked {
+
+  template <class T>
+  class LCCollectionTVec : public EVENT::LCCollection, public AccessChecked {
     
-//   class LCCollectionVec : public EVENT::LCCollection , public EVENT::LCObjectVec 
-//     , public AccessChecked {
     
     //  protected:
   public:
     /**  Default Constructor is protected  - every LCCollection needs to know the type
      *   of its elements.
      */
-    LCCollectionVec() {  /* no default c'tor */ }
+    LCCollectionTVec() {  /* no default c'tor */ }
     
   public:
     
     /** The public default constructur that takes the name of the type of the elements.     */
-    LCCollectionVec( const std::string& type ) ;
+    LCCollectionTVec( const std::string& type ) :
+      _typeName( type ),
+      _flag(0) {
+    }
     
     /* Coppy constructor creating a deep copy of an LCCollection.
      */
-    //    LCCollectionVec( const EVENT::LCCollection& col ) ;
+    //    LCCollectionTVec( const EVENT::LCCollection& col ) ;
     
     
     /** Destructor.
      */    
-    virtual ~LCCollectionVec() ;
+    virtual ~LCCollectionTVec() {
+      
+      if( ! isSubset() ){
+	// delete all elements
+	typename std::vector<T*>::const_iterator iter = _vec.begin() ;
+	//    std::cout << "deleting collection " 
+	//  	    << std::endl ;
+	//    UTIL::LCTOOLS::printParameters( parameters() )  ;
+	
+	while( iter != _vec.end() ){
+	  delete *iter++ ;
+	}
+      }
+    }
     
     /**Returns the number of entries in the collection.
      */
-    virtual int getNumberOfElements() const ;
-    
+    virtual int getNumberOfElements() const {
+      return _vec.size() ;
+    }
+
     /** Returns the type name of the collection - valid names are defined in LCIO.
      */
-    virtual const std::string & getTypeName() const ;
+    virtual const std::string & getTypeName() const {
+      return _typeName ;
+    }
     
     /** Returns pointer to element at index - no range check !.
      */
-    virtual EVENT::LCObject * getElementAt(int index) const ;
+    virtual EVENT::LCObject * getElementAt(int index) const {
+      return _vec.operator[](index) ;
+    }
     
     /** Returns flag word for collection. Bits 16-31 are reserved for LCIO
      *  Depending on the object type stored they have a special meaning, e.g. 
@@ -75,38 +98,51 @@
      *  Bits 0-15 are subdetector/user specific.
      * @see isTransient()
      */
-    virtual int getFlag() const ;
-
+    virtual int getFlag() const {
+      return _flag ;
+    }
 
     /** True if collection is transient, i.e. will not be written to any LCIO file.
      *  Convenient method that checks bit 16 of the flag word.
      */
-    virtual bool isTransient() const  ;
+    virtual bool isTransient() const 
+      return (_flag & (1<<BITTransient) ) ;
+    }
     
 
     /** Sets the transient flag for this collection. Transient collections are not written
      * to LCIO files.
      */
-    void setTransient(bool val=true) ;
+    void setTransient(bool val=true)  {
+      if(val) _flag |= (1<<BITTransient) ;
+      else _flag &= ~(1<<BITTransient) ;
+    }
+
 
     /** True if collection is the default collection for the given type.
      *  This implies that the collection is complete and unambigous.
      *  Convenient method that checks bit BITDefault of the flag word.
      */
-    virtual bool isDefault() const ;
+    virtual bool isDefault() const  { 
+      return (_flag & (1<<BITDefault) ) ; 
+    }
 
     /** Sets the default flag for this collection. User need to make sure this 
      * flag is unique for a type.
      */
-    void setDefault(bool val=true) ;
-
+    void setDefault(bool val=true)  {
+      if(val) _flag |= (1<<BITDefault) ;
+      else _flag &= ~(1<<BITDefault) ;
+    }
 
     /** True if the collection holds a subset of objects from other collections. 
      *  If the collection is not transient only the pointers/references to the original
      *  objects will be stored.
      *  Convenient method that checks bit BITSubset of the flag word.
      */
-    virtual bool isSubset() const ;
+    virtual bool isSubset() const 
+      return (_flag & (1<<BITSubset) ) ; 
+    }
 
     /** Sets the subset flag for this collection. Collections of subsets are only 
      *  written as pointers to LCIO files, i.e. the objects have to exist in 
@@ -114,27 +150,41 @@
      *  NB: Do not add any 'real' objects to a collection flagged as subset, as 
      *  this will lead to memory leaks !
      */
-    void setSubset(bool val=true) ;
-
+    void setSubset(bool val=true)  {
+      if(val) _flag |= (1<<BITSubset) ;
+      else _flag &= ~(1<<BITSubset) ;
+    }
 
     /** Sets the flag word for this collection.
      */
-    void setFlag(int flag) ;
-    
+    void setFlag(int flag) {
+      _flag  = flag ;
+    }
 
     /** Adds the given element to (end of) the collection. Throws an exception 
      * if the collection (event) is 'read only'.
      *
      * @throws ReadOnlyException
      */
-    virtual void addElement(EVENT::LCObject * obj) throw (EVENT::ReadOnlyException) ;
+    virtual void addElement(EVENT::LCObject * obj) throw (EVENT::ReadOnlyException) {
+      //    if(_access != LCIO::UPDATE )
+      //  throw ReadOnlyException("LCCollectionVec::addElement:  event is read only") ;
+      checkAccess("LCCollectionVec::addElement") ;
+      _vec.push_back( (T*) obj ) ; 
+    }
+
 
     /** Removes the i-th element from the collection. Throws an exception 
      * if the collection (event) is 'read only'.
      *
      * @throws ReadOnlyException
      */
-    virtual void removeElementAt(int i) throw (EVENT::ReadOnlyException) ;
+    virtual void removeElementAt(int i) throw (EVENT::ReadOnlyException) {
+      //    if(_access != LCIO::UPDATE )
+      //  throw ReadOnlyException("LCCollectionVec::addElement:  event is read only") ;
+      checkAccess("LCCollectionVec::removeElementAt") ;
+      _vec.erase( _vec.begin() + i ) ;
+    }
     
     /** Parameters defined for this run.
      */
@@ -145,21 +195,36 @@
     virtual EVENT::LCParameters & parameters() { return _params ; } 
     
     /**Helper function to convert object addresses into indices for all objects:  ((hash<<32)||index) */
-    void setIndices( unsigned hash ) ;
+    void setIndices( unsigned hash ) {
+      
+      for( unsigned i=0 ; i< _vec.size() ; ++i ){
+	
+	EVENT::long64 idx(i) ;
+	EVENT::long64 hashL( hash ) ;
+	
+	//       EVENT::long64 index(  idx | hashL<<32 ) ;
+	//       std::cout << "   LcCol setIndices : " << idx << " , " << hashL << ", " <<  index  << std::endl ;
+	//	_vec.operator[](i)->setIndex(  idx | hashL<<32 ) ;
+	_vec[i]->setIndex(  idx | hashL<<32 ) ;
+      }
+    }
 
     /** Calls ptrToIndex for all elements */
-    void ptrToIndex() ;
-    
+    void ptrToIndex() {
+      for( unsigned i=0 ; i< _vec.size() ; ++i ){
+	_vec.operator[](i)->ptrToIndex() ;
+      }
+    }
 
     // forward some of std::vector's interface so that we can serve as a wrapper to vector ------------
 
     inline void push_back(EVENT::LCObject* t){
-      _vec.push_back(t) ;
+      _vec.push_back( (T*) t) ;
     }
     inline void resize(size_t nS){   _vec.resize(nS) ; }
     inline EVENT::LCObject* operator[](size_t n){  return _vec[n] ; }
     inline const EVENT::LCObject* operator[](size_t n) const { return _vec[n] ; }
-    inline EVENT::LCObject*& at(size_t n){ return _vec.at(n)  ; }
+    inline EVENT::LCObject* at(size_t n){ return _vec.at(n)  ; }
     inline size_t size() const { return _vec.size()  ; }
 //     inline iterator begin(){  return _vec.begin() ; }
 //     inline iterator end(){ return _vec.end() ; }
@@ -169,15 +234,31 @@
 
 
   protected:
-    void setReadOnly(bool readOnly) ;
-
+    void setReadOnly(bool readOnly){
+      
+      AccessChecked::setReadOnly(readOnly ) ;
+      
+      typename std::vector<T*>::iterator iter = _vec.begin() ;
+      while( iter != _vec.end() ){
+	AccessChecked* element = dynamic_cast<AccessChecked*>(*iter++) ;
+	if(element){
+	  element->setReadOnly( readOnly ) ;
+	}
+      }
+    }
+    
     std::string _typeName ;
     int _flag ;
     LCParametersImpl _params ;
     //    int _access ;
 
-    EVENT::LCObjectVec _vec; 
+    //    EVENT::LCObjectVec _vec; 
+    std::vector< T*> _vec ;
 
 }; // class
+
+  
+  typedef LCCollectionTVec< EVENT::LCObject > LCCollectionVec ;
+
 } // namespace IMPL
 #endif /* ifndef EVENT_LCCOLLECTIONVEC_H */

lcio/src/cpp/include/IMPL
LCParametersImpl.h 1.2.20.1 -> 1.2.20.2
diff -u -r1.2.20.1 -r1.2.20.2
--- LCParametersImpl.h	20 Nov 2009 15:12:04 -0000	1.2.20.1
+++ LCParametersImpl.h	1 Dec 2009 11:11:03 -0000	1.2.20.2
@@ -13,7 +13,7 @@
 
   class LCRunHeaderImpl ;
   class LCEventImpl ;
-  class LCCollectionVec ;
+  //  class LCCollectionVec ;
 
   typedef std::map< std::string, EVENT::IntVec >    IntMap ;
   typedef std::map< std::string, EVENT::FloatVec >  FloatMap ;
@@ -36,8 +36,9 @@
 
     friend class LCRunHeaderImpl ;
     friend class LCEventImpl ;
-    friend class LCCollectionVec ;
-    
+    //friend class LCCollectionVec ;
+    template <typename T> friend class LCCollectionTVec ; 
+   
   public: 
     
     LCParametersImpl() ; 

lcio/src/cpp/include/RIO
RIO.h 1.1.2.3 -> 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- RIO.h	27 Nov 2009 16:03:05 -0000	1.1.2.3
+++ RIO.h	1 Dec 2009 11:11:03 -0000	1.1.2.4
@@ -16,8 +16,9 @@
 
 #define RIO_RECORD_SIZE    16000
 
-#define RIO_SPLIT_LEVEL        101
+#define RIO_SPLIT_LEVEL        5
 
-#define RIO_DEFAULT_COMPRESS   4  // what is a reasonable default ?
+#define RIO_DEFAULT_COMPRESS   1
+  // 1 is TFile default ?
 
 #endif

lcio/src/cpp/include/RIO
RIOLCCollectionHandler.h 1.1.2.4 -> 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- RIOLCCollectionHandler.h	27 Nov 2009 16:04:41 -0000	1.1.2.4
+++ RIOLCCollectionHandler.h	1 Dec 2009 11:11:03 -0000	1.1.2.5
@@ -10,6 +10,7 @@
 
 #include "TTree.h"
 #include <vector>
+#include <sstream>
 #include "RIO.h"
 
 namespace RIO{
@@ -81,7 +82,15 @@
  } else {
 	
 	//FIXME: make split level and 'record size' parameters ....
-	_br = tree->Branch( _name.c_str()  , &_tv, 16000, RIO_SPLIT_LEVEL );
+	//	_br = tree->Branch( _name.c_str(), &_tv, 16000, RIO_SPLIT_LEVEL );
+	std::stringstream typeStream ;
+	typeStream << "IMPL::LCCollectionTVec<" << type << ">" ;
+
+	std::cout << " create branch for type   " << typeStream.str()  << std::endl ;
+	
+	_br = tree->Branch( _name.c_str(), typeStream.str().c_str(), &_tv, 16000, RIO_SPLIT_LEVEL );
+
+
 
 	//((TBranch*)_br->GetListOfBranches()->FindObject("vector<EVENT::LCObject*>"))->SetName("LCObjVec")  ;
       }

lcio/src/cpp/include/RIO
rootio_templates.h 1.1.2.4 -> 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- rootio_templates.h	20 Nov 2009 15:28:50 -0000	1.1.2.4
+++ rootio_templates.h	1 Dec 2009 11:11:03 -0000	1.1.2.5
@@ -12,6 +12,7 @@
 #include "IMPL/TrackImpl.h"
 #include "IMPL/ClusterImpl.h"
 #include "IMPL/LCRelationImpl.h"
+#include "IMPL/LCCollectionVec.h"
 
 #include "TRefArray.h"
 #include <string>
@@ -67,6 +68,18 @@
 #pragma link C++ class IMPL::LCRef<EVENT::LCRelation*>+;
 #pragma link C++ class IMPL::LCRef<EVENT::Vertex*>+;
 
+//#pragma link C++ class IMPL::LCCollectionTVec<EVENT::LCObject>+;
+#pragma link C++ class IMPL::LCCollectionTVec<EVENT::ReconstructedParticle>+;
+#pragma link C++ class IMPL::LCCollectionTVec<EVENT::MCParticle>+;
+#pragma link C++ class IMPL::LCCollectionTVec<EVENT::SimTrackerHit>+;
+#pragma link C++ class IMPL::LCCollectionTVec<EVENT::SimCalorimeterHit>+;
+#pragma link C++ class IMPL::LCCollectionTVec<EVENT::TrackerHit>+;
+#pragma link C++ class IMPL::LCCollectionTVec<EVENT::CalorimeterHit>+;
+#pragma link C++ class IMPL::LCCollectionTVec<EVENT::Track>+;
+#pragma link C++ class IMPL::LCCollectionTVec<EVENT::Cluster>+;
+#pragma link C++ class IMPL::LCCollectionTVec<EVENT::LCRelation>+;
+#pragma link C++ class IMPL::LCCollectionTVec<EVENT::Vertex>+;
+
 
 
 #endif

lcio/src/cpp/src/EXAMPLE
copyfix.cc 1.4.20.1 -> 1.4.20.2
diff -u -r1.4.20.1 -r1.4.20.2
--- copyfix.cc	30 Nov 2009 17:25:38 -0000	1.4.20.1
+++ copyfix.cc	1 Dec 2009 11:11:03 -0000	1.4.20.2
@@ -113,7 +113,11 @@
       lcReader->registerLCRunListener( &evtProc ) ; 
       lcReader->registerLCEventListener( &evtProc ) ; 
       
+    if( argc > 3 )
       lcReader->readStream( maxEvt ) ;
+    else
+      lcReader->readStream() ;
+
     } 
     
     lcReader->close() ;

lcio/src/cpp/src/IMPL
LCCollectionVec.cc 1.12.20.2 -> 1.12.20.3
diff -u -r1.12.20.2 -r1.12.20.3
--- LCCollectionVec.cc	26 Nov 2009 14:28:04 -0000	1.12.20.2
+++ LCCollectionVec.cc	1 Dec 2009 11:11:03 -0000	1.12.20.3
@@ -1,5 +1,9 @@
 
 #include "IMPL/LCCollectionVec.h"
+
+#ifdef __IGNORE_THIS_FILE
+
+#include "IMPL/LCCollectionVec.h"
 #include "EVENT/LCIO.h"
 #include "LCIOTypes.h"
 
@@ -67,33 +71,33 @@
   }
  
  void LCCollectionVec::ptrToIndex() {
-
-    for( unsigned i=0 ; i< _vec.size() ; ++i ){
-
-      _vec.operator[](i)->ptrToIndex() ;
-    }
-  }
-
-LCCollectionVec::~LCCollectionVec() {
-
-  if( ! isSubset() ){
-    // delete all elements
-    LCObjectVec::const_iterator iter = _vec.begin() ;
-    //    std::cout << "deleting collection " 
-    //  	    << std::endl ;
-    //    UTIL::LCTOOLS::printParameters( parameters() )  ;
+   
+   for( unsigned i=0 ; i< _vec.size() ; ++i ){
+     
+     _vec.operator[](i)->ptrToIndex() ;
+   }
+ }
+  
+  LCCollectionVec::~LCCollectionVec() {
     
-    while( iter != _vec.end() ){
-      delete *iter++ ;
+    if( ! isSubset() ){
+      // delete all elements
+      LCObjectVec::const_iterator iter = _vec.begin() ;
+      //    std::cout << "deleting collection " 
+      //  	    << std::endl ;
+      //    UTIL::LCTOOLS::printParameters( parameters() )  ;
+      
+      while( iter != _vec.end() ){
+	delete *iter++ ;
+      }
     }
   }
-}
-
-
-int LCCollectionVec::getNumberOfElements() const{
-  return _vec.size() ;
-}
-
+  
+  
+  int LCCollectionVec::getNumberOfElements() const{
+    return _vec.size() ;
+  }
+  
 
 const std::string & LCCollectionVec::getTypeName() const{
   return _typeName ;
@@ -163,3 +167,4 @@
 
 } // namespace IMPL
 
+#endif

lcio/src/cpp/src/RIO
RIOWriter.cc 1.1.2.7 -> 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- RIOWriter.cc	27 Nov 2009 16:04:42 -0000	1.1.2.7
+++ RIOWriter.cc	1 Dec 2009 11:11:03 -0000	1.1.2.8
@@ -138,6 +138,9 @@
     if( !_file->IsOpen() )
       throw IOException( std::string( "[RIOWriter::open()] Couldn't open file: " 
 				      +  rioFilename ) ) ;
+
+
+    _tree->SetAutoSave() ;
   }
   
 
@@ -274,7 +277,7 @@
     
     _evtImpl = &proxyEvt ; 
     _tree->Fill() ;
-    _file->Flush() ;
+    //_file->Flush() ;
 
     // now we need to take the ownership for the  collections away from proxy Event
     strVec = proxyEvt.getCollectionNames() ;
@@ -296,7 +299,8 @@
   
   void RIOWriter::flush() throw (IOException, std::exception) {
 
-    _file->Flush() ;
+    // fg: we should not flush but use the auto safe feature for ROOT ....
+    //_file->Flush() ;
   }
   
 } // namespace
CVSspam 0.2.8