Crombie Tools
CutflowMaker.h
Go to the documentation of this file.
1 /**
2  @file CutflowMaker.h
3 
4  Header file for the CutflowMaker class.
5 
6  @author Daniel Abercrombie <dabercro@mit.edu>
7 */
8 
9 #ifndef CROMBIETOOLS_ANALYSISTOOLS_CUTFLOWMAKER_H
10 #define CROMBIETOOLS_ANALYSISTOOLS_CUTFLOWMAKER_H
11 
12 #include <vector>
13 #include "TTree.h"
14 #include "TString.h"
15 
16 #include "PlotBase.h"
17 
18 /**
19  @class CutflowMaker
20  Makes cutflow plots or tables from given trees.
21 */
22 
23 class CutflowMaker : public PlotBase
24 {
25  public:
27  virtual ~CutflowMaker() {}
28 
29  /**
30  Add a cut to the cutflow.
31  @param name is the name that the cut will have in the table or plot
32  @param cut is the cutstring applied to the tree left from the previous cut
33  */
34  inline void AddCut ( TString name, TString cut ) { fCutNames.push_back(name); fCuts.push_back(cut); }
35 
36  /// Types of cutflow tables to print
37  enum TableType {
38  kNormal = 0, ///< Just displays the cut name and result in two columns
39  kNumbers, ///< Shows only numbers for copying into people's Excel sheets
40  kLatex, ///< Prints a table that can be copied into LaTeX
41  };
42  /// Prints the cutflow for a single line given
43  void PrintCutflow ( TableType table = kNormal );
44 
45  /// Type of plot to show from the cutflow
46  enum PlotType {
47  kAbsolute = 0, ///< Counts the number of events for the cutflow
48  kFractional, ///< Shows the fraction of events since the last cut
49  };
50  /// Makes cutflow plots. Multiple lines can be used here.
51  void MakePlot ( TString name, PlotType type = kAbsolute );
52  /// Resets the cutflow cuts
53  inline void Reset () { fCutNames.resize(0); fCuts.resize(0); fYields.resize(0); }
54 
55  private:
56  std::vector<TString> fCutNames; ///< Names of the cuts to show up in legends or tables
57  std::vector<TString> fCuts; ///< Cut strings
58  std::vector<UInt_t> fYields; ///< Holds yields
59  void GetCutflow ( UInt_t index ); ///< Get the cutflow for a given line index
60 
61  ClassDef(CutflowMaker,1)
62 };
63 
64 #endif