HighLAND
SimpleLoopBase.hxx
1 #ifndef SimpleLoopBase_h
2 #define SimpleLoopBase_h
3 
4 #include "OutputManager.hxx"
5 #include "HighlandInputManager.hxx"
6 #include "CorrectionManager.hxx"
7 #include "DocStringManager.hxx"
8 #include "VersionManager.hxx"
9 #include "MemoryUsage.hxx"
10 
11 /// This class is a base class for simple event loops (Flat tree creation, etc).
12 /// It handles the opening and reading of input files, and converting each
13 /// spill to the AnaSpill format. The derived Process() function is called for
14 /// each spill.
16  public :
17 
18  SimpleLoopBase(int argc, char *argv[]);
19  virtual ~SimpleLoopBase(){}
20 
21  /// The main event loop, which loops over all the spills, and calls Process()
22  /// for each.
23  void Loop(int nmax=0,int imin=0);
24 
25  /// Entry point to the class, where argc and argv are the command line
26  /// parameters.
27  void Execute();
28 
29  protected:
30 
31  /// Print the program's usage statement.
32  void PrintUsage(const std::string& programName);
33 
34  /// Initialize the input manager etc, and calls the derived version of the
35  /// function. Called before any spills are read.
36  virtual bool Initialize();// = 0;
37 
38  /// Initialize each spill, including reading it from the input file. Called
39  /// before Process().
40  virtual bool InitializeSpill();// = 0;
41 
42  /// Tidy up, including closing the output file. Called after all spills have
43  /// beem read.
44 
45  virtual void Finalize();// = 0;
46 
47  /// Finalize each spill, including cleaning up data read from the input file.
48  virtual void FinalizeSpill();// = 0;
49 
50  /// The main function that should be overridden in the derived class. Called
51  /// once for each spill, after it has been read in from the input file. The
52  /// current spill can be accessed using ND::input().GetSpill().
53  virtual bool Process() = 0;
54 
55  /// Define the tree that should be written to the output file.
56  virtual void DefineOutputTree();// = 0;
57 
58  // Return the Input Manager
59  HighlandInputManager& input(){return _input;}
60 
61  protected:
62 
63  /// Fill the "config" tree, which includes details of the analysis cuts etc.
64  void FillConfigTree();
65 
66  /// The current entry in the file.
67  Long64_t _entry;
68 
69  /// Input file name, as specified by the user.
70  std::string _inputFileName;
71 
72  /// Input file type. The file type is now found automatically, so this is
73  /// deprecated.
74  std::string _inputFileType;
75 
76  /// The output file name, as specified by the user.
77  std::string _outputFileName;
78 
79  /// Whether to run in "cosmics" mode, where all the tracks are saved in a
80  /// single bunch.
82 
83  /// Check version compatibility between nd280AnalysisTools compilation and oaAnalysis file
85 
86  /// Memory logging.
88 
89  /// Correction manager
91 
92  /// DocStrings manager
94 
95  private:
96 
97  /// The number of entries in the tree to run over.
98  int _entry_nmax;
99 
100  /// The entry in the tree to start from.
101  int _entry_imin;
102 
103  /// The entry in the tree to finish with.
104  int _entry_imax;
105 
106  /// Total number of entries run so far
107  int _entry_count;
108 
109  HighlandInputManager _input;
110 
111  enum enumConfigTree_SimpleLoopBase{
112  SoftwareVersion=0,
113  HOSTNAME,
114  CMTPATH,
115  INPUTFILE,
116  OriginalFile,
117  enumConfigTreeLast_SimpleLoopBase
118  };
119 
120 };
121 
122 #endif
void Loop(int nmax=0, int imin=0)
virtual void DefineOutputTree()
Define the tree that should be written to the output file.
CorrectionManager _corrections
Correction manager.
MemoryUsage _memory
Memory logging.
std::string _inputFileName
Input file name, as specified by the user.
virtual bool InitializeSpill()
virtual bool Process()=0
Long64_t _entry
The current entry in the file.
void PrintUsage(const std::string &programName)
Print the program's usage statement.
virtual void FinalizeSpill()
Finalize each spill, including cleaning up data read from the input file.
virtual bool Initialize()
virtual void Finalize()
DocStringManager _docStrings
DocStrings manager.
bool _versionCheck
Check version compatibility between nd280AnalysisTools compilation and oaAnalysis file...
void FillConfigTree()
Fill the "config" tree, which includes details of the analysis cuts etc.
std::string _inputFileType
std::string _outputFileName
The output file name, as specified by the user.