File indexing completed on 2022-06-24 22:51:51
0001 #ifndef DQM_GEM_INTERFACE_GEMDQMBase_h
0002 #define DQM_GEM_INTERFACE_GEMDQMBase_h
0003
0004 #include <map>
0005 #include <tuple>
0006
0007 #include "FWCore/Framework/interface/ESHandle.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/PluginManager/interface/ModuleDef.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0013 #include "FWCore/Utilities/interface/InputTag.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015
0016 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0017 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0018 #include "DQMServices/Core/interface/DQMStore.h"
0019 #include "DQMServices/Core/interface/MonitorElement.h"
0020
0021 #include "CondFormats/GEMObjects/interface/GEMeMap.h"
0022 #include "Validation/MuonGEMHits/interface/GEMValidationUtils.h"
0023
0024 #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"
0025
0026 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
0027 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0028
0029 class GEMDQMBase : public DQMEDAnalyzer {
0030 public:
0031
0032 class BookingHelper {
0033 public:
0034 BookingHelper(DQMStore::IBooker &ibooker, const TString &name_suffix, const TString &title_suffix)
0035 : ibooker_(&ibooker), name_suffix_(name_suffix), title_suffix_(title_suffix) {}
0036
0037 ~BookingHelper() {}
0038
0039 MonitorElement *book1D(TString name,
0040 TString title,
0041 int nbinsx,
0042 double xlow,
0043 double xup,
0044 TString x_title = "",
0045 TString y_title = "Entries") {
0046 name += name_suffix_;
0047 title += title_suffix_ + ";" + x_title + ";" + y_title;
0048 return ibooker_->book1D(name, title, nbinsx, xlow, xup);
0049 }
0050
0051 MonitorElement *book1D(TString name,
0052 TString title,
0053 std::vector<double> &x_binning,
0054 TString x_title = "",
0055 TString y_title = "Entries") {
0056 name += name_suffix_;
0057 title += title_suffix_ + ";" + x_title + ";" + y_title;
0058 TH1F *h_obj = new TH1F(name, title, x_binning.size() - 1, &x_binning[0]);
0059 return ibooker_->book1D(name, h_obj);
0060 }
0061
0062 MonitorElement *book2D(TString name,
0063 TString title,
0064 int nbinsx,
0065 double xlow,
0066 double xup,
0067 int nbinsy,
0068 double ylow,
0069 double yup,
0070 TString x_title = "",
0071 TString y_title = "") {
0072 name += name_suffix_;
0073 title += title_suffix_ + ";" + x_title + ";" + y_title;
0074 return ibooker_->book2D(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup);
0075 }
0076
0077 MonitorElement *bookProfile2D(TString name,
0078 TString title,
0079 int nbinsx,
0080 double xlow,
0081 double xup,
0082 int nbinsy,
0083 double ylow,
0084 double yup,
0085 double zlow,
0086 double zup,
0087 TString x_title = "",
0088 TString y_title = "") {
0089 name += name_suffix_;
0090 title += title_suffix_ + ";" + x_title + ";" + y_title;
0091 return ibooker_->bookProfile2D(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup, zlow, zup);
0092 }
0093
0094 DQMStore::IBooker *getBooker() { return ibooker_; }
0095
0096 private:
0097 DQMStore::IBooker *ibooker_;
0098 const TString name_suffix_;
0099 const TString title_suffix_;
0100 };
0101
0102 template <class M, class K>
0103 class MEMapInfT {
0104 public:
0105 MEMapInfT() : bOperating_(false), bIsNoUnderOverflowBin_(false){};
0106
0107 MEMapInfT(
0108 GEMDQMBase *pDQMBase, TString strName, TString strTitle, TString strTitleX = "", TString strTitleY = "Entries")
0109 : pDQMBase_(pDQMBase),
0110 strName_(strName),
0111 strTitle_(strTitle),
0112 strTitleX_(strTitleX),
0113 strTitleY_(strTitleY),
0114 log_category_own_(pDQMBase->log_category_){};
0115
0116 MEMapInfT(GEMDQMBase *pDQMBase,
0117 TString strName,
0118 TString strTitle,
0119 Int_t nBinsX,
0120 Double_t dXL,
0121 Double_t dXH,
0122 TString strTitleX = "",
0123 TString strTitleY = "Entries")
0124 : pDQMBase_(pDQMBase),
0125 strName_(strName),
0126 strTitle_(strTitle),
0127 strTitleX_(strTitleX),
0128 strTitleY_(strTitleY),
0129 bOperating_(true),
0130 bIsProfile_(false),
0131 bIsNoUnderOverflowBin_(false),
0132 nBinsX_(nBinsX),
0133 dXL_(dXL),
0134 dXH_(dXH),
0135 nBinsY_(-1),
0136 log_category_own_(pDQMBase->log_category_){};
0137
0138 MEMapInfT(GEMDQMBase *pDQMBase,
0139 TString strName,
0140 TString strTitle,
0141 std::vector<Double_t> &x_binning,
0142 TString strTitleX = "",
0143 TString strTitleY = "Entries")
0144 : pDQMBase_(pDQMBase),
0145 strName_(strName),
0146 strTitle_(strTitle),
0147 strTitleX_(strTitleX),
0148 strTitleY_(strTitleY),
0149 bOperating_(true),
0150 bIsProfile_(false),
0151 bIsNoUnderOverflowBin_(false),
0152 nBinsX_(-1),
0153 nBinsY_(-1),
0154 log_category_own_(pDQMBase->log_category_) {
0155 for (Int_t i = 0; i < (Int_t)x_binning.size(); i++)
0156 x_binning_.push_back(x_binning[i]);
0157 };
0158
0159 MEMapInfT(GEMDQMBase *pDQMBase,
0160 TString strName,
0161 TString strTitle,
0162 Int_t nBinsX,
0163 Double_t dXL,
0164 Double_t dXH,
0165 Int_t nBinsY,
0166 Double_t dYL,
0167 Double_t dYH,
0168 TString strTitleX = "",
0169 TString strTitleY = "")
0170 : pDQMBase_(pDQMBase),
0171 strName_(strName),
0172 strTitle_(strTitle),
0173 strTitleX_(strTitleX),
0174 strTitleY_(strTitleY),
0175 bOperating_(true),
0176 bIsProfile_(false),
0177 bIsNoUnderOverflowBin_(false),
0178 nBinsX_(nBinsX),
0179 dXL_(dXL),
0180 dXH_(dXH),
0181 nBinsY_(nBinsY),
0182 dYL_(dYL),
0183 dYH_(dYH),
0184 dZL_(0),
0185 dZH_(1024),
0186 log_category_own_(pDQMBase->log_category_){};
0187
0188 MEMapInfT(GEMDQMBase *pDQMBase,
0189 TString strName,
0190 TString strTitle,
0191 Int_t nBinsX,
0192 Double_t dXL,
0193 Double_t dXH,
0194 Int_t nBinsY,
0195 Double_t dYL,
0196 Double_t dYH,
0197 Double_t dZL,
0198 Double_t dZH,
0199 TString strTitleX = "",
0200 TString strTitleY = "")
0201 : pDQMBase_(pDQMBase),
0202 strName_(strName),
0203 strTitle_(strTitle),
0204 strTitleX_(strTitleX),
0205 strTitleY_(strTitleY),
0206 bOperating_(true),
0207 bIsProfile_(true),
0208 bIsNoUnderOverflowBin_(false),
0209 nBinsX_(nBinsX),
0210 dXL_(dXL),
0211 dXH_(dXH),
0212 nBinsY_(nBinsY),
0213 dYL_(dYL),
0214 dYH_(dYH),
0215 dZL_(dZL),
0216 dZH_(dZH),
0217 log_category_own_(pDQMBase->log_category_){};
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241 ~MEMapInfT(){};
0242
0243 Bool_t isOperating() { return bOperating_; };
0244 void SetOperating(Bool_t bOperating) { bOperating_ = bOperating; };
0245 void TurnOn() { bOperating_ = true; };
0246 void TurnOff() { bOperating_ = false; };
0247 void SetNoUnderOverflowBin() { bIsNoUnderOverflowBin_ = true; };
0248
0249 Bool_t isProfile() { return bIsProfile_; };
0250 void SetProfile(Bool_t bIsProfile) { bIsProfile_ = bIsProfile; };
0251
0252 TString GetName() { return strName_; };
0253 void SetName(TString strName) { strName_ = strName; };
0254 TString GetTitle() { return strTitle_; };
0255 void SetTitle(TString strTitle) { strTitle_ = strTitle; };
0256 TString GetTitleX() { return strTitleX_; };
0257 void SetTitleX(TString strTitleX) { strTitleX_ = strTitleX; };
0258 TString GetTitleY() { return strTitleY_; };
0259 void SetTitleY(TString strTitleY) { strTitleY_ = strTitleY; };
0260
0261 Int_t GetNbinsX() { return nBinsX_; };
0262 void SetNbinsX(Int_t nBinsX) { nBinsX_ = nBinsX; };
0263 Double_t GetBinLowEdgeX() { return dXL_; };
0264 void SetBinLowEdgeX(Double_t dXL) { dXL_ = dXL; };
0265 Double_t GetBinHighEdgeX() { return dXH_; };
0266 void SetBinHighEdgeX(Double_t dXH) { dXH_ = dXH; };
0267
0268
0269 Int_t GetNbinsY() { return nBinsY_; };
0270 void SetNbinsY(Int_t nBinsY) { nBinsY_ = nBinsY; };
0271 Double_t GetBinLowEdgeY() { return dYL_; };
0272 void SetBinLowEdgeY(Double_t dYL) { dYL_ = dYL; };
0273 Double_t GetBinHighEdgeY() { return dYH_; };
0274 void SetBinHighEdgeY(Double_t dYH) { dYH_ = dYH; };
0275
0276 Double_t GetBinLowEdgeZ() { return dZL_; };
0277 void SetBinLowEdgeZ(Double_t dZL) { dZL_ = dZL; };
0278 Double_t GetBinHighEdgeZ() { return dZH_; };
0279 void SetBinHighEdgeZ(Double_t dZH) { dZH_ = dZH; };
0280
0281 void SetBinConfX(Int_t nBins, Double_t dL = 0.5, Double_t dH = -1048576.0) {
0282 nBinsX_ = nBins;
0283 dXL_ = dL;
0284 if (dH <= dL)
0285 dH = dL + nBins;
0286 dXH_ = dH;
0287 };
0288
0289 void SetBinConfY(Int_t nBins, Double_t dL = 0.5, Double_t dH = -1048576.0) {
0290 nBinsY_ = nBins;
0291 dYL_ = dL;
0292 if (dH <= dL)
0293 dH = dL + nBins;
0294 dYH_ = dH;
0295 };
0296
0297 void SetPointUOFlow() {
0298 dXU_ = dXL_ + (dXH_ - dXL_) / nBinsX_ * 0.5;
0299 dXO_ = dXL_ + (dXH_ - dXL_) / nBinsX_ * (nBinsX_ - 0.5);
0300 dYU_ = dYL_ + (dYH_ - dYL_) / nBinsY_ * 0.5;
0301 dYO_ = dYL_ + (dYH_ - dYL_) / nBinsY_ * (nBinsY_ - 0.5);
0302 dZU_ = dZL_ + (dZH_ - dZL_) / nBinsZ_ * 0.5;
0303 dZO_ = dZL_ + (dZH_ - dZL_) / nBinsZ_ * (nBinsZ_ - 0.5);
0304 };
0305
0306 M &map() { return mapHist; }
0307 int bookND(BookingHelper &bh, K key) {
0308 if (!bOperating_)
0309 return 0;
0310 SetPointUOFlow();
0311 if (bIsProfile_) {
0312 mapHist[key] = bh.bookProfile2D(
0313 strName_, strTitle_, nBinsX_, dXL_, dXH_, nBinsY_, dYL_, dYH_, dZL_, dZH_, strTitleX_, strTitleY_);
0314 } else if (nBinsY_ > 0 && nBinsX_ > 0) {
0315 mapHist[key] = bh.book2D(strName_, strTitle_, nBinsX_, dXL_, dXH_, nBinsY_, dYL_, dYH_, strTitleX_, strTitleY_);
0316 return 0;
0317 } else if (!x_binning_.empty()) {
0318 mapHist[key] = bh.book1D(strName_, strTitle_, nBinsX_, dXL_, dXH_, strTitleX_, strTitleY_);
0319 return 0;
0320 } else if (nBinsX_ > 0) {
0321 mapHist[key] = bh.book1D(strName_, strTitle_, nBinsX_, dXL_, dXH_, strTitleX_, strTitleY_);
0322 return 0;
0323 }
0324
0325 return -1;
0326 };
0327
0328 dqm::impl::MonitorElement *FindHist(K key) {
0329 if (mapHist.find(key) == mapHist.end()) {
0330 edm::LogError(log_category_own_)
0331 << "WARNING: Cannot find the histogram corresponing to the given key\n";
0332 return nullptr;
0333 }
0334 return mapHist[key];
0335 };
0336
0337 int SetLabelForChambers(K key, Int_t nAxis, Int_t nNumBin = -1, Int_t nIdxStart = 1) {
0338 if (!bOperating_)
0339 return 0;
0340 if (nNumBin <= 0) {
0341 if (nAxis == 1)
0342 nNumBin = nBinsX_;
0343 else if (nAxis == 2)
0344 nNumBin = nBinsY_;
0345 else
0346 return -1;
0347 }
0348 dqm::impl::MonitorElement *histCurr = FindHist(key);
0349 if (histCurr == nullptr)
0350 return -999;
0351 for (Int_t i = nIdxStart; i <= nNumBin; i++) {
0352 histCurr->setBinLabel(i, Form("%i", i), nAxis);
0353 }
0354 return 0;
0355 };
0356
0357 int SetLabelForIEta(K key, Int_t nAxis, Int_t nNumBin = -1) { return SetLabelForChambers(key, nAxis, nNumBin); };
0358
0359 int SetLabelForVFATs(K key, Int_t nNumEtaPartitions, Int_t nAxis, Int_t nNumBin = -1) {
0360 if (!bOperating_)
0361 return 0;
0362 if (nNumBin <= 0) {
0363 if (nAxis == 1)
0364 nNumBin = nBinsX_;
0365 else if (nAxis == 2)
0366 nNumBin = nBinsY_;
0367 else
0368 return -1;
0369 }
0370 dqm::impl::MonitorElement *histCurr = FindHist(key);
0371 if (histCurr == nullptr)
0372 return -999;
0373 for (Int_t i = 0; i < nNumBin; i++) {
0374 Int_t nIEta = pDQMBase_->getIEtaFromVFAT(std::get<1>(key), i);
0375 histCurr->setBinLabel(i + 1, Form("%i (%i)", i, nIEta), nAxis);
0376 }
0377 return 0;
0378 };
0379
0380 int Fill(K key, Double_t x) {
0381 if (!bOperating_)
0382 return 0;
0383 dqm::impl::MonitorElement *hist = FindHist(key);
0384 if (hist == nullptr)
0385 return -999;
0386 if (bIsNoUnderOverflowBin_) {
0387 if (x <= dXL_)
0388 x = dXU_;
0389 else if (x >= dXH_)
0390 x = dXO_;
0391 }
0392 hist->Fill(x);
0393 return 1;
0394 };
0395
0396 int Fill(K key, Double_t x, Double_t y, Double_t w = 1.0) {
0397 if (!bOperating_)
0398 return 0;
0399 dqm::impl::MonitorElement *hist = FindHist(key);
0400 if (hist == nullptr)
0401 return -999;
0402 if (bIsNoUnderOverflowBin_) {
0403 if (x <= dXL_)
0404 x = dXU_;
0405 else if (x >= dXH_)
0406 x = dXO_;
0407 if (y <= dYL_)
0408 y = dYU_;
0409 else if (y >= dYH_)
0410 y = dYO_;
0411 }
0412 hist->Fill(x, y, w);
0413 return 1;
0414 };
0415
0416 int FillBits(K key, Double_t x, UInt_t bits, Double_t w = 1.0) {
0417 if (!bOperating_)
0418 return 0;
0419 dqm::impl::MonitorElement *hist = FindHist(key);
0420 if (hist == nullptr)
0421 return -999;
0422
0423 if (nBinsY_ <= 0)
0424 return -888;
0425 UInt_t unMask = 0x1;
0426 for (Int_t i = 1; i <= nBinsY_; i++) {
0427 if ((unMask & bits) != 0)
0428 hist->Fill(x, i, w);
0429 unMask <<= 1;
0430 }
0431
0432 return 1;
0433 };
0434
0435 private:
0436 GEMDQMBase *pDQMBase_;
0437
0438 M mapHist;
0439 TString strName_, strTitle_, strTitleX_, strTitleY_;
0440 Bool_t bOperating_;
0441 Bool_t bIsProfile_;
0442 Bool_t bIsNoUnderOverflowBin_;
0443
0444 std::vector<double> x_binning_;
0445 Int_t nBinsX_;
0446 Double_t dXL_, dXH_;
0447 Int_t nBinsY_;
0448 Double_t dYL_, dYH_;
0449 Int_t nBinsZ_;
0450 Double_t dZL_, dZH_;
0451 Double_t dXU_, dXO_;
0452 Double_t dYU_, dYO_;
0453 Double_t dZU_, dZO_;
0454
0455 std::string log_category_own_;
0456 };
0457
0458 typedef MEMapInfT<MEMap2Ids, ME2IdsKey> MEMap2Inf;
0459 typedef MEMapInfT<MEMap3Ids, ME3IdsKey> MEMap3Inf;
0460 typedef MEMapInfT<MEMap4Ids, ME4IdsKey> MEMap4Inf;
0461
0462 class MEStationInfo {
0463 public:
0464 MEStationInfo() : nNumChambers_(-1){};
0465 MEStationInfo(Int_t nRegion,
0466 Int_t nStation,
0467 Int_t nLayer,
0468 Int_t nNumChambers,
0469 Int_t nNumEtaPartitions,
0470 Int_t nMaxVFAT,
0471 Int_t nNumDigi)
0472 : nRegion_(nRegion),
0473 nStation_(nStation),
0474 nLayer_(nLayer),
0475 nNumChambers_(nNumChambers),
0476 nNumEtaPartitions_(nNumEtaPartitions),
0477 nMaxVFAT_(nMaxVFAT),
0478 nNumDigi_(nNumDigi),
0479 fMinPhi_(0){};
0480
0481 bool operator==(const MEStationInfo &other) const {
0482 return (nRegion_ == other.nRegion_ && nStation_ == other.nStation_ && nLayer_ == other.nLayer_ &&
0483 nNumChambers_ == other.nNumChambers_ && nNumEtaPartitions_ == other.nNumEtaPartitions_ &&
0484 nMaxVFAT_ == other.nMaxVFAT_ && nNumDigi_ == other.nNumDigi_);
0485 };
0486
0487 Int_t nRegion_;
0488 Int_t nStation_;
0489 Int_t nLayer_;
0490 Int_t nNumChambers_;
0491 Int_t nNumEtaPartitions_;
0492 Int_t nMaxVFAT_;
0493 Int_t nNumDigi_;
0494
0495 Int_t nMinIdxChamber_;
0496 Int_t nMaxIdxChamber_;
0497 Float_t fMinPhi_;
0498
0499 std::vector<Float_t> listRadiusEvenChamber_;
0500 std::vector<Float_t> listRadiusOddChamber_;
0501 };
0502
0503 int readGeometryRadiusInfoChamber(const GEMStation *station, MEStationInfo &stationInfo);
0504 int readGeometryPhiInfoChamber(const GEMStation *station, MEStationInfo &stationInfo);
0505
0506 public:
0507 explicit GEMDQMBase(const edm::ParameterSet &cfg);
0508 ~GEMDQMBase() override{};
0509
0510 enum {
0511 GEMDQM_RUNTYPE_ONLINE,
0512 GEMDQM_RUNTYPE_OFFLINE,
0513 GEMDQM_RUNTYPE_RELVAL,
0514 GEMDQM_RUNTYPE_ALLPLOTS,
0515 GEMDQM_RUNTYPE_NONE = -1
0516 };
0517
0518 Int_t nRunType_;
0519
0520 std::string log_category_;
0521
0522 protected:
0523 int initGeometry(edm::EventSetup const &iSetup);
0524 int loadChambers();
0525
0526 int GenerateMEPerChamber(DQMStore::IBooker &ibooker);
0527 virtual int ProcessWithMEMap2(BookingHelper &bh, ME2IdsKey key) { return 0; };
0528 virtual int ProcessWithMEMap2WithEta(BookingHelper &bh, ME3IdsKey key) { return 0; };
0529 virtual int ProcessWithMEMap2AbsReWithEta(BookingHelper &bh, ME3IdsKey key) { return 0; };
0530 virtual int ProcessWithMEMap3(BookingHelper &bh, ME3IdsKey key) { return 0; };
0531 virtual int ProcessWithMEMap4(BookingHelper &bh, ME4IdsKey key) { return 0; };
0532 virtual int ProcessWithMEMap3WithChamber(BookingHelper &bh, ME4IdsKey key) { return 0; };
0533
0534 int keyToRegion(ME2IdsKey key) { return std::get<0>(key); };
0535 int keyToRegion(ME3IdsKey key) { return std::get<0>(key); };
0536 int keyToRegion(ME4IdsKey key) { return std::get<0>(key); };
0537 int keyToStation(ME2IdsKey key) { return std::get<1>(key); };
0538 int keyToStation(ME3IdsKey key) { return std::get<1>(key); };
0539 int keyToStation(ME4IdsKey key) { return std::get<1>(key); };
0540 int keyToLayer(ME3IdsKey key) { return std::get<2>(key); };
0541 int keyToLayer(ME4IdsKey key) { return std::get<2>(key); };
0542 int keyToChamber(ME4IdsKey key) { return std::get<3>(key); };
0543 int keyToIEta(ME3IdsKey key) { return std::get<2>(key); };
0544 int keyToIEta(ME4IdsKey key) { return std::get<3>(key); };
0545
0546 ME2IdsKey key3Tokey2(ME3IdsKey key) {
0547 auto keyNew = ME2IdsKey{keyToRegion(key), keyToStation(key)};
0548 return keyNew;
0549 };
0550
0551 ME3IdsKey key4Tokey3(ME4IdsKey key) {
0552 auto keyNew = ME3IdsKey{keyToRegion(key), keyToStation(key), keyToLayer(key)};
0553 return keyNew;
0554 };
0555
0556 int SortingLayers(std::vector<ME3IdsKey> &listLayers);
0557 dqm::impl::MonitorElement *CreateSummaryHist(DQMStore::IBooker &ibooker, TString strName);
0558
0559 template <typename T>
0560 inline bool checkRefs(const std::vector<T *> &);
0561
0562 int getNumEtaPartitions(const GEMStation *);
0563 inline int getVFATNumber(const int, const int, const int);
0564 inline int getVFATNumberGE11(const int, const int, const int);
0565 inline int getVFATNumberByDigi(const int, const int, const int);
0566 inline int getIEtaFromVFAT(const int station, const int vfat);
0567 inline int getIEtaFromVFATGE0(const int vfat);
0568 inline int getIEtaFromVFATGE11(const int vfat);
0569 inline int getIEtaFromVFATGE21(const int vfat);
0570 inline int getMaxVFAT(const int);
0571 inline int getDetOccXBin(const int, const int, const int);
0572 inline Float_t restrictAngle(const Float_t fTheta, const Float_t fStart);
0573 inline std::string getNameDirLayer(ME3IdsKey key3);
0574
0575 const GEMGeometry *GEMGeometry_;
0576 edm::ESGetToken<GEMGeometry, MuonGeometryRecord> geomToken_;
0577
0578 std::vector<GEMChamber> gemChambers_;
0579
0580 std::map<ME2IdsKey, bool> MEMap2Check_;
0581 std::map<ME3IdsKey, bool> MEMap2WithEtaCheck_;
0582 std::map<ME3IdsKey, bool> MEMap2AbsReWithEtaCheck_;
0583 std::map<ME3IdsKey, bool> MEMap3Check_;
0584 std::map<ME4IdsKey, bool> MEMap3WithChCheck_;
0585 std::map<ME4IdsKey, bool> MEMap4Check_;
0586
0587 int nMaxNumCh_;
0588 std::map<ME3IdsKey, int> mapStationToIdx_;
0589 std::map<ME3IdsKey, MEStationInfo> mapStationInfo_;
0590 };
0591
0592
0593 template <typename T>
0594 inline bool GEMDQMBase::checkRefs(const std::vector<T *> &refs) {
0595 if (refs.empty())
0596 return false;
0597 if (refs.front() == nullptr)
0598 return false;
0599 return true;
0600 }
0601
0602
0603 inline int GEMDQMBase::getMaxVFAT(const int station) {
0604 if (station == 0)
0605 return GEMeMap::maxVFatGE0_;
0606 if (station == 1)
0607 return GEMeMap::maxVFatGE11_;
0608 else if (station == 2)
0609 return GEMeMap::maxVFatGE21_;
0610 else
0611 return -1;
0612 }
0613
0614 inline int GEMDQMBase::getVFATNumber(const int station, const int ieta, const int vfat_phi) {
0615 if (station == 1)
0616 return getVFATNumberGE11(station, ieta, vfat_phi);
0617 return getVFATNumberGE11(station, ieta, vfat_phi);
0618 }
0619
0620 inline int GEMDQMBase::getVFATNumberGE11(const int station, const int ieta, const int vfat_phi) {
0621 return vfat_phi * GEMeMap::maxiEtaIdGE11_ + (GEMeMap::maxiEtaIdGE11_ - ieta);
0622 }
0623
0624 inline int GEMDQMBase::getVFATNumberByDigi(const int station, const int ieta, const int digi) {
0625 const int vfat_phi = digi / GEMeMap::maxChan_;
0626 return getVFATNumber(station, ieta, vfat_phi);
0627 }
0628
0629 inline int GEMDQMBase::getIEtaFromVFAT(const int station, const int vfat) {
0630 if (station == 0)
0631 return getIEtaFromVFATGE0(vfat);
0632 if (station == 1)
0633 return getIEtaFromVFATGE11(vfat);
0634 if (station == 2)
0635 return getIEtaFromVFATGE21(vfat);
0636 return getIEtaFromVFATGE11(vfat);
0637 }
0638
0639 inline int GEMDQMBase::getIEtaFromVFATGE0(const int vfat) {
0640 return GEMeMap::maxiEtaIdGE0_ - (vfat % GEMeMap::maxiEtaIdGE0_);
0641 }
0642
0643 inline int GEMDQMBase::getIEtaFromVFATGE11(const int vfat) {
0644 return GEMeMap::maxiEtaIdGE11_ - (vfat % GEMeMap::maxiEtaIdGE11_);
0645 }
0646
0647 inline int GEMDQMBase::getIEtaFromVFATGE21(const int vfat) {
0648 return GEMeMap::maxiEtaIdGE21_ - (vfat % GEMeMap::maxiEtaIdGE21_);
0649 }
0650
0651 inline int GEMDQMBase::getDetOccXBin(const int chamber, const int layer, const int n_chambers) {
0652 return n_chambers * (chamber - 1) + layer;
0653 }
0654
0655 inline Float_t GEMDQMBase::restrictAngle(const Float_t fTheta, const Float_t fStart) {
0656 Float_t fLoop = (fTheta - fStart) / (2 * M_PI);
0657 int nLoop = (fLoop >= 0 ? (int)fLoop : (int)fLoop - 1);
0658 return fTheta - nLoop * 2 * M_PI;
0659 }
0660
0661 inline std::string GEMDQMBase::getNameDirLayer(ME3IdsKey key3) {
0662 auto nStation = keyToStation(key3);
0663 char cRegion = (keyToRegion(key3) > 0 ? 'P' : 'M');
0664 auto nLayer = keyToLayer(key3);
0665 return std::string(Form("GE%i1-%c-L%i", nStation, cRegion, nLayer));
0666 }
0667
0668 #endif