528 if (!hRecoProtonsSingleRP->empty())
532 throw cms::Exception(
"CTPPSProtonReconstructionPlotter") <<
"Number of non empty events reached maximum.";
543 std::map<unsigned int, unsigned int> armTrackCounter, armTimingTrackCounter;
544 std::map<unsigned int, unsigned int> armTrackCounter_N, armTrackCounter_F;
546 for (
const auto &tr : *hTracks) {
548 unsigned int decRPId =
rpId.arm() * 100 +
rpId.station() * 10 +
rpId.rp();
552 armTrackCounter_N[0]++;
556 armTrackCounter_F[0]++;
560 armTrackCounter_N[1]++;
564 armTrackCounter_F[1]++;
567 armTrackCounter[
rpId.arm()]++;
569 const bool trackerRP =
572 armTimingTrackCounter[
rpId.arm()]++;
575 if (tr_L_N && tr_L_F) {
580 if (tr_R_N && tr_R_F) {
586 std::map<unsigned int, unsigned int> singleRPMultiplicity, multiRPMultiplicity;
589 multiRPMultiplicity[0] = multiRPMultiplicity[1] = 0;
592 for (
const auto &proton : *hRecoProtonsSingleRP) {
594 unsigned int decRPId =
rpId.arm() * 100 +
rpId.station() * 10 +
rpId.rp();
596 const bool n1f1 = (armTrackCounter_N[
rpId.arm()] == 1 && armTrackCounter_F[
rpId.arm()] == 1);
600 if (proton.validFit())
601 singleRPMultiplicity[decRPId]++;
604 for (
const auto it : singleRPMultiplicity)
608 for (
const auto &proton : *hRecoProtonsMultiRP) {
610 unsigned int armId =
rpId.arm();
612 const bool n1f1 = (armTrackCounter_N[armId] == 1 && armTrackCounter_F[armId] == 1);
614 multiRPPlots_[armId].fill(proton, armTrackCounter[armId], n1f1);
616 if (proton.validFit())
617 multiRPMultiplicity[armId]++;
620 for (
const auto it : multiRPMultiplicity) {
622 pl.h_multiplicity->Fill(it.second);
623 pl.h2_timing_tracks_vs_prot_mult->Fill(it.second, armTimingTrackCounter[it.first]);
627 map<unsigned int, bool> clCo;
628 clCo[0] = (singleRPMultiplicity[
rpId_45_N_] && singleRPMultiplicity[
rpId_45_F_] && multiRPMultiplicity[0] == 1);
629 clCo[1] = (singleRPMultiplicity[
rpId_56_N_] && singleRPMultiplicity[
rpId_56_F_] && multiRPMultiplicity[1] == 1);
632 for (
const auto &proton : *hRecoProtonsMultiRP) {
633 if (!proton.validFit())
636 CTPPSDetId rpId_proton((*proton.contributingLocalTracks().begin())->
rpId());
637 unsigned int armId = rpId_proton.
arm();
640 for (
const auto &tr : *hTracks) {
642 if (rpId_tr.arm() != armId)
645 const bool trackerRP =
650 double de_x = 0., de_x_unc = 0.;
653 const double rd = (de_x_unc > 0.) ?
de_x / de_x_unc : -1E10;
655 const bool match = (ac.ti_tr_min <= fabs(rd) && fabs(rd) <= ac.ti_tr_max);
657 pl.h_de_x_timing_vs_tracking->Fill(
de_x);
658 pl.h_de_x_rel_timing_vs_tracking->Fill(rd);
659 pl.h_de_x_match_timing_vs_tracking->Fill(
match ? 1. : 0.);
661 if (clCo[armId] && armTimingTrackCounter[armId] == 1) {
662 pl.h_de_x_timing_vs_tracking_ClCo->Fill(
de_x);
663 pl.h_de_x_rel_timing_vs_tracking_ClCo->Fill(rd);
664 pl.h_de_x_match_timing_vs_tracking_ClCo->Fill(
match ? 1. : 0.);
670 for (
const auto &proton : *hRecoProtonsMultiRP) {
671 if (!proton.validFit())
675 unsigned int armId =
rpId.arm();
677 const auto &nTimingTracks = armTimingTrackCounter[armId];
682 double x_ref = 0., y_ref = 0.;
692 if (nTimingTracks == 0)
693 pl.h2_y_vs_x_tt0_ClCo->Fill(x_ref, y_ref);
694 if (nTimingTracks == 1)
695 pl.h2_y_vs_x_tt1_ClCo->Fill(x_ref, y_ref);
696 if (nTimingTracks > 1)
697 pl.h2_y_vs_x_ttm_ClCo->Fill(x_ref, y_ref);
701 for (
const auto &proton_m : *hRecoProtonsMultiRP) {
702 CTPPSDetId rpId_m((*proton_m.contributingLocalTracks().begin())->
rpId());
703 unsigned int arm = rpId_m.
arm();
707 for (
const auto &proton_s : *hRecoProtonsSingleRP) {
710 bool compatible =
false;
711 for (
const auto &tr_m : proton_m.contributingLocalTracks()) {
712 if (tr_m.key() == key_s) {
722 CTPPSDetId rpId_s((*proton_s.contributingLocalTracks().begin())->
rpId());
723 const unsigned int idx = rpId_s.arm() * 1000 + rpId_s.station() * 100 + rpId_s.rp() * 10 + rpId_s.arm();
727 const unsigned int rpDecId_s = rpId_s.arm() * 100 + rpId_s.station() * 10 + rpId_s.rp();