Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
StreamSelectionAlgorithm.cc
Go to the documentation of this file.
1
10
12
15
17
18#include <numeric>
19
20using namespace pandora;
21
22namespace lar_content
23{
24
25StreamSelectionAlgorithm::StreamSelectionAlgorithm() : m_inputListName{""}, m_listType{"cluster"}
26{
27}
28
29//------------------------------------------------------------------------------------------------------------------------------------------
30
32{
33 if (m_listNames.empty())
34 {
35 std::cout << "StreamSelectionAlgorithm::Run - Error: No output lists found" << std::endl;
36 return STATUS_CODE_NOT_FOUND;
37 }
38
39 const ClusterList *pClusterList{nullptr};
40 std::string originalClusterListName;
41 if (m_inputListName.empty())
42 {
43 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pClusterList));
44 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentListName<Cluster>(*this, originalClusterListName));
45 }
46 else
47 {
48 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_inputListName, pClusterList));
49 originalClusterListName = m_inputListName;
50 }
51
52 for (std::string listName : m_listNames)
53 m_clusterListMap[listName] = ClusterList();
54
55 for (const Cluster *pCluster : *pClusterList)
56 {
57 StatusCode status{this->AllocateToStreams(pCluster)};
58 if (status != STATUS_CODE_SUCCESS)
59 return status;
60 }
61
62 // ATTN - We're ok with saving empty lists here and allowing future algorithms to simply do nothing if there are no clusters
63 // Moves the subset of clusters in the cluster list from the old list to the new list
64 for (std::string listName : m_listNames)
65 PandoraContentApi::SaveList<ClusterList>(*this, originalClusterListName, listName, m_clusterListMap.at(listName));
66
67 return STATUS_CODE_SUCCESS;
68}
69
70//------------------------------------------------------------------------------------------------------------------------------------------
71
73{
74 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "InputListName", m_inputListName));
75 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ListType", m_listType));
76 std::transform(m_listType.begin(), m_listType.end(), m_listType.begin(), ::tolower);
77 if (m_listType != "cluster")
78 {
79 std::cout << "StreamingAlgorithm::ReadSettings - Error: Only Cluster list type is supported at this time" << std::endl;
80 return STATUS_CODE_INVALID_PARAMETER;
81 }
82
83 // ATTN - Classes implementing this interface should ensure that m_listNames gets populated from the list names provided to the
84 // implementing class
85 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "ListNames", m_listNames));
86
87 return STATUS_CODE_SUCCESS;
88}
89
90} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the lar calo hit class.
Header file for the lar monte carlo particle helper helper class.
Header file for the lar monitoring helper helper class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
Header file for the deep learning track shower cluster streaming algorithm.
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 GetCurrentList(const pandora::Algorithm &algorithm, const T *&pT)
Get the current list.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
pandora::StatusCode Run()
Run the algorithm.
pandora::StringVector m_listNames
The name of the output lists.
ClusterListMap m_clusterListMap
The map from cluster list names to cluster lists.
std::string m_listType
The type of the input lists (currently only Cluster is supported)
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
std::string m_inputListName
The input list name if not using the current list.
virtual pandora::StatusCode AllocateToStreams(const pandora::Cluster *const pCluster)=0
Allocate a cluster to the appropriate streams.
Cluster class.
Definition Cluster.h:31
static StatusCode ReadVectorOfValues(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, std::vector< T > &vector)
Read a vector of values from a (space separated) list in an xml element.
Definition XmlHelper.h:229
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
StatusCode
The StatusCode enum.