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-2022 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/SgTEvent.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::SgTEvent *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
320 protected:
321 virtual ::StatusCode execute ();
322
328 protected:
329 virtual ::StatusCode finalize ();
330
335 protected:
336 virtual void print () const;
337
364 protected:
365 virtual ::StatusCode fileExecute ();
366
389 protected:
390 virtual ::StatusCode beginInputFile ();
391
414 protected:
415 virtual ::StatusCode endInputFile ();
416
417
418
419 //
420 // framework interface
421 //
422
423#ifdef XAOD_STANDALONE
425 public:
427
429 public:
430 ::StatusCode sysExecute ();
431
433 public:
434 ::StatusCode sysFinalize ();
435
437 public:
438 void sysPrint ();
439
441 public:
442 ::StatusCode sysFileExecute ();
443
445 public:
446 ::StatusCode sysBeginInputFile ();
447
449 public:
450 ::StatusCode sysEndInputFile ();
451
452
458 public:
459 void setEvtStore (asg::SgTEvent *val_evtStore);
460
466 public:
467 void setHistogramWorker (IHistogramWorker *val_histogramWorker);
468
474 public:
475 void setTreeWorker (ITreeWorker *val_treeWorker);
476
482 public:
483 void setFilterWorker (IFilterWorker *val_filterWorker);
484
490 public:
491 void setWk (IWorker *val_wk);
492
493
498 public:
499 bool hasFileExecute () const noexcept;
500
501
506 public:
507 bool hasBeginInputFile () const noexcept;
508
509
514 public:
515 bool hasEndInputFile () const noexcept;
516#endif
517
518
519#ifndef XAOD_STANDALONE
525 public:
526 void handle (const Incident& inc);
527#endif
528
529
530
531 //
532 // private interface
533 //
534
535#ifdef XAOD_STANDALONE
537 private:
538 asg::SgTEvent *m_evtStore = nullptr;
539#endif
540
541#ifdef XAOD_STANDALONE
544#else
547#endif // XAOD_STANDALONE
548
550 private:
552
554 private:
556
557#ifdef XAOD_STANDALONE
559 private:
560 IHistogramWorker *m_histogramWorker = nullptr;
561#endif
562
563#ifdef XAOD_STANDALONE
565 private:
566 ITreeWorker *m_treeWorker = nullptr;
568 private:
569 std::string m_treeStreamName;
570#endif
571
572#ifdef XAOD_STANDALONE
574 private:
575 IFilterWorker *m_filterWorker = nullptr;
576#endif
577
578#ifdef XAOD_STANDALONE
580 private:
581 IWorker *m_wk = nullptr;
582#endif
583
585 private:
586 bool m_hasFileExecute {false};
587
589 private:
591
593 private:
594 bool m_hasEndInputFile {false};
595 };
596}
597
598#include "AnaAlgorithm.icc"
599
600#endif
macros for messaging and checking status codes
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.
Wrapper for TEvent to make it look like StoreGate.
Definition SgTEvent.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