ATLAS Offline Software
Loading...
Searching...
No Matches
Geo2G4AssemblyVolume.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef GEO2G4_ASSEMBLYVOLUME_H
6#define GEO2G4_ASSEMBLYVOLUME_H
7
9#include "G4Transform3D.hh"
10#include <atomic>
11#include <vector>
12
13class G4VPhysicalVolume;
14
16{
17public: // with description
18
20 Geo2G4AssemblyVolume( G4LogicalVolume* volume,
21 G4ThreeVector& translation,
22 G4RotationMatrix* rotation);
24 //
25 // Constructors & destructor.
26 // At destruction all the generated physical volumes and associated
27 // rotation matrices of the imprints will be destroyed.
28 //
29 // The rotation matrix passed as argument can be 0 (identity) or an address
30 // even of an object on the upper stack frame. During assembly imprint, a
31 // new matrix is created anyway and it is kept track of it so it can be
32 // automatically deleted later at the end of the application.
33 // This policy is adopted since user has no control on the way the
34 // rotations are combined.
35
36 void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
37 G4ThreeVector& translation,
38 G4RotationMatrix* rotation,
39 int copyNo=0,const G4String& userComment="");
40 //
41 // Place the given volume 'pPlacedVolume' inside the assembly.
42 //
43 // The adopted approach:
44 //
45 // - Place it w.r.t. the assembly coordinate system.
46 // This step is applied to each of the participating volumes.
47 //
48 // The other possible approaches:
49 //
50 // - Place w.r.t. the firstly added volume.
51 // When placed the first, the virtual coordinate system becomes
52 // the coordinate system of the first one.
53 // Every next volume being added into the assembly will be placed
54 // w.r.t to the first one.
55 //
56 // - Place w.r.t the last placed volume.
57 // When placed the first, the virtual coordinate system becomes
58 // the coordinate system of the first one.
59 // Every next volume being added into the assembly will be placed
60 // w.r.t to the previous one.
61 //
62 // The rotation matrix passed as argument can be 0 (identity) or an address
63 // even of an object on the upper stack frame. During assembly imprint, a
64 // new matrix is created anyway and it is kept track of it so it can be
65 // automatically deleted later at the end of the application.
66 // This policy is adopted since user has no control on the way the
67 // rotations are combined.
68
69 void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
70 G4Transform3D& transformation,
71 int copyNo=0,const G4String& userComment="");
72 //
73 // The same as previous, but takes complete 3D transformation in space
74 // as its argument.
75
77 G4Transform3D& transformation);
78 //
79 // The same as previous AddPlacedVolume(), but takes an assembly volume
80 // as its argument.
81
83 G4ThreeVector& translation,
84 G4RotationMatrix* rotation);
85 //
86 // The same as above AddPlacedVolume(), but takes an assembly volume
87 // as its argument with translation and rotation.
88
89 void MakeImprint( G4LogicalVolume* pMotherLV,
90 G4ThreeVector& translationInMother,
91 const G4RotationMatrix* pRotationInMother,
92 G4int copyNumBase = 0,
93 G4bool ITkScheme = false,
94 G4bool surfCheck = false );
95 //
96 // Creates instance of an assembly volume inside the given mother volume.
97
98 void MakeImprint( G4LogicalVolume* pMotherLV,
99 G4Transform3D& transformation,
100 G4int copyNumBase = 0,
101 G4bool ITkScheme = false,
102 G4bool surfCheck = false );
103 //
104 // The same as previous Imprint() method, but takes complete 3D
105 // transformation in space as its argument.
106
107 inline std::vector<G4VPhysicalVolume*>::iterator GetVolumesIterator();
108 inline unsigned int TotalImprintedVolumes() const;
109 //
110 // Methods to access the physical volumes imprinted with the assembly.
111
112 unsigned int GetImprintsCount() const;
113 //
114 // Return the number of made imprints.
115
116 unsigned int GetInstanceCount() const;
117 //
118 // Return the number of existing instance of Geo2G4AssemblyVolume class.
119
120 unsigned int GetAssemblyID() const;
121 //
122 // Return instance number of this concrete object.
123
124protected:
125
126 void SetAssemblyID( unsigned int value );
127
128 void InstanceCountPlus();
129 void InstanceCountMinus();
130
131 void SetImprintsCount( unsigned int value );
132 void ImprintsCountPlus();
133 void ImprintsCountMinus();
134 //
135 // Internal counting mechanism, used to compute unique the names of
136 // physical volumes created by MakeImprint() methods.
137
138private:
139
140 void MakeImprint( Geo2G4AssemblyVolume* pAssembly,
141 G4LogicalVolume* pMotherLV,
142 G4Transform3D& transformation,
143 G4int copyNumBase = 0,
144 G4bool ITkScheme = false,
145 G4bool surfCheck = false );
146 //
147 // Function for placement of the given assembly in the given mother
148 // (called recursively if the assembly contains an assembly).
149
150private:
151
152 std::vector<Geo2G4AssemblyTriplet> m_triplets;
153 std::vector<int> m_copyNumbers;
154 std::vector<G4String> m_userComments;
155 //
156 // Participating volumes represented as a vector of
157 // <logical volume, translation, rotation>.
158
159 std::vector<G4VPhysicalVolume*> m_PVStore;
160 //
161 // We need to keep list of physical volumes created by MakeImprint() method
162 // in order to be able to cleanup the objects when not needed anymore.
163 // This requires the user to keep assembly objects in memory during the
164 // whole job or during the life-time of G4Navigator, logical volume store
165 // and physical volume store keep pointers to physical volumes generated by
166 // the assembly volume.
167 // When an assembly object is about to die it will destroy all its
168 // generated physical volumes and rotation matrices as well !
169
170 unsigned int m_imprintsCounter;
171 //
172 // Number of imprints of the given assembly volume.
173
174 static std::atomic<unsigned int> s_instanceCounter;
175 //
176 // Class instance counter.
177
178 unsigned int m_assemblyID;
179 //
180 // Assembly object ID derived from instance counter at construction time.
181
182};
183
184inline
186{
187 return m_imprintsCounter;
188}
189
190inline
192{
193 m_imprintsCounter = value;
194}
195
196
197inline
202
203inline
208
209inline
211{
212 return m_assemblyID;
213}
214
215inline
216void Geo2G4AssemblyVolume::SetAssemblyID( unsigned int value )
217{
218 m_assemblyID = value;
219}
220
221inline
222std::vector<G4VPhysicalVolume*>::iterator
224{
225 std::vector<G4VPhysicalVolume*>::iterator iterator = m_PVStore.begin();
226 return iterator;
227}
228
229inline
231{
232 return m_PVStore.size();
233}
234
235#endif
unsigned int GetInstanceCount() const
std::vector< int > m_copyNumbers
std::vector< G4String > m_userComments
unsigned int GetAssemblyID() const
std::vector< G4VPhysicalVolume * >::iterator GetVolumesIterator()
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, const G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool ITkScheme=false, G4bool surfCheck=false)
void SetAssemblyID(unsigned int value)
std::vector< G4VPhysicalVolume * > m_PVStore
void AddPlacedAssembly(Geo2G4AssemblyVolume *pAssembly, G4Transform3D &transformation)
void AddPlacedVolume(G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation, int copyNo=0, const G4String &userComment="")
static std::atomic< unsigned int > s_instanceCounter
unsigned int GetImprintsCount() const
std::vector< Geo2G4AssemblyTriplet > m_triplets
void SetImprintsCount(unsigned int value)
unsigned int TotalImprintedVolumes() const
Geo2G4AssemblyVolume(G4LogicalVolume *volume, G4ThreeVector &translation, G4RotationMatrix *rotation)