| Report problems to ATLAS LXR Team (with time and IP address indicated) |
|
[ source navigation ] [ diff markup ] [ identifier search ] [ general search ] |
||||
|
||||||
| Links to LXR source navigation pages for stable releases | [ 12.*.* ] [ 13.*.* ] [ 14.*.* ] [ 15.*.* ] | |||||
001 // $Id: GaudiTuples.h,v 1.7 2008/10/27 19:22:20 marcocle Exp $ 002 #ifndef GAUDIALG_GAUDITUPLES_H 003 #define GAUDIALG_GAUDITUPLES_H 1 004 005 // ============================================================================ 006 /* @file GaudiTuples.h 007 * 008 * Header file for class : GaudiTuples 009 * 010 * @author Chris Jones Christopher.Rob.Jones@cern.ch 011 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 012 * @date 2005-08-08 013 */ 014 // ============================================================================ 015 016 // Include files 017 // ============================================================================ 018 // GaudiKernel 019 // ============================================================================ 020 #include "GaudiKernel/ClassID.h" 021 // ============================================================================ 022 // GaudiAlg 023 // ============================================================================ 024 #include "GaudiAlg/Maps.h" 025 #include "GaudiAlg/Tuple.h" 026 #include "GaudiAlg/TupleObj.h" 027 028 // ============================================================================ 029 /** @class GaudiTuples GaudiTuples.h GaudiAlg/GaudiTuples.h 030 * 031 * Templated base class providing common 'ntupling' methods 032 * 033 * @author Chris Jones Christopher.Rob.Jones@cern.ch 034 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 035 * @date 2005-08-08 036 */ 037 // ============================================================================ 038 039 template <class PBASE> 040 class GaudiTuples : public PBASE 041 { 042 043 public: 044 045 /// the actual type for histogram identifier 046 typedef GaudiAlg::HistoID HistoID; 047 048 /// the actual type of the tuple 049 typedef Tuples::Tuple Tuple ; 050 /// the actual type of N-tuple ID 051 typedef GaudiAlg::TupleID TupleID ; 052 053 /// the actual type of (title) -> (tuple) mappping 054 typedef GaudiAlg::TupleMapTitle TupleMapTitle ; 055 /// the actual type of (Numeric ID) -> (tuple) mappping 056 typedef GaudiAlg::TupleMapNumericID TupleMapNumID ; 057 /// the actual type of (Literal ID) -> (tuple) mappping 058 typedef GaudiAlg::TupleMapLiteralID TupleMapLitID ; 059 060 public: 061 062 /** Access an N-Tuple object (book on-demand) with unique identifier 063 * 064 * @code 065 * 066 * Tuple tuple = nTuple( "My N-Tuple" ) ; 067 * tuple->column( "A" , sin(0.1) ); 068 * tuple->column( "B" , cos(0.1) ); 069 * tuple->column( "C" , tan(0.1) ); 070 * tuple->write(); 071 * 072 * @endcode 073 * 074 * @attention 075 * The NTuple will get a unique identifier automatically assigned which by 076 * default will be equal to the histogram title. An option exists to instead 077 * use numerical IDs. In this case the first NTuple booked will be ID=1 the 078 * next ID=2 and so on. Note though this scheme is not recommended as it does 079 * NOT guarantee predictability of the ID a given NTuple will be given when 080 * filled under conditional statements, since in these circumstances the order 081 * in which the NTuple are first filled, and thus booked, will depend on the 082 * nature of the first few events read. This is particularly problematic when 083 * users submit many parallel 'sub-jobs' and then attempt to merge the final 084 * output ROOT (or HBOOK) files, since a given NTuple could have different IDs 085 * in each of the sub-jobs. Consequently it is strongly recommended that users do 086 * not use numerical automatic IDs unless they are sure they understand what they 087 * are doing. 088 * 089 * @param title Unique title for N-Tuple 090 * @param clid N-Tuple class identifier (row or column wise) 091 * @return ntuple The ntuple object 092 */ 093 Tuple nTuple ( const std::string& title , 094 const CLID& clid = CLID_ColumnWiseTuple ) const ; 095 096 /** Access an N-Tuple object (book on-demand) with forced identifier 097 * 098 * @code 099 * 100 * // Book Ntuple with a numeric ID 101 * Tuple tuple = nTuple( 1, "My tuple" ) ; 102 * // ... or 103 * Tuple tuple = nTuple( "1", "My tuple" ) ; 104 * 105 * // ... or, Book Ntuple with a literal ID 106 * Tuple tuple = nTuple( "mytuple", "My tuple" ) ; 107 * 108 * // ... or, Book Ntuple with a literal ID in a sub-dir 109 * Tuple tuple = nTuple( "subdir/mytuple", "My tuple" ) ; 110 * 111 * // Fill and write NTuple 112 * tuple->column( "A" , sin(0.1) ); 113 * tuple->column( "B" , cos(0.1) ); 114 * tuple->column( "C" , tan(0.1) ); 115 * tuple->write(); 116 * 117 * @endcode 118 * 119 * @attention 120 * If the N-Tuple with given ID is already booked 121 * through automatic assignement of N-Tuple ID, 122 * the error will not be detected. 123 * Therefore it is recommended 124 * to use a non-trivial N-Tuple ID offset (property "NTupleOffSet") 125 * if one need to combine these techniques together 126 * It is still desirable to use the unique N-Tuple title 127 * to avoid a bad interference. 128 * 129 * @param ID The forced N-Tuple ID 130 * @param title Unique title for N-Tuple 131 * @param clid N-Tuple class identifier (row or column wise) 132 * @return ntuple The ntuple object 133 */ 134 Tuple nTuple ( const TupleID& ID , 135 const std::string& title , 136 const CLID& clid = CLID_ColumnWiseTuple ) const ; 137 138 /** Access an Event Tag Collection object (book on-demand) with unique identifier 139 * 140 * @code 141 * 142 * Tuple tuple = evtCol( "My Tag Collection" ) ; 143 * tuple->column( "A" , sin(0.1) ); 144 * tuple->column( "B" , cos(0.1) ); 145 * tuple->column( "C" , tan(0.1) ); 146 * tuple->write(); 147 * 148 * @endcode 149 * 150 * The Event Tag Collection will get a unique identifier automatically assigned which by 151 * default will be equal to the histogram title. An option exists to instead 152 * use numerical IDs. In this case the first Event Tag Collection booked will be ID=1 the 153 * next ID=2 and so on. Note though this scheme is not recommended as it does 154 * NOT guarantee predictability of the ID a given Event Tag Collection will be given when 155 * filled under conditional statements, since in these circumstances the order 156 * in which the Event Tag Collection are first filled, and thus booked, will depend on the 157 * nature of the first few events read. This is particularly problematic when 158 * users submit many parallel 'sub-jobs' and then attempt to merge the final 159 * output ROOT (or HBOOK) files, since a given Event Tag Collection could have different IDs 160 * in each of the sub-jobs. Consequently it is strongly recommended that users do 161 * not use numerical automatic IDs unless they are sure they understand what they 162 * are doing. 163 * 164 * @param title Unique title for Event Tag Collection 165 * @param clid N-Tuple class identifier (row or column wise) 166 * @return ntuple The Event Tag Collection object 167 */ 168 Tuple evtCol ( const std::string& title , 169 const CLID& clid = CLID_ColumnWiseTuple ) const ; 170 171 /** Access an Event Tag Collection object (book on-demand) with forced identifier 172 * 173 * @code 174 * 175 * // Book Ntuple with a numeric ID 176 * Tuple tuple = evtCol( 1, "My Tag Collection" ) ; 177 * // ... or 178 * Tuple tuple = evtCol( "1", "My Tag Collection" ) ; 179 * 180 * // ... or, Book Ntuple with a literal ID 181 * Tuple tuple = evtCol( "mytuple", "My Tag Collection" ) ; 182 * 183 * // ... or, Book Ntuple with a literal ID in a sub-dir 184 * Tuple tuple = evtCol( "subdir/mytuple", "My Tag Collection" ) ; 185 * 186 * // Fill and write 187 * tuple->column( "A" , sin(0.1) ); 188 * tuple->column( "B" , cos(0.1) ); 189 * tuple->column( "C" , tan(0.1) ); 190 * tuple->write(); 191 * 192 * @endcode 193 * 194 * @attention 195 * If the Event Tag Collection with given ID is already booked 196 * through automatic assignement of Event Tag Collection ID, 197 * the error will not be detected. 198 * Therefore it is recommended 199 * to use a non-trivial Event Tag Collection ID offset (property "EvtColOffSet") 200 * if one need to combine these techniques together 201 * It is still desirable to use the unique Event Tag Collection title 202 * to avoid a bad interference. 203 * 204 * @param ID The forced Event Tag Collection ID 205 * @param title Unique title for Event Tag Collection 206 * @param clid N-Tuple class identifier (row or column wise) 207 * @return ntuple The Event Tag Collection object 208 */ 209 Tuple evtCol ( const TupleID& ID , 210 const std::string& title , 211 const CLID& clid = CLID_ColumnWiseTuple ) const ; 212 213 public: // trivial accessors 214 215 /// get the flag for N-Tuple production (property "NTupleProduce") 216 bool produceNTuples () const { return m_produceNTuples ; } 217 /// get the flag for N-Tuple path split (property "NTupleSplitDir") 218 bool splitNTupleDir () const { return m_splitNTupleDir ; } 219 /// get the logical unit for N-Tuples (property "NTupleLUN") 220 const std::string& nTupleLUN () const { return m_nTupleLUN ; } 221 /// get the top-level N-Tuple directory (property "NTupleTopDir") 222 const std::string& nTupleTopDir () const { return m_nTupleTopDir ; } 223 /// get the N-Tuple directory (property "NTupleDir") 224 const std::string& nTupleDir () const { return m_nTupleDir ; } 225 /// get the value for N-Tuple offset (property "NTupleOffSet") 226 TupleID::NumericID nTupleOffSet () const { return m_nTupleOffSet ; } 227 /// get the constructed N-Tuple path 228 std::string nTuplePath () const 229 { 230 const std::string path = nTupleLUN() + "/" + nTupleTopDir() + nTupleDir(); 231 return ( splitNTupleDir() ? dirHbookName( path ) : path ) ; 232 } 233 234 /// get the flag for Event Tag Collection production (property "EvtColsProduce") 235 bool produceEvtCols () const { return m_produceEvtCols ; } 236 /// get the flag for Event Tag Collection path split (property "EvtColsSplitDir") 237 bool splitEvtColDir () const { return m_splitEvtColDir ; } 238 /// get the logical unit for Event Tag Collections (property "EvtColsLUN") 239 const std::string& evtColLUN () const { return m_evtColLUN ; } 240 /// get the top-level Event Tag Collection directory (property "EvtColsTopDir") 241 const std::string& evtColTopDir () const { return m_evtColTopDir ; } 242 /// get the Event Tag Collection directory (property "EvtColsDir") 243 const std::string& evtColDir () const { return m_evtColDir ; } 244 /// get the value for Event Tag Collection offset (property "EvtColsOffSet") 245 TupleID::NumericID evtColOffSet () const { return m_evtColOffSet ; } 246 /// get the constructed Event Tag Collection path 247 std::string evtColPath () const 248 { 249 std::string path = evtColLUN() + "/" + evtColTopDir() + evtColDir(); 250 return ( splitEvtColDir() ? dirHbookName( path ) : path ); 251 } 252 253 /// print tuples at finalization 254 bool tuplesPrint () const { return m_tuplesPrint ; } 255 /// print event collections at finalization 256 bool evtColsPrint () const { return m_evtColsPrint ; } 257 258 public : 259 260 /** perform the actual printout of N-tuples 261 * @return number of active N-Tuples 262 */ 263 long printTuples () const ; 264 265 /** perform the actual printout of Evt Tag Collections 266 * @return number of active Event Tag Collections 267 */ 268 long printEvtCols () const ; 269 270 public : 271 272 /// check the existence AND validity of the N-Tuple with the given ID 273 bool nTupleExists ( const TupleID& ID ) const; 274 275 /// check the existence AND validity of the Event Tag Collection with the given ID 276 bool evtColExists ( const TupleID& ID ) const; 277 278 protected: 279 280 /// access to the all ntuples by title 281 const TupleMapTitle& nTupleMapTitle () const { return m_nTupleMapTitle ; } 282 /// access to the all evet tag collections by title 283 const TupleMapTitle& evtColMapTitle () const { return m_evtColMapTitle ; } 284 /// access to the all ntuples by numeric ID 285 const TupleMapNumID& nTupleMapNumID () const { return m_nTupleMapNumID ; } 286 /// access to the all evet tag collections by numeric ID 287 const TupleMapNumID& evtColMapNumID () const { return m_evtColMapNumID ; } 288 /// access to the all ntuples by literal ID 289 const TupleMapLitID& nTupleMapLitID () const { return m_nTupleMapLitID ; } 290 /// access to the all evet tag collections by literal ID 291 const TupleMapLitID& evtColMapLitID () const { return m_evtColMapLitID ; } 292 293 protected: 294 295 /** create TupleObj 296 * @attention The method should never used directly by users 297 * @param name name/title 298 * @param tuple the underlying ntuple implementation 299 * @param clid unique classID for ntuple 300 * @return pointer to newly created TupleObj 301 */ 302 virtual Tuples::TupleObj* 303 createNTuple ( const std::string& name , 304 NTuple::Tuple* tuple , 305 const CLID& clid ) const ; 306 307 /** create TupleObj for event tag collection 308 * @attention The method should never used directly by users 309 * @param name name/title 310 * @param tuple the underlying ntuple implementation 311 * @param clid unique classID for ntuple 312 * @return pointer to newly created TupelObj 313 */ 314 virtual Tuples::TupleObj* 315 createEvtCol ( const std::string& name , 316 NTuple::Tuple* tuple , 317 const CLID& clid ) const ; 318 319 public: 320 321 /// Algorithm constructor 322 GaudiTuples ( const std::string & name, 323 ISvcLocator * pSvcLocator ); 324 325 /// Tool constructor 326 GaudiTuples ( const std::string& type , 327 const std::string& name , 328 const IInterface* parent ); 329 330 /// Destructor 331 virtual ~GaudiTuples(); 332 333 protected: 334 335 /** standard initialization method 336 * @return status code 337 */ 338 virtual StatusCode initialize (); 339 340 /** standard finalization method 341 * @return status code 342 */ 343 virtual StatusCode finalize (); 344 345 private: 346 347 /// Constructor initialisation and job options 348 inline void initGaudiTuplesConstructor() 349 { 350 m_produceNTuples = true ; // Switch ON/OFF ntuple production 351 m_splitNTupleDir = false ; // for HBOOK it is better to use 'true' 352 m_nTupleLUN = "FILE1" ; // logical unit for ntuples 353 m_nTupleTopDir = "" ; // top level ntuple directory 354 m_nTupleDir = this->name() ; // ntuple directory 355 m_nTupleOffSet = 0 ; // offset for ntuples 356 // 357 m_produceEvtCols = false ; // Switch ON/OFF ntupel production 358 m_splitEvtColDir = false ; // for HBOOK it is better to use 'true' 359 m_evtColLUN = "EVTCOL" ; // logical unit for ntuples 360 m_evtColTopDir = "" ; // top level ntuple directory 361 m_evtColDir = this->name() ; // ntuple directory 362 m_evtColOffSet = 0 ; // offset for ntuples 363 // 364 m_tuplesPrint = true ; // print tuples at end of job 365 m_evtColsPrint = false ; // print event collections at end of job 366 // 367 this->declareProperty ( "NTupleProduce" , m_produceNTuples ) ; 368 this->declareProperty ( "NTuplePrint" , m_tuplesPrint ) ; 369 this->declareProperty ( "NTupleSplitDir" , m_splitNTupleDir ) ; 370 this->declareProperty ( "NTupleOffSet" , m_nTupleOffSet ) ; 371 this->declareProperty ( "NTupleLUN" , m_nTupleLUN ) ; 372 this->declareProperty ( "NTupleTopDir" , m_nTupleTopDir ) ; 373 this->declareProperty ( "NTupleDir" , m_nTupleDir ) ; 374 // 375 this->declareProperty ( "EvtColsProduce" , m_produceEvtCols ) ; 376 this->declareProperty ( "EvtColsPrint" , m_evtColsPrint ) ; 377 this->declareProperty ( "EvtColSplitDir" , m_splitEvtColDir ) ; 378 this->declareProperty ( "EvtColOffSet" , m_evtColOffSet ) ; 379 this->declareProperty ( "EvtColLUN" , m_evtColLUN ) ; 380 this->declareProperty ( "EvtColTopDir" , m_evtColTopDir ) ; 381 this->declareProperty ( "EvtColDir" , m_evtColDir ) ; 382 } 383 384 private: 385 386 /// flag to switch ON/OFF the ntuple filling and booking 387 bool m_produceNTuples ; 388 /// flag to indicate splitting of tuple directories (useful for HBOOK) 389 bool m_splitNTupleDir ; 390 /// name of logical unit for tuple directory 391 std::string m_nTupleLUN ; 392 /// top level tuple directory 393 std::string m_nTupleTopDir ; 394 /// local tuple directory 395 std::string m_nTupleDir ; 396 /// the offset for ntuple numerical ID 397 TupleID::NumericID m_nTupleOffSet ; 398 399 /// flag to switch ON/OFF the ntuple filling and booking 400 bool m_produceEvtCols ; 401 /// flag to indicate splitting of tuple directories (useful for HBOOK) 402 bool m_splitEvtColDir ; 403 /// name of Logical Unit for tuple directory 404 std::string m_evtColLUN ; 405 /// top level tuple directory 406 std::string m_evtColTopDir ; 407 /// local tuple directory 408 std::string m_evtColDir ; 409 /// the offset for ntuple numerical ID 410 TupleID::NumericID m_evtColOffSet ; 411 412 /// print tuples at finalization? 413 bool m_tuplesPrint ; ///< print tuples at finalization? 414 /// print event collections at finalization 415 bool m_evtColsPrint ; ///< print event collections at finalization 416 417 /// the actual storage of ntuples by title 418 mutable TupleMapTitle m_nTupleMapTitle ; 419 /// the actual storage of ntuples by numeric ID 420 mutable TupleMapNumID m_nTupleMapNumID ; 421 /// the actual storage of ntuples by literal ID 422 mutable TupleMapLitID m_nTupleMapLitID ; 423 424 /// the actual storage of event collections by title 425 mutable TupleMapTitle m_evtColMapTitle ; 426 /// the actual storage of event collections by numeric ID 427 mutable TupleMapNumID m_evtColMapNumID ; 428 /// the actual storage of event collections by literal ID 429 mutable TupleMapLitID m_evtColMapLitID ; 430 431 }; 432 433 #endif // GAUDIALG_GAUDITUPLES_H 434
| [ source navigation ] | [ diff markup ] | [ identifier search ] | [ general search ] |
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems | |
| This page was automatically generated by the LXR engine. |
|