ATLAS Offline Software
Loading...
Searching...
No Matches
AthAnalysisAlgorithm.h
Go to the documentation of this file.
1
2
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
25
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
34class 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 {
78 return AthAnalysisHelper::retrieveMetadata(folder,key,out,inputMetaStore(),time,channel);
79 } catch(std::exception& e) {
80 ATH_MSG_WARNING(e.what());
81 return StatusCode::FAILURE;
82 }
83 }
84
85protected:
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
114private:
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
#define ATH_MSG_WARNING(x)
virtual TFile * currentFile(const char *evtSelName="EventSelector") final
Function returning the TFile pointer of the currently open file of the given EventSelector (in athena...
StatusCode retrieveMetadata(const std::string &folder, const std::string &key, T &out)
Helper function to access IOVMetaDataContainer information helped in the MetaDataStore.
ServiceHandle< StoreGateSvc > & outputMetaStore()
Accessor for the output metadata store.
virtual StatusCode beginInputFile()
Function called when a new input file is opened user can read input metadata from inputMetaStore()
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,...
virtual StatusCode endInputFile()
Function called as an input file is being closed.
virtual StatusCode sysExecute(const EventContext &) override
override to do firstEvent method
ServiceHandle< StoreGateSvc > m_inputMetaStore
Object accessing the input metadata store.
virtual void handle(const Incident &inc) override
Function receiving incidents from IncidentSvc/TEvent Experts can override but they should ensure they...
const ServiceHandle< StoreGateSvc > & outputMetaStore() const
Const accessor for the output metadata store.
virtual StatusCode metaDataStop()
Function called before finalize user can read output metadata from outputMetaStore()
void updateEvtStore(Gaudi::Details::PropertyBase &prop)
ServiceHandle< StoreGateSvc > m_outputMetaStore
Object accessing the output metadata store.
ServiceHandle< StoreGateSvc > & inputMetaStore()
Accessor for the input metadata store.
virtual ~AthAnalysisAlgorithm() override
virtual StatusCode firstExecute()
Function called when first execute is encountered user can read event information with evtStore()
const ServiceHandle< StoreGateSvc > & inputMetaStore() const
Const accessor for the input metadata store.
virtual StatusCode sysInitialize() override
Function initialising the tool in the correct way in Athena.
AthAnalysisAlgorithm(const std::string &name)
Constructor taking just a name.
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....
AthHistogramAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Basic time unit for IOVSvc.
Definition IOVTime.h:33
The Athena Transient Store API.
#define private