ATLAS Offline Software
AthHistogramAlgorithm.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 */
6 
11 
12 // This class' header file
14 
15 // STL includes
16 #include <string>
17 #include <map>
18 
19 // Framework includes
20 #include "Gaudi/Property.h"
21 #include "GaudiKernel/ITHistSvc.h"
22 
23 
24 
26 // Public methods:
28 
29 // Constructors
32  ISvcLocator* pSvcLocator ) :
33  ::AthAlgorithm( name, pSvcLocator ),
35  m_histSvc ( "THistSvc/THistSvc", name )
36 {
37  //
38  // Property declaration
39  //
40  // The histogram service
41  declareProperty("THistSvc",
42  m_histSvc = ServiceHandle<ITHistSvc>("THistSvc/THistSvc", name),
43  "Handle to a THistSvc instance: it will be used to write "
44  "ROOT objects to ROOT files" );
45  // declareProperty("THistService", m_histSvc, "The THistSvc" );
46 
47  declareProperty("RootStreamName", m_prefix = "/ANALYSIS", "Name of the output ROOT stream (file) that the THistSvc uses");
48  declareProperty("RootDirName", m_rootDir = "",
49  "Name of the ROOT directory inside the ROOT file where the histograms will go");
50 
51  declareProperty( "HistNamePrefix", m_histNamePrefix = "", "The prefix for the histogram THx name" );
52  declareProperty( "HistNamePostfix", m_histNamePostfix = "", "The postfix for the histogram THx name" );
53 
54  declareProperty( "HistTitlePrefix", m_histTitlePrefix = "", "The prefix for the histogram THx title" );
55  declareProperty( "HistTitlePostfix", m_histTitlePostfix = "", "The postfix for the histogram THx title" );
56 }
57 
58 
59 
60 
61 // Destructor
64 {
65  ATH_MSG_DEBUG ("Calling destructor");
66 }
67 
68 
69 
76 {
77  // ---- stolen from GaudiKernel/Algorithm::sysInitialize -------
78  // Bypass the initialization if the algorithm
79  // has already been initialized.
80  if ( Gaudi::StateMachine::INITIALIZED <= FSMState() ) return StatusCode::SUCCESS;
81 
82  // Set the Algorithm's properties
83  bindPropertiesTo( serviceLocator()->getOptsSvc() );
84 
85  // Bypass the initialization if the algorithm is disabled.
86  // Need to do this after bindPropertiesTo.
87  if ( !isEnabled( ) ) return StatusCode::SUCCESS;
88 
89  // ---- stolen from GaudiKernel/Algorithm::sysInitialize ------- END ---
90 
91 
92  // Get the THistSvc
93  ATH_CHECK ( histSvc().retrieve() );
94 
95  // Configure the underlying AthHistogramming helper
100 
101  // Print some setup information into the log file
102  ATH_MSG_DEBUG ("Initializing " << name() << "...");
103  ATH_MSG_DEBUG (" using THistService = " << m_histSvc );
104  ATH_MSG_DEBUG (" using RootStreamName = " << m_prefix );
105  ATH_MSG_DEBUG (" using RootDirName = " << m_rootDir );
106  ATH_MSG_DEBUG (" using HistNamePrefix = " << m_histNamePrefix );
107  ATH_MSG_DEBUG (" using HistNamePostfix = " << m_histNamePostfix );
108  ATH_MSG_DEBUG (" using HistTitlePrefix = " << m_histTitlePrefix );
109  ATH_MSG_DEBUG (" using HistTitlePostfix = " << m_histTitlePostfix );
110 
111 
112  // re-direct to base class...
114 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AthHistogramAlgorithm::histSvc
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
Definition: AthHistogramAlgorithm.h:113
AthHistogramAlgorithm::AthHistogramAlgorithm
AthHistogramAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Definition: AthHistogramAlgorithm.cxx:31
AthHistogramAlgorithm::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Default constructor: AthHistogramAlgorithm();.
Definition: AthHistogramAlgorithm.h:83
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
AthHistogramAlgorithm::m_prefix
std::string m_prefix
Name of the ROOT output stream (file)
Definition: AthHistogramAlgorithm.h:88
AthHistogramAlgorithm::m_histNamePrefix
std::string m_histNamePrefix
The prefix for the histogram THx name.
Definition: AthHistogramAlgorithm.h:94
AthHistogramming
Definition: AthHistogramming.h:37
AthHistogramAlgorithm::m_histTitlePrefix
std::string m_histTitlePrefix
The prefix for the histogram THx title.
Definition: AthHistogramAlgorithm.h:100
AthHistogramAlgorithm::~AthHistogramAlgorithm
virtual ~AthHistogramAlgorithm()
Destructor:
Definition: AthHistogramAlgorithm.cxx:63
AthHistogramAlgorithm.h
AthAlgorithm::sysInitialize
virtual StatusCode sysInitialize() override
Override sysInitialize.
Definition: AthAlgorithm.cxx:66
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthHistogramming::configAthHistogramming
StatusCode configAthHistogramming(const ServiceHandle< ITHistSvc > &histSvc, const std::string &prefix, const std::string &rootDir, const std::string &histNamePrefix, const std::string &histNamePostfix, const std::string &histTitlePrefix, const std::string &histTitlePostfix)
To be called by the derived classes to fill the internal configuration.
Definition: AthHistogramming.cxx:66
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthHistogramAlgorithm::sysInitialize
virtual StatusCode sysInitialize()
Initialization method invoked by the framework.
Definition: AthHistogramAlgorithm.cxx:75
AthHistogramAlgorithm::m_histNamePostfix
std::string m_histNamePostfix
The postfix for the histogram THx name.
Definition: AthHistogramAlgorithm.h:97
AthHistogramAlgorithm::m_histTitlePostfix
std::string m_histTitlePostfix
The postfix for the histogram THx title.
Definition: AthHistogramAlgorithm.h:103
AthHistogramAlgorithm::m_rootDir
std::string m_rootDir
Name of the ROOT directory.
Definition: AthHistogramAlgorithm.h:91
ServiceHandle< ITHistSvc >