@@ -27,6 +27,13 @@ namespace o2
2727{
2828namespace trk
2929{
30+
31+ // Helper function for floating point comparison
32+ inline bool isFullCircle (double phiSpanDeg, double epsilon = 0.005 )
33+ {
34+ return (std::fabs (phiSpanDeg - 360.0 ) < epsilon);
35+ }
36+
3037// Base layer constructor
3138VDLayer::VDLayer (int layerNumber, const std::string& layerName, double layerX2X0)
3239 : mLayerNumber (layerNumber), mLayerName (layerName), mX2X0 (layerX2X0), mModuleWidth (4.54 )
@@ -88,8 +95,13 @@ TGeoVolume* VDCylindricalLayer::createSensor() const
8895 const double rIn = mRadius ;
8996 const double rOut = mRadius + mSensorThickness ;
9097 const double halfZ = 0.5 * mLengthSensZ ;
91- const double halfPhi = 0.5 * mPhiSpanDeg ; // degrees
92- auto * shape = new TGeoTubeSeg (rIn, rOut, halfZ, -halfPhi, +halfPhi);
98+ TGeoShape* shape;
99+ if (isFullCircle (mPhiSpanDeg )) {
100+ shape = new TGeoTube (rIn, rOut, halfZ);
101+ } else {
102+ const double halfPhi = 0.5 * mPhiSpanDeg ; // degrees
103+ shape = new TGeoTubeSeg (rIn, rOut, halfZ, -halfPhi, +halfPhi);
104+ }
93105 auto * vol = new TGeoVolume (sensName.c_str (), shape, medSi);
94106 vol->SetLineColor (kYellow );
95107 vol->SetTransparency (30 );
@@ -138,10 +150,15 @@ TGeoVolume* VDDiskLayer::createSensor() const
138150 }
139151 std::string sensName = Form (" %s_%s%d" , this ->mLayerName .c_str (), GeometryTGeo::getTRKSensorPattern (), this ->mLayerNumber );
140152 const double halfThickness = 0.5 * mSensorThickness ; // active sensor thickness along Z
141- const double halfPhi = 0.5 * mPhiSpanDeg ; // degrees
142153
143154 // Same geometry as the layer (identical radii + phi span + thickness)
144- auto * shape = new TGeoTubeSeg (mRMin , mRMax , halfThickness, -halfPhi, +halfPhi);
155+ TGeoShape* shape;
156+ if (isFullCircle (mPhiSpanDeg )) {
157+ shape = new TGeoTube (mRMin , mRMax , halfThickness);
158+ } else {
159+ const double halfPhi = 0.5 * mPhiSpanDeg ; // degrees
160+ shape = new TGeoTubeSeg (mRMin , mRMax , halfThickness, -halfPhi, +halfPhi);
161+ }
145162
146163 auto * sensVol = new TGeoVolume (sensName.c_str (), shape, medSi);
147164 sensVol->SetLineColor (kYellow );
@@ -177,9 +194,14 @@ TGeoVolume* VDCylindricalLayer::createMetalStack() const
177194 const double rIn = mRadius + mSensorThickness ;
178195 const double rOut = mRadius + mChipThickness ;
179196 const double halfZ = 0.5 * mLengthSensZ ;
180- const double halfPhi = 0.5 * mPhiSpanDeg ;
181197
182- auto * shape = new TGeoTubeSeg (rIn, rOut, halfZ, -halfPhi, +halfPhi);
198+ TGeoShape* shape;
199+ if (isFullCircle (mPhiSpanDeg )) {
200+ shape = new TGeoTube (rIn, rOut, halfZ);
201+ } else {
202+ const double halfPhi = 0.5 * mPhiSpanDeg ;
203+ shape = new TGeoTubeSeg (rIn, rOut, halfZ, -halfPhi, +halfPhi);
204+ }
183205 auto * vol = new TGeoVolume (name.c_str (), shape, medSi);
184206 vol->SetLineColor (kGray );
185207 vol->SetTransparency (30 );
@@ -244,9 +266,14 @@ TGeoVolume* VDDiskLayer::createMetalStack() const
244266 GeometryTGeo::getTRKMetalStackPattern (), mLayerNumber );
245267
246268 const double halfThickness = 0.5 * metalT;
247- const double halfPhi = 0.5 * mPhiSpanDeg ;
248269
249- auto * shape = new TGeoTubeSeg (mRMin , mRMax , halfThickness, -halfPhi, +halfPhi);
270+ TGeoShape* shape;
271+ if (isFullCircle (mPhiSpanDeg )) {
272+ shape = new TGeoTube (mRMin , mRMax , halfThickness);
273+ } else {
274+ const double halfPhi = 0.5 * mPhiSpanDeg ;
275+ shape = new TGeoTubeSeg (mRMin , mRMax , halfThickness, -halfPhi, +halfPhi);
276+ }
250277 auto * vol = new TGeoVolume (name.c_str (), shape, medSi);
251278 vol->SetLineColor (kGray );
252279 vol->SetTransparency (30 );
@@ -275,9 +302,14 @@ TGeoVolume* VDCylindricalLayer::createChip() const
275302 const double rIn = mRadius ;
276303 const double rOut = mRadius + mChipThickness ;
277304 const double halfZ = 0.5 * mLengthSensZ ;
278- const double halfPhi = 0.5 * mPhiSpanDeg ;
279305
280- auto * chipShape = new TGeoTubeSeg (rIn, rOut, halfZ, -halfPhi, +halfPhi);
306+ TGeoShape* chipShape;
307+ if (isFullCircle (mPhiSpanDeg )) {
308+ chipShape = new TGeoTube (rIn, rOut, halfZ);
309+ } else {
310+ const double halfPhi = 0.5 * mPhiSpanDeg ;
311+ chipShape = new TGeoTubeSeg (rIn, rOut, halfZ, -halfPhi, +halfPhi);
312+ }
281313 auto * chipVol = new TGeoVolume (chipName.c_str (), chipShape, medSi);
282314
283315 // sensor
@@ -361,9 +393,14 @@ TGeoVolume* VDDiskLayer::createChip() const
361393 GeometryTGeo::getTRKChipPattern (), mLayerNumber );
362394
363395 const double halfThickness = 0.5 * mChipThickness ;
364- const double halfPhi = 0.5 * mPhiSpanDeg ;
365396
366- auto * chipShape = new TGeoTubeSeg (mRMin , mRMax , halfThickness, -halfPhi, +halfPhi);
397+ TGeoShape* chipShape;
398+ if (isFullCircle (mPhiSpanDeg )) {
399+ chipShape = new TGeoTube (mRMin , mRMax , halfThickness);
400+ } else {
401+ const double halfPhi = 0.5 * mPhiSpanDeg ;
402+ chipShape = new TGeoTubeSeg (mRMin , mRMax , halfThickness, -halfPhi, +halfPhi);
403+ }
367404 auto * chipVol = new TGeoVolume (chipName.c_str (), chipShape, medSi);
368405 chipVol->SetLineColor (kYellow );
369406 chipVol->SetTransparency (30 );
@@ -417,9 +454,14 @@ void VDCylindricalLayer::createLayer(TGeoVolume* motherVolume, TGeoMatrix* combi
417454 const double rIn = mRadius ;
418455 const double rOut = mRadius + mChipThickness ;
419456 const double halfZ = 0.5 * mLengthZ ;
420- const double halfPhi = 0.5 * mPhiSpanDeg ; // degrees
421457
422- auto * layerShape = new TGeoTubeSeg (rIn, rOut, halfZ, -halfPhi, +halfPhi);
458+ TGeoShape* layerShape;
459+ if (isFullCircle (mPhiSpanDeg )) {
460+ layerShape = new TGeoTube (rIn, rOut, halfZ);
461+ } else {
462+ const double halfPhi = 0.5 * mPhiSpanDeg ; // degrees
463+ layerShape = new TGeoTubeSeg (rIn, rOut, halfZ, -halfPhi, +halfPhi);
464+ }
423465 auto * layerVol = new TGeoVolume (mLayerName .c_str (), layerShape, medAir);
424466 layerVol->SetLineColor (kYellow );
425467 layerVol->SetTransparency (30 );
@@ -523,10 +565,15 @@ void VDDiskLayer::createLayer(TGeoVolume* motherVolume, TGeoMatrix* combiTrans)
523565
524566 // For disks the thickness is along Z and equals mChipThickness
525567 const double halfThickness = 0.5 * mChipThickness ;
526- const double halfPhi = 0.5 * mPhiSpanDeg ;
527568
528569 // AIR container (layer)
529- auto * layerShape = new TGeoTubeSeg (mRMin , mRMax , halfThickness, -halfPhi, +halfPhi);
570+ TGeoShape* layerShape;
571+ if (isFullCircle (mPhiSpanDeg )) {
572+ layerShape = new TGeoTube (mRMin , mRMax , halfThickness);
573+ } else {
574+ const double halfPhi = 0.5 * mPhiSpanDeg ;
575+ layerShape = new TGeoTubeSeg (mRMin , mRMax , halfThickness, -halfPhi, +halfPhi);
576+ }
530577 auto * layerVol = new TGeoVolume (mLayerName .c_str (), layerShape, medAir);
531578 layerVol->SetLineColor (kYellow );
532579 layerVol->SetTransparency (30 );
0 commit comments