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>();
185 using namespace geant_units::operators;
191 const MTDTopology* topology = topologyHandle.product();
199 std::unordered_map<uint32_t, MTDHit> m_btlSimHits;
200 for (
auto const& simHit : btlSimHits) {
202 if (simHit.tof() < 0 || simHit.tof() > 25.)
205 DetId id = simHit.detUnitId();
207 auto simHitIt = m_btlSimHits.emplace(
id.rawId(),
MTDHit()).first;
213 if ((simHitIt->second).time == 0 || simHit.tof() < (simHitIt->second).time) {
214 (simHitIt->second).time = simHit.tof();
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;
238 const auto& global_point = thedet->
toGlobal(local_point);
270 float longpos_res = recHit.position() -
convertMmToCm(m_btlSimHits[detId.
rawId()].x_local);
271 float time_res = recHit.time() - m_btlSimHits[detId.
rawId()].time;
272 float energy_res = recHit.energy() - m_btlSimHits[detId.
rawId()].energy;
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;
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) {
342 BTLDetId hitId(recHit.id().rawId());
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])
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;
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])
485 etaBin = (int)(fabs(global_point.eta()) /
binWidthEta_);
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);
MonitorElement * meHitXlocal_
MonitorElement * meHitYlocal_
MonitorElement * meCluTPullvsE_
edm::ESGetToken< MTDGeometry, MTDDigiGeometryRecord > mtdgeoToken_
MonitorElement * meHitLongPos_
MonitorElement * meLongPosPull_
virtual void setCurrentFolder(std::string const &fullpath)
MonitorElement * meNhits_
MonitorElement * meHitEnergy_
virtual const Topology & topology() const
#define DEFINE_FWK_MODULE(type)
MonitorElement * meCluZRes_
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr uint32_t rawId() const
get the raw id
const double hitMinEnergy_
MonitorElement * meCluEta_
MonitorElement * meCluZvsPhi_
MonitorElement * meCluPhi_
static constexpr float binWidthQ_
MonitorElement * meTPullvsEta_
MonitorElement * meHitTvsPhi_
static constexpr int nBinsEtaQ_
MonitorElement * meLongPosPullvsEta_
MonitorElement * meCluTimeRes_
constexpr NumType convertUnitsTo(double desiredUnits, NumType val)
MonitorElement * meCluYXLocal_
MonitorElement * meTimeRes_
MonitorElement * meHitLongPosErr_
MonitorElement * meCluTime_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
BTLDetId geographicalId(CrysLayout lay) const
MonitorElement * meLongPosPullvsE_
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())
MonitorElement * meCluHits_
MonitorElement * meHitTimeError_
MonitorElement * meCluYXLocalSim_
static constexpr float binWidthEta_
~BtlLocalRecoValidation() override
edm::EDGetTokenT< FTLClusterCollection > btlRecCluToken_
static constexpr float binsQEta_[nBinsQEta_+1]
virtual const PixelTopology & specificTopology() const
Abs< T >::type abs(const T &t)
MonitorElement * meHitTime_
MonitorElement * meCluYRes_
static constexpr int nBinsQEta_
int nrows() const override
MonitorElement * meEnergyRes_
const double hitMinAmplitude_
edm::ESGetToken< MTDTopology, MTDTopologyRcd > mtdtopoToken_
MonitorElement * meHitEta_
MonitorElement * meLocalOccupancy_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
LocalPoint pixelToModuleLocalPoint(const LocalPoint &plp, int row, int col) const
MonitorElement * meTimeResEta_[nBinsEta_]
MonitorElement * meCluRhoRes_
float localY(const float mpY) const override
BtlLocalRecoValidation(const edm::ParameterSet &)
edm::EDGetTokenT< FTLUncalibratedRecHitCollection > btlUncalibRecHitsToken_
MonitorElement * meCluTimeError_
MonitorElement * meHitTvsEta_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * meHitZlocal_
MonitorElement * meCluTPullvsEta_
edm::EDGetTokenT< FTLRecHitCollection > btlRecHitsToken_
MonitorElement * meCluEnergy_
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
T getParameter(std::string const &) const
MonitorElement * meHitEvsZ_
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
MonitorElement * meCluPhiRes_
void analyze(const edm::Event &, const edm::EventSetup &) override
static constexpr int nBinsQ_
MonitorElement * meTimeResQvsEta_[nBinsQ_][nBinsQEta_]
MonitorElement * meHitEvsPhi_
static constexpr float binsEtaQ_[nBinsEtaQ_+1]
const std::string folder_
MonitorElement * meTimeResEtavsQ_[nBinsEta_][nBinsEtaQ_]
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
constexpr NumType convertMmToCm(NumType millimeters)
int column(unsigned nrows=16) const
static constexpr int nBinsEta_
BTLDetId::CrysLayout crysLayoutFromTopoMode(const int &topoMode)
const bool LocalPosDebug_
MonitorElement * meHitEvsEta_
auto makeValid(const U &iOtherHandleType) noexcept(false)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
MonitorElement * meHitTvsZ_
MonitorElement * meHitTvsE_
edm::EDGetTokenT< CrossingFrame< PSimHit > > btlSimHitsToken_
MonitorElement * meOccupancy_
MonitorElement * meTimeResQ_[nBinsQ_]
MonitorElement * meCluEnergyRes_
int etaBin(const l1t::HGCalMulticluster *cl)
MonitorElement * meTPullvsE_
const bool uncalibRecHitsPlots_
MonitorElement * meCluXRes_
MonitorElement * meHitPhi_
int row(unsigned nrows=16) const