eventAnalysis  7.0-49-g0ac7482
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TAnalysisLoop.hxx
Go to the documentation of this file.
1 #include <vector>
2 
3 #include <TOADatabase.hxx>
4 #include <nd280EventLoop.hxx>
5 
7 
8 /// Used to expose globals that may be of use to other modules.
9 namespace AnalysisLoopGlobals {
10 /// Holds the number of processed events.
11 ///
12 /// Used by an interrupt handler in RunEventAnalysis.cxx to report loop progress.
13 extern int EventNumber;
14 ///\brief Holds the name of the module that is currently executing
15 /// TAnalysisBase::Process
16 ///
17 /// Set by ND::TAnalysisLoop::Operator().
18 /// Used by an interrupt handler in RunEventAnalysis.cxx to report loop progress.
19 extern std::string CurrentlyProcessingModule;
20 /// Used to notify the event loop to stop processing events and finish quickly.
21 extern bool StopProcessing;
22 }
23 
24 namespace ND {
25 class TAnalysisLoop;
26 OA_EXCEPTION(EProductionException, EeventAnalysis);
27 
28 /// Generate an analysis tree to summarize the event reconstruction. This
29 /// should be replaced by the general eventAnalysis tree, but that's not ready.
30 class TAnalysisLoop : public ND::TND280EventLoopFunction {
31  public:
32  ///\brief Initialize any class specific variables.
33  ///
34  /// Most of the work can be done in ND::TAnalysisLoop::Initialize.
35  ///\warning Don't create histograms here!
36  TAnalysisLoop();
37  virtual ~TAnalysisLoop();
38 
39  ///\brief Print a usage message.
40  ///
41  /// \note This is generally called when there is a command line input error.
42  void Usage(void);
43 
44  ///\brief Set an option and return true if it is valid.
45  ///
46  /// This is called by the event loop command line argument processing code
47  /// for each "-O [name]=[value]" option found on the command line. If the
48  /// command line has "-O [name]" without a value, then the value string will
49  /// be equal to "". This must return false if the option was not correctly
50  /// processed.
51  virtual bool SetOption(std::string, std::string);
52 
53  /// \brief Called for each event inside the event loop, and returns true if
54  /// the event should be saved to the output file.
55  ///
56  /// If the remainder of the current file should be skipped, this should
57  /// throw the ENextEventLoopFile exception.
58  bool operator()(ND::TND280Event& event);
59 
60  ///\brief Called after the arguments are processes by before reading the
61  /// first event.
62  ///
63  /// The output file is open so any histograms will be added to the
64  /// output file.
65  virtual void Initialize(void);
66 
67  ///\brief Called before the first event of a file is read, but you should
68  /// prefer TAnalysisLoop::Initialize for general initialization.
69  ///
70  /// This method will be called once for each input file.
71  virtual void BeginFile(ND::TVInputFile* input);
72 
73  ///\brief Called after the last event of a file is read, but you should
74  /// prefer TAnalysisLoop: Finalize() for general finalization.
75  ///
76  /// This method will be called once for each input file.
77  virtual void EndFile(ND::TVInputFile*);
78 
79  ///\brief Called after The last event but before the output file is closed.
80  ///
81  /// Because of an idiosyncrasy in the way root handles histograms, objects
82  /// created in Initialize() will already be stored in the output file.
83  using ND::TND280EventLoopFunction::Finalize;
84  virtual void Finalize(ND::TND280Output* const output);
85 
86  private:
87  /// Private typedef which makes talking to fAnalysisModules slightly nicer.
88  typedef std::pair<std::string, ND::TAnalysisModuleBase*> ModDescriptor;
89  /// Private typedef which makes talking to fAnalysisModules slightly nicer.
90  typedef std::vector<ModDescriptor>::iterator ModDescripterator;
91  /// Private typedef which makes talking to fAnalysisModules slightly nicer.
92  typedef std::vector<ModDescriptor>::const_iterator CModDescripterator;
93 
94  ///\brief Method to set the the default enable/disable values for all
95  /// modules in fAnalysisModules map.
96  void SetModuleDefaults();
97 
98  ///\brief Searches through TAnalysisLoop::fAnalysisModules for a street
99  /// module named Bob.
100  ///
101  ///\returns std::vector::end if none is found.
103  std::vector<TAnalysisLoop::ModDescriptor>& ModMap,
104  std::string ModuleName);
105 
106  ///\brief Searches through TAnalysisLoop::fAnalysisModules for a street
107  /// module named Bob.
108  ///
109  ///\returns std::vector::end if none is found.
111  std::vector<TAnalysisLoop::ModDescriptor> const& ModMap,
112  std::string ModuleName);
113 
114  /// Keep track of the events that have been read.
116 
117  /// Flag if the full event (not the analysis format) is also to be saved
118  /// This overrides any -preselection=<&lt;moduleclass&gt;> settings
120 
121  /// Set automatically if the oaEvent tree needs to be saved in output
122  /// file.
124 
125  /// Internal map of all modules.
126  std::vector<ModDescriptor> fAnalysisModules;
127 
128  ///\brief Store whether a module has been set to disabled/enables by user
129  /// as well as whether the disable/enable all options have been set.
130  ///
131  /// fUserEnabled takes highest precidence over fDisableAll and fEnableAll.
132  std::map<std::string, bool> fUserEnabled;
133 
134  /// This is overridden by fEnableAll.
136  ///\brief Enables All modules, if a given module
137  /// isn't disabled in fUserEnabled.
139 
140  /// Controls production mode
142  ///\brief If set to true during execution will result in execution
143  /// termination at the end of the next event.
144  bool fExit;
145 
146  /// Control validation mode
148 
149  /// The ND280 geometry to be saved
150  TGeoManager* fGeom;
151  /// Flag to control saving ND280 geometry
152  bool fGeometry;
153 };
154 }
bool fGeometry
Flag to control saving ND280 geometry.
std::string CurrentlyProcessingModule
Holds the name of the module that is currently executing TAnalysisBase::Process.
bool fEnableAll
Enables All modules, if a given module isn&#39;t disabled in fUserEnabled.
OA_EXCEPTION(EeventAnalysis, EoaCore)
Generate a base exception for the Analysis library.
bool fExit
If set to true during execution will result in execution termination at the end of the next event...
std::vector< ModDescriptor > fAnalysisModules
Internal map of all modules.
bool fSaveOutputOaEventTree
Set automatically if the oaEvent tree needs to be saved in output file.
TGeoManager * fGeom
The ND280 geometry to be saved.
TAnalysisLoop()
Initialize any class specific variables.
int EventNumber
Holds the number of processed events.
std::pair< std::string, ND::TAnalysisModuleBase * > ModDescriptor
Private typedef which makes talking to fAnalysisModules slightly nicer.
void SetModuleDefaults()
Method to set the the default enable/disable values for all modules in fAnalysisModules map...
int fEventCount
Keep track of the events that have been read.
bool fSaveOriginalFullEvent
Flag if the full event (not the analysis format) is also to be saved This overrides any -preselection...
bool operator()(ND::TND280Event &event)
Called for each event inside the event loop, and returns true if the event should be saved to the out...
std::map< std::string, bool > fUserEnabled
Store whether a module has been set to disabled/enables by user as well as whether the disable/enable...
bool fProduction
Controls production mode.
virtual void BeginFile(ND::TVInputFile *input)
Called before the first event of a file is read, but you should prefer TAnalysisLoop::Initialize for ...
virtual void Finalize(ND::TND280Output *const output)
virtual void EndFile(ND::TVInputFile *)
Called after the last event of a file is read, but you should prefer TAnalysisLoop: Finalize() for ge...
virtual ~TAnalysisLoop()
void Usage(void)
Print a usage message.
std::vector< ModDescriptor >::iterator ModDescripterator
Private typedef which makes talking to fAnalysisModules slightly nicer.
bool fDisableAll
This is overridden by fEnableAll.
Generate an analysis tree to summarize the event reconstruction.
virtual void Initialize(void)
Called after the arguments are processes by before reading the first event.
bool StopProcessing
Used to notify the event loop to stop processing events and finish quickly.
bool fValidation
Control validation mode.
ModDescripterator FindNamedModule(std::vector< TAnalysisLoop::ModDescriptor > &ModMap, std::string ModuleName)
Searches through TAnalysisLoop::fAnalysisModules for a street module named Bob.
std::vector< ModDescriptor >::const_iterator CModDescripterator
Private typedef which makes talking to fAnalysisModules slightly nicer.
virtual bool SetOption(std::string, std::string)
Set an option and return true if it is valid.

Package Summary
Package Name: eventAnalysis
Package Version: 7.0-49-g0ac7482
Package Manager:

Generated on Mon Mar 25 2024 14:43:58 for eventAnalysis by doxygen 1.8.5