Geant4-11
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
G4AssemblyVolume Class Reference

#include <G4AssemblyVolume.hh>

Public Member Functions

void AddPlacedAssembly (G4AssemblyVolume *pAssembly, G4ThreeVector &translation, G4RotationMatrix *rotation)
 
void AddPlacedAssembly (G4AssemblyVolume *pAssembly, G4Transform3D &transformation)
 
void AddPlacedVolume (G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation)
 
void AddPlacedVolume (G4LogicalVolume *pPlacedVolume, G4Transform3D &transformation)
 
 G4AssemblyVolume ()
 
 G4AssemblyVolume (G4LogicalVolume *volume, G4ThreeVector &translation, G4RotationMatrix *rotation)
 
unsigned int GetAssemblyID () const
 
unsigned int GetImprintsCount () const
 
G4Transform3DGetImprintTransformation (unsigned int imprintID)
 
unsigned int GetInstanceCount () const
 
std::vector< G4AssemblyTriplet >::iterator GetTripletsIterator ()
 
std::vector< G4VPhysicalVolume * >::iterator GetVolumesIterator ()
 
void MakeImprint (G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool surfCheck=false)
 
void MakeImprint (G4LogicalVolume *pMotherLV, G4Transform3D &transformation, G4int copyNumBase=0, G4bool surfCheck=false)
 
std::size_t TotalImprintedVolumes () const
 
std::size_t TotalTriplets () const
 
 ~G4AssemblyVolume ()
 

Protected Member Functions

void ImprintsCountMinus ()
 
void ImprintsCountPlus ()
 
void InstanceCountMinus ()
 
void InstanceCountPlus ()
 
void SetAssemblyID (unsigned int value)
 
void SetImprintsCount (unsigned int value)
 
void SetInstanceCount (unsigned int value)
 

Private Member Functions

void MakeImprint (G4AssemblyVolume *pAssembly, G4LogicalVolume *pMotherLV, G4Transform3D &transformation, G4int copyNumBase=0, G4bool surfCheck=false)
 

Private Attributes

unsigned int fAssemblyID = 0
 
unsigned int fImprintsCounter
 
std::map< unsigned int, G4Transform3DfImprintsTransf
 
std::vector< G4VPhysicalVolume * > fPVStore
 
std::vector< G4AssemblyTripletfTriplets
 

Static Private Attributes

static G4ThreadLocal unsigned int fsInstanceCounter = 0
 

Detailed Description

Definition at line 53 of file G4AssemblyVolume.hh.

Constructor & Destructor Documentation

◆ G4AssemblyVolume() [1/2]

G4AssemblyVolume::G4AssemblyVolume ( )

Definition at line 45 of file G4AssemblyVolume.cc.

46{
51 if (aStore->GetAssembly(fAssemblyID,false))
52 {
53 std::ostringstream message;
54 message << "The assembly has NOT been registered !" << G4endl
55 << " Assembly " << fAssemblyID
56 << " already existing in store !" << G4endl;
57 G4Exception("G4AssemblyVolume::G4AssemblyVolume()", "GeomVol1001",
58 JustWarning, message);
59 }
60 else
61 {
62 aStore->Register(this);
63 }
64}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
#define G4endl
Definition: G4ios.hh:57
static G4AssemblyStore * GetInstance()
G4AssemblyVolume * GetAssembly(unsigned int id, G4bool verbose=true) const
static void Register(G4AssemblyVolume *pAssembly)
void SetAssemblyID(unsigned int value)
void SetImprintsCount(unsigned int value)
unsigned int fAssemblyID
unsigned int GetInstanceCount() const

References fAssemblyID, G4endl, G4Exception(), G4AssemblyStore::GetAssembly(), G4AssemblyStore::GetInstance(), GetInstanceCount(), InstanceCountPlus(), JustWarning, G4AssemblyStore::Register(), SetAssemblyID(), and SetImprintsCount().

◆ G4AssemblyVolume() [2/2]

G4AssemblyVolume::G4AssemblyVolume ( G4LogicalVolume volume,
G4ThreeVector translation,
G4RotationMatrix rotation 
)

Definition at line 68 of file G4AssemblyVolume.cc.

71{
75 AddPlacedVolume(volume, translation, rotation);
77 if (aStore->GetAssembly(fAssemblyID,false))
78 {
79 std::ostringstream message;
80 message << "The assembly has NOT been registered !" << G4endl
81 << " Assembly " << fAssemblyID
82 << " already existing in store !" << G4endl;
83 G4Exception("G4Assembly::G4Assembly()", "GeomVol1001",
84 JustWarning, message);
85 }
86 else
87 {
88 aStore->Register(this);
89 }
90}
void AddPlacedVolume(G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation)

References AddPlacedVolume(), fAssemblyID, G4endl, G4Exception(), G4AssemblyStore::GetAssembly(), G4AssemblyStore::GetInstance(), GetInstanceCount(), InstanceCountPlus(), JustWarning, G4AssemblyStore::Register(), SetAssemblyID(), and SetImprintsCount().

◆ ~G4AssemblyVolume()

G4AssemblyVolume::~G4AssemblyVolume ( )

Definition at line 94 of file G4AssemblyVolume.cc.

95{
96 unsigned int howmany = fTriplets.size();
97 if( howmany != 0 )
98 {
99 for( unsigned int i = 0; i < howmany; ++i )
100 {
101 G4RotationMatrix* pRotToClean = fTriplets[i].GetRotation();
102 if( pRotToClean != 0 )
103 {
104 delete pRotToClean;
105 }
106 }
107 }
108 fTriplets.clear();
109
110 // No need to delete physical volumes, as these are deleted
111 // by physical-volumes store.
112 //
113 fPVStore.clear();
116}
static void DeRegister(G4AssemblyVolume *pAssembly)
std::vector< G4VPhysicalVolume * > fPVStore
std::vector< G4AssemblyTriplet > fTriplets

References G4AssemblyStore::DeRegister(), fPVStore, fTriplets, G4AssemblyStore::GetInstance(), and InstanceCountMinus().

Member Function Documentation

◆ AddPlacedAssembly() [1/2]

void G4AssemblyVolume::AddPlacedAssembly ( G4AssemblyVolume pAssembly,
G4ThreeVector translation,
G4RotationMatrix rotation 
)

Definition at line 165 of file G4AssemblyVolume.cc.

168{
169 G4RotationMatrix* toStore = new G4RotationMatrix;
170
171 if( pRotation != nullptr ) { *toStore = *pRotation; }
172
173 G4AssemblyTriplet toAdd( pAssembly, translation, toStore );
174 fTriplets.push_back( toAdd );
175}
CLHEP::HepRotation G4RotationMatrix

References fTriplets.

◆ AddPlacedAssembly() [2/2]

void G4AssemblyVolume::AddPlacedAssembly ( G4AssemblyVolume pAssembly,
G4Transform3D transformation 
)

Definition at line 180 of file G4AssemblyVolume.cc.

182{
183 // Decompose transformation
184 //
185 G4Scale3D scale;
186 G4Rotate3D rotation;
187 G4Translate3D translation;
188 transformation.getDecomposition(scale, rotation, translation);
189
190 G4ThreeVector v = translation.getTranslation();
192 *r = rotation.getRotation();
193
194 G4bool isReflection = false;
195 if (scale(0,0)*scale(1,1)*scale(2,2) < 0.) { isReflection = true; }
196
197 G4AssemblyTriplet toAdd( pAssembly, v, r, isReflection );
198 fTriplets.push_back( toAdd );
199}
bool G4bool
Definition: G4Types.hh:86
CLHEP::HepRotation getRotation() const
void getDecomposition(Scale3D &scale, Rotate3D &rotation, Translate3D &translation) const
Definition: Transform3D.cc:173
CLHEP::Hep3Vector getTranslation() const

References fTriplets, HepGeom::Transform3D::getDecomposition(), HepGeom::Transform3D::getRotation(), and HepGeom::Transform3D::getTranslation().

Referenced by G4GDMLReadStructure::PhysvolRead().

◆ AddPlacedVolume() [1/2]

void G4AssemblyVolume::AddPlacedVolume ( G4LogicalVolume pPlacedVolume,
G4ThreeVector translation,
G4RotationMatrix rotation 
)

Definition at line 128 of file G4AssemblyVolume.cc.

131{
132 G4RotationMatrix* toStore = new G4RotationMatrix;
133
134 if( pRotation != nullptr ) { *toStore = *pRotation; }
135
136 G4AssemblyTriplet toAdd( pVolume, translation, toStore );
137 fTriplets.push_back( toAdd );
138}

References fTriplets.

Referenced by G4tgbVolume::ConstructG4PhysVol(), G4AssemblyVolume(), and G4GDMLReadStructure::PhysvolRead().

◆ AddPlacedVolume() [2/2]

void G4AssemblyVolume::AddPlacedVolume ( G4LogicalVolume pPlacedVolume,
G4Transform3D transformation 
)

Definition at line 142 of file G4AssemblyVolume.cc.

144{
145 // Decompose transformation
146 G4Scale3D scale;
147 G4Rotate3D rotation;
148 G4Translate3D translation;
149 transformation.getDecomposition(scale, rotation, translation);
150
151 G4ThreeVector v = translation.getTranslation();
153 *r = rotation.getRotation();
154
155 G4bool isReflection = false;
156 if (scale(0,0)*scale(1,1)*scale(2,2) < 0.) { isReflection = true; }
157
158 G4AssemblyTriplet toAdd( pVolume, v, r, isReflection );
159 fTriplets.push_back( toAdd );
160}

References fTriplets, HepGeom::Transform3D::getDecomposition(), HepGeom::Transform3D::getRotation(), and HepGeom::Transform3D::getTranslation().

◆ GetAssemblyID()

unsigned int G4AssemblyVolume::GetAssemblyID ( ) const
inline

Referenced by MakeImprint().

◆ GetImprintsCount()

unsigned int G4AssemblyVolume::GetImprintsCount ( ) const
inline

Referenced by MakeImprint().

◆ GetImprintTransformation()

G4Transform3D & G4AssemblyVolume::GetImprintTransformation ( unsigned int  imprintID)
inline

◆ GetInstanceCount()

unsigned int G4AssemblyVolume::GetInstanceCount ( ) const

Definition at line 377 of file G4AssemblyVolume.cc.

378{
380}
static G4ThreadLocal unsigned int fsInstanceCounter

References fsInstanceCounter.

Referenced by G4AssemblyVolume().

◆ GetTripletsIterator()

std::vector< G4AssemblyTriplet >::iterator G4AssemblyVolume::GetTripletsIterator ( )
inline

◆ GetVolumesIterator()

std::vector< G4VPhysicalVolume * >::iterator G4AssemblyVolume::GetVolumesIterator ( )
inline

◆ ImprintsCountMinus()

void G4AssemblyVolume::ImprintsCountMinus ( )
inlineprotected

◆ ImprintsCountPlus()

void G4AssemblyVolume::ImprintsCountPlus ( )
inlineprotected

Referenced by MakeImprint().

◆ InstanceCountMinus()

void G4AssemblyVolume::InstanceCountMinus ( )
protected

Definition at line 392 of file G4AssemblyVolume.cc.

References fsInstanceCounter.

Referenced by ~G4AssemblyVolume().

◆ InstanceCountPlus()

void G4AssemblyVolume::InstanceCountPlus ( )
protected

Definition at line 387 of file G4AssemblyVolume.cc.

References fsInstanceCounter.

Referenced by G4AssemblyVolume().

◆ MakeImprint() [1/3]

void G4AssemblyVolume::MakeImprint ( G4AssemblyVolume pAssembly,
G4LogicalVolume pMotherLV,
G4Transform3D transformation,
G4int  copyNumBase = 0,
G4bool  surfCheck = false 
)
private

Definition at line 239 of file G4AssemblyVolume.cc.

244{
245 unsigned int numberOfDaughters;
246
247 if( copyNumBase == 0 )
248 {
249 numberOfDaughters = pMotherLV->GetNoDaughters();
250 }
251 else
252 {
253 numberOfDaughters = copyNumBase;
254 }
255
256 // We start from the first available index
257 //
258 numberOfDaughters++;
259
261
262 auto triplets = pAssembly->fTriplets;
263
264 // store the transformation in a container (for GDML persistency)
265 fImprintsTransf[GetImprintsCount()] = transformation;
266
267 for( unsigned int i = 0; i < triplets.size(); ++i )
268 {
269 G4Transform3D Ta( *(triplets[i].GetRotation()),
270 triplets[i].GetTranslation() );
271 if ( triplets[i].IsReflection() ) { Ta = Ta * G4ReflectZ3D(); }
272
273 G4Transform3D Tfinal = transformation * Ta;
274
275 if ( triplets[i].GetVolume() )
276 {
277 // Generate the unique name for the next PV instance
278 // The name has format:
279 //
280 // av_WWW_impr_XXX_YYY_ZZZ
281 // where the fields mean:
282 // WWW - assembly volume instance number
283 // XXX - assembly volume imprint number
284 // YYY - the name of a log. volume we want to make a placement of
285 // ZZZ - the log. volume index inside the assembly volume
286 //
287 std::stringstream pvName;
288 pvName << "av_"
289 << GetAssemblyID()
290 << "_impr_"
292 << "_"
293 << triplets[i].GetVolume()->GetName().c_str()
294 << "_pv_"
295 << i
296 << std::ends;
297
298 // Generate a new physical volume instance inside a mother
299 // (as we allow 3D transformation use G4ReflectionFactory to
300 // take into account eventual reflection)
301 //
302 G4PhysicalVolumesPair pvPlaced
304 pvName.str().c_str(),
305 triplets[i].GetVolume(),
306 pMotherLV,
307 false,
308 numberOfDaughters + i,
309 surfCheck );
310
311 // Register the physical volume created by us so we can delete it later
312 //
313 fPVStore.push_back( pvPlaced.first );
314 if ( pvPlaced.second ) { fPVStore.push_back( pvPlaced.second ); }
315
316 // Here I want to save the imprint transformation to some container, so I can retrieve the original values later
317 // imprintTrans[GetImprintsCount()] = transformation;
318
319 }
320 else if ( triplets[i].GetAssembly() )
321 {
322 // Place volumes in this assembly with composed transformation
323 //
324 MakeImprint( triplets[i].GetAssembly(), pMotherLV,
325 Tfinal, i*100+copyNumBase, surfCheck );
326 }
327 else
328 {
329 G4Exception("G4AssemblyVolume::MakeImprint(..)",
330 "GeomVol0003", FatalException,
331 "Triplet has no volume and no assembly");
332 }
333 }
334}
@ FatalException
std::pair< G4VPhysicalVolume *, G4VPhysicalVolume * > G4PhysicalVolumesPair
HepGeom::ReflectZ3D G4ReflectZ3D
std::map< unsigned int, G4Transform3D > fImprintsTransf
unsigned int GetImprintsCount() const
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool surfCheck=false)
unsigned int GetAssemblyID() const
void ImprintsCountPlus()
size_t GetNoDaughters() const
static G4ReflectionFactory * Instance()
G4PhysicalVolumesPair Place(const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)

References FatalException, fImprintsTransf, fPVStore, fTriplets, G4Exception(), GetAssemblyID(), GetImprintsCount(), G4LogicalVolume::GetNoDaughters(), pyG4VTouchable::GetRotation, ImprintsCountPlus(), G4ReflectionFactory::Instance(), MakeImprint(), and G4ReflectionFactory::Place().

◆ MakeImprint() [2/3]

void G4AssemblyVolume::MakeImprint ( G4LogicalVolume pMotherLV,
G4ThreeVector translationInMother,
G4RotationMatrix pRotationInMother,
G4int  copyNumBase = 0,
G4bool  surfCheck = false 
)

Definition at line 336 of file G4AssemblyVolume.cc.

341{
342 // If needed user can specify explicitely the base count from which to start
343 // off for the generation of phys. vol. copy numbers.
344 // The old behaviour is preserved when copyNumBase == 0, e.g. the generated
345 // copy numbers start from the count equal to current number of daughter
346 // volumes before an imprint is made
347
348 // Compose transformation
349 //
350 if( pRotationInMother == nullptr )
351 {
352 // Make it by default an indentity matrix
353 //
354 pRotationInMother =
356 }
357
358 G4Transform3D transform( *pRotationInMother,
359 translationInMother );
360 MakeImprint(this, pMotherLV, transform, copyNumBase, surfCheck);
361}
static DLL_API const HepRotation IDENTITY
Definition: Rotation.h:366
G4bool transform(G4String &input, const G4String &type)

References CLHEP::HepRotation::IDENTITY, MakeImprint(), and G4coutFormatters::anonymous_namespace{G4coutFormatters.cc}::transform().

Referenced by G4tgbVolume::ConstructG4PhysVol(), MakeImprint(), and G4GDMLReadStructure::PhysvolRead().

◆ MakeImprint() [3/3]

void G4AssemblyVolume::MakeImprint ( G4LogicalVolume pMotherLV,
G4Transform3D transformation,
G4int  copyNumBase = 0,
G4bool  surfCheck = false 
)

Definition at line 363 of file G4AssemblyVolume.cc.

367{
368 // If needed user can specify explicitely the base count from which to start
369 // off for the generation of phys. vol. copy numbers.
370 // The old behaviour is preserved when copyNumBase == 0, e.g. the generated
371 // copy numbers start from the count equal to current number of daughter
372 // volumes before a imprint is made
373
374 MakeImprint(this, pMotherLV, transformation, copyNumBase, surfCheck);
375}

References MakeImprint().

◆ SetAssemblyID()

void G4AssemblyVolume::SetAssemblyID ( unsigned int  value)
inlineprotected

Referenced by G4AssemblyVolume().

◆ SetImprintsCount()

void G4AssemblyVolume::SetImprintsCount ( unsigned int  value)
inlineprotected

Referenced by G4AssemblyVolume().

◆ SetInstanceCount()

void G4AssemblyVolume::SetInstanceCount ( unsigned int  value)
inlineprotected

Definition at line 382 of file G4AssemblyVolume.cc.

383{
385}

References fsInstanceCounter.

◆ TotalImprintedVolumes()

std::size_t G4AssemblyVolume::TotalImprintedVolumes ( ) const
inline

◆ TotalTriplets()

std::size_t G4AssemblyVolume::TotalTriplets ( ) const
inline

Field Documentation

◆ fAssemblyID

unsigned int G4AssemblyVolume::fAssemblyID = 0
private

Definition at line 217 of file G4AssemblyVolume.hh.

Referenced by G4AssemblyVolume().

◆ fImprintsCounter

unsigned int G4AssemblyVolume::fImprintsCounter
private

Definition at line 209 of file G4AssemblyVolume.hh.

◆ fImprintsTransf

std::map<unsigned int, G4Transform3D> G4AssemblyVolume::fImprintsTransf
private

Definition at line 221 of file G4AssemblyVolume.hh.

Referenced by MakeImprint().

◆ fPVStore

std::vector<G4VPhysicalVolume*> G4AssemblyVolume::fPVStore
private

Definition at line 198 of file G4AssemblyVolume.hh.

Referenced by MakeImprint(), and ~G4AssemblyVolume().

◆ fsInstanceCounter

G4ThreadLocal unsigned int G4AssemblyVolume::fsInstanceCounter = 0
staticprivate

◆ fTriplets

std::vector<G4AssemblyTriplet> G4AssemblyVolume::fTriplets
private

The documentation for this class was generated from the following files: