ATLAS Offline Software
Loading...
Searching...
No Matches
GeoPixelTMT.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// Build The TMT.
6// This is built one time per layer.
7// Each layer is given slightly different mass due to differences
8// in the measured mass.
9
10#include "GeoPixelTMT.h"
11#include "GeoModelKernel/GeoBox.h"
12#include "GeoModelKernel/GeoTubs.h"
13#include "GeoModelKernel/GeoTrap.h"
14#include "GeoModelKernel/GeoLogVol.h"
15#include "GeoModelKernel/GeoPhysVol.h"
16#include "GeoModelKernel/GeoMaterial.h"
17#include "GeoModelKernel/GeoNameTag.h"
18#include "GeoModelKernel/GeoTransform.h"
19#include "GeoModelKernel/GeoShapeShift.h"
20#include "GeoModelKernel/GeoShapeUnion.h"
21#include "GaudiKernel/SystemOfUnits.h"
22#include <utility> //std::swap
23#include <cmath>
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 GeoPixelStaveSupport(ddmgr, mgr, sqliteReader, std::move(mapFPV), std::move(mapAX)),
31 m_transform(GeoTrf::Transform3D::Identity())
32{
33 if(!m_sqliteReader) {
35
36 }
37}
38
39
40GeoVPhysVol* GeoPixelTMT::Build() {
41
42 if(m_sqliteReader) return nullptr;
43
44 // we want to use an assembly; therefore, we need a dummy volume to trigger the mechanism
45 const GeoMaterial* ether = m_mat_mgr->getMaterial("special::Ether");
46 GeoBox* dummybox= new GeoBox(4711., 4711., 4711.);
47 GeoLogVol* dummyTMT = new GeoLogVol("TMT",dummybox,ether);
48 GeoPhysVol* theTMT = new GeoPhysVol(dummyTMT);
49
50 // get the material by dividing the total material by the volume per layer,
51 // the weight is only stored in DB for the whole TMT layer
52 // we will commonly use TMT as name for the stuff
53 std::string matName = m_gmt_mgr->getMaterialName("TMT", m_gmt_mgr->GetLD());
54
55 double volume = 12647.7; // this number seems to be wrong
56 const GeoMaterial* material = m_mat_mgr->getMaterialForVolume(matName,volume);
57 GeoNameTag* tag = new GeoNameTag("TMT");
58
59 // this part is unchanged: reading the DB, creating the shapes of the volumes and defining their position
60 GeoTrf::RotateX3D traprot(180.*Gaudi::Units::deg);
61
62 int halfNModule = m_gmt_mgr->PixelNModule()/2;
63
64 for (int ii = 0; ii < m_gmt_mgr->PixelTMTNumParts(); ii++) {
65 double z1 = m_gmt_mgr->PixelTMTPosZ1(ii);
66 double z2 = m_gmt_mgr->PixelTMTPosZ2(ii);
67 double xbase1 = m_gmt_mgr->PixelTMTBaseX1(ii);
68 double xbase2 = m_gmt_mgr->PixelTMTBaseX2(ii);
69 double w1 = m_gmt_mgr->PixelTMTWidthX1(ii);
70 double w2 = m_gmt_mgr->PixelTMTWidthX2(ii);
71 double widthy = m_gmt_mgr->PixelTMTWidthY(ii);
72 double ypos = m_gmt_mgr->PixelTMTPosY(ii);
73 bool perModule = m_gmt_mgr->PixelTMTPerModule(ii);
74
75
76 // Code below assume z2>z1. Swap if this is not the case
77 if (z1>z2) {
78 std::swap(z1,z2);
79 std::swap(xbase1,xbase2);
80 std::swap(w1,w2);
81 }
82
83 double length = z2-z1;
84 double zpos = 0.5*(z1+z2);
85 double xpos = 0.5*(xbase1 + xbase2 - 0.5*(w2+w1));
86
87 double theta = 0;
88 if (w1 != w2 || xbase1 != xbase2) {
89 theta = std::atan((xbase2 - xbase1 - 0.5*(w2-w1))/length);
90 }
91
92 double phi = 0;
93 double angleydzn = 0;
94 double angleydzp = 0;
95
96 GeoIntrusivePtr<const GeoShape> shape{};
97 if (w1 == w2 && theta == 0) {
98 // Its a box
99 shape = new GeoBox(0.5*w1, 0.5*widthy, 0.5*length);
100 } else {
101 shape = new GeoTrap(0.5*length, theta, phi, 0.5*widthy, 0.5*w1, 0.5*w1, angleydzn,
102 0.5*widthy, 0.5*w2, 0.5*w2, angleydzp);
103 // Test GeoModel volume calculation. OK.
104 }
105
106
107 // end of the old part
108 // now we put everything into the assembly
109 if (!perModule) { // For middle section and others
110
111 // create the colume, move it to the correct relative position and add it to the assembly
112
113 GeoLogVol* tmpLogVol= new GeoLogVol("TMT",shape,material);
114 GeoPhysVol* tmpPhysVol= new GeoPhysVol(tmpLogVol);
115 GeoTransform* trans = new GeoTransform(GeoTrf::Translate3D(xpos,ypos,zpos));
116
117 theTMT->add(tag);
118 theTMT->add(trans);
119 theTMT->add(tmpPhysVol);
120
121 } else { // Once per module, copied in +z and -z side.
122 // we will add the same volume many times, need to create it only once
123
124 GeoLogVol* tmpLogVol= new GeoLogVol("TMT",shape,material);
125 GeoPhysVol* tmpPhysVol= new GeoPhysVol(tmpLogVol);
126
127 for (int ii = 0; ii < halfNModule; ii++) {
128
129 // move the dublicates to the correct relative position and add it to the assembly
130 double zshift = m_gmt_mgr->PixelModuleZPosition(1) * ii;
131
132 GeoTransform* transPos = new GeoTransform(GeoTrf::Translate3D(xpos,ypos,zpos+zshift));
133 theTMT->add(tag);
134 theTMT->add(transPos);
135 theTMT->add(tmpPhysVol);
136
137 GeoTransform* transNeg = new GeoTransform(GeoTrf::Translate3D(xpos,ypos,-(zpos+zshift))*GeoTrf::RotateX3D(180*Gaudi::Units::deg));
138 theTMT->add(tag);
139 theTMT->add(transNeg);
140 theTMT->add(tmpPhysVol);
141
142 }
143 }
144 }
145 // Return the assembly
146 return theTMT;
147
148}
149
150const GeoShape *
151GeoPixelTMT::addShape(const GeoShape * lastShape, const GeoShape * nextShape, const GeoTrf::Transform3D & trans)
152{
153 const GeoShape * shiftedShape = &(*nextShape << trans);
154 if (lastShape) {
155 lastShape = &(lastShape->add(*shiftedShape));
156 } else {
157 lastShape = shiftedShape;
158 }
159 return lastShape;
160}
Scalar phi() const
phi method
Scalar theta() const
theta method
Eigen::Affine3d Transform3D
double length(const pvec &v)
GeoTrf::Transform3D m_transform
Definition GeoPixelTMT.h:44
PVLink m_physVol
Definition GeoPixelTMT.h:43
const GeoShape * addShape(const GeoShape *lastShape, const GeoShape *nextShape, const GeoTrf::Transform3D &trans)
GeoPixelTMT(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)
virtual GeoVPhysVol * Build() override
GeoModelIO::ReadGeoModel * m_sqliteReader
PixelGeometryManager * m_gmt_mgr
InDetMaterialManager * m_mat_mgr
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated pixel ...
STL namespace.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)