Print

Print


Commit in lcio/src/cpp/include/IMPL on rio_v00-00
LCRefVec.h+170added 1.1.2.1
AccessChecked.h+2-21.6 -> 1.6.12.1
ClusterImpl.h+12-31.13 -> 1.13.16.1
LCCollectionVec.h+7-11.11.20.1 -> 1.11.20.2
LCEventImpl.h+17-331.19.8.4 -> 1.19.8.5
LCParametersImpl.h+41.2 -> 1.2.20.1
LCRelationImpl.h+10-21.7 -> 1.7.16.1
MCParticleImpl.h+12-41.23.16.1 -> 1.23.16.2
ReconstructedParticleImpl.h+15-41.12.12.2 -> 1.12.12.3
TrackImpl.h+7-31.15 -> 1.15.8.1
VertexImpl.h+3-11.2 -> 1.2.12.1
+259-53
1 added + 10 modified, total 11 files
added classes Ref and RefVec to replace pointers in  data classes

lcio/src/cpp/include/IMPL
LCRefVec.h added at 1.1.2.1
diff -N LCRefVec.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ LCRefVec.h	20 Nov 2009 15:12:05 -0000	1.1.2.1
@@ -0,0 +1,170 @@
+// -*- C++ -*-
+#ifndef IMPL_LCRefVec_H
+#define IMPL_LCRefVec_H 1
+
+#include "LCIOTypes.h"
+#include "LCEventImpl.h"
+#include <iostream>
+#include <vector>
+
+namespace IMPL {
+
+  /** LCRef is used for replacing single pointers with object-indices 
+   * 
+   * @see LCIO
+   * @author gaede 
+   * @version Nov 14, 2009
+   */
+  template <class T>
+  class LCRef{
+
+    T _ptr;               //!
+    EVENT::long64 _ref ;
+    bool _havePtr ;       //!
+    LCEventImpl* _evt ;   //!
+
+  public:
+
+    LCRef() : _ptr(0), 
+	      _ref(0),
+	      _havePtr( false ) {
+      // -- need to get current event on loading.... 
+      _evt = LCEventImpl::getCurrentEvent() ;
+    }
+
+    LCRef(T t) : _ptr(t), 
+		 _ref(0),
+		 _havePtr( true ) {
+      // -- need to get current event on loading.... 
+      _evt = LCEventImpl::getCurrentEvent() ;
+    }
+    
+    const LCRef<T>& operator=(const T& t) {
+      _ptr = t ;
+      _ref = 0 ;
+      _havePtr = true  ;
+      return *this ;
+    }
+
+    void ptrToIndex() {
+      _ref = _ptr->getIndex() ;
+    }
+    
+    void indexToPtr() {
+      _ptr = reinterpret_cast<T>( _evt->getObjectForIndex(_ref)  )  ;
+    }
+
+
+    // conversion to ptr
+    operator T&() { 
+      
+      if( ! _havePtr ) {
+	_havePtr = (_ptr!=0 && _ref==0 ) ;
+	if( ! _havePtr ) {
+	  indexToPtr() ;
+	  _havePtr = true ; 
+	}
+      }
+      return _ptr ;
+    }
+
+  };
+
+
+  /** LCRefVec is used for replacing vectors of pointers with verctor of indices 
+   * 
+   * @see LCIO
+   * @author gaede 
+   * @version Nov 14, 2009
+   */
+  template <class T>
+  class LCRefVec{
+
+    std::vector<T> _vec;                 //! no RIO
+    std::vector<EVENT::long64> _refVec ;
+    LCEventImpl* _evt ;                  //! no RIO
+    bool _havePtrs ;                     //! no RIO
+
+  public:
+    
+    typedef typename std::vector<T>::iterator iterator ;
+    typedef typename std::vector<T>::const_iterator const_iterator ;
+
+  LCRefVec() : _havePtrs( false ) {
+      // -- need to get current event on loading.... 
+      _evt = LCEventImpl::getCurrentEvent() ;
+    }
+    
+    void ptrToIndex() {
+
+
+      unsigned n =  _vec.size() ;
+
+      //      std::cout << " ----------------ptrToIndex - n : " << n  << std::endl ;
+
+      _refVec.clear() ;
+      _refVec.resize( n ) ;
+      for(unsigned i=0 ; i<n ; i++) {
+
+	//	std::cout << " ----------------ptrToIndex " << _vec[i]->getIndex() << std::endl ;
+
+      	_refVec[ i ] = _vec[i]->getIndex() ;
+      }
+    }
+
+    void indexToPtr() {
+
+      unsigned n =  _refVec.size() ;
+      //      std::cout << " ----------------indexToPtr - n: " << n << "  _vec.size()  " << _vec.size() << std::endl ;
+
+      _vec.clear() ;
+      _vec.resize( n ) ;
+      for(unsigned i=0 ; i<n ; i++) {
+
+	//std::cout << " ----------------indexToPtr " << _refVec[i] << std::endl ;
+ 
+      	_vec[i] = static_cast<T>( _evt->getObjectForIndex(  _refVec[i]  )  )  ;
+      }
+    }
+
+    // forward some of std::vector's interface so that we can serve as a wrapper to vector ------------
+
+    inline void push_back(T t){
+      _vec.push_back(t) ;
+    }
+    inline void resize(size_t nS){   _vec.resize(nS) ; }
+
+    inline T& operator[](size_t n){  return _vec[n] ; }
+
+    inline const T& operator[](size_t n) const { return _vec[n] ; }
+
+    inline T& 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() ; }
+    inline const_iterator begin() const {  return _vec.begin() ; }
+    inline const_iterator end() const { return _vec.end() ; }
+    
+    // conversion to reference of std::vector
+    operator std::vector<T>&() { 
+
+      //      std::cout << " --------------- operator std::vector<T>&() -  _vec.size()  " << _vec.size() << " refVec.size() " << _refVec.size() << std::endl ;
+
+      if( ! _havePtrs ) {
+	_havePtrs = (_vec.size()>0 && _refVec.size()==0 ) ;
+	if( ! _havePtrs ) {
+	  indexToPtr() ;
+	  _havePtrs = true ; 
+	}
+      }
+      return _vec ;
+    }
+
+  };
+
+
+
+} // namespace 
+#endif 

lcio/src/cpp/include/IMPL
AccessChecked.h 1.6 -> 1.6.12.1
diff -u -r1.6 -r1.6.12.1
--- AccessChecked.h	18 Dec 2006 14:29:08 -0000	1.6
+++ AccessChecked.h	20 Nov 2009 15:12:04 -0000	1.6.12.1
@@ -31,8 +31,8 @@
     void checkAccess(const char* what) throw ( EVENT::ReadOnlyException ) ;
 
   protected: 
-    bool _readOnly ;
-    int _id ;
+    bool _readOnly ;    //! no RIO
+    int _id ;           //! no RIO
     
   };
 } // namespace IMPL

lcio/src/cpp/include/IMPL
ClusterImpl.h 1.13 -> 1.13.16.1
diff -u -r1.13 -r1.13.16.1
--- ClusterImpl.h	4 Aug 2006 16:52:46 -0000	1.13
+++ ClusterImpl.h	20 Nov 2009 15:12:04 -0000	1.13.16.1
@@ -1,9 +1,11 @@
+// -*- C++ -*-
 #ifndef IMPL_CLUSTERIMPL_H
 #define IMPL_CLUSTERIMPL_H 1
 
 
 #include "EVENT/Cluster.h"
 #include "AccessChecked.h"
+#include "IMPL/LCRefVec.h"
 #include <map>
 #include <bitset>
 
@@ -19,7 +21,7 @@
  *
  * @see Cluster
  * @author gaede
- * @version $Id: ClusterImpl.h,v 1.13 2006/08/04 16:52:46 gaede Exp $
+ * @version $Id: ClusterImpl.h,v 1.13.16.1 2009/11/20 15:12:04 gaede Exp $
  */
   class ClusterImpl : public EVENT::Cluster, public AccessChecked {
     
@@ -135,6 +137,11 @@
      */
     EVENT::FloatVec& subdetectorEnergies() ;
 
+    void ptrToIndex() {
+      _clusters.ptrToIndex() ;
+      _hits.ptrToIndex() ;
+    }
+
   protected:
     void setType(int type ) ; 
 
@@ -149,8 +156,10 @@
     EVENT::FloatVec _errdir ;
     EVENT::FloatVec _shape ;
     EVENT::ParticleIDVec _pid ;
-    EVENT::ClusterVec _clusters ;
-    EVENT::CalorimeterHitVec _hits ;
+    //    EVENT::ClusterVec _clusters ;
+    mutable LCRefVec<EVENT::Cluster*> _clusters ;
+    //    EVENT::CalorimeterHitVec _hits ;
+    mutable LCRefVec<EVENT::CalorimeterHit*> _hits ;
     EVENT::FloatVec _weights ;
     EVENT::FloatVec _subdetectorEnergies ;
 

lcio/src/cpp/include/IMPL
LCCollectionVec.h 1.11.20.1 -> 1.11.20.2
diff -u -r1.11.20.1 -r1.11.20.2
--- LCCollectionVec.h	7 Jul 2009 12:49:54 -0000	1.11.20.1
+++ LCCollectionVec.h	20 Nov 2009 15:12:04 -0000	1.11.20.2
@@ -19,7 +19,7 @@
    *  of LCObjects.
    * 
    * @author gaede 
-   * @version $Id: LCCollectionVec.h,v 1.11.20.1 2009/07/07 12:49:54 gaede Exp $
+   * @version $Id: LCCollectionVec.h,v 1.11.20.2 2009/11/20 15:12:04 gaede Exp $
    * @see LCObject
    * @see LCCollection
    */
@@ -142,6 +142,12 @@
      */
     virtual EVENT::LCParameters & parameters() { return _params ; } 
     
+    /**Helper function to convert object addresses into indices for all objects:  ((hash<<32)||index) */
+    void setIndices( unsigned hash ) ;
+
+    /** Calls ptrToIndex for all elements */
+    void ptrToIndex() ;
+    
 
   protected:
     void setReadOnly(bool readOnly) ;

lcio/src/cpp/include/IMPL
LCEventImpl.h 1.19.8.4 -> 1.19.8.5
diff -u -r1.19.8.4 -r1.19.8.5
--- LCEventImpl.h	18 Sep 2009 09:33:39 -0000	1.19.8.4
+++ LCEventImpl.h	20 Nov 2009 15:12:04 -0000	1.19.8.5
@@ -16,7 +16,9 @@
   
   //class  EVENT::LCCollection ;
   
-  typedef std::map<std::string,EVENT::LCCollection*> LCCollectionMap ; 
+  //  typedef std::map<std::string,EVENT::LCCollection*> LCCollectionMap ; 
+  typedef std::map<unsigned,EVENT::LCCollection*> LCCollectionMap ; 
+
   typedef std::set<EVENT::LCCollection*> LCCollectionSet ;
   //   typedef std::map<std::string,EVENT::LCRelation*> LCRelationMap ; 
   
@@ -32,10 +34,10 @@
     
   public: 
     LCEventImpl() ;
-    /** Copy contructor, creates a deep copy of the event.
-     * Not yet - needs pointer chasing ...
+
+    /** Copy contructor only copies the event header - the collectionds have to be copied manually as needed.
      */
-    //    LCEventImpl(const EVENT::LCEvent& evt) ;  // copy c'tor
+    LCEventImpl(const LCEventImpl& evt) ;  
     
     /**Destructor.
      */
@@ -103,31 +105,6 @@
     virtual void removeCollection(const std::string & name) throw (EVENT::ReadOnlyException, std::exception)  ;
     
 
-//     //fg20040528:   added relations to the event
-//     /** Returns the names of the relations in the  event.
-//      */
-//     virtual const std::vector<std::string>  * getRelationNames() const ;
-
-//     /** Returns the relation for the given name.
-//      *
-//      * @throws DataNotAvailableException
-//      */
-//     virtual EVENT::LCRelation * getRelation(const std::string & name) const throw (EVENT::DataNotAvailableException, std::exception)  ;
-
-//     /** Adds a relation with the given name. Throws an exception if the name already
-//      * exists in the event. NB: Adding relations is allowed even when the event is 'read only'.
-//      * 
-//      *@throws EventException
-//      */ 
-//     virtual void addRelation(EVENT::LCRelation * col, const std::string & name) throw (EVENT::EventException, std::exception)  ;
-
-//     /** Removes (and deletes) the relation with name (if it exists in the event). 
-//      * Throws an exception if the event is 'read only' as defined by the read mode in LCReader.
-//      *
-//      *@throws ReadOnlyException
-//      */ 
-//     virtual void removeRelation(const std::string & name) throw (EVENT::ReadOnlyException, std::exception)  ;
-
     /** Parameters defined for this event.
      */
     virtual const EVENT::LCParameters & getParameters() const { return _params ; }
@@ -157,6 +134,12 @@
      */
     void setWeight(double w) ;
      
+    static LCEventImpl* getCurrentEvent() { return _current ; }
+    EVENT::LCObject* getObjectForIndex(EVENT::long64 index) ;
+    void setCurrentEvent( LCEventImpl* evt) { _current = evt ; } 
+    void ptrToIndex() ;
+
+
   protected:
     void setAccessMode( int accessMode ) ;
     
@@ -164,8 +147,8 @@
      * (regular expression) [A-Za-z_] and continuing with [A-Za-z0-9_] (C/C++ variable name).
      */
     bool validateCollectionName( const char* name ) ;
-      
-    // data members - declared protected to be accessible 
+    
+  // data members - declared protected to be accessible 
     // for friends of sub classes ...
     
   protected:  
@@ -175,14 +158,15 @@
     std::string _detectorName ;
     
     // map has to be defined mutable in order to use _map[]  for const methods ...
-    mutable LCCollectionMap _colMap ;    
-    mutable std::vector<std::string> _colNames ; //! no RIO
+    mutable LCCollectionMap _colMap ;         //! no RIO
+    mutable std::vector<std::string> _colNames ;
     
     LCParametersImpl _params ;
     
     // set of collections that are not owned by the event anymore
     mutable LCCollectionSet _notOwned ;   //! no RIO
     
+    static LCEventImpl* _current ;
 
   }; // class
 

lcio/src/cpp/include/IMPL
LCParametersImpl.h 1.2 -> 1.2.20.1
diff -u -r1.2 -r1.2.20.1
--- LCParametersImpl.h	14 Jul 2004 15:50:41 -0000	1.2
+++ LCParametersImpl.h	20 Nov 2009 15:12:04 -0000	1.2.20.1
@@ -41,6 +41,9 @@
   public: 
     
     LCParametersImpl() ; 
+   
+    LCParametersImpl(const LCParametersImpl& other) ;
+    LCParametersImpl&  operator=(const LCParametersImpl& other) ;
     
     /// Destructor.
     virtual ~LCParametersImpl() { /* nop */; }
@@ -121,6 +124,7 @@
     virtual void setValues(const std::string & key, EVENT::StringVec & values);
 
 
+
   protected:
 
     mutable IntMap _intMap ;

lcio/src/cpp/include/IMPL
LCRelationImpl.h 1.7 -> 1.7.16.1
diff -u -r1.7 -r1.7.16.1
--- LCRelationImpl.h	4 Aug 2006 16:52:46 -0000	1.7
+++ LCRelationImpl.h	20 Nov 2009 15:12:05 -0000	1.7.16.1
@@ -7,6 +7,7 @@
 
 #include "EVENT/LCRelation.h"
 #include "EVENT/LCObject.h"
+#include "IMPL/LCRefVec.h"
 #include "AccessChecked.h"
 
 
@@ -39,9 +40,16 @@
     void setWeight( float weight ) { _weight = weight ; }
     
 
+    void ptrToIndex() {
+      _from.ptrToIndex() ;
+      _to.ptrToIndex() ;
+    }
+
   protected:
-    EVENT::LCObject* _from ;
-    EVENT::LCObject* _to ;
+    //    EVENT::LCObject* _from ;
+    mutable IMPL::LCRef<EVENT::LCObject*> _from ;
+    //EVENT::LCObject* _to ;
+    mutable IMPL::LCRef<EVENT::LCObject*> _to ;
     float _weight ;
 
 }; // class

lcio/src/cpp/include/IMPL
MCParticleImpl.h 1.23.16.1 -> 1.23.16.2
diff -u -r1.23.16.1 -r1.23.16.2
--- MCParticleImpl.h	8 Jul 2009 15:09:02 -0000	1.23.16.1
+++ MCParticleImpl.h	20 Nov 2009 15:12:05 -0000	1.23.16.2
@@ -7,6 +7,7 @@
 #include "AccessChecked.h"
 
 #include "EVENT/MCParticle.h"
+#include "IMPL/LCRefVec.h"
 #include <bitset>
 
 namespace IMPL {
@@ -19,7 +20,7 @@
   /** Implementation of MCParticle.
    * 
    * @author gaede
-   * @version $Id: MCParticleImpl.h,v 1.23.16.1 2009/07/08 15:09:02 gaede Exp $
+   * @version $Id: MCParticleImpl.h,v 1.23.16.2 2009/11/20 15:12:05 gaede Exp $
    */
   class MCParticleImpl : public EVENT::MCParticle, public AccessChecked {
     
@@ -229,6 +230,11 @@
 
     virtual void setStopped(bool val) ;
 
+    void ptrToIndex() {
+      _parents.ptrToIndex() ;
+      _daughters.ptrToIndex() ;
+    }
+
   protected:
 
     /** Adds a daughter particle - only called from addParent().
@@ -247,9 +253,11 @@
     double _mass ;
     float _charge ;
     float _time ;
-    EVENT::MCParticleVec _parents ;
-    EVENT::MCParticleVec _daughters ;
-    bool _endpointSet ;
+    mutable LCRefVec<EVENT::MCParticle*> _parents ;
+    mutable LCRefVec<EVENT::MCParticle*> _daughters ;
+//     EVENT::MCParticleVec _parents ;
+//     EVENT::MCParticleVec _daughters ;
+    bool _endpointSet ;    //! no RIO
 
 }; // class
 } // namespace IMPL

lcio/src/cpp/include/IMPL
ReconstructedParticleImpl.h 1.12.12.2 -> 1.12.12.3
diff -u -r1.12.12.2 -r1.12.12.3
--- ReconstructedParticleImpl.h	13 Jul 2009 08:30:46 -0000	1.12.12.2
+++ ReconstructedParticleImpl.h	20 Nov 2009 15:12:05 -0000	1.12.12.3
@@ -5,6 +5,7 @@
 
 #include "EVENT/ReconstructedParticle.h"
 #include "AccessChecked.h"
+#include "LCRefVec.h"
 
 
 #define NCOVARIANCE 10
@@ -32,6 +33,11 @@
 
     virtual int id() const { return simpleUID() ; }
 
+    void ptrToIndex() {
+//       _particles.ptrToIndex() ;
+//       _clusters.ptrToIndex() ;
+//       _tracks.ptrToIndex() ;
+    }
 
     /** Type of reconstructed particle.
      *  Check/set collection parameterrs ReconstructedParticleTypeNames and 
@@ -139,11 +145,16 @@
     EVENT::ParticleID* _pidUsed ;
     float _goodnessOfPID ;
     EVENT::ParticleIDVec _pid ;
-    EVENT::ReconstructedParticleVec _particles ;
-    EVENT::ClusterVec _clusters ;
-    EVENT::TrackVec _tracks ; //#### ! tell ROOT to not stream this ...
 
-    EVENT::Vertex* _sv ;
+    //    EVENT::ReconstructedParticleVec _particles ;
+    mutable LCRefVec<EVENT::ReconstructedParticle*> _particles ;
+    //    EVENT::ClusterVec _clusters ;
+    mutable LCRefVec<EVENT::Cluster*> _clusters ;
+    //    EVENT::TrackVec _tracks ; 
+    mutable LCRefVec<EVENT::Track*> _tracks ;
+    
+    //    EVENT::Vertex* _sv ;
+    mutable LCRef<EVENT::Vertex*> _sv ;
     
 }; // class
 

lcio/src/cpp/include/IMPL
TrackImpl.h 1.15 -> 1.15.8.1
diff -u -r1.15 -r1.15.8.1
--- TrackImpl.h	18 Sep 2007 09:47:10 -0000	1.15
+++ TrackImpl.h	20 Nov 2009 15:12:05 -0000	1.15.8.1
@@ -1,9 +1,11 @@
+// -*- C++ -*-
 #ifndef IMPL_TRACKIMPL_H
 #define IMPL_TRACKIMPL_H 1
 
 
 #include "EVENT/Track.h"
 #include "AccessChecked.h"
+#include "IMPL/LCRefVec.h"
 #include <map>
 #include <bitset>
 
@@ -22,7 +24,7 @@
  *
  * @see Track
  * @author gaede
- * @version $Id: TrackImpl.h,v 1.15 2007/09/18 09:47:10 gaede Exp $
+ * @version $Id: TrackImpl.h,v 1.15.8.1 2009/11/20 15:12:05 gaede Exp $
  */
 
   class TrackImpl : public EVENT::Track, public AccessChecked {
@@ -192,8 +194,10 @@
     float _radiusOfInnermostHit ;
     EVENT::IntVec _subdetectorHitNumbers ;
 
-    EVENT::TrackVec _tracks ;
-    EVENT::TrackerHitVec _hits ;
+    //    EVENT::TrackVec _tracks ;
+    mutable LCRefVec <EVENT::Track*> _tracks ;
+    //EVENT::TrackerHitVec _hits ;
+    mutable LCRefVec <EVENT::TrackerHit*> _hits ;
 
 }; // class
 

lcio/src/cpp/include/IMPL
VertexImpl.h 1.2 -> 1.2.12.1
diff -u -r1.2 -r1.2.12.1
--- VertexImpl.h	21 Sep 2006 06:10:38 -0000	1.2
+++ VertexImpl.h	20 Nov 2009 15:12:05 -0000	1.2.12.1
@@ -4,6 +4,7 @@
 
 
 #include "EVENT/Vertex.h"
+#include "IMPL/LCRefVec.h"
 #include "AccessChecked.h"
 
 #define VTXCOVMATRIX 6
@@ -91,7 +92,8 @@
     float _vpos[3] ;
     EVENT::FloatVec _cov ;
     EVENT::FloatVec _par ;
-    EVENT::ReconstructedParticle* _aParticle ;
+    //    EVENT::ReconstructedParticle* _aParticle ;
+    mutable LCRef<EVENT::ReconstructedParticle*> _aParticle ;
    
 }; // class
 
CVSspam 0.2.8