5#ifndef JETRECTOOLS_CHARGEDHADRONSUBTRACTIONTOOL_H
6#define JETRECTOOLS_CHARGEDHADRONSUBTRACTIONTOOL_H
51 Gaudi::Property<bool>
m_useTrackToVertexTool = {
this,
"UseTrackToVertexTool",
false,
"True if we will use the track to vertex tool"};
52 Gaudi::Property<bool>
m_ignoreVertex = {
this,
"IgnoreVertex",
false,
"Dummy option for cosmics - accept everything"};
53 Gaudi::Property<float>
m_z0sinThetaCutValue = {
this,
"Z0sinThetaCutValue", 2.0,
"True if we will use the track to vertex tool"};
54 Gaudi::Property<bool>
m_byVertex = {
this,
"DoByVertex",
false,
"True if we should match to each primary vertex, not just PV0"};
68 const static SG::AuxElement::Accessor<char> PVMatchedAcc(
"matchedToPV");
69 const static SG::AuxElement::Accessor<char> PUsidebandMatchedAcc(
"matchedToPUsideband");
81 if (!handle.isValid())
84 return StatusCode::FAILURE;
86 trkVtxAssoc = handle.cptr();
93 ATH_MSG_ERROR(
"Primary vertex container was empty or no valid vertex found!");
94 return StatusCode::FAILURE;
98 ATH_MSG_VERBOSE(
"No genuine primary vertex found. Will consider all PFOs matched.");
106 if constexpr (std::is_same_v<U, xAOD::PFO>) {
107 if (std::abs(ppfo->charge()) < FLT_MIN)
109 }
else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
110 if (!ppfo->isCharged())
114 bool matchedToPrimaryVertex =
false;
115 bool matchedToPileupSideband =
false;
120 matchedToPrimaryVertex =
true;
127 if constexpr (std::is_same_v<U, xAOD::PFO>) {
128 ptrk = ppfo->
track(0);
129 }
else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
134 ATH_MSG_WARNING(
"Charged PFO with index " << ppfo->index() <<
" has no ID track!");
140 if (thisTracksVertex ==
nullptr)
142 ATH_MSG_DEBUG(
"No vertex associated to track " << ptrk->index() <<
"! So it cannot be associated to the primary vertex");
143 matchedToPrimaryVertex =
false;
156 matchedToPileupSideband =
true;
164 matchedToPrimaryVertex =
true;
170 float z0 = ptrk->
z0() + ptrk->
vz() - vtx->
z();
174 matchedToPileupSideband =
true;
178 PVMatchedAcc(*ppfo) = matchedToPrimaryVertex;
179 PUsidebandMatchedAcc(*ppfo) = matchedToPileupSideband;
182 return StatusCode::SUCCESS;
187 const static SG::AuxElement::Accessor<std::vector<unsigned>> matchingPVs(
"MatchingPVs");
188 const static SG::AuxElement::Accessor<std::vector<unsigned>> matchingPUSBs(
"MatchingPUsidebands");
192 if (!handle.isValid())
195 return StatusCode::FAILURE;
202 return StatusCode::FAILURE;
210 if (!handle.isValid())
213 return StatusCode::FAILURE;
215 trkVtxAssoc = handle.cptr();
221 if constexpr (std::is_same_v<U, xAOD::PFO>) {
222 if (std::abs(ppfo->charge()) < FLT_MIN)
224 }
else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
225 if (!ppfo->isCharged())
233 if constexpr (std::is_same_v<U, xAOD::PFO>) {
234 ptrk = ppfo->
track(0);
235 }
else if constexpr (std::is_same_v<U, xAOD::FlowElement>) {
240 ATH_MSG_WARNING(
"Charged PFO with index " << ppfo->index() <<
" has no ID track!");
244 std::vector<unsigned> matchingVertexList;
245 std::vector<unsigned> matchingPUSBList;
251 if (thisTracksVertex ==
nullptr)
253 ATH_MSG_DEBUG(
"No vertex associated to track " << ptrk->index() <<
"! So it cannot be associated to the primary vertex");
257 matchingVertexList.push_back(thisTracksVertex->index());
261 float z0 = ptrk->
z0() + ptrk->
vz() - vtx->z();
265 matchingPUSBList.push_back(vtx->index());
275 bool matchedToVertex =
false;
276 bool matchedToPileupSideband =
false;
280 ATH_MSG_WARNING(
"Encountered a nullptr vertex when trying to match charged PFOs to vertices");
285 matchedToVertex =
true;
292 matchedToPileupSideband =
true;
296 matchingVertexList.push_back(vtx->index());
297 if (matchedToPileupSideband)
298 matchingPUSBList.push_back(vtx->index());
302 matchingPVs(*ppfo) = std::move(matchingVertexList);
303 matchingPUSBs(*ppfo) = std::move(matchingPUSBList);
306 return StatusCode::SUCCESS;
Scalar theta() const
theta method
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
bool empty() const noexcept
Returns true if the collection is empty.
JetConstituentModifierBase(const std::string &name)
Property holding a SG store/key/clid from which a ReadHandle is made.
Class to hold N-to-one aassociations between tracks and vertices.
const xAOD::Vertex * associatedVertex(const xAOD::TrackParticle *trk) const
float z0() const
Returns the parameter.
float theta() const
Returns the parameter, which has range 0 to .
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
float vz() const
The z origin for the parameters.
float z() const
Returns the z position.
VxType::VertexType vertexType() const
The type of the vertex.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.