Belle II Software development
ClawCreator.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/claw/geometry/ClawCreator.h>
10#include <beast/claw/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 "G4SubtractionSolid.hh"
23#include <G4UserLimits.hh>
24
25//Visualization Attributes
26#include <G4VisAttributes.hh>
27
28using namespace std;
29
30namespace Belle2 {
37 namespace claw {
38
39 // Register the creator
42
43 ClawCreator::ClawCreator(): m_sensitive(0)
44 {
45 //m_sensitive = new SensitiveDetector();
46 }
47
49 {
50 if (m_sensitive) delete m_sensitive;
51 }
52
53 void ClawCreator::create(const GearDir& content, G4LogicalVolume& topVolume, geometry::GeometryTypes /* type */)
54 {
55
57
58 //lets get the stepsize parameter with a default value of 5 µm
59 double stepSize = content.getLength("stepSize", 5 * CLHEP::um);
60
61 G4VisAttributes* red = new G4VisAttributes(G4Colour(1, 0, 0));
62 red->SetForceAuxEdgeVisible(true);
63 G4VisAttributes* green = new G4VisAttributes(G4Colour(0, 1, 0));
64 green->SetForceAuxEdgeVisible(true);
65 G4VisAttributes* gray = new G4VisAttributes(G4Colour(.5, .5, .5));
66 gray->SetForceAuxEdgeVisible(true);
67
68 G4VisAttributes* coppercolor = new G4VisAttributes(G4Colour(218. / 255., 138. / 255., 103. / 255.));
69 coppercolor->SetForceAuxEdgeVisible(true);
70
71 int detID = 0;
72 //Lets loop over all the Active nodes
73 for (const GearDir& activeParams : content.getNodes("Active")) {
74 /*
75 double x_pos[100];
76 double y_pos[100];
77 double x_off[100];
78 double y_off[100];
79 double z_pos[100];
80 double phi[100];
81 double thetaZ[100];
82 double r[100];
83 int dimx = 0;
84 int dimy = 0;
85 int dimx_offset = 0;
86 int dimy_offset = 0;
87 int dimz = 0;
88 int dimr_dia = 0;
89 for (double x_offset : activeParams.getArray("x_offset", {0})) {
90 x_offset *= CLHEP::cm;
91 x_off[dimx_offset] = x_offset;
92 dimx_offset++;
93 }
94 for (double y_offset : activeParams.getArray("y_offset", {0})) {
95 y_offset *= CLHEP::cm;
96 y_off[dimy_offset] = y_offset;
97 dimy_offset++;
98 }
99 for (double x : activeParams.getArray("x", {0})) {
100 x *= CLHEP::cm;
101 x_pos[dimx] = x + x_off[dimx];
102 dimx++;
103 }
104 for (double y : activeParams.getArray("y", {0})) {
105 y *= CLHEP::cm;
106 y_pos[dimy] = y + y_off[dimy];
107 dimy++;
108 }
109 for (double z : activeParams.getArray("z", {0})) {
110 z *= CLHEP::cm;
111 z_pos[dimz] = z;
112 if (dimx != 0 && dimy != 0)
113 r[dimz] = sqrt(x_pos[dimz] * x_pos[dimz] + y_pos[dimz] * y_pos[dimz]);
114 dimz++;
115 }
116 int dimPhi = 0;
117 for (double Phi : activeParams.getArray("Phi", {0})) {
118 phi[dimPhi] = Phi;
119 dimPhi++;
120 }
121 int dimThetaZ = 0;
122 for (double ThetaZ : activeParams.getArray("ThetaZ", {0})) {
123 thetaZ[dimThetaZ] = ThetaZ;
124 dimThetaZ++;
125 }
126 if (dimx == 0 && dimy == 0) {
127 for (double r_dia : activeParams.getArray("r_dia", {0})) {
128 r_dia *= CLHEP::cm;
129 r[dimr_dia] = r_dia;
130 dimr_dia++;
131 }
132 }
133 */
134 int Nscint = activeParams.getInt("Nscint");
135 G4double x = activeParams.getLength("x") * CLHEP::cm;
136 G4double y = activeParams.getLength("y") * CLHEP::cm;
137 G4double z = activeParams.getLength("z_claw") * CLHEP::cm;
138 /*G4double r = 0;
139 if (x == 0 && y == 0)
140 r = activeParams.getLength("r_claw") * CLHEP::cm;
141 else
142 r = sqrt(x * x + y * y);*/
143 //G4double phi = activeParams.getAngle("Phi");
144 //G4double thetaZ = activeParams.getAngle("ThetaZ");
145 G4double dx_board = activeParams.getLength("dx_board") / 2.*CLHEP::cm;
146 G4double dy_board = activeParams.getLength("dy_board") / 2.*CLHEP::cm;
147 G4double dz_board = activeParams.getLength("dz_board") / 2.*CLHEP::cm;
148 G4double dz_Culayer = activeParams.getLength("dz_Culayer") / 2.*CLHEP::cm;
149 G4double dx_scint = activeParams.getLength("dx_scint") / 2.*CLHEP::cm;
150 G4double dy_scint = activeParams.getLength("dy_scint") / 2.*CLHEP::cm;
151 G4double dz_scint = activeParams.getLength("dz_scint") / 2.*CLHEP::cm;
152 G4double Al_width = activeParams.getLength("Al_width") / 2.*CLHEP::cm;
153 G4double dx_Al = dx_scint + Al_width;
154 G4double dy_Al = dy_scint + Al_width;
155 G4double dz_Al = dz_scint + Al_width;
156 G4double dx_air = dx_Al;
157 G4double dy_air = dy_Al * Nscint;
158 G4double dz_air = dz_board + 2. * dz_Culayer + dz_Al;
159 //cout << " dx sol 1 " << dx_air << " sol 2 " << dx_board << endl;
160 //cout << " dy sol 1 " << dy_air << " sol 2 " << dy_board << endl;
161
162 //create air volume engloging ladder + scintillator + Al foil
163 G4Box* s_air = new G4Box("s_air", dx_air, dy_air, dz_air);
164 G4LogicalVolume* l_air = new G4LogicalVolume(s_air, geometry::Materials::get("G4_AIR"), "l_air");
165
166
167 //create claw G10 board
168 G4Box* s_board = new G4Box("s_board", dx_board, dy_board, dz_board);
169 G4LogicalVolume* l_board = new G4LogicalVolume(s_board, geometry::Materials::get("G10"), "l_board");
170 l_board->SetVisAttributes(green);
171
172 G4double r_board = dz_air - 2. * dz_Culayer - dz_board;
173
174 //create copper layer on each side of the G10 board
175 G4Box* s_Culayer = new G4Box("s_Culayer", dx_board, dy_board, dz_Culayer);
176 G4LogicalVolume* l_Culayer = new G4LogicalVolume(s_Culayer, geometry::Materials::get("Cu"), "l_Culayer");
177 l_Culayer->SetVisAttributes(coppercolor);
178
179 G4double r_Culayer_bot = r_board - dz_board - dz_Culayer;
180 G4double r_Culayer_top = r_board + dz_board + dz_Culayer;
181 //cout << " cu bot sol 1 " << r_Culayer_bot << " sol 2 " << -dz_air + dz_Culayer<< endl;
182
183 //create scintillator and Al foil around it
184 G4VSolid* s_scint = new G4Box("s_scint", dx_scint, dy_scint, dz_scint);
185 G4VSolid* s_Al = new G4Box("s_Al", dx_Al, dy_Al, dz_Al);
186 s_Al = new G4SubtractionSolid("s_Al", s_Al, s_scint, 0, G4ThreeVector(0, 0, 0));
187 G4LogicalVolume* l_Al = new G4LogicalVolume(s_Al, geometry::Materials::get("Al"), "l_Al");
188 l_Al->SetVisAttributes(gray);
189
190 G4LogicalVolume* l_scint = new G4LogicalVolume(s_scint, geometry::Materials::get("G4_POLYSTYRENE"), "l_scint", 0, m_sensitive);
191 l_scint->SetVisAttributes(red);
192 //Lets limit the Geant4 stepsize inside the volume
193 l_scint->SetUserLimits(new G4UserLimits(stepSize));
194
195 G4double r_Al = r_Culayer_bot - dz_Culayer - dz_Al;
196 //cout << " dz_air " << dz_air << " x2 " << 2. * dz_air << " r_Al " << r_Al << " tot " << r_Al + dz_Al << " sol3 " << r_Culayer_top + dz_Culayer + dz_Al << endl;
197 double z_0 = -dy_air + dy_Al;
198
199 //for(int i = 0; i < dimz; i++) {
200
201 //G4Transform3D transform = G4RotateZ3D(-M_PI / 2 + phi[i]) * G4Translate3D(0, r[i], z_pos[i]) * G4RotateX3D(-M_PI / 2 - thetaZ[i]);
202 //G4Transform3D transform = G4RotateZ3D(-M_PI / 2 + phi) * G4Translate3D(0, r, z) * G4RotateX3D(-M_PI / 2 - thetaZ);
203 G4Transform3D transform = G4Translate3D(x, y, z);
204 new G4PVPlacement(transform, l_air, "p_air", &topVolume, false, 1);
205 new G4PVPlacement(0, G4ThreeVector(0, 0, r_board), l_board, "p_board", l_air, false, 1);
206 new G4PVPlacement(0, G4ThreeVector(0, 0, r_Culayer_bot), l_Culayer, "p_Culayer_bot", l_air, false, 1);
207 new G4PVPlacement(0, G4ThreeVector(0, 0, r_Culayer_top), l_Culayer, "p_Culayer_top", l_air, false, 1);
208
209 for (int j = 0; j < Nscint; j++) {
210 double i_z = z_0 + j * 2. * dy_Al;
211
212 new G4PVPlacement(0, G4ThreeVector(0, i_z, r_Al), l_Al, "p_Al", l_air, false, 1);
213 new G4PVPlacement(0, G4ThreeVector(0, i_z, r_Al), l_scint, "p_scint", l_air, false, detID);
214 B2INFO("Phase1-CLAWS-" << detID << " placed at: " << transform.getTranslation() << " mm");
215 detID++;
216 //}
217 }
218 }
219 }
220 } // claw namespace
222} // Belle2 namespace
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
virtual ~ClawCreator()
Destructor.
Definition: ClawCreator.cc:48
ClawCreator()
Constructor.
Definition: ClawCreator.cc:43
virtual void create(const GearDir &content, G4LogicalVolume &topVolume, geometry::GeometryTypes type)
Creation of the detector geometry from Gearbox (XML).
Definition: ClawCreator.cc:53
SensitiveDetector * m_sensitive
SensitiveDetector CLAW.
Definition: ClawCreator.h:46
Sensitive Detector implementation of the CLAW detector.
static G4Material * get(const std::string &name)
Find given material.
Definition: Materials.h:63
geometry::CreatorFactory< ClawCreator > ClawFactory("CLAWCreator")
Creator creates the CLAW geometry.
GeometryTypes
Flag indiciating the type of geometry to be used.
Abstract base class for different kinds of events.
STL namespace.
Very simple class to provide an easy way to register creators with the CreatorManager.