EDepSimVolumeId.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////
2 // $Id: EDepSim::VolumeId.cc,v 1.4 2010/04/07 18:06:51 gum Exp $
3 //
4 
5 #include <vector>
6 
7 #include <G4TouchableHandle.hh>
8 
9 #include "EDepSimVolumeId.hh"
10 
12 
14 
15 EDepSim::VolumeId::VolumeId(const G4TouchableHandle& handle) {
16  if(fVolumes.size()>0)fVolumes.clear();
17  int historyDepth = handle->GetHistoryDepth();
18 
19  for (int i=0; i< historyDepth; ++i) {
20  AddVolume(handle->GetVolume(i),handle->GetReplicaNumber(i));
21  }
22 
23 }
24 
25 EDepSim::VolumeId& EDepSim::VolumeId::operator = (const G4TouchableHandle& handle) {
26  if(fVolumes.size()>0)fVolumes.clear();
27  int historyDepth = handle->GetHistoryDepth();
28 
29  for (int i=0; i< historyDepth; ++i) {
30  AddVolume(handle->GetVolume(i),handle->GetReplicaNumber(i));
31  }
32 
33  return *this;
34 }
35 
37  if(fVolumes.size()>0)fVolumes.clear();
39  i != id.fVolumes.end();
40  ++i) {
41  AddVolume(i->fHandle, i->fReplica);
42  }
43 
44  return *this;
45 }
46 
47 void EDepSim::VolumeId::AddVolume(G4VPhysicalVolume* handle, int replica) {
48  Volume vol;
49  vol.fHandle = handle;
50  vol.fReplica = replica;
51  fVolumes.push_back(vol);
52 }
53 
55  if (x.fVolumes.size() != y.fVolumes.size()) return false;
58  for (a = x.fVolumes.begin(), b = y.fVolumes.begin();
59  a != x.fVolumes.end();
60  ++a, ++b) {
61  if (a->fHandle != b->fHandle) return false;
62  if (a->fReplica != b->fReplica) return false;
63  }
64  return true;
65 }
66 
68  return !(x==y);
69 }
70 
71 bool operator == (const EDepSim::VolumeId& x, const G4TouchableHandle& y) {
72  unsigned int historyDepth = y->GetHistoryDepth();
73  if (x.fVolumes.size() != historyDepth) return false;
75  int b;
76  for (a = x.fVolumes.begin(), b=0;
77  a != x.fVolumes.end() && b < 4;
78  ++a, ++b) {
79  if (a->fHandle != y->GetVolume(b)) {
80  return false;
81  }
82  if (a->fReplica != y->GetReplicaNumber(b)) {
83  return false;
84  }
85  }
86  return true;
87 }
88 
89 bool operator == (const G4TouchableHandle& x, const EDepSim::VolumeId& y) {
90  return (y==x);
91 }
92 
93 bool operator != (const EDepSim::VolumeId& x, const G4TouchableHandle& y) {
94  return !(x==y);
95 }
96 
97 bool operator != (const G4TouchableHandle& x, const EDepSim::VolumeId& y) {
98  return !(y==x);
99 }
100 
102  if (x.fVolumes.size() < y.fVolumes.size()) return true;
103  if (x.fVolumes.size() > y.fVolumes.size()) return false;
106  for (a = x.fVolumes.begin(), b = y.fVolumes.begin();
107  a != x.fVolumes.end();
108  ++a, ++b) {
109  if (a->fHandle < b->fHandle) return true;
110  if (a->fHandle > b->fHandle) return false;
111  if (a->fHandle == b->fHandle) {
112  if (a->fReplica < b->fReplica) return true;
113  if (a->fReplica > b->fReplica) return false;
114  }
115  }
116  return false;
117 }
118 
119 std::ostream& operator << (std::ostream& stream, const EDepSim::VolumeId& v) {
121  stream<< "<VolumeId ";
122  if (v.fVolumes.size()<1) {
123  stream << "empty>";
124  return stream;
125  }
126  if (!v.fVolumes.front().fHandle) {
127  stream << "null>";
128  return stream;
129  }
130  stream << v.fVolumes.front().fHandle->GetName() << ">";
131  return stream;
132 }
133 
intermediate_table::const_iterator const_iterator
EDepSim::VolumeId & operator=(const G4TouchableHandle &handle)
const double a
G4VPhysicalVolume * fHandle
friend std::ostream & operator<<(std::ostream &s, const EDepSim::VolumeId &)
VolumeId()
Construct an empty volume Id.
static bool * b
Definition: config.cpp:1043
bool operator<(const EDepSim::VolumeId &x, const EDepSim::VolumeId &y)
list x
Definition: train.py:276
void AddVolume(G4VPhysicalVolume *fHandle, int fReplica)
Explicitly add a new volume to the volume Id.
bool operator==(const EDepSim::VolumeId &x, const EDepSim::VolumeId &y)
bool operator!=(const EDepSim::VolumeId &x, const EDepSim::VolumeId &y)