20 #include "GeoModelKernel/GeoTube.h"
21 #include "GeoModelKernel/GeoPara.h"
22 #include "GeoModelKernel/GeoSimplePolygonBrep.h"
23 #include "GeoModelKernel/GeoLogVol.h"
24 #include "GeoModelKernel/GeoNameTag.h"
25 #include "GeoModelKernel/GeoIdentifierTag.h"
26 #include "GeoModelKernel/GeoPhysVol.h"
27 #include "GeoModelKernel/GeoFullPhysVol.h"
28 #include "GeoModelKernel/GeoMaterial.h"
29 #include "GeoModelKernel/GeoTransform.h"
31 #include "GeoModelKernel/GeoTubs.h"
32 #include "GaudiKernel/SystemOfUnits.h"
40 GeoModelIO::ReadGeoModel* sqliteReader,
41 std::shared_ptr<std::map<std::string, GeoFullPhysVol*>> mapFPV,
42 std::shared_ptr<std::map<std::string, GeoAlignableTransform*>> mapAX)
44 m_supportPhysA (nullptr),
45 m_supportPhysC (nullptr),
46 m_supportMidRing (nullptr),
47 m_xformSupportA (nullptr),
48 m_xformSupportC (nullptr),
49 m_xformSupportMidRing (nullptr)
75 bool isBLayer =
false;
78 std::unique_ptr<GeoPixelStaveSupport> staveSupport;
79 if (staveLayout ==0 || staveLayout==1) {
82 if (staveLayout == 3) {
85 else if (staveLayout >3 && staveLayout <7)
90 if (staveLayout >3 && staveLayout <7)
98 m_gmt_mgr->
msg(MSG::ERROR)<<
"No stave support corresponding to the staveLayout "<<staveLayout<<
" could be defined "<<
endmsg;
120 for(
int ii = 0; ii < nSectors; ii++) {
124 if(bAddIBLStaveRings) {
127 staveRingService.
Build();
136 double ladderHalfThickN = pixelLadder.
thicknessN();
137 double ladderHalfThickP = pixelLadder.
thicknessP();
138 double ladderHalfWidth = pixelLadder.
width()/2;
144 double grad = -1/
tan(std::abs(ladderTilt));
146 double y1 = -ladderHalfThickN*
sin(std::abs(ladderTilt));
147 double x1 = -ladderHalfThickN*
cos(std::abs(ladderTilt))+layerRadius;
149 double y2 = (
y1 - grad*
x1)/(1+grad*grad);
150 double x2 = -grad*
y2;
155 double radClosest = (
y1 - grad*
x1)/(sqrt(1+grad*grad));
163 ladderLowerCorner = GeoTrf::TranslateX3D(layerRadius) * GeoTrf::RotateZ3D(std::abs(ladderTilt)) * ladderLowerCorner;
164 ladderUpperCorner = GeoTrf::TranslateX3D(layerRadius) * GeoTrf::RotateZ3D(std::abs(ladderTilt)) * ladderUpperCorner;
166 double layerThicknessN = layerRadius - ladderLowerCorner.perp();
167 double layerThicknessP = ladderUpperCorner.perp() - layerRadius;
175 if (distToClosestPoint < ladderHalfWidth) {
176 layerThicknessN = layerRadius - radClosest;
187 std::vector<GeoVPhysVol *> ladderServicesArray;
189 GeoVPhysVol* pigtailPhysVol =
nullptr;
193 if (staveLayout == 0) {
207 maxLadType =
std::max(ladderType, maxLadType);
212 ladderServicesArray.resize(2*(maxLadType+1));
219 if (ladderType < 0) std::cout <<
"ERROR: Unexpected value of ladderType: " << ladderType << std::endl;
220 if (!ladderServicesArray[biStave*(maxLadType+1) + ladderType]) {
223 ladderServicesArray[biStave*(maxLadType+1) + ladderType] = ladderServices->
Build();
224 if (!firstLadderServices) {
226 firstLadderServices = ladderServices;
229 delete ladderServices;
245 if(firstLadderServices){
260 xCenter = (firstLadderServices->
referenceX() + xLadderServicesOffset);
261 yCenter = (firstLadderServices->
referenceY() + yLadderServicesOffset);
263 * GeoTrf::RotateZ3D(ladderTilt)
264 * GeoTrf::Translate3D(xCenter, yCenter, 0);
270 double rMaxTmp =
std::max(corner1global.perp(),
272 std::max(corner3global.perp(), corner4global.perp())));
280 delete firstLadderServices;
293 ladderServicesTransform = GeoTrf::Translate3D(xCenter, yCenter, 0);
299 pigtailPhysVol = pigtail.
Build();
317 bool bAddIBLStaveRings=
false;
320 bAddIBLStaveRings=
true;
323 rmax=outerRadius-safety;
327 rmax=outerRadius+safety;
329 m_gmt_mgr->
msg(MSG::INFO)<<
"Layer IBL / stave ring : outer radius max "<<rmax<<
endmsg;
347 GeoFullPhysVol* layerPhys =
nullptr;
353 GeoTrf::Transform3D transRadiusAndTilt = GeoTrf::TranslateX3D(layerRadius)*GeoTrf::RotateZ3D(ladderTilt);
364 GeoTrf::Transform3D staveTrf = GeoTrf::RotateZ3D(ladderTilt)*GeoTrf::Translate3D(-centerCoolingPipe.x(),-centerCoolingPipe.y(),-centerCoolingPipe.z());
367 transRadiusAndTilt = GeoTrf::TranslateX3D(staveRadius)*staveTrf;
373 for(
int ii = 0; ii < nSectors; ii++) {
377 GeoVPhysVol *ladderPhys=pixelLadder.
Build();
380 if(bAddIBLStaveRings)
382 const GeoSimplePolygonBrep* bRep =
dynamic_cast<const GeoSimplePolygonBrep*
> (ladderPhys->getLogVol()->getShape());
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);
398 double phiOfSector = phiOfModuleZero + ii*
angle;
406 std::ostringstream nameTag;
407 nameTag <<
"Ladder" << ii;
408 GeoNameTag *
tag =
new GeoNameTag(nameTag.str());
409 GeoTransform* xform =
new GeoTransform(ladderTransform);
411 layerPhys->add(
new GeoIdentifierTag(ii) );
412 layerPhys->add(xform);
413 layerPhys->add(ladderPhys);
434 xform =
new GeoTransform(ladderTransform * ladderServicesTransform);
435 layerPhys->add(xform);
436 layerPhys->add(ladderServicesArray[biStave*(maxLadType+1) + ladderType]);
440 xform =
new GeoTransform(ladderTransform*transPigtail);
441 layerPhys->add(xform);
442 layerPhys->add(pigtailPhysVol);
448 if(layerPhys==
nullptr)
458 xMat.
add(layerPhys,
"PixelLayer");
460 xMat.
add(layerPhys,
"PixelLayer"+ostr.str());
466 if(bAddIBLStaveRings)
471 staveRingService.
Build();
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);