GaudiTuples.h
Go to the documentation of this file.
1 // $Id: GaudiTuples.h,v 1.7 2008/10/27 19:22:20 marcocle Exp $
2 // ============================================================================
3 #ifndef GAUDIALG_GAUDITUPLES_H
4 #define GAUDIALG_GAUDITUPLES_H 1
5 // ============================================================================
6 /* @file GaudiTuples.h
7  *
8  * Header file for class : GaudiTuples
9  *
10  * @author Chris Jones Christopher.Rob.Jones@cern.ch
11  * @author Vanya BELYAEV Ivan.Belyaev@itep.ru
12  * @date 2005-08-08
13  */
14 // ============================================================================
15 // Include files
16 // ============================================================================
17 // GaudiKernel
18 // ============================================================================
19 #include "GaudiKernel/ClassID.h"
20 // ============================================================================
21 // GaudiAlg
22 // ============================================================================
23 #include "GaudiAlg/Maps.h"
24 #include "GaudiAlg/Tuple.h"
25 #include "GaudiAlg/TupleObj.h"
26 // ============================================================================
35 // ============================================================================
36 template <class PBASE>
37 class GAUDI_API GaudiTuples: public PBASE
38 {
39 public:
40  // ==========================================================================
42  typedef GaudiAlg::HistoID HistoID;
44  typedef Tuples::Tuple Tuple ;
46  typedef GaudiAlg::TupleID TupleID ;
51  // ==========================================================================
52 public:
53  // ==========================================================================
85  Tuple nTuple ( const std::string& title ,
86  const CLID& clid = CLID_ColumnWiseTuple ) const ;
87 
126  Tuple nTuple ( const TupleID& ID ,
127  const std::string& title ,
128  const CLID& clid = CLID_ColumnWiseTuple ) const ;
129 
160  Tuple evtCol ( const std::string& title ,
161  const CLID& clid = CLID_ColumnWiseTuple ) const ;
162 
201  Tuple evtCol ( const TupleID& ID ,
202  const std::string& title ,
203  const CLID& clid = CLID_ColumnWiseTuple ) const ;
204  // ==========================================================================
205 public: // trivial accessors
206  // ==========================================================================
208  bool produceNTuples () const { return m_produceNTuples ; }
210  bool splitNTupleDir () const { return m_splitNTupleDir ; }
212  const std::string& nTupleLUN () const { return m_nTupleLUN ; }
214  const std::string& nTupleTopDir () const { return m_nTupleTopDir ; }
216  const std::string& nTupleDir () const { return m_nTupleDir ; }
218  TupleID::NumericID nTupleOffSet () const { return m_nTupleOffSet ; }
220  std::string nTuplePath () const;
222  bool produceEvtCols () const { return m_produceEvtCols ; }
224  bool splitEvtColDir () const { return m_splitEvtColDir ; }
226  const std::string& evtColLUN () const { return m_evtColLUN ; }
228  const std::string& evtColTopDir () const { return m_evtColTopDir ; }
230  const std::string& evtColDir () const { return m_evtColDir ; }
232  TupleID::NumericID evtColOffSet () const { return m_evtColOffSet ; }
234  std::string evtColPath () const;
236  bool tuplesPrint () const { return m_tuplesPrint ; }
238  bool evtColsPrint () const { return m_evtColsPrint ; }
239  // ==========================================================================
240 public :
241  // ==========================================================================
245  long printTuples () const ;
249  long printEvtCols () const ;
250  // ==========================================================================
251 public :
252  // ==========================================================================
254  bool nTupleExists ( const TupleID& ID ) const;
256  bool evtColExists ( const TupleID& ID ) const;
257  // ==========================================================================
258 protected:
259  // ==========================================================================
261  const TupleMapTitle& nTupleMapTitle () const { return m_nTupleMapTitle ; }
263  const TupleMapTitle& evtColMapTitle () const { return m_evtColMapTitle ; }
265  const TupleMapID& nTupleMapID () const { return m_nTupleMapID ; }
267  const TupleMapID& evtColMapID () const { return m_evtColMapID ; }
268  // ==========================================================================
269 protected:
270  // ==========================================================================
278  virtual Tuples::TupleObj*
279  createNTuple ( const std::string& name ,
280  NTuple::Tuple* tuple ,
281  const CLID& clid ) const ;
289  virtual Tuples::TupleObj*
290  createEvtCol ( const std::string& name ,
291  NTuple::Tuple* tuple ,
292  const CLID& clid ) const ;
293  // ==========================================================================
294 public:
295  // ==========================================================================
297  GaudiTuples ( const std::string & name,
298  ISvcLocator * pSvcLocator );
300  GaudiTuples ( const std::string& type ,
301  const std::string& name ,
302  const IInterface* parent );
304  virtual ~GaudiTuples();
305  // ==========================================================================
306 protected:
307  // ==========================================================================
311  virtual StatusCode initialize()
312 #ifdef __ICC
313  { return i_gtInitialize(); }
314  StatusCode i_gtInitialize()
315 #endif
316  ;
320  virtual StatusCode finalize()
321 #ifdef __ICC
322  { return i_gtFinalize(); }
323  StatusCode i_gtFinalize()
324 #endif
325  ;
326  // ==========================================================================
327 private:
328  // ==========================================================================
330  inline void initGaudiTuplesConstructor()
331  {
332  m_produceNTuples = true ; // Switch ON/OFF ntuple production
333  m_splitNTupleDir = false ; // for HBOOK it is better to use 'true'
334  m_nTupleLUN = "FILE1" ; // logical unit for ntuples
335  m_nTupleTopDir = "" ; // top level ntuple directory
336  m_nTupleDir = this->name() ; // ntuple directory
337  m_nTupleOffSet = 0 ; // offset for ntuples
338  //
339  m_produceEvtCols = false ; // Switch ON/OFF ntupel production
340  m_splitEvtColDir = false ; // for HBOOK it is better to use 'true'
341  m_evtColLUN = "EVTCOL" ; // logical unit for ntuples
342  m_evtColTopDir = "" ; // top level ntuple directory
343  m_evtColDir = this->name() ; // ntuple directory
344  m_evtColOffSet = 0 ; // offset for ntuples
345  //
346  m_tuplesPrint = true ; // print tuples at end of job
347  m_evtColsPrint = false ; // print event collections at end of job
348  //
349  this -> declareProperty
350  ( "NTupleProduce" , m_produceNTuples ,
351  "General switch to enable/disable N-tuples" ) ;
352  this -> declareProperty
353  ( "NTuplePrint" , m_tuplesPrint ,
354  "Print N-tuple statistics" )
355  -> declareUpdateHandler ( &GaudiTuples<PBASE>::printNTupleHandler , this ) ;
356  this -> declareProperty
357  ( "NTupleSplitDir" , m_splitNTupleDir ,
358  "Split long directory names into short pieces (suitable for HBOOK)" ) ;
359  this -> declareProperty
360  ( "NTupleOffSet" , m_nTupleOffSet ,
361  "Offset for numerical N-tuple ID" ) ;
362  this -> declareProperty
363  ( "NTupleLUN" , m_nTupleLUN ,
364  "Logical File Unit for N-tuples" ) ;
365  this -> declareProperty
366  ( "NTupleTopDir" , m_nTupleTopDir ,
367  "Top-level directory for N-Tuples") ;
368  this -> declareProperty
369  ( "NTupleDir" , m_nTupleDir ,
370  "Subdirectory for N-Tuples" ) ;
371  // ========================================================================
372  this -> declareProperty
373  ( "EvtColsProduce" , m_produceEvtCols ,
374  "General switch to enable/disable Event Tag Collections" ) ;
375  this -> declareProperty
376  ( "EvtColsPrint" , m_evtColsPrint ,
377  "Print statistics for Event Tag Collections " )
378  -> declareUpdateHandler ( &GaudiTuples<PBASE>::printEvtColHandler , this ) ;
379  this -> declareProperty
380  ( "EvtColSplitDir" , m_splitEvtColDir ,
381  "Split long directory names into short pieces" ) ;
382  this -> declareProperty
383  ( "EvtColOffSet" , m_evtColOffSet ,
384  "Offset for numerical N-tuple ID" ) ;
385  this -> declareProperty
386  ( "EvtColLUN" , m_evtColLUN ,
387  "Logical File Unit for Event Tag Collections" ) ;
388  this -> declareProperty
389  ( "EvtColTopDir" , m_evtColTopDir ,
390  "Top-level directory for Event Tag Collections" ) ;
391  this -> declareProperty
392  ( "EvtColDir" , m_evtColDir ,
393  "Subdirectory for Event Tag Collections" ) ;
394  // ========================================================================
395  }
396  // ==========================================================================
397 private:
398  // ==========================================================================
400  void printNTupleHandler ( Property& /* theProp */ ) ; // "NTuplePrint"
402  void printEvtColHandler ( Property& /* theProp */ ) ; // "EvtcolsPrint"
403  // ==========================================================================
404 private:
405  // ==========================================================================
407  bool m_produceNTuples ;
409  bool m_splitNTupleDir ;
411  std::string m_nTupleLUN ;
413  std::string m_nTupleTopDir ;
415  std::string m_nTupleDir ;
417  TupleID::NumericID m_nTupleOffSet ;
418  // ==========================================================================
420  bool m_produceEvtCols ;
422  bool m_splitEvtColDir ;
424  std::string m_evtColLUN ;
426  std::string m_evtColTopDir ;
428  std::string m_evtColDir ;
430  TupleID::NumericID m_evtColOffSet ;
431  // ==========================================================================
433  bool m_tuplesPrint ; // print tuples at finalization?
435  bool m_evtColsPrint ; // print event collections at finalization
436  // ==========================================================================
438  mutable TupleMapTitle m_nTupleMapTitle ;
440  mutable TupleMapID m_nTupleMapID ;
441  // ==========================================================================
443  mutable TupleMapTitle m_evtColMapTitle ;
445  mutable TupleMapID m_evtColMapID ;
446  // ==========================================================================
447 };
448 // ============================================================================
449 // The END
450 // ============================================================================
451 #endif // GAUDIALG_GAUDITUPLES_H
452 // ============================================================================
def initialize()
Definition: AnalysisTest.py:12
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
Templated base class providing common 'ntupling' methods.
Definition: GaudiTuples.h:37
#define GAUDI_API
Definition: Kernel.h:108
GaudiAlg::ID HistoID
The actual type for histogram identifier.
Definition: HistoID.h:25
return false
Definition: Bootstrap.cpp:338
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: Tuple.h:115
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:180
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Definition of the basic interface.
Definition: IInterface.h:160
GaudiAlg::ID TupleID
the actual type for N-Tuple identifier (HBOOK-style)
Definition: TupleID.h:25
def nTuple
Retrieve (book-on-demand) 'Smart'-N-tuple object.
Definition: TupleUtils.py:66
unsigned int CLID
Class ID definition.
Definition: ClassID.h:9
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:367
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
Common class providing an architecture-independent hash map.
Definition: HashMap.h:108
GaudiUtils::HashMap< TupleID, Tuples::TupleObj * > TupleMapID
the actual type for (ID)->(tuple) map
Definition: Maps.h:137
ID class for Histogram and Ntuples.
Definition: GaudiHistoID.h:46
GaudiUtils::HashMap< std::string, Tuples::TupleObj * > TupleMapTitle
the actual type for (title)->(tuple) map
Definition: Maps.h:131
string type
Definition: gaudirun.py:151