5 #ifndef JETRECTOOLS_CHARGEDHADRONSUBTRACTIONTOOL_H
6 #define JETRECTOOLS_CHARGEDHADRONSUBTRACTIONTOOL_H
50 Gaudi::Property<bool>
m_useTrackToVertexTool = {
this,
"UseTrackToVertexTool",
false,
"True if we will use the track to vertex tool"};
51 Gaudi::Property<bool>
m_ignoreVertex = {
this,
"IgnoreVertex",
false,
"Dummy option for cosmics - accept everything"};
52 Gaudi::Property<float>
m_z0sinThetaCutValue = {
this,
"Z0sinThetaCutValue", 2.0,
"True if we will use the track to vertex tool"};
53 Gaudi::Property<bool>
m_byVertex = {
this,
"DoByVertex",
false,
"True if we should match to each primary vertex, not just PV0"};
80 if (!handle.isValid())
83 return StatusCode::FAILURE;
85 trkVtxAssoc = handle.cptr();
92 ATH_MSG_ERROR(
"Primary vertex container was empty or no valid vertex found!");
93 return StatusCode::FAILURE;
97 ATH_MSG_VERBOSE(
"No genuine primary vertex found. Will consider all PFOs matched.");
105 if constexpr (std::is_same_v<U, xAOD::PFO>) {
106 if (std::abs(ppfo->charge()) < FLT_MIN)
108 }
else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
109 if (!ppfo->isCharged())
113 bool matchedToPrimaryVertex =
false;
114 bool matchedToPileupSideband =
false;
119 matchedToPrimaryVertex =
true;
126 if constexpr (std::is_same_v<U, xAOD::PFO>) {
127 ptrk = ppfo->
track(0);
128 }
else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
133 ATH_MSG_WARNING(
"Charged PFO with index " << ppfo->index() <<
" has no ID track!");
139 if (thisTracksVertex ==
nullptr)
141 ATH_MSG_DEBUG(
"No vertex associated to track " << ptrk->
index() <<
"! So it cannot be associated to the primary vertex");
142 matchedToPrimaryVertex =
false;
155 matchedToPileupSideband =
true;
163 matchedToPrimaryVertex =
true;
169 float z0 = ptrk->
z0() + ptrk->
vz() - vtx->
z();
173 matchedToPileupSideband =
true;
177 PVMatchedAcc(*ppfo) = matchedToPrimaryVertex;
178 PUsidebandMatchedAcc(*ppfo) = matchedToPileupSideband;
181 return StatusCode::SUCCESS;
191 if (!handle.isValid())
194 return StatusCode::FAILURE;
201 return StatusCode::FAILURE;
209 if (!handle.isValid())
212 return StatusCode::FAILURE;
214 trkVtxAssoc = handle.cptr();
220 if constexpr (std::is_same_v<U, xAOD::PFO>) {
221 if (std::abs(ppfo->charge()) < FLT_MIN)
223 }
else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
224 if (!ppfo->isCharged())
232 if constexpr (std::is_same_v<U, xAOD::PFO>) {
233 ptrk = ppfo->
track(0);
234 }
else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
239 ATH_MSG_WARNING(
"Charged PFO with index " << ppfo->index() <<
" has no ID track!");
243 std::vector<unsigned> matchingVertexList;
244 std::vector<unsigned> matchingPUSBList;
250 if (thisTracksVertex ==
nullptr)
252 ATH_MSG_DEBUG(
"No vertex associated to track " << ptrk->
index() <<
"! So it cannot be associated to the primary vertex");
256 matchingVertexList.push_back(thisTracksVertex->
index());
260 float z0 = ptrk->
z0() + ptrk->
vz() - vtx->z();
264 matchingPUSBList.push_back(vtx->index());
274 bool matchedToVertex =
false;
275 bool matchedToPileupSideband =
false;
279 ATH_MSG_WARNING(
"Encountered a nullptr vertex when trying to match charged PFOs to vertices");
284 matchedToVertex =
true;
291 matchedToPileupSideband =
true;
295 matchingVertexList.push_back(vtx->index());
296 if (matchedToPileupSideband)
297 matchingPUSBList.push_back(vtx->index());
301 matchingPVs(*ppfo) = matchingVertexList;
302 matchingPUSBs(*ppfo) = matchingPUSBList;
305 return StatusCode::SUCCESS;