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 }
14 
17  desc.add<edm::InputTag>("digisInputLabel", edm::InputTag("muonGEMDigis", ""));
18  desc.addUntracked<std::string>("runType", "online");
19  desc.addUntracked<std::string>("logCategory", "GEMDigiSource");
20  desc.add<int>("bxMin", -10);
21  desc.add<int>("bxMax", 10);
22  descriptions.add("GEMDigiSource", desc);
23 }
24 
26  //if (useDBEMap_)
27  if (true) {
28  const auto& chMap = iSetup.getData(gemChMapToken_);
29  auto gemChMap = std::make_unique<GEMChMap>(chMap);
30 
31  std::map<int, bool> mapCheckedType;
32  for (auto const& p : gemChMap->chamberMap()) {
33  auto& dc = p.second;
34  GEMDetId gemChId(dc.detId);
35  for (Int_t ieta = 1; ieta <= 24; ieta++) {
36  if (!gemChMap->isValidStrip(dc.chamberType, ieta, 1))
37  continue;
38  mapChamberType_[{gemChId.station(), gemChId.layer(), gemChId.chamber(), ieta}] = dc.chamberType;
39  if (mapCheckedType[dc.chamberType])
40  continue;
41  for (Int_t strip = 0; strip <= 3 * 128; strip++) {
42  if (!gemChMap->isValidStrip(dc.chamberType, ieta, strip))
43  continue;
44  auto& stripInfo = gemChMap->getChannel(dc.chamberType, ieta, strip);
45  mapStripToVFAT_[{dc.chamberType, ieta, strip}] = stripInfo.vfatAdd;
46  }
47  }
48  mapCheckedType[dc.chamberType] = true;
49  }
50  } else {
51  // no EMap in DB, using dummy
52  auto gemChMap = std::make_unique<GEMChMap>();
53  gemChMap->setDummy();
54 
55  std::map<int, bool> mapCheckedType;
56  for (auto const& p : gemChMap->chamberMap()) {
57  auto& dc = p.second;
58  GEMDetId gemChId(dc.detId);
59 
60  for (Int_t ieta = 1; ieta <= 24; ieta++) {
61  if (!gemChMap->isValidStrip(dc.chamberType, ieta, 1))
62  continue;
63  mapChamberType_[{gemChId.station(), gemChId.layer(), gemChId.chamber(), ieta}] = dc.chamberType;
64  if (mapCheckedType[dc.chamberType])
65  continue;
66  mapCheckedType[dc.chamberType] = true;
67  for (Int_t strip = 0; strip <= 3 * 128; strip++) {
68  if (!gemChMap->isValidStrip(dc.chamberType, ieta, strip))
69  continue;
70  auto& stripInfo = gemChMap->getChannel(dc.chamberType, ieta, strip);
71  mapStripToVFAT_[{dc.chamberType, ieta, strip}] = stripInfo.vfatAdd;
72  }
73  }
74  }
75  }
76 }
77 
79  initGeometry(iSetup);
80  if (GEMGeometry_ == nullptr)
81  return;
82  loadChambers();
83  LoadROMap(iSetup);
84 
85  strFolderMain_ = "GEM/Digis";
86 
87  fRadiusMin_ = 120.0;
88  fRadiusMax_ = 250.0;
89  float radS = -5.0 / 180 * M_PI;
90  float radL = 355.0 / 180 * M_PI;
91 
92  mapTotalDigi_layer_ = MEMap3Inf(this, "occ", "Digi Occupancy", 36, 0.5, 36.5, 24, -0.5, 24 - 0.5, "Chamber", "VFAT");
94  this, "occ_rphi", "Digi R-Phi Occupancy", 360, radS, radL, 8, fRadiusMin_, fRadiusMax_, "#phi (rad)", "R [cm]");
95  mapDigiOcc_ieta_ = MEMap3Inf(this, "occ_ieta", "Digi iEta Occupancy", 8, 0.5, 8.5, "iEta", "Number of fired digis");
97  MEMap3Inf(this, "occ_phi", "Digi Phi Occupancy", 72, -5, 355, "#phi (degree)", "Number of fired digis");
99  "digis_per_layer",
100  "Total number of digis per event for each layers",
101  50,
102  -0.5,
103  99.5,
104  "Number of fired digis",
105  "Events");
108  "digis_per_ieta",
109  "Total number of digis per event for each eta partitions",
110  50,
111  -0.5,
112  99.5,
113  "Number of fired digis",
114  "Events");
116 
117  mapBX_ = MEMap2Inf(this, "bx", "Digi Bunch Crossing", 21, nBXMin_ - 0.5, nBXMax_ + 0.5, "Bunch crossing");
118 
119  mapDigiOccPerCh_ = MEMap4Inf(this, "occ", "Digi Occupancy", 1, -0.5, 1.5, 1, 0.5, 1.5, "Digi", "iEta");
120 
123  mapBX_.TurnOff();
124  }
125 
130  }
131 
135  }
136 
140  }
141 
142  ibooker.cd();
144  GenerateMEPerChamber(ibooker);
145 }
146 
148  mapBX_.bookND(bh, key);
149 
150  return 0;
151 }
152 
155 
156  return 0;
157 }
158 
160  MEStationInfo& stationInfo = mapStationInfo_[key];
161 
162  Int_t nNewNumCh = stationInfo.nMaxIdxChamber_ - stationInfo.nMinIdxChamber_ + 1;
163  Int_t nNewMinIdxChamber = stationInfo.nNumModules_ * (stationInfo.nMinIdxChamber_ - 1) + 1;
164  Int_t nNewMaxIdxChamber = stationInfo.nNumModules_ * stationInfo.nMaxIdxChamber_;
165 
166  nNewNumCh *= stationInfo.nNumModules_;
167 
168  Int_t nNumVFATPerModule = stationInfo.nMaxVFAT_ / stationInfo.nNumModules_;
169 
170  int nNumVFATPerEta = stationInfo.nMaxVFAT_ / stationInfo.nNumEtaPartitions_;
171 
172  mapTotalDigi_layer_.SetBinConfX(nNewNumCh, nNewMinIdxChamber - 0.5, nNewMaxIdxChamber + 0.5);
173  mapTotalDigi_layer_.SetBinConfY(nNumVFATPerModule, -0.5);
175  mapTotalDigi_layer_.SetLabelForChambers(key, 1, -1, nNewMinIdxChamber, stationInfo.nNumModules_);
177 
180  mapDigiWheel_layer_.SetNbinsX(nNumVFATPerEta * stationInfo.nNumChambers_);
183 
187 
188  mapDigiOcc_phi_.SetBinLowEdgeX(stationInfo.fMinPhi_ * 180 / M_PI);
189  mapDigiOcc_phi_.SetBinHighEdgeX(stationInfo.fMinPhi_ * 180 / M_PI + 360);
192 
193  return 0;
194 }
195 
197  ME3IdsKey key3 = key4Tokey3(key);
198  MEStationInfo& stationInfo = mapStationInfo_[key3];
199 
200  bh.getBooker()->setCurrentFolder(strFolderMain_ + "/occupancy_" + getNameDirLayer(key3));
201 
202  int nNumVFATPerEta = stationInfo.nMaxVFAT_ / stationInfo.nNumEtaPartitions_;
203  int nNumCh = stationInfo.nNumDigi_;
204 
205  mapDigiOccPerCh_.SetBinConfX(nNumCh * nNumVFATPerEta, stationInfo.nFirstStrip_ - 0.5);
209 
211 
212  return 0;
213 }
214 
217  event.getByToken(this->tagDigi_, gemDigis);
219  event.getByToken(lumiScalers_, lumiScalers);
220 
221  std::map<ME3IdsKey, Int_t> total_digi_layer;
222  std::map<ME3IdsKey, Int_t> total_digi_eta;
223  for (auto gid : listChamberId_) {
224  ME2IdsKey key2{gid.region(), gid.station()};
225  ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
226  ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
227  std::map<Int_t, bool> bTagVFAT;
228  bTagVFAT.clear();
229  MEStationInfo& stationInfo = mapStationInfo_[key3];
230  const BoundPlane& surface = GEMGeometry_->idToDet(gid)->surface();
231  if (total_digi_layer.find(key3) == total_digi_layer.end())
232  total_digi_layer[key3] = 0;
233  for (auto iEta : mapEtaPartition_[gid]) {
234  GEMDetId eId = iEta->id();
235  ME3IdsKey key3IEta{gid.region(), gid.station(), eId.ieta()};
236  if (total_digi_eta.find(key3IEta) == total_digi_eta.end())
237  total_digi_eta[key3IEta] = 0;
238  const auto& digis_in_det = gemDigis->get(eId);
239  auto nChamberType = mapChamberType_[{gid.station(), gid.layer(), gid.chamber(), eId.ieta()}];
240  Int_t nIdxModule = getIdxModule(gid.station(), nChamberType);
241  Int_t nCh = (gid.chamber() - 1) * stationInfo.nNumModules_ + nIdxModule;
242  for (auto d = digis_in_det.first; d != digis_in_det.second; ++d) {
243  // Filling of digi occupancy
244  Int_t nIdxVFAT = mapStripToVFAT_[{nChamberType, eId.ieta(), d->strip()}];
245  mapTotalDigi_layer_.Fill(key3, nCh, nIdxVFAT);
246 
247  // Filling of digi
248  mapDigiOcc_ieta_.Fill(key3, eId.ieta()); // Eta (partition)
249 
250  GlobalPoint digi_global_pos = surface.toGlobal(iEta->centreOfStrip(d->strip()));
251  Float_t fPhi = (Float_t)digi_global_pos.phi();
252  Float_t fPhiShift = restrictAngle(fPhi, stationInfo.fMinPhi_);
253  Float_t fPhiDeg = fPhiShift * 180.0 / M_PI;
254  mapDigiOcc_phi_.Fill(key3, fPhiDeg); // Phi
255 
256  // Filling of R-Phi occupancy
257  Float_t fR = fRadiusMin_ + (fRadiusMax_ - fRadiusMin_) * (eId.ieta() - 0.5) / stationInfo.nNumEtaPartitions_;
258  mapDigiWheel_layer_.Fill(key3, fPhiShift, fR);
259 
260  mapDigiOccPerCh_.Fill(key4Ch, d->strip(), eId.ieta()); // Per chamber
261 
262  // For total digis
263  total_digi_layer[key3]++;
264  total_digi_eta[key3IEta]++;
265 
266  // Filling of bx
267  Int_t nBX = std::min(std::max((Int_t)d->bx(), nBXMin_), nBXMax_); // For under/overflow
268  if (bTagVFAT.find(nIdxVFAT) == bTagVFAT.end()) {
269  mapBX_.Fill(key2, nBX);
270  }
271 
272  bTagVFAT[nIdxVFAT] = true;
273  }
274  }
275  }
276  for (auto [key, num_total_digi] : total_digi_layer)
277  mapTotalDigiPerEvtLayer_.Fill(key, num_total_digi);
278  for (auto [key, num_total_digi] : total_digi_eta)
279  mapTotalDigiPerEvtIEta_.Fill(key, num_total_digi);
280 }
281 
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:481
Int_t nRunType_
Definition: GEMDQMBase.h:550
int getIdxModule(const int, const int)
Definition: GEMDQMBase.h:660
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
MEMap3Inf mapTotalDigiPerEvtLayer_
Definition: GEMDigiSource.h:66
std::vector< GEMDetId > listChamberId_
Definition: GEMDQMBase.h:612
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
MEMapInfT< MEMap3Ids, ME3IdsKey > MEMap3Inf
Definition: GEMDQMBase.h:480
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
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:76
MEMap3Inf mapDigiOcc_ieta_
Definition: GEMDigiSource.h:64
MEMap4Inf mapDigiOccPerCh_
Definition: GEMDigiSource.h:70
MEMap3Inf mapDigiOcc_phi_
Definition: GEMDigiSource.h:65
int SetLabelForVFATs(K key, Int_t nNumEtaPartitions, Int_t nAxis, Int_t nNumBin=-1)
Definition: GEMDQMBase.h:365
std::map< ME3IdsKey, MEStationInfo > mapStationInfo_
Definition: GEMDQMBase.h:624
int loadChambers()
Definition: GEMDQMBase.cc:56
edm::EDGetTokenT< LumiScalersCollection > lumiScalers_
Definition: GEMDigiSource.h:57
void SetBinHighEdgeX(Double_t dXH)
Definition: GEMDQMBase.h:266
std::string strFolderMain_
Definition: GEMDigiSource.h:72
constexpr int layer() const
Definition: GEMDetId.h:190
int Fill(K key, Double_t x)
Definition: GEMDQMBase.h:401
edm::EDGetToken tagDigi_
Definition: GEMDigiSource.h:55
MEMap3Inf mapTotalDigiPerEvtIEta_
Definition: GEMDigiSource.h:67
constexpr int chamber() const
Definition: GEMDetId.h:183
MEMap3Inf mapTotalDigi_layer_
Definition: GEMDigiSource.h:62
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MEMap2Inf mapBX_
Definition: GEMDigiSource.h:68
void SetBinLowEdgeX(Double_t dXL)
Definition: GEMDQMBase.h:264
int GenerateMEPerChamber(DQMStore::IBooker &ibooker)
Definition: GEMDQMBase.cc:180
Float_t restrictAngle(const Float_t fTheta, const Float_t fStart)
Definition: GEMDQMBase.h:712
Transition
Definition: Transition.h:12
const edm::ESGetToken< GEMChMap, GEMChMapRcd > gemChMapToken_
Definition: GEMDigiSource.h:53
MEMapInfT< MEMap2Ids, ME2IdsKey > MEMap2Inf
Definition: GEMDQMBase.h:479
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void SetNbinsY(Int_t nBinsY)
Definition: GEMDQMBase.h:270
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:609
int ProcessWithMEMap3WithChamber(BookingHelper &bh, ME4IdsKey key) override
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:59
void SetNoUnderOverflowBin()
Definition: GEMDQMBase.h:247
int SetLabelForIEta(K key, Int_t nAxis, Int_t nNumBin=-1)
Definition: GEMDQMBase.h:363
void add(std::string const &label, ParameterSetDescription const &psetDescription)
DQMStore::IBooker * getBooker()
Definition: GEMDQMBase.h:94
std::string getNameDirLayer(ME3IdsKey key3)
Definition: GEMDQMBase.h:718
int bookND(BookingHelper &bh, K key)
Definition: GEMDQMBase.h:307
ME3IdsKey key4Tokey3(ME4IdsKey key)
Definition: GEMDQMBase.h:583
std::map< GEMDetId, std::vector< const GEMEtaPartition * > > mapEtaPartition_
Definition: GEMDQMBase.h:613
HLT enums.
void SetNbinsX(Int_t nBinsX)
Definition: GEMDQMBase.h:262
std::tuple< Int_t, Int_t > ME2IdsKey
Float_t fRadiusMin_
Definition: GEMDigiSource.h:75
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
int SetLabelForChambers(K key, Int_t nAxis, Int_t nNumBin=-1, Int_t nIdxStart=1, Int_t nNumModules=1)
Definition: GEMDQMBase.h:337
Definition: event.py:1
Definition: Run.h:45
MEMap3Inf mapDigiWheel_layer_
Definition: GEMDigiSource.h:63
int ProcessWithMEMap3(BookingHelper &bh, ME3IdsKey key) override
std::map< ME3IdsKey, Int_t > mapStripToVFAT_
Definition: GEMDigiSource.h:60