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