Belle II Software  release-08-01-10
Belle2::geometry Namespace Reference

Common code concerning the geometry representation of the detector. More...

Classes

class  CreatorBase
 Pure virtual base class for all geometry creators. More...
 
struct  CreatorFactory
 Very simple class to provide an easy way to register creators with the CreatorManager. More...
 
class  CreatorManager
 Class to manage all creators and provide factory access. More...
 
class  GeometryManager
 Class to manage the creation and conversion of the geometry. More...
 
class  Materials
 Thin wrapper around the Geant4 Material system. More...
 

Enumerations

enum  GeometryTypes {
  FullGeometry ,
  TrackingGeometry ,
  DisplayGeometry
}
 Flag indiciating the type of geometry to be used. More...
 

Functions

void setColor (G4LogicalVolume &volume, const std::string &color)
 Set the color of a logical volume. More...
 
void setVisibility (G4LogicalVolume &volume, bool visible)
 Helper function to quickly set the visibility of a given volume. More...
 
G4Polycone * createPolyCone (const std::string &name, const GearDir &params, double &minZ, double &maxZ)
 Create Polycone Shape from XML Parameters. More...
 
G4Polycone * createRotationSolid (const std::string &name, const GearDir &params, double &minZ, double &maxZ)
 Create a solid by roating two polylines around the Z-Axis. More...
 
G4Polycone * createRotationSolid (const std::string &name, std::list< std::pair< double, double > > innerPoints, std::list< std::pair< double, double > > outerPoints, double minPhi, double maxPhi, double &minZ, double &maxZ)
 Create a solid by rotating two polylines around the Z-Axis. More...
 
G4Colour parseColor (std::string colorString)
 Parse a color string of the form "#rgb", "#rrggbb", "#rgba", "#rrggbbaa" or "rgb(r, g, b)" and return a corresponding G4Colour. More...
 
 TEST (Materials, Element)
 Check that we can find hydrogen and that the basic Parameters are correct.
 
 TEST (Materials, Material)
 Check if we find the Air Material which is named G4_AIR in Geant4 So check if Air and G4_AIR refer to the same material.
 
 TEST (Materials, Create)
 Check creation of a simple mixture with fractions of other materials The density of the new material should be equal to the weighted sum of the original densities.
 
 TEST (Materials, CreateDensityError)
 When adding elements one has to specify a density since elements do not have a density.
 
 TEST (Materials, CreateDensity)
 Same as above, but with density so it should work.
 
 TEST (Materials, CreateMaterialError)
 When adding unknown materials we should get NULL.
 
 TEST (Materials, CreateElementError)
 When adding unknown elements we should get NULL.
 
 TEST (Materials, OpticalSurface)
 Check the OpticalSurface setting.
 
 TEST (Materials, Properties)
 Check the material properties (need to be checked)
 

Detailed Description

Common code concerning the geometry representation of the detector.

Enumeration Type Documentation

◆ GeometryTypes

Flag indiciating the type of geometry to be used.

Enumerator
FullGeometry 

Full geometry for simulation.

TrackingGeometry 

Simplified geometry for tracking purposes.

DisplayGeometry 

Simplified geometry for display purposes.

Definition at line 36 of file GeometryManager.h.

36  {
37  FullGeometry,
40  };
@ TrackingGeometry
Simplified geometry for tracking purposes.
@ FullGeometry
Full geometry for simulation.
@ DisplayGeometry
Simplified geometry for display purposes.

Function Documentation

◆ createPolyCone()

G4Polycone * createPolyCone ( const std::string &  name,
const GearDir params,
double &  minZ,
double &  maxZ 
)

Create Polycone Shape from XML Parameters.

This function will create a polycone shape directly from Gearbox Parameters of the form

<minPhi unit="deg"> 0</minPhi>
<maxPhi unit="deg">360</maxPhi>
<posZ unit="mm">-10.0</posZ>
<innerRadius unit="mm"> 20.000</innerRadius>
<outerRadius unit="mm"> 20.000</outerRadius>
...
<posZ unit="mm">10.0</posZ>
<innerRadius unit="mm"> 15.000</innerRadius>
<outerRadius unit="mm"> 30.000</outerRadius>

There must be at least two Plane definitions, minPhi and maxPhi can be omitted. minZ and maxZ will return the extents of the Polycone along z

Parameters
nameName of the shape to create
paramsGearDir pointing to the parameters
[out]minZwill contain the minimal z coordinate of the polycone
[out]maxZwill contain the maximal z coordinate of the polycone

Definition at line 116 of file utilities.cc.

117  {
118  if (!params) return nullptr;
119 
120  double minPhi = params.getAngle("minPhi", 0);
121  double dPhi = params.getAngle("maxPhi", 2 * M_PI) - minPhi;
122  const std::vector<GearDir> planes = params.getNodes("Plane");
123  int nPlanes = planes.size();
124  if (nPlanes < 2) {
125  B2ERROR("Polycone needs at least two planes");
126  return nullptr;
127  }
128  std::vector<double> z(nPlanes, 0);
129  std::vector<double> rMin(nPlanes, 0);
130  std::vector<double> rMax(nPlanes, 0);
131  int index(0);
132  minZ = std::numeric_limits<double>::infinity();
133  maxZ = -std::numeric_limits<double>::infinity();
134  for (const GearDir& plane : planes) {
135  z[index] = plane.getLength("posZ") / Unit::mm;
136  minZ = std::min(minZ, z[index]);
137  maxZ = std::max(maxZ, z[index]);
138  rMin[index] = plane.getLength("innerRadius") / Unit::mm;
139  rMax[index] = plane.getLength("outerRadius") / Unit::mm;
140  ++index;
141  }
142  G4Polycone* polycone = new G4Polycone(name, minPhi, dPhi, nPlanes, z.data(), rMin.data(), rMax.data());
143  return polycone;
144  }

◆ createRotationSolid() [1/2]

G4Polycone * createRotationSolid ( const std::string &  name,
const GearDir params,
double &  minZ,
double &  maxZ 
)

Create a solid by roating two polylines around the Z-Axis.

This function will create a polycone shape directly from Gearbox Parameters describing the inner and the outer envelope of the polycone. The XML Parameters should be of the form

<minPhi unit="deg"> 0</minPhi>
<maxPhi unit="deg">360</maxPhi>
<OuterPoints>
<point><z unit="mm">-393.000</z><x unit="mm">100.000</x></point>
<point><z unit="mm">-337.000</z><x unit="mm"> 85.500</x></point>
...
<point><z unit="mm">-138.000</z><x unit="mm"> 35.000</x></point>
</OuterPoints>
<InnerPoints>
<point><z unit="mm">-393.000</z><x unit="mm"> 97.934</x></point>
<point><z unit="mm">-339.000</z><x unit="mm"> 83.952</x></point>
...
<point><z unit="mm">-138.000</z><x unit="mm"> 33.000</x></point>
</InnerPoints>

Where OuterPoints and InnerPoints specify a polyline which is the outer respective inner envelope of the Polycone. The number of points doe s not have to be the same for Outer- and InnerPoints. Needed positions will be interpolated when creating the Polycone.

The Positions for Outer- and InnerPoints have to be in ascending Z coordinates. The first and last point of OuterPoints will be connected to the first respective last point of InnerPoints. The resulting shape will be rotated around the z axis to create the polycone.

Parameters
nameName of the Solid
paramsParameters to use for the Solid
[out]minZwill contain the minimal z coordinate of the polycone
[out]maxZwill contain the maximal z coordinate of the polycone

Definition at line 203 of file utilities.cc.

◆ createRotationSolid() [2/2]

G4Polycone * createRotationSolid ( const std::string &  name,
std::list< std::pair< double, double > >  innerPoints,
std::list< std::pair< double, double > >  outerPoints,
double  minPhi,
double  maxPhi,
double &  minZ,
double &  maxZ 
)

Create a solid by rotating two polylines around the Z-Axis.

This function will create a polycone shape. The InnerPoints and OuterPoints are passed directly as stl::lists to avoid dependence on gearbox.

Where OuterPoints and InnerPoints specify a polyline which is the outer respective inner envelope of the Polycone. The number of points does not have to be the same for Outer- and InnerPoints. Needed positions will be interpolated when creating the Polycone.

The Positions for Outer- and InnerPoints have to be in ascending Z coordinates. The first and last point of OuterPoints will be connected to the first respective last point of InnerPoints. The resulting shape will be rotated around the z axis to create the polycone.

Parameters
[in]nameName of the solid.
[in]innerPointsList of inner points.
[in]outerPointsList of outer points.
[in]minPhiMinimum phi angle.
[in]maxPhiMaximum phi angle.
[out]minZMinimum z coordinate.
[out]maxZMaximum z coordinate.

Definition at line 263 of file utilities.cc.

◆ parseColor()

G4Colour Belle2::geometry::parseColor ( std::string  colorString)

Parse a color string of the form "#rgb", "#rrggbb", "#rgba", "#rrggbbaa" or "rgb(r, g, b)" and return a corresponding G4Colour.

For "#rgb" and "#rgba" the color for red, green, blue (and optionally alpha) is each represented by one hexadecimal digit, "#rrggbb" and "#rrggbbaa" is the same with two digits per colour.

"rgb(r, g, b)" expects the fraction of red, green and blue as float between 0 and 1.

Definition at line 44 of file utilities.cc.

◆ setColor()

void setColor ( G4LogicalVolume &  volume,
const std::string &  color 
)

Set the color of a logical volume.

This function will set the visualization color of a logical volume from a string representation of the color. Recognized formats for the color are:

  • "#rgb" where r,g,b are hexadecimal values from 0 to f representing the color values for red, green and blue respectively
  • "#rgba" where r,g,b,a are hexadecimal values from 0 to f and a represents the alpha value
  • "#rrggbb" where rr,gg,bb are hexadecimal values from 00 to ff representing the color values for red, green and blue respectively
  • "#rrggbbaa" where rr,gg,bb,aa are hexadecimal values from 00 to ff and aa represents the alpha value
  • "rgb(r,g,b)" where r,g,b are float values between 0.0 and 1.0 representing the color values for red, green and blue respectively
  • "rgb(r,g,b,a)" where r,g,b,a are float values between 0.0 and 1.0 representing the color values for red, green, blue and alpha respectively
Parameters
volumeVolume for which to set the color
colorString representation of the color

Definition at line 100 of file utilities.cc.

◆ setVisibility()

void setVisibility ( G4LogicalVolume &  volume,
bool  visible 
)

Helper function to quickly set the visibility of a given volume.

Parameters
volumeVolume for which to set the visibility
visibletrue if the volume should be visible, false otherwise

Definition at line 108 of file utilities.cc.