Belle II Software development
GeoVXDCreator Class Referenceabstract

The creator for the VXD geometry of the Belle II detector. More...

#include <GeoVXDCreator.h>

Inheritance diagram for GeoVXDCreator:
CreatorBase GeoPXDCreator GeoSVDCreator

Public Member Functions

 GeoVXDCreator (const std::string &prefix)
 Constructor of the GeoVXDCreator class.
 
virtual ~GeoVXDCreator ()
 The destructor of the GeoVXDCreator class.
 
virtual SensorInfoBasecreateSensorInfo (const VXDGeoSensorPar &sensor)=0
 Read the sensor definitions from the database.
 
virtual SensitiveDetectorBasecreateSensitiveDetector (VxdID sensorID, const VXDGeoSensor &sensor, const VXDGeoSensorPlacement &placement)=0
 Return a SensitiveDetector implementation for a given sensor.
 
virtual void setCurrentLayer (int layer, const VXDGeometryPar &parameters)
 Read parameters for given layer and store in m_ladder.
 
G4Transform3D placeLadder (int ladderID, double phi, G4LogicalVolume *volume, const G4Transform3D &placement, const VXDGeometryPar &parameters)
 Place ladder corresponding to the given ladder id into volume setLayer has to be called first to set the correct layer id.
 
G4Transform3D getPosition (const VXDGeoComponent &mother, const VXDGeoComponent &daughter, const VXDGeoPlacement &placement, bool originCenter)
 Return the position where a daughter component is to be placed.
 
G4Transform3D getAlignment (const VXDAlignmentPar &params)
 Get Alignment from paylead object.
 
GeoVXDAssembly createSubComponents (const std::string &name, VXDGeoComponent &component, std::vector< VXDGeoPlacement > placements, bool originCenter=true, bool allowOutside=false)
 Place a list of subcomponents into an component.
 
G4VSolid * createTrapezoidal (const std::string &name, double width, double width2, double length, double &height, double angle=0)
 Create a trapezoidal solid.
 
void createDiamonds (const VXDGeoRadiationSensorsPar &params, G4LogicalVolume &topVolume, G4LogicalVolume &envelopeVolume)
 Create diamond radiation sensors.
 
std::vector< VXDGeoPlacementPargetSubComponents (const GearDir &path)
 Return vector of VXDGeoPlacements with all the components defined inside a given path.
 
virtual void readLadder (int layer, GearDir components, VXDGeometryPar &geoparameters)
 Read parameters for a ladder in layer with given ID from gearbox and layer store them in payload.
 
virtual void readLadderComponents (int layerID, int ladderID, GearDir content, VXDGeometryPar &vxdGeometryPar)
 Read parameters for ladder components and their alignment corresponding to the given ladder id.
 
void readComponent (const std::string &name, GearDir components, VXDGeometryPar &vxdGeometryPar)
 Read parameters for component name from Gearbox into geometry payload.
 
void readSubComponents (const std::vector< VXDGeoPlacementPar > &placements, const GearDir &componentsDir, VXDGeometryPar &vxdGeometryPar)
 Read parameters for all components in placement container from Gearbox into payload.
 
 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 create (const GearDir &content, G4LogicalVolume &topVolume, GeometryTypes type)=0
 Function to actually create the geometry, has to be overridden by derived classes.
 
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

std::string m_prefix
 Prefix to prepend to all volume names.
 
GearDir m_alignment
 GearDir pointing to the alignment parameters.
 
GearDir m_components
 GearDir pointing to the toplevel of the components.
 
std::map< std::string, VXDGeoComponentm_componentCache
 Cache of all previously created components.
 
std::map< std::string, VXDGeoSensorm_sensorMap
 Map containing Information about all defined sensor types.
 
VXDGeoLadder m_ladder
 Parameters of the currently active ladder.
 
std::vector< Simulation::SensitiveDetectorBase * > m_sensitive
 List to all created sensitive detector instances.
 
GeoVXDRadiationSensors m_radiationsensors
 Diamond radiation sensor "sub creator".
 
std::string m_defaultMaterial
 Name of the Material to be used for Air.
 
float m_distanceTolerance {(float)(5 * Unit::um)}
 tolerance for Geant4 steps to be merged to a single step
 
float m_electronTolerance {100}
 tolerance for the energy deposition in electrons to be merged in a single step
 
float m_minimumElectrons {10}
 minimum number of electrons to be deposited by a particle to be saved
 
double m_activeStepSize {5 * Unit::um}
 Stepsize to be used inside active volumes.
 
bool m_activeChips {false}
 Make also chips sensitive.
 
bool m_seeNeutrons {false}
 Make sensitive detectors also see neutrons.
 
bool m_onlyPrimaryTrueHits {false}
 If true only create TrueHits from primary particles and ignore secondaries.
 
bool m_onlyActiveMaterial {false}
 If this is true, only active Materials will be placed for tracking studies.
 
std::vector< G4UserLimits * > m_UserLimits
 Vector of G4UserLimit pointers.
 
std::string m_currentHalfShell {""}
 Current half-shell being processed (need to know ladder parent for hierarchy)
 
std::map< std::string, Belle2::VxdIDm_halfShellVxdIDs
 Used for translation of half-shell name into a VxdID to consitently handle it in hierarchy.
 

Detailed Description

The creator for the VXD geometry of the Belle II detector.


Definition at line 48 of file GeoVXDCreator.h.

Constructor & Destructor Documentation

◆ GeoVXDCreator()

GeoVXDCreator ( const std::string &  prefix)
explicit

Constructor of the GeoVXDCreator class.

Definition at line 54 of file GeoVXDCreator.cc.

54 : m_prefix(prefix), m_radiationsensors(prefix)
55 {
56 m_UserLimits.clear();
57 }
GeoVXDRadiationSensors m_radiationsensors
Diamond radiation sensor "sub creator".
std::string m_prefix
Prefix to prepend to all volume names.
std::vector< G4UserLimits * > m_UserLimits
Vector of G4UserLimit pointers.

◆ ~GeoVXDCreator()

~GeoVXDCreator ( )
virtual

The destructor of the GeoVXDCreator class.

Definition at line 59 of file GeoVXDCreator.cc.

60 {
61 //Lets assume that it cannot be that only one part of the vxd gets destroyed
62 // FIXME: This causes problems: VXD::GeoCache::getInstance().clear();
63 //Delete all sensitive detectors
64 for (Simulation::SensitiveDetectorBase* sensitive : m_sensitive) {
65 delete sensitive;
66 }
67 m_sensitive.clear();
68
69 for (G4UserLimits* userLimit : m_UserLimits) delete userLimit;
70 m_UserLimits.clear();
71
72 }
std::vector< Simulation::SensitiveDetectorBase * > m_sensitive
List to all created sensitive detector instances.

Member Function Documentation

◆ create()

virtual void create ( const GearDir content,
G4LogicalVolume &  topVolume,
GeometryTypes  type 
)
pure virtualinherited

◆ createDiamonds()

void createDiamonds ( const VXDGeoRadiationSensorsPar params,
G4LogicalVolume &  topVolume,
G4LogicalVolume &  envelopeVolume 
)

Create diamond radiation sensors.

Definition at line 209 of file GeoVXDCreator.cc.

211 {
212 //Set the correct top volume to either global top or detector envelope
213 G4LogicalVolume* top = &topVolume;
214 if (params.getInsideEnvelope()) {
215 top = &envelopeVolume;
216 }
217
218 //shape and material are the same for all sensors so create them now
219 const double width = params.getWidth();
220 const double length = params.getLength();
221 const double height = params.getHeight();
222 G4Box* shape = 0;
223 G4Material* material = geometry::Materials::get(params.getMaterial());
224
225 //Now loop over all positions
226 const std::vector<VXDGeoRadiationSensorsPositionPar>& Positions = params.getPositions();
227 for (const VXDGeoRadiationSensorsPositionPar& position : Positions) {
228 //get the radial and z position
229 const double r = position.getRadius();
230 const double z = position.getZ();
231 const double theta = position.getTheta();
232 //and loop over all phi positions
233 const std::map<int, double>& Sensors = position.getSensors();
234 for (const std::pair<const int, double>& sensor : Sensors) {
235 //for (GearDir& sensor : position.getNodes("phi")) {
236 //we need angle and Id
237 const double phi = sensor.second;
238 const int id = sensor.first;
239 //then we create a nice name
240 const std::string name = params.getSubDetector() + ".DiamondSensor." + std::to_string(id);
241 //and create the sensor volume
242 if (not shape) shape = new G4Box("radiationSensorDiamond", width / 2 * CLHEP::cm, length / 2 * CLHEP::cm, height / 2 * CLHEP::cm);
243 G4LogicalVolume* volume = new G4LogicalVolume(shape, material, name);
244 //add a sensitive detector implementation
245 BkgSensitiveDetector* sensitive = new BkgSensitiveDetector(params.getSubDetector().c_str(), id);
246 volume->SetSensitiveDetector(sensitive);
247 //and place it at the correct position
248 G4Transform3D transform = G4RotateZ3D(phi - M_PI / 2) * G4Translate3D(0, r * CLHEP::cm,
249 z * CLHEP::cm) * G4RotateX3D(-M_PI / 2 - theta);
250 new G4PVPlacement(transform, volume, name, top, false, 1);
251 }
252 }
253 }
static G4Material * get(const std::string &name)
Find given material.
Definition: Materials.h:63
std::map< VxdID, Sensor > Sensors
Map of all hits in all Sensors.

◆ 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{}

◆ createSensitiveDetector()

virtual SensitiveDetectorBase * createSensitiveDetector ( VxdID  sensorID,
const VXDGeoSensor sensor,
const VXDGeoSensorPlacement placement 
)
pure virtual

Return a SensitiveDetector implementation for a given sensor.

Parameters
sensorIDSensorID for the sensor
sensorInformation about the sensor to create the Sensitive Detector for
placementPlacement of the sensor

Implemented in GeoPXDCreator, and GeoSVDCreator.

◆ createSensorInfo()

virtual SensorInfoBase * createSensorInfo ( const VXDGeoSensorPar sensor)
pure virtual

Read the sensor definitions from the database.

Parameters
sensorReference to the database containing the parameters

Implemented in GeoPXDCreator, and GeoSVDCreator.

◆ createSubComponents()

GeoVXDAssembly createSubComponents ( const std::string &  name,
VXDGeoComponent component,
std::vector< VXDGeoPlacement placements,
bool  originCenter = true,
bool  allowOutside = false 
)

Place a list of subcomponents into an component.

If the volume of the given component is NULL, a new container will be created to fit all subcomponents. It will have air as medium. If at least one subcomponent with this placement is found the whole component is wrapped in a container volume with Air medium which extends above and below to fit the subcomponents

Parameters
nameName for the potential new volume or as prefix for the container to extend the component
componentComponent to fit the subcomponents into
placementsPlacement information for all subcomponents
originCenterbool
allowOutsidebool
Returns
offset in w which was applied to the component when extending it

Definition at line 74 of file GeoVXDCreator.cc.

76 {
77 GeoVXDAssembly assembly;
78 B2DEBUG(100, "Creating component " << name);
79 vector<VXDGeoComponent> subComponents;
80 subComponents.reserve(placements.size());
81 //Go over all subcomponents and check if they will fit inside.
82 //If component.volume is zero we will create one so sum up needed space
83 bool widthResize = component.getWidth() <= 0;
84 bool lengthResize = component.getLength() <= 0;
85 bool heightResize = component.getHeight() <= 0;
86
87 for (VXDGeoPlacement& p : placements) {
88 //Test component already exists
89 if (m_componentCache.find(p.getName()) == m_componentCache.end()) {
90 B2FATAL("A component is requested that was not created before!");
91 }
92 VXDGeoComponent sub = m_componentCache[p.getName()];
93
94 B2DEBUG(100, "SubComponent " << p.getName());
95 B2DEBUG(100, boost::format("Placement: u:%1% cm, v:%2% cm, w:%3% + %4% cm") % p.getU() % p.getV() % p.getW() % p.getWOffset());
96 B2DEBUG(100, boost::format("Dimensions: %1%x%2%x%3% cm") % sub.getWidth() % sub.getLength() % sub.getHeight());
97
98 if (p.getW() == VXDGeoPlacement::c_above || p.getW() == VXDGeoPlacement::c_below) {
99 //Below placement only valid if we are allowed to create a container around component
100 if (!allowOutside) B2FATAL("Cannot place component " << p.getName() << " outside of component " << name);
101 } else if (sub.getHeight() + p.getWOffset() > component.getHeight()) {
102 //Component will not fit heightwise. If we resize the volume anyway than we don't have problems
103 if (!heightResize) {
104 B2FATAL("Subcomponent " << p.getName() << " does not fit into volume: "
105 << "height " << sub.getHeight() << " > " << component.getHeight());
106 }
107 component.getHeight() = sub.getHeight() + p.getWOffset();
108 }
109
110 //Check if compoent will fit inside width,length. If we can resize do it if needed, otherwise bail
111 double minWidth = max(abs(p.getU() + sub.getWidth() / 2.0), abs(p.getU() - sub.getWidth() / 2.0));
112 double minLength = max(abs(p.getV() + sub.getLength() / 2.0), abs(p.getV() - sub.getLength() / 2.0));
113 if (minWidth > component.getWidth() + component.getWidth() * numeric_limits<double>::epsilon()) {
114 if (!widthResize) {
115 B2FATAL("Subcomponent " << p.getName() << " does not fit into volume: "
116 << "minWidth " << minWidth << " > " << component.getWidth());
117 }
118 component.setWidth(minWidth * 2.0);
119 }
120 if (minLength > component.getLength() + component.getLength() * numeric_limits<double>::epsilon()) {
121 if (!lengthResize) {
122 B2FATAL("Subcomponent " << p.getName() << " does not fit into volume: "
123 << "minLength " << minLength << " > " << component.getLength());
124 }
125 component.setLength(minLength * 2.0);
126 }
127 subComponents.push_back(sub);
128 }
129
130 //zero dimensions are fine mathematically but we don't want them in the simulation
131 if (component.getWidth() <= 0 || component.getLength() <= 0 || component.getHeight() <= 0) {
132 B2FATAL("At least one dimension of component " << name << " is zero which does not make sense");
133 }
134
135 //No volume yet, create a new one automatically assuming air material
136 if (!component.getVolume()) {
137 G4VSolid* componentShape = createTrapezoidal(name, component.getWidth(), component.getWidth2(), component.getLength(),
138 component.getHeight());
139 component.setVolume(new G4LogicalVolume(componentShape, Materials::get(component.getMaterial()), name));
140 }
141
142 B2DEBUG(100, boost::format("Component %1% dimensions: %2%x%3%x%4% cm") % name % component.getWidth() % component.getLength() %
143 component.getHeight());
144
145 //Ok, all volumes set up, now add them together
146 for (size_t i = 0; i < placements.size(); ++i) {
147 VXDGeoPlacement& p = placements[i];
148 VXDGeoComponent& s = subComponents[i];
149
150 G4Transform3D transform = getPosition(component, s, p, originCenter);
151 if (p.getW() == VXDGeoPlacement::c_below || p.getW() == VXDGeoPlacement::c_above) {
152 //Add to selected mother (either component or container around component
153 assembly.add(s.getVolume(), transform);
154 } else {
155 new G4PVPlacement(transform, s.getVolume(), name + "." + p.getName(), component.getVolume(), false, i);
156 }
157 }
158
159 //Set some visibility options for volume. Done here because all components including sensor go through here
160 if (component.getColor().empty()) {
161 B2DEBUG(200, "Component " << name << " is an Air volume, setting invisible");
162 setVisibility(*component.getVolume(), false);
163 } else {
164 B2DEBUG(200, "Component " << name << " color: " << component.getColor());
165 setColor(*component.getVolume(), component.getColor());
166 }
167 B2DEBUG(100, "--> Created component " << name);
168 //Return the difference in W between the origin of the original component and the including container
169 return assembly;
170 }
@ c_above
Place the component above the mother.
@ c_below
Place the component below the mother.
G4VSolid * createTrapezoidal(const std::string &name, double width, double width2, double length, double &height, double angle=0)
Create a trapezoidal solid.
G4Transform3D getPosition(const VXDGeoComponent &mother, const VXDGeoComponent &daughter, const VXDGeoPlacement &placement, bool originCenter)
Return the position where a daughter component is to be placed.
std::map< std::string, VXDGeoComponent > m_componentCache
Cache of all previously created components.
void setVisibility(G4LogicalVolume &volume, bool visible)
Helper function to quickly set the visibility of a given volume.
Definition: utilities.cc:108
void setColor(G4LogicalVolume &volume, const std::string &color)
Set the color of a logical volume.
Definition: utilities.cc:100

◆ createTrapezoidal()

G4VSolid * createTrapezoidal ( const std::string &  name,
double  width,
double  width2,
double  length,
double &  height,
double  angle = 0 
)

Create a trapezoidal solid.

Parameters
namename of the Geant4 solid
widthfull forward width of the shape in mm
width2full backward width of the shape in mm
lengthlength of the shape in mm
[in,out]heightof the shape in mm. If angle is not 0 this value might be changed if the actual height will be smaller due to the slanted edges
angleangle of the sides along w with respect to to the uv plane. 0 means normal box shaped, !=0 means the upper endcap of the solid will be smaller since all edges will be slanted by angle
Returns
A G4VShape which could be a G4Box, a G4Trd or a G4Trap depending on the parameters

Definition at line 255 of file GeoVXDCreator.cc.

257 {
258 double offset(0);
259 if (angle > 0) {
260 const double tana = tan(angle);
261 height = min(tana * length, min(tana * width, height));
262 offset = height / tana;
263 }
264 const double hwidth = width / 2.0;
265 const double hwidth2 = width2 / 2.0;
266 const double hlength = length / 2.0;
267 const double hheight = height / 2.0;
268
269 if (width2 <= 0 || width == width2) {
270 if (angle <= 0) {
271 return new G4Box(name, hwidth, hlength, hheight);
272 } else {
273 return new G4Trd(name, hwidth, hwidth - offset, hlength, hlength - offset, hheight);
274 }
275 }
276 //FIXME: offset not working, g4 complains about nonplanarity of face -X. But we do not need that shape at the moment
277 //so lets ignore it for now
278 return new G4Trap(name, hheight, 0, 0, hlength, hwidth, hwidth2, 0, hlength - offset, hwidth - offset, hwidth2 - offset, 0);
279 }

◆ getAlignment()

G4Transform3D getAlignment ( const VXDAlignmentPar params)

Get Alignment from paylead object.

Parameters
paramsPayload object
Returns
Transformation matrix for component

Definition at line 172 of file GeoVXDCreator.cc.

173 {
174 G4RotationMatrix rotation(params.getAlpha(), params.getBeta(), params.getGamma());
175 G4ThreeVector translation(params.getDU() / Unit::mm, params.getDV() / Unit::mm, params.getDW() / Unit::mm);
176 return G4Transform3D(rotation, translation);
177 }
static const double mm
[millimeters]
Definition: Unit.h:70

◆ getPosition()

G4Transform3D getPosition ( const VXDGeoComponent mother,
const VXDGeoComponent daughter,
const VXDGeoPlacement placement,
bool  originCenter 
)

Return the position where a daughter component is to be placed.

Parameters
motherMother component
daughterDaughter component
placementVXDGeoPlacement
originCenterbool
Returns
Transformation matrix to place the daughter relative to the origin to the mother

Definition at line 179 of file GeoVXDCreator.cc.

181 {
182 double u(placement.getU()), v(placement.getV()), w(0);
183 switch (placement.getW()) {
184 case VXDGeoPlacement::c_below: //Place below component
185 w = - mother.getHeight() / 2.0 - daughter.getHeight() / 2.0;
186 break;
187 case VXDGeoPlacement::c_bottom: //Place inside, at bottom of component
188 w = - mother.getHeight() / 2.0 + daughter.getHeight() / 2.0;
189 break;
190 case VXDGeoPlacement::c_center: //Place inside, centered
191 w = 0;
192 break;
193 case VXDGeoPlacement::c_top: //Place inside, at top of mother
194 w = mother.getHeight() / 2.0 - daughter.getHeight() / 2.0;
195 break;
196 case VXDGeoPlacement::c_above: //Place above mother
197 w = mother.getHeight() / 2.0 + daughter.getHeight() / 2.0;
198 break;
199 }
200 if (!originCenter) { //Sensor has coordinate origin in the corner, all submothers at their center
201 u -= mother.getWidth() / 2.0;
202 v -= mother.getLength() / 2.0;
203 }
204 return G4Translate3D(u, v, w + placement.getWOffset());
205 }
@ c_bottom
Place the component at the bottom of the mother.
@ c_center
Place the component at the center of the mother.
@ c_top
Place the component at the top of the mother.

◆ getSubComponents()

std::vector< VXDGeoPlacementPar > getSubComponents ( const GearDir path)

Return vector of VXDGeoPlacements with all the components defined inside a given path.

Definition at line 606 of file GeoVXDCreator.cc.

607 {
608 vector<VXDGeoPlacementPar> result;
609 for (const GearDir& component : path.getNodes("Component")) {
610 string type;
611 if (!component.exists("@type")) {
612 type = component.getString("@name");
613 } else {
614 type = component.getString("@type");
615 }
616 int nPos = max(component.getNumberNodes("u"), component.getNumberNodes("v"));
617 nPos = max(nPos, component.getNumberNodes("w"));
618 nPos = max(nPos, component.getNumberNodes("woffset"));
619 for (int iPos = 1; iPos <= nPos; ++iPos) {
620 string index = (boost::format("[%1%]") % iPos).str();
621 result.push_back(VXDGeoPlacementPar(
622 type,
623 component.getLength("u" + index, 0),
624 component.getLength("v" + index, 0),
625 component.getString("w" + index, "bottom"),
626 component.getLength("woffset" + index, 0)
627 ));
628 }
629 }
630 return result;
631 }

◆ placeLadder()

G4Transform3D placeLadder ( int  ladderID,
double  phi,
G4LogicalVolume *  volume,
const G4Transform3D &  placement,
const VXDGeometryPar parameters 
)

Place ladder corresponding to the given ladder id into volume setLayer has to be called first to set the correct layer id.

Definition at line 281 of file GeoVXDCreator.cc.

284 {
285 VxdID ladder(m_ladder.getLayerID(), ladderID, 0);
286
287 G4Translate3D ladderPos(m_ladder.getRadius(), m_ladder.getShift(), 0);
288 G4Transform3D ladderPlacement = placement * G4RotateZ3D(phi) * ladderPos * getAlignment(parameters.getAlignment(ladder));
289 // The actuall coordinate system of ladder (w still points to Z, there is only phi rotation + move to correct radius + shift)
291
292
293 vector<G4Point3D> lastSensorEdge;
294 for (const VXDGeoSensorPlacement& p : m_ladder.getSensors()) {
295 VxdID sensorID(ladder);
296 sensorID.setSensorNumber(p.getSensorID());
297
298
299 std::map<string, VXDGeoSensor>::iterator it = m_sensorMap.find(p.getSensorTypeID());
300 if (it == m_sensorMap.end()) {
301 B2FATAL("Invalid SensorTypeID " << p.getSensorTypeID() << ", please check the definition of " << sensorID);
302 }
303 VXDGeoSensor& s = it->second;
304 string name = m_prefix + "." + (string)sensorID;
305
306 //Calculate the reflection transformation needed. Since we want the
307 //active area to be non reflected we apply this transformation on the
308 //sensor and on the active area
309 G4Transform3D reflection;
310 if (p.getFlipU()) reflection = reflection * G4ReflectX3D();
311 if (p.getFlipV()) reflection = reflection * G4ReflectY3D();
312 if (p.getFlipW()) reflection = reflection * G4ReflectZ3D();
313
314 G4VSolid* sensorShape = createTrapezoidal(name, s.getWidth(), s.getWidth2(), s.getLength(),
315 s.getHeight());
316 G4Material* sensorMaterial = Materials::get(s.getMaterial());
318 s.setVolume(new G4LogicalVolume(sensorShape, Materials::get(m_defaultMaterial), name));
319 } else {
320 s.setVolume(new G4LogicalVolume(sensorShape, sensorMaterial, name));
321 }
322
323 // Create sensitive Area: this Part is created separately since we want full control over the coordinate system:
324 // local x (called u) should point in RPhi direction
325 // local y (called v) should point in global z
326 // local z (called w) should away from the origin
327 G4VSolid* activeShape = createTrapezoidal(name + ".Active", s.getActiveArea().getWidth(), s.getActiveArea().getWidth2(),
328 s.getActiveArea().getLength(), s.getActiveArea().getHeight());
329
330 //Create appropriate sensitive detector instance
331 SensitiveDetectorBase* sensitive = createSensitiveDetector(sensorID, s, p);
332
333 sensitive->setOptions(m_seeNeutrons, m_onlyPrimaryTrueHits,
335 m_sensitive.push_back(sensitive);
336 G4LogicalVolume* active = new G4LogicalVolume(activeShape, sensorMaterial, name + ".Active",
337 0, sensitive);
338 m_UserLimits.push_back(new G4UserLimits(m_activeStepSize));
339 active->SetUserLimits(m_UserLimits.back());
340
341 setColor(*active, s.getActiveArea().getColor());
342
343 //The coordinates of the active region are given as the distance between the corners, not to the center
344 //Place the active area
345 G4Transform3D activePosition = G4Translate3D(s.getActiveArea().getWidth() / 2.0, s.getActiveArea().getLength() / 2.0, 0) *
346 getPosition(s, s.getActiveArea(), s.getActivePlacement(), false);
347
348 G4ReflectionFactory::Instance()->Place(activePosition * reflection, name + ".Active", active, s.getVolume(),
349 false, (int)sensorID, false);
350
351 //Now create all the other components and place the Sensor
352 GeoVXDAssembly assembly;
353 if (!m_onlyActiveMaterial) assembly = createSubComponents(name, s, s.getComponents(), false, true);
354
355 G4RotationMatrix rotation(0, -M_PI / 2.0, -M_PI / 2.0);
356 G4Transform3D sensorAlign = getAlignment(parameters.getAlignment(sensorID));
357 G4Transform3D sensorPlacement = G4Rotate3D(rotation) * sensorAlign * reflection;
358
359 if (s.getSlanted()) {
360 sensorPlacement = G4TranslateX3D(m_ladder.getSlantedRadius() - m_ladder.getRadius()) * G4RotateY3D(
361 -m_ladder.getSlantedAngle()) * sensorPlacement;
362 }
363 sensorPlacement = G4Translate3D(0.0, 0.0, p.getZ()) * sensorPlacement;
364 // Remember the placement of sensor into ladder
365 VXD::GeoCache::getInstance().addSensorPlacement(ladder, sensorID, sensorPlacement * activePosition * reflection);
366 sensorPlacement = ladderPlacement * sensorPlacement;
367
368 assembly.add(s.getVolume());
369 assembly.place(volume, sensorPlacement);
370
371 //See if we want to glue the modules together
372 if (!m_ladder.getGlueMaterial().empty() && !m_onlyActiveMaterial) {
373 double u = s.getWidth() / 2.0 + m_ladder.getGlueSize();
374 double v = s.getLength() / 2.0;
375 double w = s.getHeight() / 2.0 + m_ladder.getGlueSize();
376 std::vector<G4Point3D> curSensorEdge(4);
377 //Lets get the forward corners of the sensor by applying the unreflected placement matrix
378 curSensorEdge[0] = sensorPlacement * reflection * G4Point3D(u, v, + w);
379 curSensorEdge[1] = sensorPlacement * reflection * G4Point3D(u, v, - w);
380 curSensorEdge[2] = sensorPlacement * reflection * G4Point3D(-u, v, - w);
381 curSensorEdge[3] = sensorPlacement * reflection * G4Point3D(-u, v, + w);
382 //If we already have backward edges this is not the first module so we can apply the glue
383 if (lastSensorEdge.size()) {
384 //Check that the modules don't overlap in z
385 bool glueOK = true;
386 for (int i = 0; i < 4; ++i) glueOK &= curSensorEdge[i].z() <= lastSensorEdge[i].z();
387 if (!glueOK) {
388 B2WARNING("Cannot place Glue at sensor " + (string)sensorID +
389 " since it overlaps with the last module in z");
390 } else {
391 //Create Glue which spans from last sensor to this sensor
392 G4TessellatedSolid* solidTarget = new G4TessellatedSolid(m_prefix + ".Glue." + (string)sensorID);
393
394 //Face at end of last Sensor
395 solidTarget->AddFacet(new G4QuadrangularFacet(
396 curSensorEdge[3], curSensorEdge[2], curSensorEdge[1], curSensorEdge[0], ABSOLUTE));
397 //Face at begin of current Sensor
398 solidTarget->AddFacet(new G4QuadrangularFacet(
399 lastSensorEdge[0], lastSensorEdge[1], lastSensorEdge[2], lastSensorEdge[3], ABSOLUTE));
400
401 //Top faces
402 solidTarget->AddFacet(new G4TriangularFacet(
403 curSensorEdge[3], curSensorEdge[0], lastSensorEdge[0], ABSOLUTE));
404 solidTarget->AddFacet(new G4TriangularFacet(
405 lastSensorEdge[0], lastSensorEdge[3], curSensorEdge[3], ABSOLUTE));
406 //Bottom faces
407 solidTarget->AddFacet(new G4TriangularFacet(
408 curSensorEdge[1], curSensorEdge[2], lastSensorEdge[2], ABSOLUTE));
409 solidTarget->AddFacet(new G4TriangularFacet(
410 lastSensorEdge[2], lastSensorEdge[1], curSensorEdge[1], ABSOLUTE));
411 //Right faces
412 solidTarget->AddFacet(new G4TriangularFacet(
413 curSensorEdge[0], curSensorEdge[1], lastSensorEdge[1], ABSOLUTE));
414 solidTarget->AddFacet(new G4TriangularFacet(
415 lastSensorEdge[1], lastSensorEdge[0], curSensorEdge[0], ABSOLUTE));
416 //Left faces
417 solidTarget->AddFacet(new G4TriangularFacet(
418 curSensorEdge[2], curSensorEdge[3], lastSensorEdge[3], ABSOLUTE));
419 solidTarget->AddFacet(new G4TriangularFacet(
420 lastSensorEdge[3], lastSensorEdge[2], curSensorEdge[2], ABSOLUTE));
421
422 solidTarget->SetSolidClosed(true);
423
424 G4LogicalVolume* glue = new G4LogicalVolume(solidTarget, Materials::get(m_ladder.getGlueMaterial()),
425 m_prefix + ".Glue." + (string)sensorID);
426 setColor(*glue, "#097");
427 new G4PVPlacement(G4Transform3D(), glue, m_prefix + ".Glue." + (string)sensorID, volume, false, 1);
428 }
429 }
430 //Remember the backward edge of this sensor to be glued to.
431 lastSensorEdge.resize(4);
432 lastSensorEdge[0] = sensorPlacement * reflection * G4Point3D(u, -v, + w);
433 lastSensorEdge[1] = sensorPlacement * reflection * G4Point3D(u, -v, - w);
434 lastSensorEdge[2] = sensorPlacement * reflection * G4Point3D(-u, -v, - w);
435 lastSensorEdge[3] = sensorPlacement * reflection * G4Point3D(-u, -v, + w);
436 }
437 }
438
439 return ladderPlacement;
440 }
const std::vector< VXDGeoSensorPlacement > & getSensors() const
get list of sensors
int getLayerID() const
get the layer id
const std::string & getGlueMaterial() const
get the glue material
double getSlantedAngle() const
get the slant angle for slanted sensors
double getRadius() const
get the radius of all sensors except slanted ones
double getShift() const
get the shift along the u coordinate for all sensors in the ladder
double getSlantedRadius() const
get the radius for slanted sensors
double getGlueSize() const
get the additional glue size, e.g.
void addSensorPlacement(VxdID ladder, VxdID sensor, const G4Transform3D &placement)
Remember how sensor is placed into ladder.
Definition: GeoCache.cc:220
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
void addLadderPlacement(VxdID halfShell, VxdID ladder, const G4Transform3D &placement)
Remember how ladder is placed into half-shell.
Definition: GeoCache.cc:225
std::map< std::string, VXDGeoSensor > m_sensorMap
Map containing Information about all defined sensor types.
float m_minimumElectrons
minimum number of electrons to be deposited by a particle to be saved
bool m_onlyActiveMaterial
If this is true, only active Materials will be placed for tracking studies.
double m_activeStepSize
Stepsize to be used inside active volumes.
float m_distanceTolerance
tolerance for Geant4 steps to be merged to a single step
VXDGeoLadder m_ladder
Parameters of the currently active ladder.
std::map< std::string, Belle2::VxdID > m_halfShellVxdIDs
Used for translation of half-shell name into a VxdID to consitently handle it in hierarchy.
bool m_onlyPrimaryTrueHits
If true only create TrueHits from primary particles and ignore secondaries.
float m_electronTolerance
tolerance for the energy deposition in electrons to be merged in a single step
G4Transform3D getAlignment(const VXDAlignmentPar &params)
Get Alignment from paylead object.
GeoVXDAssembly createSubComponents(const std::string &name, VXDGeoComponent &component, std::vector< VXDGeoPlacement > placements, bool originCenter=true, bool allowOutside=false)
Place a list of subcomponents into an component.
virtual SensitiveDetectorBase * createSensitiveDetector(VxdID sensorID, const VXDGeoSensor &sensor, const VXDGeoSensorPlacement &placement)=0
Return a SensitiveDetector implementation for a given sensor.
bool m_seeNeutrons
Make sensitive detectors also see neutrons.
std::string m_defaultMaterial
Name of the Material to be used for Air.
std::string m_currentHalfShell
Current half-shell being processed (need to know ladder parent for hierarchy)

◆ readComponent()

void readComponent ( const std::string &  name,
GearDir  components,
VXDGeometryPar vxdGeometryPar 
)

Read parameters for component name from Gearbox into geometry payload.

The name is assumed to be unique and Volumes are cached.

Parameters
nameName of the component
componentsPath to components
vxdGeometryParVXD geometry parameters

Definition at line 533 of file GeoVXDCreator.cc.

534 {
535
536
537 //Check if component already exists
538 if (vxdGeometryPar.getComponentMap().find(name) != vxdGeometryPar.getComponentMap().end()) {
539 return; // nothing to do
540 }
541
542 //Component does not exist, so lets create a new one
543 string path = (boost::format("descendant::Component[@name='%1%']/") % name).str();
544 GearDir params(componentsDir, path);
545 if (!params) {
546 B2FATAL("Could not find definition for component " << name);
547 return;
548 }
549
550 VXDGeoComponentPar c(
551 params.getString("Material", vxdGeometryPar.getGlobalParams().getDefaultMaterial()),
552 params.getString("Color", ""),
553 params.getLength("width", 0),
554 params.getLength("width2", 0),
555 params.getLength("length", 0),
556 params.getLength("height", 0),
557 params.getAngle("angle", 0)
558 );
559
560 if (c.getWidth() <= 0 || c.getLength() <= 0 || c.getHeight() <= 0) {
561 B2DEBUG(100, "One dimension empty, using auto resize for component");
562 }
563
564 c.setSubComponents(getSubComponents(params));
565 readSubComponents(c.getSubComponents(), componentsDir, vxdGeometryPar);
566
567 if (vxdGeometryPar.getGlobalParams().getActiveChips() && params.exists("activeChipID")) {
568 int chipID = params.getInt("activeChipID");
569 vxdGeometryPar.getSensitiveChipIdMap()[name] = chipID;
570 }
571 vxdGeometryPar.getComponentMap()[name] = c;
572 vxdGeometryPar.getComponentInsertOder().push_back(name);
573 }
void readSubComponents(const std::vector< VXDGeoPlacementPar > &placements, const GearDir &componentsDir, VXDGeometryPar &vxdGeometryPar)
Read parameters for all components in placement container from Gearbox into payload.
std::vector< VXDGeoPlacementPar > getSubComponents(const GearDir &path)
Return vector of VXDGeoPlacements with all the components defined inside a given path.

◆ readLadder()

void readLadder ( int  layer,
GearDir  components,
VXDGeometryPar geoparameters 
)
virtual

Read parameters for a ladder in layer with given ID from gearbox and layer store them in payload.

Definition at line 575 of file GeoVXDCreator.cc.

576 {
577 string path = (boost::format("Ladder[@layer=%1%]/") % layer).str();
578 GearDir paramsLadder(components, path);
579 if (!paramsLadder) {
580 B2FATAL("Could not find Ladder definition for layer " << layer);
581 }
582
583 geoparameters.getLadderMap()[layer] = VXDGeoLadderPar(
584 layer,
585 paramsLadder.getLength("shift"),
586 paramsLadder.getLength("radius"),
587 paramsLadder.getAngle("slantedAngle", 0),
588 paramsLadder.getLength("slantedRadius", 0),
589 paramsLadder.getLength("Glue/oversize", 0),
590 paramsLadder.getString("Glue/Material", "")
591 );
592
593 for (const GearDir& sensorInfo : paramsLadder.getNodes("Sensor")) {
594
595 geoparameters.getLadderMap()[layer].addSensor(VXDGeoSensorPlacementPar(
596 sensorInfo.getInt("@id"),
597 sensorInfo.getString("@type"),
598 sensorInfo.getLength("."),
599 sensorInfo.getBool("@flipU", false),
600 sensorInfo.getBool("@flipV", false),
601 sensorInfo.getBool("@flipW", false)
602 ));
603 }
604 }

◆ readLadderComponents()

void readLadderComponents ( int  layerID,
int  ladderID,
GearDir  content,
VXDGeometryPar vxdGeometryPar 
)
virtual

Read parameters for ladder components and their alignment corresponding to the given ladder id.

Definition at line 471 of file GeoVXDCreator.cc.

472 {
473 VxdID ladder(layerID, ladderID, 0);
474
475 // Read alignment for ladder
476 string path = (boost::format("Align[@component='%1%']/") % ladder).str();
477 GearDir params(GearDir(content, "Alignment/"), path);
478 if (!params) {
479 B2WARNING("Could not find alignment parameters for ladder " << ladder);
480 return;
481 }
482 vxdGeometryPar.getAlignmentMap()[ladder] = VXDAlignmentPar(params.getLength("du"),
483 params.getLength("dv"),
484 params.getLength("dw"),
485 params.getAngle("alpha"),
486 params.getAngle("beta"),
487 params.getAngle("gamma")
488 );
489
490
491
492 for (const VXDGeoSensorPlacementPar& p : vxdGeometryPar.getLadderMap()[layerID].getSensors()) {
493 VxdID sensorID(ladder);
494 sensorID.setSensorNumber(p.getSensorID());
495
496 std::map<string, VXDGeoSensorPar>::iterator it = vxdGeometryPar.getSensorMap().find(p.getSensorTypeID());
497 if (it == vxdGeometryPar.getSensorMap().end()) {
498 B2FATAL("Invalid SensorTypeID " << p.getSensorTypeID() << ", please check the definition of " << sensorID);
499 }
500
501 //Now create all the other components and place the Sensor
502 if (!vxdGeometryPar.getGlobalParams().getOnlyActiveMaterial()) {
503 VXDGeoSensorPar& s = it->second;
504 readSubComponents(s.getComponents(), GearDir(content, "Components/"), vxdGeometryPar);
505 }
506 // Read alignment for sensor
507 string pathSensor = (boost::format("Align[@component='%1%']/") % sensorID).str();
508 GearDir paramsSensor(GearDir(content, "Alignment/"), pathSensor);
509 if (!paramsSensor) {
510 B2WARNING("Could not find alignment parameters for sensorID " << sensorID);
511 return;
512 }
513 vxdGeometryPar.getAlignmentMap()[sensorID] = VXDAlignmentPar(paramsSensor.getLength("du"),
514 paramsSensor.getLength("dv"),
515 paramsSensor.getLength("dw"),
516 paramsSensor.getAngle("alpha"),
517 paramsSensor.getAngle("beta"),
518 paramsSensor.getAngle("gamma")
519 );
520 }
521 return;
522 }

◆ readSubComponents()

void readSubComponents ( const std::vector< VXDGeoPlacementPar > &  placements,
const GearDir componentsDir,
VXDGeometryPar vxdGeometryPar 
)

Read parameters for all components in placement container from Gearbox into payload.

Parameters
placementscontainer holding names of all components to be cached
componentsDirPath to Gearbox where parameters are to be found
vxdGeometryPar

Definition at line 524 of file GeoVXDCreator.cc.

526 {
527 for (const VXDGeoPlacementPar& p : placements) {
528 readComponent(p.getName(), componentsDir, vxdGeometryPar);
529 }
530 return;
531 }
void readComponent(const std::string &name, GearDir components, VXDGeometryPar &vxdGeometryPar)
Read parameters for component name from Gearbox into geometry payload.

◆ setCurrentLayer()

void setCurrentLayer ( int  layer,
const VXDGeometryPar parameters 
)
virtual

Read parameters for given layer and store in m_ladder.

Definition at line 442 of file GeoVXDCreator.cc.

443 {
444 const VXDGeoLadderPar& paramsLadder = parameters.getLadder(layer);
445
446 m_ladder = VXDGeoLadder(
447 layer,
448 paramsLadder.getShift() / Unit::mm,
449 paramsLadder.getRadius() / Unit::mm,
450 paramsLadder.getSlantedAngle(),
451 paramsLadder.getSlantedRadius() / Unit::mm,
452 paramsLadder.getGlueSize() / Unit::mm,
453 paramsLadder.getGlueMaterial()
454 );
455
456
457 for (const VXDGeoSensorPlacementPar& sensorInfo : paramsLadder.getSensors()) {
458 m_ladder.addSensor(VXDGeoSensorPlacement(
459 sensorInfo.getSensorID(),
460 sensorInfo.getSensorTypeID(),
461 sensorInfo.getZ() / Unit::mm,
462 sensorInfo.getFlipU(),
463 sensorInfo.getFlipV(),
464 sensorInfo.getFlipW()
465 ));
466 }
467 }
void addSensor(const VXDGeoSensorPlacement &sensor)
add a sensor to the list of sensors in the ladder

Member Data Documentation

◆ m_activeChips

bool m_activeChips {false}
protected

Make also chips sensitive.

Definition at line 209 of file GeoVXDCreator.h.

◆ m_activeStepSize

double m_activeStepSize {5 * Unit::um}
protected

Stepsize to be used inside active volumes.

Definition at line 207 of file GeoVXDCreator.h.

◆ m_alignment

GearDir m_alignment
protected

GearDir pointing to the alignment parameters.

Definition at line 183 of file GeoVXDCreator.h.

◆ m_componentCache

std::map<std::string, VXDGeoComponent> m_componentCache
protected

Cache of all previously created components.

Definition at line 188 of file GeoVXDCreator.h.

◆ m_components

GearDir m_components
protected

GearDir pointing to the toplevel of the components.

Definition at line 185 of file GeoVXDCreator.h.

◆ m_currentHalfShell

std::string m_currentHalfShell {""}
protected

Current half-shell being processed (need to know ladder parent for hierarchy)

Definition at line 220 of file GeoVXDCreator.h.

◆ m_defaultMaterial

std::string m_defaultMaterial
protected

Name of the Material to be used for Air.

Definition at line 199 of file GeoVXDCreator.h.

◆ m_distanceTolerance

float m_distanceTolerance {(float)(5 * Unit::um)}
protected

tolerance for Geant4 steps to be merged to a single step

Definition at line 201 of file GeoVXDCreator.h.

◆ m_electronTolerance

float m_electronTolerance {100}
protected

tolerance for the energy deposition in electrons to be merged in a single step

Definition at line 203 of file GeoVXDCreator.h.

◆ m_halfShellVxdIDs

std::map<std::string, Belle2::VxdID> m_halfShellVxdIDs
protected
Initial value:
{
{{"PXD.Ying"}, {Belle2::VxdID(1, 0, 0, 1)}},
{{"PXD.Yang"}, {Belle2::VxdID(1, 0, 0, 2)}},
{{"SVD.Pat"}, {Belle2::VxdID(3, 0, 0, 1)}},
{{"SVD.Mat"}, {Belle2::VxdID(3, 0, 0, 2)}}
}
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33

Used for translation of half-shell name into a VxdID to consitently handle it in hierarchy.

Definition at line 222 of file GeoVXDCreator.h.

◆ m_ladder

VXDGeoLadder m_ladder
protected

Parameters of the currently active ladder.

Definition at line 192 of file GeoVXDCreator.h.

◆ m_minimumElectrons

float m_minimumElectrons {10}
protected

minimum number of electrons to be deposited by a particle to be saved

Definition at line 205 of file GeoVXDCreator.h.

◆ m_onlyActiveMaterial

bool m_onlyActiveMaterial {false}
protected

If this is true, only active Materials will be placed for tracking studies.

Dead Material will be ignored

Definition at line 216 of file GeoVXDCreator.h.

◆ m_onlyPrimaryTrueHits

bool m_onlyPrimaryTrueHits {false}
protected

If true only create TrueHits from primary particles and ignore secondaries.

Definition at line 213 of file GeoVXDCreator.h.

◆ m_prefix

std::string m_prefix
protected

Prefix to prepend to all volume names.

Definition at line 181 of file GeoVXDCreator.h.

◆ m_radiationsensors

GeoVXDRadiationSensors m_radiationsensors
protected

Diamond radiation sensor "sub creator".

Definition at line 196 of file GeoVXDCreator.h.

◆ m_seeNeutrons

bool m_seeNeutrons {false}
protected

Make sensitive detectors also see neutrons.

Definition at line 211 of file GeoVXDCreator.h.

◆ m_sensitive

std::vector<Simulation::SensitiveDetectorBase*> m_sensitive
protected

List to all created sensitive detector instances.

Definition at line 194 of file GeoVXDCreator.h.

◆ m_sensorMap

std::map<std::string, VXDGeoSensor> m_sensorMap
protected

Map containing Information about all defined sensor types.

Definition at line 190 of file GeoVXDCreator.h.

◆ m_UserLimits

std::vector<G4UserLimits*> m_UserLimits
protected

Vector of G4UserLimit pointers.

Definition at line 218 of file GeoVXDCreator.h.


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