ATLAS Offline Software
AthAnalysisAlgorithm.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // AthAnalysisAlgorithm.h
8 // Header file for class AthAnalysisAlgorithm
9 // Inherits from AthHistogramAlgorithm
10 // Author: W.Buttinger<will@cern.ch>
12 
13 #ifndef ATHANALYSISBASECOMPS_ATHANALYSISALGORITHM_H
14 #define ATHANALYSISBASECOMPS_ATHANALYSISALGORITHM_H 1
15 
27 #include "GaudiKernel/ToolHandle.h" //included under assumption you'll want to use some tools!
28 #include "GaudiKernel/IIncidentSvc.h"
29 
30 
32 #include "TFile.h"
33 
34 class AthAnalysisAlgorithm : public ::AthHistogramAlgorithm, virtual public IIncidentListener {
35  public:
36 
38  AthAnalysisAlgorithm(const std::string& name);
39 
41  AthAnalysisAlgorithm(const std::string& name, ISvcLocator* pSvcLocator);
42 
43  virtual ~AthAnalysisAlgorithm() override;
44 
47 
56 
58 
60  virtual StatusCode sysInitialize() override;
62  virtual StatusCode sysExecute(const EventContext&) override;
63 
65  template<typename T> StatusCode retrieveMetadata(const std::string& folder, const std::string& key, T& out) {
66  try {
68  } catch(std::exception& e) {
69  ATH_MSG_WARNING(e.what());
70  return StatusCode::FAILURE;
71  }
72  }
73 
76  template<typename T> StatusCode retrieveMetadata(const std::string& folder, const std::string& key, T& out, const IOVTime& time, int channel=-1) {
77  try {
79  } catch(std::exception& e) {
80  ATH_MSG_WARNING(e.what());
81  return StatusCode::FAILURE;
82  }
83  }
84 
85 protected:
86  void updateEvtStore(Gaudi::Details::PropertyBase& prop);
87 
88 
93  virtual void handle( const Incident& inc ) override;
94 
97  virtual StatusCode beginInputFile();
98 
100  virtual StatusCode endInputFile();
101 
104  virtual StatusCode metaDataStop();
105 
108  virtual StatusCode firstExecute();
109 
112  virtual TFile* currentFile(const char* evtSelName="EventSelector") final;
113 
114 private:
119 
120  TFile* m_currentFile{nullptr}; //used to cache the current file
121 
122  bool m_doneFirstEvent{false};
123 };
124 
125 #endif //> !ATHANALYSISBASECOMPS_ATHANALYSISALGORITHM_H
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
AthAnalysisAlgorithm::m_currentFile
TFile * m_currentFile
Definition: AthAnalysisAlgorithm.h:120
AthAnalysisAlgorithm
Definition: AthAnalysisAlgorithm.h:34
AthAnalysisAlgorithm::endInputFile
virtual StatusCode endInputFile()
Function called as an input file is being closed.
Definition: AthAnalysisAlgorithm.cxx:122
AthAnalysisAlgorithm::outputMetaStore
const ServiceHandle< StoreGateSvc > & outputMetaStore() const
Const accessor for the output metadata store.
Definition: AthAnalysisAlgorithm.h:53
AthAnalysisAlgorithm::firstExecute
virtual StatusCode firstExecute()
Function called when first execute is encountered user can read event information with evtStore()
Definition: AthAnalysisAlgorithm.cxx:139
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
AthAnalysisAlgorithm::sysInitialize
virtual StatusCode sysInitialize() override
Function initialising the tool in the correct way in Athena.
Definition: AthAnalysisAlgorithm.cxx:50
AthAnalysisAlgorithm::retrieveMetadata
StatusCode retrieveMetadata(const std::string &folder, const std::string &key, T &out, const IOVTime &time, int channel=-1)
Helper function to access IOVMetaDataContainer information held in InputMetaDataStore,...
Definition: AthAnalysisAlgorithm.h:76
AthAnalysisAlgorithm::~AthAnalysisAlgorithm
virtual ~AthAnalysisAlgorithm() override
Definition: AthAnalysisAlgorithm.cxx:43
AthAnalysisAlgorithm::m_inputMetaStore
ServiceHandle< StoreGateSvc > m_inputMetaStore
Object accessing the input metadata store.
Definition: AthAnalysisAlgorithm.h:116
AthAnalysisAlgorithm::updateEvtStore
void updateEvtStore(Gaudi::Details::PropertyBase &prop)
Definition: AthAnalysisAlgorithm.cxx:45
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
AthAnalysisAlgorithm::retrieveMetadata
StatusCode retrieveMetadata(const std::string &folder, const std::string &key, T &out)
Helper function to access IOVMetaDataContainer information helped in the MetaDataStore.
Definition: AthAnalysisAlgorithm.h:65
AthAnalysisAlgorithm::handle
virtual void handle(const Incident &inc) override
Function receiving incidents from IncidentSvc/TEvent Experts can override but they should ensure they...
Definition: AthAnalysisAlgorithm.cxx:83
AthAnalysisAlgorithm::inputMetaStore
const ServiceHandle< StoreGateSvc > & inputMetaStore() const
Const accessor for the input metadata store.
Definition: AthAnalysisAlgorithm.h:49
AthAnalysisAlgorithm::AthAnalysisAlgorithm
AthAnalysisAlgorithm(const std::string &name)
Constructor taking just a name.
Definition: AthAnalysisAlgorithm.cxx:19
AthAnalysisAlgorithm::m_doneFirstEvent
bool m_doneFirstEvent
Definition: AthAnalysisAlgorithm.h:122
AthHistogramAlgorithm.h
IOVTime
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
Definition: IOVTime.h:33
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
AthAnalysisAlgorithm::inputMetaStore
ServiceHandle< StoreGateSvc > & inputMetaStore()
Accessor for the input metadata store.
Definition: AthAnalysisAlgorithm.h:51
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAnalysisAlgorithm::outputMetaStore
ServiceHandle< StoreGateSvc > & outputMetaStore()
Accessor for the output metadata store.
Definition: AthAnalysisAlgorithm.h:55
calibdata.exception
exception
Definition: calibdata.py:496
AthAnalysisAlgorithm::metaDataStop
virtual StatusCode metaDataStop()
Function called before finalize user can read output metadata from outputMetaStore()
Definition: AthAnalysisAlgorithm.cxx:130
AthHistogramAlgorithm
Definition: AthHistogramAlgorithm.h:32
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
AthAnalysisHelper.h
AthAnalysisAlgorithm::beginInputFile
virtual StatusCode beginInputFile()
Function called when a new input file is opened user can read input metadata from inputMetaStore()
Definition: AthAnalysisAlgorithm.cxx:114
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloCondBlobAlgs_fillNoiseFromASCII.folder
folder
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:56
AthAnalysisAlgorithm::currentFile
virtual TFile * currentFile(const char *evtSelName="EventSelector") final
Function returning the TFile pointer of the currently open file of the given EventSelector (in athena...
Definition: AthAnalysisAlgorithm.cxx:147
AthAnalysisAlgorithm::m_outputMetaStore
ServiceHandle< StoreGateSvc > m_outputMetaStore
Object accessing the output metadata store.
Definition: AthAnalysisAlgorithm.h:118
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
AthAnalysisHelper::retrieveMetadata
static std::string retrieveMetadata(const std::string &folder, const std::string &key, const ServiceHandle< StoreGateSvc > &inputMetaStore)
method that always returns as a string you can use from, e.g, pyROOT with evt = ROOT....
Definition: AthAnalysisHelper.h:254
ServiceHandle< StoreGateSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
AthAnalysisAlgorithm::sysExecute
virtual StatusCode sysExecute(const EventContext &) override
override to do firstEvent method
Definition: AthAnalysisAlgorithm.cxx:72