Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
SlicingAlgorithm.cc
Go to the documentation of this file.
1
9#include "Api/PandoraApi.h"
10
12
14
15using namespace pandora;
16
17namespace lar_content
18{
19
20SlicingAlgorithm::SlicingAlgorithm() : m_pEventSlicingTool(nullptr)
21{
22}
23
24//------------------------------------------------------------------------------------------------------------------------------------------
25
27{
28 SliceList sliceList;
31
32 if (sliceList.empty())
33 return STATUS_CODE_SUCCESS;
34
35 std::string clusterListName;
36 const ClusterList *pClusterList(nullptr);
37 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pClusterList, clusterListName));
38
39 std::string pfoListName;
40 const PfoList *pPfoList(nullptr);
41 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pPfoList, pfoListName));
42
43 for (const Slice &slice : sliceList)
44 {
45 const Cluster *pClusterU(nullptr), *pClusterV(nullptr), *pClusterW(nullptr);
46 PandoraContentApi::Cluster::Parameters clusterParametersU, clusterParametersV, clusterParametersW;
47 clusterParametersU.m_caloHitList = slice.m_caloHitListU;
48 clusterParametersV.m_caloHitList = slice.m_caloHitListV;
49 clusterParametersW.m_caloHitList = slice.m_caloHitListW;
50 if (!clusterParametersU.m_caloHitList.empty())
51 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, clusterParametersU, pClusterU));
52 if (!clusterParametersV.m_caloHitList.empty())
53 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, clusterParametersV, pClusterV));
54 if (!clusterParametersW.m_caloHitList.empty())
55 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, clusterParametersW, pClusterW));
56
57 if (!pClusterU && !pClusterV && !pClusterW)
58 throw StatusCodeException(STATUS_CODE_FAILURE);
59
60 const Pfo *pSlicePfo(nullptr);
61 PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
62 if (pClusterU)
63 pfoParameters.m_clusterList.push_back(pClusterU);
64 if (pClusterV)
65 pfoParameters.m_clusterList.push_back(pClusterV);
66 if (pClusterW)
67 pfoParameters.m_clusterList.push_back(pClusterW);
68 pfoParameters.m_charge = 0;
69 pfoParameters.m_energy = 0.f;
70 pfoParameters.m_mass = 0.f;
71 pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
72 pfoParameters.m_particleId = 0;
73 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pSlicePfo));
74 }
75
76 if (!pClusterList->empty())
77 {
80 }
81
82 if (!pPfoList->empty())
83 {
86 }
87
88 return STATUS_CODE_SUCCESS;
89}
90
91//------------------------------------------------------------------------------------------------------------------------------------------
92
94{
95 AlgorithmTool *pAlgorithmTool(nullptr);
96 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmTool(*this, xmlHandle, "SliceCreation", pAlgorithmTool));
97 m_pEventSlicingTool = dynamic_cast<EventSlicingBaseTool *>(pAlgorithmTool);
98
100 return STATUS_CODE_INVALID_PARAMETER;
101
103 STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithm(*this, xmlHandle, "SlicingListDeletion", m_slicingListDeletionAlgorithm));
104
105 std::string caloHitListNameU, caloHitListNameV, caloHitListNameW;
106 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputCaloHitListNameU", caloHitListNameU));
107 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputCaloHitListNameV", caloHitListNameV));
108 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputCaloHitListNameW", caloHitListNameW));
109 m_caloHitListNames[TPC_VIEW_U] = caloHitListNameU;
110 m_caloHitListNames[TPC_VIEW_V] = caloHitListNameV;
111 m_caloHitListNames[TPC_VIEW_W] = caloHitListNameW;
112
113 std::string clusterListNameU, clusterListNameV, clusterListNameW;
114 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameU", clusterListNameU));
115 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameV", clusterListNameV));
116 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameW", clusterListNameW));
117 m_clusterListNames[TPC_VIEW_U] = clusterListNameU;
118 m_clusterListNames[TPC_VIEW_V] = clusterListNameV;
119 m_clusterListNames[TPC_VIEW_W] = clusterListNameW;
120
121 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputClusterListName", m_sliceClusterListName));
122 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputPfoListName", m_slicePfoListName));
123
124 return STATUS_CODE_SUCCESS;
125}
126
127} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the pandora api class.
Header file for the master algorithm class.
#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 RunDaughterAlgorithm(const pandora::Algorithm &algorithm, const std::string &daughterAlgorithmName)
Run an algorithm registered with pandora, from within a parent algorithm.
EventSlicingBaseTool class.
virtual void RunSlicing(const pandora::Algorithm *const pAlgorithm, const SlicingAlgorithm::HitTypeToNameMap &caloHitListNames, const SlicingAlgorithm::HitTypeToNameMap &clusterListNames, SlicingAlgorithm::SliceList &sliceList)=0
Run the slicing tool.
std::string m_slicingListDeletionAlgorithm
The name of the slicing list deletion algorithm.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
std::string m_sliceClusterListName
The name of the output slice cluster list.
pandora::StatusCode Run()
Run the algorithm.
EventSlicingBaseTool * m_pEventSlicingTool
The address of the event slicing tool.
HitTypeToNameMap m_clusterListNames
The hit type to cluster list name map.
std::string m_slicePfoListName
The name of the output slice pfo list.
std::vector< Slice > SliceList
HitTypeToNameMap m_caloHitListNames
The hit type to calo hit list name map.
SlicingAlgorithm()
Default constructor.
AlgorithmTool class. Algorithm tools will tend to be tailored for specific parent algorithms,...
CartesianVector class.
Cluster class.
Definition Cluster.h:31
ParticleFlowObject class.
StatusCodeException class.
static StatusCode ProcessAlgorithm(const Algorithm &algorithm, const TiXmlHandle &xmlHandle, const std::string &description, std::string &algorithmName)
Process an algorithm described in an xml element with a matching "description = .....
Definition XmlHelper.cc:16
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
static StatusCode ProcessAlgorithmTool(const Algorithm &algorithm, const TiXmlHandle &xmlHandle, const std::string &description, AlgorithmTool *&pAlgorithmTool)
Process an algorithm tool described in an xml element with a matching "description = ....
Definition XmlHelper.cc:69
MANAGED_CONTAINER< const Cluster * > ClusterList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList