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#include <framework/gearbox/GearDir.h>
12
13#include <CLHEP/Units/SystemOfUnits.h>
14#include <G4Box.hh>
15#include <G4PVPlacement.hh>
16#include <G4LogicalVolume.hh>
17#include <simulation/background/BkgSensitiveDetector.h>
18
19namespace Belle2 {
24
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 = 0;
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 if (not shape) shape = new G4Box("radiationSensorDiamond", width / 2 * CLHEP::cm, length / 2 * CLHEP::cm, height / 2 * CLHEP::cm);
55 G4LogicalVolume* volume = new G4LogicalVolume(shape, material, name);
56 //add a sensitive detector implementation
57 BkgSensitiveDetector* sensitive = new BkgSensitiveDetector(m_subdetector.c_str(), id);
58 volume->SetSensitiveDetector(sensitive);
59 //and place it at the correct position
60 G4Transform3D transform = G4RotateZ3D(phi - M_PI / 2) * G4Translate3D(0, r * CLHEP::cm,
61 z * CLHEP::cm) * G4RotateX3D(-M_PI / 2 - theta);
62 new G4PVPlacement(transform, volume, name, top, false, 1);
63 }
64 }
65 }
66
68} //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.