Crombie Tools
FlatSkimmer.h
Go to the documentation of this file.
1 /**
2  @file FlatSkimmer.h
3  Header file for the FlatSkimmer class.
4  @author Daniel Abercrombie <dabercro@mit.edu>
5 */
6 
7 #ifndef CROMBIETOOLS_SKIMMINGTOOLS_FLATSKIMMER_H
8 #define CROMBIETOOLS_SKIMMINGTOOLS_FLATSKIMMER_H
9 
10 #include <vector>
11 #include <set>
12 
13 #include "TString.h"
14 
15 #include "ProgressReporter.h"
16 #include "InOutDirectoryHolder.h"
17 #include "GoodLumiFilter.h"
18 
19 /**
20  @ingroup skimminggroup
21  @class FlatSkimmer
22  @brief Can be created using the CrombieTools.SkimmingTools.FlatSkimmer module.
23 
24  Skims events out of a flat tree.
25  Takes files from one directory, and writes copies to another directory,
26  taking out events based on a cut string, event filters, a GoodLumiFilter,
27  and duplicate events.
28 */
29 
31 {
32  public:
33  FlatSkimmer();
34  virtual ~FlatSkimmer();
35 
36  void Skim ( TString fileName );
37  void AddEventFilter ( TString filterName );
38 
39  /// Copy this FlatSkimmer for parallelization
40  FlatSkimmer* Copy ();
41 
42  /// Set GoodLumiFilter to determine good events
43  void SetGoodLumiFilter ( GoodLumiFilter *filter ) { fGoodLumiFilter = *filter; }
44  /// Set cut that events must pass
45  void SetCut ( TString cut ) { fCut = cut; }
46  /// Set input tree name
47  void SetTreeName ( TString name ) { fTreeName = name; }
48  /// Set branch name for run number
49  void SetRunExpr ( TString expr ) { fRunExpr = expr; }
50  /// Set branch name for lumi number
51  void SetLumiExpr ( TString expr ) { fLumiExpr = expr; }
52  /// Set branch name for event number
53  void SetEventExpr ( TString expr ) { fEventExpr = expr; }
54  /// Set flag to check for duplicate events
55  void SetCheckDuplicates ( Bool_t check ) { fCheckDuplicates = check; }
56  /// Add name of TObject to copy from input file to output file unchanged
57  void AddCopyObject ( TString name ) { fCopyObjects.push_back(name); }
58 
59  /// Wrapper to be used by CrombieTools.Parallelization.RunOnDirectory()
60  void RunOnFile ( TString name ) { Skim(name); }
61 
62  /// Gives a file that contains names of branches to not activate
63  void SetDisableFile ( TString name ) { fDisableFile = name; }
64 
65  /// Gives a file that contains names of branches to activate
66  void SetKeepFile ( TString name ) { fKeepFile = name; }
67 
68  private:
69  std::set<TString> fEventFilter; ///< Events to skim out
70  GoodLumiFilter fGoodLumiFilter; ///< GoodLumiFilter for this FlatSkimmer
71  TString fCut = "1"; ///< Event cut
72  TString fTreeName = "events"; ///< Tree name of flat tree to read
73  TString fRunExpr = "runNumber"; ///< Branch for run number
74  TString fLumiExpr = "lumiNumber"; ///< Branch for lumi number
75  TString fEventExpr = "eventNumber"; ///< Branch for event number
76  TString fDisableFile = ""; ///< File to look for branches to disable
77  TString fKeepFile = ""; ///< File to look for branches to keep
78  Int_t fCheckDuplicates = false; ///< Flag to check duplicates
79  std::vector<TString> fCopyObjects; ///< List of TObject names to also copy from original file
80 
81  ClassDef(FlatSkimmer,1)
82 };
83 
84 #endif