Crombie Tools
CorrectorApplicator.h
Go to the documentation of this file.
1 /**
2  @file CorrectorApplicator.h
3  Header that defines the CorrectorApplicator class.
4  @author Daniel Abercrombie <dabercro@mit.edu>
5 */
6 
7 #ifndef CROMBIETOOLS_SKIMMINGTOOLS_CORRECTORAPPLICATOR_H
8 #define CROMBIETOOLS_SKIMMINGTOOLS_CORRECTORAPPLICATOR_H
9 
10 #include <vector>
11 #include "TString.h"
12 #include "ProgressReporter.h"
13 #include "InDirectoryHolder.h"
14 #include "Corrector.h"
15 
16 /**
17  @ingroup skimminggroup
18  @class CorrectorApplicator
19  @brief Can be created using the CrombieTools.SkimmingTools.Corrector module.
20 
21  Applies multiple Corrector objects to a tree in a file.
22  @todo create a type of corrector that does trigger bits from a TFormula
23 */
24 
26 {
27  public:
28  CorrectorApplicator( TString name = "", Bool_t saveAll = true );
29  virtual ~CorrectorApplicator();
30 
31  /// Copy this CorrectorApplicator for parallelization
33 
34  /// Apply the corrections to a given file.
35  void ApplyCorrections ( TString fileName );
36 
37  /// Set the name of the input tree for each of the Corrector objects to read.
38  inline void SetInputTreeName ( TString tree ) { fInputTreeName = tree; }
39  /**
40  Set the name of the output tree for the correctors.
41  If this is the same as the input tree, the branch must not already exist.
42  */
43  inline void SetOutputTreeName ( TString tree ) { fOutputTreeName = tree; }
44  /// Add a Corrector object to the CorrectorApplicator
45  inline void AddCorrector ( Corrector* corrector ) { fCorrectors.push_back(corrector); }
46  /// Add a branch name to include by multiplication into the main output branch of the CorrectorApplicator.
47  inline void AddFactorToMerge ( TString factor ) { fMergeFactors.push_back(factor); }
48 
49  /// Wrapper for CrombieTools.Parallelization.RunOnDirectory() to use.
50  inline void RunOnFile ( TString fileName ) { ApplyCorrections(fileName); }
51 
52  /// Sets whether the common branch is an uncertainty or a scale factor.
53  inline void SetIsUncertainty ( Bool_t unc ) { fIsUncertainty = unc; }
54 
55  private:
56  TString fName; ///< Name of the master output branch.
57  Bool_t fSaveAll; ///< Bool to save other Corrector results to tree too.
58  TString fInputTreeName = "events"; ///< Input tree name.
59  TString fOutputTreeName = "corrections"; ///< Output tree name.
60  std::vector<Corrector*> fCorrectors; ///< Vector of corrector pointers.
61  std::vector<TString> fMergeFactors; ///< Vector of branches to merge.
62  Bool_t fIsUncertainty = false; ///< Determines how to merge the branches.
63 
64  ClassDef(CorrectorApplicator,1)
65 };
66 
67 #endif