Belle II Software development
GeoVXDRadiationSensors.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 <vxd/geometry/GeoVXDRadiationSensors.h>
10#include <geometry/Materials.h>
11
12#include <CLHEP/Units/SystemOfUnits.h>
13#include <G4Box.hh>
14#include <G4PVPlacement.hh>
15#include <simulation/background/BkgSensitiveDetector.h>
16
17namespace Belle2 {
23 void GeoVXDRadiationSensors::create(const GearDir& content, G4LogicalVolume& topVolume, G4LogicalVolume& envelopeVolume)
24 {
25 //Set the correct top volume to either global top or detector envelope
26 G4LogicalVolume* top = &topVolume;
27 if (content.getBool("insideEnvelope")) {
28 top = &envelopeVolume;
29 }
30
31 //shape and material are the same for all sensors so create them now
32 const double width = content.getLength("width");
33 const double length = content.getLength("length");
34 const double height = content.getLength("height");
35 G4Box* shape = 0;
36 G4Material* material = geometry::Materials::get(content.getString("material"));
37
38 //Now loop over all positions
39 for (GearDir& position : content.getNodes("position")) {
40 //get the radial and z position
41 const double r = position.getLength("radius");
42 const double z = position.getLength("z");
43 const double theta = position.getAngle("theta");
44 //and loop over all phi positions
45 for (GearDir& sensor : position.getNodes("phi")) {
46 //we need angle and Id
47 const double phi = sensor.getAngle();
48 const int id = sensor.getInt("@id");
49 //then we create a nice name
50 const std::string name = m_subdetector + ".DiamondSensor." + std::to_string(id);
51 //and create the sensor volume
52 if (not shape) shape = new G4Box("radiationSensorDiamond", width / 2 * CLHEP::cm, length / 2 * CLHEP::cm, height / 2 * CLHEP::cm);
53 G4LogicalVolume* volume = new G4LogicalVolume(shape, material, name);
54 //add a sensitive detector implementation
55 BkgSensitiveDetector* sensitive = new BkgSensitiveDetector(m_subdetector.c_str(), id);
56 volume->SetSensitiveDetector(sensitive);
57 //and place it at the correct position
58 G4Transform3D transform = G4RotateZ3D(phi - M_PI / 2) * G4Translate3D(0, r * CLHEP::cm,
59 z * CLHEP::cm) * G4RotateX3D(-M_PI / 2 - theta);
60 new G4PVPlacement(transform, volume, name, top, false, 1);
61 }
62 }
63 }
64
66} //Belle2 namespace
The Class for BeamBackground Sensitive Detector.
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
std::string m_subdetector
one of "PXD" or "SVD"
static G4Material * get(const std::string &name)
Find given material.
Definition: Materials.h:63
void create(const GearDir &content, G4LogicalVolume &topVolume, G4LogicalVolume &envelopeVolume)
create the Sensor geometry and assign the sensitive detector implementation.
Abstract base class for different kinds of events.