CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQMOffline/Trigger/interface/EgHLTMonElemFuncs.h

Go to the documentation of this file.
00001 #ifndef DQMOFFLINE_TRIGGER_EGHLTMONELEMFUNCS
00002 #define DQMOFFLINE_TRIGGER_EGHLTMONELEMFUNCS
00003 
00004 
00005 //Author: Sam Harper
00006 
00007 //Description: A collection of functions which assist and automate the creation
00008 //             of useful monitor elements for Eg DQM
00009 //
00010 
00011 #include "DQMOffline/Trigger/interface/EgHLTMonElemManager.h"
00012 #include "DQMOffline/Trigger/interface/EgHLTOffEle.h"
00013 #include "DQMOffline/Trigger/interface/EgHLTOffPho.h"
00014 #include "DQMOffline/Trigger/interface/EgHLTMonElemWithCut.h"
00015 #include "DQMOffline/Trigger/interface/EgHLTMonElemMgrEBEE.h"
00016 #include "DQMOffline/Trigger/interface/EgHLTDQMCut.h"
00017 #include "DQMOffline/Trigger/interface/EgHLTMonElemContainer.h"
00018 #include "DQMOffline/Trigger/interface/EgHLTBinData.h"
00019 #include "DQMOffline/Trigger/interface/EgHLTTrigTools.h"
00020 #include "DQMOffline/Trigger/interface/EgHLTMonElemWithCutEBEE.h"
00021 
00022 #include <boost/algorithm/string.hpp>
00023 
00024 namespace egHLT {
00025 
00026   class CutMasks;
00027 
00028   namespace MonElemFuncs {
00029     
00030     
00031     void initStdEleHists(std::vector<MonElemManagerBase<OffEle>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData& bins); 
00032     void initStdPhoHists(std::vector<MonElemManagerBase<OffPho>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData& bins); 
00033     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); 
00034     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);
00035     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);   
00036     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);
00037 
00038     //we own the passed in pointer
00039     void initStdEleCutHists(std::vector<MonElemWithCutBase<OffEle>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData& bins,EgHLTDQMCut<OffEle>* cut=NULL);
00040     void initStdPhoCutHists(std::vector<MonElemWithCutBase<OffPho>*>& histVec,const std::string& filterName,const std::string& baseName,const BinData& bins,EgHLTDQMCut<OffPho>* cut=NULL);
00041 
00042 
00043     
00044   
00045     void initTightLooseTrigHists(std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins,EgHLTDQMCut<OffEle>* eleCut);
00046     void initTightLooseTrigHists(std::vector<MonElemContainer<OffPho>*>& phoMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins,EgHLTDQMCut<OffPho>* phoCut);
00047     
00048     void initTightLooseTrigHistsTrigCuts(std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins);  
00049     void initTightLooseTrigHistsTrigCuts(std::vector<MonElemContainer<OffPho>*>& phoMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins);
00050     
00051     void addTightLooseTrigHist(std::vector<MonElemContainer<OffEle>*>& eleMonElems,
00052                                const std::string& tightTrig,const std::string& looseTrig,
00053                                EgHLTDQMCut<OffEle>* eleCut,const std::string& histId,const BinData& bins);
00054 
00055 
00056     void addTightLooseTrigHist(std::vector<MonElemContainer<OffPho>*>& phoMonElems,
00057                                const std::string& tightTrig,const std::string& looseTrig,
00058                                EgHLTDQMCut<OffPho>* phoCut,const std::string& histId,const BinData& bins);
00059     
00060 
00061     
00062     void initTightLooseDiObjTrigHistsTrigCuts(std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins);
00063     void initTightLooseDiObjTrigHistsTrigCuts(std::vector<MonElemContainer<OffPho>*>& phoMonElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins);
00064 
00065     //ele only (Now for pho also!)
00066     void initTrigTagProbeHists(std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::vector<std::string> filterNames,int cutMask,const BinData& bins);
00067     void initTrigTagProbeHists(std::vector<MonElemContainer<OffPho>*>& phoMonElems,const std::vector<std::string> filterNames,int cutMask,const BinData& bins);
00068     void initTrigTagProbeHist(std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::string filterName,int cutMask,const BinData& bins);
00069     void initTrigTagProbeHist(std::vector<MonElemContainer<OffPho>*>& phoMonElems,const std::string filterName,int cutMask,const BinData& bins);
00070     void initTrigTagProbeHist_2Leg(std::vector<MonElemContainer<OffEle>*>& eleMonElems,const std::string filterName,int cutMask,const BinData& bins);
00071   
00072 
00073     template<class T,typename varType> void addStdHist(std::vector<MonElemManagerBase<T>*>& histVec,const std::string& name,const std::string& title,
00074                                                        const BinData::Data1D& binData,varType (T::*varFunc)()const){
00075       histVec.push_back(new MonElemMgrEBEE<T,varType>(name,title,binData.nr,binData.min,binData.max,varFunc));
00076     }
00077 
00078     //this function is special in that it figures out the Et cut from the trigger name
00079     //it then passes the cut as normal into the other addTightLooseTrigHist functions
00080     //it also makes an uncut et distribution
00081     template<class T> void addTightLooseTrigHist(std::vector<MonElemContainer<T>*>& monElems,
00082                                          const std::string& tightTrig,const std::string& looseTrig,
00083                                          const std::string& histId,const BinData& bins)
00084     {
00085   
00086       float etCutValue = trigTools::getEtThresFromName(tightTrig);
00087       
00088       EgHLTDQMCut<T>* etCut = new EgGreaterCut<T,float>(etCutValue,&T::etSC); //note the cut in trigger is on SC Et
00089       addTightLooseTrigHist(monElems,tightTrig,looseTrig,etCut,histId,bins);
00090 
00091       //now make the new mon elems without the et cut (have to be placed in containers even though each container just has one monelem)
00092       MonElemContainer<T>* passEtMonElem;
00093       passEtMonElem = new MonElemContainer<T>(tightTrig+"_"+looseTrig+"_"+histId+"_passTrig","",
00094                                               new EgObjTrigCut<T>(TrigCodes::getCode(tightTrig+":"+looseTrig),EgObjTrigCut<T>::AND));
00095       addStdHist<T,float>(passEtMonElem->monElems(),passEtMonElem->name()+"_etUnCut",passEtMonElem->name()+" E_{T} (Uncut);E_{T} (GeV)",bins.et,&T::et);
00096       
00097       MonElemContainer<T>* failEtMonElem;
00098       failEtMonElem = new MonElemContainer<T>(tightTrig+"_"+looseTrig+"_"+histId+"_failTrig","",
00099                                               new EgObjTrigCut<T>(TrigCodes::getCode(looseTrig),EgObjTrigCut<T>::AND,TrigCodes::getCode(tightTrig)));
00100       addStdHist<T,float>(failEtMonElem->monElems(),failEtMonElem->name()+"_etUnCut",failEtMonElem->name()+" E_{T} (Uncut);E_{T} (GeV)",bins.et,&T::et);
00101 
00102       monElems.push_back(passEtMonElem);
00103       monElems.push_back(failEtMonElem);
00104     }
00105   
00106 
00107     //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
00108     template<class T> void initTightLooseTrigHists(std::vector<MonElemContainer<T>*>& monElems,const std::vector<std::string>& tightLooseTrigs,const BinData& bins,const std::string& objName)
00109       {
00110         for(size_t trigNr=0;trigNr<tightLooseTrigs.size();trigNr++){
00111           //dbe_->SetCurrentFolder(dirName_+"/"+tightLooseTrigs[trigNr]);
00112           std::vector<std::string> splitString;
00113           boost::split(splitString,tightLooseTrigs[trigNr],boost::is_any_of(std::string(":")));
00114           if(splitString.size()!=2) continue; //format incorrect
00115           const std::string& tightTrig = splitString[0];
00116           const std::string& looseTrig = splitString[1];
00117           //this step is necessary as we want to transfer ownership of eleCut to the addTrigLooseTrigHist func on the last iteration
00118           //but clone it before that
00119           //perhaps my object ownership rules need to be re-evalulated
00120           if(trigNr!=tightLooseTrigs.size()-2) addTightLooseTrigHist(monElems,tightTrig,looseTrig,objName,bins);
00121           else addTightLooseTrigHist(monElems,tightTrig,looseTrig,objName,bins);
00122         }
00123         //dbe_->SetCurrentFolder(dirName_);
00124       }
00125     
00126 
00127   }//end namespace
00128 }
00129 #endif