ATLAS Offline Software
GeoPixelEnvelope.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 #include "GeoPixelEnvelope.h"
6 #include "GeoModelKernel/GeoTube.h"
7 #include "GeoModelKernel/GeoPcon.h"
8 #include "GeoModelKernel/GeoLogVol.h"
9 #include "GeoModelKernel/GeoNameTag.h"
10 #include "GeoModelKernel/GeoIdentifierTag.h"
11 #include "GeoModelKernel/GeoFullPhysVol.h"
12 #include "GeoModelKernel/GeoTransform.h"
13 #include "GeoModelKernel/GeoMaterial.h"
14 #include "GaudiKernel/PhysicalConstants.h"
15 
16 #include "GeoPixelBarrel.h"
17 #include "GeoPixelEndCap.h"
18 #include "GeoPixelServices.h"
19 #include "GeoPixelFrame.h"
20 #include "GeoPixelOldFrame.h"
21 #include "GeoPixelIFlexServices.h"
22 #include "GeoPixelIBLFwdServices.h"
23 #include "DBM_Det.h"
24 
27 
29 
31 #include "GaudiKernel/StatusCode.h"
32 
34 
35 GeoVPhysVol* GeoPixelEnvelope::Build( ) {
36 
37  //
38  // Control which parts get built. This is mainly of use for
39  // Cosmic runs where the whole detector is not present
40  //
41 
42  bool barrelPresent = m_gmt_mgr->partPresent("Barrel");
43  bool endcapAPresent = m_gmt_mgr->partPresent("EndcapA");
44  bool endcapCPresent = m_gmt_mgr->partPresent("EndcapC");
45 
46 
47  if(m_sqliteReader) {
48 
49  GeoFullPhysVol* pPixelEnvelopeVol=(*m_mapFPV)["Pixel_Envelope"];
50 
51  // Add Barrel
52  if (barrelPresent) {
56  brl.Build();
57  }
58 
59  // Add EndCaps
60  if (endcapAPresent || endcapCPresent) {
62 
64 
65  // EndCap A
66  if (endcapAPresent) {
68  m_gmt_mgr->SetPos();
69  pec.Build();
70  }
71 
72  // EndCap C
73  if (endcapCPresent) {
76  m_gmt_mgr->SetNeg();
77  pec.Build();
78  }
79  }
80  // Extra Material
82  xMat.add(pPixelEnvelopeVol,"Pixel");
83 
84  // DBM
85  if(m_gmt_mgr->dbm()) {
87  m_gmt_mgr->SetPos();
89  theDBM.Build() ;
90 
91  m_gmt_mgr->SetNeg();
92  theDBM.Build() ;
93  }
94  else {
97  }
98 
99  // reset BarrelEndcap value to zero
100  m_gmt_mgr->SetBarrel();
101 
102  return pPixelEnvelopeVol;
103  }
104 
105 
106  // NB. We apply the part transforms only to the active parts.
107  // In general though they should always be zero. It would make more sense to apply
108  // a transform to the overl pixel if one wants to move the detector.
109 
110  //
111  // create the External volume where I'll put all the pixel detector
112  // This can either be a simple tube or a more general PCON.
113  //
114  const GeoShape * envelopeShape;
115  InDetDD::Zone * pixZone = nullptr;
117  double rmin = m_gmt_mgr->PixelRMin();
118  double rmax = m_gmt_mgr->PixelRMax();
119  double halflength = m_gmt_mgr->PixelHalfLength();
120  envelopeShape = new GeoTube(rmin,rmax,halflength);
121  pixZone = new InDetDD::TubeZone("Pixel",-halflength,halflength,rmin,rmax);
122  } else {
123  GeoPcon* envelopeShapeTmp = new GeoPcon(0.,2*Gaudi::Units::pi);
124  // table contains +ve z values only and envelope is assumed to be symmetric around z.
125  int numPlanes = m_gmt_mgr->PixelEnvelopeNumPlanes();
126  for (int i = 0; i < numPlanes * 2; i++) {
127  int tableIndex = (i < numPlanes) ? numPlanes - 1 - i : i - numPlanes;
128  int sign = (i < numPlanes) ? -1 : 1;
129  double z = m_gmt_mgr->PixelEnvelopeZ(tableIndex) * sign;
130  double rmin = m_gmt_mgr->PixelEnvelopeRMin(tableIndex);
131  double rmax = m_gmt_mgr->PixelEnvelopeRMax(tableIndex);
132  envelopeShapeTmp->addPlane(z, rmin, rmax);
133  }
134  envelopeShape = envelopeShapeTmp;
135  pixZone = new InDetDD::PconZone("Pixel",envelopeShapeTmp);
136  }
137  const GeoMaterial* air = m_mat_mgr->getMaterial("std::Air");
138  const GeoLogVol* envelopeLog = new GeoLogVol("Pixel",envelopeShape,air);
139  GeoFullPhysVol* envelopePhys = new GeoFullPhysVol(envelopeLog);
140 
141  GeoPixelServices * pixServices = nullptr;
142  if(m_gmt_mgr->DoServices() ) {
143  // Takes ownership of pixZone
144  pixServices = new GeoPixelServices(m_DDmgr, m_gmt_mgr, m_sqliteReader, m_mapFPV, m_mapAX, pixZone);
145  } else {
146  delete pixZone;
147  }
148 
149  if (barrelPresent) {
150 
152  //
153  // Add the Barrel:
154  //
155  GeoTrf::Transform3D barrelTransform = m_gmt_mgr->partTransform("Barrel");
156 
157  m_gmt_mgr->SetBarrel();
159  GeoNameTag* tag = new GeoNameTag("Barrel");
160  GeoVPhysVol* barrelPhys = brl.Build() ;
161  envelopePhys->add(tag);
162  envelopePhys->add(new GeoIdentifierTag(0));
163  envelopePhys->add(new GeoTransform(barrelTransform));
164  envelopePhys->add(barrelPhys );
165  }
166  //
167  // Add the EndCaps
168  if (endcapAPresent || endcapCPresent) {
169  m_gmt_mgr->SetEndcap();
170 
172  double zpos = (m_gmt_mgr->PixelEndcapZMax()+m_gmt_mgr->PixelEndcapZMin())/2.;
173 
174  // EndCap A
175  if (endcapAPresent) {
176 
178 
179  GeoTrf::Transform3D endcapATransform = m_gmt_mgr->partTransform("EndcapA");
180 
181  m_gmt_mgr->SetPos();
182  GeoTransform* xform = new GeoTransform(endcapATransform * GeoTrf::TranslateZ3D(zpos));
183  GeoNameTag* tag = new GeoNameTag("EndCapA");
184  envelopePhys->add(tag);
185  envelopePhys->add(new GeoIdentifierTag(2));
186  envelopePhys->add(xform);
187  envelopePhys->add(pec.Build() );
188  }
189 
190  // EndCap C
191  if (endcapCPresent) {
192 
194 
195  GeoTrf::Transform3D endcapCTransform = m_gmt_mgr->partTransform("EndcapC");
196 
197  m_gmt_mgr->SetEndcap();
198  m_gmt_mgr->SetNeg();
199  GeoTransform* xform = new GeoTransform(endcapCTransform * GeoTrf::TranslateZ3D(-zpos) * GeoTrf::RotateY3D(180*Gaudi::Units::deg));
200  GeoNameTag* tag = new GeoNameTag("EndCapC");
201  envelopePhys->add(tag);
202  envelopePhys->add(new GeoIdentifierTag(-2));
203  envelopePhys->add(xform);
204  envelopePhys->add(pec.Build() );
205 
206  }
207 
208  if(m_gmt_mgr->DoServices() ) {
209  // Pixel Frame. In recent versions this taken care of in the general services.
210  if (m_gmt_mgr->oldFrame()) {
212  frame.BuildOutBarrel(envelopePhys);
213  }
214  }
215  }
216 
217 
218  if(pixServices) {
219  //
220  // Add the Barrel and endcap services outside the barrel and endcap volume
221  //
222  pixServices->getBuilder()->buildAndPlace("Pixel", envelopePhys);
223  if (pixServices->getServMatBuilder()) {
224  pixServices->getServMatBuilder()->buildAndPlace("Pixel", envelopePhys);
225  }
226 
227  //
228  // Add IBL services
229  //
232  {
233  // Build IBL services from endblock to PP0
234  for(int iSection=1; iSection<4; iSection++)
235  {
236 
237  // ----------- end of stave PP0 services (insde barrel)
238 
240  iFlexSrv.Build();
241 
242  GeoNameTag * tagFlexA = new GeoNameTag("PP0Flex_A");
243  GeoTransform *xformFlexA = iFlexSrv.getSupportTrfA();
244  GeoPhysVol *flexPhys_A = iFlexSrv.getSupportA();
245  envelopePhys->add(tagFlexA);
246  envelopePhys->add(xformFlexA);
247  envelopePhys->add(flexPhys_A);
248 
249  GeoNameTag * tagFlexC = new GeoNameTag("PP0Flex_C");
250  GeoTransform *xformFlexC = iFlexSrv.getSupportTrfC();
251  GeoPhysVol *flexPhys_C = iFlexSrv.getSupportC();
252  envelopePhys->add(tagFlexC);
253  envelopePhys->add(xformFlexC);
254  envelopePhys->add(flexPhys_C);
255  }
256 
257  // Build IBL fwd services (wavy shapes)
258  int iSection=2;
260  if(fwdSrv.isComplexShapeDefined()){
261 
262  fwdSrv.Build();
263 
264  GeoNameTag * tagFwdSvcA = new GeoNameTag("FwdSvc_A");
265  GeoTransform *xformFwdSvcA = fwdSrv.getSupportTrfA();
266  GeoPhysVol *svcPhys_A = fwdSrv.getSupportA();
267  envelopePhys->add(tagFwdSvcA);
268  envelopePhys->add(xformFwdSvcA);
269  envelopePhys->add(svcPhys_A);
270 
271  GeoNameTag * tagFwdSvcC = new GeoNameTag("FwdSvc_C");
272  GeoTransform *xformFwdSvcC = fwdSrv.getSupportTrfC();
273  GeoPhysVol *svcPhys_C = fwdSrv.getSupportC();
274  envelopePhys->add(tagFwdSvcC);
275  envelopePhys->add(xformFwdSvcC);
276  envelopePhys->add(svcPhys_C);
277  }
278  }
279  }
280 
281  // Build detailed frame
283  int numSections = m_gmt_mgr->PixelFrameSections();
285  for (int iSection = 0; iSection < numSections; iSection++) {
286  //GeoVPhysVol * framePhys = frame.Build(iSection);
287  //envelopePhys->add(framePhys);
288  frame.BuildAndPlace(envelopePhys,iSection);
289  }
290  }
291 
292  // Extra Material
294  xMat.add(envelopePhys,"Pixel");
295 
296  // DBM
297  // Z-positon is Hardcoded,
298  // so if change then change in DBM_module too
299 
300  if (m_gmt_mgr->dbm()) {
301  GeoTrf::Translate3D dbmTransform1( 0, 0, 887.002*Gaudi::Units::mm + ( m_gmt_mgr->DBMTelescopeZ() )/2.); //Add 0.002mm to 887mm for safety
302 
303  //m_DDmgr->numerology().addEndcap(4);
305  m_gmt_mgr->SetPos();
307  GeoNameTag* tag1 = new GeoNameTag("DBMA");
308  GeoVPhysVol* dbmPhys1 = theDBM.Build() ;
309  envelopePhys->add(tag1);
310  envelopePhys->add(new GeoIdentifierTag(4));
311  envelopePhys->add(new GeoTransform(dbmTransform1));
312  envelopePhys->add(dbmPhys1 );
313 
314  //m_DDmgr->numerology().addEndcap(-4);
315  m_gmt_mgr->SetNeg();
316  GeoNameTag* tag2 = new GeoNameTag("DBMC");
317  GeoTransform* dbmTransform2 = new GeoTransform(GeoTrf::TranslateZ3D(-887.002*Gaudi::Units::mm - ( m_gmt_mgr->DBMTelescopeZ() )/2.) * GeoTrf::RotateY3D(180*Gaudi::Units::deg));
318  envelopePhys->add(tag2);
319  envelopePhys->add(new GeoIdentifierTag(-4));
320  envelopePhys->add(dbmTransform2);
321  envelopePhys->add(theDBM.Build());
322  } else {
325  }
326 
327  // reset BarrelEndcap value to zero
328  m_gmt_mgr->SetBarrel();
329 
330 
331  // BCM
332  if (m_gmt_mgr->athenaComps()->bcm()) {
333  // Already retrieved in PixelDetectorTool
334  StatusCode sc = m_gmt_mgr->athenaComps()->bcm()->build(envelopePhys);
335  if (sc.isFailure()) {
336  std::cout << "PixelGeoModel failed to build BCM." << std::endl;
337  }
338  }
339 
340  // BLM
341  if (m_gmt_mgr->athenaComps()->blm()) {
342  // Already retrieved in PixelDetectorTool
343  StatusCode sc = m_gmt_mgr->athenaComps()->blm()->build(envelopePhys);
344  if (sc.isFailure()) {
345  std::cout << "PixelGeoModel failed to build BLM." << std::endl;
346  }
347  }
348 
349  if(pixServices) delete pixServices;
350 
351  return envelopePhys;
352 
353 
354 }
355 
356 
PixelGeometryManager::distortedMatManager
virtual InDetDD::DistortedMaterialManager * distortedMatManager()=0
GeoPixelIBLFwdServices::getSupportA
GeoPhysVol * getSupportA()
Definition: GeoPixelIBLFwdServices.h:30
GeoPixelIBLFwdServices::getSupportC
GeoPhysVol * getSupportC()
Definition: GeoPixelIBLFwdServices.h:31
PixelGeometryManager::PixelEnvelopeRMax
virtual double PixelEnvelopeRMax(int i)=0
GeoPixelFrame.h
GeoPixelOldFrame.h
PixelGeometryManager::DBMTelescopeZ
virtual double DBMTelescopeZ()=0
InDetDD::SiDetectorManager::numerology
const SiNumerology & numerology() const
Access Numerology.
Definition: SiDetectorManager.h:126
PixelGeometryManager::SetPartsDBM
virtual void SetPartsDBM()=0
PixelGeometryManager::PixelFrameSections
virtual int PixelFrameSections()=0
PixelGeometryManager::PixelEndcapZMax
virtual double PixelEndcapZMax()=0
GeoPixelIBLFwdServices::getSupportTrfC
GeoTransform * getSupportTrfC()
Definition: GeoPixelIBLFwdServices.h:33
GeoPixelEnvelope.h
PixelGeometryManager::SetEndcap
virtual void SetEndcap()=0
PixelGeometryManager::PixelSimpleEnvelope
virtual bool PixelSimpleEnvelope()=0
InDetDD::Zone
Definition: VolumeSplitterUtils.h:71
GeoPixelBarrel.h
InDetDD::SiNumerology::addEndcap
void addEndcap(int id)
Definition: SiNumerology.cxx:102
PixelGeometryManager::ibl
virtual bool ibl() const =0
GeoPixelBarrel
Definition: GeoPixelBarrel.h:11
IGeoSubDetTool::build
virtual StatusCode build(GeoVPhysVol *parent)=0
GeoPixelEndCap.h
deg
#define deg
Definition: SbPolyhedron.cxx:17
DBM_Det.h
GeoPixelFrame::BuildAndPlace
void BuildAndPlace(GeoFullPhysVol *parent, int section)
Definition: GeoPixelFrame.cxx:30
ExtraMaterial.h
PixelGeometryManager::DoServices
virtual bool DoServices()=0
GeoPixelIFlexServices::getSupportA
GeoPhysVol * getSupportA()
Definition: GeoPixelIFlexServices.h:29
GeoVPixelFactory::m_mapAX
std::shared_ptr< std::map< std::string, GeoAlignableTransform * > > m_mapAX
Definition: GeoVPixelFactory.h:48
GeoVPixelFactory::m_sqliteReader
GeoModelIO::ReadGeoModel * m_sqliteReader
Definition: GeoVPixelFactory.h:46
PixelGeoModelAthenaComps::blm
IGeoSubDetTool * blm()
Definition: PixelGeoModelAthenaComps.cxx:35
GeoPixelOldFrame
Definition: GeoPixelOldFrame.h:14
GeoPixelServices.h
InDetDD::VolumeBuilder::buildAndPlace
void buildAndPlace(const std::string &region, GeoPhysVol *parent, double zcenter=0)
Definition: VolumeBuilder.cxx:83
GeoVPixelFactory::m_DDmgr
InDetDD::PixelDetectorManager * m_DDmgr
Definition: GeoVPixelFactory.h:45
InDetDD::ExtraMaterial::add
void add(GeoPhysVol *parent, const std::string &parentName, double zPos=0)
Definition: ExtraMaterial.cxx:42
pi
#define pi
Definition: TileMuonFitter.cxx:65
GeoVPixelFactory::m_gmt_mgr
PixelGeometryManager * m_gmt_mgr
Definition: GeoVPixelFactory.h:43
InDetDD::SiNumerology::setNumDisksDBM
void setNumDisksDBM(int nDisks)
Definition: SiNumerology.cxx:108
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
GeoPixelEnvelope::Build
virtual GeoVPhysVol * Build() override
Definition: GeoPixelEnvelope.cxx:35
GeoVPixelFactory::m_mapFPV
std::shared_ptr< std::map< std::string, GeoFullPhysVol * > > m_mapFPV
Definition: GeoVPixelFactory.h:47
PixelGeometryManager::PixelHalfLength
virtual double PixelHalfLength()=0
PixelGeoModelAthenaComps::bcm
IGeoSubDetTool * bcm()
Definition: PixelGeoModelAthenaComps.cxx:23
PixelGeometryManager::athenaComps
PixelGeoModelAthenaComps * athenaComps()
Definition: PixelGeometryManager.h:616
GeoPixelOldFrame::BuildOutBarrel
void BuildOutBarrel(GeoFullPhysVol *parent)
Definition: GeoPixelOldFrame.cxx:207
GeoPixelIBLFwdServices
Definition: GeoPixelIBLFwdServices.h:17
PixelDetectorManager.h
GeoPixelEndCap::Build
virtual GeoVPhysVol * Build() override
Definition: GeoPixelEndCap.cxx:37
PixelGeometryManager::PixelRMax
virtual double PixelRMax()=0
PixelGeometryManager::SetBarrel
virtual void SetBarrel()=0
lumiFormat.i
int i
Definition: lumiFormat.py:85
PixelGeometryManager::detailedFrame
virtual bool detailedFrame()=0
z
#define z
GeoPixelIFlexServices
Definition: GeoPixelIFlexServices.h:17
plotBeamSpotCompare.tag1
string tag1
Definition: plotBeamSpotCompare.py:75
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
GeoPixelServices
Definition: GeoPixelServices.h:17
GeoPixelFrame
Definition: GeoPixelFrame.h:10
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
plotBeamSpotCompare.tag2
string tag2
Definition: plotBeamSpotCompare.py:76
GeoPixelIBLFwdServices::Build
virtual GeoVPhysVol * Build() override
Definition: GeoPixelIBLFwdServices.cxx:69
PixelGeometryManager::PixelEnvelopeNumPlanes
virtual unsigned int PixelEnvelopeNumPlanes()=0
IGeoSubDetTool.h
PixelGeometryManager::PixelEnvelopeZ
virtual double PixelEnvelopeZ(int i)=0
InDetDD::SiNumerology::setNumBarrelDBM
void setNumBarrelDBM(int nBarrel)
Definition: SiNumerology.cxx:125
PixelGeometryManager::partTransform
virtual const GeoTrf::Transform3D & partTransform(const std::string &partName) const =0
GeoPixelIFlexServices::getSupportC
GeoPhysVol * getSupportC()
Definition: GeoPixelIFlexServices.h:30
PixelGeometryManager::oldFrame
virtual bool oldFrame()=0
PixelGeometryManager::SetPos
virtual void SetPos()=0
GeoPixelIFlexServices::getSupportTrfA
GeoTransform * getSupportTrfA()
Definition: GeoPixelIFlexServices.h:31
PixelGeometryManager::PixelStaveLayout
virtual int PixelStaveLayout()=0
PixelGeometryManager::SetNeg
virtual void SetNeg()=0
GeoPixelEndCap
Definition: GeoPixelEndCap.h:11
PixelGeometryManager::SetCurrentLD
virtual void SetCurrentLD(int i)=0
DBM_Det
Diamond Beam Monitor detector builder.
Definition: DBM_Det.h:15
GeoVPixelFactory::m_mat_mgr
InDetMaterialManager * m_mat_mgr
Definition: GeoVPixelFactory.h:44
GeoPixelBarrel::Build
virtual GeoVPhysVol * Build() override
Definition: GeoPixelBarrel.cxx:43
InDetDD::PconZone
Definition: VolumeSplitterUtils.h:120
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
VolumeSplitterUtils.h
PixelGeometryManager::PixelEndcapZMin
virtual double PixelEndcapZMin()=0
GeoPixelIFlexServices::Build
virtual GeoVPhysVol * Build() override
Definition: GeoPixelIFlexServices.cxx:41
GeoPixelServices::getServMatBuilder
InDetDD::VolumeBuilder * getServMatBuilder()
Definition: GeoPixelServices.h:32
GeoPixelIBLFwdServices.h
PixelGeometryManager::dbm
virtual bool dbm() const =0
VolumeBuilder.h
PixelGeometryManager::IBLFlexAndWingDefined
virtual bool IBLFlexAndWingDefined()=0
PixelGeometryManager::PixelRMin
virtual double PixelRMin()=0
GeoPixelIFlexServices.h
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
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
InDetDD::ExtraMaterial
Definition: ExtraMaterial.h:23
GeoPixelIFlexServices::getSupportTrfC
GeoTransform * getSupportTrfC()
Definition: GeoPixelIFlexServices.h:32
PixelGeometryManager::PixelEnvelopeRMin
virtual double PixelEnvelopeRMin(int i)=0
GeoPixelIBLFwdServices::isComplexShapeDefined
bool isComplexShapeDefined()
Definition: GeoPixelIBLFwdServices.cxx:42
GeoPixelIBLFwdServices::getSupportTrfA
GeoTransform * getSupportTrfA()
Definition: GeoPixelIBLFwdServices.h:32
DBM_Det::Build
virtual GeoVPhysVol * Build() override
Definition: DBM_Det.cxx:41
GeoPixelServices::getBuilder
InDetDD::VolumeBuilder * getBuilder()
Definition: GeoPixelServices.h:31
PixelGeometryManager::partPresent
virtual bool partPresent(const std::string &partName) const =0
InDetDD::TubeZone
Definition: VolumeSplitterUtils.h:99
InDetDD::SiNumerology::addBarrel
void addBarrel(int id)
Definition: SiNumerology.cxx:97