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

MultiPandoraApiImpl class. More...

#include "MultiPandoraApiImpl.h"

Private Types

typedef std::unordered_map< const pandora::Pandora *, const pandora::Pandora * > PandoraRelationMap
 
typedef std::unordered_map< const pandora::Pandora *, unsigned int > PandoraToVolumeIdMap
 

Private Member Functions

 MultiPandoraApiImpl ()
 Default constructor;. More...
 
 ~MultiPandoraApiImpl ()
 Destructor;. More...
 
const PandoraInstanceMapGetPandoraInstanceMap () const
 Get the pandora instance map. More...
 
const pandora::Pandora * GetPandoraInstance (const pandora::Pandora *const pPrimaryPandora, const unsigned int volumeId) const
 Get the address of the pandora instance associated with a given primary pandora instance and volume id number. More...
 
const PandoraInstanceListGetDaughterPandoraInstanceList (const pandora::Pandora *const pPrimaryPandora) const
 Get the list of daughter pandora instances associated with a given primary pandora instance. More...
 
const pandora::Pandora * GetPrimaryPandoraInstance (const pandora::Pandora *const pDaughterPandora) const
 Get the address of the primary pandora instance associated with a given daughter pandora instance. More...
 
unsigned int GetVolumeId (const pandora::Pandora *const pPandora) const
 Get the volume id associated with a given pandora instance. More...
 
void AddPrimaryPandoraInstance (const pandora::Pandora *const pPrimaryPandora)
 Declare a new primary pandora instance. More...
 
void AddDaughterPandoraInstance (const pandora::Pandora *const pPrimaryPandora, const pandora::Pandora *const pDaughterPandora)
 Add a pandora daughter instance, associated to a primary pandora instance. More...
 
void DeletePandoraInstances (const pandora::Pandora *const pPrimaryPandora)
 Delete all pandora instances associated with (and including) a specified primary pandora instance. More...
 
void SetVolumeId (const pandora::Pandora *const pPandora, const unsigned int volumeId)
 Set the volume id associated with a given pandora instance. More...
 

Private Attributes

PandoraInstanceMap m_primaryToDaughtersMap
 The map from primary pandora instance to list of daughter pandora instances. More...
 
PandoraRelationMap m_daughterToPrimaryMap
 The map from daughter pandora instance to primary pandora instance. More...
 
PandoraToVolumeIdMap m_pandoraToVolumeIdMap
 The map from pandora instance to volume id. More...
 

Friends

class MultiPandoraApi
 

Detailed Description

MultiPandoraApiImpl class.

Definition at line 21 of file MultiPandoraApiImpl.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::Pandora *, const pandora::Pandora *> MultiPandoraApiImpl::PandoraRelationMap
private

Definition at line 108 of file MultiPandoraApiImpl.h.

typedef std::unordered_map<const pandora::Pandora *, unsigned int> MultiPandoraApiImpl::PandoraToVolumeIdMap
private

Definition at line 109 of file MultiPandoraApiImpl.h.

Constructor & Destructor Documentation

MultiPandoraApiImpl::MultiPandoraApiImpl ( )
private

Default constructor;.

Definition at line 90 of file MultiPandoraApiImpl.cc.

91 {
92 }
MultiPandoraApiImpl::~MultiPandoraApiImpl ( )
private

Destructor;.

Definition at line 96 of file MultiPandoraApiImpl.cc.

References DeletePandoraInstances(), and m_primaryToDaughtersMap.

97 {
98  // ATTN This is a copy of the input map, which will be modified by calls to delete pandora instances
99  PandoraInstanceMap pandoraInstanceMap(m_primaryToDaughtersMap);
100 
101  for (const auto &mapElement : pandoraInstanceMap)
102  this->DeletePandoraInstances(mapElement.first);
103 }
void DeletePandoraInstances(const pandora::Pandora *const pPrimaryPandora)
Delete all pandora instances associated with (and including) a specified primary pandora instance...
std::unordered_map< const pandora::Pandora *, PandoraInstanceList > PandoraInstanceMap
PandoraInstanceMap m_primaryToDaughtersMap
The map from primary pandora instance to list of daughter pandora instances.

Member Function Documentation

void MultiPandoraApiImpl::AddDaughterPandoraInstance ( const pandora::Pandora *const  pPrimaryPandora,
const pandora::Pandora *const  pDaughterPandora 
)
private

Add a pandora daughter instance, associated to a primary pandora instance.

Parameters
pPrimaryPandorathe address of the primary pandora instance
pDaughterPandorathe address of the daughter pandora instance

Definition at line 115 of file MultiPandoraApiImpl.cc.

References m_daughterToPrimaryMap, and m_primaryToDaughtersMap.

Referenced by MultiPandoraApi::AddDaughterPandoraInstance().

116 {
117  PandoraInstanceMap::iterator iter = m_primaryToDaughtersMap.find(pPrimaryPandora);
118 
119  if (m_primaryToDaughtersMap.end() == iter)
120  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
121 
122  iter->second.push_back(pDaughterPandora);
123 
124  if (!m_daughterToPrimaryMap.insert(PandoraRelationMap::value_type(pDaughterPandora, pPrimaryPandora)).second)
125  throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
126 }
intermediate_table::iterator iterator
PandoraRelationMap m_daughterToPrimaryMap
The map from daughter pandora instance to primary pandora instance.
PandoraInstanceMap m_primaryToDaughtersMap
The map from primary pandora instance to list of daughter pandora instances.
void MultiPandoraApiImpl::AddPrimaryPandoraInstance ( const pandora::Pandora *const  pPrimaryPandora)
private

Declare a new primary pandora instance.

Parameters
pPrimaryPandorathe address of the primary pandora instance

Definition at line 107 of file MultiPandoraApiImpl.cc.

References m_primaryToDaughtersMap.

Referenced by MultiPandoraApi::AddPrimaryPandoraInstance().

108 {
109  if (!m_primaryToDaughtersMap.insert(PandoraInstanceMap::value_type(pPrimaryPandora, PandoraInstanceList())).second)
110  throw pandora::StatusCodeException(pandora::STATUS_CODE_ALREADY_PRESENT);
111 }
std::vector< const pandora::Pandora * > PandoraInstanceList
PandoraInstanceMap m_primaryToDaughtersMap
The map from primary pandora instance to list of daughter pandora instances.
void MultiPandoraApiImpl::DeletePandoraInstances ( const pandora::Pandora *const  pPrimaryPandora)
private

Delete all pandora instances associated with (and including) a specified primary pandora instance.

Parameters
pPrimaryPandorathe address of the primary pandora instance

Definition at line 130 of file MultiPandoraApiImpl.cc.

References GetDaughterPandoraInstanceList(), m_daughterToPrimaryMap, m_pandoraToVolumeIdMap, and m_primaryToDaughtersMap.

Referenced by MultiPandoraApi::DeletePandoraInstances(), and ~MultiPandoraApiImpl().

131 {
132  PandoraInstanceList pandoraInstanceList;
133 
134  try
135  {
136  pandoraInstanceList = this->GetDaughterPandoraInstanceList(pPrimaryPandora);
137  }
138  catch (const pandora::StatusCodeException &)
139  {
140  std::cout << "MultiPandoraApiImpl::DeletePandoraInstances - unable to find daughter instances associated with primary "
141  << pPrimaryPandora << std::endl;
142  }
143 
144  pandoraInstanceList.push_back(pPrimaryPandora);
145  m_primaryToDaughtersMap.erase(pPrimaryPandora);
146 
147  for (const pandora::Pandora *const pPandora : pandoraInstanceList)
148  {
149  m_pandoraToVolumeIdMap.erase(pPandora);
150  m_daughterToPrimaryMap.erase(pPandora);
151  delete pPandora;
152  }
153 }
PandoraToVolumeIdMap m_pandoraToVolumeIdMap
The map from pandora instance to volume id.
std::vector< const pandora::Pandora * > PandoraInstanceList
PandoraRelationMap m_daughterToPrimaryMap
The map from daughter pandora instance to primary pandora instance.
const PandoraInstanceList & GetDaughterPandoraInstanceList(const pandora::Pandora *const pPrimaryPandora) const
Get the list of daughter pandora instances associated with a given primary pandora instance...
PandoraInstanceMap m_primaryToDaughtersMap
The map from primary pandora instance to list of daughter pandora instances.
const PandoraInstanceList & MultiPandoraApiImpl::GetDaughterPandoraInstanceList ( const pandora::Pandora *const  pPrimaryPandora) const
private

Get the list of daughter pandora instances associated with a given primary pandora instance.

Parameters
pPrimaryPandorathe address of the primary pandora instance
Returns
the daughter pandora instance list

Definition at line 43 of file MultiPandoraApiImpl.cc.

References m_primaryToDaughtersMap.

Referenced by DeletePandoraInstances(), MultiPandoraApi::GetDaughterPandoraInstanceList(), and GetPandoraInstance().

44 {
46 
47  if (m_primaryToDaughtersMap.end() == iter)
48  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
49 
50  return iter->second;
51 }
intermediate_table::const_iterator const_iterator
PandoraInstanceMap m_primaryToDaughtersMap
The map from primary pandora instance to list of daughter pandora instances.
const pandora::Pandora * MultiPandoraApiImpl::GetPandoraInstance ( const pandora::Pandora *const  pPrimaryPandora,
const unsigned int  volumeId 
) const
private

Get the address of the pandora instance associated with a given primary pandora instance and volume id number.

Parameters
pPrimaryPandorathe address of the primary pandora instance
volumeIdthe volume identifier number
Returns
the address of the pandora instance

Definition at line 21 of file MultiPandoraApiImpl.cc.

References GetDaughterPandoraInstanceList(), and GetVolumeId().

Referenced by MultiPandoraApi::GetPandoraInstance().

22 {
23  PandoraInstanceList instanceList(this->GetDaughterPandoraInstanceList(pPrimaryPandora));
24  instanceList.push_back(pPrimaryPandora);
25 
26  for (const pandora::Pandora *const pPandora : instanceList)
27  {
28  try
29  {
30  if (volumeId == this->GetVolumeId(pPandora))
31  return pPandora;
32  }
33  catch (const pandora::StatusCodeException &)
34  {
35  }
36  }
37 
38  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
39 }
std::vector< const pandora::Pandora * > PandoraInstanceList
const PandoraInstanceList & GetDaughterPandoraInstanceList(const pandora::Pandora *const pPrimaryPandora) const
Get the list of daughter pandora instances associated with a given primary pandora instance...
unsigned int GetVolumeId(const pandora::Pandora *const pPandora) const
Get the volume id associated with a given pandora instance.
const PandoraInstanceMap & MultiPandoraApiImpl::GetPandoraInstanceMap ( ) const
private

Get the pandora instance map.

Returns
the pandora instance map

Definition at line 14 of file MultiPandoraApiImpl.cc.

References m_primaryToDaughtersMap.

Referenced by MultiPandoraApi::GetPandoraInstanceMap().

15 {
17 }
PandoraInstanceMap m_primaryToDaughtersMap
The map from primary pandora instance to list of daughter pandora instances.
const pandora::Pandora * MultiPandoraApiImpl::GetPrimaryPandoraInstance ( const pandora::Pandora *const  pDaughterPandora) const
private

Get the address of the primary pandora instance associated with a given daughter pandora instance.

Parameters
pDaughterPandorathe address of the daughter pandora instance
Returns
the address of the primary pandora instance

Definition at line 55 of file MultiPandoraApiImpl.cc.

References m_daughterToPrimaryMap.

Referenced by MultiPandoraApi::GetPrimaryPandoraInstance().

56 {
57  PandoraRelationMap::const_iterator iter = m_daughterToPrimaryMap.find(pDaughterPandora);
58 
59  if (m_daughterToPrimaryMap.end() == iter)
60  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
61 
62  return iter->second;
63 }
intermediate_table::const_iterator const_iterator
PandoraRelationMap m_daughterToPrimaryMap
The map from daughter pandora instance to primary pandora instance.
unsigned int MultiPandoraApiImpl::GetVolumeId ( const pandora::Pandora *const  pPandora) const
private

Get the volume id associated with a given pandora instance.

Parameters
pPandorathe address of the pandora instance
Returns
the volume id

Definition at line 67 of file MultiPandoraApiImpl.cc.

References m_pandoraToVolumeIdMap.

Referenced by GetPandoraInstance(), and MultiPandoraApi::GetVolumeId().

68 {
70 
71  if (m_pandoraToVolumeIdMap.end() == iter)
72  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
73 
74  return iter->second;
75 }
PandoraToVolumeIdMap m_pandoraToVolumeIdMap
The map from pandora instance to volume id.
intermediate_table::const_iterator const_iterator
void MultiPandoraApiImpl::SetVolumeId ( const pandora::Pandora *const  pPandora,
const unsigned int  volumeId 
)
private

Set the volume id associated with a given pandora instance.

Parameters
pPandorathe address of the pandora instance
volumeIdthe volume id

Definition at line 79 of file MultiPandoraApiImpl.cc.

References m_pandoraToVolumeIdMap.

Referenced by MultiPandoraApi::SetVolumeId().

80 {
81  if (m_pandoraToVolumeIdMap.count(pPandora))
82  throw pandora::StatusCodeException(pandora::STATUS_CODE_ALREADY_PRESENT);
83 
84  if (!m_pandoraToVolumeIdMap.insert(PandoraToVolumeIdMap::value_type(pPandora, volumeId)).second)
85  throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
86 }
PandoraToVolumeIdMap m_pandoraToVolumeIdMap
The map from pandora instance to volume id.

Friends And Related Function Documentation

friend class MultiPandoraApi
friend

Definition at line 115 of file MultiPandoraApiImpl.h.

Member Data Documentation

PandoraRelationMap MultiPandoraApiImpl::m_daughterToPrimaryMap
private

The map from daughter pandora instance to primary pandora instance.

Definition at line 112 of file MultiPandoraApiImpl.h.

Referenced by AddDaughterPandoraInstance(), DeletePandoraInstances(), and GetPrimaryPandoraInstance().

PandoraToVolumeIdMap MultiPandoraApiImpl::m_pandoraToVolumeIdMap
private

The map from pandora instance to volume id.

Definition at line 113 of file MultiPandoraApiImpl.h.

Referenced by DeletePandoraInstances(), GetVolumeId(), and SetVolumeId().

PandoraInstanceMap MultiPandoraApiImpl::m_primaryToDaughtersMap
private

The map from primary pandora instance to list of daughter pandora instances.

Definition at line 111 of file MultiPandoraApiImpl.h.

Referenced by AddDaughterPandoraInstance(), AddPrimaryPandoraInstance(), DeletePandoraInstances(), GetDaughterPandoraInstanceList(), GetPandoraInstanceMap(), and ~MultiPandoraApiImpl().


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