LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::StreamSelectionAlgorithm Class Referenceabstract

StreamSelectionAlgorithm class. More...

#include "StreamSelectionAlgorithm.h"

Inheritance diagram for lar_content::StreamSelectionAlgorithm:
lar_dl_content::DlTrackShowerStreamSelectionAlgorithm

Public Member Functions

 StreamSelectionAlgorithm ()
 Default constructor. More...
 
virtual ~StreamSelectionAlgorithm ()=default
 

Protected Types

typedef std::map< std::string, pandora::ClusterList > ClusterListMap
 

Protected Member Functions

virtual pandora::StatusCode AllocateToStreams (const pandora::Cluster *const pCluster)=0
 Allocate a cluster to the appropriate streams. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Protected Attributes

std::string m_inputListName
 The input list name if not using the current list. More...
 
std::string m_listType
 The type of the input lists (currently only Cluster is supported) More...
 
pandora::StringVector m_listNames
 The name of the output lists. More...
 
ClusterListMap m_clusterListMap
 The map from cluster list names to cluster lists. More...
 

Private Member Functions

pandora::StatusCode Run ()
 

Detailed Description

StreamSelectionAlgorithm class.

Definition at line 19 of file StreamSelectionAlgorithm.h.

Member Typedef Documentation

typedef std::map<std::string, pandora::ClusterList> lar_content::StreamSelectionAlgorithm::ClusterListMap
protected

Definition at line 30 of file StreamSelectionAlgorithm.h.

Constructor & Destructor Documentation

lar_content::StreamSelectionAlgorithm::StreamSelectionAlgorithm ( )

Default constructor.

Definition at line 25 of file StreamSelectionAlgorithm.cc.

References m_listType.

25  :
26  m_inputListName{""},
27  m_listType{"cluster"}
28 {
29 }
std::string m_listType
The type of the input lists (currently only Cluster is supported)
std::string m_inputListName
The input list name if not using the current list.
virtual lar_content::StreamSelectionAlgorithm::~StreamSelectionAlgorithm ( )
virtualdefault

Member Function Documentation

virtual pandora::StatusCode lar_content::StreamSelectionAlgorithm::AllocateToStreams ( const pandora::Cluster *const  pCluster)
protectedpure virtual

Allocate a cluster to the appropriate streams.

Parameters
pClusterThe cluster to allocate to a stream
Returns
The StatusCode

Implemented in lar_dl_content::DlTrackShowerStreamSelectionAlgorithm.

Referenced by Run().

StatusCode lar_content::StreamSelectionAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protected

Definition at line 74 of file StreamSelectionAlgorithm.cc.

References m_inputListName, m_listNames, and m_listType.

75 {
76  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "InputListName", m_inputListName));
77  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ListType", m_listType));
78  std::transform(m_listType.begin(), m_listType.end(), m_listType.begin(), ::tolower);
79  if (m_listType != "cluster")
80  {
81  std::cout << "StreamingAlgorithm::ReadSettings - Error: Only Cluster list type is supported at this time" << std::endl;
82  return STATUS_CODE_INVALID_PARAMETER;
83  }
84 
85  // ATTN - Classes implementing this interface should ensure that m_listNames gets populated from the list names provided to the
86  // implementing class
87  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "ListNames", m_listNames));
88 
89  return STATUS_CODE_SUCCESS;
90 }
std::string m_listType
The type of the input lists (currently only Cluster is supported)
std::string m_inputListName
The input list name if not using the current list.
pandora::StringVector m_listNames
The name of the output lists.
StatusCode lar_content::StreamSelectionAlgorithm::Run ( )
private

Definition at line 33 of file StreamSelectionAlgorithm.cc.

References AllocateToStreams(), m_clusterListMap, m_inputListName, and m_listNames.

34 {
35  if (m_listNames.empty())
36  {
37  std::cout << "StreamSelectionAlgorithm::Run - Error: No output lists found" << std::endl;
38  return STATUS_CODE_NOT_FOUND;
39  }
40 
41  const ClusterList *pClusterList{nullptr};
42  std::string originalClusterListName;
43  if (m_inputListName.empty())
44  {
45  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pClusterList));
46  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentListName<Cluster>(*this, originalClusterListName));
47  }
48  else
49  {
50  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_inputListName, pClusterList));
51  originalClusterListName = m_inputListName;
52  }
53 
54  for (std::string listName : m_listNames)
55  m_clusterListMap[listName] = ClusterList();
56 
57  for (const Cluster *pCluster : *pClusterList)
58  {
59  StatusCode status{this->AllocateToStreams(pCluster)};
60  if (status != STATUS_CODE_SUCCESS)
61  return status;
62  }
63 
64  // ATTN - We're ok with saving empty lists here and allowing future algorithms to simply do nothing if there are no clusters
65  // Moves the subset of clusters in the cluster list from the old list to the new list
66  for (std::string listName : m_listNames)
67  PandoraContentApi::SaveList<ClusterList>(*this, originalClusterListName, listName, m_clusterListMap.at(listName));
68 
69  return STATUS_CODE_SUCCESS;
70 }
std::string m_inputListName
The input list name if not using the current list.
pandora::StringVector m_listNames
The name of the output lists.
ClusterListMap m_clusterListMap
The map from cluster list names to cluster lists.
virtual pandora::StatusCode AllocateToStreams(const pandora::Cluster *const pCluster)=0
Allocate a cluster to the appropriate streams.

Member Data Documentation

ClusterListMap lar_content::StreamSelectionAlgorithm::m_clusterListMap
protected

The map from cluster list names to cluster lists.

Definition at line 46 of file StreamSelectionAlgorithm.h.

Referenced by Run().

std::string lar_content::StreamSelectionAlgorithm::m_inputListName
protected

The input list name if not using the current list.

Definition at line 43 of file StreamSelectionAlgorithm.h.

Referenced by ReadSettings(), and Run().

pandora::StringVector lar_content::StreamSelectionAlgorithm::m_listNames
protected

The name of the output lists.

Definition at line 45 of file StreamSelectionAlgorithm.h.

Referenced by ReadSettings(), and Run().

std::string lar_content::StreamSelectionAlgorithm::m_listType
protected

The type of the input lists (currently only Cluster is supported)

Definition at line 44 of file StreamSelectionAlgorithm.h.

Referenced by ReadSettings(), and StreamSelectionAlgorithm().


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