ATLAS Offline Software
GeoPixelIBLFwdSvcModel1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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 #include "GeoModelKernel/GeoSimplePolygonBrep.h"
14 #include "GeoModelKernel/GeoShape.h"
15 #include "GeoModelKernel/GeoShapeUnion.h"
16 #include "GeoModelKernel/GeoShapeShift.h"
17 #include "GeoModelKernel/GeoLogVol.h"
18 #include "GeoModelKernel/GeoPhysVol.h"
19 #include "GeoModelKernel/GeoMaterial.h"
20 #include "GeoModelKernel/GeoNameTag.h"
21 
22 #include "GeoModelKernel/GeoTransform.h"
23 #include "GaudiKernel/SystemOfUnits.h"
24 
25 #include <algorithm>
26 #include <iostream>
27 #include <iomanip>
28 #include <cmath>
29 using std::max;
30 
33  GeoModelIO::ReadGeoModel* sqliteReader,
34  std::shared_ptr<std::map<std::string, GeoFullPhysVol*>> mapFPV,
35  std::shared_ptr<std::map<std::string, GeoAlignableTransform*>> mapAX,
36  int /*section*/)
37  : GeoVPixelFactory (ddmgr, mgr, sqliteReader, mapFPV, mapAX),
38  m_supportPhysA(nullptr),
39  m_supportPhysC(nullptr),
40  m_xformSupportA(nullptr),
41  m_xformSupportC(nullptr)
42 {
43 }
44 
46 {
47 
48  m_gmt_mgr->msg(MSG::INFO) <<"Build IBL fwd services"<<endmsg;
49 
50  // double safety = 0.01*Gaudi::Units::mm;
51 
52  // IBL layer shift ( 2mm shift issue )
53  double layerZshift = m_gmt_mgr->PixelLayerGlobalShift();
54  int nSectors = m_gmt_mgr->NPixelSectors();
55  double phiOfModuleZero = m_gmt_mgr->PhiOfModuleZero();
56  double layerRadius = m_gmt_mgr->PixelLayerRadius();
57 
58  // check if sectors are properly defined
59  if(nSectors==0) return nullptr;
60  double angle=360./(double)nSectors*Gaudi::Units::deg;
61 
62  // Defines the IBL_Fwd02 section in the IBL services area
63  double innerRadius = 33.;
64  double outerRadius = 42.499;
65  double zMin = 834.607;
66  double zMax = 3290.795;
67 
68  double zLength = zMax-zMin;
69  double halfLength = zLength*.5;
70  double zMiddle = (zMin+zMax)*.5;
71 
72  // Define IBL fwd svc section for side A and C
73  std::ostringstream lnameA;
74  lnameA<<"Brl0A_FwdSvc";
75  std::ostringstream lnameC;
76  lnameC<<"Brl0C_FwdSvc";
77 
78  // Build encompassing volume for both A and C sides (assemblies)
79  const GeoTube* supportShapeA = new GeoTube(innerRadius,outerRadius,halfLength);
80  const GeoTube* supportShapeC = new GeoTube(innerRadius,outerRadius,halfLength);
81  const GeoMaterial* ether = m_mat_mgr->getMaterial("special::Ether");
82  // const GeoMaterial* ether = m_mat_mgr->getMaterial("std::Air");
83  GeoLogVol* supportLogVol_A = new GeoLogVol(lnameA.str(),supportShapeA,ether);
84  GeoLogVol* supportLogVol_C = new GeoLogVol(lnameC.str(),supportShapeC,ether);
85 
86  // Shift in phi
87  double pi = M_PI;
88  // double deltaPhi = pi/28.;
89 
90  // Data taken fron CATIA desgin file
91  double devTotalLength = 2460.188;
92 
93  // Cable bundle sizes
94  double rminCable = 0.;
95  double rmaxCable = 8.*.5;
96  double surfCable = rmaxCable*rmaxCable*pi;
97 
98  // Cooling tube sizes
99  double rminCooling = 0.;
100  double rmaxCooling = 1.75*.5;
101  double surfCooling = rmaxCooling*rmaxCooling*pi;
102 
103  // IPT clip starting position
104  // double zpos0 = 903.;
105  double zpos = 0.;
106  // double zposRing = 0.;
107  // double hermJunction = .4;
108  double breakAngle = 11.*Gaudi::Units::deg;
109 
110  double cooling_radius = 35.1;
111  double cooling_angle = -2.154*Gaudi::Units::deg;
112 
113  if(m_gmt_mgr->PixelStaveAxe()==1)
114  {
115  cooling_radius = 34.7 + layerRadius-33.25;
116  cooling_angle = -.1*Gaudi::Units::deg;
117  }
118 
119  double cable_radius = 36.501;
120  // double cable_radius = innerRadius+rmaxCable+0.001;
121 
122  // Eta steps
123  int nbSteps = 3;
124  double etaSteps[3] = {3.8, 4.3, 4.8 };
125 
126  // Z steps
127  // double zDelta1 = 50;
128  std::vector<double> zSteps;
129  bool bFirstLin = true;
130  for(int i=0; i<nbSteps; i++){
131  double tmp = 2.*atan(exp(etaSteps[i]));
132  double tmp2 = tan(tmp);
133  double z = fabs(cable_radius/tmp2);
134 
135  if(i==0) {
136  if(z>zMin){
137  zSteps.push_back(zMin+0.001);
138  zSteps.push_back(z);
139  }
140  else {
141  // bFirstLin = false;
142  zSteps.push_back(zMin+0.001);
143  zSteps.push_back(zMin+10.);
144  }
145  }
146  else
147  zSteps.push_back(z);
148 
149  // std::cout<<"Eta/Z : "<<etaSteps[i]<<" "<<z<<std::endl;
150  }
151  zSteps.push_back(zMax-0.001);
152  nbSteps+=1;
153  if(bFirstLin)nbSteps++;
154 
155  // Loop over the wavy shape sections to build a cable and a cooling pipe
156  const GeoShape * gblShapeCableA = nullptr;
157  const GeoShape * gblShapeCoolingA = nullptr;
158  const GeoShape * gblShapeCableC = nullptr;
159  const GeoShape * gblShapeCoolingC = nullptr;
160 
161 // deltaPhi = (2.*pi)/28.;
162 // deltaPhi = .2815;
163 // double deltaMiddle_all = cable_radius*tan(deltaPhi);
164 
165  double deltaMiddle_all = 18.;
166 
167  // deltaMiddle_all = 10.5.;
168  // std::cout<<"IBL fwd : "<<deltaMiddle_all<<std::endl;
169 
170  zpos = zSteps[0];
171  int angleSign = 1;
172  for(int iStep=0; iStep<nbSteps-1; iStep++)
173  {
174  double zInit = zSteps[iStep];
175  double zFinal = zSteps[iStep+1];
176  double zMid = (zInit+zFinal)*.5;
177  double zHalfLength = zMid-zInit;
178  double zLength = zFinal-zInit;
179 
180  // std::cout<<"--- STEP "<<std::setprecision(13)<<iStep<<" "<<zInit<<" "<<zFinal<<std::endl;
181 
182 // double deltaPhiLoc = fabs(atan(deltaMiddle_all/(zHalfLength));
183 // double cableHalfLength = zHalfLength / cos(deltaPhiLoc);
184 // double cableLength = zHalfLength / cos(deltaPhiLoc);
185 // double deltaMiddleLoc = deltaMiddle_all*.5;
186 
187  double deltaPhiLoc = fabs(atan(deltaMiddle_all/zLength));
188  double cableHalfLength = (zLength / cos(deltaPhiLoc))*.5;
189  double deltaMiddleLoc = deltaMiddle_all*.5;
190 
191  // std::cout<<" "<<zHalfLength<<"/"<<cableHalfLength<<" "<<deltaMiddleLoc<<std::endl;
192 
193  if((iStep==0&&bFirstLin)||iStep==nbSteps-2) {
194  // linear section
195  zpos += zHalfLength;
196 
197  // Cable
198  const GeoTube* cableShape = new GeoTube(rminCable, rmaxCable, zHalfLength);
199  double angle = 0.; //11.*Gaudi::Units::deg;
200  GeoTrf::Transform3D trfA1 = GeoTrf::RotateZ3D(angle)*GeoTrf::TranslateZ3D(zpos-zMiddle);
201  gblShapeCableA = addShape(gblShapeCableA, cableShape, trfA1 );
202  GeoTrf::Transform3D trfC1 = GeoTrf::RotateZ3D(angle)*GeoTrf::TranslateZ3D(zMax-(zpos-zMin)-zMiddle);
203  gblShapeCableC = addShape(gblShapeCableC, cableShape, trfC1 );
204 
205  // Cooling
206  const GeoTube* coolingShape = new GeoTube(rminCooling, rmaxCooling, zHalfLength);
207  gblShapeCoolingA = addShape(gblShapeCoolingA, coolingShape, trfA1 );
208  gblShapeCoolingC = addShape(gblShapeCoolingC, coolingShape, trfC1 );
209 
210  zpos += zHalfLength;
211  }
212  else {
213 
214  // First section
215  zpos += zHalfLength;
216 
217  // Cable
218  const GeoTube* cableShape = new GeoTube(rminCable, rmaxCable, cableHalfLength);
219  double angle= 0.;
220  GeoTrf::Transform3D trfA1 = GeoTrf::RotateZ3D(angle)*GeoTrf::TranslateY3D(deltaMiddleLoc)* GeoTrf::TranslateZ3D(zpos-zMiddle)*GeoTrf::RotateX3D(-angleSign*deltaPhiLoc);
221  gblShapeCableA = addShape(gblShapeCableA, cableShape, trfA1 );
222  GeoTrf::Transform3D trfC1 = GeoTrf::RotateZ3D(angle)*GeoTrf::TranslateY3D(deltaMiddleLoc)* GeoTrf::TranslateZ3D(zMax-(zpos-zMin)-zMiddle)*GeoTrf::RotateX3D(angleSign*deltaPhiLoc);
223  gblShapeCableC = addShape(gblShapeCableC, cableShape, trfC1 );
224 
225  // Cooling
226  const GeoTube* coolingShape = new GeoTube(rminCooling, rmaxCooling, cableHalfLength);
227  gblShapeCoolingA = addShape(gblShapeCoolingA, coolingShape, trfA1 );
228  gblShapeCoolingC = addShape(gblShapeCoolingC, coolingShape, trfC1 );
229 
230  zpos += zHalfLength;
231  angleSign*=-1;
232  }
233 
234 
235  }
236 
237  // std::cout<<"--- MATERIAL : length "<<devTotalLength<<" surf "<<surfCable<<std::endl;
238 
239  // Material (material budget computed based on the detailed description of a cable bundle and cooling pipe
240  const GeoMaterial* cableMat = m_mat_mgr->getMaterialForVolume("pix::IBL_Fwd02_Cable_Wvy_M1",surfCable*devTotalLength);
241 
242  // std::cout<<"--- MATERIAL : cable defined "<<(cableMat==0)<<std::endl;
243 
244  GeoLogVol * cable_logA = new GeoLogVol("IBL_Fwd02_Cable_A",gblShapeCableA,cableMat);
245  GeoLogVol * cable_logC = new GeoLogVol("IBL_Fwd02_Cable_C",gblShapeCableC,cableMat);
246 
247  const GeoMaterial* coolingMat = m_mat_mgr->getMaterialForVolume("pix::IBL_Fwd02_Cooling_Wvy_M1",surfCooling*devTotalLength);
248  // std::cout<<"--- MATERIAL : cooling defined "<<(cableMat==0)<<std::endl;
249  GeoLogVol * cooling_logA = new GeoLogVol("IBL_Fwd02_Cooling_A",gblShapeCoolingA,coolingMat);
250  GeoLogVol * cooling_logC = new GeoLogVol("IBL_Fwd02_Cooling_C",gblShapeCoolingC,coolingMat);
251 
252  // ----------- Create the PhysVol object
253  m_supportPhysA = new GeoPhysVol(supportLogVol_A);
254  m_supportPhysC = new GeoPhysVol(supportLogVol_C);
255 
256  // -------------- Alignement of the services with the previous services (Fwd01 area)
257  GeoPhysVol* cablePhysVolA = new GeoPhysVol(cable_logA);
258  GeoPhysVol* cablePhysVolC = new GeoPhysVol(cable_logC);
259  GeoPhysVol* coolingPhysVolA = new GeoPhysVol(cooling_logA);
260  GeoPhysVol* coolingPhysVolC = new GeoPhysVol(cooling_logC);
261 
262  // std::cout<<"--- LOOP over sectors"<<std::endl;
263 
264  // nSectors = 1;
265 
266  // Loop over the sectors to place the 14 bundles and cooling pipes
267  for(int ii=0; ii<nSectors; ii++)
268  {
269  m_gmt_mgr->SetPhi(ii);
270 
271  // cooling transform
272  double phiOfCooling = phiOfModuleZero+ cooling_angle + ii*angle;
273 
274  std::ostringstream tmp1;
275  tmp1 << "IBL_Fwd02_Cooling_AC" << ii;
276  GeoNameTag * tag1 = new GeoNameTag(tmp1.str());
277  GeoTransform* xformA1 = new GeoTransform(GeoTrf::RotateZ3D(phiOfCooling)*GeoTrf::TranslateX3D(cooling_radius));
278  m_supportPhysA->add(tag1);
279  m_supportPhysA->add(xformA1);
280  m_supportPhysA->add(coolingPhysVolA);
281 
282  GeoTransform* xformC1 = new GeoTransform(GeoTrf::RotateZ3D(phiOfCooling)*GeoTrf::TranslateX3D(cooling_radius));
283  m_supportPhysC->add(tag1);
284  m_supportPhysC->add(xformC1);
285  m_supportPhysC->add(coolingPhysVolC);
286 
287  double phiOfCable = phiOfCooling + angle*.5;
288 
289  std::ostringstream tmp2;
290  tmp2 << "IBL_Fwd02_Cable_AC" << ii;
291  GeoNameTag * tag2 = new GeoNameTag(tmp2.str());
292  GeoTransform* xformA2 = new GeoTransform(GeoTrf::RotateZ3D(phiOfCable)*GeoTrf::TranslateX3D(cable_radius)*GeoTrf::RotateZ3D(breakAngle));
293  m_supportPhysA->add(tag2);
294  m_supportPhysA->add(xformA2);
295  m_supportPhysA->add(cablePhysVolA);
296 
297  GeoTransform* xformC2 = new GeoTransform(GeoTrf::RotateZ3D(phiOfCable)*GeoTrf::TranslateX3D(cable_radius)*GeoTrf::RotateZ3D(breakAngle));
298  m_supportPhysC->add(tag2);
299  m_supportPhysC->add(xformC2);
300  m_supportPhysC->add(cablePhysVolC);
301  }
302 
303  // Global transforms that include the IBL shift in Z
304  double middleA = zMiddle+layerZshift;
305  double middleC = -zMiddle+layerZshift;
306 
307  GeoTrf::Transform3D supportTrfA = GeoTrf::TranslateZ3D(middleA);
308  m_xformSupportA = new GeoTransform(supportTrfA);
309 
310  GeoTrf::Transform3D supportTrfC = GeoTrf::TranslateZ3D(middleC);
311  m_xformSupportC = new GeoTransform(supportTrfC);
312 
313  return nullptr;
314 }
315 
316 
317 const GeoShape * GeoPixelIBLFwdSvcModel1::addShape(const GeoShape * lastShape, const GeoShape * nextShape, const GeoTrf::Transform3D & trans)
318 {
319  const GeoShape * shiftedShape = &(*nextShape << trans);
320  if (lastShape) {
321  lastShape = &(lastShape->add(*shiftedShape));
322  } else {
323  lastShape = shiftedShape;
324  }
325  return lastShape;
326 }
PixelGeometryManager::PixelLayerGlobalShift
virtual double PixelLayerGlobalShift()=0
GeoPixelIBLFwdSvcModel1::Build
virtual GeoVPhysVol * Build() override
Definition: GeoPixelIBLFwdSvcModel1.cxx:45
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
GeoPixelIBLFwdSvcModel1.h
M_PI
#define M_PI
Definition: ActiveFraction.h:11
GeoPixelIBLFwdSvcModel1::m_xformSupportA
GeoTransform * m_xformSupportA
Definition: GeoPixelIBLFwdSvcModel1.h:40
deg
#define deg
Definition: SbPolyhedron.cxx:17
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
GeoPixelIBLFwdSvcModel1::GeoPixelIBLFwdSvcModel1
GeoPixelIBLFwdSvcModel1(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: GeoPixelIBLFwdSvcModel1.cxx:31
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
GeoPixelIBLFwdSvcModel1::m_supportPhysC
GeoPhysVol * m_supportPhysC
Definition: GeoPixelIBLFwdSvcModel1.h:39
GeoPixelIBLFwdSvcModel1::m_supportPhysA
GeoPhysVol * m_supportPhysA
Definition: GeoPixelIBLFwdSvcModel1.h:38
pi
#define pi
Definition: TileMuonFitter.cxx:65
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
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
GeoPixelIBLFwdSvcModel1::m_xformSupportC
GeoTransform * m_xformSupportC
Definition: GeoPixelIBLFwdSvcModel1.h:41
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
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
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
GeoVPixelFactory::m_mat_mgr
InDetMaterialManager * m_mat_mgr
Definition: GeoVPixelFactory.h:44
PixelGeometryManager::PixelStaveAxe
virtual int PixelStaveAxe()=0
PixelGeometryManager::PhiOfModuleZero
virtual double PhiOfModuleZero()=0
GeoPixelIBLFwdSvcModel1::addShape
const GeoShape * addShape(const GeoShape *lastShape, const GeoShape *nextShape, const GeoTrf::Transform3D &trans)
Definition: GeoPixelIBLFwdSvcModel1.cxx:317
PixelGeometryManager::PixelLayerRadius
virtual double PixelLayerRadius()=0
GeoVPixelFactory
This is the base class for all the pieces of the Pixel detector.
Definition: GeoVPixelFactory.h:31
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