File indexing completed on 2022-11-28 04:00: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, Int_t nNumModules = 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 = 1; i <= nNumBin; i++) {
0352 Int_t nIdxCh = (nIdxStart + i - 2) / nNumModules + 1;
0353 Int_t nIdxMod = (nIdxStart + i - 2) % nNumModules + 1;
0354 if (nNumModules > 1) {
0355 histCurr->setBinLabel(i, Form("#splitline{%i}{M%i}", nIdxCh, nIdxMod), nAxis);
0356 } else {
0357 histCurr->setBinLabel(i, Form("%i", nIdxStart + i - 1), nAxis);
0358 }
0359 }
0360 return 0;
0361 };
0362
0363 int SetLabelForIEta(K key, Int_t nAxis, Int_t nNumBin = -1) { return SetLabelForChambers(key, nAxis, nNumBin); };
0364
0365 int SetLabelForVFATs(K key, Int_t nNumEtaPartitions, Int_t nAxis, Int_t nNumBin = -1) {
0366 if (!bOperating_)
0367 return 0;
0368 if (nNumBin <= 0) {
0369 if (nAxis == 1)
0370 nNumBin = nBinsX_;
0371 else if (nAxis == 2)
0372 nNumBin = nBinsY_;
0373 else
0374 return -1;
0375 }
0376 dqm::impl::MonitorElement *histCurr = FindHist(key);
0377 if (histCurr == nullptr)
0378 return -999;
0379 if (std::get<1>(key) == 2) {
0380 Int_t nNumVFATPerModule = 12;
0381 if (nNumBin > nNumVFATPerModule) {
0382 for (Int_t i = 0; i < nNumBin; i++) {
0383 Int_t nIModule = i / nNumVFATPerModule + 1;
0384 histCurr->setBinLabel(
0385 i + 1, Form((nAxis == 1 ? "#splitline{%i}{M%i}" : "%i (M%i)"), i % nNumVFATPerModule, nIModule), nAxis);
0386 }
0387 } else {
0388 for (Int_t i = 0; i < nNumBin; i++) {
0389 histCurr->setBinLabel(i + 1, Form("%i", i), nAxis);
0390 }
0391 }
0392 } else {
0393 for (Int_t i = 0; i < nNumBin; i++) {
0394 Int_t nIEta = pDQMBase_->getIEtaFromVFAT(std::get<1>(key), i);
0395 histCurr->setBinLabel(i + 1, Form("%i (%i)", i, nIEta), nAxis);
0396 }
0397 }
0398 return 0;
0399 };
0400
0401 int Fill(K key, Double_t x) {
0402 if (!bOperating_)
0403 return 0;
0404 dqm::impl::MonitorElement *hist = FindHist(key);
0405 if (hist == nullptr)
0406 return -999;
0407 if (bIsNoUnderOverflowBin_) {
0408 if (x <= dXL_)
0409 x = dXU_;
0410 else if (x >= dXH_)
0411 x = dXO_;
0412 }
0413 hist->Fill(x);
0414 return 1;
0415 };
0416
0417 int Fill(K key, Double_t x, Double_t y, Double_t w = 1.0) {
0418 if (!bOperating_)
0419 return 0;
0420 dqm::impl::MonitorElement *hist = FindHist(key);
0421 if (hist == nullptr)
0422 return -999;
0423 if (bIsNoUnderOverflowBin_) {
0424 if (x <= dXL_)
0425 x = dXU_;
0426 else if (x >= dXH_)
0427 x = dXO_;
0428 if (y <= dYL_)
0429 y = dYU_;
0430 else if (y >= dYH_)
0431 y = dYO_;
0432 }
0433 hist->Fill(x, y, w);
0434 return 1;
0435 };
0436
0437 int FillBits(K key, Double_t x, UInt_t bits, Double_t w = 1.0) {
0438 if (!bOperating_)
0439 return 0;
0440 dqm::impl::MonitorElement *hist = FindHist(key);
0441 if (hist == nullptr)
0442 return -999;
0443
0444 if (nBinsY_ <= 0)
0445 return -888;
0446 UInt_t unMask = 0x1;
0447 for (Int_t i = 1; i <= nBinsY_; i++) {
0448 if ((unMask & bits) != 0)
0449 hist->Fill(x, i, w);
0450 unMask <<= 1;
0451 }
0452
0453 return 1;
0454 };
0455
0456 private:
0457 GEMDQMBase *pDQMBase_;
0458
0459 M mapHist;
0460 TString strName_, strTitle_, strTitleX_, strTitleY_;
0461 Bool_t bOperating_;
0462 Bool_t bIsProfile_;
0463 Bool_t bIsNoUnderOverflowBin_;
0464
0465 std::vector<double> x_binning_;
0466 Int_t nBinsX_;
0467 Double_t dXL_, dXH_;
0468 Int_t nBinsY_;
0469 Double_t dYL_, dYH_;
0470 Int_t nBinsZ_;
0471 Double_t dZL_, dZH_;
0472 Double_t dXU_, dXO_;
0473 Double_t dYU_, dYO_;
0474 Double_t dZU_, dZO_;
0475
0476 std::string log_category_own_;
0477 };
0478
0479 typedef MEMapInfT<MEMap2Ids, ME2IdsKey> MEMap2Inf;
0480 typedef MEMapInfT<MEMap3Ids, ME3IdsKey> MEMap3Inf;
0481 typedef MEMapInfT<MEMap4Ids, ME4IdsKey> MEMap4Inf;
0482
0483 class MEStationInfo {
0484 public:
0485 MEStationInfo() : nNumChambers_(-1){};
0486 MEStationInfo(Int_t nRegion,
0487 Int_t nStation,
0488 Int_t nLayer,
0489 Int_t nNumChambers,
0490 Int_t nNumModules,
0491 Int_t nNumEtaPartitions,
0492 Int_t nMaxVFAT,
0493 Int_t nFirstStrip,
0494 Int_t nNumDigi,
0495 Int_t nMinIdxChamber,
0496 Int_t nMaxIdxChamber)
0497 : nRegion_(nRegion),
0498 nStation_(nStation),
0499 nLayer_(nLayer),
0500 nNumChambers_(nNumChambers),
0501 nNumModules_(nNumModules),
0502 nNumEtaPartitions_(nNumEtaPartitions),
0503 nMaxVFAT_(nMaxVFAT),
0504 nFirstStrip_(nFirstStrip),
0505 nNumDigi_(nNumDigi),
0506 nMinIdxChamber_(nMinIdxChamber),
0507 nMaxIdxChamber_(nMaxIdxChamber),
0508 fMinPhi_(0){};
0509
0510 bool operator==(const MEStationInfo &other) const {
0511 return (nRegion_ == other.nRegion_ && nStation_ == other.nStation_ && nLayer_ == other.nLayer_ &&
0512 nNumChambers_ == other.nNumChambers_ && nNumModules_ == other.nNumModules_ &&
0513 nNumEtaPartitions_ == other.nNumEtaPartitions_ && nMaxVFAT_ == other.nMaxVFAT_ &&
0514 nFirstStrip_ == other.nFirstStrip_ && nNumDigi_ == other.nNumDigi_);
0515 };
0516
0517 Int_t nRegion_;
0518 Int_t nStation_;
0519 Int_t nLayer_;
0520 Int_t nNumChambers_;
0521 Int_t nNumModules_;
0522 Int_t nNumEtaPartitions_;
0523 Int_t nMaxVFAT_;
0524 Int_t nFirstStrip_;
0525 Int_t nNumDigi_;
0526
0527 Int_t nMinIdxChamber_;
0528 Int_t nMaxIdxChamber_;
0529 Float_t fMinPhi_;
0530
0531 std::vector<Float_t> listRadiusEvenChamber_;
0532 std::vector<Float_t> listRadiusOddChamber_;
0533 };
0534
0535 int readGeometryRadiusInfoChamber(const GEMStation *station, MEStationInfo &stationInfo);
0536 int readGeometryPhiInfoChamber(const GEMStation *station, MEStationInfo &stationInfo);
0537
0538 public:
0539 explicit GEMDQMBase(const edm::ParameterSet &cfg);
0540 ~GEMDQMBase() override{};
0541
0542 enum {
0543 GEMDQM_RUNTYPE_ONLINE,
0544 GEMDQM_RUNTYPE_OFFLINE,
0545 GEMDQM_RUNTYPE_RELVAL,
0546 GEMDQM_RUNTYPE_ALLPLOTS,
0547 GEMDQM_RUNTYPE_NONE = -1
0548 };
0549
0550 Int_t nRunType_;
0551
0552 std::string log_category_;
0553
0554 protected:
0555 int initGeometry(edm::EventSetup const &iSetup);
0556 int loadChambers();
0557
0558 int GenerateMEPerChamber(DQMStore::IBooker &ibooker);
0559 virtual int ProcessWithMEMap2(BookingHelper &bh, ME2IdsKey key) { return 0; };
0560 virtual int ProcessWithMEMap2WithEta(BookingHelper &bh, ME3IdsKey key) { return 0; };
0561 virtual int ProcessWithMEMap2AbsReWithEta(BookingHelper &bh, ME3IdsKey key) { return 0; };
0562 virtual int ProcessWithMEMap3(BookingHelper &bh, ME3IdsKey key) { return 0; };
0563 virtual int ProcessWithMEMap4(BookingHelper &bh, ME4IdsKey key) { return 0; };
0564 virtual int ProcessWithMEMap3WithChamber(BookingHelper &bh, ME4IdsKey key) { return 0; };
0565
0566 int keyToRegion(ME2IdsKey key) { return std::get<0>(key); };
0567 int keyToRegion(ME3IdsKey key) { return std::get<0>(key); };
0568 int keyToRegion(ME4IdsKey key) { return std::get<0>(key); };
0569 int keyToStation(ME2IdsKey key) { return std::get<1>(key); };
0570 int keyToStation(ME3IdsKey key) { return std::get<1>(key); };
0571 int keyToStation(ME4IdsKey key) { return std::get<1>(key); };
0572 int keyToLayer(ME3IdsKey key) { return std::get<2>(key); };
0573 int keyToLayer(ME4IdsKey key) { return std::get<2>(key); };
0574 int keyToChamber(ME4IdsKey key) { return std::get<3>(key); };
0575 int keyToIEta(ME3IdsKey key) { return std::get<2>(key); };
0576 int keyToIEta(ME4IdsKey key) { return std::get<3>(key); };
0577
0578 ME2IdsKey key3Tokey2(ME3IdsKey key) {
0579 auto keyNew = ME2IdsKey{keyToRegion(key), keyToStation(key)};
0580 return keyNew;
0581 };
0582
0583 ME3IdsKey key4Tokey3(ME4IdsKey key) {
0584 auto keyNew = ME3IdsKey{keyToRegion(key), keyToStation(key), keyToLayer(key)};
0585 return keyNew;
0586 };
0587
0588 int SortingLayers(std::vector<ME3IdsKey> &listLayers);
0589 dqm::impl::MonitorElement *CreateSummaryHist(DQMStore::IBooker &ibooker, TString strName);
0590
0591 template <typename T>
0592 inline bool checkRefs(const std::vector<T *> &);
0593
0594 int getNumEtaPartitions(const GEMStation *);
0595 inline int getVFATNumber(const int, const int, const int);
0596 inline int getVFATNumberGE11(const int, const int, const int);
0597 inline int getVFATNumberByDigi(const int, const int, const int);
0598 inline int getIEtaFromVFAT(const int station, const int vfat);
0599 inline int getIEtaFromVFATGE0(const int vfat);
0600 inline int getIEtaFromVFATGE11(const int vfat);
0601 inline int getIEtaFromVFATGE21(const int vfat);
0602 inline int getMaxVFAT(const int);
0603 inline int getNumModule(const int);
0604 inline int getIdxModule(const int, const int);
0605 inline int getDetOccXBin(const int, const int, const int);
0606 inline Float_t restrictAngle(const Float_t fTheta, const Float_t fStart);
0607 inline std::string getNameDirLayer(ME3IdsKey key3);
0608
0609 const GEMGeometry *GEMGeometry_;
0610 edm::ESGetToken<GEMGeometry, MuonGeometryRecord> geomToken_;
0611
0612 std::vector<GEMDetId> listChamberId_;
0613 std::map<GEMDetId, std::vector<const GEMEtaPartition *>> mapEtaPartition_;
0614
0615 std::map<ME2IdsKey, bool> MEMap2Check_;
0616 std::map<ME3IdsKey, bool> MEMap2WithEtaCheck_;
0617 std::map<ME3IdsKey, bool> MEMap2AbsReWithEtaCheck_;
0618 std::map<ME3IdsKey, bool> MEMap3Check_;
0619 std::map<ME4IdsKey, bool> MEMap3WithChCheck_;
0620 std::map<ME4IdsKey, bool> MEMap4Check_;
0621
0622 int nMaxNumCh_;
0623 std::map<ME3IdsKey, int> mapStationToIdx_;
0624 std::map<ME3IdsKey, MEStationInfo> mapStationInfo_;
0625 };
0626
0627
0628 template <typename T>
0629 inline bool GEMDQMBase::checkRefs(const std::vector<T *> &refs) {
0630 if (refs.empty())
0631 return false;
0632 if (refs.front() == nullptr)
0633 return false;
0634 return true;
0635 }
0636
0637
0638 inline int GEMDQMBase::getMaxVFAT(const int station) {
0639 if (station == 0)
0640 return GEMeMap::maxVFatGE0_;
0641 if (station == 1)
0642 return GEMeMap::maxVFatGE11_;
0643 else if (station == 2)
0644 return GEMeMap::maxVFatGE21_ / 2;
0645 else
0646 return -1;
0647 }
0648
0649 inline int GEMDQMBase::getNumModule(const int station) {
0650 if (station == 0)
0651 return 1;
0652 if (station == 1)
0653 return 1;
0654 else if (station == 2)
0655 return 4;
0656 else
0657 return -1;
0658 }
0659
0660 inline int GEMDQMBase::getIdxModule(const int station, const int chamberType) {
0661 if (station == 0)
0662 return 1;
0663 if (station == 1)
0664 return 1;
0665 else if (station == 2)
0666 return chamberType - 20;
0667 else
0668 return -1;
0669 }
0670
0671 inline int GEMDQMBase::getVFATNumber(const int station, const int ieta, const int vfat_phi) {
0672 if (station == 1)
0673 return getVFATNumberGE11(station, ieta, vfat_phi);
0674 return getVFATNumberGE11(station, ieta, vfat_phi);
0675 }
0676
0677 inline int GEMDQMBase::getVFATNumberGE11(const int station, const int ieta, const int vfat_phi) {
0678 return vfat_phi * GEMeMap::maxiEtaIdGE11_ + (GEMeMap::maxiEtaIdGE11_ - ieta);
0679 }
0680
0681 inline int GEMDQMBase::getVFATNumberByDigi(const int station, const int ieta, const int digi) {
0682 const int vfat_phi = digi / GEMeMap::maxChan_;
0683 return getVFATNumber(station, ieta, vfat_phi);
0684 }
0685
0686 inline int GEMDQMBase::getIEtaFromVFAT(const int station, const int vfat) {
0687 if (station == 0)
0688 return getIEtaFromVFATGE0(vfat);
0689 if (station == 1)
0690 return getIEtaFromVFATGE11(vfat);
0691 if (station == 2)
0692 return getIEtaFromVFATGE21(vfat);
0693 return getIEtaFromVFATGE11(vfat);
0694 }
0695
0696 inline int GEMDQMBase::getIEtaFromVFATGE0(const int vfat) {
0697 return GEMeMap::maxiEtaIdGE0_ - (vfat % GEMeMap::maxiEtaIdGE0_);
0698 }
0699
0700 inline int GEMDQMBase::getIEtaFromVFATGE11(const int vfat) {
0701 return GEMeMap::maxiEtaIdGE11_ - (vfat % GEMeMap::maxiEtaIdGE11_);
0702 }
0703
0704 inline int GEMDQMBase::getIEtaFromVFATGE21(const int vfat) {
0705 return GEMeMap::maxiEtaIdGE21_ - (vfat % GEMeMap::maxiEtaIdGE21_);
0706 }
0707
0708 inline int GEMDQMBase::getDetOccXBin(const int chamber, const int layer, const int n_chambers) {
0709 return n_chambers * (chamber - 1) + layer;
0710 }
0711
0712 inline Float_t GEMDQMBase::restrictAngle(const Float_t fTheta, const Float_t fStart) {
0713 Float_t fLoop = (fTheta - fStart) / (2 * M_PI);
0714 int nLoop = (fLoop >= 0 ? (int)fLoop : (int)fLoop - 1);
0715 return fTheta - nLoop * 2 * M_PI;
0716 }
0717
0718 inline std::string GEMDQMBase::getNameDirLayer(ME3IdsKey key3) {
0719 auto nStation = keyToStation(key3);
0720 char cRegion = (keyToRegion(key3) > 0 ? 'P' : 'M');
0721 auto nLayer = keyToLayer(key3);
0722 return std::string(Form("GE%i1-%c-L%i", nStation, cRegion, nLayer));
0723 }
0724
0725 #endif