Belle II Software development
CsiCreator Class Reference

The creator for the CSI geometry. More...

#include <CsiCreator.h>

Inheritance diagram for CsiCreator:
CreatorBase

Public Member Functions

 CsiCreator ()
 Constructor.
 
virtual ~CsiCreator ()
 Destructor.
 
virtual void create (const GearDir &content, G4LogicalVolume &topVolume, geometry::GeometryTypes type)
 Creation of the detector geometry from Gearbox (XML).
 
 BELLE2_DEFINE_EXCEPTION (DBNotImplemented, "Cannot create geometry from Database.")
 Exception that will be thrown in createFromDB if member is not yet implemented by creator.
 
virtual void createFromDB (const std::string &name, G4LogicalVolume &topVolume, GeometryTypes type)
 Function to create the geometry from the Database.
 
virtual void createPayloads (const GearDir &content, const IntervalOfValidity &iov)
 Function to create the geometry database.
 

Protected Member Functions

void BuildEnclosure (const GearDir &content, G4AssemblyVolume *assembly, std::string side, int iEnclosure)
 Builds the crystals enclosures.
 
void PutCrystal (const GearDir &content, G4AssemblyVolume *assembly, G4Transform3D position, int iEnclosure, int iCry)
 Builds the crystals and their wrapping (foil)
 

Protected Attributes

SensitiveDetectorm_sensitive
 SensitiveDetector CSI.
 

Detailed Description

The creator for the CSI geometry.

Definition at line 30 of file CsiCreator.h.

Constructor & Destructor Documentation

◆ CsiCreator()

Constructor.

Definition at line 50 of file CsiCreator.cc.

50 : m_sensitive(0)
51 {
52 //m_sensitive = new SensitiveDetector();
53 }
SensitiveDetector * m_sensitive
SensitiveDetector CSI.
Definition: CsiCreator.h:49

◆ ~CsiCreator()

~CsiCreator ( )
virtual

Destructor.

Definition at line 55 of file CsiCreator.cc.

56 {
57 if (m_sensitive) delete m_sensitive;
58 }

Member Function Documentation

◆ BuildEnclosure()

void BuildEnclosure ( const GearDir content,
G4AssemblyVolume *  assembly,
std::string  side,
int  iEnclosure 
)
protected

Builds the crystals enclosures.

< Position of the nominal centre of crystals in the box

< Nominal position of the centre of the box

Definition at line 209 of file CsiCreator.cc.

210 {
211
212 string gearPath = "Enclosures/Enclosure";
213 int nEnclosures = content.getNumberNodes(gearPath);
214
215 if (iEnclosure > nEnclosures) {
216 B2ERROR("Enclosure index too high");
217 return ;
218 }
219
220 // Build the box (same for all)
221 double width = content.getLength("Enclosures/Width") * CLHEP::cm;
222 double length = content.getLength("Enclosures/Length") * CLHEP::cm;
223 double depth = content.getLength("Enclosures/Depth") * CLHEP::cm;
224 double thk = content.getLength("Enclosures/Thickness") * CLHEP::cm;
225 double fold = content.getLength("Enclosures/Fold") * CLHEP::cm;
226 double lidthk = content.getLength("Enclosures/LidThickness") * CLHEP::cm;
227 double halflength = 15.0 * CLHEP::cm;
228 double zshift = 0.5 * length - thk - halflength; /*< Shift of the box along z-axis to make crystal touch the panel **/
229
230 string strMatEnclosure = content.getString("Enclosures/Material", "5052-Alloy");
231 G4Material* EnclosureMat = geometry::Materials::get(strMatEnclosure);
232
233 string strMatEncloLid = content.getString("Enclosures/LidMaterial", "5052-Alloy");
234 G4Material* EncloLidMat = geometry::Materials::get(strMatEncloLid);
235
236 G4Box* outer = new G4Box("Outer", 0.5 * width, 0.5 * depth, 0.5 * length);
237 G4Box* inner = new G4Box("Inner", 0.5 * width - thk, 0.5 * depth - thk, 0.5 * length - thk);
238 G4Box* opening = new G4Box("Opening", 0.5 * width - fold, 0.5 * depth, 0.5 * length - fold);
239 G4Box* lid = new G4Box("Lid", 0.5 * width, 0.5 * lidthk, 0.5 * length);
240
241 G4ThreeVector translation(0, thk, 0);
242 G4Translate3D transform(translation);
243 G4SubtractionSolid* enclosureShapeT = new G4SubtractionSolid("EnclosureShapeT", outer, inner);
244 G4SubtractionSolid* enclosureShape = new G4SubtractionSolid("EnclosureShape",
245 enclosureShapeT, opening, transform);
246
247 //Thread the strings
248 string enclosurePath = (boost::format("/%1%[%2%]") % gearPath % iEnclosure).str();
249 string logiVolName = (boost::format("%1%Enclosure_%2%") % side % iEnclosure).str();
250 string logiLidVolName = (boost::format("%1%EnclosureLid_%2%") % side % iEnclosure).str();
251
252 // Connect the appropriate Gearbox path
253 GearDir enclosureContent(content);
254 enclosureContent.append(enclosurePath);
255
256 // Create logical volumes
257 G4LogicalVolume* logiEnclosure = new G4LogicalVolume(enclosureShape, EnclosureMat, logiVolName, 0, 0, 0);
258 G4LogicalVolume* logiEncloLid = new G4LogicalVolume(lid, EncloLidMat, logiLidVolName, 0, 0, 0);
259
260 // Read position
261 double PosZ = enclosureContent.getLength("PosZ") * CLHEP::cm;
262 double PosR = enclosureContent.getLength("PosR") * CLHEP::cm;
263 double PosT = enclosureContent.getAngle("PosT") ;
264
265 // Read Orientation
266 double Phi1 = enclosureContent.getAngle("AngPhi1") ;
267 double Theta = enclosureContent.getAngle("AngTheta") ;
268 double Phi2 = enclosureContent.getAngle("AngPhi2") ;
269
270 //Read position adjustments from nominal
271 double AdjX = enclosureContent.getLength("ShiftX") * CLHEP::cm;
272 double AdjY = enclosureContent.getLength("ShiftY") * CLHEP::cm;
273 double AdjZ = enclosureContent.getLength("ShiftZ") * CLHEP::cm;
274
275 G4Transform3D zsh = G4Translate3D(0, 0, zshift);
276 //G4Transform3D invzsh = G4Translate3D(0, 0, -zshift);
277 G4Transform3D m1 = G4RotateZ3D(Phi1);
278 G4Transform3D m2 = G4RotateY3D(Theta);
279 G4Transform3D m3 = G4RotateZ3D(Phi2);
280 G4Transform3D position = G4Translate3D(PosR * cos(PosT), PosR * sin(PosT), PosZ);
281 G4Transform3D adjust = G4Translate3D(AdjX, AdjY, AdjZ);
282 G4Transform3D lidpos = G4Translate3D(0, 0.5 * (depth + lidthk), 0);
283
284 G4Transform3D Tr = position * m3 * m2 * m1;
285 G4Transform3D ZshTr = Tr * zsh;
286 G4Transform3D ZshTrAdj = adjust * ZshTr;
287 G4Transform3D LidTr = ZshTr * lidpos;
288 G4Transform3D LidTrAdj = adjust * LidTr;
289
290 G4VisAttributes* VisAtt = new G4VisAttributes(G4Colour(1.0, 0.5, 0.0, 0.5));
291 logiEnclosure->SetVisAttributes(VisAtt);
292
293 G4VisAttributes* LidVisAtt = new G4VisAttributes(G4Colour(0.8, 1.0, 0.4, 0.5));
294 logiEncloLid->SetVisAttributes(LidVisAtt);
295 //logiEncloLid->SetVisAttributes(G4VisAttributes::GetInvisible());
296
297 B2INFO("CsIBox No. " << iEnclosure << " Nominal pos. (mm): " << ZshTr.getTranslation());
298 B2INFO(" Installed pos. (mm): " << ZshTrAdj.getTranslation());
299 B2INFO(" Rotation matrix : " << ZshTrAdj.getRotation());
300 B2INFO(" ");
301
302 assembly->AddPlacedVolume(logiEnclosure, ZshTrAdj);
303 assembly->AddPlacedVolume(logiEncloLid, LidTrAdj);
304
305
306 int nSlots = enclosureContent.getNumberNodes("CrystalInSlot");
307
308 for (int iSlot = 1; iSlot <= nSlots; iSlot++) {
309 //Thread the strings
310 string slotPath = (boost::format("/Enclosures/Slot[%1%]") % iSlot).str();
311
312 GearDir slotContent(content);
313 slotContent.append(slotPath);
314
315 double SlotX = slotContent.getLength("PosX") * CLHEP::cm;
316 double SlotY = slotContent.getLength("PosY") * CLHEP::cm;
317 double SlotZ = slotContent.getLength("PosZ") * CLHEP::cm;
318
319
320 G4Transform3D Pos = G4Translate3D(SlotX, SlotY, SlotZ);
321
322 int CryID = enclosureContent.getInt((boost::format("/CrystalInSlot[%1%]") % iSlot).str());
323
324 PutCrystal(content, assembly, adjust * Tr * Pos, iEnclosure, CryID);
325 }
326
327 return;
328
329 }
void PutCrystal(const GearDir &content, G4AssemblyVolume *assembly, G4Transform3D position, int iEnclosure, int iCry)
Builds the crystals and their wrapping (foil)
Definition: CsiCreator.cc:108
static G4Material * get(const std::string &name)
Find given material.
Definition: Materials.h:63
void fold(double xu, double A, double &x, double &kx, int &nx)
fold a coordinate (inverse of unfold).
Definition: func.h:59

◆ create()

void create ( const GearDir content,
G4LogicalVolume &  topVolume,
geometry::GeometryTypes  type 
)
virtual

Creation of the detector geometry from Gearbox (XML).

Parameters
[in]contentXML data directory.
[in]topVolumeGeant world volume.
[in]typeGeometry type.

Implements CreatorBase.

Definition at line 60 of file CsiCreator.cc.

61 {
62
64
65 //Print the type (not used for now)
66 B2DEBUG(200, "CsI Geometry Type: " << type);
67
68 // Print list of defined materials
69 /*
70 G4NistManager* nistManager = G4NistManager::Instance();
71 cout << *(G4Material::GetMaterialTable()) << endl;
72 */
73
74 G4Transform3D BrR = G4RotateZ3D(0.0);
75
76 int nEnc = content.getNumberNodes("/Enclosures/Enclosure");
77
78 G4AssemblyVolume* assemblyEnclosures = new G4AssemblyVolume();
79 for (int iEnc = 1; iEnc <= nEnc; iEnc++) {
80 BuildEnclosure(content, assemblyEnclosures, "side", iEnc);
81 //
82 }
83
84 assemblyEnclosures->MakeImprint(&topVolume, BrR);
85
86 // Show cell IDs and volume names
87 B2INFO("Positions of the individual CsI crystals");
88 CsiGeometryPar* eclp = CsiGeometryPar::Instance();
89 unsigned int i = 0;
90 for (std::vector<G4VPhysicalVolume*>::iterator it = assemblyEnclosures->GetVolumesIterator();
91 i != assemblyEnclosures->TotalImprintedVolumes();
92 ++it, ++i) {
93
94 G4VPhysicalVolume* volume = *it;
95 string VolumeName = volume->GetName();
96 if (VolumeName.find("Crystal") < string::npos) {
97 B2INFO("Crystal Number " << eclp->CsiVolNameToCellID(VolumeName) <<
98 " placed at (r[cm],[deg],z[cm]) = (" << setprecision(1) << fixed <<
99 volume->GetTranslation().perp() / CLHEP::cm << "," <<
100 volume->GetTranslation().phi() * 180.0 / M_PI << "," <<
101 volume->GetTranslation().z() / CLHEP::cm << ")");
102 }
103
104
105 }// for all physical volumes in the assembly
106 }// create
void BuildEnclosure(const GearDir &content, G4AssemblyVolume *assembly, std::string side, int iEnclosure)
Builds the crystals enclosures.
Definition: CsiCreator.cc:209
static CsiGeometryPar * Instance()
Static method to get a reference to the CsiGeometryPar instance.
VXD::SensitiveDetector< PXDSimHit, PXDTrueHit > SensitiveDetector
The PXD Sensitive Detector class.

◆ createFromDB()

void createFromDB ( const std::string &  name,
G4LogicalVolume &  topVolume,
GeometryTypes  type 
)
virtualinherited

Function to create the geometry from the Database.

Parameters
namename of the component in the database, could be used to disambiguate multiple components created with the same creator
topVolumeTop volume in which the geometry has to be placed
typeType of geometry to be build

Reimplemented in GeoMagneticField, GeoARICHCreator, BeamabortCreator, GeoCDCCreator, GeoCDCCreatorReducedCDC, GeoECLCreator, MyDBCreator, GeoBeamPipeCreator, GeoCryostatCreator, GeoFarBeamLineCreator, GeoBKLMCreator, GeoEKLMCreator, GeoKLMCreator, GeoPXDCreator, GeoCOILCreator, GeoServiceMaterialCreator, GeoSTRCreator, GeoSVDCreator, GeoTOPCreator, GeoHeavyMetalShieldCreator, and GeoVXDServiceCreator.

Definition at line 17 of file CreatorBase.cc.

18 {
19 //Do nothing but raise exception that we don't do anything
20 throw DBNotImplemented();
21 }

◆ createPayloads()

void createPayloads ( const GearDir content,
const IntervalOfValidity iov 
)
virtualinherited

Function to create the geometry database.

This function should be implemented to convert Gearbox parameters to one ore more database payloads

Parameters
contentGearDir pointing to the parameters which should be used for construction
iovinterval of validity to use when generating payloads

Reimplemented in GeoARICHCreator, BeamabortCreator, GeoCDCCreator, GeoCDCCreatorReducedCDC, GeoECLCreator, GeoMagneticField, MyDBCreator, GeoBeamPipeCreator, GeoCryostatCreator, GeoFarBeamLineCreator, GeoBKLMCreator, GeoEKLMCreator, GeoKLMCreator, GeoPXDCreator, GeoCOILCreator, GeoServiceMaterialCreator, GeoSTRCreator, GeoSVDCreator, GeoTOPCreator, GeoHeavyMetalShieldCreator, and GeoVXDServiceCreator.

Definition at line 24 of file CreatorBase.cc.

24{}

◆ PutCrystal()

void PutCrystal ( const GearDir content,
G4AssemblyVolume *  assembly,
G4Transform3D  position,
int  iEnclosure,
int  iCry 
)
protected

Builds the crystals and their wrapping (foil)

Definition at line 108 of file CsiCreator.cc.

113 {
114 if (iCry <= 0) return;
115
116 GearDir counter(content);
117 double foilthickness = counter.getLength("/Wrapping/Thickness") * CLHEP::cm;
118 G4Material* foilMaterial = geometry::Materials::get(counter.getString("/Wrapping/Material"));
119
120
121 int nCry = content.getNumberNodes("/EndCapCrystals/EndCapCrystal");
122 if (iCry > nCry) {
123 B2ERROR("CsiCreator: Crystal index too high");
124 return ;
125 }
126
127 counter.append((boost::format("/EndCapCrystals/EndCapCrystal[%1%]/") % (iCry)).str());
128 double h1 = counter.getLength("K_h1") * CLHEP::cm;
129 double h2 = counter.getLength("K_h2") * CLHEP::cm;
130 double bl1 = counter.getLength("K_bl1") * CLHEP::cm;
131 double bl2 = counter.getLength("K_bl2") * CLHEP::cm;
132 double tl1 = counter.getLength("K_tl1") * CLHEP::cm;
133 double tl2 = counter.getLength("K_tl2") * CLHEP::cm;
134 double alpha1 = counter.getAngle("K_alpha1");
135 double alpha2 = counter.getAngle("K_alpha2");
136 double halflength = counter.getLength("k_HalfLength") * CLHEP::cm;
137
138 // Read and create material
139 string strMatCrystal = counter.getString("Material", "Air");
140 G4Material* crystalMaterial = geometry::Materials::get(strMatCrystal);
141
142
143 G4VisAttributes* CrystalVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0, 1.0));
144
145 if (strMatCrystal.compare("CsI") == 0) {
146 CrystalVisAtt->SetColour(18.0 / 256, 230.0 / 256, 3.0 / 256);
147 } else if (strMatCrystal.compare("CsI-Tl") == 0) {
148 CrystalVisAtt->SetColour(0.0, 0.5, 1.0);
149 } else if (strMatCrystal.compare("LYSO") == 0) {
150 CrystalVisAtt->SetColour(0.820, 0.148, 0.1875);
151 }
152
154 double fwtrapangle1 = atan(2 * h1 / (bl1 - tl1)); // the smaller angle of the trap
155 double fwtrapangle2 = atan(2 * h2 / (bl2 - tl2));
156 double foilh1 = h1 + foilthickness;
157 double foilh2 = h2 + foilthickness;
158 double foiltl1 = tl1 + foilthickness * tan(fwtrapangle1 / 2);
159 double foilbl1 = bl1 + foilthickness / tan(fwtrapangle1 / 2);
160 double foiltl2 = tl2 + foilthickness * tan(fwtrapangle2 / 2);
161 double foilbl2 = foiltl2 + (foilbl1 - foiltl1) * foilh2 / foilh1;
162
163 double foilhalflength = halflength + foilthickness;
165
166 string cryLogiVolName = (boost::format("Enclosure_%1%_Crystal_%2%") % iEnclosure % iCry).str();
167 G4Trap* CrystalShape = new G4Trap((boost::format("sCrystal_%1%") % iCry).str().c_str(),
168 halflength, 0, 0, h1, bl1, tl1, alpha1, h2, bl2, tl2, alpha2);
169 G4LogicalVolume* Crystal = new G4LogicalVolume(CrystalShape, crystalMaterial,
170 cryLogiVolName.c_str(),
171 0, 0, 0);
172
173 Crystal->SetVisAttributes(CrystalVisAtt);
174 Crystal->SetSensitiveDetector(m_sensitive);
175
176 //cout << "CSI volume " << CrystalShape->GetCubicVolume() / CLHEP::cm / CLHEP::cm / CLHEP::cm
177 //<< " density " << crystalMaterial->GetDensity() / CLHEP::g * CLHEP::cm * CLHEP::cm * CLHEP::cm << endl;
178
180 G4Trap* Foilout = new G4Trap((boost::format("Foilout_%1%") % iCry).str().c_str(),
181 foilhalflength, 0, 0, foilh1, foilbl1,
182 foiltl1, alpha1, foilh2, foilbl2,
183 foiltl2, alpha2);
184
185 G4Trap* Foilin = new G4Trap((boost::format("solidEclCrystal_%1%") % iCry).str().c_str(),
186 halflength * avoidov, 0, 0, h1 * avoidov,
187 bl1 * avoidov, tl1 * avoidov, alpha1, h2 * avoidov,
188 bl2 * avoidov, tl2 * avoidov, alpha2);
189 G4SubtractionSolid* FoilShape = new G4SubtractionSolid((boost::format("sFoil_%1%") % iCry).str().c_str(),
190 Foilout, Foilin);
191
192 G4LogicalVolume* Foil = new G4LogicalVolume(FoilShape, foilMaterial,
193 (boost::format("Foil_%1%") % iCry).str().c_str(),
194 0, 0, 0);
195
196 G4VisAttributes* FoilVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1, 0.5));
197 Foil->SetVisAttributes(FoilVisAtt);
198
199 //Hide the foils for now...
200 Foil->SetVisAttributes(G4VisAttributes::GetInvisible());
201
202 assembly->AddPlacedVolume(Crystal, position);
203 assembly->AddPlacedVolume(Foil, position);
204
205 return ;
206
207 }
double atan(double a)
atan for double
Definition: beamHelpers.h:34
const double avoidov
foil inside is a little bit lager than crystal to avoid overlap
Definition: CsiCreator.cc:46

Member Data Documentation

◆ m_sensitive

SensitiveDetector* m_sensitive
protected

SensitiveDetector CSI.

Definition at line 49 of file CsiCreator.h.


The documentation for this class was generated from the following files: