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"
39 GeoModelIO::ReadGeoModel* sqliteReader,
40 std::shared_ptr<std::map<std::string, GeoFullPhysVol*>> mapFPV,
41 std::shared_ptr<std::map<std::string, GeoAlignableTransform*>> mapAX)
43 m_supportPhysA (nullptr),
44 m_supportPhysC (nullptr),
45 m_supportMidRing (nullptr),
46 m_xformSupportA (nullptr),
47 m_xformSupportC (nullptr),
48 m_xformSupportMidRing (nullptr)
74 bool isBLayer =
false;
77 std::unique_ptr<GeoPixelStaveSupport> staveSupport;
78 if (staveLayout ==0 || staveLayout==1) {
81 if (staveLayout == 3) {
84 else if (staveLayout >3 && staveLayout <7)
89 if (staveLayout >3 && staveLayout <7)
97 m_gmt_mgr->
msg(MSG::ERROR)<<
"No stave support corresponding to the staveLayout "<<staveLayout<<
" could be defined "<<
endmsg;
119 for(
int ii = 0; ii < nSectors; ii++) {
123 if(bAddIBLStaveRings) {
126 staveRingService.
Build();
135 double ladderHalfThickN = pixelLadder.
thicknessN();
136 double ladderHalfThickP = pixelLadder.
thicknessP();
137 double ladderHalfWidth = pixelLadder.
width()/2;
143 double grad = -1/
tan(std::abs(ladderTilt));
145 double y1 = -ladderHalfThickN*
sin(std::abs(ladderTilt));
146 double x1 = -ladderHalfThickN*
cos(std::abs(ladderTilt))+layerRadius;
148 double y2 = (
y1 - grad*
x1)/(1+grad*grad);
149 double x2 = -grad*
y2;
154 double radClosest = (
y1 - grad*
x1)/(sqrt(1+grad*grad));
162 ladderLowerCorner = GeoTrf::TranslateX3D(layerRadius) * GeoTrf::RotateZ3D(std::abs(ladderTilt)) * ladderLowerCorner;
163 ladderUpperCorner = GeoTrf::TranslateX3D(layerRadius) * GeoTrf::RotateZ3D(std::abs(ladderTilt)) * ladderUpperCorner;
165 double layerThicknessN = layerRadius - ladderLowerCorner.perp();
166 double layerThicknessP = ladderUpperCorner.perp() - layerRadius;
174 if (distToClosestPoint < ladderHalfWidth) {
175 layerThicknessN = layerRadius - radClosest;
186 std::vector<GeoVPhysVol *> ladderServicesArray;
188 GeoVPhysVol* pigtailPhysVol =
nullptr;
192 if (staveLayout == 0) {
206 maxLadType =
std::max(ladderType, maxLadType);
211 ladderServicesArray.resize(2*(maxLadType+1));
218 if (ladderType < 0) std::cout <<
"ERROR: Unexpected value of ladderType: " << ladderType << std::endl;
219 if (!ladderServicesArray[biStave*(maxLadType+1) + ladderType]) {
222 ladderServicesArray[biStave*(maxLadType+1) + ladderType] = ladderServices->
Build();
223 if (!firstLadderServices) {
225 firstLadderServices = ladderServices;
228 delete ladderServices;
244 if(firstLadderServices){
259 xCenter = (firstLadderServices->
referenceX() + xLadderServicesOffset);
260 yCenter = (firstLadderServices->
referenceY() + yLadderServicesOffset);
262 * GeoTrf::RotateZ3D(ladderTilt)
263 * GeoTrf::Translate3D(xCenter, yCenter, 0);
269 double rMaxTmp =
std::max(corner1global.perp(),
271 std::max(corner3global.perp(), corner4global.perp())));
279 delete firstLadderServices;
292 ladderServicesTransform = GeoTrf::Translate3D(xCenter, yCenter, 0);
298 pigtailPhysVol = pigtail.
Build();
316 bool bAddIBLStaveRings=
false;
319 bAddIBLStaveRings=
true;
322 rmax=outerRadius-safety;
326 rmax=outerRadius+safety;
328 m_gmt_mgr->
msg(MSG::INFO)<<
"Layer IBL / stave ring : outer radius max "<<rmax<<
endmsg;
346 GeoFullPhysVol* layerPhys =
nullptr;
352 GeoTrf::Transform3D transRadiusAndTilt = GeoTrf::TranslateX3D(layerRadius)*GeoTrf::RotateZ3D(ladderTilt);
363 GeoTrf::Transform3D staveTrf = GeoTrf::RotateZ3D(ladderTilt)*GeoTrf::Translate3D(-centerCoolingPipe.x(),-centerCoolingPipe.y(),-centerCoolingPipe.z());
366 transRadiusAndTilt = GeoTrf::TranslateX3D(staveRadius)*staveTrf;
372 for(
int ii = 0; ii < nSectors; ii++) {
376 GeoVPhysVol *ladderPhys=pixelLadder.
Build();
379 if(bAddIBLStaveRings)
381 const GeoSimplePolygonBrep* bRep =
dynamic_cast<const GeoSimplePolygonBrep*
> (ladderPhys->getLogVol()->getShape());
390 std::ostringstream lname;
392 const GeoTube* layerTube =
new GeoTube(rmin,rmax,0.5*
length);
393 const GeoLogVol* layerLog =
new GeoLogVol(lname.str(),layerTube,air);
394 layerPhys =
new GeoFullPhysVol(layerLog);
397 double phiOfSector = phiOfModuleZero + ii*
angle;
405 std::ostringstream nameTag;
406 nameTag <<
"Ladder" << ii;
407 GeoNameTag *
tag =
new GeoNameTag(nameTag.str());
408 GeoTransform* xform =
new GeoTransform(ladderTransform);
410 layerPhys->add(
new GeoIdentifierTag(ii) );
411 layerPhys->add(xform);
412 layerPhys->add(ladderPhys);
433 xform =
new GeoTransform(ladderTransform * ladderServicesTransform);
434 layerPhys->add(xform);
435 layerPhys->add(ladderServicesArray[biStave*(maxLadType+1) + ladderType]);
439 xform =
new GeoTransform(ladderTransform*transPigtail);
440 layerPhys->add(xform);
441 layerPhys->add(pigtailPhysVol);
447 if(layerPhys==
nullptr)
457 xMat.
add(layerPhys,
"PixelLayer");
459 xMat.
add(layerPhys,
"PixelLayer"+ostr.str());
465 if(bAddIBLStaveRings)
470 staveRingService.
Build();
481 GeoNameTag *tagM =
new GeoNameTag(
"Brl0M_StaveRing");
482 GeoTransform *xformSupportMidRing =
new GeoTransform(GeoTrf::Transform3D::Identity());
484 layerPhys->add(tagM);
485 layerPhys->add(xformSupportMidRing);
486 layerPhys->add(supportPhysMidRing);