20#include <TGeoVolume.h>
33 : mLayerNumber(layerNumber), mLayerName(layerName), mInnerRadius(rInn), mLength(
length)
50 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
53 TGeoVolume* sensVol =
new TGeoVolume(sensName.c_str(), sensor, medSi);
54 sensVol->SetLineColor(kYellow);
61 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
64 TGeoVolume* metalVol =
new TGeoVolume(metalName.c_str(), metalStack, medSi);
65 metalVol->SetLineColor(kGray);
72 TGeoMedium* medAir = gGeoManager->GetMedium(
"TRK_AIR$");
74 TGeoVolume* layerVol =
new TGeoVolume(
mLayerName.c_str(),
layer, medAir);
75 layerVol->SetLineColor(kYellow);
78 LOGP(
debug,
"Inserting {} in {} ", sensVol->GetName(), layerVol->GetName());
79 layerVol->AddNode(sensVol, 1,
nullptr);
82 LOGP(
debug,
"Inserting {} in {} ", metalVol->GetName(), layerVol->GetName());
83 layerVol->AddNode(metalVol, 1,
nullptr);
85 LOGP(
debug,
"Inserting {} in {} ", layerVol->GetName(), motherVolume->GetName());
86 motherVolume->AddNode(layerVol, 1,
nullptr);
92 :
TRKCylindricalLayer(layerNumber, layerName, rInn, numberOfModules * sModuleLength, thickOrX2X0,
mode), mTiltAngle(tiltAngle), mNumberOfStaves(numberOfStaves), mNumberOfModules(numberOfModules)
94 assert(numberOfStaves % 2 == 0 &&
"Error: numberOfStaves must be even!");
99 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
102 TGeoVolume* sensVol =
new TGeoVolume(sensName.c_str(), sensor, medSi);
103 sensVol->SetLineColor(kYellow);
110 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
113 TGeoVolume* deadVol =
new TGeoVolume(deadName.c_str(), deadzone, medSi);
114 deadVol->SetLineColor(kGray);
121 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
124 TGeoVolume* metalVol =
new TGeoVolume(metalName.c_str(), metalStack, medSi);
125 metalVol->SetLineColor(kGray);
132 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
135 TGeoVolume* chipVol =
new TGeoVolume(chipName.c_str(), chip, medSi);
136 chipVol->SetLineColor(kYellow);
139 TGeoCombiTrans* transSens =
new TGeoCombiTrans();
142 TGeoCombiTrans* transDead =
new TGeoCombiTrans();
145 TGeoCombiTrans* transMetal =
new TGeoCombiTrans();
157 LOGP(
debug,
"Inserting {} in {} ", sensVol->GetName(), chipVol->GetName());
158 chipVol->AddNode(sensVol, 1, transSens);
160 LOGP(
debug,
"Inserting {} in {} ", deadVol->GetName(), chipVol->GetName());
161 chipVol->AddNode(deadVol, 1, transDead);
163 LOGP(
debug,
"Inserting {} in {} ", metalVol->GetName(), chipVol->GetName());
164 chipVol->AddNode(metalVol, 1, transMetal);
171 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
173 TGeoShape*
module = new TGeoBBox(sModuleWidth / 2, mChipThickness / 2, sModuleLength / 2);
174 TGeoVolume* moduleVol =
new TGeoVolume(moduleName.c_str(), module, medSi);
175 moduleVol->SetLineColor(kYellow);
181 TGeoCombiTrans* transLeft =
new TGeoCombiTrans();
182 transLeft->SetTranslation(xLeft, 0, zLeft);
183 TGeoRotation* rot =
new TGeoRotation();
185 transLeft->SetRotation(rot);
186 LOGP(
debug,
"Inserting {} in {} ", chipVolLeft->GetName(), moduleVol->GetName());
187 moduleVol->AddNode(chipVolLeft, iChip * 2, transLeft);
192 TGeoCombiTrans* transRight =
new TGeoCombiTrans();
193 transRight->SetTranslation(xRight, 0, zRight);
194 LOGP(
debug,
"Inserting {} in {} ", chipVolRight->GetName(), moduleVol->GetName());
195 moduleVol->AddNode(chipVolRight, iChip * 2 + 1, transRight);
204 const float staveSizeX = staveWidth;
215 double u_max = avgRadius * std::sin(
alpha) + staveSizeX / 2.0;
216 double v_max = avgRadius * std::cos(
alpha) + staveSizeY / 2.0;
217 double radiusMax = std::sqrt(u_max * u_max + v_max * v_max);
220 double perpDistance = avgRadius * std::cos(
alpha) - staveSizeY / 2.0;
223 double projDistance = avgRadius * std::sin(
alpha);
226 if (projDistance <= staveSizeX / 2.0) {
229 radiusMin = perpDistance;
232 double u_min = projDistance - staveSizeX / 2.0;
233 radiusMin = std::sqrt(u_min * u_min + perpDistance * perpDistance);
237 const float precisionMargin = 0.05f;
239 return {radiusMin - precisionMargin, radiusMax + precisionMargin};
245 :
TRKSegmentedLayer(layerNumber, layerName, rInn, tiltAngle, numberOfStaves, numberOfModules, thickOrX2X0,
mode), mStaggerOffset(staggerOffset)
251 mStaggerOffset = -staggerOffset;
252 LOGP(info,
"Layer {} is flipped: sensor and metal stack positions are switched",
mLayerNumber);
258 TGeoMedium* medAir = gGeoManager->GetMedium(
"TRK_AIR$");
261 TGeoVolume* staveVol =
new TGeoVolume(staveName.c_str(), stave, medAir);
262 staveVol->SetLineColor(kYellow);
267 TGeoCombiTrans* trans =
new TGeoCombiTrans();
268 trans->SetTranslation(0, 0, zPos);
269 LOGP(
debug,
"Inserting {} in {} ", moduleVol->GetName(), staveVol->GetName());
270 staveVol->AddNode(moduleVol, iModule, trans);
279 auto [rMin, rMax] = getBoundingRadii(sStaveWidth);
281 TGeoMedium* medAir = gGeoManager->GetMedium(
"TRK_AIR$");
283 TGeoTube*
layer =
new TGeoTube(rMin, rMax,
mLength / 2);
284 TGeoVolume* layerVol =
new TGeoVolume(
mLayerName.c_str(),
layer, medAir);
285 layerVol->SetLineColor(kYellow);
293 const double avgRadiusOuter = avgRadiusInner + mStaggerOffset;
297 double theta1 = std::atan(sStaveWidth / 2 /
mInnerRadius);
298 double st = std::sin(theta);
299 double ct = std::cos(theta);
302 LOGP(info,
"Creating a layer with {} staves and {} mm overlap",
mNumberOfStaves, overlap * 10);
306 TGeoCombiTrans* trans =
new TGeoCombiTrans();
308 double phi = (
mNumberOfStaves % 4 == 0) ? theta * (iStave + 0.5) : theta * iStave;
309 double phiDeg = phi * TMath::RadToDeg();
310 TGeoRotation* rot =
new TGeoRotation(
"rot", phiDeg + 90 +
mTiltAngle, 0, 0);
311 trans->SetRotation(rot);
313 float trueRadius = (
mLayerNumber == 3 ||
mLayerNumber == 4) ? (iStave % 2 == 0 ? avgRadiusInner : avgRadiusOuter) : avgRadiusInner;
314 trans->SetTranslation(trueRadius * std::cos(phi), trueRadius * std::sin(phi), 0);
315 LOGP(
debug,
"Inserting {} in {} ", staveVol->GetName(), layerVol->GetName());
316 layerVol->AddNode(staveVol, iStave, trans);
319 LOGP(
debug,
"Inserting {} in {} ", layerVol->GetName(), motherVolume->GetName());
320 motherVolume->AddNode(layerVol, 1,
nullptr);
323std::pair<float, float> TRKMLLayer::getBoundingRadii(
double staveWidth)
const
330 return {defaultRadiusMin, defaultRadiusMax};
345 const float avgRadiusStaggered = avgRadiusInner + mStaggerOffset;
347 const float staveSizeX = staveWidth;
351 const float precisionMargin = 0.05f;
356 float u_max = avgRadiusStaggered * std::sin(
alpha) + staveSizeX / 2.0;
357 float v_max = avgRadiusStaggered * std::cos(
alpha) + staveSizeY / 2.0;
358 float radiusMax = std::sqrt(u_max * u_max + v_max * v_max);
360 return {defaultRadiusMin, radiusMax + precisionMargin};
365 double perpDistance = avgRadiusStaggered * std::cos(
alpha) - staveSizeY / 2.0;
366 double projDistance = avgRadiusStaggered * std::sin(
alpha);
369 if (projDistance <= staveSizeX / 2.0) {
370 newRadiusMin = perpDistance;
372 double u_min = projDistance - staveSizeX / 2.0;
373 newRadiusMin = std::sqrt(u_min * u_min + perpDistance * perpDistance);
376 return {newRadiusMin - precisionMargin, defaultRadiusMax};
383 :
TRKSegmentedLayer(layerNumber, layerName, rInn, tiltAngle, numberOfStaves, numberOfModules, thickOrX2X0,
mode)
389 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
392 TGeoVolume* halfStaveVol =
new TGeoVolume(halfStaveName.c_str(), halfStave, medSi);
393 halfStaveVol->SetLineColor(kYellow);
398 TGeoCombiTrans* trans =
new TGeoCombiTrans();
399 trans->SetTranslation(0, 0, zPos);
400 LOGP(
debug,
"Inserting {} in {} ", moduleVol->GetName(), halfStaveVol->GetName());
401 halfStaveVol->AddNode(moduleVol, iModule, trans);
410 TGeoVolume* staveVol =
new TGeoVolumeAssembly(staveName.c_str());
413 TGeoCombiTrans* transLeft =
new TGeoCombiTrans();
414 transLeft->SetTranslation(-(sHalfStaveWidth - sInStaveOverlap) / 2, 0, 0);
415 LOGP(
debug,
"Inserting {} in {} ", halfStaveVolLeft->GetName(), staveVol->GetName());
416 staveVol->AddNode(halfStaveVolLeft, 0, transLeft);
419 TGeoCombiTrans* transRight =
new TGeoCombiTrans();
420 transRight->SetTranslation((sHalfStaveWidth - sInStaveOverlap) / 2, 0.2, 0);
421 LOGP(
debug,
"Inserting {} in {} ", halfStaveVolRight->GetName(), staveVol->GetName());
422 staveVol->AddNode(halfStaveVolRight, 1, transRight);
430 auto [rMin, rMax] = getBoundingRadii(sStaveWidth);
432 TGeoMedium* medAir = gGeoManager->GetMedium(
"TRK_AIR$");
434 TGeoTube*
layer =
new TGeoTube(rMin, rMax,
mLength / 2);
435 TGeoVolume* layerVol =
new TGeoVolume(
mLayerName.c_str(),
layer, medAir);
436 layerVol->SetLineColor(kYellow);
439 int nStaves = (
int)std::ceil(
mInnerRadius * 2 * TMath::Pi() / sStaveWidth);
440 nStaves += nStaves % 2;
446 double theta = 2. * TMath::Pi() / nStaves;
447 double theta1 = std::atan(sStaveWidth / 2 /
mInnerRadius);
448 double st = std::sin(theta);
449 double ct = std::cos(theta);
452 LOGP(info,
"Creating a layer with {} staves and {} mm overlap", nStaves, overlap * 10);
454 for (
int iStave = 0; iStave < nStaves; iStave++) {
456 TGeoCombiTrans* trans =
new TGeoCombiTrans();
457 double phi = theta * iStave;
458 double phiDeg = phi * TMath::RadToDeg();
459 TGeoRotation* rot =
new TGeoRotation(
"rot", phiDeg + 90 +
mTiltAngle, 0, 0);
460 trans->SetRotation(rot);
462 trans->SetTranslation(avgRadius * std::cos(phi), avgRadius * std::sin(phi), 0);
463 LOGP(
debug,
"Inserting {} in {} ", staveVol->GetName(), layerVol->GetName());
464 layerVol->AddNode(staveVol, iStave, trans);
467 LOGP(
debug,
"Inserting {} in {} ", layerVol->GetName(), motherVolume->GetName());
468 motherVolume->AddNode(layerVol, 1,
nullptr);
471std::pair<float, float> TRKOTLayer::getBoundingRadii(
double staveWidth)
const
475 return {radiusMin - 0.201f, radiusMax};
static const char * getTRKStavePattern()
static const char * getTRKChipPattern()
static const char * getTRKSensorPattern()
static const char * getTRKDeadzonePattern()
static const char * getTRKHalfStavePattern()
static const char * getTRKMetalStackPattern()
static const char * getTRKModulePattern()
TRKCylindricalLayer()=default
static constexpr float Si_X0
virtual void createLayer(TGeoVolume *motherVolume)
virtual TGeoVolume * createSensor()
virtual TGeoVolume * createMetalStack()
static constexpr double sSensorThickness
void createLayer(TGeoVolume *motherVolume) override
TGeoVolume * createStave() override
TGeoVolume * createHalfStave()
void createLayer(TGeoVolume *motherVolume) override
TGeoVolume * createStave() override
static constexpr double sChipWidth
TGeoVolume * createMetalStack() override
static constexpr int sHalfNumberOfChips
TGeoVolume * createSensor() override
TRKSegmentedLayer()=default
TGeoVolume * createModule()
static constexpr double sChipLength
TGeoVolume * createChip()
static constexpr double sDeadzoneWidth
static constexpr double sModuleLength
static constexpr double sModuleWidth
TGeoVolume * createDeadzone()
virtual std::pair< float, float > getBoundingRadii(double staveWidth) const
GLfloat GLfloat GLfloat alpha
GLuint GLsizei GLsizei * length
GLenum GLuint GLint GLint layer
constexpr double outerEdgeLongSide
constexpr double outerEdgeShortSide
constexpr double interChips
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)