18#include "TGeoVolume.h"
19#include "TGeoCompositeShape.h"
25#include "fairlogger/Logger.h"
41void ITS3Layer::getMaterials(
bool create)
43 if (gGeoManager ==
nullptr) {
44 LOGP(fatal,
"gGeoManager not initalized!");
47 mSilicon = getMaterial(
"IT3_SI$", create);
48 mAir = getMaterial(
"IT3_AIR$", create);
49 mCarbon = getMaterial(
"IT3_CARBON$", create);
52TGeoMedium* ITS3Layer::getMaterial(
const char* matName,
bool create)
54 auto mat = gGeoManager->GetMedium(matName);
57 LOGP(fatal,
"Cannot get medium {}", matName);
59 auto matDummy = gGeoManager->GetMaterial(
"MAT_DUMMY$");
60 if (matDummy ==
nullptr) {
61 LOGP(info,
"Created Dummy material");
62 matDummy =
new TGeoMaterial(
"MAT_DUMMY$", 26.98, 13, 2.7);
64 mat =
new TGeoMedium(matName, 1, matDummy);
65 LOGP(info,
"Created medium {}", matName);
78 LOGP(info,
"ITS3-Layer: Created Layer {} with mR={} (minR={}, maxR={})", mNLayer, mR, mRmin, mRmax);
79 if (motherVolume ==
nullptr) {
83 LOGP(
debug,
" `-> Attaching to motherVolume '{}'", motherVolume->GetName());
84 auto* trans =
new TGeoTranslation(0, 0, -constants::segment::lengthSensitive / 2.);
85 motherVolume->AddNode(mLayer, 0, trans);
88void ITS3Layer::createPixelArray()
90 if (mPixelArray !=
nullptr) {
98 using namespace its3c::pixelarray;
101 auto pixelArray =
new TGeoTubeSeg(mRmin, mRmax,
length / 2.,
102 pixelArrayPhi1, pixelArrayPhi2);
104 mPixelArray->SetLineColor(
color);
105 mPixelArray->RegisterYourself();
108void ITS3Layer::createTile()
110 if (mTile !=
nullptr) {
119 using namespace constants::tile;
121 mTile->VisibleDaughters();
124 auto zMoveReadout =
new TGeoTranslation(0, 0, +powerswitches::length / 2.);
125 double readoutPhi1 = 0;
126 double readoutPhi2 = readout::width / mR *
o2m::Rad2Deg;
127 auto readout =
new TGeoTubeSeg(mRmin, mRmax, readout::length / 2, readoutPhi1, readoutPhi2);
128 auto readoutVol =
new TGeoVolume(Form(
"readout%d", mNLayer), readout, mSilicon);
129 readoutVol->SetLineColor(readout::color);
130 readoutVol->RegisterYourself();
131 mTile->AddNode(readoutVol, 0, zMoveReadout);
135 mTile->AddNode(mPixelArray, 0);
139 double biasPhi2 = biasing::width / mR *
o2m::Rad2Deg + biasPhi1;
140 auto biasing =
new TGeoTubeSeg(mRmin, mRmax, biasing::length / 2, biasPhi1, biasPhi2);
141 auto biasingVol =
new TGeoVolume(Form(
"biasing%d", mNLayer), biasing, mSilicon);
142 biasingVol->SetLineColor(biasing::color);
143 biasingVol->RegisterYourself();
144 mTile->AddNode(biasingVol, 0);
148 double powerPhi1 = readoutPhi2;
149 double powerPhi2 = powerswitches::width / mR *
o2m::Rad2Deg + powerPhi1;
150 auto powerSwitches =
new TGeoTubeSeg(mRmin, mRmax, powerswitches::length / 2, powerPhi1, powerPhi2);
151 auto powerSwitchesVol =
new TGeoVolume(Form(
"powerswitches%d", mNLayer), powerSwitches, mSilicon);
152 powerSwitchesVol->SetLineColor(powerswitches::color);
153 powerSwitchesVol->RegisterYourself();
154 mTile->AddNode(powerSwitchesVol, 0, zMovePowerSwitches);
157void ITS3Layer::createRSU()
159 if (mRSU !=
nullptr) {
165 using namespace constants::rsu;
167 mRSU->VisibleDaughters();
168 int nCopyRSU{0}, nCopyDB{0};
172 double dataBackbonePhi1 = 0;
173 double dataBackbonePhi2 = databackbone::width / mR *
o2m::Rad2Deg;
174 auto dataBackbone =
new TGeoTubeSeg(mRmin, mRmax, databackbone::length / 2., dataBackbonePhi1, dataBackbonePhi2);
175 auto dataBackboneVol =
new TGeoVolume(Form(
"databackbone%d", mNLayer), dataBackbone, mSilicon);
176 dataBackboneVol->SetLineColor(databackbone::color);
177 dataBackboneVol->RegisterYourself();
184 mRSU->AddNode(mTile, nCopyRSU++,
nullptr);
185 mRSU->AddNode(mTile, nCopyRSU++, zMoveLL1);
186 mRSU->AddNode(mTile, nCopyRSU++, zMoveLL2);
187 mRSU->AddNode(dataBackboneVol, nCopyDB++, zMoveLLDB);
190 auto zMoveLR0 =
new TGeoTranslation(0, 0, +
length / 2.);
195 mRSU->AddNode(mTile, nCopyRSU++, zMoveLR0);
196 mRSU->AddNode(mTile, nCopyRSU++, zMoveLR1);
197 mRSU->AddNode(mTile, nCopyRSU++, zMoveLR2);
198 mRSU->AddNode(dataBackboneVol, nCopyDB++, zMoveLRDB);
202 auto rot =
new TGeoRotation(
"", 0, 0, -phi);
210 mRSU->AddNode(mTile, nCopyRSU++, rot);
211 mRSU->AddNode(mTile, nCopyRSU++, zMoveUL1);
212 mRSU->AddNode(mTile, nCopyRSU++, zMoveUL2);
213 mRSU->AddNode(dataBackboneVol, nCopyDB++, zMoveULDB);
216 auto zMoveUR0 =
new TGeoCombiTrans(0, 0, +
length / 2., rot);
221 mRSU->AddNode(mTile, nCopyRSU++, zMoveUR0);
222 mRSU->AddNode(mTile, nCopyRSU++, zMoveUR1);
223 mRSU->AddNode(mTile, nCopyRSU++, zMoveUR2);
224 mRSU->AddNode(dataBackboneVol, nCopyDB++, zMoveURDB);
227void ITS3Layer::createSegment()
229 if (mSegment !=
nullptr) {
237 using namespace constants::segment;
239 mSegment->VisibleDaughters();
243 mSegment->AddNode(mRSU,
i, zMove);
249 auto zMoveLEC =
new TGeoTranslation(0, 0, -lec::length / 2.);
251 new TGeoTubeSeg(mRmin, mRmax, lec::length / 2., lecPhi1, lecPhi2);
252 auto lecVol =
new TGeoVolume(Form(
"lec%d", mNLayer), lec, mSilicon);
253 lecVol->SetLineColor(lec::color);
254 lecVol->RegisterYourself();
255 mSegment->AddNode(lecVol, 0, zMoveLEC);
260 new TGeoTubeSeg(mRmin, mRmax, rec::length / 2., lecPhi1, lecPhi2);
261 auto recVol =
new TGeoVolume(Form(
"rec%d", mNLayer),
rec, mSilicon);
262 recVol->SetLineColor(rec::color);
263 recVol->RegisterYourself();
264 mSegment->AddNode(recVol, 0, zMoveREC);
267void ITS3Layer::createChip()
269 if (mChip !=
nullptr) {
277 mChip->VisibleDaughters();
280 double phiOffset = constants::segment::width / mR *
o2m::Rad2Deg;
281 auto rot =
new TGeoRotation(
"", 0, 0, phiOffset *
i);
282 mChip->AddNode(mSegment,
i, rot);
286void ITS3Layer::createCarbonForm()
288 if (mCarbonForm !=
nullptr) {
294 using namespace constants::carbonfoam;
296 mCarbonForm->VisibleDaughters();
308 auto HringC =
new TGeoTubeSeg(Form(
"HringC%d", mNLayer), mRmax, mRmax + dRadius, HringLength / 2., phiSta, phiEnd);
309 auto HringA =
new TGeoTubeSeg(Form(
"HringA%d", mNLayer), mRmax, mRmax + dRadius, HringLength / 2., phiSta, phiEnd);
310 auto HringCWithHoles = getHringShape(HringC);
311 auto HringAWithHoles = getHringShape(HringA);
312 auto HringCVol =
new TGeoVolume(Form(
"hringC%d", mNLayer), HringCWithHoles, mCarbon);
313 HringCVol->SetLineColor(
color);
314 auto HringAVol =
new TGeoVolume(Form(
"hringA%d", mNLayer), HringAWithHoles, mCarbon);
315 HringAVol->SetLineColor(
color);
316 auto zMoveHringC =
new TGeoTranslation(0, 0, -constants::segment::lec::length + HringLength / 2.);
317 auto zMoveHringA =
new TGeoTranslation(0, 0, -constants::segment::lec::length + HringLength / 2. + constants::segment::length - HringLength);
320 [[maybe_unused]]
auto longeronR =
new TGeoTubeSeg(Form(
"longeronR%d", mNLayer), mRmax, mRmax + dRadius, longeronsLength / 2, phiSta, phiSta + phiLongeronsCover);
321 [[maybe_unused]]
auto longeronL =
new TGeoTubeSeg(Form(
"longeronL%d", mNLayer), mRmax, mRmax + dRadius, longeronsLength / 2, phiEnd - phiLongeronsCover, phiEnd);
322 TString nameLongerons = Form(
"longeronR%d + longeronL%d", mNLayer, mNLayer);
323 auto longerons =
new TGeoCompositeShape(nameLongerons);
324 auto longeronsVol =
new TGeoVolume(Form(
"longerons%d", mNLayer), longerons, mCarbon);
325 longeronsVol->SetLineColor(
color);
326 auto zMoveLongerons =
new TGeoTranslation(0, 0, -constants::segment::lec::length + constants::segment::length / 2.);
328 mCarbonForm->AddNode(HringCVol, 0, zMoveHringC);
329 mCarbonForm->AddNode(HringAVol, 0, zMoveHringA);
330 mCarbonForm->AddNode(longeronsVol, 0, zMoveLongerons);
331 mCarbonForm->AddNode(mChip, 0);
334TGeoCompositeShape* ITS3Layer::getHringShape(TGeoTubeSeg* Hring)
337 using namespace constants::carbonfoam;
338 double stepPhiHoles = (Hring->GetPhi2() - Hring->GetPhi1()) / (nHoles[mNLayer]);
339 double phiHolesSta = Hring->GetPhi1() + stepPhiHoles / 2.;
340 double radiusHring = 0.5 * (Hring->GetRmin() + Hring->GetRmax());
341 TGeoCompositeShape* HringWithHoles =
nullptr;
342 TString nameAllHoles =
"";
343 for (
int iHoles = 0; iHoles <
nHoles[mNLayer]; iHoles++) {
344 double phiHole = phiHolesSta + stepPhiHoles * iHoles;
345 TString nameHole = Form(
"hole_%d_%d", iHoles, mNLayer);
346 [[maybe_unused]]
auto hole =
new TGeoTube(nameHole, 0, radiusHoles[mNLayer], 3 * Hring->GetDz());
348 auto zMoveHole =
new TGeoTranslation(Form(
"zMoveHole_%d_%d", iHoles, mNLayer), radiusHring * cos(phiHole *
o2m::Deg2Rad), radiusHring * sin(phiHole *
o2m::Deg2Rad), 0);
349 zMoveHole->RegisterYourself();
350 nameAllHoles += Form(
"hole_%d_%d:zMoveHole_%d_%d + ", iHoles, mNLayer, iHoles, mNLayer);
352 nameAllHoles.Remove(nameAllHoles.Length() - 3, 3);
353 TString nameHringWithHoles = Form(
"%s - (%s)", Hring->GetName(), nameAllHoles.Data());
354 HringWithHoles =
new TGeoCompositeShape(nameHringWithHoles);
355 return HringWithHoles;
358void ITS3Layer::createLayerImpl()
360 if (mLayer !=
nullptr) {
370 mLayer->VisibleDaughters();
375 auto rotTop =
new TGeoRotation(
"", 0, 0, +phiOffset);
376 auto rotBot =
new TGeoRotation(
"", 0, 0, phiOffset + 180);
378 mLayer->AddNode(mCarbonForm, 0, rotTop);
379 mLayer->AddNode(mCarbonForm, 1, rotBot);
385 getMaterials(createMaterials);
390 motherVolume->AddNode(mPixelArray, 0, mat);
394 motherVolume->AddNode(mTile, 0, mat);
398 motherVolume->AddNode(mRSU, 0, mat);
402 motherVolume->AddNode(mSegment, 0, mat);
406 motherVolume->AddNode(mChip, 0, mat);
410 motherVolume->AddNode(mCarbonForm, 0, mat);
416 motherVolume->AddNode(mLayer, 0, mat);
418 LOGP(info,
"Partially built ITS3-{}-{}", mNLayer,
getName(
level));
Definition of the ITS3Layer class.
Definition of the GeometryTGeo class.
static std::string_view getName(BuildLevel b)
void createLayer(TGeoVolume *motherVolume)
void buildPartial(TGeoVolume *motherVolume, TGeoMatrix *mat=nullptr, BuildLevel level=BuildLevel::kAll, bool createMaterials=false)
static const char * getITS3SegmentPattern(int layer)
static const char * getITS3ChipPattern()
static const char * getITS3TilePattern(int layer)
static const char * getITS3RSUPattern(int layer)
static const char * getITS3CarbonFormPattern(int layer)
static const char * getITS3PixelArrayPattern(int layer)
static const char * getITS3LayerPattern()
GLuint GLsizei GLsizei * length
constexpr float longeronsWidth
constexpr float edgeBetwChipAndFoam
constexpr std::array< int, 3 > nHoles
constexpr unsigned int nRSUs
constexpr std::array< unsigned int, nLayers > nSegments
constexpr std::array< float, nLayers > radiiOuter
constexpr float thickness
constexpr float equatorialGap
constexpr std::array< float, nLayers > radiiInner
constexpr std::array< float, nLayers > radii