CMS 3D CMS Logo

TrigObjTnPHistColl.h
Go to the documentation of this file.
1 #ifndef DQM_HLTEvF_TrigObjTnPHistColl_h
2 #define DQM_HLTEvF_TrigObjTnPHistColl_h
3 
4 //********************************************************************************
5 //
6 // Description:
7 // Manages a set of histograms intended for tag and probe efficiency measurements
8 // using TriggerObjects stored in TriggerEvent as the input
9 // selection is limited to basic et/eta/phi cuts and trigger filter requirements
10 // The idea that this can run on any of the following data formats RAW,RECO,AOD
11 // or even as part of the HLT job
12 //
13 // All histograms in a TrigObjTnPHistColl share the same tag defination and
14 // currently the same probe et/eta/phi cuts. The tag trigger requirements may be
15 // to pass multiple triggers anded or ored together
16 //
17 // The TrigObjTnPHistColl then has a series of histograms which are filled for
18 // probes which pass a specified filter. For each specified filter, a set of
19 // 2D histograms are produced, <var> vs mass where var is configuable via python
20 // These histograms may have additional cuts, eg eta cuts which limit them to barrel
21 // or endcap
22 
23 // This allows us to get the mass spectrum in each bin to allow signal & bkg fits
24 //
25 // Class Structure
26 // TrigObjTnPHistColl : master object which manages a series of histograms which
27 // share a common tag defination. It selects tag and probe pairs
28 // and then sends selected probes to fill the relavent histograms
29 //
30 // FilterSelector : specifies and cuts on the trigger filters an object has to pass.
31 // It allows ANDed and ORing of trigger filter requirements.
32 // It acheives this by grouping the filters in sets of filters (FilterSet)
33 // and an object either has to pass all of those filters in the sets or
34 // any of those filters in the set.
35 // An object can then be required to pass all defined FilterSets or any of them
36 //
37 // PathSelector : checks that a given path has fired. Was originally supposed to use instead
38 // GenericTriggerEventFlag but that class was awkward to use in the
39 // concurrentME workflow so PathSelector was created to mimic the required
40 // functionality. It was a quick port of GenericTriggerEventFlag adapted to
41 // to work in our desired workflow and may be replaced/reworked in the future
42 //
43 // TrigObjVarF : allows arbitary access to a given float variable of trigger::TriggerObject
44 // it can also return the abs value of that variable if so requested
45 //
46 // HistFiller : stores the variable a histogram is to be filled with and any cuts the object
47 // must additional pass. It then can fill/not fill a histogram using this information
48 //
49 // HistDefs : has all the information necesary to define a histograms to be produced.
50 // The Data sub struct containts the HistFiller object, the binning of the
51 // histogram and name /title suffexs. There is one set of histogram definations
52 // for a TrigObjTnPHistColl so each probe filter has identical binning
53 // Each booked histogram contains a local copy of the approprate HistFiller
54 //
55 // HistColl : a collection of histograms to be filled by a probe passing a particular trigger
56 // and kinematic selection. Histograms may have additional further selection on the
57 // probe (eg limiting to the barrel etc). Each histogram is booked using the central
58 // histogram definations and contains a copy of the approprate HistFiller
59 //
60 // ProbeData : a specific filter for a probe object to pass with a collection of histograms to
61 // fill managed by HistColl. The filter is not measured by FilterSelector as it is
62 // intentionally limited to only a single filter
63 //
64 // TrigObjTnPHistColl : single tag selection and generic requirements for a probe
65 // |
66 // |--> collection of ProbeData : a set of histos to fill for probes passing a given filter
67 // |
68 // |--> ProbeData : filter to pass to fill histograms + histograms
69 // |
70 // |--> HistColl : hists for it to be filled
71 // |
72 // |--> collection of HistFillters+their hists, histfillter fills the hist
73 //
74 // Author : Sam Harper , RAL, Aug 2018
75 //
76 //***********************************************************************************
77 
78 
81 
87 
88 
90 public:
91 
93  public:
94  class FilterSet {
95  public:
96  explicit FilterSet(const edm::ParameterSet& config);
98  const trigger::Keys getPassingKeys(const trigger::TriggerEvent& trigEvt)const;
99 
100  private:
101  std::vector<std::string> filters_;
102  bool isAND_;
103  };
104 
105  public:
106  explicit FilterSelector(const edm::ParameterSet& config);
108  const trigger::Keys getPassingKeys(const trigger::TriggerEvent& trigEvt)const;
109  private:
110  //helper functions
111  static void mergeTrigKeys(trigger::Keys& keys,const trigger::Keys& keysToMerge,bool isAND);
112  static void cleanTrigKeys(trigger::Keys& keys);
113 
114  std::vector<FilterSet> filterSets_;
115  bool isAND_;
116 
117  };
118 
119  //A rather late addition to replace GenericTriggerEventFlag as it was incompatible with the
120  //move to concurrentMEs as GenericTriggerEventFlag owns tokens
121  //its more or less a direct port of that class, with the functions inspired by it
122  //obviously much less feature rich, only handles HLT
123  class PathSelector {
124  public:
127  void init(const HLTConfigProvider& hltConfig);
128  bool operator()(const edm::TriggerResults& trigResults,const edm::TriggerNames& trigNames)const;
129  private:
130  static std::string expandSelectionStr(const std::string& selStr,const HLTConfigProvider& hltConfig,bool isAND,int verbose);
131  static std::string expandPath(const std::string& pathPattern, const HLTConfigProvider& hltConfig,bool isAND,int verbose);
132 
133  std::string selectionStr_; //with wildcard etc
134  std::string expandedSelStr_; //with wildcards expanded, set by init
136  int verbose_;
137  bool isInited_;
138  };
139 
140  class TrigObjVarF {
141  public:
142  explicit TrigObjVarF(std::string varName);
144  return isAbs_ ? std::abs((obj.*varFunc_)()) : (obj.*varFunc_)();
145  }
146  private:
147  float (trigger::TriggerObject::*varFunc_)()const;
148  bool isAbs_;
149  };
150 
151  class HistFiller {
152  public:
153  explicit HistFiller(const edm::ParameterSet& config);
155  void operator()(const trigger::TriggerObject& probe,float mass,const ConcurrentMonitorElement& hist)const;
156  private:
159  };
160 
161  //Histogram Defination, defines the histogram (name,title,bins,how its filled)
162  class HistDefs {
163  private:
164  class Data {
165  public:
166  explicit Data(const edm::ParameterSet& config);
168  ConcurrentMonitorElement book(DQMStore::ConcurrentBooker& iBooker,const std::string& name,const std::string& title,const std::vector<float>& massBins)const;
169  const HistFiller& filler()const{return histFiller_;}
170  private:
172  std::vector<float> bins_;
175  };
176  public:
177  explicit HistDefs(const edm::ParameterSet& config);
179  std::vector<std::pair<HistFiller,ConcurrentMonitorElement> > bookHists(DQMStore::ConcurrentBooker& iBooker,const std::string& name,const std::string& title)const;
180  private:
181  std::vector<Data> histData_;
182  std::vector<float> massBins_;
183  };
184 
185  class HistColl {
186  public:
189  const std::string& title,const HistDefs& histDefs);
190  void fill(const trigger::TriggerObject& probe,float mass)const;
191  private:
192  std::vector<std::pair<HistFiller,ConcurrentMonitorElement> > hists_;
193  };
194 
195 
196  class ProbeData {
197  public:
198  explicit ProbeData(std::string probeFilter):probeFilter_(std::move(probeFilter)){}
199  void bookHists(const std::string& tagName,DQMStore::ConcurrentBooker& iBooker,const HistDefs& histDefs);
200  void fill(const trigger::size_type tagKey,const trigger::TriggerEvent& trigEvt,const VarRangeCutColl<trigger::TriggerObject>& probeCuts)const;
201 
202  private:
205  };
206 
207 public:
210  void init(const HLTConfigProvider& hltConfig){evtTrigSel_.init(hltConfig);}
211  void bookHists(DQMStore::ConcurrentBooker& iBooker);
212  void fill(const trigger::TriggerEvent& trigEvt,
213  const edm::TriggerResults& trigResults,
214  const edm::TriggerNames& trigNames)const;
215 
216 private:
217  //helper function, probably should go in a utilty class
218  static const trigger::Keys getKeys(const trigger::TriggerEvent& trigEvt,const std::string& filterName);
219 
225  std::vector<ProbeData> probeHists_;
227 
228 };
229 
230 
231 #endif
static void cleanTrigKeys(trigger::Keys &keys)
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
static edm::ParameterSetDescription makePSetDescription()
static const trigger::Keys getKeys(const trigger::TriggerEvent &trigEvt, const std::string &filterName)
std::vector< ProbeData > probeHists_
TrigObjTnPHistColl(const edm::ParameterSet &config)
const trigger::Keys getPassingKeys(const trigger::TriggerEvent &trigEvt) const
FilterSet(const edm::ParameterSet &config)
Definition: config.py:1
void init(const HLTConfigProvider &hltConfig)
std::vector< float > massBins_
uint16_t size_type
const HistFiller & filler() const
ProbeData(std::string probeFilter)
VarRangeCutColl< trigger::TriggerObject > probeCuts_
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
void init(const HLTConfigProvider &hltConfig)
std::vector< std::pair< HistFiller, ConcurrentMonitorElement > > hists_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float operator()(const trigger::TriggerObject &obj) const
static void mergeTrigKeys(trigger::Keys &keys, const trigger::Keys &keysToMerge, bool isAND)
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
std::vector< size_type > Keys
void bookHists(DQMStore::ConcurrentBooker &iBooker)
std::vector< FilterSet > filterSets_
VarRangeCutColl< trigger::TriggerObject > tagCuts_
VarRangeCutColl< trigger::TriggerObject > localCuts_
FilterSelector(const edm::ParameterSet &config)
FilterSelector tagFilters_
void fill(const trigger::TriggerEvent &trigEvt, const edm::TriggerResults &trigResults, const edm::TriggerNames &trigNames) const
def move(src, dest)
Definition: eostools.py:511