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  nCLSMax_ = cfg.getParameter<int>("clsMax");
11  nClusterSizeBinNum_ = cfg.getParameter<int>("ClusterSizeBinNum");
12  bModeRelVal_ = cfg.getParameter<bool>("modeRelVal");
13 }
14 
17  desc.add<edm::InputTag>("recHitsInputLabel", edm::InputTag("gemRecHits", ""));
18 
19  desc.add<int>("idxFirstDigi", 0);
20  desc.add<int>("clsMax", 10);
21  desc.add<int>("ClusterSizeBinNum", 9);
22  desc.add<bool>("modeRelVal", false);
23 
24  desc.addUntracked<std::string>("logCategory", "GEMRecHitSource");
25 
26  descriptions.add("GEMRecHitSource", desc);
27 }
28 
30  std::vector<GEMDetId> listLayerOcc;
31 
32  initGeometry(iSetup);
33  if (GEMGeometry_ == nullptr)
34  return;
35  loadChambers();
36 
37  ibooker.cd();
38  ibooker.setCurrentFolder("GEM/RecHits");
39 
40  fRadiusMin_ = 120.0;
41  fRadiusMax_ = 250.0;
42  float radS = -5.0 / 180 * M_PI;
43  float radL = 355.0 / 180 * M_PI;
44 
45  mapTotalRecHit_layer_ = MEMap3Inf(this, "det", "RecHit Occupancy", 36, 0.5, 36.5, 8, 0.5, 8.5, "Chamber", "iEta");
47  this, "rphi_occ", "RecHit R-Phi Occupancy", 360, radS, radL, 8, fRadiusMin_, fRadiusMax_, "#phi (rad)", "R [cm]");
48  mapRecHitOcc_ieta_ = MEMap3Inf(this, "occ_ieta", "RecHit iEta Occupancy", 8, 0.5, 8.5, "iEta", "Number of RecHits");
50  MEMap3Inf(this, "occ_phi", "RecHit Phi Occupancy", 360, -5, 355, "#phi (degree)", "Number of RecHits");
52  "rechits_per_layer",
53  "Total number of RecHits per event for each layers",
54  2000,
55  -0.5,
56  2000 - 0.5,
57  "Number of RecHits",
58  "Events");
61  "rechits_per_ieta",
62  "Total number of RecHits per event for each eta partitions",
63  300,
64  -0.5,
65  300 - 0.5,
66  "Number of RecHits",
67  "Events");
70  this, "cls", "Cluster size of RecHits", nCLSMax_, 0.5, nCLSMax_ + 0.5, "Cluster size", "Number of RecHits");
71  mapCLSAverage_ = MEMap3Inf(this, // TProfile2D
72  "rechit_average",
73  "Average of Cluster Sizes",
74  36,
75  0.5,
76  36.5,
77  8,
78  0.5,
79  8.5,
80  0,
81  400, // For satefy, larger than 384
82  "Chamber",
83  "iEta");
85  this, "largeCls_occ", "Occupancy of Large Clusters (>5)", 36, 0.5, 36.5, 8, 0.5, 8.5, "Chamber", "iEta");
86 
88  this, "cls", "Cluster size of RecHits", nCLSMax_, 0.5, nCLSMax_ + 0.5, 1, 0.5, 1.5, "Cluster size", "iEta");
89 
90  if (bModeRelVal_) {
96  }
97 
98  GenerateMEPerChamber(ibooker);
99 }
100 
101 //int GEMRecHitSource::SetupRPhiPlot(ME3IdsKey key) {
102 // MEStationInfo& stationInfo = mapStationInfo_[key];
103 //
104 // auto hRPhi = mapRecHitWheel_layer_.FindHist(key);
105 //
106 //
107 //
108 // return 0;
109 //}
110 
113 
114  return 0;
115 }
116 
118  mapCLSRecHit_ieta_.bookND(bh, key);
119 
120  return 0;
121 }
122 
124  MEStationInfo& stationInfo = mapStationInfo_[key];
125 
126  Int_t nNumVFATPerEta = stationInfo.nMaxVFAT_ / stationInfo.nNumEtaPartitions_;
127 
130  mapTotalRecHit_layer_.bookND(bh, key);
133 
136  mapRecHitWheel_layer_.SetNbinsX(nNumVFATPerEta * stationInfo.nNumChambers_);
138  mapRecHitWheel_layer_.bookND(bh, key);
139  //SetupRPhiPlot(key);
140 
142  mapRecHitOcc_ieta_.bookND(bh, key);
144 
145  mapRecHitOcc_phi_.SetBinLowEdgeX(stationInfo.fMinPhi_ * 180 / M_PI);
146  mapRecHitOcc_phi_.SetBinHighEdgeX(stationInfo.fMinPhi_ * 180 / M_PI + 360);
147  mapRecHitOcc_phi_.bookND(bh, key);
148 
150 
151  mapCLSAverage_.bookND(bh, key);
152  mapCLSOver5_.bookND(bh, key);
157 
158  return 0;
159 }
160 
162  ME3IdsKey key3 = key4Tokey3(key);
163  MEStationInfo& stationInfo = mapStationInfo_[key3];
164 
166  mapCLSPerCh_.bookND(bh, key);
168 
169  return 0;
170 }
171 
172 void GEMRecHitSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) {
174  event.getByToken(this->tagRecHit_, gemRecHits);
175  if (!gemRecHits.isValid()) {
176  edm::LogError(log_category_) << "GEM RecHit is not valid.\n";
177  return;
178  }
179 
180  std::map<ME3IdsKey, Int_t> total_rechit_layer;
181  std::map<ME3IdsKey, Int_t> total_rechit_iEta;
182  std::map<ME4IdsKey, std::map<Int_t, Bool_t>> mapCLSOver5;
183 
184  for (const auto& ch : gemChambers_) {
185  GEMDetId gid = ch.id();
186  auto chamber = gid.chamber();
187  ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
188  ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
189  MEStationInfo& stationInfo = mapStationInfo_[key3];
190  for (auto ieta : ch.etaPartitions()) {
191  GEMDetId eId = ieta->id();
192  ME3IdsKey key3IEta{gid.region(), gid.station(), eId.ieta()};
193  ME3IdsKey key3AbsReIEta{std::abs(gid.region()), gid.station(), eId.ieta()};
194  ME4IdsKey key4IEta{gid.region(), gid.station(), gid.layer(), eId.ieta()};
195 
196  if (total_rechit_layer.find(key3) == total_rechit_layer.end())
197  total_rechit_layer[key3] = 0;
198 
199  const auto& recHitsRange = gemRecHits->get(eId);
200  auto gemRecHit = recHitsRange.first;
201  for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) {
202  GlobalPoint recHitGP = GEMGeometry_->idToDet(hit->gemId())->surface().toGlobal(hit->localPosition());
203  Float_t fPhi = recHitGP.phi();
204 
205  // Filling of RecHit occupancy
206  mapTotalRecHit_layer_.Fill(key3, chamber, eId.ieta());
207 
208  // Filling of R-Phi occupancy
209  Float_t fR = fRadiusMin_ + (fRadiusMax_ - fRadiusMin_) * (eId.ieta() - 0.5) / stationInfo.nNumEtaPartitions_;
210  Float_t fPhiShift = restrictAngle(fPhi, stationInfo.fMinPhi_);
211  Float_t fPhiDeg = fPhiShift * 180.0 / M_PI;
212  mapRecHitWheel_layer_.Fill(key3, fPhiShift, fR);
213 
214  // Filling of RecHit (iEta)
215  mapRecHitOcc_ieta_.Fill(key3, eId.ieta());
216 
217  // Filling of RecHit (phi)
218  mapRecHitOcc_phi_.Fill(key3, fPhiDeg);
219 
220  // For total RecHits
221  total_rechit_layer[key3]++;
222  total_rechit_iEta[key3IEta]++;
223 
224  // Filling of cluster size (CLS)
225  Int_t nCLS = hit->clusterSize();
226  Int_t nCLSCutOff = std::min(nCLS, nCLSMax_); // For overflow
227  mapCLSRecHit_ieta_.Fill(key3AbsReIEta, nCLSCutOff);
228  mapCLSPerCh_.Fill(key4Ch, nCLSCutOff, eId.ieta());
229  mapCLSAverage_.Fill(key3, (Double_t)chamber, (Double_t)eId.ieta(), nCLS);
230  if (nCLS > 5)
231  mapCLSOver5[key4IEta][chamber] = true;
232  }
233  }
234  }
235  for (auto [key, num_total_rechit] : total_rechit_layer) {
236  mapTotalRecHitPerEvtLayer_.Fill(key, num_total_rechit);
237  }
238  for (auto [key, num_total_rechit] : total_rechit_iEta) {
239  mapTotalRecHitPerEvtIEta_.Fill(key, num_total_rechit);
240  }
241  for (auto [key, mapSub] : mapCLSOver5) {
242  for (auto [chamber, b] : mapSub) {
244  }
245  }
246 }
247 
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MEMapInfT< MEMap4Ids, ME4IdsKey > MEMap4Inf
Definition: GEMDQMBase.h:457
int ProcessWithMEMap3WithChamber(BookingHelper &bh, ME4IdsKey key) override
tuple cfg
Definition: looper.py:296
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:456
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int SetLabelForChambers(K key, Int_t nAxis, Int_t nNumBin=-1)
Definition: GEMDQMBase.h:334
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:15
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
GEMRecHitSource(const edm::ParameterSet &cfg)
std::map< ME3IdsKey, MEStationInfo > mapStationInfo_
Definition: GEMDQMBase.h:564
int loadChambers()
Definition: GEMDQMBase.cc:46
void SetBinHighEdgeX(Double_t dXH)
Definition: GEMDQMBase.h:264
Log< level::Error, false > LogError
MEMap3Inf mapRecHitOcc_ieta_
int Fill(K key, Double_t x)
Definition: GEMDQMBase.h:377
std::string log_category_
Definition: GEMDQMBase.h:496
constexpr int ieta() const
Definition: GEMDetId.h:199
MEMap3Inf mapCLSOver5_
MEMap3Inf mapTotalRecHitPerEvtIEta_
void SetBinLowEdgeX(Double_t dXL)
Definition: GEMDQMBase.h:262
int GenerateMEPerChamber(DQMStore::IBooker &ibooker)
Definition: GEMDQMBase.cc:159
constexpr int region() const
Definition: GEMDetId.h:171
Float_t restrictAngle(const Float_t fTheta, const Float_t fStart)
Definition: GEMDQMBase.h:618
std::vector< GEMChamber > gemChambers_
Definition: GEMDQMBase.h:553
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_
MEMap3Inf mapTotalRecHit_layer_
void SetNbinsY(Int_t nBinsY)
Definition: GEMDQMBase.h:268
MEMap3Inf mapRecHitOcc_phi_
T min(T a, T b)
Definition: MathUtil.h:58
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:70
MEMap3Inf mapRecHitWheel_layer_
MEMap4Inf mapCLSPerCh_
#define M_PI
MEMap3Inf mapCLSAverage_
MEMap3Inf mapCLSRecHit_ieta_
const GEMGeometry * GEMGeometry_
Definition: GEMDQMBase.h:550
MEMap3Inf mapTotalRecHitPerEvtLayer_
void SetNoUnderOverflowBin()
Definition: GEMDQMBase.h:245
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:354
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)
int bookND(BookingHelper &bh, K key)
Definition: GEMDQMBase.h:305
ME3IdsKey key4Tokey3(ME4IdsKey key)
Definition: GEMDQMBase.h:529
void SetNbinsX(Int_t nBinsX)
Definition: GEMDQMBase.h:260
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:279
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:287
int keyToIEta(ME3IdsKey key)
Definition: GEMDQMBase.h:521
Definition: Run.h:45