Print

Print


Commit in lcio/src/cpp on rio_v00-00
include/IMPL/LCEventImpl.h+3-11.19.8.5 -> 1.19.8.6
src/IMPL/LCEventImpl.cc+29-41.24.8.2 -> 1.24.8.3
+32-5
2 modified files
added caching of last collection used for getObjectForIndex()

lcio/src/cpp/include/IMPL
LCEventImpl.h 1.19.8.5 -> 1.19.8.6
diff -u -r1.19.8.5 -r1.19.8.6
--- LCEventImpl.h	20 Nov 2009 15:12:04 -0000	1.19.8.5
+++ LCEventImpl.h	27 Nov 2009 16:01:31 -0000	1.19.8.6
@@ -166,8 +166,10 @@
     // set of collections that are not owned by the event anymore
     mutable LCCollectionSet _notOwned ;   //! no RIO
     
-    static LCEventImpl* _current ;
+    std::pair< unsigned , EVENT::LCCollection* > _cache ; //! no RIO
 
+    static LCEventImpl* _current ;
+    
   }; // class
 
 } // namespace IMPL

lcio/src/cpp/src/IMPL
LCEventImpl.cc 1.24.8.2 -> 1.24.8.3
diff -u -r1.24.8.2 -r1.24.8.3
--- LCEventImpl.cc	20 Nov 2009 15:28:51 -0000	1.24.8.2
+++ LCEventImpl.cc	27 Nov 2009 16:01:31 -0000	1.24.8.3
@@ -7,7 +7,8 @@
 
 #include <iostream>
 #include <sstream>
-
+#include <algorithm>
+#include <iomanip>
 
 using namespace EVENT ;
 //using namespace DATA ;
@@ -20,7 +21,7 @@
   _runNumber(0),
   _eventNumber(0),
   _timeStamp(0),
-  _detectorName("unknown") {
+  _detectorName("unknown"),_cache(0,0) {
 }
 
 LCEventImpl::LCEventImpl(const LCEventImpl& evt) :
@@ -28,7 +29,7 @@
   _eventNumber( evt._eventNumber ),
   _timeStamp( evt._timeStamp ),
   _detectorName(evt._detectorName),
-  _params( evt._params ) {
+  _params( evt._params ),_cache(0,0) {
   
   //  mutable LCCollectionSet _notOwned ;   // what should we do here ??
   
@@ -82,12 +83,31 @@
     unsigned hash = ( index >> 32 &  0xffffffff ) ;
     unsigned i = index & 0xffffffff ;
 
+    if( hash == _cache.first && _cache.second ){
+      
+      return _cache.second->getElementAt( i ) ;
+    }
+
+    _cache.first = 0 ;
+    _cache.second = 0 ;
+
     LCCollectionMap::iterator it = _colMap.find( hash  )  ;
 
     if( it != _colMap.end() ) {
       
+      _cache = *it ;
+
       return it->second->getElementAt( i ) ;
     }
+
+//     std::cout << " getObjectForIndex - col not found for idx: "  << std::hex <<  index  
+// 	      << " ! - cols : "   ;
+//     for ( LCCollectionMap::iterator i=_colMap.begin() ; i != _colMap.end() ; i++ ){
+//       std::cout <<  i->first  << " , " ;
+//     }
+//     std::cout <<  std::dec << std::endl ;
+    
+
     return 0 ;
   }
 
@@ -204,7 +224,12 @@
 
   _colMap[ Hash( name  ) ]  = col ;
   
-  _colNames.push_back( name ) ;
+
+  // check if the name already exists in the event (e.g. after it has been read from a file )
+  std::vector<std::string>::iterator it =  std::find( _colNames.begin(), _colNames.end() , name ) ;
+  if( it == _colNames.end() ) 
+    _colNames.push_back( name ) ;
+  
 }
 
     
CVSspam 0.2.8