CMS 3D CMS Logo

BtlLocalRecoValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Validation/MtdValidation
4 // Class: BtlLocalRecoValidation
5 //
14 #include <string>
15 
20 
23 
30 
34 
39 
42 
44 
45 struct MTDHitData {
46  float energy;
47  float time;
48  float x_local;
49  float y_local;
50  float z_local;
51 };
52 
54 public:
56  ~BtlLocalRecoValidation() override;
57 
58  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
59 
60 private:
61  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
62 
63  void analyze(const edm::Event&, const edm::EventSetup&) override;
64 
65  bool isSameCluster(const FTLCluster&, const FTLCluster&);
66 
67  // ------------ member data ------------
68 
70  const double hitMinEnergy_;
71  const bool optionalPlots_;
73  const double hitMinAmplitude_;
74 
80 
83 
84  // --- histograms declaration
85 
87 
89 
94 
96 
97  //local position monitoring
102 
108 
118 
121 
125 
128 
130 
140 
159 
161 
162  // --- UncalibratedRecHits histograms
163 
164  static constexpr int nBinsQ_ = 20;
165  static constexpr float binWidthQ_ = 30.;
166  static constexpr int nBinsQEta_ = 3;
167  static constexpr float binsQEta_[nBinsQEta_ + 1] = {0., 0.65, 1.15, 1.55};
168 
171 
172  static constexpr int nBinsEta_ = 31;
173  static constexpr float binWidthEta_ = 0.05;
174  static constexpr int nBinsEtaQ_ = 7;
175  static constexpr float binsEtaQ_[nBinsEtaQ_ + 1] = {0., 30., 60., 90., 120., 150., 360., 600.};
176 
179 };
180 
182  return clu1.id() == clu2.id() && clu1.size() == clu2.size() && clu1.x() == clu2.x() && clu1.y() == clu2.y() &&
183  clu1.time() == clu2.time();
184 }
185 
186 // ------------ constructor and destructor --------------
188  : folder_(iConfig.getParameter<std::string>("folder")),
189  hitMinEnergy_(iConfig.getParameter<double>("HitMinimumEnergy")),
190  optionalPlots_(iConfig.getParameter<bool>("optionalPlots")),
191  uncalibRecHitsPlots_(iConfig.getParameter<bool>("UncalibRecHitsPlots")),
192  hitMinAmplitude_(iConfig.getParameter<double>("HitMinimumAmplitude")) {
193  btlRecHitsToken_ = consumes<FTLRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsTag"));
196  consumes<FTLUncalibratedRecHitCollection>(iConfig.getParameter<edm::InputTag>("uncalibRecHitsTag"));
197  btlSimHitsToken_ = consumes<CrossingFrame<PSimHit> >(iConfig.getParameter<edm::InputTag>("simHitsTag"));
198  btlRecCluToken_ = consumes<FTLClusterCollection>(iConfig.getParameter<edm::InputTag>("recCluTag"));
199  mtdTrackingHitToken_ = consumes<MTDTrackingDetSetVector>(iConfig.getParameter<edm::InputTag>("trkHitTag"));
200 
201  mtdgeoToken_ = esConsumes<MTDGeometry, MTDDigiGeometryRecord>();
202  mtdtopoToken_ = esConsumes<MTDTopology, MTDTopologyRcd>();
203 }
204 
206 
207 // ------------ method called for each event ------------
209  using namespace edm;
210  using namespace std;
211  using namespace geant_units::operators;
212 
213  auto geometryHandle = iSetup.getTransientHandle(mtdgeoToken_);
214  const MTDGeometry* geom = geometryHandle.product();
215 
216  auto topologyHandle = iSetup.getTransientHandle(mtdtopoToken_);
217  const MTDTopology* topology = topologyHandle.product();
218 
219  auto btlRecHitsHandle = makeValid(iEvent.getHandle(btlRecHitsToken_));
220  auto btlSimHitsHandle = makeValid(iEvent.getHandle(btlSimHitsToken_));
221  auto btlRecCluHandle = makeValid(iEvent.getHandle(btlRecCluToken_));
222  auto mtdTrkHitHandle = makeValid(iEvent.getHandle(mtdTrackingHitToken_));
223  MixCollection<PSimHit> btlSimHits(btlSimHitsHandle.product());
224 
225 #ifdef EDM_ML_DEBUG
226  for (const auto& hits : *mtdTrkHitHandle) {
227  if (MTDDetId(hits.id()).mtdSubDetector() == MTDDetId::MTDType::BTL) {
228  LogDebug("BtlLocalRecoValidation") << "MTD cluster DetId " << hits.id() << " # cluster " << hits.size();
229  for (const auto& hit : hits) {
230  LogDebug("BtlLocalRecoValidation")
231  << "MTD_TRH: " << hit.localPosition().x() << "," << hit.localPosition().y() << " : "
232  << hit.localPositionError().xx() << "," << hit.localPositionError().yy() << " : " << hit.time() << " : "
233  << hit.timeError();
234  }
235  }
236  }
237 #endif
238 
239  // --- Loop over the BTL SIM hits
240  std::unordered_map<uint32_t, MTDHitData> m_btlSimHits;
241  for (auto const& simHit : btlSimHits) {
242  // --- Use only hits compatible with the in-time bunch-crossing
243  if (simHit.tof() < 0 || simHit.tof() > 25.)
244  continue;
245 
246  DetId id = simHit.detUnitId();
247 
248  auto simHitIt = m_btlSimHits.emplace(id.rawId(), MTDHitData()).first;
249 
250  // --- Accumulate the energy (in MeV) of SIM hits in the same detector cell
251  (simHitIt->second).energy += convertUnitsTo(0.001_MeV, simHit.energyLoss());
252 
253  // --- Get the time of the first SIM hit in the cell
254  if ((simHitIt->second).time == 0 || simHit.tof() < (simHitIt->second).time) {
255  (simHitIt->second).time = simHit.tof();
256 
257  auto hit_pos = simHit.entryPoint();
258  (simHitIt->second).x_local = hit_pos.x();
259  (simHitIt->second).y_local = hit_pos.y();
260  (simHitIt->second).z_local = hit_pos.z();
261  }
262 
263  } // simHit loop
264 
265  // --- Loop over the BTL RECO hits
266  unsigned int n_reco_btl = 0;
267  for (const auto& recHit : *btlRecHitsHandle) {
268  BTLDetId detId = recHit.id();
270  const MTDGeomDet* thedet = geom->idToDet(geoId);
271  if (thedet == nullptr)
272  throw cms::Exception("BtlLocalRecoValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
273  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
274  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
275  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
276 
277  Local3DPoint local_point(0., 0., 0.);
278  local_point = topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows()));
279  const auto& global_point = thedet->toGlobal(local_point);
280 
281  meHitEnergy_->Fill(recHit.energy());
282  meHitLogEnergy_->Fill(log10(recHit.energy()));
283  meHitTime_->Fill(recHit.time());
284  meHitTimeError_->Fill(recHit.timeError());
285  meHitLongPos_->Fill(recHit.position());
286  meHitLongPosErr_->Fill(recHit.positionError());
287 
288  meOccupancy_->Fill(global_point.z(), global_point.phi());
289 
290  if (optionalPlots_) {
291  meLocalOccupancy_->Fill(local_point.x() + recHit.position(), local_point.y());
292  meHitXlocal_->Fill(local_point.x());
293  meHitYlocal_->Fill(local_point.y());
294  meHitZlocal_->Fill(local_point.z());
295  }
296  meHitX_->Fill(global_point.x());
297  meHitY_->Fill(global_point.y());
298  meHitZ_->Fill(global_point.z());
299  meHitPhi_->Fill(global_point.phi());
300  meHitEta_->Fill(global_point.eta());
301 
302  meHitTvsE_->Fill(recHit.energy(), recHit.time());
303  meHitEvsPhi_->Fill(global_point.phi(), recHit.energy());
304  meHitEvsEta_->Fill(global_point.eta(), recHit.energy());
305  meHitEvsZ_->Fill(global_point.z(), recHit.energy());
306  meHitTvsPhi_->Fill(global_point.phi(), recHit.time());
307  meHitTvsEta_->Fill(global_point.eta(), recHit.time());
308  meHitTvsZ_->Fill(global_point.z(), recHit.time());
309 
310  // Resolution histograms
311  if (m_btlSimHits.count(detId.rawId()) == 1 && m_btlSimHits[detId.rawId()].energy > hitMinEnergy_) {
312  float longpos_res = recHit.position() - convertMmToCm(m_btlSimHits[detId.rawId()].x_local);
313  float time_res = recHit.time() - m_btlSimHits[detId.rawId()].time;
314  float energy_res = recHit.energy() - m_btlSimHits[detId.rawId()].energy;
315 
316  Local3DPoint local_point_sim(convertMmToCm(m_btlSimHits[detId.rawId()].x_local),
317  convertMmToCm(m_btlSimHits[detId.rawId()].y_local),
318  convertMmToCm(m_btlSimHits[detId.rawId()].z_local));
319  local_point_sim =
320  topo.pixelToModuleLocalPoint(local_point_sim, detId.row(topo.nrows()), detId.column(topo.nrows()));
321  const auto& global_point_sim = thedet->toGlobal(local_point_sim);
322 
323  meTimeRes_->Fill(time_res);
324  meEnergyRes_->Fill(energy_res);
325 
326  meLongPosPull_->Fill(longpos_res / recHit.positionError());
327  meLongPosPullvsEta_->Fill(std::abs(global_point_sim.eta()), longpos_res / recHit.positionError());
328  meLongPosPullvsE_->Fill(m_btlSimHits[detId.rawId()].energy, longpos_res / recHit.positionError());
329 
330  meTPullvsEta_->Fill(std::abs(global_point_sim.eta()), time_res / recHit.timeError());
331  meTPullvsE_->Fill(m_btlSimHits[detId.rawId()].energy, time_res / recHit.timeError());
332  }
333 
334  n_reco_btl++;
335 
336  } // recHit loop
337 
338  if (n_reco_btl > 0)
339  meNhits_->Fill(log10(n_reco_btl));
340 
341  // --- Loop over the BTL RECO clusters ---
342  unsigned int n_clus_btl(0);
343  for (const auto& DetSetClu : *btlRecCluHandle) {
344  for (const auto& cluster : DetSetClu) {
345  if (cluster.energy() < hitMinEnergy_)
346  continue;
347  BTLDetId cluId = cluster.id();
348  DetId detIdObject(cluId);
349  const auto& genericDet = geom->idToDetUnit(detIdObject);
350  if (genericDet == nullptr) {
351  throw cms::Exception("BtlLocalRecoValidation")
352  << "GeographicalID: " << std::hex << cluId << " is invalid!" << std::dec << std::endl;
353  }
354  n_clus_btl++;
355 
356  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(genericDet->topology());
357  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
358 
359  // --- Cluster position in the module reference frame
360  Local3DPoint local_point(topo.localX(cluster.x()), topo.localY(cluster.y()), 0.);
361  const auto& global_point = genericDet->toGlobal(local_point);
362 
363  meCluEnergy_->Fill(cluster.energy());
364  meCluTime_->Fill(cluster.time());
365  meCluTimeError_->Fill(cluster.timeError());
366  meCluPhi_->Fill(global_point.phi());
367  meCluEta_->Fill(global_point.eta());
368  meCluZvsPhi_->Fill(global_point.z(), global_point.phi());
369  meCluHits_->Fill(cluster.size());
370 
371  // --- Get the SIM hits associated to the cluster and calculate
372  // the cluster SIM energy, time and position
373 
374  double cluEneSIM = 0.;
375  double cluTimeSIM = 0.;
376  double cluLocXSIM = 0.;
377  double cluLocYSIM = 0.;
378  double cluLocZSIM = 0.;
379 
380  for (int ihit = 0; ihit < cluster.size(); ++ihit) {
381  int hit_row = cluster.minHitRow() + cluster.hitOffset()[ihit * 2];
382  int hit_col = cluster.minHitCol() + cluster.hitOffset()[ihit * 2 + 1];
383 
384  // Match the RECO hit to the corresponding SIM hit
385  for (const auto& recHit : *btlRecHitsHandle) {
386  BTLDetId hitId(recHit.id().rawId());
387 
388  if (m_btlSimHits.count(hitId.rawId()) == 0)
389  continue;
390 
391  // Check the hit position
392  if (hitId.mtdSide() != cluId.mtdSide() || hitId.mtdRR() != cluId.mtdRR() || recHit.row() != hit_row ||
393  recHit.column() != hit_col)
394  continue;
395 
396  // Check the hit energy and time
397  if (recHit.energy() != cluster.hitENERGY()[ihit] || recHit.time() != cluster.hitTIME()[ihit])
398  continue;
399 
400  // SIM hit's position in the module reference frame
401  Local3DPoint local_point_sim(convertMmToCm(m_btlSimHits[recHit.id().rawId()].x_local),
402  convertMmToCm(m_btlSimHits[recHit.id().rawId()].y_local),
403  convertMmToCm(m_btlSimHits[recHit.id().rawId()].z_local));
404  local_point_sim =
405  topo.pixelToModuleLocalPoint(local_point_sim, hitId.row(topo.nrows()), hitId.column(topo.nrows()));
406 
407  // Calculate the SIM cluster's position in the module reference frame
408  cluLocXSIM += local_point_sim.x() * m_btlSimHits[recHit.id().rawId()].energy;
409  cluLocYSIM += local_point_sim.y() * m_btlSimHits[recHit.id().rawId()].energy;
410  cluLocZSIM += local_point_sim.z() * m_btlSimHits[recHit.id().rawId()].energy;
411 
412  // Calculate the SIM cluster energy and time
413  cluEneSIM += m_btlSimHits[recHit.id().rawId()].energy;
414  cluTimeSIM += m_btlSimHits[recHit.id().rawId()].time * m_btlSimHits[recHit.id().rawId()].energy;
415 
416  break;
417 
418  } // recHit loop
419 
420  } // ihit loop
421 
422  // Find the MTDTrackingRecHit corresponding to the cluster
423  const MTDTrackingRecHit* comp(nullptr);
424  bool matchClu = false;
425  const auto& trkHits = (*mtdTrkHitHandle)[detIdObject];
426  for (const auto& trkHit : trkHits) {
427  if (isSameCluster(trkHit.mtdCluster(), cluster)) {
428  comp = trkHit.clone();
429  matchClu = true;
430  break;
431  }
432  }
433  if (!matchClu) {
434  edm::LogWarning("BtlLocalRecoValidation")
435  << "No valid TrackingRecHit corresponding to cluster, detId = " << detIdObject.rawId();
436  }
437 
438  // --- Fill the cluster resolution histograms
439  if (cluTimeSIM > 0. && cluEneSIM > 0.) {
440  cluTimeSIM /= cluEneSIM;
441 
442  Local3DPoint cluLocalPosSIM(cluLocXSIM / cluEneSIM, cluLocYSIM / cluEneSIM, cluLocZSIM / cluEneSIM);
443  const auto& cluGlobalPosSIM = genericDet->toGlobal(cluLocalPosSIM);
444 
445  float time_res = cluster.time() - cluTimeSIM;
446  float energy_res = cluster.energy() - cluEneSIM;
447  meCluTimeRes_->Fill(time_res);
448  meCluEnergyRes_->Fill(energy_res);
449 
450  float rho_res = global_point.perp() - cluGlobalPosSIM.perp();
451  float phi_res = global_point.phi() - cluGlobalPosSIM.phi();
452 
453  meCluRhoRes_->Fill(rho_res);
454  meCluPhiRes_->Fill(phi_res);
455 
456  float xlocal_res = local_point.x() - cluLocalPosSIM.x();
457  float ylocal_res = local_point.y() - cluLocalPosSIM.y();
458  float z_res = global_point.z() - cluGlobalPosSIM.z();
459 
460  meCluZRes_->Fill(z_res);
461 
462  if (optionalPlots_) {
463  if (matchClu && comp != nullptr) {
464  meCluLocalXRes_->Fill(xlocal_res);
465  meCluLocalYRes_->Fill(ylocal_res);
466  meCluLocalXPull_->Fill(xlocal_res / std::sqrt(comp->localPositionError().xx()));
467  meCluLocalYPull_->Fill(ylocal_res / std::sqrt(comp->localPositionError().yy()));
468  meCluZPull_->Fill(z_res / std::sqrt(comp->globalPositionError().czz()));
469  meCluXLocalErr_->Fill(std::sqrt(comp->localPositionError().xx()));
470  meCluYLocalErr_->Fill(std::sqrt(comp->localPositionError().yy()));
471  }
472 
473  meCluYXLocal_->Fill(local_point.x(), local_point.y());
474  meCluYXLocalSim_->Fill(cluLocalPosSIM.x(), cluLocalPosSIM.y());
475  }
476 
477  meCluEnergyvsEta_->Fill(std::abs(cluGlobalPosSIM.eta()), cluster.energy());
478  meCluHitsvsEta_->Fill(std::abs(cluGlobalPosSIM.eta()), cluster.size());
479 
480  meCluTResvsEta_->Fill(std::abs(cluGlobalPosSIM.eta()), time_res);
481  meCluTResvsE_->Fill(cluEneSIM, time_res);
482 
483  meCluTPullvsEta_->Fill(std::abs(cluGlobalPosSIM.eta()), time_res / cluster.timeError());
484  meCluTPullvsE_->Fill(cluEneSIM, time_res / cluster.timeError());
485 
486  } // if ( cluTimeSIM > 0. && cluEneSIM > 0. )
487  else {
488  meUnmatchedCluEnergy_->Fill(std::log10(cluster.energy()));
489  }
490 
491  } // cluster loop
492 
493  } // DetSetClu loop
494 
495  if (n_clus_btl > 0)
496  meNclusters_->Fill(log10(n_clus_btl));
497 
498  // --- This is to count the number of processed events, needed in the harvesting step
499  meNevents_->Fill(0.5);
500 
501  // --- Loop over the BTL Uncalibrated RECO hits
502  if (uncalibRecHitsPlots_) {
503  auto btlUncalibRecHitsHandle = makeValid(iEvent.getHandle(btlUncalibRecHitsToken_));
504 
505  for (const auto& uRecHit : *btlUncalibRecHitsHandle) {
506  BTLDetId detId = uRecHit.id();
507 
508  // --- Skip UncalibratedRecHits not matched to SimHits
509  if (m_btlSimHits.count(detId.rawId()) != 1)
510  continue;
511 
513  const MTDGeomDet* thedet = geom->idToDet(geoId);
514  if (thedet == nullptr)
515  throw cms::Exception("BtlLocalRecoValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " ("
516  << detId.rawId() << ") is invalid!" << std::dec << std::endl;
517  const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(thedet->topology());
518  const RectangularMTDTopology& topo = static_cast<const RectangularMTDTopology&>(topoproxy.specificTopology());
519 
520  Local3DPoint local_point(0., 0., 0.);
521  local_point = topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows()));
522  const auto& global_point = thedet->toGlobal(local_point);
523 
524  // --- Combine the information from the left and right BTL cell sides
525 
526  float nHits = 0.;
527  float hit_amplitude = 0.;
528  float hit_time = 0.;
529 
530  // left side:
531  if (uRecHit.amplitude().first > 0.) {
532  hit_amplitude += uRecHit.amplitude().first;
533  hit_time += uRecHit.time().first;
534  nHits += 1.;
535  }
536  // right side:
537  if (uRecHit.amplitude().second > 0.) {
538  hit_amplitude += uRecHit.amplitude().second;
539  hit_time += uRecHit.time().second;
540  nHits += 1.;
541  }
542 
543  hit_amplitude /= nHits;
544  hit_time /= nHits;
545 
546  // --- Fill the histograms
547 
548  if (hit_amplitude < hitMinAmplitude_)
549  continue;
550 
551  float time_res = hit_time - m_btlSimHits[detId.rawId()].time;
552 
553  // amplitude histograms
554 
555  int qBin = (int)(hit_amplitude / binWidthQ_);
556  if (qBin > nBinsQ_ - 1)
557  qBin = nBinsQ_ - 1;
558 
559  meTimeResQ_[qBin]->Fill(time_res);
560 
561  int etaBin = 0;
562  for (int ibin = 1; ibin < nBinsQEta_; ++ibin)
563  if (fabs(global_point.eta()) >= binsQEta_[ibin] && fabs(global_point.eta()) < binsQEta_[ibin + 1])
564  etaBin = ibin;
565 
566  meTimeResQvsEta_[qBin][etaBin]->Fill(time_res);
567 
568  // eta histograms
569 
570  etaBin = (int)(fabs(global_point.eta()) / binWidthEta_);
571  if (etaBin > nBinsEta_ - 1)
572  etaBin = nBinsEta_ - 1;
573 
574  meTimeResEta_[etaBin]->Fill(time_res);
575 
576  qBin = 0;
577  for (int ibin = 1; ibin < nBinsEtaQ_; ++ibin)
578  if (hit_amplitude >= binsEtaQ_[ibin] && hit_amplitude < binsEtaQ_[ibin + 1])
579  qBin = ibin;
580 
581  meTimeResEtavsQ_[etaBin][qBin]->Fill(time_res);
582 
583  } // uRecHit loop
584  }
585 }
586 
587 // ------------ method for histogram booking ------------
589  edm::Run const& run,
590  edm::EventSetup const& iSetup) {
591  ibook.setCurrentFolder(folder_);
592 
593  // --- histograms booking
594 
595  meNevents_ = ibook.book1D("BtlNevents", "Number of events", 1, 0., 1.);
596 
597  meNhits_ = ibook.book1D("BtlNhits", "Number of BTL RECO hits;log_{10}(N_{RECO})", 100, 0., 5.25);
598 
599  meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL RECO hits energy;E_{RECO} [MeV]", 100, 0., 20.);
600  meHitLogEnergy_ = ibook.book1D("BtlHitLogEnergy", "BTL RECO hits energy;log_{10}(E_{RECO} [MeV])", 25, -1., 1.5);
601  meHitTime_ = ibook.book1D("BtlHitTime", "BTL RECO hits ToA;ToA_{RECO} [ns]", 100, 0., 25.);
602  meHitTimeError_ = ibook.book1D("BtlHitTimeError", "BTL RECO hits ToA error;#sigma^{ToA}_{RECO} [ns]", 50, 0., 0.1);
603  meOccupancy_ = ibook.book2D(
604  "BtlOccupancy", "BTL RECO hits occupancy;Z_{RECO} [cm]; #phi_{RECO} [rad]", 65, -260., 260., 126, -3.2, 3.2);
605  if (optionalPlots_) {
606  meLocalOccupancy_ = ibook.book2D(
607  "BtlLocalOccupancy", "BTL RECO hits local occupancy;X_{RECO} [cm]; Y_{RECO} [cm]", 100, 10., 10., 60, -3., 3.);
608  meHitXlocal_ = ibook.book1D("BtlHitXlocal", "BTL RECO local X;X_{RECO}^{LOC} [cm]", 100, -10., 10.);
609  meHitYlocal_ = ibook.book1D("BtlHitYlocal", "BTL RECO local Y;Y_{RECO}^{LOC} [cm]", 60, -3, 3);
610  meHitZlocal_ = ibook.book1D("BtlHitZlocal", "BTL RECO local z;z_{RECO}^{LOC} [cm]", 10, -1, 1);
611  }
612  meHitX_ = ibook.book1D("BtlHitX", "BTL RECO hits X;X_{RECO} [cm]", 60, -120., 120.);
613  meHitY_ = ibook.book1D("BtlHitY", "BTL RECO hits Y;Y_{RECO} [cm]", 60, -120., 120.);
614  meHitZ_ = ibook.book1D("BtlHitZ", "BTL RECO hits Z;Z_{RECO} [cm]", 100, -260., 260.);
615  meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL RECO hits #phi;#phi_{RECO} [rad]", 126, -3.2, 3.2);
616  meHitEta_ = ibook.book1D("BtlHitEta", "BTL RECO hits #eta;#eta_{RECO}", 100, -1.55, 1.55);
617  meHitTvsE_ =
618  ibook.bookProfile("BtlHitTvsE", "BTL RECO ToA vs energy;E_{RECO} [MeV];ToA_{RECO} [ns]", 50, 0., 20., 0., 100.);
619  meHitEvsPhi_ = ibook.bookProfile(
620  "BtlHitEvsPhi", "BTL RECO energy vs #phi;#phi_{RECO} [rad];E_{RECO} [MeV]", 50, -3.2, 3.2, 0., 100.);
621  meHitEvsEta_ = ibook.bookProfile(
622  "BtlHitEvsEta", "BTL RECO energy vs #eta;#eta_{RECO};E_{RECO} [MeV]", 50, -1.55, 1.55, 0., 100.);
623  meHitEvsZ_ =
624  ibook.bookProfile("BtlHitEvsZ", "BTL RECO energy vs Z;Z_{RECO} [cm];E_{RECO} [MeV]", 50, -260., 260., 0., 100.);
625  meHitTvsPhi_ = ibook.bookProfile(
626  "BtlHitTvsPhi", "BTL RECO ToA vs #phi;#phi_{RECO} [rad];ToA_{RECO} [ns]", 50, -3.2, 3.2, 0., 100.);
627  meHitTvsEta_ =
628  ibook.bookProfile("BtlHitTvsEta", "BTL RECO ToA vs #eta;#eta_{RECO};ToA_{RECO} [ns]", 50, -1.6, 1.6, 0., 100.);
629  meHitTvsZ_ =
630  ibook.bookProfile("BtlHitTvsZ", "BTL RECO ToA vs Z;Z_{RECO} [cm];ToA_{RECO} [ns]", 50, -260., 260., 0., 100.);
631  meHitLongPos_ = ibook.book1D("BtlLongPos", "BTL RECO hits longitudinal position;long. pos._{RECO}", 100, -10, 10);
633  ibook.book1D("BtlLongPosErr", "BTL RECO hits longitudinal position error; long. pos. error_{RECO}", 100, -1, 1);
634  meTimeRes_ = ibook.book1D("BtlTimeRes", "BTL time resolution;T_{RECO}-T_{SIM}", 100, -0.5, 0.5);
635  meEnergyRes_ = ibook.book1D("BtlEnergyRes", "BTL energy resolution;E_{RECO}-E_{SIM}", 100, -0.5, 0.5);
636  meLongPosPull_ = ibook.book1D("BtlLongPosPull",
637  "BTL longitudinal position pull;X^{loc}_{RECO}-X^{loc}_{SIM}/#sigma_{xloc_{RECO}}",
638  100,
639  -5.,
640  5.);
642  "BtlLongposPullvsE",
643  "BTL longitudinal position pull vs E;E_{SIM} [MeV];X^{loc}_{RECO}-X^{loc}_{SIM}/#sigma_{xloc_{RECO}}",
644  20,
645  0.,
646  20.,
647  -5.,
648  5.,
649  "S");
651  "BtlLongposPullvsEta",
652  "BTL longitudinal position pull vs #eta;|#eta_{RECO}|;X^{loc}_{RECO}-X^{loc}_{SIM}/#sigma_{xloc_{RECO}}",
653  32,
654  0,
655  1.55,
656  -5.,
657  5.,
658  "S");
659  meTPullvsE_ = ibook.bookProfile(
660  "BtlTPullvsE", "BTL time pull vs E;E_{SIM} [MeV];(T_{RECO}-T_{SIM})/#sigma_{T_{RECO}}", 20, 0., 20., -5., 5., "S");
661  meTPullvsEta_ = ibook.bookProfile("BtlTPullvsEta",
662  "BTL time pull vs #eta;|#eta_{RECO}|;(T_{RECO}-T_{SIM})/#sigma_{T_{RECO}}",
663  30,
664  0,
665  1.55,
666  -5.,
667  5.,
668  "S");
669 
670  meNclusters_ = ibook.book1D("BtlNclusters", "Number of BTL RECO clusters;log_{10}(N_{RECO})", 100, 0., 5.25);
671  meCluTime_ = ibook.book1D("BtlCluTime", "BTL cluster time ToA;ToA [ns]", 250, 0, 25);
672  meCluTimeError_ = ibook.book1D("BtlCluTimeError", "BTL cluster time error;#sigma_{t} [ns]", 100, 0, 0.1);
673  meCluEnergy_ = ibook.book1D("BtlCluEnergy", "BTL cluster energy;E_{RECO} [MeV]", 100, 0, 20);
674  meCluPhi_ = ibook.book1D("BtlCluPhi", "BTL cluster #phi;#phi_{RECO} [rad]", 144, -3.2, 3.2);
675  meCluEta_ = ibook.book1D("BtlCluEta", "BTL cluster #eta;#eta_{RECO}", 100, -1.55, 1.55);
676  meCluHits_ = ibook.book1D("BtlCluHitNumber", "BTL hits per cluster; Cluster size", 10, 0, 10);
677  meCluZvsPhi_ = ibook.book2D(
678  "BtlOccupancy", "BTL cluster Z vs #phi;Z_{RECO} [cm]; #phi_{RECO} [rad]", 144, -260., 260., 50, -3.2, 3.2);
680  "BtlCluEnergyVsEta", "BTL cluster energy vs #eta; |#eta_{RECO}|; E_{RECO} [cm]", 30, 0., 1.55, 0., 20., "S");
682  "BtlCluHitsVsEta", "BTL hits per cluster vs #eta; |#eta_{RECO}|;Cluster size", 30, 0., 1.55, 0., 10., "S");
683 
684  meCluTimeRes_ = ibook.book1D("BtlCluTimeRes", "BTL cluster time resolution;T_{RECO}-T_{SIM} [ns]", 100, -0.5, 0.5);
686  ibook.book1D("BtlCluEnergyRes", "BTL cluster energy resolution;E_{RECO}-E_{SIM} [MeV]", 100, -0.5, 0.5);
687  meCluTResvsE_ = ibook.bookProfile("BtlCluTResvsE",
688  "BTL cluster time resolution vs E;E_{SIM} [MeV];(T_{RECO}-T_{SIM}) [ns]",
689  20,
690  0.,
691  20.,
692  -0.5,
693  0.5,
694  "S");
695  meCluTResvsEta_ = ibook.bookProfile("BtlCluTResvsEta",
696  "BTL cluster time resolution vs #eta;|#eta_{RECO}|;(T_{RECO}-T_{SIM}) [ns]",
697  30,
698  0,
699  1.55,
700  -0.5,
701  0.5,
702  "S");
703  meCluTPullvsE_ = ibook.bookProfile("BtlCluTPullvsE",
704  "BTL cluster time pull vs E;E_{SIM} [MeV];(T_{RECO}-T_{SIM})/#sigma_{T_{RECO}}",
705  20,
706  0.,
707  20.,
708  -5.,
709  5.,
710  "S");
712  ibook.bookProfile("BtlCluTPullvsEta",
713  "BTL cluster time pull vs #eta;|#eta_{RECO}|;(T_{RECO}-T_{SIM})/#sigma_{T_{RECO}}",
714  30,
715  0,
716  1.55,
717  -5.,
718  5.,
719  "S");
720  meCluRhoRes_ =
721  ibook.book1D("BtlCluRhoRes", "BTL cluster #rho resolution;#rho_{RECO}-#rho_{SIM} [cm]", 100, -0.5, 0.5);
722  meCluPhiRes_ =
723  ibook.book1D("BtlCluPhiRes", "BTL cluster #phi resolution;#phi_{RECO}-#phi_{SIM} [rad]", 100, -0.03, 0.03);
724  meCluZRes_ = ibook.book1D("BtlCluZRes", "BTL cluster Z resolution;Z_{RECO}-Z_{SIM} [cm]", 100, -0.2, 0.2);
725  if (optionalPlots_) {
727  ibook.book1D("BtlCluLocalXRes", "BTL cluster local X resolution;X_{RECO}-X_{SIM} [cm]", 100, -3.1, 3.1);
729  ibook.book1D("BtlCluLocalYRes", "BTL cluster local Y resolution;Y_{RECO}-Y_{SIM} [cm]", 100, -3.1, 3.1);
731  ibook.book1D("BtlCluLocalXPull", "BTL cluster local X pull;X_{RECO}-X_{SIM}/sigmaX_[RECO]", 100, -5., 5.);
733  ibook.book1D("BtlCluLocalYPull", "BTL cluster local Y pull;Y_{RECO}-Y_{SIM}/sigmaY_[RECO]", 100, -5., 5.);
734  meCluZPull_ = ibook.book1D("BtlCluZPull", "BTL cluster Z pull;Z_{RECO}-Z_{SIM}/sigmaZ_[RECO]", 100, -5., 5.);
735  meCluYXLocal_ = ibook.book2D("BtlCluYXLocal",
736  "BTL cluster local Y vs X;X^{local}_{RECO} [cm];Y^{local}_{RECO} [cm]",
737  200,
738  -9.5,
739  9.5,
740  200,
741  -2.8,
742  2.8);
743  meCluYXLocalSim_ = ibook.book2D("BtlCluYXLocalSim",
744  "BTL cluster local Y vs X;X^{local}_{SIM} [cm];Y^{local}_{SIM} [cm]",
745  200,
746  -9.5,
747  9.5,
748  200,
749  -2.8,
750  2.8);
751  meCluXLocalErr_ = ibook.book1D("BtlCluXLocalErr", "BTL cluster X local error;sigmaX_{RECO,loc} [cm]", 30, 0., 3.);
752  meCluYLocalErr_ = ibook.book1D("BtlCluYLocalErr", "BTL cluster Y local error;sigmaY_{RECO,loc} [cm]", 30, 0., 0.9);
753  }
755  ibook.book1D("BtlUnmatchedCluEnergy", "BTL unmatched cluster log10(energy);log10(E_{RECO} [MeV])", 5, -3, 2);
756 
757  // --- UncalibratedRecHits histograms
758 
759  if (uncalibRecHitsPlots_) {
760  for (unsigned int ihistoQ = 0; ihistoQ < nBinsQ_; ++ihistoQ) {
761  std::string hname = Form("TimeResQ_%d", ihistoQ);
762  std::string htitle = Form("BTL time resolution (Q bin = %d);T_{RECO} - T_{SIM} [ns]", ihistoQ);
763  meTimeResQ_[ihistoQ] = ibook.book1D(hname, htitle, 200, -0.3, 0.7);
764 
765  for (unsigned int ihistoEta = 0; ihistoEta < nBinsQEta_; ++ihistoEta) {
766  hname = Form("TimeResQvsEta_%d_%d", ihistoQ, ihistoEta);
767  htitle = Form("BTL time resolution (Q bin = %d, |#eta| bin = %d);T_{RECO} - T_{SIM} [ns]", ihistoQ, ihistoEta);
768  meTimeResQvsEta_[ihistoQ][ihistoEta] = ibook.book1D(hname, htitle, 200, -0.3, 0.7);
769 
770  } // ihistoEta loop
771 
772  } // ihistoQ loop
773 
774  for (unsigned int ihistoEta = 0; ihistoEta < nBinsEta_; ++ihistoEta) {
775  std::string hname = Form("TimeResEta_%d", ihistoEta);
776  std::string htitle = Form("BTL time resolution (|#eta| bin = %d);T_{RECO} - T_{SIM} [ns]", ihistoEta);
777  meTimeResEta_[ihistoEta] = ibook.book1D(hname, htitle, 200, -0.3, 0.7);
778 
779  for (unsigned int ihistoQ = 0; ihistoQ < nBinsEtaQ_; ++ihistoQ) {
780  hname = Form("TimeResEtavsQ_%d_%d", ihistoEta, ihistoQ);
781  htitle = Form("BTL time resolution (|#eta| bin = %d, Q bin = %d);T_{RECO} - T_{SIM} [ns]", ihistoEta, ihistoQ);
782  meTimeResEtavsQ_[ihistoEta][ihistoQ] = ibook.book1D(hname, htitle, 200, -0.3, 0.7);
783 
784  } // ihistoQ loop
785 
786  } // ihistoEta loop
787  }
788 }
789 
790 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
793 
794  desc.add<std::string>("folder", "MTD/BTL/LocalReco");
795  desc.add<edm::InputTag>("recHitsTag", edm::InputTag("mtdRecHits", "FTLBarrel"));
796  desc.add<edm::InputTag>("uncalibRecHitsTag", edm::InputTag("mtdUncalibratedRecHits", "FTLBarrel"));
797  desc.add<edm::InputTag>("simHitsTag", edm::InputTag("mix", "g4SimHitsFastTimerHitsBarrel"));
798  desc.add<edm::InputTag>("recCluTag", edm::InputTag("mtdClusters", "FTLBarrel"));
799  desc.add<edm::InputTag>("trkHitTag", edm::InputTag("mtdTrackingRecHits"));
800  desc.add<double>("HitMinimumEnergy", 1.); // [MeV]
801  desc.add<bool>("optionalPlots", false);
802  desc.add<bool>("UncalibRecHitsPlots", false);
803  desc.add<double>("HitMinimumAmplitude", 30.); // [pC]
804 
805  descriptions.add("btlLocalRecoValid", desc);
806 }
807 
uint8_t geoId(const VFATFrame &frame)
retrieve the GEO information for this channel
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< MTDGeometry, MTDDigiGeometryRecord > mtdgeoToken_
std::string folder_
float x() const
Definition: FTLCluster.h:120
int size() const
Definition: FTLCluster.h:141
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
T z() const
Definition: PV3DBase.h:61
virtual const Topology & topology() const
Definition: GeomDet.cc:67
virtual const PixelTopology & specificTopology() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int mtdSide() const
Definition: MTDDetId.h:59
int row(unsigned nrows=kCrystalsPerModuleTdr) const
Definition: BTLDetId.h:73
static constexpr float binWidthQ_
MonitorElement * meUnmatchedCluEnergy_
static constexpr int nBinsEtaQ_
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int row, int col) const
edm::EDGetTokenT< MTDTrackingDetSetVector > mtdTrackingHitToken_
MonitorElement * meLongPosPullvsEta_
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
constexpr NumType convertUnitsTo(double desiredUnits, NumType val)
Definition: GeantUnits.h:73
bool isSameCluster(const FTLCluster &, const FTLCluster &)
void Fill(long long x)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
float y() const
Definition: FTLCluster.h:125
int iEvent
Definition: GenABIO.cc:224
float localX(const float mpX) const override
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
static constexpr float binWidthEta_
T sqrt(T t)
Definition: SSEVec.h:19
edm::EDGetTokenT< FTLClusterCollection > btlRecCluToken_
static constexpr float binsQEta_[nBinsQEta_+1]
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int mtdRR() const
Definition: MTDDetId.h:64
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static constexpr int nBinsQEta_
int nrows() const override
edm::ESGetToken< MTDTopology, MTDTopologyRcd > mtdtopoToken_
MonitorElement * meLocalOccupancy_
MonitorElement * meTimeResEta_[nBinsEta_]
float localY(const float mpY) const override
BtlLocalRecoValidation(const edm::ParameterSet &)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
edm::EDGetTokenT< FTLUncalibratedRecHitCollection > btlUncalibRecHitsToken_
Definition: DetId.h:17
const DetId & id() const
Definition: FTLCluster.h:178
constexpr NumType convertMmToCm(NumType millimeters)
Definition: angle_units.h:44
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::EDGetTokenT< FTLRecHitCollection > btlRecHitsToken_
A 2D TrackerRecHit with time and time error information.
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
void add(std::string const &label, ParameterSetDescription const &psetDescription)
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell const int32_t nHits
void analyze(const edm::Event &, const edm::EventSetup &) override
static constexpr int nBinsQ_
MonitorElement * meTimeResQvsEta_[nBinsQ_][nBinsQEta_]
static constexpr float binsEtaQ_[nBinsEtaQ_+1]
HLT enums.
MonitorElement * meTimeResEtavsQ_[nBinsEta_][nBinsEtaQ_]
int column(unsigned nrows=kCrystalsPerModuleTdr) const
Definition: BTLDetId.h:78
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:18
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:162
static constexpr int nBinsEta_
float time() const
Definition: FTLCluster.h:130
BTLDetId::CrysLayout crysLayoutFromTopoMode(const int &topoMode)
Log< level::Warning, false > LogWarning
auto makeValid(const U &iOtherHandleType) noexcept(false)
Definition: ValidHandle.h:52
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
edm::EDGetTokenT< CrossingFrame< PSimHit > > btlSimHitsToken_
MonitorElement * meTimeResQ_[nBinsQ_]
BTLDetId geographicalId(CrysLayout lay) const
Definition: BTLDetId.cc:3
Definition: Run.h:45
#define LogDebug(id)