CMS 3D CMS Logo

EgHLTMonElemFuncs.h
Go to the documentation of this file.
1 #ifndef DQMOFFLINE_TRIGGER_EGHLTMONELEMFUNCS
2 #define DQMOFFLINE_TRIGGER_EGHLTMONELEMFUNCS
3 
4 //Author: Sam Harper
5 
6 //Description: A collection of functions which assist and automate the creation
7 // of useful monitor elements for Eg DQM
8 //
9 
21 
22 #include <boost/algorithm/string.hpp>
23 
24 namespace egHLT {
27 
28  struct CutMasks;
29 
30  class MonElemFuncs {
31  private:
34 
35  public:
37  ~MonElemFuncs() = default;
38  ;
40 
41  public:
43  const std::string& filterName,
44  const std::string& baseName,
45  const BinData& bins);
47  const std::string& filterName,
48  const std::string& baseName,
49  const BinData& bins);
51  const std::string& filterName,
52  const std::string& baseName,
53  int nrBins,
54  double xMin,
55  double xMax,
56  float (OffEle::*vsVarFunc)() const,
57  const CutMasks& masks);
59  const std::string& filterName,
60  const std::string& baseName,
61  const BinData::Data1D& bins,
62  float (OffEle::*vsVarFunc)() const,
63  const CutMasks& masks);
65  const std::string& filterName,
66  const std::string& baseName,
67  int nrBins,
68  double xMin,
69  double xMax,
70  float (OffPho::*vsVarFunc)() const,
71  const CutMasks& masks);
73  const std::string& filterName,
74  const std::string& baseName,
75  const BinData::Data1D& bins,
76  float (OffPho::*vsVarFunc)() const,
77  const CutMasks& masks);
78 
79  //for hep region plots
81  const std::string& filterName,
82  const std::string& baseName,
83  const BinData& bins);
85  const std::string& filterName,
86  const std::string& baseName,
87  const BinData& bins);
88  //we own the passed in pointer
90  const std::string& filterName,
91  const std::string& baseName,
92  const BinData& bins,
93  EgHLTDQMCut<OffEle>* cut = nullptr);
95  const std::string& filterName,
96  const std::string& baseName,
97  const BinData& bins,
98  EgHLTDQMCut<OffPho>* cut = nullptr);
99 
101  const std::vector<std::string>& tightLooseTrigs,
102  const BinData& bins,
103  EgHLTDQMCut<OffEle>* eleCut);
105  const std::vector<std::string>& tightLooseTrigs,
106  const BinData& bins,
107  EgHLTDQMCut<OffPho>* phoCut);
108 
110  const std::vector<std::string>& tightLooseTrigs,
111  const BinData& bins);
113  const std::vector<std::string>& tightLooseTrigs,
114  const BinData& bins);
115 
117  const std::string& tightTrig,
118  const std::string& looseTrig,
119  EgHLTDQMCut<OffEle>* eleCut,
120  const std::string& histId,
121  const BinData& bins);
122 
124  const std::string& tightTrig,
125  const std::string& looseTrig,
126  EgHLTDQMCut<OffPho>* phoCut,
127  const std::string& histId,
128  const BinData& bins);
129 
131  const std::vector<std::string>& tightLooseTrigs,
132  const BinData& bins);
134  const std::vector<std::string>& tightLooseTrigs,
135  const BinData& bins);
136 
137  //ele only (Now for pho also!)
139  const std::vector<std::string>& filterNames,
140  int cutMask,
141  const BinData& bins);
143  const std::vector<std::string>& filterNames,
144  int cutMask,
145  const BinData& bins);
147  const std::string& filterName,
148  int cutMask,
149  const BinData& bins);
151  const std::string& filterName,
152  int cutMask,
153  const BinData& bins);
155  const std::string& filterName,
156  int cutMask,
157  const BinData& bins);
158 
159  template <class T, typename varType>
161  const std::string& name,
162  const std::string& title,
163  const BinData::Data1D& binData,
164  varType (T::*varFunc)() const) {
165  histVec.push_back(
166  new MonElemMgrEBEE<T, varType>(iBooker, name, title, binData.nr, binData.min, binData.max, varFunc));
167  }
168 
169  template <class T, typename varType>
171  const std::string& name,
172  const std::string& title,
173  const BinData::Data1D& binData,
174  varType (T::*varFunc)() const) {
175  histVec.push_back(
176  new MonElemMgrHEP<T, varType>(iBooker, name, title, binData.nr, binData.min, binData.max, varFunc));
177  }
178  //this function is special in that it figures out the Et cut from the trigger name
179  //it then passes the cut as normal into the other addTightLooseTrigHist functions
180  //it also makes an uncut et distribution
181  template <class T>
183  const std::string& tightTrig,
184  const std::string& looseTrig,
185  const std::string& histId,
186  const BinData& bins) {
187  float etCutValue = trigTools::getEtThresFromName(tightTrig);
188 
189  EgHLTDQMCut<T>* etCut = new EgGreaterCut<T, float>(etCutValue, &T::etSC); //note the cut in trigger is on SC Et
190  addTightLooseTrigHist(monElems, tightTrig, looseTrig, etCut, histId, bins);
191 
192  //now make the new mon elems without the et cut (have to be placed in containers even though each container just has one monelem)
193  MonElemContainer<T>* passEtMonElem;
194  passEtMonElem = new MonElemContainer<T>(
195  tightTrig + "_" + looseTrig + "_" + histId + "_passTrig",
196  "",
197  new EgObjTrigCut<T>(trigCodes.getCode(tightTrig + ":" + looseTrig), EgObjTrigCut<T>::AND));
198  addStdHist<T, float>(passEtMonElem->monElems(),
199  passEtMonElem->name() + "_etUnCut",
200  passEtMonElem->name() + " E_{T} (Uncut);E_{T} (GeV)",
201  bins.et,
202  &T::et);
203 
204  MonElemContainer<T>* failEtMonElem;
205  failEtMonElem = new MonElemContainer<T>(
206  tightTrig + "_" + looseTrig + "_" + histId + "_failTrig",
207  "",
209  addStdHist<T, float>(failEtMonElem->monElems(),
210  failEtMonElem->name() + "_etUnCut",
211  failEtMonElem->name() + " E_{T} (Uncut);E_{T} (GeV)",
212  bins.et,
213  &T::et);
214 
215  monElems.push_back(passEtMonElem);
216  monElems.push_back(failEtMonElem);
217  }
218 
219  //this function will ultimately produce a set of distributions with the Et cut of the trigger applied + make an additional un cut et monitor element for turn on purposes
220  template <class T>
222  const std::vector<std::string>& tightLooseTrigs,
223  const BinData& bins,
224  const std::string& objName) {
225  for (size_t trigNr = 0; trigNr < tightLooseTrigs.size(); trigNr++) {
226  //dbe_->SetCurrentFolder(dirName_+"/"+tightLooseTrigs[trigNr]);
227  std::vector<std::string> splitString;
228  boost::split(splitString, tightLooseTrigs[trigNr], boost::is_any_of(std::string(":")));
229  if (splitString.size() != 2)
230  continue; //format incorrect
231  const std::string& tightTrig = splitString[0];
232  const std::string& looseTrig = splitString[1];
233  //this step is necessary as we want to transfer ownership of eleCut to the addTrigLooseTrigHist func on the last iteration
234  //but clone it before that
235  //perhaps my object ownership rules need to be re-evalulated
236  if (trigNr != tightLooseTrigs.size() - 2)
237  addTightLooseTrigHist(monElems, tightTrig, looseTrig, objName, bins);
238  else
239  addTightLooseTrigHist(monElems, tightTrig, looseTrig, objName, bins);
240  }
241  //dbe_->SetCurrentFolder(dirName_);
242  }
243 
244  }; // end of class
245 } // namespace egHLT
246 #endif
void initStdEleCutHists(std::vector< MonElemWithCutBase< OffEle > *> &histVec, const std::string &filterName, const std::string &baseName, const BinData &bins, EgHLTDQMCut< OffEle > *cut=nullptr)
void initStdEffHists(std::vector< MonElemWithCutBase< OffEle > *> &histVec, const std::string &filterName, const std::string &baseName, int nrBins, double xMin, double xMax, float(OffEle::*vsVarFunc)() const, const CutMasks &masks)
void initTrigTagProbeHists(std::vector< MonElemContainer< OffEle > *> &eleMonElems, const std::vector< std::string > &filterNames, int cutMask, const BinData &bins)
const TrigCodes & trigCodes
void addTightLooseTrigHist(std::vector< MonElemContainer< OffEle > *> &eleMonElems, const std::string &tightTrig, const std::string &looseTrig, EgHLTDQMCut< OffEle > *eleCut, const std::string &histId, const BinData &bins)
void initTightLooseDiObjTrigHistsTrigCuts(std::vector< MonElemContainer< OffEle > *> &eleMonElems, const std::vector< std::string > &tightLooseTrigs, const BinData &bins)
void initStdEleHists(std::vector< MonElemManagerBase< OffEle > *> &histVec, const std::string &filterName, const std::string &baseName, const BinData &bins)
void addStdHistHEP(std::vector< MonElemManagerBase< T > *> &histVec, const std::string &name, const std::string &title, const BinData::Data1D &binData, varType(T::*varFunc)() const)
MonElemFuncs(DQMStore::IBooker &i, const TrigCodes &c)
std::vector< std::string > splitString(const std::string &fLine)
void initTightLooseTrigHists(std::vector< MonElemContainer< OffEle > *> &eleMonElems, const std::vector< std::string > &tightLooseTrigs, const BinData &bins, EgHLTDQMCut< OffEle > *eleCut)
dqm::reco::DQMStore DQMStore
~MonElemFuncs()=default
void addTightLooseTrigHist(std::vector< MonElemContainer< T > *> &monElems, const std::string &tightTrig, const std::string &looseTrig, const std::string &histId, const BinData &bins)
float getEtThresFromName(const std::string &trigName)
void addStdHist(std::vector< MonElemManagerBase< T > *> &histVec, const std::string &name, const std::string &title, const BinData::Data1D &binData, varType(T::*varFunc)() const)
void initTrigTagProbeHist(std::vector< MonElemContainer< OffEle > *> &eleMonElems, const std::string &filterName, int cutMask, const BinData &bins)
dqm::legacy::MonitorElement MonitorElement
DQMStore::IBooker & iBooker
const std::string & name() const
void initTightLooseTrigHistsTrigCuts(std::vector< MonElemContainer< OffEle > *> &eleMonElems, const std::vector< std::string > &tightLooseTrigs, const BinData &bins)
TrigBitSet getCode(const char *descript) const
void initStdEleHistsHEP(std::vector< MonElemManagerBase< OffEle > *> &histVec, const std::string &filterName, const std::string &baseName, const BinData &bins)
void initStdPhoCutHists(std::vector< MonElemWithCutBase< OffPho > *> &histVec, const std::string &filterName, const std::string &baseName, const BinData &bins, EgHLTDQMCut< OffPho > *cut=nullptr)
std::vector< MonElemManagerBase< T > * > & monElems()
DQMStore::IBooker & getIB()
void initTightLooseTrigHists(std::vector< MonElemContainer< T > *> &monElems, const std::vector< std::string > &tightLooseTrigs, const BinData &bins, const std::string &objName)
long double T
void initTrigTagProbeHist_2Leg(std::vector< MonElemContainer< OffEle > *> &eleMonElems, const std::string &filterName, int cutMask, const BinData &bins)
void initStdPhoHists(std::vector< MonElemManagerBase< OffPho > *> &histVec, const std::string &filterName, const std::string &baseName, const BinData &bins)
void initStdPhoHistsHEP(std::vector< MonElemManagerBase< OffPho > *> &histVec, const std::string &filterName, const std::string &baseName, const BinData &bins)