ATLAS Offline Software
Loading...
Searching...
No Matches
AFP_GeoModelTD.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
10#include "GeoModelKernel/GeoMaterial.h"
11#include "GeoModelKernel/GeoBox.h"
12#include "GeoModelKernel/GeoTube.h"
13#include "GeoModelKernel/GeoTubs.h"
14#include "GeoModelKernel/GeoShapeSubtraction.h"
15#include "GeoModelKernel/GeoShapeIntersection.h"
16#include "GeoModelKernel/GeoShapeUnion.h"
17#include "GeoModelKernel/GeoShapeShift.h"
18#include "GeoModelKernel/GeoLogVol.h"
19#include "GeoModelKernel/GeoNameTag.h"
20#include "GeoModelKernel/GeoPhysVol.h"
21#include "GeoModelKernel/GeoFullPhysVol.h"
22#include "GeoModelKernel/GeoTransform.h"
23#include "GeoModelKernel/GeoAlignableTransform.h"
24#include "CLHEP/GenericFunctions/AbsFunction.hh"
25#include "CLHEP/GenericFunctions/Variable.hh"
26#include "CLHEP/GenericFunctions/Sin.hh"
27#include "CLHEP/GenericFunctions/Cos.hh"
30
32
37
38#include <string>
39
40#include <cmath>
41
42
43#include <cstdlib>
44
46{
47 // Surface definition (preliminary)
49
52 double pfEnergy1[2]={ 1.62*CLHEP::eV, 6.20*CLHEP::eV };
53 double pfReflectivity1[2]={ 0.9, 0.9};
54 pMPT->AddProperty("REFLECTIVITY",pfEnergy1,pfReflectivity1,2);
55 m_pReflectionOptSurface->SetMaterialPropertiesTable(pMPT);
56}
57
58StatusCode AFP_GeoModelFactory::addTimingDetector(const char* pszStationName, GeoOpticalPhysVol* pPhysMotherVol, HepGeom::Transform3D& TransInMotherVolume, GeoBorderSurfaceContainer* bsContainer)
59{
60 int i,j,nPixelID;
61 double fXShift,fYShift,fZShift;
62
63 eAFPStation eStation=m_pGeometry->parseStationName(pszStationName);
64
65 AFP_TDCONFIGURATION TofCfg=m_CfgParams.tdcfg[eStation];
66 AFPTOF_LBARDIMENSIONS BarDims11=TofCfg.mapBarDims[11];
67 fXShift=-73.5*CLHEP::mm; //FIXME TODO
68 fYShift=(BarDims11.fRadLength+TofCfg.mapTrainInfo[BarDims11.nTrainID].fPerpShiftInPixel-0.5*(BarDims11.fLGuideWidth-TofCfg.mapTrainInfo[BarDims11.nTrainID].fTaperOffset)-0.5*BarDims11.fLBarThickness/std::tan(TofCfg.fAlpha))*std::sin(TofCfg.fAlpha);
69 fZShift=std::fabs(fYShift)/std::tan(TofCfg.fAlpha)+0.5*BarDims11.fLBarThickness/std::sin(TofCfg.fAlpha);
70
71 HepGeom::Transform3D TofTransform=TransInMotherVolume*HepGeom::Translate3D(fXShift,fYShift,fZShift)*HepGeom::RotateX3D((90.0*CLHEP::deg-TofCfg.fAlpha))*HepGeom::RotateZ3D(-90.0*CLHEP::deg);
72
73 for(i=0;i<m_CfgParams.tdcfg[eStation].nX1PixCnt;i++)
74 {
75 for(j=0;j<m_CfgParams.tdcfg[eStation].nX2PixCnt;j++)
76 {
77 nPixelID=10*(i+1)+(j+1);
78 addSepRadLBar(pszStationName,1,nPixelID,pPhysMotherVol,TofTransform,bsContainer);
79 }
80 }
81
83 {
84 addLBarSensorSeparationWindow(pszStationName,1,pPhysMotherVol,TofTransform,bsContainer);
85 }
86 addSensor(pszStationName,1,pPhysMotherVol,TofTransform,bsContainer);
87
88 return StatusCode::SUCCESS;
89}
90
91void AFP_GeoModelFactory::addSepRadLBar(const char* pszStationName, const int nQuarticID, const int nBarID, GeoOpticalPhysVol* pPhysMotherVolume, HepGeom::Transform3D& TransInMotherVolume, GeoBorderSurfaceContainer* bsContainer)
92{
93 double fX1Pos,fX2Pos,falpha,fd;
94 HepGeom::Vector3D<double> vecA1, vecA2, vecX;
95 CLHEP::Hep3Vector vecCutShift;
96 HepGeom::Transform3D TransCut;
97 GeoShapeShift* pMoveCut;
98 GeoBox* pSolAux;
99 char szlabel[64];
100
101 CLHEP::HepRotation Rot1,Rot2,Rot3;
102
103 eAFPStation eStation=m_pGeometry->parseStationName(pszStationName);
104 AFP_TDCONFIGURATION TofCfg=m_CfgParams.tdcfg[eStation];
105 AFPTOF_LBARDIMENSIONS BarDims=TofCfg.mapBarDims[nBarID];
106
107 double fTaperOffset=TofCfg.mapTrainInfo[BarDims.nTrainID].fTaperOffset;
108 m_pGeometry->getPixelLocalPosition(eStation,nBarID,&fX1Pos,&fX2Pos);
109
110 fX1Pos+=TofCfg.mapTrainInfo[BarDims.nTrainID].fPerpShiftInPixel;
111
112
113 //Light guide
114 HepGeom::Transform3D TotTransform=TransInMotherVolume*HepGeom::Translate3D( fX1Pos,
115 0.5*BarDims.fLGuideLength,
116 fX2Pos);
117 GeoShape* pSolVolume=new GeoBox(0.5*BarDims.fLGuideWidth,0.5*BarDims.fLGuideLength,0.5*BarDims.fLBarThickness);
118
119 if(TofCfg.mapTrainInfo[BarDims.nTrainID].bUseTaper)
120 {
121 falpha=TofCfg.mapTrainInfo[BarDims.nTrainID].fTaperAngle;
122 fd=fTaperOffset/std::sin(falpha);
123 vecA1=-fd*std::cos(falpha)*CLHEP::Hep3Vector(0.0,1.0,0.0);
124 vecA2=+0.5*fd*std::sqrt(2.0)*(CLHEP::HepRotationZ(+(45*CLHEP::deg-falpha))*CLHEP::Hep3Vector(0.0,1.0,0.0)).unit();
125 vecX=vecA1+vecA2;
126 vecCutShift=CLHEP::Hep3Vector(-0.5*BarDims.fLGuideWidth,0.5*BarDims.fLGuideLength,0.0)+CLHEP::Hep3Vector(vecX);
127 Rot1.rotateZ(-falpha);
128
129 pSolAux=new GeoBox(0.5*fd,0.5*fd,0.5*BarDims.fLBarThickness+SLIMCUT);
130 TransCut=HepGeom::Transform3D(Rot1,vecCutShift);
131 pMoveCut=new GeoShapeShift(pSolAux, Amg::CLHEPTransformToEigen(TransCut));
132 pSolVolume=new GeoShapeSubtraction(pSolVolume, pMoveCut);
133 }
134
135 sprintf(szlabel,"%s_Q%i_LogLGuide[%i]",pszStationName,nQuarticID,nBarID);
136 GeoLogVol* pLogLGuide=new GeoLogVol(szlabel,pSolVolume,m_MapMaterials[std::string("Quartz")]);
137 GeoOpticalPhysVol* pPhysLGuide=new GeoOpticalPhysVol(pLogLGuide);
138 sprintf(szlabel,"%s_Q%i_LGuide[%i]",pszStationName,nQuarticID,nBarID);
139 pPhysMotherVolume->add(new GeoNameTag(szlabel));
140 pPhysMotherVolume->add(new GeoTransform(Amg::CLHEPTransformToEigen(TotTransform)));
141 pPhysMotherVolume->add(pPhysLGuide);
142 sprintf(szlabel,"%s_Q%i_LGuideSurface[%i]",pszStationName,nQuarticID,nBarID);
143 bsContainer->push_back(GeoBorderSurface(szlabel, pPhysLGuide, pPhysMotherVolume, m_pOpticalSurface));
144
145 //Radiator elbow
146 double fRadYDim=BarDims.fRadYDim;
147 double fElbowXDim=fRadYDim;
148 TotTransform=TransInMotherVolume*HepGeom::Translate3D( fX1Pos-0.5*BarDims.fLGuideWidth+0.5*fElbowXDim+fTaperOffset,
149 BarDims.fLGuideLength+0.5*fRadYDim,
150 fX2Pos);
151 pSolVolume=new GeoBox(0.5*fElbowXDim,0.5*fRadYDim,0.5*BarDims.fLBarThickness);
152
153 falpha=45.0*CLHEP::deg;
154 fd=fRadYDim/std::sin(falpha);//std::sqrt(2.0)*fRadYDim;
155 vecA1=-fd*std::cos(falpha)*CLHEP::Hep3Vector(0.0,1.0,0.0);
156 vecA2=+0.5*fd*std::sqrt(2.0)*(CLHEP::HepRotationZ(+(45*CLHEP::deg-falpha))*CLHEP::Hep3Vector(0.0,1.0,0.0)).unit();
157 vecX=vecA1+vecA2;
158 vecCutShift=CLHEP::Hep3Vector(-0.5*fElbowXDim,0.5*fRadYDim,0.0)+CLHEP::Hep3Vector(vecX);
159 Rot2.rotateZ(-falpha);
160
161 pSolAux=new GeoBox(0.5*fd,0.5*fd,0.5*BarDims.fLBarThickness+SLIMCUT);
162 TransCut=HepGeom::Transform3D(Rot2,vecCutShift);
163 pMoveCut=new GeoShapeShift(pSolAux, Amg::CLHEPTransformToEigen(TransCut));
164 pSolVolume=new GeoShapeSubtraction(pSolVolume, pMoveCut);
165
166 sprintf(szlabel,"%s_Q%i_LogRadiator[%i]",pszStationName,nQuarticID,nBarID);
167 GeoLogVol* pLogRadiator=new GeoLogVol(szlabel,pSolVolume,m_MapMaterials[std::string("Quartz")]);
168 GeoOpticalPhysVol* pPhysRadiator=new GeoOpticalPhysVol(pLogRadiator);
169 sprintf(szlabel,"%s_Q%i_Radiator[%i]",pszStationName,nQuarticID,nBarID);
170 pPhysMotherVolume->add(new GeoNameTag(szlabel));
171 pPhysMotherVolume->add(new GeoTransform(Amg::CLHEPTransformToEigen(TotTransform)));
172 pPhysMotherVolume->add(pPhysRadiator);
173 sprintf(szlabel,"%s_Q%i_RadiatorElbowSurface[%i]",pszStationName,nQuarticID,nBarID);
174 bsContainer->push_back(GeoBorderSurface(szlabel, pPhysRadiator, pPhysMotherVolume, m_pReflectionOptSurface));
175
176 //Radiator
177 double fRadLength=BarDims.fRadLength-(BarDims.fLGuideWidth-fTaperOffset);
178 TotTransform=TransInMotherVolume*HepGeom::Translate3D( fX1Pos-0.5*BarDims.fLGuideWidth+fElbowXDim+fTaperOffset+0.5*fRadLength,
179 BarDims.fLGuideLength+0.5*fRadYDim,
180 fX2Pos);
181 pSolVolume=new GeoBox(0.5*fRadLength,0.5*fRadYDim,0.5*BarDims.fLBarThickness);
182
183 if(TofCfg.bApplyBottomCut){
184 falpha = TofCfg.fAlpha;
185 fd = BarDims.fLBarThickness/std::sin(falpha);
186 vecA1 = -fd*std::cos(falpha)*CLHEP::Hep3Vector(1.0,0.0,0.0);
187 vecA2 = 0.5*fd*std::sqrt(2.0)*(CLHEP::HepRotationY(-(45*CLHEP::deg-falpha))*CLHEP::Hep3Vector(1.0,0.0,0.0)).unit();
188 vecX = vecA1 + vecA2;
189 vecCutShift = CLHEP::Hep3Vector(0.5*fRadLength,0.0,0.5*BarDims.fLBarThickness) + CLHEP::Hep3Vector(vecX);
190 Rot3.rotateY(falpha);
191
192 pSolAux=new GeoBox(0.5*fd,0.5*fRadYDim+SLIMCUT,0.5*fd);
193 TransCut=HepGeom::Transform3D(Rot3,vecCutShift);
194 pMoveCut=new GeoShapeShift(pSolAux, Amg::CLHEPTransformToEigen(TransCut));
195 pSolVolume=new GeoShapeSubtraction(pSolVolume, pMoveCut);
196 }
197
198 sprintf(szlabel,"%s_Q%i_LogRadiator[%i]",pszStationName,nQuarticID,nBarID);
199 pLogRadiator=new GeoLogVol(szlabel,pSolVolume,m_MapMaterials[std::string("Quartz")]);
200 pPhysRadiator=new GeoOpticalPhysVol(pLogRadiator);
201 sprintf(szlabel,"%s_Q%i_Radiator[%i]",pszStationName,nQuarticID,nBarID);
202 pPhysMotherVolume->add(new GeoNameTag(szlabel));
203 pPhysMotherVolume->add(new GeoTransform(Amg::CLHEPTransformToEigen(TotTransform)));
204 pPhysMotherVolume->add(pPhysRadiator);
205 sprintf(szlabel,"%s_Q%i_RadiatorSurface[%i]",pszStationName,nQuarticID,nBarID);
206 bsContainer->push_back(GeoBorderSurface(szlabel, pPhysRadiator, pPhysMotherVolume, m_pOpticalSurface));
207}
208
209
210void AFP_GeoModelFactory::addLBarSensorSeparationWindow(const char* pszStationName, const int nQuarticID, GeoOpticalPhysVol* pPhysMotherVolume,
211 HepGeom::Transform3D &TransInMotherVolume, GeoBorderSurfaceContainer* bsContainer)
212{
213 int nPixelID;
214 char szlabel[64];
215 double fX1Pos_1, fX2Pos_1, fX1Pos_2, fX2Pos_2;
216 HepGeom::Transform3D TotTransform;
217
218 eAFPStation eStation=m_pGeometry->parseStationName(pszStationName);
219 AFP_TDCONFIGURATION TofCfg=m_CfgParams.tdcfg[eStation];
220 double fSensor2BarDistance=(TofCfg.bEmulateImmersion)? 0.0:AFP_CONSTANTS::ToF_Sensor2BarDist;
221
223
224 nPixelID=10*( TofCfg.nX1PixCnt/2-1 +1)+( TofCfg.nX1PixCnt/2-1 +1);
225 m_pGeometry->getPixelLocalPosition(eStation,nPixelID,&fX1Pos_1,&fX2Pos_1);
226 nPixelID=10*( TofCfg.nX1PixCnt/2 +1)+( TofCfg.nX1PixCnt/2 +1);
227 m_pGeometry->getPixelLocalPosition(eStation,nPixelID,&fX1Pos_2,&fX2Pos_2);
228
229 sprintf(szlabel,"%s_Q%i_LogLBarSensorSeparationWindow",pszStationName,nQuarticID);
230 TotTransform=TransInMotherVolume*HepGeom::Translate3D(0.5*(fX1Pos_1+fX1Pos_2),-0.5*AFP_CONSTANTS::ToF_SeparationWindowThickness-fSensor2BarDistance,0.5*(fX2Pos_1+fX2Pos_2))*HepGeom::RotateX3D(90.0*CLHEP::deg);
231 GeoLogVol* pLogWindow=new GeoLogVol(szlabel,pSolWindow,m_MapMaterials["Quartz"]);
232 GeoOpticalPhysVol* pPhysWindow=new GeoOpticalPhysVol(pLogWindow);
233 sprintf(szlabel,"%s_Q%i_LBarSensorSeparationWindow",pszStationName,nQuarticID);
234 pPhysMotherVolume->add(new GeoNameTag(szlabel));
235 pPhysMotherVolume->add(new GeoTransform(Amg::CLHEPTransformToEigen(TotTransform)));
236 pPhysMotherVolume->add(pPhysWindow);
237 sprintf(szlabel,"%s_Q%i_WindowSurface",pszStationName,nQuarticID);
238 bsContainer->push_back(GeoBorderSurface(szlabel, pPhysWindow, pPhysMotherVolume, m_pOpticalSurface));
239
240 pPhysWindow=nullptr;
241
242}
243
244
245
246void AFP_GeoModelFactory::addSensor(const char* pszStationName, const int nQuarticID, GeoOpticalPhysVol* pPhysMotherVolume,
247 HepGeom::Transform3D &TransInMotherVolume, GeoBorderSurfaceContainer* bsContainer)
248{
249 int i,j,nPixelID;
250 char szlabel[64];
251 double fX1Pos, fX2Pos;
252 HepGeom::Transform3D TotTransform;
253
254 eAFPStation eStation=m_pGeometry->parseStationName(pszStationName);
255 AFP_TDCONFIGURATION TofCfg=m_CfgParams.tdcfg[eStation];
256 double fSensor2BarDistance=(TofCfg.bEmulateImmersion)? 0.0:AFP_CONSTANTS::ToF_Sensor2BarDist;
258 {
260 }
261
262 GeoBox* pSolSensor=new GeoBox(0.5*TofCfg.fPixelX1Dim,0.5*AFP_CONSTANTS::ToF_SensorThickness,0.5*TofCfg.fPixelX2Dim);
263
264 for(i=0;i<TofCfg.nX1PixCnt;i++)
265 {
266 for(j=0;j<TofCfg.nX2PixCnt;j++)
267 {
268 nPixelID=10*(i+1)+(j+1);
269 m_pGeometry->getPixelLocalPosition(eStation,nPixelID,&fX1Pos,&fX2Pos);
270
271 sprintf(szlabel,"%s_Q%i_LogTDSensor[%i]",pszStationName,nQuarticID,nPixelID);
272 TotTransform=TransInMotherVolume*HepGeom::Translate3D(fX1Pos,-0.5*AFP_CONSTANTS::ToF_SensorThickness-fSensor2BarDistance,fX2Pos);
273 GeoLogVol* pLogSensor=new GeoLogVol(szlabel,pSolSensor,m_MapMaterials["SiliconPMT"]);
274 GeoOpticalPhysVol* pPhysSensor=new GeoOpticalPhysVol(pLogSensor);
275 sprintf(szlabel,"%s_Q%i_TDSensor[%i]",pszStationName,nQuarticID,nPixelID);
276 pPhysMotherVolume->add(new GeoNameTag(szlabel));
277 pPhysMotherVolume->add(new GeoTransform(Amg::CLHEPTransformToEigen(TotTransform)));
278 pPhysMotherVolume->add(pPhysSensor);
279 sprintf(szlabel,"%s_Q%i_SensorSurface[%i]",pszStationName,nQuarticID,nPixelID);
280 bsContainer->push_back(GeoBorderSurface(szlabel, pPhysSensor, pPhysMotherVolume, m_pOpticalSurface));
281
282 pPhysSensor=nullptr;
283 }
284 }
285
286}
eAFPStation
#define SLIMCUT
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
std::vector< GeoBorderSurface > GeoBorderSurfaceContainer
std::map< std::string, GeoRef< const GeoMaterial > > m_MapMaterials
void addLBarSensorSeparationWindow(const char *pszStationName, const int nQuarticID, GeoOpticalPhysVol *pPhysMotherVolume, HepGeom::Transform3D &TransInMotherVolume, GeoBorderSurfaceContainer *bsContainer)
GeoIntrusivePtr< GeoOpticalSurface > m_pOpticalSurface
void addSepRadLBar(const char *pszStationName, const int nQuarticID, const int nBarID, GeoOpticalPhysVol *pPhysMotherVolume, HepGeom::Transform3D &TransInMotherVolume, GeoBorderSurfaceContainer *bsContainer)
void addSensor(const char *pszStationName, const int nQuarticID, GeoOpticalPhysVol *pPhysMotherVolume, HepGeom::Transform3D &TransInMotherVolume, GeoBorderSurfaceContainer *bsContainer)
StatusCode addTimingDetector(const char *pszStationName, GeoOpticalPhysVol *pPhysMotherVol, HepGeom::Transform3D &TransInMotherVolume, GeoBorderSurfaceContainer *bsContainer)
GeoIntrusivePtr< GeoOpticalSurface > m_pReflectionOptSurface
AFP_CONFIGURATION m_CfgParams
void AddProperty(const char *key, double *PhotonMomenta, double *PropertyValues, int NumEntries)
Ensure that the extensions for the Vector3D are properly loaded.
Ensure that the extensions for the Vector3D are properly loaded.
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
static constexpr double ToF_SensorThickness
static constexpr double ToF_SeparationWindowThickness
static constexpr double ToF_SeparationWindowDiameter
static constexpr double ToF_Sensor2BarDist
std::map< int, AFPTOF_LBARDIMENSIONS > mapBarDims
std::map< int, AFPTOF_TRAININFO > mapTrainInfo