CMS 3D CMS Logo

GEMDQMBase.cc
Go to the documentation of this file.
3 
4 using namespace std;
5 using namespace edm;
6 
8  log_category_ = cfg.getUntrackedParameter<std::string>("logCategory");
9 
10  nNumEtaPartitionGE0_ = 0;
11  nNumEtaPartitionGE11_ = 0;
12  nNumEtaPartitionGE21_ = 0;
13 }
14 
16  GEMGeometry_ = nullptr;
17  try {
19  iSetup.get<MuonGeometryRecord>().get(hGeom);
20  GEMGeometry_ = &*hGeom;
22  edm::LogError(log_category_) << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
23  return -1;
24  }
25 
26  return 0;
27 }
28 
29 // Borrowed from DQMOffline/Muon/src/GEMOfflineDQMBase.cc
31  const auto&& superchambers = station->superChambers();
32  if (not checkRefs(superchambers)) {
33  edm::LogError(log_category_) << "failed to get a valid vector of GEMSuperChamber ptrs" << std::endl;
34  return 0;
35  }
36 
37  const auto& chambers = superchambers.front()->chambers();
38  if (not checkRefs(chambers)) {
39  edm::LogError(log_category_) << "failed to get a valid vector of GEMChamber ptrs" << std::endl;
40  return 0;
41  }
42 
43  return chambers.front()->nEtaPartitions();
44 }
45 
47  if (GEMGeometry_ == nullptr)
48  return -1;
49  gemChambers_.clear();
50  const std::vector<const GEMSuperChamber*>& superChambers_ = GEMGeometry_->superChambers();
51  for (auto sch : superChambers_) { // FIXME: This loop can be merged into the below loop
52  int n_lay = sch->nChambers();
53  for (int l = 0; l < n_lay; l++) {
54  Bool_t bExist = false;
55  for (const auto& ch : gemChambers_) {
56  if (ch.id() == sch->chamber(l + 1)->id()) {
57  bExist = true;
58  break;
59  }
60  }
61  if (bExist)
62  continue;
63  gemChambers_.push_back(*sch->chamber(l + 1));
64  }
65  }
66 
67  // Borrwed from DQMOffline/Muon/src/GEMOfflineMonitor.cc
68  nMaxNumCh_ = 0;
69  for (const GEMRegion* region : GEMGeometry_->regions()) {
70  const int region_number = region->region();
71 
72  for (const GEMStation* station : region->stations()) {
73  const auto&& superchambers = station->superChambers();
74 
75  const int station_number = station->station();
76  const int num_superchambers = superchambers.size();
77  const int num_layers = superchambers.front()->nChambers();
78  const int max_vfat = getMaxVFAT(station->station()); // the number of VFATs per GEMEtaPartition
79  const int num_etas = getNumEtaPartitions(station); // the number of eta partitions per GEMChamber
80  const int num_vfat = num_etas * max_vfat; // the number of VFATs per GEMChamber
81  const int num_strip = GEMeMap::maxChan_; // the number of strips (channels) per VFAT
82 
83  nMaxNumCh_ = std::max(nMaxNumCh_, num_superchambers);
84 
85  for (int layer_number = 1; layer_number <= num_layers; layer_number++) {
86  ME3IdsKey key3(region_number, station_number, layer_number);
87  mapStationInfo_[key3] = MEStationInfo(
88  region_number, station_number, layer_number, num_superchambers, num_etas, num_vfat, num_strip);
89  }
90  }
91  }
92 
93  if (mapStationInfo_.find(ME3IdsKey(-1, 0, 1)) != mapStationInfo_.end())
94  nNumEtaPartitionGE0_ = mapStationInfo_[ME3IdsKey(-1, 0, 1)].nNumEtaPartitions_;
95  if (mapStationInfo_.find(ME3IdsKey(-1, 1, 1)) != mapStationInfo_.end())
96  nNumEtaPartitionGE11_ = mapStationInfo_[ME3IdsKey(-1, 1, 1)].nNumEtaPartitions_;
97  if (mapStationInfo_.find(ME3IdsKey(-1, 2, 1)) != mapStationInfo_.end())
98  nNumEtaPartitionGE21_ = mapStationInfo_[ME3IdsKey(-1, 2, 1)].nNumEtaPartitions_;
99 
100  return 0;
101 }
102 
103 int GEMDQMBase::SortingLayers(std::vector<ME3IdsKey>& listLayers) {
104  std::sort(listLayers.begin(), listLayers.end(), [](ME3IdsKey key1, ME3IdsKey key2) {
105  Int_t re1 = std::get<0>(key1), st1 = std::get<1>(key1), la1 = std::get<2>(key1);
106  Int_t re2 = std::get<0>(key2), st2 = std::get<1>(key2), la2 = std::get<2>(key2);
107  if (re1 < 0 && re2 > 0)
108  return false;
109  if (re1 > 0 && re2 < 0)
110  return true;
111  Bool_t bRes = (re1 < 0); // == re2 < 0
112  Int_t sum1 = 256 * std::abs(re1) + 16 * st1 + 1 * la1;
113  Int_t sum2 = 256 * std::abs(re2) + 16 * st2 + 1 * la2;
114  if (sum1 <= sum2)
115  return bRes;
116  return !bRes;
117  });
118 
119  return 0;
120 }
121 
123  std::vector<ME3IdsKey> listLayers;
124  for (auto const& [key, stationInfo] : mapStationInfo_)
125  listLayers.push_back(key);
126  SortingLayers(listLayers);
127  for (Int_t i = 0; i < (Int_t)listLayers.size(); i++)
128  mapStationToIdx_[listLayers[i]] = i + 1;
129 
130  auto h2Res =
131  ibooker.book2D(strName, "", nMaxNumCh_, 0.5, nMaxNumCh_ + 0.5, listLayers.size(), 0.5, listLayers.size() + 0.5);
132 
133  if (h2Res == nullptr)
134  return nullptr;
135 
136  for (Int_t i = 1; i <= nMaxNumCh_; i++)
137  h2Res->setBinLabel(i, Form("%i", i), 1);
138  for (Int_t i = 1; i <= (Int_t)listLayers.size(); i++) {
139  auto key = listLayers[i - 1];
140  auto strInfo = GEMUtils::getSuffixName(key); // NOTE: It starts with '_'
141  auto label = Form("GE%+i/%iL%i;%s", keyToRegion(key), keyToStation(key), keyToLayer(key), strInfo.Data());
142  h2Res->setBinLabel(i, label, 2);
143  Int_t nNumCh = mapStationInfo_[key].nNumChambers_;
144  h2Res->setBinContent(0, i, nNumCh);
145  }
146 
147  return h2Res;
148 }
149 
151  MEMap2Check_.clear();
152  MEMap3Check_.clear();
153  MEMap3WithChCheck_.clear();
154  MEMap4Check_.clear();
155  for (const auto& ch : gemChambers_) {
156  GEMDetId gid = ch.id();
157  ME2IdsKey key2{gid.region(), gid.station()};
158  ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
159  ME4IdsKey key3WithChamber{gid.region(), gid.station(), gid.layer(), gid.chamber()};
160  if (!MEMap2Check_[key2]) {
161  auto strSuffixName = GEMUtils::getSuffixName(key2);
162  auto strSuffixTitle = GEMUtils::getSuffixTitle(key2);
163  BookingHelper bh2(ibooker, strSuffixName, strSuffixTitle);
164  ProcessWithMEMap2(bh2, key2);
165  MEMap2Check_[key2] = true;
166  }
167  if (!MEMap3Check_[key3]) {
168  auto strSuffixName = GEMUtils::getSuffixName(key3);
169  auto strSuffixTitle = GEMUtils::getSuffixTitle(key3);
170  BookingHelper bh3(ibooker, strSuffixName, strSuffixTitle);
171  ProcessWithMEMap3(bh3, key3);
172  MEMap3Check_[key3] = true;
173  }
174  if (!MEMap3WithChCheck_[key3WithChamber]) {
175  auto strSuffixName = GEMUtils::getSuffixName(key3) + Form("_ch%02i", gid.chamber());
176  auto strSuffixTitle = GEMUtils::getSuffixTitle(key3) + Form(" Chamber %02i", gid.chamber());
177  BookingHelper bh3Ch(ibooker, strSuffixName, strSuffixTitle);
178  ProcessWithMEMap3WithChamber(bh3Ch, key3WithChamber);
179  MEMap3WithChCheck_[key3WithChamber] = true;
180  }
181  for (auto iEta : ch.etaPartitions()) {
182  GEMDetId rId = iEta->id();
183  ME4IdsKey key4{gid.region(), gid.station(), gid.layer(), rId.ieta()};
184  if (!MEMap4Check_[key4]) {
185  auto strSuffixName = GEMUtils::getSuffixName(key3) + Form("_ieta%02i", rId.ieta());
186  auto strSuffixTitle = GEMUtils::getSuffixTitle(key3) + Form(" iEta %02i", rId.ieta());
187  BookingHelper bh4(ibooker, strSuffixName, strSuffixTitle);
188  ProcessWithMEMap4(bh4, key4);
189  MEMap4Check_[key4] = true;
190  }
191  }
192  }
193  return 0;
194 }
ME2IdsKey
std::tuple< Int_t, Int_t > ME2IdsKey
Definition: GEMValidationUtils.h:16
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
mps_fire.i
i
Definition: mps_fire.py:428
GEMDetId::layer
constexpr int layer() const
Definition: GEMDetId.h:190
GEMDQMBase::MEStationInfo
Definition: GEMDQMBase.h:340
GEMDetId::region
constexpr int region() const
Definition: GEMDetId.h:171
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
ME4IdsKey
std::tuple< Int_t, Int_t, Int_t, Int_t > ME4IdsKey
Definition: GEMValidationUtils.h:20
GEMStripTopology.h
GEMDQMBase::SortingLayers
int SortingLayers(std::vector< ME3IdsKey > &listLayers)
Definition: GEMDQMBase.cc:103
GEMUtils::getSuffixName
TString getSuffixName(Int_t region_id)
Definition: GEMValidationUtils.cc:5
GEMDQMBase::BookingHelper
Definition: GEMDQMBase.h:32
GEMDQMBase.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
GEMDQMBase::GEMDQMBase
GEMDQMBase(const edm::ParameterSet &cfg)
Definition: GEMDQMBase.cc:7
GEMStation
Definition: GEMStation.h:19
edm::ESHandle< GEMGeometry >
GEMDQMBase::CreateSummaryHist
dqm::impl::MonitorElement * CreateSummaryHist(DQMStore::IBooker &ibooker, TString strName)
Definition: GEMDQMBase.cc:122
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GEMDetId::chamber
constexpr int chamber() const
Definition: GEMDetId.h:183
GEMDQMBase::initGeometry
int initGeometry(edm::EventSetup const &iSetup)
Definition: GEMDQMBase.cc:15
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
GEMDetId
Definition: GEMDetId.h:18
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88271
dqm::impl::MonitorElement::setBinLabel
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:771
chambers
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
combinedConstraintHelpers::sum2
void sum2(T &x, T y)
Definition: CombinedKinematicConstraintT.h:74
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
looper.cfg
cfg
Definition: looper.py:297
GEMDQMBase::loadChambers
int loadChambers()
Definition: GEMDQMBase.cc:46
std
Definition: JetResolutionObject.h:76
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
GEMUtils::getSuffixTitle
TString getSuffixTitle(Int_t region_id)
Definition: GEMValidationUtils.cc:34
ME3IdsKey
std::tuple< Int_t, Int_t, Int_t > ME3IdsKey
Definition: GEMValidationUtils.h:19
dqm::implementation::IBooker
Definition: DQMStore.h:43
edm::eventsetup::NoProxyException
Definition: NoProxyException.h:31
L1TowerCalibrationProducer_cfi.iEta
iEta
Definition: L1TowerCalibrationProducer_cfi.py:60
GEMDetId::station
constexpr int station() const
Definition: GEMDetId.h:179
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GEMRegion
Definition: GEMRegion.h:19
GEMDetId::ieta
constexpr int ieta() const
Definition: GEMDetId.h:199
GEMDQMBase::getNumEtaPartitions
int getNumEtaPartitions(const GEMStation *)
Definition: GEMDQMBase.cc:30
crabWrapper.key
key
Definition: crabWrapper.py:19
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
label
const char * label
Definition: PFTauDecayModeTools.cc:11
GEMeMap::maxChan_
static const int maxChan_
Definition: GEMeMap.h:69
GEMDQMBase::GenerateMEPerChamber
int GenerateMEPerChamber(DQMStore::IBooker &ibooker)
Definition: GEMDQMBase.cc:150
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37