CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/DQMOffline/Trigger/interface/EgHLTMonElemWithCut.h

Go to the documentation of this file.
00001 #ifndef DQMOFFLINE_TRIGGER_EGHLTMONELEMWITHCUT
00002 #define DQMOFFLINE_TRIGGER_EGHLTMONELEMWITHCUT
00003 
00004 
00005 //class: MonElemWithCut, short for MonitorElementWithCut (note not MonEleWith Cut as Ele might be confused for electron
00006 //
00007 //author: Sam Harper (Aug 2008)
00008 //
00009 //WARNING: interface is NOT final, please dont use this class for now without clearing it with me
00010 //         as I will change it and possibly break all your code
00011 //
00012 //aim:  to improve the fire and forget nature of MonElemManger
00013 //      allows some arbitary selection to be placed on objects used to fill the monitoring element
00014 //      examples include it having to be associated with a specific trigger filter
00015 
00016 //implimentation: uses a MonElemManager to handle the Monitor Element and EgHLTDQMCut descide whether to fill it or not
00017 //                it was debated adding this capacity directly to MonElemManager 
00018 //                this may happen in a future itteration of the code when things have stabilised
00019 
00020 
00021 
00022 #include "DQMOffline/Trigger/interface/EgHLTMonElemManager.h"
00023 #include "DQMOffline/Trigger/interface/EgHLTDQMCut.h"
00024 #include "DQMOffline/Trigger/interface/EgHLTOffEvt.h"
00025 namespace egHLT {
00026   template<class T> class MonElemWithCutBase {
00027     
00028   private:
00029     MonElemWithCutBase(const MonElemWithCutBase& rhs){}
00030     MonElemWithCutBase& operator=(const MonElemWithCutBase& rhs){return *this;}
00031   public:
00032     MonElemWithCutBase(){}
00033     virtual ~MonElemWithCutBase(){}
00034     
00035     virtual void fill(const T& obj,const OffEvt& evt ,float weight)=0;
00036     
00037   };
00038   
00039   
00040   template<class T,typename varTypeX,typename varTypeY=varTypeX> class MonElemWithCut : public MonElemWithCutBase<T> {
00041     
00042   private:
00043     MonElemManagerBase<T>* monElemMgr_; //we own this
00044     const EgHLTDQMCut<T>* cut_; //we also own this
00045     
00046   private:
00047     MonElemWithCut(const MonElemWithCut& rhs){}
00048     MonElemWithCut& operator=(const MonElemWithCut& rhs){return *this;}
00049   public:
00050     
00051     MonElemWithCut(const std::string& name,const std::string& title,int nrBins,double xMin,double xMax,
00052                    varTypeX (T::*varFunc)()const,const EgHLTDQMCut<T>* cut=NULL):
00053       monElemMgr_(new MonElemManager<T,varTypeX>(name,title,nrBins,xMin,xMax,varFunc)),
00054       cut_(cut){}
00055     
00056     MonElemWithCut(const std::string& name,const std::string& title,int nrBinsX,double xMin,double xMax,int nrBinsY,double yMin,double yMax,
00057                    varTypeX (T::*varFuncX)()const,varTypeY (T::*varFuncY)()const,const EgHLTDQMCut<T>* cut=NULL):
00058       monElemMgr_(new MonElemManager2D<T,varTypeX,varTypeY>(name,title,nrBinsX,xMin,xMax,nrBinsY,yMin,yMax,varFuncX,varFuncY)),
00059       cut_(cut){}
00060     ~MonElemWithCut();
00061     
00062     void fill(const T& obj,const OffEvt& evt,float weight);
00063     
00064   };
00065   
00066   template<class T,typename varTypeX,typename varTypeY> 
00067   MonElemWithCut<T,varTypeX,varTypeY>::~MonElemWithCut()
00068   {
00069     if(cut_) delete cut_;
00070     if(monElemMgr_) delete monElemMgr_;
00071   }
00072   
00073   template<class T,typename varTypeX,typename varTypeY> 
00074   void MonElemWithCut<T,varTypeX,varTypeY>::fill(const T& obj,const OffEvt& evt,float weight)
00075   {
00076     if(cut_==NULL || cut_->pass(obj,evt)) monElemMgr_->fill(obj,weight);
00077   }
00078   
00079 }
00080 
00081 #endif