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 
80 
85 
87 public:
90 
92  public:
93  class FilterSet {
94  public:
95  explicit FilterSet(const edm::ParameterSet& config);
97  const trigger::Keys getPassingKeys(const trigger::TriggerEvent& trigEvt) const;
98 
99  private:
100  std::vector<std::string> filters_;
101  bool isAND_;
102  };
103 
104  public:
105  explicit FilterSelector(const edm::ParameterSet& config);
107  const trigger::Keys getPassingKeys(const trigger::TriggerEvent& trigEvt) const;
108 
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  //A rather late addition to replace GenericTriggerEventFlag as it was incompatible with the
119  //move to concurrentMEs as GenericTriggerEventFlag owns tokens
120  //its more or less a direct port of that class, with the functions inspired by it
121  //obviously much less feature rich, only handles HLT
122  class PathSelector {
123  public:
126  void init(const HLTConfigProvider& hltConfig);
127  bool operator()(const edm::TriggerResults& trigResults, const edm::TriggerNames& trigNames) const;
128 
129  private:
130  static std::string expandSelectionStr(const std::string& selStr,
132  bool isAND,
133  int verbose);
134  static std::string expandPath(const std::string& pathPattern,
136  bool isAND,
137  int verbose);
138 
139  std::string selectionStr_; //with wildcard etc
140  std::string expandedSelStr_; //with wildcards expanded, set by init
142  int verbose_;
143  bool isInited_;
144  };
145 
146  class TrigObjVarF {
147  public:
148  explicit TrigObjVarF(std::string varName);
149  float operator()(const trigger::TriggerObject& obj) const {
150  return isAbs_ ? std::abs((obj.*varFunc_)()) : (obj.*varFunc_)();
151  }
152 
153  private:
155  bool isAbs_;
156  };
157 
158  class HistFiller {
159  public:
160  explicit HistFiller(const edm::ParameterSet& config);
162  void operator()(const trigger::TriggerObject& probe, float mass, dqm::reco::MonitorElement* hist) const;
163 
164  private:
167  };
168 
169  //Histogram Defination, defines the histogram (name,title,bins,how its filled)
170  class HistDefs {
171  private:
172  class Data {
173  public:
174  explicit Data(const edm::ParameterSet& config);
177  const std::string& name,
178  const std::string& title,
179  const std::vector<float>& massBins) const;
180  const HistFiller& filler() const { return histFiller_; }
181 
182  private:
184  std::vector<float> bins_;
187  };
188 
189  public:
190  explicit HistDefs(const edm::ParameterSet& config);
192  std::vector<std::pair<HistFiller, dqm::reco::MonitorElement*> > bookHists(DQMStore::IBooker& iBooker,
193  const std::string& name,
194  const std::string& title) const;
195 
196  private:
197  std::vector<Data> histData_;
198  std::vector<float> massBins_;
199  };
200 
201  class HistColl {
202  public:
203  HistColl() {}
204  void bookHists(DQMStore::IBooker& iBooker,
205  const std::string& name,
206  const std::string& title,
207  const HistDefs& histDefs);
208  void fill(const trigger::TriggerObject& probe, float mass) const;
209 
210  private:
211  std::vector<std::pair<HistFiller, dqm::reco::MonitorElement*> > hists_;
212  };
213 
214  class ProbeData {
215  public:
216  explicit ProbeData(std::string probeFilter) : probeFilter_(std::move(probeFilter)) {}
217  void bookHists(const std::string& tagName, DQMStore::IBooker& iBooker, const HistDefs& histDefs);
218  void fill(const trigger::size_type tagKey,
219  const trigger::TriggerEvent& trigEvt,
221 
222  private:
225  };
226 
227 public:
231  void bookHists(DQMStore::IBooker& iBooker);
232  void fill(const trigger::TriggerEvent& trigEvt,
233  const edm::TriggerResults& trigResults,
234  const edm::TriggerNames& trigNames) const;
235 
236 private:
237  //helper function, probably should go in a utilty class
238  static const trigger::Keys getKeys(const trigger::TriggerEvent& trigEvt, const std::string& filterName);
239 
245  std::vector<ProbeData> probeHists_;
247 };
248 
249 #endif
static void cleanTrigKeys(trigger::Keys &keys)
bool operator()(const edm::TriggerResults &trigResults, const edm::TriggerNames &trigNames) const
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
static edm::ParameterSetDescription makePSetDescription()
static edm::ParameterSetDescription makePSetDescription()
static const trigger::Keys getKeys(const trigger::TriggerEvent &trigEvt, const std::string &filterName)
std::vector< ProbeData > probeHists_
bool verbose
TrigObjTnPHistColl(const edm::ParameterSet &config)
void bookHists(DQMStore::IBooker &iBooker)
static edm::ParameterSetDescription makePSetDescription()
Data(const edm::ParameterSet &config)
FilterSet(const edm::ParameterSet &config)
Definition: config.py:1
void init(const HLTConfigProvider &hltConfig)
std::vector< float > massBins_
uint16_t size_type
static std::string expandPath(const std::string &pathPattern, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
ProbeData(std::string probeFilter)
VarRangeCutColl< trigger::TriggerObject > probeCuts_
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
void bookHists(const std::string &tagName, DQMStore::IBooker &iBooker, const HistDefs &histDefs)
static edm::ParameterSetDescription makePSetDescription()
dqm::legacy::DQMStore DQMStore
void init(const HLTConfigProvider &hltConfig)
void fill(const trigger::size_type tagKey, const trigger::TriggerEvent &trigEvt, const VarRangeCutColl< trigger::TriggerObject > &probeCuts) const
std::vector< std::pair< HistFiller, dqm::reco::MonitorElement * > > hists_
dqm::legacy::MonitorElement MonitorElement
dqm::reco::MonitorElement * book(DQMStore::IBooker &iBooker, const std::string &name, const std::string &title, const std::vector< float > &massBins) const
const trigger::Keys getPassingKeys(const trigger::TriggerEvent &trigEvt) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void bookHists(DQMStore::IBooker &iBooker, const std::string &name, const std::string &title, const HistDefs &histDefs)
float(trigger::TriggerObject::* varFunc_)() const
static void mergeTrigKeys(trigger::Keys &keys, const trigger::Keys &keysToMerge, bool isAND)
__shared__ Hist hist
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
void fill(const trigger::TriggerObject &probe, float mass) const
HistFiller(const edm::ParameterSet &config)
PathSelector(const edm::ParameterSet &config)
static std::string expandSelectionStr(const std::string &selStr, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
std::vector< size_type > Keys
void fill(const trigger::TriggerEvent &trigEvt, const edm::TriggerResults &trigResults, const edm::TriggerNames &trigNames) const
const trigger::Keys getPassingKeys(const trigger::TriggerEvent &trigEvt) const
float operator()(const trigger::TriggerObject &obj) const
HistDefs(const edm::ParameterSet &config)
std::vector< std::pair< HistFiller, dqm::reco::MonitorElement * > > bookHists(DQMStore::IBooker &iBooker, const std::string &name, const std::string &title) const
std::vector< FilterSet > filterSets_
VarRangeCutColl< trigger::TriggerObject > tagCuts_
VarRangeCutColl< trigger::TriggerObject > localCuts_
const HistFiller & filler() const
void operator()(const trigger::TriggerObject &probe, float mass, dqm::reco::MonitorElement *hist) const
static edm::ParameterSetDescription makePSetDescription()
FilterSelector(const edm::ParameterSet &config)
static edm::ParameterSetDescription makePSetDescription()
FilterSelector tagFilters_
def move(src, dest)
Definition: eostools.py:511
static edm::ParameterSetDescription makePSetDescription()