28TRKLayer::TRKLayer(
int layerNumber, std::string layerName,
float rInn,
float rOut,
int numberOfModules,
float layerX2X0)
29 : mLayerNumber(layerNumber), mLayout(
kCylinder), mLayerName(layerName), mInnerRadius(rInn), mOuterRadius(rOut), mNumberOfModules(numberOfModules), mX2X0(layerX2X0), mChipWidth(constants::moduleMLOT::chip::
width), mChipLength(constants::moduleMLOT::chip::
length), mDeadzoneWidth(constants::moduleMLOT::chip::passiveEdgeReadOut), mSensorThickness(constants::moduleMLOT::silicon::thickness), mHalfNumberOfChips(4)
32 mChipThickness = mX2X0 * Si_X0;
33 LOGP(info,
"Creating layer: id: {} rInner: {} rOuter: {} zLength: {} x2X0: {}", mLayerNumber, mInnerRadius, mOuterRadius,
getZ(), mX2X0);
36TRKLayer::TRKLayer(
int layerNumber, std::string layerName,
float rInn,
int numberOfModules,
float thick)
37 : mLayerNumber(layerNumber), mLayout(
kCylinder), mLayerName(layerName), mInnerRadius(rInn), mNumberOfModules(numberOfModules), mChipThickness(thick), mChipWidth(constants::moduleMLOT::chip::
width), mChipLength(constants::moduleMLOT::chip::
length), mDeadzoneWidth(constants::moduleMLOT::chip::passiveEdgeReadOut), mSensorThickness(constants::moduleMLOT::silicon::thickness), mHalfNumberOfChips(4)
40 mOuterRadius = rInn + thick;
41 mX2X0 = mChipThickness / Si_X0;
42 LOGP(info,
"Creating layer: id: {} rInner: {} rOuter: {} zLength: {} x2X0: {}", mLayerNumber, mInnerRadius, mOuterRadius,
getZ(), mX2X0);
110 TGeoMedium* medSi = gGeoManager->GetMedium(
"TRK_SILICON$");
118 TGeoVolume* metalVol;
120 if (
type ==
"cylinder") {
121 chip =
new TGeoTube(mInnerRadius, mInnerRadius + mChipThickness, mChipLength / 2);
122 chipVol =
new TGeoVolume(chipName.c_str(), chip, medSi);
127 TGeoCombiTrans* transSens =
new TGeoCombiTrans();
128 transSens->SetTranslation(0, -(mChipThickness - mSensorThickness) / 2, 0);
129 LOGP(info,
"Inserting {} in {} ", sensVol->GetName(), chipVol->GetName());
130 chipVol->AddNode(sensVol, 1, transSens);
132 TGeoCombiTrans* transMetal =
new TGeoCombiTrans();
133 transMetal->SetTranslation(0, mSensorThickness / 2, 0);
134 LOGP(info,
"Inserting {} in {} ", metalVol->GetName(), chipVol->GetName());
135 chipVol->AddNode(metalVol, 1, transMetal);
138 }
else if (
type ==
"flat") {
139 chip =
new TGeoBBox(mChipWidth / 2, mChipThickness / 2, mChipLength / 2);
140 chipVol =
new TGeoVolume(chipName.c_str(), chip, medSi);
146 TGeoCombiTrans* transSens =
new TGeoCombiTrans();
147 transSens->SetTranslation(-mDeadzoneWidth / 2, -(mChipThickness - mSensorThickness) / 2, 0);
148 LOGP(info,
"Inserting {} in {} ", sensVol->GetName(), chipVol->GetName());
149 chipVol->AddNode(sensVol, 1, transSens);
151 TGeoCombiTrans* transDead =
new TGeoCombiTrans();
152 transDead->SetTranslation((mChipWidth - mDeadzoneWidth) / 2, -(mChipThickness - mSensorThickness) / 2, 0);
153 LOGP(info,
"Inserting {} in {} ", deadVol->GetName(), chipVol->GetName());
154 chipVol->AddNode(deadVol, 1, transDead);
156 TGeoCombiTrans* transMetal =
new TGeoCombiTrans();
157 transMetal->SetTranslation(0, mSensorThickness / 2, 0);
158 LOGP(info,
"Inserting {} in {} ", metalVol->GetName(), chipVol->GetName());
159 chipVol->AddNode(metalVol, 1, transMetal);
161 LOGP(fatal,
"Sensor of type '{}' is not implemented",
type);
164 chipVol->SetLineColor(kYellow);
171 TGeoMedium* medAir = gGeoManager->GetMedium(
"TRK_AIR$");
175 TGeoVolume* moduleVol;
177 if (
type ==
"cylinder") {
178 module = new TGeoTube(mInnerRadius, mInnerRadius + mChipThickness, mChipLength / 2);
179 moduleVol =
new TGeoVolume(moduleName.c_str(), module, medAir);
182 LOGP(info,
"Inserting {} in {} ", chipVol->GetName(), moduleVol->GetName());
183 moduleVol->AddNode(chipVol, 1,
nullptr);
184 }
else if (
type ==
"flat") {
188 module = new TGeoBBox(moduleWidth / 2, mChipThickness / 2, moduleLength / 2);
189 moduleVol =
new TGeoVolume(moduleName.c_str(), module, medAir);
191 for (
int iChip = 0; iChip < mHalfNumberOfChips; iChip++) {
193 TGeoVolume* chipVolRight =
createChip(
"flat");
199 TGeoCombiTrans* transLeft =
new TGeoCombiTrans();
200 transLeft->SetTranslation(xLeft, 0, zLeft);
201 TGeoRotation* rot =
new TGeoRotation();
203 transLeft->SetRotation(rot);
204 LOGP(info,
"Inserting {} in {} ", chipVolLeft->GetName(), moduleVol->GetName());
205 moduleVol->AddNode(chipVolLeft, iChip * 2, transLeft);
210 TGeoCombiTrans* transRight =
new TGeoCombiTrans();
211 transRight->SetTranslation(xRight, 0, zRight);
212 LOGP(info,
"Inserting {} in {} ", chipVolRight->GetName(), moduleVol->GetName());
213 moduleVol->AddNode(chipVolRight, iChip * 2 + 1, transRight);
216 LOGP(fatal,
"Chip of type '{}' is not implemented",
type);
219 moduleVol->SetLineColor(kYellow);
226 TGeoMedium* medAir = gGeoManager->GetMedium(
"TRK_AIR$");
229 TGeoShape* halfStave;
230 TGeoVolume* halfStaveVol;
232 if (
type ==
"cylinder") {
233 halfStave =
new TGeoTube(mInnerRadius, mInnerRadius + mChipThickness, mChipLength / 2);
234 halfStaveVol =
new TGeoVolume(halfStaveName.c_str(), halfStave, medAir);
237 LOGP(info,
"Inserting {} in {} ", moduleVol->GetName(), halfStaveVol->GetName());
238 halfStaveVol->AddNode(moduleVol, 1,
nullptr);
239 }
else if (
type ==
"flat") {
244 halfStave =
new TGeoBBox(halfStaveWidth / 2, mChipThickness / 2, halfStaveLength / 2);
245 halfStaveVol =
new TGeoVolume(halfStaveName.c_str(), halfStave, medAir);
247 for (
int iModule = 0; iModule < mNumberOfModules; iModule++) {
251 double zPos = -0.5 * mNumberOfModules * moduleLength + (iModule + 0.5) * moduleLength;
253 TGeoCombiTrans* trans =
new TGeoCombiTrans();
254 trans->SetTranslation(0, 0, zPos);
256 LOGP(info,
"Inserting {} in {} ", moduleVol->GetName(), halfStaveVol->GetName());
257 halfStaveVol->AddNode(moduleVol, iModule, trans);
265 TGeoMedium* medAir = gGeoManager->GetMedium(
"TRK_AIR$");
269 TGeoVolume* staveVol;
271 if (
type ==
"cylinder") {
272 stave =
new TGeoTube(mInnerRadius, mInnerRadius + mChipThickness, mChipLength / 2);
273 staveVol =
new TGeoVolume(staveName.c_str(), stave, medAir);
276 LOGP(info,
"Inserting {} in {} ", moduleVol->GetName(), staveVol->GetName());
277 staveVol->AddNode(moduleVol, 1,
nullptr);
278 }
else if (
type ==
"flat") {
283 stave =
new TGeoBBox(staveWidth / 2, mChipThickness / 2, staveLength / 2);
284 staveVol =
new TGeoVolume(staveName.c_str(), stave, medAir);
286 for (
int iModule = 0; iModule < mNumberOfModules; iModule++) {
290 double zPos = -0.5 * mNumberOfModules * moduleLength + (iModule + 0.5) * moduleLength;
292 TGeoCombiTrans* trans =
new TGeoCombiTrans();
293 trans->SetTranslation(0, 0, zPos);
295 LOGP(info,
"Inserting {} in {} ", moduleVol->GetName(), staveVol->GetName());
296 staveVol->AddNode(moduleVol, iModule, trans);
298 }
else if (
type ==
"staggered") {
306 stave =
new TGeoBBox(staveWidth / 2, mLogicalVolumeThickness / 2, staveLength / 2);
307 staveVol =
new TGeoVolume(staveName.c_str(), stave, medAir);
313 TGeoCombiTrans* transLeft =
new TGeoCombiTrans();
314 transLeft->SetTranslation(-halfstaveWidth / 2 + 0.05, 0, 0);
315 LOGP(info,
"Inserting {} in {} ", halfStaveVolLeft->GetName(), staveVol->GetName());
316 staveVol->AddNode(halfStaveVolLeft, 0, transLeft);
318 TGeoCombiTrans* transRight =
new TGeoCombiTrans();
319 transRight->SetTranslation(halfstaveWidth / 2 - 0.05, 0.2, 0);
320 LOGP(info,
"Inserting {} in {} ", halfStaveVolRight->GetName(), staveVol->GetName());
321 staveVol->AddNode(halfStaveVolRight, 1, transRight);
323 LOGP(fatal,
"Chip of type '{}' is not implemented",
type);
326 staveVol->SetLineColor(kYellow);
333 TGeoMedium* medAir = gGeoManager->GetMedium(
"TRK_AIR$");
335 double layerThickness = mChipThickness;
337 layerThickness = mLogicalVolumeThickness;
341 TGeoVolume* layerVol;
344 layer =
new TGeoTube(mInnerRadius - 0.333 * layerThickness, mInnerRadius + 0.667 * layerThickness, mChipLength / 2);
345 layerVol =
new TGeoVolume(mLayerName.c_str(),
layer, medAir);
348 LOGP(info,
"Inserting {} in {} ", staveVol->GetName(), layerVol->GetName());
349 layerVol->AddNode(staveVol, 1,
nullptr);
354 if (mInnerRadius > 25) {
358 layer =
new TGeoTube(mInnerRadius - 0.333 * layerThickness, mInnerRadius + 0.667 * layerThickness, layerLength / 2);
359 layerVol =
new TGeoVolume(mLayerName.c_str(),
layer, medAir);
362 int nStaves = (
int)std::ceil(mInnerRadius * 2 * TMath::Pi() / staveWidth);
363 nStaves += nStaves % 2;
366 double theta = 2 * TMath::Pi() / nStaves;
367 double theta1 = std::atan(staveWidth / 2 / mInnerRadius);
368 double st = std::sin(theta);
369 double ct = std::cos(theta);
370 double theta2 = std::atan((mInnerRadius *
st - staveWidth / 2 * ct) / (mInnerRadius * ct + staveWidth / 2 *
st));
371 double overlap = (theta1 - theta2) * mInnerRadius;
372 LOGP(info,
"Creating a layer with {} staves and {} mm overlap", nStaves, overlap * 10);
374 for (
int iStave = 0; iStave < nStaves; iStave++) {
378 TGeoCombiTrans* trans =
new TGeoCombiTrans();
379 double theta = 360. * iStave / nStaves;
380 TGeoRotation* rot =
new TGeoRotation(
"rot", theta + 90 + 3, 0, 0);
381 trans->SetRotation(rot);
382 trans->SetTranslation(mInnerRadius * std::cos(2. * TMath::Pi() * iStave / nStaves), mInnerRadius * std::sin(2 * TMath::Pi() * iStave / nStaves), 0);
384 LOGP(info,
"Inserting {} in {} ", staveVol->GetName(), layerVol->GetName());
385 layerVol->AddNode(staveVol, iStave, trans);
390 layer =
new TGeoTube(mInnerRadius - 0.333 * layerThickness, mInnerRadius + 0.667 * layerThickness, layerLength / 2);
391 layerVol =
new TGeoVolume(mLayerName.c_str(),
layer, medAir);
395 int nStaves = (
int)std::ceil(mInnerRadius * 2 * TMath::Pi() / staveWidth);
396 nStaves += nStaves % 2;
399 double theta = 2 * TMath::Pi() / nStaves;
400 double theta1 = std::atan(staveWidth / 2 / mInnerRadius);
401 double st = std::sin(theta);
402 double ct = std::cos(theta);
403 double theta2 = std::atan((mInnerRadius *
st - staveWidth / 2 * ct) / (mInnerRadius * ct + staveWidth / 2 *
st));
404 double overlap = (theta1 - theta2) * mInnerRadius;
405 LOGP(info,
"Creating a layer with {} staves and {} mm overlap", nStaves, overlap * 10);
407 for (
int iStave = 0; iStave < nStaves; iStave++) {
411 TGeoCombiTrans* trans =
new TGeoCombiTrans();
412 double theta = 360. * iStave / nStaves;
413 TGeoRotation* rot =
new TGeoRotation(
"rot", theta + 90, 0, 0);
414 trans->SetRotation(rot);
415 trans->SetTranslation(mInnerRadius * std::cos(2. * TMath::Pi() * iStave / nStaves), mInnerRadius * std::sin(2 * TMath::Pi() * iStave / nStaves), 0);
417 LOGP(info,
"Inserting {} in {} ", staveVol->GetName(), layerVol->GetName());
418 layerVol->AddNode(staveVol, iStave, trans);
421 LOGP(fatal,
"Layout not implemented");
423 layerVol->SetLineColor(kYellow);
425 LOGP(info,
"Inserting {} in {} ", layerVol->GetName(), motherVolume->GetName());
426 motherVolume->AddNode(layerVol, 1,
nullptr);