Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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.

Definition at line 237 of file NeutrinoHierarchyAlgorithm.h.

Constructor & Destructor Documentation

lar_content::NeutrinoHierarchyAlgorithm::NeutrinoHierarchyAlgorithm ( )

Default constructor.

Definition at line 22 of file NeutrinoHierarchyAlgorithm.cc.

23 {
24 }
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 227 of file NeutrinoHierarchyAlgorithm.cc.

229 {
230  PfoVector candidateDaughterPfoVector(candidateDaughterPfoList.begin(), candidateDaughterPfoList.end());
231  std::sort(candidateDaughterPfoVector.begin(), candidateDaughterPfoVector.end(), LArPfoHelper::SortByNHits);
232 
233  // TODO Consider deleting the neutrino pfo if there are no daughter pfo candidates
234  if (candidateDaughterPfoVector.empty())
235  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
236 
237  ClusterList daughterClusterList3D;
238  LArPfoHelper::GetThreeDClusterList(candidateDaughterPfoVector.front(), daughterClusterList3D);
239  daughterClusterList3D.sort(LArClusterHelper::SortByNHits);
240 
241  // If no 3D hits, must leave vertex where it was
242  if (daughterClusterList3D.empty())
243  return;
244 
245  const Vertex *pOldNeutrinoVertex(LArPfoHelper::GetVertex(pNeutrinoPfo));
246  const CartesianVector newVertexPosition(LArClusterHelper::GetClosestPosition(pOldNeutrinoVertex->GetPosition(), daughterClusterList3D.front()));
247 
248  PandoraContentApi::Vertex::Parameters parameters;
249  parameters.m_position = newVertexPosition;
250  parameters.m_vertexLabel = pOldNeutrinoVertex->GetVertexLabel();
251  parameters.m_vertexType = pOldNeutrinoVertex->GetVertexType();
252  parameters.m_x0 = pOldNeutrinoVertex->GetX0();
253 
254  std::string neutrinoVertexListName(m_neutrinoVertexListName);
255  if (neutrinoVertexListName.empty())
256  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentListName<Vertex>(*this, neutrinoVertexListName));
257 
258  std::string temporaryVertexListName;
259  const VertexList *pTemporaryVertexList(nullptr);
260  const Vertex *pNewNeutrinoVertex(nullptr);
261  PANDORA_THROW_RESULT_IF(
262  STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pTemporaryVertexList, temporaryVertexListName));
263  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, parameters, pNewNeutrinoVertex));
264  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*this, neutrinoVertexListName));
265 
266  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromPfo(*this, pNeutrinoPfo, pOldNeutrinoVertex));
267  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pNeutrinoPfo, pNewNeutrinoVertex));
268  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Vertex>(*this, pOldNeutrinoVertex, neutrinoVertexListName));
269 
270  for (auto &mapIter : pfoInfoMap)
271  delete mapIter.second;
272 
273  pfoInfoMap.clear();
274 
275  for (PfoRelationTool *const pPfoRelationTool : m_algorithmToolVector)
276  pPfoRelationTool->Run(this, pNewNeutrinoVertex, pfoInfoMap);
277 }
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.
std::string string
Definition: nybbler.cc:12
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:182
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 281 of file NeutrinoHierarchyAlgorithm.cc.

282 {
283  bool display(false);
284  PANDORA_MONITORING_API(SetEveDisplayParameters(this->GetPandora(), false, DETECTOR_VIEW_XZ, -1.f, -1.f, 1.f));
285  std::cout << "-Neutrino Pfo, nDaughters " << pNeutrinoPfo->GetDaughterPfoList().size() << ", nVertices "
286  << pNeutrinoPfo->GetVertexList().size() << std::endl;
287 
288  PfoVector sortedPfos;
289  for (const auto &mapEntry : pfoInfoMap)
290  sortedPfos.push_back(mapEntry.first);
291  std::sort(sortedPfos.begin(), sortedPfos.end(), LArPfoHelper::SortByNHits);
292 
293  for (const Pfo *const pPfo : sortedPfos)
294  {
295  const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
296 
297  std::cout << "Pfo " << pPfoInfo->GetThisPfo() << ", vtxAssoc " << pPfoInfo->IsNeutrinoVertexAssociated() << ", parent "
298  << pPfoInfo->GetParentPfo() << ", nDaughters " << pPfoInfo->GetDaughterPfoList().size() << " (";
299 
300  for (const ParticleFlowObject *const pDaughterPfo : pPfoInfo->GetDaughterPfoList())
301  std::cout << pDaughterPfo << " ";
302  std::cout << ") " << std::endl;
303 
304  if (pPfoInfo->IsNeutrinoVertexAssociated())
305  {
306  display = true;
307  const PfoList tempPfoList(1, pPfoInfo->GetThisPfo());
308  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &tempPfoList, "VertexPfo", RED, true, false));
309  }
310  }
311 
312  if (display)
313  {
314  PANDORA_MONITORING_API(VisualizeVertices(this->GetPandora(), &(pNeutrinoPfo->GetVertexList()), "NeutrinoVertex", ORANGE));
315  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
316  display = false;
317  }
318 
319  for (const Pfo *const pPfo : sortedPfos)
320  {
321  const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
322 
323  if (!pPfoInfo->GetDaughterPfoList().empty())
324  {
325  display = true;
326  const PfoList tempPfoList(1, pPfoInfo->GetThisPfo());
327  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &tempPfoList, "ParentPfo", RED, true, false));
328  PANDORA_MONITORING_API(
329  VisualizeParticleFlowObjects(this->GetPandora(), &(pPfoInfo->GetDaughterPfoList()), "DaughterPfos", BLUE, true, false));
330  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
331  }
332  }
333 }
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.
NeutrinoHierarchyAlgorithm::PfoInfo PfoInfo
QTextStream & endl(QTextStream &s)
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 127 of file NeutrinoHierarchyAlgorithm.cc.

128 {
129  for (const std::string &daughterPfoListName : m_daughterPfoListNames)
130  {
131  const PfoList *pCandidatePfoList(nullptr);
132 
133  if (STATUS_CODE_SUCCESS == PandoraContentApi::GetList(*this, daughterPfoListName, pCandidatePfoList))
134  {
135  candidateDaughterPfoList.insert(candidateDaughterPfoList.end(), pCandidatePfoList->begin(), pCandidatePfoList->end());
136  }
137  else if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
138  {
139  std::cout << "NeutrinoHierarchyAlgorithm: unable to find pfo list " << daughterPfoListName << std::endl;
140  }
141  }
142 
143  if (candidateDaughterPfoList.empty())
144  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
145 }
std::string string
Definition: nybbler.cc:12
pandora::StringVector m_daughterPfoListNames
The list of daughter pfo list names.
QTextStream & endl(QTextStream &s)
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 149 of file NeutrinoHierarchyAlgorithm.cc.

150 {
151  const float layerPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
152 
153  for (const ParticleFlowObject *const pPfo : pfoList)
154  {
155  PfoInfo *pPfoInfo(nullptr);
156 
157  try
158  {
159  pPfoInfo = new PfoInfo(pPfo, m_halfWindowLayers, layerPitch);
160  (void)pfoInfoMap.insert(PfoInfoMap::value_type(pPfo, pPfoInfo));
161  }
162  catch (StatusCodeException &)
163  {
164  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
165  std::cout << "NeutrinoHierarchyAlgorithm: Unable to calculate pfo information " << std::endl;
166 
167  delete pPfoInfo;
168  }
169  }
170 }
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
NeutrinoHierarchyAlgorithm::PfoInfo PfoInfo
QTextStream & endl(QTextStream &s)
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 104 of file NeutrinoHierarchyAlgorithm.cc.

105 {
106  const PfoList *pPfoList = nullptr;
107  PANDORA_THROW_RESULT_IF_AND_IF(
108  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_neutrinoPfoListName, pPfoList));
109 
110  if (!pPfoList || pPfoList->empty())
111  {
112  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
113  std::cout << "NeutrinoHierarchyAlgorithm: unable to find pfo list " << m_neutrinoPfoListName << std::endl;
114 
115  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
116  }
117 
118  // ATTN Enforces that only one pfo, of neutrino-type, be in the specified input list
119  pNeutrinoPfo = ((1 == pPfoList->size()) ? *(pPfoList->begin()) : nullptr);
120 
121  if (!pNeutrinoPfo || !LArPfoHelper::IsNeutrino(pNeutrinoPfo))
122  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
123 }
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.
QTextStream & endl(QTextStream &s)
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 174 of file NeutrinoHierarchyAlgorithm.cc.

176 {
177  PfoVector candidateDaughterPfoVector(candidateDaughterPfoList.begin(), candidateDaughterPfoList.end());
178  std::sort(candidateDaughterPfoVector.begin(), candidateDaughterPfoVector.end(), LArPfoHelper::SortByNHits);
179 
180  // Add neutrino->primary pfo links
181  for (const ParticleFlowObject *const pDaughterPfo : candidateDaughterPfoVector)
182  {
183  PfoInfoMap::const_iterator iter = pfoInfoMap.find(pDaughterPfo);
184 
185  if ((pfoInfoMap.end() != iter) && (iter->second->IsNeutrinoVertexAssociated()))
186  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pNeutrinoPfo, pDaughterPfo));
187  }
188 
189  // Handle exceptional case where vertex selected far from any other particle passing creation thresholds
190  if ((0 == callDepth) && (0 == pNeutrinoPfo->GetNDaughterPfos()))
191  {
192  this->AdjustVertexAndPfoInfo(pNeutrinoPfo, candidateDaughterPfoList, pfoInfoMap);
193  return this->ProcessPfoInfoMap(pNeutrinoPfo, candidateDaughterPfoList, pfoInfoMap, callDepth + 1);
194  }
195 
196  // Add primary pfo->daughter pfo links
197  PfoVector sortedPfos;
198  for (const auto &mapEntry : pfoInfoMap)
199  sortedPfos.push_back(mapEntry.first);
200  std::sort(sortedPfos.begin(), sortedPfos.end(), LArPfoHelper::SortByNHits);
201 
202  for (const Pfo *const pPfo : sortedPfos)
203  {
204  const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
205 
206  PfoVector daughterPfos(pPfoInfo->GetDaughterPfoList().begin(), pPfoInfo->GetDaughterPfoList().end());
207  std::sort(daughterPfos.begin(), daughterPfos.end(), LArPfoHelper::SortByNHits);
208 
209  for (const ParticleFlowObject *const pDaughterPfo : daughterPfos)
210  PANDORA_THROW_RESULT_IF(
211  STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pPfoInfo->GetThisPfo(), pDaughterPfo));
212  }
213 
214  // Deal with any remaining parent-less pfos
215  for (const ParticleFlowObject *const pRemainingPfo : candidateDaughterPfoVector)
216  {
217  if (!pRemainingPfo->GetParentPfoList().empty())
218  continue;
219 
220  // TODO Most appropriate decision - add as daughter of either i) nearest pfo, or ii) the neutrino (current approach)
221  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pNeutrinoPfo, pRemainingPfo));
222  }
223 }
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 467 of file NeutrinoHierarchyAlgorithm.cc.

468 {
469  AlgorithmToolVector algorithmToolVector;
470  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "PfoRelationTools", algorithmToolVector));
471 
472  for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
473  {
474  PfoRelationTool *const pPfoRelationTool(dynamic_cast<PfoRelationTool *>(*iter));
475 
476  if (!pPfoRelationTool)
477  return STATUS_CODE_INVALID_PARAMETER;
478 
479  m_algorithmToolVector.push_back(pPfoRelationTool);
480  }
481 
482  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "NeutrinoPfoListName", m_neutrinoPfoListName));
483 
484  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "DaughterPfoListNames", m_daughterPfoListNames));
485 
486  PANDORA_RETURN_RESULT_IF_AND_IF(
487  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NeutrinoVertexListName", m_neutrinoVertexListName));
488 
489  PANDORA_RETURN_RESULT_IF_AND_IF(
490  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitHalfWindow", m_halfWindowLayers));
491 
492  PANDORA_RETURN_RESULT_IF_AND_IF(
493  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DisplayPfoInfoMap", m_displayPfoInfoMap));
494 
495  return STATUS_CODE_SUCCESS;
496 }
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 52 of file NeutrinoHierarchyAlgorithm.cc.

53 {
54  const ParticleFlowObject *pNeutrinoPfo(nullptr);
55  PfoList candidateDaughterPfoList;
56 
57  try
58  {
59  this->GetNeutrinoPfo(pNeutrinoPfo);
60  this->GetCandidateDaughterPfoList(candidateDaughterPfoList);
61  }
62  catch (StatusCodeException &statusCodeException)
63  {
64  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
65  std::cout << "NeutrinoHierarchyAlgorithm: required input pfos unavailable." << std::endl;
66 
67  if (STATUS_CODE_NOT_FOUND != statusCodeException.GetStatusCode())
68  throw statusCodeException;
69 
70  return STATUS_CODE_SUCCESS;
71  }
72 
73  PfoInfoMap pfoInfoMap;
74 
75  try
76  {
77  if (!pNeutrinoPfo->GetVertexList().empty())
78  {
79  const Vertex *const pNeutrinoVertex(LArPfoHelper::GetVertex(pNeutrinoPfo));
80  this->GetInitialPfoInfoMap(candidateDaughterPfoList, pfoInfoMap);
81 
82  for (PfoRelationTool *const pPfoRelationTool : m_algorithmToolVector)
83  pPfoRelationTool->Run(this, pNeutrinoVertex, pfoInfoMap);
84  }
85 
86  this->ProcessPfoInfoMap(pNeutrinoPfo, candidateDaughterPfoList, pfoInfoMap);
87  }
88  catch (StatusCodeException &statusCodeException)
89  {
90  std::cout << "NeutrinoHierarchyAlgorithm: unable to process input neutrino pfo, " << statusCodeException.ToString() << std::endl;
91  }
92 
94  this->DisplayPfoInfoMap(pNeutrinoPfo, pfoInfoMap);
95 
96  for (auto &mapIter : pfoInfoMap)
97  delete mapIter.second;
98 
99  return STATUS_CODE_SUCCESS;
100 }
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.
QTextStream & endl(QTextStream &s)
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 28 of file NeutrinoHierarchyAlgorithm.cc.

29 {
30  PfoVector sortedPfos;
31  for (const auto &mapEntry : pfoInfoMap)
32  sortedPfos.push_back(mapEntry.first);
33  std::sort(sortedPfos.begin(), sortedPfos.end(), LArPfoHelper::SortByNHits);
34 
35  for (const Pfo *const pPfo : sortedPfos)
36  {
37  const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
38 
39  if (pPfoInfo->IsNeutrinoVertexAssociated() || pPfoInfo->GetParentPfo())
40  {
41  assignedPfos.push_back(pPfoInfo->GetThisPfo());
42  }
43  else
44  {
45  unassignedPfos.push_back(pPfoInfo->GetThisPfo());
46  }
47  }
48 }
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.

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

The list of daughter pfo list names.

Definition at line 241 of file NeutrinoHierarchyAlgorithm.h.

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.

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.

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

The neutrino pfo list name.

Definition at line 240 of file NeutrinoHierarchyAlgorithm.h.

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.


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