ATLAS Offline Software
Loading...
Searching...
No Matches
AnaAlgorithm.h
Go to the documentation of this file.
1// Dear emacs, this is -*- c++ -*-
2/*
3 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4*/
5
7
8
9
10#ifndef ANA_ALGORITHM__ANA_ALGORITHM_H
11#define ANA_ALGORITHM__ANA_ALGORITHM_H
12
13#include <AnaAlgorithm/Global.h>
14
15#ifdef XAOD_STANDALONE
17#include <AsgTools/SgEvent.h>
19#include <memory>
20#include <vector>
21#else
25#include <GaudiKernel/IIncidentListener.h>
26#include <GaudiKernel/ServiceHandle.h>
27#endif
28
29class TH1;
30class TH2;
31class TH3;
32class TEfficiency;
33class TTree;
34class ISvcLocator;
35
36namespace EL
37{
38#ifdef XAOD_STANDALONE
39 class IWorker;
40#endif
41
65
66
68#ifdef XAOD_STANDALONE
69 : public asg::AsgComponent
70#else
71 : public AthHistogramAlgorithm, virtual public IIncidentListener
72#endif
73 {
74 //
75 // public interface
76 //
77
88 public:
89 AnaAlgorithm (const std::string& name,
90 ISvcLocator* pSvcLocator);
91
95 public:
96 virtual ~AnaAlgorithm() noexcept;
97
98
99
100 //
101 // services interface
102 //
103
104#ifdef XAOD_STANDALONE
108#else
112#endif // XAOD_STANDALONE
113
119
125
126#ifdef XAOD_STANDALONE
134 public:
135 asg::SgEvent *evtStore() const;
136
137
143 public:
144 ::StatusCode book (const TH1& hist);
145
146
152 public:
153 ::StatusCode book (const TEfficiency& hist);
154
155
161 public:
162 template<typename T=TH1>
163 T *hist (const std::string& name) const;
164
165
171 public:
172 TH2 *hist2d (const std::string& name) const;
173
174
180 public:
181 TH3 *hist3d (const std::string& name) const;
182
183
193 public:
194 TEfficiency *histeff (const std::string& name) const;
195 TEfficiency *efficiency (const std::string& name) const;
196
197
204 public:
205 IHistogramWorker *histogramWorker () const;
206
207
213 public:
214 ::StatusCode book (const TTree& tree);
215
216
222 public:
223 TTree *tree (const std::string& name) const;
224
225
232 public:
233 ITreeWorker *treeWorker () const;
234
235
242 public:
243 IFilterWorker *filterWorker () const;
244
245
250 public:
251 bool filterPassed() const;
252
256 public:
257 void setFilterPassed (bool val_filterPassed);
258
259
267 public:
268 IWorker *wk () const;
269#endif
270
271
278 public:
280
281
288 public:
290
291
298 public:
300
301
302
303 //
304 // virtual interface
305 //
306
313 protected:
314 virtual ::StatusCode initialize ();
315
316#pragma GCC diagnostic push
317#pragma GCC diagnostic ignored "-Woverloaded-virtual"
318
326 protected:
327 virtual ::StatusCode execute ();
328
335 protected:
336 virtual ::StatusCode execute (const EventContext& ctx);
337
338#pragma GCC diagnostic pop
339
345 protected:
346 virtual ::StatusCode finalize ();
347
352 protected:
353 virtual void print () const;
354
381 protected:
382 virtual ::StatusCode fileExecute ();
383
406 protected:
407 virtual ::StatusCode beginInputFile ();
408
431 protected:
432 virtual ::StatusCode endInputFile ();
433
434
435
436 //
437 // framework interface
438 //
439
440#ifdef XAOD_STANDALONE
442 public:
444
446 public:
447 ::StatusCode sysExecute (const EventContext& ctx);
448
450 public:
451 ::StatusCode sysFinalize ();
452
454 public:
455 void sysPrint ();
456
458 public:
459 ::StatusCode sysFileExecute ();
460
462 public:
463 ::StatusCode sysBeginInputFile ();
464
466 public:
467 ::StatusCode sysEndInputFile ();
468
469
475 public:
476 void setEvtStore (asg::SgEvent *val_evtStore);
477
483 public:
484 void setHistogramWorker (IHistogramWorker *val_histogramWorker);
485
491 public:
492 void setTreeWorker (ITreeWorker *val_treeWorker);
493
499 public:
500 void setFilterWorker (IFilterWorker *val_filterWorker);
501
507 public:
508 void setWk (IWorker *val_wk);
509
510
515 public:
516 bool hasFileExecute () const noexcept;
517
518
523 public:
524 bool hasBeginInputFile () const noexcept;
525
526
531 public:
532 bool hasEndInputFile () const noexcept;
533#endif
534
535
536#ifndef XAOD_STANDALONE
542 public:
543 void handle (const Incident& inc);
544#endif
545
546
547
548 //
549 // private interface
550 //
551
552#ifdef XAOD_STANDALONE
554 private:
555 asg::SgEvent *m_evtStore = nullptr;
556#endif
557
558#ifdef XAOD_STANDALONE
561#else
564#endif // XAOD_STANDALONE
565
567 private:
569
571 private:
573
574#ifdef XAOD_STANDALONE
576 private:
577 IHistogramWorker *m_histogramWorker = nullptr;
578#endif
579
580#ifdef XAOD_STANDALONE
582 private:
583 ITreeWorker *m_treeWorker = nullptr;
585 private:
586 std::string m_treeStreamName;
587#endif
588
589#ifdef XAOD_STANDALONE
591 private:
592 IFilterWorker *m_filterWorker = nullptr;
593#endif
594
595#ifdef XAOD_STANDALONE
597 private:
598 IWorker *m_wk = nullptr;
599#endif
600
602 private:
603 bool m_hasFileExecute {false};
604
606 private:
608
610 private:
611 bool m_hasEndInputFile {false};
612 };
613}
614
615#include "AnaAlgorithm.icc"
616
617#endif
macros for messaging and checking status codes
virtual bool filterPassed(const EventContext &ctx) const
virtual void setFilterPassed(bool state, const EventContext &ctx) const
virtual StatusCode sysExecute(const EventContext &ctx) override
ServiceHandle< StoreGateSvc > & evtStore()
virtual StatusCode sysInitialize()
Initialization method invoked by the framework.
AthHistogramAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
TTree * tree(const std::string &treeName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TTrees.
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
TH3 * hist3d(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered 3-d histograms.
TEfficiency * efficiency(const std::string &effName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TEfficiency.
TH2 * hist2d(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered 2-d histograms.
virtual void print() const
print the state of the algorithm
virtual::StatusCode endInputFile()
perform the action for the end of an input file
ConstMetaStorePtr_t inputMetaStore() const
::StatusCode requestBeginInputFile()
register this algorithm to have an implementation of beginInputFile
virtual::StatusCode fileExecute()
perform the action exactly once for each file in the dataset
bool m_hasBeginInputFile
the value of hasBeginInputFile
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
::StatusCode requestEndInputFile()
register this algorithm to have an implementation of endInputFile
::StatusCode requestFileExecute()
register this algorithm to have an implementation of fileexecute
bool m_hasFileExecute
the value of hasFileExecute
MetaStore_t m_outputMetaStore
Object accessing the output metadata store.
MetaStore_t m_inputMetaStore
Object accessing the input metadata store.
ServiceHandle< StoreGateSvc > MetaStore_t
Type of the metadata store variable in Athena.
void handle(const Incident &inc)
receive the given incident
virtual::StatusCode execute()
execute this algorithm
ServiceHandle< StoreGateSvc > & MetaStorePtr_t
Type of the metadata store pointer in standalone mode.
bool m_hasEndInputFile
the value of hasEndInputFile
const ServiceHandle< StoreGateSvc > & ConstMetaStorePtr_t
virtual::StatusCode finalize()
finalize this algorithm
virtual::StatusCode beginInputFile()
perform the action for the beginning of an input file
ConstMetaStorePtr_t outputMetaStore() const
virtual::StatusCode initialize()
initialize this algorithm
virtual ~AnaAlgorithm() noexcept
standard (virtual) destructor
the interface to the filter functions in the algorithm sequence
the interface to histogram storage on the worker
The interface to TTree storage on the worker.
Definition ITreeWorker.h:32
the interface for algorithms to access IWorker
Definition IWorker.h:40
Wrapper class providing StoreGate-like access to metadata in ROOT.
Definition SgEventMeta.h:45
Wrapper for Event to make it look like StoreGate.
Definition SgEvent.h:44
This module defines the arguments passed from the BATCH driver to the BATCH worker.
::StatusCode StatusCode
StatusCode definition for legacy code.
TChain * tree