CMS 3D CMS Logo

CaloSimHitAnalysis.cc
Go to the documentation of this file.
3 
13 
16 
22 
27 
32 
33 #include <TH1F.h>
34 #include <TH2F.h>
35 
36 #include <memory>
37 #include <iostream>
38 #include <fstream>
39 #include <vector>
40 #include <map>
41 #include <string>
42 
43 //#define EDM_ML_DEBUG
44 
45 class CaloSimHitAnalysis : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
46 public:
48  ~CaloSimHitAnalysis() override {}
49  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
50 
51 protected:
52  void beginJob() override {}
53  void analyze(edm::Event const&, edm::EventSetup const&) override;
54  void beginRun(edm::Run const&, edm::EventSetup const&) override {}
55  void endRun(edm::Run const&, edm::EventSetup const&) override {}
56 
57  void analyzeHits(std::vector<PCaloHit>&, int);
58  void analyzePassiveHits(std::vector<PassiveHit>& hits);
59 
60 private:
62  const std::vector<std::string> hitLab_;
63  const std::vector<double> timeSliceUnit_;
65  const bool testNumber_, passive_;
66  const int allSteps_;
67  const std::vector<std::string> detNames_;
68  std::vector<edm::EDGetTokenT<edm::PCaloHitContainer> > toks_calo_;
70 
73 
74  static constexpr int nCalo_ = 6;
79  TH2F *h_rz_, *h_rz1_, *h_etaphi_;
81  std::vector<TH1F*> h_edepTk_, h_timeTk_;
82  std::vector<TH2F*> h_rzH_;
83  std::map<int, unsigned int> etaDepth_;
84 };
85 
87  : g4Label_(ps.getUntrackedParameter<std::string>("moduleLabel", "g4SimHits")),
88  hitLab_(ps.getParameter<std::vector<std::string> >("hitCollection")),
89  timeSliceUnit_(ps.getParameter<std::vector<double> >("timeSliceUnit")),
90  maxEnergy_(ps.getUntrackedParameter<double>("maxEnergy", 250.0)),
91  maxTime_(ps.getUntrackedParameter<double>("maxTime", 1000.0)),
92  tMax_(ps.getUntrackedParameter<double>("timeCut", 100.0)),
93  tScale_(ps.getUntrackedParameter<double>("timeScale", 1.0)),
94  tCut_(ps.getUntrackedParameter<double>("timeThreshold", 15.0)),
95  testNumber_(ps.getUntrackedParameter<bool>("testNumbering", false)),
96  passive_(ps.getUntrackedParameter<bool>("passiveHits", false)),
97  allSteps_(ps.getUntrackedParameter<int>("allSteps", 100)),
98  detNames_(ps.getUntrackedParameter<std::vector<std::string> >("detNames")) {
99  usesResource(TFileService::kSharedResource);
100 
101  // register for data access
102  for (unsigned int i = 0; i < hitLab_.size(); i++)
103  toks_calo_.emplace_back(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, hitLab_[i])));
104  tok_passive_ = consumes<edm::PassiveHitContainer>(edm::InputTag(g4Label_, "AllPassiveHits"));
105 
106  edm::LogVerbatim("HitStudy") << "Module Label: " << g4Label_ << " Hits|timeSliceUnit:";
107  for (unsigned int i = 0; i < hitLab_.size(); i++)
108  edm::LogVerbatim("HitStudy") << "[" << i << "] " << hitLab_[i] << " " << timeSliceUnit_[i];
109  edm::LogVerbatim("HitStudy") << "Passive Hits " << passive_ << " from AllPassiveHits";
110  edm::LogVerbatim("HitStudy") << "maxEnergy: " << maxEnergy_ << " maxTime: " << maxTime_ << " tMax: " << tMax_;
111  for (unsigned int k = 0; k < detNames_.size(); ++k)
112  edm::LogVerbatim("HitStudy") << "Detector[" << k << "] " << detNames_[k];
113 
115  if (!tfile.isAvailable())
116  throw cms::Exception("BadConfig") << "TFileService unavailable: "
117  << "please add it to config file";
118  char name[29], title[120];
119  std::string dets[nCalo_] = {"EB", "EE", "HB", "HE", "HO", "HF"};
120  for (int i = 0; i < nCalo_; i++) {
121  sprintf(name, "Hit%d", i);
122  sprintf(title, "Number of hits in %s", dets[i].c_str());
123  h_hit_[i] = tfile->make<TH1F>(name, title, 100, 0., 20000.);
124  h_hit_[i]->GetXaxis()->SetTitle(title);
125  h_hit_[i]->GetYaxis()->SetTitle("Events");
126  sprintf(name, "Time%d", i);
127  sprintf(title, "Time of the hit (ns) in %s", dets[i].c_str());
128  h_time_[i] = tfile->make<TH1F>(name, title, 100, 0., 200.);
129  h_time_[i]->GetXaxis()->SetTitle(title);
130  h_time_[i]->GetYaxis()->SetTitle("Hits");
131  sprintf(name, "TimeT%d", i);
132  sprintf(title, "Time of each hit (ns) in %s", dets[i].c_str());
133  h_timeT_[i] = tfile->make<TH1F>(name, title, 100, 0., 200.);
134  h_timeT_[i]->GetXaxis()->SetTitle(title);
135  h_timeT_[i]->GetYaxis()->SetTitle("Hits");
136  double ymax = (i > 1) ? 0.01 : 0.1;
137  double ymx0 = (i > 1) ? 0.0025 : 0.025;
138  sprintf(name, "Edep%d", i);
139  sprintf(title, "Energy deposit (GeV) in %s", dets[i].c_str());
140  h_edep_[i] = tfile->make<TH1F>(name, title, 100, 0., ymax);
141  h_edep_[i]->GetXaxis()->SetTitle(title);
142  h_edep_[i]->GetYaxis()->SetTitle("Hits");
143  sprintf(name, "EdepT%d", i);
144  sprintf(title, "Energy deposit (GeV) of each hit in %s", dets[i].c_str());
145  h_edepT_[i] = tfile->make<TH1F>(name, title, 100, 0., ymx0);
146  h_edepT_[i]->GetXaxis()->SetTitle(title);
147  h_edepT_[i]->GetYaxis()->SetTitle("Hits");
148  sprintf(name, "EdepEM%d", i);
149  sprintf(title, "Energy deposit (GeV) by EM particles in %s", dets[i].c_str());
150  h_edepEM_[i] = tfile->make<TH1F>(name, title, 100, 0., ymx0);
151  h_edepEM_[i]->GetXaxis()->SetTitle(title);
152  h_edepEM_[i]->GetYaxis()->SetTitle("Hits");
153  sprintf(name, "EdepHad%d", i);
154  sprintf(title, "Energy deposit (GeV) by hadrons in %s", dets[i].c_str());
155  h_edepHad_[i] = tfile->make<TH1F>(name, title, 100, 0., ymx0);
156  h_edepHad_[i]->GetXaxis()->SetTitle(title);
157  h_edepHad_[i]->GetYaxis()->SetTitle("Hits");
158  sprintf(name, "Edep15%d", i);
159  sprintf(title, "Energy deposit (GeV) for T > %4.0f ns in %s", tCut_, dets[i].c_str());
160  h_edep1_[i] = tfile->make<TH1F>(name, title, 100, 0., ymax);
161  h_edep1_[i]->GetXaxis()->SetTitle(title);
162  h_edep1_[i]->GetYaxis()->SetTitle("Hits");
163  sprintf(name, "EdepT15%d", i);
164  sprintf(title, "Energy deposit (GeV) of each hit for T > %4.0f in %s", tCut_, dets[i].c_str());
165  h_edepT1_[i] = tfile->make<TH1F>(name, title, 100, 0., ymx0);
166  h_edepT1_[i]->GetXaxis()->SetTitle(title);
167  h_edepT1_[i]->GetYaxis()->SetTitle("Hits");
168  ymax = (i > 1) ? 1.0 : maxEnergy_;
169  sprintf(name, "Etot%d", i);
170  sprintf(title, "Total energy deposit (GeV) in %s", dets[i].c_str());
171  h_etot_[i] = tfile->make<TH1F>(name, title, 50, 0., ymax);
172  h_etot_[i]->GetXaxis()->SetTitle(title);
173  h_etot_[i]->GetYaxis()->SetTitle("Events");
174  sprintf(name, "EtotG%d", i);
175  sprintf(title, "Total energy deposit (GeV) in %s (t < 100 ns)", dets[i].c_str());
176  h_etotg_[i] = tfile->make<TH1F>(name, title, 50, 0., ymax);
177  h_etotg_[i]->GetXaxis()->SetTitle(title);
178  h_etotg_[i]->GetYaxis()->SetTitle("Events");
179  sprintf(name, "rr%d", i);
180  sprintf(title, "R of hit point (cm) in %s", dets[i].c_str());
181  h_rr_[i] = tfile->make<TH1F>(name, title, 100, 0., 250.);
182  h_rr_[i]->GetXaxis()->SetTitle(title);
183  h_rr_[i]->GetYaxis()->SetTitle("Hits");
184  sprintf(name, "zz%d", i);
185  sprintf(title, "z of hit point (cm) in %s", dets[i].c_str());
186  h_zz_[i] = tfile->make<TH1F>(name, title, 240, -600., 600.);
187  h_zz_[i]->GetXaxis()->SetTitle(title);
188  h_zz_[i]->GetYaxis()->SetTitle("Hits");
189  sprintf(name, "eta%d", i);
190  sprintf(title, "#eta of hit point in %s", dets[i].c_str());
191  h_eta_[i] = tfile->make<TH1F>(name, title, 100, -5.0, 5.0);
192  h_eta_[i]->GetXaxis()->SetTitle(title);
193  h_eta_[i]->GetYaxis()->SetTitle("Hits");
194  sprintf(name, "phi%d", i);
195  sprintf(title, "#phi of hit point in %s", dets[i].c_str());
196  h_phi_[i] = tfile->make<TH1F>(name, title, 100, -M_PI, M_PI);
197  h_phi_[i]->GetXaxis()->SetTitle(title);
198  h_phi_[i]->GetYaxis()->SetTitle("Hits");
199  }
200  sprintf(title, "R vs Z of hit point");
201  h_rz_ = tfile->make<TH2F>("rz", title, 120, 0., 600., 100, 0., 250.);
202  h_rz_->GetXaxis()->SetTitle("z (cm)");
203  h_rz_->GetYaxis()->SetTitle("R (cm)");
204  sprintf(title, "R vs Z of hit point for hits with T > %4.0f ns", tCut_);
205  h_rz1_ = tfile->make<TH2F>("rz2", title, 120, 0., 600., 100, 0., 250.);
206  h_rz1_->GetXaxis()->SetTitle("z (cm)");
207  h_rz1_->GetYaxis()->SetTitle("R (cm)");
208  sprintf(title, "#phi vs #eta of hit point");
209  h_etaphi_ = tfile->make<TH2F>("etaphi", title, 100, 0., 5., 100, 0., M_PI);
210  h_etaphi_->GetXaxis()->SetTitle("#eta");
211  h_etaphi_->GetYaxis()->SetTitle("#phi");
212 
213  if (passive_) {
214  h_hitp_ = tfile->make<TH1F>("hitp", "All Steps", 100, 0.0, 20000.0);
215  h_hitp_->GetXaxis()->SetTitle("Hits");
216  h_hitp_->GetYaxis()->SetTitle("Events");
217  h_trackp_ = tfile->make<TH1F>("trackp", "All Steps", 100, 0.0, 200000.0);
218  h_hitp_->GetXaxis()->SetTitle("Tracks");
219  h_hitp_->GetYaxis()->SetTitle("Events");
220  h_edepp_ = tfile->make<TH1F>("edepp", "All Steps", 100, 0.0, 50.0);
221  h_edepp_->GetXaxis()->SetTitle("Energy Deposit (MeV)");
222  h_edepp_->GetYaxis()->SetTitle("Hits");
223  h_timep_ = tfile->make<TH1F>("timep", "All Steps", 100, 0.0, 100.0);
224  h_timep_->GetXaxis()->SetTitle("Hits");
225  h_timep_->GetYaxis()->SetTitle("Hit Time (ns)");
226  h_stepp_ = tfile->make<TH1F>("stepp", "All Steps", 1000, 0.0, 100.0);
227  h_stepp_->GetXaxis()->SetTitle("Hits");
228  h_stepp_->GetYaxis()->SetTitle("Step length (cm)");
229  for (unsigned int k = 0; k < detNames_.size(); ++k) {
230  sprintf(name, "edept%d", k);
231  sprintf(title, "Energy Deposit (MeV) in %s", detNames_[k].c_str());
232  h_edepTk_.emplace_back(tfile->make<TH1F>(name, title, 100, 0.0, 1.0));
233  h_edepTk_.back()->GetYaxis()->SetTitle("Hits");
234  h_edepTk_.back()->GetXaxis()->SetTitle(title);
235  sprintf(name, "timet%d", k);
236  sprintf(title, "Hit Time (ns) in %s", detNames_[k].c_str());
237  h_timeTk_.emplace_back(tfile->make<TH1F>(name, title, 100, 0.0, 100.0));
238  h_timeTk_.back()->GetYaxis()->SetTitle("Hits");
239  h_timeTk_.back()->GetXaxis()->SetTitle(title);
240  }
241  if ((allSteps_ / 100) % 10 > 0) {
242  for (int eta = 1; eta <= 29; ++eta) {
243  int dmax = (eta < 16) ? 4 : 7;
244  for (int depth = 1; depth <= dmax; ++depth) {
245  sprintf(name, "Eta%dDepth%d", eta, depth);
246  sprintf(title, "R vs Z (#eta = %d, depth = %d)", eta, depth);
247  etaDepth_[eta * 100 + depth] = h_rzH_.size();
248  h_rzH_.emplace_back(tfile->make<TH2F>(name, title, 120, 0., 600., 100, 0., 250.));
249  h_rzH_.back()->GetXaxis()->SetTitle("z (cm)");
250  h_rzH_.back()->GetYaxis()->SetTitle("R (cm)");
251  }
252  }
253  }
254  }
255 }
256 
259  std::vector<std::string> labels = {"EcalHitsEB1", "EcalHitsEE1", "HcalHits1"};
260  std::vector<double> times = {1, 1, 1};
261  desc.addUntracked<std::string>("moduleLabel", "g4SimHits");
262  desc.add<std::vector<std::string> >("hitCollection", labels);
263  desc.add<std::vector<double> >("timeSliceUnit", times);
264  desc.addUntracked<double>("maxEnergy", 250.0);
265  desc.addUntracked<double>("maxTime", 1000.0);
266  desc.addUntracked<double>("timeCut", 100.0);
267  desc.addUntracked<double>("timeScale", 1.0);
268  desc.addUntracked<double>("timeThreshold", 15.0);
269  desc.addUntracked<bool>("testNumbering", false);
270  desc.addUntracked<bool>("passiveHits", false);
271  std::vector<std::string> names = {"PixelBarrel", "PixelForward", "TIB", "TID", "TOB", "TEC"};
272  desc.addUntracked<std::vector<std::string> >("detNames", names);
273  desc.addUntracked<int>("allStep", 100);
274  descriptions.add("caloSimHitAnalysis", desc);
275 }
276 
278  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis:Run = " << e.id().run() << " Event = " << e.id().event();
279 
280  edm::ESHandle<CaloGeometry> calo_handle;
281  set.get<CaloGeometryRecord>().get(calo_handle);
282  caloGeometry_ = calo_handle.product();
283  hcalGeom_ = static_cast<const HcalGeometry*>(caloGeometry_->getSubdetectorGeometry(DetId::Hcal, HcalBarrel));
284 
285  for (unsigned int i = 0; i < toks_calo_.size(); i++) {
287  e.getByToken(toks_calo_[i], hitsCalo);
288  bool getHits = (hitsCalo.isValid());
289 #ifdef EDM_ML_DEBUG
290  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis: Input flags Hits[" << i << "]: " << getHits;
291 #endif
292  if (getHits) {
293  std::vector<PCaloHit> caloHits;
294  caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
295 #ifdef EDM_ML_DEBUG
296  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis: Hit buffer [" << i << "] " << caloHits.size();
297 #endif
298  analyzeHits(caloHits, i);
299  }
300  }
301 
302  if (passive_) {
304  e.getByToken(tok_passive_, hitsPassive);
305  bool getHits = (hitsPassive.isValid());
306 #ifdef EDM_ML_DEBUG
307  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis: Passive: " << getHits;
308 #endif
309  if (getHits) {
310  std::vector<PassiveHit> passiveHits;
311  passiveHits.insert(passiveHits.end(), hitsPassive->begin(), hitsPassive->end());
312 #ifdef EDM_ML_DEBUG
313  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis: Passive Hit buffer " << passiveHits.size();
314 #endif
315  analyzePassiveHits(passiveHits);
316  }
317  }
318 }
319 
320 void CaloSimHitAnalysis::analyzeHits(std::vector<PCaloHit>& hits, int indx) {
321  int nHit = hits.size();
322  int nHB = 0, nHE = 0, nHO = 0, nHF = 0, nEB = 0, nEE = 0, nBad = 0, iHit = 0;
323  std::map<CaloHitID, std::pair<double, double> > hitMap;
324  double etot[nCalo_], etotG[nCalo_];
325  for (unsigned int k = 0; k < nCalo_; ++k) {
326  etot[k] = etotG[k] = 0;
327  }
328  for (const auto& hit : hits) {
329  double edep = hit.energy();
330  double time = tScale_ * hit.time();
331  uint32_t id = hit.id();
332  int itra = hit.geantTrackId();
333  double edepEM = hit.energyEM();
334  double edepHad = hit.energyHad();
335  int idx(-1);
336  if (indx != 2) {
337  idx = indx;
338  if (indx == 0)
339  ++nEB;
340  else
341  ++nEE;
342  } else {
343  int subdet(0);
344  if (testNumber_) {
345  int ieta(0), phi(0), z(0), lay(0), depth(0);
346  HcalTestNumbering::unpackHcalIndex(id, subdet, z, depth, ieta, phi, lay);
347  id = HcalDetId(static_cast<HcalSubdetector>(subdet), z * ieta, phi, depth).rawId();
348  } else {
349  subdet = HcalDetId(id).subdet();
350  }
351  if (subdet == static_cast<int>(HcalBarrel)) {
352  idx = indx;
353  nHB++;
354  } else if (subdet == static_cast<int>(HcalEndcap)) {
355  idx = indx + 1;
356  nHE++;
357  } else if (subdet == static_cast<int>(HcalOuter)) {
358  idx = indx + 2;
359  nHO++;
360  } else if (subdet == static_cast<int>(HcalForward)) {
361  idx = indx + 3;
362  nHF++;
363  }
364  }
365 #ifdef EDM_ML_DEBUG
366  edm::LogVerbatim("HitStudy") << "Hit[" << iHit << ":" << nHit << ":" << idx << "] E " << edep << ":" << edepEM
367  << ":" << edepHad << " T " << time << " itra " << itra << " ID " << std::hex << id
368  << std::dec;
369 #endif
370  ++iHit;
371  if (idx >= 0) {
372  CaloHitID hid(id, time, itra, 0, timeSliceUnit_[indx]);
373  auto itr = hitMap.find(hid);
374  if (itr == hitMap.end())
375  hitMap[hid] = std::make_pair(time, edep);
376  else
377  ((itr->second).second) += edep;
378  h_edepT_[idx]->Fill(edep);
379  h_timeT_[idx]->Fill(time);
380  if (edepEM > 0)
381  h_edepEM_[idx]->Fill(edepEM);
382  if (edepHad > 0)
383  h_edepHad_[idx]->Fill(edepHad);
384  if (time > tCut_)
385  h_edepT1_[idx]->Fill(edep);
386  } else {
387  ++nBad;
388  }
389  }
390 
391  //Now make plots
392  for (auto itr = hitMap.begin(); itr != hitMap.end(); ++itr) {
393  int idx = -1;
395  DetId id((itr->first).unitID());
396 #ifdef EDM_ML_DEBUG
397  edm::LogVerbatim("HitStudy") << "Index " << indx << " Geom " << caloGeometry_ << ":" << hcalGeom_ << " "
398  << std::hex << id.rawId() << std::dec;
399 #endif
400  if (indx != 2) {
401  idx = indx;
403  } else {
404  int subdet = id.subdetId();
405  if (subdet == static_cast<int>(HcalBarrel)) {
406  idx = indx;
407  } else if (subdet == static_cast<int>(HcalEndcap)) {
408  idx = indx + 1;
409  } else if (subdet == static_cast<int>(HcalOuter)) {
410  idx = indx + 2;
411  } else if (subdet == static_cast<int>(HcalForward)) {
412  idx = indx + 3;
413  }
414  point = hcalGeom_->getPosition(id);
415  }
416  double edep = (itr->second).second;
417  double time = (itr->second).first;
418 #ifdef EDM_ML_DEBUG
419  edm::LogVerbatim("HitStudy") << "Index " << idx << ":" << nCalo_ << " Point " << point << " E " << edep << " T "
420  << time;
421 #endif
422  if (idx >= 0) {
423  h_time_[idx]->Fill(time);
424  h_edep_[idx]->Fill(edep);
425  h_rr_[idx]->Fill(point.perp());
426  h_zz_[idx]->Fill(point.z());
427  h_eta_[idx]->Fill(point.eta());
428  h_phi_[idx]->Fill(point.phi());
429  h_rz_->Fill(std::abs(point.z()), point.perp());
430  h_etaphi_->Fill(std::abs(point.eta()), std::abs(point.phi()));
431  etot[idx] += edep;
432  if (time < tMax_)
433  etotG[idx] += edep;
434  if (time > tCut_) {
435  h_edep1_[idx]->Fill(edep);
436  h_rz1_->Fill(std::abs(point.z()), point.perp());
437  }
438  }
439  }
440 
441  if (indx < 2) {
442  h_etot_[indx]->Fill(etot[indx]);
443  h_etotg_[indx]->Fill(etotG[indx]);
444  if (indx == 0)
445  h_hit_[indx]->Fill(double(nEB));
446  else
447  h_hit_[indx]->Fill(double(nEE));
448  } else {
449  h_hit_[2]->Fill(double(nHB));
450  h_hit_[3]->Fill(double(nHE));
451  h_hit_[4]->Fill(double(nHO));
452  h_hit_[5]->Fill(double(nHF));
453  for (int idx = 2; idx < nCalo_; idx++) {
454  h_etot_[idx]->Fill(etot[idx]);
455  h_etotg_[idx]->Fill(etotG[idx]);
456  }
457  }
458 
459  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis::analyzeHits: EB " << nEB << " EE " << nEE << " HB " << nHB
460  << " HE " << nHE << " HO " << nHO << " HF " << nHF << " Bad " << nBad << " All " << nHit
461  << " Reduced " << hitMap.size();
462 }
463 
464 void CaloSimHitAnalysis::analyzePassiveHits(std::vector<PassiveHit>& hits) {
465  const std::string active = "Active";
466  const std::string sensor = "Sensor";
467  std::map<std::pair<std::string, uint32_t>, int> hitx;
468  std::map<int, int> tracks;
469  unsigned int passive1(0), passive2(0);
470  for (auto& hit : hits) {
471  std::string name = hit.vname();
472  std::pair<std::string, uint32_t> volume = std::make_pair(name, (hit.id() % 1000000));
473  auto itr = hitx.find(volume);
474  if (itr == hitx.end())
475  hitx[volume] = 1;
476  else
477  ++(itr->second);
478  auto ktr = tracks.find(hit.trackId());
479  if (ktr == tracks.end())
480  tracks[hit.trackId()] = 1;
481  else
482  ++(ktr->second);
483  h_edepp_->Fill(hit.energy());
484  h_timep_->Fill(hit.time());
485  h_stepp_->Fill(hit.stepLength());
486  if ((name.find(active) != std::string::npos) || (name.find(sensor) != std::string::npos)) {
487  unsigned idet = detNames_.size();
488  for (unsigned int k = 0; k < detNames_.size(); ++k) {
489  if (name.find(detNames_[k]) != std::string::npos) {
490  idet = k;
491  break;
492  }
493  }
494  if (idet < detNames_.size()) {
495  h_edepTk_[idet]->Fill(hit.energy());
496  h_timeTk_[idet]->Fill(hit.time());
497  }
498  }
499 
500  if ((allSteps_ / 100) % 10 > 0) {
501  uint32_t id = hit.id();
502  if (DetId(id).det() == DetId::Hcal) {
503  HcalDetId hid = HcalDetId(id);
504  int indx = (100 * hid.ietaAbs() + hid.depth());
505  auto itr = etaDepth_.find(indx);
506 #ifdef EDM_ML_DEBUG
507  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis::ID: " << hid << " Index " << indx << " Iterator "
508  << (itr != etaDepth_.end());
509 #endif
510  ++passive1;
511  if (itr != etaDepth_.end()) {
512  uint32_t ipos = itr->second;
513  double rr = std::sqrt(hit.x() * hit.x() + hit.y() * hit.y());
514  if (ipos < h_rzH_.size()) {
515  h_rzH_[ipos]->Fill(hit.z(), rr);
516  ++passive2;
517  }
518  }
519  }
520  }
521  }
522  h_hitp_->Fill(hitx.size());
523  h_trackp_->Fill(tracks.size());
524  edm::LogVerbatim("HitStudy") << "CaloSimHitAnalysis::analyzPassiveHits: Total " << hits.size() << " Cells "
525  << hitx.size() << " Tracks " << tracks.size() << " Passive " << passive1 << ":"
526  << passive2;
527 }
528 
529 //define this as a plug-in
ConfigurationDescriptions.h
CaloSimHitAnalysis::h_timeTk_
std::vector< TH1F * > h_timeTk_
Definition: CaloSimHitAnalysis.cc:81
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
CaloSimHitAnalysis::h_edepT1_
TH1F * h_edepT1_[nCalo_]
Definition: CaloSimHitAnalysis.cc:76
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
electrons_cff.bool
bool
Definition: electrons_cff.py:366
EDAnalyzer.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
PassiveHit.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
hit::y
double y
Definition: SiStripHitEffFromCalibTree.cc:90
CaloSimHitAnalysis::passive_
const bool passive_
Definition: CaloSimHitAnalysis.cc:65
ESHandle.h
CaloSimHitAnalysis::g4Label_
const std::string g4Label_
Definition: CaloSimHitAnalysis.cc:61
edm::Run
Definition: Run.h:45
CaloGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
CaloSimHitAnalysis::toks_calo_
std::vector< edm::EDGetTokenT< edm::PCaloHitContainer > > toks_calo_
Definition: CaloSimHitAnalysis.cc:68
edm::EDGetTokenT< edm::PassiveHitContainer >
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
CaloSimHitAnalysis::analyzeHits
void analyzeHits(std::vector< PCaloHit > &, int)
Definition: CaloSimHitAnalysis.cc:320
EBDetId.h
EEDetId.h
CaloSimHitAnalysis::beginJob
void beginJob() override
Definition: CaloSimHitAnalysis.cc:52
DetId::Hcal
Definition: DetId.h:28
CaloSimHitAnalysis::~CaloSimHitAnalysis
~CaloSimHitAnalysis() override
Definition: CaloSimHitAnalysis.cc:48
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
CaloSimHitAnalysis::testNumber_
const bool testNumber_
Definition: CaloSimHitAnalysis.cc:65
protons_cff.time
time
Definition: protons_cff.py:39
CaloSimHitAnalysis::h_rz_
TH2F * h_rz_
Definition: CaloSimHitAnalysis.cc:79
CaloSimHitAnalysis::h_etotg_
TH1F * h_etotg_[nCalo_]
Definition: CaloSimHitAnalysis.cc:78
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
HcalDetId::depth
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164
CaloHitID.h
HcalTestNumbering.h
CaloSimHitAnalysis::tScale_
const double tScale_
Definition: CaloSimHitAnalysis.cc:64
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
HcalBarrel
Definition: HcalAssistant.h:33
CaloSimHitAnalysis::h_edepHad_
TH1F * h_edepHad_[nCalo_]
Definition: CaloSimHitAnalysis.cc:77
CaloSimHitAnalysis::tMax_
const double tMax_
Definition: CaloSimHitAnalysis.cc:64
CaloSimHitAnalysis::h_etaphi_
TH2F * h_etaphi_
Definition: CaloSimHitAnalysis.cc:79
edm::Handle
Definition: AssociativeIterator.h:50
HcalGeometry.h
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
CaloSimHitAnalysis::h_edep_
TH1F * h_edep_[nCalo_]
Definition: CaloSimHitAnalysis.cc:75
hit::x
double x
Definition: SiStripHitEffFromCalibTree.cc:89
CaloSimHitAnalysis::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CaloSimHitAnalysis.cc:257
CaloSimHitAnalysis::h_rr_
TH1F * h_rr_[nCalo_]
Definition: CaloSimHitAnalysis.cc:77
CaloSimHitAnalysis::tok_passive_
edm::EDGetTokenT< edm::PassiveHitContainer > tok_passive_
Definition: CaloSimHitAnalysis.cc:69
DetId
Definition: DetId.h:17
MakerMacros.h
CaloSimHitAnalysis::h_edepT_
TH1F * h_edepT_[nCalo_]
Definition: CaloSimHitAnalysis.cc:75
CaloGeometry
Definition: CaloGeometry.h:21
CaloSimHitAnalysis::h_time_
TH1F * h_time_[nCalo_]
Definition: CaloSimHitAnalysis.cc:75
CaloSimHitAnalysis::h_hitp_
TH1F * h_hitp_
Definition: CaloSimHitAnalysis.cc:80
HcalTestNumbering::unpackHcalIndex
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
Definition: HcalTestNumbering.cc:18
CaloSimHitAnalysis::hitLab_
const std::vector< std::string > hitLab_
Definition: CaloSimHitAnalysis.cc:62
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
CaloSimHitAnalysis::CaloSimHitAnalysis
CaloSimHitAnalysis(const edm::ParameterSet &ps)
Definition: CaloSimHitAnalysis.cc:86
CaloSimHitAnalysis::etaDepth_
std::map< int, unsigned int > etaDepth_
Definition: CaloSimHitAnalysis.cc:83
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1TOccupancyClient_cfi.ymax
ymax
Definition: L1TOccupancyClient_cfi.py:43
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
CaloSimHitAnalysis::hcalGeom_
const HcalGeometry * hcalGeom_
Definition: CaloSimHitAnalysis.cc:72
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
Service.h
PVValHelper::eta
Definition: PVValidationHelpers.h:70
CaloSimHitAnalysis::h_edepTk_
std::vector< TH1F * > h_edepTk_
Definition: CaloSimHitAnalysis.cc:81
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
CaloSimHitAnalysis::h_etot_
TH1F * h_etot_[nCalo_]
Definition: CaloSimHitAnalysis.cc:78
tfile
Definition: tfile.py:1
DDAxes::z
edm::ESHandle< CaloGeometry >
HcalOuter
Definition: HcalAssistant.h:35
CaloSimHitAnalysis::h_hit_
TH1F * h_hit_[nCalo_]
Definition: CaloSimHitAnalysis.cc:75
CaloSimHitAnalysis::maxEnergy_
const double maxEnergy_
Definition: CaloSimHitAnalysis.cc:64
dqmdumpme.k
k
Definition: dqmdumpme.py:60
CaloSimHitAnalysis::timeSliceUnit_
const std::vector< double > timeSliceUnit_
Definition: CaloSimHitAnalysis.cc:63
Point3DBase< float, GlobalTag >
CaloSimHitAnalysis::h_zz_
TH1F * h_zz_[nCalo_]
Definition: CaloSimHitAnalysis.cc:77
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
CaloSimHitAnalysis::h_edepp_
TH1F * h_edepp_
Definition: CaloSimHitAnalysis.cc:80
hit::z
double z
Definition: SiStripHitEffFromCalibTree.cc:91
CaloGeometryRecord.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CaloSimHitAnalysis::detNames_
const std::vector< std::string > detNames_
Definition: CaloSimHitAnalysis.cc:67
TFileService.h
CaloSimHitAnalysis::h_phi_
TH1F * h_phi_[nCalo_]
Definition: CaloSimHitAnalysis.cc:78
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
CaloSubdetectorGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
HcalGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Definition: HcalGeometry.cc:179
CaloSimHitAnalysis::h_eta_
TH1F * h_eta_[nCalo_]
Definition: CaloSimHitAnalysis.cc:78
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
HcalDetId.h
CaloSimHitAnalysis::h_rz1_
TH2F * h_rz1_
Definition: CaloSimHitAnalysis.cc:79
CaloSimHitAnalysis::h_rzH_
std::vector< TH2F * > h_rzH_
Definition: CaloSimHitAnalysis.cc:82
PCaloHit.h
HcalDetId::subdet
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
HcalDetId
Definition: HcalDetId.h:12
edm::Service< TFileService >
createfilelist.int
int
Definition: createfilelist.py:10
CaloSimHitAnalysis::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: CaloSimHitAnalysis.cc:55
CaloSimHitAnalysis::maxTime_
const double maxTime_
Definition: CaloSimHitAnalysis.cc:64
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
HcalSubdetector.h
get
#define get
CaloSimHitAnalysis::allSteps_
const int allSteps_
Definition: CaloSimHitAnalysis.cc:66
InputTag.h
CaloSimHitAnalysis
Definition: CaloSimHitAnalysis.cc:45
compare.tfile
tfile
Definition: compare.py:325
HcalForward
Definition: HcalAssistant.h:36
DDAxes::phi
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
CaloSimHitAnalysis::h_stepp_
TH1F * h_stepp_
Definition: CaloSimHitAnalysis.cc:80
HcalEndcap
Definition: HcalAssistant.h:34
CaloSimHitAnalysis::nCalo_
static constexpr int nCalo_
Definition: CaloSimHitAnalysis.cc:74
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
CaloSimHitAnalysis::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: CaloSimHitAnalysis.cc:54
CaloHitID
Definition: CaloHitID.h:11
CaloGeometry.h
TFileService::kSharedResource
static const std::string kSharedResource
Definition: TFileService.h:76
CaloSimHitAnalysis::h_edep1_
TH1F * h_edep1_[nCalo_]
Definition: CaloSimHitAnalysis.cc:76
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
CaloSimHitAnalysis::h_edepEM_
TH1F * h_edepEM_[nCalo_]
Definition: CaloSimHitAnalysis.cc:77
Exception.h
PCaloHitContainer.h
CaloSimHitAnalysis::caloGeometry_
const CaloGeometry * caloGeometry_
Definition: CaloSimHitAnalysis.cc:71
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CaloSimHitAnalysis::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: CaloSimHitAnalysis.cc:277
HcalDetId::ietaAbs
constexpr int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:148
ParameterSet.h
CaloSimHitAnalysis::h_timeT_
TH1F * h_timeT_[nCalo_]
Definition: CaloSimHitAnalysis.cc:76
CaloSimHitAnalysis::analyzePassiveHits
void analyzePassiveHits(std::vector< PassiveHit > &hits)
Definition: CaloSimHitAnalysis.cc:464
point
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
CaloSimHitAnalysis::h_trackp_
TH1F * h_trackp_
Definition: CaloSimHitAnalysis.cc:80
CaloSimHitAnalysis::tCut_
const double tCut_
Definition: CaloSimHitAnalysis.cc:64
CaloSimHitAnalysis::h_timep_
TH1F * h_timep_
Definition: CaloSimHitAnalysis.cc:80
edm::Log
Definition: MessageLogger.h:70
HcalGeometry
Definition: HcalGeometry.h:17
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37