Belle II Software  release-08-01-10
GeoPXDCreator Class Reference

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

#include <GeoPXDCreator.h>

Inheritance diagram for GeoPXDCreator:
Collaboration diagram for GeoPXDCreator:

Public Member Functions

 GeoPXDCreator ()
 Constructor of the GeoPXDCreator class.
 
virtual ~GeoPXDCreator ()
 The destructor of the GeoPXDCreator class.
 
virtual void create (const GearDir &content, G4LogicalVolume &topVolume, geometry::GeometryTypes type) override
 The old create member: create the configuration object(s) on the fly and call the geometry creation routine.
 
virtual void createPayloads (const GearDir &content, const IntervalOfValidity &iov) override
 Create the configuration objects and save them in the Database. More...
 
virtual void createFromDB (const std::string &name, G4LogicalVolume &topVolume, geometry::GeometryTypes type) override
 Create the geometry from the Database.
 
virtual VXD::GeoVXDAssembly createLayerSupport ()
 Create support structure for a PXD Layer. More...
 
virtual VXD::GeoVXDAssembly createLadderSupport ()
 Create support structure for a PXD Ladder. More...
 
virtual VXD::GeoVXDAssembly createHalfShellSupport (const PXDGeometryPar &parameters)
 Create support structure for PXD Half Shell, that means everything that does not depend on layer or sensor alignment. More...
 
virtual VXD::SensorInfoBasecreateSensorInfo (const VXDGeoSensorPar &sensor) override
 Read the sensor definitions from the database. More...
 
PXDSensorInfoParreadSensorInfo (const GearDir &sensor)
 Read the sensor definitions from the gearbox. More...
 
virtual VXD::SensitiveDetectorBasecreateSensitiveDetector (VxdID sensorID, const VXDGeoSensor &sensor, const VXDGeoSensorPlacement &placement) override
 Return a SensitiveDetector implementation for a given sensor. More...
 
void readHalfShellSupport (const GearDir &support, PXDGeometryPar &pxdGeometryPar)
 Create support structure for VXD Half Shell, that means everything that does not depend on layer or sensor alignment. More...
 
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. More...
 
G4Transform3D getAlignment (const VXDAlignmentPar &params)
 Get Alignment from paylead object. More...
 
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. More...
 
G4VSolid * createTrapezoidal (const std::string &name, double width, double width2, double length, double &height, double angle=0)
 Create a trapezoidal solid. More...
 
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. More...
 
void readSubComponents (const std::vector< VXDGeoPlacementPar > &placements, const GearDir &componentsDir, VXDGeometryPar &vxdGeometryPar)
 Read parameters for all components in placement container from Gearbox into payload. More...
 
 BELLE2_DEFINE_EXCEPTION (DBNotImplemented, "Cannot create geometry from Database.")
 Exception that will be thrown in createFromDB if member is not yet implemented by creator.
 

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

Private Member Functions

PXDGeometryPar createConfiguration (const GearDir &param)
 Create a parameter object from the Gearbox XML parameters.
 
void createGeometry (const PXDGeometryPar &parameters, G4LogicalVolume &topVolume, geometry::GeometryTypes type)
 Create the geometry from a parameter object.
 

Private Attributes

std::vector< SensorInfo * > m_SensorInfo
 Vector of points to SensorInfo objects.
 

Detailed Description

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


Definition at line 27 of file GeoPXDCreator.h.

Member Function Documentation

◆ createHalfShellSupport()

VXD::GeoVXDAssembly createHalfShellSupport ( const PXDGeometryPar parameters)
virtual

Create support structure for PXD Half Shell, that means everything that does not depend on layer or sensor alignment.

Parameters
parametersReference to the database containing the parameters

Definition at line 561 of file GeoPXDCreator.cc.

562  {
563  VXD::GeoVXDAssembly supportAssembly;
564 
565  if (!parameters.getBuildSupport()) return supportAssembly;
566 
567 
568  // Create the Endlanges
569  const std::vector<VXDPolyConePar> Endflanges = parameters.getEndflanges();
570  for (const VXDPolyConePar& endflange : Endflanges) {
571 
572  double minZ(0), maxZ(0);
573  string name = endflange.getName();
574 
575  // Create a polycone
576  double minPhi = endflange.getMinPhi();
577  double dPhi = endflange.getMaxPhi() - minPhi;
578  int nPlanes = endflange.getPlanes().size();
579  if (nPlanes < 2) {
580  B2ERROR("Polycone needs at least two planes");
581  return supportAssembly;
582  }
583  std::vector<double> z(nPlanes, 0);
584  std::vector<double> rMin(nPlanes, 0);
585  std::vector<double> rMax(nPlanes, 0);
586  int index(0);
587  minZ = numeric_limits<double>::infinity();
588  maxZ = -numeric_limits<double>::infinity();
589 
590  const std::vector<VXDPolyConePlanePar> Planes = endflange.getPlanes();
591  for (const VXDPolyConePlanePar& plane : Planes) {
592  z[index] = plane.getPosZ() / Unit::mm;
593  minZ = min(minZ, z[index]);
594  maxZ = max(maxZ, z[index]);
595  rMin[index] = plane.getInnerRadius() / Unit::mm;
596  rMax[index] = plane.getOuterRadius() / Unit::mm;
597  ++index;
598  }
599 
600  G4VSolid* supportCone = new G4Polycone(name, minPhi, dPhi, nPlanes, z.data(), rMin.data(), rMax.data());
601 
602 
603  //Cutout boxes to make place for modules
604 
605  //We have the z dimensions of the polycon. Let's
606  //add 1mm on each side to make sure we don't run into problems when the
607  //surfaces match
608  minZ -= 1. / Unit::mm;
609  maxZ += 1. / Unit::mm;
610 
611 
612  //Now get the number of cutouts and their size/position/angle
613  int nCutouts = parameters.getNCutOuts();
614  double sizeX = parameters.getCutOutWidth() / Unit::mm / 2.;
615  double sizeY = parameters.getCutOutHeight() / Unit::mm / 2.;
616  double sizeZ = (maxZ - minZ) / 2.;
617  G4ThreeVector origin(
618  parameters.getCutOutShift() / Unit::mm,
619  parameters.getCutOutRPhi() / Unit::mm,
620  minZ + sizeZ
621  );
622 
623  double phi0 = parameters.getCutOutStartPhi();
624  double dphi = parameters.getCutOutDeltaPhi();
625  for (int i = 0; i < nCutouts; ++i) {
626  G4Box* box = new G4Box("Cutout", sizeX, sizeY, sizeZ);
627  G4Transform3D placement = G4RotateZ3D(phi0 + i * dphi) * G4Translate3D(origin);
628  G4VSolid* supportConeOld = supportCone;
629  supportCone = new G4SubtractionSolid("PXD Support endflange", supportConeOld, box, placement);
630  }
631 
632 
633  string materialName = endflange.getMaterial();
634  G4Material* material = geometry::Materials::get(materialName);
635  if (!material) B2FATAL("Material '" << materialName << "', required by PXD component " << name << ", could not be found");
636 
637  G4LogicalVolume* volume = new G4LogicalVolume(supportCone, material, name);
638  geometry::setColor(*volume, "#ccc4");
639  supportAssembly.add(volume);
640 
641  }
642 
643 
644  //Create Carbon cooling tubes
645  {
646  int nTubes = parameters.getNTubes();
647  double minZ = parameters.getTubesMinZ() / Unit::mm;
648  double maxZ = parameters.getTubesMaxZ() / Unit::mm;
649  double minR = parameters.getTubesMinR() / Unit::mm;
650  double maxR = parameters.getTubesMaxR() / Unit::mm;
651  double sizeZ = (maxZ - minZ) / 2.;
652  double shiftX = parameters.getTubesRPhi() / Unit::mm;
653  double shiftY = 0;
654  double shiftZ = minZ + sizeZ;
655  double phi0 = parameters.getTubesStartPhi();
656  double dphi = parameters.getTubesDeltaPhi();
657  string material = parameters.getTubesMaterial();
658 
659  G4Tubs* tube = new G4Tubs("CarbonTube", minR, maxR, sizeZ, 0, 2 * M_PI);
660  G4LogicalVolume* tubeVol = new G4LogicalVolume(tube, geometry::Materials::get(material), "CarbonTube");
661  geometry::setColor(*tubeVol, "#000");
662  for (int i = 0; i < nTubes; ++i) {
663  G4Transform3D placement = G4RotateZ3D(phi0 + i * dphi) * G4Translate3D(shiftX, shiftY, shiftZ);
664  supportAssembly.add(tubeVol, placement);
665  }
666  }
667 
668  return supportAssembly;
669  }
static const double mm
[millimeters]
Definition: Unit.h:70
static G4Material * get(const std::string &name)
Find given material.
Definition: Materials.h:63
void setColor(G4LogicalVolume &volume, const std::string &color)
Set the color of a logical volume.
Definition: utilities.cc:100

◆ createLadderSupport()

VXD::GeoVXDAssembly createLadderSupport ( )
virtual

Create support structure for a PXD Ladder.

Parameters
layerLayer ID to create the support
supportReference to the database containing the parameters

Definition at line 559 of file GeoPXDCreator.cc.

◆ createLayerSupport()

VXD::GeoVXDAssembly createLayerSupport ( )
virtual

Create support structure for a PXD Layer.

Parameters
layerLayer ID to create the support
supportReference to the database containing the parameters

Definition at line 557 of file GeoPXDCreator.cc.

◆ createPayloads()

virtual void createPayloads ( const GearDir content,
const IntervalOfValidity iov 
)
inlineoverridevirtual

Create the configuration objects and save them in the Database.

If more than one object is needed adjust accordingly

Reimplemented from CreatorBase.

Definition at line 51 of file GeoPXDCreator.h.

52  {
53  DBImportObjPtr<PXDGeometryPar> importObj;
54  PXDGeometryPar config = createConfiguration(content);
55  importObj.construct(config);
56  importObj.import(iov);
57  }
PXDGeometryPar createConfiguration(const GearDir &param)
Create a parameter object from the Gearbox XML parameters.

◆ createSensitiveDetector()

VXD::SensitiveDetectorBase * createSensitiveDetector ( VxdID  sensorID,
const VXDGeoSensor sensor,
const VXDGeoSensorPlacement placement 
)
overridevirtual

Return a SensitiveDetector implementation for a given sensor.

Parameters
sensorIDSensorID for the sensor
sensorInformation about the sensor to create the Sensitive Detector for
placementInformation on how to place the sensor

Implements GeoVXDCreator.

Definition at line 547 of file GeoPXDCreator.cc.

◆ createSensorInfo()

VXD::SensorInfoBase * createSensorInfo ( const VXDGeoSensorPar sensor)
overridevirtual

Read the sensor definitions from the database.

Parameters
sensorReference to the database containing the parameters

Implements GeoVXDCreator.

Definition at line 57 of file GeoPXDCreator.cc.

◆ createSubComponents()

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

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

◆ createTrapezoidal()

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

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 254 of file GeoVXDCreator.cc.

◆ getAlignment()

G4Transform3D getAlignment ( const VXDAlignmentPar params)
inherited

Get Alignment from paylead object.

Parameters
paramsPayload object
Returns
Transformation matrix for component

Definition at line 172 of file GeoVXDCreator.cc.

◆ getPosition()

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

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.

◆ readComponent()

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

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 532 of file GeoVXDCreator.cc.

◆ readHalfShellSupport()

void readHalfShellSupport ( const GearDir support,
PXDGeometryPar pxdGeometryPar 
)

Create support structure for VXD Half Shell, that means everything that does not depend on layer or sensor alignment.

Parameters
supportReference to the database containing the parameters
pxdGeometryParPXD geometry

Definition at line 295 of file GeoPXDCreator.cc.

◆ readSensorInfo()

PXDSensorInfoPar * readSensorInfo ( const GearDir sensor)

Read the sensor definitions from the gearbox.

Parameters
sensorReference to the database containing the parameters

Definition at line 96 of file GeoPXDCreator.cc.

◆ readSubComponents()

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

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 523 of file GeoVXDCreator.cc.

Member Data Documentation

◆ m_halfShellVxdIDs

std::map<std::string, Belle2::VxdID> m_halfShellVxdIDs
protectedinherited
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_onlyActiveMaterial

bool m_onlyActiveMaterial {false}
protectedinherited

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.


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