20#include "TGeoVolume.h"
21#include "TGeoMatrix.h"
22#include "TGeoManager.h"
34 return (std::fabs(phiSpanDeg - 360.0) < epsilon);
39 : mLayerNumber(layerNumber), mLayerName(layerName), mX2X0(layerX2X0), mModuleWidth(4.54)
41 constexpr double kSiX0_cm = 9.5;
49 double phiSpanDeg,
double lengthZ,
double lengthSensZ)
50 :
VDLayer(layerNumber, layerName, layerX2X0), mRadius(radius), mPhiSpanDeg(phiSpanDeg), mLengthZ(lengthZ), mLengthSensZ(lengthSensZ)
52 LOGP(info,
"Creating VD cylindrical layer: id: {} name: {} x2X0: {} radius: {} phiSpanDeg: {} lengthZ: {} lengthSensZ: {} chipThickness = {} cm",
58 double width,
double lengthZ,
double lengthSensZ)
59 :
VDLayer(layerNumber, layerName, layerX2X0), mWidth(
width), mLengthZ(lengthZ), mLengthSensZ(lengthSensZ)
62 if (mLengthSensZ <= 0 || mLengthSensZ > mLengthZ) {
63 LOGP(fatal,
"Invalid sensor length: sensZ={} layerZ={}", mLengthSensZ, mLengthZ);
65 LOGP(info,
"Creating VD rectangular layer: id: {} name: {} x2X0: {} width: {} lengthZ: {} lengthSensZ: {} chipThickness = {} cm",
71 double phiSpanDeg,
double zPos)
72 :
VDLayer(layerNumber, layerName, layerX2X0), mRMin(rMin), mRMax(rMax), mPhiSpanDeg(phiSpanDeg), mZPos(zPos)
75 LOGP(info,
"Creating VD disk layer: id: {} name: {} x2X0: {} rMin: {} rMax: {} phiSpanDeg: {} zPos: {} chipThickness = {} cm",
86 LOGP(error,
"gGeoManager is null");
89 auto* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
91 LOGP(error,
"Missing medium TRK_SILICON$");
95 const double rIn = mRadius;
97 const double halfZ = 0.5 * mLengthSensZ;
100 shape =
new TGeoTube(rIn, rOut, halfZ);
102 const double halfPhi = 0.5 * mPhiSpanDeg;
103 shape =
new TGeoTubeSeg(rIn, rOut, halfZ, -halfPhi, +halfPhi);
105 auto* vol =
new TGeoVolume(sensName.c_str(), shape, medSi);
106 vol->SetLineColor(kYellow);
107 vol->SetTransparency(30);
114 LOGP(error,
"gGeoManager is null");
117 auto* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
119 LOGP(error,
"Missing medium TRK_SILICON$");
123 const double hx = 0.5 * mWidth;
125 const double hz = 0.5 * mLengthSensZ;
127 auto* shape =
new TGeoBBox(hx, hy, hz);
128 auto* vol =
new TGeoVolume(sensName.c_str(), shape, medSi);
129 vol->SetLineColor(kYellow);
130 vol->SetTransparency(30);
138 LOGP(error,
"gGeoManager is null");
141 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
143 LOGP(error,
"Missing medium TRK_SILICON$");
146 if (mRMin < 0 || mRMax <= mRMin ||
mChipThickness <= 0 || mPhiSpanDeg <= 0 || mPhiSpanDeg > 360.0) {
147 LOGP(error,
"Invalid disk sensor dims: rMin={}, rMax={}, t={}, phiSpanDeg={}",
157 shape =
new TGeoTube(mRMin, mRMax, halfThickness);
159 const double halfPhi = 0.5 * mPhiSpanDeg;
160 shape =
new TGeoTubeSeg(mRMin, mRMax, halfThickness, -halfPhi, +halfPhi);
163 auto* sensVol =
new TGeoVolume(sensName.c_str(), shape, medSi);
164 sensVol->SetLineColor(kYellow);
165 sensVol->SetTransparency(30);
177 LOGP(error,
"gGeoManager is null");
180 auto* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
182 LOGP(error,
"Missing medium TRK_SILICON$");
196 const double halfZ = 0.5 * mLengthSensZ;
200 shape =
new TGeoTube(rIn, rOut, halfZ);
202 const double halfPhi = 0.5 * mPhiSpanDeg;
203 shape =
new TGeoTubeSeg(rIn, rOut, halfZ, -halfPhi, +halfPhi);
205 auto* vol =
new TGeoVolume(
name.c_str(), shape, medSi);
206 vol->SetLineColor(kGray);
207 vol->SetTransparency(30);
214 LOGP(error,
"gGeoManager is null");
217 auto* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
219 LOGP(error,
"Missing medium TRK_SILICON$");
231 const double hx = 0.5 * mWidth;
232 const double hy = 0.5 * metalT;
233 const double hz = 0.5 * mLengthSensZ;
235 auto* shape =
new TGeoBBox(hx, hy, hz);
236 auto* vol =
new TGeoVolume(
name.c_str(), shape, medSi);
237 vol->SetLineColor(kGray);
238 vol->SetTransparency(30);
245 LOGP(error,
"gGeoManager is null");
248 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
250 LOGP(error,
"Missing medium TRK_SILICON$");
259 if (mRMin < 0 || mRMax <= mRMin || mPhiSpanDeg <= 0 || mPhiSpanDeg > 360.0) {
260 LOGP(error,
"Invalid disk metal dims: rMin={}, rMax={}, metalT={}, phiSpanDeg={}",
261 mRMin, mRMax, metalT, mPhiSpanDeg);
268 const double halfThickness = 0.5 * metalT;
272 shape =
new TGeoTube(mRMin, mRMax, halfThickness);
274 const double halfPhi = 0.5 * mPhiSpanDeg;
275 shape =
new TGeoTubeSeg(mRMin, mRMax, halfThickness, -halfPhi, +halfPhi);
277 auto* vol =
new TGeoVolume(
name.c_str(), shape, medSi);
278 vol->SetLineColor(kGray);
279 vol->SetTransparency(30);
290 LOGP(error,
"gGeoManager is null");
293 auto* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
295 LOGP(error,
"Missing medium TRK_SILICON$");
299 std::string chipName = Form(
"%s_%s%d",
mLayerName.c_str(),
302 const double rIn = mRadius;
304 const double halfZ = 0.5 * mLengthSensZ;
306 TGeoShape* chipShape;
308 chipShape =
new TGeoTube(rIn, rOut, halfZ);
310 const double halfPhi = 0.5 * mPhiSpanDeg;
311 chipShape =
new TGeoTubeSeg(rIn, rOut, halfZ, -halfPhi, +halfPhi);
313 auto* chipVol =
new TGeoVolume(chipName.c_str(), chipShape, medSi);
317 LOGP(
debug,
"Inserting {} in {} ", sensVol->GetName(), chipVol->GetName());
318 chipVol->AddNode(sensVol, 1,
nullptr);
323 LOGP(
debug,
"Inserting {} in {} ", metalVol->GetName(), chipVol->GetName());
324 chipVol->AddNode(metalVol, 1,
nullptr);
327 chipVol->SetLineColor(kYellow);
328 chipVol->SetTransparency(30);
335 LOGP(error,
"gGeoManager is null");
338 auto* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
340 LOGP(error,
"Missing medium TRK_SILICON$");
344 std::string chipName = Form(
"%s_%s%d",
mLayerName.c_str(),
347 const double hx = 0.5 * mWidth;
349 const double hz = 0.5 * mLengthSensZ;
351 auto* chipShape =
new TGeoBBox(hx, hy, hz);
352 auto* chipVol =
new TGeoVolume(chipName.c_str(), chipShape, medSi);
357 LOGP(
debug,
"Inserting {} in {} ", sensVol->GetName(), chipVol->GetName());
358 chipVol->AddNode(sensVol, 1, transSens);
364 LOGP(
debug,
"Inserting {} in {} ", metalVol->GetName(), chipVol->GetName());
365 chipVol->AddNode(metalVol, 1, transMetal);
368 chipVol->SetLineColor(kYellow);
369 chipVol->SetTransparency(30);
376 LOGP(error,
"gGeoManager is null");
379 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
381 LOGP(error,
"Missing medium TRK_SILICON$");
386 mPhiSpanDeg <= 0 || mPhiSpanDeg > 360.0) {
387 LOGP(error,
"Invalid disk chip dims: rMin={}, rMax={}, t={}, phi={}",
392 std::string chipName = Form(
"%s_%s%d",
mLayerName.c_str(),
397 TGeoShape* chipShape;
399 chipShape =
new TGeoTube(mRMin, mRMax, halfThickness);
401 const double halfPhi = 0.5 * mPhiSpanDeg;
402 chipShape =
new TGeoTubeSeg(mRMin, mRMax, halfThickness, -halfPhi, +halfPhi);
404 auto* chipVol =
new TGeoVolume(chipName.c_str(), chipShape, medSi);
405 chipVol->SetLineColor(kYellow);
406 chipVol->SetTransparency(30);
411 auto* tSens =
new TGeoTranslation(0.0, 0.0, zSens);
412 LOGP(
debug,
"Inserting {} in {} ", sensVol->GetName(), chipVol->GetName());
413 chipVol->AddNode(sensVol, 1, tSens);
419 auto* tMetal =
new TGeoTranslation(0.0, 0.0, zMetal);
420 LOGP(
debug,
"Inserting {} in {} ", metalVol->GetName(), chipVol->GetName());
421 chipVol->AddNode(metalVol, 1, tMetal);
434 if (!motherVolume || !gGeoManager) {
435 LOGP(error,
"Null motherVolume or gGeoManager");
438 TGeoMedium* medAir = gGeoManager->GetMedium(
"TRK_AIR$");
440 LOGP(error,
"Missing TRK_AIR$");
446 mPhiSpanDeg <= 0 || mPhiSpanDeg > 360.0 ||
447 mLengthSensZ <= 0 || mLengthSensZ > mLengthZ) {
448 LOGP(error,
"Invalid cylindrical dimensions: r={}, t={}, Z={}, phi={}, sensZ={}",
454 const double rIn = mRadius;
456 const double halfZ = 0.5 * mLengthZ;
458 TGeoShape* layerShape;
460 layerShape =
new TGeoTube(rIn, rOut, halfZ);
462 const double halfPhi = 0.5 * mPhiSpanDeg;
463 layerShape =
new TGeoTubeSeg(rIn, rOut, halfZ, -halfPhi, +halfPhi);
465 auto* layerVol =
new TGeoVolume(
mLayerName.c_str(), layerShape, medAir);
466 layerVol->SetLineColor(kYellow);
467 layerVol->SetTransparency(30);
472 LOGP(error,
"VDCylindricalLayer::createChip() returned null");
475 LOGP(
debug,
"Inserting {} in {} ", chipVol->GetName(), layerVol->GetName());
476 layerVol->AddNode(chipVol, 1,
nullptr);
489 motherVolume->AddNode(layerVol, 1, combiTrans);
495 if (!motherVolume || !gGeoManager) {
496 LOGP(error,
"Null motherVolume or gGeoManager");
499 TGeoMedium* medAir = gGeoManager->GetMedium(
"TRK_AIR$");
501 LOGP(error,
"Missing TRK_AIR$");
506 mLengthSensZ <= 0 || mLengthSensZ > mLengthZ) {
507 LOGP(error,
"Invalid rectangular dims: W={}, t={}, Z={}, sensZ={}",
513 const double hx = 0.5 * mWidth;
515 const double hz = 0.5 * mLengthZ;
517 auto* layerShape =
new TGeoBBox(hx, hy, hz);
518 auto* layerVol =
new TGeoVolume(
mLayerName.c_str(), layerShape, medAir);
519 layerVol->SetLineColor(kYellow);
520 layerVol->SetTransparency(30);
525 LOGP(error,
"VDRectangularLayer::chipVol() returned null");
529 LOGP(
debug,
"Inserting {} in {} ", chipVol->GetName(), layerVol->GetName());
530 layerVol->AddNode(chipVol, 1,
nullptr);
543 motherVolume->AddNode(layerVol, 1, combiTrans);
549 if (!motherVolume || !gGeoManager) {
550 LOGP(error,
"Null motherVolume or gGeoManager");
553 TGeoMedium* medAir = gGeoManager->GetMedium(
"TRK_AIR$");
555 LOGP(error,
"Missing TRK_AIR$");
560 mPhiSpanDeg <= 0 || mPhiSpanDeg > 360.0) {
561 LOGP(error,
"Invalid disk dims: rMin={}, rMax={}, t={}, phi={}",
570 TGeoShape* layerShape;
572 layerShape =
new TGeoTube(mRMin, mRMax, halfThickness);
574 const double halfPhi = 0.5 * mPhiSpanDeg;
575 layerShape =
new TGeoTubeSeg(mRMin, mRMax, halfThickness, -halfPhi, +halfPhi);
577 auto* layerVol =
new TGeoVolume(
mLayerName.c_str(), layerShape, medAir);
578 layerVol->SetLineColor(kYellow);
579 layerVol->SetTransparency(30);
584 LOGP(error,
"VDDiskLayer::createChip() returned null");
589 layerVol->AddNode(chipVol, 1,
nullptr);
591 TGeoTranslation tz(0.0, 0.0, mZPos);
592 motherVolume->AddNode(layerVol, 1, combiTrans ? combiTrans : &tz);
static const char * getTRKChipPattern()
static const char * getTRKSensorPattern()
static const char * getTRKMetalStackPattern()
VDCylindricalLayer(int layerNumber, const std::string &layerName, double layerX2X0, double radius, double phiSpanDeg, double lengthZ, double lengthSensZ)
void createLayer(TGeoVolume *motherVolume, TGeoMatrix *combiTrans=nullptr) const override
TGeoVolume * createSensor() const
TGeoVolume * createChip() const
TGeoVolume * createMetalStack() const
TGeoVolume * createMetalStack() const
void createLayer(TGeoVolume *motherVolume, TGeoMatrix *combiTrans=nullptr) const override
TGeoVolume * createChip() const
VDDiskLayer(int layerNumber, const std::string &layerName, double layerX2X0, double rMin, double rMax, double phiSpanDeg, double zPos)
TGeoVolume * createSensor() const
TGeoVolume * createSensor() const
void createLayer(TGeoVolume *motherVolume, TGeoMatrix *combiTrans=nullptr) const override
TGeoVolume * createMetalStack() const
VDRectangularLayer(int layerNumber, const std::string &layerName, double layerX2X0, double width, double lengthZ, double lengthSensZ)
TGeoVolume * createChip() const
GLuint const GLchar * name
constexpr double thickness
bool isFullCircle(double phiSpanDeg, double epsilon=0.005)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...