53 {
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 int staveLayout =
m_gmt_mgr->PixelStaveLayout();
71
72
73
74
75 bool isBLayer = false;
76 if(
m_gmt_mgr->GetLD() == 0) isBLayer =
true;
78 std::unique_ptr<GeoPixelStaveSupport> staveSupport;
79 if (staveLayout ==0 || staveLayout==1) {
81 }
82 if (staveLayout == 3) {
84 }
85 else if (staveLayout >3 && staveLayout <7)
86 {
88 }
89
90 if (staveLayout >3 && staveLayout <7)
91 {
92 m_gmt_mgr->SetIBLPlanarModuleNumber(staveSupport->PixelNPlanarModule());
93 m_gmt_mgr->SetIBL3DModuleNumber(staveSupport->PixelN3DModule());
94 }
95
96 if(!staveSupport)
97 {
98 m_gmt_mgr->msg(MSG::ERROR)<<
"No stave support corresponding to the staveLayout "<<staveLayout<<
" could be defined "<<
endmsg;
99 return nullptr;
100 }
101
102 m_gmt_mgr->msg(MSG::INFO)<<
"*** LAYER "<<
m_gmt_mgr->GetLD()<<
" planar/3D modules : "<< staveSupport->PixelNPlanarModule()<<
" "<<staveSupport->PixelN3DModule()<<
endmsg;
103
104
106
107
108
109
110 double layerRadius =
m_gmt_mgr->PixelLayerRadius();
111 double ladderTilt =
m_gmt_mgr->PixelLadderTilt();
112 int nSectors =
m_gmt_mgr->NPixelSectors();
113
114
115 m_DDmgr->numerology().setNumPhiModulesForLayer(
m_gmt_mgr->GetLD(),nSectors);
117
120 for(int ii = 0; ii < nSectors; ii++) {
122 pixelLadder.Build();
123 }
124 if(bAddIBLStaveRings) {
127 staveRingService.Build();
128 }
129 return nullptr;
130 }
131
132
133
134
135
136 double ladderHalfThickN = pixelLadder.thicknessN();
137 double ladderHalfThickP = pixelLadder.thicknessP();
138 double ladderHalfWidth = pixelLadder.width()/2;
139
140
141
142
143
144 double grad = -1/
tan(std::abs(ladderTilt));
145
146 double y1 = -ladderHalfThickN*
sin(std::abs(ladderTilt));
147 double x1 = -ladderHalfThickN*
cos(std::abs(ladderTilt))+layerRadius;
148
149 double y2 = (
y1 - grad*
x1)/(1+grad*grad);
150 double x2 = -grad*
y2;
151
152
153 double distToClosestPoint = sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
154
155 double radClosest = (
y1 - grad*
x1)/(sqrt(1+grad*grad));
156
157
158
159
160
161 GeoTrf::Vector3D ladderLowerCorner(-ladderHalfThickN, ladderHalfWidth, 0);
162 GeoTrf::Vector3D ladderUpperCorner(ladderHalfThickP, -ladderHalfWidth, 0);
163 ladderLowerCorner = GeoTrf::TranslateX3D(layerRadius) * GeoTrf::RotateZ3D(std::abs(ladderTilt)) * ladderLowerCorner;
164 ladderUpperCorner = GeoTrf::TranslateX3D(layerRadius) * GeoTrf::RotateZ3D(std::abs(ladderTilt)) * ladderUpperCorner;
165
166 double layerThicknessN = layerRadius - ladderLowerCorner.perp();
167 double layerThicknessP = ladderUpperCorner.perp() - layerRadius;
168
169
170
171
172
173
174
175 if (distToClosestPoint < ladderHalfWidth) {
176 layerThicknessN = layerRadius - radClosest;
177 }
178
179
180
181
182
183
184
185
186 int maxLadType = 0;
187 std::vector<GeoVPhysVol *> ladderServicesArray;
188 GeoTrf::Transform3D ladderServicesTransform(GeoTrf::Transform3D::Identity());
189 GeoVPhysVol* pigtailPhysVol = nullptr;
190 GeoTrf::Transform3D transPigtail(GeoTrf::Transform3D::Identity());
191
192
193 if (staveLayout == 0) {
194
195
196
197
198
199
200
201
202
203
204 for(
int iPhi = 0;
iPhi < nSectors;
iPhi++) {
207 maxLadType = std::max(ladderType, maxLadType);
208 }
209
210
211
212 ladderServicesArray.resize(2*(maxLadType+1));
213 GeoPixelLadderServices *firstLadderServices = nullptr;
214 for(
int iPhi = 0;
iPhi < nSectors;
iPhi++) {
218
219 if (ladderType < 0) std::cout << "ERROR: Unexpected value of ladderType: " << ladderType << std::endl;
220 if (!ladderServicesArray[biStave*(maxLadType+1) + ladderType]) {
222
223 ladderServicesArray[biStave*(maxLadType+1) + ladderType] = ladderServices->
Build();
224 if (!firstLadderServices) {
225
226 firstLadderServices = ladderServices;
227 } else {
228
229 delete ladderServices;
230 }
231 }
232 }
233
234
235
236
237
238
239
240
241
242
243 double xCenter = 0.;
244 double yCenter = 0.;
245 if(firstLadderServices){
246
247
248
249
254
255
256
257 double xLadderServicesOffset =
m_gmt_mgr->PixelLadderServicesX();
258 double yLadderServicesOffset =
m_gmt_mgr->PixelLadderServicesY();
259
260 xCenter = (firstLadderServices->
referenceX() + xLadderServicesOffset);
261 yCenter = (firstLadderServices->
referenceY() + yLadderServicesOffset);
262 GeoTrf::Transform3D ladderSvcToglobal = GeoTrf::TranslateX3D(layerRadius)
263 * GeoTrf::RotateZ3D(ladderTilt)
264 * GeoTrf::Translate3D(xCenter, yCenter, 0);
265 GeoTrf::Vector3D corner1global = ladderSvcToglobal * corner1;
266 GeoTrf::Vector3D corner2global = ladderSvcToglobal * corner2;
267 GeoTrf::Vector3D corner3global = ladderSvcToglobal * corner3;
268 GeoTrf::Vector3D corner4global = ladderSvcToglobal * corner4;
269
270 double rMaxTmp = std::max(corner1global.perp(),
271 std::max(corner2global.perp(),
272 std::max(corner3global.perp(), corner4global.perp())));
273
274 layerThicknessP = std::max(layerThicknessP, rMaxTmp -
m_gmt_mgr->PixelLayerRadius());
275
276
277
278
279
280 delete firstLadderServices;
281
282 }
283
284
285
286
287
288
289
290
291
292
293 ladderServicesTransform = GeoTrf::Translate3D(xCenter, yCenter, 0);
294
295
296
297
299 pigtailPhysVol = pigtail.Build();
300 transPigtail = GeoTrf::Translate3D(
m_gmt_mgr->PixelPigtailBendX() +
m_gmt_mgr->PixelLadderCableOffsetX(),
302 0.);
303
304
305 }
306
307
308
309
310 double safety = 0.01 * Gaudi::Units::mm;
311 double rmin =
m_gmt_mgr->PixelLayerRadius()-layerThicknessN - safety;
312 double rmax =
m_gmt_mgr->PixelLayerRadius()+layerThicknessP + safety;
314
315
316
317 bool bAddIBLStaveRings=false;
319 {
320 bAddIBLStaveRings=true;
321 double safety = 0.001 * Gaudi::Units::mm;
322 double outerRadius =
m_gmt_mgr->IBLSupportMidRingInnerRadius();
323 rmax=outerRadius-safety;
324
326 double outerRadius =
m_gmt_mgr->IBLSupportMidRingOuterRadius();
327 rmax=outerRadius+safety;
328 }
329 m_gmt_mgr->msg(MSG::INFO)<<
"Layer IBL / stave ring : outer radius max "<<rmax<<
endmsg;
330
331 }
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347 GeoFullPhysVol* layerPhys = nullptr;
348
349
350
351
352 double angle=(nSectors>0)?(360./(
double)nSectors)*Gaudi::Units::deg:(360.*Gaudi::Units::deg);
353 GeoTrf::Transform3D transRadiusAndTilt = GeoTrf::TranslateX3D(layerRadius)*GeoTrf::RotateZ3D(ladderTilt);
354 double phiOfModuleZero =
m_gmt_mgr->PhiOfModuleZero();
355
356
358 {
359
360
361 GeoTrf::Vector3D centerCoolingPipe =
m_gmt_mgr->IBLStaveRotationAxis() ;
362
363
364 GeoTrf::Transform3D staveTrf = GeoTrf::RotateZ3D(ladderTilt)*GeoTrf::Translate3D(-centerCoolingPipe.x(),-centerCoolingPipe.y(),-centerCoolingPipe.z());
365 double staveRadius =
m_gmt_mgr->IBLStaveRadius() ;
366
367 transRadiusAndTilt = GeoTrf::TranslateX3D(staveRadius)*staveTrf;
368 }
369
370
371
372
373 for(int ii = 0; ii < nSectors; ii++) {
375
376
377 GeoVPhysVol *ladderPhys=pixelLadder.Build();
378
379 if(ii==0){
380 if(bAddIBLStaveRings)
381 {
382 const GeoSimplePolygonBrep* bRep = dynamic_cast<const GeoSimplePolygonBrep*> (ladderPhys->getLogVol()->getShape());
384 }
385
386
387
388
390 const GeoMaterial* air =
m_mat_mgr->getMaterial(
"std::Air");
391 std::ostringstream lname;
393 const GeoTube* layerTube =
new GeoTube(rmin,rmax,0.5*
length);
394 const GeoLogVol* layerLog = new GeoLogVol(lname.str(),layerTube,air);
395 layerPhys = new GeoFullPhysVol(layerLog);
396 }
397
398 double phiOfSector = phiOfModuleZero + ii*
angle;
399
400
401 GeoTrf::Transform3D ladderTransform = GeoTrf::RotateZ3D(phiOfSector) * transRadiusAndTilt;
402
403
404
405
406 std::ostringstream nameTag;
407 nameTag << "Ladder" << ii;
408 GeoNameTag *
tag =
new GeoNameTag(nameTag.str());
409 GeoTransform* xform = new GeoTransform(ladderTransform);
410 layerPhys->add(tag);
411 layerPhys->add(new GeoIdentifierTag(ii) );
412 layerPhys->add(xform);
413 layerPhys->add(ladderPhys);
414
415 if(
m_gmt_mgr->DoServicesOnLadder() && staveLayout == 0) {
416
417
418
419
420
423
424
425
426
427
428
429
430
431
432
433
434 xform = new GeoTransform(ladderTransform * ladderServicesTransform);
435 layerPhys->add(xform);
436 layerPhys->add(ladderServicesArray[biStave*(maxLadType+1) + ladderType]);
437
438
439
440 xform = new GeoTransform(ladderTransform*transPigtail);
441 layerPhys->add(xform);
442 layerPhys->add(pigtailPhysVol);
443
444 }
445 }
446
447
448 if(layerPhys==nullptr)
449 {
450 m_gmt_mgr->msg(MSG::ERROR)<<
"layerPhys = 0 in GeoPixelLayer in "<<__FILE__<<
endmsg;
451 std::abort();
452 }
453
454
455
456
457 InDetDD::ExtraMaterial xMat(
m_gmt_mgr->distortedMatManager());
458 xMat.add(layerPhys,"PixelLayer");
459 std::ostringstream ostr; ostr <<
m_gmt_mgr->GetLD();
460 xMat.add(layerPhys,"PixelLayer"+ostr.str());
461
462
463
464
465
466 if(bAddIBLStaveRings)
467 {
469
471 staveRingService.Build();
472
476
480
482 GeoNameTag *tagM = new GeoNameTag("Brl0M_StaveRing");
483 GeoTransform *xformSupportMidRing = new GeoTransform(GeoTrf::Transform3D::Identity());
485 layerPhys->add(tagM);
486 layerPhys->add(xformSupportMidRing);
487 layerPhys->add(supportPhysMidRing);
488 }
489
490 }
491
492
493 return layerPhys;
494}
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
const GeoTrf::Vector3D & envelopeCornerA1()
const GeoTrf::Vector3D & envelopeCornerA2()
virtual GeoVPhysVol * Build() override
const GeoTrf::Vector3D & envelopeCornerC2()
const GeoTrf::Vector3D & envelopeCornerC1()
GeoVPhysVol * getSupportMidRing()
std::shared_ptr< std::map< std::string, GeoFullPhysVol * > > m_mapFPV
std::shared_ptr< std::map< std::string, GeoAlignableTransform * > > m_mapAX
GeoModelIO::ReadGeoModel * m_sqliteReader
PixelGeometryManager * m_gmt_mgr
InDetDD::PixelDetectorManager * m_DDmgr
InDetMaterialManager * m_mat_mgr