Bug Summary

File:beast/he3tube/geometry/src/He3tubeCreator.cc
Warning:line 59, column 47
Although the value stored to 'z' is used in the enclosing expression, the value is never actually read from 'z'

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 He3tubeCreator.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/he3tube/geometry/src/He3tubeCreator.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/he3tube/geometry/He3tubeCreator.h>
10#include <beast/he3tube/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 <G4UserLimits.hh>
22#include "G4Tubs.hh"
23
24//Visualization Attributes
25#include <G4VisAttributes.hh>
26
27
28using namespace std;
29
30namespace Belle2 {
31
32 /** Namespace to encapsulate code needed for simulation and reconstrucion of the HE3TUBE detector */
33 namespace he3tube {
34
35 // Register the creator
36 /** Creator creates the He-3 tube geometry */
37 geometry::CreatorFactory<He3tubeCreator> He3tubeFactory("HE3TUBECreator");
38
39 He3tubeCreator::He3tubeCreator(): m_sensitive(0)
40 {
41 //m_sensitive = new SensitiveDetector();
42 }
43
44 He3tubeCreator::~He3tubeCreator()
45 {
46 if (m_sensitive) delete m_sensitive;
47 }
48
49 void He3tubeCreator::create(const GearDir& content, G4LogicalVolume& topVolume, geometry::GeometryTypes /* type */)
50 {
51
52 m_sensitive = new SensitiveDetector();
53
54 G4String symbol;
55 G4double a, z, n;
56 G4double abundance, density;
57 G4int ncomponents;
58
59 G4Isotope* iHe3 = new G4Isotope("iHe3", z = 2, n = 3, a = 3.0160293 * CLHEP::g / CLHEP::mole);
Although the value stored to 'z' is used in the enclosing expression, the value is never actually read from 'z'
60 G4Element* eHe3 = new G4Element("eHe3", symbol = "eHe3", ncomponents = 1);
61 eHe3->AddIsotope(iHe3, abundance = 100.);
62 G4Material* gHe3 = new G4Material("gHe3", density = 0.00066 * CLHEP::g / CLHEP::cm3, ncomponents = 1);
63 gHe3->AddElement(eHe3, 1);
64
65 //lets get the stepsize parameter with a default value of 5 µm
66 double stepSize = content.getLength("stepSize", 5 * CLHEP::um);
67
68 //no get the array. Notice that the default framework unit is cm, so the
69 //values will be automatically converted
70 int detID = 0;
71 //Lets loop over all the Active nodes
72 for (const GearDir& activeParams : content.getNodes("Active")) {
73
74 //create he3tube
75 G4double startAngle = 0.*CLHEP::deg;
76 G4double spanningAngle = 360.*CLHEP::deg;
77 G4Tubs* s_He3TUBE = new G4Tubs("s_He3TUBE",
78 activeParams.getLength("tube_innerRadius")*CLHEP::cm,
79 activeParams.getLength("tube_outerRadius")*CLHEP::cm,
80 activeParams.getLength("tube_hz")*CLHEP::cm,
81 startAngle, spanningAngle);
82
83 string matTube = activeParams.getString("MaterialTube");
84 G4LogicalVolume* l_He3TUBE = new G4LogicalVolume(s_He3TUBE, geometry::Materials::get(matTube), "l_He3TUBE");
85
86 G4VisAttributes* l_He3TubeVisAtt = new G4VisAttributes(G4Colour(0, 1.0, 1.0, 1.0));
87 l_He3TUBE->SetVisAttributes(l_He3TubeVisAtt);
88
89 //position he3tube volume
90 G4ThreeVector He3TUBEpos = G4ThreeVector(
91 activeParams.getLength("x_he3tube") * CLHEP::cm,
92 activeParams.getLength("y_he3tube") * CLHEP::cm,
93 activeParams.getLength("z_he3tube") * CLHEP::cm
94 );
95
96 G4RotationMatrix* rot_he3tube = new G4RotationMatrix();
97 rot_he3tube->rotateX(activeParams.getAngle("AngleX"));
98 rot_he3tube->rotateY(activeParams.getAngle("AngleY"));
99 rot_he3tube->rotateZ(activeParams.getAngle("AngleZ"));
100
101 //geometry::setColor(*l_HE3TUBE, "#006699");
102
103 new G4PVPlacement(rot_he3tube, He3TUBEpos, l_He3TUBE, "p_He3TUBE", &topVolume, false, 1);
104
105 B2INFO("HE3-tube-" << detID << " placed at: " << He3TUBEpos << " mm")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "beast")) { { LogVariableStream varStream
; varStream << "HE3-tube-" << detID << " placed at: "
<< He3TUBEpos << " mm"; Belle2::LogSystem::Instance
().sendMessage(Belle2::LogMessage(Belle2::LogConfig::c_Info, std
::move(varStream), "beast", __PRETTY_FUNCTION__, "beast/he3tube/geometry/src/He3tubeCreator.cc"
, 105, 0)); }; } } while(false)
;
106
107 //create endcaps
108 G4double EndcapinnerRadius = 0.;
109 G4Tubs* s_He3endcap = new G4Tubs("s_He3endcap",
110 EndcapinnerRadius,
111 activeParams.getLength("tube_outerRadius")*CLHEP::cm,
112 activeParams.getLength("endcap_hz")*CLHEP::cm,
113 startAngle, spanningAngle);
114
115 G4LogicalVolume* l_He3endcap = new G4LogicalVolume(s_He3endcap, geometry::Materials::get(matTube), "l_He3endcap");
116
117 l_He3endcap->SetVisAttributes(l_He3TubeVisAtt);
118
119 //position endcaps
120 G4ThreeVector He3endcapposTop = G4ThreeVector(
121 activeParams.getLength("x_he3tube") * CLHEP::cm,
122 activeParams.getLength("y_he3tube") * CLHEP::cm,
123 activeParams.getLength("z_he3tube") * CLHEP::cm + activeParams.getLength("tube_hz") * CLHEP::cm +
124 activeParams.getLength("endcap_hz") * CLHEP::cm
125 );
126
127 G4ThreeVector He3endcapposBot = G4ThreeVector(
128 activeParams.getLength("x_he3tube") * CLHEP::cm,
129 activeParams.getLength("y_he3tube") * CLHEP::cm,
130 activeParams.getLength("z_he3tube") * CLHEP::cm - activeParams.getLength("tube_hz") * CLHEP::cm -
131 activeParams.getLength("endcap_hz") * CLHEP::cm
132 );
133
134 new G4PVPlacement(rot_he3tube, He3endcapposTop, l_He3endcap, "p_He3endcapTop", &topVolume, false, 1);
135 new G4PVPlacement(rot_he3tube, He3endcapposBot, l_He3endcap, "p_He3endcapBot", &topVolume, false, 1);
136
137 //create he3 inactif gas
138 G4double GasinnerRadius = 0.;
139 G4Tubs* s_iHe3Gas = new G4Tubs("s_iHe3Gas",
140 GasinnerRadius,
141 activeParams.getLength("tube_innerRadius")*CLHEP::cm,
142 activeParams.getLength("tube_hz")*CLHEP::cm,
143 startAngle, spanningAngle);
144
145 //string matGas = activeParams.getString("MaterialGas");
146 G4LogicalVolume* l_iHe3Gas = new G4LogicalVolume(s_iHe3Gas, gHe3, "l_iHe3Gas");
147 l_iHe3Gas->SetVisAttributes(l_He3TubeVisAtt);
148
149 new G4PVPlacement(rot_he3tube, He3TUBEpos, l_iHe3Gas, "p_iHe3Gas", &topVolume, false, 1);
150
151 //create he3 actif gas
152 G4Tubs* s_He3Gas = new G4Tubs("s_He3Gas",
153 GasinnerRadius,
154 activeParams.getLength("gas_outerRadius")*CLHEP::cm,
155 activeParams.getLength("gas_hz")*CLHEP::cm,
156 startAngle, spanningAngle);
157
158 G4LogicalVolume* l_He3Gas = new G4LogicalVolume(s_He3Gas, gHe3, "l_He3Gas", 0, m_sensitive);
159 l_He3Gas->SetVisAttributes(l_He3TubeVisAtt);
160 //Lets limit the Geant4 stepsize inside the volume
161 l_He3Gas->SetUserLimits(new G4UserLimits(stepSize));
162
163 new G4PVPlacement(0, G4ThreeVector(0, 0, activeParams.getLength("SV_offset_inZ")*CLHEP::cm), l_He3Gas, "p_He3Gas", l_iHe3Gas, false,
164 detID);
165 B2INFO("HE3-tube-Sensitive-Volume-" << detID << " placed at: (" << He3TUBEpos.getX() << "," << He3TUBEpos.getY() << "," <<do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "beast")) { { LogVariableStream varStream
; varStream << "HE3-tube-Sensitive-Volume-" << detID
<< " placed at: (" << He3TUBEpos.getX() <<
"," << He3TUBEpos.getY() << "," << He3TUBEpos
.getZ() + activeParams.getLength("SV_offset_inZ")*CLHEP::cm <<
") mm"; Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage
(Belle2::LogConfig::c_Info, std::move(varStream), "beast", __PRETTY_FUNCTION__
, "beast/he3tube/geometry/src/He3tubeCreator.cc", 166, 0)); }
; } } while(false)
166 He3TUBEpos.getZ() + activeParams.getLength("SV_offset_inZ")*CLHEP::cm << ") mm")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "beast")) { { LogVariableStream varStream
; varStream << "HE3-tube-Sensitive-Volume-" << detID
<< " placed at: (" << He3TUBEpos.getX() <<
"," << He3TUBEpos.getY() << "," << He3TUBEpos
.getZ() + activeParams.getLength("SV_offset_inZ")*CLHEP::cm <<
") mm"; Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage
(Belle2::LogConfig::c_Info, std::move(varStream), "beast", __PRETTY_FUNCTION__
, "beast/he3tube/geometry/src/He3tubeCreator.cc", 166, 0)); }
; } } while(false)
;
167 detID++;
168 }
169 }
170 } // he3tube namespace
171} // Belle2 namespace