18#include "TGeoVolume.h"
19#include "TGeoCompositeShape.h"
34void ITS3Layer::getMaterials(
bool create)
36 if (gGeoManager ==
nullptr) {
37 LOGP(fatal,
"gGeoManager not initalized!");
40 mSilicon = getMaterial(
"IT3_SI$", create);
41 mAir = getMaterial(
"IT3_AIR$", create);
42 mCarbon = getMaterial(
"IT3_CARBON$", create);
43 mCopper = getMaterial(
"IT3_COPPER$", create);
46TGeoMedium* ITS3Layer::getMaterial(
const char* matName,
bool create)
48 auto mat = gGeoManager->GetMedium(matName);
51 LOGP(fatal,
"Cannot get medium {}", matName);
53 auto matDummy = gGeoManager->GetMaterial(
"MAT_DUMMY$");
54 if (matDummy ==
nullptr) {
55 LOGP(warn,
"Created Dummy material");
56 matDummy =
new TGeoMaterial(
"MAT_DUMMY$", 26.98, 13, 2.7);
58 mat =
new TGeoMedium(matName, 1, matDummy);
59 LOGP(warn,
"Created medium {}", matName);
72 if (motherVolume ==
nullptr) {
76 auto* trans =
new TGeoTranslation(0, 0, -constants::segment::lengthSensitive / 2.);
77 motherVolume->AddNode(mLayer, 0, trans);
80void ITS3Layer::createPixelArray()
82 if (mPixelArray !=
nullptr) {
86 using namespace its3c::pixelarray;
88 auto pixelArray =
new TGeoTubeSeg(mRmin, mRmax,
length / 2., 0, pixelArrayPhi);
90 mPixelArray->SetLineColor(
color);
91 mPixelArray->RegisterYourself();
94void ITS3Layer::createTile()
96 if (mTile !=
nullptr) {
105 using namespace constants::tile;
107 mTile->VisibleDaughters();
110 auto zMoveReadout =
new TGeoTranslation(0, 0, +powerswitches::length / 2.);
111 double readoutPhi1 = 0;
112 double readoutPhi2 = readout::width / mR *
o2m::Rad2Deg;
113 auto readout =
new TGeoTubeSeg(mRmin, mRmax, readout::length / 2, readoutPhi1, readoutPhi2);
114 auto readoutVol =
new TGeoVolume(Form(
"readout%d", mNLayer), readout, mSilicon);
115 readoutVol->SetLineColor(readout::color);
116 readoutVol->RegisterYourself();
117 mTile->AddNode(readoutVol, 0, zMoveReadout);
121 auto phiRotPixelArray =
new TGeoRotation(Form(
"its3PhiPixelArrayOffset_%d", mNLayer), readoutPhi2, 0, 0);
122 mTile->AddNode(mPixelArray, 0, phiRotPixelArray);
126 double biasPhi2 = biasing::width / mR *
o2m::Rad2Deg + biasPhi1;
127 auto biasing =
new TGeoTubeSeg(mRmin, mRmax, biasing::length / 2, biasPhi1, biasPhi2);
128 auto biasingVol =
new TGeoVolume(Form(
"biasing%d", mNLayer), biasing, mSilicon);
129 biasingVol->SetLineColor(biasing::color);
130 biasingVol->RegisterYourself();
131 mTile->AddNode(biasingVol, 0);
135 double powerPhi1 = readoutPhi2;
136 double powerPhi2 = powerswitches::width / mR *
o2m::Rad2Deg + powerPhi1;
137 auto powerSwitches =
new TGeoTubeSeg(mRmin, mRmax, powerswitches::length / 2, powerPhi1, powerPhi2);
138 auto powerSwitchesVol =
new TGeoVolume(Form(
"powerswitches%d", mNLayer), powerSwitches, mSilicon);
139 powerSwitchesVol->SetLineColor(powerswitches::color);
140 powerSwitchesVol->RegisterYourself();
141 mTile->AddNode(powerSwitchesVol, 0, zMovePowerSwitches);
144void ITS3Layer::createRSU()
146 if (mRSU !=
nullptr) {
152 using namespace constants::rsu;
154 mRSU->VisibleDaughters();
155 int nCopyRSU{0}, nCopyDB{0};
159 double dataBackbonePhi1 = 0;
160 double dataBackbonePhi2 = databackbone::width / mR *
o2m::Rad2Deg;
161 auto dataBackbone =
new TGeoTubeSeg(mRmin, mRmax, databackbone::length / 2., dataBackbonePhi1, dataBackbonePhi2);
162 auto dataBackboneVol =
new TGeoVolume(Form(
"databackbone%d", mNLayer), dataBackbone, mSilicon);
163 dataBackboneVol->SetLineColor(databackbone::color);
164 dataBackboneVol->RegisterYourself();
171 mRSU->AddNode(mTile, nCopyRSU++,
nullptr);
172 mRSU->AddNode(mTile, nCopyRSU++, zMoveLL1);
173 mRSU->AddNode(mTile, nCopyRSU++, zMoveLL2);
174 mRSU->AddNode(dataBackboneVol, nCopyDB++, zMoveLLDB);
177 auto zMoveLR0 =
new TGeoTranslation(0, 0, +
length / 2.);
182 mRSU->AddNode(mTile, nCopyRSU++, zMoveLR0);
183 mRSU->AddNode(mTile, nCopyRSU++, zMoveLR1);
184 mRSU->AddNode(mTile, nCopyRSU++, zMoveLR2);
185 mRSU->AddNode(dataBackboneVol, nCopyDB++, zMoveLRDB);
189 auto rot =
new TGeoRotation(Form(
"its3RotHalfBarrel_%d", mNLayer), 0, 0, -phi);
197 mRSU->AddNode(mTile, nCopyRSU++, rot);
198 mRSU->AddNode(mTile, nCopyRSU++, zMoveUL1);
199 mRSU->AddNode(mTile, nCopyRSU++, zMoveUL2);
200 mRSU->AddNode(dataBackboneVol, nCopyDB++, zMoveULDB);
203 auto zMoveUR0 =
new TGeoCombiTrans(0, 0, +
length / 2., rot);
208 mRSU->AddNode(mTile, nCopyRSU++, zMoveUR0);
209 mRSU->AddNode(mTile, nCopyRSU++, zMoveUR1);
210 mRSU->AddNode(mTile, nCopyRSU++, zMoveUR2);
211 mRSU->AddNode(dataBackboneVol, nCopyDB++, zMoveURDB);
214void ITS3Layer::createSegment()
216 if (mSegment !=
nullptr) {
224 using namespace constants::segment;
226 mSegment->VisibleDaughters();
230 mSegment->AddNode(mRSU,
i, zMove);
236 auto zMoveLEC =
new TGeoTranslation(0, 0, -lec::length / 2.);
238 new TGeoTubeSeg(mRmin, mRmax, lec::length / 2., lecPhi1, lecPhi2);
239 auto lecVol =
new TGeoVolume(Form(
"lec%d", mNLayer), lec, mSilicon);
240 lecVol->SetLineColor(lec::color);
241 lecVol->RegisterYourself();
242 mSegment->AddNode(lecVol, 0, zMoveLEC);
247 new TGeoTubeSeg(mRmin, mRmax, rec::length / 2., lecPhi1, lecPhi2);
248 auto recVol =
new TGeoVolume(Form(
"rec%d", mNLayer),
rec, mSilicon);
249 recVol->SetLineColor(rec::color);
250 recVol->RegisterYourself();
251 mSegment->AddNode(recVol, 0, zMoveREC);
254void ITS3Layer::createChip()
256 if (mChip !=
nullptr) {
264 mChip->VisibleDaughters();
266 auto phiOffset = constants::segment::width / mR *
o2m::Rad2Deg;
268 auto rot =
new TGeoRotation(Form(
"its3PhiSegmentOffset_%d_%d", mNLayer,
i), 0, 0, phiOffset *
i);
269 mChip->AddNode(mSegment,
i, rot);
275 auto metalVol =
new TGeoVolume(Form(
"metal%d", mNLayer), metal, mCopper);
277 metalVol->RegisterYourself();
278 mChip->AddNode(metalVol, 0, zMoveMetal);
281void ITS3Layer::createCarbonForm()
283 if (mCarbonForm !=
nullptr) {
289 using namespace constants::carbonfoam;
291 mCarbonForm->VisibleDaughters();
303 auto HringC =
new TGeoTubeSeg(Form(
"HringC%d", mNLayer), mRmax, mRmax + dRadius, HringLength / 2., phiSta, phiEnd);
304 auto HringA =
new TGeoTubeSeg(Form(
"HringA%d", mNLayer), mRmax, mRmax + dRadius, HringLength / 2., phiSta, phiEnd);
305 auto HringCWithHoles = getHringShape(HringC);
306 auto HringAWithHoles = getHringShape(HringA);
307 auto HringCVol =
new TGeoVolume(Form(
"hringC%d", mNLayer), HringCWithHoles, mCarbon);
308 HringCVol->SetLineColor(
color);
309 auto HringAVol =
new TGeoVolume(Form(
"hringA%d", mNLayer), HringAWithHoles, mCarbon);
310 HringAVol->SetLineColor(
color);
311 auto zMoveHringC =
new TGeoTranslation(0, 0, -constants::segment::lec::length + HringLength / 2.);
312 auto zMoveHringA =
new TGeoTranslation(0, 0, -constants::segment::lec::length + HringLength / 2. + constants::segment::length - HringLength);
315 [[maybe_unused]]
auto longeronR =
new TGeoTubeSeg(Form(
"longeronR%d", mNLayer), mRmax, mRmax + dRadius, longeronsLength / 2, phiSta, phiSta + phiLongeronsCover);
316 [[maybe_unused]]
auto longeronL =
new TGeoTubeSeg(Form(
"longeronL%d", mNLayer), mRmax, mRmax + dRadius, longeronsLength / 2, phiEnd - phiLongeronsCover, phiEnd);
317 TString nameLongerons = Form(
"longeronR%d + longeronL%d", mNLayer, mNLayer);
318 auto longerons =
new TGeoCompositeShape(nameLongerons);
319 auto longeronsVol =
new TGeoVolume(Form(
"longerons%d", mNLayer), longerons, mCarbon);
320 longeronsVol->SetLineColor(
color);
321 auto zMoveLongerons =
new TGeoTranslation(0, 0, -constants::segment::lec::length + constants::segment::length / 2.);
323 mCarbonForm->AddNode(HringCVol, 0, zMoveHringC);
324 mCarbonForm->AddNode(HringAVol, 0, zMoveHringA);
325 mCarbonForm->AddNode(longeronsVol, 0, zMoveLongerons);
326 mCarbonForm->AddNode(mChip, 0);
329TGeoCompositeShape* ITS3Layer::getHringShape(TGeoTubeSeg* Hring)
332 using namespace constants::carbonfoam;
333 double stepPhiHoles = (Hring->GetPhi2() - Hring->GetPhi1()) / (nHoles[mNLayer]);
334 double phiHolesSta = Hring->GetPhi1() + stepPhiHoles / 2.;
335 double radiusHring = 0.5 * (Hring->GetRmin() + Hring->GetRmax());
336 TGeoCompositeShape* HringWithHoles =
nullptr;
337 TString nameAllHoles =
"";
338 for (
int iHoles = 0; iHoles <
nHoles[mNLayer]; iHoles++) {
339 double phiHole = phiHolesSta + stepPhiHoles * iHoles;
340 TString nameHole = Form(
"hole_%d_%d", iHoles, mNLayer);
341 [[maybe_unused]]
auto hole =
new TGeoTube(nameHole, 0, radiusHoles[mNLayer], 3 * Hring->GetDz());
343 auto zMoveHole =
new TGeoTranslation(Form(
"zMoveHole_%d_%d", iHoles, mNLayer), radiusHring * cos(phiHole *
o2m::Deg2Rad), radiusHring * sin(phiHole *
o2m::Deg2Rad), 0);
344 zMoveHole->RegisterYourself();
345 nameAllHoles += Form(
"hole_%d_%d:zMoveHole_%d_%d + ", iHoles, mNLayer, iHoles, mNLayer);
347 nameAllHoles.Remove(nameAllHoles.Length() - 3, 3);
348 TString nameHringWithHoles = Form(
"%s - (%s)", Hring->GetName(), nameAllHoles.Data());
349 HringWithHoles =
new TGeoCompositeShape(nameHringWithHoles);
350 return HringWithHoles;
353void ITS3Layer::createLayerImpl()
355 if (mLayer !=
nullptr) {
365 mLayer->VisibleDaughters();
370 auto rotTop =
new TGeoRotation(Form(
"its3CarbonPhiOffsetTop_%d", mNLayer), 0, 0, +phiOffset);
371 auto rotBot =
new TGeoRotation(Form(
"its3CarbonPhiOffsetBot_%d", mNLayer), 0, 0, phiOffset + 180);
373 mLayer->AddNode(mCarbonForm, 0, rotTop);
374 mLayer->AddNode(mCarbonForm, 1, rotBot);
380 getMaterials(createMaterials);
385 motherVolume->AddNode(mPixelArray, 0, mat);
389 motherVolume->AddNode(mTile, 0, mat);
393 motherVolume->AddNode(mRSU, 0, mat);
397 motherVolume->AddNode(mSegment, 0, mat);
401 motherVolume->AddNode(mChip, 0, mat);
405 motherVolume->AddNode(mCarbonForm, 0, mat);
412 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 double edgeBetwChipAndFoam
constexpr double longeronsWidth
constexpr std::array< int, 3 > nHoles
constexpr unsigned int nRSUs
constexpr double totalThickness
constexpr std::array< unsigned int, nLayers > nSegments
constexpr std::array< double, nLayers > radii
constexpr double equatorialGap