CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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>
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  private:
41  MonElemContainer& operator=(const MonElemContainer& rhs) { return *this; }
42 
43  public:
44  MonElemContainer(std::string baseName = "", std::string baseTitle = "", EgHLTDQMCut<T>* cut = nullptr)
45  : baseName_(std::move(baseName)), baseTitle_(std::move(baseTitle)), cut_(cut) {}
46 
47  ~MonElemContainer() override;
48 
49  //yes this is little more than a struct with some unnecessary function wrapers
50  std::vector<MonElemWithCutBase<T>*>& cutMonElems() { return cutMonElems_; }
51  const std::vector<MonElemWithCutBase<T>*>& cutMonElems() const { return cutMonElems_; }
52  std::vector<MonElemManagerBase<T>*>& monElems() { return monElems_; }
53  const std::vector<MonElemManagerBase<T>*>& monElems() const { return monElems_; }
54 
55  const std::string& name() const { return baseName_; }
56  const std::string& title() const { return baseTitle_; }
57 
58  void fill(const T& obj, const OffEvt& evt, float weight) override;
59  };
60 
61  template <class T>
63  for (size_t i = 0; i < monElems_.size(); i++)
64  delete monElems_[i];
65  for (size_t i = 0; i < cutMonElems_.size(); i++)
66  delete cutMonElems_[i];
67  if (cut_ != nullptr)
68  delete cut_;
69  }
70 
71  template <class T>
72  void MonElemContainer<T>::fill(const T& obj, const OffEvt& evt, float weight) {
73  if (cut_ == nullptr || cut_->pass(obj, evt)) {
74  for (size_t i = 0; i < monElems_.size(); i++)
75  monElems_[i]->fill(obj, weight);
76  for (size_t i = 0; i < cutMonElems_.size(); i++)
77  cutMonElems_[i]->fill(obj, evt, weight);
78  }
79  }
80 } // namespace egHLT
81 #endif
MonElemContainer(const MonElemContainer &rhs)
const std::string & name() const
void fill(const T &obj, const OffEvt &evt, float weight) override
std::vector< MonElemManagerBase< T > * > monElems_
def move
Definition: eostools.py:511
const std::string & title() const
const std::vector< MonElemWithCutBase< T > * > & cutMonElems() const
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
std::vector< MonElemManagerBase< T > * > & monElems()
MonElemContainer(std::string baseName="", std::string baseTitle="", EgHLTDQMCut< T > *cut=nullptr)
int weight
Definition: histoStyle.py:51
std::vector< MonElemWithCutBase< T > * > cutMonElems_
long double T
const std::vector< MonElemManagerBase< T > * > & monElems() const
std::vector< MonElemWithCutBase< T > * > & cutMonElems()
MonElemContainer & operator=(const MonElemContainer &rhs)