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

#include <ExtParameterisedVolumeBuilder.h>

Inheritance diagram for ExtParameterisedVolumeBuilder:
Collaboration diagram for ExtParameterisedVolumeBuilder:

Public Member Functions

 ExtParameterisedVolumeBuilder (const std::string &n, Geo2G4AssemblyFactory *G4AssemblyFactory)
 
virtual G4LogicalVolume * Build (PVConstLink pv, OpticalVolumesMap *optical_volumes=0) override
 
Geo2G4AssemblyVolumeBuildAssembly (const PVConstLink &pv)
 
std::string GetKey () const
 
void SetParam (bool flag)
 
bool GetParam () const
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Protected Attributes

bool m_paramOn
 

Private Member Functions

void PrintSTInfo (const std::string &volume) const
 Prints info when some PhysVol contains both types (PV and ST) of daughters. More...
 
void getMatEther ()
 
void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

bool m_getMatEther
 
const GeoMaterial * m_matEther
 
const GeoMaterial * m_matHypUr
 
Geo2G4AssemblyFactorym_G4AssemblyFactory
 
std::string m_key
 
std::string m_nm
 Message source name. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

Detailed Description

Definition at line 18 of file ExtParameterisedVolumeBuilder.h.

Constructor & Destructor Documentation

◆ ExtParameterisedVolumeBuilder()

ExtParameterisedVolumeBuilder::ExtParameterisedVolumeBuilder ( const std::string &  n,
Geo2G4AssemblyFactory G4AssemblyFactory 
)

Definition at line 31 of file ExtParameterisedVolumeBuilder.cxx.

31  :
33  AthMessaging(n),
34  m_getMatEther(true),
35  m_matEther(nullptr),
36  m_matHypUr(nullptr),
37  m_G4AssemblyFactory(G4AssemblyFactory)
38 {
39 }

Member Function Documentation

◆ Build()

G4LogicalVolume * ExtParameterisedVolumeBuilder::Build ( PVConstLink  pv,
OpticalVolumesMap optical_volumes = 0 
)
overridevirtual

Implements VolumeBuilder.

Definition at line 41 of file ExtParameterisedVolumeBuilder.cxx.

42 {
43  PVConstLink theGeoPhysChild;
44  const GeoSerialTransformer* serialTransformerChild{nullptr};
45  G4LogicalVolume* theG4LogChild{nullptr};
46  unsigned int numChildNodes; // number of child nodes (PV and ST)
47  bool descend; // flag to continue geo tree navigation
48  bool serialExists = false; // flag for existence of ST among childs
49  std::string nameChild;
50 
52 
53  static Geo2G4LVFactory LVFactory;
54 
55  G4LogicalVolume* theG4LogVolume = LVFactory.Build(theGeoPhysVolume,descend);
56 
57  if(!descend) return theG4LogVolume;
58 
59  numChildNodes = theGeoPhysVolume->getNChildVolAndST();
60 
61  // *****************************************************************
62  // **
63  // ** If m_ST2Param flag is set:
64  // ** Check if there's any serial transformer among child volumes
65  // **
66  // *****************************************************************
67 
68  if(m_paramOn)
69  for(size_t counter1=0; counter1<numChildNodes; counter1++)
70  {
71  GeoAccessVolAndSTAction actionVolAndST(counter1);
72  theGeoPhysVolume->exec(&actionVolAndST);
73 
74  if((serialTransformerChild=actionVolAndST.getSerialTransformer()))
75  {
76  nameChild = actionVolAndST.getName();
77  serialExists = true;
78  break;
79  }
80  }
81  // ***************************************************************************
82  // ** Next steps:
83  // **
84  // ** 1. If ST exists and numChildNodes==1, translate ST to G4 ST
85  // **
86  // ** 2. If ST exists and numChildNodes !=1, print information message and
87  // ** translate ST to single placements as well as all other child volumes
88  // **
89  // ** 3. There's no ST - ok, nothing special ...
90  // **
91  // ***************************************************************************
92 
93  if(serialExists && (numChildNodes==1))
94  {
95  theGeoPhysChild = serialTransformerChild->getVolume();
96 
97  // Build the child
98  if(!(theG4LogChild = Build(theGeoPhysChild,optical_volumes))) return nullptr;
99 
100  if (nameChild == "ANON") nameChild=theG4LogChild->GetName();
101  nameChild += "_Param";
102 
103  Geo2G4STParameterisation* stParameterisation = new Geo2G4STParameterisation(serialTransformerChild->getFunction(),
104  serialTransformerChild->getNCopies());
105 
106  [[maybe_unused]] G4VPhysicalVolume* pvParametrised = new G4PVParameterised(nameChild,
107  theG4LogChild,
108  theG4LogVolume,
109  kUndefined,
110  serialTransformerChild->getNCopies(),
111  stParameterisation);
112  }
113  else
114  {
115  if(serialExists)
116  {
117  std::string volName = theGeoPhysVolume->getLogVol()->getName();
118  PrintSTInfo(volName);
119  }
120 
121  GeoVolumeCursor av(theGeoPhysVolume);
122  while (!av.atEnd())
123  {
124  int id = 16969;
125 
126  // Get child phys volume
127  theGeoPhysChild = av.getVolume();
128  // Get its transform
129  G4Transform3D theG4Position(Amg::EigenTransformToCLHEP(av.getTransform()));
130 
131  Query<int> Qint = av.getId();
132  if(Qint.isValid()) id = Qint;
133 
134  bool isEther = theGeoPhysChild->getLogVol()->getMaterial()->getName().compare("special::Ether")==0;
135  bool isHypUr = theGeoPhysChild->getLogVol()->getMaterial()->getName().compare("special::HyperUranium")==0;
136 
137  if(isEther) {
138  Geo2G4AssemblyVolume* assembly = BuildAssembly(theGeoPhysChild);
139 
140  if(Qint.isValid()) {
141  assembly->MakeImprint(theG4LogVolume,theG4Position,id);
142  }
143  else {
144  assembly->MakeImprint(theG4LogVolume,theG4Position);
145  }
146  }
147  else if(isHypUr) {
148  Geo2G4AssemblyVolume* assembly = BuildAssembly(theGeoPhysChild);
149 
150  if(Qint.isValid()) {
151  assembly->MakeImprint(theG4LogVolume,theG4Position,id,true);
152  }
153  else {
154  assembly->MakeImprint(theG4LogVolume,theG4Position,0,true);
155  }
156  }
157  else {
158  nameChild = av.getName();
159 
160  // Build the child
161  if(!(theG4LogChild = Build(theGeoPhysChild,optical_volumes))) return nullptr;
162 
163  if (nameChild == "ANON") nameChild=theG4LogChild->GetName();
164 
165  G4PhysicalVolumesPair pvPair = G4ReflectionFactory::Instance()->Place(theG4Position
166  , nameChild
167  , theG4LogChild
168  , theG4LogVolume
169  , false
170  , id);
171 
172  // if GeoModel volume is optical store it in the map
173  if(optical_volumes!=0) {
174  const GeoOpticalPhysVol* opticalGeoPhysChild =
175  dynamic_cast < const GeoOpticalPhysVol* >(theGeoPhysChild.operator->());
176  if(opticalGeoPhysChild)
177  (*optical_volumes)[opticalGeoPhysChild] = pvPair.first;
178  }
179  }
180 
181  av.next();
182  }
183  }
184 
185  return theG4LogVolume;
186 }

◆ BuildAssembly()

Geo2G4AssemblyVolume * ExtParameterisedVolumeBuilder::BuildAssembly ( const PVConstLink &  pv)

Definition at line 188 of file ExtParameterisedVolumeBuilder.cxx.

189 {
190  PVConstLink theGeoPhysChild;
191  G4LogicalVolume* theG4LogChild{nullptr};
192  Geo2G4AssemblyVolume* theG4AssemblyChild{nullptr};
193  bool descend; // flag to continue geo tree navigation
194 
196 
198 
199  if(!descend) return assemblyVolume;
200 
201  // Loop over child volumes and add them to the Geo2G4AssemblyVolume
202  GeoVolumeCursor av(pv);
203  while (!av.atEnd())
204  {
205  theGeoPhysChild = av.getVolume();
206  std::string nameChild = av.getName();
207 
208  std::string strVolume = std::string("Volume ") + nameChild + " ("
209  + theGeoPhysChild->getLogVol()->getName() + ")";
210 
211  // Check if it is an assembly
212  bool isEther = theGeoPhysChild->getLogVol()->getMaterial()->getName().compare("special::Ether")==0;
213  bool isHypUr = theGeoPhysChild->getLogVol()->getMaterial()->getName().compare("special::HyperUranium")==0;
214 
215  if(isEther || isHypUr) {
216  // Build the child assembly
217  if(!(theG4AssemblyChild = BuildAssembly(theGeoPhysChild))) return nullptr;
218 
219  // Get its transform
220  G4Transform3D theG4Position(Amg::EigenTransformToCLHEP(av.getTransform()));
221 
222  assemblyVolume->AddPlacedAssembly(theG4AssemblyChild,theG4Position);
223  }
224  else {
225  Query<int> Qint = av.getId();
226 
227  // Build the child
228  if(!(theG4LogChild = Build(theGeoPhysChild))) return nullptr;
229 
230  // Get its transform
231  G4Transform3D theG4Position(Amg::EigenTransformToCLHEP(av.getTransform()));
232 
233  int placedID = 0;
234  if(Qint.isValid()) placedID = Qint;
235 
236  std::string placedName = nameChild=="ANON" ? "" : nameChild;
237 
238  assemblyVolume->AddPlacedVolume(theG4LogChild,theG4Position,placedID,placedName);
239  }
240 
241  av.next();
242  }
243 
244  return assemblyVolume;
245 }

◆ GetKey()

std::string VolumeBuilder::GetKey ( ) const
inlineinherited

Definition at line 30 of file Simulation/G4Utilities/Geo2G4/src/VolumeBuilder.h.

30 {return m_key;}

◆ getMatEther()

void ExtParameterisedVolumeBuilder::getMatEther ( )
private

Definition at line 261 of file ExtParameterisedVolumeBuilder.cxx.

262 {
263  StoreGateSvc* pDetStore{nullptr};
264  ISvcLocator* svcLocator = Gaudi::svcLocator();
265  if(svcLocator->service("DetectorStore",pDetStore).isFailure()) {
266  ATH_MSG_ERROR ( "ExtParameterisedVolumeBuilder: Unable to access Detector Store" );
267  }
268  else {
269  StoredMaterialManager* theMaterialManager = pDetStore->tryRetrieve<StoredMaterialManager>("MATERIALS");
270  if(theMaterialManager) {
271  m_matEther = theMaterialManager->getMaterial("special::Ether");
272  m_matHypUr = theMaterialManager->getMaterial("special::HyperUranium");
273  }
274  }
275  m_getMatEther = false;
276 }

◆ GetParam()

bool VolumeBuilder::GetParam ( ) const
inlineinherited

Definition at line 34 of file Simulation/G4Utilities/Geo2G4/src/VolumeBuilder.h.

34 {return m_paramOn;}

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40 {
42  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level  lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152 {
153  if (!m_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ PrintSTInfo()

void ExtParameterisedVolumeBuilder::PrintSTInfo ( const std::string &  volume) const
private

Prints info when some PhysVol contains both types (PV and ST) of daughters.

Definition at line 247 of file ExtParameterisedVolumeBuilder.cxx.

248 {
249  ATH_MSG_INFO ( "**********************************************" );
250  ATH_MSG_INFO ( "** " );
251  ATH_MSG_INFO ( "** The Volume " << volume );
252  ATH_MSG_INFO ( "** Has children of two different types" );
253  ATH_MSG_INFO ( "** PeoPhysVolume and GeoSerialTransformer" );
254  ATH_MSG_INFO ( "** In this case GeoSerialTransformer will be " );
255  ATH_MSG_INFO ( "** translated into G4 placement but not in " );
256  ATH_MSG_INFO ( "** G4Parameterisation" );
257  ATH_MSG_INFO ( "** " );
258  ATH_MSG_INFO ( "********************************************** " );
259 }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level  lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29 {
30  m_lvl = lvl;
31 }

◆ SetParam()

void VolumeBuilder::SetParam ( bool  flag)
inlineinherited

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_G4AssemblyFactory

Geo2G4AssemblyFactory* ExtParameterisedVolumeBuilder::m_G4AssemblyFactory
private

Definition at line 37 of file ExtParameterisedVolumeBuilder.h.

◆ m_getMatEther

bool ExtParameterisedVolumeBuilder::m_getMatEther
private

Definition at line 33 of file ExtParameterisedVolumeBuilder.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_key

std::string VolumeBuilder::m_key
privateinherited

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ m_matEther

const GeoMaterial* ExtParameterisedVolumeBuilder::m_matEther
private

Definition at line 34 of file ExtParameterisedVolumeBuilder.h.

◆ m_matHypUr

const GeoMaterial* ExtParameterisedVolumeBuilder::m_matHypUr
private

Definition at line 35 of file ExtParameterisedVolumeBuilder.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_paramOn

bool VolumeBuilder::m_paramOn
protectedinherited

The documentation for this class was generated from the following files:
Geo2G4STParameterisation
Definition: Geo2G4STParameterisation.h:32
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
GeoOpticalPhysVol
Ensure that the extensions for the Vector3D are properly loaded.
Definition: GeoOpticalPhysVol.h:14
ExtParameterisedVolumeBuilder::m_getMatEther
bool m_getMatEther
Definition: ExtParameterisedVolumeBuilder.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ExtParameterisedVolumeBuilder::m_G4AssemblyFactory
Geo2G4AssemblyFactory * m_G4AssemblyFactory
Definition: ExtParameterisedVolumeBuilder.h:37
ExtParameterisedVolumeBuilder::Build
virtual G4LogicalVolume * Build(PVConstLink pv, OpticalVolumesMap *optical_volumes=0) override
Definition: ExtParameterisedVolumeBuilder.cxx:41
ExtParameterisedVolumeBuilder::m_matHypUr
const GeoMaterial * m_matHypUr
Definition: ExtParameterisedVolumeBuilder.h:35
ExtParameterisedVolumeBuilder::PrintSTInfo
void PrintSTInfo(const std::string &volume) const
Prints info when some PhysVol contains both types (PV and ST) of daughters.
Definition: ExtParameterisedVolumeBuilder.cxx:247
Geo2G4AssemblyVolume::MakeImprint
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, const G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool ITkScheme=false, G4bool surfCheck=false)
Definition: Geo2G4AssemblyVolume.cxx:289
descend
void descend(TDirectory *d, int level, int maxdepth, const std::vector< std::string > &labels)
Definition: chains.cxx:107
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
ExtParameterisedVolumeBuilder::BuildAssembly
Geo2G4AssemblyVolume * BuildAssembly(const PVConstLink &pv)
Definition: ExtParameterisedVolumeBuilder.cxx:188
VolumeBuilder::VolumeBuilder
VolumeBuilder(const std::string &k)
Definition: Simulation/G4Utilities/Geo2G4/src/VolumeBuilder.h:24
Geo2G4AssemblyFactory::Build
Geo2G4AssemblyVolume * Build(const PVConstLink &thePhys, bool &descend)
Definition: Geo2G4AssemblyFactory.cxx:17
ExtParameterisedVolumeBuilder::m_matEther
const GeoMaterial * m_matEther
Definition: ExtParameterisedVolumeBuilder.h:34
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Geo2G4AssemblyVolume::AddPlacedVolume
void AddPlacedVolume(G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation, int copyNo=0, const G4String &userComment="")
Definition: Geo2G4AssemblyVolume.cxx:72
ExtParameterisedVolumeBuilder::getMatEther
void getMatEther()
Definition: ExtParameterisedVolumeBuilder.cxx:261
beamspotman.n
n
Definition: beamspotman.py:731
master.flag
bool flag
Definition: master.py:29
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
Geo2G4AssemblyVolume
Definition: Geo2G4AssemblyVolume.h:16
Geo2G4AssemblyVolume::AddPlacedAssembly
void AddPlacedAssembly(Geo2G4AssemblyVolume *pAssembly, G4Transform3D &transformation)
Definition: Geo2G4AssemblyVolume.cxx:132
VolumeBuilder::m_key
std::string m_key
Definition: Simulation/G4Utilities/Geo2G4/src/VolumeBuilder.h:42
VolumeBuilder::m_paramOn
bool m_paramOn
Definition: Simulation/G4Utilities/Geo2G4/src/VolumeBuilder.h:39
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
Amg::EigenTransformToCLHEP
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Definition: CLHEPtoEigenConverter.h:120
python.changerun.pv
pv
Definition: changerun.py:81
StoredMaterialManager::getMaterial
virtual const GeoMaterial * getMaterial(const std::string &name)=0
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
Geo2G4LVFactory
Definition: Geo2G4LVFactory.h:15
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132