CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCalSimHitValidation.cc
Go to the documentation of this file.
1 // system include files
2 #include <cmath>
3 #include <iostream>
4 #include <fstream>
5 #include <vector>
6 #include <map>
7 #include <string>
8 
13 
21 
24 
33 
37 
42 
43 #include "CLHEP/Geometry/Point3D.h"
44 #include "CLHEP/Geometry/Transform3D.h"
45 #include "CLHEP/Geometry/Vector3D.h"
46 #include "CLHEP/Units/GlobalSystemOfUnits.h"
47 #include "CLHEP/Units/GlobalPhysicalConstants.h"
48 
50 public:
51  struct energysum {
53  etotal = 0;
54  for (int i = 0; i < 6; ++i)
55  eTime[i] = 0.;
56  }
57  double eTime[6], etotal;
58  };
59 
60  struct hitsinfo {
62  x = y = z = phi = eta = 0.0;
63  cell = cell2 = sector = sector2 = type = layer = 0;
64  }
65  double x, y, z, phi, eta;
67  };
68 
70  ~HGCalSimHitValidation() override {}
71 
72  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
73 
74 protected:
75  void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override;
76  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
77  void analyze(const edm::Event&, const edm::EventSetup&) override;
78 
79 private:
80  void analyzeHits(std::vector<PCaloHit>& hits);
81  void fillOccupancyMap(std::map<int, int>& OccupancyMap, int layer);
82  void fillHitsInfo(std::pair<hitsinfo, energysum> hit_, unsigned int itimeslice, double esum);
83  bool defineGeometry(const DDCompactView* ddViewH);
84  bool defineGeometry(const cms::DDCompactView* ddViewH);
85 
86  TH1F* createHisto(std::string histname, const int nbins, float minIndexX, float maxIndexX, bool isLogX = true);
87  void histoSetting(TH1F*& histo,
88  const char* xTitle,
89  const char* yTitle = "",
90  Color_t lineColor = kBlack,
91  Color_t markerColor = kBlack,
92  int linewidth = 1);
93  void histoSetting(TH2F*& histo,
94  const char* xTitle,
95  const char* yTitle = "",
96  Color_t lineColor = kBlack,
97  Color_t markerColor = kBlack,
98  int linewidth = 1);
99  void fillMuonTomoHistos(int partialType, std::pair<hitsinfo, energysum> hit_);
100 
101  // ----------member data ---------------------------
104  const std::vector<double> times_;
105  const int verbosity_;
106  const bool fromDDD_;
112  bool symmDet_;
113  unsigned int layers_;
115  std::map<uint32_t, HepGeom::Transform3D> transMap_;
116 
117  std::vector<MonitorElement*> HitOccupancy_Plus_, HitOccupancy_Minus_;
118  std::vector<MonitorElement*> EtaPhi_Plus_, EtaPhi_Minus_;
120  static const unsigned int maxTime_ = 6;
121  std::vector<MonitorElement*> energy_[maxTime_];
122  std::vector<MonitorElement*> energyFWF_, energyFWCN_, energyFWCK_;
123  std::vector<MonitorElement*> energyPWF_, energyPWCN_, energyPWCK_;
124  std::vector<MonitorElement*> hitXYFWF_, hitXYFWCN_, hitXYFWCK_, hitXYB_;
125  unsigned int nTimes_;
126 };
127 
129  : nameDetector_(iConfig.getParameter<std::string>("DetectorName")),
130  caloHitSource_(iConfig.getParameter<std::string>("CaloHitSource")),
131  times_(iConfig.getParameter<std::vector<double> >("TimeSlices")),
132  verbosity_(iConfig.getUntrackedParameter<int>("Verbosity", 0)),
133  fromDDD_(iConfig.getUntrackedParameter<bool>("fromDDD", true)),
134  tok_hgcal_(esConsumes<HGCalDDDConstants, IdealGeometryRecord, edm::Transition::BeginRun>(
135  edm::ESInputTag{"", nameDetector_})),
136  tok_cpv_(esConsumes<DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>()),
137  tok_cpvc_(esConsumes<cms::DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>()),
138  symmDet_(true),
139  firstLayer_(1) {
140  tok_hepMC_ = consumes<edm::HepMCProduct>(edm::InputTag("generatorSmeared"));
141  tok_hits_ = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", caloHitSource_));
142  nTimes_ = (times_.size() > maxTime_) ? maxTime_ : times_.size();
143 }
144 
147  std::vector<double> times = {25.0, 1000.0};
148  desc.add<std::string>("DetectorName", "HGCalEESensitive");
149  desc.add<std::string>("CaloHitSource", "HGCHitsEE");
150  desc.add<std::vector<double> >("TimeSlices", times);
151  desc.addUntracked<int>("Verbosity", 0);
152  desc.addUntracked<bool>("TestNumber", true);
153  desc.addUntracked<bool>("fromDDD", true);
154  descriptions.add("hgcalSimHitValidationEE", desc);
155 }
156 
158  //Generator input
159  if (verbosity_ > 0) {
161  iEvent.getByToken(tok_hepMC_, evtMC);
162  if (!evtMC.isValid()) {
163  edm::LogVerbatim("HGCalValidation") << "no HepMCProduct found";
164  } else {
165  const HepMC::GenEvent* myGenEvent = evtMC->GetEvent();
166  unsigned int k(0);
167  for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end();
168  ++p, ++k) {
169  edm::LogVerbatim("HGCalValidation") << "Particle[" << k << "] with pt " << (*p)->momentum().perp() << " eta "
170  << (*p)->momentum().eta() << " phi " << (*p)->momentum().phi();
171  }
172  }
173  }
174 
175  //Now the hits
176  edm::Handle<edm::PCaloHitContainer> theCaloHitContainers;
177  iEvent.getByToken(tok_hits_, theCaloHitContainers);
178  if (theCaloHitContainers.isValid()) {
179  if (verbosity_ > 0)
180  edm::LogVerbatim("HGCalValidation") << " PcalohitItr = " << theCaloHitContainers->size();
181  std::vector<PCaloHit> caloHits;
182  caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), theCaloHitContainers->end());
183  analyzeHits(caloHits);
184  } else if (verbosity_ > 0) {
185  edm::LogVerbatim("HGCalValidation") << "PCaloHitContainer does not exist!";
186  }
187 }
188 
189 void HGCalSimHitValidation::analyzeHits(std::vector<PCaloHit>& hits) {
190  std::map<int, int> OccupancyMap_plus, OccupancyMap_minus;
191  OccupancyMap_plus.clear();
192  OccupancyMap_minus.clear();
193 
194  std::map<uint32_t, std::pair<hitsinfo, energysum> > map_hits;
195  map_hits.clear();
196 
197  if (verbosity_ > 0)
198  edm::LogVerbatim("HGCalValidation") << nameDetector_ << " with " << hits.size() << " PcaloHit elements";
199  unsigned int nused(0);
200  for (unsigned int i = 0; i < hits.size(); i++) {
201  double energy = hits[i].energy();
202  double time = hits[i].time();
203  uint32_t id_ = hits[i].id();
204  int cell, sector, subsector(0), layer, zside;
205  int cell2(0), type(0);
206  if (hgcons_->waferHexagon8()) {
207  HGCSiliconDetId detId = HGCSiliconDetId(id_);
208  cell = detId.cellU();
209  cell2 = detId.cellV();
210  sector = detId.waferU();
211  subsector = detId.waferV();
212  type = detId.type();
213  layer = detId.layer();
214  zside = detId.zside();
215  } else if (hgcons_->tileTrapezoid()) {
217  sector = detId.ietaAbs();
218  cell = detId.iphi();
219  subsector = 1;
220  type = detId.type();
221  layer = detId.layer();
222  zside = detId.zside();
223  } else {
224  int subdet;
225  HGCalTestNumbering::unpackHexagonIndex(id_, subdet, zside, layer, sector, type, cell);
226  }
227  nused++;
228  if (verbosity_ > 1)
229  edm::LogVerbatim("HGCalValidation")
230  << "Detector " << nameDetector_ << " zside = " << zside << " sector|wafer = " << sector << ":" << subsector
231  << " type = " << type << " layer = " << layer << " cell = " << cell << ":" << cell2 << " energy = " << energy
232  << " energyem = " << hits[i].energyEM() << " energyhad = " << hits[i].energyHad() << " time = " << time;
233 
234  HepGeom::Point3D<float> gcoord;
235  std::pair<float, float> xy;
236  if (hgcons_->waferHexagon8()) {
237  xy = hgcons_->locateCell(layer, sector, subsector, cell, cell2, false, true);
238  } else if (hgcons_->tileTrapezoid()) {
239  xy = hgcons_->locateCellTrap(layer, sector, cell, false);
240  } else {
241  xy = hgcons_->locateCell(cell, layer, sector, false);
242  }
243  double zp = hgcons_->waferZ(layer, false);
244  if (zside < 0)
245  zp = -zp;
246  float xp = (zp < 0) ? -xy.first : xy.first;
247  gcoord = HepGeom::Point3D<float>(xp, xy.second, zp);
248  double tof = (gcoord.mag() * CLHEP::mm) / CLHEP::c_light;
249  if (verbosity_ > 1)
250  edm::LogVerbatim("HGCalValidation")
251  << std::hex << id_ << std::dec << " global coordinate " << gcoord << " time " << time << ":" << tof;
252  time -= tof;
253 
254  energysum esum;
255  hitsinfo hinfo;
256  if (map_hits.count(id_) != 0) {
257  hinfo = map_hits[id_].first;
258  esum = map_hits[id_].second;
259  } else {
260  hinfo.x = gcoord.x();
261  hinfo.y = gcoord.y();
262  hinfo.z = gcoord.z();
263  hinfo.sector = sector;
264  hinfo.sector2 = subsector;
265  hinfo.cell = cell;
266  hinfo.cell2 = cell2;
267  hinfo.type = type;
268  hinfo.layer = layer - firstLayer_;
269  hinfo.phi = gcoord.getPhi();
270  hinfo.eta = gcoord.getEta();
271  }
272  esum.etotal += energy;
273  for (unsigned int k = 0; k < nTimes_; ++k) {
274  if (time > 0 && time < times_[k])
275  esum.eTime[k] += energy;
276  }
277 
278  if (verbosity_ > 1)
279  edm::LogVerbatim("HGCalValidation") << " ----------------------- gx = " << hinfo.x << " gy = " << hinfo.y
280  << " gz = " << hinfo.z << " phi = " << hinfo.phi << " eta = " << hinfo.eta;
281  map_hits[id_] = std::pair<hitsinfo, energysum>(hinfo, esum);
282  }
283  if (verbosity_ > 0)
284  edm::LogVerbatim("HGCalValidation") << nameDetector_ << " with " << map_hits.size()
285  << " detector elements being hit";
286 
287  std::map<uint32_t, std::pair<hitsinfo, energysum> >::iterator itr;
288  for (itr = map_hits.begin(); itr != map_hits.end(); ++itr) {
289  hitsinfo hinfo = (*itr).second.first;
290  energysum esum = (*itr).second.second;
291  int layer = hinfo.layer;
292  double eta = hinfo.eta;
293  int type, part, orient;
294  int partialType = -1;
295  if (nameDetector_ == "HGCalEESensitive" or nameDetector_ == "HGCalHESiliconSensitive") {
296  HGCSiliconDetId detId = HGCSiliconDetId((*itr).first);
297  std::tie(type, part, orient) = hgcons_->waferType(detId);
298  partialType = part;
299  }
300 
301  for (unsigned int itimeslice = 0; itimeslice < nTimes_; itimeslice++) {
302  fillHitsInfo((*itr).second, itimeslice, esum.eTime[itimeslice]);
303  }
304 
305  if (eta > 0.0)
306  fillOccupancyMap(OccupancyMap_plus, layer);
307  else
308  fillOccupancyMap(OccupancyMap_minus, layer);
309 
310  fillMuonTomoHistos(partialType, (*itr).second);
311  }
312  if (verbosity_ > 0)
313  edm::LogVerbatim("HGCalValidation") << "With map:used:total " << hits.size() << "|" << nused << "|"
314  << map_hits.size() << " hits";
315 
316  for (auto const& itr : OccupancyMap_plus) {
317  int layer = itr.first;
318  int occupancy = itr.second;
319  HitOccupancy_Plus_.at(layer)->Fill(occupancy);
320  }
321  for (auto const& itr : OccupancyMap_minus) {
322  int layer = itr.first;
323  int occupancy = itr.second;
324  HitOccupancy_Minus_.at(layer)->Fill(occupancy);
325  }
326 }
327 
328 void HGCalSimHitValidation::fillOccupancyMap(std::map<int, int>& OccupancyMap, int layer) {
329  if (OccupancyMap.find(layer) != OccupancyMap.end()) {
330  ++OccupancyMap[layer];
331  } else {
332  OccupancyMap[layer] = 1;
333  }
334 }
335 
336 void HGCalSimHitValidation::fillHitsInfo(std::pair<hitsinfo, energysum> hits, unsigned int itimeslice, double esum) {
337  unsigned int ilayer = hits.first.layer;
338  if (ilayer < layers_) {
339  energy_[itimeslice].at(ilayer)->Fill(esum);
340  if (itimeslice == 0) {
341  EtaPhi_Plus_.at(ilayer)->Fill(hits.first.eta, hits.first.phi);
342  EtaPhi_Minus_.at(ilayer)->Fill(hits.first.eta, hits.first.phi);
343  }
344  } else {
345  if (verbosity_ > 0)
346  edm::LogVerbatim("HGCalValidation")
347  << "Problematic Hit for " << nameDetector_ << " at sector " << hits.first.sector << ":" << hits.first.sector2
348  << " layer " << hits.first.layer << " cell " << hits.first.cell << ":" << hits.first.cell2 << " energy "
349  << hits.second.etotal;
350  }
351 }
352 
353 void HGCalSimHitValidation::fillMuonTomoHistos(int partialType, std::pair<hitsinfo, energysum> hits) {
354  hitsinfo hinfo = hits.first;
355  energysum esum = hits.second;
356  double edep =
357  esum.eTime[0] * CLHEP::GeV /
358  CLHEP::keV; //index 0 and 1 corresponds to 25 ns and 1000 ns, respectively. In addititon, chaging energy loss unit to keV.
359 
360  unsigned int ilayer = hinfo.layer;
361  double x = hinfo.x * CLHEP::mm / CLHEP::cm; // chaging length unit to cm.
362  double y = hinfo.y * CLHEP::mm / CLHEP::cm;
363  if (ilayer < layers_) {
364  if (nameDetector_ == "HGCalEESensitive" or nameDetector_ == "HGCalHESiliconSensitive") {
365  // Fill the energy loss histograms for MIP
366  if (!TMath::AreEqualAbs(edep, 0.0, 1.e-5)) { //to avoid peak at zero due Eloss less than 10 mili eV.
367  if (hinfo.type == HGCSiliconDetId::HGCalFine) {
368  if (partialType == 0)
369  energyFWF_.at(ilayer)->Fill(edep);
370  if (partialType > 0)
371  energyPWF_.at(ilayer)->Fill(edep);
372  }
373  if (hinfo.type == HGCSiliconDetId::HGCalCoarseThin) {
374  if (partialType == 0)
375  energyFWCN_.at(ilayer)->Fill(edep);
376  if (partialType > 0)
377  energyPWCN_.at(ilayer)->Fill(edep);
378  }
380  if (partialType == 0)
381  energyFWCK_.at(ilayer)->Fill(edep);
382  if (partialType > 0)
383  energyPWCK_.at(ilayer)->Fill(edep);
384  }
385  }
386 
387  // Fill the XY distribution of detector hits
388  if (hinfo.type == HGCSiliconDetId::HGCalFine)
389  hitXYFWF_.at(ilayer)->Fill(x, y);
390 
392  hitXYFWCN_.at(ilayer)->Fill(x, y);
393 
395  hitXYFWCK_.at(ilayer)->Fill(x, y);
396 
397  } //is Silicon
398  if (nameDetector_ == "HGCalHEScintillatorSensitive") {
399  hitXYB_.at(ilayer)->Fill(x, y);
400  } //is Scintillator
401  } //layer condition
402 }
403 
405  if (verbosity_ > 0)
406  edm::LogVerbatim("HGCalValidation") << "Initialize HGCalDDDConstants (DDD) for " << nameDetector_ << " : "
407  << hgcons_;
408 
409  if (hgcons_->geomMode() == HGCalGeometryMode::Square) {
410  const DDCompactView& cview = *ddViewH;
411  std::string attribute = "Volume";
413 
414  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0)};
415  DDFilteredView fv(cview, filter);
416  bool dodet = fv.firstChild();
417 
418  while (dodet) {
419  const DDSolid& sol = fv.logicalPart().solid();
420  const std::string& name = sol.name().fullname();
421  int isd = (name.find(nameDetector_) == std::string::npos) ? -1 : 1;
422  if (isd > 0) {
423  std::vector<int> copy = fv.copyNumbers();
424  int nsiz = static_cast<int>(copy.size());
425  int lay = (nsiz > 0) ? copy[nsiz - 1] : -1;
426  int sec = (nsiz > 1) ? copy[nsiz - 2] : -1;
427  int zp = (nsiz > 3) ? copy[nsiz - 4] : -1;
428  if (zp != 1)
429  zp = -1;
430  const DDTrap& trp = static_cast<DDTrap>(sol);
431  int subs = (trp.alpha1() > 0 ? 1 : 0);
432  symmDet_ = (trp.alpha1() == 0 ? true : false);
433  uint32_t id = HGCalTestNumbering::packSquareIndex(zp, lay, sec, subs, 0);
434  DD3Vector x, y, z;
435  fv.rotation().GetComponents(x, y, z);
436  const CLHEP::HepRep3x3 rotation(x.X(), y.X(), z.X(), x.Y(), y.Y(), z.Y(), x.Z(), y.Z(), z.Z());
437  const CLHEP::HepRotation hr(rotation);
438  const CLHEP::Hep3Vector h3v(fv.translation().X(), fv.translation().Y(), fv.translation().Z());
439  const HepGeom::Transform3D ht3d(hr, h3v);
440  transMap_.insert(std::make_pair(id, ht3d));
441  if (verbosity_ > 2)
442  edm::LogVerbatim("HGCalValidation") << HGCalDetId(id) << " Transform using " << h3v << " and " << hr;
443  }
444  dodet = fv.next();
445  }
446  if (verbosity_ > 0)
447  edm::LogVerbatim("HGCalValidation") << "Finds " << transMap_.size() << " elements and SymmDet_ = " << symmDet_;
448  }
449  return true;
450 }
451 
453  if (verbosity_ > 0)
454  edm::LogVerbatim("HGCalValidation") << "Initialize HGCalDDDConstants (DD4hep) for " << nameDetector_ << " : "
455  << hgcons_;
456 
457  if (hgcons_->geomMode() == HGCalGeometryMode::Square) {
458  const cms::DDCompactView& cview = *ddViewH;
459  const cms::DDFilter filter("Volume", nameDetector_);
460  cms::DDFilteredView fv(cview, filter);
461 
462  while (fv.firstChild()) {
463  const auto& name = fv.name();
464  int isd = (name.find(nameDetector_) == std::string::npos) ? -1 : 1;
465  if (isd > 0) {
466  const auto& copy = fv.copyNos();
467  int nsiz = static_cast<int>(copy.size());
468  int lay = (nsiz > 0) ? copy[0] : -1;
469  int sec = (nsiz > 1) ? copy[1] : -1;
470  int zp = (nsiz > 3) ? copy[3] : -1;
471  if (zp != 1)
472  zp = -1;
473  const auto& pars = fv.parameters();
474  int subs = (pars[6] > 0 ? 1 : 0);
475  symmDet_ = (pars[6] == 0 ? true : false);
476  uint32_t id = HGCalTestNumbering::packSquareIndex(zp, lay, sec, subs, 0);
477  DD3Vector x, y, z;
478  fv.rotation().GetComponents(x, y, z);
479  const CLHEP::HepRep3x3 rotation(x.X(), y.X(), z.X(), x.Y(), y.Y(), z.Y(), x.Z(), y.Z(), z.Z());
480  const CLHEP::HepRotation hr(rotation);
481  const CLHEP::Hep3Vector h3v(fv.translation().X(), fv.translation().Y(), fv.translation().Z());
482  const HepGeom::Transform3D ht3d(hr, h3v);
483  transMap_.insert(std::make_pair(id, ht3d));
484  if (verbosity_ > 2)
485  edm::LogVerbatim("HGCalValidation") << HGCalDetId(id) << " Transform using " << h3v << " and " << hr;
486  }
487  }
488  if (verbosity_ > 0)
489  edm::LogVerbatim("HGCalValidation") << "Finds " << transMap_.size() << " elements and SymmDet_ = " << symmDet_;
490  }
491  return true;
492 }
493 
494 // ------------ method called when starting to processes a run ------------
496  hgcons_ = &iSetup.getData(tok_hgcal_);
497  layers_ = hgcons_->layers(false);
499  if (fromDDD_) {
500  const DDCompactView* pDD = &iSetup.getData(tok_cpv_);
501  defineGeometry(pDD);
502  } else {
503  const cms::DDCompactView* pDD = &iSetup.getData(tok_cpvc_);
504  defineGeometry(pDD);
505  }
506  if (verbosity_ > 0)
507  edm::LogVerbatim("HGCalValidation") << nameDetector_ << " defined with " << layers_ << " Layers with first at "
508  << firstLayer_;
509 }
510 
512  iB.setCurrentFolder("HGCAL/HGCalSimHitsV/" + nameDetector_);
513 
514  std::ostringstream histoname;
515  for (unsigned int il = 0; il < layers_; ++il) {
516  int ilayer = firstLayer_ + static_cast<int>(il);
517  auto istr1 = std::to_string(ilayer);
518  while (istr1.size() < 2) {
519  istr1.insert(0, "0");
520  }
521  histoname.str("");
522  histoname << "HitOccupancy_Plus_layer_" << istr1;
523  HitOccupancy_Plus_.push_back(iB.book1D(histoname.str().c_str(), "HitOccupancy_Plus", 501, -0.5, 500.5));
524  histoname.str("");
525  histoname << "HitOccupancy_Minus_layer_" << istr1;
526  HitOccupancy_Minus_.push_back(iB.book1D(histoname.str().c_str(), "HitOccupancy_Minus", 501, -0.5, 500.5));
527 
528  histoname.str("");
529  histoname << "EtaPhi_Plus_"
530  << "layer_" << istr1;
531  EtaPhi_Plus_.push_back(iB.book2D(histoname.str().c_str(), "Occupancy", 31, 1.45, 3.0, 72, -CLHEP::pi, CLHEP::pi));
532  histoname.str("");
533  histoname << "EtaPhi_Minus_"
534  << "layer_" << istr1;
535  EtaPhi_Minus_.push_back(
536  iB.book2D(histoname.str().c_str(), "Occupancy", 31, -3.0, -1.45, 72, -CLHEP::pi, CLHEP::pi));
537 
538  for (unsigned int itimeslice = 0; itimeslice < nTimes_; itimeslice++) {
539  histoname.str("");
540  histoname << "energy_time_" << itimeslice << "_layer_" << istr1;
541  energy_[itimeslice].push_back(iB.book1D(histoname.str().c_str(), "energy_", 100, 0, 0.1));
542  }
543 
545  if (nameDetector_ == "HGCalEESensitive" or nameDetector_ == "HGCalHESiliconSensitive") {
546  histoname.str("");
547  histoname << "energy_FullWafer_Fine_layer_" << istr1;
548  TH1F* hEdepFWF = createHisto(histoname.str(), 100, 0., 400., false);
549  histoSetting(hEdepFWF, "Eloss (keV)", "", kRed, kRed, 2);
550  energyFWF_.push_back(iB.book1D(histoname.str().c_str(), hEdepFWF));
551  hEdepFWF->Delete();
552 
553  histoname.str("");
554  histoname << "energy_FullWafer_CoarseThin_layer_" << istr1;
555  TH1F* hEdepFWCN = createHisto(histoname.str(), 100, 0., 400., false);
556  histoSetting(hEdepFWCN, "Eloss (keV)", "", kGreen + 1, kGreen + 1, 2);
557  energyFWCN_.push_back(iB.book1D(histoname.str().c_str(), hEdepFWCN));
558  hEdepFWCN->Delete();
559 
560  histoname.str("");
561  histoname << "energy_FullWafer_CoarseThick_layer_" << istr1;
562  TH1F* hEdepFWCK = createHisto(histoname.str(), 100, 0., 400., false);
563  histoSetting(hEdepFWCK, "Eloss (keV)", "", kMagenta, kMagenta, 2);
564  energyFWCK_.push_back(iB.book1D(histoname.str().c_str(), hEdepFWCK));
565  hEdepFWCK->Delete();
566  }
567 
569 
571  if (nameDetector_ == "HGCalEESensitive" or nameDetector_ == "HGCalHESiliconSensitive") {
572  histoname.str("");
573  histoname << "energy_PartialWafer_Fine_layer_" << istr1;
574  TH1F* hEdepPWF = createHisto(histoname.str(), 100, 0., 400., false);
575  histoSetting(hEdepPWF, "Eloss (keV)", "", kRed, kRed, 2);
576  energyPWF_.push_back(iB.book1D(histoname.str().c_str(), hEdepPWF));
577  hEdepPWF->Delete();
578 
579  histoname.str("");
580  histoname << "energy_PartialWafer_CoarseThin_layer_" << istr1;
581  TH1F* hEdepPWCN = createHisto(histoname.str(), 100, 0., 400., false);
582  histoSetting(hEdepPWCN, "Eloss (keV)", "", kGreen + 1, kGreen + 1, 2);
583  energyPWCN_.push_back(iB.book1D(histoname.str().c_str(), hEdepPWCN));
584  hEdepPWCN->Delete();
585 
586  histoname.str("");
587  histoname << "energy_PartialWafer_CoarseThick_layer_" << istr1;
588  TH1F* hEdepPWCK = createHisto(histoname.str(), 100, 0., 400., false);
589  histoSetting(hEdepPWCK, "Eloss (keV)", "", kMagenta, kMagenta, 2);
590  energyPWCK_.push_back(iB.book1D(histoname.str().c_str(), hEdepPWCK));
591  hEdepPWCK->Delete();
592  }
594 
595  // ///////////// Histograms for the XY distribution of fired cells/scintillator tiles ///////////////
596  if (nameDetector_ == "HGCalEESensitive" or nameDetector_ == "HGCalHESiliconSensitive") {
597  histoname.str("");
598  histoname << "hitXY_FullWafer_Fine_layer_" << istr1;
599  TH2F* hitXYFWF = new TH2F(
600  Form("hitXYFWF_%s", histoname.str().c_str()), histoname.str().c_str(), 100, -300., 300., 100, -300., 300.);
601  histoSetting(hitXYFWF, "x (cm)", "y (cm)", kRed, kRed);
602  hitXYFWF_.push_back(iB.book2D(histoname.str().c_str(), hitXYFWF));
603  hitXYFWF->Delete();
604 
605  histoname.str("");
606  histoname << "hitXY_FullWafer_CoarseThin_layer_" << istr1;
607  TH2F* hitXYFWCN = new TH2F(
608  Form("hitXYFWCN_%s", histoname.str().c_str()), histoname.str().c_str(), 100, -300., 300., 100, -300., 300.);
609  histoSetting(hitXYFWCN, "x (cm)", "y (cm)", kGreen + 1, kGreen + 1);
610  hitXYFWCN_.push_back(iB.book2D(histoname.str().c_str(), hitXYFWCN));
611  hitXYFWCN->Delete();
612 
613  histoname.str("");
614  histoname << "hitXY_FullWafer_CoarseThick_layer_" << istr1;
615  TH2F* hitXYFWCK = new TH2F(
616  Form("hitXYFWCK_%s", histoname.str().c_str()), histoname.str().c_str(), 100, -300., 300., 100, -300., 300.);
617  histoSetting(hitXYFWCK, "x (cm)", "y (cm)", kMagenta, kMagenta);
618  hitXYFWCK_.push_back(iB.book2D(histoname.str().c_str(), hitXYFWCK));
619  hitXYFWCK->Delete();
620  }
621 
622  if (nameDetector_ == "HGCalHEScintillatorSensitive") {
623  histoname.str("");
624  histoname << "hitXY_Scintillator_layer_" << istr1;
625  TH2F* hitXYB = new TH2F(
626  Form("hitXYB_%s", histoname.str().c_str()), histoname.str().c_str(), 100, -300., 300., 100, -300., 300.);
627  histoSetting(hitXYB, "x (cm)", "y (cm)", kBlue, kBlue);
628  hitXYB_.push_back(iB.book2D(histoname.str().c_str(), hitXYB));
629  hitXYB->Delete();
630  }
632  }
633  MeanHitOccupancy_Plus_ = iB.book1D("MeanHitOccupancy_Plus", "MeanHitOccupancy_Plus", layers_, 0.5, layers_ + 0.5);
634  MeanHitOccupancy_Minus_ = iB.book1D("MeanHitOccupancy_Minus", "MeanHitOccupancy_Minus", layers_, 0.5, layers_ + 0.5);
635 }
636 
638  std::string histname, const int nbins, float minIndexX, float maxIndexX, bool isLogX) {
639  TH1F* hist = nullptr;
640  if (isLogX) {
641  Double_t xbins[nbins + 1];
642  double dx = (maxIndexX - minIndexX) / nbins;
643  for (int i = 0; i <= nbins; i++) {
644  xbins[i] = TMath::Power(10, (minIndexX + i * dx));
645  }
646  hist = new TH1F(Form("hEdep_%s", histname.c_str()), histname.c_str(), nbins, xbins);
647  } else {
648  hist = new TH1F(Form("hEdep_%s", histname.c_str()), histname.c_str(), nbins, minIndexX, maxIndexX);
649  }
650  return hist;
651 }
652 
654  TH1F*& histo, const char* xTitle, const char* yTitle, Color_t lineColor, Color_t markerColor, int lineWidth) {
655  histo->SetStats();
656  histo->SetLineColor(lineColor);
657  histo->SetLineWidth(lineWidth);
658  histo->SetMarkerColor(markerColor);
659  histo->GetXaxis()->SetTitle(xTitle);
660  histo->GetYaxis()->SetTitle(yTitle);
661 }
662 
664  TH2F*& histo, const char* xTitle, const char* yTitle, Color_t lineColor, Color_t markerColor, int lineWidth) {
665  histo->SetStats();
666  histo->SetLineColor(lineColor);
667  histo->SetLineWidth(lineWidth);
668  histo->SetMarkerColor(markerColor);
669  histo->SetMarkerStyle(kFullCircle);
670  histo->SetMarkerSize(0.6);
671  histo->GetXaxis()->SetTitle(xTitle);
672  histo->GetYaxis()->SetTitle(yTitle);
673 }
675 //define this as a plug-in
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * MeanHitOccupancy_Plus_
Log< level::Info, true > LogVerbatim
bool defineGeometry(const DDCompactView *ddViewH)
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >> DD3Vector
const N & name() const
Definition: DDBase.h:59
void fillOccupancyMap(std::map< int, int > &OccupancyMap, int layer)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< MonitorElement * > HitOccupancy_Plus_
const double xbins[]
void analyze(const edm::Event &, const edm::EventSetup &) override
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
const std::vector< double > times_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
nav_type copyNumbers() const
return the stack of copy numbers
const RotationMatrix rotation() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int waferU() const
int cellV() const
edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
int type() const
get/set the type
std::string to_string(const V &value)
Definition: OMSAccess.h:71
void analyzeHits(std::vector< PCaloHit > &hits)
std::vector< MonitorElement * > energyPWF_
int zside() const
get the z-side of the cell (1/-1)
int zside(DetId const &)
std::vector< MonitorElement * > HitOccupancy_Minus_
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
int cellU() const
get the cell #&#39;s in u,v or in x,y
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
MonitorElement * MeanHitOccupancy_Minus_
constexpr std::array< uint8_t, layerIndexSize > layer
const Translation translation() const
const Double_t pi
std::vector< MonitorElement * > energyPWCN_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
const std::string nameDetector_
int iEvent
Definition: GenABIO.cc:224
unsigned int layers(bool reco) const
bool next()
set current node to the next node in the filtered tree
std::vector< MonitorElement * > hitXYFWCK_
int type() const
get the type
int layer() const
get the layer #
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
int waferV() const
static const unsigned int maxTime_
bool tileTrapezoid() const
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
const std::string fullname() const
Definition: DDName.h:43
TH1F * createHisto(std::string histname, const int nbins, float minIndexX, float maxIndexX, bool isLogX=true)
Interface to a Trapezoid.
Definition: DDSolid.h:88
Transition
Definition: Transition.h:12
int iphi() const
get the phi index
std::vector< MonitorElement * > energyFWF_
std::vector< MonitorElement * > EtaPhi_Plus_
std::string_view name() const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:70
std::vector< MonitorElement * > energyFWCN_
bool firstChild()
set the current node to the first child
HGCalSimHitValidation(const edm::ParameterSet &)
double waferZ(int layer, bool reco) const
__shared__ Hist hist
const std::vector< int > copyNos() const
The list of the volume copy numbers.
std::vector< MonitorElement * > energyFWCK_
Basic2DVector< T > xy() const
std::vector< MonitorElement * > hitXYFWF_
constexpr float sol
Definition: Config.h:48
const std::string caloHitSource_
part
Definition: HCALResponse.h:20
std::vector< MonitorElement * > energyPWCK_
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
double alpha1(void) const
Angle with respect to the y axis from the centre of the side at y=-pDy1 to the centre at y=+pDy1 of t...
Definition: DDSolid.cc:147
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hits_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< MonitorElement * > energy_[maxTime_]
int layer() const
get the layer #
int zside() const
get the z-side of the cell (1/-1)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::map< uint32_t, HepGeom::Transform3D > transMap_
bool firstChild()
set the current node to the first child ...
const edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > tok_cpvc_
void histoSetting(TH1F *&histo, const char *xTitle, const char *yTitle="", Color_t lineColor=kBlack, Color_t markerColor=kBlack, int linewidth=1)
bool waferHexagon8() const
const HGCalDDDConstants * hgcons_
const std::vector< double > parameters() const
extract shape parameters
int firstLayer() const
std::vector< MonitorElement * > EtaPhi_Minus_
const DDTranslation & translation() const
The absolute translation of the current node.
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
static uint32_t packSquareIndex(int z, int lay, int sec, int subsec, int cell)
std::vector< MonitorElement * > hitXYFWCN_
void fillMuonTomoHistos(int partialType, std::pair< hitsinfo, energysum > hit_)
std::vector< MonitorElement * > hitXYB_
const edm::ESGetToken< DDCompactView, IdealGeometryRecord > tok_cpv_
void fillHitsInfo(std::pair< hitsinfo, energysum > hit_, unsigned int itimeslice, double esum)
const edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > tok_hgcal_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
Definition: Run.h:45
int waferType(DetId const &id, bool fromFile=false) const