ATLAS Offline Software
Loading...
Searching...
No Matches
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)
const std::string & GetKey () const
void SetParam (bool flag)
bool GetParam () const
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

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.
void getMatEther ()
void initMessaging () const
 Initialize our message level and MessageSvc.

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.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

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}
AthMessaging()
Default constructor:

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 std::optional<int> Qint = av.getId();
132 if(Qint) 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) {
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) {
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}
void descend(TDirectory *d, int level, int maxdepth, const std::vector< std::string > &labels)
Definition chains.cxx:107
void PrintSTInfo(const std::string &volume) const
Prints info when some PhysVol contains both types (PV and ST) of daughters.
virtual G4LogicalVolume * Build(PVConstLink pv, OpticalVolumesMap *optical_volumes=0) override
Geo2G4AssemblyVolume * BuildAssembly(const PVConstLink &pv)
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, const G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool ITkScheme=false, G4bool surfCheck=false)
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.

◆ 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
197 Geo2G4AssemblyVolume* assemblyVolume = m_G4AssemblyFactory->Build(pv,descend);
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 std::optional<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) 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}
void AddPlacedAssembly(Geo2G4AssemblyVolume *pAssembly, G4Transform3D &transformation)
void AddPlacedVolume(G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation, int copyNo=0, const G4String &userComment="")

◆ GetKey()

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

◆ getMatEther()

void ExtParameterisedVolumeBuilder::getMatEther ( )
private

Definition at line 261 of file ExtParameterisedVolumeBuilder.cxx.

262{
263 SmartIF<IService> smartDetStore = Gaudi::svcLocator()->service("DetectorStore");
264 StoreGateSvc *pDetStore = dynamic_cast<StoreGateSvc*>(smartDetStore.get());
265 if (!pDetStore) {
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}
#define ATH_MSG_ERROR(x)
T * tryRetrieve() const
Variant of the above which doesn't print a warning message.
virtual const GeoMaterial * getMaterial(const std::string &name)=0

◆ GetParam()

bool VolumeBuilder::GetParam ( ) const
inlineinherited

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

32{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 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ 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 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ 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 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ 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_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ 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}
#define ATH_MSG_INFO(x)

◆ 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

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

31{m_paramOn = flag;}
bool flag
Definition master.py:29

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.

135{ nullptr };

◆ 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.

138{ MSG::NIL };

◆ 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: