Crombie Tools
LimitTreeMaker.h
Go to the documentation of this file.
1 /**
2  @file LimitTreeMaker.h
3 
4  Header file for the LimitTreeMaker class.
5 
6  @author Daniel Abercrombie <dabercro@mit.edu>
7 */
8 
9 #ifndef CROMBIETOOLS_ANALYSISTOOLS_LIMITTREEMAKER_H
10 #define CROMBIETOOLS_ANALYSISTOOLS_LIMITTREEMAKER_H
11 
12 #include <map>
13 #include <set>
14 #include <vector>
15 #include "TString.h"
16 #include "InOutDirectoryHolder.h"
17 #include "FileConfigReader.h"
18 
19 /**
20  @ingroup analysisgroup
21  @class LimitTreeMaker
22  @brief Can be created using the CrombieTools.AnalysisTools.LimitTreeMaker module.
23 
24  Makes small flat trees for limit tools.
25  Reads from a [config file](@ref formatmc) or multiple and creates one file
26  with a tree for each control region and each file read in. Only works if you have
27  write access to /tmp/$USER since it uses the space to hold trees while copying.
28 */
29 
31 {
32  public:
33  /// Default constructor, making the output file name "`limittree.root`".
34  LimitTreeMaker() { LimitTreeMaker("limittree.root"); }
35  LimitTreeMaker( TString outputName );
36  virtual ~LimitTreeMaker();
37 
38  /// Reads a config and swaps out files for one control region
39  void ReadExceptionConfig ( const char* config, TString region, TString fileDir = "" );
40  /// Makes the file containing all of the limit trees.
41  void MakeTrees ();
42 
43  /// Set name of limit tree file
44  inline void SetOutFileName ( TString file ) { fOutputFileName = file; }
45  /// Set the name of the tree read from each input file
46  inline void SetTreeName ( TString tree ) { fTreeName = tree; }
47  /// Add friends to input tree. @todo I don't think this works.
48  inline void AddFriendName ( TString tree ) { fFriendNames.push_back(tree); }
49  /// Adds a branch to keep in the limit tree
50  inline void AddKeepBranch ( TString branch, Bool_t isInt = false ) { fKeepBranches.push_back(branch);
51  fKeepBranchIsInt.push_back(isInt); }
52  /// Adds a name of a branch to multiply into the weights branch
53  inline void AddWeightBranch ( TString branch ) { fWeightBranch.push_back(branch); }
54  /// Adds a region by name and cut
55  inline void AddRegion ( TString regionName, TString regionCut )
56  { fRegionNames.push_back(regionName); fRegionCuts.push_back(regionCut); }
57  /// Sets the name of the output weight branch
58  inline void SetOutputWeightBranch ( TString branch ) { fOutputWeightBranch = branch; }
59 
60  /**
61  Add a file to skip within a region.
62 
63  @param region is the region to do the skipping in
64  @param outTreeName can be either the tree name as listed in the config, or the name of the file
65  */
66  inline void ExceptionSkip ( TString region, TString outTreeName ) { fExceptionSkip[region].insert(outTreeName); }
67  /// Add a file to only one region
68  inline void ExceptionAdd ( TString region, TString fileName, TString outTreeName, Float_t XSec = -1 )
69  { fExceptionFileNames[region].push_back(fileName);
70  fExceptionTreeNames[region].push_back(outTreeName);
71  fExceptionXSecs[region].push_back(XSec); }
72 
73  inline void AddExceptionDataCut ( TString region, TString cut ) { fExceptionDataCuts[region] = cut; }
74  inline void AddExceptionWeightBranch ( TString region, TString weight ) { fExceptionWeightBranches[region].push_back(weight); }
75  /// @todo make all frequency reports in a centralized class
76  inline void SetReportFrequency ( UInt_t freq ) { fReportFrequency = freq; }
77 
78  private:
80  TString fOutputFileName;
81  TString fTreeName;
82  std::vector<TString> fFriendNames;
83  std::vector<TString> fKeepBranches;
84  std::vector<Bool_t> fKeepBranchIsInt;
85  std::vector<TString> fWeightBranch;
86  std::vector<TString> fRegionNames;
87  std::vector<TString> fRegionCuts;
89 
90  std::map<TString,std::set<TString> > fExceptionSkip;
91  std::map<TString,std::vector<TString> > fExceptionFileNames;
92  std::map<TString,std::vector<TString> > fExceptionTreeNames;
93  std::map<TString,std::vector<Float_t> > fExceptionXSecs;
94 
95  std::map<TString,TString> fExceptionDataCuts;
96  std::map<TString,std::vector<TString> > fExceptionWeightBranches;
97 
98  ClassDef(LimitTreeMaker,1)
99 };
100 
101 #endif