CMS 3D CMS Logo

EgHLTMonElemContainer.h
Go to the documentation of this file.
1 #ifndef DQMOFFLINE_TRIGGER_EGHLTMONELEMCONTAINER
2 #define DQMOFFLINE_TRIGGER_EGHLTMONELEMCONTAINER
3 
4 //class: MonElemContainer, short for Monitor Element Container
5 
6 //author: Sam Harper (Aug 2008)
7 //
8 //WARNING: interface is NOT final, please dont use this class for now without clearing it with me
9 // as I will change it and possibly break all your code
10 //
11 //aim: to improve the fire and forget nature of MonElemManger
12 // holds a collection on monitor elements for which there is a global cut
13 // for example: they all have to pass a paricular trigger
14 
15 //implimentation: a cut to pass and then a list of monitor elements to fill
16 // two seperate vectors of MonitorElements and MonElemsWithCuts
17 
22 
23 #include <string>
24 #include <utility>
25 #include <vector>
26 namespace egHLT {
27  template<class T> class MonElemContainer : public MonElemWithCutBase<T> {
28 
29  private:
32 
33  //so I want the ability to have both normal monitor elements and monitor elements with indivdual cuts
34  //so untill the two classes are merged, I just have two vectors
35  std::vector<MonElemWithCutBase<T>*> cutMonElems_; //we own these
36  std::vector<MonElemManagerBase<T>*> monElems_; //we own these
37  EgHLTDQMCut<T>* cut_; //we also own this
38 
39 
40 
41  private:
43  MonElemContainer& operator=(const MonElemContainer& rhs){return *this;}
44  public:
45 
46  MonElemContainer(std::string baseName="",std::string baseTitle="",
47  EgHLTDQMCut<T>* cut=nullptr):
48  baseName_(std::move(baseName)),
49  baseTitle_(std::move(baseTitle)),
50  cut_(cut){}
51 
52  ~MonElemContainer() override;
53 
54  //yes this is little more than a struct with some unnecessary function wrapers
55  std::vector<MonElemWithCutBase<T>*>& cutMonElems(){return cutMonElems_;}
56  const std::vector<MonElemWithCutBase<T>*>& cutMonElems()const{return cutMonElems_;}
57  std::vector<MonElemManagerBase<T>*>& monElems(){return monElems_;}
58  const std::vector<MonElemManagerBase<T>*>& monElems()const{return monElems_;}
59 
60 
61  const std::string& name()const{return baseName_;}
62  const std::string& title()const{return baseTitle_;}
63 
64  void fill(const T& obj,const OffEvt& evt,float weight) override;
65 
66  };
67 
69  {
70  for(size_t i=0;i<monElems_.size();i++) delete monElems_[i];
71  for(size_t i=0;i<cutMonElems_.size();i++) delete cutMonElems_[i];
72  if(cut_!=nullptr) delete cut_;
73  }
74 
75 
76  template<class T> void MonElemContainer<T>::fill(const T& obj,const OffEvt& evt,float weight)
77  {
78  if(cut_==nullptr || cut_->pass(obj,evt)){
79  for(size_t i=0;i<monElems_.size();i++) monElems_[i]->fill(obj,weight);
80  for(size_t i=0;i<cutMonElems_.size();i++) cutMonElems_[i]->fill(obj,evt,weight);
81  }
82  }
83 }
84 #endif
MonElemContainer(std::string baseName="", std::string baseTitle="", EgHLTDQMCut< T > *cut=0)
MonElemContainer(const MonElemContainer &rhs)
const std::string & name() const
Definition: weight.py:1
void fill(const T &obj, const OffEvt &evt, float weight) override
std::vector< MonElemManagerBase< T > * > monElems_
const std::string & title() const
const std::vector< MonElemWithCutBase< T > * > & cutMonElems() const
std::vector< MonElemManagerBase< T > * > & monElems()
std::vector< MonElemWithCutBase< T > * > cutMonElems_
long double T
const std::vector< MonElemManagerBase< T > * > & monElems() const
std::vector< MonElemWithCutBase< T > * > & cutMonElems()
def move(src, dest)
Definition: eostools.py:510
MonElemContainer & operator=(const MonElemContainer &rhs)