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 EventContext;
35class ISvcLocator;
36
37namespace EL
38{
39#ifdef XAOD_STANDALONE
40 class IWorker;
41#endif
42
66
67
69#ifdef XAOD_STANDALONE
70 : public asg::AsgComponent
71#else
72 : public AthHistogramAlgorithm, virtual public IIncidentListener
73#endif
74 {
75 //
76 // public interface
77 //
78
89 public:
90 AnaAlgorithm (const std::string& name,
91 ISvcLocator* pSvcLocator);
92
96 public:
97 virtual ~AnaAlgorithm() noexcept = default;
98
99
100
101 //
102 // services interface
103 //
104
105#ifdef XAOD_STANDALONE
109#else
113#endif // XAOD_STANDALONE
114
120
126
127#ifdef XAOD_STANDALONE
135 public:
136 asg::SgEvent *evtStore() const;
137
138
144 public:
145 ::StatusCode book (const TH1& hist);
146
147
153 public:
154 ::StatusCode book (const TEfficiency& hist);
155
156
162 public:
163 template<typename T=TH1>
164 T *hist (const std::string& name) const;
165
166
172 public:
173 TH2 *hist2d (const std::string& name) const;
174
175
181 public:
182 TH3 *hist3d (const std::string& name) const;
183
184
194 public:
195 TEfficiency *histeff (const std::string& name) const;
196 TEfficiency *efficiency (const std::string& name) const;
197
198
205 public:
206 IHistogramWorker *histogramWorker () const;
207
208
214 public:
215 ::StatusCode book (const TTree& tree);
216
217
223 public:
224 TTree *tree (const std::string& name) const;
225
226
233 public:
234 ITreeWorker *treeWorker () const;
235
236
243 public:
244 IFilterWorker *filterWorker () const;
245
246
251 public:
252 bool filterPassed() const;
253
257 public:
258 void setFilterPassed (bool val_filterPassed);
259
260
268 public:
269 IWorker *wk () const;
270#endif
271
272
279 public:
281
282
289 public:
291
292
299 public:
301
302
303
304 //
305 // virtual interface
306 //
307
314 protected:
315 virtual ::StatusCode initialize ();
316
317#pragma GCC diagnostic push
318#pragma GCC diagnostic ignored "-Woverloaded-virtual"
319
327 protected:
328 virtual ::StatusCode execute ();
329
336 protected:
337 virtual ::StatusCode execute (const EventContext& ctx);
338
339#pragma GCC diagnostic pop
340
346 protected:
347 virtual ::StatusCode finalize ();
348
353 protected:
354 virtual void print () const;
355
382 protected:
383 virtual ::StatusCode fileExecute ();
384
407 protected:
408 virtual ::StatusCode beginInputFile ();
409
432 protected:
433 virtual ::StatusCode endInputFile ();
434
435
436
437 //
438 // framework interface
439 //
440
441#ifdef XAOD_STANDALONE
443 public:
445
447 public:
448 ::StatusCode sysExecute (const EventContext& ctx);
449
451 public:
452 ::StatusCode sysFinalize ();
453
455 public:
456 void sysPrint ();
457
459 public:
460 ::StatusCode sysFileExecute ();
461
463 public:
464 ::StatusCode sysBeginInputFile ();
465
467 public:
468 ::StatusCode sysEndInputFile ();
469
470
476 public:
477 void setEvtStore (asg::SgEvent *val_evtStore);
478
484 public:
485 void setHistogramWorker (IHistogramWorker *val_histogramWorker);
486
492 public:
493 void setTreeWorker (ITreeWorker *val_treeWorker);
494
500 public:
501 void setFilterWorker (IFilterWorker *val_filterWorker);
502
508 public:
509 void setWk (IWorker *val_wk);
510
511
516 public:
517 bool hasFileExecute () const noexcept;
518
519
524 public:
525 bool hasBeginInputFile () const noexcept;
526
527
532 public:
533 bool hasEndInputFile () const noexcept;
534#endif
535
536
537#ifndef XAOD_STANDALONE
543 public:
544 void handle (const Incident& inc);
545#endif
546
547
548
549 //
550 // private interface
551 //
552
553#ifdef XAOD_STANDALONE
555 private:
556 asg::SgEvent *m_evtStore = nullptr;
557#endif
558
559#ifdef XAOD_STANDALONE
562#else
565#endif // XAOD_STANDALONE
566
568 private:
570
572 private:
574
575#ifdef XAOD_STANDALONE
577 private:
578 IHistogramWorker *m_histogramWorker = nullptr;
579#endif
580
581#ifdef XAOD_STANDALONE
583 private:
584 ITreeWorker *m_treeWorker = nullptr;
586 private:
587 std::string m_treeStreamName;
588#endif
589
590#ifdef XAOD_STANDALONE
592 private:
593 IFilterWorker *m_filterWorker = nullptr;
594#endif
595
596#ifdef XAOD_STANDALONE
598 private:
599 IWorker *m_wk = nullptr;
600#endif
601
603 private:
604 bool m_hasFileExecute {false};
605
607 private:
609
611 private:
612 bool m_hasEndInputFile {false};
613 };
614}
615
616#include "AnaAlgorithm.icc"
617
618#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
virtual ~AnaAlgorithm() noexcept=default
standard (virtual) destructor
const ServiceHandle< StoreGateSvc > & ConstMetaStorePtr_t
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
ServiceHandle< StoreGateSvc > MetaStore_t
Type of the metadata store variable in Athena.
::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.
ServiceHandle< StoreGateSvc > & MetaStorePtr_t
Type of the metadata store pointer in Athena.
MetaStore_t m_inputMetaStore
Object accessing the input metadata store.
void handle(const Incident &inc)
receive the given incident
virtual::StatusCode execute()
execute this algorithm
bool m_hasEndInputFile
the value of hasEndInputFile
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
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