CMS 3D CMS Logo

GEMOfflineDQMBase.h
Go to the documentation of this file.
1 #ifndef DQMOffline_Muon_GEMOfflineDQMBase_h
2 #define DQMOffline_Muon_GEMOfflineDQMBase_h
3 
10 
12 public:
13  explicit GEMOfflineDQMBase(const edm::ParameterSet&);
14 
15  typedef std::tuple<int, int> MEMapKey1; // (region, station)
16  typedef std::tuple<int, int, bool> MEMapKey2; // (region, station, is odd superchamber)
17  typedef std::tuple<int, int, bool, int> MEMapKey3; // (region, station, is odd superchamber, ieta)
18  typedef std::map<MEMapKey1, MonitorElement*> MEMap1;
19  typedef std::map<MEMapKey2, MonitorElement*> MEMap2;
20  typedef std::map<MEMapKey3, MonitorElement*> MEMap3;
21 
22  inline int getVFATNumber(const int, const int, const int);
23  inline int getVFATNumberByStrip(const int, const int, const int);
24  inline int getMaxVFAT(const int);
25  inline int getDetOccXBin(const int, const int, const int);
26 
30  // the number of eta partitions per GEMChamber
31  int getNumEtaPartitions(const GEMStation*);
32 
33  template <typename AnyKey>
34  TString convertKeyToStr(const AnyKey& key);
35 
36  template <typename AnyKey>
37  void fillME(std::map<AnyKey, MonitorElement*>&, const AnyKey&, const float);
38 
39  template <typename AnyKey>
40  void fillME(std::map<AnyKey, MonitorElement*>&, const AnyKey&, const float, const float y);
41 
42  template <typename T>
43  inline bool checkRefs(const std::vector<T*>&);
44 
46 
47  class BookingHelper {
48  public:
49  BookingHelper(DQMStore::IBooker& ibooker, const TString& name_suffix, const TString& title_suffix)
50  : ibooker_(&ibooker), name_suffix_(name_suffix), title_suffix_(title_suffix) {}
51 
53 
55  TString title,
56  int nbinsx,
57  double xlow,
58  double xup,
59  TString x_title = "",
60  TString y_title = "Entries") {
61  name += name_suffix_;
62  title += title_suffix_ + ";" + x_title + ";" + y_title;
63  return ibooker_->book1D(name, title, nbinsx, xlow, xup);
64  }
65 
67  TString title,
68  std::vector<double>& x_binning,
69  TString x_title = "",
70  TString y_title = "Entries") {
71  name += name_suffix_;
72  title += title_suffix_ + ";" + x_title + ";" + y_title;
73  TH1F* h_obj = new TH1F(name, title, x_binning.size() - 1, &x_binning[0]);
74  return ibooker_->book1D(name, h_obj);
75  }
76 
78  TString title,
79  int nbinsx,
80  double xlow,
81  double xup,
82  int nbinsy,
83  double ylow,
84  double yup,
85  TString x_title = "",
86  TString y_title = "") {
87  name += name_suffix_;
88  title += title_suffix_ + ";" + x_title + ";" + y_title;
89  return ibooker_->book2D(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup);
90  }
91 
92  private:
94  const TString name_suffix_;
95  const TString title_suffix_;
96  }; // BookingHelper
97 };
98 
99 inline int GEMOfflineDQMBase::getMaxVFAT(const int station) {
100  if (station == 1)
101  return GEMeMap::maxVFatGE11_;
102  else if (station == 2)
103  return GEMeMap::maxVFatGE21_;
104  else
105  return -1;
106 }
107 
108 inline int GEMOfflineDQMBase::getVFATNumber(const int station, const int ieta, const int vfat_phi) {
109  const int max_vfat = getMaxVFAT(station);
110  return max_vfat * (ieta - 1) + vfat_phi;
111 }
112 
113 inline int GEMOfflineDQMBase::getVFATNumberByStrip(const int station, const int ieta, const int strip) {
114  const int vfat_phi = (strip % GEMeMap::maxChan_) ? strip / GEMeMap::maxChan_ + 1 : strip / GEMeMap::maxChan_;
115  return getVFATNumber(station, ieta, vfat_phi);
116 };
117 
118 inline int GEMOfflineDQMBase::getDetOccXBin(const int chamber, const int layer, const int n_chambers) {
119  return n_chambers * (chamber - 1) + layer;
120 }
121 
122 template <typename T>
123 inline bool GEMOfflineDQMBase::checkRefs(const std::vector<T*>& refs) {
124  if (refs.empty())
125  return false;
126  if (refs.front() == nullptr)
127  return false;
128  return true;
129 }
130 
131 template <typename AnyKey>
132 TString GEMOfflineDQMBase::convertKeyToStr(const AnyKey& key) {
133  if constexpr (std::is_same_v<AnyKey, MEMapKey1>) {
134  return TString::Format("Region %d, Station %d.", std::get<0>(key), std::get<1>(key));
135 
136  } else if constexpr (std::is_same_v<AnyKey, MEMapKey2>) {
137  const char* superchamber_type = std::get<2>(key) ? "Odd" : "Even";
138  return TString::Format(
139  "Region %d, Station %d, %s Superchamber", std::get<0>(key), std::get<1>(key), superchamber_type);
140 
141  } else if constexpr (std::is_same_v<AnyKey, MEMapKey3>) {
142  const char* superchamber_type = std::get<2>(key) ? "Odd" : "Even";
143  return TString::Format("Region %d, Station %d, %s Superchamber, Roll %d",
144  std::get<0>(key),
145  std::get<1>(key),
146  superchamber_type,
147  std::get<3>(key));
148 
149  } else {
150  return TString::Format("unknown key type: %s", typeid(key).name());
151  }
152 }
153 
154 template <typename AnyKey>
155 void GEMOfflineDQMBase::fillME(std::map<AnyKey, MonitorElement*>& me_map, const AnyKey& key, const float x) {
156  if (me_map.find(key) == me_map.end()) {
157  const TString&& key_str = convertKeyToStr(key);
158  edm::LogError(log_category_) << "got invalid key: " << key_str << std::endl;
159 
160  } else {
161  me_map[key]->Fill(x);
162  }
163 }
164 
165 template <typename AnyKey>
166 void GEMOfflineDQMBase::fillME(std::map<AnyKey, MonitorElement*>& me_map,
167  const AnyKey& key,
168  const float x,
169  const float y) {
170  if (me_map.find(key) == me_map.end()) {
171  const TString&& key_str = convertKeyToStr(key);
172  edm::LogError(log_category_) << "got invalid key: " << key_str << std::endl;
173 
174  } else {
175  me_map[key]->Fill(x, y);
176  }
177 }
178 
179 #endif // DQMOffline_Muon_GEMOfflineDQMBase_h
GEMOfflineDQMBase::BookingHelper::book2D
MonitorElement * book2D(TString name, TString title, int nbinsx, double xlow, double xup, int nbinsy, double ylow, double yup, TString x_title="", TString y_title="")
Definition: GEMOfflineDQMBase.h:77
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
DDAxes::y
GEMOfflineDQMBase::MEMapKey3
std::tuple< int, int, bool, int > MEMapKey3
Definition: GEMOfflineDQMBase.h:17
MessageLogger.h
GEMOfflineDQMBase::BookingHelper::ibooker_
DQMStore::IBooker * ibooker_
Definition: GEMOfflineDQMBase.h:93
relativeConstraints.station
station
Definition: relativeConstraints.py:67
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
GEMOfflineDQMBase
Definition: GEMOfflineDQMBase.h:11
GEMOfflineDQMBase::MEMap3
std::map< MEMapKey3, MonitorElement * > MEMap3
Definition: GEMOfflineDQMBase.h:20
GEMOfflineDQMBase::getVFATNumberByStrip
int getVFATNumberByStrip(const int, const int, const int)
Definition: GEMOfflineDQMBase.h:113
DQMStore.h
GEMOfflineDQMBase::GEMOfflineDQMBase
GEMOfflineDQMBase(const edm::ParameterSet &)
Definition: GEMOfflineDQMBase.cc:3
DDAxes::x
GEMOfflineDQMBase::BookingHelper::title_suffix_
const TString title_suffix_
Definition: GEMOfflineDQMBase.h:95
GEMOfflineDQMBase::getMaxVFAT
int getMaxVFAT(const int)
Definition: GEMOfflineDQMBase.h:99
GEMOfflineDQMBase::BookingHelper::name_suffix_
const TString name_suffix_
Definition: GEMOfflineDQMBase.h:94
GEMOfflineDQMBase::getVFATNumber
int getVFATNumber(const int, const int, const int)
Definition: GEMOfflineDQMBase.h:108
GEMeMap::maxVFatGE21_
static const int maxVFatGE21_
Definition: GEMeMap.h:68
GEMOfflineDQMBase::log_category_
std::string log_category_
Definition: GEMOfflineDQMBase.h:45
GEMOfflineDQMBase::setDetLabelsEta
void setDetLabelsEta(MonitorElement *, const GEMStation *)
Definition: GEMOfflineDQMBase.cc:50
GEMOfflineDQMBase::MEMapKey2
std::tuple< int, int, bool > MEMapKey2
Definition: GEMOfflineDQMBase.h:16
GEMOfflineDQMBase::getNumEtaPartitions
int getNumEtaPartitions(const GEMStation *)
Definition: GEMOfflineDQMBase.cc:77
GEMeMap.h
vertices_cff.x
x
Definition: vertices_cff.py:29
GEMStation
Definition: GEMStation.h:19
edm::ESHandle< GEMGeometry >
GEMeMap::maxVFatGE11_
static const int maxVFatGE11_
Definition: GEMeMap.h:67
DQMEDAnalyzer.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GEMOfflineDQMBase::MEMap2
std::map< MEMapKey2, MonitorElement * > MEMap2
Definition: GEMOfflineDQMBase.h:19
GEMOfflineDQMBase::fillME
void fillME(std::map< AnyKey, MonitorElement * > &, const AnyKey &, const float)
Definition: GEMOfflineDQMBase.h:155
DQMEDAnalyzer
Definition: DQMEDAnalyzer.py:1
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
GEMOfflineDQMBase::MEMapKey1
std::tuple< int, int > MEMapKey1
Definition: GEMOfflineDQMBase.h:15
GEMOfflineDQMBase::BookingHelper
Definition: GEMOfflineDQMBase.h:47
GEMOfflineDQMBase::checkRefs
bool checkRefs(const std::vector< T * > &)
Definition: GEMOfflineDQMBase.h:123
GEMDetId
Definition: GEMDetId.h:17
GEMOfflineDQMBase::convertKeyToStr
TString convertKeyToStr(const AnyKey &key)
Definition: GEMOfflineDQMBase.h:132
GEMOfflineDQMBase::MEMap1
std::map< MEMapKey1, MonitorElement * > MEMap1
Definition: GEMOfflineDQMBase.h:18
GEMOfflineDQMBase::setDetLabelsVFAT
void setDetLabelsVFAT(MonitorElement *, const GEMStation *)
Definition: GEMOfflineDQMBase.cc:15
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
GEMGeometry.h
GEMDetId.h
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqm::implementation::IBooker
Definition: DQMStore.h:43
GEMOfflineDQMBase::BookingHelper::~BookingHelper
~BookingHelper()
Definition: GEMOfflineDQMBase.h:52
GEMOfflineDQMBase::BookingHelper::book1D
MonitorElement * book1D(TString name, TString title, int nbinsx, double xlow, double xup, TString x_title="", TString y_title="Entries")
Definition: GEMOfflineDQMBase.h:54
crabWrapper.key
key
Definition: crabWrapper.py:19
GEMeMap::maxChan_
static const int maxChan_
Definition: GEMeMap.h:69
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
GEMOfflineDQMBase::BookingHelper::book1D
MonitorElement * book1D(TString name, TString title, std::vector< double > &x_binning, TString x_title="", TString y_title="Entries")
Definition: GEMOfflineDQMBase.h:66
GEMOfflineDQMBase::BookingHelper::BookingHelper
BookingHelper(DQMStore::IBooker &ibooker, const TString &name_suffix, const TString &title_suffix)
Definition: GEMOfflineDQMBase.h:49
GEMOfflineDQMBase::getDetOccXBin
int getDetOccXBin(const int, const int, const int)
Definition: GEMOfflineDQMBase.h:118