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) {
101  return GEMeMap::maxVFatGE0_;
103  return GEMeMap::maxVFatGE11_;
105  return GEMeMap::maxVFatGE21_;
106  else
107  return -1;
108 }
109 
110 inline int GEMOfflineDQMBase::getVFATNumber(const int station, const int ieta, const int vfat_phi) {
111  const int max_vfat = getMaxVFAT(station);
112  return max_vfat * (ieta - 1) + vfat_phi;
113 }
114 
115 inline int GEMOfflineDQMBase::getVFATNumberByStrip(const int station, const int ieta, const int strip) {
116  const int vfat_phi = (strip % GEMeMap::maxChan_) ? strip / GEMeMap::maxChan_ + 1 : strip / GEMeMap::maxChan_;
117  return getVFATNumber(station, ieta, vfat_phi);
118 };
119 
120 inline int GEMOfflineDQMBase::getDetOccXBin(const int chamber, const int layer, const int n_chambers) {
121  return n_chambers * (chamber - 1) + layer;
122 }
123 
124 template <typename T>
125 inline bool GEMOfflineDQMBase::checkRefs(const std::vector<T*>& refs) {
126  if (refs.empty())
127  return false;
128  if (refs.front() == nullptr)
129  return false;
130  return true;
131 }
132 
133 template <typename AnyKey>
134 TString GEMOfflineDQMBase::convertKeyToStr(const AnyKey& key) {
135  if constexpr (std::is_same_v<AnyKey, MEMapKey1>) {
136  return TString::Format("Region %d, Station %d.", std::get<0>(key), std::get<1>(key));
137 
138  } else if constexpr (std::is_same_v<AnyKey, MEMapKey2>) {
139  const char* superchamber_type = std::get<2>(key) ? "Odd" : "Even";
140  return TString::Format(
141  "Region %d, Station %d, %s Superchamber", std::get<0>(key), std::get<1>(key), superchamber_type);
142 
143  } else if constexpr (std::is_same_v<AnyKey, MEMapKey3>) {
144  const char* superchamber_type = std::get<2>(key) ? "Odd" : "Even";
145  return TString::Format("Region %d, Station %d, %s Superchamber, Roll %d",
146  std::get<0>(key),
147  std::get<1>(key),
148  superchamber_type,
149  std::get<3>(key));
150 
151  } else {
152  return TString::Format("unknown key type: %s", typeid(key).name());
153  }
154 }
155 
156 template <typename AnyKey>
157 void GEMOfflineDQMBase::fillME(std::map<AnyKey, MonitorElement*>& me_map, const AnyKey& key, const float x) {
158  if (me_map.find(key) == me_map.end()) {
159  const TString&& key_str = convertKeyToStr(key);
160  edm::LogError(log_category_) << "got invalid key: " << key_str << std::endl;
161 
162  } else {
163  me_map[key]->Fill(x);
164  }
165 }
166 
167 template <typename AnyKey>
168 void GEMOfflineDQMBase::fillME(std::map<AnyKey, MonitorElement*>& me_map,
169  const AnyKey& key,
170  const float x,
171  const float y) {
172  if (me_map.find(key) == me_map.end()) {
173  const TString&& key_str = convertKeyToStr(key);
174  edm::LogError(log_category_) << "got invalid key: " << key_str << std::endl;
175 
176  } else {
177  me_map[key]->Fill(x, y);
178  }
179 }
180 
181 #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
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
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:115
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
GEMSubDetId::Station::GE21
GEMOfflineDQMBase::getVFATNumber
int getVFATNumber(const int, const int, const int)
Definition: GEMOfflineDQMBase.h:110
GEMeMap::maxVFatGE21_
static const int maxVFatGE21_
Definition: GEMeMap.h:66
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
GEMStation
Definition: GEMStation.h:19
edm::ESHandle< GEMGeometry >
GEMSubDetId::Station::GE0
GEMeMap::maxVFatGE11_
static const int maxVFatGE11_
Definition: GEMeMap.h:65
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:157
DQMEDAnalyzer
Definition: DQMEDAnalyzer.py:1
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
edm::ParameterSet
Definition: ParameterSet.h:47
GEMSubDetId::station
static Station station(uint16_t st)
Definition: GEMSubDetId.h:13
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:125
GEMDetId
Definition: GEMDetId.h:18
GEMOfflineDQMBase::convertKeyToStr
TString convertKeyToStr(const AnyKey &key)
Definition: GEMOfflineDQMBase.h:134
GEMOfflineDQMBase::MEMap1
std::map< MEMapKey1, MonitorElement * > MEMap1
Definition: GEMOfflineDQMBase.h:18
GEMOfflineDQMBase::setDetLabelsVFAT
void setDetLabelsVFAT(MonitorElement *, const GEMStation *)
Definition: GEMOfflineDQMBase.cc:15
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
GEMeMap::maxVFatGE0_
static const int maxVFatGE0_
Definition: GEMeMap.h:64
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
genVertex_cff.x
x
Definition: genVertex_cff.py:12
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
GEMSubDetId::Station::GE11
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:67
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:120