CMS 3D CMS Logo

GEMRecHitSource.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace edm;
5 
7  tagRecHit_ = consumes<GEMRecHitCollection>(cfg.getParameter<edm::InputTag>("recHitsInputLabel"));
8 
9  nIdxFirstDigi_ = cfg.getParameter<int>("idxFirstDigi");
10  nNumDivideEtaPartitionInRPhi_ = cfg.getParameter<int>("numDivideEtaPartitionInRPhi");
11  nCLSMax_ = cfg.getParameter<int>("clsMax");
12  nClusterSizeBinNum_ = cfg.getParameter<int>("ClusterSizeBinNum");
13 }
14 
17  desc.add<edm::InputTag>("recHitsInputLabel", edm::InputTag("gemRecHits", ""));
18  desc.addUntracked<std::string>("runType", "online");
19 
20  desc.add<int>("idxFirstDigi", 0);
21  desc.add<int>("numDivideEtaPartitionInRPhi", 10);
22  desc.add<int>("clsMax", 10);
23  desc.add<int>("ClusterSizeBinNum", 9);
24 
25  desc.addUntracked<std::string>("logCategory", "GEMRecHitSource");
26 
27  descriptions.add("GEMRecHitSource", desc);
28 }
29 
31  std::vector<GEMDetId> listLayerOcc;
32 
33  initGeometry(iSetup);
34  if (GEMGeometry_ == nullptr)
35  return;
36  loadChambers();
37 
38  strFolderMain_ = "GEM/RecHits";
39 
40  ibooker.cd();
42 
44  MEMap3Inf(this, "occ_xy", "RecHit xy Occupancy", 160, -250, 250, 160, -250, 250, "X [cm]", "Y [cm]");
45  mapRecHitOcc_ieta_ = MEMap3Inf(this, "occ_ieta", "RecHit iEta Occupancy", 8, 0.5, 8.5, "iEta", "Number of RecHits");
47  MEMap3Inf(this, "occ_phi", "RecHit Phi Occupancy", 72, -5, 355, "#phi (degree)", "Number of RecHits");
49  "rechits_per_layer",
50  "Total number of RecHits per event for each layers",
51  2000,
52  -0.5,
53  2000 - 0.5,
54  "Number of RecHits",
55  "Events");
58  "rechits_per_ieta",
59  "Total number of RecHits per event for each eta partitions",
60  300,
61  -0.5,
62  300 - 0.5,
63  "Number of RecHits",
64  "Events");
67  this, "cls", "Cluster size of RecHits", nCLSMax_, 0.5, nCLSMax_ + 0.5, "Cluster size", "Number of RecHits");
68  mapCLSAverage_ = MEMap3Inf(this, // TProfile2D
69  "rechit_average",
70  "Average of Cluster Sizes",
71  36,
72  0.5,
73  36.5,
74  8,
75  0.5,
76  8.5,
77  0,
78  400, // For satefy, larger than 384
79  "Chamber",
80  "iEta");
82  this, "largeCls_occ", "Occupancy of Large Clusters (>5)", 36, 0.5, 36.5, 8, 0.5, 8.5, "Chamber", "iEta");
83 
85  this, "cls", "Cluster size of RecHits", nCLSMax_, 0.5, nCLSMax_ + 0.5, 1, 0.5, 1.5, "Cluster size", "iEta");
86 
90  }
91 
97  }
98 
103  }
104 
108  }
109 
110  GenerateMEPerChamber(ibooker);
111 }
112 
115 
116  return 0;
117 }
118 
121 
122  return 0;
123 }
124 
126  MEStationInfo& stationInfo = mapStationInfo_[key];
127 
128  Float_t fR1 = !stationInfo.listRadiusEvenChamber_.empty() ? stationInfo.listRadiusEvenChamber_.back() : 0.0;
129  Float_t fR2 = !stationInfo.listRadiusOddChamber_.empty() ? stationInfo.listRadiusOddChamber_.back() : 0.0;
130  Float_t fRangeRadius = (int)(std::max(fR1, fR2) * 0.11 + 0.99999) * 10.0;
131 
132  mapRecHitXY_layer_.SetBinLowEdgeX(-fRangeRadius);
133  mapRecHitXY_layer_.SetBinHighEdgeX(fRangeRadius);
134  mapRecHitXY_layer_.SetBinLowEdgeY(-fRangeRadius);
135  mapRecHitXY_layer_.SetBinHighEdgeY(fRangeRadius);
137 
138  Int_t nNumEta = stationInfo.nNumEtaPartitions_;
139  if (stationInfo.nNumModules_ > 1) {
140  nNumEta = stationInfo.nNumModules_;
141  }
145 
146  mapRecHitOcc_phi_.SetBinLowEdgeX(stationInfo.fMinPhi_ * 180 / M_PI);
147  mapRecHitOcc_phi_.SetBinHighEdgeX(stationInfo.fMinPhi_ * 180 / M_PI + 360);
149 
151 
152  Int_t nNewNumCh = stationInfo.nMaxIdxChamber_ - stationInfo.nMinIdxChamber_ + 1;
153 
154  mapCLSAverage_.SetBinConfX(nNewNumCh, stationInfo.nMinIdxChamber_ - 0.5, stationInfo.nMaxIdxChamber_ + 0.5);
155  mapCLSAverage_.SetBinConfY(nNumEta, 0.5);
159 
160  mapCLSOver5_.SetBinConfX(nNewNumCh, stationInfo.nMinIdxChamber_ - 0.5, stationInfo.nMaxIdxChamber_ + 0.5);
161  mapCLSOver5_.SetBinConfY(nNumEta, 0.5);
162  mapCLSOver5_.bookND(bh, key);
165 
166  if (keyToStation(key) == 2) {
167  if (mapCLSAverage_.isOperating()) {
168  mapCLSAverage_.FindHist(key)->setYTitle("Module");
169  }
170  if (mapCLSOver5_.isOperating()) {
171  mapCLSOver5_.FindHist(key)->setYTitle("Module");
172  }
173  for (Int_t i = 1; i <= stationInfo.nNumModules_; i++) {
174  std::string strLabel = std::string(Form("M%i", i));
175  if (mapCLSAverage_.isOperating()) {
176  mapCLSAverage_.FindHist(key)->setBinLabel(i, strLabel, 2);
177  }
178  if (mapCLSOver5_.isOperating()) {
179  mapCLSOver5_.FindHist(key)->setBinLabel(i, strLabel, 2);
180  }
181  }
182  }
183 
184  return 0;
185 }
186 
188  ME3IdsKey key3 = key4Tokey3(key);
189  MEStationInfo& stationInfo = mapStationInfo_[key3];
190 
191  bh.getBooker()->setCurrentFolder(strFolderMain_ + "/clusterSize_" + getNameDirLayer(key3));
192 
193  Int_t nNumEta = stationInfo.nNumEtaPartitions_;
194  if (stationInfo.nNumModules_ > 1) {
195  nNumEta = stationInfo.nNumModules_;
196  }
197 
198  mapCLSPerCh_.SetBinConfY(nNumEta, 0.5);
199  mapCLSPerCh_.bookND(bh, key);
201 
202  if (keyToStation(key) == 2) {
203  if (mapCLSPerCh_.isOperating()) {
204  mapCLSPerCh_.FindHist(key)->setYTitle("Module");
205  }
206  for (Int_t i = 1; i <= stationInfo.nNumModules_; i++) {
207  std::string strLabel = std::string(Form("M%i", i));
208  if (mapCLSPerCh_.isOperating()) {
209  mapCLSPerCh_.FindHist(key)->setBinLabel(i, strLabel, 2);
210  }
211  }
212  }
213 
215 
216  return 0;
217 }
218 
221  event.getByToken(this->tagRecHit_, gemRecHits);
222  if (!gemRecHits.isValid()) {
223  edm::LogError(log_category_) << "GEM RecHit is not valid.\n";
224  return;
225  }
226 
227  std::map<ME3IdsKey, Int_t> total_rechit_layer;
228  std::map<ME3IdsKey, Int_t> total_rechit_iEta;
229  std::map<ME4IdsKey, std::map<Int_t, Bool_t>> mapCLSOver5;
230 
231  for (auto gid : listChamberId_) {
232  auto chamber = gid.chamber();
233  ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
234  ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
235  MEStationInfo& stationInfo = mapStationInfo_[key3];
236  for (auto iEta : mapEtaPartition_[gid]) {
237  GEMDetId eId = iEta->id();
238  ME3IdsKey key3IEta{gid.region(), gid.station(), eId.ieta()};
239  ME3IdsKey key3AbsReIEta{std::abs(gid.region()), gid.station(), eId.ieta()};
240  ME4IdsKey key4IEta{gid.region(), gid.station(), gid.layer(), eId.ieta()};
241 
242  Int_t nEtaModule = eId.ieta();
243  if (gid.station() == 2) {
244  nEtaModule = getIdxModule(2, 24 - (nEtaModule - 1) / 4);
245  }
246  ME4IdsKey key4IEtaMod{gid.region(), gid.station(), gid.layer(), nEtaModule};
247 
248  if (total_rechit_layer.find(key3) == total_rechit_layer.end())
249  total_rechit_layer[key3] = 0;
250 
251  const auto& recHitsRange = gemRecHits->get(eId);
252  auto gemRecHit = recHitsRange.first;
253  for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) {
254  LocalPoint recHitLP = hit->localPosition();
255  GlobalPoint recHitGP = GEMGeometry_->idToDet(hit->gemId())->surface().toGlobal(recHitLP);
256 
257  // Filling of XY occupancy
258  mapRecHitXY_layer_.Fill(key3, recHitGP.x(), recHitGP.y());
259 
260  // Filling of RecHit (iEta)
261  mapRecHitOcc_ieta_.Fill(key3, nEtaModule);
262 
263  // Filling of RecHit (phi)
264  Float_t fPhi = recHitGP.phi();
265  Float_t fPhiShift = restrictAngle(fPhi, stationInfo.fMinPhi_);
266  Float_t fPhiDeg = fPhiShift * 180.0 / M_PI;
267  mapRecHitOcc_phi_.Fill(key3, fPhiDeg);
268 
269  // For total RecHits
270  total_rechit_layer[key3]++;
271  total_rechit_iEta[key3IEta]++;
272 
273  // Filling of cluster size (CLS)
274  Int_t nCLS = hit->clusterSize();
275  Int_t nCLSCutOff = std::min(nCLS, nCLSMax_); // For overflow
276  mapCLSRecHit_ieta_.Fill(key3AbsReIEta, nCLSCutOff);
277  mapCLSPerCh_.Fill(key4Ch, nCLSCutOff, nEtaModule);
278  mapCLSAverage_.Fill(key3, (Double_t)chamber, (Double_t)nEtaModule, nCLS);
279  if (nCLS > 5)
280  mapCLSOver5[key4IEtaMod][chamber] = true;
281  }
282  }
283  }
284  for (auto [key, num_total_rechit] : total_rechit_layer) {
285  mapTotalRecHitPerEvtLayer_.Fill(key, num_total_rechit);
286  }
287  for (auto [key, num_total_rechit] : total_rechit_iEta) {
288  mapTotalRecHitPerEvtIEta_.Fill(key, num_total_rechit);
289  }
290  for (auto [key, mapSub] : mapCLSOver5) {
291  for (auto [chamber, b] : mapSub) {
293  }
294  }
295 }
296 
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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
std::vector< GEMDetId > listChamberId_
Definition: GEMDQMBase.h:632
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
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
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
int ProcessWithMEMap3(BookingHelper &bh, ME3IdsKey key) override
GEMRecHitSource(const edm::ParameterSet &cfg)
std::map< ME3IdsKey, MEStationInfo > mapStationInfo_
Definition: GEMDQMBase.h:651
int loadChambers()
Definition: GEMDQMBase.cc:56
void SetBinHighEdgeX(Double_t dXH)
Definition: GEMDQMBase.h:266
Log< level::Error, false > LogError
std::vector< Float_t > listRadiusOddChamber_
Definition: GEMDQMBase.h:527
MEMap3Inf mapRecHitOcc_ieta_
int Fill(K key, Double_t x)
Definition: GEMDQMBase.h:395
int nNumDivideEtaPartitionInRPhi_
std::string log_category_
Definition: GEMDQMBase.h:547
MEMap3Inf mapCLSOver5_
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
MEMap3Inf mapRecHitXY_layer_
MEMap3Inf mapTotalRecHitPerEvtIEta_
void SetBinLowEdgeX(Double_t dXL)
Definition: GEMDQMBase.h:264
int GenerateMEPerChamber(DQMStore::IBooker &ibooker)
Definition: GEMDQMBase.cc:197
std::vector< Float_t > listRadiusEvenChamber_
Definition: GEMDQMBase.h:526
Float_t restrictAngle(const Float_t fTheta, const Float_t fStart)
Definition: GEMDQMBase.h:740
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int ProcessWithMEMap4WithChamber(BookingHelper &bh, ME4IdsKey key) override
edm::EDGetToken tagRecHit_
void SetBinHighEdgeY(Double_t dYH)
Definition: GEMDQMBase.h:274
key
prepare the HTCondor submission files and eventually submit them
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MEMap3Inf mapRecHitOcc_phi_
float fPhi(int hwPhi)
Definition: conversion.h:18
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)
int keyToStation(ME2IdsKey key)
Definition: GEMDQMBase.h:574
std::string strFolderMain_
MEMap4Inf mapCLSPerCh_
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
#define M_PI
constexpr int ieta() const
Definition: GEMDetId.h:199
MEMap3Inf mapCLSAverage_
MEMap3Inf mapCLSRecHit_ieta_
const GEMGeometry * GEMGeometry_
Definition: GEMDQMBase.h:629
int keyToIEta(ME4IdsKey key)
Definition: GEMDQMBase.h:588
virtual void setYTitle(std::string const &title)
MEMap3Inf mapTotalRecHitPerEvtLayer_
void SetNoUnderOverflowBin()
Definition: GEMDQMBase.h:247
int ProcessWithMEMap2AbsReWithEta(BookingHelper &bh, ME3IdsKey key) override
int SetLabelForIEta(K key, Int_t nAxis, Int_t nNumBin=-1)
Definition: GEMDQMBase.h:357
double b
Definition: hdecay.h:120
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.
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
int ProcessWithMEMap2WithEta(BookingHelper &bh, ME3IdsKey key) override
void SetBinConfY(Int_t nBins, Double_t dL=0.5, Double_t dH=-1048576.0)
Definition: GEMDQMBase.h:289
dqm::impl::MonitorElement * FindHist(K key)
Definition: GEMDQMBase.h:328
Definition: event.py:1
Definition: Run.h:45
void SetBinLowEdgeY(Double_t dYL)
Definition: GEMDQMBase.h:272