CMS 3D CMS Logo

GEMDigiSource.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace edm;
5 
8  tagDigi_ = consumes<GEMDigiCollection>(cfg.getParameter<edm::InputTag>("digisInputLabel"));
9  lumiScalers_ = consumes<LumiScalersCollection>(
10  cfg.getUntrackedParameter<edm::InputTag>("lumiCollection", edm::InputTag("scalersRawToDigi")));
11  nBXMin_ = cfg.getParameter<int>("bxMin");
12  nBXMax_ = cfg.getParameter<int>("bxMax");
13  useDBEMap_ = cfg.getParameter<bool>("useDBEMap");
14 }
15 
18  desc.add<edm::InputTag>("digisInputLabel", edm::InputTag("muonGEMDigis", ""));
19  desc.addUntracked<std::string>("runType", "online");
20  desc.addUntracked<std::string>("logCategory", "GEMDigiSource");
21  desc.add<int>("bxMin", -10);
22  desc.add<int>("bxMax", 10);
23  desc.add<bool>("useDBEMap", true);
24  descriptions.add("GEMDigiSource", desc);
25 }
26 
28  if (useDBEMap_) {
29  const auto& chMap = iSetup.getData(gemChMapToken_);
30  auto gemChMap = std::make_unique<GEMChMap>(chMap);
31 
32  std::map<int, bool> mapCheckedType;
33  for (auto const& p : gemChMap->chamberMap()) {
34  auto& dc = p.second;
35  GEMDetId gemChId(dc.detId);
36  for (Int_t ieta = 1; ieta <= 24; ieta++) {
37  if (!gemChMap->isValidStrip(dc.chamberType, ieta, 1))
38  continue;
39  mapChamberType_[{gemChId.station(), gemChId.layer(), gemChId.chamber(), ieta}] = dc.chamberType;
40  if (mapCheckedType[dc.chamberType])
41  continue;
42  for (Int_t strip = 0; strip <= 3 * 128; strip++) {
43  if (!gemChMap->isValidStrip(dc.chamberType, ieta, strip))
44  continue;
45  auto& stripInfo = gemChMap->getChannel(dc.chamberType, ieta, strip);
46  mapStripToVFAT_[{dc.chamberType, ieta, strip}] = stripInfo.vfatAdd;
47  }
48  }
49  mapCheckedType[dc.chamberType] = true;
50  }
51  } else {
52  // no EMap in DB, using dummy
53  auto gemChMap = std::make_unique<GEMChMap>();
54  gemChMap->setDummy();
55 
56  std::map<int, bool> mapCheckedType;
57  for (auto const& p : gemChMap->chamberMap()) {
58  auto& dc = p.second;
59  GEMDetId gemChId(dc.detId);
60 
61  for (Int_t ieta = 1; ieta <= 24; ieta++) {
62  if (!gemChMap->isValidStrip(dc.chamberType, ieta, 1))
63  continue;
64  Int_t nChamberType = dc.chamberType;
65  if (gemChId.station() == 1) {
66  nChamberType = 13 - gemChId.layer();
67  } else if (gemChId.station() == 2) {
68  nChamberType = 24 - (ieta - 1) / 4;
69  }
70  mapChamberType_[{gemChId.station(), gemChId.layer(), gemChId.chamber(), ieta}] = nChamberType;
71  if (mapCheckedType[nChamberType])
72  continue;
73  mapCheckedType[nChamberType] = true;
74  for (Int_t strip = 0; strip <= 3 * 128; strip++) {
75  if (!gemChMap->isValidStrip(nChamberType, ieta, strip))
76  continue;
77  auto& stripInfo = gemChMap->getChannel(nChamberType, ieta, strip);
78  mapStripToVFAT_[{nChamberType, ieta, strip}] = stripInfo.vfatAdd;
79  }
80  }
81  }
82  }
83 }
84 
86  initGeometry(iSetup);
87  if (GEMGeometry_ == nullptr)
88  return;
89  loadChambers();
90  LoadROMap(iSetup);
91 
92  strFolderMain_ = "GEM/Digis";
93 
94  fRadiusMin_ = 120.0;
95  fRadiusMax_ = 250.0;
96  float radS = -5.0 / 180 * M_PI;
97  float radL = 355.0 / 180 * M_PI;
98 
99  mapTotalDigi_layer_ = MEMap4Inf(this, "occ", "Digi Occupancy", 36, 0.5, 36.5, 24, -0.5, 24 - 0.5, "Chamber", "VFAT");
101  this, "occ_rphi", "Digi R-Phi Occupancy", 360, radS, radL, 8, fRadiusMin_, fRadiusMax_, "#phi (rad)", "R [cm]");
102  mapDigiOcc_ieta_ = MEMap4Inf(this, "occ_ieta", "Digi iEta Occupancy", 8, 0.5, 8.5, "iEta", "Number of fired digis");
104  MEMap4Inf(this, "occ_phi", "Digi Phi Occupancy", 72, -5, 355, "#phi (degree)", "Number of fired digis");
106  "digis_per_layer",
107  "Total number of digis per event for each layers",
108  50,
109  -0.5,
110  99.5,
111  "Number of fired digis",
112  "Events");
115  "digis_per_ieta",
116  "Total number of digis per event for each eta partitions",
117  50,
118  -0.5,
119  99.5,
120  "Number of fired digis",
121  "Events");
123 
124  mapBX_ = MEMap2Inf(this, "bx", "Digi Bunch Crossing", 21, nBXMin_ - 0.5, nBXMax_ + 0.5, "Bunch crossing");
125 
126  mapDigiOccPerCh_ = MEMap5Inf(this, "occ", "Digi Occupancy", 1, -0.5, 1.5, 1, 0.5, 1.5, "Digi", "iEta");
127 
130  mapBX_.TurnOff();
131  }
132 
137  }
138 
142  }
143 
147  }
148 
149  ibooker.cd();
151  GenerateMEPerChamber(ibooker);
152 }
153 
155  mapBX_.bookND(bh, key);
156 
157  return 0;
158 }
159 
162 
163  return 0;
164 }
165 
167  MEStationInfo& stationInfo = mapStationInfo_[key];
168 
169  int nNumVFATPerEta = stationInfo.nMaxVFAT_ / stationInfo.nNumEtaPartitions_;
170 
173  mapDigiWheel_layer_.SetNbinsX(nNumVFATPerEta * stationInfo.nNumChambers_);
176 
177  return 0;
178 }
179 
181  ME3IdsKey key3 = key4Tokey3(key);
182  MEStationInfo& stationInfo = mapStationInfo_[key3];
183 
184  Int_t nNewNumCh = stationInfo.nMaxIdxChamber_ - stationInfo.nMinIdxChamber_ + 1;
185  Int_t nNewMinIdxChamber = (stationInfo.nMinIdxChamber_ - 1) + 1;
186  Int_t nNewMaxIdxChamber = stationInfo.nMaxIdxChamber_;
187 
188  Int_t nNumVFATPerModule = stationInfo.nMaxVFAT_ / stationInfo.nNumModules_;
189 
190  mapTotalDigi_layer_.SetBinConfX(nNewNumCh, nNewMinIdxChamber - 0.5, nNewMaxIdxChamber + 0.5);
191  mapTotalDigi_layer_.SetBinConfY(nNumVFATPerModule, -0.5);
193  mapTotalDigi_layer_.SetLabelForChambers(key, 1, -1, nNewMinIdxChamber);
195 
199 
200  mapDigiOcc_phi_.SetBinLowEdgeX(stationInfo.fMinPhi_ * 180 / M_PI);
201  mapDigiOcc_phi_.SetBinHighEdgeX(stationInfo.fMinPhi_ * 180 / M_PI + 360);
204 
205  return 0;
206 }
207 
209  ME4IdsKey key4 = key5Tokey4(key);
210  ME3IdsKey key3 = key4Tokey3(key4);
211  MEStationInfo& stationInfo = mapStationInfo_[key3];
212 
213  bh.getBooker()->setCurrentFolder(strFolderMain_ + "/occupancy_" + getNameDirLayer(key4));
214 
215  int nNumVFATPerEta = stationInfo.nMaxVFAT_ / stationInfo.nNumEtaPartitions_;
216  int nNumCh = stationInfo.nNumDigi_;
217 
218  mapDigiOccPerCh_.SetBinConfX(nNumCh * nNumVFATPerEta, stationInfo.nFirstStrip_ - 0.5);
219  mapDigiOccPerCh_.SetBinConfY(stationInfo.nNumEtaPartitions_ / stationInfo.nNumModules_);
222 
224 
225  return 0;
226 }
227 
230  event.getByToken(this->tagDigi_, gemDigis);
232  event.getByToken(lumiScalers_, lumiScalers);
233 
234  std::map<ME4IdsKey, Int_t> total_digi_layer;
235  std::map<ME3IdsKey, Int_t> total_digi_eta;
236  for (auto gid : listChamberId_) {
237  ME2IdsKey key2{gid.region(), gid.station()};
238  ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
239  ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
240  std::map<Int_t, bool> bTagVFAT;
241  bTagVFAT.clear();
242  MEStationInfo& stationInfo = mapStationInfo_[key3];
243  const BoundPlane& surface = GEMGeometry_->idToDet(gid)->surface();
244  for (auto iEta : mapEtaPartition_[gid]) {
245  GEMDetId eId = iEta->id();
246  ME3IdsKey key3IEta{gid.region(), gid.station(), eId.ieta()};
247  if (total_digi_eta.find(key3IEta) == total_digi_eta.end())
248  total_digi_eta[key3IEta] = 0;
249  const auto& digis_in_det = gemDigis->get(eId);
250  auto nChamberType = mapChamberType_[{gid.station(), gid.layer(), gid.chamber(), eId.ieta()}];
251  Int_t nIdxModule = getIdxModule(gid.station(), nChamberType);
252  ME4IdsKey key4{gid.region(), gid.station(), gid.layer(), nIdxModule};
253  ME5IdsKey key5Ch{gid.region(), gid.station(), gid.layer(), nIdxModule, gid.chamber()};
254  if (total_digi_layer.find(key4) == total_digi_layer.end())
255  total_digi_layer[key4] = 0;
256  for (auto d = digis_in_det.first; d != digis_in_det.second; ++d) {
257  // Filling of digi occupancy
258  Int_t nIdxVFAT = mapStripToVFAT_[{nChamberType, eId.ieta(), d->strip()}];
259  mapTotalDigi_layer_.Fill(key4, gid.chamber(), nIdxVFAT);
260 
261  // Filling of digi
262  mapDigiOcc_ieta_.Fill(key4, eId.ieta()); // Eta (partition)
263 
264  GlobalPoint digi_global_pos = surface.toGlobal(iEta->centreOfStrip(d->strip()));
265  Float_t fPhi = (Float_t)digi_global_pos.phi();
266  Float_t fPhiShift = restrictAngle(fPhi, stationInfo.fMinPhi_);
267  Float_t fPhiDeg = fPhiShift * 180.0 / M_PI;
268  mapDigiOcc_phi_.Fill(key4, fPhiDeg); // Phi
269 
270  // Filling of R-Phi occupancy
271  Float_t fR = fRadiusMin_ + (fRadiusMax_ - fRadiusMin_) * (eId.ieta() - 0.5) / stationInfo.nNumEtaPartitions_;
272  mapDigiWheel_layer_.Fill(key3, fPhiShift, fR);
273 
274  Int_t nIEtaInMod = eId.ieta();
275  if (gid.station() == 2) {
276  nIEtaInMod = (eId.ieta() - 1) % stationInfo.nNumModules_ + 1;
277  }
278  mapDigiOccPerCh_.Fill(key5Ch, d->strip(), nIEtaInMod); // Per chamber
279 
280  // For total digis
281  total_digi_layer[key4]++;
282  total_digi_eta[key3IEta]++;
283 
284  // Filling of bx
285  Int_t nBX = std::min(std::max((Int_t)d->bx(), nBXMin_), nBXMax_); // For under/overflow
286  if (bTagVFAT.find(nIdxVFAT) == bTagVFAT.end()) {
287  mapBX_.Fill(key2, nBX);
288  }
289 
290  bTagVFAT[nIdxVFAT] = true;
291  }
292  }
293  }
294  for (auto [key, num_total_digi] : total_digi_layer)
295  mapTotalDigiPerEvtLayer_.Fill(key, num_total_digi);
296  for (auto [key, num_total_digi] : total_digi_eta)
297  mapTotalDigiPerEvtIEta_.Fill(key, num_total_digi);
298 }
299 
MEMap4Inf mapTotalDigi_layer_
Definition: GEMDigiSource.h:65
int ProcessWithMEMap2WithEta(BookingHelper &bh, ME3IdsKey key) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr int station() const
Definition: GEMDetId.h:179
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
MEMapInfT< MEMap4Ids, ME4IdsKey > MEMap4Inf
Definition: GEMDQMBase.h:475
Int_t nRunType_
Definition: GEMDQMBase.h:545
int getIdxModule(const int, const int)
Definition: GEMDQMBase.h:688
int ProcessWithMEMap5WithChamber(BookingHelper &bh, ME5IdsKey key) override
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::tuple< Int_t, Int_t, Int_t, Int_t, Int_t > ME5IdsKey
std::vector< GEMDetId > listChamberId_
Definition: GEMDQMBase.h:632
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
int SetLabelForChambers(K key, Int_t nAxis, Int_t nNumBin=-1, Int_t nIdxStart=1)
Definition: GEMDQMBase.h:337
MEMapInfT< MEMap3Ids, ME3IdsKey > MEMap3Inf
Definition: GEMDQMBase.h:474
int ProcessWithMEMap2(BookingHelper &bh, ME2IdsKey key) override
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
int initGeometry(edm::EventSetup const &iSetup)
Definition: GEMDQMBase.cc:27
std::tuple< Int_t, Int_t, Int_t, Int_t > ME4IdsKey
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:25
Float_t fRadiusMax_
Definition: GEMDigiSource.h:80
int SetLabelForVFATs(K key, Int_t nNumEtaPartitions, Int_t nAxis, Int_t nNumBin=-1)
Definition: GEMDQMBase.h:359
std::map< ME3IdsKey, MEStationInfo > mapStationInfo_
Definition: GEMDQMBase.h:651
int loadChambers()
Definition: GEMDQMBase.cc:56
edm::EDGetTokenT< LumiScalersCollection > lumiScalers_
Definition: GEMDigiSource.h:58
void SetBinHighEdgeX(Double_t dXH)
Definition: GEMDQMBase.h:266
std::string strFolderMain_
Definition: GEMDigiSource.h:74
constexpr int layer() const
Definition: GEMDetId.h:190
int Fill(K key, Double_t x)
Definition: GEMDQMBase.h:395
edm::EDGetToken tagDigi_
Definition: GEMDigiSource.h:56
MEMap3Inf mapTotalDigiPerEvtIEta_
Definition: GEMDigiSource.h:69
constexpr int chamber() const
Definition: GEMDetId.h:183
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MEMap2Inf mapBX_
Definition: GEMDigiSource.h:70
int ProcessWithMEMap4(BookingHelper &bh, ME4IdsKey key) override
void SetBinLowEdgeX(Double_t dXL)
Definition: GEMDQMBase.h:264
int GenerateMEPerChamber(DQMStore::IBooker &ibooker)
Definition: GEMDQMBase.cc:195
Float_t restrictAngle(const Float_t fTheta, const Float_t fStart)
Definition: GEMDQMBase.h:740
MEMap4Inf mapTotalDigiPerEvtLayer_
Definition: GEMDigiSource.h:68
Transition
Definition: Transition.h:12
const edm::ESGetToken< GEMChMap, GEMChMapRcd > gemChMapToken_
Definition: GEMDigiSource.h:54
key
prepare the HTCondor submission files and eventually submit them
MEMapInfT< MEMap2Ids, ME2IdsKey > MEMap2Inf
Definition: GEMDQMBase.h:473
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void SetNbinsY(Int_t nBinsY)
Definition: GEMDQMBase.h:270
float fPhi(int hwPhi)
Definition: conversion.h:18
GEMDigiSource(const edm::ParameterSet &cfg)
Definition: GEMDigiSource.cc:6
d
Definition: ztail.py:151
#define M_PI
constexpr int ieta() const
Definition: GEMDetId.h:199
const GEMGeometry * GEMGeometry_
Definition: GEMDQMBase.h:629
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
void LoadROMap(edm::EventSetup const &iSetup)
std::map< ME4IdsKey, Int_t > mapChamberType_
Definition: GEMDigiSource.h:60
void SetNoUnderOverflowBin()
Definition: GEMDQMBase.h:247
MEMap4Inf mapDigiOcc_phi_
Definition: GEMDigiSource.h:67
int SetLabelForIEta(K key, Int_t nAxis, Int_t nNumBin=-1)
Definition: GEMDQMBase.h:357
MEMap4Inf mapDigiOcc_ieta_
Definition: GEMDigiSource.h:66
void add(std::string const &label, ParameterSetDescription const &psetDescription)
DQMStore::IBooker * getBooker()
Definition: GEMDQMBase.h:94
std::string getNameDirLayer(ME3IdsKey key3)
Definition: GEMDQMBase.h:746
int bookND(BookingHelper &bh, K key)
Definition: GEMDQMBase.h:307
ME3IdsKey key4Tokey3(ME4IdsKey key)
Definition: GEMDQMBase.h:596
std::map< GEMDetId, std::vector< const GEMEtaPartition * > > mapEtaPartition_
Definition: GEMDQMBase.h:633
HLT enums.
MEMapInfT< MEMap5Ids, ME5IdsKey > MEMap5Inf
Definition: GEMDQMBase.h:476
void SetNbinsX(Int_t nBinsX)
Definition: GEMDQMBase.h:262
MEMap5Inf mapDigiOccPerCh_
Definition: GEMDigiSource.h:72
std::tuple< Int_t, Int_t > ME2IdsKey
Float_t fRadiusMin_
Definition: GEMDigiSource.h:79
std::tuple< Int_t, Int_t, Int_t > ME3IdsKey
void SetBinConfX(Int_t nBins, Double_t dL=0.5, Double_t dH=-1048576.0)
Definition: GEMDQMBase.h:281
void SetBinConfY(Int_t nBins, Double_t dL=0.5, Double_t dH=-1048576.0)
Definition: GEMDQMBase.h:289
Bool_t useDBEMap_
Definition: GEMDigiSource.h:76
Definition: event.py:1
Definition: Run.h:45
ME4IdsKey key5Tokey4(ME5IdsKey key)
Definition: GEMDQMBase.h:601
MEMap3Inf mapDigiWheel_layer_
Definition: GEMDigiSource.h:63
int ProcessWithMEMap3(BookingHelper &bh, ME3IdsKey key) override
std::map< ME3IdsKey, Int_t > mapStripToVFAT_
Definition: GEMDigiSource.h:61