Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
CustomParticleCreationAlgorithm.cc
Go to the documentation of this file.
1
10
12
14
15using namespace pandora;
16
17namespace lar_content
18{
19
21{
22 // Get input Pfo List
23 const PfoList *pPfoList(NULL);
24
25 if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*this, m_pfoListName, pPfoList))
26 {
28 std::cout << "CustomParticleCreationAlgorithm: cannot find pfo list " << m_pfoListName << std::endl;
29
30 return STATUS_CODE_SUCCESS;
31 }
32
33 // Get input Vertex List
34 const VertexList *pVertexList(NULL);
35
36 if (STATUS_CODE_SUCCESS != PandoraContentApi::GetList(*this, m_vertexListName, pVertexList))
37 {
39 std::cout << "CustomParticleCreationAlgorithm: cannot find vertex list " << m_vertexListName << std::endl;
40
41 return STATUS_CODE_SUCCESS;
42 }
43
44 // Create temporary lists
45 const PfoList *pTempPfoList = NULL;
46 std::string tempPfoListName;
47 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pTempPfoList, tempPfoListName));
48
49 const VertexList *pTempVertexList = NULL;
50 std::string tempVertexListName;
51 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pTempVertexList, tempVertexListName));
52
53 // Loop over input Pfos
54 PfoList pfoList(pPfoList->begin(), pPfoList->end());
55 VertexList vertexList(pVertexList->begin(), pVertexList->end());
56
57 for (PfoList::const_iterator iter = pfoList.begin(), iterEnd = pfoList.end(); iter != iterEnd; ++iter)
58 {
59 const ParticleFlowObject *const pInputPfo = *iter;
60
61 if (pInputPfo->GetVertexList().empty())
62 continue;
63
64 const Vertex *const pInputVertex = LArPfoHelper::GetVertex(pInputPfo);
65
66 if (vertexList.end() == std::find(vertexList.begin(), vertexList.end(), pInputVertex))
67 throw StatusCodeException(STATUS_CODE_FAILURE);
68
69 // Build a new pfo and vertex from the old pfo
70 const ParticleFlowObject *pOutputPfo(NULL);
71
72 this->CreatePfo(pInputPfo, pOutputPfo);
73
74 if (NULL == pOutputPfo)
75 continue;
76
77 if (pOutputPfo->GetVertexList().empty())
78 throw StatusCodeException(STATUS_CODE_FAILURE);
79
80 // Transfer clusters and hierarchy information to new pfo, and delete old pfo and vertex
81 ClusterList clusterList(pInputPfo->GetClusterList().begin(), pInputPfo->GetClusterList().end());
82 PfoList parentList(pInputPfo->GetParentPfoList().begin(), pInputPfo->GetParentPfoList().end());
83 PfoList daughterList(pInputPfo->GetDaughterPfoList().begin(), pInputPfo->GetDaughterPfoList().end());
84
85 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Pfo>(*this, pInputPfo, m_pfoListName));
86 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Vertex>(*this, pInputVertex, m_vertexListName));
87
88 for (ClusterList::const_iterator cIter = clusterList.begin(), cIterEnd = clusterList.end(); cIter != cIterEnd; ++cIter)
89 {
90 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo<Cluster>(*this, pOutputPfo, *cIter));
91 }
92
93 for (PfoList::const_iterator pIter = parentList.begin(), pIterEnd = parentList.end(); pIter != pIterEnd; ++pIter)
94 {
95 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, *pIter, pOutputPfo));
96 }
97
98 for (PfoList::const_iterator dIter = daughterList.begin(), dIterEnd = daughterList.end(); dIter != dIterEnd; ++dIter)
99 {
100 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pOutputPfo, *dIter));
101 }
102 }
103
104 if (!pTempPfoList->empty())
105 {
108 }
109
110 if (!pTempVertexList->empty())
111 {
114 }
115
116 return STATUS_CODE_SUCCESS;
117}
118
119//------------------------------------------------------------------------------------------------------------------------------------------
120
122{
123 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "PfoListName", m_pfoListName));
124 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "VertexListName", m_vertexListName));
125
126 return STATUS_CODE_SUCCESS;
127}
128
129} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the 3D particle creation algorithm class.
Header file for the pfo helper class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:43
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode CreateTemporaryListAndSetCurrent(const pandora::Algorithm &algorithm, const T *&pT, std::string &temporaryListName)
Create a temporary list and set it to be the current list, enabling object creation.
static pandora::StatusCode SetPfoParentDaughterRelationship(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pParentPfo, const pandora::ParticleFlowObject *const pDaughterPfo)
Set parent-daughter particle flow object relationship.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
virtual void CreatePfo(const pandora::ParticleFlowObject *const pInputPfo, const pandora::ParticleFlowObject *&pOutputPfo) const =0
Create specialised Pfo from an generic input Pfo.
std::string m_pfoListName
The name of the input pfo list.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
virtual pandora::StatusCode Run()
Run the algorithm.
std::string m_vertexListName
The name of the input vertex list.
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
const PfoList & GetDaughterPfoList() const
Get the daughter pfo list.
const ClusterList & GetClusterList() const
Get the cluster list.
const PfoList & GetParentPfoList() const
Get the parent pfo list.
const VertexList & GetVertexList() const
Get the vertex list.
StatusCodeException class.
Vertex class.
Definition Vertex.h:26
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
MANAGED_CONTAINER< const Cluster * > ClusterList
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList