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) {
608 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId());
609 unsigned int decRPId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
611 const bool n1f1 = (armTrackCounter_N[rpId.arm()] == 1 && armTrackCounter_F[rpId.arm()] == 1);
615 if (proton.validFit())
616 singleRPMultiplicity[
decRPId]++;
619 for (
const auto it : singleRPMultiplicity)
623 for (
const auto &proton : *hRecoProtonsMultiRP) {
624 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId());
625 unsigned int armId = rpId.
arm();
627 const bool n1f1 = (armTrackCounter_N[armId] == 1 && armTrackCounter_F[armId] == 1);
629 multiRPPlots_[armId].fill(proton, armTrackCounter[armId], n1f1);
631 if (proton.validFit())
632 multiRPMultiplicity[armId]++;
635 for (
const auto it : multiRPMultiplicity) {
637 pl.h_multiplicity->Fill(it.second);
638 pl.h2_timing_tracks_vs_prot_mult->Fill(it.second, armTimingTrackCounter[it.first]);
642 map<unsigned int, bool> clCo;
643 clCo[0] = (singleRPMultiplicity[
rpId_45_N_] && singleRPMultiplicity[
rpId_45_F_] && multiRPMultiplicity[0] == 1);
644 clCo[1] = (singleRPMultiplicity[
rpId_56_N_] && singleRPMultiplicity[
rpId_56_F_] && multiRPMultiplicity[1] == 1);
647 for (
const auto &proton : *hRecoProtonsMultiRP) {
648 if (!proton.validFit())
651 CTPPSDetId rpId_proton((*proton.contributingLocalTracks().begin())->rpId());
652 unsigned int armId = rpId_proton.
arm();
655 for (
const auto &tr : *hTracks) {
657 if (rpId_tr.arm() != armId)
660 const bool trackerRP =
665 double x_tr = -1., x_ti = -1.;
666 double de_x = 0., de_x_unc = 0.;
669 const double rd = (de_x_unc > 0.) ?
de_x / de_x_unc : -1E10;
671 const bool match = (ac.getTiTrMin() <= fabs(rd) && fabs(rd) <= ac.getTiTrMax());
673 pl.h_de_x_timing_vs_tracking->Fill(
de_x);
674 pl.h_de_x_rel_timing_vs_tracking->Fill(rd);
675 pl.h_de_x_match_timing_vs_tracking->Fill(
match ? 1. : 0.);
677 if (clCo[armId] && armTimingTrackCounter[armId] == 1) {
678 pl.h2_x_timing_vs_x_tracking_ClCo->Fill(x_tr, x_ti);
680 pl.h_de_x_timing_vs_tracking_ClCo->Fill(
de_x);
681 pl.h_de_x_rel_timing_vs_tracking_ClCo->Fill(rd);
682 pl.h_de_x_match_timing_vs_tracking_ClCo->Fill(
match ? 1. : 0.);
684 pl.p_time_unc_vs_x_ClCo->Fill(x_tr, proton.timeError());
690 for (
const auto &proton : *hRecoProtonsMultiRP) {
691 if (!proton.validFit())
694 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId());
695 unsigned int armId = rpId.
arm();
697 const auto &nTimingTracks = armTimingTrackCounter[armId];
702 double x_ref = 0., y_ref = 0.;
712 if (nTimingTracks == 0)
713 pl.h2_y_vs_x_tt0_ClCo->Fill(x_ref, y_ref);
714 if (nTimingTracks == 1)
715 pl.h2_y_vs_x_tt1_ClCo->Fill(x_ref, y_ref);
716 if (nTimingTracks > 1)
717 pl.h2_y_vs_x_ttm_ClCo->Fill(x_ref, y_ref);
721 for (
const auto &proton_m : *hRecoProtonsMultiRP) {
722 CTPPSDetId rpId_m((*proton_m.contributingLocalTracks().begin())->rpId());
723 unsigned int arm = rpId_m.arm();
727 for (
const auto &proton_s : *hRecoProtonsSingleRP) {
730 bool compatible =
false;
731 for (
const auto &tr_m : proton_m.contributingLocalTracks()) {
732 if (tr_m.key() == key_s) {
742 CTPPSDetId rpId_s((*proton_s.contributingLocalTracks().begin())->rpId());
743 const unsigned int idx = rpId_s.arm() * 1000 + rpId_s.station() * 100 + rpId_s.rp() * 10 + rpId_s.arm();
747 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_
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
bool getData(T &iHolder) const
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_