530 if (!hRecoProtonsSingleRP->empty())
534 throw cms::Exception(
"CTPPSProtonReconstructionPlotter") <<
"Number of non empty events reached maximum.";
545 std::map<unsigned int, unsigned int> armTrackCounter, armTimingTrackCounter;
546 std::map<unsigned int, unsigned int> armTrackCounter_N, armTrackCounter_F;
548 for (
const auto &tr : *hTracks) {
554 armTrackCounter_N[0]++;
558 armTrackCounter_F[0]++;
562 armTrackCounter_N[1]++;
566 armTrackCounter_F[1]++;
569 armTrackCounter[
rpId.arm()]++;
571 const bool trackerRP =
574 armTimingTrackCounter[
rpId.arm()]++;
577 if (tr_L_N && tr_L_F) {
582 if (tr_R_N && tr_R_F) {
588 std::map<unsigned int, unsigned int> singleRPMultiplicity, multiRPMultiplicity;
591 multiRPMultiplicity[0] = multiRPMultiplicity[1] = 0;
594 for (
const auto &proton : *hRecoProtonsSingleRP) {
595 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId());
596 unsigned int decRPId =
rpId.arm() * 100 +
rpId.station() * 10 +
rpId.rp();
598 const bool n1f1 = (armTrackCounter_N[
rpId.arm()] == 1 && armTrackCounter_F[
rpId.arm()] == 1);
602 if (proton.validFit())
603 singleRPMultiplicity[decRPId]++;
606 for (
const auto it : singleRPMultiplicity)
610 for (
const auto &proton : *hRecoProtonsMultiRP) {
611 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId());
612 unsigned int armId =
rpId.arm();
614 const bool n1f1 = (armTrackCounter_N[armId] == 1 && armTrackCounter_F[armId] == 1);
616 multiRPPlots_[armId].fill(proton, armTrackCounter[armId], n1f1);
618 if (proton.validFit())
619 multiRPMultiplicity[armId]++;
622 for (
const auto it : multiRPMultiplicity) {
624 pl.h_multiplicity->Fill(it.second);
625 pl.h2_timing_tracks_vs_prot_mult->Fill(it.second, armTimingTrackCounter[it.first]);
629 map<unsigned int, bool> clCo;
630 clCo[0] = (singleRPMultiplicity[
rpId_45_N_] && singleRPMultiplicity[
rpId_45_F_] && multiRPMultiplicity[0] == 1);
631 clCo[1] = (singleRPMultiplicity[
rpId_56_N_] && singleRPMultiplicity[
rpId_56_F_] && multiRPMultiplicity[1] == 1);
634 for (
const auto &proton : *hRecoProtonsMultiRP) {
635 if (!proton.validFit())
638 CTPPSDetId rpId_proton((*proton.contributingLocalTracks().begin())->getRPId());
639 unsigned int armId = rpId_proton.
arm();
642 for (
const auto &tr : *hTracks) {
644 if (rpId_tr.arm() != armId)
647 const bool trackerRP =
652 double de_x = 0., de_x_unc = 0.;
655 const double rd = (de_x_unc > 0.) ? de_x / de_x_unc : -1E10;
657 const bool match = (ac.ti_tr_min <= fabs(rd) && fabs(rd) <= ac.ti_tr_max);
659 pl.h_de_x_timing_vs_tracking->Fill(de_x);
660 pl.h_de_x_rel_timing_vs_tracking->Fill(rd);
661 pl.h_de_x_match_timing_vs_tracking->Fill(match ? 1. : 0.);
663 if (clCo[armId] && armTimingTrackCounter[armId] == 1) {
664 pl.h_de_x_timing_vs_tracking_ClCo->Fill(de_x);
665 pl.h_de_x_rel_timing_vs_tracking_ClCo->Fill(rd);
666 pl.h_de_x_match_timing_vs_tracking_ClCo->Fill(match ? 1. : 0.);
672 for (
const auto &proton : *hRecoProtonsMultiRP) {
673 if (!proton.validFit())
676 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId());
677 unsigned int armId =
rpId.arm();
679 const auto &nTimingTracks = armTimingTrackCounter[armId];
684 double x_ref = 0., y_ref = 0.;
686 x_ref = tr_L_N->
getX();
687 y_ref = tr_L_N->
getY();
690 x_ref = tr_R_N->
getX();
691 y_ref = tr_R_N->
getY();
694 if (nTimingTracks == 0)
695 pl.h2_y_vs_x_tt0_ClCo->Fill(x_ref, y_ref);
696 if (nTimingTracks == 1)
697 pl.h2_y_vs_x_tt1_ClCo->Fill(x_ref, y_ref);
698 if (nTimingTracks > 1)
699 pl.h2_y_vs_x_ttm_ClCo->Fill(x_ref, y_ref);
703 for (
const auto &proton_m : *hRecoProtonsMultiRP) {
704 CTPPSDetId rpId_m((*proton_m.contributingLocalTracks().begin())->getRPId());
705 unsigned int arm = rpId_m.arm();
709 for (
const auto &proton_s : *hRecoProtonsSingleRP) {
712 bool compatible =
false;
713 for (
const auto &tr_m : proton_m.contributingLocalTracks()) {
714 if (tr_m.key() == key_s) {
724 CTPPSDetId rpId_s((*proton_s.contributingLocalTracks().begin())->getRPId());
725 const unsigned int idx = rpId_s.arm() * 1000 + rpId_s.station() * 100 + rpId_s.rp() * 10 + rpId_s.arm();
729 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_
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_
std::unique_ptr< TProfile > p_y_L_diffNF_vs_y_L_N_
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tokenTracks_
float getX() const
returns the horizontal track position
Event setup record containing the real (actual) geometry information.
float getY() const
returns the vertical track position
const CTPPSLocalTrackLiteRefVector & contributingLocalTracks() const
list of RP tracks that contributed to this global track
std::map< unsigned int, ArmCorrelationPlots > armCorrelationPlots_
void CalculateTimingTrackingDistance(const reco::ForwardProton &proton, const CTPPSLocalTrackLite &tr, const CTPPSGeometry &geometry, double &de_x, double &de_x_unc)
Base class for CTPPS detector IDs.
signed int maxNonEmptyEvents_
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::map< unsigned int, AssociationCuts > association_cuts_
std::unique_ptr< TProfile > p_x_L_diffNF_vs_x_L_N_