ATLAS Offline Software
SCT_FwdModule.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 // Simulation for the COMBINED TESTBEAM 2004 //
7 // //
8 // Zdenka.Broklova@matfyz.cz //
9 // Carlos.Escobar@ific.uv.es //
10 // Peter.Kodys@ific.uv.es //
11 // January 23, 2004 //
13 
17 
21 
26 
28 
29 #include "GeoModelRead/ReadGeoModel.h"
30 #include "GeoModelKernel/GeoTrd.h"
31 #include "GeoModelKernel/GeoShapeShift.h"
32 #include "GeoModelKernel/GeoShape.h"
33 #include "GeoModelKernel/GeoLogVol.h"
34 #include "GeoModelKernel/GeoPhysVol.h"
35 #include "GeoModelKernel/GeoFullPhysVol.h"
36 #include "GeoModelKernel/GeoNameTag.h"
37 #include "GeoModelKernel/GeoIdentifierTag.h"
38 #include "GeoModelKernel/GeoTransform.h"
39 #include "GeoModelKernel/GeoAlignableTransform.h"
40 #include "GeoModelKernel/GeoMaterial.h"
41 #include "GeoModelKernel/GeoDefinitions.h"
42 #include "GaudiKernel/SystemOfUnits.h"
43 
44 #include <cmath>
45 #include <sstream>
46 
47 inline double sqr(double x) {return x*x;}
48 
49 SCT_FwdModule::SCT_FwdModule(const std::string & name, int ringType,
50  InDetDD::SCT_DetectorManager* detectorManager,
51  SCT_GeometryManager* geometryManager,
52  SCT_MaterialManager* materials,
53  GeoModelIO::ReadGeoModel* sqliteReader,
54  std::shared_ptr<std::map<std::string, GeoFullPhysVol*>> mapFPV,
55  std::shared_ptr<std::map<std::string, GeoAlignableTransform*>> mapAX)
56  : SCT_UniqueComponentFactory(name, detectorManager, geometryManager, materials, sqliteReader, mapFPV, mapAX),
57  m_ringType(ringType)
58 {
59  getParameters();
60  if(!m_sqliteReader)
61  {
62  m_hybrid = std::make_unique<SCT_FwdHybrid>("SCT_FwdHybrid"+intToString(ringType), m_ringType, m_detectorManager, m_geometryManager, materials);
63  m_spine = std::make_unique<SCT_FwdSpine>("SCT_FwdSpine"+intToString(ringType), m_ringType, m_detectorManager, m_geometryManager, materials);
64  m_subspineL = std::make_unique<SCT_FwdSubSpine>("SCT_FwdSubSpineL"+intToString(ringType), m_ringType, SUBSPINE_LEFT,
66  m_subspineR = std::make_unique<SCT_FwdSubSpine>("SCT_FwdSubSpineR"+intToString(ringType), m_ringType, SUBSPINE_RIGHT,
68  if (m_connectorPresent) {
69  m_connector = std::make_unique<SCT_FwdModuleConnector>("SCT_FwdModuleConnector"+intToString(ringType), m_ringType,
71  }
72  }
73  m_sensor = std::make_unique<SCT_FwdSensor>("ECSensor"+intToString(ringType), m_ringType,
76 
77 }
78 
80 {
81 }
82 
83 
84 void
86 {
88  m_upperSide = parameters->fwdModuleUpperSideNumber(m_ringType);
89  if(!m_sqliteReader)
90  {
91  m_glueThickness = parameters->fwdModuleGlueThickness(m_ringType);
92  m_distBtwMountPoints = parameters->fwdModuleDistBtwMountPoints(m_ringType);
93  m_mountPointToCenter = parameters->fwdModuleMountPoint(m_ringType);
94  m_hybridIsOnInnerEdge = parameters->fwdHybridIsOnInnerEdge(m_ringType);
95  m_stereoAngle = parameters->fwdModuleStereoAngle(m_ringType);
96  m_connectorPresent = parameters->fwdModuleConnectorPresent();
97 
98  }
99 
100 }
101 
102 
103 const GeoLogVol * SCT_FwdModule::preBuild()
104 {
105  // module volume preparing
106 
107  if(m_sqliteReader) return nullptr;
108 
109  const SCT_GeneralParameters * generalParameters = m_geometryManager->generalParameters();
110  double safety = generalParameters->safety();
111  double safetyTmp = safety * Gaudi::Units::cm; // For compatibility with minor bug in older version - safety already in CLHEP units;
112 
113  // module_length = (zhyb->hyby - zhyb->hybysh + zsmi[m_ringType].mountd2 + 0.33 ) * Gaudi::Units::cm + safety;
114  // Distance from outer bybrid edge to outer spine edge.
115  // FIXME: The 1.05Gaudi::Units::mm is not needed
116  double moduleLength = m_hybrid->mountPointToOuterEdge() + m_mountPointToCenter + m_spine->moduleCenterToEnd() + 1.05 * Gaudi::Units::mm;
117  m_length = moduleLength + safety; // We add a bit of safety for the envelope
118 
119  // module_thickness = (zhyb->hybz0 * 2 + safety) * Gaudi::Units::cm;
120  double sensorEnvelopeThickness = 2 * m_sensor->thickness() + m_spine->thickness() + 2 * m_glueThickness;
121  m_thickness = std::max(sensorEnvelopeThickness, m_hybrid->thickness());
122 
123  // module_widthInner = ((zsmo->subdq + zssp[m_ringType].ssp0l + 0.325) * 2.+ 0.7 + safety)*Gaudi::Units::cm; // upto to NOVA_760
124  // module_widthOuter = ((zsmo->subdq + zssp[m_ringType].ssp2l + 0.325) * 2.+ 0.7 + safety)*Gaudi::Units::cm; // upto to NOVA_760
125 
126  //module_widthInner = ((zsmo->subdq + zssp[m_ringType].ssp0l) * 2.+ 0.7 + safety)*Gaudi::Units::cm;
127  //module_widthOuter = ((zsmo->subdq + zssp[m_ringType].ssp2l) * 2.+ 0.7 + safety)*Gaudi::Units::cm;
128 
129  m_widthInner = (m_spine->width() + 2 * m_subspineL->innerWidth() + 0.7*Gaudi::Units::cm) + safetyTmp;
130  m_widthOuter = (m_spine->width() + 2 * m_subspineL->outerWidth() + 0.7*Gaudi::Units::cm) + safetyTmp;
131 
132  if (m_ringType == 3 ) {
133  // module_widthOuter = (( zsmo->subdq + zssp[m_ringType].ssp2l + 0.325) * 2.+ 1.6 + safety)*Gaudi::Units::cm; // upto to NOVA_760
134  // module_widthOuter = (( zsmo->subdq + zssp[m_ringType].ssp2l) * 2.+ 1.6 + safety)*Gaudi::Units::cm;
135  m_widthOuter = m_spine->width() + 2 * m_subspineL->outerWidth() + 1.6*Gaudi::Units::cm + safetyTmp;
136  }
137 
138  // Calculate module shift. Distance between module physics center and center of envelope.
139  int hybridSign = m_hybridIsOnInnerEdge ? +1: -1;
140  //module_shift = (zhyb->hyby - zhyb->hybysh + zsmi[m_ringType].mountd + 0.05)*Gaudi::Units::cm;
141  //module_shift = hybrid * (module_length / 2. - module_shift);
142 
143  double moduleCenterToHybridOuterEdge = m_hybrid->mountPointToOuterEdge() + m_mountPointToCenter + 0.5*Gaudi::Units::mm;
144  //FIXME: Should be: (ie don't need the 0.5Gaudi::Units::mm)
145  // double moduleCenterToHybridOuterEdge = m_hybrid->mountPointToOuterEdge() + m_mountPointToCenter ;
146  m_moduleShift = hybridSign * (0.5 * m_length - moduleCenterToHybridOuterEdge);
147 
148  // Envelope inner/outer radius
149  m_innerRadius = m_sensor->centerRadius() + m_moduleShift - 0.5*m_length;
150  m_outerRadius = m_sensor->centerRadius() + m_moduleShift + 0.5*m_length;
151 
152  // Radial location of mount points (ignoring streo rotation)
153  m_mainMountPoint = m_sensor->centerRadius() - hybridSign * m_mountPointToCenter;
155  m_endLocator = m_sensor->centerRadius() + hybridSign * m_spine->moduleCenterToEnd();
156 
157  // Outer module the hybrid is on inner edge.
158  // For the rest its in the outer edge.
159  // TODO Check this.
160  m_powerTapeStart = m_sensor->centerRadius() - hybridSign * moduleCenterToHybridOuterEdge;
161 
162 
163  const GeoTrd * moduleEnvelopeShape = new GeoTrd(0.5 * m_thickness, 0.5 * m_thickness,
164  0.5 * m_widthInner, 0.5 * m_widthOuter,
165  0.5 * m_length);
166  const GeoShapeShift & moduleEnvelope = (*moduleEnvelopeShape << GeoTrf::TranslateZ3D(m_moduleShift) );
167 
168  GeoLogVol * moduleLog = new GeoLogVol(getName(), &moduleEnvelope, m_materials->gasMaterial());
169 
170  return moduleLog;
171 
172 }
173 
175 {
176 
177  // build method for creating module parent physical volume
178  // and puting all components into it
179  // - relative position of component is part of its shape
180  GeoFullPhysVol * module=nullptr;
181 
182  if(!m_sqliteReader){
183 
184  module= new GeoFullPhysVol(m_logVolume);
185 
186  if (m_connector != nullptr) module->add(m_connector->getVolume());
187  module->add(m_hybrid->getVolume());
188  module->add(m_spine->getVolume());
189  module->add(m_subspineL->getVolume());
190  module->add(m_subspineR->getVolume());
191 
192 
193  // name tags are not final
194 
195 
196  // Position bottom (x<0)sensor
197  double positionX;
198  double positionZ = m_sensor->sensorOffset(); // For truncated middle the sensor is offset.
199  double rotation;
200  positionX =-(0.5*m_spine->thickness() + m_glueThickness + 0.5*m_sensor->thickness());
201  rotation = 0.5 * m_stereoAngle;
202  GeoTrf::Translation3D vecB(positionX,0,0);
203  // Rotate so that X axis goes from backside to implant side
204  GeoTrf::Transform3D rotB = GeoTrf::RotateX3D(rotation)*GeoTrf::RotateZ3D(180*Gaudi::Units::degree);
205  // First translate in z (only non-zero for truncated middle)
206  // Then rotate and then translate in x.
207  GeoAlignableTransform *bottomTransform
208  = new GeoAlignableTransform(GeoTrf::Transform3D(vecB*rotB)*GeoTrf::TranslateZ3D(positionZ));
209 
210  int bottomSideNumber = (m_upperSide) ? 0 : 1;
211  id.setSide(bottomSideNumber);
212  module->add(new GeoNameTag("Sensor_Side#"+intToString(bottomSideNumber)));
213  module->add(new GeoIdentifierTag(600+bottomSideNumber));
214  module->add(bottomTransform);
215  GeoVPhysVol * bottomSensorPV = m_sensor->build(id);
216  module->add(bottomSensorPV);
217 
218  // Store transform
219  m_detectorManager->addAlignableTransform(0, id.getWaferId(), bottomTransform, bottomSensorPV);
220 
221 
222  if (m_ringType == 2) { // Place glass pieces in place of sensor
223  module->add(new GeoTransform(GeoTrf::Transform3D(vecB*rotB)));
224  module->add(m_sensor->getInactive());
225  }
226 
227  // Position top (x>0) sensor
228  positionX=-positionX;
230  GeoTrf::RotateX3D rotT(rotation);
231  //rotT.rotateZ(180*Gaudi::Units::degree); // Rotate so that X axis goes from implant side to backside
232  GeoTrf::Translation3D vecT(positionX,0,0);
233  // First translate in z (only non-zero for truncated middle)
234  // Then rotate and then translate in x.
235  GeoAlignableTransform *topTransform
236  = new GeoAlignableTransform(GeoTrf::Transform3D(vecT*rotT)*GeoTrf::TranslateZ3D(positionZ));
237 
238  int topSideNumber = m_upperSide;
239  id.setSide(topSideNumber);
240  module->add(new GeoNameTag("Sensor_Side#"+intToString(topSideNumber)));
241  module->add(new GeoIdentifierTag(600+topSideNumber));
242  module->add(topTransform);
243  GeoVPhysVol * topSensorPV = m_sensor->build(id);
244  module->add(topSensorPV);
245 
246  // Store transform
247  m_detectorManager->addAlignableTransform(0, id.getWaferId(), topTransform, topSensorPV);
248 
249  if (m_ringType == 2) { // Place glass pieces in place of sensor
250  module->add(new GeoTransform(GeoTrf::Transform3D(vecT*rotT)));
251  module->add(m_sensor->getInactive());
252  };
253  }
254  else{
255 
256  int bottomSideNumber = (m_upperSide) ? 0 : 1;
257  id.setSide(bottomSideNumber);
258  m_sensor->build(id);
259 
260  // Store transform
261  std::string key="FwdSensor_Side#"+std::to_string(bottomSideNumber)+"_"+std::to_string(id.getBarrelEC())+"_"+std::to_string(id.getLayerDisk())+"_"+std::to_string(id.getEtaModule())+"_"+std::to_string(id.getPhiModule());
262  m_detectorManager->addAlignableTransform(0, id.getWaferId(), (*m_mapAX)[key], (*m_mapFPV)[key]);
263 
264  int topSideNumber = m_upperSide;
265  id.setSide(topSideNumber);
266 
267  m_sensor->build(id);
268 
269  key="FwdSensor_Side#"+std::to_string(topSideNumber)+"_"+std::to_string(id.getBarrelEC())+"_"+std::to_string(id.getLayerDisk())+"_"+std::to_string(id.getEtaModule())+"_"+std::to_string(id.getPhiModule());
270 
271  // Store transform
272  m_detectorManager->addAlignableTransform(0, id.getWaferId(), (*m_mapAX)[key], (*m_mapFPV)[key]);
273 
274  }
275  return module;
276 
277 }
SCT_ComponentFactory::m_geometryManager
SCT_GeometryManager * m_geometryManager
Definition: SCT_ComponentFactory.h:42
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
SCT_FwdModule::m_widthInner
double m_widthInner
Definition: SCT_FwdModule.h:77
SCT_FwdModule::SCT_FwdModule
SCT_FwdModule(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_FwdModule.cxx:49
SCT_FwdModule.h
InDetDD::SCT_DetectorManager
Definition: SCT_DetectorManager.h:49
SCT_UniqueComponentFactory::m_mapFPV
std::shared_ptr< std::map< std::string, GeoFullPhysVol * > > m_mapFPV
Definition: SCT_ComponentFactory.h:95
max
#define max(a, b)
Definition: cfImp.cxx:41
SCT_GeneralParameters::safety
double safety() const
Definition: SCT_GeneralParameters.cxx:48
SCT_FwdModule::m_length
double m_length
Definition: SCT_FwdModule.h:75
SCT_Identifier.h
SCT_UniqueComponentFactory::m_mapAX
std::shared_ptr< std::map< std::string, GeoAlignableTransform * > > m_mapAX
Definition: SCT_ComponentFactory.h:96
SCT_FwdModule::m_distBtwMountPoints
double m_distBtwMountPoints
Definition: SCT_FwdModule.h:81
SCT_FwdModule::m_outerRadius
double m_outerRadius
Definition: SCT_FwdModule.h:87
SCT_MaterialManager.h
SCT_FwdModule::m_glueThickness
double m_glueThickness
Definition: SCT_FwdModule.h:80
SCT_FwdHybrid.h
SCT_FwdSubSpine.h
SCT_FwdModule::build
virtual GeoVPhysVol * build(SCT_Identifier id)
Definition: SCT_FwdModule.cxx:174
SCT_FwdModule::ringType
int ringType() const
Definition: SCT_FwdModule.h:43
SCT_FwdModule::~SCT_FwdModule
~SCT_FwdModule()
Definition: SCT_FwdModule.cxx:79
SUBSPINE_RIGHT
#define SUBSPINE_RIGHT
Definition: SCT_FwdSubSpine.h:14
SCT_ComponentFactory::m_detectorManager
InDetDD::SCT_DetectorManager * m_detectorManager
Definition: SCT_ComponentFactory.h:41
x
#define x
SCT_GeometryManager::generalParameters
const SCT_GeneralParameters * generalParameters() const
Definition: SCT_GeometryManager.cxx:105
SCT_FwdModule::m_widthOuter
double m_widthOuter
Definition: SCT_FwdModule.h:76
SCT_FwdModule::m_subspineR
std::unique_ptr< SCT_FwdSubSpine > m_subspineR
Definition: SCT_FwdModule.h:103
SCT_FwdModule::m_secMountPoint
double m_secMountPoint
Definition: SCT_FwdModule.h:91
SCT_GeneralParameters.h
SCT_FwdModule::m_moduleShift
double m_moduleShift
Definition: SCT_FwdModule.h:79
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
SCT_FwdModule::m_stereoAngle
double m_stereoAngle
Definition: SCT_FwdModule.h:74
python.PyAthena.module
module
Definition: PyAthena.py:134
SCT_FwdModule::m_mainMountPoint
double m_mainMountPoint
Definition: SCT_FwdModule.h:90
SCT_ForwardModuleParameters
Definition: SCT_ForwardModuleParameters.h:12
SCT_FwdSpine.h
SCT_FwdModule::m_mountPointToCenter
double m_mountPointToCenter
Definition: SCT_FwdModule.h:82
SCT_MaterialManager::gasMaterial
const GeoMaterial * gasMaterial() const
Definition: SCT_MaterialManager.cxx:80
SCT_FwdModule::m_connector
std::unique_ptr< SCT_FwdModuleConnector > m_connector
Definition: SCT_FwdModule.h:99
xAOD::rotation
rotation
Definition: TrackSurface_v1.cxx:15
SCT_FwdModule::m_innerRadius
double m_innerRadius
Definition: SCT_FwdModule.h:86
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
SCT_FwdModuleConnector.h
SCT_FwdModule::getParameters
void getParameters()
Definition: SCT_FwdModule.cxx:85
SCT_FwdModule::m_subspineL
std::unique_ptr< SCT_FwdSubSpine > m_subspineL
Definition: SCT_FwdModule.h:102
SCT_ForwardModuleParameters.h
SCT_FwdModule::m_ringType
int m_ringType
Definition: SCT_FwdModule.h:72
SCT_FwdModule::m_powerTapeStart
double m_powerTapeStart
Definition: SCT_FwdModule.h:88
sqr
double sqr(double x)
Definition: SCT_FwdModule.cxx:47
SCT_ComponentFactory::intToString
std::string intToString(int i) const
Definition: SCT_ComponentFactory.cxx:29
SCT_FwdModule::m_connectorPresent
bool m_connectorPresent
Definition: SCT_FwdModule.h:94
SCT_FwdModule::m_hybrid
std::unique_ptr< SCT_FwdHybrid > m_hybrid
Definition: SCT_FwdModule.h:100
SCT_GeneralParameters
Definition: SCT_GeneralParameters.h:16
SCT_FwdModule::m_endLocator
double m_endLocator
Definition: SCT_FwdModule.h:92
SCT_FwdModule::m_upperSide
int m_upperSide
Definition: SCT_FwdModule.h:84
SCT_ComponentFactory::m_materials
SCT_MaterialManager * m_materials
Definition: SCT_ComponentFactory.h:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
SCT_FwdModule::m_sensor
std::unique_ptr< SCT_FwdSensor > m_sensor
Definition: SCT_FwdModule.h:98
SCT_UniqueComponentFactory::m_logVolume
const GeoLogVol * m_logVolume
Definition: SCT_ComponentFactory.h:90
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
SCT_UniqueComponentFactory
Definition: SCT_ComponentFactory.h:76
SCT_FwdModule::preBuild
virtual const GeoLogVol * preBuild()
Definition: SCT_FwdModule.cxx:103
InDetDD::SCT_DetectorManager::addAlignableTransform
virtual void addAlignableTransform(int level, const Identifier &id, GeoAlignableTransform *xf, const GeoVFullPhysVol *child)
Add alignable transforms. No access to these, they will be changed by manager:
Definition: SCT_DetectorManager.cxx:264
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
SCT_FwdModule::m_spine
std::unique_ptr< SCT_FwdSpine > m_spine
Definition: SCT_FwdModule.h:101
SCT_DetectorManager.h
SCT_UniqueComponentFactory::m_sqliteReader
GeoModelIO::ReadGeoModel * m_sqliteReader
Definition: SCT_ComponentFactory.h:91
SCT_ComponentFactory::getName
const std::string & getName() const
Definition: SCT_ComponentFactory.h:35
SCT_FwdModule::m_thickness
double m_thickness
Definition: SCT_FwdModule.h:78
SCT_GeometryManager.h
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106
SCT_GeometryManager
Definition: SCT_GeometryManager.h:25
SUBSPINE_LEFT
#define SUBSPINE_LEFT
Definition: SCT_FwdSubSpine.h:13
SCT_FwdModule::m_hybridIsOnInnerEdge
bool m_hybridIsOnInnerEdge
Definition: SCT_FwdModule.h:83
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37