Belle II Software  release-05-01-25
GeoVXDRadiationSensors.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <vxd/geometry/GeoVXDRadiationSensors.h>
12 #include <geometry/Materials.h>
13 
14 #include <CLHEP/Units/SystemOfUnits.h>
15 #include <G4Box.hh>
16 #include <G4PVPlacement.hh>
17 #include <simulation/background/BkgSensitiveDetector.h>
18 
19 namespace Belle2 {
25  void GeoVXDRadiationSensors::create(const GearDir& content, G4LogicalVolume& topVolume, G4LogicalVolume& envelopeVolume)
26  {
27  //Set the correct top volume to either global top or detector envelope
28  G4LogicalVolume* top = &topVolume;
29  if (content.getBool("insideEnvelope")) {
30  top = &envelopeVolume;
31  }
32 
33  //shape and material are the same for all sensors so create them now
34  const double width = content.getLength("width");
35  const double length = content.getLength("length");
36  const double height = content.getLength("height");
37  G4Box* shape = new G4Box("radiationSensorDiamond", width / 2 * CLHEP::cm, length / 2 * CLHEP::cm, height / 2 * CLHEP::cm);
38  G4Material* material = geometry::Materials::get(content.getString("material"));
39 
40  //Now loop over all positions
41  for (GearDir& position : content.getNodes("position")) {
42  //get the radial and z position
43  const double r = position.getLength("radius");
44  const double z = position.getLength("z");
45  const double theta = position.getAngle("theta");
46  //and loop over all phi positions
47  for (GearDir& sensor : position.getNodes("phi")) {
48  //we need angle and Id
49  const double phi = sensor.getAngle();
50  const int id = sensor.getInt("@id");
51  //then we create a nice name
52  const std::string name = m_subdetector + ".DiamondSensor." + std::to_string(id);
53  //and create the sensor volume
54  G4LogicalVolume* volume = new G4LogicalVolume(shape, material, name);
55  //add a sensitive detector implementation
56  BkgSensitiveDetector* sensitive = new BkgSensitiveDetector(m_subdetector.c_str(), id);
57  volume->SetSensitiveDetector(sensitive);
58  //and place it at the correct position
59  G4Transform3D transform = G4RotateZ3D(phi - M_PI / 2) * G4Translate3D(0, r * CLHEP::cm,
60  z * CLHEP::cm) * G4RotateX3D(-M_PI / 2 - theta);
61  new G4PVPlacement(transform, volume, name, top, false, 1);
62  }
63  }
64  }
65 
67 } //Belle2 namespace
Belle2::GeoVXDRadiationSensors::create
void create(const GearDir &content, G4LogicalVolume &topVolume, G4LogicalVolume &envelopeVolume)
create the Sensor geometry and assign the sensitive detector implementation.
Definition: GeoVXDRadiationSensors.cc:33
Belle2::BkgSensitiveDetector
The Class for BeamBackground Sensitive Detector.
Definition: BkgSensitiveDetector.h:34
Belle2::geometry::Materials::get
static G4Material * get(const std::string &name)
Find given material.
Definition: Materials.h:65
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::GearDir
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:41
Belle2::GeoVXDRadiationSensors::m_subdetector
std::string m_subdetector
one of "PXD" or "SVD"
Definition: GeoVXDRadiationSensors.h:53
Belle2::gearbox::Interface::getNodes
std::vector< GearDir > getNodes(const std::string &path="") const
Get vector of GearDirs which point to all the nodes the given path evaluates to.
Definition: Interface.cc:31