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