ATLAS Offline Software
Loading...
Searching...
No Matches
GeoPixelModule.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
23using 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 (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
42 m_isModule3D=m_theSensor.GetModule3DFlag();
43 m_nbModuleSvc = m_gmt_mgr->PixelModuleServiceNumber();
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 {
97 int type = m_gmt_mgr->PixelModuleServiceModuleType(iSvc);
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
119GeoVPhysVol* 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 //
150 if (m_gmt_mgr->PixelHybridThickness(m_isModule3D)>0.00001*Gaudi::Units::mm){
152 double hybxpos = -0.5*(m_gmt_mgr->PixelBoardThickness(m_isModule3D)+m_gmt_mgr->PixelHybridThickness(m_isModule3D));
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 //
162 double chipxpos = 0.5*(m_gmt_mgr->PixelBoardThickness(m_isModule3D)+m_gmt_mgr->PixelChipThickness(m_isModule3D))+m_gmt_mgr->PixelChipGap(m_isModule3D);
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 {
176 int type = m_gmt_mgr->PixelModuleServiceModuleType(iSvc);
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;
214 double thickn = 0.5 * m_gmt_mgr->PixelBoardThickness(m_isModule3D)+ m_gmt_mgr->PixelHybridThickness(m_isModule3D) + safety;
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 {
223 int type = m_gmt_mgr->PixelModuleServiceModuleType(iSvc);
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;
248 double thickn = 0.5 * m_gmt_mgr->PixelBoardThickness(m_isModule3D)+ m_gmt_mgr->PixelHybridThickness(m_isModule3D) + safety;
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 {
257 int type = m_gmt_mgr->PixelModuleServiceModuleType(iSvc);
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) +
280 m_gmt_mgr->PixelChipThickness(m_isModule3D)+m_gmt_mgr->PixelChipGap(m_isModule3D) + safety;
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(
294 m_gmt_mgr->PixelBoardWidth(m_isModule3D),
295 m_gmt_mgr->PixelHybridWidth(m_isModule3D)),
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(
305 m_gmt_mgr->PixelHybridLength(m_isModule3D),
306 m_gmt_mgr->PixelBoardLength(m_isModule3D)),
307 //2*m_gmt_mgr->PixelBalcony()),
308 m_gmt_mgr->PixelChipLength(m_isModule3D));
309
310 return length;
311}
312
316
317
318const 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}
double length(const pvec &v)
const double width
#define max(a, b)
Definition cfImp.cxx:41
virtual GeoVPhysVol * Build() override
Identifier getID()
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)
double ThicknessN_noSvc()
Identifier m_id
double m_moduleSvcWidth
GeoPixelSiCrystal & m_theSensor
GeoIntrusivePtr< const GeoLogVol > m_theModule
const GeoShape * addShape(const GeoShape *lastShape, const GeoShape *nextShape, const GeoTrf::Transform3D &trans)
virtual GeoVPhysVol * Build() override
double m_moduleSvcThickness
std::shared_ptr< std::map< std::string, GeoFullPhysVol * > > m_mapFPV
std::shared_ptr< std::map< std::string, GeoAlignableTransform * > > m_mapAX
GeoModelIO::ReadGeoModel * m_sqliteReader
PixelGeometryManager * m_gmt_mgr
InDetDD::PixelDetectorManager * m_DDmgr
InDetMaterialManager * m_mat_mgr
GeoVPixelFactory(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)
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated pixel ...
STL namespace.