LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TrackParticleBuildingAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
11 #include "Managers/GeometryManager.h"
12 
15 
17 
19 
20 using namespace pandora;
21 
22 namespace lar_content
23 {
24 
25 TrackParticleBuildingAlgorithm::TrackParticleBuildingAlgorithm() :
26  m_slidingFitHalfWindow(20)
27 {
28 
29 }
30 
31 //------------------------------------------------------------------------------------------------------------------------------------------
32 
33 void TrackParticleBuildingAlgorithm::CreatePfo(const ParticleFlowObject *const pInputPfo, const ParticleFlowObject*& pOutputPfo) const
34 {
35  try
36  {
37  // Need an input vertex to provide a track propagation direction
38  const Vertex *const pInputVertex = LArPfoHelper::GetVertex(pInputPfo);
39 
40  // In cosmic mode, build tracks from all parent pfos, otherwise require that pfo is track-like
42  {
43  if (!LArPfoHelper::IsTrack(pInputPfo))
44  return;
45  }
46  else
47  {
48  if (!LArPfoHelper::IsFinalState(pInputPfo))
49  return;
50 
51  if (LArPfoHelper::IsNeutrino(pInputPfo))
52  return;
53  }
54 
55  // ATTN If wire w pitches vary between TPCs, exception will be raised in initialisation of lar pseudolayer plugin
56  const LArTPC *const pFirstLArTPC(this->GetPandora().GetGeometry()->GetLArTPCMap().begin()->second);
57  const float layerPitch(pFirstLArTPC->GetWirePitchW());
58 
59  // Calculate sliding fit trajectory
60  LArTrackStateVector trackStateVector;
61  LArPfoHelper::GetSlidingFitTrajectory(pInputPfo, pInputVertex, m_slidingFitHalfWindow, layerPitch, trackStateVector);
62 
63  if (trackStateVector.empty())
64  return;
65 
66  // Build track-like pfo from track trajectory (TODO Correct these placeholder parameters)
67  LArTrackPfoFactory trackFactory;
68  LArTrackPfoParameters pfoParameters;
69  pfoParameters.m_particleId = (LArPfoHelper::IsTrack(pInputPfo) ? pInputPfo->GetParticleId() : MU_MINUS);
70  pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
71  pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
72  pfoParameters.m_energy = 0.f;
73  pfoParameters.m_momentum = pInputPfo->GetMomentum();
74  pfoParameters.m_propertiesToAdd = pInputPfo->GetPropertiesMap();
75  pfoParameters.m_trackStateVector = trackStateVector;
76 
77  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pOutputPfo,
78  trackFactory));
79 
80  const LArTrackPfo *const pLArPfo = dynamic_cast<const LArTrackPfo*>(pOutputPfo);
81  if (NULL == pLArPfo)
82  throw StatusCodeException(STATUS_CODE_FAILURE);
83 
84  // Now update vertex and direction
85  PandoraContentApi::ParticleFlowObject::Metadata pfodata;
86  pfodata.m_momentum = pLArPfo->GetVertexDirection();
87  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pOutputPfo, pfodata));
88 
89  const Vertex *pOutputVertex(NULL);
90 
91  PandoraContentApi::Vertex::Parameters vtxParameters;
92  vtxParameters.m_position = pLArPfo->GetVertexPosition();
93  vtxParameters.m_vertexLabel = pInputVertex->GetVertexLabel();
94  vtxParameters.m_vertexType = pInputVertex->GetVertexType();
95 
96  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, vtxParameters, pOutputVertex));
97  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pOutputPfo, pOutputVertex));
98  }
99  catch (StatusCodeException &statusCodeException)
100  {
101  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
102  throw statusCodeException;
103  }
104 }
105 
106 //------------------------------------------------------------------------------------------------------------------------------------------
107 
108 StatusCode TrackParticleBuildingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
109 {
110  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
111  "SlidingFitHalfWindow", m_slidingFitHalfWindow));
112 
114 }
115 
116 } // namespace lar_content
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
lar pfo object
Definition: LArTrackPfo.h:41
Header file for the pfo helper class.
Header file for the lar pfo class.
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
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.
const pandora::CartesianVector & GetVertexDirection() const
Get vertex direction.
Definition: LArTrackPfo.cc:46
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
Header file for the 3D track building algorithm class.
LArTrackStateVector m_trackStateVector
Definition: LArTrackPfo.h:33
Header file for the cluster helper class.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
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)
static bool IsFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a primary parent particle.
lar pfo object factory responsible for pfo creation
Definition: LArTrackPfo.h:81
static bool IsNeutrinoFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a final-state particle from a neutrino (or antineutrino) interaction.
std::vector< LArTrackState > LArTrackStateVector
Definition: LArPfoObjects.h:64
const pandora::CartesianVector & GetVertexPosition() const
Get vertex position.
Definition: LArTrackPfo.cc:26