Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/volumes/src/G4AssemblyVolume.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/volumes/src/G4AssemblyVolume.cc (Version 11.3.0) and /geometry/volumes/src/G4AssemblyVolume.cc (Version 10.7.p4)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 // 
 26 // Class G4AssemblyVolume - implementation         26 // Class G4AssemblyVolume - implementation
 27 //                                                 27 //
 28 // Author: Radovan Chytracek, CERN - November  <<  28 // ----------------------------------------------------------------------
 29 // ------------------------------------------- << 
 30                                                    29 
 31 #include "G4AssemblyVolume.hh"                     30 #include "G4AssemblyVolume.hh"
 32 #include "G4AssemblyStore.hh"                      31 #include "G4AssemblyStore.hh"
 33 #include "G4PVPlacement.hh"                        32 #include "G4PVPlacement.hh"
 34 #include "G4RotationMatrix.hh"                     33 #include "G4RotationMatrix.hh"
 35 #include "G4AffineTransform.hh"                    34 #include "G4AffineTransform.hh"
 36 #include "G4LogicalVolume.hh"                      35 #include "G4LogicalVolume.hh"
 37 #include "G4VPhysicalVolume.hh"                    36 #include "G4VPhysicalVolume.hh"
 38 #include "G4ReflectionFactory.hh"                  37 #include "G4ReflectionFactory.hh"
 39                                                    38 
 40 #include <sstream>                                 39 #include <sstream>
 41                                                    40 
 42 G4ThreadLocal unsigned int G4AssemblyVolume::f     41 G4ThreadLocal unsigned int G4AssemblyVolume::fsInstanceCounter = 0;
 43                                                    42 
 44 // ------------------------------------------- << 
 45 // Default constructor                             43 // Default constructor
 46 //                                                 44 //
 47 G4AssemblyVolume::G4AssemblyVolume()               45 G4AssemblyVolume::G4AssemblyVolume()
 48 {                                                  46 {
 49   InstanceCountPlus();                             47   InstanceCountPlus();
 50   SetAssemblyID( GetInstanceCount() );             48   SetAssemblyID( GetInstanceCount() );
 51   SetImprintsCount( 0 );                           49   SetImprintsCount( 0 );
 52   G4AssemblyStore* aStore = G4AssemblyStore::G     50   G4AssemblyStore* aStore = G4AssemblyStore::GetInstance();
 53   if (aStore->GetAssembly(fAssemblyID,false) ! <<  51   if (aStore->GetAssembly(fAssemblyID,false))
 54   {                                                52   {
 55     std::ostringstream message;                    53     std::ostringstream message;
 56     message << "The assembly has NOT been regi     54     message << "The assembly has NOT been registered !" << G4endl
 57             << "          Assembly " << fAssem     55             << "          Assembly " << fAssemblyID
 58             << " already existing in store !"      56             << " already existing in store !" << G4endl;
 59     G4Exception("G4AssemblyVolume::G4AssemblyV     57     G4Exception("G4AssemblyVolume::G4AssemblyVolume()", "GeomVol1001",
 60                 JustWarning, message);             58                 JustWarning, message);
 61   }                                                59   }
 62   else                                             60   else
 63   {                                                61   {
 64     aStore->Register(this);                        62     aStore->Register(this);
 65   }                                                63   }
 66 }                                                  64 }
 67                                                    65 
 68 // ------------------------------------------- << 
 69 // Composing constructor                           66 // Composing constructor
 70 //                                                 67 //
 71 G4AssemblyVolume::G4AssemblyVolume( G4LogicalV     68 G4AssemblyVolume::G4AssemblyVolume( G4LogicalVolume* volume,
 72                                     G4ThreeVec     69                                     G4ThreeVector& translation,
 73                                     G4Rotation     70                                     G4RotationMatrix* rotation )
 74 {                                                  71 {
 75   InstanceCountPlus();                             72   InstanceCountPlus();
 76   SetAssemblyID( GetInstanceCount() );             73   SetAssemblyID( GetInstanceCount() );
 77   SetImprintsCount( 0 );                           74   SetImprintsCount( 0 );
 78   AddPlacedVolume(volume, translation, rotatio     75   AddPlacedVolume(volume, translation, rotation);
 79   G4AssemblyStore* aStore = G4AssemblyStore::G     76   G4AssemblyStore* aStore = G4AssemblyStore::GetInstance();
 80   if (aStore->GetAssembly(fAssemblyID,false) ! <<  77   if (aStore->GetAssembly(fAssemblyID,false))
 81   {                                                78   {
 82     std::ostringstream message;                    79     std::ostringstream message;
 83     message << "The assembly has NOT been regi     80     message << "The assembly has NOT been registered !" << G4endl
 84             << "          Assembly " << fAssem     81             << "          Assembly " << fAssemblyID
 85             << " already existing in store !"      82             << " already existing in store !" << G4endl;
 86     G4Exception("G4Assembly::G4Assembly()", "G     83     G4Exception("G4Assembly::G4Assembly()", "GeomVol1001",
 87                 JustWarning, message);             84                 JustWarning, message);
 88   }                                                85   }
 89   else                                             86   else
 90   {                                                87   {
 91     aStore->Register(this);                        88     aStore->Register(this);
 92   }                                                89   }
 93 }                                                  90 }
 94                                                    91 
 95 // ------------------------------------------- << 
 96 // Destructor                                      92 // Destructor
 97 //                                                 93 //
 98 G4AssemblyVolume::~G4AssemblyVolume()              94 G4AssemblyVolume::~G4AssemblyVolume()
 99 {                                                  95 {
100   std::size_t howmany = fTriplets.size();      <<  96   unsigned int howmany = fTriplets.size();
101   if( howmany != 0 )                               97   if( howmany != 0 )
102   {                                                98   {
103     for( std::size_t i = 0; i < howmany; ++i ) <<  99     for( unsigned int i = 0; i < howmany; ++i )
104     {                                             100     {
105       G4RotationMatrix* pRotToClean = fTriplet    101       G4RotationMatrix* pRotToClean = fTriplets[i].GetRotation();
106       delete pRotToClean;                      << 102       if( pRotToClean != 0 )
                                                   >> 103       {
                                                   >> 104         delete pRotToClean;
                                                   >> 105       }
107     }                                             106     }
108   }                                               107   }
109   fTriplets.clear();                              108   fTriplets.clear();
110                                                   109   
111   // No need to delete physical volumes, as th    110   // No need to delete physical volumes, as these are deleted
112   // by physical-volumes store.                   111   // by physical-volumes store.
113   //                                              112   //
114   fPVStore.clear();                               113   fPVStore.clear();
115   InstanceCountMinus();                           114   InstanceCountMinus();
116   G4AssemblyStore::GetInstance()->DeRegister(t    115   G4AssemblyStore::GetInstance()->DeRegister(this);
117 }                                                 116 }
118                                                   117 
119 // ------------------------------------------- << 
120 // Add and place the given volume according to    118 // Add and place the given volume according to the specified
121 // translation and rotation.                      119 // translation and rotation.
122 //                                                120 //
123 // The rotation matrix passed in can be 0 = id    121 // The rotation matrix passed in can be 0 = identity or an address even of an
124 // object on the upper stack frame. During ass    122 // object on the upper stack frame. During assembly imprint, it creates anyway
125 // a new matrix and keeps track of it so it ca    123 // a new matrix and keeps track of it so it can delete it later at destruction
126 // time.                                          124 // time.
127 // This policy has been adopted since user has    125 // This policy has been adopted since user has no control on the way the
128 // rotations are combined.                        126 // rotations are combined.
129 //                                                127 //
130 void G4AssemblyVolume::AddPlacedVolume( G4Logi    128 void G4AssemblyVolume::AddPlacedVolume( G4LogicalVolume*  pVolume,
131                                         G4Thre    129                                         G4ThreeVector&    translation,
132                                         G4Rota    130                                         G4RotationMatrix* pRotation )
133 {                                                 131 {
134   auto toStore = new G4RotationMatrix;         << 132   G4RotationMatrix*  toStore  = new G4RotationMatrix;
135                                                   133   
136   if( pRotation != nullptr )  { *toStore = *pR    134   if( pRotation != nullptr )  { *toStore = *pRotation; }
137                                                   135   
138   G4AssemblyTriplet toAdd( pVolume, translatio    136   G4AssemblyTriplet toAdd( pVolume, translation, toStore );
139   fTriplets.push_back( toAdd );                   137   fTriplets.push_back( toAdd );
140 }                                                 138 }
141                                                   139 
142 // ------------------------------------------- << 
143 // Add and place the given volume according to    140 // Add and place the given volume according to the specified transformation
144 //                                                141 //
145 void G4AssemblyVolume::AddPlacedVolume( G4Logi    142 void G4AssemblyVolume::AddPlacedVolume( G4LogicalVolume*  pVolume,
146                                         G4Tran    143                                         G4Transform3D&    transformation )
147 {                                                 144 {
148   // Decompose transformation                     145   // Decompose transformation
149   G4Scale3D     scale;                            146   G4Scale3D     scale;
150   G4Rotate3D    rotation;                         147   G4Rotate3D    rotation;
151   G4Translate3D translation;                      148   G4Translate3D translation;
152   transformation.getDecomposition(scale, rotat    149   transformation.getDecomposition(scale, rotation, translation);
153                                                   150 
154   G4ThreeVector v = translation.getTranslation << 151   G4ThreeVector      v = translation.getTranslation();
155   auto r = new G4RotationMatrix;               << 152   G4RotationMatrix*  r = new G4RotationMatrix;
156       *r = rotation.getRotation();             << 153                     *r = rotation.getRotation();
157                                                   154   
158   G4bool isReflection = false;                    155   G4bool isReflection = false;
159   if (scale(0,0)*scale(1,1)*scale(2,2) < 0.)      156   if (scale(0,0)*scale(1,1)*scale(2,2) < 0.)  { isReflection = true; }
160                                                   157 
161   G4AssemblyTriplet toAdd( pVolume, v, r, isRe    158   G4AssemblyTriplet toAdd( pVolume, v, r, isReflection );
162   fTriplets.push_back( toAdd );                   159   fTriplets.push_back( toAdd );
163 }                                                 160 }
164                                                   161 
165 // ------------------------------------------- << 
166 // Add and place the given assembly volume acc    162 // Add and place the given assembly volume according to the specified
167 // translation and rotation.                      163 // translation and rotation.
168 //                                                164 //
169 void G4AssemblyVolume::AddPlacedAssembly( G4As    165 void G4AssemblyVolume::AddPlacedAssembly( G4AssemblyVolume* pAssembly,
170                                           G4Th    166                                           G4ThreeVector&    translation,
171                                           G4Ro    167                                           G4RotationMatrix* pRotation )
172 {                                                 168 {
173   auto toStore = new G4RotationMatrix;         << 169   G4RotationMatrix*  toStore  = new G4RotationMatrix;
174                                                   170   
175   if( pRotation != nullptr )  { *toStore = *pR    171   if( pRotation != nullptr )  { *toStore = *pRotation; }
176                                                   172   
177   G4AssemblyTriplet toAdd( pAssembly, translat    173   G4AssemblyTriplet toAdd( pAssembly, translation, toStore );
178   fTriplets.push_back( toAdd );                   174   fTriplets.push_back( toAdd );
179 }                                                 175 }
180                                                   176 
181 // ------------------------------------------- << 
182 // Add and place the given assembly volume acc    177 // Add and place the given assembly volume according to the specified 
183 // transformation                                 178 // transformation
184 //                                                179 //
185 void G4AssemblyVolume::AddPlacedAssembly( G4As    180 void G4AssemblyVolume::AddPlacedAssembly( G4AssemblyVolume* pAssembly,
186                                           G4Tr    181                                           G4Transform3D&    transformation )
187 {                                                 182 {
188   // Decompose transformation                     183   // Decompose transformation
189   //                                              184   //
190   G4Scale3D     scale;                            185   G4Scale3D     scale;
191   G4Rotate3D    rotation;                         186   G4Rotate3D    rotation;
192   G4Translate3D translation;                      187   G4Translate3D translation;
193   transformation.getDecomposition(scale, rotat    188   transformation.getDecomposition(scale, rotation, translation);
194                                                   189 
195   G4ThreeVector      v = translation.getTransl    190   G4ThreeVector      v = translation.getTranslation();
196   auto r = new G4RotationMatrix;               << 191   G4RotationMatrix*  r = new G4RotationMatrix;
197       *r = rotation.getRotation();             << 192                     *r = rotation.getRotation();
198                                                   193   
199   G4bool isReflection = false;                    194   G4bool isReflection = false;
200   if (scale(0,0)*scale(1,1)*scale(2,2) < 0.)      195   if (scale(0,0)*scale(1,1)*scale(2,2) < 0.)  { isReflection = true; }
201                                                   196   
202   G4AssemblyTriplet toAdd( pAssembly, v, r, is    197   G4AssemblyTriplet toAdd( pAssembly, v, r, isReflection );
203   fTriplets.push_back( toAdd );                   198   fTriplets.push_back( toAdd );
204 }                                                 199 }
205                                                   200 
206 // ------------------------------------------- << 
207 // Create an instance of an assembly volume in    201 // Create an instance of an assembly volume inside of the specified
208 // mother volume. This works analogically to m    202 // mother volume. This works analogically to making stamp imprints.
209 // This method makes use of the Geant4 affine     203 // This method makes use of the Geant4 affine transformation class.
210 // The algorithm is defined as follows:           204 // The algorithm is defined as follows:
211 //                                                205 //  
212 // Having rotation matrix Rm and translation v    206 // Having rotation matrix Rm and translation vector Tm to be applied
213 // inside the mother and rotation matrix Ra an    207 // inside the mother and rotation matrix Ra and translation vector Ta
214 // to be applied inside the assembly itself fo    208 // to be applied inside the assembly itself for each of the participating
215 // volumes the resulting transformation is        209 // volumes the resulting transformation is
216 //                                                210 //  
217 // Tfinal = Ta * Tm                               211 // Tfinal = Ta * Tm
218 //                                                212 //  
219 // where Ta and Tm are constructed as             213 // where Ta and Tm are constructed as
220 //                                                214 //  
221 //        -1                                      215 //        -1                                     -1
222 // Ta = Ra  * Ta           and            Tm =    216 // Ta = Ra  * Ta           and            Tm = Rm  * Tm
223 //                                                217 //  
224 // which in words means that we create first t    218 // which in words means that we create first the affine transformations
225 // by inverse rotation matrices and translatio    219 // by inverse rotation matrices and translations for mother and assembly.
226 // The resulting final transformation to be ap    220 // The resulting final transformation to be applied to each of the
227 // participating volumes is their product.        221 // participating volumes is their product.
228 //                                                222 //
229 // IMPORTANT NOTE!                                223 // IMPORTANT NOTE!
230 // The order of multiplication is reversed whe    224 // The order of multiplication is reversed when comparing to CLHEP 3D
231 // transformation matrix(G4Transform3D class).    225 // transformation matrix(G4Transform3D class).
232 //                                                226 //  
233 // The rotation matrix passed in can be 0 = id    227 // The rotation matrix passed in can be 0 = identity or an address even of an
234 // object on the upper stack frame. During ass    228 // object on the upper stack frame. During assembly imprint, it creates anyway
235 // a new matrix and keeps track of it so it ca    229 // a new matrix and keeps track of it so it can delete it later at destruction
236 // time.                                          230 // time.
237 // This policy has been adopted since user has    231 // This policy has been adopted since user has no control on the way the
238 // rotations are combined.                        232 // rotations are combined.
239 //                                                233 // 
240 // If the assembly volume contains assembly (a    234 // If the assembly volume contains assembly (a'), the function is called
241 // recursively with composed transformation:      235 // recursively with composed transformation:
242 //                                                236 //
243 // Tanew =  Ta * Ta'                              237 // Tanew =  Ta * Ta'
244 //                                                238 //
245 void G4AssemblyVolume::MakeImprint( G4Assembly    239 void G4AssemblyVolume::MakeImprint( G4AssemblyVolume* pAssembly,
246                                     G4LogicalV    240                                     G4LogicalVolume*  pMotherLV,
247                                     G4Transfor    241                                     G4Transform3D&    transformation,
248                                     G4int copy    242                                     G4int copyNumBase,
249                                     G4bool sur    243                                     G4bool surfCheck )
250 {                                                 244 {
251   std::size_t numberOfDaughters;               << 245   unsigned int  numberOfDaughters;
252                                                   246     
253   if( copyNumBase == 0 )                          247   if( copyNumBase == 0 )
254   {                                               248   {
255     numberOfDaughters = pMotherLV->GetNoDaught    249     numberOfDaughters = pMotherLV->GetNoDaughters();
256   }                                               250   }
257   else                                            251   else
258   {                                               252   {
259     numberOfDaughters = copyNumBase;              253     numberOfDaughters = copyNumBase;
260   }                                               254   }
261                                                   255 
262   // We start from the first available index      256   // We start from the first available index
263   //                                              257   //
264   ++numberOfDaughters;                         << 258   numberOfDaughters++;
265                                                   259 
266   ImprintsCountPlus();                            260   ImprintsCountPlus();
267                                                   261   
268   auto triplets = pAssembly->fTriplets;           262   auto triplets = pAssembly->fTriplets;
269                                                   263 
270   // store the transformation in a container (    264   // store the transformation in a container (for GDML persistency)
271   fImprintsTransf[GetImprintsCount()] = transf    265   fImprintsTransf[GetImprintsCount()] = transformation;
272                                                   266 
273   for( std::size_t i = 0; i < triplets.size(); << 267   for( unsigned int i = 0; i < triplets.size(); ++i )
274   {                                               268   {
275     G4Transform3D Ta( *(triplets[i].GetRotatio    269     G4Transform3D Ta( *(triplets[i].GetRotation()),
276                       triplets[i].GetTranslati    270                       triplets[i].GetTranslation() );
277     if ( triplets[i].IsReflection() )  { Ta =     271     if ( triplets[i].IsReflection() )  { Ta = Ta * G4ReflectZ3D(); }
278                                                   272 
279     G4Transform3D Tfinal = transformation * Ta    273     G4Transform3D Tfinal = transformation * Ta;
280                                                   274     
281     if ( triplets[i].GetVolume() != nullptr )  << 275     if ( triplets[i].GetVolume() )
282     {                                             276     {
283       // Generate the unique name for the next    277       // Generate the unique name for the next PV instance
284       // The name has format:                     278       // The name has format:
285       //                                          279       //
286       // av_WWW_impr_XXX_YYY_ZZZ                  280       // av_WWW_impr_XXX_YYY_ZZZ
287       // where the fields mean:                   281       // where the fields mean:
288       // WWW - assembly volume instance number    282       // WWW - assembly volume instance number
289       // XXX - assembly volume imprint number     283       // XXX - assembly volume imprint number
290       // YYY - the name of a log. volume we wa    284       // YYY - the name of a log. volume we want to make a placement of
291       // ZZZ - the log. volume index inside th    285       // ZZZ - the log. volume index inside the assembly volume
292       //                                          286       //
293       std::stringstream pvName;                   287       std::stringstream pvName;
294       pvName << "av_"                             288       pvName << "av_"
295              << GetAssemblyID()                   289              << GetAssemblyID()
296              << "_impr_"                          290              << "_impr_"
297              << GetImprintsCount()                291              << GetImprintsCount()
298              << "_"                               292              << "_"
299              << triplets[i].GetVolume()->GetNa    293              << triplets[i].GetVolume()->GetName().c_str()
300              << "_pv_"                            294              << "_pv_"
301              << i                                 295              << i
302              << std::ends;                        296              << std::ends;
303                                                   297 
304       // Generate a new physical volume instan    298       // Generate a new physical volume instance inside a mother
305       // (as we allow 3D transformation use G4    299       // (as we allow 3D transformation use G4ReflectionFactory to 
306       //  take into account eventual reflectio    300       //  take into account eventual reflection)
307       //                                          301       //
308       G4PhysicalVolumesPair pvPlaced              302       G4PhysicalVolumesPair pvPlaced
309         = G4ReflectionFactory::Instance()->Pla    303         = G4ReflectionFactory::Instance()->Place( Tfinal,
310                                                   304                                                   pvName.str().c_str(),
311                                                   305                                                   triplets[i].GetVolume(),
312                                                   306                                                   pMotherLV,
313                                                   307                                                   false,
314                                                << 308                                                   numberOfDaughters + i,
315                                                   309                                                   surfCheck );
316                                                   310 
317       // Register the physical volume created     311       // Register the physical volume created by us so we can delete it later
318       //                                          312       //
319       fPVStore.push_back( pvPlaced.first );       313       fPVStore.push_back( pvPlaced.first );
320       if ( pvPlaced.second != nullptr )  { fPV << 314       if ( pvPlaced.second )  { fPVStore.push_back( pvPlaced.second ); }
321                                                   315 
322       // Here I want to save the imprint trans    316       // Here I want to save the imprint transformation to some container, so I can retrieve the original values later
323       // imprintTrans[GetImprintsCount()] = tr    317       // imprintTrans[GetImprintsCount()] = transformation;
324                                                   318       
325     }                                             319     }
326     else if ( triplets[i].GetAssembly() != nul << 320     else if ( triplets[i].GetAssembly() )
327     {                                             321     {
328       // Place volumes in this assembly with c    322       // Place volumes in this assembly with composed transformation
329       //                                          323       //
330       MakeImprint( triplets[i].GetAssembly(),     324       MakeImprint( triplets[i].GetAssembly(), pMotherLV,
331                    Tfinal, (G4int)i*100+copyNu << 325                    Tfinal, i*100+copyNumBase, surfCheck ); 
332     }                                             326     }
333     else                                          327     else
334     {                                             328     {
335       G4Exception("G4AssemblyVolume::MakeImpri    329       G4Exception("G4AssemblyVolume::MakeImprint(..)",
336                   "GeomVol0003", FatalExceptio    330                   "GeomVol0003", FatalException,
337                   "Triplet has no volume and n    331                   "Triplet has no volume and no assembly");
338     }                                             332     }  
339   }                                               333   }  
340 }                                                 334 }    
341                                                   335 
342 // ------------------------------------------- << 
343 void G4AssemblyVolume::MakeImprint( G4LogicalV    336 void G4AssemblyVolume::MakeImprint( G4LogicalVolume*  pMotherLV,
344                                     G4ThreeVec    337                                     G4ThreeVector&    translationInMother,
345                                     G4Rotation    338                                     G4RotationMatrix* pRotationInMother,
346                                     G4int copy    339                                     G4int copyNumBase,
347                                     G4bool sur    340                                     G4bool surfCheck )
348 {                                                 341 {
349   // If needed user can specify explicitely th    342   // If needed user can specify explicitely the base count from which to start
350   // off for the generation of phys. vol. copy    343   // off for the generation of phys. vol. copy numbers.
351   // The old behaviour is preserved when copyN    344   // The old behaviour is preserved when copyNumBase == 0, e.g. the generated
352   // copy numbers start from the count equal t    345   // copy numbers start from the count equal to current number of daughter
353   // volumes before an imprint is made            346   // volumes before an imprint is made
354                                                   347 
355   // Compose transformation                       348   // Compose transformation
356   //                                              349   //
357   if( pRotationInMother == nullptr )              350   if( pRotationInMother == nullptr )
358   {                                               351   {
359     // Make it by default an indentity matrix     352     // Make it by default an indentity matrix
360     //                                            353     //
361     pRotationInMother =                           354     pRotationInMother =
362       const_cast<G4RotationMatrix*>( &G4Rotati    355       const_cast<G4RotationMatrix*>( &G4RotationMatrix::IDENTITY );
363   }                                               356   }
364                                                   357 
365   G4Transform3D transform( *pRotationInMother,    358   G4Transform3D transform( *pRotationInMother,
366                             translationInMothe    359                             translationInMother );
367   MakeImprint(this, pMotherLV, transform, copy    360   MakeImprint(this, pMotherLV, transform, copyNumBase, surfCheck);
368 }                                                 361 }
369                                                   362 
370 // ------------------------------------------- << 
371 void G4AssemblyVolume::MakeImprint( G4LogicalV    363 void G4AssemblyVolume::MakeImprint( G4LogicalVolume*  pMotherLV,
372                                     G4Transfor    364                                     G4Transform3D&    transformation,
373                                     G4int copy    365                                     G4int copyNumBase,
374                                     G4bool sur    366                                     G4bool surfCheck )
375 {                                                 367 {
376   // If needed user can specify explicitely th    368   // If needed user can specify explicitely the base count from which to start
377   // off for the generation of phys. vol. copy    369   // off for the generation of phys. vol. copy numbers.
378   // The old behaviour is preserved when copyN    370   // The old behaviour is preserved when copyNumBase == 0, e.g. the generated
379   // copy numbers start from the count equal t    371   // copy numbers start from the count equal to current number of daughter
380   // volumes before a imprint is made             372   // volumes before a imprint is made
381                                                   373 
382   MakeImprint(this, pMotherLV, transformation,    374   MakeImprint(this, pMotherLV, transformation, copyNumBase, surfCheck);
383 }                                                 375 }
384                                                   376 
385 // ------------------------------------------- << 
386 unsigned int G4AssemblyVolume::GetInstanceCoun    377 unsigned int G4AssemblyVolume::GetInstanceCount() const
387 {                                                 378 {
388   return G4AssemblyVolume::fsInstanceCounter;     379   return G4AssemblyVolume::fsInstanceCounter;
389 }                                                 380 }
390                                                   381 
391 // ------------------------------------------- << 
392 void G4AssemblyVolume::SetInstanceCount( unsig    382 void G4AssemblyVolume::SetInstanceCount( unsigned int value )
393 {                                                 383 {
394   G4AssemblyVolume::fsInstanceCounter = value;    384   G4AssemblyVolume::fsInstanceCounter = value;
395 }                                                 385 }
396                                                   386 
397 // ------------------------------------------- << 
398 void G4AssemblyVolume::InstanceCountPlus()        387 void G4AssemblyVolume::InstanceCountPlus()
399 {                                                 388 {
400   G4AssemblyVolume::fsInstanceCounter++;          389   G4AssemblyVolume::fsInstanceCounter++;
401 }                                                 390 }
402                                                   391 
403 // ------------------------------------------- << 
404 void G4AssemblyVolume::InstanceCountMinus()       392 void G4AssemblyVolume::InstanceCountMinus()
405 {                                                 393 {
406   G4AssemblyVolume::fsInstanceCounter--;          394   G4AssemblyVolume::fsInstanceCounter--;
407 }                                                 395 }
408                                                   396