ATLAS Offline Software
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 
13 class G4VPhysicalVolume;
14 
16 {
17 public: // 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 
76  void AddPlacedAssembly( Geo2G4AssemblyVolume* pAssembly,
77  G4Transform3D& transformation);
78  //
79  // The same as previous AddPlacedVolume(), but takes an assembly volume
80  // as its argument.
81 
82  void AddPlacedAssembly( Geo2G4AssemblyVolume* pAssembly,
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 
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 
124 protected:
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 
138 private:
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 
150 private:
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 
184 inline
186 {
187  return m_imprintsCounter;
188 }
189 
190 inline
192 {
194 }
195 
196 
197 inline
199 {
201 }
202 
203 inline
205 {
207 }
208 
209 inline
211 {
212  return m_assemblyID;
213 }
214 
215 inline
217 {
219 }
220 
221 inline
224 {
226  return iterator;
227 }
228 
229 inline
231 {
232  return m_PVStore.size();
233 }
234 
235 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Geo2G4AssemblyVolume::m_userComments
std::vector< G4String > m_userComments
Definition: Geo2G4AssemblyVolume.h:154
Geo2G4AssemblyVolume::GetAssemblyID
unsigned int GetAssemblyID() const
Definition: Geo2G4AssemblyVolume.h:210
Geo2G4AssemblyVolume::GetImprintsCount
unsigned int GetImprintsCount() const
Definition: Geo2G4AssemblyVolume.h:185
Geo2G4AssemblyVolume::Geo2G4AssemblyVolume
Geo2G4AssemblyVolume()
Definition: Geo2G4AssemblyVolume.cxx:19
Geo2G4AssemblyVolume::SetAssemblyID
void SetAssemblyID(unsigned int value)
Definition: Geo2G4AssemblyVolume.h:216
Geo2G4AssemblyVolume::MakeImprint
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, const G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool ITkScheme=false, G4bool surfCheck=false)
Definition: Geo2G4AssemblyVolume.cxx:289
athena.value
value
Definition: athena.py:124
Geo2G4AssemblyVolume::m_copyNumbers
std::vector< int > m_copyNumbers
Definition: Geo2G4AssemblyVolume.h:153
Geo2G4AssemblyVolume::ImprintsCountPlus
void ImprintsCountPlus()
Definition: Geo2G4AssemblyVolume.h:198
Geo2G4AssemblyVolume::TotalImprintedVolumes
unsigned int TotalImprintedVolumes() const
Definition: Geo2G4AssemblyVolume.h:230
Geo2G4AssemblyVolume::s_instanceCounter
static std::atomic< unsigned int > s_instanceCounter
Definition: Geo2G4AssemblyVolume.h:174
Geo2G4AssemblyVolume::AddPlacedVolume
void AddPlacedVolume(G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation, int copyNo=0, const G4String &userComment="")
Definition: Geo2G4AssemblyVolume.cxx:72
Geo2G4AssemblyVolume::Geo2G4AssemblyVolume
Geo2G4AssemblyVolume(G4LogicalVolume *volume, G4ThreeVector &translation, G4RotationMatrix *rotation)
Geo2G4AssemblyVolume::~Geo2G4AssemblyVolume
~Geo2G4AssemblyVolume()
Definition: Geo2G4AssemblyVolume.cxx:29
xAOD::rotation
rotation
Definition: TrackSurface_v1.cxx:15
Geo2G4AssemblyVolume::InstanceCountPlus
void InstanceCountPlus()
Definition: Geo2G4AssemblyVolume.cxx:336
Geo2G4AssemblyVolume::m_assemblyID
unsigned int m_assemblyID
Definition: Geo2G4AssemblyVolume.h:178
Geo2G4AssemblyVolume
Definition: Geo2G4AssemblyVolume.h:16
Geo2G4AssemblyVolume::AddPlacedAssembly
void AddPlacedAssembly(Geo2G4AssemblyVolume *pAssembly, G4Transform3D &transformation)
Definition: Geo2G4AssemblyVolume.cxx:132
Geo2G4AssemblyVolume::ImprintsCountMinus
void ImprintsCountMinus()
Definition: Geo2G4AssemblyVolume.h:204
Geo2G4AssemblyVolume::SetImprintsCount
void SetImprintsCount(unsigned int value)
Definition: Geo2G4AssemblyVolume.h:191
Geo2G4AssemblyTriplet.h
Geo2G4AssemblyVolume::m_PVStore
std::vector< G4VPhysicalVolume * > m_PVStore
Definition: Geo2G4AssemblyVolume.h:159
Geo2G4AssemblyVolume::m_imprintsCounter
unsigned int m_imprintsCounter
Definition: Geo2G4AssemblyVolume.h:170
Geo2G4AssemblyVolume::m_triplets
std::vector< Geo2G4AssemblyTriplet > m_triplets
Definition: Geo2G4AssemblyVolume.h:152
Geo2G4AssemblyVolume::InstanceCountMinus
void InstanceCountMinus()
Definition: Geo2G4AssemblyVolume.cxx:341
Geo2G4AssemblyVolume::GetInstanceCount
unsigned int GetInstanceCount() const
Definition: Geo2G4AssemblyVolume.cxx:331
Geo2G4AssemblyVolume::GetVolumesIterator
std::vector< G4VPhysicalVolume * >::iterator GetVolumesIterator()
Definition: Geo2G4AssemblyVolume.h:223