9#include <structure/geometry/GeoSTRCreator.h>
10#include "structure/dbobjects/STRGeometryPar.h"
12#include <geometry/Materials.h>
13#include <geometry/CreatorFactory.h>
14#include <geometry/utilities.h>
16#include <framework/logging/Logger.h>
19#include <boost/format.hpp>
23#include <G4NistManager.hh>
24#include <G4LogicalVolume.hh>
25#include <G4PVPlacement.hh>
26#include <G4Polycone.hh>
27#include <G4VisAttributes.hh>
38 using namespace geometry;
68 for (
int iShield = 0; iShield < parameters.NECLSHIELDS; iShield++) {
71 if (iShield == parameters.FWD_ECLSHIELD) {
73 }
else if (iShield == parameters.BWD_ECLSHIELD) {
76 B2FATAL(
"Only 2 ECL shields should be defined. Can't retrieve info for shield #" << iShield);
79 int nLayers = parameters.getNLayers(iShield);
81 for (
int iLayer = 0; iLayer < nLayers; iLayer++) {
82 G4Material* LayerMat =
Materials::get(parameters.getLayerMaterial(iShield, iLayer));
83 int nPlanes = parameters.getLayerNPlanes(iShield, iLayer);
86 string shapeName = (boost::format(
"%1%Layer_%2%") % side % (iLayer + 1)).str();
87 string logiVolName = (boost::format(
"logi%1%Layer_%2%") % side % (iLayer + 1)).str();
88 string physVolName = (boost::format(
"phys%1%Layer_%2%") % side % (iLayer + 1)).str();
90 G4Polycone* LayerShape =
new G4Polycone(shapeName.c_str(), 0, 2 * M_PI, nPlanes,
91 parameters.getLayerPlaneZ(iShield, iLayer),
92 parameters.getLayerPlaneInnerRadius(iShield, iLayer),
93 parameters.getLayerPlaneOuterRadius(iShield, iLayer));
96 G4LogicalVolume* logiShieldLayer =
new G4LogicalVolume(LayerShape, LayerMat, logiVolName, 0, 0, 0);
99 new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logiShieldLayer, physVolName, &topVolume,
false, 0);
101 B2DEBUG(1,
"Mass of " << side <<
" layer " << iLayer
102 <<
" = " << logiShieldLayer->GetMass() / CLHEP::kg <<
".kg.");
104 _mass += (logiShieldLayer->GetMass() / CLHEP::kg);
107 B2DEBUG(1,
"Total mass of side " << side <<
" = " << _mass <<
" kg");
111 for (
int iPole = 0; iPole < parameters.NPOLEPIECES; iPole++) {
114 if (iPole == parameters.FWD_POLEPIECE) {
116 }
else if (iPole == parameters.BWD_POLEPIECE) {
119 B2FATAL(
"Only 2 pole pieces should be defined. Can't retrieve info for pole #" << iPole);
123 G4Material* PoleMat =
Materials::get(parameters.getPoleMaterial(iPole));
124 int nPlanes = parameters.getPoleNPlanes(iPole);
127 string shapeName = (boost::format(
"%1%") % side).str();
128 string logiVolName = (boost::format(
"logi%1%") % side).str();
129 string physVolName = (boost::format(
"phys%1%") % side).str();
131 G4Polycone* PoleShape =
new G4Polycone(shapeName.c_str(), 0, 2 * M_PI, nPlanes,
132 parameters.getPolePlaneZ(iPole),
133 parameters.getPolePlaneInnerRadius(iPole),
134 parameters.getPolePlaneOuterRadius(iPole));
137 G4LogicalVolume* logiPole =
new G4LogicalVolume(PoleShape, PoleMat, logiVolName, 0, 0, 0);
140 new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logiPole, physVolName, &topVolume,
false, 0);
142 B2DEBUG(1,
"Total mass of " << side <<
" = " << logiPole->GetMass() / CLHEP::kg <<
" kg");
153 readShield(param, strGeometryPar,
"FWD_Shield");
154 readShield(param, strGeometryPar,
"BWD_Shield");
155 readPole(param, strGeometryPar,
"PolePieceL");
156 readPole(param, strGeometryPar,
"PolePieceR");
159 return strGeometryPar;
165 std::size_t foundF = side.find(
"PolePieceR");
166 std::size_t foundB = side.find(
"PolePieceL");
169 if (foundF != std::string::npos) { iPole = parameters.FWD_POLEPIECE; }
170 else if (foundB != std::string::npos) { iPole = parameters.BWD_POLEPIECE; }
171 else { B2FATAL(
"No data for the Pole Piece requested " << side <<
"(not found)");}
175 std::string polePath = (boost::format(
"/%1%/") % side).str();
179 poleContent.
append(polePath);
182 parameters.setPoleMaterial(iPole, poleContent.
getString(
"Material",
"Air"));
185 const std::vector<GearDir> planes = poleContent.
getNodes(
"Plane");
186 parameters.setPoleNPlanes(iPole, planes.size());
187 B2DEBUG(1,
"Number of planes on side " << side <<
" : " << planes.size());
189 for (
unsigned int iPlane = 0; iPlane < planes.size(); iPlane++) {
190 parameters.setPolePlaneZ(iPole, iPlane, planes.at(iPlane).getLength(
"posZ") /
Unit::mm);
191 parameters.setPolePlaneInnerRadius(iPole, iPlane, planes.at(iPlane).getLength(
"innerRadius") /
Unit::mm);
192 parameters.setPolePlaneOuterRadius(iPole, iPlane, planes.at(iPlane).getLength(
"outerRadius") /
Unit::mm);
201 std::size_t foundF = side.find(
"FWD_Shield");
202 std::size_t foundB = side.find(
"BWD_Shield");
205 if (foundF != std::string::npos) { iShield = parameters.FWD_ECLSHIELD; }
206 else if (foundB != std::string::npos) { iShield = parameters.BWD_ECLSHIELD; }
207 else { B2FATAL(
"No data for the ECL shield called " << side <<
"(not found)");}
210 std::string gearPath = (boost::format(
"%1%/Layers/Layer") % side).str();
213 int nLayers = content.getNumberNodes(gearPath);
214 parameters.setNLayers(iShield, nLayers);
217 for (
int iLayer = 0 ; iLayer < nLayers ; ++iLayer) {
219 std::string layerPath = (boost::format(
"/%1%[%2%]/") % gearPath % (iLayer + 1)).str();
223 layerContent.
append(layerPath);
226 parameters.setLayerMaterial(iShield, iLayer, layerContent.
getString(
"Material",
"Air"));
229 const std::vector<GearDir> planes = layerContent.
getNodes(
"Plane");
230 parameters.setLayerNPlanes(iShield, iLayer, planes.size());
231 B2DEBUG(1,
"Number of planes on side " << side <<
" layer " << iLayer
232 <<
" : " << planes.size());
234 for (
unsigned int iPlane = 0; iPlane < planes.size(); iPlane++) {
235 parameters.setLayerPlaneZ(iShield, iLayer, iPlane, planes.at(iPlane).getLength(
"posZ") /
Unit::mm);
236 parameters.setLayerPlaneInnerRadius(iShield, iLayer, iPlane, planes.at(iPlane).getLength(
"innerRadius") /
Unit::mm);
237 parameters.setLayerPlaneOuterRadius(iShield, iLayer, iPlane, planes.at(iPlane).getLength(
"outerRadius") /
Unit::mm);
GearDir is the basic class used for accessing the parameter store.
void append(const std::string &path)
Append something to the current path, modifying the GearDir in place.
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
The Class for STR geometry.
static const double mm
[millimeters]
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.
void createGeometry(const STRGeometryPar ¶meters, G4LogicalVolume &topVolume, geometry::GeometryTypes type)
Create the geometry from a parameter object.
STRGeometryPar createConfiguration(const GearDir ¶m)
Create a parameter object from the Gearbox XML parameters.
void readPole(const GearDir &content, STRGeometryPar ¶meters, std::string side)
Read xml files from GearDir for one of the Pole Pieces.
void readShield(const GearDir &content, STRGeometryPar ¶meters, std::string side)
Read xml files from GearDir for one of the ECL shields.
GeoSTRCreator()
The Constructor of the GeoSTRCreator class.
virtual ~GeoSTRCreator()
The destructor of the GeoSTRCreator class.
GeometryTypes
Flag indiciating the type of geometry to be used.
geometry::CreatorFactory< GeoSTRCreator > GeoSTRFactory("STRCreator")
Create factory instance so that the framework can instantiate the STRCreator.
Abstract base class for different kinds of events.
Very simple class to provide an easy way to register creators with the CreatorManager.