Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DQMOFFLINE_TRIGGER_EGHLTMONELEMWITHCUT
0002 #define DQMOFFLINE_TRIGGER_EGHLTMONELEMWITHCUT
0003 
0004 //class: MonElemWithCut, short for MonitorElementWithCut (note not MonEleWith Cut as Ele might be confused for electron
0005 //
0006 //author: Sam Harper (Aug 2008)
0007 //
0008 //WARNING: interface is NOT final, please dont use this class for now without clearing it with me
0009 //         as I will change it and possibly break all your code
0010 //
0011 //aim:  to improve the fire and forget nature of MonElemManger
0012 //      allows some arbitary selection to be placed on objects used to fill the monitoring element
0013 //      examples include it having to be associated with a specific trigger filter
0014 
0015 //implimentation: uses a MonElemManager to handle the Monitor Element and EgHLTDQMCut descide whether to fill it or not
0016 //                it was debated adding this capacity directly to MonElemManager
0017 //                this may happen in a future itteration of the code when things have stabilised
0018 
0019 #include "DQMOffline/Trigger/interface/EgHLTMonElemManager.h"
0020 #include "DQMOffline/Trigger/interface/EgHLTDQMCut.h"
0021 #include "DQMOffline/Trigger/interface/EgHLTOffEvt.h"
0022 namespace egHLT {
0023   template <class T>
0024   class MonElemWithCutBase {
0025   private:
0026     MonElemWithCutBase(const MonElemWithCutBase& rhs) = default;
0027     MonElemWithCutBase& operator=(const MonElemWithCutBase& rhs) { return *this; }
0028 
0029   public:
0030     MonElemWithCutBase() = default;
0031     virtual ~MonElemWithCutBase() = default;
0032 
0033     virtual void fill(const T& obj, const OffEvt& evt, float weight) = 0;
0034   };
0035 
0036   template <class T, typename varTypeX, typename varTypeY = varTypeX>
0037   class MonElemWithCut : public MonElemWithCutBase<T> {
0038   private:
0039     MonElemManagerBase<T>* monElemMgr_;  //we own this
0040     const EgHLTDQMCut<T>* cut_;          //we also own this
0041 
0042   private:
0043     MonElemWithCut(const MonElemWithCut& rhs) {}
0044     MonElemWithCut& operator=(const MonElemWithCut& rhs) { return *this; }
0045 
0046   public:
0047     MonElemWithCut(DQMStore::IBooker& iBooker,
0048                    const std::string& name,
0049                    const std::string& title,
0050                    int nrBins,
0051                    double xMin,
0052                    double xMax,
0053                    varTypeX (T::*varFunc)() const,
0054                    const EgHLTDQMCut<T>* cut = NULL)
0055         : monElemMgr_(new MonElemManager<T, varTypeX>(iBooker, name, title, nrBins, xMin, xMax, varFunc)), cut_(cut) {}
0056 
0057     MonElemWithCut(DQMStore::IBooker& iBooker,
0058                    const std::string& name,
0059                    const std::string& title,
0060                    int nrBinsX,
0061                    double xMin,
0062                    double xMax,
0063                    int nrBinsY,
0064                    double yMin,
0065                    double yMax,
0066                    varTypeX (T::*varFuncX)() const,
0067                    varTypeY (T::*varFuncY)() const,
0068                    const EgHLTDQMCut<T>* cut = NULL)
0069         : monElemMgr_(new MonElemManager2D<T, varTypeX, varTypeY>(
0070               iBooker, name, title, nrBinsX, xMin, xMax, nrBinsY, yMin, yMax, varFuncX, varFuncY)),
0071           cut_(cut) {}
0072     ~MonElemWithCut() override;
0073 
0074     void fill(const T& obj, const OffEvt& evt, float weight) override;
0075   };
0076 
0077   template <class T, typename varTypeX, typename varTypeY>
0078   MonElemWithCut<T, varTypeX, varTypeY>::~MonElemWithCut() {
0079     if (cut_)
0080       delete cut_;
0081     if (monElemMgr_)
0082       delete monElemMgr_;
0083   }
0084 
0085   template <class T, typename varTypeX, typename varTypeY>
0086   void MonElemWithCut<T, varTypeX, varTypeY>::fill(const T& obj, const OffEvt& evt, float weight) {
0087     if (cut_ == nullptr || cut_->pass(obj, evt))
0088       monElemMgr_->fill(obj, weight);
0089   }
0090 
0091 }  // namespace egHLT
0092 
0093 #endif