Belle II Software development
DosiCreator.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <beast/dosi/geometry/DosiCreator.h>
10#include <beast/dosi/simulation/SensitiveDetector.h>
11
12#include <geometry/Materials.h>
13#include <geometry/CreatorFactory.h>
14#include <framework/gearbox/GearDir.h>
15
16#include <cmath>
17
18#include <G4LogicalVolume.hh>
19#include <G4PVPlacement.hh>
20
21//Shapes
22#include <G4Box.hh>
23#include <G4UserLimits.hh>
24
25//Visualization Attributes
26#include <G4VisAttributes.hh>
27
28using namespace std;
29
30namespace Belle2 {
37 namespace dosi {
38
39 // Register the creator
42
43 DosiCreator::DosiCreator(): m_sensitive(0)
44 {
45 //m_sensitive = new SensitiveDetector();
46 }
47
49 {
50 if (m_sensitive) delete m_sensitive;
51 }
52
53 void DosiCreator::create(const GearDir& content, G4LogicalVolume& topVolume, geometry::GeometryTypes /* type */)
54 {
55
57
58 //lets get the stepsize parameter with a default value of 5 µm
59 double stepSize = content.getLength("stepSize", 5 * CLHEP::um);
60
61 G4VisAttributes* red = new G4VisAttributes(G4Colour(1, 0, 0));
62 red->SetForceAuxEdgeVisible(true);
63 G4VisAttributes* green = new G4VisAttributes(G4Colour(0, 1, 0));
64 green->SetForceAuxEdgeVisible(true);
65 G4VisAttributes* gray = new G4VisAttributes(G4Colour(.5, .5, .5));
66 gray->SetForceAuxEdgeVisible(true);
67 G4VisAttributes* coppercolor = new G4VisAttributes(G4Colour(218. / 255., 138. / 255., 103. / 255.));
68 coppercolor->SetForceAuxEdgeVisible(true);
69
70 //Lets loop over all the Active nodes
71 for (const GearDir& activeParams : content.getNodes("Active")) {
72 G4double dx_dosi = activeParams.getLength("dx_dosi") / 2.*CLHEP::cm;
73 G4double dy_dosi = activeParams.getLength("dy_dosi") / 2.*CLHEP::cm;
74 G4double dz_dosi = activeParams.getLength("dz_dosi") / 2.*CLHEP::cm;
75 double thetaZ = activeParams.getAngle("ThetaZ");
76 G4VSolid* s_dosi = new G4Box("s_dosi", dx_dosi, dy_dosi, dz_dosi);
77 //G4LogicalVolume* l_dosi = new G4LogicalVolume(s_dosi, geometry::Materials::get("BGO"), "l_dosi", 0, m_sensitive);
78 G4LogicalVolume* l_dosi = new G4LogicalVolume(s_dosi, geometry::Materials::get("G4_SILICON_DIOXIDE"), "l_dosi", 0, m_sensitive);
79
80 l_dosi->SetVisAttributes(green);
81 //Lets limit the Geant4 stepsize inside the volume
82 l_dosi->SetUserLimits(new G4UserLimits(stepSize));
83 double z_pos[100];
84 double r_pos[100];
85 int dim = 0;
86 for (double z : activeParams.getArray("z", {0})) {
87 z *= CLHEP::cm;
88 z_pos[dim] = z;
89 dim++;
90 }
91 dim = 0;
92 for (double r : activeParams.getArray("r", {0})) {
93 r *= CLHEP::cm;
94 r_pos[dim] = r + dz_dosi;
95 dim++;
96 }
97
98 int detID = 0;
99 G4Transform3D transform;
100 for (double phi : activeParams.getArray("Phi", {M_PI / 2})) {
101 //phi *= CLHEP::deg;
102 for (int i = 0; i < dim; i++) {
103 transform = G4RotateZ3D(phi - M_PI / 2) * G4Translate3D(0, r_pos[i], z_pos[i]) * G4RotateX3D(-M_PI / 2 - thetaZ);
104 new G4PVPlacement(transform, l_dosi, TString::Format("p_dosi_%d", detID).Data(), &topVolume, false, detID);
105 detID++;
106 }
107 }
108 }
109 }
110 } // dosi namespace
112} // Belle2 namespace
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
virtual ~DosiCreator()
Destructor.
Definition: DosiCreator.cc:48
DosiCreator()
Constructor.
Definition: DosiCreator.cc:43
virtual void create(const GearDir &content, G4LogicalVolume &topVolume, geometry::GeometryTypes type)
Creation of the detector geometry from Gearbox (XML).
Definition: DosiCreator.cc:53
SensitiveDetector * m_sensitive
SensitiveDetector DOSI.
Definition: DosiCreator.h:46
Sensitive Detector implementation of the DOSI detector.
static G4Material * get(const std::string &name)
Find given material.
Definition: Materials.h:63
geometry::CreatorFactory< DosiCreator > DosiFactory("DOSICreator")
Creator creates the DOSI geometry.
GeometryTypes
Flag indicating the type of geometry to be used.
Abstract base class for different kinds of events.
STL namespace.
Very simple class to provide an easy way to register creators with the CreatorManager.