ATLAS Offline Software
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
16 #include <AsgTools/AsgComponent.h>
17 #include <AsgTools/SgTEvent.h>
18 #include <AsgTools/SgTEventMeta.h>
19 #include <memory>
20 #include <vector>
21 #else
24 #include <StoreGate/StoreGateSvc.h>
25 #include <GaudiKernel/IIncidentListener.h>
26 #include <GaudiKernel/ServiceHandle.h>
27 #endif
28 
29 class TH1;
30 class TH2;
31 class TH3;
32 class TEfficiency;
33 class TTree;
34 class ISvcLocator;
35 
36 namespace 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
107  typedef const asg::SgTEventMeta* ConstMetaStorePtr_t;
108 #else
112 #endif // XAOD_STANDALONE
113 
119 
125 
126 #ifdef XAOD_STANDALONE
127  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:
315 
320  protected:
322 
328  protected:
330 
335  protected:
336  virtual void print () const;
337 
364  protected:
366 
389  protected:
391 
414  protected:
416 
417 
418 
419  //
420  // framework interface
421  //
422 
423 #ifdef XAOD_STANDALONE
424  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
520  public:
526  void handle (const Incident& inc);
527 #endif
528 
529 
530 
531  //
532  // private interface
533  //
534 
535 #ifdef XAOD_STANDALONE
536  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
558  private:
560  IHistogramWorker *m_histogramWorker = nullptr;
561 #endif
562 
563 #ifdef XAOD_STANDALONE
564  private:
566  ITreeWorker *m_treeWorker = nullptr;
568  private:
569  std::string m_treeStreamName;
570 #endif
571 
572 #ifdef XAOD_STANDALONE
573  private:
575  IFilterWorker *m_filterWorker = nullptr;
576 #endif
577 
578 #ifdef XAOD_STANDALONE
579  private:
581  IWorker *m_wk = nullptr;
582 #endif
583 
585  private:
586  bool m_hasFileExecute {false};
587 
589  private:
590  bool m_hasBeginInputFile {false};
591 
593  private:
594  bool m_hasEndInputFile {false};
595  };
596 }
597 
598 #include "AnaAlgorithm.icc"
599 
600 #endif
EL::AnaAlgorithm::requestFileExecute
::StatusCode requestFileExecute()
register this algorithm to have an implementation of fileexecute
Definition: AnaAlgorithm.cxx:250
EL::AnaAlgorithm::m_hasBeginInputFile
bool m_hasBeginInputFile
the value of hasBeginInputFile
Definition: AnaAlgorithm.h:590
AthHistogramming::hist2d
TH2 * hist2d(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered 2-d histograms.
Definition: AthHistogramming.h:369
EL::AnaAlgorithm::ConstMetaStorePtr_t
const ServiceHandle< StoreGateSvc > & ConstMetaStorePtr_t
Definition: AnaAlgorithm.h:111
EL::IFilterWorker
the interface to the filter functions in the algorithm sequence
Definition: IFilterWorker.h:27
EL::AnaAlgorithm::endInputFile
virtual ::StatusCode endInputFile()
perform the action for the end of an input file
Definition: AnaAlgorithm.cxx:359
AthHistogramming::book
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
Definition: AthHistogramming.h:303
AthHistogramming::efficiency
TEfficiency * efficiency(const std::string &effName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TEfficiency.
Definition: AthHistogramming.cxx:250
EL::AnaAlgorithm::m_inputMetaStore
MetaStore_t m_inputMetaStore
Object accessing the input metadata store.
Definition: AnaAlgorithm.h:551
EL::AnaAlgorithm::m_outputMetaStore
MetaStore_t m_outputMetaStore
Object accessing the output metadata store.
Definition: AnaAlgorithm.h:555
EL::AnaAlgorithm::inputMetaStore
ConstMetaStorePtr_t inputMetaStore() const
Definition: AnaAlgorithm.cxx:72
EL::IHistogramWorker
the interface to histogram storage on the worker
Definition: IHistogramWorker.h:30
EL::AnaAlgorithm::execute
virtual ::StatusCode execute()
execute this algorithm
Definition: AnaAlgorithm.cxx:321
EL::AnaAlgorithm::beginInputFile
virtual ::StatusCode beginInputFile()
perform the action for the beginning of an input file
Definition: AnaAlgorithm.cxx:351
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
EL::AnaAlgorithm::~AnaAlgorithm
virtual ~AnaAlgorithm() noexcept
standard (virtual) destructor
Definition: AnaAlgorithm.cxx:67
EL::AnaAlgorithm::print
virtual void print() const
print the state of the algorithm
Definition: AnaAlgorithm.cxx:337
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
EL::AnaAlgorithm::AnaAlgorithm
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Definition: AnaAlgorithm.cxx:40
EL::AnaAlgorithm::fileExecute
virtual ::StatusCode fileExecute()
perform the action exactly once for each file in the dataset
Definition: AnaAlgorithm.cxx:343
AthHistogramAlgorithm.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
AthHistogramming::hist3d
TH3 * hist3d(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered 3-d histograms.
Definition: AthHistogramming.h:386
EL::AnaAlgorithm
the (new) base class for EventLoop algorithms
Definition: AnaAlgorithm.h:73
EL::AnaAlgorithm::handle
void handle(const Incident &inc)
receive the given incident
Definition: AnaAlgorithm.cxx:521
EL::AnaAlgorithm::finalize
virtual ::StatusCode finalize()
finalize this algorithm
Definition: AnaAlgorithm.cxx:329
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EL::ITreeWorker
The interface to TTree storage on the worker.
Definition: ITreeWorker.h:32
EL::IWorker
the interface for algorithms to access IWorker
Definition: IWorker.h:40
EL::AnaAlgorithm::requestBeginInputFile
::StatusCode requestBeginInputFile()
register this algorithm to have an implementation of beginInputFile
Definition: AnaAlgorithm.cxx:271
MessageCheck.h
macros for messaging and checking status codes
SgTEventMeta.h
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
EL::AnaAlgorithm::m_hasFileExecute
bool m_hasFileExecute
the value of hasFileExecute
Definition: AnaAlgorithm.h:586
AthHistogramAlgorithm
Definition: AthHistogramAlgorithm.h:32
EL::AnaAlgorithm::MetaStore_t
ServiceHandle< StoreGateSvc > MetaStore_t
Type of the metadata store variable in Athena.
Definition: AnaAlgorithm.h:546
AnaAlgorithm.icc
Global.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
EL::AnaAlgorithm::requestEndInputFile
::StatusCode requestEndInputFile()
register this algorithm to have an implementation of endInputFile
Definition: AnaAlgorithm.cxx:292
AsgComponent.h
AthHistogramAlgorithm::sysInitialize
virtual StatusCode sysInitialize()
Initialization method invoked by the framework.
Definition: AthHistogramAlgorithm.cxx:75
asg::SgTEvent
Wrapper for TEvent to make it look like StoreGate.
Definition: SgTEvent.h:44
asg::SgTEventMeta
Wrapper class providing StoreGate-like access to metadata in ROOT.
Definition: SgTEventMeta.h:44
EL::AnaAlgorithm::MetaStorePtr_t
ServiceHandle< StoreGateSvc > & MetaStorePtr_t
Type of the metadata store pointer in standalone mode.
Definition: AnaAlgorithm.h:110
EL::AnaAlgorithm::m_hasEndInputFile
bool m_hasEndInputFile
the value of hasEndInputFile
Definition: AnaAlgorithm.h:594
test_pyathena.filterPassed
filterPassed
now, add a sequencer: it will only execute seqalg1 and 2 and never 3
Definition: test_pyathena.py:38
AthHistogramming::hist
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
Definition: AthHistogramming.cxx:198
EL::AnaAlgorithm::initialize
virtual ::StatusCode initialize()
initialize this algorithm
Definition: AnaAlgorithm.cxx:313
EL::AnaAlgorithm::outputMetaStore
ConstMetaStorePtr_t outputMetaStore() const
Definition: AnaAlgorithm.cxx:92
StoreGateSvc.h
AthHistogramming::tree
TTree * tree(const std::string &treeName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TTrees.
Definition: AthHistogramming.cxx:378
SgTEvent.h
ServiceHandle< StoreGateSvc >