ATLAS Offline Software
GeoMaterialPropertyVector.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <stdexcept>
7 #include <iostream>
8 
10 {
13  return true;
14  else
15  return false;
16 }
17 
19 {
20  if (this == &right) return *this;
21 
22  for(unsigned i=0; i<m_MPV.size(); ++i)
23  delete m_MPV[i];
24  m_MPV.clear();
25 
26  m_NumEntries = 0;
27  m_CurrentEntry = -1;
28 
29  for(int i = 0 ; i < right.m_NumEntries; i++)
30  {
31  GeoMPVEntry *newElement = new GeoMPVEntry(right.GetEntry(i));
32  m_MPV.push_back(newElement);
33  m_NumEntries++;
34  }
35 
36  return *this;
37 }
38 
40  double *PropertyValues,
41  int NumElements)
42 {
43  m_NumEntries = 0;
44  m_CurrentEntry = -1;
45 
46  for(int i = 0; i < NumElements; i++)
47  AddElement(PhotonMomenta[i], PropertyValues[i]);
48 }
49 
51 {
52  m_NumEntries = 0;
53  m_CurrentEntry = -1;
54 
55  for(int i = 0 ; i < right.m_NumEntries; i++)
56  {
57  GeoMPVEntry *newElement = new GeoMPVEntry(right.GetEntry(i));
58  m_MPV.push_back(newElement);
59  m_NumEntries++;
60  }
61 }
62 
64 {
65  for(unsigned i=0; i<m_MPV.size(); ++i)
66  delete m_MPV[i];
67  m_MPV.clear();
68 }
69 
71 {
72  m_CurrentEntry = -1;
73 }
74 
75 void GeoMaterialPropertyVector::AddElement(double aPhotonMomentum,
76  double aPropertyValue)
77 {
78  GeoMPVEntry *newElement;
79 
80  newElement = new GeoMPVEntry(aPhotonMomentum, aPropertyValue);
81  m_MPV.push_back(newElement);
82  m_NumEntries++;
83 }
84 
86 {
88  throw std::runtime_error("GeoMaterialPropertyVector::GetProperty ==>Iterator attempted to Retrieve Property out of range");
89  else
90  return m_MPV[m_CurrentEntry]->GetProperty();
91 }
92 
94 {
96  throw std::runtime_error("GeoMaterialPropertyVector::GetPhotonMomentum ==>Iterator attempted to Retrieve Photon Momentum out of range");
97  else
98  return m_MPV[m_CurrentEntry]->GetPhotonMomentum();
99 }
100 
102 {
103  if (m_MPV.empty())
104  {
105  std::cerr << "nothing to dump\n";
106  throw std::runtime_error("GeoMaterialPropertyVector::DumpVector ==>Nothing to dump! Vector is empty");
107  }
108 
109  for (int i = 0; i < m_NumEntries; i++)
110  {
111  std::cout << "m_MPV["<< i << "]: ";
112  m_MPV[i]->DumpEntry();
113  }
114  std::cout << " Done DumpVector of " << m_NumEntries << " entries\n";
115 
116 }
117 
119 {
120  return *m_MPV[i];
121 }
GeoMaterialPropertyVector::operator=
GeoMaterialPropertyVector & operator=(const GeoMaterialPropertyVector &right)
Definition: GeoMaterialPropertyVector.cxx:18
GeoMaterialPropertyVector.h
GeoMaterialPropertyVector::AddElement
void AddElement(double aPhotonMomentum, double aPropertyValue)
Definition: GeoMaterialPropertyVector.cxx:75
GeoMaterialPropertyVector::m_CurrentEntry
int m_CurrentEntry
Definition: GeoMaterialPropertyVector.h:49
GeoMaterialPropertyVector::m_MPV
std::vector< GeoMPVEntry * > m_MPV
Definition: GeoMaterialPropertyVector.h:47
GeoMaterialPropertyVector::GetProperty
double GetProperty() const
Definition: GeoMaterialPropertyVector.cxx:85
GeoMaterialPropertyVector::GetEntry
GeoMPVEntry GetEntry(int i) const
Definition: GeoMaterialPropertyVector.cxx:118
GeoMaterialPropertyVector::GeoMaterialPropertyVector
GeoMaterialPropertyVector()
Definition: GeoMaterialPropertyVector.h:18
GeoMaterialPropertyVector::ResetIterator
void ResetIterator()
Definition: GeoMaterialPropertyVector.cxx:70
GeoMaterialPropertyVector::GetPhotonMomentum
double GetPhotonMomentum() const
Definition: GeoMaterialPropertyVector.cxx:93
lumiFormat.i
int i
Definition: lumiFormat.py:85
GeoMPVEntry
Definition: GeoMPVEntry.h:9
GeoMaterialPropertyVector::~GeoMaterialPropertyVector
~GeoMaterialPropertyVector()
Definition: GeoMaterialPropertyVector.cxx:63
GeoMaterialPropertyVector::DumpVector
void DumpVector()
Definition: GeoMaterialPropertyVector.cxx:101
GeoMaterialPropertyVector::m_NumEntries
int m_NumEntries
Definition: GeoMaterialPropertyVector.h:48
GeoMaterialPropertyVector::operator++
bool operator++()
Definition: GeoMaterialPropertyVector.cxx:9
GeoMaterialPropertyVector
Definition: GeoMaterialPropertyVector.h:12