|
|
[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] |
||||
|   | ||||||
|
||||||
001 //============================================================================ 002 // CdfTrackView.hh 003 // --------------- 004 // Collection of references to CdfTrack objects that can be stored and 005 // retrieved from the event record. The collection uses the ConstStrViewVector 006 // class, and provides direct access to the underlying container, 007 // std::vector< CdfTrack_clnk >, where CdfTrack_clnk is a typedef to 008 // ConstStrRefVectorLink<CdfTrackColl,CdfTrack>. The view is a sub-class 009 // of StorableObject, and can therefore be appended to the event record, 010 // and stored and restored from a data file. The view, unlike the CdfTrackColl, 011 // does not own tracks -- it just points to them. 012 // 013 // The references in the view (the CdfTrack_clnk objects) behave like 014 // pointers for most purposes: 015 // 016 // Given a CdfTrack_clnk, 'link': 017 // 1) *link returns CdfTrack & 018 // 2) link-> allows access to methods of CdfTrack 019 // 3) if ( link ) return true if the link is non-null, and false if null 020 // 021 // Since a CdfTrack_clnk is a small object and simple to initialize, creating 022 // a view is very fast. The view is therefore ideal for holding the result 023 // of track selection or sorting operations. 024 // 025 // To add a track to the view, one must add a properly initialized 026 // link object to the underlying vector. The typedef 'CdfTrack_clnk' has 027 // been provided in CdfTrack.hh to simplify this task. Note that a link 028 // must be initialized with a link to the CdfTrackColl in which the track 029 // lives (see note on backward compatibility): 030 // 031 // Let 'pColl' = CdfTrackColl *, and 'pView' = CdfTrackView *. Then: 032 // 033 // CdfTrackColl::collection_type & tracks = pColl->contents(); 034 // CdfTrackView::collection_type & view = pView->contents(); 035 // for ( int i = 0 ; i < tracks.size() ; ++i ) 036 // { 037 // view.push_back( CdfTrack_clnk( Link<CdfTrackColl>(pColl), i ) ); 038 // } 039 // 040 // In most cases, a CdfTrack_clnk will already be available, so that 041 // 'view.push_back( link )' will work. See the header file for 042 // ConstStrRefVectorLink for alternative constructors. 043 // 044 // Several constructors have been provided to simplify the task of adding 045 // tracks subject to an arbitrary filter function. The standard library 046 // algorithms can also be used for this purpose. 047 // 048 // Standard views 049 // -------------- 050 // There are currently two static functions that apply pre-defined 051 // selection criteria to the tracks in the event, and return a view filled 052 // with only those tracks. The selection is defined by the tracking group, 053 // and cannot be altered except as provided by the tracking group. 054 // The functions include: 055 // 056 // 1) CdfTrackView::allTracks( CdfTrackView_h & handle, 057 // const std::string & procName) 058 // 059 // Fill a view with all tracks in the event record that belong to a 060 // CdfTrackColl with the process name 'procName'. A null string 061 // matches all process names. The default is a null string. 062 // 063 // 2) CdfTrackView::defTracks( CdfTrackView_h & handle, 064 // const std::string & procName ) 065 // 066 // Fill a view with all tracks in the event that (a) pass the default 067 // track selection, and (b) belong to a CdfTrackColl with the process 068 // name 'procName'. A null string matches all process names. The 069 // default process name is "PROD". 070 // 071 // 3) CdfTrackView::defTracksUnCut( CdfTrackView_h & handle, 072 // const std::string & procName ) 073 // 074 // Fill a view with all tracks in the event that (a) pass the default 075 // track selection, and (b) belong to a CdfTrackColl with the process 076 // name 'procName'. A null string matches all process names. The 077 // default process name is "PROD". 078 // 079 // An error is returned if no collections with the specified process 080 // name are found, if the appropriate track collection is not found 081 // among those with the correct process name, or if more than one 082 // "appropriate" collection is found. In the last case, all tracks 083 // from the matching collections will be included in the output view. 084 // 085 // 4) CdfTrackView::defTracksL3( CdfTrackView_h & handle, 086 // const std::string & procName ) 087 // 088 // Fill a view with all tracks in the event that (a) pass the l3 default 089 // track selection(COT parents are taken instead of OI children, and 090 // (b) belong to a CdfTrackColl with the process 091 // name 'procName'. A null string matches all process names. The 092 // default process name is "PROD". 093 // 094 // An error is returned if no collections with the specified process 095 // name are found, if the appropriate track collection is not found 096 // among those with the correct process name, or if more than one 097 // "appropriate" collection is found. In the last case, all tracks 098 // from the matching collections will be included in the output view. 099 // 100 // Another static function, CdfTrackView::selectTracks, fills a view 101 // with all tracks that pass a user-specified selector, and that live in a 102 // CdfTrackColl that passes a separate user-specified selector. 103 // 104 // Note that all three of the above functions, allTracks, defTracks and 105 // selectTracks, work correctly regardless of whether the view handle points 106 // to a pre-existing view or is null. In the former case, the functions clear 107 // the view and fill it with the result. In the latter case, the functions 108 // will create a new view, fill it with the results and set the description 109 // string (allTracks and defTracks only) to a standard value. 110 // 111 // Note on backwards compatibility 112 // ------------------------------- 113 // The view will work normally for tracks created prior to V4.1.0 of 114 // cdfsoft2 (i.e., CdfTracks that are derived from StorableObject and 115 // that live in the event record), provided that the tracks are referenced 116 // by a CdfTrackColl, and the links in the view are initialized as specified 117 // above. 118 // 119 // For backward compatibility, the view can also be used for tracks for which 120 // no reference to a CdfTrackColl is available. (This information is not 121 // always available for tracks treated as StorableObjects.) Such a view 122 // cannot be saved and restored in the event record, and cannot simultaneously 123 // contain fully initialized links. 124 // 125 // Author: 126 // R. Snider 127 // 12-Nov-1999 128 // Aug-2001: (RS) Re-written to accommodate streamable CdfTrack 129 //============================================================================ 130 #ifndef CDFTRACKVIEW_HH_ 131 #define CDFTRACKVIEW_HH_ 1 132 133 #include <algorithm> 134 #include <iosfwd> 135 #include <string> 136 #include <vector> 137 138 #include "Edm/ConstHandle.hh" 139 #include "Edm/ConstLink.hh" 140 #include "Edm/StorableObject.hh" 141 #include "StorableContainers/ConstStrViewVector.hh" 142 #include "StorableContainers/ViewVector.hh" 143 #include "TrackingObjects/Storable/CdfTrackColl.hh" 144 #include "TrackingObjects/Tracks/CdfTrack.hh" 145 #include "TrackingObjects/Tracks/track_cut.hh" 146 147 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 148 // Forward declarations 149 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 150 151 class CdfTrack; 152 // class CdfTrackColl; 153 class CdfTrackViewNtuplizer; 154 class CdfTrackIdManager; 155 class EventRecord; 156 class StorableSiClusterData; 157 class TBuffer; 158 159 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 160 // Global typedefs for EDM handles 161 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 162 163 class CdfTrackView; 164 typedef Handle<CdfTrackView> CdfTrackView_h; 165 typedef ConstHandle<CdfTrackView> CdfTrackView_ch; 166 167 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 168 // Class definition 169 //=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= 170 171 class CdfTrackView : public StorableObject 172 { 173 174 // The clone pseudo constructor has been automatically 175 // inserted by a batch process. A unique identifier 176 // was not found so it was placed at the very beginning 177 // of the class definition. 178 179 public: 180 virtual CdfTrackView* clone(void); // Pseudo-constructor 181 182 public: 183 184 //-------------------------------------------------------------------------- 185 // Typedefs 186 //-------------------------------------------------------------------------- 187 188 typedef CdfTrack_clnk value_type; 189 typedef std::vector<value_type>::iterator iterator; 190 typedef std::vector<value_type>::const_iterator const_iterator; 191 typedef value_type & reference; 192 typedef const value_type & const_reference; 193 typedef value_type * pointer; 194 typedef const value_type * const_pointer; 195 typedef std::vector<value_type>::difference_type difference_type; 196 typedef std::vector<value_type>::size_type size_type; 197 198 typedef std::vector<value_type> CollType; 199 typedef CollType collection_type; 200 201 //-------------------------------------------------------------------------- 202 // Functions to retrieve views from the event, or create standard views 203 //-------------------------------------------------------------------------- 204 205 enum Error 206 { 207 OK, 208 209 // Returned by 'find' methods 210 // 211 VIEW_NOT_FOUND, 212 213 // Returned by allTracks, defTracks, defTrackUnCut, defTracksL3 214 // 215 PROC_NAME_NOT_FOUND, // No CdfTrackColl's with requested process name 216 217 // Returned by defTracks and defTracksUnCut: 218 // No global tracking results found (=> collections with the process 219 // name were found, but none with the results needed by defTracks) 220 // 221 GLOB_TRKNG_NOT_FOUND, 222 // 223 // More than one collection with the appropriate global tracking 224 // results was found. 225 // 226 MULTIPLE_COLL_FOUND, 227 228 // Returned by selectTracks 229 // 230 MATCHING_COLL_NOT_FOUND 231 232 }; 233 234 static Error find( CdfTrackView_ch & viewHandle ); 235 static Error find( CdfTrackView_ch & viewHandle, 236 const StorableObject::Selector & selector ); 237 238 // Find a view identified by a description string 239 // 240 static Error find( CdfTrackView_ch & viewHandle, std::string description ); 241 242 // Description strings used by standard views: 243 // 244 static const std::string ALL_TRACK_DESCR; // allTracks 245 static const std::string DEF_TRACK_DESCR; // defTracks 246 static const std::string DEF_TRACK_UNCUT_DESCR; // defTracksUnCut 247 static const std::string DEF_TRACK_L3_DESCR; // defTracksL3 248 249 // Standard views: 250 // NOTE: a view passed into these functions will be cleared 251 // and filled with the result. If no view is assigned 252 // to the handle argument, the functions will create a new 253 // view and assign a standard description string to it. 254 // 255 static Error allTracks( CdfTrackView_h & viewHandle, 256 const std::string & processName = "" ); 257 static Error defTracks( CdfTrackView_h & viewHandle, 258 const std::string & processName = "PROD" ); 259 static Error defTracksUnCut( CdfTrackView_h & viewHandle, 260 const std::string & processName = "PROD" ); 261 static Error defTracksL3( CdfTrackView_h & viewHandle, 262 const std::string & processName = "PROD" ); 263 264 // Select tracks with independent selectors for the CdfTrackColl's 265 // scanned, and for the tracks within the collection. 266 // NOTE: same as note for allTracks and defTracks, except that 267 // no description string is ever assigned. 268 // 269 template<class TrackSelector> 270 static Error selectTracks( CdfTrackView_h & viewHandle, 271 const StorableObject::Selector & collSelector = 272 StorableObject::SelectAll(), 273 const TrackSelector & trackSelector = 274 track_cut::SelectAll() ); 275 276 //-------------------------------------------------------------------------- 277 // Constructors, assignment 278 //-------------------------------------------------------------------------- 279 280 CdfTrackView(); 281 CdfTrackView( const CdfTrackView & view ); 282 283 // Copy from 'first' to 'last'. Iterators assumed to point 284 // to CdfTrack_lnk 285 // 286 #ifndef __CINT__ 287 CdfTrackView( const_iterator first, const_iterator last ); 288 CdfTrackView( const ConstLink<CdfTrackColl> & sourceColl, 289 CdfTrackColl::const_iterator first, 290 CdfTrackColl::const_iterator last ); 291 #endif // !__CINT__ 292 293 #ifndef __CINT__ 294 // Copy from 'first' to 'last' subject to some 295 // selection cut. 296 // 297 template<class CdfTrackCut> 298 CdfTrackView( const_iterator first, const_iterator last, 299 CdfTrackCut selector ); 300 301 template<class CdfTrackCut> 302 CdfTrackView( const ConstLink<CdfTrackColl> & collLink, 303 CdfTrackColl::const_iterator first, 304 CdfTrackColl::const_iterator last, 305 CdfTrackCut selector ); 306 #endif // !__CINT__ 307 308 CdfTrackView & operator = ( const CdfTrackView & view ); 309 310 //-------------------------------------------------------------------------- 311 // Access to the underlying set of tracks. 312 //-------------------------------------------------------------------------- 313 314 // Non-const access 315 collection_type & contents(); 316 317 // Const access 318 const collection_type & contents() const; 319 320 // Construct track ID lookup table. 321 // Fills 'vector<int> & table' such that 322 // table[id] = index into vector returned by 'contents()' for 323 // the track with ID = 'id' (i.e., 324 // view.contents()[table[id]] = CdfTrack_clnk & for the 325 // desired track) 326 // = -1 if no track in the view has the specified ID 327 // Note that the user must guard against out-of-range ID's 328 // 329 void idLookupTable( std::vector<int> & table ) const; 330 331 //-------------------------------------------------------------------------- 332 // EDM: functions required by StorableObject 333 //-------------------------------------------------------------------------- 334 335 // Classification 336 // 337 // class_version = current version of this class 338 // 339 virtual std::string class_name() const ; 340 virtual Version_t class_version() const; 341 342 // EDM I/O functions 343 // 344 virtual bool postread( EventRecord * pRecord ); 345 // Streamer declared in ClassDef macro: 346 // virtual void Streamer( TBuffer & iobuffer ); 347 virtual bool prewrite( EventRecord * pRecord ); 348 349 virtual bool activate( EventRecord * pRecord ); 350 virtual bool deactivate( EventRecord * pRecord ); 351 352 // Pseudo-destructors for EDM 353 // 354 virtual void destroy(); 355 virtual void deallocate(); 356 357 // I/O 358 // 359 virtual void print( std::ostream & os = std::cout ) const; 360 361 362 //-------------------------------------------------------------------------- 363 // Ntuplizer methods 364 //-------------------------------------------------------------------------- 365 366 static void attach_ntuplizer( CdfTrackViewNtuplizer * pNtuplizer ); 367 virtual void ntuplize() const; 368 369 370 protected: 371 372 virtual ~CdfTrackView(); 373 374 private: 375 376 //-------------------------------------------------------------------------- 377 // Private utilities 378 // 379 void _fillViewFromTemp(); 380 bool _checkAndFillTempFromView(); 381 382 //-------------------------------------------------------------------------- 383 // Private data 384 //-------------------------------------------------------------------------- 385 386 // Data stored in persistent representation 387 // 388 ConstStrViewVector<CdfTrackColl,CdfTrack> _trackView; 389 ViewVector<CdfTrack> _tempTrackView; 390 391 // The streamer version used to read this instance 392 // => need to write accordingly: 393 // 1: view read in uses Link<CdfTrack> 394 // 2: view read in uses ConstStrRefVectorLink<CdfTrackColl,CdfTrack> 395 // 396 Version_t _readStreamerVersion; 397 398 // If true, check view for storage mode, and fill temp if needed. 399 // Allowed storage modes: 400 // 1) All links in view point to a collection 401 // => stream normally, do not fill temp 402 // 2) No links in view point to a collection and all tracks 403 // in the view are stored in the event 404 // => fill and stream the temp 405 // Illegal storage mode: 406 // 3) Some links in view point to tracks stored in the event, but not 407 // to a collection, while others point to tracks not stored in 408 // the event 409 // So, if one links does not point at a collection, then all links 410 // must point to tracks stored in the event. 411 // 412 bool _checkStorageMode; 413 414 // For n-tuplizing 415 // 416 static CdfTrackViewNtuplizer * _pNtuplizer; 417 418 419 420 //-------------------------------------------------------------------------- 421 // Root I/O hooks. 422 // ClassDef macro defined in root/include/Rtypes.h 423 // 424 ClassDef( CdfTrackView, 2 ) // class name, current version 425 // 426 //-------------------------------------------------------------------------- 427 428 }; 429 430 inline ostream & operator << ( std::ostream & os, 431 const CdfTrackView & trackSet ); 432 433 #ifndef __CINT__ 434 #include "TrackingObjects/Storable/CdfTrackView.icc" 435 #endif // !__CINT__ 436 437 #endif // CDFTRACKCOLL_HH_ 438
| [ source navigation ] | [ diff markup ] | [ identifier search ] | [ freetext search ] | [ file search ] |
| This page was automatically generated by the LXR engine. The LXR team |
|