|
|
[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] |
||||
|   | ||||||
|
||||||
001 //============================================================================ 002 // CdfTrackColl.hh 003 // --------------- 004 // Collection of CdfTrack objects that can be stored and retrieved from the 005 // event record. The collection uses the RefVector class from the CDF Event 006 // Data Model (EDM), and therefore provides direct access to the underlying 007 // container, std::vector< CdfTrack_lnk >. Tracks are stored by reference 008 // in the container, using the CdfTrack_lnk "smart pointer" class from 009 // the EDM as the reference. (The Link<> behaves like a normal pointer.) 010 // The tracks themselves are stored directly in the event, since CdfTrack is 011 // a StorableObject, but the collection manages the task of adding the tracks 012 // to the event at the appropriate time. 013 // 014 // NOTE: Under no circumstances should users append to the event record 015 // any track contained in a CdfTrackColl. 016 // 017 // To add a track to the collection, one must add a properly initialized 018 // CdfTrack_lnk to the underlying vector. The typedef CdfTrack_lnk has 019 // been defined in CdfTrack.hh to facilitate this task: 020 // 021 // CdfTrack * pTrack = new CdfTrack; 022 // CdfTrackColl * pColl = new CdfTrackColl; 023 // pColl->contents().push_back( CdfTrack_lnk( pTrack ) ); 024 // 025 // Note that the collection assumes ownership of the CdfTrack upon 026 // insertion. See Edm/Link.hh for details of other ways to initialize 027 // Link's. 028 // 029 // NOTE: The user should never delete the pointer to a CdfTrack that 030 // is contained in a CdfTrackColl. 031 // 032 // The set also manages track ID numbers: every track added to the set 033 // will be assigned an ID value that is unique among all other tracks in all 034 // CdfTrackColls ever defined within a particular event. Tracks are 035 // automatically assigned ID's by the assignTrackIds() method. This can 036 // be called by the user, but is also called by the set immediately prior 037 // writing the set to persistent storage. Note that tracks with pre-existing 038 // ID values that were not assigned by the set may result in corrupted, 039 // missing or non-unique ID values. Users should not assign ID's to tracks. 040 // 041 // 042 // How to use standard algorithms to filter a set of tracks 043 // -------------------------------------------------------- 044 // Since the underlying container is an STL class, the generic algorithms 045 // in the standard library can be used to manipulate the contents of the 046 // set. A common need is to select a set of tracks satisfying some criterion. 047 // Commonly used criteria can be found in TrackingObjects/Tracks/track_cut.hh. 048 // Others can be derived from the base class CdfTrackCut in 049 // TrackingObjects/Tracks/CdfTrackCutBase.hh. Note that any class that 050 // has a member function 'bool operator () (const CdfTrack_lnk &)' can be 051 // used as a filter in the generic algorithm. Given such a class Selector, one 052 // can find all tracks in the set satisfying Selector( track ) == true 053 // with the following loop: 054 // 055 // CdfTrackColl::const_iterator i; 056 // for ( i = find_if( trackSet.contents().begin(), 057 // trackSet.contents().end(), 058 // Selector() ) 059 // ; i != trackSet.contents().end() 060 // ; i = find_if( ++i, trackSet.contents().end(), Selector() ) ) 061 // { 062 // ... 063 // } 064 // 065 // 066 // Note on constructiong a *new* set for tracks with silicon hits 067 // -------------------------------------------------------------- 068 // Since there are potentially many independent sets of 069 // silicon clusters in an event, the source of silicon hits used for the 070 // tracks in a newly constructed set must be specified before the links 071 // to the silicon hits can be properly written out with the event. 072 // Specify a SiHitSet in the constructor for the track 073 // set to establish this source. This is necessary only 074 // if the set is written out, and then only if the silicon hit links are 075 // to be stored. 076 // 077 // COT hits are assumed to come from whatever (single) CT_HitSet is in 078 // the event. 079 // 080 // Author: 081 // R. Snider 082 // 1-Oct-1999 083 // 12-Nov-1999: Design 2. 084 //============================================================================ 085 #ifndef CDFTRACKCOLL_HH_ 086 #define CDFTRACKCOLL_HH_ 1 087 088 #include <algorithm> 089 #include <iosfwd> 090 #include <string> 091 #include <vector> 092 093 #include "TrackingObjects/Tracks/CdfTrack.hh" 094 #include "Edm/ConstHandle.hh" 095 #include "Edm/Link.hh" 096 #include "Edm/StorableObject.hh" 097 #include "StorableContainers/RefVector.hh" 098 #include "StorableContainers/StrRefVector.hh" 099 100 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 101 // Forward declarations 102 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 103 104 class CdfTrack; 105 class CdfTrackCollNtuplizer; 106 class CdfTrackIdManager; 107 class EventRecord; 108 class SiHitSet; 109 class TBuffer; 110 111 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 112 // Global typedefs for EDM handles 113 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 114 115 class CdfTrackColl; 116 typedef Handle<CdfTrackColl> CdfTrackColl_h; 117 typedef ConstHandle<CdfTrackColl> CdfTrackColl_ch; 118 119 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 120 // Class definition 121 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 122 123 class CdfTrackColl : public StorableObject 124 { 125 126 // The clone pseudo constructor has been automatically 127 // inserted by a batch process. A unique identifier 128 // was not found so it was placed at the very beginning 129 // of the class definition. 130 131 public: 132 virtual CdfTrackColl* clone(void); // Pseudo-constructor 133 134 public: 135 136 //-------------------------------------------------------------------------- 137 // Typedefs 138 //-------------------------------------------------------------------------- 139 140 typedef CdfTrack * value_type; 141 typedef std::vector<value_type>::iterator iterator; 142 typedef std::vector<value_type>::const_iterator const_iterator; 143 typedef value_type & reference; 144 typedef const value_type & const_reference; 145 typedef value_type * pointer; 146 typedef const value_type * const_pointer; 147 typedef std::vector<value_type>::difference_type difference_type; 148 typedef std::vector<value_type>::size_type size_type; 149 150 typedef std::vector<value_type> CollType; 151 typedef CollType collection_type; 152 153 //-------------------------------------------------------------------------- 154 // Function to retrieve set from the event 155 //-------------------------------------------------------------------------- 156 157 enum Error 158 { 159 OK, 160 ERROR 161 }; 162 163 static Error find( CdfTrackColl_ch & setHandle ); 164 static Error find( CdfTrackColl_ch & setHandle, 165 const StorableObject::Selector & selector ); 166 167 //-------------------------------------------------------------------------- 168 // Constructors 169 //-------------------------------------------------------------------------- 170 171 // Create an empty collection for tracks with NO silicon hits. 172 // 173 CdfTrackColl(); 174 175 // Create an empty collection for tracks WITH silicon hits. 176 // 177 CdfTrackColl( const ConstHandle<SiHitSet> & ); 178 179 // Copy from 'first' to 'last'. If the tracks are to contain silicon 180 // hits, then a ConstHandle<SiHitSet> must be provided. 181 // 182 template<class InputIterator> 183 CdfTrackColl( InputIterator first, InputIterator last, 184 const ConstHandle<SiHitSet> & 185 = ConstHandle<SiHitSet>() ); 186 187 //-------------------------------------------------------------------------- 188 // Allow owner of track collection to assign ID's to tracks 189 //-------------------------------------------------------------------------- 190 191 void assignTrackIds( EventRecord * pEvent ); 192 193 //-------------------------------------------------------------------------- 194 // Access to the underlying set of tracks. 195 //-------------------------------------------------------------------------- 196 197 // Non-const access 198 collection_type & contents(); 199 200 // Const access 201 const collection_type & contents() const; 202 203 //-------------------------------------------------------------------------- 204 // EDM: functions required by StorableObject 205 //-------------------------------------------------------------------------- 206 207 // Classification 208 // 209 // class_version = current version of this class 210 // 211 virtual std::string class_name() const ; 212 virtual Version_t class_version() const; 213 214 // EDM I/O functions 215 // 216 // I/O modes: 217 // 1) CdfTrack is a StorableObject: 218 // Tracks are streamed independently of collection. No compression 219 // possible. Tracks are streamed in and out in exactly the same way, 220 // although the streamer version number will change to the current 221 // version on output. (Streamer version 1.) 222 // 2) CdfTrack is streamable, collection is not compressed: 223 // Contents of collection are streamed during event I/O. 224 // (Streamer version 2, isCompressed() = false.) 225 // 3) CdfTrack is streamable, collection is compressed. 226 // Only the number of tracks is streamed during event I/O, not any 227 // information contained within the tracks. Transient state 228 // of the collection is restored/compressed during a "puffing" 229 // stage. (Streamer version 2, isCompressed() = true.) 230 // 231 bool isCompressed() const; 232 void setIsCompressed( bool isCompressed ); 233 // 234 // Streamer declared in ClassDef macro: 235 // virtual void Streamer( TBuffer & iobuffer ); 236 void ReadVersion1( TBuffer &iobuffer ); 237 void ReadVersion2( TBuffer &iobuffer ); 238 void ReadVersion3( TBuffer &iobuffer ); 239 void WriteVersion1( TBuffer &iobuffer ); 240 void WriteVersion2( TBuffer &iobuffer ); 241 void WriteVersion3( TBuffer &iobuffer ); 242 243 virtual bool postread( EventRecord * pRecord ); 244 virtual bool prewrite( EventRecord * pRecord ); 245 246 virtual bool activate( EventRecord * pRecord ); 247 virtual bool deactivate( EventRecord * pRecord ); 248 249 // Pseudo-destructors for EDM 250 // 251 virtual void destroy(); 252 virtual void deallocate(); 253 254 // I/O 255 // 256 virtual void print( std::ostream & os = std::cout ) const; 257 258 //-------------------------------------------------------------------------- 259 // Ntuplizer methods 260 //-------------------------------------------------------------------------- 261 262 static void attach_ntuplizer( CdfTrackCollNtuplizer * pNtuplizer ); 263 virtual void ntuplize() const; 264 265 protected: 266 267 virtual ~CdfTrackColl(); 268 269 private: 270 271 //-------------------------------------------------------------------------- 272 // Private utilities 273 //-------------------------------------------------------------------------- 274 275 // Initialize ID manager 276 void _initIdManager( EventRecord * pRecord ); 277 278 // Assign ID's to all tracks in the set 279 void _assignId(); 280 281 // Initialize tracks from the event on first access 282 void _initTracks() const; 283 void _setHitSets() const; 284 void _setMCMatches( EventRecord * pRecord ) const; 285 286 //-------------------------------------------------------------------------- 287 // Private data 288 //-------------------------------------------------------------------------- 289 290 // Data stored in persistent representation 291 // 292 StrRefVector<CdfTrack> _trackSet; 293 RefVector<CdfTrack> _tempTrackSet; // needed for backward compat. 294 Link<SiHitSet> _pHitSet; 295 296 // Transient state information 297 // 298 ConstHandle<CdfTrackIdManager> _pIdManager; 299 mutable bool _assignIdsOnOutput; // the set can grow 300 301 // _readStreamerVersion: 302 // 1 => CdfTrack is StorableObject. 303 // Input via ReadVersion1 304 // Output: 305 // Streamer version set to 2, 306 // _privateStreamerVersion written with value 1, 307 // _isCompressed written with value false, 308 // tracks stored using WriteVersion1. 309 // 2 => CdfTrack is Streamable 310 // Input: 311 // If restored _privateStreamerVersion == 1, then: 312 // tracks read using ReadVersion1 313 // If restored _privateStreamerVersion == 2 && restored 314 // _isCompressed == false, then: 315 // tracks read using ReadVersion2 316 // If restored _privateStreamerVersion == 2 && restored 317 // _isCompressed == true, then: 318 // only number of tracks read 319 // Output: 320 // Streamed out in exactly the same way as it was streamed in. 321 // 322 Version_t _privateStreamerVersion; 323 mutable bool _isCompressed; 324 325 // For n-tuplizing 326 // 327 static CdfTrackCollNtuplizer * _pNtuplizer; 328 329 //-------------------------------------------------------------------------- 330 // Not implemented 331 // 332 CdfTrackColl( const CdfTrackColl & ); 333 CdfTrackColl & operator = ( const CdfTrackColl & ); 334 //-------------------------------------------------------------------------- 335 336 337 //-------------------------------------------------------------------------- 338 // Root I/O hooks. 339 // ClassDef macro defined in root/include/Rtypes.h 340 // ClassDef( CdfTrackColl, 1 ) // CdfTracks are StorableObjects 341 // 342 // ClassDef( CdfTrackColl, 2 ) // CdfTracks are StreamableObjects 343 // 344 ClassDef( CdfTrackColl, 3 ) // bug fixes in compressed streaming 345 //-------------------------------------------------------------------------- 346 347 }; 348 349 inline ostream & operator << ( std::ostream & os, 350 const CdfTrackColl & trackSet ); 351 352 #ifndef __CINT__ 353 #include "TrackingObjects/Storable/CdfTrackColl.icc" 354 #endif // !__CINT__ 355 356 #endif // CDFTRACKCOLL_HH_ 357
| [ source navigation ] | [ diff markup ] | [ identifier search ] | [ freetext search ] | [ file search ] |
| This page was automatically generated by the LXR engine. The LXR team |
|