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

#include <TrackingVolumeToSoNode.h>

Collaboration diagram for TrackingVolumeToSoNode:

Public Member Functions

 TrackingVolumeToSoNode ()
virtual ~TrackingVolumeToSoNode ()
SoNode * translateTrackingVolume (const Trk::TrackingVolume &tvol) const

Private Member Functions

const GeoShape * getShapeFromBounds (const Trk::VolumeBounds *volBounds) const

Detailed Description

Definition at line 28 of file TrackingVolumeToSoNode.h.

Constructor & Destructor Documentation

◆ TrackingVolumeToSoNode()

TrackingVolumeToSoNode::TrackingVolumeToSoNode ( )

Definition at line 51 of file TrackingVolumeToSoNode.cxx.

52{
55}
static void initClass()
static void initClass()
Class Initializer, required.
Definition SoTubs.cxx:63

◆ ~TrackingVolumeToSoNode()

TrackingVolumeToSoNode::~TrackingVolumeToSoNode ( )
virtualdefault

Member Function Documentation

◆ getShapeFromBounds()

const GeoShape * TrackingVolumeToSoNode::getShapeFromBounds ( const Trk::VolumeBounds * volBounds) const
private

Definition at line 212 of file TrackingVolumeToSoNode.cxx.

213{
214 const GeoShape* sh=nullptr;
215 // cast bounds
216 const Trk::CylinderVolumeBounds* tvolCylBounds = dynamic_cast<const Trk::CylinderVolumeBounds*>(tvolBounds);
217 const Trk::CuboidVolumeBounds* tvolCubBounds = dynamic_cast<const Trk::CuboidVolumeBounds*>(tvolBounds);
218 const Trk::TrapezoidVolumeBounds* tvolTrdBounds = dynamic_cast<const Trk::TrapezoidVolumeBounds*>(tvolBounds);
219 //const Trk::DoubleTrapezoidVolumeBounds* tvolDTrdBounds = dynamic_cast<const Trk::DoubleTrapezoidVolumeBounds*>(tvolBounds);
220 const Trk::BevelledCylinderVolumeBounds* tvolBevCylBounds = dynamic_cast<const Trk::BevelledCylinderVolumeBounds*>(tvolBounds);
221 const Trk::SubtractedVolumeBounds* tvolSubtrBounds = dynamic_cast<const Trk::SubtractedVolumeBounds*>(tvolBounds);
222 const Trk::CombinedVolumeBounds* tvolCombBounds = dynamic_cast<const Trk::CombinedVolumeBounds*>(tvolBounds);
223 const Trk::SimplePolygonBrepVolumeBounds* tvolSpbBounds = dynamic_cast<const Trk::SimplePolygonBrepVolumeBounds*>(tvolBounds);
224
225 if (tvolSpbBounds) {
226
227 GeoSimplePolygonBrep* shape = new GeoSimplePolygonBrep(tvolSpbBounds->halflengthZ());
228 for (unsigned int i=0;i<tvolSpbBounds->xyVertices().size();i++)
229 shape->addVertex(tvolSpbBounds->xyVertices()[i].first,tvolSpbBounds->xyVertices()[i].second);
230
231 return shape;
232 }
233
234 if (tvolCylBounds){
235 // the Tube Node
236 const GeoTube* tube = new GeoTube(tvolCylBounds->innerRadius(),
237 tvolCylBounds->outerRadius(),
238 tvolCylBounds->halflengthZ() );
239 return tube;
240 }
241 if (tvolCubBounds){
242 // the Cube Node
243 const GeoBox* box = new GeoBox(tvolCubBounds->halflengthX(),
244 tvolCubBounds->halflengthY(),
245 tvolCubBounds->halflengthZ());
246 return box;
247 }
248 if (tvolTrdBounds) {
249 // the Trapezoid Node
250
251 const GeoTrd* trd = new GeoTrd(tvolTrdBounds->halflengthY(),
252 tvolTrdBounds->halflengthY(),
253 tvolTrdBounds->minHalflengthX(),
254 tvolTrdBounds->maxHalflengthX(),
255 tvolTrdBounds->halflengthZ());
256
257
258 return trd;
259 }
260
261 if (tvolBevCylBounds) {
262 // bevelled cylinder: define subtracted shape and let GeoModel to process it
263 double innerR = tvolBevCylBounds->innerRadius();
264 double outerR = tvolBevCylBounds->outerRadius();
265 double halfZ = tvolBevCylBounds->halflengthZ();
266 double thPlus = tvolBevCylBounds->thetaPlus();
267 double thMinus= tvolBevCylBounds->thetaMinus();
268 const GeoTube* tub = new GeoTube(innerR, outerR, halfZ);
269 GeoTrf::Transform3D trBoxP = GeoTrf::TranslateZ3D(+halfZ)*GeoTrf::RotateY3D(thPlus);
270 const GeoShapeShift* boxP = new GeoShapeShift(new GeoBox(2*outerR/cos(thPlus),outerR ,outerR*sin(thPlus)),trBoxP);
271 GeoTrf::Transform3D trBoxM = GeoTrf::TranslateZ3D(-halfZ)*GeoTrf::RotateY3D(-thMinus);
272 const GeoShapeShift* boxM = new GeoShapeShift(new GeoBox(2*outerR/cos(thPlus),outerR ,outerR*sin(thPlus)),trBoxM);
273 const GeoShapeSubtraction* shape= new GeoShapeSubtraction( new GeoShapeSubtraction(tub,boxM), boxP);
274
275 return shape;
276 }
277
278 if (tvolSubtrBounds) {
279
280 const Trk::VolumeBounds* vb1 = &(tvolSubtrBounds->outer()->volumeBounds());
281 const Trk::VolumeBounds* vb2 = &(tvolSubtrBounds->inner()->volumeBounds());
282 const Trk::TrapezoidVolumeBounds* tr1 = dynamic_cast<const Trk::TrapezoidVolumeBounds*> (vb1);
283 const Trk::TrapezoidVolumeBounds* tr2 = dynamic_cast<const Trk::TrapezoidVolumeBounds*> (vb2);
284 Amg::Transform3D transf1 = tvolSubtrBounds->outer()->transform();
285 Amg::Transform3D transf2 = tvolSubtrBounds->inner()->transform();
286 if (tr1) {
287 Trk::TrapezoidVolumeBounds* ntr = new Trk::TrapezoidVolumeBounds(tr1->minHalflengthX(),tr1->maxHalflengthX(),
288 tr1->halflengthZ(),tr1->halflengthY());
289 vb1 = ntr;
290 transf1 = transf1 * Amg::getRotateX3D(-90*Gaudi::Units::deg) * Amg::getRotateZ3D(-90*Gaudi::Units::deg);
291 }
292 if (tr2) {
293 Trk::TrapezoidVolumeBounds* ntr = new Trk::TrapezoidVolumeBounds(tr2->minHalflengthX(),tr2->maxHalflengthX(),
294 tr2->halflengthZ(),tr2->halflengthY());
295 vb2 = ntr;
296 transf2 = transf2 * Amg::getRotateX3D(-90*Gaudi::Units::deg) * Amg::getRotateZ3D(-90*Gaudi::Units::deg);
297 }
298 const GeoShape* shape1 = getShapeFromBounds(vb1);
299 const GeoShape* shape2 = getShapeFromBounds(vb2);
300 const GeoShapeShift* shift1 = new GeoShapeShift(shape1, transf1);
301 const GeoShapeShift* shift2 = new GeoShapeShift(shape2, transf2);
302 const GeoShapeSubtraction* subtr= new GeoShapeSubtraction(shift1, shift2);
303 return subtr;
304 }
305
306 if (tvolCombBounds) {
307 const Trk::VolumeBounds* vb1 = &(tvolCombBounds->first()->volumeBounds());
308 const Trk::VolumeBounds* vb2 = &(tvolCombBounds->second()->volumeBounds());
309 const Trk::TrapezoidVolumeBounds* tr1 = dynamic_cast<const Trk::TrapezoidVolumeBounds*> (vb1);
310 const Trk::TrapezoidVolumeBounds* tr2 = dynamic_cast<const Trk::TrapezoidVolumeBounds*> (vb2);
311 Amg::Transform3D transf1 = tvolCombBounds->first()->transform();
312 Amg::Transform3D transf2 = tvolCombBounds->second()->transform();
313 if (tr1) {
314 Trk::TrapezoidVolumeBounds* ntr = new Trk::TrapezoidVolumeBounds(tr1->minHalflengthX(),tr1->maxHalflengthX(),
315 tr1->halflengthZ(),tr1->halflengthY());
316 vb1 = ntr;
317 transf1 = transf1*Amg::getRotateX3D(-90*Gaudi::Units::deg)*Amg::getRotateZ3D(-90*Gaudi::Units::deg);
318 }
319 if (tr2) {
320 Trk::TrapezoidVolumeBounds* ntr = new Trk::TrapezoidVolumeBounds(tr2->minHalflengthX(),tr2->maxHalflengthX(),
321 tr2->halflengthZ(),tr2->halflengthY());
322 vb2 = ntr;
323 transf2 = transf2*Amg::getRotateX3D(-90*Gaudi::Units::deg)*Amg::getRotateZ3D(-90*Gaudi::Units::deg);
324 }
325 const GeoShape* shape1 = getShapeFromBounds(vb1);
326 const GeoShape* shape2 = getShapeFromBounds(vb2);
327 const GeoShapeShift* shift1 = new GeoShapeShift(shape1,transf1);
328 const GeoShapeShift* shift2 = new GeoShapeShift(shape2,transf2);
329 if (tvolCombBounds->intersection()) {
330 const GeoShapeIntersection* intersection= new GeoShapeIntersection( shift1, shift2);
331 return intersection;
332 }
333 const GeoShapeUnion* uni= new GeoShapeUnion( shift1, shift2);
334 return uni;
335 }
336
337 std::cout << "TrackingVolumeToSoNode::getShapeFromBounds: bounds not recognized" << std::endl;
338
339 return sh;
340}
const GeoShape * getShapeFromBounds(const Trk::VolumeBounds *volBounds) const
double thetaPlus() const
This method returns the thetaPlus.
double halflengthZ() const
This method returns the halflengthZ.
double innerRadius() const
This method returns the inner radius.
double outerRadius() const
This method returns the outer radius.
double thetaMinus() const
This method returns the thetaMinus.
const Volume * second() const
This method returns the second VolumeBounds.
const Volume * first() const
This method returns the first VolumeBounds.
bool intersection() const
This method distinguishes between Union(0) and Intersection(1)
double halflengthX() const
This method returns the halflength in local x.
double halflengthY() const
This method returns the halflength in local y.
double halflengthZ() const
This method returns the halflength in local z.
double innerRadius() const
This method returns the inner radius.
double halflengthZ() const
This method returns the halflengthZ.
double outerRadius() const
This method returns the outer radius.
double halflengthZ() const
This method returns the halflength in local z.
const std::vector< std::pair< double, double > > & xyVertices() const
This method returns the set of xy generating vertices.
const Volume * inner() const
This method returns the inner Volume.
const Volume * outer() const
This method returns the outer Volume.
double halflengthZ() const
This method returns the halflength in local z.
double minHalflengthX() const
This method returns the minimal halflength in local x.
double halflengthY() const
This method returns the halflength in local y.
double maxHalflengthX() const
This method returns the maximal halflength in local x.
const Amg::Transform3D & transform() const
Return methods for geometry transform.
Definition Volume.h:83
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
Amg::Transform3D getRotateX3D(double angle)
get a rotation transformation around X-axis
Amg::Transform3D getRotateZ3D(double angle)
get a rotation transformation around Z-axis
Eigen::Affine3d Transform3D
double halfZ(const Acts::VolumeBounds &bounds)
Returns the half-Z length for the parsed volume bounds (Trapezoid/ Cuboid)

◆ translateTrackingVolume()

SoNode * TrackingVolumeToSoNode::translateTrackingVolume ( const Trk::TrackingVolume & tvol) const

Definition at line 60 of file TrackingVolumeToSoNode.cxx.

60 {
61
62 //Fixme: We need to add a transformation also.
63
64 SoNode* sovol = nullptr;
65
66 // get the surface bounds
67 const Trk::VolumeBounds& tvolBounds = tvol.volumeBounds();
68
69 const Trk::SimplePolygonBrepVolumeBounds* tvolSpbBounds = dynamic_cast<const Trk::SimplePolygonBrepVolumeBounds*>(&tvolBounds);
70 if (tvolSpbBounds) {
71
72 // tvolBounds = &( (tvolSpbBounds->combinedVolume())->volumeBounds() );
73 GeoSimplePolygonBrep* shape = new GeoSimplePolygonBrep(tvolSpbBounds->halflengthZ());
74 for (unsigned int i=0;i<tvolSpbBounds->xyVertices().size();i++)
75 shape->addVertex(tvolSpbBounds->xyVertices()[i].first,tvolSpbBounds->xyVertices()[i].second);
76
77 SoVisualizeAction* sa = new SoVisualizeAction();
78 sa->handleShape(shape);
79 sovol = sa->getShape();
80
81 }
82
83 const Trk::SubtractedVolumeBounds* tvolSubtrBounds = dynamic_cast<const Trk::SubtractedVolumeBounds*>(&tvolBounds);
84 if (tvolSubtrBounds) {
85
86 const GeoShape* shape = getShapeFromBounds(tvolSubtrBounds);
87
88 SoVisualizeAction* sa = new SoVisualizeAction();
89 sa->handleShape(shape);
90 sovol = sa->getShape();
91 }
92
93 const Trk::CombinedVolumeBounds* tvolCombBounds = dynamic_cast<const Trk::CombinedVolumeBounds*>(&tvolBounds);
94 if (tvolCombBounds) {
95
96 const GeoShape* shape = getShapeFromBounds(tvolCombBounds);
97
98 SoVisualizeAction* sa = new SoVisualizeAction();
99 sa->handleShape(shape);
100 sovol = sa->getShape();
101 }
102
103 const Trk::CylinderVolumeBounds* tvolCylBounds = dynamic_cast<const Trk::CylinderVolumeBounds*>(&tvolBounds);
104 if (tvolCylBounds){
105 // the Tubs Node
106 SoTubs* tvolTubs = new SoTubs();
107 (*tvolTubs).pRMin = tvolCylBounds->innerRadius();
108 (*tvolTubs).pRMax = tvolCylBounds->outerRadius();
109 (*tvolTubs).pDz = tvolCylBounds->halflengthZ();
110 (*tvolTubs).pDPhi = 2*tvolCylBounds->halfPhiSector();
111 (*tvolTubs).pSPhi = -tvolCylBounds->halfPhiSector();
112
113 sovol = tvolTubs;
114 }
115 const Trk::CuboidVolumeBounds* tvolCubBounds = dynamic_cast<const Trk::CuboidVolumeBounds*>(&tvolBounds);
116 if (tvolCubBounds){
117 // A Cube
118 SoGenericBox * gb = new SoGenericBox;
119 gb->setParametersForBox( tvolCubBounds->halflengthX(),tvolCubBounds->halflengthY(),tvolCubBounds->halflengthZ());
120
121 sovol = gb;
122 }
123 const Trk::TrapezoidVolumeBounds* tvolTrdBounds = dynamic_cast<const Trk::TrapezoidVolumeBounds*>(&tvolBounds);
124 if (tvolTrdBounds) {
125 // A Trapezoid
126 const double minHalfX(tvolTrdBounds->minHalflengthX()), maxHalfX(tvolTrdBounds->maxHalflengthX()),
127 halfY(tvolTrdBounds->halflengthY()), halfZ(tvolTrdBounds->halflengthZ());
128 SoGenericBox * gb = new SoGenericBox;
129 gb->setParametersForTrapezoid( halfZ/*dz*/, 0/*theta*/, 0/*phi*/, halfY/*dy1*/,
130 minHalfX/*dx1*/, maxHalfX/*dx2*/, halfY/*dy2*/, minHalfX/*dx3*/,
131 maxHalfX/*dx4*/, 0/*alp1*/, 0/*alp2*/ );
132
133 sovol = gb;
134 }
135
136 const Trk::DoubleTrapezoidVolumeBounds* tvolDTrdBounds = dynamic_cast<const Trk::DoubleTrapezoidVolumeBounds*>(&tvolBounds);
137 if (tvolDTrdBounds) {
138 double minX = tvolDTrdBounds->minHalflengthX();
139 double medX = tvolDTrdBounds->medHalflengthX();
140 double maxX = tvolDTrdBounds->maxHalflengthX();
141 double y1 = tvolDTrdBounds->halflengthY1();
142 double y2 = tvolDTrdBounds->halflengthY2();
143 double z = tvolDTrdBounds->halflengthZ();
144 Trk::TrapezoidVolumeBounds* trBoundA = new Trk::TrapezoidVolumeBounds(minX,medX,z,y1);
145 Trk::TrapezoidVolumeBounds* trBoundB = new Trk::TrapezoidVolumeBounds(medX,maxX,z,y2);
146 const GeoShape* trdA = getShapeFromBounds( trBoundA );
147 const GeoShape* trdB = getShapeFromBounds( trBoundB );
148 const GeoShapeShift* shiftA = new GeoShapeShift(trdA,GeoTrf::TranslateY3D(-y1)*GeoTrf::RotateX3D(-90*CLHEP::deg)*GeoTrf::RotateZ3D(-90*CLHEP::deg));
149 const GeoShapeShift* shiftB = new GeoShapeShift(trdB,GeoTrf::TranslateY3D(+y2)*GeoTrf::RotateX3D(-90*CLHEP::deg)*GeoTrf::RotateZ3D(-90*CLHEP::deg));
150 const GeoShapeUnion* dtrd = new GeoShapeUnion(shiftA,shiftB);
151
152 SoVisualizeAction* sa = new SoVisualizeAction();
153 sa->handleShape(dtrd);
154 sovol = sa->getShape();
155 }
156
157 const Trk::BevelledCylinderVolumeBounds* tvolBevCylBounds = dynamic_cast<const Trk::BevelledCylinderVolumeBounds*>(&tvolBounds);
158 if (tvolBevCylBounds) {
159 // the Tubs Node
160 int type = tvolBevCylBounds->type();
161 double hPhi = tvolBevCylBounds->halfPhiSector();
162 double tp = tan(hPhi);
163 double innerR = tvolBevCylBounds->innerRadius();
164 double outerR = tvolBevCylBounds->outerRadius();
165 double hZ = tvolBevCylBounds->halflengthZ();
166 if (type<1) {
167 SoTubs* tvolTubs = new SoTubs();
168 (*tvolTubs).pRMin = innerR;
169 (*tvolTubs).pRMax = outerR;
170 (*tvolTubs).pDz = hZ;
171 (*tvolTubs).pDPhi = 2*hPhi;
172 (*tvolTubs).pSPhi = -hPhi;
173 sovol = tvolTubs;
174 } else if ( type==1 ) {
175 const GeoTubs* tubs = new GeoTubs(innerR,outerR,hZ,-hPhi,2*hPhi);
176 const GeoBox* box = new GeoBox( innerR, tp*innerR, hZ);
177 const GeoShapeSubtraction* sub = new GeoShapeSubtraction(tubs,new GeoShapeShift(box,GeoTrf::Transform3D::Identity()));
178 SoVisualizeAction* sa = new SoVisualizeAction();
179 sa->handleShape(sub);
180 sovol = sa->getShape();
181 } else if ( type==2 ) {
182 const GeoTubs* tubs = new GeoTubs(innerR,outerR/cos(hPhi),hZ,-hPhi,2*hPhi);
183 const GeoBox* box = new GeoBox( outerR*(1./cos(hPhi)-1.),tp*outerR,hZ );
184 const GeoShapeSubtraction* sub = new GeoShapeSubtraction(tubs,new GeoShapeShift(box,GeoTrf::TranslateX3D(outerR/cos(hPhi))));
185 SoVisualizeAction* sa = new SoVisualizeAction();
186 sa->handleShape(sub);
187 sovol = sa->getShape();
188 } else if ( type==3 ) {
189 const GeoTubs* tubs = new GeoTubs(innerR,outerR/cos(hPhi),hZ,-hPhi,2*hPhi);
190 const GeoBox* boxO = new GeoBox( outerR*(1./cos(hPhi)-1.),tp*outerR,hZ );
191 const GeoBox* boxI = new GeoBox( innerR, tp*innerR, hZ);
192 const GeoShapeUnion* uni = new GeoShapeUnion(boxI,new GeoShapeShift(boxO,GeoTrf::TranslateX3D(outerR/cos(hPhi))));
193 const GeoShapeSubtraction* sub = new GeoShapeSubtraction(tubs,uni);
194 SoVisualizeAction* sa = new SoVisualizeAction();
195 sa->handleShape(sub);
196 sovol = sa->getShape();
197 }
198 }
199
200 if (!sovol) return nullptr;
201
202 // place and transform them
203 SoSeparator* sosep = new SoSeparator();
204 SoTransform* sotra = VP1LinAlgUtils::toSoTransform(tvol.transform());
205 sosep->addChild(sotra);
206 sosep->addChild(sovol);
207
208 return sosep;
209
210}
#define z
void setParametersForBox(float dx, float dy, float dz, float xcenter=0.0, float ycenter=0.0, float zcenter=0.0)
void setParametersForTrapezoid(float dz, float theta, float phi, float dy1, float dx1, float dx2, float dy2, float dx3, float dx4, float alp1, float alp2)
virtual void handleShape(const GeoShape *subtract)
int type() const
This method returns the type.
double halfPhiSector() const
This method returns the halfPhiSector angle.
double halfPhiSector() const
This method returns the halfPhiSector angle.
double minHalflengthX() const
This method returns the X halflength at minimal Y.
double halflengthZ() const
This method returns the halflength in local z.
double halflengthY1() const
This method returns the halflength1 in local y.
double halflengthY2() const
This method returns the halflength2 in local y.
double maxHalflengthX() const
This method returns the X halflength at maximal Y (local coordinates)
double medHalflengthX() const
This method returns the (maximal) halflength in local x.
const VolumeBounds & volumeBounds() const
returns the volumeBounds()
Definition Volume.h:96
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
double halfY(const Acts::VolumeBounds &bounds)
Returns the half-Y length for the parsed volume bounds (Trapezoid/ Cuboid)

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