543 if (!hRecoProtonsSingleRP->empty())
547 throw cms::Exception(
"CTPPSProtonReconstructionPlotter") <<
"Number of non empty events reached maximum.";
558 std::map<unsigned int, unsigned int> armTrackCounter, armTimingTrackCounter;
559 std::map<unsigned int, unsigned int> armTrackCounter_N, armTrackCounter_F;
561 for (
const auto &tr : *hTracks) {
563 unsigned int decRPId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
567 armTrackCounter_N[0]++;
571 armTrackCounter_F[0]++;
575 armTrackCounter_N[1]++;
579 armTrackCounter_F[1]++;
582 armTrackCounter[rpId.arm()]++;
584 const bool trackerRP =
587 armTimingTrackCounter[rpId.arm()]++;
590 if (tr_L_N && tr_L_F) {
595 if (tr_R_N && tr_R_F) {
601 std::map<unsigned int, unsigned int> singleRPMultiplicity, multiRPMultiplicity;
604 multiRPMultiplicity[0] = multiRPMultiplicity[1] = 0;
607 for (
const auto &proton : *hRecoProtonsSingleRP) {
609 const auto &pcLTiter = *proton.contributingLocalTracks().begin();
610 assert(pcLTiter.isNonnull());
612 unsigned int decRPId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
614 const bool n1f1 = (armTrackCounter_N[rpId.arm()] == 1 && armTrackCounter_F[rpId.arm()] == 1);
618 if (proton.validFit())
619 singleRPMultiplicity[
decRPId]++;
622 for (
const auto it : singleRPMultiplicity)
626 for (
const auto &proton : *hRecoProtonsMultiRP) {
627 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId());
628 unsigned int armId = rpId.
arm();
630 const bool n1f1 = (armTrackCounter_N[armId] == 1 && armTrackCounter_F[armId] == 1);
632 multiRPPlots_[armId].fill(proton, armTrackCounter[armId], n1f1);
634 if (proton.validFit())
635 multiRPMultiplicity[armId]++;
638 for (
const auto it : multiRPMultiplicity) {
640 pl.h_multiplicity->Fill(
it.second);
641 pl.h2_timing_tracks_vs_prot_mult->Fill(
it.second, armTimingTrackCounter[
it.first]);
645 map<unsigned int, bool> clCo;
646 clCo[0] = (singleRPMultiplicity[
rpId_45_N_] && singleRPMultiplicity[
rpId_45_F_] && multiRPMultiplicity[0] == 1);
647 clCo[1] = (singleRPMultiplicity[
rpId_56_N_] && singleRPMultiplicity[
rpId_56_F_] && multiRPMultiplicity[1] == 1);
650 for (
const auto &proton : *hRecoProtonsMultiRP) {
651 if (!proton.validFit())
654 CTPPSDetId rpId_proton((*proton.contributingLocalTracks().begin())->rpId());
655 unsigned int armId = rpId_proton.
arm();
658 for (
const auto &tr : *hTracks) {
660 if (rpId_tr.arm() != armId)
663 const bool trackerRP =
668 double x_tr = -1., x_ti = -1.;
669 double de_x = 0., de_x_unc = 0.;
672 const double rd = (de_x_unc > 0.) ?
de_x / de_x_unc : -1E10;
674 const bool match = (ac.getTiTrMin() <= fabs(rd) && fabs(rd) <= ac.getTiTrMax());
676 pl.h_de_x_timing_vs_tracking->Fill(
de_x);
677 pl.h_de_x_rel_timing_vs_tracking->Fill(rd);
678 pl.h_de_x_match_timing_vs_tracking->Fill(
match ? 1. : 0.);
680 if (clCo[armId] && armTimingTrackCounter[armId] == 1) {
681 pl.h2_x_timing_vs_x_tracking_ClCo->Fill(x_tr, x_ti);
683 pl.h_de_x_timing_vs_tracking_ClCo->Fill(
de_x);
684 pl.h_de_x_rel_timing_vs_tracking_ClCo->Fill(rd);
685 pl.h_de_x_match_timing_vs_tracking_ClCo->Fill(
match ? 1. : 0.);
687 pl.p_time_unc_vs_x_ClCo->Fill(x_tr, proton.timeError());
693 for (
const auto &proton : *hRecoProtonsMultiRP) {
694 if (!proton.validFit())
697 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId());
698 unsigned int armId = rpId.
arm();
700 const auto &nTimingTracks = armTimingTrackCounter[armId];
705 double x_ref = 0., y_ref = 0.;
715 if (nTimingTracks == 0)
716 pl.h2_y_vs_x_tt0_ClCo->Fill(x_ref, y_ref);
717 if (nTimingTracks == 1)
718 pl.h2_y_vs_x_tt1_ClCo->Fill(x_ref, y_ref);
719 if (nTimingTracks > 1)
720 pl.h2_y_vs_x_ttm_ClCo->Fill(x_ref, y_ref);
724 for (
const auto &proton_m : *hRecoProtonsMultiRP) {
725 CTPPSDetId rpId_m((*proton_m.contributingLocalTracks().begin())->rpId());
726 unsigned int arm = rpId_m.arm();
730 for (
const auto &proton_s : *hRecoProtonsSingleRP) {
733 bool compatible =
false;
734 for (
const auto &tr_m : proton_m.contributingLocalTracks()) {
735 if (tr_m.key() == key_s) {
745 CTPPSDetId rpId_s((*proton_s.contributingLocalTracks().begin())->rpId());
746 const unsigned int idx = rpId_s.arm() * 1000 + rpId_s.station() * 100 + rpId_s.rp() * 10 + rpId_s.arm();
750 const unsigned int rpDecId_s = rpId_s.arm() * 100 + rpId_s.station() * 10 + rpId_s.rp();
std::map< unsigned int, MultiRPPlots > multiRPPlots_
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsSingleRP_
const CTPPSLocalTrackLiteRefVector & contributingLocalTracks() const
list of RP tracks that contributed to this global track
std::unique_ptr< TProfile > p_y_R_diffNF_vs_y_R_N_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
std::unique_ptr< TProfile > p_x_R_diffNF_vs_x_R_N_
std::map< unsigned int, SingleRPPlots > singleRPPlots_
Local (=single RP) track with essential information only.
signed int n_non_empty_events_
edm::ESGetToken< PPSAssociationCuts, PPSAssociationCutsRcd > ppsAssociationCutsToken_
std::unique_ptr< TProfile > p_y_L_diffNF_vs_y_L_N_
edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > geometryESToken_
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tokenTracks_
float y() const
returns the vertical track position
const CutsPerArm & getAssociationCuts(const int sector) const
float x() const
returns the horizontal track position
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
std::map< unsigned int, ArmCorrelationPlots > armCorrelationPlots_
Base class for CTPPS detector IDs.
signed int maxNonEmptyEvents_
void CalculateTimingTrackingDistance(const reco::ForwardProton &proton, const CTPPSLocalTrackLite &tr, const CTPPSGeometry &geometry, double &x_tr, double &x_ti, double &de_x, double &de_x_unc)
std::map< unsigned int, SingleMultiCorrelationPlots > singleMultiCorrelationPlots_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_
std::unique_ptr< TProfile > p_x_L_diffNF_vs_x_L_N_