Belle II Software  release-08-01-10
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 <boost/format.hpp>
18 #include <boost/foreach.hpp>
19 #include <boost/algorithm/string.hpp>
20 
21 #include <G4LogicalVolume.hh>
22 #include <G4PVPlacement.hh>
23 
24 //Shapes
25 #include <G4Box.hh>
26 #include <G4UserLimits.hh>
27 
28 using namespace std;
29 using namespace boost;
30 
31 namespace Belle2 {
38  namespace srsensor {
39 
40  // Register the creator
43 
44  DiamondCreator::DiamondCreator(): m_sensitive(0)
45  {
46  //m_sensitive = new SensitiveDetector();
47  }
48 
50  {
51  if (m_sensitive) delete m_sensitive;
52  }
53 
54  void DiamondCreator::create(const GearDir& content, G4LogicalVolume& topVolume, geometry::GeometryTypes /* type */)
55  {
56 
58 
59  //lets get the stepsize parameter with a default value of 5 µm
60  double stepSize = content.getLength("stepSize", 5 * CLHEP::um);
61 
62  //no get the array. Notice that the default framework unit is cm, so the
63  //values will be automatically converted
64  vector<double> bar_diamond = content.getArray("bar_diamond");
65  B2INFO("Contents of bar_diamond: ");
66  BOOST_FOREACH(double value, bar_diamond) {
67  B2INFO("value: " << value);
68  }
69  int diamondNb = 200;
70  //Lets loop over all the Active nodes
71  BOOST_FOREACH(const GearDir & activeParams, content.getNodes("Active")) {
72 
73  //create diamond volume
74  G4Box* s_DIAMOND = new G4Box("s_DIAMOND",
75  activeParams.getLength("diamond_dx")*CLHEP::cm,
76  activeParams.getLength("diamond_dy")*CLHEP::cm,
77  activeParams.getLength("diamond_dz")*CLHEP::cm);
78 
79  string matDIAMOND = activeParams.getString("MaterialDIAMOND");
80  G4LogicalVolume* l_DIAMOND = new G4LogicalVolume(s_DIAMOND, geometry::Materials::get(matDIAMOND), "l_DIAMOND", 0, m_sensitive);
81 
82  //Lets limit the Geant4 stepsize inside the volume
83  l_DIAMOND->SetUserLimits(new G4UserLimits(stepSize));
84 
85  //position diamond volume
86  G4ThreeVector DIAMONDpos = G4ThreeVector(
87  activeParams.getLength("x_diamond") * CLHEP::cm,
88  activeParams.getLength("y_diamond") * CLHEP::cm,
89  activeParams.getLength("z_diamond") * CLHEP::cm
90  );
91 
92  G4RotationMatrix* rot_diamond = new G4RotationMatrix();
93  rot_diamond->rotateX(activeParams.getAngle("AngleX"));
94  rot_diamond->rotateY(activeParams.getAngle("AngleY"));
95  rot_diamond->rotateZ(activeParams.getAngle("AngleZ"));
96  //geometry::setColor(*l_DIAMOND, "#006699");
97 
98  new G4PVPlacement(rot_diamond, DIAMONDpos, l_DIAMOND, "p_DIAMOND", &topVolume, false, diamondNb);
99 
100  diamondNb++;
101  }
102 
103  }
104  } // srsensor namespace
106 } // Belle2 namespace
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
Definition: GearDir.h:69
double getAngle(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard angle unit.
Definition: Interface.h:299
double getLength(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard length unit.
Definition: Interface.h:259
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 indiciating 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.
Very simple class to provide an easy way to register creators with the CreatorManager.