ATLAS Offline Software
SCT_FwdSensor.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
11 
13 
14 #include "GeoModelRead/ReadGeoModel.h"
15 #include "GeoModelKernel/GeoTrd.h"
16 #include "GeoModelKernel/GeoShape.h"
17 #include "GeoModelKernel/GeoLogVol.h"
18 #include "GeoModelKernel/GeoShapeShift.h"
19 #include "GeoModelKernel/GeoShapeUnion.h"
20 #include "GeoModelKernel/GeoPhysVol.h"
21 #include "GeoModelKernel/GeoFullPhysVol.h"
22 #include "GeoModelKernel/GeoNameTag.h"
23 #include "GeoModelKernel/GeoTransform.h"
24 #include "GeoModelKernel/GeoAlignableTransform.h"
25 #include "GeoModelKernel/GeoMaterial.h"
26 #include "GaudiKernel/SystemOfUnits.h"
27 
28 #include "GeoModelKernel/GeoDefinitions.h"
29 
35 
36 #include <cmath>
37 
38 using namespace InDetDD;
39 
40 
41 SCT_FwdSensor::SCT_FwdSensor(const std::string & name,
42  int ringType,
43  InDetDD::SCT_DetectorManager* detectorManager,
44  SCT_GeometryManager* geometryManager,
45  SCT_MaterialManager* materials,
46  GeoModelIO::ReadGeoModel* sqliteReader,
47  std::shared_ptr<std::map<std::string, GeoFullPhysVol*>> mapFPV,
48  std::shared_ptr<std::map<std::string, GeoAlignableTransform*>> mapAX)
49  : SCT_UniqueComponentFactory(name, detectorManager, geometryManager, materials, sqliteReader, mapFPV, mapAX),
50  m_ringType{ringType},
51  m_noElementWarning{true}
52 {
53  getParameters();
54  m_logVolume = SCT_FwdSensor::preBuild();
55 
56 }
57 
59 
60 void
62 {
64 
65  if(!m_sqliteReader){
67 
68  m_materialGlass = nullptr;
69  if (m_ringType == 2) { // Only need to define glass if its a Truncated middle module.
70  m_materialGlass = m_materials->getMaterial(parameters->fwdSensorMaterialNear(m_ringType));
71  }
72  }
73 
74  m_thicknessN = m_thicknessF = parameters->fwdSensorThickness(m_ringType);
75 
76  m_innerWidthF = parameters->fwdSensorInnerWidthFar(m_ringType);
77  m_outerWidthF = parameters->fwdSensorOuterWidthFar(m_ringType);
78  m_lengthF = parameters->fwdSensorLengthFar(m_ringType);
79  m_radiusF = parameters->fwdSensorRadiusFar(m_ringType);
80 
81  m_innerWidthN = parameters->fwdSensorInnerWidthNear(m_ringType);
82  m_outerWidthN = parameters->fwdSensorOuterWidthNear(m_ringType);
83  m_lengthN = parameters->fwdSensorLengthNear(m_ringType);
84  m_radiusN = parameters->fwdSensorRadiusNear(m_ringType);
85 
86  if (m_ringType == 3) {
87  // For Inner Module only use number for far sensor.
90  } else {
93  }
96 
97  m_activeHalfLengthFar = parameters->fwdSensorActiveHalfLengthFar(m_ringType);
98  m_activeHalfLengthNear = parameters->fwdSensorActiveHalfLengthNear(m_ringType);
99 
100  if (m_ringType == 3) { // Inner
102  } else {
105  }
106 
107  // For truncated middle the sensor is offset from what it would be if it was a full middle.
108  m_sensorOffset = 0;
109  if (m_ringType == 2) { // truncated middle
111  }
112 
113  // The thickness of the two are the same, but to be pedantic.
115 }
116 
117 const GeoLogVol * SCT_FwdSensor::preBuild()
118 {
119  const GeoLogVol * sensorLog=nullptr;
120  if(!m_sqliteReader){
121 
122  const GeoTrd * sensorShapeF = new GeoTrd(0.5 * m_thicknessF, 0.5 * m_thicknessF,
123  0.5 * m_innerWidthF, 0.5 * m_outerWidthF,
124  0.5 * m_lengthF);
125 
126 
127  const GeoTrd * sensorShapeN= nullptr;
128  if (m_ringType != 3) {
129  sensorShapeN= new GeoTrd(0.5 * m_thicknessN, 0.5 * m_thicknessN,
130  0.5 * m_innerWidthN, 0.5 * m_outerWidthN,
131  0.5 * m_lengthN);
132  }
133 
134 
135  const GeoShape * sensorShape = nullptr;
136  if ((m_ringType == 2) || (m_ringType == 3)) {
137  // For truncated middle and inner there is only one wafer.
138  sensorShape = sensorShapeF;
139  } else {
140  // For outer and middle there are two wafers. We
141  // define the sensor as a boolean volume of the two wafers.
142  // relative position of near sensor
143  double positionNearZ = m_radiusN - m_sensorRadius;
144  const GeoShape & sensorPosN = (*sensorShapeN<< GeoTrf::TranslateZ3D(positionNearZ)) ;
145  // relative position of near sensor
146  double positionFarZ = m_radiusF - m_sensorRadius;
147  const GeoShape & sensorPosF = (*sensorShapeF<< GeoTrf::TranslateZ3D(positionFarZ) );
148  sensorShape = &(sensorPosF.add(sensorPosN));
149  }
150 
151  sensorLog = new GeoLogVol(getName(), sensorShape, m_materialSensor);
152 
153 
154  if (m_ringType == 2) {
155  // Make inactive glass sensor.
156  double positionZ = m_radiusN - m_sensorRadius;
157  const GeoShape & sensorPosN = (*sensorShapeN<< GeoTrf::TranslateZ3D(positionZ) );
158  GeoLogVol * inactiveLog = new GeoLogVol(getName()+"Glass", &sensorPosN, m_materialGlass);
159  m_inactive = new GeoPhysVol(inactiveLog);
160  }
161  }
162 
163  // Make the moduleside design for this sensor
164  makeDesign();
165 
166  return sensorLog;
167 }
168 
170 {
171 
172  // The designs require a name when put in the collection
173  // but usually the design is accessed through SiDetectorElement
174  // and so is not generally acessesed through the DesignCollection.
175 
176  // Design names are no longer used/needed, but might be used in the future for
177  // information purposes.
178  /*
179  std::string designName;
180  switch (m_ringType) {
181  case 0: // Outer
182  designName = "SCT:ForwardRing1G3";
183  break;
184  case 1: // Middle
185  designName = "SCT:ForwardRing2G3";
186  break;
187  case 2: // Truncated Middle
188  designName = "SCT:ForwardRing3G3";
189  break;
190  case 3: // Inner
191  designName = "SCT:ForwardRing4G3";
192  break;
193  default:
194  break;
195  }
196  */
197 
198  // These can no longer be user defined and are ignored.
199  //SiDetectorDesign::Axis etaAxis = SiDetectorDesign::zAxis;
200  //SiDetectorDesign::Axis phiAxis = SiDetectorDesign::yAxis;
201  //SiDetectorDesign::Axis depthAxis = SiDetectorDesign::xAxis;
202 
203 
204  // SCT_ForwardModuleSideDesign Constructor with parameters:
205  // local axis corresponding to eta direction
206  // local axis corresponding to phi direction
207  // local axis corresponding to depth direction
208  // thickness of silicon sensor
209  // number of crystals within module side
210  // number of diodes within crystal
211  // number of cells within module side
212  // index of diode connected to cell with index 0
213  // radius from inner crystal center to beam
214  // inner crystal half height
215  // radius from outer crystal (if present) center to beam
216  // outer crystal (if present) half height
217  // strip step in angle (same for both crystals)
218  // eta coordinate of crystal center
219  // phi coordinate of crystal center
220 
222 
223  double radius1=0;
224  double radius2=0;
225  double halfHeight1=0;
226  double halfHeight2=0;
227  int crystals=0;
228 
229  switch (m_ringType) {
230  case 0: // Outer Module
231  case 1: // Full Middle module
232  crystals = 2;
233  radius1 = m_radiusN;
234  radius2 = m_radiusF;
235  halfHeight1 = m_activeHalfLengthNear;
236  halfHeight2 = m_activeHalfLengthFar;
237  break;
238  case 2: // Truncated Middle Module
239  case 3: // Inner Module
240  crystals = 1;
241  radius1 = m_radiusF;
242  radius2 = 0.;
243  halfHeight1 = m_activeHalfLengthFar;
244  halfHeight2 = 0.;
245  break;
246  default:
247  std::cout << "ERROR!!!! SCT_FwdSensor: Invalid ring type" << std::endl;
248  }
249 
250  double etaCenter = 0;
251  double phiCenter = 0;
252 
253  //int cells = parameters->fwdSensorNumReadoutStrips();
254  //int diodes = parameters->fwdSensorNumStrips();
255  //int shift = parameters->fwdSensorStripShift();
256  // For consistency with older version we keep shift = 0.
257  int cells = parameters->fwdSensorNumReadoutStrips(m_ringType);
258  int diodes = cells;
259  int shift = 0;
260 
261  double step = parameters->fwdSensorAngularPitch(m_ringType);
262 
263  // Readout direction is same direction as local phi direction for outer module
264  // and the opposite direction for inner and middle module.
265  bool swapStripReadout = (m_ringType != 0); // ie false for outer module only.
266 
267  // The readout side is at the +ve depth direction
268  int readoutSide = +1;
269 
270  // m_design will be owned and deleted by SCT_DetectorManager
271  std::unique_ptr<SCT_ForwardModuleSideDesign> design = std::make_unique<SCT_ForwardModuleSideDesign>(m_thicknessN,
272  crystals,
273  diodes,
274  cells,
275  shift,
276  swapStripReadout,
278  radius1,
279  halfHeight1,
280  radius2,
281  halfHeight2,
282  step,
283  etaCenter,
284  phiCenter,
285  readoutSide);
286  m_design = m_detectorManager->addDesign(std::move(design));
287 
288  //
289  // Flags to signal if axis can be swapped.
290  // For trapezoid z axis (xEta) cannot be swapped.
291  // This is the default and no action is required.
292  // Can force axes not to be swapped by setting to false.
293  //
294  // bool phiSyGaudi::Units::mmetric = true;
295  // bool etaSyGaudi::Units::mmetric = false;
296  // bool depthSyGaudi::Units::mmetric = true;
297  // m_design->setSyGaudi::Units::mmetry(phiSyGaudi::Units::mmetric, etaSyGaudi::Units::mmetric, depthSyGaudi::Units::mmetric,
298  //
299 
300 }
301 
303 {
304 
305  GeoFullPhysVol * sensor=nullptr;
306  if (m_sqliteReader)
307  {
308 
309  std::string key="FwdSensor_Side#"+std::to_string(id.getSide())+"_"+std::to_string(id.getBarrelEC())+"_"+std::to_string(id.getLayerDisk())+"_"+std::to_string(id.getEtaModule())+"_"+std::to_string(id.getPhiModule());
310 
311  sensor = (*m_mapFPV)[key];
312  } else
313  sensor= new GeoFullPhysVol(m_logVolume);
314 
315  // Make detector element and add to collection
316  // Only do so if we have a valid id helper.
317  //id.print(); // for debugging only
318 
319  const SiCommonItems* commonItems = m_geometryManager->commonItems();
320 
321  if (commonItems->getIdHelper()) {
322 
323  // detElement will be owned by SCT_DetectorManager
324  // and will be deleted in destructor of SiDetectorElementCollection in SCT_DetectorManager
325  SiDetectorElement * detElement = new SiDetectorElement(id.getWaferId(),
326  m_design,
327  sensor,
328  commonItems);
329 
330  // Add the detector element.
332 
333  } else {
334  if (m_noElementWarning) {
335  std::cout << "WARNING!!!!: No SCT id helper and so no elements being produced." << std::endl;
336  m_noElementWarning = false;
337  }
338  }
339 
340  return sensor;
341 }
342 
343 
SCT_FwdSensor::ringType
int ringType() const
Definition: SCT_FwdSensor.h:43
SCT_FwdSensor::build
virtual GeoVPhysVol * build(SCT_Identifier id)
Definition: SCT_FwdSensor.cxx:302
SCT_FwdSensor::m_lengthF
double m_lengthF
Definition: SCT_FwdSensor.h:107
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
SCT_ComponentFactory::m_geometryManager
SCT_GeometryManager * m_geometryManager
Definition: SCT_ComponentFactory.h:42
SCT_FwdSensor::m_ringType
int m_ringType
Definition: SCT_FwdSensor.h:89
SCT_MaterialManager
Definition: SCT_MaterialManager.h:21
SCT_GeometryManager::forwardModuleParameters
const SCT_ForwardModuleParameters * forwardModuleParameters() const
Definition: SCT_GeometryManager.cxx:91
SCT_Identifier
Definition: SCT_Identifier.h:12
InDetDD::SCT_DetectorManager
Definition: SCT_DetectorManager.h:49
SCT_FwdSensor::m_lengthN
double m_lengthN
Definition: SCT_FwdSensor.h:100
max
#define max(a, b)
Definition: cfImp.cxx:41
SCT_Identifier.h
SCT_FwdSensor::m_radiusN
double m_radiusN
Definition: SCT_FwdSensor.h:102
InDetDD::SiCommonItems::getIdHelper
const AtlasDetectorID * getIdHelper() const
Definition: SiCommonItems.h:83
SCT_FwdSensor::SCT_FwdSensor
SCT_FwdSensor(const std::string &name, int ringType, InDetDD::SCT_DetectorManager *detectorManager, SCT_GeometryManager *geometryManager, SCT_MaterialManager *materials, GeoModelIO::ReadGeoModel *sqliteReader, std::shared_ptr< std::map< std::string, GeoFullPhysVol * >> mapFPV, std::shared_ptr< std::map< std::string, GeoAlignableTransform * >> mapAX)
Definition: SCT_FwdSensor.cxx:41
InDetDD::holes
@ holes
Definition: InDetDD_Defs.h:17
SCT_MaterialManager.h
SCT_FwdSensor::m_activeHalfLengthNear
double m_activeHalfLengthNear
Definition: SCT_FwdSensor.h:103
SCT_GeometryManager::commonItems
const InDetDD::SiCommonItems * commonItems() const
Definition: SCT_GeometryManager.cxx:66
SCT_FwdSensor::m_inactive
GeoIntrusivePtr< GeoPhysVol > m_inactive
Definition: SCT_FwdSensor.h:120
SCT_FwdSensor::m_outerWidthN
double m_outerWidthN
Definition: SCT_FwdSensor.h:98
InDetDD::SiDetectorManager::addDesign
const SiDetectorDesign * addDesign(std::unique_ptr< const SiDetectorDesign > &&)
Access to module design; returns an observer pointer.
Definition: SiDetectorManager.cxx:134
SCT_ForwardModuleSideDesign.h
SCT_FwdSensor::m_thicknessF
double m_thicknessF
Definition: SCT_FwdSensor.h:108
SCT_ComponentFactory::m_detectorManager
InDetDD::SCT_DetectorManager * m_detectorManager
Definition: SCT_ComponentFactory.h:41
SCT_FwdSensor::m_outerWidthF
double m_outerWidthF
Definition: SCT_FwdSensor.h:105
SCT_FwdSensor::m_materialSensor
const GeoMaterial * m_materialSensor
Definition: SCT_FwdSensor.h:117
SCT_FwdSensor.h
InDetDD_Defs.h
SCT_ForwardModuleParameters
Definition: SCT_ForwardModuleParameters.h:12
SiCommonItems.h
SCT_FwdSensor::m_thickness
double m_thickness
Definition: SCT_FwdSensor.h:91
SCT_FwdSensor::preBuild
virtual const GeoLogVol * preBuild()
Definition: SCT_FwdSensor.cxx:117
SCT_FwdSensor::m_sensorRadius
double m_sensorRadius
Definition: SCT_FwdSensor.h:112
SCT_FwdSensor::m_radiusF
double m_radiusF
Definition: SCT_FwdSensor.h:109
SCT_ForwardModuleParameters.h
SCT_FwdSensor::m_outerWidth
double m_outerWidth
Definition: SCT_FwdSensor.h:95
SCT_FwdSensor::~SCT_FwdSensor
~SCT_FwdSensor()
SCT_ComponentFactory::m_materials
SCT_MaterialManager * m_materials
Definition: SCT_ComponentFactory.h:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
InDetDD::SiCommonItems
Definition: SiCommonItems.h:45
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SiDetectorElement.h
SCT_FwdSensor::m_innerWidth
double m_innerWidth
Definition: SCT_FwdSensor.h:94
SCT_UniqueComponentFactory::m_logVolume
const GeoLogVol * m_logVolume
Definition: SCT_ComponentFactory.h:90
SCT_FwdSensor::m_thicknessN
double m_thicknessN
Definition: SCT_FwdSensor.h:101
SCT_UniqueComponentFactory
Definition: SCT_ComponentFactory.h:76
SCT_MaterialManager::getMaterial
const GeoMaterial * getMaterial(const std::string &materialName)
Definition: SCT_MaterialManager.cxx:51
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
PowhegPy8EG_H2a.getParameters
def getParameters()
Definition: PowhegPy8EG_H2a.py:39
SCT_FwdSensor::m_innerWidthN
double m_innerWidthN
Definition: SCT_FwdSensor.h:99
InDetDD::SCT_DetectorManager::addDetectorElement
virtual void addDetectorElement(SiDetectorElement *element) override
Add elememts during construction.
Definition: SCT_DetectorManager.cxx:104
SCT_FwdSensor::m_innerRadius
double m_innerRadius
Definition: SCT_FwdSensor.h:93
LArCellBinning.step
step
Definition: LArCellBinning.py:158
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
SCT_FwdSensor::getParameters
void getParameters()
Definition: SCT_FwdSensor.cxx:61
SCT_DetectorManager.h
SCT_UniqueComponentFactory::m_sqliteReader
GeoModelIO::ReadGeoModel * m_sqliteReader
Definition: SCT_ComponentFactory.h:91
SCT_FwdSensor::m_materialGlass
const GeoMaterial * m_materialGlass
Definition: SCT_FwdSensor.h:118
SCT_ComponentFactory::getName
const std::string & getName() const
Definition: SCT_ComponentFactory.h:35
SCT_FwdSensor::m_activeHalfLengthFar
double m_activeHalfLengthFar
Definition: SCT_FwdSensor.h:110
SCT_GeometryManager.h
SCT_FwdSensor::m_sensorOffset
double m_sensorOffset
Definition: SCT_FwdSensor.h:114
SCT_FwdSensor::makeDesign
void makeDesign()
Definition: SCT_FwdSensor.cxx:169
SCT_GeometryManager
Definition: SCT_GeometryManager.h:25
SCT_FwdSensor::m_outerRadius
double m_outerRadius
Definition: SCT_FwdSensor.h:92
SCT_FwdSensor::m_design
const InDetDD::SiDetectorDesign * m_design
Definition: SCT_FwdSensor.h:122
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
SCT_FwdSensor::m_noElementWarning
std::atomic_bool m_noElementWarning
Definition: SCT_FwdSensor.h:124
SCT_FwdSensor::m_innerWidthF
double m_innerWidthF
Definition: SCT_FwdSensor.h:106