From f696f3ffc978fb0fc131c839501055154193093b Mon Sep 17 00:00:00 2001 From: Aizat Daribayeva Date: Mon, 27 Oct 2025 19:51:50 +0100 Subject: [PATCH 1/3] additional features added to TRK geometry --- .../TRK/base/include/TRKBase/GeometryTGeo.h | 23 +++- .../ALICE3/TRK/base/src/GeometryTGeo.cxx | 129 +++++++++++++++++- 2 files changed, 150 insertions(+), 2 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h b/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h index 0e9ff8727a977..ee7fa2506968b 100644 --- a/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h +++ b/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h @@ -15,6 +15,7 @@ #include #include #include "DetectorsCommonDataFormats/DetID.h" +#include namespace o2 { @@ -58,7 +59,7 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache int extractNumberOfLayersMLOT(); int extractNumberOfLayersVD() const; int extractNumberOfPetalsVD() const; - int extractNumberOfActivePartsVD() const; + int extractNumberOfActivePartsVD() const; int extractNumberOfDisksVD() const; int extractNumberOfChipsPerPetalVD() const; int extractNumberOfStavesMLOT(int lay) const; @@ -84,6 +85,22 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache int getPetalCase(int index) const; int getDisk(int index) const; + void defineMLOTSensors(); + int getBarrelLayer(int) const; + + //sensor ref X and alpha for ML & OT + void extractSensorXAlphaMLOT(int, float&, float&); + + //cache for tracking frames (ML & OT) + bool isTrackingFrameCachedMLOT() const {return !mCacheRefXMLOT.empty();} + void fillTrackingFramesCacheMLOT(); + + float getSensorRefAlphaMLOT(int index) const {return mCacheRefAlphaMLOT[index];} + float getSensorXMLOT(int index) const {return mCacheRefXMLOT[index];} + + //create matrix for tracking to local frame for MLOT + TGeoHMatrix& createT2LMatrixMLOT(int); + /// This routine computes the chip index number from the subDetID, petal, disk, layer, stave /// TODO: retrieve also from chip when chips will be available /// \param int subDetID The subdetector ID, 0 for VD, 1 for MLOT /// \param int petalcase The petal case number for VD, from 0 to 3 @@ -173,6 +190,10 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache bool mOwner = true; //! is it owned by the singleton? + std::vector sensorsMLOT; + std::vector mCacheRefXMLOT; ///cache for X of ML and OT + std::vector mCacheRefAlphaMLOT; ///cache for sensor ref alpha ML and OT + private: static std::unique_ptr sInstance; }; diff --git a/Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx b/Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx index 9325f5079375d..a11ebdcc7e1ca 100644 --- a/Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx +++ b/Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx @@ -12,6 +12,7 @@ #include #include #include "TRKBase/SegmentationChip.h" +#include using Segmentation = o2::trk::SegmentationChip; @@ -94,7 +95,7 @@ void GeometryTGeo::Build(int loadTrans) int numberOfChipsTotal = 0; /// filling the information for the VD - for (int i = 0; i < mNumberOfPetalsVD; i++) { + for (int i = 0; i < mNumberOfPetalsVD; i++) { mNumberOfChipsPerPetalVD[i] = extractNumberOfChipsPerPetalVD(); numberOfChipsTotal += mNumberOfChipsPerPetalVD[i]; mLastChipIndex[i] = numberOfChipsTotal - 1; @@ -111,6 +112,8 @@ void GeometryTGeo::Build(int loadTrans) setSize(numberOfChipsTotal); /// temporary, number of chips = number of staves and active parts fillMatrixCache(loadTrans); + defineMLOTSensors(); + fillTrackingFramesCacheMLOT(); } //__________________________________________________________________________ @@ -342,6 +345,32 @@ TGeoHMatrix* GeometryTGeo::extractMatrixSensor(int index) const return &matTmp; } +//__________________________________________________________________________ +void GeometryTGeo::defineMLOTSensors() +{ + for(int i=0; i 1) { + LOG(error) << "getBarrelLayer(): Invalid subDetID for barrel: " << subDetID + << ". Expected values are 0 or 1."; + return -1; + } + + if (subLayerID < 0 || subLayerID > 7) { + LOG(error) << "getBarrelLayer(): Invalid subLayerID for barrel: " << subDetID + << ". Expected values are between 0 and 7."; + return -1; + } + + const int baseOffsets[] = {0, 3}; + + return baseOffsets[subDetID] + subLayerID; + +} + +//__________________________________________________________________________ +void GeometryTGeo::extractSensorXAlphaMLOT(int chipID, float& x, float& alp) +{ + //works for ML and OT only, a.k.a flat sensors !!! + double locA[3] = {-100., 0., 0.}, locB[3] = {100., 0., 0.}, gloA[3], gloB[3]; + double xp{0}, yp{0}; + + if(getSubDetID(chipID) == 0){ + + LOG(error) << "extractSensorXAlphaMLOT(): VD layers are not supported yet! chipID = " << chipID; + return; + + } else { //flat sensors, ML and OT + const TGeoHMatrix* matL2G = extractMatrixSensor(chipID); + matL2G->LocalToMaster(locA, gloA); + matL2G->LocalToMaster(locB, gloB); + double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1]; + double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy); + xp = gloB[0] - dx * t; + yp = gloB[1] - dy * t; + } + + alp = std::atan2(yp, xp); + x = std::hypot(xp, yp); + o2::math_utils::bringTo02Pi(alp); + + ///TODO: + //once the VD segmentation is done, VD should be added +} + +//__________________________________________________________________________ +TGeoHMatrix& GeometryTGeo::createT2LMatrixMLOT(int chipID) +{ + //works only for ML & OT + //for VD is yet to be implemented once we have more refined geometry + if(getSubDetID(chipID) == 0){ + + LOG(error) << "createT2LMatrixMLOT(): VD layers are not supported yet! chipID = " << chipID + << "returning dummy values! "; + static TGeoHMatrix dummy; + return dummy; + + } else { + static TGeoHMatrix t2l; + t2l.Clear(); + float alpha = getSensorRefAlphaMLOT(chipID); + t2l.RotateZ(alpha * TMath::RadToDeg()); + const TGeoHMatrix* matL2G = extractMatrixSensor(chipID); + const TGeoHMatrix& matL2Gi = matL2G->Inverse(); + t2l.MultiplyLeft(&matL2Gi); + return t2l; + } +} + } // namespace trk } // namespace o2 From 5a5750ce32862c4fe3c44414daaceb77c82f3cfa Mon Sep 17 00:00:00 2001 From: Aizat Daribayeva Date: Tue, 28 Oct 2025 14:18:01 +0100 Subject: [PATCH 2/3] Fix whitespace and formatting in geometry implementation --- .../TRK/base/include/TRKBase/GeometryTGeo.h | 24 +++---- .../ALICE3/TRK/base/src/GeometryTGeo.cxx | 69 +++++++++---------- 2 files changed, 46 insertions(+), 47 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h b/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h index ee7fa2506968b..a6726fb0c5bcc 100644 --- a/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h +++ b/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h @@ -59,7 +59,7 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache int extractNumberOfLayersMLOT(); int extractNumberOfLayersVD() const; int extractNumberOfPetalsVD() const; - int extractNumberOfActivePartsVD() const; + int extractNumberOfActivePartsVD() const; int extractNumberOfDisksVD() const; int extractNumberOfChipsPerPetalVD() const; int extractNumberOfStavesMLOT(int lay) const; @@ -85,20 +85,20 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache int getPetalCase(int index) const; int getDisk(int index) const; - void defineMLOTSensors(); + void defineMLOTSensors(); int getBarrelLayer(int) const; - //sensor ref X and alpha for ML & OT - void extractSensorXAlphaMLOT(int, float&, float&); + // sensor ref X and alpha for ML & OT + void extractSensorXAlphaMLOT(int, float&, float&); - //cache for tracking frames (ML & OT) - bool isTrackingFrameCachedMLOT() const {return !mCacheRefXMLOT.empty();} + // cache for tracking frames (ML & OT) + bool isTrackingFrameCachedMLOT() const { return !mCacheRefXMLOT.empty(); } void fillTrackingFramesCacheMLOT(); - float getSensorRefAlphaMLOT(int index) const {return mCacheRefAlphaMLOT[index];} - float getSensorXMLOT(int index) const {return mCacheRefXMLOT[index];} + float getSensorRefAlphaMLOT(int index) const { return mCacheRefAlphaMLOT[index]; } + float getSensorXMLOT(int index) const { return mCacheRefXMLOT[index]; } - //create matrix for tracking to local frame for MLOT + // create matrix for tracking to local frame for MLOT TGeoHMatrix& createT2LMatrixMLOT(int); /// This routine computes the chip index number from the subDetID, petal, disk, layer, stave /// TODO: retrieve also from chip when chips will be available @@ -190,9 +190,9 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache bool mOwner = true; //! is it owned by the singleton? - std::vector sensorsMLOT; - std::vector mCacheRefXMLOT; ///cache for X of ML and OT - std::vector mCacheRefAlphaMLOT; ///cache for sensor ref alpha ML and OT + std::vector sensorsMLOT; + std::vector mCacheRefXMLOT; /// cache for X of ML and OT + std::vector mCacheRefAlphaMLOT; /// cache for sensor ref alpha ML and OT private: static std::unique_ptr sInstance; diff --git a/Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx b/Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx index a11ebdcc7e1ca..a48b6af4c6b9a 100644 --- a/Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx +++ b/Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx @@ -95,7 +95,7 @@ void GeometryTGeo::Build(int loadTrans) int numberOfChipsTotal = 0; /// filling the information for the VD - for (int i = 0; i < mNumberOfPetalsVD; i++) { + for (int i = 0; i < mNumberOfPetalsVD; i++) { mNumberOfChipsPerPetalVD[i] = extractNumberOfChipsPerPetalVD(); numberOfChipsTotal += mNumberOfChipsPerPetalVD[i]; mLastChipIndex[i] = numberOfChipsTotal - 1; @@ -348,7 +348,7 @@ TGeoHMatrix* GeometryTGeo::extractMatrixSensor(int index) const //__________________________________________________________________________ void GeometryTGeo::defineMLOTSensors() { - for(int i=0; i 1) { - LOG(error) << "getBarrelLayer(): Invalid subDetID for barrel: " << subDetID + LOG(error) << "getBarrelLayer(): Invalid subDetID for barrel: " << subDetID << ". Expected values are 0 or 1."; - return -1; + return -1; } if (subLayerID < 0 || subLayerID > 7) { - LOG(error) << "getBarrelLayer(): Invalid subLayerID for barrel: " << subDetID + LOG(error) << "getBarrelLayer(): Invalid subLayerID for barrel: " << subDetID << ". Expected values are between 0 and 7."; - return -1; + return -1; } const int baseOffsets[] = {0, 3}; - return baseOffsets[subDetID] + subLayerID; - + return baseOffsets[subDetID] + subLayerID; } //__________________________________________________________________________ -void GeometryTGeo::extractSensorXAlphaMLOT(int chipID, float& x, float& alp) +void GeometryTGeo::extractSensorXAlphaMLOT(int chipID, float& x, float& alp) { - //works for ML and OT only, a.k.a flat sensors !!! + // works for ML and OT only, a.k.a flat sensors !!! double locA[3] = {-100., 0., 0.}, locB[3] = {100., 0., 0.}, gloA[3], gloB[3]; double xp{0}, yp{0}; - if(getSubDetID(chipID) == 0){ - + if (getSubDetID(chipID) == 0) { + LOG(error) << "extractSensorXAlphaMLOT(): VD layers are not supported yet! chipID = " << chipID; return; - } else { //flat sensors, ML and OT + } else { // flat sensors, ML and OT const TGeoHMatrix* matL2G = extractMatrixSensor(chipID); matL2G->LocalToMaster(locA, gloA); matL2G->LocalToMaster(locB, gloB); @@ -1006,20 +1005,20 @@ void GeometryTGeo::extractSensorXAlphaMLOT(int chipID, float& x, float& alp) } alp = std::atan2(yp, xp); - x = std::hypot(xp, yp); + x = std::hypot(xp, yp); o2::math_utils::bringTo02Pi(alp); - ///TODO: - //once the VD segmentation is done, VD should be added + /// TODO: + // once the VD segmentation is done, VD should be added } //__________________________________________________________________________ TGeoHMatrix& GeometryTGeo::createT2LMatrixMLOT(int chipID) { - //works only for ML & OT - //for VD is yet to be implemented once we have more refined geometry - if(getSubDetID(chipID) == 0){ - + // works only for ML & OT + // for VD is yet to be implemented once we have more refined geometry + if (getSubDetID(chipID) == 0) { + LOG(error) << "createT2LMatrixMLOT(): VD layers are not supported yet! chipID = " << chipID << "returning dummy values! "; static TGeoHMatrix dummy; @@ -1029,13 +1028,13 @@ TGeoHMatrix& GeometryTGeo::createT2LMatrixMLOT(int chipID) static TGeoHMatrix t2l; t2l.Clear(); float alpha = getSensorRefAlphaMLOT(chipID); - t2l.RotateZ(alpha * TMath::RadToDeg()); + t2l.RotateZ(alpha * TMath::RadToDeg()); const TGeoHMatrix* matL2G = extractMatrixSensor(chipID); const TGeoHMatrix& matL2Gi = matL2G->Inverse(); t2l.MultiplyLeft(&matL2Gi); return t2l; } } - + } // namespace trk } // namespace o2 From c74725fbaef8b26fd09929bd53a9b24d09c43808 Mon Sep 17 00:00:00 2001 From: Aizat Daribayeva Date: Tue, 28 Oct 2025 16:17:05 +0100 Subject: [PATCH 3/3] minor corrections --- .../Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h b/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h index a6726fb0c5bcc..8cc9a7c19e981 100644 --- a/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h +++ b/Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h @@ -15,7 +15,6 @@ #include #include #include "DetectorsCommonDataFormats/DetID.h" -#include namespace o2 { @@ -200,4 +199,4 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache } // namespace trk } // namespace o2 -#endif \ No newline at end of file +#endif