Bug Summary

File:beast/microtpc/geometry/src/MicrotpcCreator.cc
Warning:line 62, column 74
Although the value stored to 'a' is used in the enclosing expression, the value is never actually read from 'a'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -O3 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name MicrotpcCreator.cc -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/data/b2soft/buildbot/development/build -fcoverage-compilation-dir=/data/b2soft/buildbot/development/build -resource-dir /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/lib/clang/21 -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/c++ -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/c++/x86_64-redhat-linux -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/c++/backward -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/python3.12 -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include/CLHEP -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/Geant4 -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include/root -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include/belle_legacy -I include/ -D _PACKAGE_="beast" -D G4UI_USE_TCSH -D RaveDllExport= -D HAS_SQLITE -D HAS_CALLGRIND -I include -I /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/libxml2 -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../include/c++ -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../include/c++/x86_64-redhat-linux -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../include/c++/backward -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-missing-braces -Wno-unused-command-line-argument -std=c++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /scan_build/2026-05-31-004316-385593-1 -x c++ beast/microtpc/geometry/src/MicrotpcCreator.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/microtpc/geometry/MicrotpcCreator.h>
10#include <beast/microtpc/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#include "G4Tubs.hh"
25
26//Visualization
27#include "G4Colour.hh"
28#include <G4VisAttributes.hh>
29
30using namespace std;
31
32namespace Belle2 {
33
34 /** Namespace to encapsulate code needed for simulation and reconstrucion of the MICROTPC detector */
35 namespace microtpc {
36
37 // Register the creator
38 /** Creator creates the micro-tpc geometry */
39 geometry::CreatorFactory<MicrotpcCreator> MicrotpcFactory("MICROTPCCreator");
40
41 MicrotpcCreator::MicrotpcCreator(): m_sensitive(0)
42 {
43 //m_sensitive = new SensitiveDetector();
44 }
45
46 MicrotpcCreator::~MicrotpcCreator()
47 {
48 if (m_sensitive) delete m_sensitive;
49 }
50
51 void MicrotpcCreator::create(const GearDir& content, G4LogicalVolume& topVolume, geometry::GeometryTypes /* type */)
52 {
53
54 m_sensitive = new SensitiveDetector();
55
56 G4String symbol;
57 G4double a, z;
58 G4double density;
59 G4int ncomponents;
60
61 G4Element* H = new G4Element("Hydrogen", symbol = "H", z = 1., a = 1.00794 * CLHEP::g / CLHEP::mole);
62 G4Element* He = new G4Element("Helium", symbol = "He", z = 2., a = 4.002602 * CLHEP::g / CLHEP::mole);
Although the value stored to 'a' is used in the enclosing expression, the value is never actually read from 'a'
63 G4Element* C = new G4Element("Carbon", symbol = "C", z = 6., a = 12.01 * CLHEP::g / CLHEP::mole);
64 G4Element* O = new G4Element("Oxygen", symbol = "O", z = 8., a = 16.00 * CLHEP::g / CLHEP::mole);
65 G4Element* Si = new G4Element("Silicon", symbol = "Si", z = 14., a = 28.09 * CLHEP::g / CLHEP::mole);
66 G4Element* Cl = new G4Element("Chlore", symbol = "Cl", z = 17., a = 35.453 * CLHEP::g / CLHEP::mole);
67 G4Element* Cu = new G4Element("Copper", symbol = "Cu", z = 29., a = 63.546 * CLHEP::g / CLHEP::mole);
68 G4Element* Zn = new G4Element("Zinc", symbol = "Zn", z = 30., a = 65.38 * CLHEP::g / CLHEP::mole);
69
70 //Helium 4
71 G4Material* gas_4He = new G4Material("gas_4He", density = 0.0001664 * CLHEP::g / CLHEP::cm3, ncomponents = 1, kStateGas,
72 293.15 * CLHEP::kelvin, 1.*CLHEP::atmosphere);
73 gas_4He->AddElementByNumberOfAtoms(He, 1);
74 //C02
75 G4Material* gas_CO2 = new G4Material("gas_CO2", density = 0.001842 * CLHEP::g / CLHEP::cm3, ncomponents = 2, kStateGas,
76 293.15 * CLHEP::kelvin, 1.*CLHEP::atmosphere);
77 gas_CO2->AddElementByNumberOfAtoms(C, 1);
78 gas_CO2->AddElementByNumberOfAtoms(O, 2);
79
80 //70/30 - 4He/ CO2
81 G4Material* gasmix_4HeCO2 = new G4Material("gasmix_4HeCO2", density = 0.00066908 * CLHEP::g / CLHEP::cm3, ncomponents = 2,
82 kStateGas, 293.15 * CLHEP::kelvin, 1.*CLHEP::atmosphere);
83 gasmix_4HeCO2->AddMaterial(gas_4He, 17.409 * CLHEP::perCent);
84 gasmix_4HeCO2->AddMaterial(gas_CO2, 82.591 * CLHEP::perCent);
85
86 //c8h7cl
87 G4Material* TPC_ParylenC = new G4Material("TPC_ParylenC", density = 1.298 * CLHEP::g / CLHEP::cm3, ncomponents = 3);
88 TPC_ParylenC->AddElementByMassFraction(H, 0.050908 * CLHEP::perCent);
89 TPC_ParylenC->AddElementByMassFraction(C, 0.693276 * CLHEP::perCent);
90 TPC_ParylenC->AddElementByMassFraction(Cl, 0.255816 * CLHEP::perCent);
91
92 //G10
93 G4Material* TPC_G10 = new G4Material("TPC_G10", density = 1.700 * CLHEP::g / CLHEP::cm3, ncomponents = 4);
94 TPC_G10->AddElementByNumberOfAtoms(Si, 1);
95 TPC_G10->AddElementByNumberOfAtoms(O, 2);
96 TPC_G10->AddElementByNumberOfAtoms(C, 3);
97 TPC_G10->AddElementByNumberOfAtoms(H, 3);
98
99 //Cu - copper
100 G4Material* metalCu = new G4Material("MetalCopper", density = 8.960 * CLHEP::g / CLHEP::cm3, ncomponents = 1);
101 metalCu->AddElement(Cu, 1);
102
103 //Copper screen
104 G4Material* TPC_metaCuScreen = new G4Material("TPC_metaCuScreen", density = 8.95 * CLHEP::g / CLHEP::cm3, ncomponents = 2);
105 TPC_metaCuScreen->AddElementByMassFraction(Cu, 90.*CLHEP::perCent);
106 TPC_metaCuScreen->AddElementByMassFraction(Zn, 10.*CLHEP::perCent);
107
108
109 //lets get the stepsize parameter with a default value of 5 µm
110 double stepSize = content.getLength("stepSize", 5 * CLHEP::um);
111
112 //no get the array. Notice that the default framework unit is cm, so the
113 //values will be automatically converted
114 vector<double> bar = content.getArray("bar");
115 B2INFO("Contents of bar: ")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "beast")) { { LogVariableStream varStream
; varStream << "Contents of bar: "; Belle2::LogSystem::
Instance().sendMessage(Belle2::LogMessage(Belle2::LogConfig::
c_Info, std::move(varStream), "beast", __PRETTY_FUNCTION__, "beast/microtpc/geometry/src/MicrotpcCreator.cc"
, 115, 0)); }; } } while(false)
;
116 for (double value : bar) {
117 B2INFO("value: " << value)do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "beast")) { { LogVariableStream varStream
; varStream << "value: " << value; Belle2::LogSystem
::Instance().sendMessage(Belle2::LogMessage(Belle2::LogConfig
::c_Info, std::move(varStream), "beast", __PRETTY_FUNCTION__,
"beast/microtpc/geometry/src/MicrotpcCreator.cc", 117, 0)); }
; } } while(false)
;
118 }
119 int detID = 0;
120 //Lets loop over all the Active nodes
121 for (const GearDir& activeParams : content.getNodes("Active")) {
122
123 G4double inch = 2.54 * CLHEP::cm;
124
125 //create vessel volume inner volume will be subtracted by "inactive" gas
126 G4double dx_Vessel = activeParams.getLength("dx_Vessel") * CLHEP::cm / 2.;
127 G4double dy_Vessel = activeParams.getLength("dy_Vessel") * CLHEP::cm / 2.;
128 G4double dz_VesselEndCap = 1. / 8. / 2.*inch;
129 G4double dz_Vessel = activeParams.getLength("dz_Vessel") * CLHEP::cm / 2. + dz_VesselEndCap;
130 G4VSolid* s_Vessel = new G4Box("s_Vessel_tmp", dx_Vessel, dy_Vessel, dz_Vessel);
131
132 G4double width = 1. / 8.*inch;
133 G4double dx_iGasTPC = (dx_Vessel - width);
134 G4double dy_iGasTPC = (dy_Vessel - width);
135 G4double dz_iGasTPC = (dz_Vessel);
136
137 //create "inactive" gas volume
138 G4VSolid* s_iGasTPC = new G4Box("s_iGasTPC", dx_iGasTPC, dy_iGasTPC, dz_iGasTPC);
139
140 //create subtraction ie vessel
141 s_Vessel = new G4SubtractionSolid("s_Vessel", s_Vessel, s_iGasTPC, 0, G4ThreeVector(0, 0, 0));
142
143 G4LogicalVolume* l_Vessel = new G4LogicalVolume(s_Vessel, geometry::Materials::get("TPC_Al6061"), "l_Vessel");
144 G4LogicalVolume* l_iGasTPC = new G4LogicalVolume(s_iGasTPC, gasmix_4HeCO2, "l_iGasTPC");
145
146 G4RotationMatrix* rotXx = new G4RotationMatrix();
147 G4double AngleX = activeParams.getAngle("AngleX");
148 G4double AngleZ = activeParams.getAngle("AngleZ");
149 rotXx->rotateX(AngleX);
150 rotXx->rotateZ(AngleZ);
151 G4ThreeVector TPCpos = G4ThreeVector(
152 activeParams.getLength("TPCpos_x") * CLHEP::cm,
153 activeParams.getLength("TPCpos_y") * CLHEP::cm,
154 activeParams.getLength("TPCpos_z") * CLHEP::cm
155 );
156
157 new G4PVPlacement(rotXx, TPCpos, l_Vessel, "p_Vessel", &topVolume, false, 1);
158 new G4PVPlacement(rotXx, TPCpos, l_iGasTPC, "p_iGasTPC", &topVolume, false, 1);
159
160 B2INFO("Micro-TPC-" << detID << " placed at: " << TPCpos << " mm")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "beast")) { { LogVariableStream varStream
; varStream << "Micro-TPC-" << detID << " placed at: "
<< TPCpos << " mm"; Belle2::LogSystem::Instance(
).sendMessage(Belle2::LogMessage(Belle2::LogConfig::c_Info, std
::move(varStream), "beast", __PRETTY_FUNCTION__, "beast/microtpc/geometry/src/MicrotpcCreator.cc"
, 160, 0)); }; } } while(false)
;
161
162 /*
163 //create endcap top and bottom
164 G4double dx_VesselEndCap = dx_Vessel;
165 G4double dy_VesselEndCap = dy_Vessel;
166 G4double dz_VesselEndCap = 1. / 8. / 2.*inch;
167 G4VSolid* s_VesselEndCap = new G4Box("s_VesselEndCap", dx_VesselEndCap, dy_VesselEndCap, dz_VesselEndCap);
168
169 string matEndCap = activeParams.getString("MaterialEndCap");
170 G4LogicalVolume* l_VesselEndCap = new G4LogicalVolume(s_VesselEndCap, geometry::Materials::get(matEndCap), "l_VesselEndCap");
171
172 G4double x_VesselEndCap[2] = {0, 0};
173 //G4double y_VesselEndCap[2] = {(dz_Vessel + dz_VesselEndCap)* sin(AngleX * CLHEP::deg), (-dz_VesselEndCap - dz_Vessel - 0.00001)* sin(AngleX * CLHEP::deg)};
174 //G4double z_VesselEndCap[2] = {(dz_Vessel + dz_VesselEndCap)* cos(AngleX * CLHEP::deg), (-dz_VesselEndCap - dz_Vessel - 0.00001)* cos(AngleX * CLHEP::deg)};
175 G4double y_VesselEndCap[2] = {(dz_Vessel + dz_VesselEndCap) * sin(AngleX * CLHEP::deg),
176 (-dz_VesselEndCap - dz_Vessel) * sin(AngleX * CLHEP::deg)};
177 G4double z_VesselEndCap[2] = {(dz_Vessel + dz_VesselEndCap) * cos(AngleX * CLHEP::deg),
178 (-dz_VesselEndCap - dz_Vessel) * cos(AngleX * CLHEP::deg)};
179
180 new G4PVPlacement(rotXx, G4ThreeVector(x_VesselEndCap[0], y_VesselEndCap[0], z_VesselEndCap[0]) + TPCpos, l_VesselEndCap,
181 "p_VesselEndCapTop", &topVolume, false, 1);
182 new G4PVPlacement(rotXx, G4ThreeVector(x_VesselEndCap[1], y_VesselEndCap[1], z_VesselEndCap[1]) + TPCpos, l_VesselEndCap,
183 "p_VesselEndCapBottom", &topVolume, false, 1);
184 */
185 G4VisAttributes* orange = new G4VisAttributes(G4Colour(1, 2, 0));
186 orange->SetForceAuxEdgeVisible(true);
187 //l_VesselEndCap->SetVisAttributes(orange);
188 l_Vessel->SetVisAttributes(orange);
189
190 G4double dx_parC1 = dx_iGasTPC;
191 G4double dy_parC1 = dy_iGasTPC;
192 G4double dz_parC1 = dz_iGasTPC;
193 G4double cwidth = 0.001 / 2. * inch;
194 G4double dx_parC2 = dx_parC1 - cwidth;
195 G4double dy_parC2 = dy_parC1 - cwidth;
196 G4double dz_parC2 = dz_parC1 - cwidth;
197 G4Box* s_parC1 = new G4Box("s_parC1", dx_parC1, dy_parC1, dz_parC1);
198 G4Box* s_parC2 = new G4Box("s_parC2", dx_parC2, dy_parC2, dz_parC2);
199 G4VSolid* s_parylenC = new G4SubtractionSolid("s_parylenC", s_parC1, s_parC2, 0, G4ThreeVector(0, 0, 0));
200 G4LogicalVolume* l_parylenC = new G4LogicalVolume(s_parylenC, TPC_ParylenC, "l_parylenC");
201 new G4PVPlacement(0, G4ThreeVector(0 * CLHEP::cm, 0 * CLHEP::cm, 0 * CLHEP::cm), l_parylenC, "p_parylenC", l_iGasTPC, false, 1);
202
203 G4double dx_kap1 = dx_parC2;
204 G4double dy_kap1 = dy_parC2;
205 G4double dz_kap1 = dz_parC2;
206 G4double kwidth = 0.05 / 2. * CLHEP::cm;
207 G4double dx_kap2 = dx_kap1 - kwidth;
208 G4double dy_kap2 = dy_kap1 - kwidth;
209 G4double dz_kap2 = dz_kap1 - kwidth;
210 G4Box* s_kap1 = new G4Box("s_kap1", dx_kap1, dy_kap1, dz_kap1);
211 G4Box* s_kap2 = new G4Box("s_kap2", dx_kap2, dy_kap2, dz_kap2);
212 G4VSolid* s_kapton = new G4SubtractionSolid("s_kapton", s_kap1, s_kap2, 0, G4ThreeVector(0, 0, 0));
213 G4LogicalVolume* l_kapton = new G4LogicalVolume(s_kapton, geometry::Materials::get("TPC_Kapton"), "l_kapton");
214 new G4PVPlacement(0, G4ThreeVector(0 * CLHEP::cm, 0 * CLHEP::cm, 0 * CLHEP::cm), l_kapton, "p_kapton", l_iGasTPC, false, 1);
215
216 //ring
217 G4double w = 1.4 * CLHEP::cm;
218 G4double rodx = 9.476 * CLHEP::cm;
219 G4double rody = 6.976 * CLHEP::cm;
220 G4double ridx = rodx - w;
221 G4double ridy = rody - w;
222 //rod hole position
223 G4double xrodh = ridx / 2. + w / 8.;
224 G4double yrodh = ridy / 2. + w / 8.;
225
226 //create rods
227 G4double iR_Rod = 0.*CLHEP::mm;
228 G4double oR_Rod = 5. / 2.*CLHEP::mm;
229 G4double h_Rod = 20. / 2. * CLHEP::cm;
230 G4double sA_Rod = 0.*CLHEP::deg;
231 G4double spA_Rod = 360.*CLHEP::deg;
232 /*cout << "h_Rod " << h_Rod / CLHEP::cm
233 << " dx " << dx_kap2 / CLHEP::cm
234 << " dy " << dy_kap2 / CLHEP::cm
235 << " dz " << dz_kap2 / CLHEP::cm
236 << endl;*/
237 //G4double x_Rod[4] = {3.2 * CLHEP::cm, 3.2 * CLHEP::cm, -3.2 * CLHEP::cm, -3.2 * CLHEP::cm};
238 //G4double y_Rod[4] = {3.2 * CLHEP::cm, -3.2 * CLHEP::cm, 3.2 * CLHEP::cm, -3.2 * CLHEP::cm};
239 G4double x_Rod[4] = {xrodh, xrodh, -xrodh, -xrodh};
240 G4double y_Rod[4] = {yrodh, -yrodh, yrodh, -yrodh};
241 //G4double z_Rod = -dz_iGasTPC + h_Rod;
242 G4double z_Rod = 0. * CLHEP::cm;
243
244 G4Tubs* s_Rod = new G4Tubs("s_Rod", iR_Rod, oR_Rod, h_Rod, sA_Rod, spA_Rod);
245 G4LogicalVolume* l_Rod = new G4LogicalVolume(s_Rod, geometry::Materials::get("G4_POLYVINYL_ACETATE"), "l_Rod");
246
247 new G4PVPlacement(0, G4ThreeVector(x_Rod[0], y_Rod[0], z_Rod), l_Rod, "p_Rod_0", l_iGasTPC, false, 1);
248 new G4PVPlacement(0, G4ThreeVector(x_Rod[1], y_Rod[1], z_Rod), l_Rod, "p_Rod_1", l_iGasTPC, false, 1);
249 new G4PVPlacement(0, G4ThreeVector(x_Rod[2], y_Rod[2], z_Rod), l_Rod, "p_Rod_2", l_iGasTPC, false, 1);
250 new G4PVPlacement(0, G4ThreeVector(x_Rod[3], y_Rod[3], z_Rod), l_Rod, "p_Rod_3", l_iGasTPC, false, 1);
251
252 //create the rings
253 //G4double dx_Ring = 7.4 / 2.*CLHEP::cm;
254 //G4double dy_Ring = 7.4 / 2.*CLHEP::cm;
255 G4double dx_Ring = rodx / 2.;
256 G4double dy_Ring = rody / 2.;
257 G4double dz_Ring = 0.127 / 2.*CLHEP::cm;
258
259 G4VSolid* s_Ring = new G4Box("s_RingFilled", dx_Ring, dy_Ring, dz_Ring);
260 //G4double dx_RingHole = 5.4 / 2.*CLHEP::cm;
261 //G4double dy_RingHole = 5.4 / 2.*CLHEP::cm;
262 G4double dx_RingHole = xrodh / 2.;
263 G4double dy_RingHole = yrodh / 2.;
264 G4double dz_RingHole = dz_Ring;
265 G4VSolid* s_RingHole = new G4Box("s_RingHole", dx_RingHole, dy_RingHole, dz_RingHole);
266 s_Ring = new G4SubtractionSolid("s_Ring", s_Ring, s_RingHole, 0, G4ThreeVector(0, 0, 0));
267
268 G4double iR_RingHoles = 0.*CLHEP::mm;
269 G4double oR_RingHoles = oR_Rod;
270 G4double h_RingHoles = dz_Ring;
271 G4double sA_RingHoles = 0.*CLHEP::deg;
272 G4double spA_RingHoles = 360.*CLHEP::deg;
273 G4VSolid* s_RingHoles = new G4Tubs("s_RingHoles", iR_RingHoles, oR_RingHoles, h_RingHoles, sA_RingHoles, spA_RingHoles);
274 char Name[400];
275 for (G4int i = 0; i < 4; i++) {
276 sprintf(Name, "s_Ring_%d", i);
277 s_Ring = new G4SubtractionSolid(Name, s_Ring, s_RingHoles, 0, G4ThreeVector(x_Rod[i], y_Rod[i], 0));
278 }
279
280 G4LogicalVolume* l_Ring = new G4LogicalVolume(s_Ring, geometry::Materials::get("TPC_Al6061"), "l_Ring");
281 G4int RingNb = 10;
282 G4double hspacer = 1.*CLHEP::cm;
283 G4double offset = dz_iGasTPC - 5.*CLHEP::cm;
284
285 G4double x_Ring[40];
286 G4double y_Ring[40];
287 G4double z_Ring[40];
288 for (G4int i = 0; i < RingNb; i++) {
289 x_Ring[i] = 0;
290 y_Ring[i] = 0;
291 z_Ring[i] = -dz_iGasTPC + offset + (hspacer + 2. * dz_Ring) * i;
292 //cout << "z ring # " << i << " pos. " << z_Ring[i] / CLHEP::cm << endl;
293 sprintf(Name, "p_Ring_%d", i);
294 new G4PVPlacement(0, G4ThreeVector(x_Ring[i], y_Ring[i], z_Ring[i]), l_Ring, Name, l_iGasTPC, false, 1);
295 }
296
297 //create anode
298 G4VSolid* s_Anode = new G4Box("s_Anode", dx_Ring, dy_Ring, dz_Ring);
299 for (G4int i = 0; i < 4; i++) {
300 sprintf(Name, "s_Anode_%d", i);
301 s_Anode = new G4SubtractionSolid(Name, s_Anode, s_RingHoles, 0, G4ThreeVector(x_Rod[i], y_Rod[i], 0));
302 }
303 G4LogicalVolume* l_Anode = new G4LogicalVolume(s_Anode, geometry::Materials::get("TPC_Al6061"), "l_Anode");
304 x_Ring[10] = 0;
305 y_Ring[10] = 0;
306 z_Ring[10] = -dz_iGasTPC + offset + (hspacer + 2.*dz_Ring) * RingNb;
307 new G4PVPlacement(0, G4ThreeVector(x_Ring[RingNb], y_Ring[RingNb], z_Ring[RingNb]), l_Anode, "p_Anode", l_iGasTPC, false, 1);
308
309 //create ring spacer
310 G4double iR_RSpacer = oR_Rod;
311 G4double oR_RSpacer = oR_Rod + 2.*CLHEP::mm;
312 G4double h_RSpacer = (z_Ring[1] - dz_Ring - (z_Ring[0] + dz_Ring)) / 2.;
313 G4double sA_RSpacer = 0.*CLHEP::deg;
314 G4double spA_RSpacer = 360.*CLHEP::deg;
315 G4Tubs* s_RSpacer = new G4Tubs("s_RSpacer1", iR_RSpacer, oR_RSpacer, h_RSpacer, sA_RSpacer, spA_RSpacer);
316 G4LogicalVolume* l_RSpacer = new G4LogicalVolume(s_RSpacer, geometry::Materials::get("G4_POLYVINYL_ACETATE"), "l_RSpacer");
317
318 G4double x_RSpacer[40];
319 G4double y_RSpacer[40];
320 G4double z_RSpacer[40];
321 for (G4int i = 0; i < 10; i++) {
322 for (G4int k = 0; k < 4; k++) {
323 x_RSpacer[i] = x_Rod[k];
324 y_RSpacer[i] = y_Rod[k];
325 z_RSpacer[i] = z_Ring[i] + dz_Ring + h_RSpacer;
326 sprintf(Name, "p_RSpacer_%d_%d", i, k);
327 new G4PVPlacement(0, G4ThreeVector(x_RSpacer[i], y_RSpacer[i], z_RSpacer[i]), l_RSpacer, Name, l_iGasTPC, false, 1);
328 }
329 }
330
331 //create GEM
332 G4double dx_GEM = 50. / 2.*CLHEP::mm;
333 G4double dy_GEM = 50. / 2.*CLHEP::mm;
334 G4double dz_GEM = 1.6 / 2.*CLHEP::mm;
335
336 G4double x_GEM = 0.*CLHEP::cm;
337 G4double y_GEM = 0.*CLHEP::cm;
338 //G4double z_GEM[] = { -dz_iGasTPC + 2.*CLHEP::cm - 0.21 * CLHEP::cm - dz_GEM, -dz_iGasTPC + 2.*CLHEP::cm - dz_GEM};
339 G4double z_GEM[] = { z_Ring[0] - dz_Ring - dz_GEM, z_Ring[0] - dz_Ring - 2. * dz_GEM - 0.28 * CLHEP::cm};
340 /*cout << "ring 1 " << z_Ring[1] / CLHEP::cm << " ring 0 " << z_Ring[0] / CLHEP::cm << " gem 1 " << z_GEM[0] / CLHEP::cm << " gem 2 "
341 << z_GEM[1] / CLHEP::cm << endl;*/
342
343 G4VSolid* s_GEM = new G4Box("s_GEM", dx_GEM, dy_GEM, dz_GEM);
344 G4LogicalVolume* l_GEM = new G4LogicalVolume(s_GEM, geometry::Materials::get("TPC_Kovar"), "l_GEM");
345 for (G4int i = 0; i < 2; i++) {
346 sprintf(Name, "p_GEM_%d", i);
347 new G4PVPlacement(0, G4ThreeVector(x_GEM, y_GEM, z_GEM[i]), l_GEM, Name, l_iGasTPC, false, 1);
348 }
349
350 //create GEM support holder
351 G4double dx_GEMSupport = dx_Ring;
352 G4double dy_GEMSupport = dy_Ring;
353 G4double dz_GEMSupport = dz_GEM;
354 G4VSolid* s_GEMSupport = new G4Box("s_GEMSupport1", dx_GEMSupport, dy_GEMSupport, dz_GEMSupport);
355
356 G4double iR_GEMSupportHoles = 0.*CLHEP::mm;
357 G4double oR_GEMSupportHoles = oR_Rod;
358 G4double h_GEMSupportHoles = dz_GEMSupport;
359 G4double sA_GEMSupportHoles = 0.*CLHEP::deg;
360 G4double spA_GEMSupportHoles = 360.*CLHEP::deg;
361 G4VSolid* s_GEMSupportHoles = new G4Tubs("s_GEMSupportHoles", iR_GEMSupportHoles, oR_GEMSupportHoles, h_GEMSupportHoles,
362 sA_GEMSupportHoles, spA_GEMSupportHoles);
363 s_GEMSupport = new G4SubtractionSolid("s_GEMSupport2", s_GEMSupport, s_GEM, 0, G4ThreeVector(0, 0, 0));
364 for (G4int i = 0; i < 4; i++) {
365 sprintf(Name, "s_GEMSupport_%d", i);
366 s_GEMSupport = new G4SubtractionSolid(Name, s_GEMSupport, s_GEMSupportHoles, 0, G4ThreeVector(x_Rod[i], y_Rod[i], 0));
367 }
368
369 G4LogicalVolume* l_GEMSupport = new G4LogicalVolume(s_GEMSupport, TPC_G10, "l_GEMSupport");
370 for (G4int i = 0; i < 2; i++) {
371 sprintf(Name, "p_GEMSupport_%d", i);
372 new G4PVPlacement(0, G4ThreeVector(x_GEM, y_GEM, z_GEM[i]), l_GEMSupport, Name, l_iGasTPC, false, 1);
373 }
374 //cout <<"gem 1 " << z_GEM[0] << " gem 2 " << z_GEM[1] << " ring 22 " << z_Ring[22] << " anode " << z_Ring[23] << " dz_GEM " << dz_GEM << " dz_Ring " << dz_Ring << endl;
375 //create sensitive volume
376 G4double dx_GasTPC = 2.95 / 2. * CLHEP::cm;
377 G4double dy_GasTPC = 2.95 / 2. * CLHEP::cm;
378 G4double dz_GasTPC = (z_Ring[10] - dz_Ring - z_GEM[0] - dz_GEM) / 2.; //13.5 * CLHEP::cm;
379 cout << " dz_GasTPC " << dz_GasTPC / CLHEP::cm << endl;
380 G4Box* s_GasTPC = new G4Box("s_GasTPC", dx_GasTPC, dy_GasTPC, dz_GasTPC);
381 G4LogicalVolume* l_GasTPC = new G4LogicalVolume(s_GasTPC, gasmix_4HeCO2, "l_GasTPC", 0, m_sensitive);
382
383 //Lets limit the Geant4 stepsize inside the volume
384 l_GasTPC->SetUserLimits(new G4UserLimits(stepSize));
385
386 G4double x_GasTPC = 0;
387 G4double y_GasTPC = 0;
388 G4double z_GasTPC = z_GEM[0] + dz_GEM + dz_GasTPC;
389
390 new G4PVPlacement(0, G4ThreeVector(x_GasTPC, y_GasTPC, z_GasTPC), l_GasTPC, "p_GasTPC", l_iGasTPC, false, detID);
391
392 B2INFO("Micro-TPC-Sensitive-Volume-" << detID << " placed at: (" << TPCpos.getX() + x_GasTPC << "," << TPCpos.getY() + y_GasTPC <<do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "beast")) { { LogVariableStream varStream
; varStream << "Micro-TPC-Sensitive-Volume-" << detID
<< " placed at: (" << TPCpos.getX() + x_GasTPC <<
"," << TPCpos.getY() + y_GasTPC << "," << TPCpos
.getZ() + z_GasTPC << ") mm"; Belle2::LogSystem::Instance
().sendMessage(Belle2::LogMessage(Belle2::LogConfig::c_Info, std
::move(varStream), "beast", __PRETTY_FUNCTION__, "beast/microtpc/geometry/src/MicrotpcCreator.cc"
, 393, 0)); }; } } while(false)
393 "," << TPCpos.getZ() + z_GasTPC << ") mm")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "beast")) { { LogVariableStream varStream
; varStream << "Micro-TPC-Sensitive-Volume-" << detID
<< " placed at: (" << TPCpos.getX() + x_GasTPC <<
"," << TPCpos.getY() + y_GasTPC << "," << TPCpos
.getZ() + z_GasTPC << ") mm"; Belle2::LogSystem::Instance
().sendMessage(Belle2::LogMessage(Belle2::LogConfig::c_Info, std
::move(varStream), "beast", __PRETTY_FUNCTION__, "beast/microtpc/geometry/src/MicrotpcCreator.cc"
, 393, 0)); }; } } while(false)
;
394
395 //create pixel chip
396 G4double dx_PixelChip = dx_GasTPC;
397 G4double dy_PixelChip = dy_GasTPC;
398 G4double dz_PixelChip = 1. / 2.*CLHEP::mm;
399
400 G4double x_PixelChip = 0.*CLHEP::mm;
401 G4double y_PixelChip = 0.*CLHEP::mm;
402 G4double z_PixelChip = z_GEM[1] - 0.3 * CLHEP::cm;
403
404 G4Box* s_PixelChip = new G4Box("s_PixelChip", dx_PixelChip, dy_PixelChip, dz_PixelChip);
405 G4LogicalVolume* l_PixelChip = new G4LogicalVolume(s_PixelChip, geometry::Materials::get("G4_PLASTIC_SC_VINYLTOLUENE"),
406 "l_PixelChip");
407 new G4PVPlacement(0, G4ThreeVector(x_PixelChip, y_PixelChip, z_PixelChip), l_PixelChip, "p_PixelChip", l_iGasTPC, false, 1);
408
409 //create cu plate
410 G4double dx_CuPlate = dx_Ring;
411 G4double dy_CuPlate = dy_Ring;
412 G4double dz_CuPlate = dz_PixelChip;
413
414 G4VSolid* s_CuPlate = new G4Box("s_CuPlate", dx_CuPlate, dy_CuPlate, dz_CuPlate);
415 G4VSolid* s_HolesInCuPlate = new G4Tubs("HolesInCuPlate", iR_RingHoles, oR_RingHoles, dz_PixelChip, sA_RingHoles, spA_RingHoles);
416 for (G4int i = 0; i < 4; i++) {
417 sprintf(Name, "s_CuPlate_%d", i);
418 s_CuPlate = new G4SubtractionSolid(Name, s_CuPlate, s_HolesInCuPlate, 0, G4ThreeVector(x_Rod[i], y_Rod[i], 0));
419 }
420 s_CuPlate = new G4SubtractionSolid("s_CuPlate", s_CuPlate, s_PixelChip, 0, G4ThreeVector(0, 0, 0));
421
422
423 G4LogicalVolume* l_CuPlate = new G4LogicalVolume(s_CuPlate, TPC_metaCuScreen, "l_CuPlate");
424 new G4PVPlacement(0, G4ThreeVector(x_PixelChip, y_PixelChip, z_PixelChip), l_CuPlate, "p_CuPlate", l_iGasTPC, false, 1);
425
426 //create pixel board
427 G4double dx_PixelBoard = dx_Ring;
428 G4double dy_PixelBoard = dy_Ring;
429 G4double dz_PixelBoard = 2.*CLHEP::mm;
430
431 G4VSolid* s_PixelBoard = new G4Box("s_PixelBoard1", dx_PixelBoard, dy_PixelBoard, dz_PixelBoard);
432 G4VSolid* s_PixelBoardHoles = new G4Tubs("s_PixelBoardHoles", iR_RingHoles, oR_RingHoles, dz_PixelBoard, sA_RingHoles,
433 spA_RingHoles);
434 for (G4int i = 0; i < 4; i++) {
435 sprintf(Name, "s_PixelBoard_%d", i);
436 s_PixelBoard = new G4SubtractionSolid(Name, s_PixelBoard, s_PixelBoardHoles, 0, G4ThreeVector(x_Rod[i], y_Rod[i], 0));
437 }
438
439 G4double x_PixelBoard = 0.*CLHEP::mm;
440 G4double y_PixelBoard = 0.*CLHEP::mm;
441 G4double z_PixelBoard = z_PixelChip - dz_PixelBoard - dz_PixelChip;
442
443 G4LogicalVolume* l_PixelBoard = new G4LogicalVolume(s_PixelBoard, TPC_G10, "l_PixelBoard");
444
445 new G4PVPlacement(0, G4ThreeVector(x_PixelBoard, y_PixelBoard, z_PixelBoard), l_PixelBoard, "p_PixelBoard", l_iGasTPC, false, 1);
446 detID++;
447 }
448 }
449 } // microtpc namespace
450} // Belle2 namespace