Belle II Software development
CLAWSCreator Class Reference

The creator for the CLAWS geometry. More...

#include <CLAWSCreator.h>

Inheritance diagram for CLAWSCreator:
CreatorBase

Public Member Functions

 CLAWSCreator (Simulation::SensitiveDetectorBase *sensitive=nullptr)
 Constructor.
 
virtual ~CLAWSCreator ()
 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 CLAWS geometry.

Definition at line 29 of file CLAWSCreator.h.

Constructor & Destructor Documentation

◆ CLAWSCreator()

CLAWSCreator ( Simulation::SensitiveDetectorBase sensitive = nullptr)

Constructor.

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

Definition at line 36 of file CLAWSCreator.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: CLAWSCreator.h:62

◆ ~CLAWSCreator()

~CLAWSCreator ( )
virtual

Destructor.

Definition at line 43 of file CLAWSCreator.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: CLAWSCreator.h:66

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 130 of file CLAWSCreator.cc.

131 {
132 m_topMaterial = topVolume.GetMaterial();
133 double stepLength = content.getLength("stepLength", 0) / Unit::mm * CLHEP::mm;
134 if (stepLength > 0) {
135 if (m_stepLength) delete m_stepLength;
136 m_stepLength = new G4UserLimits(stepLength);
137 }
138 for (auto shape : content.getNodes("shape")) {
139 createShape("", shape, &topVolume, 0, false);
140 }
141 }
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: CLAWSCreator.cc:49
G4Material * m_topMaterial
pointer to the material in the top volume to use as default
Definition: CLAWSCreator.h:64

◆ 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 CLAWSCreator.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 std::vector<double> ri = params.getArray("r", {0});
64 int phase = 0;
65 if (ri.size() > 1) phase = 1;
66
67 //const double r = params.getLength("r", 0) / Unit::mm * CLHEP::mm;
68 const double top = params.getLength("top", 0) / Unit::mm * CLHEP::mm;
69 const double u = params.getLength("u", 0) / Unit::mm * CLHEP::mm;
70 const bool active = params.getBool("active", false);
71
72 G4Material* mat = m_topMaterial;
73 if (!material.empty()) {
74 mat = geometry::Materials::get(material);
75 }
76 G4VSolid* shape{nullptr};
77 double height{0};
78 if (type == "box") {
79 const double length = params.getLength("length") / Unit::mm * CLHEP::mm;
80 const double width = params.getLength("width") / Unit::mm * CLHEP::mm;
81 height = params.getLength("height") / Unit::mm * CLHEP::mm;
82 shape = new G4Box(name, width / 2, height / 2, length / 2);
83 } else if (type == "tube") {
84 const double length = params.getLength("length") / Unit::mm * CLHEP::mm;
85 height = params.getLength("diameter") / Unit::mm * CLHEP::mm;
86 shape = new G4Tubs(name, 0, height / 2, length / 2, 0, 2 * M_PI);
87 }
88 G4LogicalVolume* volume = new G4LogicalVolume(shape, mat, name);
89 if (active) {
90 volume->SetSensitiveDetector(m_sensitive);
91 if (m_stepLength) {
92 volume->SetUserLimits(m_stepLength);
93 }
94 }
95 for (const GearDir& child : params.getNodes("shape")) {
96 createShape(name, child, volume, height / 2, true);
97 }
98
99 int copyNo = 1;
100
101 if (!phase) {
102 double center = ri[0] / Unit::mm * CLHEP::mm + roffset - height / 2 - top;
103 //center *=CLHEP::mm / Unit::mm;
104 for (double phi : params.getArray("phi", {M_PI / 2})) {
105 for (double z : params.getArray("z", {0})) {
106 z *= CLHEP::mm / Unit::mm;
107 G4Transform3D transform = G4RotateZ3D(phi - M_PI / 2) * G4Translate3D(u, center, z);
108 new G4PVPlacement(transform, volume, name, parent, false, copyNo++, check);
109 }
110 }
111 } else {
112 int i = 0;
113 std::vector<double> alpha = params.getArray("alpha", {0});
114 for (double z : params.getArray("z", {0})) {
115 double center = ri[i] / Unit::mm * CLHEP::mm + roffset - height / 2 - top;
116 // center *= CLHEP::mm / Unit::mm;
117 z *= CLHEP::mm / Unit::mm;
118 for (double phi : params.getArray("phi", {M_PI / 2})) {
119 G4Transform3D transform = G4RotateZ3D(phi - M_PI / 2) * G4Translate3D(u, center, z) * G4RotateY3D(alpha[i]);
120 new G4PVPlacement(transform, volume, name, parent, false, copyNo++, check);
121 }
122 i++;
123 }
124
125 }
126 }
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 62 of file CLAWSCreator.h.

◆ m_stepLength

G4UserLimits* m_stepLength {nullptr}
protected

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

Definition at line 66 of file CLAWSCreator.h.

◆ m_topMaterial

G4Material* m_topMaterial {nullptr}
protected

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

Definition at line 64 of file CLAWSCreator.h.


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