ATLAS Offline Software
GeoPixelModule.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 "GeoPixelModule.h"
6 #include "GeoPixelHybrid.h"
7 #include "GeoPixelChip.h"
8 #include "GeoPixelSiCrystal.h"
9 #include "GeoModelKernel/GeoBox.h"
10 #include "GeoModelKernel/GeoPhysVol.h"
11 #include "GeoModelKernel/GeoLogVol.h"
12 #include "GeoModelKernel/GeoNameTag.h"
13 #include "GeoModelKernel/GeoIdentifierTag.h"
14 #include "GeoModelKernel/GeoFullPhysVol.h"
15 #include "GeoModelKernel/GeoMaterial.h"
16 #include "GeoModelKernel/GeoTransform.h"
17 #include "GeoModelKernel/GeoShapeShift.h"
18 #include "GeoModelKernel/GeoShapeUnion.h"
19 #include "GaudiKernel/SystemOfUnits.h"
20 
21 using std::max;
22 
25  GeoModelIO::ReadGeoModel* sqliteReader,
26  std::shared_ptr<std::map<std::string, GeoFullPhysVol*>> mapFPV,
27  std::shared_ptr<std::map<std::string, GeoAlignableTransform*>> mapAX,
28  GeoPixelSiCrystal& theSensor)
29  : GeoVPixelFactory (m_DDmgr, mgr, sqliteReader, mapFPV, mapAX)
30  , m_theSensor(theSensor)
31 {
32  //
33  // Define the log volume in the constructor, so I do it only once.
34  //
35  // The module orientation is
36  // x normal to the detector
37  // y in the phi direction
38  // z in the eta (z) direction
39 
42 
43  if(!m_sqliteReader) {
44  int svcType = (m_isModule3D) ? 1 : 0;
45 
46  //
47  // The Dimensions are in separate routines
48  //
49  double length = this->Length();
50  double thickness = this->Thickness();
51  double width = this->Width();
52  const GeoMaterial* air = m_mat_mgr->getMaterial("std::Air");
53 
54  // const GeoShape * moduleShape = 0;
55  std::string logName = m_gmt_mgr->isBarrel() ? "ModuleBrl" : "ModuleEC";
56 
57  if (ThicknessP() == ThicknessN()) {
58  const GeoBox* moduleBox = new GeoBox(thickness/2.,width/2.,length/2.);
59  const GeoShape * moduleShape = moduleBox;
60  m_theModule = new GeoLogVol(logName,moduleShape,air);
61  }
62  else {
63 
64  // Shift so the center of the box is the center of the sensor.
65  double shift = 0.5 * (ThicknessP() - ThicknessN_noSvc());
66  // const GeoShape & shiftedBox = (*moduleBox) << GeoTrf::TranslateX3D(shift);
67  // moduleShape = &shiftedBox;
68 
69  thickness = ThicknessP()+ThicknessN_noSvc();
70  const GeoBox* moduleBox = new GeoBox(thickness/2.,width/2.,length/2.);
71  const GeoShape & shiftedBox = (*moduleBox) << GeoTrf::TranslateX3D(shift);
72  const GeoShape * moduleShape = &shiftedBox;
73 
74  if(m_moduleSvcThickness<0.001) {
75  m_theModule = new GeoLogVol(logName,moduleShape,air);
76  }
77  else {
78  const GeoShape * gblShape = nullptr;
79  gblShape = addShape(gblShape, moduleShape, GeoTrf::Transform3D::Identity() );
80 
81  double svcWidth = width*.6;
82  m_moduleSvcWidth = svcWidth;
83  const GeoBox* moduleSvcBox1 = new GeoBox(m_moduleSvcThickness*.5,svcWidth*.25,length*.5);
84  double yShift = width*.5-svcWidth*.75;
85  double xShift = thickness*.5+m_moduleSvcThickness*.5;
86  gblShape = addShape(gblShape, moduleSvcBox1, (GeoTrf::TranslateX3D(-xShift)*GeoTrf::TranslateY3D(-yShift)) );
87 
88  const GeoBox* moduleSvcBox2 = new GeoBox(m_moduleSvcThickness*.25,svcWidth*.25,length*.5);
89  yShift = width*.5-svcWidth*.25;
90  xShift = thickness*.5+m_moduleSvcThickness*.25;
91  gblShape = addShape(gblShape, moduleSvcBox2, (GeoTrf::TranslateX3D(-xShift)*GeoTrf::TranslateY3D(-yShift)) );
92 
93  for(int iSvc=0; iSvc<m_nbModuleSvc; iSvc++)
94  {
96  std::string name = m_gmt_mgr->PixelModuleServiceName(iSvc);
97  double offsetX = m_gmt_mgr->PixelModuleServiceOffsetX(iSvc);
98 
99  if(type==svcType&&(name=="WingFlex"||offsetX<0)) {
100  double width_svc = m_gmt_mgr->PixelModuleServiceWidth(iSvc);
101  double thick_svc = m_gmt_mgr->PixelModuleServiceThick(iSvc);
102  double offsetY = m_gmt_mgr->PixelModuleServiceOffsetY(iSvc);
103  double xPos = -0.5*(m_gmt_mgr->PixelBoardThickness(m_isModule3D)-m_gmt_mgr->PixelHybridThickness(m_isModule3D)) - offsetX - thick_svc*.5;
104  const GeoBox* moduleSvcBox3 = new GeoBox(thick_svc*.5+.01,width_svc*.5+.01,length*.5+.01);
105  gblShape = addShape(gblShape, moduleSvcBox3, (GeoTrf::TranslateX3D(xPos)*GeoTrf::TranslateY3D(offsetY)) );
106  }
107  }
108 
109  m_theModule = new GeoLogVol(logName,gblShape,air);
110  }
111  }
112  }
113 
114 }
115 
116 
117 GeoVPhysVol* GeoPixelModule::Build( ) {
118 
119  if(m_sqliteReader) {
120  m_theSensor.Build();
121  m_id = m_theSensor.getID();
122  return nullptr;
123  }
124 
125  GeoFullPhysVol* modulePhys = new GeoFullPhysVol(m_theModule);
126  //
127  // Place the Si Crystal
128  //
129  GeoVPhysVol *theSi = m_theSensor.Build();
130  m_id = m_theSensor.getID();
131  std::string sensorName = m_gmt_mgr->isBarrel() ? "SensorBrl" : "SensorEC";
132  GeoNameTag *tag = new GeoNameTag(sensorName);
133  modulePhys->add(tag);
134  // We give the barrel sensors an id of 100 and endcap sensors an id of 200 so that they can
135  // can be distinguished in the G4 sensitive detector.
136  int idTag = 100; // barrel
137  if (m_gmt_mgr->isEndcap()) {
138  idTag = 200; // endcap
139  }
140  modulePhys->add(new GeoIdentifierTag(idTag) );
141  //Sensor is centered so we don't need the transform.
142  //GeoTransform *xformsi = new GeoTransform(GeoTrf::Transform3D());
143  //modulePhys->add(xformsi);
144  modulePhys->add(theSi );
145  //
146  // Place the Hybrid
147  //
151  GeoTransform* xform = new GeoTransform(GeoTrf::TranslateX3D(hybxpos));
152  modulePhys->add(xform);
153  modulePhys->add(ph.Build() );
154  }
155 
156  //
157  // Place the Chip
158  //
161  double chipypos =m_gmt_mgr->PixelChipOffset(m_isModule3D);
162  GeoTransform* xform = new GeoTransform(GeoTrf::TranslateX3D(chipxpos)*GeoTrf::TranslateY3D(chipypos));
163  modulePhys->add(xform);
164  modulePhys->add(pc.Build() );
165 
166  //
167  // Add the module services
168  //
169  if(m_nbModuleSvc==0) return modulePhys;
170 
171  int svcType = (m_isModule3D) ? 1 : 0;
172  for(int iSvc=0; iSvc<m_nbModuleSvc; iSvc++)
173  {
175 
176  if(type==svcType){
177  double length = m_gmt_mgr->PixelModuleServiceLength(iSvc);
178  double width = m_gmt_mgr->PixelModuleServiceWidth(iSvc);
179  double thick = m_gmt_mgr->PixelModuleServiceThick(iSvc);
180  double offsetX = m_gmt_mgr->PixelModuleServiceOffsetX(iSvc);
181  double offsetY = m_gmt_mgr->PixelModuleServiceOffsetY(iSvc);
182  double offsetZ = m_gmt_mgr->PixelModuleServiceOffsetZ(iSvc);
183  std::string name = m_gmt_mgr->PixelModuleServiceName(iSvc);
184  std::string material = m_gmt_mgr->PixelModuleServiceMaterial(iSvc);
185 
186  const GeoBox* svcBox = new GeoBox(thick*.5-0.01,width*.5,length*.5);
187  const GeoMaterial* svcMat = m_mat_mgr->getMaterialForVolume(material,svcBox->volume());
188  GeoLogVol* svcLogVol = new GeoLogVol(name, svcBox, svcMat);
189  GeoPhysVol* svcPhys = new GeoPhysVol(svcLogVol);
190 
191  double xPos = -0.5*(m_gmt_mgr->PixelBoardThickness(m_isModule3D)-m_gmt_mgr->PixelHybridThickness(m_isModule3D)) - offsetX - thick*.5;
192  double yPos = offsetY;
193  double zPos = offsetZ;
194  GeoTransform* xform = new GeoTransform(GeoTrf::Translate3D(xPos,yPos,zPos));
195  modulePhys->add(xform);
196  modulePhys->add(svcPhys);
197  }
198  }
199 
200 
201  return modulePhys;
202 }
203 
205  //
206  // The module envelope is no longer forced to symmetric about its
207  // center to allow for room between the module and TMT. ThicknessN
208  // is the max of ThicknessP and thickness from the module center to
209  // the outer surface of the hybrid plus some safety.
210  //
211  double safety = 0.01*Gaudi::Units::mm;
213  double thick = max(thickn, ThicknessP());
214 
215  if(m_nbModuleSvc==0) return thick;
216 
217  double thickSvc=0;
218  int svcType = (m_isModule3D) ? 1 : 0;
219  for(int iSvc=0; iSvc<m_nbModuleSvc; iSvc++)
220  {
222  int fullSize = m_gmt_mgr->PixelModuleServiceFullSize(iSvc);
223  if(type==svcType&&fullSize==1){
224  double locThick = m_gmt_mgr->PixelModuleServiceThick(iSvc);
225  double offsetX = m_gmt_mgr->PixelModuleServiceOffsetX(iSvc);
226  double tmp = offsetX+locThick;
227  thickSvc = std::max(thickSvc,tmp);
228  }
229  }
230 
231  return thick+thickSvc;
232 
233 }
234 
235 
237  //
238  // The module envelope is no longer forced to symmetric about its
239  // center to allow for room between the module and TMT. ThicknessN
240  // is the max of ThicknessP and thickness from the module center to
241  // the outer surface of the hybrid plus some safety.
242  //
243 
244 
245  double safety = 0.01*Gaudi::Units::mm;
247  double thick = max(thickn, ThicknessP());
248 
249  if(m_nbModuleSvc==0) return thick;
250 
251  double thickSvc=0;
252  int svcType = (m_isModule3D) ? 1 : 0;
253  for(int iSvc=0; iSvc<m_nbModuleSvc; iSvc++)
254  {
256  if(type==svcType){
257  double locThick = m_gmt_mgr->PixelModuleServiceThick(iSvc);
258  double offsetX = m_gmt_mgr->PixelModuleServiceOffsetX(iSvc);
259  double tmp = offsetX+locThick;
260  thickSvc = std::max(thickSvc,tmp);
261  }
262  }
263  m_moduleSvcThickness = thickSvc;
264 
265  return thick+thickSvc;
266 }
267 
268 
270  //
271  // The module envelope is no longer forced to symmetric about its
272  // center to allow for room between the module and TMT. ThicknessP
273  // is thickness from the module center to the outer surface of the
274  // chips plus some safety.
275 
276  double safety = 0.01*Gaudi::Units::mm;
277  double thick = 0.5 * m_gmt_mgr->PixelBoardThickness(m_isModule3D) +
279 
280  return thick;
281 }
282 
284  // This is total thickness of the module envelope
285  return ThicknessP()+ThicknessN();
286 }
287 
289 
290  double chipypos =fabs(m_gmt_mgr->PixelChipOffset(m_isModule3D));
291  double width = max( max(
294  m_gmt_mgr->PixelChipWidth(m_isModule3D)+2.*chipypos);
295  return width;
296 }
298  // balcony is zero
299 
300  // std::cout<<m_isModule3D<<" "<<m_gmt_mgr->PixelHybridLength(m_isModule3D)<<" "<<m_gmt_mgr->PixelBoardLength(m_isModule3D)<<" "<<m_gmt_mgr->PixelChipLength(m_isModule3D)<<std::endl;
301 
302  double length = max( max( //max(
305  //2*m_gmt_mgr->PixelBalcony()),
307 
308  return length;
309 }
310 
312  return m_id;
313 }
314 
315 
316 const GeoShape * GeoPixelModule::addShape(const GeoShape * lastShape, const GeoShape * nextShape, const GeoTrf::Transform3D & trans)
317 {
318  const GeoShape * shiftedShape = &(*nextShape << trans);
319  if (lastShape) {
320  lastShape = &(lastShape->add(*shiftedShape));
321  } else {
322  lastShape = shiftedShape;
323  }
324  return lastShape;
325 }
GeoPixelModule::m_nbModuleSvc
int m_nbModuleSvc
Definition: GeoPixelModule.h:48
GeoPixelModule::m_theModule
GeoIntrusivePtr< const GeoLogVol > m_theModule
Definition: GeoPixelModule.h:41
GeoPixelModule::Build
virtual GeoVPhysVol * Build() override
Definition: GeoPixelModule.cxx:117
PixelGeometryManager::PixelChipThickness
virtual double PixelChipThickness(bool isModule3D=false)=0
GeoPixelModule::addShape
const GeoShape * addShape(const GeoShape *lastShape, const GeoShape *nextShape, const GeoTrf::Transform3D &trans)
Definition: GeoPixelModule.cxx:316
PixelGeometryManager::PixelChipWidth
virtual double PixelChipWidth(bool isModule3D=false)=0
max
#define max(a, b)
Definition: cfImp.cxx:41
GeoPixelModule::ThicknessN
double ThicknessN()
Definition: GeoPixelModule.cxx:236
PixelGeometryManager
Definition: PixelGeometryManager.h:28
PixelGeometryManager::PixelModuleServiceModuleType
virtual int PixelModuleServiceModuleType(int svc)=0
GeoPixelModule::m_moduleSvcWidth
double m_moduleSvcWidth
Definition: GeoPixelModule.h:47
GeoPixelHybrid.h
PixelGeometryManager::PixelModuleServiceName
virtual std::string PixelModuleServiceName(int svc)=0
PixelGeometryManager::PixelModuleServiceLength
virtual double PixelModuleServiceLength(int svc)=0
PixelGeometryManager::PixelModuleServiceOffsetZ
virtual double PixelModuleServiceOffsetZ(int svc)=0
GeoPixelSiCrystal.h
GeoPixelModule::Width
double Width()
Definition: GeoPixelModule.cxx:288
PixelGeometryManager::PixelModuleServiceFullSize
virtual int PixelModuleServiceFullSize(int svc)=0
GeoPixelSiCrystal::Build
virtual GeoVPhysVol * Build() override
Definition: GeoPixelSiCrystal.cxx:138
PixelGeometryManager::PixelHybridWidth
virtual double PixelHybridWidth(bool isModule3D=false)=0
PixelGeometryManager::PixelChipGap
virtual double PixelChipGap(bool isModule3D=false)=0
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
PixelGeometryManager::PixelHybridThickness
virtual double PixelHybridThickness(bool isModule3D=false)=0
GeoPixelModule::ThicknessN_noSvc
double ThicknessN_noSvc()
Definition: GeoPixelModule.cxx:204
GeoVPixelFactory::m_DDmgr
InDetDD::PixelDetectorManager * m_DDmgr
Definition: GeoVPixelFactory.h:45
GeoVPixelFactory::m_gmt_mgr
PixelGeometryManager * m_gmt_mgr
Definition: GeoVPixelFactory.h:43
GeoVPixelFactory::m_mapFPV
std::shared_ptr< std::map< std::string, GeoFullPhysVol * > > m_mapFPV
Definition: GeoVPixelFactory.h:47
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
GeoPixelSiCrystal
Definition: GeoPixelSiCrystal.h:20
GeoPixelModule::ThicknessP
double ThicknessP()
Definition: GeoPixelModule.cxx:269
GeoPixelChip
Definition: GeoPixelChip.h:11
PixelGeometryManager::isBarrel
virtual bool isBarrel()=0
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
PixelGeometryManager::PixelBoardThickness
virtual double PixelBoardThickness(bool isModule3D=false)=0
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
PixelGeometryManager::PixelChipOffset
virtual double PixelChipOffset(bool isModule3D=false)=0
PixelGeometryManager::PixelModuleServiceNumber
virtual int PixelModuleServiceNumber()=0
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
GeoPixelHybrid
Definition: GeoPixelHybrid.h:11
GeoPixelModule::Length
double Length()
Definition: GeoPixelModule.cxx:297
GeoPixelModule::m_theSensor
GeoPixelSiCrystal & m_theSensor
Definition: GeoPixelModule.h:43
PixelGeometryManager::isEndcap
virtual bool isEndcap()=0
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
PixelGeometryManager::PixelChipLength
virtual double PixelChipLength(bool isModule3D=false)=0
GeoPixelModule::m_id
Identifier m_id
Definition: GeoPixelModule.h:42
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
PixelGeometryManager::PixelModuleServiceOffsetX
virtual double PixelModuleServiceOffsetX(int svc)=0
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
PixelGeometryManager::PixelModuleServiceOffsetY
virtual double PixelModuleServiceOffsetY(int svc)=0
GeoPixelModule::m_moduleSvcThickness
double m_moduleSvcThickness
Definition: GeoPixelModule.h:46
GeoPixelModule::getID
Identifier getID()
Definition: GeoPixelModule.cxx:311
GeoVPixelFactory::m_mat_mgr
InDetMaterialManager * m_mat_mgr
Definition: GeoVPixelFactory.h:44
GeoPixelModule::m_isModule3D
bool m_isModule3D
Definition: GeoPixelModule.h:44
PixelGeometryManager::PixelHybridLength
virtual double PixelHybridLength(bool isModule3D=false)=0
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
GeoPixelModule.h
GeoPixelSiCrystal::GetModule3DFlag
bool GetModule3DFlag()
Definition: GeoPixelSiCrystal.h:31
PixelGeometryManager::PixelBoardLength
virtual double PixelBoardLength(bool isModule3D=false)=0
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
PixelGeometryManager::PixelModuleServiceWidth
virtual double PixelModuleServiceWidth(int svc)=0
GeoVPixelFactory
This is the base class for all the pieces of the Pixel detector.
Definition: GeoVPixelFactory.h:31
PixelGeometryManager::PixelModuleServiceMaterial
virtual std::string PixelModuleServiceMaterial(int svc)=0
PixelGeometryManager::PixelBoardWidth
virtual double PixelBoardWidth(bool isModule3D=false)=0
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
PixelGeometryManager::PixelModuleServiceThick
virtual double PixelModuleServiceThick(int svc)=0
GeoPixelHybrid::Build
virtual GeoVPhysVol * Build() override
Definition: GeoPixelHybrid.cxx:20
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
GeoPixelSiCrystal::getID
Identifier getID()
Definition: GeoPixelSiCrystal.h:29
GeoPixelModule::Thickness
double Thickness()
Definition: GeoPixelModule.cxx:283
GeoPixelModule::GeoPixelModule
GeoPixelModule(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, GeoPixelSiCrystal &theSensor)
Definition: GeoPixelModule.cxx:23
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
python.SystemOfUnits.pc
float pc
Definition: SystemOfUnits.py:99
GeoPixelChip.h