556 if (!hRecoProtonsSingleRP->empty())
560 throw cms::Exception(
"CTPPSProtonReconstructionPlotter") <<
"Number of non empty events reached maximum.";
570 std::map<unsigned int, unsigned int> armTrackCounter, armTimingTrackCounter;
571 std::map<unsigned int, unsigned int> armTrackCounter_N, armTrackCounter_F;
573 for (
const auto &tr : *hTracks) {
579 armTrackCounter_N[0]++;
583 armTrackCounter_F[0]++;
587 armTrackCounter_N[1]++;
591 armTrackCounter_F[1]++;
594 armTrackCounter[
rpId.arm()]++;
596 const bool trackerRP =
599 armTimingTrackCounter[
rpId.arm()]++;
602 if (tr_L_N && tr_L_F) {
607 if (tr_R_N && tr_R_F) {
613 std::map<unsigned int, unsigned int> singleRPMultiplicity, multiRPMultiplicity;
616 multiRPMultiplicity[0] = multiRPMultiplicity[1] = 0;
619 for (
const auto &proton : *hRecoProtonsSingleRP) {
623 const bool n1f1 = (armTrackCounter_N[
rpId.arm()] == 1 && armTrackCounter_F[
rpId.arm()] == 1);
627 if (proton.validFit())
628 singleRPMultiplicity[
decRPId]++;
631 for (
const auto it : singleRPMultiplicity)
635 for (
const auto &proton : *hRecoProtonsMultiRP) {
637 unsigned int armId =
rpId.arm();
639 const bool n1f1 = (armTrackCounter_N[armId] == 1 && armTrackCounter_F[armId] == 1);
641 multiRPPlots_[armId].fill(proton, armTrackCounter[armId], n1f1);
643 if (proton.validFit())
644 multiRPMultiplicity[armId]++;
647 for (
const auto it : multiRPMultiplicity) {
649 pl.h_multiplicity->Fill(it.second);
650 pl.h2_timing_tracks_vs_prot_mult->Fill(it.second, armTimingTrackCounter[it.first]);
654 map<unsigned int, bool> clCo;
655 clCo[0] = (singleRPMultiplicity[
rpId_45_N_] && singleRPMultiplicity[
rpId_45_F_] && multiRPMultiplicity[0] == 1);
656 clCo[1] = (singleRPMultiplicity[
rpId_56_N_] && singleRPMultiplicity[
rpId_56_F_] && multiRPMultiplicity[1] == 1);
659 for (
const auto &proton : *hRecoProtonsMultiRP) {
660 if (!proton.validFit())
663 CTPPSDetId rpId_proton((*proton.contributingLocalTracks().begin())->
rpId());
664 unsigned int armId = rpId_proton.
arm();
667 for (
const auto &tr : *hTracks) {
669 if (rpId_tr.arm() != armId)
672 const bool trackerRP =
677 double x_tr = -1., x_ti = -1.;
678 double de_x = 0., de_x_unc = 0.;
681 const double rd = (de_x_unc > 0.) ?
de_x / de_x_unc : -1E10;
683 const bool match = (ac.ti_tr_min <= fabs(rd) && fabs(rd) <= ac.ti_tr_max);
685 pl.h_de_x_timing_vs_tracking->Fill(
de_x);
686 pl.h_de_x_rel_timing_vs_tracking->Fill(rd);
687 pl.h_de_x_match_timing_vs_tracking->Fill(
match ? 1. : 0.);
689 if (clCo[armId] && armTimingTrackCounter[armId] == 1) {
690 pl.h2_x_timing_vs_x_tracking_ClCo->Fill(x_tr, x_ti);
692 pl.h_de_x_timing_vs_tracking_ClCo->Fill(
de_x);
693 pl.h_de_x_rel_timing_vs_tracking_ClCo->Fill(rd);
694 pl.h_de_x_match_timing_vs_tracking_ClCo->Fill(
match ? 1. : 0.);
696 pl.p_time_unc_vs_x_ClCo->Fill(x_tr, proton.timeError());
702 for (
const auto &proton : *hRecoProtonsMultiRP) {
703 if (!proton.validFit())
707 unsigned int armId =
rpId.arm();
709 const auto &nTimingTracks = armTimingTrackCounter[armId];
714 double x_ref = 0., y_ref = 0.;
724 if (nTimingTracks == 0)
725 pl.h2_y_vs_x_tt0_ClCo->Fill(x_ref, y_ref);
726 if (nTimingTracks == 1)
727 pl.h2_y_vs_x_tt1_ClCo->Fill(x_ref, y_ref);
728 if (nTimingTracks > 1)
729 pl.h2_y_vs_x_ttm_ClCo->Fill(x_ref, y_ref);
733 for (
const auto &proton_m : *hRecoProtonsMultiRP) {
734 CTPPSDetId rpId_m((*proton_m.contributingLocalTracks().begin())->
rpId());
735 unsigned int arm = rpId_m.arm();
739 for (
const auto &proton_s : *hRecoProtonsSingleRP) {
742 bool compatible =
false;
743 for (
const auto &tr_m : proton_m.contributingLocalTracks()) {
744 if (tr_m.key() == key_s) {
754 CTPPSDetId rpId_s((*proton_s.contributingLocalTracks().begin())->
rpId());
755 const unsigned int idx = rpId_s.arm() * 1000 + rpId_s.station() * 100 + rpId_s.rp() * 10 + rpId_s.arm();
759 const unsigned int rpDecId_s = rpId_s.arm() * 100 + rpId_s.station() * 10 + rpId_s.rp();