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;
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)
SG::Accessor< T, ALLOC > Accessor
size_t index() const
Return the index of this element within its container.
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.