LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 88 of file MultiPandoraApiImpl.cc.

89 {
90 }
MultiPandoraApiImpl::~MultiPandoraApiImpl ( )
private

Destructor;.

Definition at line 94 of file MultiPandoraApiImpl.cc.

References DeletePandoraInstances(), and m_primaryToDaughtersMap.

95 {
96  // ATTN This is a copy of the input map, which will be modified by calls to delete pandora instances
97  PandoraInstanceMap pandoraInstanceMap(m_primaryToDaughtersMap);
98 
99  for (const auto &mapElement : pandoraInstanceMap)
100  this->DeletePandoraInstances(mapElement.first);
101 }
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 113 of file MultiPandoraApiImpl.cc.

References m_daughterToPrimaryMap, and m_primaryToDaughtersMap.

Referenced by MultiPandoraApi::AddDaughterPandoraInstance().

114 {
115  PandoraInstanceMap::iterator iter = m_primaryToDaughtersMap.find(pPrimaryPandora);
116 
117  if (m_primaryToDaughtersMap.end() == iter)
118  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
119 
120  iter->second.push_back(pDaughterPandora);
121 
122  if (!m_daughterToPrimaryMap.insert(PandoraRelationMap::value_type(pDaughterPandora, pPrimaryPandora)).second)
123  throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
124 }
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 105 of file MultiPandoraApiImpl.cc.

References m_primaryToDaughtersMap.

Referenced by MultiPandoraApi::AddPrimaryPandoraInstance().

106 {
107  if (!m_primaryToDaughtersMap.insert(PandoraInstanceMap::value_type(pPrimaryPandora, PandoraInstanceList())).second)
108  throw pandora::StatusCodeException(pandora::STATUS_CODE_ALREADY_PRESENT);
109 }
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 128 of file MultiPandoraApiImpl.cc.

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

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

129 {
130  PandoraInstanceList pandoraInstanceList;
131 
132  try
133  {
134  pandoraInstanceList = this->GetDaughterPandoraInstanceList(pPrimaryPandora);
135  }
136  catch (const pandora::StatusCodeException &)
137  {
138  std::cout << "MultiPandoraApiImpl::DeletePandoraInstances - unable to find daughter instances associated with primary " << pPrimaryPandora << std::endl;
139  }
140 
141  pandoraInstanceList.push_back(pPrimaryPandora);
142  m_primaryToDaughtersMap.erase(pPrimaryPandora);
143 
144  for (const pandora::Pandora *const pPandora : pandoraInstanceList)
145  {
146  m_pandoraToVolumeIdMap.erase(pPandora);
147  m_daughterToPrimaryMap.erase(pPandora);
148  delete pPandora;
149  }
150 }
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 41 of file MultiPandoraApiImpl.cc.

References m_primaryToDaughtersMap.

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

42 {
44 
45  if (m_primaryToDaughtersMap.end() == iter)
46  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
47 
48  return iter->second;
49 }
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  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
37 }
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 53 of file MultiPandoraApiImpl.cc.

References m_daughterToPrimaryMap.

Referenced by MultiPandoraApi::GetPrimaryPandoraInstance().

54 {
55  PandoraRelationMap::const_iterator iter = m_daughterToPrimaryMap.find(pDaughterPandora);
56 
57  if (m_daughterToPrimaryMap.end() == iter)
58  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
59 
60  return iter->second;
61 }
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 65 of file MultiPandoraApiImpl.cc.

References m_pandoraToVolumeIdMap.

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

66 {
68 
69  if (m_pandoraToVolumeIdMap.end() == iter)
70  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
71 
72  return iter->second;
73 }
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 77 of file MultiPandoraApiImpl.cc.

References m_pandoraToVolumeIdMap.

Referenced by MultiPandoraApi::SetVolumeId().

78 {
79  if (m_pandoraToVolumeIdMap.count(pPandora))
80  throw pandora::StatusCodeException(pandora::STATUS_CODE_ALREADY_PRESENT);
81 
82  if (!m_pandoraToVolumeIdMap.insert(PandoraToVolumeIdMap::value_type(pPandora, volumeId)).second)
83  throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
84 }
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: