File indexing completed on 2024-04-06 12:09:49
0001 #ifndef DQMOFFLINE_TRIGGER_EGHLTMONELEMCONTAINER
0002 #define DQMOFFLINE_TRIGGER_EGHLTMONELEMCONTAINER
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include "DQMOffline/Trigger/interface/EgHLTMonElemManager.h"
0019 #include "DQMOffline/Trigger/interface/EgHLTMonElemWithCut.h"
0020 #include "DQMOffline/Trigger/interface/EgHLTDQMCut.h"
0021 #include "DQMOffline/Trigger/interface/EgHLTOffEvt.h"
0022
0023 #include <string>
0024 #include <utility>
0025 #include <vector>
0026 namespace egHLT {
0027 template <class T>
0028 class MonElemContainer : public MonElemWithCutBase<T> {
0029 private:
0030 std::string baseName_;
0031 std::string baseTitle_;
0032
0033
0034
0035 std::vector<MonElemWithCutBase<T>*> cutMonElems_;
0036 std::vector<MonElemManagerBase<T>*> monElems_;
0037 EgHLTDQMCut<T>* cut_;
0038
0039 private:
0040 MonElemContainer(const MonElemContainer& rhs) {}
0041 MonElemContainer& operator=(const MonElemContainer& rhs) { return *this; }
0042
0043 public:
0044 MonElemContainer(std::string baseName = "", std::string baseTitle = "", EgHLTDQMCut<T>* cut = nullptr)
0045 : baseName_(std::move(baseName)), baseTitle_(std::move(baseTitle)), cut_(cut) {}
0046
0047 ~MonElemContainer() override;
0048
0049
0050 std::vector<MonElemWithCutBase<T>*>& cutMonElems() { return cutMonElems_; }
0051 const std::vector<MonElemWithCutBase<T>*>& cutMonElems() const { return cutMonElems_; }
0052 std::vector<MonElemManagerBase<T>*>& monElems() { return monElems_; }
0053 const std::vector<MonElemManagerBase<T>*>& monElems() const { return monElems_; }
0054
0055 const std::string& name() const { return baseName_; }
0056 const std::string& title() const { return baseTitle_; }
0057
0058 void fill(const T& obj, const OffEvt& evt, float weight) override;
0059 };
0060
0061 template <class T>
0062 MonElemContainer<T>::~MonElemContainer() {
0063 for (size_t i = 0; i < monElems_.size(); i++)
0064 delete monElems_[i];
0065 for (size_t i = 0; i < cutMonElems_.size(); i++)
0066 delete cutMonElems_[i];
0067 if (cut_ != nullptr)
0068 delete cut_;
0069 }
0070
0071 template <class T>
0072 void MonElemContainer<T>::fill(const T& obj, const OffEvt& evt, float weight) {
0073 if (cut_ == nullptr || cut_->pass(obj, evt)) {
0074 for (size_t i = 0; i < monElems_.size(); i++)
0075 monElems_[i]->fill(obj, weight);
0076 for (size_t i = 0; i < cutMonElems_.size(); i++)
0077 cutMonElems_[i]->fill(obj, evt, weight);
0078 }
0079 }
0080 }
0081 #endif