CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DQMOffline/Trigger/interface/EgHLTMonElemContainer.h

Go to the documentation of this file.
00001 #ifndef DQMOFFLINE_TRIGGER_EGHLTMONELEMCONTAINER
00002 #define DQMOFFLINE_TRIGGER_EGHLTMONELEMCONTAINER
00003 
00004 //class: MonElemContainer, short for Monitor Element Container 
00005 
00006 //author: Sam Harper (Aug 2008)
00007 //
00008 //WARNING: interface is NOT final, please dont use this class for now without clearing it with me
00009 //         as I will change it and possibly break all your code
00010 //
00011 //aim:  to improve the fire and forget nature of MonElemManger
00012 //      holds a collection on monitor elements for which there is a global cut
00013 //      for example: they all have to pass a paricular trigger
00014 
00015 //implimentation: a cut to pass and then a list of monitor elements to fill 
00016 //                two seperate vectors of MonitorElements and MonElemsWithCuts
00017 
00018 #include "DQMOffline/Trigger/interface/EgHLTMonElemManager.h"
00019 #include "DQMOffline/Trigger/interface/EgHLTMonElemWithCut.h"
00020 #include "DQMOffline/Trigger/interface/EgHLTDQMCut.h"
00021 #include "DQMOffline/Trigger/interface/EgHLTOffEvt.h"
00022 
00023 #include <string>
00024 #include <vector>
00025 namespace egHLT {
00026   template<class T> class MonElemContainer : public MonElemWithCutBase<T> {
00027     
00028   private:
00029     std::string baseName_;
00030     std::string baseTitle_;
00031     
00032     //so I want the ability to have both normal monitor elements and monitor elements with indivdual cuts
00033     //so untill the two classes are merged, I just have two vectors
00034     std::vector<MonElemWithCutBase<T>*> cutMonElems_; //we own these
00035     std::vector<MonElemManagerBase<T>*> monElems_; //we own these
00036     EgHLTDQMCut<T>* cut_; //we also own this
00037     
00038     
00039     
00040   private:
00041     MonElemContainer(const MonElemContainer& rhs){}
00042     MonElemContainer& operator=(const MonElemContainer& rhs){return *this;}
00043   public:
00044     
00045     MonElemContainer(std::string baseName="",std::string baseTitle="",
00046                      EgHLTDQMCut<T>* cut=NULL):
00047       baseName_(baseName),
00048       baseTitle_(baseTitle),
00049       cut_(cut){}
00050     
00051     ~MonElemContainer();
00052     
00053   //yes this is little more than a struct with some unnecessary function wrapers
00054     std::vector<MonElemWithCutBase<T>*>& cutMonElems(){return cutMonElems_;}
00055     const std::vector<MonElemWithCutBase<T>*>& cutMonElems()const{return cutMonElems_;}
00056     std::vector<MonElemManagerBase<T>*>& monElems(){return monElems_;}
00057     const std::vector<MonElemManagerBase<T>*>& monElems()const{return monElems_;}
00058     
00059     
00060     const std::string& name()const{return baseName_;}
00061     const std::string& title()const{return baseTitle_;}
00062     
00063     void fill(const T& obj,const OffEvt& evt,float weight);
00064     
00065   };
00066   
00067   template<class T> MonElemContainer<T>::~MonElemContainer()
00068   {
00069     for(size_t i=0;i<monElems_.size();i++) delete monElems_[i];
00070     for(size_t i=0;i<cutMonElems_.size();i++) delete cutMonElems_[i];
00071     if(cut_!=NULL) delete cut_;
00072   }
00073   
00074   
00075   template<class T> void MonElemContainer<T>::fill(const T& obj,const OffEvt& evt,float weight)
00076   {
00077     if(cut_==NULL || cut_->pass(obj,evt)){
00078     for(size_t i=0;i<monElems_.size();i++) monElems_[i]->fill(obj,weight);
00079     for(size_t i=0;i<cutMonElems_.size();i++) cutMonElems_[i]->fill(obj,evt,weight);
00080     }
00081   }
00082 }
00083 #endif