9#include <vxd/geometry/GeoVXDServiceCreator.h>
10#include <vxd/geometry/GeoVXDComponents.h>
11#include <geometry/CreatorFactory.h>
12#include <geometry/Materials.h>
13#include <simulation/background/BkgSensitiveDetector.h>
14#include <framework/gearbox/GearDir.h>
15#include <framework/logging/Logger.h>
16#include <G4Transform3D.hh>
17#include <G4LogicalVolume.hh>
18#include <G4PVPlacement.hh>
28 using namespace geometry;
39 GearDir content2(content,
"DockBoxes");
44 boxtype.getString(
"@name"),
45 boxtype.getString(
"material"),
46 boxtype.getInt(
"@identifier", 0),
47 boxtype.getLength(
"width"),
48 boxtype.getLength(
"length"),
49 boxtype.getLength(
"height")
51 vxdServiceGeometryPar.
getBoxTypes().push_back(boxtypePar);
57 position.getString(
"@name"),
58 position.getLength(
"minZ"),
59 position.getLength(
"maxZ"),
60 position.getLength(
"minR"),
61 position.getLength(
"maxR"),
62 position.getInt(
"divisions")
64 for (
const GearDir& slot : position.getNodes(
"slots")) {
66 for (
const double number : slot.getArray(
"")) {
69 positionPar.
getSlots().push_back(slotsPar);
71 vxdServiceGeometryPar.
getPositions().push_back(positionPar);
74 return vxdServiceGeometryPar;
80 bool active = parameters.getRecordBackground();
83 std::map<std::string, VXDGeoComponent> boxes;
87 boxtype.getMaterial(),
"",
88 boxtype.getWidth() / 2.0 /
Unit::mm, 0,
89 boxtype.getLength() / 2.0 /
Unit::mm,
90 boxtype.getHeight() / 2.0 /
Unit::mm);
91 const std::string name = boxtype.getName();
94 B2DEBUG(50,
"Created " << name <<
" DockBox with a mass of " << (box.
getVolume()->GetMass(
true) / CLHEP::kg) <<
"kg");
96 int identifier = boxtype.getIdentifier();
97 B2DEBUG(50,
"Creating BkgSensitiveDetector for DockBox " << name <<
" with identifier " << identifier);
99 box.
getVolume()->SetSensitiveDetector(sensitive);
106 const double minZ = position.getMinZ() /
Unit::mm;
107 const double maxZ = position.getMaxZ() /
Unit::mm;
108 const double minR = position.getMinR() /
Unit::mm;
109 const double maxR = position.getMaxR() /
Unit::mm;
110 const int divisions = position.getDivisions();
111 const std::string name =
"VXD.DockBoxes." + position.getName();
115 const int signZ = minZ < 0 ? -1 : +1;
116 double startPhiAngle = 0;
117 double deltaAngle = 2 * M_PI;
119 startPhiAngle = 0.35;
120 deltaAngle = 2 * M_PI - startPhiAngle;
122 G4VSolid* shape_envelope =
new G4Tubs(name, minR, maxR, (maxZ - minZ) / 2.0, startPhiAngle, deltaAngle);
123 G4LogicalVolume* envelope =
new G4LogicalVolume(shape_envelope,
m_defaultMaterial, name);
124 new G4PVPlacement(G4TranslateZ3D((minZ + maxZ) / 2.0), envelope, name, &topVolume,
false, 1);
128 for (
const VXDSlotsPar& slot : position.getSlots()) {
129 const std::string type = slot.getType();
131 if (!box.
getVolume()) B2FATAL(
"Unknown DockBox type: " << type);
132 for (
double number : slot.getSlotNumbers()) {
133 const double angle = (2 * M_PI / divisions) * (number + 0.5);
137 const double z = -signZ * ((maxZ - minZ) / 2.0 - box.
getLength());
138 const G4Transform3D placement = G4RotateZ3D(angle) * G4Translate3D(r, 0, z);
139 new G4PVPlacement(placement, box.
getVolume(), name +
".box", envelope,
false,
static_cast<int>(number));
The Class for BeamBackground Sensitive Detector.
GearDir is the basic class used for accessing the parameter store.
static const double mm
[millimeters]
The Class for VXD doc box envelope.
const std::vector< VXDSlotsPar > & getSlots(void) const
Get slots.
The Class for VXD doc box.
Class holding all parameters for an VXD geometry component.
double getWidth() const
get the width of the component
double & getHeight()
get the height of the component
const std::string & getMaterial() const
get the name of the Material for the component
void setVolume(G4LogicalVolume *volume)
set the pointer to the logical volume
G4LogicalVolume * getVolume() const
get the pointer to the logical volume, NULL if not yet created
double getLength() const
get the length of the component
The Class for VXD service geometry.
const std::vector< VXDBoxPositionsPar > & getPositions(void) const
Get positions.
const std::vector< VXDBoxTypesPar > & getBoxTypes(void) const
Get boxes.
The Class for Slot types.
const std::vector< double > & getSlotNumbers(void) const
Get slot numbers.
void createGeometry(const VXDServiceGeometryPar ¶meters, G4LogicalVolume &topVolume, geometry::GeometryTypes type)
Create the geometry from a parameter object.
VXDServiceGeometryPar createConfiguration(const GearDir ¶m)
Create a parameter object from the Gearbox XML parameters.
G4Material * m_defaultMaterial
Default Material, inherited from topVolume.
std::vector< GearDir > getNodes(const std::string &path="") const
Get vector of GearDirs which point to all the nodes the given path evaluates to.
static G4Material * get(const std::string &name)
Find given material.
geometry::CreatorFactory< GeoVXDServiceCreator > GeoVXDServiceFactory("VXDServiceCreator")
Create factory instance so that the framework can instantiate the VXDServiceCreator.
GeometryTypes
Flag indiciating the type of geometry to be used.
Abstract base class for different kinds of events.
Very simple class to provide an easy way to register creators with the CreatorManager.