39{
40
42 if(!tofTrackContainer.isValid())
43 {
44
45 return StatusCode::SUCCESS;
46 }
47
48
50 if(!protonContainer.isValid())
51 {
52
53 return StatusCode::SUCCESS;
54 }
55
56
57
58 std::vector<const xAOD::AFPToFTrack*> tofTrackSideAContainer;
59 std::copy_if(tofTrackContainer->begin(), tofTrackContainer->end(), std::back_inserter(tofTrackSideAContainer),
60 [](auto track) { return track->stationID() == 0; });
61 if(tofTrackSideAContainer.empty()) return StatusCode::SUCCESS;
62
63
64 std::vector<const xAOD::AFPToFTrack*> tofTrackSideCContainer;
65 std::copy_if(tofTrackContainer->begin(), tofTrackContainer->end(), std::back_inserter(tofTrackSideCContainer),
66 [](auto track) { return track->stationID() == 3; });
67 if(tofTrackSideCContainer.empty()) return StatusCode::SUCCESS;
68
69
70 std::vector<const xAOD::AFPProton*> protonSideAContainer;
71 std::copy_if(protonContainer->begin(), protonContainer->end(), std::back_inserter(protonSideAContainer),
72 [](auto proton) { return proton->side() == 0; });
73 if(protonSideAContainer.empty()) return StatusCode::SUCCESS;
74
75
76 std::vector<const xAOD::AFPProton*> protonSideCContainer;
77 std::copy_if(protonContainer->begin(), protonContainer->end(), std::back_inserter(protonSideCContainer),
78 [](auto proton) { return proton->side() == 1; });
79 if(protonSideCContainer.empty()) return StatusCode::SUCCESS;
80
81 ATH_MSG_DEBUG(
"tofTrackSideAContainer size: " << tofTrackSideAContainer.size());
82 ATH_MSG_DEBUG(
"tofTrackSideCContainer size: " << tofTrackSideCContainer.size());
83 ATH_MSG_DEBUG(
"protonSideAContainer size: " << protonSideAContainer.size());
84 ATH_MSG_DEBUG(
"protonSideCContainer size: " << protonSideCContainer.size());
85
86
90
91
93
95
96
97 double protonXPositionFar = protonSideA->track(0)->xLocal();
98 if(protonSideA->nTracks()==2 && protonSideA->track(1)->stationID()==0)
99 protonXPositionFar = protonSideA->track(1)->xLocal();
100
101 double dx = std::min(std::abs(protonXPositionFar-TVP_A.
trainEdge(tofTrackSideA->trainID())),std::abs(protonXPositionFar-TVP_A.
trainEdge(tofTrackSideA->trainID()+1)));
103 if( protonXPositionFar > TVP_A.
trainEdge(tofTrackSideA->trainID()) && protonXPositionFar < TVP_A.
trainEdge(tofTrackSideA->trainID()+1) ) distA = -
dx;
104
107 "Tracks too far away from each other (xProton, xLeftPositionSideA; xRightPositionSideA; distance) [mm]: "
108 << protonXPositionFar <<
", " << TVP_A.
trainEdge(tofTrackSideA->trainID()) <<
"; "
109 << TVP_A.
trainEdge(tofTrackSideA->trainID()+1) <<
", " << distA <<
"; " << distA);
110
111 continue;
112 }
113
114
115
117
119
120
121 double protonXPositionFar = protonSideC->track(0)->xLocal();
122 if(protonSideC->nTracks()==2 && protonSideC->track(1)->stationID()==3)
123 protonXPositionFar = protonSideC->track(1)->xLocal();
124 double dx = std::min(std::abs(protonXPositionFar-TVP_C.
trainEdge(tofTrackSideC->trainID())),std::abs(protonXPositionFar-TVP_C.
trainEdge(tofTrackSideC->trainID()+1)));
126 if( protonXPositionFar > TVP_C.
trainEdge(tofTrackSideC->trainID()) && protonXPositionFar < TVP_C.
trainEdge(tofTrackSideC->trainID()+1) ) distC = -
dx;
127
130 "Tracks too far away from each other (xProton, xLeftPositionSideC; xRightPositionSideC; distance) [mm]: "
131 << protonXPositionFar <<
", " << TVP_C.
trainEdge(tofTrackSideC->trainID()) <<
"; "
132 << TVP_C.
trainEdge(tofTrackSideC->trainID()+1) <<
", " << distC <<
"; " << distC);
133
134 continue;
135 }
136
137
138 xAOD::AFPVertex *
vertex =
reco(distA, distC, tofTrackSideA, tofTrackSideC, protonSideA, protonSideC, TVP_A, TVP_C, outputContainer);
139
140 if (!vertex)
141 continue;
142
143
144
149 }
150 }
151 }
152 }
153
154 return StatusCode::SUCCESS;
155}
const std::vector< double > & trainEdge() const
Train edges; the end of n-th train is also the beginning of the (n+1)-th train.
void linkProtonsToVertex(const xAOD::AFPProton *proton, SG::ReadHandle< xAOD::AFPProtonContainer > &protonContainer, xAOD::AFPVertex *vertex) const
Links proton pair to reconstructed vertex.
SG::ReadHandleKey< xAOD::AFPProtonContainer > m_protonContainerKey
xAOD::AFPVertex * reco(const double distA, const double distC, const xAOD::AFPToFTrack *toFTrackA, const xAOD::AFPToFTrack *toFTrackC, const xAOD::AFPProton *protonA, const xAOD::AFPProton *protonC, const AFP::ToFVtxParamData &TVP_A, const AFP::ToFVtxParamData &TVP_C, std::unique_ptr< xAOD::AFPVertexContainer > &outputContainer) const
Reconstructs single vertex from pair of ToFTracks and a pair of protons.
SG::ReadHandleKey< xAOD::AFPToFTrackContainer > m_tofTrackContainerKey
void linkToFTracksToVertex(const xAOD::AFPToFTrack *toFTrack, SG::ReadHandle< xAOD::AFPToFTrackContainer > &tofTrackContainer, xAOD::AFPVertex *vertex) const
Links ToF track pair to reconstructed vertex.
AFPToFTrack_v1 AFPToFTrack