Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
TrackParticleBuildingAlgorithm.cc
Go to the documentation of this file.
1
10
12
15
17
19
20using namespace pandora;
21
22namespace lar_content
23{
24
28
29//------------------------------------------------------------------------------------------------------------------------------------------
30
31void TrackParticleBuildingAlgorithm::CreatePfo(const ParticleFlowObject *const pInputPfo, const ParticleFlowObject *&pOutputPfo) const
32{
33 try
34 {
35 // Need an input vertex to provide a track propagation direction
36 const Vertex *const pInputVertex = LArPfoHelper::GetVertex(pInputPfo);
37
38 // In cosmic mode, build tracks from all parent pfos, otherwise require that pfo is track-like
40 {
41 if (!LArPfoHelper::IsTrack(pInputPfo))
42 return;
43 }
44 else
45 {
46 if (!LArPfoHelper::IsFinalState(pInputPfo))
47 return;
48
49 if (LArPfoHelper::IsNeutrino(pInputPfo))
50 return;
51 }
52
53 // ATTN If wire w pitches vary between TPCs, exception will be raised in initialisation of lar pseudolayer plugin
54 const LArTPC *const pFirstLArTPC(this->GetPandora().GetGeometry()->GetLArTPCMap().begin()->second);
55 const float layerPitch(pFirstLArTPC->GetWirePitchW());
56
57 // Calculate sliding fit trajectory
58 LArTrackStateVector trackStateVector;
59 LArPfoHelper::GetSlidingFitTrajectory(pInputPfo, pInputVertex, m_slidingFitHalfWindow, layerPitch, trackStateVector);
60
61 if (trackStateVector.empty())
62 return;
63
64 // Build track-like pfo from track trajectory (TODO Correct these placeholder parameters)
65 LArTrackPfoFactory trackFactory;
66 LArTrackPfoParameters pfoParameters;
67 pfoParameters.m_particleId = (LArPfoHelper::IsTrack(pInputPfo) ? pInputPfo->GetParticleId() : MU_MINUS);
68 pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
69 pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
70 pfoParameters.m_energy = 0.f;
71 pfoParameters.m_momentum = pInputPfo->GetMomentum();
72 pfoParameters.m_propertiesToAdd = pInputPfo->GetPropertiesMap();
73 pfoParameters.m_trackStateVector = trackStateVector;
74
75 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pOutputPfo, trackFactory));
76
77 const LArTrackPfo *const pLArPfo = dynamic_cast<const LArTrackPfo *>(pOutputPfo);
78 if (NULL == pLArPfo)
79 throw StatusCodeException(STATUS_CODE_FAILURE);
80
81 // Now update vertex and direction
82 PandoraContentApi::ParticleFlowObject::Metadata pfodata;
83 pfodata.m_momentum = pLArPfo->GetVertexDirection();
84 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pOutputPfo, pfodata));
85
86 const Vertex *pOutputVertex(NULL);
87
88 PandoraContentApi::Vertex::Parameters vtxParameters;
89 vtxParameters.m_position = pLArPfo->GetVertexPosition();
90 vtxParameters.m_vertexLabel = pInputVertex->GetVertexLabel();
91 vtxParameters.m_vertexType = pInputVertex->GetVertexType();
92
93 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, vtxParameters, pOutputVertex));
94 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pOutputPfo, pOutputVertex));
95 }
96 catch (StatusCodeException &statusCodeException)
97 {
98 if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
99 throw statusCodeException;
100 }
101}
102
103//------------------------------------------------------------------------------------------------------------------------------------------
104
106{
108 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitHalfWindow", m_slidingFitHalfWindow));
109
111}
112
113} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the geometry manager class.
Header file for the cluster helper class.
Header file for the pfo helper class.
Header file for the lar pfo class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:43
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
Header file for the 3D track building algorithm class.
static pandora::StatusCode AddToPfo(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pPfo, const T *const pT)
Add a cluster to a particle flow object.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
static bool IsFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a primary parent particle.
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
static bool IsNeutrinoFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a final-state particle from a neutrino (or antineutrino) interaction.
static void GetSlidingFitTrajectory(const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition, const unsigned int layerWindow, const float layerPitch, LArTrackStateVector &trackStateVector, pandora::IntVector *const pIndexVector=nullptr)
Apply 3D sliding fit to a set of 3D points and return track trajectory.
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
lar pfo object factory responsible for pfo creation
Definition LArTrackPfo.h:85
const pandora::CartesianVector & GetVertexPosition() const
Get vertex position.
const pandora::CartesianVector & GetVertexDirection() const
Get vertex direction.
LArTrackStateVector m_trackStateVector
Definition LArTrackPfo.h:36
void CreatePfo(const pandora::ParticleFlowObject *const pInputPfo, const pandora::ParticleFlowObject *&pOutputPfo) const
Create specialised Pfo from an generic input Pfo.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
LArTPC class.
Definition LArTPC.h:26
float GetWirePitchW() const
Get the w wire pitch, units mm.
Definition LArTPC.h:231
ParticleFlowObject class.
const PropertiesMap & GetPropertiesMap() const
Get the map from registered property name to floating point property value.
StatusCode AlterMetadata(const object_creation::ParticleFlowObject::Metadata &metadata)
Alter particle flow object metadata parameters.
int GetParticleId() const
Get the particle flow object id (PDG code)
const CartesianVector & GetMomentum() const
Get particle flow object momentum vector.
static float GetParticleMass(const int pdgCode)
Get the mass of a particle type.
Definition PdgTable.h:205
static int GetParticleCharge(const int pdgCode)
Get the charge of a particle type.
Definition PdgTable.h:227
const Pandora & GetPandora() const
Get the associated pandora instance.
Definition Process.h:116
StatusCodeException class.
StatusCode GetStatusCode() const
Get status code.
Vertex class.
Definition Vertex.h:26
VertexType GetVertexType() const
Get the vertex type.
Definition Vertex.h:124
VertexLabel GetVertexLabel() const
Get the vertex label.
Definition Vertex.h:117
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
std::vector< LArTrackState > LArTrackStateVector
StatusCode
The StatusCode enum.