ATLAS Offline Software
Typedefs | Functions
Geo2G4SolidFactory.cxx File Reference
#include "Geo2G4SolidFactory.h"
#include "LArWheelSolid.h"
#include "LArWheelSliceSolid.h"
#include "LArWheelSolidDDProxy.h"
#include "GeoModelKernel/GeoShape.h"
#include "GeoModelKernel/GeoBox.h"
#include "GeoModelKernel/GeoTube.h"
#include "GeoModelKernel/GeoTubs.h"
#include "GeoModelKernel/GeoTrd.h"
#include "GeoModelKernel/GeoPcon.h"
#include "GeoModelKernel/GeoPgon.h"
#include "GeoModelKernel/GeoPara.h"
#include "GeoModelKernel/GeoTrap.h"
#include "GeoModelKernel/GeoCons.h"
#include "GeoModelKernel/GeoSimplePolygonBrep.h"
#include "GeoModelKernel/GeoTessellatedSolid.h"
#include "GeoModelKernel/GeoEllipticalTube.h"
#include "GeoModelKernel/GeoTorus.h"
#include "GeoModelKernel/GeoGenericTrap.h"
#include "GeoModelKernel/GeoShapeShift.h"
#include "GeoModelKernel/GeoShapeUnion.h"
#include "GeoModelKernel/GeoShapeIntersection.h"
#include "GeoModelKernel/GeoUnidentifiedShape.h"
#include "GeoModelKernel/GeoShapeSubtraction.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/Bootstrap.h"
#include "GeoModelInterfaces/IGeoModelSvc.h"
#include "RDBAccessSvc/IRDBRecord.h"
#include "RDBAccessSvc/IRDBRecordset.h"
#include "RDBAccessSvc/IRDBAccessSvc.h"
#include "GeoModelUtilities/DecodeVersionKey.h"
#include "GeoSpecialShapes/EMECData.h"
#include "GeoSpecialShapes/toEMECData.h"
#include "G4VSolid.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4Trd.hh"
#include "G4Polycone.hh"
#include "G4Cons.hh"
#include "G4Polyhedra.hh"
#include "G4Trap.hh"
#include "G4Para.hh"
#include "G4UnionSolid.hh"
#include "G4DisplacedSolid.hh"
#include "G4IntersectionSolid.hh"
#include "G4SubtractionSolid.hh"
#include "G4ExtrudedSolid.hh"
#include "G4TessellatedSolid.hh"
#include "G4EllipticalTube.hh"
#include "G4Torus.hh"
#include "G4TriangularFacet.hh"
#include "G4QuadrangularFacet.hh"
#include "G4GenericTrap.hh"
#include <iostream>
#include <map>
#include <cmath>
#include <utility>
#include "GeoPrimitives/CLHEPtoEigenConverter.h"

Go to the source code of this file.

Typedefs

typedef std::map< const GeoShape *, G4VSolid *, std::less< const GeoShape * > > shapesMap
 
typedef std::map< std::string, G4VSolid *, std::less< std::string > > customSolidMap
 

Functions

G4VSolid *Geo2G4SolidFactory::Build ATLAS_NOT_THREAD_SAFE (const GeoShape *geoShape, std::string name)
 
G4VSolid *Geo2G4SolidFactory::createLArWheelSolid ATLAS_NOT_THREAD_SAFE (const std::string &name, const LArWheelSolidDef_t &lwsdef, const EMECData &emecData) const
 
G4VSolid *Geo2G4SolidFactory::createLArWheelSliceSolid ATLAS_NOT_THREAD_SAFE (const GeoUnidentifiedShape *customShape, const EMECData &emecData) const
 

Typedef Documentation

◆ customSolidMap

typedef std::map<std::string, G4VSolid*,std::less<std::string> > customSolidMap

Definition at line 76 of file Geo2G4SolidFactory.cxx.

◆ shapesMap

typedef std::map<const GeoShape*, G4VSolid*, std::less<const GeoShape*> > shapesMap

Definition at line 75 of file Geo2G4SolidFactory.cxx.

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE() [1/3]

G4VSolid* Geo2G4SolidFactory::Build ATLAS_NOT_THREAD_SAFE ( const GeoShape *  geoShape,
std::string  name 
)

Definition at line 152 of file Geo2G4SolidFactory.cxx.

153 {
154  G4VSolid* theSolid(nullptr);
155 
156  static customSolidMap customSolids;
157  static shapesMap sharedShapes;
158  if(sharedShapes.find(geoShape)!=sharedShapes.end())
159  return sharedShapes[geoShape];
160 
161  // ------- Variables for boolean operations
162  G4VSolid* solidA(nullptr);
163  G4VSolid* solidB(nullptr);
164  // ------- Variables for Pcon and Pgon
165  int nPlanes;
166  double* zPlane(nullptr);
167  double* rInner(nullptr);
168  double* rOuter(nullptr);
169 
170  std::string n = std::move(name);
171 
172  //
173  // The Box
174  //
175  if(geoShape->typeID() == GeoBox::getClassTypeID() )
176  {
177  const GeoBox* theBox = dynamic_cast<const GeoBox*> (geoShape);
178  if (nullptr==theBox) throw std::runtime_error("TypeID did not match cast for box");
179  if (n.empty()) n="G4Box";
180  if (theBox->getXHalfLength()<=0.){ ATH_MSG_WARNING("Box " << n << " has an x side of " << theBox->getXHalfLength() <<" - using std::abs.");}
181  if (theBox->getYHalfLength()<=0.){ ATH_MSG_WARNING("Box " << n << " has an y side of " << theBox->getYHalfLength() <<" - using std::abs.");}
182  if (theBox->getZHalfLength()<=0.){ ATH_MSG_WARNING("Box " << n << " has an z side of " << theBox->getZHalfLength() <<" - using std::abs.");}
183  theSolid = new G4Box(n,
184  std::abs(theBox->getXHalfLength()),
185  std::abs(theBox->getYHalfLength()),
186  std::abs(theBox->getZHalfLength()));
187  }
188  //
189  // The Tube
190  //
191  else if(geoShape->typeID() == GeoTube::getClassTypeID() )
192  {
193  const GeoTube* theTube = dynamic_cast<const GeoTube*> (geoShape);
194  if (nullptr==theTube) throw std::runtime_error("TypeID did not match cast for tube");
195  if (n.empty()) n="G4Tube";
196  if (theTube->getRMax()<=0.){ ATH_MSG_WARNING("Tube " << n << " has a max radius of " << theTube->getRMax() <<" - using std::abs.");}
197  if (theTube->getZHalfLength()<=0.){ ATH_MSG_WARNING("Tube " << n << " has a z half length of " << theTube->getZHalfLength() << " - using std::abs.");}
198  if (theTube->getRMax()<theTube->getRMin()){ ATH_MSG_WARNING("Tube " << n << " has a max radius of " << theTube->getRMax() << " and a min radius of " << theTube->getRMin());}
199  theSolid = new G4Tubs(n,
200  theTube->getRMin(),
201  std::abs(theTube->getRMax()),
202  std::abs(theTube->getZHalfLength()),
203  0.,360*CLHEP::deg);
204  }
205  //
206  // The Tubs
207  //
208  else if(geoShape->typeID() == GeoTubs::getClassTypeID() )
209  {
210  const GeoTubs* theTubs = dynamic_cast<const GeoTubs*> (geoShape);
211  if (nullptr==theTubs) throw std::runtime_error("TypeID did not match cast for tubs");
212  if (n.empty()) n="G4Tubs";
213  if (theTubs->getRMin()<0.){ ATH_MSG_WARNING("Tubs " << n << " has a min radius of " << theTubs->getRMax());}
214  if (theTubs->getRMax()<=0.){ ATH_MSG_WARNING("Tubs " << n << " has a max radius of " << theTubs->getRMax() <<" - using std::abs.");}
215  if (theTubs->getZHalfLength()<=0.){ ATH_MSG_WARNING("Tubs " << n << " has a half length of " << theTubs->getZHalfLength() <<" - using std::abs.");}
216  if (theTubs->getRMax()<theTubs->getRMin()){ ATH_MSG_WARNING("Tubs " << n << " has a max radius of " << theTubs->getRMax() << " and a min radius of " << theTubs->getRMin());}
217  if (theTubs->getDPhi()<=0.){ ATH_MSG_WARNING("Tubs " << n << " has a dPhi of " << theTubs->getDPhi());}
218  theSolid = new G4Tubs(n,
219  theTubs->getRMin(),
220  std::abs(theTubs->getRMax()),
221  std::abs(theTubs->getZHalfLength()),
222  theTubs->getSPhi(),
223  theTubs->getDPhi());
224  }
225  //
226  // The Trd
227  //
228  else if(geoShape->typeID() == GeoTrd::getClassTypeID() )
229  {
230  const GeoTrd* theTrd = dynamic_cast<const GeoTrd*> (geoShape);
231  if (nullptr==theTrd) throw std::runtime_error("TypeID did not match cast for trd");
232  if (n.empty()) n="G4Trd";
233  if (theTrd->getXHalfLength1()<0.){ ATH_MSG_WARNING("Trd " << n << " has a x half length 1 of " << theTrd->getXHalfLength1() << " - using std::abs.");}
234  if (theTrd->getXHalfLength2()<0.){ ATH_MSG_WARNING("Trd " << n << " has a x half length 2 of " << theTrd->getXHalfLength2() << " - using std::abs.");}
235  if (theTrd->getYHalfLength1()<0.){ ATH_MSG_WARNING("Trd " << n << " has a y half length 1 of " << theTrd->getYHalfLength1() << " - using std::abs.");}
236  if (theTrd->getYHalfLength2()<0.){ ATH_MSG_WARNING("Trd " << n << " has a y half length 2 of " << theTrd->getYHalfLength2() << " - using std::abs.");}
237  if (theTrd->getZHalfLength()<=0.){ ATH_MSG_WARNING("Trd " << n << " has a z half length of " << theTrd->getZHalfLength() << " - using std::abs.");}
238  if (theTrd->getXHalfLength1()<=0. && theTrd->getXHalfLength2()<=0.){ ATH_MSG_WARNING("Trd " << n << " has an x half length 1 of " << theTrd->getXHalfLength1()
239  << " and an x half length 2 of " << theTrd->getXHalfLength2() << " - using std::abs.");}
240  if (theTrd->getYHalfLength1()<=0. && theTrd->getYHalfLength2()<=0.){ ATH_MSG_WARNING("Trd " << n << " has a y half length 1 of " << theTrd->getYHalfLength1()
241  << " and a y half length 2 of " << theTrd->getYHalfLength2() << " - using std::abs.");}
242  theSolid = new G4Trd(n,
243  std::abs(theTrd->getXHalfLength1()),
244  std::abs(theTrd->getXHalfLength2()),
245  std::abs(theTrd->getYHalfLength1()),
246  std::abs(theTrd->getYHalfLength2()),
247  std::abs(theTrd->getZHalfLength()));
248  }
249  //
250  // GeoPcon
251  //
252  else if(geoShape->typeID() == GeoPcon::getClassTypeID())
253  {
254  const GeoPcon* thePcon = dynamic_cast<const GeoPcon*>(geoShape);
255  if (nullptr==thePcon) throw std::runtime_error("TypeID did not match cast for pcon");
256  if (n.empty()) n="G4Polycone";
257  nPlanes = static_cast<int>(thePcon->getNPlanes());
258  zPlane = new double[nPlanes];
259  rInner = new double[nPlanes];
260  rOuter = new double[nPlanes];
261  for (unsigned int index=0; index<static_cast<unsigned int>(nPlanes); index++)
262  {
263  zPlane[index] = thePcon->getZPlane(index);
264  rInner[index] = thePcon->getRMinPlane(index);
265  rOuter[index] = thePcon->getRMaxPlane(index);
266  if (rInner[index]<0.){ ATH_MSG_WARNING("PCon " << n << " has an inner radius of " << rInner[index] << " for slice " << index << " of " << nPlanes);}
267  if (rOuter[index]<=0.){
268  ATH_MSG_WARNING("PCon " << n << " has an outer radius of " << rOuter[index] << " for slice " << index << " of " << nPlanes << " - using std::abs.");
269  rOuter[index] = std::abs(rOuter[index]);
270  }
271  }
272 
273  theSolid = new G4Polycone(n,
274  thePcon->getSPhi(),
275  thePcon->getDPhi(),
276  nPlanes,
277  zPlane,
278  rInner,
279  rOuter);
280  }
281  //
282  // GeoCons
283  //
284  else if(geoShape->typeID() == GeoCons::getClassTypeID())
285  {
286  const GeoCons* theCons = dynamic_cast<const GeoCons*>(geoShape);
287  if (nullptr==theCons) throw std::runtime_error("TypeID did not match cast for cons");
288  if (n.empty()) n="G4Cons";
289  if (theCons->getRMax1()<0.){ ATH_MSG_WARNING("Cons " << n << " has a max radius 1 of " << theCons->getRMax1() << " - will use std::abs.");}
290  if (theCons->getRMax2()<0.){ ATH_MSG_WARNING("Cons " << n << " has a max radius 2 of " << theCons->getRMax2() << " - will use std::abs.");}
291  if (theCons->getRMin1()<0.){ ATH_MSG_WARNING("Cons " << n << " has a min radius 1 of " << theCons->getRMin1());}
292  if (theCons->getRMin2()<0.){ ATH_MSG_WARNING("Cons " << n << " has a min radius 2 of " << theCons->getRMin2());}
293  if (theCons->getDZ()<=0){ ATH_MSG_WARNING("Cons " << n << " has a DZ of " << theCons->getDZ() << " - will use std::abs.");}
294  if (theCons->getRMax1()<=0. && theCons->getRMax2()<=0.){ ATH_MSG_WARNING("Cons " << n << " has a max radius 1 of " << theCons->getRMax1()
295  << " and a max radius 2 of " << theCons->getRMax2() << " - will use std::abs.");}
296  theSolid = new G4Cons(n,
297  theCons->getRMin1(),
298  std::abs(theCons->getRMax1()),
299  theCons->getRMin2(),
300  std::abs(theCons->getRMax2()),
301  std::abs(theCons->getDZ()),
302  theCons->getSPhi(),
303  theCons->getDPhi());
304  }
305  //
306  // GeoPara
307  //
308  else if(geoShape->typeID() == GeoPara::getClassTypeID())
309  {
310  const GeoPara* thePara = dynamic_cast<const GeoPara*>(geoShape);
311  if (nullptr==thePara) throw std::runtime_error("TypeID did not match cast for para");
312  if (n.empty()) n="G4Para";
313  if (thePara->getXHalfLength()<=0.){ ATH_MSG_WARNING("Para " << n << " has an x side of " << thePara->getXHalfLength() <<" - using std::abs.");}
314  if (thePara->getYHalfLength()<=0.){ ATH_MSG_WARNING("Para " << n << " has an y side of " << thePara->getYHalfLength() <<" - using std::abs.");}
315  if (thePara->getZHalfLength()<=0.){ ATH_MSG_WARNING("Para " << n << " has an z side of " << thePara->getZHalfLength() <<" - using std::abs.");}
316  theSolid = new G4Para(n,
317  std::abs(thePara->getXHalfLength()),
318  std::abs(thePara->getYHalfLength()),
319  std::abs(thePara->getZHalfLength()),
320  thePara->getAlpha(),
321  thePara->getTheta(),
322  thePara->getPhi());
323  }
324  //
325  // GeoPgon
326  //
327  else if(geoShape->typeID() == GeoPgon::getClassTypeID())
328  {
329  const GeoPgon* thePgon = dynamic_cast<const GeoPgon*>(geoShape);
330  if (nullptr==thePgon) throw std::runtime_error("TypeID did not match cast for pgon");
331  if (n.empty()) n="G4Polyhedra";
332  nPlanes = static_cast<int>(thePgon->getNPlanes());
333  zPlane = new double[nPlanes];
334  rInner = new double[nPlanes];
335  rOuter = new double[nPlanes];
336  double alpha = thePgon->getDPhi()/(2*thePgon->getNSides()); // 1/2 openning angle
337  for (unsigned int index=0; index<static_cast<unsigned int>(nPlanes); index++)
338  {
339  zPlane[index] = thePgon->getZPlane(index);
340  rInner[index] = thePgon->getRMinPlane(index)*cos(alpha);
341  rOuter[index] = thePgon->getRMaxPlane(index)*cos(alpha);
342  if (rInner[index]<0.){ ATH_MSG_WARNING("Pgon " << n << " has an inner radius of " << rInner[index] << " for slice " << index << " of " << nPlanes);}
343  if (rOuter[index]<=0.){
344  ATH_MSG_WARNING("Pgon " << n << " has an outer radius of " << rOuter[index] << " for slice " << index << " of " << nPlanes << " - using std::abs.");
345  rOuter[index] = std::abs(rOuter[index]);
346  }
347  }
348 
349  theSolid = new G4Polyhedra(n,
350  thePgon->getSPhi(),
351  thePgon->getDPhi(),
352  thePgon->getNSides(),
353  nPlanes,
354  zPlane,
355  rInner,
356  rOuter);
357  }
358  //
359  // GeoTrap
360  //
361  else if(geoShape->typeID() == GeoTrap::getClassTypeID())
362  {
363  const GeoTrap* theTrap = dynamic_cast<const GeoTrap*>(geoShape);
364  if (nullptr==theTrap) throw std::runtime_error("TypeID did not match cast for trap");
365  if (n.empty()) n="G4Trap";
366  if (theTrap->getZHalfLength()<=0.){ ATH_MSG_WARNING("Trap " << n << " has an z side of " << theTrap->getZHalfLength() <<" - using std::abs.");}
367  theSolid = new G4Trap(n,
368  std::abs(theTrap->getZHalfLength()),
369  theTrap->getTheta(),
370  theTrap->getPhi(),
371  theTrap->getDydzn(),
372  theTrap->getDxdyndzn(),
373  theTrap->getDxdypdzn(),
374  theTrap->getAngleydzn(),
375  theTrap->getDydzp(),
376  theTrap->getDxdyndzp(),
377  theTrap->getDxdypdzp(),
378  theTrap->getAngleydzp());
379  }
380  //
381  // Simple Polygon Brep
382  //
383  else if(geoShape->typeID() == GeoSimplePolygonBrep::getClassTypeID())
384  {
385  const GeoSimplePolygonBrep* theBrep = dynamic_cast<const GeoSimplePolygonBrep*>(geoShape);
386  if (nullptr==theBrep) throw std::runtime_error("TypeID did not match cast for brep");
387  if (n.empty()) n="G4ExtrudedSolid";
388  double dz = theBrep->getDZ();
389  int nVertices = theBrep->getNVertices();
390 
391  G4TwoVector off(0,0);
392  std::vector<G4TwoVector> polygon;
393 
394  polygon.reserve(nVertices);
395 for(int i=0; i<nVertices; i++)
396  polygon.push_back(G4TwoVector(theBrep->getXVertex(nVertices-1-i),theBrep->getYVertex(nVertices-1-i)));
397 
398  theSolid = new G4ExtrudedSolid(n,polygon,dz,off,1,off,1);
399  }
400  //
401  // Tessellated Solid
402  //
403  else if(geoShape->typeID() == GeoTessellatedSolid::getClassTypeID())
404  {
405  const GeoTessellatedSolid* theTessellated = dynamic_cast<const GeoTessellatedSolid*>(geoShape);
406  if (nullptr==theTessellated) throw std::runtime_error("TypeID did not match cast for tessellated solid");
407  if(n.empty()) n="G4TessellatedSolid";
408 
409  G4TessellatedSolid* g4Tessellated = new G4TessellatedSolid(n);
410  for(size_t i=0; i<theTessellated->getNumberOfFacets(); ++i) {
411  GeoFacet* geoFacet = theTessellated->getFacet(i);
412  G4FacetVertexType vertexType = (geoFacet->getVertexType()==GeoFacet::ABSOLUTE? ABSOLUTE : RELATIVE);
413  G4VFacet* g4Facet(nullptr);
414  if(geoFacet->getNumberOfVertices()==3)
415  g4Facet = new G4TriangularFacet(Amg::EigenToHep3Vector(geoFacet->getVertex(0)),
416  Amg::EigenToHep3Vector(geoFacet->getVertex(1)),
417  Amg::EigenToHep3Vector(geoFacet->getVertex(2)),
418  vertexType);
419  else
420  g4Facet = new G4QuadrangularFacet(Amg::EigenToHep3Vector(geoFacet->getVertex(0)),
421  Amg::EigenToHep3Vector(geoFacet->getVertex(1)),
422  Amg::EigenToHep3Vector(geoFacet->getVertex(2)),
423  Amg::EigenToHep3Vector(geoFacet->getVertex(3)),
424  vertexType);
425 
426  g4Tessellated->AddFacet(g4Facet);
427  }
428  g4Tessellated->SetSolidClosed(true);
429  theSolid = g4Tessellated;
430  }
431  //
432  // Elliptical Tube
433  //
434  else if(geoShape->typeID() == GeoEllipticalTube::getClassTypeID())
435  {
436  const GeoEllipticalTube* theEltube = dynamic_cast<const GeoEllipticalTube*>(geoShape);
437  if (nullptr==theEltube) throw std::runtime_error("TypeID did not match cast for elliptical tube");
438  if (n.empty()) n="G4EllipticalTube";
439 
440  if (theEltube->getXHalfLength()<=0.){ ATH_MSG_WARNING("Eltube " << n << " has an x side of " << theEltube->getXHalfLength() <<" - using std::abs.");}
441  if (theEltube->getYHalfLength()<=0.){ ATH_MSG_WARNING("Eltube " << n << " has an y side of " << theEltube->getYHalfLength() <<" - using std::abs.");}
442  if (theEltube->getZHalfLength()<=0.){ ATH_MSG_WARNING("Eltube " << n << " has an z side of " << theEltube->getZHalfLength() <<" - using std::abs.");}
443  G4EllipticalTube* g4Eltube = new G4EllipticalTube(n
444  ,std::abs(theEltube->getXHalfLength())
445  ,std::abs(theEltube->getYHalfLength())
446  ,std::abs(theEltube->getZHalfLength()));
447  theSolid = g4Eltube;
448  }
449  //
450  // Torus
451  //
452  else if(geoShape->typeID() == GeoTorus::getClassTypeID() ) {
453  const GeoTorus* theTorus = dynamic_cast<const GeoTorus*> (geoShape);
454  if (nullptr==theTorus) throw std::runtime_error("TypeID did not match cast for torus");
455  if (n.empty()) n="G4Torus";
456 
457  theSolid = new G4Torus(n,
458  theTorus->getRMin(),
459  theTorus->getRMax(),
460  theTorus->getRTor(),
461  theTorus->getSPhi(),
462  theTorus->getDPhi());
463  }
464  //
465  // Generic Trap
466  //
467  else if(geoShape->typeID() == GeoGenericTrap::getClassTypeID()) {
468  const GeoGenericTrap* theGenTrap = dynamic_cast<const GeoGenericTrap*>(geoShape);
469  if (nullptr==theGenTrap) throw std::runtime_error("TypeID did not match cast for generic trap");
470  if (n.empty()) n="G4GenericTrap";
471  if (theGenTrap->getZHalfLength()<=0.){ ATH_MSG_WARNING("GenTrap " << n << " has an z side of " << theGenTrap->getZHalfLength() <<" - using std::abs.");}
472 
473  // Translate vector of vertices from Eigen to CLHEP
474  std::vector<CLHEP::Hep2Vector> clhepVertices;
475  clhepVertices.reserve(theGenTrap->getVertices().size());
476  for(const GeoTrf::Vector2D& geoVertex : theGenTrap->getVertices()) {
477  clhepVertices.push_back(CLHEP::Hep2Vector(geoVertex.x(),geoVertex.y()));
478  }
479 
480  G4GenericTrap* g4GenTrap = new G4GenericTrap(n
481  ,std::abs(theGenTrap->getZHalfLength())
482  ,clhepVertices);
483  theSolid = g4GenTrap;
484  }
485  //
486  // Boolean volumes
487  // We make use of G4DisplacedSolid which is not documented in the manual but makes the implementation
488  // a lot simpler.
489  //
490  // GeoShapeShift
491  //
492  else if (geoShape->typeID() == GeoShapeShift::getClassTypeID() )
493  {
494  const GeoShapeShift* theShapeShift = dynamic_cast<const GeoShapeShift*> (geoShape);
495  if (nullptr==theShapeShift) throw std::runtime_error("TypeID did not match cast for shape shift");
496  if (n.empty()) n="DisplacedSolid";
497  G4VSolid * undisplacedSolid = Build(theShapeShift->getOp());
498  theSolid = new G4DisplacedSolid(n, undisplacedSolid, Amg::EigenTransformToCLHEP(theShapeShift->getX()));
499  }
500  //
501  // GeoShapeUnion
502  //
503  else if (geoShape->typeID() == GeoShapeUnion::getClassTypeID() )
504  {
505  const GeoShapeUnion* theUnion = dynamic_cast<const GeoShapeUnion*> (geoShape);
506  if (nullptr==theUnion) throw std::runtime_error("TypeID did not match cast for union");
507  if (n.empty()) n="Union";
508  solidA = Build(theUnion->getOpA());
509  solidB = Build(theUnion->getOpB());
510  theSolid = new G4UnionSolid(n, solidA, solidB);
511  }
512  //
513  // GeoShapeIntersection
514  //
515  else if (geoShape->typeID() == GeoShapeIntersection::getClassTypeID() )
516  {
517  const GeoShapeIntersection* theIntersection = dynamic_cast<const GeoShapeIntersection*>(geoShape);
518  if (nullptr==theIntersection) throw std::runtime_error("TypeID did not match cast for intersection");
519  if (n.empty()) n="Intersection";
520  solidA = Build(theIntersection->getOpA());
521  solidB = Build(theIntersection->getOpB());
522  theSolid = new G4IntersectionSolid(n, solidA, solidB);
523  }
524  //
525  // GeoShapeSubtraction
526  //
527  else if (geoShape->typeID() == GeoShapeSubtraction::getClassTypeID() )
528  {
529  const GeoShapeSubtraction* theSubtraction = dynamic_cast<const GeoShapeSubtraction*>(geoShape);
530  if (nullptr==theSubtraction) throw std::runtime_error("TypeID did not match cast for subtraction");
531  if (n.empty()) n="Subtraction";
532  solidA = Build(theSubtraction->getOpA());
533  solidB = Build(theSubtraction->getOpB());
534  theSolid = new G4SubtractionSolid(n, solidA, solidB);
535  }
536  //
537  // Custom Shapes (presently LAr shapes only)
538  //
539  else if(geoShape->typeID() == GeoUnidentifiedShape::getClassTypeID())
540  {
541  const GeoUnidentifiedShape* customShape = dynamic_cast<const GeoUnidentifiedShape*> (geoShape);
542  if (nullptr==customShape) throw std::runtime_error("TypeID did not match cast for custom shape");
543  if (customShape->name()=="LArCustomShape") {
544 
545 
546 
547  ISvcLocator* svcLocator = Gaudi::svcLocator();
548  // Access the GeoModelSvc:
549  IGeoModelSvc *geoModel=0;
550  if (svcLocator->service ("GeoModelSvc",geoModel) !=StatusCode::SUCCESS) {
551  G4Exception(
552  "Geo2G4SolidFactory", "AccessGeoModel", FatalException,
553  "Build cannot access GeoModelSvc");
554  }
555  IGeoDbTagSvc *geoDbTagSvc(nullptr);
556  if ( svcLocator->service ("GeoDbTagSvc",geoDbTagSvc)!=StatusCode::SUCCESS ) {
557  G4Exception(
558  "Geo2G4SolidFactory", "AccessDbTagSvc", FatalException,
559  "Build cannot access DbTagSvc");
560  }
561  // Access the geometry database:
562  IRDBAccessSvc *pAccessSvc=0;
563  if ( svcLocator->service(geoDbTagSvc->getParamSvcName(),pAccessSvc)!=StatusCode::SUCCESS) {
564  G4Exception(
565  "Geo2G4SolidFactory", "AccessAccessSvc", FatalException,
566  "Build cannot access AccessSvc");
567  }
568  DecodeVersionKey larVersionKey(geoModel, "LAr");
569  EMECData emecData=toEMECData(pAccessSvc,larVersionKey);
570 
571 
572 
573  std::string customName = customShape->asciiData();
574  customSolidMap::const_iterator it = customSolids.find(customName);
575  if(it!=customSolids.end())
576  theSolid = it->second;
577  else
578  {
579  theSolid = nullptr;
580  if(customName.find("Slice") != std::string::npos){
581  theSolid = createLArWheelSliceSolid(customShape,emecData);
582  } else {
583  theSolid = createLArWheelSolid(customName, s_lwsTypes.at(customName) ,emecData); // map.at throws std::out_of_range exception on unknown shape name
584  }
585  if ( nullptr == theSolid ) {
586  std::string error = std::string("Can't create LArWheelSolid for name ") + customName + " in Geo2G4SolidFactory::Build";
587  throw std::runtime_error(error);
588  }
589 
590  if(theSolid != nullptr) customSolids[customName] = theSolid;
591  }
592  }
593  }
594  //
595  // Catch All
596  //
597  else
598  {
599  ATH_MSG_FATAL("Sorry this solid is not yet implemented... ");
600  ATH_MSG_FATAL(geoShape->type());
601  ATH_MSG_FATAL("You will have a core dump...");
602  return nullptr;
603  }
604 
605  sharedShapes[geoShape] = theSolid;
606  return theSolid;
607 }

◆ ATLAS_NOT_THREAD_SAFE() [2/3]

G4VSolid* Geo2G4SolidFactory::createLArWheelSliceSolid ATLAS_NOT_THREAD_SAFE ( const GeoUnidentifiedShape *  customShape,
const EMECData emecData 
) const

Definition at line 624 of file Geo2G4SolidFactory.cxx.

625 {
626  LArWheelSliceSolid *theLWS = new LArWheelSliceSolid(customShape->asciiData(),&emecData);
627 
628  LArWheelSolidDDProxy *theLWS_p = new LArWheelSolidDDProxy(theLWS);
629  // ownership is passed to detStore
630  if(m_detStore->record(theLWS_p, theLWS->GetName()).isFailure()){
631  ATH_MSG_WARNING("Can't store proxy for LArWheelSolid to the DetectorStore");
632  delete theLWS_p;
633  }
634  return theLWS;
635 }

◆ ATLAS_NOT_THREAD_SAFE() [3/3]

G4VSolid* Geo2G4SolidFactory::createLArWheelSolid ATLAS_NOT_THREAD_SAFE ( const std::string &  name,
const LArWheelSolidDef_t &  lwsdef,
const EMECData emecData 
) const

Definition at line 609 of file Geo2G4SolidFactory.cxx.

609  { // LArWheelSolid_t wheelType, int zside
610  LArWheelSolid_t wheelType = lwsdef.first;
611  int zside = lwsdef.second;
612 
613  LArWheelSolid * theLWS = new LArWheelSolid(name, wheelType, zside,nullptr, &emecData);
614 
615  LArWheelSolidDDProxy * theLWS_p = new LArWheelSolidDDProxy(theLWS);
616  // ownership is passed to detStore
617  if ( m_detStore->record(theLWS_p, name).isFailure() ) {
618  ATH_MSG_WARNING("Can't store proxy for LArWheelSolid to the DetectorStore");
619  delete theLWS_p;
620  }
621  return theLWS;
622 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
NSWL1::nVertices
int nVertices(const Polygon &p)
Definition: GeoUtils.cxx:35
IGeoModelSvc
Definition: IGeoModelSvc.h:17
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
index
Definition: index.py:1
EMECData
Definition: EMECData.h:131
skel.it
it
Definition: skel.GENtoEVGEN.py:423
LArWheelSolid_t
LArWheelSolid_t
Definition: LArWheelSolid_type.h:12
deg
#define deg
Definition: SbPolyhedron.cxx:17
Amg::EigenToHep3Vector
CLHEP::Hep3Vector EigenToHep3Vector(const Amg::Vector3D &eigenvector)
Converts an Eigen-based Amg::Vector3D into a CLHEP-based CLHEP::Hep3Vector.
Definition: CLHEPtoEigenConverter.h:147
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
IRDBAccessSvc
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
Definition: IRDBAccessSvc.h:45
DecodeVersionKey
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
Definition: DecodeVersionKey.h:18
shapesMap
std::map< const GeoShape *, G4VSolid *, std::less< const GeoShape * > > shapesMap
Definition: Geo2G4SolidFactory.cxx:75
IGeoDbTagSvc
Definition: IGeoDbTagSvc.h:26
LArWheelSolidDDProxy
Definition: LArWheelSolidDDProxy.h:17
LArWheelSolid
Definition: LArWheelSolid.h:94
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::vertexType
vertexType
Definition: Vertex_v1.cxx:166
DeMoScan.index
string index
Definition: DeMoScan.py:362
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
toEMECData
EMECData toEMECData(IRDBAccessSvc *rdbAccess, const DecodeVersionKey &larVersionKey)
Definition: toEMECData.h:14
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
LArWheelSliceSolid
Definition: LArWheelSliceSolid.h:46
error
Definition: IImpactPoint3dEstimator.h:70
customSolidMap
std::map< std::string, G4VSolid *, std::less< std::string > > customSolidMap
Definition: Geo2G4SolidFactory.cxx:76