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

NeutrinoPropertiesAlgorithm class. More...

#include "NeutrinoPropertiesAlgorithm.h"

Inheritance diagram for lar_content::NeutrinoPropertiesAlgorithm:

Public Member Functions

 NeutrinoPropertiesAlgorithm ()
 Default constructor. More...
 

Private Member Functions

pandora::StatusCode Run ()
 
void SetNeutrinoId (const pandora::ParticleFlowObject *const pNeutrinoPfo) const
 identifying the primary daughter of a neutrino pfo and set the particle id accordingly More...
 
unsigned int GetNTwoDHitsInPfoChain (const pandora::ParticleFlowObject *const pPfo) const
 Get the number of two dimensional hits (TPC_VIEW_U, V or W) contained in clusters in a pfo and all its daughters. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

std::string m_neutrinoPfoListName
 The name of the output neutrino pfo list. More...
 
bool m_includeIsolatedHits
 Whether to include isolated hits when counting 2d hits in pfo chain. More...
 

Detailed Description

Constructor & Destructor Documentation

lar_content::NeutrinoPropertiesAlgorithm::NeutrinoPropertiesAlgorithm ( )

Default constructor.

Definition at line 21 of file NeutrinoPropertiesAlgorithm.cc.

21  :
23 {
24 }
bool m_includeIsolatedHits
Whether to include isolated hits when counting 2d hits in pfo chain.

Member Function Documentation

unsigned int lar_content::NeutrinoPropertiesAlgorithm::GetNTwoDHitsInPfoChain ( const pandora::ParticleFlowObject *const  pPfo) const
private

Get the number of two dimensional hits (TPC_VIEW_U, V or W) contained in clusters in a pfo and all its daughters.

Parameters
pPfoaddress of the pfo
Returns
the number of two dimensional hits

Definition at line 106 of file NeutrinoPropertiesAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), and m_includeIsolatedHits.

Referenced by SetNeutrinoId().

107 {
108  unsigned int nTwoDHits(0);
109 
110  for (const Cluster *const pCluster : pPfo->GetClusterList())
111  {
112  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
113 
114  if ((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType))
115  {
116  nTwoDHits += pCluster->GetNCaloHits();
117 
119  nTwoDHits += pCluster->GetNIsolatedCaloHits();
120  }
121  }
122 
123  for (const ParticleFlowObject *const pDaughterPfo : pPfo->GetDaughterPfoList())
124  {
125  nTwoDHits += this->GetNTwoDHitsInPfoChain(pDaughterPfo);
126  }
127 
128  return nTwoDHits;
129 }
bool m_includeIsolatedHits
Whether to include isolated hits when counting 2d hits in pfo chain.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
unsigned int GetNTwoDHitsInPfoChain(const pandora::ParticleFlowObject *const pPfo) const
Get the number of two dimensional hits (TPC_VIEW_U, V or W) contained in clusters in a pfo and all it...
HitType
Definition: HitType.h:12
StatusCode lar_content::NeutrinoPropertiesAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 133 of file NeutrinoPropertiesAlgorithm.cc.

References m_includeIsolatedHits, and m_neutrinoPfoListName.

134 {
135  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "NeutrinoPfoListName", m_neutrinoPfoListName));
136 
137  PANDORA_RETURN_RESULT_IF_AND_IF(
138  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "IncludeIsolatedHits", m_includeIsolatedHits));
139 
140  return STATUS_CODE_SUCCESS;
141 }
bool m_includeIsolatedHits
Whether to include isolated hits when counting 2d hits in pfo chain.
std::string m_neutrinoPfoListName
The name of the output neutrino pfo list.
StatusCode lar_content::NeutrinoPropertiesAlgorithm::Run ( )
private

Definition at line 28 of file NeutrinoPropertiesAlgorithm.cc.

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

29 {
30  const PfoList *pPfoList(nullptr);
31  PANDORA_THROW_RESULT_IF_AND_IF(
32  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_neutrinoPfoListName, pPfoList));
33 
34  if (!pPfoList || pPfoList->empty())
35  {
36  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
37  std::cout << "NeutrinoPropertiesAlgorithm: unable to find pfo list " << m_neutrinoPfoListName << std::endl;
38 
39  return STATUS_CODE_SUCCESS;
40  }
41 
42  // ATTN Enforces that only one pfo, of neutrino-type, be in the specified input list
43  const ParticleFlowObject *const pNeutrinoPfo((1 == pPfoList->size()) ? *(pPfoList->begin()) : nullptr);
44 
45  if (!pNeutrinoPfo || !LArPfoHelper::IsNeutrino(pNeutrinoPfo))
46  return STATUS_CODE_FAILURE;
47 
48  // ATTN At this (maybe unconventional) stage, remove any lone, placeholder neutrinos, with no daughter particles
49  if (pNeutrinoPfo->GetDaughterPfoList().empty())
50  {
51  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, pNeutrinoPfo, m_neutrinoPfoListName));
52  }
53  else
54  {
55  this->SetNeutrinoId(pNeutrinoPfo);
56  }
57 
58  return STATUS_CODE_SUCCESS;
59 }
void SetNeutrinoId(const pandora::ParticleFlowObject *const pNeutrinoPfo) const
identifying the primary daughter of a neutrino pfo and set the particle id accordingly ...
std::string m_neutrinoPfoListName
The name of the output neutrino pfo list.
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
void lar_content::NeutrinoPropertiesAlgorithm::SetNeutrinoId ( const pandora::ParticleFlowObject *const  pNeutrinoPfo) const
private

identifying the primary daughter of a neutrino pfo and set the particle id accordingly

Parameters
pNeutrinoPfoaddress of the neutrino pfo

Definition at line 63 of file NeutrinoPropertiesAlgorithm.cc.

References util::abs(), GetNTwoDHitsInPfoChain(), and lar_content::LArPfoHelper::SortByNHits().

Referenced by Run().

64 {
65  unsigned int nPrimaryTwoDHits(0);
66  const ParticleFlowObject *pPrimaryDaughter(nullptr);
67 
68  PfoVector daughterPfoVector(pNeutrinoPfo->GetDaughterPfoList().begin(), pNeutrinoPfo->GetDaughterPfoList().end());
69  std::sort(daughterPfoVector.begin(), daughterPfoVector.end(), LArPfoHelper::SortByNHits);
70 
71  for (const ParticleFlowObject *const pDaughterPfo : daughterPfoVector)
72  {
73  const unsigned int nTwoDHits(this->GetNTwoDHitsInPfoChain(pDaughterPfo));
74 
75  if (!pPrimaryDaughter || (nTwoDHits > nPrimaryTwoDHits))
76  {
77  nPrimaryTwoDHits = nTwoDHits;
78  pPrimaryDaughter = pDaughterPfo;
79  }
80  }
81 
82  if (!pPrimaryDaughter)
83  throw StatusCodeException(STATUS_CODE_FAILURE);
84 
85  PandoraContentApi::ParticleFlowObject::Metadata metadata;
86 
87  if (E_MINUS == std::abs(pPrimaryDaughter->GetParticleId()))
88  {
89  metadata.m_particleId = NU_E;
90  }
91  else if (MU_MINUS == std::abs(pPrimaryDaughter->GetParticleId()))
92  {
93  metadata.m_particleId = NU_MU;
94  }
95 
96  if (metadata.m_particleId.IsInitialized())
97  {
98  metadata.m_charge = PdgTable::GetParticleCharge(metadata.m_particleId.Get());
99  metadata.m_mass = PdgTable::GetParticleMass(metadata.m_particleId.Get());
100  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pNeutrinoPfo, metadata));
101  }
102 }
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
constexpr auto abs(T v)
Returns the absolute value of the argument.
unsigned int GetNTwoDHitsInPfoChain(const pandora::ParticleFlowObject *const pPfo) const
Get the number of two dimensional hits (TPC_VIEW_U, V or W) contained in clusters in a pfo and all it...

Member Data Documentation

bool lar_content::NeutrinoPropertiesAlgorithm::m_includeIsolatedHits
private

Whether to include isolated hits when counting 2d hits in pfo chain.

Definition at line 50 of file NeutrinoPropertiesAlgorithm.h.

Referenced by GetNTwoDHitsInPfoChain(), and ReadSettings().

std::string lar_content::NeutrinoPropertiesAlgorithm::m_neutrinoPfoListName
private

The name of the output neutrino pfo list.

Definition at line 48 of file NeutrinoPropertiesAlgorithm.h.

Referenced by ReadSettings(), and Run().


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