2424
2525#ifdef ENABLE_UPGRADES
2626#include " ITS3Base/SpecsV2.h"
27- #include " ITS3Base/SegmentationSuperAlpide.h"
28- using SuperSegmentation = o2::its3::SegmentationSuperAlpide;
2927#endif
3028
3129#include < TGeoBBox.h> // for TGeoBBox
@@ -420,33 +418,20 @@ TGeoHMatrix* GeometryTGeo::extractMatrixSensor(int index) const
420418 static int chipInGlo{0 };
421419
422420 // account for the difference between physical sensitive layer (where charge collection is simulated) and effective sensor thicknesses
421+ // in the ITS3 case this accounted by specialized functions
423422 double delta = Segmentation::SensorLayerThickness - Segmentation::SensorLayerThicknessEff;
424- #ifdef ENABLE_UPGRADES
425- if (mIsLayerITS3 [getLayer (index)]) {
426- delta = its3::SegmentationSuperAlpide::mSensorLayerThickness - its3::SegmentationSuperAlpide::mSensorLayerThicknessEff ;
427- }
428- #endif
429-
430423 static TGeoTranslation tra (0 ., 0.5 * delta, 0 .);
431-
424+ #ifdef ENABLE_UPGRADES // only apply for non ITS3 OB layers
425+ if (!mIsLayerITS3 [getLayer (index)]) {
426+ matTmp *= tra;
427+ }
428+ #else
432429 matTmp *= tra;
430+ #endif
433431
434432 return &matTmp;
435433}
436434
437- // __________________________________________________________________________
438- const o2::math_utils::Transform3D GeometryTGeo::getT2LMatrixITS3 (int isn, float alpha)
439- {
440- // create for sensor isn the TGeo matrix for Tracking to Local frame transformations
441- static TGeoHMatrix t2l;
442- t2l.Clear ();
443- t2l.RotateZ (alpha * RadToDeg ()); // rotate in direction of normal to the tangent to the cylinder
444- const TGeoHMatrix& matL2G = getMatrixL2G (isn);
445- const auto & matL2Gi = matL2G.Inverse ();
446- t2l.MultiplyLeft (&matL2Gi);
447- return Mat3D (t2l);
448- }
449-
450435// __________________________________________________________________________
451436void GeometryTGeo::Build (int loadTrans)
452437{
@@ -492,23 +477,6 @@ void GeometryTGeo::Build(int loadTrans)
492477 mLastChipIndex [i] = numberOfChips - 1 ;
493478 }
494479
495- LOGP (debug, " Summary of extracted Geometry:" );
496- LOGP (debug, " There are {} Layers and {} HalfBarrels" , mNumberOfLayers , mNumberOfHalfBarrels );
497- for (int i = 0 ; i < mNumberOfLayers ; i++) {
498- LOGP (debug, " Layer {}: {:*^30}" , i, " START" );
499- LOGP (debug, " - mNumberOfStaves={}" , mNumberOfStaves [i]);
500- LOGP (debug, " - mNumberOfChipsPerStave={}" , mNumberOfChipsPerStave [i]);
501- LOGP (debug, " - mNumberOfHalfStaves={}" , mNumberOfHalfStaves [i]);
502- LOGP (debug, " - mNumberOfChipsPerHalfStave={}" , mNumberOfChipsPerHalfStave [i]);
503- LOGP (debug, " - mNumberOfModules={}" , mNumberOfModules [i]);
504- LOGP (debug, " - mNumberOfChipsPerModules={}" , mNumberOfChipsPerModule [i]);
505- LOGP (debug, " - mNumberOfChipsPerLayer={}" , mNumberOfChipsPerLayer [i]);
506- LOGP (debug, " - mNumberOfChipsPerHalfBarrel={}" , mNumberOfChipsPerHalfBarrel [i]);
507- LOGP (debug, " - mLastChipIndex={}" , mLastChipIndex [i]);
508- LOGP (debug, " Layer {}: {:*^30}" , i, " END" );
509- }
510- LOGP (debug, " In total there {} chips registered" , numberOfChips);
511-
512480#ifdef ENABLE_UPGRADES
513481 if (std::any_of (mIsLayerITS3 .cbegin (), mIsLayerITS3 .cend (), [](auto b) { return b; })) {
514482 LOGP (info, " Found active IT3 layers -> Renaming Detector ITS to IT3" );
@@ -880,34 +848,39 @@ void GeometryTGeo::extractSensorXAlpha(int isn, float& x, float& alp)
880848
881849 const TGeoHMatrix* matL2G = extractMatrixSensor (isn);
882850 double locA[3 ] = {-100 ., 0 ., 0 .}, locB[3 ] = {100 ., 0 ., 0 .}, gloA[3 ], gloB[3 ];
883- int iLayer = getLayer (isn) ;
851+ double xp{ 0 }, yp{ 0 } ;
884852
885853#ifdef ENABLE_UPGRADES
886- if (mIsLayerITS3 [iLayer]) {
887- // We need to calcualte the line tangent at the mid-point in the geometry
854+ if (int iLayer = getLayer (isn); mIsLayerITS3 [iLayer]) {
855+ // For a TGeoTubeSeg the local coordinate system is defined at the origin
856+ // of the circle of the side, since in our implementation we rotated the geometry a bit
888857 const auto radius = o2::its3::constants::radii[iLayer];
889858 const auto phi1 = o2::its3::constants::tile::width / radius;
890859 const auto phi2 = o2::its3::constants::pixelarray::width / radius + phi1;
891860 const auto phi3 = (phi2 - phi1) / 2 .; // mid-point in phi
892- const auto x = radius * std::cos (phi3);
893- const auto y = radius * std::sin (phi3);
894- // For the tangent we make the parametric line equation y = m * x - c
895- const auto m = x / y;
896- const auto c = y - m * x;
897- // Now we can given any x calulate points along this line, we pick points far away,
898- // the calculation of the normal should work then below.
899- locA[1 ] = m * locA[0 ] + c;
900- locB[1 ] = m * locB[0 ] + c;
901- }
902- #endif
903-
861+ locA[0 ] = radius * std::cos (phi3);
862+ locA[1 ] = radius * std::sin (phi3);
863+ matL2G->LocalToMaster (locA, gloA);
864+ xp = gloA[0 ];
865+ yp = gloA[1 ];
866+ } else {
867+ matL2G->LocalToMaster (locA, gloA);
868+ matL2G->LocalToMaster (locB, gloB);
869+ double dx = gloB[0 ] - gloA[0 ], dy = gloB[1 ] - gloA[1 ];
870+ double t = (gloB[0 ] * dx + gloB[1 ] * dy) / (dx * dx + dy * dy);
871+ xp = gloB[0 ] - dx * t;
872+ yp = gloB[1 ] - dy * t;
873+ }
874+ #else // just ITS2 part
904875 matL2G->LocalToMaster (locA, gloA);
905876 matL2G->LocalToMaster (locB, gloB);
906877 double dx = gloB[0 ] - gloA[0 ], dy = gloB[1 ] - gloA[1 ];
907878 double t = (gloB[0 ] * dx + gloB[1 ] * dy) / (dx * dx + dy * dy);
908- double xp = gloB[0 ] - dx * t, yp = gloB[1 ] - dy * t;
909- x = Sqrt (xp * xp + yp * yp);
910- alp = ATan2 (yp, xp);
879+ xp = gloB[0 ] - dx * t;
880+ yp = gloB[1 ] - dy * t;
881+ #endif
882+ x = std::hypot (xp, yp);
883+ alp = std::atan2 (yp, xp);
911884 o2::math_utils::bringTo02Pi (alp);
912885}
913886
@@ -926,6 +899,19 @@ TGeoHMatrix& GeometryTGeo::createT2LMatrix(int isn)
926899 return t2l;
927900}
928901
902+ // __________________________________________________________________________
903+ const o2::math_utils::Transform3D GeometryTGeo::getT2LMatrixITS3 (int isn, float alpha)
904+ {
905+ // create for sensor isn the TGeo matrix for Tracking to Local frame transformations with correction for effective thickness
906+ static TGeoHMatrix t2l;
907+ t2l.Clear ();
908+ t2l.RotateZ (alpha * RadToDeg ()); // rotate in direction of normal to the tangent to the cylinder
909+ const TGeoHMatrix& matL2G = getMatrixL2G (isn);
910+ const auto & matL2Gi = matL2G.Inverse ();
911+ t2l.MultiplyLeft (&matL2Gi);
912+ return Mat3D (t2l);
913+ }
914+
929915// __________________________________________________________________________
930916int GeometryTGeo::extractVolumeCopy (const char * name, const char * prefix) const
931917{
0 commit comments