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
TrigObjTnPHistColl::PathSelector::PathSelector
PathSelector(const edm::ParameterSet &config)
Definition: TrigObjTnPHistColl.cc:133
TrigObjTnPHistColl::PathSelector::expandSelectionStr
static std::string expandSelectionStr(const std::string &selStr, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
Definition: TrigObjTnPHistColl.cc:184
TrigObjTnPHistColl::getKeys
static const trigger::Keys getKeys(const trigger::TriggerEvent &trigEvt, const std::string &filterName)
Definition: TrigObjTnPHistColl.cc:68
TrigObjTnPHistColl::HistDefs::Data::nameSuffex_
std::string nameSuffex_
Definition: TrigObjTnPHistColl.h:185
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
TrigObjTnPHistColl::probeHists_
std::vector< ProbeData > probeHists_
Definition: TrigObjTnPHistColl.h:245
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
TrigObjTnPHistColl::FilterSelector::makePSetDescription
static edm::ParameterSetDescription makePSetDescription()
Definition: TrigObjTnPHistColl.cc:84
TrigObjTnPHistColl::PathSelector::expandPath
static std::string expandPath(const std::string &pathPattern, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
Definition: TrigObjTnPHistColl.cc:203
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
trigNames
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
TrigObjTnPHistColl::HistFiller::var_
TrigObjVarF var_
Definition: TrigObjTnPHistColl.h:166
TrigObjTnPHistColl::FilterSelector
Definition: TrigObjTnPHistColl.h:91
TriggerEvent.h
TrigObjTnPHistColl::HistDefs::Data::titleSuffex_
std::string titleSuffex_
Definition: TrigObjTnPHistColl.h:186
TrigObjTnPHistColl::FilterSelector::isAND_
bool isAND_
Definition: TrigObjTnPHistColl.h:115
TrigObjTnPHistColl::ProbeData::probeFilter_
std::string probeFilter_
Definition: TrigObjTnPHistColl.h:223
TrigObjTnPHistColl::HistFiller::operator()
void operator()(const trigger::TriggerObject &probe, float mass, dqm::reco::MonitorElement *hist) const
Definition: TrigObjTnPHistColl.cc:300
TrigObjTnPHistColl::HistFiller::localCuts_
VarRangeCutColl< trigger::TriggerObject > localCuts_
Definition: TrigObjTnPHistColl.h:165
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TrigObjTnPHistColl::HistDefs::Data::histFiller_
HistFiller histFiller_
Definition: TrigObjTnPHistColl.h:183
TrigObjTnPHistColl::TrigObjVarF::TrigObjVarF
TrigObjVarF(std::string varName)
Definition: TrigObjTnPHistColl.cc:266
TrigObjTnPHistColl::HistColl
Definition: TrigObjTnPHistColl.h:201
DQMStore.h
TrigObjTnPHistColl::HistDefs::massBins_
std::vector< float > massBins_
Definition: TrigObjTnPHistColl.h:198
TrigObjTnPHistColl::HistDefs::Data::makePSetDescription
static edm::ParameterSetDescription makePSetDescription()
Definition: TrigObjTnPHistColl.cc:342
TrigObjTnPHistColl::fill
void fill(const trigger::TriggerEvent &trigEvt, const edm::TriggerResults &trigResults, const edm::TriggerNames &trigNames) const
Definition: TrigObjTnPHistColl.cc:49
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
TrigObjTnPHistColl
Definition: TrigObjTnPHistColl.h:86
TrigObjTnPHistColl::FilterSelector::cleanTrigKeys
static void cleanTrigKeys(trigger::Keys &keys)
Definition: TrigObjTnPHistColl.cc:122
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
TrigObjTnPHistColl::HistColl::bookHists
void bookHists(DQMStore::IBooker &iBooker, const std::string &name, const std::string &title, const HistDefs &histDefs)
Definition: TrigObjTnPHistColl.cc:363
TrigObjTnPHistColl::HistDefs::HistDefs
HistDefs(const edm::ParameterSet &config)
Definition: TrigObjTnPHistColl.cc:307
TrigObjTnPHistColl::PathSelector::makePSetDescription
static edm::ParameterSetDescription makePSetDescription()
Definition: TrigObjTnPHistColl.cc:139
VarRangeCutColl< trigger::TriggerObject >
TrigObjTnPHistColl::FilterSelector::FilterSet::filters_
std::vector< std::string > filters_
Definition: TrigObjTnPHistColl.h:100
TrigObjTnPHistColl::TrigObjTnPHistColl
TrigObjTnPHistColl(const edm::ParameterSet &config)
Definition: TrigObjTnPHistColl.cc:11
TrigObjTnPHistColl::tagCuts_
VarRangeCutColl< trigger::TriggerObject > tagCuts_
Definition: TrigObjTnPHistColl.h:240
TrigObjTnPHistColl::ProbeData::fill
void fill(const trigger::size_type tagKey, const trigger::TriggerEvent &trigEvt, const VarRangeCutColl< trigger::TriggerObject > &probeCuts) const
Definition: TrigObjTnPHistColl.cc:382
TrigObjTnPHistColl::HistDefs::Data::Data
Data(const edm::ParameterSet &config)
Definition: TrigObjTnPHistColl.cc:336
trigObjTnPSource_cfi.isAND
isAND
Definition: trigObjTnPSource_cfi.py:61
TrigObjTnPHistColl::FilterSelector::FilterSet::FilterSet
FilterSet(const edm::ParameterSet &config)
Definition: TrigObjTnPHistColl.cc:130
config
Definition: config.py:1
TrigObjTnPHistColl::HistDefs::histData_
std::vector< Data > histData_
Definition: TrigObjTnPHistColl.h:197
TrigObjTnPHistColl::PathSelector::operator()
bool operator()(const edm::TriggerResults &trigResults, const edm::TriggerNames &trigNames) const
Definition: TrigObjTnPHistColl.cc:155
trigObjTnPSource_cfi.histDefs
histDefs
Definition: trigObjTnPSource_cfi.py:73
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
TrigObjTnPHistColl::FilterSelector::mergeTrigKeys
static void mergeTrigKeys(trigger::Keys &keys, const trigger::Keys &keysToMerge, bool isAND)
Definition: TrigObjTnPHistColl.cc:106
dqm::legacy::DQMStore
Definition: DQMStore.h:727
TrigObjTnPHistColl::FilterSelector::FilterSelector
FilterSelector(const edm::ParameterSet &config)
Definition: TrigObjTnPHistColl.cc:77
TrigObjTnPHistColl::MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition: TrigObjTnPHistColl.h:89
compare.hist
hist
Definition: compare.py:376
TrigObjTnPHistColl::PathSelector::verbose_
int verbose_
Definition: TrigObjTnPHistColl.h:142
GenericTriggerEventFlag.h
TrigObjTnPHistColl::probeCuts_
VarRangeCutColl< trigger::TriggerObject > probeCuts_
Definition: TrigObjTnPHistColl.h:240
TrigObjTnPHistColl::PathSelector::selectionStr_
std::string selectionStr_
Definition: TrigObjTnPHistColl.h:139
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
TrigObjTnPHistColl::TrigObjVarF
Definition: TrigObjTnPHistColl.h:146
ParameterSetDescription.h
VarRangeCutColl.h
trigger::TriggerObject
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrigObjTnPHistColl::FilterSelector::getPassingKeys
const trigger::Keys getPassingKeys(const trigger::TriggerEvent &trigEvt) const
Definition: TrigObjTnPHistColl.cc:91
TrigObjTnPHistColl::makePSetDescription
static edm::ParameterSetDescription makePSetDescription()
Definition: TrigObjTnPHistColl.cc:27
TrigObjTnPHistColl::evtTrigSel_
PathSelector evtTrigSel_
Definition: TrigObjTnPHistColl.h:246
TrigObjTnPHistColl::collName_
std::string collName_
Definition: TrigObjTnPHistColl.h:242
edm::ParameterSet
Definition: ParameterSet.h:47
TrigObjTnPHistColl::HistFiller::makePSetDescription
static edm::ParameterSetDescription makePSetDescription()
Definition: TrigObjTnPHistColl.cc:293
TrigObjTnPHistColl::HistFiller
Definition: TrigObjTnPHistColl.h:158
TrigObjTnPHistColl::HistDefs
Definition: TrigObjTnPHistColl.h:170
TrigObjTnPHistColl::FilterSelector::FilterSet::getPassingKeys
const trigger::Keys getPassingKeys(const trigger::TriggerEvent &trigEvt) const
Definition: TrigObjTnPHistColl.cc:249
TrigObjTnPHistColl::HistFiller::HistFiller
HistFiller(const edm::ParameterSet &config)
Definition: TrigObjTnPHistColl.cc:289
TrigObjTnPHistColl::PathSelector::isInited_
bool isInited_
Definition: TrigObjTnPHistColl.h:143
TrigObjTnPHistColl::PathSelector::isANDForExpandedPaths_
bool isANDForExpandedPaths_
Definition: TrigObjTnPHistColl.h:141
TrigObjTnPHistColl::TrigObjVarF::operator()
float operator()(const trigger::TriggerObject &obj) const
Definition: TrigObjTnPHistColl.h:149
TrigObjTnPHistColl::HistDefs::bookHists
std::vector< std::pair< HistFiller, dqm::reco::MonitorElement * > > bookHists(DQMStore::IBooker &iBooker, const std::string &name, const std::string &title) const
Definition: TrigObjTnPHistColl.cc:326
trigger::Keys
std::vector< size_type > Keys
Definition: TriggerTypeDefs.h:19
TrigObjTnPHistColl::FilterSelector::FilterSet::makePSetDescription
static edm::ParameterSetDescription makePSetDescription()
Definition: TrigObjTnPHistColl.cc:242
trigger::TriggerEvent
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
TrigObjTnPHistColl::PathSelector::init
void init(const HLTConfigProvider &hltConfig)
Definition: TrigObjTnPHistColl.cc:147
pdwgDoubleElectron_cfi.filterName
filterName
Definition: pdwgDoubleElectron_cfi.py:7
TrigObjTnPHistColl::TrigObjVarF::isAbs_
bool isAbs_
Definition: TrigObjTnPHistColl.h:155
HLTConfigProvider
Definition: HLTConfigProvider.h:29
TrigObjTnPHistColl::bookHists
void bookHists(DQMStore::IBooker &iBooker)
Definition: TrigObjTnPHistColl.cc:42
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
TrigObjTnPHistColl::HistDefs::Data
Definition: TrigObjTnPHistColl.h:172
TrigObjTnPHistColl::PathSelector::expandedSelStr_
std::string expandedSelStr_
Definition: TrigObjTnPHistColl.h:140
TrigObjTnPHistColl::FilterSelector::FilterSet::isAND_
bool isAND_
Definition: TrigObjTnPHistColl.h:101
TrigObjTnPHistColl::histDefs_
HistDefs histDefs_
Definition: TrigObjTnPHistColl.h:244
TrigObjTnPHistColl::init
void init(const HLTConfigProvider &hltConfig)
Definition: TrigObjTnPHistColl.h:230
TrigObjTnPHistColl::ProbeData
Definition: TrigObjTnPHistColl.h:214
edm::TriggerNames
Definition: TriggerNames.h:55
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
TrigObjTnPHistColl::DQMStore
dqm::legacy::DQMStore DQMStore
Definition: TrigObjTnPHistColl.h:88
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
TrigObjTnPHistColl::HistDefs::Data::bins_
std::vector< float > bins_
Definition: TrigObjTnPHistColl.h:184
HltComparatorCreateWorkflow.hltConfig
hltConfig
Definition: HltComparatorCreateWorkflow.py:161
TrigObjTnPHistColl::ProbeData::ProbeData
ProbeData(std::string probeFilter)
Definition: TrigObjTnPHistColl.h:216
dqm::implementation::IBooker
Definition: DQMStore.h:43
TrigObjTnPHistColl::ProbeData::bookHists
void bookHists(const std::string &tagName, DQMStore::IBooker &iBooker, const HistDefs &histDefs)
Definition: TrigObjTnPHistColl.cc:376
TrigObjTnPHistColl::HistColl::HistColl
HistColl()
Definition: TrigObjTnPHistColl.h:203
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
TrigObjTnPHistColl::HistDefs::Data::book
dqm::reco::MonitorElement * book(DQMStore::IBooker &iBooker, const std::string &name, const std::string &title, const std::vector< float > &massBins) const
Definition: TrigObjTnPHistColl.cc:351
TrigObjTnPHistColl::HistDefs::Data::filler
const HistFiller & filler() const
Definition: TrigObjTnPHistColl.h:180
trigObjTnPSource_cfi.massBins
massBins
Definition: trigObjTnPSource_cfi.py:74
TrigObjTnPHistColl::HistColl::hists_
std::vector< std::pair< HistFiller, dqm::reco::MonitorElement * > > hists_
Definition: TrigObjTnPHistColl.h:211
TrigObjTnPHistColl::FilterSelector::FilterSet
Definition: TrigObjTnPHistColl.h:93
TrigObjTnPHistColl::FilterSelector::filterSets_
std::vector< FilterSet > filterSets_
Definition: TrigObjTnPHistColl.h:114
TrigObjTnPHistColl::HistColl::fill
void fill(const trigger::TriggerObject &probe, float mass) const
Definition: TrigObjTnPHistColl.cc:370
JetPartonCorrections_cff.tagName
tagName
Definition: JetPartonCorrections_cff.py:12
TrigObjTnPHistColl::folderName_
std::string folderName_
Definition: TrigObjTnPHistColl.h:243
edm::TriggerResults
Definition: TriggerResults.h:35
trigObjTnPSource_cfi.probeCuts
probeCuts
Definition: trigObjTnPSource_cfi.py:54
TrigObjTnPHistColl::HistDefs::makePSetDescription
static edm::ParameterSetDescription makePSetDescription()
Definition: TrigObjTnPHistColl.cc:315
TrigObjTnPHistColl::ProbeData::hists_
HistColl hists_
Definition: TrigObjTnPHistColl.h:224
TrigObjTnPHistColl::PathSelector
Definition: TrigObjTnPHistColl.h:122
TrigObjTnPHistColl::tagFilters_
FilterSelector tagFilters_
Definition: TrigObjTnPHistColl.h:241
TrigObjTnPHistColl::TrigObjVarF::varFunc_
float(trigger::TriggerObject::* varFunc_)() const
Definition: TrigObjTnPHistColl.h:154