Private Member Functions | Private Attributes | List of all members
lar_content::TestBeamParticleCreationAlgorithm Class Reference

TestBeamParticleCreationAlgorithm class. More...

#include <TestBeamParticleCreationAlgorithm.h>

Inheritance diagram for lar_content::TestBeamParticleCreationAlgorithm:

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode SetupTestBeamPfo (const pandora::Pfo *const pNuPfo, const pandora::Pfo *&pTestBeamPfo, pandora::CartesianVector &testBeamStartVertex) const
 Set up the test beam pfo. More...
 
pandora::StatusCode SetupTestBeamVertex (const pandora::Pfo *const pNuPfo, const pandora::Pfo *const pTestBeamPfo, const pandora::CartesianVector &testBeamStartVertex) const
 Set up the test beam vertex. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

std::string m_parentPfoListName
 The parent pfo list name. More...
 
std::string m_trackPfoListName
 The track pfo list name. More...
 
std::string m_showerPfoListName
 The shower pfo list name. More...
 
std::string m_parentVertexListName
 The parent vertex list name. More...
 
std::string m_daughterVertexListName
 The daughter vertex list name. More...
 

Detailed Description

TestBeamParticleCreationAlgorithm class.

Definition at line 19 of file TestBeamParticleCreationAlgorithm.h.

Member Function Documentation

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

Definition at line 149 of file TestBeamParticleCreationAlgorithm.cc.

150 {
151  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "ParentPfoListName", m_parentPfoListName));
152 
153  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "TrackPfoListName", m_trackPfoListName));
154 
155  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "ShowerPfoListName", m_showerPfoListName));
156 
157  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "ParentVertexListName", m_parentVertexListName));
158 
159  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "DaughterVertexListName", m_daughterVertexListName));
160 
161  return STATUS_CODE_SUCCESS;
162 }
std::string m_daughterVertexListName
The daughter vertex list name.
std::string m_parentVertexListName
The parent vertex list name.
StatusCode lar_content::TestBeamParticleCreationAlgorithm::Run ( )
private

Definition at line 20 of file TestBeamParticleCreationAlgorithm.cc.

21 {
22  const PfoList *pParentNuPfoList(nullptr);
23 
24  if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*this, m_parentPfoListName, pParentNuPfoList))
25  {
26  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
27  std::cout << "TestBeamParticleCreationAlgorithm: pfo list " << m_parentPfoListName << " unavailable." << std::endl;
28 
29  return STATUS_CODE_SUCCESS;
30  }
31 
32  PfoList neutrinoPfos;
33 
34  for (const Pfo *const pNuPfo : *pParentNuPfoList)
35  {
36  if (!LArPfoHelper::IsNeutrino(pNuPfo))
37  continue;
38 
39  neutrinoPfos.push_back(pNuPfo);
40 
41  const Pfo *pTestBeamPfo(nullptr);
43  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->SetupTestBeamPfo(pNuPfo, pTestBeamPfo, testBeamStartVertex));
44  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->SetupTestBeamVertex(pNuPfo, pTestBeamPfo, testBeamStartVertex));
45  }
46 
47  for (const Pfo *const pNuPfo : neutrinoPfos)
48  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Pfo>(*this, pNuPfo, m_parentPfoListName));
49 
50  return STATUS_CODE_SUCCESS;
51 }
pandora::StatusCode SetupTestBeamVertex(const pandora::Pfo *const pNuPfo, const pandora::Pfo *const pTestBeamPfo, const pandora::CartesianVector &testBeamStartVertex) const
Set up the test beam vertex.
static int max(int a, int b)
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
pandora::StatusCode SetupTestBeamPfo(const pandora::Pfo *const pNuPfo, const pandora::Pfo *&pTestBeamPfo, pandora::CartesianVector &testBeamStartVertex) const
Set up the test beam pfo.
QTextStream & endl(QTextStream &s)
StatusCode lar_content::TestBeamParticleCreationAlgorithm::SetupTestBeamPfo ( const pandora::Pfo *const  pNuPfo,
const pandora::Pfo *&  pTestBeamPfo,
pandora::CartesianVector &  testBeamStartVertex 
) const
private

Set up the test beam pfo.

Parameters
pNuPfothe input neutrino-hypothesis pfo
pTestBeamPfoto receive the output test-beam-hypothesis pfo
testBeamStartVertexto receive the position of the test beam start-position vertex (position of hit at minimum z)
Returns
status code

Definition at line 55 of file TestBeamParticleCreationAlgorithm.cc.

56 {
57  pTestBeamPfo = nullptr;
59 
60  for (const Pfo *const pNuDaughterPfo : pNuPfo->GetDaughterPfoList())
61  {
62  CaloHitList collectedHits;
63  LArPfoHelper::GetCaloHits(pNuDaughterPfo, TPC_3D, collectedHits);
64 
65  for (const CaloHit *const pCaloHit : collectedHits)
66  {
67  if (pCaloHit->GetPositionVector().GetZ() < testBeamStartVertex.GetZ())
68  {
69  testBeamStartVertex = pCaloHit->GetPositionVector();
70  pTestBeamPfo = pNuDaughterPfo;
71  }
72  }
73  }
74 
75  if (!pTestBeamPfo)
76  return STATUS_CODE_NOT_FOUND;
77 
78  for (const Pfo *const pNuDaughterPfo : pNuPfo->GetDaughterPfoList())
79  {
80  if (pNuDaughterPfo != pTestBeamPfo)
81  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pTestBeamPfo, pNuDaughterPfo));
82  }
83 
84  // Move test beam pfo to parent list from its initial track or shower list
85  const std::string &originalListName(LArPfoHelper::IsTrack(pTestBeamPfo) ? m_trackPfoListName : m_showerPfoListName);
86  PANDORA_RETURN_RESULT_IF(
87  STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*this, originalListName, m_parentPfoListName, PfoList(1, pTestBeamPfo)));
88 
89  // Alter metadata: test beam score (1, if not previously set) and particle id (electron if primary pfo shower-like, else charged pion)
90  PandoraContentApi::ParticleFlowObject::Metadata pfoMetadata;
91  pfoMetadata.m_propertiesToAdd["IsTestBeam"] = 1.f;
92  pfoMetadata.m_propertiesToAdd["TestBeamScore"] =
93  (pNuPfo->GetPropertiesMap().count("TestBeamScore")) ? pNuPfo->GetPropertiesMap().at("TestBeamScore") : 1.f;
94  pfoMetadata.m_particleId = (std::fabs(pTestBeamPfo->GetParticleId()) == E_MINUS) ? E_MINUS : PI_PLUS;
95  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pTestBeamPfo, pfoMetadata));
96 
97  return STATUS_CODE_SUCCESS;
98 }
std::string string
Definition: nybbler.cc:12
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
static int max(int a, int b)
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.
StatusCode lar_content::TestBeamParticleCreationAlgorithm::SetupTestBeamVertex ( const pandora::Pfo *const  pNuPfo,
const pandora::Pfo *const  pTestBeamPfo,
const pandora::CartesianVector &  testBeamStartVertex 
) const
private

Set up the test beam vertex.

Parameters
pNuPfothe input neutrino-hypothesis pfo
pTestBeamPfothe input test-beam-hypothesis pfo
testBeamStartVertexthe input position of the test beam start-position vertex
Returns
status code

Definition at line 102 of file TestBeamParticleCreationAlgorithm.cc.

104 {
105  try
106  {
107  const Vertex *const pInitialVertex(LArPfoHelper::GetVertex(pTestBeamPfo));
108  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromPfo(*this, pTestBeamPfo, pInitialVertex));
109  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Vertex>(*this, pInitialVertex, m_daughterVertexListName));
110  }
111  catch (const StatusCodeException &)
112  {
113  std::cout << "TestBeamParticleCreationAlgorithm::SetupTestBeamVertex - Test beam particle has no initial vertex" << std::endl;
114  }
115 
116  // Set start vertex
117  std::string vertexListName;
118  const VertexList *pVertexList(nullptr);
119  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pVertexList, vertexListName));
120 
121  PandoraContentApi::Vertex::Parameters parameters;
122  parameters.m_position = testBeamStartVertex;
123  parameters.m_vertexLabel = VERTEX_START;
124  parameters.m_vertexType = VERTEX_3D;
125  const Vertex *pTestBeamStartVertex(nullptr);
126  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, parameters, pTestBeamStartVertex));
127  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*this, m_parentVertexListName));
128  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pTestBeamPfo, pTestBeamStartVertex));
129 
130  // Retain interaction vertex
131  try
132  {
133  const Vertex *const pNuVertex(LArPfoHelper::GetVertex(pNuPfo));
134  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromPfo(*this, pNuPfo, pNuVertex));
135  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pTestBeamPfo, pNuVertex));
136  // ATTN This vertex already lives in m_parentVertexListName
137  }
138  catch (const StatusCodeException &)
139  {
140  std::cout << "TestBeamParticleCreationAlgorithm::SetupTestBeamVertex - Cannot transfer interaction vertex to test beam particle" << std::endl;
141  }
142 
143  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Vertex>(*this, m_parentVertexListName));
144  return STATUS_CODE_SUCCESS;
145 }
std::string string
Definition: nybbler.cc:12
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
std::string m_daughterVertexListName
The daughter vertex list name.
std::string m_parentVertexListName
The parent vertex list name.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::list< Vertex > VertexList
Definition: DCEL.h:182
QTextStream & endl(QTextStream &s)

Member Data Documentation

std::string lar_content::TestBeamParticleCreationAlgorithm::m_daughterVertexListName
private

The daughter vertex list name.

Definition at line 55 of file TestBeamParticleCreationAlgorithm.h.

std::string lar_content::TestBeamParticleCreationAlgorithm::m_parentPfoListName
private

The parent pfo list name.

Definition at line 50 of file TestBeamParticleCreationAlgorithm.h.

std::string lar_content::TestBeamParticleCreationAlgorithm::m_parentVertexListName
private

The parent vertex list name.

Definition at line 54 of file TestBeamParticleCreationAlgorithm.h.

std::string lar_content::TestBeamParticleCreationAlgorithm::m_showerPfoListName
private

The shower pfo list name.

Definition at line 52 of file TestBeamParticleCreationAlgorithm.h.

std::string lar_content::TestBeamParticleCreationAlgorithm::m_trackPfoListName
private

The track pfo list name.

Definition at line 51 of file TestBeamParticleCreationAlgorithm.h.


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