CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
43  fRadiusMin_ = 120.0;
44  fRadiusMax_ = 250.0;
45  float radS = -5.0 / 180 * M_PI;
46  float radL = 355.0 / 180 * M_PI;
47 
49  MEMap3Inf(this, "occ_rphi", "RecHit R-Phi Occupancy", 360, radS, radL, 8, 0, 8, "Phi-direction division", "iEta");
51  MEMap3Inf(this, "occ_xy", "RecHit xy Occupancy", 160, -250, 250, 160, -250, 250, "X [cm]", "Y [cm]");
52  mapRecHitOcc_ieta_ = MEMap3Inf(this, "occ_ieta", "RecHit iEta Occupancy", 8, 0.5, 8.5, "iEta", "Number of RecHits");
54  MEMap3Inf(this, "occ_phi", "RecHit Phi Occupancy", 72, -5, 355, "#phi (degree)", "Number of RecHits");
56  "rechits_per_layer",
57  "Total number of RecHits per event for each layers",
58  2000,
59  -0.5,
60  2000 - 0.5,
61  "Number of RecHits",
62  "Events");
65  "rechits_per_ieta",
66  "Total number of RecHits per event for each eta partitions",
67  300,
68  -0.5,
69  300 - 0.5,
70  "Number of RecHits",
71  "Events");
74  this, "cls", "Cluster size of RecHits", nCLSMax_, 0.5, nCLSMax_ + 0.5, "Cluster size", "Number of RecHits");
75  mapCLSAverage_ = MEMap3Inf(this, // TProfile2D
76  "rechit_average",
77  "Average of Cluster Sizes",
78  36,
79  0.5,
80  36.5,
81  8,
82  0.5,
83  8.5,
84  0,
85  400, // For satefy, larger than 384
86  "Chamber",
87  "iEta");
89  this, "largeCls_occ", "Occupancy of Large Clusters (>5)", 36, 0.5, 36.5, 8, 0.5, 8.5, "Chamber", "iEta");
90 
92  this, "cls", "Cluster size of RecHits", nCLSMax_, 0.5, nCLSMax_ + 0.5, 1, 0.5, 1.5, "Cluster size", "iEta");
93 
98  }
99 
105  }
106 
109  }
110 
115  }
116 
120  }
121 
122  GenerateMEPerChamber(ibooker);
123 }
124 
127 
128  return 0;
129 }
130 
132  mapCLSRecHit_ieta_.bookND(bh, key);
133 
134  return 0;
135 }
136 
138  MEStationInfo& stationInfo = mapStationInfo_[key];
139 
140  Int_t nNumPartX = stationInfo.nNumChambers_ * nNumDivideEtaPartitionInRPhi_;
143  mapRecHitWheel_layer_.bookND(bh, key);
144 
145  mapRecHitXY_layer_.bookND(bh, key);
146 
148  mapRecHitOcc_ieta_.bookND(bh, key);
150 
151  mapRecHitOcc_phi_.SetBinLowEdgeX(stationInfo.fMinPhi_ * 180 / M_PI);
152  mapRecHitOcc_phi_.SetBinHighEdgeX(stationInfo.fMinPhi_ * 180 / M_PI + 360);
153  mapRecHitOcc_phi_.bookND(bh, key);
154 
156 
157  mapCLSAverage_.bookND(bh, key);
158  mapCLSOver5_.bookND(bh, key);
163 
164  return 0;
165 }
166 
168  ME3IdsKey key3 = key4Tokey3(key);
169  MEStationInfo& stationInfo = mapStationInfo_[key3];
170 
171  bh.getBooker()->setCurrentFolder(strFolderMain_ + "/clusterSize_" + getNameDirLayer(key3));
172 
174  mapCLSPerCh_.bookND(bh, key);
176 
178 
179  return 0;
180 }
181 
182 void GEMRecHitSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) {
184  event.getByToken(this->tagRecHit_, gemRecHits);
185  if (!gemRecHits.isValid()) {
186  edm::LogError(log_category_) << "GEM RecHit is not valid.\n";
187  return;
188  }
189 
190  std::map<ME3IdsKey, Int_t> total_rechit_layer;
191  std::map<ME3IdsKey, Int_t> total_rechit_iEta;
192  std::map<ME4IdsKey, std::map<Int_t, Bool_t>> mapCLSOver5;
193 
194  for (const auto& ch : gemChambers_) {
195  GEMDetId gid = ch.id();
196  auto chamber = gid.chamber();
197  ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
198  ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
199  MEStationInfo& stationInfo = mapStationInfo_[key3];
200  for (auto iEta : ch.etaPartitions()) {
201  GEMDetId eId = iEta->id();
202  ME3IdsKey key3IEta{gid.region(), gid.station(), eId.ieta()};
203  ME3IdsKey key3AbsReIEta{std::abs(gid.region()), gid.station(), eId.ieta()};
204  ME4IdsKey key4IEta{gid.region(), gid.station(), gid.layer(), eId.ieta()};
205 
206  if (total_rechit_layer.find(key3) == total_rechit_layer.end())
207  total_rechit_layer[key3] = 0;
208 
209  const auto& recHitsRange = gemRecHits->get(eId);
210  auto gemRecHit = recHitsRange.first;
211  for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) {
212  LocalPoint recHitLP = hit->localPosition();
213  GlobalPoint recHitGP = GEMGeometry_->idToDet(hit->gemId())->surface().toGlobal(recHitLP);
214 
215  // Filling of XY occupancy
216  mapRecHitXY_layer_.Fill(key3, recHitGP.x(), recHitGP.y());
217 
218  // Filling of R-Phi occupancy
219  // Trick: It would be efficient to find a phi-partition of the eta partition
220  // in which the recHit places from the 'strip position' of the recHit position
221  Int_t nOffset = chamber * nNumDivideEtaPartitionInRPhi_;
222  Float_t fStripRecHit = iEta->strip(recHitLP);
223  Int_t nStripRecHit = Int_t(fStripRecHit / iEta->nstrips() * nNumDivideEtaPartitionInRPhi_);
224  nStripRecHit = std::min(std::max(0, nStripRecHit), nNumDivideEtaPartitionInRPhi_ - 1);
225  mapRecHitWheel_layer_.Fill(key3, nOffset + nStripRecHit, eId.ieta());
226 
227  // Filling of RecHit (iEta)
228  mapRecHitOcc_ieta_.Fill(key3, eId.ieta());
229 
230  // Filling of RecHit (phi)
231  Float_t fPhi = recHitGP.phi();
232  Float_t fPhiShift = restrictAngle(fPhi, stationInfo.fMinPhi_);
233  Float_t fPhiDeg = fPhiShift * 180.0 / M_PI;
234  mapRecHitOcc_phi_.Fill(key3, fPhiDeg);
235 
236  // For total RecHits
237  total_rechit_layer[key3]++;
238  total_rechit_iEta[key3IEta]++;
239 
240  // Filling of cluster size (CLS)
241  Int_t nCLS = hit->clusterSize();
242  Int_t nCLSCutOff = std::min(nCLS, nCLSMax_); // For overflow
243  mapCLSRecHit_ieta_.Fill(key3AbsReIEta, nCLSCutOff);
244  mapCLSPerCh_.Fill(key4Ch, nCLSCutOff, eId.ieta());
245  mapCLSAverage_.Fill(key3, (Double_t)chamber, (Double_t)eId.ieta(), nCLS);
246  if (nCLS > 5)
247  mapCLSOver5[key4IEta][chamber] = true;
248  }
249  }
250  }
251  for (auto [key, num_total_rechit] : total_rechit_layer) {
252  mapTotalRecHitPerEvtLayer_.Fill(key, num_total_rechit);
253  }
254  for (auto [key, num_total_rechit] : total_rechit_iEta) {
255  mapTotalRecHitPerEvtIEta_.Fill(key, num_total_rechit);
256  }
257  for (auto [key, mapSub] : mapCLSOver5) {
258  for (auto [chamber, b] : mapSub) {
260  }
261  }
262 }
263 
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MEMapInfT< MEMap4Ids, ME4IdsKey > MEMap4Inf
Definition: GEMDQMBase.h:460
int ProcessWithMEMap3WithChamber(BookingHelper &bh, ME4IdsKey key) override
tuple cfg
Definition: looper.py:296
Int_t nRunType_
Definition: GEMDQMBase.h:516
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MEMapInfT< MEMap3Ids, ME3IdsKey > MEMap3Inf
Definition: GEMDQMBase.h:459
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int SetLabelForChambers(K key, Int_t nAxis, Int_t nNumBin=-1)
Definition: GEMDQMBase.h:337
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
int initGeometry(edm::EventSetup const &iSetup)
Definition: GEMDQMBase.cc:31
std::tuple< Int_t, Int_t, Int_t, Int_t > ME4IdsKey
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:25
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
int ProcessWithMEMap3(BookingHelper &bh, ME3IdsKey key) override
T y() const
Definition: PV3DBase.h:60
GEMRecHitSource(const edm::ParameterSet &cfg)
std::map< ME3IdsKey, MEStationInfo > mapStationInfo_
Definition: GEMDQMBase.h:585
int loadChambers()
Definition: GEMDQMBase.cc:62
void SetBinHighEdgeX(Double_t dXH)
Definition: GEMDQMBase.h:266
Log< level::Error, false > LogError
MEMap3Inf mapRecHitOcc_ieta_
int Fill(K key, Double_t x)
Definition: GEMDQMBase.h:380
int nNumDivideEtaPartitionInRPhi_
std::string log_category_
Definition: GEMDQMBase.h:518
constexpr int ieta() const
Definition: GEMDetId.h:199
MEMap3Inf mapCLSOver5_
MEMap3Inf mapRecHitXY_layer_
MEMap3Inf mapTotalRecHitPerEvtIEta_
void SetBinLowEdgeX(Double_t dXL)
Definition: GEMDQMBase.h:264
int GenerateMEPerChamber(DQMStore::IBooker &ibooker)
Definition: GEMDQMBase.cc:174
constexpr int region() const
Definition: GEMDetId.h:171
Float_t restrictAngle(const Float_t fTheta, const Float_t fStart)
Definition: GEMDQMBase.h:639
std::vector< GEMChamber > gemChambers_
Definition: GEMDQMBase.h:574
tuple key
prepare the HTCondor submission files and eventually submit them
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetToken tagRecHit_
void SetNbinsY(Int_t nBinsY)
Definition: GEMDQMBase.h:270
MEMap3Inf mapRecHitOcc_phi_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:70
MEMap3Inf mapRecHitWheel_layer_
std::string strFolderMain_
MEMap4Inf mapCLSPerCh_
#define M_PI
MEMap3Inf mapCLSAverage_
MEMap3Inf mapCLSRecHit_ieta_
const GEMGeometry * GEMGeometry_
Definition: GEMDQMBase.h:571
MEMap3Inf mapTotalRecHitPerEvtLayer_
void SetNoUnderOverflowBin()
Definition: GEMDQMBase.h:247
constexpr int chamber() const
Definition: GEMDetId.h:183
constexpr int layer() const
Definition: GEMDetId.h:190
int ProcessWithMEMap2AbsReWithEta(BookingHelper &bh, ME3IdsKey key) override
int SetLabelForIEta(K key, Int_t nAxis, Int_t nNumBin=-1)
Definition: GEMDQMBase.h:357
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
constexpr int station() const
Definition: GEMDetId.h:179
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:645
int bookND(BookingHelper &bh, K key)
Definition: GEMDQMBase.h:307
ME3IdsKey key4Tokey3(ME4IdsKey key)
Definition: GEMDQMBase.h:549
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
T x() const
Definition: PV3DBase.h:59
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:541
Definition: Run.h:45