ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Geo2G4AssemblyVolume Class Reference

#include <Geo2G4AssemblyVolume.h>

Collaboration diagram for Geo2G4AssemblyVolume:

Public Member Functions

 Geo2G4AssemblyVolume ()
 
 Geo2G4AssemblyVolume (G4LogicalVolume *volume, G4ThreeVector &translation, G4RotationMatrix *rotation)
 
 ~Geo2G4AssemblyVolume ()
 
void AddPlacedVolume (G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation, int copyNo=0, const G4String &userComment="")
 
void AddPlacedVolume (G4LogicalVolume *pPlacedVolume, G4Transform3D &transformation, int copyNo=0, const G4String &userComment="")
 
void AddPlacedAssembly (Geo2G4AssemblyVolume *pAssembly, G4Transform3D &transformation)
 
void AddPlacedAssembly (Geo2G4AssemblyVolume *pAssembly, G4ThreeVector &translation, G4RotationMatrix *rotation)
 
void MakeImprint (G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, const G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool ITkScheme=false, G4bool surfCheck=false)
 
void MakeImprint (G4LogicalVolume *pMotherLV, G4Transform3D &transformation, G4int copyNumBase=0, G4bool ITkScheme=false, G4bool surfCheck=false)
 
std::vector< G4VPhysicalVolume * >::iterator GetVolumesIterator ()
 
unsigned int TotalImprintedVolumes () const
 
unsigned int GetImprintsCount () const
 
unsigned int GetInstanceCount () const
 
unsigned int GetAssemblyID () const
 

Protected Member Functions

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

Private Member Functions

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

Private Attributes

std::vector< Geo2G4AssemblyTripletm_triplets
 
std::vector< int > m_copyNumbers
 
std::vector< G4String > m_userComments
 
std::vector< G4VPhysicalVolume * > m_PVStore
 
unsigned int m_imprintsCounter
 
unsigned int m_assemblyID
 

Static Private Attributes

static std::atomic< unsigned int > s_instanceCounter = 0
 

Detailed Description

Definition at line 15 of file Geo2G4AssemblyVolume.h.

Constructor & Destructor Documentation

◆ Geo2G4AssemblyVolume() [1/2]

Geo2G4AssemblyVolume::Geo2G4AssemblyVolume ( )

Definition at line 19 of file Geo2G4AssemblyVolume.cxx.

20 : m_assemblyID( 0 )
21 {
24  SetImprintsCount( 0 );
25 }

◆ Geo2G4AssemblyVolume() [2/2]

Geo2G4AssemblyVolume::Geo2G4AssemblyVolume ( G4LogicalVolume *  volume,
G4ThreeVector &  translation,
G4RotationMatrix *  rotation 
)

◆ ~Geo2G4AssemblyVolume()

Geo2G4AssemblyVolume::~Geo2G4AssemblyVolume ( )

Definition at line 29 of file Geo2G4AssemblyVolume.cxx.

30 {
31  unsigned int howmany = m_triplets.size();
32  if( howmany != 0 )
33  {
34  for( unsigned int i = 0; i < howmany; i++ )
35  {
36  G4RotationMatrix* pRotToClean = m_triplets[i].GetRotation();
37  if( pRotToClean != 0 )
38  {
39  delete pRotToClean;
40  }
41  }
42  }
43  m_triplets.clear();
44 
45  howmany = m_PVStore.size();
46  if( howmany != 0 )
47  {
48  for( unsigned int j = 0; j < howmany; j++ )
49  {
50  G4RotationMatrix* pRotToClean = m_PVStore[j]->GetRotation();
51  if( pRotToClean != 0 )
52  {
53  delete pRotToClean;
54  }
55  delete m_PVStore[j];
56  }
57  }
58  m_PVStore.clear();
60 }

Member Function Documentation

◆ AddPlacedAssembly() [1/2]

void Geo2G4AssemblyVolume::AddPlacedAssembly ( Geo2G4AssemblyVolume pAssembly,
G4ThreeVector &  translation,
G4RotationMatrix *  rotation 
)

Definition at line 117 of file Geo2G4AssemblyVolume.cxx.

120 {
121  G4RotationMatrix* toStore = new G4RotationMatrix;
122 
123  if( pRotation != 0 ) { *toStore = *pRotation; }
124 
125  Geo2G4AssemblyTriplet toAdd( pAssembly, translation, toStore );
126  m_triplets.push_back( toAdd );
127 }

◆ AddPlacedAssembly() [2/2]

void Geo2G4AssemblyVolume::AddPlacedAssembly ( Geo2G4AssemblyVolume pAssembly,
G4Transform3D &  transformation 
)

Definition at line 132 of file Geo2G4AssemblyVolume.cxx.

134 {
135  // Decompose transformation
136  //
137  G4Scale3D scale;
138  G4Rotate3D rotation;
139  G4Translate3D translation;
140  transformation.getDecomposition(scale, rotation, translation);
141 
142  G4ThreeVector v = translation.getTranslation();
143  G4RotationMatrix* r = new G4RotationMatrix;
144  *r = rotation.getRotation();
145 
146  G4bool isReflection = false;
147  if (scale(0,0)*scale(1,1)*scale(2,2) < 0.) { isReflection = true; }
148 
149  Geo2G4AssemblyTriplet toAdd( pAssembly, v, r, isReflection );
150  m_triplets.push_back( toAdd );
151 }

◆ AddPlacedVolume() [1/2]

void Geo2G4AssemblyVolume::AddPlacedVolume ( G4LogicalVolume *  pPlacedVolume,
G4ThreeVector &  translation,
G4RotationMatrix *  rotation,
int  copyNo = 0,
const G4String &  userComment = "" 
)

Definition at line 72 of file Geo2G4AssemblyVolume.cxx.

76 {
77  G4RotationMatrix* toStore = new G4RotationMatrix;
78 
79  if( pRotation != 0 ) { *toStore = *pRotation; }
80 
81  Geo2G4AssemblyTriplet toAdd( pVolume, translation, toStore );
82  m_triplets.push_back( toAdd );
83 
84  m_copyNumbers.push_back( copyNo );
85  m_userComments.push_back( userC );
86 }

◆ AddPlacedVolume() [2/2]

void Geo2G4AssemblyVolume::AddPlacedVolume ( G4LogicalVolume *  pPlacedVolume,
G4Transform3D &  transformation,
int  copyNo = 0,
const G4String &  userComment = "" 
)

Definition at line 90 of file Geo2G4AssemblyVolume.cxx.

93 {
94  // Decompose transformation
95  G4Scale3D scale;
96  G4Rotate3D rotation;
97  G4Translate3D translation;
98  transformation.getDecomposition(scale, rotation, translation);
99 
100  G4ThreeVector v = translation.getTranslation();
101  G4RotationMatrix* r = new G4RotationMatrix;
102  *r = rotation.getRotation();
103 
104  G4bool isReflection = false;
105  if (scale(0,0)*scale(1,1)*scale(2,2) < 0.) { isReflection = true; }
106 
107  Geo2G4AssemblyTriplet toAdd( pVolume, v, r, isReflection );
108  m_triplets.push_back( toAdd );
109 
110  m_copyNumbers.push_back( copyNo );
111  m_userComments.push_back( userC );
112 }

◆ GetAssemblyID()

unsigned int Geo2G4AssemblyVolume::GetAssemblyID ( ) const
inline

Definition at line 210 of file Geo2G4AssemblyVolume.h.

211 {
212  return m_assemblyID;
213 }

◆ GetImprintsCount()

unsigned int Geo2G4AssemblyVolume::GetImprintsCount ( ) const
inline

Definition at line 185 of file Geo2G4AssemblyVolume.h.

186 {
187  return m_imprintsCounter;
188 }

◆ GetInstanceCount()

unsigned int Geo2G4AssemblyVolume::GetInstanceCount ( ) const

Definition at line 331 of file Geo2G4AssemblyVolume.cxx.

332 {
334 }

◆ GetVolumesIterator()

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

Definition at line 223 of file Geo2G4AssemblyVolume.h.

224 {
226  return iterator;
227 }

◆ ImprintsCountMinus()

void Geo2G4AssemblyVolume::ImprintsCountMinus ( )
inlineprotected

Definition at line 204 of file Geo2G4AssemblyVolume.h.

205 {
207 }

◆ ImprintsCountPlus()

void Geo2G4AssemblyVolume::ImprintsCountPlus ( )
inlineprotected

Definition at line 198 of file Geo2G4AssemblyVolume.h.

199 {
201 }

◆ InstanceCountMinus()

void Geo2G4AssemblyVolume::InstanceCountMinus ( )
protected

Definition at line 341 of file Geo2G4AssemblyVolume.cxx.

◆ InstanceCountPlus()

void Geo2G4AssemblyVolume::InstanceCountPlus ( )
protected

Definition at line 336 of file Geo2G4AssemblyVolume.cxx.

◆ MakeImprint() [1/3]

void Geo2G4AssemblyVolume::MakeImprint ( G4LogicalVolume *  pMotherLV,
G4ThreeVector &  translationInMother,
const G4RotationMatrix *  pRotationInMother,
G4int  copyNumBase = 0,
G4bool  ITkScheme = false,
G4bool  surfCheck = false 
)

Definition at line 289 of file Geo2G4AssemblyVolume.cxx.

295 {
296  // If needed user can specify explicitely the base count from which to start
297  // off for the generation of phys. vol. copy numbers.
298  // The old behaviour is preserved when copyNumBase == 0, e.g. the generated
299  // copy numbers start from the count equal to current number of daughter
300  // volumes before an imprint is made
301 
302  // Compose transformation
303  //
304  if( pRotationInMother == 0 )
305  {
306  // Make it by default an indentity matrix
307  //
308  pRotationInMother = &G4RotationMatrix::IDENTITY;
309  }
310 
311  G4Transform3D transform( *pRotationInMother,
312  translationInMother );
313  MakeImprint(this, pMotherLV, transform, copyNumBase, ITkScheme, surfCheck);
314 }

◆ MakeImprint() [2/3]

void Geo2G4AssemblyVolume::MakeImprint ( G4LogicalVolume *  pMotherLV,
G4Transform3D &  transformation,
G4int  copyNumBase = 0,
G4bool  ITkScheme = false,
G4bool  surfCheck = false 
)

Definition at line 316 of file Geo2G4AssemblyVolume.cxx.

321 {
322  // If needed user can specify explicitely the base count from which to start
323  // off for the generation of phys. vol. copy numbers.
324  // The old behaviour is preserved when copyNumBase == 0, e.g. the generated
325  // copy numbers start from the count equal to current number of daughter
326  // volumes before a imprint is made
327 
328  MakeImprint(this, pMotherLV, transformation, copyNumBase, ITkScheme, surfCheck);
329 }

◆ MakeImprint() [3/3]

void Geo2G4AssemblyVolume::MakeImprint ( Geo2G4AssemblyVolume pAssembly,
G4LogicalVolume *  pMotherLV,
G4Transform3D &  transformation,
G4int  copyNumBase = 0,
G4bool  ITkScheme = false,
G4bool  surfCheck = false 
)
private

Definition at line 191 of file Geo2G4AssemblyVolume.cxx.

197 {
198  unsigned int numberOfDaughters;
199 
200  if( copyNumBase == 0 )
201  {
202  numberOfDaughters = pMotherLV->GetNoDaughters();
203  }
204  else
205  {
206  numberOfDaughters = copyNumBase;
207  }
208  // We start from the first available index
209  //
210  numberOfDaughters++;
211 
213  std::vector<Geo2G4AssemblyTriplet> triplets = pAssembly->m_triplets;
214  for( unsigned int i = 0; i < triplets.size(); i++ )
215  {
216  G4Transform3D Ta( *(triplets[i].GetRotation()),
217  triplets[i].GetTranslation() );
218  if ( triplets[i].IsReflection() ) { Ta = Ta * G4ReflectZ3D(); }
219 
220  G4Transform3D Tfinal = transformation * Ta;
221  if ( triplets[i].GetVolume() )
222  {
223  // Generate the unique name for the next PV instance
224  // The name has format:
225  //
226  // av_WWW_impr_XXX_YYY_ZZZ
227  // where the fields mean:
228  // WWW - assembly volume instance number
229  // XXX - assembly volume imprint number
230  // YYY - the name of a log. volume we want to make a placement of
231  // ZZZ - the log. volume index inside the assembly volume
232  //
233 
234 
235  std::stringstream pvName;
236  pvName << "av_"
237  << GetAssemblyID()
238  << "_impr_"
239  << GetImprintsCount()
240  << "_"
241  << triplets[i].GetVolume()->GetName().c_str()
242  << "_pv_"
243  << i;
244  if (i<m_userComments.size() && !(m_userComments[i].empty())) pvName<<"_"<<m_userComments[i];
245  pvName<<std::ends;
246  // Generate a new physical volume instance inside a mother
247  // (as we allow 3D transformation use G4ReflectionFactory to
248  // take into account eventual reflection)
249  //
250  int ccn=numberOfDaughters + i;
251  if (i<m_copyNumbers.size() && m_copyNumbers[i]) {
252  if(ITkScheme) ccn=m_copyNumbers[i];
253  else ccn=m_copyNumbers[i]+copyNumBase;
254  }
255 
256  G4PhysicalVolumesPair pvPlaced
257  = G4ReflectionFactory::Instance()->Place( Tfinal,
258  pvName.str().c_str(),
259  triplets[i].GetVolume(),
260  pMotherLV,
261  false,
262  ccn,
263  surfCheck );
264 
265 
266  // Register the physical volume created by us so we can delete it later
267  //
268  m_PVStore.push_back( pvPlaced.first );
269  if ( pvPlaced.second ) { m_PVStore.push_back( pvPlaced.second ); }
270  }
271  else if ( triplets[i].GetAssembly() )
272  {
273  // Place volumes in this assembly with composed transformation
274  //
275  if(ITkScheme) triplets[i].GetAssembly()->MakeImprint( triplets[i].GetAssembly(), pMotherLV,
276  Tfinal, i*100+copyNumBase, ITkScheme, surfCheck );
277  else MakeImprint( triplets[i].GetAssembly(), pMotherLV,
278  Tfinal, i*100+copyNumBase, ITkScheme, surfCheck );
279  }
280  else
281  {
282  G4Exception("Geo2G4AssemblyVolume::MakeImprint(..)",
283  "NotApplicable", FatalException,
284  "Triplet has no volume and no assembly");
285  }
286  }
287 }

◆ SetAssemblyID()

void Geo2G4AssemblyVolume::SetAssemblyID ( unsigned int  value)
inlineprotected

Definition at line 216 of file Geo2G4AssemblyVolume.h.

217 {
219 }

◆ SetImprintsCount()

void Geo2G4AssemblyVolume::SetImprintsCount ( unsigned int  value)
inlineprotected

Definition at line 191 of file Geo2G4AssemblyVolume.h.

192 {
194 }

◆ TotalImprintedVolumes()

unsigned int Geo2G4AssemblyVolume::TotalImprintedVolumes ( ) const
inline

Definition at line 230 of file Geo2G4AssemblyVolume.h.

231 {
232  return m_PVStore.size();
233 }

Member Data Documentation

◆ m_assemblyID

unsigned int Geo2G4AssemblyVolume::m_assemblyID
private

Definition at line 178 of file Geo2G4AssemblyVolume.h.

◆ m_copyNumbers

std::vector<int> Geo2G4AssemblyVolume::m_copyNumbers
private

Definition at line 153 of file Geo2G4AssemblyVolume.h.

◆ m_imprintsCounter

unsigned int Geo2G4AssemblyVolume::m_imprintsCounter
private

Definition at line 170 of file Geo2G4AssemblyVolume.h.

◆ m_PVStore

std::vector<G4VPhysicalVolume*> Geo2G4AssemblyVolume::m_PVStore
private

Definition at line 159 of file Geo2G4AssemblyVolume.h.

◆ m_triplets

std::vector<Geo2G4AssemblyTriplet> Geo2G4AssemblyVolume::m_triplets
private

Definition at line 152 of file Geo2G4AssemblyVolume.h.

◆ m_userComments

std::vector<G4String> Geo2G4AssemblyVolume::m_userComments
private

Definition at line 154 of file Geo2G4AssemblyVolume.h.

◆ s_instanceCounter

std::atomic< unsigned int > Geo2G4AssemblyVolume::s_instanceCounter = 0
staticprivate

Definition at line 174 of file Geo2G4AssemblyVolume.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Geo2G4AssemblyVolume::m_userComments
std::vector< G4String > m_userComments
Definition: Geo2G4AssemblyVolume.h:154
beamspotman.r
def r
Definition: beamspotman.py:676
Geo2G4AssemblyVolume::GetAssemblyID
unsigned int GetAssemblyID() const
Definition: Geo2G4AssemblyVolume.h:210
Geo2G4AssemblyVolume::GetImprintsCount
unsigned int GetImprintsCount() const
Definition: Geo2G4AssemblyVolume.h:185
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
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
Geo2G4AssemblyVolume::m_copyNumbers
std::vector< int > m_copyNumbers
Definition: Geo2G4AssemblyVolume.h:153
Geo2G4AssemblyVolume::ImprintsCountPlus
void ImprintsCountPlus()
Definition: Geo2G4AssemblyVolume.h:198
Geo2G4AssemblyVolume::s_instanceCounter
static std::atomic< unsigned int > s_instanceCounter
Definition: Geo2G4AssemblyVolume.h:174
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::rotation
rotation
Definition: TrackSurface_v1.cxx:15
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
Geo2G4AssemblyVolume::InstanceCountPlus
void InstanceCountPlus()
Definition: Geo2G4AssemblyVolume.cxx:336
DeMoUpdate.toAdd
bool toAdd
Definition: DeMoUpdate.py:1304
Geo2G4AssemblyTriplet
Definition: Geo2G4AssemblyTriplet.h:15
Geo2G4AssemblyVolume::m_assemblyID
unsigned int m_assemblyID
Definition: Geo2G4AssemblyVolume.h:178
python.PyAthena.v
v
Definition: PyAthena.py:154
Geo2G4AssemblyVolume::SetImprintsCount
void SetImprintsCount(unsigned int value)
Definition: Geo2G4AssemblyVolume.h:191
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