554 if (!hRecoProtonsSingleRP->empty())
558 throw cms::Exception(
"CTPPSProtonReconstructionPlotter") <<
"Number of non empty events reached maximum.";
569 std::map<unsigned int, unsigned int> armTrackCounter, armTimingTrackCounter;
570 std::map<unsigned int, unsigned int> armTrackCounter_N, armTrackCounter_F;
572 for (
const auto &tr : *hTracks) {
574 unsigned int decRPId =
rpId.arm() * 100 +
rpId.station() * 10 +
rpId.rp();
578 armTrackCounter_N[0]++;
582 armTrackCounter_F[0]++;
586 armTrackCounter_N[1]++;
590 armTrackCounter_F[1]++;
593 armTrackCounter[
rpId.arm()]++;
595 const bool trackerRP =
598 armTimingTrackCounter[
rpId.arm()]++;
601 if (tr_L_N && tr_L_F) {
606 if (tr_R_N && tr_R_F) {
612 std::map<unsigned int, unsigned int> singleRPMultiplicity, multiRPMultiplicity;
615 multiRPMultiplicity[0] = multiRPMultiplicity[1] = 0;
618 for (
const auto &proton : *hRecoProtonsSingleRP) {
620 unsigned int decRPId =
rpId.arm() * 100 +
rpId.station() * 10 +
rpId.rp();
622 const bool n1f1 = (armTrackCounter_N[
rpId.arm()] == 1 && armTrackCounter_F[
rpId.arm()] == 1);
626 if (proton.validFit())
627 singleRPMultiplicity[decRPId]++;
630 for (
const auto it : singleRPMultiplicity)
634 for (
const auto &proton : *hRecoProtonsMultiRP) {
636 unsigned int armId =
rpId.arm();
638 const bool n1f1 = (armTrackCounter_N[armId] == 1 && armTrackCounter_F[armId] == 1);
640 multiRPPlots_[armId].fill(proton, armTrackCounter[armId], n1f1);
642 if (proton.validFit())
643 multiRPMultiplicity[armId]++;
646 for (
const auto it : multiRPMultiplicity) {
648 pl.h_multiplicity->Fill(it.second);
649 pl.h2_timing_tracks_vs_prot_mult->Fill(it.second, armTimingTrackCounter[it.first]);
653 map<unsigned int, bool> clCo;
654 clCo[0] = (singleRPMultiplicity[
rpId_45_N_] && singleRPMultiplicity[
rpId_45_F_] && multiRPMultiplicity[0] == 1);
655 clCo[1] = (singleRPMultiplicity[
rpId_56_N_] && singleRPMultiplicity[
rpId_56_F_] && multiRPMultiplicity[1] == 1);
658 for (
const auto &proton : *hRecoProtonsMultiRP) {
659 if (!proton.validFit())
662 CTPPSDetId rpId_proton((*proton.contributingLocalTracks().begin())->
rpId());
663 unsigned int armId = rpId_proton.
arm();
666 for (
const auto &tr : *hTracks) {
668 if (rpId_tr.arm() != armId)
671 const bool trackerRP =
676 double x_tr = -1., x_ti = -1.;
677 double de_x = 0., de_x_unc = 0.;
680 const double rd = (de_x_unc > 0.) ?
de_x / de_x_unc : -1E10;
682 const bool match = (ac.ti_tr_min <= fabs(rd) && fabs(rd) <= ac.ti_tr_max);
684 pl.h_de_x_timing_vs_tracking->Fill(
de_x);
685 pl.h_de_x_rel_timing_vs_tracking->Fill(rd);
686 pl.h_de_x_match_timing_vs_tracking->Fill(
match ? 1. : 0.);
688 if (clCo[armId] && armTimingTrackCounter[armId] == 1) {
689 pl.h2_x_timing_vs_x_tracking_ClCo->Fill(x_tr, x_ti);
691 pl.h_de_x_timing_vs_tracking_ClCo->Fill(
de_x);
692 pl.h_de_x_rel_timing_vs_tracking_ClCo->Fill(rd);
693 pl.h_de_x_match_timing_vs_tracking_ClCo->Fill(
match ? 1. : 0.);
695 pl.p_time_unc_vs_x_ClCo->Fill(x_tr, proton.timeError());
701 for (
const auto &proton : *hRecoProtonsMultiRP) {
702 if (!proton.validFit())
706 unsigned int armId =
rpId.arm();
708 const auto &nTimingTracks = armTimingTrackCounter[armId];
713 double x_ref = 0., y_ref = 0.;
723 if (nTimingTracks == 0)
724 pl.h2_y_vs_x_tt0_ClCo->Fill(x_ref, y_ref);
725 if (nTimingTracks == 1)
726 pl.h2_y_vs_x_tt1_ClCo->Fill(x_ref, y_ref);
727 if (nTimingTracks > 1)
728 pl.h2_y_vs_x_ttm_ClCo->Fill(x_ref, y_ref);
732 for (
const auto &proton_m : *hRecoProtonsMultiRP) {
733 CTPPSDetId rpId_m((*proton_m.contributingLocalTracks().begin())->
rpId());
734 unsigned int arm = rpId_m.
arm();
738 for (
const auto &proton_s : *hRecoProtonsSingleRP) {
741 bool compatible =
false;
742 for (
const auto &tr_m : proton_m.contributingLocalTracks()) {
743 if (tr_m.key() == key_s) {
753 CTPPSDetId rpId_s((*proton_s.contributingLocalTracks().begin())->
rpId());
754 const unsigned int idx = rpId_s.arm() * 1000 + rpId_s.station() * 100 + rpId_s.rp() * 10 + rpId_s.arm();
758 const unsigned int rpDecId_s = rpId_s.arm() * 100 + rpId_s.station() * 10 + rpId_s.rp();