Belle II Software development
FANGSCreator Class Reference

The creator for the FANGS geometry. More...

#include <FANGSCreator.h>

Inheritance diagram for FANGSCreator:
CreatorBase

Public Member Functions

 FANGSCreator (Simulation::SensitiveDetectorBase *sensitive=nullptr)
 Constructor.
 
virtual ~FANGSCreator ()
 Destructor.
 
void createShape (const std::string &prefix, const GearDir &params, G4LogicalVolume *parent, double roffset, bool check)
 create a shape (box or cylinder) from XML description and place all child shapes in it by recursively calling this function for all children.
 
virtual void create (const GearDir &content, G4LogicalVolume &topVolume, geometry::GeometryTypes type)
 Creation of the detector geometry from Gearbox (XML).
 
 BELLE2_DEFINE_EXCEPTION (DBNotImplemented, "Cannot create geometry from Database.")
 Exception that will be thrown in createFromDB if member is not yet implemented by creator.
 
virtual void createFromDB (const std::string &name, G4LogicalVolume &topVolume, GeometryTypes type)
 Function to create the geometry from the Database.
 
virtual void createPayloads (const GearDir &content, const IntervalOfValidity &iov)
 Function to create the geometry database.
 

Protected Attributes

Simulation::SensitiveDetectorBasem_sensitive {nullptr}
 pointer to the sensitive detector implementation
 
G4Material * m_topMaterial {nullptr}
 pointer to the material in the top volume to use as default
 
G4UserLimits * m_stepLength {nullptr}
 pointer to the G4Userlimits to set for sensitive volumes (if any)
 

Detailed Description

The creator for the FANGS geometry.

Definition at line 29 of file FANGSCreator.h.

Constructor & Destructor Documentation

◆ FANGSCreator()

FANGSCreator ( Simulation::SensitiveDetectorBase sensitive = nullptr)

Constructor.

Parameters
sensitivedetector instance to use, if null a fangs::SensitiveDetector instance will be created.

Definition at line 36 of file FANGSCreator.cc.

36 : m_sensitive(sensitive)
37 {
38 /*if (!m_sensitive) {
39 m_sensitive = new SensitiveDetector();
40 }*/
41 }
Simulation::SensitiveDetectorBase * m_sensitive
pointer to the sensitive detector implementation
Definition: FANGSCreator.h:61

◆ ~FANGSCreator()

~FANGSCreator ( )
virtual

Destructor.

Definition at line 43 of file FANGSCreator.cc.

44 {
45 delete m_sensitive;
46 delete m_stepLength;
47 }
G4UserLimits * m_stepLength
pointer to the G4Userlimits to set for sensitive volumes (if any)
Definition: FANGSCreator.h:65

Member Function Documentation

◆ create()

void create ( const GearDir content,
G4LogicalVolume &  topVolume,
geometry::GeometryTypes  type 
)
virtual

Creation of the detector geometry from Gearbox (XML).

Parameters
[in]contentXML data directory.
[in]topVolumeGeant world volume.
[in]typeGeometry type.

Implements CreatorBase.

Definition at line 106 of file FANGSCreator.cc.

107 {
108 m_topMaterial = topVolume.GetMaterial();
109 double stepLength = content.getLength("stepLength", 0) / Unit::mm * CLHEP::mm;
110 if (stepLength > 0) {
111 if (m_stepLength) delete m_stepLength;
112 m_stepLength = new G4UserLimits(stepLength);
113 }
114 for (auto shape : content.getNodes("shape")) {
115 createShape("", shape, &topVolume, 0, false);
116 }
117 }
static const double mm
[millimeters]
Definition: Unit.h:70
void createShape(const std::string &prefix, const GearDir &params, G4LogicalVolume *parent, double roffset, bool check)
create a shape (box or cylinder) from XML description and place all child shapes in it by recursively...
Definition: FANGSCreator.cc:49
G4Material * m_topMaterial
pointer to the material in the top volume to use as default
Definition: FANGSCreator.h:63

◆ createFromDB()

void createFromDB ( const std::string &  name,
G4LogicalVolume &  topVolume,
GeometryTypes  type 
)
virtualinherited

Function to create the geometry from the Database.

Parameters
namename of the component in the database, could be used to disambiguate multiple components created with the same creator
topVolumeTop volume in which the geometry has to be placed
typeType of geometry to be build

Reimplemented in GeoMagneticField, GeoARICHCreator, BeamabortCreator, GeoCDCCreator, GeoCDCCreatorReducedCDC, GeoECLCreator, MyDBCreator, GeoBeamPipeCreator, GeoCryostatCreator, GeoFarBeamLineCreator, GeoBKLMCreator, GeoEKLMCreator, GeoKLMCreator, GeoPXDCreator, GeoCOILCreator, GeoServiceMaterialCreator, GeoSTRCreator, GeoSVDCreator, GeoTOPCreator, GeoHeavyMetalShieldCreator, and GeoVXDServiceCreator.

Definition at line 17 of file CreatorBase.cc.

18 {
19 //Do nothing but raise exception that we don't do anything
20 throw DBNotImplemented();
21 }

◆ createPayloads()

void createPayloads ( const GearDir content,
const IntervalOfValidity iov 
)
virtualinherited

Function to create the geometry database.

This function should be implemented to convert Gearbox parameters to one ore more database payloads

Parameters
contentGearDir pointing to the parameters which should be used for construction
iovinterval of validity to use when generating payloads

Reimplemented in GeoARICHCreator, BeamabortCreator, GeoCDCCreator, GeoCDCCreatorReducedCDC, GeoECLCreator, GeoMagneticField, MyDBCreator, GeoBeamPipeCreator, GeoCryostatCreator, GeoFarBeamLineCreator, GeoBKLMCreator, GeoEKLMCreator, GeoKLMCreator, GeoPXDCreator, GeoCOILCreator, GeoServiceMaterialCreator, GeoSTRCreator, GeoSVDCreator, GeoTOPCreator, GeoHeavyMetalShieldCreator, and GeoVXDServiceCreator.

Definition at line 24 of file CreatorBase.cc.

24{}

◆ createShape()

void createShape ( const std::string &  prefix,
const GearDir params,
G4LogicalVolume *  parent,
double  roffset,
bool  check 
)

create a shape (box or cylinder) from XML description and place all child shapes in it by recursively calling this function for all children.

Parameters
prefixprefix of the volume names
paramsXML parameters
parentLogical Volume where to place the shape
roffsetradial offset for the placement
checkif true check for overlaps when placing the volumes

Definition at line 49 of file FANGSCreator.cc.

51 {
52
53 if (!m_sensitive) {
55 }
56
57 std::string name = params.getString("@name");
58 if (!prefix.empty()) {
59 name = prefix + "." + name;
60 }
61 const std::string type = params.getString("@type");
62 const std::string material = params.getString("material", "");
63 const double r = params.getLength("r", 0) / Unit::mm * CLHEP::mm;
64 const double top = params.getLength("top", 0) / Unit::mm * CLHEP::mm;
65 const double u = params.getLength("u", 0) / Unit::mm * CLHEP::mm;
66 const bool active = params.getBool("active", false);
67
68 G4Material* mat = m_topMaterial;
69 if (!material.empty()) {
70 mat = geometry::Materials::get(material);
71 }
72 G4VSolid* shape{nullptr};
73 double height{0};
74 if (type == "box") {
75 const double length = params.getLength("length") / Unit::mm * CLHEP::mm;
76 const double width = params.getLength("width") / Unit::mm * CLHEP::mm;
77 height = params.getLength("height") / Unit::mm * CLHEP::mm;
78 shape = new G4Box(name, width / 2, height / 2, length / 2);
79 } else if (type == "tube") {
80 const double length = params.getLength("length") / Unit::mm * CLHEP::mm;
81 height = params.getLength("diameter") / Unit::mm * CLHEP::mm;
82 shape = new G4Tubs(name, 0, height / 2, length / 2, 0, 2 * M_PI);
83 }
84 G4LogicalVolume* volume = new G4LogicalVolume(shape, mat, name);
85 if (active) {
86 volume->SetSensitiveDetector(m_sensitive);
87 if (m_stepLength) {
88 volume->SetUserLimits(m_stepLength);
89 }
90 }
91 for (const GearDir& child : params.getNodes("shape")) {
92 createShape(name, child, volume, height / 2, true);
93 }
94
95 int copyNo = 1;
96 const double center = r + roffset - height / 2 - top;
97 for (double phi : params.getArray("phi", {M_PI / 2})) {
98 for (double z : params.getArray("z", {0})) {
99 z *= CLHEP::mm / Unit::mm;
100 G4Transform3D transform = G4RotateZ3D(phi - M_PI / 2) * G4Translate3D(u, center, z);
101 new G4PVPlacement(transform, volume, name, parent, false, copyNo++, check);
102 }
103 }
104 }
static G4Material * get(const std::string &name)
Find given material.
Definition: Materials.h:63
VXD::SensitiveDetector< PXDSimHit, PXDTrueHit > SensitiveDetector
The PXD Sensitive Detector class.

Member Data Documentation

◆ m_sensitive

Simulation::SensitiveDetectorBase* m_sensitive {nullptr}
protected

pointer to the sensitive detector implementation

Definition at line 61 of file FANGSCreator.h.

◆ m_stepLength

G4UserLimits* m_stepLength {nullptr}
protected

pointer to the G4Userlimits to set for sensitive volumes (if any)

Definition at line 65 of file FANGSCreator.h.

◆ m_topMaterial

G4Material* m_topMaterial {nullptr}
protected

pointer to the material in the top volume to use as default

Definition at line 63 of file FANGSCreator.h.


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