EDepSimVolumeId.hh
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////
2 // $Id: EDepSim::VolumeId.hh,v 1.2 2004/11/18 01:30:40 jnurep Exp $
3 //
4 #ifndef EDepSim_VolumeId_hh_seen
5 #define EDepSim_VolumeId_hh_seen
6 
7 #include <vector>
8 #include <ostream>
9 
10 #include <G4VPhysicalVolume.hh>
11 #include <G4TouchableHandle.hh>
12 
13 namespace EDepSim {class VolumeId;}
14 
16 bool operator ==(const EDepSim::VolumeId& x, const G4TouchableHandle& y);
17 bool operator ==(const G4TouchableHandle& x, const EDepSim::VolumeId& y);
19 bool operator !=(const EDepSim::VolumeId& x, const G4TouchableHandle& y);
20 bool operator !=(const G4TouchableHandle& x, const EDepSim::VolumeId& y);
21 bool operator <(const EDepSim::VolumeId& x, const EDepSim::VolumeId& y);
22 
23 std::ostream& operator << (std::ostream& stream, const EDepSim::VolumeId& v);
24 
25 /// A class to provide a unique identifier for all physical volumes. One of
26 /// the features of G4 is that physical volumes are identified by their
27 /// position in the volume tree. This has many advantages, but it means that
28 /// it can be quite trick to figure out if two physical volume pointers refer
29 /// to the same physical volume, or different replicas of the same physical
30 /// volume. (Consider the case where a you have an unreplicated sub-volume of
31 /// a replicated parent). This class provides a unique comparable object that
32 /// allows an equality test between volumes taking into account the full
33 /// position in the hierarchy. It is similar in function to
34 /// G4TouchableHandle, but provides better comparison operators.
36 public:
37  /// Construct a new volume Id.
38  VolumeId(const G4TouchableHandle& handle);
39  /// Construct an empty volume Id.
40  VolumeId();
41  ~VolumeId();
42 
43  /// Explicitly add a new volume to the volume Id.
44  void AddVolume(G4VPhysicalVolume* fHandle,int fReplica);
45 
46  bool operator !() {
47  return (fVolumes.size()==0);
48  };
49 
50  EDepSim::VolumeId& operator = (const G4TouchableHandle& handle);
52 
53  friend bool ::operator ==(const EDepSim::VolumeId& x,
54  const G4TouchableHandle& y);
55  friend bool ::operator ==(const G4TouchableHandle& x,
56  const EDepSim::VolumeId& y);
57  friend bool ::operator ==(const EDepSim::VolumeId& x,
58  const EDepSim::VolumeId& y);
59 
60  friend bool ::operator !=(const EDepSim::VolumeId& x,
61  const G4TouchableHandle& y);
62  friend bool ::operator !=(const G4TouchableHandle& x,
63  const EDepSim::VolumeId& y);
64  friend bool ::operator !=(const EDepSim::VolumeId& x,
65  const EDepSim::VolumeId& y);
66 
67  friend bool ::operator <(const EDepSim::VolumeId& x,
68  const EDepSim::VolumeId& y);
69 
70  friend std::ostream& ::operator << (std::ostream& s, const EDepSim::VolumeId&);
71 
72  class Volume {
73  public:
74  G4VPhysicalVolume* fHandle;
75  int fReplica;
76  };
77  typedef std::vector<Volume> Volumes;
78 
79  /// This is a vector of information required to uniquely identify the
80  /// volume. It is arranged so that the most local information is at the
81  /// front of the vector and the world volume will be the last element in
82  /// the vector.
83  Volumes fVolumes;
84 };
85 #endif
EDepSim::VolumeId & operator=(const G4TouchableHandle &handle)
std::ostream & operator<<(std::ostream &stream, const EDepSim::VolumeId &v)
bool operator<(const EDepSim::VolumeId &x, const EDepSim::VolumeId &y)
Construct a module from components.
Definition: TG4HitSegment.h:10
G4VPhysicalVolume * fHandle
bool operator==(const EDepSim::VolumeId &x, const EDepSim::VolumeId &y)
VolumeId()
Construct an empty volume Id.
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.
static QCString * s
Definition: config.cpp:1042
std::vector< Volume > Volumes