LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
SlicingAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Api/PandoraApi.h"
10 
11 #include "Pandora/AlgorithmHeaders.h"
12 
14 
15 using namespace pandora;
16 
17 namespace lar_content
18 {
19 
20 SlicingAlgorithm::SlicingAlgorithm() :
21  m_pEventSlicingTool(nullptr)
22 {
23 }
24 
25 //------------------------------------------------------------------------------------------------------------------------------------------
26 
28 {
29  SliceList sliceList;
31  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RunDaughterAlgorithm(*this, m_slicingListDeletionAlgorithm));
32 
33  if (sliceList.empty())
34  return STATUS_CODE_SUCCESS;
35 
36  std::string clusterListName;
37  const ClusterList *pClusterList(nullptr);
38  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pClusterList, clusterListName));
39 
40  std::string pfoListName;
41  const PfoList *pPfoList(nullptr);
42  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pPfoList, pfoListName));
43 
44  for (const Slice &slice : sliceList)
45  {
46  const Cluster *pClusterU(nullptr), *pClusterV(nullptr), *pClusterW(nullptr);
47  PandoraContentApi::Cluster::Parameters clusterParametersU, clusterParametersV, clusterParametersW;
48  clusterParametersU.m_caloHitList = slice.m_caloHitListU;
49  clusterParametersV.m_caloHitList = slice.m_caloHitListV;
50  clusterParametersW.m_caloHitList = slice.m_caloHitListW;
51  if (!clusterParametersU.m_caloHitList.empty()) PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, clusterParametersU, pClusterU));
52  if (!clusterParametersV.m_caloHitList.empty()) PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, clusterParametersV, pClusterV));
53  if (!clusterParametersW.m_caloHitList.empty()) PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, clusterParametersW, pClusterW));
54 
55  if (!pClusterU && !pClusterV && !pClusterW)
56  throw StatusCodeException(STATUS_CODE_FAILURE);
57 
58  const Pfo *pSlicePfo(nullptr);
59  PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
60  if (pClusterU) pfoParameters.m_clusterList.push_back(pClusterU);
61  if (pClusterV) pfoParameters.m_clusterList.push_back(pClusterV);
62  if (pClusterW) pfoParameters.m_clusterList.push_back(pClusterW);
63  pfoParameters.m_charge = 0;
64  pfoParameters.m_energy = 0.f;
65  pfoParameters.m_mass = 0.f;
66  pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
67  pfoParameters.m_particleId = 0;
68  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pSlicePfo));
69  }
70 
71  if (!pClusterList->empty())
72  {
73  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Cluster>(*this, m_sliceClusterListName));
74  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Cluster>(*this, m_sliceClusterListName));
75  }
76 
77  if (!pPfoList->empty())
78  {
79  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<ParticleFlowObject>(*this, m_slicePfoListName));
80  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<ParticleFlowObject>(*this, m_slicePfoListName));
81  }
82 
83  return STATUS_CODE_SUCCESS;
84 }
85 
86 //------------------------------------------------------------------------------------------------------------------------------------------
87 
88 StatusCode SlicingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
89 {
90  AlgorithmTool *pAlgorithmTool(nullptr);
91  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmTool(*this, xmlHandle, "SliceCreation", pAlgorithmTool));
92  m_pEventSlicingTool = dynamic_cast<EventSlicingBaseTool*>(pAlgorithmTool);
93 
95  return STATUS_CODE_INVALID_PARAMETER;
96 
97  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithm(*this, xmlHandle, "SlicingListDeletion", m_slicingListDeletionAlgorithm));
98 
99  std::string caloHitListNameU, caloHitListNameV, caloHitListNameW;
100  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputCaloHitListNameU", caloHitListNameU));
101  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputCaloHitListNameV", caloHitListNameV));
102  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputCaloHitListNameW", caloHitListNameW));
103  m_caloHitListNames[TPC_VIEW_U] = caloHitListNameU;
104  m_caloHitListNames[TPC_VIEW_V] = caloHitListNameV;
105  m_caloHitListNames[TPC_VIEW_W] = caloHitListNameW;
106 
107  std::string clusterListNameU, clusterListNameV, clusterListNameW;
108  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameU", clusterListNameU));
109  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameV", clusterListNameV));
110  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameW", clusterListNameW));
111  m_clusterListNames[TPC_VIEW_U] = clusterListNameU;
112  m_clusterListNames[TPC_VIEW_V] = clusterListNameV;
113  m_clusterListNames[TPC_VIEW_W] = clusterListNameW;
114 
115  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputClusterListName", m_sliceClusterListName));
116  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputPfoListName", m_slicePfoListName));
117 
118  return STATUS_CODE_SUCCESS;
119 }
120 
121 } // namespace lar_content
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
HitTypeToNameMap m_caloHitListNames
The hit type to calo hit list name map.
EventSlicingBaseTool class.
std::string m_slicingListDeletionAlgorithm
The name of the slicing list deletion algorithm.
TFile f
Definition: plotHisto.C:6
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_sliceClusterListName
The name of the output slice cluster list.
HitTypeToNameMap m_clusterListNames
The hit type to cluster list name map.
std::vector< Slice > SliceList
std::string m_slicePfoListName
The name of the output slice pfo list.
Header file for the master algorithm class.
EventSlicingBaseTool * m_pEventSlicingTool
The address of the event slicing tool.