Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:17

0001 #ifndef DQMOFFLINE_TRIGGER_EGHLTMONELEMFUNCS
0002 #define DQMOFFLINE_TRIGGER_EGHLTMONELEMFUNCS
0003 
0004 //Author: Sam Harper
0005 
0006 //Description: A collection of functions which assist and automate the creation
0007 //             of useful monitor elements for Eg DQM
0008 //
0009 
0010 #include "DQMOffline/Trigger/interface/EgHLTMonElemManager.h"
0011 #include "DQMOffline/Trigger/interface/EgHLTOffEle.h"
0012 #include "DQMOffline/Trigger/interface/EgHLTOffPho.h"
0013 #include "DQMOffline/Trigger/interface/EgHLTMonElemWithCut.h"
0014 #include "DQMOffline/Trigger/interface/EgHLTMonElemMgrEBEE.h"
0015 #include "DQMOffline/Trigger/interface/EgHLTMonElemMgrHEP.h"
0016 #include "DQMOffline/Trigger/interface/EgHLTDQMCut.h"
0017 #include "DQMOffline/Trigger/interface/EgHLTMonElemContainer.h"
0018 #include "DQMOffline/Trigger/interface/EgHLTBinData.h"
0019 #include "DQMOffline/Trigger/interface/EgHLTTrigTools.h"
0020 #include "DQMOffline/Trigger/interface/EgHLTMonElemWithCutEBEE.h"
0021 
0022 #include <boost/algorithm/string.hpp>
0023 
0024 namespace egHLT {
0025   using dqm::legacy::DQMStore;
0026   using dqm::legacy::MonitorElement;
0027 
0028   struct CutMasks;
0029 
0030   class MonElemFuncs {
0031   private:
0032     DQMStore::IBooker& iBooker;
0033     const TrigCodes& trigCodes;
0034 
0035   public:
0036     MonElemFuncs(DQMStore::IBooker& i, const TrigCodes& c) : iBooker(i), trigCodes(c){};
0037     ~MonElemFuncs() = default;
0038     ;
0039     DQMStore::IBooker& getIB() { return iBooker; };
0040 
0041   public:
0042     void initStdEleHists(std::vector<MonElemManagerBase<OffEle>*>& histVec,
0043                          const std::string& filterName,
0044                          const std::string& baseName,
0045                          const BinData& bins);
0046     void initStdPhoHists(std::vector<MonElemManagerBase<OffPho>*>& histVec,
0047                          const std::string& filterName,
0048                          const std::string& baseName,
0049                          const BinData& bins);
0050     void initStdEffHists(std::vector<MonElemWithCutBase<OffEle>*>& histVec,
0051                          const std::string& filterName,
0052                          const std::string& baseName,
0053                          int nrBins,
0054                          double xMin,
0055                          double xMax,
0056                          float (OffEle::*vsVarFunc)() const,
0057                          const CutMasks& masks);
0058     void initStdEffHists(std::vector<MonElemWithCutBase<OffEle>*>& histVec,
0059                          const std::string& filterName,
0060                          const std::string& baseName,
0061                          const BinData::Data1D& bins,
0062                          float (OffEle::*vsVarFunc)() const,
0063                          const CutMasks& masks);
0064     void initStdEffHists(std::vector<MonElemWithCutBase<OffPho>*>& histVec,
0065                          const std::string& filterName,
0066                          const std::string& baseName,
0067                          int nrBins,
0068                          double xMin,
0069                          double xMax,
0070                          float (OffPho::*vsVarFunc)() const,
0071                          const CutMasks& masks);
0072     void initStdEffHists(std::vector<MonElemWithCutBase<OffPho>*>& histVec,
0073                          const std::string& filterName,
0074                          const std::string& baseName,
0075                          const BinData::Data1D& bins,
0076                          float (OffPho::*vsVarFunc)() const,
0077                          const CutMasks& masks);
0078 
0079     //for hep region plots
0080     void initStdEleHistsHEP(std::vector<MonElemManagerBase<OffEle>*>& histVec,
0081                             const std::string& filterName,
0082                             const std::string& baseName,
0083                             const BinData& bins);
0084     void initStdPhoHistsHEP(std::vector<MonElemManagerBase<OffPho>*>& histVec,
0085                             const std::string& filterName,
0086                             const std::string& baseName,
0087                             const BinData& bins);
0088     //we own the passed in pointer
0089     void initStdEleCutHists(std::vector<MonElemWithCutBase<OffEle>*>& histVec,
0090                             const std::string& filterName,
0091                             const std::string& baseName,
0092                             const BinData& bins,
0093                             EgHLTDQMCut<OffEle>* cut = nullptr);
0094     void initStdPhoCutHists(std::vector<MonElemWithCutBase<OffPho>*>& histVec,
0095                             const std::string& filterName,
0096                             const std::string& baseName,
0097                             const BinData& bins,
0098                             EgHLTDQMCut<OffPho>* cut = nullptr);
0099 
0100     void initTightLooseTrigHists(std::vector<MonElemContainer<OffEle>*>& eleMonElems,
0101                                  const std::vector<std::string>& tightLooseTrigs,
0102                                  const BinData& bins,
0103                                  EgHLTDQMCut<OffEle>* eleCut);
0104     void initTightLooseTrigHists(std::vector<MonElemContainer<OffPho>*>& phoMonElems,
0105                                  const std::vector<std::string>& tightLooseTrigs,
0106                                  const BinData& bins,
0107                                  EgHLTDQMCut<OffPho>* phoCut);
0108 
0109     void initTightLooseTrigHistsTrigCuts(std::vector<MonElemContainer<OffEle>*>& eleMonElems,
0110                                          const std::vector<std::string>& tightLooseTrigs,
0111                                          const BinData& bins);
0112     void initTightLooseTrigHistsTrigCuts(std::vector<MonElemContainer<OffPho>*>& phoMonElems,
0113                                          const std::vector<std::string>& tightLooseTrigs,
0114                                          const BinData& bins);
0115 
0116     void addTightLooseTrigHist(std::vector<MonElemContainer<OffEle>*>& eleMonElems,
0117                                const std::string& tightTrig,
0118                                const std::string& looseTrig,
0119                                EgHLTDQMCut<OffEle>* eleCut,
0120                                const std::string& histId,
0121                                const BinData& bins);
0122 
0123     void addTightLooseTrigHist(std::vector<MonElemContainer<OffPho>*>& phoMonElems,
0124                                const std::string& tightTrig,
0125                                const std::string& looseTrig,
0126                                EgHLTDQMCut<OffPho>* phoCut,
0127                                const std::string& histId,
0128                                const BinData& bins);
0129 
0130     void initTightLooseDiObjTrigHistsTrigCuts(std::vector<MonElemContainer<OffEle>*>& eleMonElems,
0131                                               const std::vector<std::string>& tightLooseTrigs,
0132                                               const BinData& bins);
0133     void initTightLooseDiObjTrigHistsTrigCuts(std::vector<MonElemContainer<OffPho>*>& phoMonElems,
0134                                               const std::vector<std::string>& tightLooseTrigs,
0135                                               const BinData& bins);
0136 
0137     //ele only (Now for pho also!)
0138     void initTrigTagProbeHists(std::vector<MonElemContainer<OffEle>*>& eleMonElems,
0139                                const std::vector<std::string>& filterNames,
0140                                int cutMask,
0141                                const BinData& bins);
0142     void initTrigTagProbeHists(std::vector<MonElemContainer<OffPho>*>& phoMonElems,
0143                                const std::vector<std::string>& filterNames,
0144                                int cutMask,
0145                                const BinData& bins);
0146     void initTrigTagProbeHist(std::vector<MonElemContainer<OffEle>*>& eleMonElems,
0147                               const std::string& filterName,
0148                               int cutMask,
0149                               const BinData& bins);
0150     void initTrigTagProbeHist(std::vector<MonElemContainer<OffPho>*>& phoMonElems,
0151                               const std::string& filterName,
0152                               int cutMask,
0153                               const BinData& bins);
0154     void initTrigTagProbeHist_2Leg(std::vector<MonElemContainer<OffEle>*>& eleMonElems,
0155                                    const std::string& filterName,
0156                                    int cutMask,
0157                                    const BinData& bins);
0158 
0159     template <class T, typename varType>
0160     void addStdHist(std::vector<MonElemManagerBase<T>*>& histVec,
0161                     const std::string& name,
0162                     const std::string& title,
0163                     const BinData::Data1D& binData,
0164                     varType (T::*varFunc)() const) {
0165       histVec.push_back(
0166           new MonElemMgrEBEE<T, varType>(iBooker, name, title, binData.nr, binData.min, binData.max, varFunc));
0167     }
0168 
0169     template <class T, typename varType>
0170     void addStdHistHEP(std::vector<MonElemManagerBase<T>*>& histVec,
0171                        const std::string& name,
0172                        const std::string& title,
0173                        const BinData::Data1D& binData,
0174                        varType (T::*varFunc)() const) {
0175       histVec.push_back(
0176           new MonElemMgrHEP<T, varType>(iBooker, name, title, binData.nr, binData.min, binData.max, varFunc));
0177     }
0178     //this function is special in that it figures out the Et cut from the trigger name
0179     //it then passes the cut as normal into the other addTightLooseTrigHist functions
0180     //it also makes an uncut et distribution
0181     template <class T>
0182     void addTightLooseTrigHist(std::vector<MonElemContainer<T>*>& monElems,
0183                                const std::string& tightTrig,
0184                                const std::string& looseTrig,
0185                                const std::string& histId,
0186                                const BinData& bins) {
0187       float etCutValue = trigTools::getEtThresFromName(tightTrig);
0188 
0189       EgHLTDQMCut<T>* etCut = new EgGreaterCut<T, float>(etCutValue, &T::etSC);  //note the cut in trigger is on SC Et
0190       addTightLooseTrigHist(monElems, tightTrig, looseTrig, etCut, histId, bins);
0191 
0192       //now make the new mon elems without the et cut (have to be placed in containers even though each container just has one monelem)
0193       MonElemContainer<T>* passEtMonElem;
0194       passEtMonElem = new MonElemContainer<T>(
0195           tightTrig + "_" + looseTrig + "_" + histId + "_passTrig",
0196           "",
0197           new EgObjTrigCut<T>(trigCodes.getCode(tightTrig + ":" + looseTrig), EgObjTrigCut<T>::AND));
0198       addStdHist<T, float>(passEtMonElem->monElems(),
0199                            passEtMonElem->name() + "_etUnCut",
0200                            passEtMonElem->name() + " E_{T} (Uncut);E_{T} (GeV)",
0201                            bins.et,
0202                            &T::et);
0203 
0204       MonElemContainer<T>* failEtMonElem;
0205       failEtMonElem = new MonElemContainer<T>(
0206           tightTrig + "_" + looseTrig + "_" + histId + "_failTrig",
0207           "",
0208           new EgObjTrigCut<T>(trigCodes.getCode(looseTrig), EgObjTrigCut<T>::AND, trigCodes.getCode(tightTrig)));
0209       addStdHist<T, float>(failEtMonElem->monElems(),
0210                            failEtMonElem->name() + "_etUnCut",
0211                            failEtMonElem->name() + " E_{T} (Uncut);E_{T} (GeV)",
0212                            bins.et,
0213                            &T::et);
0214 
0215       monElems.push_back(passEtMonElem);
0216       monElems.push_back(failEtMonElem);
0217     }
0218 
0219     //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
0220     template <class T>
0221     void initTightLooseTrigHists(std::vector<MonElemContainer<T>*>& monElems,
0222                                  const std::vector<std::string>& tightLooseTrigs,
0223                                  const BinData& bins,
0224                                  const std::string& objName) {
0225       for (size_t trigNr = 0; trigNr < tightLooseTrigs.size(); trigNr++) {
0226         //dbe_->SetCurrentFolder(dirName_+"/"+tightLooseTrigs[trigNr]);
0227         std::vector<std::string> splitString;
0228         boost::split(splitString, tightLooseTrigs[trigNr], boost::is_any_of(std::string(":")));
0229         if (splitString.size() != 2)
0230           continue;  //format incorrect
0231         const std::string& tightTrig = splitString[0];
0232         const std::string& looseTrig = splitString[1];
0233         //this step is necessary as we want to transfer ownership of eleCut to the addTrigLooseTrigHist func on the last iteration
0234         //but clone it before that
0235         //perhaps my object ownership rules need to be re-evalulated
0236         if (trigNr != tightLooseTrigs.size() - 2)
0237           addTightLooseTrigHist(monElems, tightTrig, looseTrig, objName, bins);
0238         else
0239           addTightLooseTrigHist(monElems, tightTrig, looseTrig, objName, bins);
0240       }
0241       //dbe_->SetCurrentFolder(dirName_);
0242     }
0243 
0244   };  // end of class
0245 }  // namespace egHLT
0246 #endif