ATLAS Offline Software
GeoPixelIBLFwdSvcCADModel.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 // Build IBL fwd services (wavy shape)
7 // This is built one time per layer.
8 
10 
11 #include "GeoModelKernel/GeoTube.h"
12 #include "GeoModelKernel/GeoTubs.h"
13 
14 #if defined(GEOTORUS) && GEOTORUS==1
15  #include "GeoModelKernel/GeoTorus.h"
16 #endif
17 
18 #include "GeoModelKernel/GeoSimplePolygonBrep.h"
19 #include "GeoModelKernel/GeoShape.h"
20 #include "GeoModelKernel/GeoShapeUnion.h"
21 #include "GeoModelKernel/GeoShapeShift.h"
22 #include "GeoModelKernel/GeoLogVol.h"
23 #include "GeoModelKernel/GeoPhysVol.h"
24 #include "GeoModelKernel/GeoMaterial.h"
25 #include "GeoModelKernel/GeoNameTag.h"
26 
27 #include "GeoModelKernel/GeoTransform.h"
28 #include "GaudiKernel/PhysicalConstants.h"
29 
30 #include <algorithm>
31 #include <iostream>
32 #include <iomanip>
33 using std::max;
34 
37  GeoModelIO::ReadGeoModel* sqliteReader,
38  std::shared_ptr<std::map<std::string, GeoFullPhysVol*>> mapFPV,
39  std::shared_ptr<std::map<std::string, GeoAlignableTransform*>> mapAX,
40  int /*section*/)
41  : GeoVPixelFactory(ddmgr, mgr, sqliteReader, mapFPV, mapAX),
42  m_supportPhysA(nullptr),
43  m_supportPhysC(nullptr),
44  m_xformSupportA(nullptr),
45  m_xformSupportC(nullptr)
46 {
47 }
48 
50 {
51 
52  m_gmt_mgr->msg(MSG::INFO) <<"Build IBL fwd services - CAD tool design - Build()"<<endmsg;
53 
54 #if !defined(GEOTORUS) || GEOTORUS==0
55 
56  m_gmt_mgr->msg(MSG::INFO) <<"Build IBL fwd services - CAD tool design - Torus object is not defined "<<GEOTORUS<<endmsg;
57  return 0;
58 
59 #else
60 
61  m_gmt_mgr->msg(MSG::INFO) <<"Build IBL fwd services - CAD tool design - Torus object is defined"<<endmsg;
62 
63  // double safety = 0.01*Gaudi::Units::mm;
64 
65  // IBL layer shift ( 2mm shift issue )
66  double layerZshift = m_gmt_mgr->PixelLayerGlobalShift();
67  int nSectors = m_gmt_mgr->NPixelSectors();
68  double phiOfModuleZero = m_gmt_mgr->PhiOfModuleZero();
69  double layerRadius = m_gmt_mgr->PixelLayerRadius();
70 
71  // check if sectors are properly defined
72  if(nSectors==0) return nullptr;
73  double angle=360./(double)nSectors*Gaudi::Units::deg;
74 
75  // Defines the IBL_Fwd02 section in the IBL services area
76  double innerRadius = 33.;
77  double outerRadius = 42.499;
78  double zMin = 834.607;
79  double zMax = 3290.795;
80 
81  double zLength = zMax-zMin;
82  double halfLength = zLength*.5;
83  double zMiddle = (zMin+zMax)*.5;
84 
85  // Define IBL fwd svc section for side A and C
86  std::ostringstream lnameA;
87  lnameA<<"Brl0A_FwdSvc";
88  std::ostringstream lnameC;
89  lnameC<<"Brl0C_FwdSvc";
90 
91  // Build encompassing volume for both A and C sides (assemblies)
92  const GeoTube* supportShapeA = new GeoTube(innerRadius,outerRadius,halfLength);
93  const GeoTube* supportShapeC = new GeoTube(innerRadius,outerRadius,halfLength);
94  const GeoMaterial* ether = m_mat_mgr->getMaterial("special::Ether");
95  GeoLogVol* supportLogVol_A = new GeoLogVol(lnameA.str(),supportShapeA,ether);
96  GeoLogVol* supportLogVol_C = new GeoLogVol(lnameA.str(),supportShapeC,ether);
97 
98  // Data taken fron CATIA desgin file
99  double delta = 18.;
100  double deltaJunction = 0.;
101  double lgFwdSvc[4]={511., 561., 560., 706. };
102  //double devLgFwdSvc[4]={512., 562., 562., 707. };
103  double devTotalLength = 2460.188;
104  double pi = Gaudi::Units::pi;
105 
106  // Cable bundle sizes
107  double rminCable = 0.;
108  double rmaxCable = 8.*.5;
109  double surfCable = rmaxCable*rmaxCable*pi;
110 
111  // Cooling tube sizes
112  double rminCooling = 0.;
113  double rmaxCooling = 1.75*.5;
114  double surfCooling = rmaxCooling*rmaxCooling*pi;
115 
116  // IPT clip starting position
117  double zpos0 = 903.;
118  double zpos = 0.;
119  double hermJunction = .4;
120  double breakAngle = 11.*Gaudi::Units::deg;
121 
122  // Loop over the wavy shape sections to build a cable and a cooling pipe
123  const GeoShape * gblShapeCableA = nullptr;
124  const GeoShape * gblShapeCoolingA = nullptr;
125  const GeoShape * gblShapeCableC = nullptr;
126  const GeoShape * gblShapeCoolingC = nullptr;
127  for(int i=0; i<4; i++)
128  {
129  double initHalfLength = lgFwdSvc[i]*.5;
130  zpos += initHalfLength;
131  double corHalfLength = initHalfLength-deltaJunction;
132  double radius = .5*(corHalfLength*corHalfLength+delta*delta)/delta;
133  double theta = asin(corHalfLength/radius);
134 
135  if(i==0){
136  double tubeLength=deltaJunction+zpos0-zMin+hermJunction;
137  double zposTrans=zMin+tubeLength*.5-zpos0;
138  const GeoTube* tubeShape = new GeoTube(0., rmaxCable, tubeLength*.5);
139  GeoTrf::Transform3D trfA = GeoTrf::TranslateZ3D(zpos0+zposTrans-zMiddle);
140  gblShapeCableA = addShape(gblShapeCableA, tubeShape, trfA );
141  GeoTrf::Transform3D trfC = GeoTrf::RotateY3D(pi)*GeoTrf::TranslateZ3D(zpos0+zposTrans-zMiddle);
142  gblShapeCableC = addShape(gblShapeCableC, tubeShape, trfC );
143 
144  // std::cout<<"IBL_fwd : junction "<<std::setprecision(15)<<i<<" : "<<zpos0+zposTrans-tubeLength*.5<<" "<<zpos0+zposTrans+tubeLength*.5<<" // "<<zMin<<std::endl;
145 
146  const GeoTube* tubeShape_cooling = new GeoTube(0., rmaxCooling, tubeLength*.5);
147  gblShapeCoolingA = addShape(gblShapeCoolingA, tubeShape_cooling, trfA );
148  gblShapeCoolingC = addShape(gblShapeCoolingC, tubeShape_cooling, trfC );
149  }
150 
151  // std::cout<<"Torus radius : "<<radius<<" "<<perimeter*(2.*theta)/(2.*pi)+2*deltaJunction<<" / "<<devLgFwdSvc[i]<<std::endl;
152 
153  double rtor = radius;
154  const GeoTorus* torusShape = new GeoTorus(rminCable,rmaxCable,rtor,pi*.5-theta,2.*theta);
155  double angle=(i%2==0)?breakAngle:pi-breakAngle;
156  GeoTrf::Transform3D trfA = GeoTrf::RotateZ3D(angle)*GeoTrf::RotateY3D(-pi*.5)*GeoTrf::TranslateY3D(-radius+delta)* GeoTrf::TranslateX3D(zpos0+zpos-zMiddle);
157  gblShapeCableA = addShape(gblShapeCableA, torusShape, trfA );
158  GeoTrf::Transform3D trfC = GeoTrf::RotateZ3D(angle)*GeoTrf::RotateY3D(pi*.5)*GeoTrf::TranslateY3D(-radius+delta)* GeoTrf::TranslateX3D(zpos0+zpos-zMiddle);
159  gblShapeCableC = addShape(gblShapeCableC, torusShape, trfC );
160 
161  const GeoTorus* torusShape_cooling = new GeoTorus(rminCooling,rmaxCooling,rtor,pi*.5-theta,2.*theta);
162  gblShapeCoolingA = addShape(gblShapeCoolingA, torusShape_cooling, trfA );
163  gblShapeCoolingC = addShape(gblShapeCoolingC, torusShape_cooling, trfC );
164 
165  zpos += initHalfLength;
166 
167  if(i==3){
168  zpos=zpos0+zpos-deltaJunction;
169  double tubeLength=zMax-zpos+hermJunction;
170  double zposTrans=zMax-tubeLength*.5;
171  const GeoTube* tubeShape = new GeoTube(0., rmaxCable, tubeLength*.5);
172  GeoTrf::Transform3D trfA = GeoTrf::TranslateZ3D(zposTrans-zMiddle);
173  gblShapeCableA = addShape(gblShapeCableA, tubeShape, trfA );
174  GeoTrf::Transform3D trfC = GeoTrf::RotateY3D(pi)*GeoTrf::TranslateZ3D(zposTrans-zMiddle);
175  gblShapeCableC = addShape(gblShapeCableC, tubeShape, trfC );
176 
177  const GeoTube* tubeShape_cooling = new GeoTube(0., rmaxCooling, tubeLength*.5);
178  gblShapeCoolingA = addShape(gblShapeCoolingA, tubeShape_cooling, trfA );
179  gblShapeCoolingC = addShape(gblShapeCoolingC, tubeShape_cooling, trfC );
180  }
181 
182  }
183 
184 
185  // Material (material budget computed based on the detailed description of a cable bundle and cooling pipe
186  const GeoMaterial* cableMat = m_mat_mgr->getMaterialForVolume("pix::IBL_Fwd02_Cable_Wvy",surfCable*devTotalLength);
187  GeoLogVol * cable_logA = new GeoLogVol("IBL_Fwd02_Cable_A",gblShapeCableA,cableMat);
188  GeoLogVol * cable_logC = new GeoLogVol("IBL_Fwd02_Cable_C",gblShapeCableC,cableMat);
189 
190  const GeoMaterial* coolingMat = m_mat_mgr->getMaterialForVolume("pix::IBL_Fwd02_Cooling_Wvy",surfCooling*devTotalLength);
191  GeoLogVol * cooling_logA = new GeoLogVol("IBL_Fwd02_Cooling_A",gblShapeCoolingA,coolingMat);
192  GeoLogVol * cooling_logC = new GeoLogVol("IBL_Fwd02_Cooling_C",gblShapeCoolingC,coolingMat);
193 
194  // ----------- Create the PhysVol object
195  m_supportPhysA = new GeoPhysVol(supportLogVol_A);
196  m_supportPhysC = new GeoPhysVol(supportLogVol_C);
197 
198  // -------------- Alignement of the services with the previous services (Fwd01 area)
199  double cooling_radius = 35.1;
200  double cooling_angle = -2.154*Gaudi::Units::deg;
201 
202  if(m_gmt_mgr->PixelStaveAxe()==1)
203  {
204  cooling_radius = 34.7 + layerRadius-33.25;
205  cooling_angle = -.1*Gaudi::Units::deg;
206  }
207 
208  double cable_radius = 36.501;
209  GeoPhysVol* cablePhysVolA = new GeoPhysVol(cable_logA);
210  GeoPhysVol* cablePhysVolC = new GeoPhysVol(cable_logC);
211  GeoPhysVol* coolingPhysVolA = new GeoPhysVol(cooling_logA);
212  GeoPhysVol* coolingPhysVolC = new GeoPhysVol(cooling_logC);
213 
214  // nSectors=1;
215 
216  // Loop over the sectors to place the 14 bundles and cooling pipes
217  for(int ii=0; ii<nSectors; ii++)
218  {
219  m_gmt_mgr->SetPhi(ii);
220 
221  // cooling transform
222  double phiOfCooling = phiOfModuleZero+ cooling_angle + ii*angle;
223 
224  std::ostringstream tmp1;
225  tmp1 << "IBL_Fwd02_Cooling_A" << ii;
226  GeoNameTag * tag1 = new GeoNameTag(tmp1.str());
227  GeoTransform* xformA1 = new GeoTransform(GeoTrf::RotateZ3D(phiOfCooling)*GeoTrf::TranslateX3D(cooling_radius));
228  m_supportPhysA->add(tag1);
229  m_supportPhysA->add(xformA1);
230  m_supportPhysA->add(coolingPhysVolA);
231 
232  std::ostringstream tmp1C;
233  tmp1C << "IBL_Fwd02_Cooling_C" << ii;
234  GeoNameTag * tag1C = new GeoNameTag(tmp1C.str());
235  GeoTransform* xformC1 = new GeoTransform(GeoTrf::RotateZ3D(phiOfCooling)*GeoTrf::TranslateX3D(cooling_radius));
236  m_supportPhysC->add(tag1C);
237  m_supportPhysC->add(xformC1);
238  m_supportPhysC->add(coolingPhysVolC);
239 
240  double phiOfCable = phiOfCooling + angle*.5;
241 
242  std::ostringstream tmp2;
243  tmp2 << "IBL_Fwd02_Cable_A" << ii;
244  GeoNameTag * tag2 = new GeoNameTag(tmp2.str());
245  GeoTransform* xformA2 = new GeoTransform(GeoTrf::RotateZ3D(phiOfCable)*GeoTrf::TranslateX3D(cable_radius));
246  m_supportPhysA->add(tag2);
247  m_supportPhysA->add(xformA2);
248  m_supportPhysA->add(cablePhysVolA);
249 
250  std::ostringstream tmp2C;
251  tmp2C << "IBL_Fwd02_Cable_C" << ii;
252  GeoNameTag * tag2C = new GeoNameTag(tmp2C.str());
253  GeoTransform* xformC2 = new GeoTransform(GeoTrf::RotateZ3D(phiOfCable)*GeoTrf::TranslateX3D(cable_radius));
254  m_supportPhysC->add(tag2C);
255  m_supportPhysC->add(xformC2);
256  m_supportPhysC->add(cablePhysVolC);
257 
258  }
259 
260  // Global transforms that include the IBL shift in Z
261  double middleA = zMiddle+layerZshift;
262  double middleC = -zMiddle+layerZshift;
263 
264  GeoTrf::Transform3D supportTrfA = GeoTrf::TranslateZ3D(middleA);
265  m_xformSupportA = new GeoTransform(supportTrfA);
266 
267  GeoTrf::Transform3D supportTrfC = GeoTrf::TranslateZ3D(middleC);
268  m_xformSupportC = new GeoTransform(supportTrfC);
269 
270  return nullptr;
271 
272 #endif
273 
274 }
275 
276 
277 const GeoShape * GeoPixelIBLFwdSvcCADModel::addShape(const GeoShape * lastShape, const GeoShape * nextShape, const GeoTrf::Transform3D & trans)
278 {
279  const GeoShape * shiftedShape = &(*nextShape << trans);
280  if (lastShape) {
281  lastShape = &(lastShape->add(*shiftedShape));
282  } else {
283  lastShape = shiftedShape;
284  }
285  return lastShape;
286 }
PixelGeometryManager::PixelLayerGlobalShift
virtual double PixelLayerGlobalShift()=0
GeoPixelIBLFwdSvcCADModel::m_supportPhysC
GeoPhysVol * m_supportPhysC
Definition: GeoPixelIBLFwdSvcCADModel.h:39
DeMoUpdate.tmp2
string tmp2
Definition: DeMoUpdate.py:1168
max
#define max(a, b)
Definition: cfImp.cxx:41
PixelGeometryManager
Definition: PixelGeometryManager.h:28
PixelGeometryManager::msg
MsgStream & msg(MSG::Level lvl) const
Definition: PixelGeometryManager.h:611
GeoPixelIBLFwdSvcCADModel::Build
virtual GeoVPhysVol * Build() override
Definition: GeoPixelIBLFwdSvcCADModel.cxx:49
GeoPixelIBLFwdSvcCADModel::GeoPixelIBLFwdSvcCADModel
GeoPixelIBLFwdSvcCADModel(InDetDD::PixelDetectorManager *ddmgr, PixelGeometryManager *mgr, GeoModelIO::ReadGeoModel *sqliteReader, std::shared_ptr< std::map< std::string, GeoFullPhysVol * >> mapFPV, std::shared_ptr< std::map< std::string, GeoAlignableTransform * >> mapAX, int)
Definition: GeoPixelIBLFwdSvcCADModel.cxx:35
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:71
GeoPixelIBLFwdSvcCADModel.h
deg
#define deg
Definition: SbPolyhedron.cxx:17
GeoPixelIBLFwdSvcCADModel::addShape
const GeoShape * addShape(const GeoShape *lastShape, const GeoShape *nextShape, const GeoTrf::Transform3D &trans)
Definition: GeoPixelIBLFwdSvcCADModel.cxx:277
pi
#define pi
Definition: TileMuonFitter.cxx:65
GeoVPixelFactory::m_gmt_mgr
PixelGeometryManager * m_gmt_mgr
Definition: GeoVPixelFactory.h:43
PixelGeometryManager::NPixelSectors
virtual int NPixelSectors()=0
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
plotBeamSpotCompare.tag1
string tag1
Definition: plotBeamSpotCompare.py:75
angle
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
Definition: TRTDetectorFactory_Full.cxx:73
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
InDetMaterialManager::getMaterialForVolume
const GeoMaterial * getMaterialForVolume(const std::string &materialName, double volume, const std::string &newName="")
Create and get material with a density calculated to give weight in predefined weight table.
Definition: InDetMaterialManager.cxx:460
PixelGeometryManager::SetPhi
virtual void SetPhi(int phi)=0
plotBeamSpotCompare.tag2
string tag2
Definition: plotBeamSpotCompare.py:76
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
GeoPixelIBLFwdSvcCADModel::m_xformSupportC
GeoTransform * m_xformSupportC
Definition: GeoPixelIBLFwdSvcCADModel.h:41
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
GeoVPixelFactory::m_mat_mgr
InDetMaterialManager * m_mat_mgr
Definition: GeoVPixelFactory.h:44
PixelGeometryManager::PixelStaveAxe
virtual int PixelStaveAxe()=0
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
PixelGeometryManager::PhiOfModuleZero
virtual double PhiOfModuleZero()=0
GeoPixelIBLFwdSvcCADModel::m_supportPhysA
GeoPhysVol * m_supportPhysA
Definition: GeoPixelIBLFwdSvcCADModel.h:38
PixelGeometryManager::PixelLayerRadius
virtual double PixelLayerRadius()=0
GeoVPixelFactory
This is the base class for all the pieces of the Pixel detector.
Definition: GeoVPixelFactory.h:31
tubeLength
double tubeLength
Definition: MDT_ResponseTest.cxx:32
InDetMaterialManager::getMaterial
const GeoMaterial * getMaterial(const std::string &materialName)
Get material. First looks for locally defined material and if not found looks in GeoModel material ma...
Definition: InDetMaterialManager.cxx:96
GeoPixelIBLFwdSvcCADModel::m_xformSupportA
GeoTransform * m_xformSupportA
Definition: GeoPixelIBLFwdSvcCADModel.h:40