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) {
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) {
609 const auto iter = proton.contributingLocalTracks().begin();
610 if (iter == proton.contributingLocalTracks().end()) {
613 const auto pcLTiter = *iter;
614 assert(pcLTiter.isNonnull());
618 const bool n1f1 = (armTrackCounter_N[
rpId.arm()] == 1 && armTrackCounter_F[
rpId.arm()] == 1);
622 if (proton.validFit())
623 singleRPMultiplicity[
decRPId]++;
626 for (
const auto it : singleRPMultiplicity)
630 for (
const auto &proton : *hRecoProtonsMultiRP) {
632 const auto &pcLTiter = *proton.contributingLocalTracks().begin();
633 assert(pcLTiter.isNonnull());
635 unsigned int armId =
rpId.arm();
637 const bool n1f1 = (armTrackCounter_N[armId] == 1 && armTrackCounter_F[armId] == 1);
639 multiRPPlots_[armId].fill(proton, armTrackCounter[armId], n1f1);
641 if (proton.validFit())
642 multiRPMultiplicity[armId]++;
645 for (
const auto it : multiRPMultiplicity) {
647 pl.h_multiplicity->Fill(
it.second);
648 pl.h2_timing_tracks_vs_prot_mult->Fill(
it.second, armTimingTrackCounter[
it.first]);
652 map<unsigned int, bool> clCo;
653 clCo[0] = (singleRPMultiplicity[
rpId_45_N_] && singleRPMultiplicity[
rpId_45_F_] && multiRPMultiplicity[0] == 1);
654 clCo[1] = (singleRPMultiplicity[
rpId_56_N_] && singleRPMultiplicity[
rpId_56_F_] && multiRPMultiplicity[1] == 1);
657 for (
const auto &proton : *hRecoProtonsMultiRP) {
658 if (!proton.validFit())
661 CTPPSDetId rpId_proton((*proton.contributingLocalTracks().begin())->
rpId());
662 unsigned int armId = rpId_proton.
arm();
665 for (
const auto &tr : *hTracks) {
667 if (rpId_tr.arm() != armId)
670 const bool trackerRP =
675 double x_tr = -1., x_ti = -1.;
676 double de_x = 0., de_x_unc = 0.;
679 const double rd = (de_x_unc > 0.) ?
de_x / de_x_unc : -1E10;
681 const bool match = (ac.getTiTrMin() <= fabs(rd) && fabs(rd) <= ac.getTiTrMax());
683 pl.h_de_x_timing_vs_tracking->Fill(
de_x);
684 pl.h_de_x_rel_timing_vs_tracking->Fill(rd);
685 pl.h_de_x_match_timing_vs_tracking->Fill(
match ? 1. : 0.);
687 if (clCo[armId] && armTimingTrackCounter[armId] == 1) {
688 pl.h2_x_timing_vs_x_tracking_ClCo->Fill(x_tr, x_ti);
690 pl.h_de_x_timing_vs_tracking_ClCo->Fill(
de_x);
691 pl.h_de_x_rel_timing_vs_tracking_ClCo->Fill(rd);
692 pl.h_de_x_match_timing_vs_tracking_ClCo->Fill(
match ? 1. : 0.);
694 pl.p_time_unc_vs_x_ClCo->Fill(x_tr, proton.timeError());
700 for (
const auto &proton : *hRecoProtonsMultiRP) {
701 if (!proton.validFit())
705 unsigned int armId =
rpId.arm();
707 const auto &nTimingTracks = armTimingTrackCounter[armId];
712 double x_ref = 0., y_ref = 0.;
722 if (nTimingTracks == 0)
723 pl.h2_y_vs_x_tt0_ClCo->Fill(x_ref, y_ref);
724 if (nTimingTracks == 1)
725 pl.h2_y_vs_x_tt1_ClCo->Fill(x_ref, y_ref);
726 if (nTimingTracks > 1)
727 pl.h2_y_vs_x_ttm_ClCo->Fill(x_ref, y_ref);
731 for (
const auto &proton_m : *hRecoProtonsMultiRP) {
732 if (proton_m.contributingLocalTracks().begin() == proton_m.contributingLocalTracks().end()) {
735 CTPPSDetId rpId_m((*proton_m.contributingLocalTracks().begin())->
rpId());
736 unsigned int arm = rpId_m.arm();
740 for (
const auto &proton_s : *hRecoProtonsSingleRP) {
742 if (proton_s.contributingLocalTracks().empty()) {
746 bool compatible =
false;
747 for (
const auto &tr_m : proton_m.contributingLocalTracks()) {
748 if (tr_m.key() == key_s) {
758 CTPPSDetId rpId_s((*proton_s.contributingLocalTracks().begin())->
rpId());
759 const unsigned int idx = rpId_s.arm() * 1000 + rpId_s.station() * 100 + rpId_s.rp() * 10 + rpId_s.arm();
763 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_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
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
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_