Belle II Software development
DiamondCreator.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/srsensor/geometry/DiamondCreator.h>
10#include <beast/srsensor/simulation/SensitiveDetector.h>
11
12#include <geometry/Materials.h>
13#include <geometry/CreatorFactory.h>
14#include <framework/gearbox/GearDir.h>
15#include <framework/logging/Logger.h>
16
17#include <G4LogicalVolume.hh>
18#include <G4PVPlacement.hh>
19
20//Shapes
21#include <G4Box.hh>
22#include <G4UserLimits.hh>
23
24using namespace std;
25
26namespace Belle2 {
33 namespace srsensor {
34
35 // Register the creator
38
40 {
41 //m_sensitive = new SensitiveDetector();
42 }
43
45 {
46 if (m_sensitive) delete m_sensitive;
47 }
48
49 void DiamondCreator::create(const GearDir& content, G4LogicalVolume& topVolume, geometry::GeometryTypes /* type */)
50 {
51
53
54 //lets get the stepsize parameter with a default value of 5 µm
55 double stepSize = content.getLength("stepSize", 5 * CLHEP::um);
56
57 //no get the array. Notice that the default framework unit is cm, so the
58 //values will be automatically converted
59 vector<double> bar_diamond = content.getArray("bar_diamond");
60 B2INFO("Contents of bar_diamond: ");
61 for (double value : bar_diamond) {
62 B2INFO("value: " << value);
63 }
64 int diamondNb = 200;
65 //Lets loop over all the Active nodes
66 for (const GearDir& activeParams : content.getNodes("Active")) {
67
68 //create diamond volume
69 G4Box* s_DIAMOND = new G4Box("s_DIAMOND",
70 activeParams.getLength("diamond_dx")*CLHEP::cm,
71 activeParams.getLength("diamond_dy")*CLHEP::cm,
72 activeParams.getLength("diamond_dz")*CLHEP::cm);
73
74 string matDIAMOND = activeParams.getString("MaterialDIAMOND");
75 G4LogicalVolume* l_DIAMOND = new G4LogicalVolume(s_DIAMOND, geometry::Materials::get(matDIAMOND), "l_DIAMOND", 0, m_sensitive);
76
77 //Lets limit the Geant4 stepsize inside the volume
78 l_DIAMOND->SetUserLimits(new G4UserLimits(stepSize));
79
80 //position diamond volume
81 G4ThreeVector DIAMONDpos = G4ThreeVector(
82 activeParams.getLength("x_diamond") * CLHEP::cm,
83 activeParams.getLength("y_diamond") * CLHEP::cm,
84 activeParams.getLength("z_diamond") * CLHEP::cm
85 );
86
87 G4RotationMatrix* rot_diamond = new G4RotationMatrix();
88 rot_diamond->rotateX(activeParams.getAngle("AngleX"));
89 rot_diamond->rotateY(activeParams.getAngle("AngleY"));
90 rot_diamond->rotateZ(activeParams.getAngle("AngleZ"));
91 //geometry::setColor(*l_DIAMOND, "#006699");
92
93 new G4PVPlacement(rot_diamond, DIAMONDpos, l_DIAMOND, "p_DIAMOND", &topVolume, false, diamondNb);
94
95 diamondNb++;
96 }
97
98 }
99 } // srsensor namespace
101} // Belle2 namespace
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
static G4Material * get(const std::string &name)
Find given material.
Definition: Materials.h:63
virtual void create(const GearDir &content, G4LogicalVolume &topVolume, geometry::GeometryTypes type)
Creation of the detector geometry from Gearbox (XML).
virtual ~DiamondCreator()
Destructor.
SensitiveDetector * m_sensitive
SensitiveDetector DIAMOND.
Sensitive Detector implementation of the SRSENSOR detector.
GeometryTypes
Flag indicating the type of geometry to be used.
geometry::CreatorFactory< DiamondCreator > DiamondFactory("DIAMONDCreator")
Creator creates the DIAMOND geometry.
Abstract base class for different kinds of events.
STL namespace.
Very simple class to provide an easy way to register creators with the CreatorManager.