CMS 3D CMS Logo

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