164 hitMinEnergy_(iConfig.getParameter<double>(
"HitMinimumEnergy")),
165 LocalPosDebug_(iConfig.getParameter<
bool>(
"LocalPositionDebug")),
166 uncalibRecHitsPlots_(iConfig.getParameter<
bool>(
"UncalibRecHitsPlots")),
167 hitMinAmplitude_(iConfig.getParameter<double>(
"HitMinimumAmplitude")) {
175 mtdgeoToken_ = esConsumes<MTDGeometry, MTDDigiGeometryRecord>();
191 const MTDTopology* topology = topologyHandle.product();
199 std::unordered_map<uint32_t, MTDHit> m_btlSimHits;
200 for (
auto const&
simHit : btlSimHits) {
207 auto simHitIt = m_btlSimHits.emplace(
id.rawId(),
MTDHit()).first;
213 if ((simHitIt->second).time == 0 ||
simHit.tof() < (simHitIt->second).
time) {
216 auto hit_pos =
simHit.entryPoint();
217 (simHitIt->second).x_local = hit_pos.x();
218 (simHitIt->second).y_local = hit_pos.y();
219 (simHitIt->second).z_local = hit_pos.z();
225 unsigned int n_reco_btl = 0;
226 for (
const auto&
recHit : *btlRecHitsHandle) {
230 if (thedet ==
nullptr)
231 throw cms::Exception(
"BtlLocalRecoValidation") <<
"GeographicalID: " << std::hex << geoId.
rawId() <<
" ("
232 << detId.
rawId() <<
") is invalid!" <<
std::dec << std::endl;
237 local_point = topo.pixelToModuleLocalPoint(local_point, detId.
row(topo.nrows()), detId.
column(topo.nrows()));
238 const auto& global_point = thedet->
toGlobal(local_point);
271 float time_res =
recHit.time() - m_btlSimHits[detId.
rawId()].time;
272 float energy_res =
recHit.energy() - m_btlSimHits[detId.
rawId()].energy;
278 topo.pixelToModuleLocalPoint(local_point_sim, detId.
row(topo.nrows()), detId.
column(topo.nrows()));
279 const auto& global_point_sim = thedet->
toGlobal(local_point_sim);
300 for (
const auto& DetSetClu : *btlRecCluHandle) {
301 for (
const auto& cluster : DetSetClu) {
305 DetId detIdObject(cluId);
306 const auto& genericDet =
geom->idToDetUnit(detIdObject);
307 if (genericDet ==
nullptr) {
309 <<
"GeographicalID: " << std::hex << cluId <<
" is invalid!" <<
std::dec << std::endl;
312 const ProxyMTDTopology& topoproxy = static_cast<const ProxyMTDTopology&>(genericDet->topology());
316 Local3DPoint local_point(topo.localX(cluster.x()), topo.localY(cluster.y()), 0.);
317 const auto& global_point = genericDet->toGlobal(local_point);
330 double cluEneSIM = 0.;
331 double cluTimeSIM = 0.;
332 double cluLocXSIM = 0.;
333 double cluLocYSIM = 0.;
334 double cluLocZSIM = 0.;
336 for (
int ihit = 0; ihit < cluster.size(); ++ihit) {
337 int hit_row = cluster.minHitRow() + cluster.hitOffset()[ihit * 2];
338 int hit_col = cluster.minHitCol() + cluster.hitOffset()[ihit * 2 + 1];
341 for (
const auto&
recHit : *btlRecHitsHandle) {
344 if (m_btlSimHits.count(hitId.rawId()) == 0)
348 if (hitId.mtdSide() != cluId.
mtdSide() || hitId.mtdRR() != cluId.
mtdRR() ||
recHit.row() != hit_row ||
349 recHit.column() != hit_col)
353 if (
recHit.energy() != cluster.hitENERGY()[ihit] ||
recHit.time() != cluster.hitTIME()[ihit])
361 topo.pixelToModuleLocalPoint(local_point_sim, hitId.row(topo.nrows()), hitId.column(topo.nrows()));
364 cluLocXSIM += local_point_sim.
x() * m_btlSimHits[
recHit.id().rawId()].energy;
365 cluLocYSIM += local_point_sim.
y() * m_btlSimHits[
recHit.id().rawId()].energy;
366 cluLocZSIM += local_point_sim.
z() * m_btlSimHits[
recHit.id().rawId()].energy;
369 cluEneSIM += m_btlSimHits[
recHit.id().rawId()].energy;
370 cluTimeSIM += m_btlSimHits[
recHit.id().rawId()].time * m_btlSimHits[
recHit.id().rawId()].energy;
377 if (cluTimeSIM > 0. && cluEneSIM > 0.) {
378 cluTimeSIM /= cluEneSIM;
380 Local3DPoint cluLocalPosSIM(cluLocXSIM / cluEneSIM, cluLocYSIM / cluEneSIM, cluLocZSIM / cluEneSIM);
381 const auto& cluGlobalPosSIM = genericDet->toGlobal(cluLocalPosSIM);
383 float time_res = cluster.time() - cluTimeSIM;
384 float energy_res = cluster.energy() - cluEneSIM;
388 float rho_res = global_point.perp() - cluGlobalPosSIM.perp();
389 float phi_res = global_point.phi() - cluGlobalPosSIM.phi();
395 float x_res = global_point.x() - cluGlobalPosSIM.x();
396 float y_res = global_point.y() - cluGlobalPosSIM.y();
397 float z_res = global_point.z() - cluGlobalPosSIM.z();
420 for (
const auto& uRecHit : *btlUncalibRecHitsHandle) {
424 if (m_btlSimHits.count(detId.
rawId()) != 1)
429 if (thedet ==
nullptr)
430 throw cms::Exception(
"BtlLocalRecoValidation") <<
"GeographicalID: " << std::hex << geoId.
rawId() <<
" ("
431 << detId.
rawId() <<
") is invalid!" <<
std::dec << std::endl;
436 local_point = topo.pixelToModuleLocalPoint(local_point, detId.
row(topo.nrows()), detId.
column(topo.nrows()));
437 const auto& global_point = thedet->
toGlobal(local_point);
442 float hit_amplitude = 0.;
446 if (uRecHit.amplitude().first > 0.) {
447 hit_amplitude += uRecHit.amplitude().first;
448 hit_time += uRecHit.time().first;
452 if (uRecHit.amplitude().second > 0.) {
453 hit_amplitude += uRecHit.amplitude().second;
454 hit_time += uRecHit.time().second;
458 hit_amplitude /=
nHits;
466 float time_res = hit_time - m_btlSimHits[detId.
rawId()].time;
478 if (fabs(global_point.eta()) >=
binsQEta_[ibin] && fabs(global_point.eta()) <
binsQEta_[ibin + 1])
510 meNhits_ = ibook.
book1D(
"BtlNhits",
"Number of BTL RECO hits;log_{10}(N_{RECO})", 100, 0., 5.25);
512 meHitEnergy_ = ibook.
book1D(
"BtlHitEnergy",
"BTL RECO hits energy;E_{RECO} [MeV]", 100, 0., 20.);
513 meHitTime_ = ibook.
book1D(
"BtlHitTime",
"BTL RECO hits ToA;ToA_{RECO} [ns]", 100, 0., 25.);
514 meHitTimeError_ = ibook.
book1D(
"BtlHitTimeError",
"BTL RECO hits ToA error;#sigma^{ToA}_{RECO} [ns]", 50, 0., 0.1);
516 "BtlOccupancy",
"BTL RECO hits occupancy;Z_{RECO} [cm]; #phi_{RECO} [rad]", 65, -260., 260., 126, -3.2, 3.2);
519 "BtlLocalOccupancy",
"BTL RECO hits local occupancy;X_{RECO} [cm]; Y_{RECO} [cm]", 100, 10., 10., 60, -3., 3.);
520 meHitXlocal_ = ibook.
book1D(
"BtlHitXlocal",
"BTL RECO local X;X_{RECO}^{LOC} [cm]", 100, -10., 10.);
521 meHitYlocal_ = ibook.
book1D(
"BtlHitYlocal",
"BTL RECO local Y;Y_{RECO}^{LOC} [cm]", 60, -3, 3);
522 meHitZlocal_ = ibook.
book1D(
"BtlHitZlocal",
"BTL RECO local z;z_{RECO}^{LOC} [cm]", 10, -1, 1);
524 meHitX_ = ibook.
book1D(
"BtlHitX",
"BTL RECO hits X;X_{RECO} [cm]", 60, -120., 120.);
525 meHitY_ = ibook.
book1D(
"BtlHitY",
"BTL RECO hits Y;Y_{RECO} [cm]", 60, -120., 120.);
526 meHitZ_ = ibook.
book1D(
"BtlHitZ",
"BTL RECO hits Z;Z_{RECO} [cm]", 100, -260., 260.);
527 meHitPhi_ = ibook.
book1D(
"BtlHitPhi",
"BTL RECO hits #phi;#phi_{RECO} [rad]", 126, -3.2, 3.2);
528 meHitEta_ = ibook.
book1D(
"BtlHitEta",
"BTL RECO hits #eta;#eta_{RECO}", 100, -1.55, 1.55);
530 ibook.
bookProfile(
"BtlHitTvsE",
"BTL RECO ToA vs energy;E_{RECO} [MeV];ToA_{RECO} [ns]", 50, 0., 20., 0., 100.);
532 "BtlHitEvsPhi",
"BTL RECO energy vs #phi;#phi_{RECO} [rad];E_{RECO} [MeV]", 50, -3.2, 3.2, 0., 100.);
534 "BtlHitEvsEta",
"BTL RECO energy vs #eta;#eta_{RECO};E_{RECO} [MeV]", 50, -1.55, 1.55, 0., 100.);
536 ibook.
bookProfile(
"BtlHitEvsZ",
"BTL RECO energy vs Z;Z_{RECO} [cm];E_{RECO} [MeV]", 50, -260., 260., 0., 100.);
538 "BtlHitTvsPhi",
"BTL RECO ToA vs #phi;#phi_{RECO} [rad];ToA_{RECO} [ns]", 50, -3.2, 3.2, 0., 100.);
540 ibook.
bookProfile(
"BtlHitTvsEta",
"BTL RECO ToA vs #eta;#eta_{RECO};ToA_{RECO} [ns]", 50, -1.6, 1.6, 0., 100.);
542 ibook.
bookProfile(
"BtlHitTvsZ",
"BTL RECO ToA vs Z;Z_{RECO} [cm];ToA_{RECO} [ns]", 50, -260., 260., 0., 100.);
543 meHitLongPos_ = ibook.
book1D(
"BtlLongPos",
"BTL RECO hits longitudinal position;long. pos._{RECO}", 100, -10, 10);
545 ibook.
book1D(
"BtlLongPosErr",
"BTL RECO hits longitudinal position error; long. pos. error_{RECO}", 100, -1, 1);
546 meTimeRes_ = ibook.
book1D(
"BtlTimeRes",
"BTL time resolution;T_{RECO}-T_{SIM}", 100, -0.5, 0.5);
547 meEnergyRes_ = ibook.
book1D(
"BtlEnergyRes",
"BTL energy resolution;E_{RECO}-E_{SIM}", 100, -0.5, 0.5);
549 "BTL longitudinal position pull;X^{loc}_{RECO}-X^{loc}_{SIM}/#sigma_{xloc_{RECO}}",
555 "BTL longitudinal position pull vs E;E_{SIM} [MeV];X^{loc}_{RECO}-X^{loc}_{SIM}/#sigma_{xloc_{RECO}}",
563 "BtlLongposPullvsEta",
564 "BTL longitudinal position pull vs #eta;|#eta_{RECO}|;X^{loc}_{RECO}-X^{loc}_{SIM}/#sigma_{xloc_{RECO}}",
572 "BtlTPullvsE",
"BTL time pull vs E;E_{SIM} [MeV];(T_{RECO}-T_{SIM})/#sigma_{T_{RECO}}", 20, 0., 20., -5., 5.,
"S");
574 "BTL time pull vs #eta;|#eta_{RECO}|;(T_{RECO}-T_{SIM})/#sigma_{T_{RECO}}",
581 meCluTime_ = ibook.
book1D(
"BtlCluTime",
"BTL cluster time ToA;ToA [ns]", 250, 0, 25);
582 meCluTimeError_ = ibook.
book1D(
"BtlCluTimeError",
"BTL cluster time error;#sigma_{t} [ns]", 100, 0, 0.1);
583 meCluEnergy_ = ibook.
book1D(
"BtlCluEnergy",
"BTL cluster energy;E_{RECO} [MeV]", 100, 0, 20);
584 meCluPhi_ = ibook.
book1D(
"BtlCluPhi",
"BTL cluster #phi;#phi_{RECO} [rad]", 144, -3.2, 3.2);
585 meCluEta_ = ibook.
book1D(
"BtlCluEta",
"BTL cluster #eta;#eta_{RECO}", 100, -1.55, 1.55);
586 meCluHits_ = ibook.
book1D(
"BtlCluHitNumber",
"BTL hits per cluster; Cluster size", 10, 0, 10);
588 "BtlOccupancy",
"BTL cluster Z vs #phi;Z_{RECO} [cm]; #phi_{RECO} [rad]", 144, -260., 260., 50, -3.2, 3.2);
590 meCluTimeRes_ = ibook.
book1D(
"BtlCluTimeRes",
"BTL cluster time resolution;T_{RECO}-T_{SIM} [ns]", 100, -0.5, 0.5);
592 ibook.
book1D(
"BtlCluEnergyRes",
"BTL cluster energy resolution;E_{RECO}-E_{SIM} [MeV]", 100, -0.5, 0.5);
594 "BTL cluster time pull vs E;E_{SIM} [MeV];(T_{RECO}-T_{SIM})/#sigma_{T_{RECO}}",
603 "BTL cluster time pull vs #eta;|#eta_{RECO}|;(T_{RECO}-T_{SIM})/#sigma_{T_{RECO}}",
611 ibook.
book1D(
"BtlCluRhoRes",
"BTL cluster #rho resolution;#rho_{RECO}-#rho_{SIM} [cm]", 100, -0.5, 0.5);
613 ibook.
book1D(
"BtlCluPhiRes",
"BTL cluster #phi resolution;#phi_{RECO}-#phi_{SIM} [rad]", 100, -0.03, 0.03);
615 meCluXRes_ = ibook.
book1D(
"BtlCluXRes",
"BTL cluster X resolution;X_{RECO}-X_{SIM} [cm]", 100, -3.1, 3.1);
616 meCluYRes_ = ibook.
book1D(
"BtlCluYRes",
"BTL cluster Y resolution;Y_{RECO}-Y_{SIM} [cm]", 100, -3.1, 3.1);
617 meCluZRes_ = ibook.
book1D(
"BtlCluZRes",
"BTL cluster Z resolution;Z_{RECO}-Z_{SIM} [cm]", 100, -0.2, 0.2);
619 "BTL cluster local Y vs X;X^{local}_{RECO} [cm];Y^{local}_{RECO} [cm]",
627 "BTL cluster local Y vs X;X^{local}_{SIM} [cm];Y^{local}_{SIM} [cm]",
639 for (
unsigned int ihistoQ = 0; ihistoQ <
nBinsQ_; ++ihistoQ) {
641 std::string htitle = Form(
"BTL time resolution (Q bin = %d);T_{RECO} - T_{SIM} [ns]", ihistoQ);
644 for (
unsigned int ihistoEta = 0; ihistoEta <
nBinsQEta_; ++ihistoEta) {
645 hname = Form(
"TimeResQvsEta_%d_%d", ihistoQ, ihistoEta);
646 htitle = Form(
"BTL time resolution (Q bin = %d, |#eta| bin = %d);T_{RECO} - T_{SIM} [ns]", ihistoQ, ihistoEta);
653 for (
unsigned int ihistoEta = 0; ihistoEta <
nBinsEta_; ++ihistoEta) {
654 std::string hname = Form(
"TimeResEta_%d", ihistoEta);
655 std::string htitle = Form(
"BTL time resolution (|#eta| bin = %d);T_{RECO} - T_{SIM} [ns]", ihistoEta);
658 for (
unsigned int ihistoQ = 0; ihistoQ <
nBinsEtaQ_; ++ihistoQ) {
659 hname = Form(
"TimeResEtavsQ_%d_%d", ihistoEta, ihistoQ);
660 htitle = Form(
"BTL time resolution (|#eta| bin = %d, Q bin = %d);T_{RECO} - T_{SIM} [ns]", ihistoEta, ihistoQ);
678 desc.add<
double>(
"HitMinimumEnergy", 1.);
679 desc.add<
bool>(
"LocalPositionDebug",
false);
680 desc.add<
bool>(
"UncalibRecHitsPlots",
false);
681 desc.add<
double>(
"HitMinimumAmplitude", 30.);
683 descriptions.
add(
"btlLocalReco",
desc);