LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::TestBeamParticleCreationAlgorithm Class Reference

TestBeamParticleCreationAlgorithm class. More...

#include "TestBeamParticleCreationAlgorithm.h"

Inheritance diagram for lar_content::TestBeamParticleCreationAlgorithm:

Public Member Functions

 TestBeamParticleCreationAlgorithm ()
 Constructor. More...
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

std::string m_pfoListName
 Input pfo list name. More...
 
std::string m_vertexListName
 Input vertex list name. More...
 
bool m_keepInteractionVertex
 Retain the vertex for the test beam particle at the low z point. More...
 
bool m_keepStartVertex
 Retain the vertex for the test beam particle at the interaction point. More...
 

Detailed Description

Constructor & Destructor Documentation

lar_content::TestBeamParticleCreationAlgorithm::TestBeamParticleCreationAlgorithm ( )

Constructor.

Definition at line 22 of file TestBeamParticleCreationAlgorithm.cc.

22  :
23  m_pfoListName(""),
24  m_vertexListName(""),
26  m_keepStartVertex(true)
27 {
28 }
bool m_keepInteractionVertex
Retain the vertex for the test beam particle at the low z point.
bool m_keepStartVertex
Retain the vertex for the test beam particle at the interaction point.

Member Function Documentation

StatusCode lar_content::TestBeamParticleCreationAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 130 of file TestBeamParticleCreationAlgorithm.cc.

References m_keepInteractionVertex, m_keepStartVertex, m_pfoListName, and m_vertexListName.

131 {
132  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "PfoListName", m_pfoListName));
133 
134  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
135  "KeepInteractionVertex", m_keepInteractionVertex));
136 
137  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
138  "KeepStartVertex", m_keepStartVertex));
139 
140  if (m_keepStartVertex)
141  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "VertexListName", m_vertexListName));
142 
144  {
145  std::cout << "TestBeamParticleCreationAlgorithm::ReadSettings - must persist one vertex per pfo" << std::endl;
146  return STATUS_CODE_INVALID_PARAMETER;
147  }
148 
149  return STATUS_CODE_SUCCESS;
150 }
bool m_keepInteractionVertex
Retain the vertex for the test beam particle at the low z point.
bool m_keepStartVertex
Retain the vertex for the test beam particle at the interaction point.
StatusCode lar_content::TestBeamParticleCreationAlgorithm::Run ( )
private

Definition at line 32 of file TestBeamParticleCreationAlgorithm.cc.

References lar_content::LArPfoHelper::GetCaloHits(), lar_content::LArPfoHelper::GetVertex(), lar_content::LArPfoHelper::IsNeutrino(), m_keepInteractionVertex, m_keepStartVertex, m_pfoListName, m_vertexListName, and max.

33 {
34  const PfoList *pPfoList(nullptr);
35  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_pfoListName, pPfoList));
36 
37  PfoList neutrinoPfos;
38 
39  for (const Pfo *const pPfo : *pPfoList)
40  {
41  if (!LArPfoHelper::IsNeutrino(pPfo))
42  continue;
43 
44  // ATTN: If the test beam score is not set in the neutrino pfo, set the score to 1 as it has been reconstructed under the neutrino hypothesis
45  const PropertiesMap properties(pPfo->GetPropertiesMap());
46  PropertiesMap::const_iterator propertiesIter(properties.find("TestBeamScore"));
47  const float testBeamScore(propertiesIter != properties.end() ? (*propertiesIter).second : 1.f);
48 
49  const PfoList &daughterList(pPfo->GetDaughterPfoList());
50  const Pfo *pPrimaryPfo(nullptr);
52 
53  for (const Pfo *const pDaughterPfo : daughterList)
54  {
55  CaloHitList collectedHits;
56  LArPfoHelper::GetCaloHits(pDaughterPfo, TPC_3D, collectedHits);
57 
58  for (const CaloHit *const pCaloHit : collectedHits)
59  {
60  if (pCaloHit->GetPositionVector().GetZ() < positionMinZCaloHit.GetZ())
61  {
62  positionMinZCaloHit = pCaloHit->GetPositionVector();
63  pPrimaryPfo = pDaughterPfo;
64  }
65  }
66  }
67 
68  for (const Pfo *const pPrimaryDaughterPfo : daughterList)
69  {
70  if (pPrimaryDaughterPfo == pPrimaryPfo)
71  continue;
72 
73  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pPrimaryPfo, pPrimaryDaughterPfo));
74  }
75 
76  PandoraContentApi::ParticleFlowObject::Metadata pfoMetadata;
77  pfoMetadata.m_propertiesToAdd["IsTestBeam"] = 1.f;
78  pfoMetadata.m_propertiesToAdd["TestBeamScore"] = testBeamScore;
79 
80  // ATTN: If the primary pfo is shower like, the target beam particle is most likely an electron/positron. If the primary pfo is track like, the target
81  // beam particle is most likely a pion as pion interactions are more frequent than proton, kaon and muon interactions in the CERN test beam.
82  if (std::abs(pPrimaryPfo->GetParticleId()) != E_MINUS)
83  pfoMetadata.m_particleId = PI_PLUS;
84 
85  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPrimaryPfo, pfoMetadata));
86 
87  try
88  {
90  {
92  {
93  const Vertex *const pVertex(LArPfoHelper::GetVertex(pPrimaryPfo));
94  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromPfo(*this, pPrimaryPfo, pVertex));
95  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Vertex>(*this, pVertex));
96  }
97 
98  std::string vertexListName;
99  const VertexList *pVertexList(nullptr);
100  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pVertexList, vertexListName));
101 
102  PandoraContentApi::Vertex::Parameters parameters;
103  parameters.m_position = positionMinZCaloHit;
104  parameters.m_vertexLabel = VERTEX_START;
105  parameters.m_vertexType = VERTEX_3D;
106 
107  const Vertex *pVertex(nullptr);
108  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, parameters, pVertex));
109  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pPrimaryPfo, pVertex));
110  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*this, m_vertexListName));
111  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Vertex>(*this, m_vertexListName));
112  }
113  }
114  catch (const StatusCodeException &)
115  {
116  std::cout << "TestBeamParticleCreationAlgorithm::Run - unable to modify test beam particle vertex" << std::endl;
117  }
118 
119  neutrinoPfos.push_back(pPfo);
120  }
121 
122  for (const Pfo *const pNeutrinoPfo : neutrinoPfos)
123  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Pfo>(*this, pNeutrinoPfo));
124 
125  return STATUS_CODE_SUCCESS;
126 }
bool m_keepInteractionVertex
Retain the vertex for the test beam particle at the low z point.
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
Int_t max
Definition: plot.C:27
intermediate_table::const_iterator const_iterator
bool m_keepStartVertex
Retain the vertex for the test beam particle at the interaction point.
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
static void GetCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of calo hits of a particular hit type from a list of pfos.
std::list< Vertex > VertexList
Definition: DCEL.h:178

Member Data Documentation

bool lar_content::TestBeamParticleCreationAlgorithm::m_keepInteractionVertex
private

Retain the vertex for the test beam particle at the low z point.

Definition at line 34 of file TestBeamParticleCreationAlgorithm.h.

Referenced by ReadSettings(), and Run().

bool lar_content::TestBeamParticleCreationAlgorithm::m_keepStartVertex
private

Retain the vertex for the test beam particle at the interaction point.

Definition at line 35 of file TestBeamParticleCreationAlgorithm.h.

Referenced by ReadSettings(), and Run().

std::string lar_content::TestBeamParticleCreationAlgorithm::m_pfoListName
private

Input pfo list name.

Definition at line 32 of file TestBeamParticleCreationAlgorithm.h.

Referenced by ReadSettings(), and Run().

std::string lar_content::TestBeamParticleCreationAlgorithm::m_vertexListName
private

Input vertex list name.

Definition at line 33 of file TestBeamParticleCreationAlgorithm.h.

Referenced by ReadSettings(), and Run().


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