ATLAS Offline Software
Loading...
Searching...
No Matches
GeoPixelFrame Class Reference

#include <GeoPixelFrame.h>

Inheritance diagram for GeoPixelFrame:
Collaboration diagram for GeoPixelFrame:

Public Member Functions

 GeoPixelFrame (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)
void BuildAndPlace (GeoFullPhysVol *parent, int section)

Protected Attributes

PixelGeometryManagerm_gmt_mgr
InDetMaterialManagerm_mat_mgr
InDetDD::PixelDetectorManagerm_DDmgr
GeoModelIO::ReadGeoModel * m_sqliteReader
std::shared_ptr< std::map< std::string, GeoFullPhysVol * > > m_mapFPV
std::shared_ptr< std::map< std::string, GeoAlignableTransform * > > m_mapAX
const double m_epsilon

Private Member Functions

virtual GeoVPhysVol * Build () override
bool same (double v1, double v2)

Detailed Description

Definition at line 10 of file GeoPixelFrame.h.

Constructor & Destructor Documentation

◆ GeoPixelFrame()

GeoPixelFrame::GeoPixelFrame ( 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 )

Definition at line 22 of file GeoPixelFrame.cxx.

26 : GeoVPixelFactory (ddmgr, mgr, sqliteReader, std::move(mapFPV), std::move(mapAX))
27{
28}
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)

Member Function Documentation

◆ Build()

virtual GeoVPhysVol * GeoPixelFrame::Build ( )
inlineoverrideprivatevirtual

Implements GeoVPixelFactory.

Definition at line 20 of file GeoPixelFrame.h.

20{return 0;} // unused - but satisfy interface

◆ BuildAndPlace()

void GeoPixelFrame::BuildAndPlace ( GeoFullPhysVol * parent,
int section )

Definition at line 30 of file GeoPixelFrame.cxx.

31{
32 double rminSide = m_gmt_mgr->PixelFrameRMinSide(section);
33 double rmaxSide = m_gmt_mgr->PixelFrameRMaxSide(section);
34 double sideWidth = m_gmt_mgr->PixelFrameSideWidth(section);
35 double zmin = m_gmt_mgr->PixelFrameZMin(section);
36 double zmax = m_gmt_mgr->PixelFrameZMax(section);
37 double phiLoc = m_gmt_mgr->PixelFramePhiStart(section);
38 int numSides = m_gmt_mgr->PixelFrameNumSides(section);
39 bool mirrorSides = m_gmt_mgr->PixelFrameMirrorSides(section);
40
41 // No frame defined in the DB table
42 if(numSides==0)return;
43
44 double midRadius = 0.5*(rminSide+rmaxSide);
45 double zCenter = 0.5*(zmin+zmax);
46
47 const GeoMaterial* air = m_mat_mgr->getMaterial("std::Air");
48
49
51 // The Frame envelope
53
54 // Make envelope to hold the frame
55 //double safety = 0.001 * Gaudi::Units::mm;
56 double epsilon = 0.00001 * Gaudi::Units::mm;
57 double halflength = 0.5*std::abs(zmax - zmin);
58
59 double alpha = Gaudi::Units::pi/numSides;
60 double cosalpha = cos(alpha);
61 double sinalpha = sin(alpha);
62
63 /*
64 double rminEnv = (rminSide-safety)/cosalpha;
65 double rmaxEnv = (rmaxSide+safety)/cosalpha;
66 GeoPgon * frameEnvShape = new GeoPgon(phiLoc-alpha,2*Gaudi::Units::pi,numSides);
67 frameEnvShape->addPlane(zCenter-halflength-0.5*epsilon,rminEnv,rmaxEnv);
68 frameEnvShape->addPlane(zCenter+halflength+0.5*epsilon,rminEnv,rmaxEnv);
69
70 GeoLogVol * frameEnvLV = new GeoLogVol("Frame",frameEnvShape,air);
71 GeoPhysVol * frameEnvPV = new GeoPhysVol(frameEnvLV);
72 */
73
75 // The Corners
77
78 // Calculate corner parameters. This is made using a BREP by defining the vertices.
79 double rmin = rminSide/cosalpha;
80 double rmax = rmaxSide/cosalpha;
81 double innerFullSideHalfWidth = rmin * sinalpha;
82 double outerFullSideHalfWidth = rmax * sinalpha;
83 double sideHalfWidth = 0.5 * sideWidth;
84 if (innerFullSideHalfWidth - sideHalfWidth < 0) {
85 std::cout << "Error. innerFullSideWidth is smaller than sideWidth" << std::endl;
86 // ERROR
87 }
88
89 double v1x = rmax;
90 double v1y = 0;
91 double v2x = rmax - (outerFullSideHalfWidth - sideHalfWidth) * sinalpha;
92 double v2y = (outerFullSideHalfWidth - sideHalfWidth) * cosalpha;
93 double v3x = rmin - (innerFullSideHalfWidth - sideHalfWidth) * sinalpha;
94 double v3y = (innerFullSideHalfWidth - sideHalfWidth) * cosalpha;
95 double v4x = rmin;
96 double v4y = 0;
97 double v5x = v3x;
98 double v5y = -v3y;
99 double v6x = v2x;
100 double v6y = -v2y;
101
102 //std::cout << "Point 1: (" << v1x << ", " << v1y << ")" << std::endl;
103 //std::cout << "Point 2: (" << v2x << ", " << v2y << ")" << std::endl;
104 //std::cout << "Point 3: (" << v3x << ", " << v3y << ")" << std::endl;
105 //std::cout << "Point 4: (" << v4x << ", " << v4y << ")" << std::endl;
106 //std::cout << "Point 5: (" << v5x << ", " << v5y << ")" << std::endl;
107 //std::cout << "Point 6: (" << v6x << ", " << v6y << ")" << std::endl;
108
109 // Make the Corner shape
110 GeoSimplePolygonBrep * cornerShape = new GeoSimplePolygonBrep(halflength-epsilon);
111 cornerShape->addVertex(v1x,v1y);
112 cornerShape->addVertex(v2x,v2y);
113 cornerShape->addVertex(v3x,v3y);
114 cornerShape->addVertex(v4x,v4y);
115 cornerShape->addVertex(v5x,v5y);
116 cornerShape->addVertex(v6x,v6y);
117
118 // Test GeoModel volume calculation. OK.
119 // double volumeBrepTest = (innerFullSideHalfWidth + outerFullSideHalfWidth - 2*sideHalfWidth)
120 // * (rmaxSide-rminSide)*2*(halflength-epsilon);
121 // std::cout << "Volume BREP: GeoModel: " << cornerShape->volume() << " My calc: " << volumeBrepTest << std::endl;
122
123 std::string cornerMatName = m_gmt_mgr->PixelFrameCornerMaterial(section);
124 const GeoMaterial* cornerMat = m_mat_mgr->getMaterialForVolume(cornerMatName,numSides*cornerShape->volume()); // CHeck volume calc.
125 //const GeoMaterial* cornerMat = m_mat_mgr->getMaterial("std::Carbon");
126 GeoLogVol * cornerLV = new GeoLogVol("FrameCorner",cornerShape,cornerMat);
127
128
130 // The Sides
132
133 // Make the side
134 // Put the side in a box
135 GeoPhysVol * sideEnvelopePV = nullptr;
136 double zSideCenter = 0;
137 int numElements = m_gmt_mgr->PixelFrameNumSideElements(section);
138
139 if (numElements) {
140 double sideThick = rmaxSide - rminSide;
141
142 std::vector<GeoTrf::Transform3D> sideTransVec;
143 std::vector<GeoShape *> sideElementShapeVec;
144 sideTransVec.reserve(numElements);
145 sideElementShapeVec.reserve(numElements);
146
147 bool first = true;
148 double zSideMin = 0;
149 double zSideMax = 0;
150 double totSideVolume = 0;
151 for (int iElement = 0; iElement < numElements; iElement++) {
152 // 1, 2 (ie zMin1, zMin2 and zMax1 and zMax2 refers to the lower and upper (in phi) edges of the side element of the frame.
153 double zMin1 = m_gmt_mgr->PixelFrameElementZMin1(section, iElement)+2*epsilon;
154 double zMax1 = m_gmt_mgr->PixelFrameElementZMax1(section, iElement)-2*epsilon;
155 double zMin2 = m_gmt_mgr->PixelFrameElementZMin2(section, iElement)+2*epsilon;
156 double zMax2 = m_gmt_mgr->PixelFrameElementZMax2(section, iElement)-2*epsilon;
157 double zminInput = std::min(zMin1,std::min(zMax1,std::min(zMin2,zMax2)));
158 double zmaxInput = std::max(zMin1,std::max(zMax1,std::max(zMin2,zMax2)));
159 if (first) {
160 zSideMin = zminInput;
161 zSideMax = zmaxInput;
162 first = false;
163 } else {
164 zSideMin = std::min(zSideMin, zminInput);
165 zSideMax = std::max(zSideMax, zmaxInput);
166 }
167 GeoShape * sideElementShape = nullptr;
168 GeoTrf::Transform3D rotateShape(GeoTrf::Transform3D::Identity());
169 double shapeVolume = 0;
170 if (same(zMin1,zMin2) && same(zMax1,zMax2)) {
171 // Use a box
172 sideElementShape = new GeoBox(0.5*sideThick, 0.5*sideWidth-2*epsilon, 0.5*std::abs(zMax1-zMin1));
173 shapeVolume = sideElementShape->volume();
174 } else if (same(zMax1-zMin1, zMax2-zMin2)) {
175 // Use a parallelepiped
176 double alphaPara = atan2(zMin2-zMin1,sideWidth);
177 double thetaPara = 0;
178 double phiPara = 0;
179 sideElementShape = new GeoPara(0.5*std::abs(zMax1-zMin1), 0.5*sideWidth-epsilon, 0.5*sideThick, alphaPara, thetaPara, phiPara);
180 rotateShape = GeoTrf::RotateY3D(-90*Gaudi::Units::deg);
181 shapeVolume = std::abs(zMax1-zMin1) * (sideWidth-2*epsilon) * sideThick;
182 } else {//
183 // other cases not implemented. Should not occur for the frame.
184 std::cout << "GeoPixelFrame: This case is not handled for building the frame" << std::endl;
185 }
186 sideTransVec.push_back(GeoTrf::TranslateZ3D(0.25*(zMin1+zMin2+zMax1+zMax2))*rotateShape);
187 sideElementShapeVec.push_back(sideElementShape);
188 //totSideVolume += sideElementShape->volume();
189 totSideVolume += shapeVolume;
190 }
191
192 // Make envelope
193 GeoBox * sideEnvelope = new GeoBox(0.5*sideThick+epsilon, 0.5*sideWidth-epsilon, 0.5*std::abs(zSideMax-zSideMin)+epsilon);
194 GeoLogVol * sideEnvelopeLV = new GeoLogVol("PixelFrameSideEnv", sideEnvelope, air);
195 sideEnvelopePV = new GeoPhysVol(sideEnvelopeLV);
196
197 zSideCenter = 0.5*(zSideMin+zSideMax);
198
199 std::string sideMatName = m_gmt_mgr->PixelFrameSideMaterial(section);
200 const GeoMaterial* sideMat = m_mat_mgr->getMaterialForVolume(sideMatName,numSides*totSideVolume);
201 for (int iElement = 0; iElement < numElements; iElement++) {
202 GeoTransform * transSideElement = new GeoTransform(GeoTrf::TranslateZ3D(-zSideCenter)*sideTransVec[iElement]);
203 std::ostringstream frameSideName;
204 frameSideName << "FrameSide" << iElement;
205 GeoLogVol * sideElementLV = new GeoLogVol(frameSideName.str(), sideElementShapeVec[iElement], sideMat);
206 GeoPhysVol * sideElementPV = new GeoPhysVol(sideElementLV);
207 sideEnvelopePV->add(transSideElement);
208 sideEnvelopePV->add(sideElementPV);
209 }
210 }
211
213 // Put it together
215 GeoPhysVol * cornerPV = new GeoPhysVol(cornerLV);
216
217 // place the corners and sides.
218 for (int iSide = 0; iSide<numSides; iSide++) {
219 double angleCorner = phiLoc + alpha * (2*iSide - 1);
220 GeoTransform * cornerTrans = new GeoTransform(GeoTrf::TranslateZ3D(zCenter)*GeoTrf::RotateZ3D(angleCorner));
221 // Place the corners
222 parent->add(cornerTrans);
223 parent->add(cornerPV);
224 if (sideEnvelopePV) {
225 double angleSide = phiLoc + alpha * (2*iSide);
226 GeoTrf::Transform3D oddEvenRotate(GeoTrf::Transform3D::Identity());
227 if (iSide%2 && mirrorSides) {
228 oddEvenRotate = GeoTrf::RotateZ3D(Gaudi::Units::pi); // Every 2nd side we mirror the side.
229 }
230 GeoTransform * sideTrans = new GeoTransform(GeoTrf::TranslateZ3D(zSideCenter)*GeoTrf::RotateZ3D(angleSide)
231 *GeoTrf::TranslateX3D(midRadius)*oddEvenRotate);
232
233 // Place the sides
234 parent->add(sideTrans);
235 parent->add(sideEnvelopePV);
236 }
237 }
238
239}
void section(const std::string &sec)
bool same(double v1, double v2)
PixelGeometryManager * m_gmt_mgr
InDetMaterialManager * m_mat_mgr
bool first
Definition DeMoScan.py:534

◆ same()

bool GeoPixelFrame::same ( double v1,
double v2 )
private

Definition at line 241 of file GeoPixelFrame.cxx.

242{
243 const double tol = 1e-9;
244 return (std::abs(v1-v2) < tol);
245}

Member Data Documentation

◆ m_DDmgr

InDetDD::PixelDetectorManager* GeoVPixelFactory::m_DDmgr
protectedinherited

Definition at line 45 of file GeoVPixelFactory.h.

◆ m_epsilon

const double GeoVPixelFactory::m_epsilon
protectedinherited

Definition at line 49 of file GeoVPixelFactory.h.

◆ m_gmt_mgr

PixelGeometryManager* GeoVPixelFactory::m_gmt_mgr
protectedinherited

Definition at line 43 of file GeoVPixelFactory.h.

◆ m_mapAX

std::shared_ptr<std::map<std::string, GeoAlignableTransform*> > GeoVPixelFactory::m_mapAX
protectedinherited

Definition at line 48 of file GeoVPixelFactory.h.

◆ m_mapFPV

std::shared_ptr<std::map<std::string, GeoFullPhysVol*> > GeoVPixelFactory::m_mapFPV
protectedinherited

Definition at line 47 of file GeoVPixelFactory.h.

◆ m_mat_mgr

InDetMaterialManager* GeoVPixelFactory::m_mat_mgr
protectedinherited

Definition at line 44 of file GeoVPixelFactory.h.

◆ m_sqliteReader

GeoModelIO::ReadGeoModel* GeoVPixelFactory::m_sqliteReader
protectedinherited

Definition at line 46 of file GeoVPixelFactory.h.


The documentation for this class was generated from the following files: