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 
5 //Author: Sam Harper
6 
7 //Description: A collection of functions which assist and automate the creation
8 // of useful monitor elements for Eg DQM
9 //
10 
22 
23 #include <boost/algorithm/string.hpp>
24 
25 namespace egHLT {
26 
27  struct CutMasks;
28 
29  class MonElemFuncs {
30  private:
33 
34  public:
35  MonElemFuncs(DQMStore::IBooker& i, const TrigCodes& c): iBooker(i), trigCodes(c) {};
36  ~MonElemFuncs() = default;;
38 
39  public:
40 
41  void initStdEleHists(std::vector<MonElemManagerBase<OffEle>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData& bins);
42  void initStdPhoHists(std::vector<MonElemManagerBase<OffPho>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData& bins);
43  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);
44  void initStdEffHists(std::vector<MonElemWithCutBase<OffEle>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData::Data1D& bins,float (OffEle::*vsVarFunc)()const,const CutMasks& masks);
45  void initStdEffHists(std::vector<MonElemWithCutBase<OffPho>*>& histVec,const std::string& filterName,const std::string& baseName,int nrBins,double xMin,double xMax,float (OffPho::*vsVarFunc)()const,const CutMasks& masks);
46  void initStdEffHists(std::vector<MonElemWithCutBase<OffPho>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData::Data1D& bins,float (OffPho::*vsVarFunc)()const,const CutMasks& masks);
47 
48  //for hep region plots
49  void initStdEleHistsHEP(std::vector<MonElemManagerBase<OffEle>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData& bins);
50  void initStdPhoHistsHEP(std::vector<MonElemManagerBase<OffPho>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData& bins);
51  //we own the passed in pointer
52  void initStdEleCutHists(std::vector<MonElemWithCutBase<OffEle>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData& bins,EgHLTDQMCut<OffEle>* cut=nullptr);
53  void initStdPhoCutHists(std::vector<MonElemWithCutBase<OffPho>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData& bins,EgHLTDQMCut<OffPho>* cut=nullptr);
54 
55 
56 
57 
58  void initTightLooseTrigHists( std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins,EgHLTDQMCut<OffEle>* eleCut);
59  void initTightLooseTrigHists( std::vector<MonElemContainer<OffPho>*>& phoMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins,EgHLTDQMCut<OffPho>* phoCut);
60 
61  void initTightLooseTrigHistsTrigCuts( std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins);
62  void initTightLooseTrigHistsTrigCuts( std::vector<MonElemContainer<OffPho>*>& phoMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins);
63 
64  void addTightLooseTrigHist( std::vector<MonElemContainer<OffEle>*>& eleMonElems,
65  const std::string& tightTrig,const std::string& looseTrig,
66  EgHLTDQMCut<OffEle>* eleCut,const std::string& histId,const BinData& bins);
67 
68 
69  void addTightLooseTrigHist( std::vector<MonElemContainer<OffPho>*>& phoMonElems,
70  const std::string& tightTrig,const std::string& looseTrig,
71  EgHLTDQMCut<OffPho>* phoCut,const std::string& histId,const BinData& bins);
72 
73 
74 
75  void initTightLooseDiObjTrigHistsTrigCuts( std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins);
76  void initTightLooseDiObjTrigHistsTrigCuts( std::vector<MonElemContainer<OffPho>*>& phoMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins);
77 
78  //ele only (Now for pho also!)
79  void initTrigTagProbeHists(std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::vector<std::string>& filterNames,int cutMask,const BinData& bins);
80  void initTrigTagProbeHists(std::vector<MonElemContainer<OffPho>*>& phoMonElems,const std::vector<std::string>& filterNames,int cutMask,const BinData& bins);
81  void initTrigTagProbeHist(std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::string& filterName,int cutMask,const BinData& bins);
82  void initTrigTagProbeHist(std::vector<MonElemContainer<OffPho>*>& phoMonElems,const std::string& filterName,int cutMask,const BinData& bins);
83  void initTrigTagProbeHist_2Leg(std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::string& filterName,int cutMask,const BinData& bins);
84 
85 
86  template<class T,typename varType> void addStdHist( std::vector<MonElemManagerBase<T>*>& histVec,const std::string& name,const std::string& title,
87  const BinData::Data1D& binData,varType (T::*varFunc)()const){
88  histVec.push_back(new MonElemMgrEBEE<T,varType>(iBooker, name,title,binData.nr,binData.min,binData.max,varFunc));
89  }
90 
91  template<class T,typename varType> void addStdHistHEP( std::vector<MonElemManagerBase<T>*>& histVec,const std::string& name,const std::string& title,
92  const BinData::Data1D& binData,varType (T::*varFunc)()const){
93  histVec.push_back(new MonElemMgrHEP<T,varType>(iBooker, name,title,binData.nr,binData.min,binData.max,varFunc));
94  }
95  //this function is special in that it figures out the Et cut from the trigger name
96  //it then passes the cut as normal into the other addTightLooseTrigHist functions
97  //it also makes an uncut et distribution
98  template<class T> void addTightLooseTrigHist( std::vector<MonElemContainer<T>*>& monElems,
99  const std::string& tightTrig,const std::string& looseTrig,
100  const std::string& histId,const BinData& bins)
101  {
102 
103  float etCutValue = trigTools::getEtThresFromName(tightTrig);
104 
105  EgHLTDQMCut<T>* etCut = new EgGreaterCut<T,float>(etCutValue,&T::etSC); //note the cut in trigger is on SC Et
106  addTightLooseTrigHist(monElems,tightTrig,looseTrig,etCut,histId,bins);
107 
108  //now make the new mon elems without the et cut (have to be placed in containers even though each container just has one monelem)
109  MonElemContainer<T>* passEtMonElem;
110  passEtMonElem = new MonElemContainer<T>(tightTrig+"_"+looseTrig+"_"+histId+"_passTrig","",
111  new EgObjTrigCut<T>(trigCodes.getCode(tightTrig+":"+looseTrig),EgObjTrigCut<T>::AND));
112  addStdHist<T,float>(passEtMonElem->monElems(),passEtMonElem->name()+"_etUnCut",passEtMonElem->name()+" E_{T} (Uncut);E_{T} (GeV)",bins.et,&T::et);
113 
114  MonElemContainer<T>* failEtMonElem;
115  failEtMonElem = new MonElemContainer<T>(tightTrig+"_"+looseTrig+"_"+histId+"_failTrig","",
116  new EgObjTrigCut<T>(trigCodes.getCode(looseTrig),EgObjTrigCut<T>::AND,trigCodes.getCode(tightTrig)));
117  addStdHist<T,float>(failEtMonElem->monElems(),failEtMonElem->name()+"_etUnCut",failEtMonElem->name()+" E_{T} (Uncut);E_{T} (GeV)",bins.et,&T::et);
118 
119  monElems.push_back(passEtMonElem);
120  monElems.push_back(failEtMonElem);
121  }
122 
123 
124  //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
125  template<class T> void initTightLooseTrigHists(std::vector<MonElemContainer<T>*>& monElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins,const std::string& objName)
126  {
127  for(size_t trigNr=0;trigNr<tightLooseTrigs.size();trigNr++){
128  //dbe_->SetCurrentFolder(dirName_+"/"+tightLooseTrigs[trigNr]);
129  std::vector<std::string> splitString;
130  boost::split(splitString,tightLooseTrigs[trigNr],boost::is_any_of(std::string(":")));
131  if(splitString.size()!=2) continue; //format incorrect
132  const std::string& tightTrig = splitString[0];
133  const std::string& looseTrig = splitString[1];
134  //this step is necessary as we want to transfer ownership of eleCut to the addTrigLooseTrigHist func on the last iteration
135  //but clone it before that
136  //perhaps my object ownership rules need to be re-evalulated
137  if(trigNr!=tightLooseTrigs.size()-2) addTightLooseTrigHist(monElems,tightTrig,looseTrig,objName,bins);
138  else addTightLooseTrigHist(monElems,tightTrig,looseTrig,objName,bins);
139  }
140  //dbe_->SetCurrentFolder(dirName_);
141  }
142 
143 
144  }; // end of class
145 }
146 #endif
void initTightLooseTrigHistsTrigCuts(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)
const TrigCodes & trigCodes
void initStdPhoHists(std::vector< MonElemManagerBase< OffPho > * > &histVec, const std::string &filterName, const std::string &baseName, const BinData &bins)
TrigBitSet getCode(const char *descript) const
std::vector< std::string > splitString(const std::string &fLine)
void addStdHistHEP(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)
const std::string & name() const
MonElemFuncs(DQMStore::IBooker &i, const TrigCodes &c)
void initTightLooseDiObjTrigHistsTrigCuts(std::vector< MonElemContainer< OffEle > * > &eleMonElems, const std::vector< std::string > &tightLooseTrigs, const BinData &bins)
void addTightLooseTrigHist(std::vector< MonElemContainer< T > * > &monElems, const std::string &tightTrig, const std::string &looseTrig, const std::string &histId, const BinData &bins)
void initTrigTagProbeHists(std::vector< MonElemContainer< OffEle > * > &eleMonElems, const std::vector< std::string > &filterNames, int cutMask, const BinData &bins)
~MonElemFuncs()=default
void addStdHist(std::vector< MonElemManagerBase< T > * > &histVec, const std::string &name, const std::string &title, const BinData::Data1D &binData, varType(T::*varFunc)() const)
float getEtThresFromName(const std::string &trigName)
void initTightLooseTrigHists(std::vector< MonElemContainer< OffEle > * > &eleMonElems, const std::vector< std::string > &tightLooseTrigs, const BinData &bins, EgHLTDQMCut< OffEle > *eleCut)
void initTrigTagProbeHist_2Leg(std::vector< MonElemContainer< OffEle > * > &eleMonElems, const std::string &filterName, int cutMask, const BinData &bins)
void initStdPhoCutHists(std::vector< MonElemWithCutBase< OffPho > * > &histVec, const std::string &filterName, const std::string &baseName, const BinData &bins, EgHLTDQMCut< OffPho > *cut=0)
void initStdEleHistsHEP(std::vector< MonElemManagerBase< OffEle > * > &histVec, const std::string &filterName, const std::string &baseName, const BinData &bins)
DQMStore::IBooker & iBooker
et
define resolution functions of each parameter
void initStdPhoHistsHEP(std::vector< MonElemManagerBase< OffPho > * > &histVec, const std::string &filterName, const std::string &baseName, const BinData &bins)
void initStdEleCutHists(std::vector< MonElemWithCutBase< OffEle > * > &histVec, const std::string &filterName, const std::string &baseName, const BinData &bins, EgHLTDQMCut< OffEle > *cut=0)
std::vector< MonElemManagerBase< T > * > & monElems()
DQMStore::IBooker & getIB()
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)
long double T
void initTightLooseTrigHists(std::vector< MonElemContainer< T > * > &monElems, const std::vector< std::string > &tightLooseTrigs, const BinData &bins, const std::string &objName)
double split
Definition: MVATrainer.cc:139
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)