LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::NeutrinoHierarchyAlgorithm Class Reference

NeutrinoHierarchyAlgorithm class. More...

#include "NeutrinoHierarchyAlgorithm.h"

Inheritance diagram for lar_content::NeutrinoHierarchyAlgorithm:

Classes

class  PfoInfo
 PfoInfo class. More...
 

Public Types

typedef std::unordered_map< const pandora::ParticleFlowObject *, PfoInfo * > PfoInfoMap
 

Public Member Functions

 NeutrinoHierarchyAlgorithm ()
 Default constructor. More...
 
void SeparatePfos (const NeutrinoHierarchyAlgorithm::PfoInfoMap &pfoInfoMap, pandora::PfoVector &assignedPfos, pandora::PfoVector &unassignedPfos) const
 Query the pfo info map and separate/extract pfos currently either acting as parents or associated with the neutrino vertex. More...
 

Private Types

typedef std::vector< PfoRelationTool * > PfoRelationToolVector
 

Private Member Functions

pandora::StatusCode Run ()
 
void GetNeutrinoPfo (const pandora::ParticleFlowObject *&pNeutrinoPfo) const
 Get the address of the input neutrino pfo - enforces only one pfo present in input list; can return NULL if no neutrino exists. More...
 
void GetCandidateDaughterPfoList (pandora::PfoList &candidateDaughterPfoList) const
 Get the list of candidate daughter pfos. More...
 
void GetInitialPfoInfoMap (const pandora::PfoList &pfoList, PfoInfoMap &pfoInfoMap) const
 Process a provided pfo list and populate an initial pfo info map. More...
 
void ProcessPfoInfoMap (const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap, const unsigned int callDepth=0) const
 Process the information in a pfo info map, creating pfo parent/daughter links. More...
 
void AdjustVertexAndPfoInfo (const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap) const
 Adjust neutrino vertex to ensure agreement with at least one pfo (first in sorted input list) More...
 
void DisplayPfoInfoMap (const pandora::ParticleFlowObject *const pNeutrinoPfo, const PfoInfoMap &pfoInfoMap) const
 Display the information in a pfo info map, visualising pfo parent/daughter links. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

PfoRelationToolVector m_algorithmToolVector
 The algorithm tool vector. More...
 
std::string m_neutrinoPfoListName
 The neutrino pfo list name. More...
 
pandora::StringVector m_daughterPfoListNames
 The list of daughter pfo list names. More...
 
std::string m_neutrinoVertexListName
 The neutrino vertex list name - if not specified will assume current list. More...
 
unsigned int m_halfWindowLayers
 The number of layers to use for half-window of sliding fit. More...
 
bool m_displayPfoInfoMap
 Whether to display the pfo info map (if monitoring is enabled) More...
 

Detailed Description

NeutrinoHierarchyAlgorithm class.

Definition at line 27 of file NeutrinoHierarchyAlgorithm.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::ParticleFlowObject *, PfoInfo *> lar_content::NeutrinoHierarchyAlgorithm::PfoInfoMap

Definition at line 170 of file NeutrinoHierarchyAlgorithm.h.

Constructor & Destructor Documentation

lar_content::NeutrinoHierarchyAlgorithm::NeutrinoHierarchyAlgorithm ( )

Default constructor.

Definition at line 22 of file NeutrinoHierarchyAlgorithm.cc.

22  :
24  m_displayPfoInfoMap(false)
25 {
26 }
bool m_displayPfoInfoMap
Whether to display the pfo info map (if monitoring is enabled)
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.

Member Function Documentation

void lar_content::NeutrinoHierarchyAlgorithm::AdjustVertexAndPfoInfo ( const pandora::ParticleFlowObject *const  pNeutrinoPfo,
const pandora::PfoList &  candidateDaughterPfoList,
PfoInfoMap pfoInfoMap 
) const
private

Adjust neutrino vertex to ensure agreement with at least one pfo (first in sorted input list)

Parameters
pNeutrinoPfothe address of the (original) parent neutrino pfo
candidateDaughterPfoListthe list of candidate daughter pfos
pfoInfoMapthe pfo info map

Definition at line 233 of file NeutrinoHierarchyAlgorithm.cc.

References lar_content::LArClusterHelper::GetClosestPosition(), lar_content::LArPfoHelper::GetThreeDClusterList(), lar_content::LArPfoHelper::GetVertex(), m_algorithmToolVector, m_neutrinoVertexListName, lar_content::LArClusterHelper::SortByNHits(), and lar_content::LArPfoHelper::SortByNHits().

Referenced by ProcessPfoInfoMap().

235 {
236  PfoVector candidateDaughterPfoVector(candidateDaughterPfoList.begin(), candidateDaughterPfoList.end());
237  std::sort(candidateDaughterPfoVector.begin(), candidateDaughterPfoVector.end(), LArPfoHelper::SortByNHits);
238 
239  // TODO Consider deleting the neutrino pfo if there are no daughter pfo candidates
240  if (candidateDaughterPfoVector.empty())
241  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
242 
243  ClusterList daughterClusterList3D;
244  LArPfoHelper::GetThreeDClusterList(candidateDaughterPfoVector.front(), daughterClusterList3D);
245  daughterClusterList3D.sort(LArClusterHelper::SortByNHits);
246 
247  // If no 3D hits, must leave vertex where it was
248  if (daughterClusterList3D.empty())
249  return;
250 
251  const Vertex *pOldNeutrinoVertex(LArPfoHelper::GetVertex(pNeutrinoPfo));
252  const CartesianVector newVertexPosition(LArClusterHelper::GetClosestPosition(pOldNeutrinoVertex->GetPosition(), daughterClusterList3D.front()));
253 
254  PandoraContentApi::Vertex::Parameters parameters;
255  parameters.m_position = newVertexPosition;
256  parameters.m_vertexLabel = pOldNeutrinoVertex->GetVertexLabel();
257  parameters.m_vertexType = pOldNeutrinoVertex->GetVertexType();
258  parameters.m_x0 = pOldNeutrinoVertex->GetX0();
259 
260  std::string neutrinoVertexListName(m_neutrinoVertexListName);
261  if (neutrinoVertexListName.empty())
262  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentListName<Vertex>(*this, neutrinoVertexListName));
263 
264  std::string temporaryVertexListName;
265  const VertexList *pTemporaryVertexList(nullptr);
266  const Vertex *pNewNeutrinoVertex(nullptr);
267  PANDORA_THROW_RESULT_IF(
268  STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pTemporaryVertexList, temporaryVertexListName));
269  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, parameters, pNewNeutrinoVertex));
270  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*this, neutrinoVertexListName));
271 
272  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromPfo(*this, pNeutrinoPfo, pOldNeutrinoVertex));
273  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pNeutrinoPfo, pNewNeutrinoVertex));
274  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Vertex>(*this, pOldNeutrinoVertex, neutrinoVertexListName));
275 
276  for (auto &mapIter : pfoInfoMap)
277  delete mapIter.second;
278 
279  pfoInfoMap.clear();
280 
281  for (PfoRelationTool *const pPfoRelationTool : m_algorithmToolVector)
282  pPfoRelationTool->Run(this, pNewNeutrinoVertex, pfoInfoMap);
283 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
PfoRelationToolVector m_algorithmToolVector
The algorithm tool vector.
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
std::string m_neutrinoVertexListName
The neutrino vertex list name - if not specified will assume current list.
static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 3D clusters from an input pfo.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
static pandora::CartesianVector GetClosestPosition(const pandora::CartesianVector &position, const pandora::ClusterList &clusterList)
Get closest position in a list of clusters to a specified input position vector.
std::list< Vertex > VertexList
Definition: DCEL.h:169
void lar_content::NeutrinoHierarchyAlgorithm::DisplayPfoInfoMap ( const pandora::ParticleFlowObject *const  pNeutrinoPfo,
const PfoInfoMap pfoInfoMap 
) const
private

Display the information in a pfo info map, visualising pfo parent/daughter links.

Parameters
pNeutrinoPfothe address of the (original) parent neutrino pfo
pfoInfoMapthe pfo info map

Definition at line 287 of file NeutrinoHierarchyAlgorithm.cc.

References f, lar_content::NeutrinoHierarchyAlgorithm::PfoInfo::GetThisPfo(), and lar_content::LArPfoHelper::SortByNHits().

Referenced by Run().

288 {
289  bool display(false);
290  PANDORA_MONITORING_API(SetEveDisplayParameters(this->GetPandora(), false, DETECTOR_VIEW_XZ, -1.f, -1.f, 1.f));
291  std::cout << "-Neutrino Pfo, nDaughters " << pNeutrinoPfo->GetDaughterPfoList().size() << ", nVertices "
292  << pNeutrinoPfo->GetVertexList().size() << std::endl;
293 
294  PfoVector sortedPfos;
295  for (const auto &mapEntry : pfoInfoMap)
296  sortedPfos.push_back(mapEntry.first);
297  std::sort(sortedPfos.begin(), sortedPfos.end(), LArPfoHelper::SortByNHits);
298 
299  for (const Pfo *const pPfo : sortedPfos)
300  {
301  const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
302 
303  std::cout << "Pfo " << pPfoInfo->GetThisPfo() << ", vtxAssoc " << pPfoInfo->IsNeutrinoVertexAssociated() << ", parent "
304  << pPfoInfo->GetParentPfo() << ", nDaughters " << pPfoInfo->GetDaughterPfoList().size() << " (";
305 
306  for (const ParticleFlowObject *const pDaughterPfo : pPfoInfo->GetDaughterPfoList())
307  std::cout << pDaughterPfo << " ";
308  std::cout << ") " << std::endl;
309 
310  if (pPfoInfo->IsNeutrinoVertexAssociated())
311  {
312  display = true;
313  const PfoList tempPfoList(1, pPfoInfo->GetThisPfo());
314  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &tempPfoList, "VertexPfo", RED, true, false));
315  }
316  }
317 
318  if (display)
319  {
320  PANDORA_MONITORING_API(VisualizeVertices(this->GetPandora(), &(pNeutrinoPfo->GetVertexList()), "NeutrinoVertex", ORANGE));
321  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
322  display = false;
323  }
324 
325  for (const Pfo *const pPfo : sortedPfos)
326  {
327  const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
328 
329  if (!pPfoInfo->GetDaughterPfoList().empty())
330  {
331  display = true;
332  const PfoList tempPfoList(1, pPfoInfo->GetThisPfo());
333  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &tempPfoList, "ParentPfo", RED, true, false));
334  PANDORA_MONITORING_API(
335  VisualizeParticleFlowObjects(this->GetPandora(), &(pPfoInfo->GetDaughterPfoList()), "DaughterPfos", BLUE, true, false));
336  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
337  }
338  }
339 }
const pandora::ParticleFlowObject * GetThisPfo() const
Get the address of the pfo.
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
TFile f
Definition: plotHisto.C:6
NeutrinoHierarchyAlgorithm::PfoInfo PfoInfo
void lar_content::NeutrinoHierarchyAlgorithm::GetCandidateDaughterPfoList ( pandora::PfoList &  candidateDaughterPfoList) const
private

Get the list of candidate daughter pfos.

Parameters
candidateDaughterPfoListto receive the candidate daughter pfo list

Definition at line 129 of file NeutrinoHierarchyAlgorithm.cc.

References m_daughterPfoListNames.

Referenced by Run().

130 {
131  for (const std::string &daughterPfoListName : m_daughterPfoListNames)
132  {
133  const PfoList *pCandidatePfoList(nullptr);
134 
135  if (STATUS_CODE_SUCCESS == PandoraContentApi::GetList(*this, daughterPfoListName, pCandidatePfoList))
136  {
137  candidateDaughterPfoList.insert(candidateDaughterPfoList.end(), pCandidatePfoList->begin(), pCandidatePfoList->end());
138  }
139  else if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
140  {
141  std::cout << "NeutrinoHierarchyAlgorithm: unable to find pfo list " << daughterPfoListName << std::endl;
142  }
143  }
144 
145  if (candidateDaughterPfoList.empty())
146  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
147 }
pandora::StringVector m_daughterPfoListNames
The list of daughter pfo list names.
void lar_content::NeutrinoHierarchyAlgorithm::GetInitialPfoInfoMap ( const pandora::PfoList &  pfoList,
PfoInfoMap pfoInfoMap 
) const
private

Process a provided pfo list and populate an initial pfo info map.

Parameters
pfoListthe provided pfo list
pfoInfoMapto receive the initial pfo info map

Definition at line 151 of file NeutrinoHierarchyAlgorithm.cc.

References lar_content::LArGeometryHelper::GetWirePitch(), and m_halfWindowLayers.

Referenced by Run().

152 {
153  const float pitchU{LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_U)};
154  const float pitchV{LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_V)};
155  const float pitchW{LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_W)};
156  const float pitchMax{std::max({pitchU, pitchV, pitchW})};
157  const float layerPitch(pitchMax);
158 
159  for (const ParticleFlowObject *const pPfo : pfoList)
160  {
161  PfoInfo *pPfoInfo(nullptr);
162 
163  try
164  {
165  pPfoInfo = new PfoInfo(pPfo, m_halfWindowLayers, layerPitch);
166  (void)pfoInfoMap.insert(PfoInfoMap::value_type(pPfo, pPfoInfo));
167  }
168  catch (StatusCodeException &)
169  {
170  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
171  std::cout << "NeutrinoHierarchyAlgorithm: Unable to calculate pfo information " << std::endl;
172 
173  delete pPfoInfo;
174  }
175  }
176 }
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
NeutrinoHierarchyAlgorithm::PfoInfo PfoInfo
void lar_content::NeutrinoHierarchyAlgorithm::GetNeutrinoPfo ( const pandora::ParticleFlowObject *&  pNeutrinoPfo) const
private

Get the address of the input neutrino pfo - enforces only one pfo present in input list; can return NULL if no neutrino exists.

Parameters
toreceive the address of the input neutrino pfo

Definition at line 106 of file NeutrinoHierarchyAlgorithm.cc.

References lar_content::LArPfoHelper::IsNeutrino(), and m_neutrinoPfoListName.

Referenced by Run().

107 {
108  const PfoList *pPfoList = nullptr;
109  PANDORA_THROW_RESULT_IF_AND_IF(
110  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_neutrinoPfoListName, pPfoList));
111 
112  if (!pPfoList || pPfoList->empty())
113  {
114  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
115  std::cout << "NeutrinoHierarchyAlgorithm: unable to find pfo list " << m_neutrinoPfoListName << std::endl;
116 
117  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
118  }
119 
120  // ATTN Enforces that only one pfo, of neutrino-type, be in the specified input list
121  pNeutrinoPfo = ((1 == pPfoList->size()) ? *(pPfoList->begin()) : nullptr);
122 
123  if (!pNeutrinoPfo || !LArPfoHelper::IsNeutrino(pNeutrinoPfo))
124  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
125 }
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
std::string m_neutrinoPfoListName
The neutrino pfo list name.
void lar_content::NeutrinoHierarchyAlgorithm::ProcessPfoInfoMap ( const pandora::ParticleFlowObject *const  pNeutrinoPfo,
const pandora::PfoList &  candidateDaughterPfoList,
PfoInfoMap pfoInfoMap,
const unsigned int  callDepth = 0 
) const
private

Process the information in a pfo info map, creating pfo parent/daughter links.

Parameters
pNeutrinoPfothe address of the (original) parent neutrino pfo
candidateDaughterPfoListthe list of candidate daughter pfos
pfoInfoMapthe pfo info map
callDepthdepth of callstack for this function, tracking recursive use

Definition at line 180 of file NeutrinoHierarchyAlgorithm.cc.

References AdjustVertexAndPfoInfo(), and lar_content::LArPfoHelper::SortByNHits().

Referenced by Run().

182 {
183  PfoVector candidateDaughterPfoVector(candidateDaughterPfoList.begin(), candidateDaughterPfoList.end());
184  std::sort(candidateDaughterPfoVector.begin(), candidateDaughterPfoVector.end(), LArPfoHelper::SortByNHits);
185 
186  // Add neutrino->primary pfo links
187  for (const ParticleFlowObject *const pDaughterPfo : candidateDaughterPfoVector)
188  {
189  PfoInfoMap::const_iterator iter = pfoInfoMap.find(pDaughterPfo);
190 
191  if ((pfoInfoMap.end() != iter) && (iter->second->IsNeutrinoVertexAssociated()))
192  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pNeutrinoPfo, pDaughterPfo));
193  }
194 
195  // Handle exceptional case where vertex selected far from any other particle passing creation thresholds
196  if ((0 == callDepth) && (0 == pNeutrinoPfo->GetNDaughterPfos()))
197  {
198  this->AdjustVertexAndPfoInfo(pNeutrinoPfo, candidateDaughterPfoList, pfoInfoMap);
199  return this->ProcessPfoInfoMap(pNeutrinoPfo, candidateDaughterPfoList, pfoInfoMap, callDepth + 1);
200  }
201 
202  // Add primary pfo->daughter pfo links
203  PfoVector sortedPfos;
204  for (const auto &mapEntry : pfoInfoMap)
205  sortedPfos.push_back(mapEntry.first);
206  std::sort(sortedPfos.begin(), sortedPfos.end(), LArPfoHelper::SortByNHits);
207 
208  for (const Pfo *const pPfo : sortedPfos)
209  {
210  const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
211 
212  PfoVector daughterPfos(pPfoInfo->GetDaughterPfoList().begin(), pPfoInfo->GetDaughterPfoList().end());
213  std::sort(daughterPfos.begin(), daughterPfos.end(), LArPfoHelper::SortByNHits);
214 
215  for (const ParticleFlowObject *const pDaughterPfo : daughterPfos)
216  PANDORA_THROW_RESULT_IF(
217  STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pPfoInfo->GetThisPfo(), pDaughterPfo));
218  }
219 
220  // Deal with any remaining parent-less pfos
221  for (const ParticleFlowObject *const pRemainingPfo : candidateDaughterPfoVector)
222  {
223  if (!pRemainingPfo->GetParentPfoList().empty())
224  continue;
225 
226  // TODO Most appropriate decision - add as daughter of either i) nearest pfo, or ii) the neutrino (current approach)
227  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pNeutrinoPfo, pRemainingPfo));
228  }
229 }
void ProcessPfoInfoMap(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap, const unsigned int callDepth=0) const
Process the information in a pfo info map, creating pfo parent/daughter links.
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
intermediate_table::const_iterator const_iterator
void AdjustVertexAndPfoInfo(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap) const
Adjust neutrino vertex to ensure agreement with at least one pfo (first in sorted input list) ...
NeutrinoHierarchyAlgorithm::PfoInfo PfoInfo
StatusCode lar_content::NeutrinoHierarchyAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 473 of file NeutrinoHierarchyAlgorithm.cc.

References m_algorithmToolVector, m_daughterPfoListNames, m_displayPfoInfoMap, m_halfWindowLayers, m_neutrinoPfoListName, and m_neutrinoVertexListName.

474 {
475  AlgorithmToolVector algorithmToolVector;
476  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "PfoRelationTools", algorithmToolVector));
477 
478  for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
479  {
480  PfoRelationTool *const pPfoRelationTool(dynamic_cast<PfoRelationTool *>(*iter));
481 
482  if (!pPfoRelationTool)
483  return STATUS_CODE_INVALID_PARAMETER;
484 
485  m_algorithmToolVector.push_back(pPfoRelationTool);
486  }
487 
488  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "NeutrinoPfoListName", m_neutrinoPfoListName));
489 
490  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "DaughterPfoListNames", m_daughterPfoListNames));
491 
492  PANDORA_RETURN_RESULT_IF_AND_IF(
493  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NeutrinoVertexListName", m_neutrinoVertexListName));
494 
495  PANDORA_RETURN_RESULT_IF_AND_IF(
496  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitHalfWindow", m_halfWindowLayers));
497 
498  PANDORA_RETURN_RESULT_IF_AND_IF(
499  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DisplayPfoInfoMap", m_displayPfoInfoMap));
500 
501  return STATUS_CODE_SUCCESS;
502 }
PfoRelationToolVector m_algorithmToolVector
The algorithm tool vector.
bool m_displayPfoInfoMap
Whether to display the pfo info map (if monitoring is enabled)
intermediate_table::const_iterator const_iterator
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.
std::string m_neutrinoVertexListName
The neutrino vertex list name - if not specified will assume current list.
std::string m_neutrinoPfoListName
The neutrino pfo list name.
pandora::StringVector m_daughterPfoListNames
The list of daughter pfo list names.
StatusCode lar_content::NeutrinoHierarchyAlgorithm::Run ( )
private

Definition at line 54 of file NeutrinoHierarchyAlgorithm.cc.

References DisplayPfoInfoMap(), GetCandidateDaughterPfoList(), GetInitialPfoInfoMap(), GetNeutrinoPfo(), lar_content::LArPfoHelper::GetVertex(), m_algorithmToolVector, m_displayPfoInfoMap, and ProcessPfoInfoMap().

55 {
56  const ParticleFlowObject *pNeutrinoPfo(nullptr);
57  PfoList candidateDaughterPfoList;
58 
59  try
60  {
61  this->GetNeutrinoPfo(pNeutrinoPfo);
62  this->GetCandidateDaughterPfoList(candidateDaughterPfoList);
63  }
64  catch (StatusCodeException &statusCodeException)
65  {
66  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
67  std::cout << "NeutrinoHierarchyAlgorithm: required input pfos unavailable." << std::endl;
68 
69  if (STATUS_CODE_NOT_FOUND != statusCodeException.GetStatusCode())
70  throw statusCodeException;
71 
72  return STATUS_CODE_SUCCESS;
73  }
74 
75  PfoInfoMap pfoInfoMap;
76 
77  try
78  {
79  if (!pNeutrinoPfo->GetVertexList().empty())
80  {
81  const Vertex *const pNeutrinoVertex(LArPfoHelper::GetVertex(pNeutrinoPfo));
82  this->GetInitialPfoInfoMap(candidateDaughterPfoList, pfoInfoMap);
83 
84  for (PfoRelationTool *const pPfoRelationTool : m_algorithmToolVector)
85  pPfoRelationTool->Run(this, pNeutrinoVertex, pfoInfoMap);
86  }
87 
88  this->ProcessPfoInfoMap(pNeutrinoPfo, candidateDaughterPfoList, pfoInfoMap);
89  }
90  catch (StatusCodeException &statusCodeException)
91  {
92  std::cout << "NeutrinoHierarchyAlgorithm: unable to process input neutrino pfo, " << statusCodeException.ToString() << std::endl;
93  }
94 
96  this->DisplayPfoInfoMap(pNeutrinoPfo, pfoInfoMap);
97 
98  for (auto &mapIter : pfoInfoMap)
99  delete mapIter.second;
100 
101  return STATUS_CODE_SUCCESS;
102 }
void ProcessPfoInfoMap(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap, const unsigned int callDepth=0) const
Process the information in a pfo info map, creating pfo parent/daughter links.
PfoRelationToolVector m_algorithmToolVector
The algorithm tool vector.
bool m_displayPfoInfoMap
Whether to display the pfo info map (if monitoring is enabled)
void DisplayPfoInfoMap(const pandora::ParticleFlowObject *const pNeutrinoPfo, const PfoInfoMap &pfoInfoMap) const
Display the information in a pfo info map, visualising pfo parent/daughter links. ...
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
std::unordered_map< const pandora::ParticleFlowObject *, PfoInfo * > PfoInfoMap
void GetNeutrinoPfo(const pandora::ParticleFlowObject *&pNeutrinoPfo) const
Get the address of the input neutrino pfo - enforces only one pfo present in input list; can return N...
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
void GetCandidateDaughterPfoList(pandora::PfoList &candidateDaughterPfoList) const
Get the list of candidate daughter pfos.
void GetInitialPfoInfoMap(const pandora::PfoList &pfoList, PfoInfoMap &pfoInfoMap) const
Process a provided pfo list and populate an initial pfo info map.
void lar_content::NeutrinoHierarchyAlgorithm::SeparatePfos ( const NeutrinoHierarchyAlgorithm::PfoInfoMap pfoInfoMap,
pandora::PfoVector &  assignedPfos,
pandora::PfoVector &  unassignedPfos 
) const

Query the pfo info map and separate/extract pfos currently either acting as parents or associated with the neutrino vertex.

Parameters
pfoInfoMapthe pfo info map
assignedPfosto receive the sorted vector of assigned pfos
unassignedPfosto receive the sorted vector of unassigned pfos

Definition at line 30 of file NeutrinoHierarchyAlgorithm.cc.

References lar_content::LArPfoHelper::SortByNHits().

Referenced by lar_content::BranchAssociatedPfosTool::Run(), and lar_content::EndAssociatedPfosTool::Run().

31 {
32  PfoVector sortedPfos;
33  for (const auto &mapEntry : pfoInfoMap)
34  sortedPfos.push_back(mapEntry.first);
35  std::sort(sortedPfos.begin(), sortedPfos.end(), LArPfoHelper::SortByNHits);
36 
37  for (const Pfo *const pPfo : sortedPfos)
38  {
39  const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
40 
41  if (pPfoInfo->IsNeutrinoVertexAssociated() || pPfoInfo->GetParentPfo())
42  {
43  assignedPfos.push_back(pPfoInfo->GetThisPfo());
44  }
45  else
46  {
47  unassignedPfos.push_back(pPfoInfo->GetThisPfo());
48  }
49  }
50 }
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
NeutrinoHierarchyAlgorithm::PfoInfo PfoInfo

Member Data Documentation

PfoRelationToolVector lar_content::NeutrinoHierarchyAlgorithm::m_algorithmToolVector
private

The algorithm tool vector.

Definition at line 238 of file NeutrinoHierarchyAlgorithm.h.

Referenced by AdjustVertexAndPfoInfo(), ReadSettings(), and Run().

pandora::StringVector lar_content::NeutrinoHierarchyAlgorithm::m_daughterPfoListNames
private

The list of daughter pfo list names.

Definition at line 241 of file NeutrinoHierarchyAlgorithm.h.

Referenced by GetCandidateDaughterPfoList(), and ReadSettings().

bool lar_content::NeutrinoHierarchyAlgorithm::m_displayPfoInfoMap
private

Whether to display the pfo info map (if monitoring is enabled)

Definition at line 246 of file NeutrinoHierarchyAlgorithm.h.

Referenced by ReadSettings(), and Run().

unsigned int lar_content::NeutrinoHierarchyAlgorithm::m_halfWindowLayers
private

The number of layers to use for half-window of sliding fit.

Definition at line 245 of file NeutrinoHierarchyAlgorithm.h.

Referenced by GetInitialPfoInfoMap(), and ReadSettings().

std::string lar_content::NeutrinoHierarchyAlgorithm::m_neutrinoPfoListName
private

The neutrino pfo list name.

Definition at line 240 of file NeutrinoHierarchyAlgorithm.h.

Referenced by GetNeutrinoPfo(), and ReadSettings().

std::string lar_content::NeutrinoHierarchyAlgorithm::m_neutrinoVertexListName
private

The neutrino vertex list name - if not specified will assume current list.

Definition at line 243 of file NeutrinoHierarchyAlgorithm.h.

Referenced by AdjustVertexAndPfoInfo(), and ReadSettings().


The documentation for this class was generated from the following files: