LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::StreamingAlgorithm Class Reference

StreamingAlgorithm class. More...

#include "StreamingAlgorithm.h"

Inheritance diagram for lar_content::StreamingAlgorithm:

Public Member Functions

 StreamingAlgorithm ()
 Default constructor. More...
 
virtual ~StreamingAlgorithm ()
 

Private Types

typedef std::map< std::string, pandora::StringVector > StreamAlgorithmMap
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

std::string m_outputListName
 The name of the output list. More...
 
std::string m_listType
 The type of the input lists (currently only Cluster is supported) More...
 
pandora::StringVector m_inputListNames
 The names of the input lists. More...
 
pandora::StringVector m_outputListNames
 Names of the output lists if not combining into a single list at the end. More...
 
StreamAlgorithmMap m_streamAlgorithmMap
 A map from individual streams to the algorithms that stream should run. More...
 

Detailed Description

StreamingAlgorithm class.

Definition at line 19 of file StreamingAlgorithm.h.

Member Typedef Documentation

typedef std::map<std::string, pandora::StringVector> lar_content::StreamingAlgorithm::StreamAlgorithmMap
private

Definition at line 30 of file StreamingAlgorithm.h.

Constructor & Destructor Documentation

lar_content::StreamingAlgorithm::StreamingAlgorithm ( )

Default constructor.

Definition at line 26 of file StreamingAlgorithm.cc.

26  :
27  m_listType{"cluster"}
28 {
29 }
std::string m_listType
The type of the input lists (currently only Cluster is supported)
lar_content::StreamingAlgorithm::~StreamingAlgorithm ( )
virtual

Definition at line 33 of file StreamingAlgorithm.cc.

34 {
35 }

Member Function Documentation

StatusCode lar_content::StreamingAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 81 of file StreamingAlgorithm.cc.

References m_inputListNames, m_listType, m_outputListName, m_outputListNames, and m_streamAlgorithmMap.

82 {
83  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ListType", m_listType));
84  std::transform(m_listType.begin(), m_listType.end(), m_listType.begin(), ::tolower);
85  if (m_listType != "cluster")
86  {
87  std::cout << "StreamingAlgorithm::ReadSettings - Error: Only Cluster list type is supported at this time" << std::endl;
88  return STATUS_CODE_INVALID_PARAMETER;
89  }
90 
91  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "InputListNames", m_inputListNames));
92  if (m_inputListNames.empty())
93  {
94  std::cout << "StreamingAlgorithm::ReadSettings - Error: No input lists found" << std::endl;
95  return STATUS_CODE_NOT_FOUND;
96  }
97 
98  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "OutputListName", m_outputListName));
99  PANDORA_RETURN_RESULT_IF_AND_IF(
100  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "OutputListNames", m_outputListNames));
101  if ((m_outputListName.empty() && m_outputListNames.empty()) || (!m_outputListName.empty() && !m_outputListNames.empty()))
102  {
103  std::cout << "StreamingAlgorithm::ReadSettings - Error: You must provide either a single output list name OR a list of output list names"
104  << std::endl;
105  return STATUS_CODE_NOT_FOUND;
106  }
107  if (!m_outputListNames.empty() && m_inputListNames.size() != m_outputListNames.size())
108  {
109  std::cout << "StreamingAlgorithm::ReadSettings - Error: When providing a list of output lists, there should be a one-to-one "
110  << "correspondence with the list of input lists" << std::endl;
111  return STATUS_CODE_INVALID_PARAMETER;
112  }
113 
114  for (std::string listName : m_inputListNames)
115  {
116  std::string algStreamName{"Algorithms" + listName};
117  if (m_streamAlgorithmMap.find(algStreamName) != m_streamAlgorithmMap.end())
118  {
119  std::cout << "StreamingAlgorithm::ReadSettings - Error: Duplicate stream name found" << std::endl;
120  return STATUS_CODE_INVALID_PARAMETER;
121  }
122  PANDORA_RETURN_RESULT_IF(
123  STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmList(*this, xmlHandle, algStreamName, m_streamAlgorithmMap[algStreamName]));
124  if (m_streamAlgorithmMap.at(algStreamName).empty())
125  {
126  std::cout << "StreamingAlgorithm::ReadSettings - Error: Found no algorithms for \'" << algStreamName << "\'" << std::endl;
127  return STATUS_CODE_NOT_FOUND;
128  }
129  }
130 
131  return STATUS_CODE_SUCCESS;
132 }
pandora::StringVector m_inputListNames
The names of the input lists.
pandora::StringVector m_outputListNames
Names of the output lists if not combining into a single list at the end.
StreamAlgorithmMap m_streamAlgorithmMap
A map from individual streams to the algorithms that stream should run.
std::string m_listType
The type of the input lists (currently only Cluster is supported)
std::string m_outputListName
The name of the output list.
StatusCode lar_content::StreamingAlgorithm::Run ( )
private

Definition at line 39 of file StreamingAlgorithm.cc.

References m_inputListNames, m_outputListName, m_outputListNames, and m_streamAlgorithmMap.

40 {
41  unsigned int i{0};
42  for (std::string listName : m_inputListNames)
43  {
44  std::string algStreamName{"Algorithms" + listName};
45  const ClusterList *pClusterList{nullptr};
46  // Set the input list as current
47  PandoraContentApi::ReplaceCurrentList<Cluster>(*this, listName);
48  StatusCode code{PandoraContentApi::GetCurrentList(*this, pClusterList)};
49  if (code == STATUS_CODE_SUCCESS)
50  {
51  for (const auto &alg : m_streamAlgorithmMap.at(algStreamName))
52  { // ATTN - The algorithms replace the current list as they go
53  PandoraContentApi::GetCurrentList(*this, pClusterList);
54  if (!pClusterList->empty())
55  {
56  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RunDaughterAlgorithm(*this, alg));
57  }
58  }
59  // Save the current list to the target output list
60  if (!m_outputListName.empty())
61  PandoraContentApi::SaveList<Cluster>(*this, m_outputListName);
62  else
63  PandoraContentApi::SaveList<Cluster>(*this, m_outputListNames.at(i));
64  }
65  else if (code != STATUS_CODE_NOT_INITIALIZED)
66  {
67  return code;
68  }
69  ++i;
70  }
71 
72  // If we have a single output list specified, set that list as the current list
73  if (!m_outputListName.empty())
74  PandoraContentApi::ReplaceCurrentList<Cluster>(*this, m_outputListName);
75 
76  return STATUS_CODE_SUCCESS;
77 }
pandora::StringVector m_inputListNames
The names of the input lists.
pandora::StringVector m_outputListNames
Names of the output lists if not combining into a single list at the end.
StreamAlgorithmMap m_streamAlgorithmMap
A map from individual streams to the algorithms that stream should run.
std::string m_outputListName
The name of the output list.

Member Data Documentation

pandora::StringVector lar_content::StreamingAlgorithm::m_inputListNames
private

The names of the input lists.

Definition at line 36 of file StreamingAlgorithm.h.

Referenced by ReadSettings(), and Run().

std::string lar_content::StreamingAlgorithm::m_listType
private

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

Definition at line 35 of file StreamingAlgorithm.h.

Referenced by ReadSettings().

std::string lar_content::StreamingAlgorithm::m_outputListName
private

The name of the output list.

Definition at line 34 of file StreamingAlgorithm.h.

Referenced by ReadSettings(), and Run().

pandora::StringVector lar_content::StreamingAlgorithm::m_outputListNames
private

Names of the output lists if not combining into a single list at the end.

Definition at line 37 of file StreamingAlgorithm.h.

Referenced by ReadSettings(), and Run().

StreamAlgorithmMap lar_content::StreamingAlgorithm::m_streamAlgorithmMap
private

A map from individual streams to the algorithms that stream should run.

Definition at line 38 of file StreamingAlgorithm.h.

Referenced by ReadSettings(), and Run().


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