Print

Print


Commit in lcio on rio_v00-00
FindROOT.cmake+5-11.1.2.1 -> 1.1.2.2
rootio/readevent.C+1-11.1.2.5 -> 1.1.2.6
src/cpp/include/IMPL/LCParametersImpl.h+3-31.2.20.3 -> 1.2.20.4
                    /LCRefVec.h+11.1.2.3 -> 1.1.2.4
src/cpp/include/RIO/RIO.h+2-11.1.2.5 -> 1.1.2.6
                   /RIOReader.h+7-51.1.2.6 -> 1.1.2.7
                   /RIOWriter.h+5-11.1.2.4 -> 1.1.2.5
                   /rootio_templates.h+11.1.2.6 -> 1.1.2.7
src/cpp/src/RIO/RIOReader.cc+39-571.1.2.7 -> 1.1.2.8
               /RIOWriter.cc+47-471.1.2.8 -> 1.1.2.9
+111-116
10 modified files
added streaming code for LCRunheader - split LCIO tree into two: LCEvent and LCRunHeader

lcio
FindROOT.cmake 1.1.2.1 -> 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- FindROOT.cmake	7 Jul 2009 14:30:09 -0000	1.1.2.1
+++ FindROOT.cmake	4 Dec 2009 10:03:15 -0000	1.1.2.2
@@ -50,9 +50,13 @@
 
 # get lib names from 'root-config' output
 EXEC_PROGRAM( "${ROOT_HOME}/bin/root-config" "${ROOT_HOME}/bin"
-    ARGS --noauxlibs --glibs
+    ARGS --noauxlibs --libs  
+#    ARGS --noauxlibs --glibs
     OUTPUT_VARIABLE out_tmp
     RETURN_VALUE out_ret )
+
+#SET( out_tmp  "-L/data/ilcsoft/root/trunk/lib -lCore -lCint -lRIO -lNet  -lHist  -lTree -lMathCore")
+
 # check if everything went ok
 IF( NOT out_ret )
     # create a list out of the output

lcio/rootio
readevent.C 1.1.2.5 -> 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- readevent.C	27 Nov 2009 16:00:39 -0000	1.1.2.5
+++ readevent.C	4 Dec 2009 10:03:16 -0000	1.1.2.6
@@ -38,7 +38,7 @@
    
   if (!f) { return; }
   
-  TTree *t; f->GetObject("LCIO",t);
+  TTree *t; f->GetObject("LCEvent",t);
 
   
 

lcio/src/cpp/include/IMPL
LCParametersImpl.h 1.2.20.3 -> 1.2.20.4
diff -u -r1.2.20.3 -r1.2.20.4
--- LCParametersImpl.h	1 Dec 2009 14:15:32 -0000	1.2.20.3
+++ LCParametersImpl.h	4 Dec 2009 10:03:16 -0000	1.2.20.4
@@ -128,9 +128,9 @@
 
   protected:
 
-    mutable IntMap _intMap ;    //! no RIO - for debugging
-    mutable FloatMap _floatMap ;  //! no RIO - for debugging
-    mutable StringMap _stringMap ;  //! no RIO - for debugging
+    mutable IntMap _intMap ;    
+    mutable FloatMap _floatMap ;  
+    mutable StringMap _stringMap ;  
     
   }; // class
 } // namespace IMPL

lcio/src/cpp/include/IMPL
LCRefVec.h 1.1.2.3 -> 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- LCRefVec.h	27 Nov 2009 16:02:33 -0000	1.1.2.3
+++ LCRefVec.h	4 Dec 2009 10:03:16 -0000	1.1.2.4
@@ -95,6 +95,7 @@
 
     std::vector<T> _vec;                 //! no RIO
     std::vector<EVENT::long64> _refVec ;
+    //std::vector<long long> _refVec ;
     LCEventImpl* _evt ;                  //! no RIO
     bool _havePtrs ;                     //! no RIO
 

lcio/src/cpp/include/RIO
RIO.h 1.1.2.5 -> 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- RIO.h	1 Dec 2009 14:15:32 -0000	1.1.2.5
+++ RIO.h	4 Dec 2009 10:03:16 -0000	1.1.2.6
@@ -11,7 +11,8 @@
 #define RIO_LCIO_TREENAME         "LCIO"
 #define RIO_LCIO_TREENAME_CYCLE_1 "LCIO;1"   // root way of versioning 
 
-#define RIO_LCEVENT_BRANCHNAME    "LCEvent"
+#define RIO_LCEVENT_BRANCHNAME      "LCEvent"
+#define RIO_LCRUNHEADER_BRANCHNAME  "LCRunHeader"
 
 
 #define RIO_RECORD_SIZE    16000

lcio/src/cpp/include/RIO
RIOReader.h 1.1.2.6 -> 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- RIOReader.h	1 Dec 2009 09:19:23 -0000	1.1.2.6
+++ RIOReader.h	4 Dec 2009 10:03:16 -0000	1.1.2.7
@@ -18,6 +18,7 @@
 
 class TFile ;
 class TTree ;
+class TBranch ;
 
 namespace RIO {
 
@@ -30,7 +31,7 @@
   /** Concrete implementation of LCWriter using ROOT I/O.
    * 
    * @author gaede
-   * @version $Id: RIOReader.h,v 1.1.2.6 2009/12/01 09:19:23 gaede Exp $
+   * @version $Id: RIOReader.h,v 1.1.2.7 2009/12/04 10:03:16 gaede Exp $
    */
   class RIOReader : public IO::LCReader {
     
@@ -165,13 +166,14 @@
   protected:
 
     TFile* _file ;
-    TTree* _tree ;
-
+    TTree* _evtTree ;
+    TTree* _runTree ;
+    
+    TBranch* _runHdrBranch ;
     BranchHandlerMap _branches ;
     bool _haveBranches ; 
  
     IMPL::LCEventImpl *_evtImpl ;
-
     IMPL::LCRunHeaderImpl *_runImpl ;
 
     std::set<IO::LCRunListener*> _runListeners ;
@@ -183,7 +185,7 @@
     EventMap _evtMap ;
     const bool _readEventMap ;
 
-    int _entry ;
+    int _evtEntry, _runEntry ;
 
   }; // class
 } // namespace

lcio/src/cpp/include/RIO
RIOWriter.h 1.1.2.4 -> 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- RIOWriter.h	1 Dec 2009 09:19:21 -0000	1.1.2.4
+++ RIOWriter.h	4 Dec 2009 10:03:16 -0000	1.1.2.5
@@ -12,6 +12,7 @@
 
 class TFile ;
 class TTree ;
+class TBranch ;
 
 namespace RIO {
 
@@ -119,11 +120,14 @@
     int _compressionLevel ;
     
     TFile* _file ; 
-    TTree* _tree ;
+    TTree* _evtTree ;
+    TTree* _runTree ;
     
     IMPL::LCEventImpl* _evtImpl ;
     const IMPL::LCRunHeaderImpl* _runImpl ;
     
+    TBranch* _runHdrBranch ;
+
     BranchHandlerMap _branches ;
     bool _haveBranches ; 
     

lcio/src/cpp/include/RIO
rootio_templates.h 1.1.2.6 -> 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- rootio_templates.h	1 Dec 2009 14:15:32 -0000	1.1.2.6
+++ rootio_templates.h	4 Dec 2009 10:03:16 -0000	1.1.2.7
@@ -15,6 +15,7 @@
 #include "IMPL/ClusterImpl.h"
 #include "IMPL/LCRelationImpl.h"
 #include "IMPL/LCCollectionVec.h"
+#include "IMPL/LCRefVec.h"
 
 #include "TRefArray.h"
 #include <string>

lcio/src/cpp/src/RIO
RIOReader.cc 1.1.2.7 -> 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- RIOReader.cc	27 Nov 2009 16:04:42 -0000	1.1.2.7
+++ RIOReader.cc	4 Dec 2009 10:03:16 -0000	1.1.2.8
@@ -38,14 +38,15 @@
 
   RIOReader::RIOReader( int lcReaderFlag ) :
     _file(0),
-    _tree(0),
+    _evtTree(0),
+    _runTree(0),
     _haveBranches( false ),
     _evtImpl(0), 
     _runImpl(0), 
     _myFilenames(0), 
     _currentFileIndex(0),
     _readEventMap( lcReaderFlag & LCReader::directAccess ), 
-    _entry(-1) {
+    _evtEntry(-1), _runEntry(-1) {
     
 #ifdef DEBUG
 #else
@@ -118,11 +119,14 @@
 				      +  rioFilename ) ) ;
 
 
-    _tree = (TTree*) _file->Get("LCIO") ;
-    
-    if( !_tree ){
-
-      throw IOException( std::string( "[RIOReader::open()] Couldn't find \"LCIO\"-TTree " 
+    _evtTree = (TTree*) _file->Get("LCEvent") ;
+    if( !_evtTree ){
+      throw IOException( std::string( "[RIOReader::open()] Couldn't find \"LCEvent\"-TTree " 
+				      +  rioFilename ) ) ;
+    }
+    _runTree = (TTree*) _file->Get("LCRunHeader") ;
+    if( !_runTree ){
+      throw IOException( std::string( "[RIOReader::open()] Couldn't find \"LCRunHeader\"-TTree " 
 				      +  rioFilename ) ) ;
     }
     
@@ -199,24 +203,31 @@
   }
 
   LCRunHeader* RIOReader::readNextRunHeader(int accessMode) throw (IOException , std::exception ) {
+    
+    _runEntry ++ ;
 
-    // ToDo ...
+    // read event header first
+    if( ! _runHdrBranch )   {
+
+      _runHdrBranch = (TBranch*) _runTree->GetBranch( "LCRunHeader" ) ;
+      
+      if( _runHdrBranch == 0 ){        
+	
+	throw IOException( std::string( "[RIOReader::readNextRunHeader()] cant open branch \"LCRunHeader\" " ) ) ;
+      } 
 
-    // //   // set the _runRecord to unpack for this scope
-    // //     //    RIORecordUnpack runUnp( RIOWriter::_runRecord ) ;
-    // //     RIOUnpack runUnp( RIOUnpack::RUN ) ;
-
-
-    // //     // this might throw the exceptions
-    // //     try{ 
-    // //       readRecord() ;
-    // //     }
-    // //     catch(EndOfDataException){
-    // //       return 0 ;
-    // //     }
+      _runHdrBranch->SetAddress( &_runImpl ) ;
+    }
     
-    // //     // set the proper acces mode before returning the event
-    // //     (*_runP)->setReadOnly(  accessMode == LCIO::READ_ONLY   ) ;
+
+    Long64_t tentry =  _runTree->LoadTree( _runEntry );
+
+    int nbyte=0 ; 
+    nbyte = _runHdrBranch->GetEntry(tentry);
+
+    if( tentry < 0 ){
+      return 0 ; // EOF ?
+    }
 
     return _runImpl ;
   }
@@ -247,7 +258,7 @@
 	// 	if( *name == "MCParticlesSkimmed" )
 	//	if( *name == "PandoraPFOs" )
 
-	_branches[ *name ] =  new RIO::RIOLCCollectionHandler( *name, typeName   , _tree)  ;	
+	_branches[ *name ] =  new RIO::RIOLCCollectionHandler( *name, typeName   , _evtTree)  ;	
 
       }
 
@@ -268,11 +279,11 @@
     //------------------------------------------------------  
     
       
-    _entry ++ ;
+    _evtEntry ++ ;
 
     // read event header first
       
-    TBranch* br = (TBranch*) _tree->GetBranch( "LCEvent" ) ;
+    TBranch* br = (TBranch*) _evtTree->GetBranch( "LCEvent" ) ;
       
     if( br == 0 ){        
 	
@@ -281,7 +292,7 @@
       
     br->SetAddress( &_evtImpl ) ;
 
-    Long64_t tentry =  _tree->LoadTree( _entry );
+    Long64_t tentry =  _evtTree->LoadTree( _evtEntry );
 
     int nbyte=0 ; 
     nbyte = br->GetEntry(tentry);
@@ -311,7 +322,7 @@
     const StrVec& strVec = *( _evtImpl->getCollectionNames() ) ; 
 
     std::cout << " >>>>>>>>> tentry : " << tentry 
-	      << " _entry " << _entry  
+	      << " _evtEntry " << _evtEntry  
 	      << "  eventnum " << _evtImpl->getEventNumber()  
 	      << " ncols: " << strVec.size() 
 	      << " nbyte: " << nbyte
@@ -326,36 +337,7 @@
   
   void RIOReader::skipNEvents(int n) {
     
-    _entry += n ;
-
-    //     int eventsSkipped = 0 ;
-    
-    //     RIOUnpack hdrUnp( RIOUnpack::EVENTHDR ) ;
-    
-    //     while( eventsSkipped++ < n ){
-      
-    //       try { 
-	
-    // 	readRecord() ;
-
-    //       }
-    //       catch(EndOfDataException){
-
-    // 	return ;
-    //       }
-    //     }
-
-    //     // now we need to also read the next  record which suposedly is an event record
-    //     // in order to prevent readStream from reading this event (the last to be skipped)
-    //     RIOUnpack evtUnp( RIOUnpack::EVENT ) ;
-    
-    //     try{ 
-    //       readRecord() ;
-    //     }
-    //     catch(EndOfDataException){
-    //       return ;
-    //     }
-    
+    _evtEntry += n ;
   }
 
 

lcio/src/cpp/src/RIO
RIOWriter.cc 1.1.2.8 -> 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- RIOWriter.cc	1 Dec 2009 11:11:03 -0000	1.1.2.8
+++ RIOWriter.cc	4 Dec 2009 10:03:16 -0000	1.1.2.9
@@ -14,7 +14,7 @@
 #include "IMPL/LCIOExceptionHandler.h"
 #include "UTIL/LCTOOLS.h"
 
-//#define DEBUG 1
+#define DEBUG 1
 #ifdef DEBUG
 #include "IMPL/LCTOOLS.h"
 #endif
@@ -39,7 +39,9 @@
   RIOWriter::RIOWriter() : 
     _compressionLevel(-1) ,
     _file(0),
-    _tree(0),_evtImpl(0),
+    _evtTree(0),_runTree(0),
+    _evtImpl(0), _runImpl(0),
+    _runHdrBranch(0),
     _haveBranches( false ) {
     
     	// file needs 
@@ -110,21 +112,27 @@
     case EVENT::LCIO::WRITE_NEW : 
       
       _file = new TFile( rioFilename.c_str() , "RECREATE" , " LCIO file " , _compressionLevel );
-      _tree = new TTree( RIO_LCIO_TREENAME , "lcio tree");
+      _evtTree = new TTree( "LCEvent" , "lcio event tree");
+      _runTree = new TTree( "LCRunHeader" , "lcio run header tree");
       break ;
       
     case EVENT::LCIO::WRITE_APPEND : 
       
       _file = new TFile( rioFilename.c_str() , "UPDATE" , " LCIO file " , _compressionLevel );
-      _tree = (TTree*) _file->Get( RIO_LCIO_TREENAME ) ;
+      _evtTree =  (TTree*) _file->Get(  "LCEvent" ) ;
+      _runTree =  (TTree*) _file->Get(  "LCRunHeader" ) ;
       
-      if( _tree == 0 ) {
-	
-	throw IOException( std::string( "[RIOWriter::open()]  LCIO tree not found in file: " 
+      if( _evtTree == 0 ) {
+	throw IOException( std::string( "[RIOWriter::open()]  LCIO event tree not found in file: " 
 					+  rioFilename ) ) ;
       } else {
-	
-	_file->Delete(  RIO_LCIO_TREENAME_CYCLE_1 ) ; // delete the existing old cycle
+	_file->Delete(   "LCEvent;1" ) ; // delete the existing old cycle
+      }
+      if( _runTree == 0 ) {
+	throw IOException( std::string( "[RIOWriter::open()]  LCIO run header tree not found in file: " 
+					+  rioFilename ) ) ;
+      } else {
+	_file->Delete(   "LCRunHeader;1" ) ; // delete the existing old cycle
       }
       
       break ;
@@ -140,7 +148,8 @@
 				      +  rioFilename ) ) ;
 
 
-    _tree->SetAutoSave() ;
+    _evtTree->SetAutoSave() ;
+    _runTree->SetAutoSave() ;
   }
   
 
@@ -150,46 +159,37 @@
 
 
   void RIOWriter::writeRunHeader(const EVENT::LCRunHeader * hdr)  throw(IOException, std::exception) {
-
-//     // create a new handler for every new run 
-    
-// //     if( !_runHandler){
-// //       _runHandler = dynamic_cast<RIORunHeaderHandler*> 
-// // 	( RIO_blockManager::get( LCRIO::RUNBLOCKNAME  ) ) ;
-      
-// //       if( _runHandler == 0 ) 
-// // 	_runHandler = new RIORunHeaderHandler( LCRIO::RUNBLOCKNAME  ) ;
-      
-//     _runRecord->disconnect(LCRIO::RUNBLOCKNAME ) ;
-//     _runRecord->connect( _runHandler );
-// //     }
-//    _file->Close() ;
-
-
-
-//     _runHandler->setRunHeader(  hdr ) ;
     
-//     if( _stream->getState()== RIO_STATE_OPEN ){
-      
-//       _hdrRecord->setCompress( _compressionLevel != 0 ) ;
-//       _evtRecord->setCompress( _compressionLevel != 0 ) ;
-//       _runRecord->setCompress( _compressionLevel != 0 ) ; 
+#ifdef DEBUG
+    std::cout << "------- RIOWriter::writeRunHeader() "  <<   hdr->getRunNumber() << std::endl ;
+#endif
 
-//       // write LCRunHeader record
-//       unsigned int status =  _stream->write( LCRIO::RUNRECORDNAME    ) ;
+    if(  !_runHdrBranch ){
       
-//       if( !(status & 1)  )
-// 	throw IOException( std::string( "[RIOWriter::writeRunHeader] couldn't write run header to stream: "
-// 					+  *_stream->getName() ) ) ;
-//     } else {
+      _runHdrBranch = (TBranch*) _runTree->GetBranch( RIO_LCRUNHEADER_BRANCHNAME ) ;
       
-//       throw IOException( std::string( "[RIOWriter::writeRunHeader] stream not opened: "
-// 				      +  *_stream->getName() ) ) ;
+      if( _runHdrBranch != 0 ){  // branch allready exists -> update/append  mode 
+	
+	_runHdrBranch->SetAddress( &_runImpl ) ;
+	
+      } else {
+	
+	//FIXME: make split level and 'record size' parameters ....
+	_runHdrBranch = _runTree->Branch( RIO_LCRUNHEADER_BRANCHNAME , &_runImpl, RIO_RECORD_SIZE, RIO_SPLIT_LEVEL );
+      }
+#ifdef DEBUG
+      std::cout << "------- RIOWriter::writeRunHeader() branch : " << _runHdrBranch <<  std::endl ;
+#endif
       
-//     }
+      if( !_runHdrBranch ){
+	throw IOException("[RIOWriter::writeRunHeader] cannot create or find branch for LCRunHeader !" ) ;
+      }
+    } 
+    _runImpl =  dynamic_cast<const LCRunHeaderImpl*>( hdr)  ; 
+    _runTree->Fill() ;
 
   }
-
+  
   void RIOWriter::setUpHandlers(const LCEvent * evt){
    
     if( !_haveBranches ) {
@@ -197,7 +197,7 @@
 
       // first we create a branch for the event (header) 
       
-      TBranch* br = (TBranch*) _tree->GetBranch( RIO_LCEVENT_BRANCHNAME ) ;
+      TBranch* br = (TBranch*) _evtTree->GetBranch( RIO_LCEVENT_BRANCHNAME ) ;
       
       if( br != 0 ){  // branch allready exists -> update/append  mode 
 	
@@ -206,7 +206,7 @@
       } else {
 	
 	//FIXME: make split level and 'record size' parameters ....
-	br = _tree->Branch( RIO_LCEVENT_BRANCHNAME , &_evtImpl, RIO_RECORD_SIZE, RIO_SPLIT_LEVEL );
+	br = _evtTree->Branch( RIO_LCEVENT_BRANCHNAME , &_evtImpl, RIO_RECORD_SIZE, RIO_SPLIT_LEVEL );
       }
 
       // if we want to have one branch per collection (when pointer isssue is resolved)
@@ -222,7 +222,7 @@
 #endif
 	//	if( *name != "RecoMCTruthLink" ) 
 	//	if( *name == "PandoraPFOs" ) 
-	  _branches[ *name ] =  new RIO::RIOLCCollectionHandler( *name, typeName, _tree) ;	 
+	  _branches[ *name ] =  new RIO::RIOLCCollectionHandler( *name, typeName, _evtTree) ;	 
       }
 
       _haveBranches = true ;
@@ -276,7 +276,7 @@
     }
     
     _evtImpl = &proxyEvt ; 
-    _tree->Fill() ;
+    _evtTree->Fill() ;
     //_file->Flush() ;
 
     // now we need to take the ownership for the  collections away from proxy Event
CVSspam 0.2.8