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 
141 
142  mapRecHitOcc_phi_.SetBinLowEdgeX(stationInfo.fMinPhi_ * 180 / M_PI);
143  mapRecHitOcc_phi_.SetBinHighEdgeX(stationInfo.fMinPhi_ * 180 / M_PI + 360);
145 
147 
148  Int_t nNewNumCh = stationInfo.nMaxIdxChamber_ - stationInfo.nMinIdxChamber_ + 1;
149 
150  mapCLSAverage_.SetBinConfX(nNewNumCh, stationInfo.nMinIdxChamber_ - 0.5, stationInfo.nMaxIdxChamber_ + 0.5);
154 
155  mapCLSOver5_.SetBinConfX(nNewNumCh, stationInfo.nMinIdxChamber_ - 0.5, stationInfo.nMaxIdxChamber_ + 0.5);
156  mapCLSOver5_.bookND(bh, key);
159 
160  return 0;
161 }
162 
164  ME3IdsKey key3 = key4Tokey3(key);
165  MEStationInfo& stationInfo = mapStationInfo_[key3];
166 
167  bh.getBooker()->setCurrentFolder(strFolderMain_ + "/clusterSize_" + getNameDirLayer(key3));
168 
170  mapCLSPerCh_.bookND(bh, key);
172 
174 
175  return 0;
176 }
177 
180  event.getByToken(this->tagRecHit_, gemRecHits);
181  if (!gemRecHits.isValid()) {
182  edm::LogError(log_category_) << "GEM RecHit is not valid.\n";
183  return;
184  }
185 
186  std::map<ME3IdsKey, Int_t> total_rechit_layer;
187  std::map<ME3IdsKey, Int_t> total_rechit_iEta;
188  std::map<ME4IdsKey, std::map<Int_t, Bool_t>> mapCLSOver5;
189 
190  for (const auto& ch : gemChambers_) {
191  GEMDetId gid = ch.id();
192  auto chamber = gid.chamber();
193  ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
194  ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
195  MEStationInfo& stationInfo = mapStationInfo_[key3];
196  for (auto iEta : ch.etaPartitions()) {
197  GEMDetId eId = iEta->id();
198  ME3IdsKey key3IEta{gid.region(), gid.station(), eId.ieta()};
199  ME3IdsKey key3AbsReIEta{std::abs(gid.region()), gid.station(), eId.ieta()};
200  ME4IdsKey key4IEta{gid.region(), gid.station(), gid.layer(), eId.ieta()};
201 
202  if (total_rechit_layer.find(key3) == total_rechit_layer.end())
203  total_rechit_layer[key3] = 0;
204 
205  const auto& recHitsRange = gemRecHits->get(eId);
206  auto gemRecHit = recHitsRange.first;
207  for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) {
208  LocalPoint recHitLP = hit->localPosition();
209  GlobalPoint recHitGP = GEMGeometry_->idToDet(hit->gemId())->surface().toGlobal(recHitLP);
210 
211  // Filling of XY occupancy
212  mapRecHitXY_layer_.Fill(key3, recHitGP.x(), recHitGP.y());
213 
214  // Filling of RecHit (iEta)
215  mapRecHitOcc_ieta_.Fill(key3, eId.ieta());
216 
217  // Filling of RecHit (phi)
218  Float_t fPhi = recHitGP.phi();
219  Float_t fPhiShift = restrictAngle(fPhi, stationInfo.fMinPhi_);
220  Float_t fPhiDeg = fPhiShift * 180.0 / M_PI;
221  mapRecHitOcc_phi_.Fill(key3, fPhiDeg);
222 
223  // For total RecHits
224  total_rechit_layer[key3]++;
225  total_rechit_iEta[key3IEta]++;
226 
227  // Filling of cluster size (CLS)
228  Int_t nCLS = hit->clusterSize();
229  Int_t nCLSCutOff = std::min(nCLS, nCLSMax_); // For overflow
230  mapCLSRecHit_ieta_.Fill(key3AbsReIEta, nCLSCutOff);
231  mapCLSPerCh_.Fill(key4Ch, nCLSCutOff, eId.ieta());
232  mapCLSAverage_.Fill(key3, (Double_t)chamber, (Double_t)eId.ieta(), nCLS);
233  if (nCLS > 5)
234  mapCLSOver5[key4IEta][chamber] = true;
235  }
236  }
237  }
238  for (auto [key, num_total_rechit] : total_rechit_layer) {
239  mapTotalRecHitPerEvtLayer_.Fill(key, num_total_rechit);
240  }
241  for (auto [key, num_total_rechit] : total_rechit_iEta) {
242  mapTotalRecHitPerEvtIEta_.Fill(key, num_total_rechit);
243  }
244  for (auto [key, mapSub] : mapCLSOver5) {
245  for (auto [chamber, b] : mapSub) {
247  }
248  }
249 }
250 
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
constexpr int station() const
Definition: GEMDetId.h:179
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MEMapInfT< MEMap4Ids, ME4IdsKey > MEMap4Inf
Definition: GEMDQMBase.h:460
int ProcessWithMEMap3WithChamber(BookingHelper &bh, ME4IdsKey key) override
constexpr int region() const
Definition: GEMDetId.h:171
Int_t nRunType_
Definition: GEMDQMBase.h:518
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
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:459
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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:589
int loadChambers()
Definition: GEMDQMBase.cc:58
void SetBinHighEdgeX(Double_t dXH)
Definition: GEMDQMBase.h:266
Log< level::Error, false > LogError
constexpr int layer() const
Definition: GEMDetId.h:190
std::vector< Float_t > listRadiusOddChamber_
Definition: GEMDQMBase.h:500
MEMap3Inf mapRecHitOcc_ieta_
int Fill(K key, Double_t x)
Definition: GEMDQMBase.h:380
int nNumDivideEtaPartitionInRPhi_
std::string log_category_
Definition: GEMDQMBase.h:520
constexpr int chamber() const
Definition: GEMDetId.h:183
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:174
std::vector< Float_t > listRadiusEvenChamber_
Definition: GEMDQMBase.h:499
Float_t restrictAngle(const Float_t fTheta, const Float_t fStart)
Definition: GEMDQMBase.h:655
std::vector< GEMChamber > gemChambers_
Definition: GEMDQMBase.h:578
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetToken tagRecHit_
void SetBinHighEdgeY(Double_t dYH)
Definition: GEMDQMBase.h:274
MEMap3Inf mapRecHitOcc_phi_
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:575
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:118
void add(std::string const &label, ParameterSetDescription const &psetDescription)
DQMStore::IBooker * getBooker()
Definition: GEMDQMBase.h:94
std::string getNameDirLayer(ME3IdsKey key3)
Definition: GEMDQMBase.h:661
int bookND(BookingHelper &bh, K key)
Definition: GEMDQMBase.h:307
ME3IdsKey key4Tokey3(ME4IdsKey key)
Definition: GEMDQMBase.h:551
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
int keyToIEta(ME3IdsKey key)
Definition: GEMDQMBase.h:543
Definition: event.py:1
Definition: Run.h:45
void SetBinLowEdgeY(Double_t dYL)
Definition: GEMDQMBase.h:272