From ca1a86a9c0912d9cc368a7f013bd8cb2af695b08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 31 Mar 2026 10:50:59 +0200 Subject: [PATCH 1/4] [ALICE3] IOTOF: Add geometry macros --- .../Upgrades/ALICE3/IOTOF/CMakeLists.txt | 3 +- .../ALICE3/IOTOF/macros/CMakeLists.txt | 13 ++ .../ALICE3/IOTOF/macros/defineIOTOFGeo.C | 129 ++++++++++++++++++ 3 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 Detectors/Upgrades/ALICE3/IOTOF/macros/CMakeLists.txt create mode 100644 Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C diff --git a/Detectors/Upgrades/ALICE3/IOTOF/CMakeLists.txt b/Detectors/Upgrades/ALICE3/IOTOF/CMakeLists.txt index 83838a01d13f1..808320bf66404 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/IOTOF/CMakeLists.txt @@ -10,4 +10,5 @@ # or submit itself to any jurisdiction. add_subdirectory(base) -add_subdirectory(simulation) \ No newline at end of file +add_subdirectory(simulation) +add_subdirectory(macros) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/macros/CMakeLists.txt b/Detectors/Upgrades/ALICE3/IOTOF/macros/CMakeLists.txt new file mode 100644 index 0000000000000..b2f1857186c0b --- /dev/null +++ b/Detectors/Upgrades/ALICE3/IOTOF/macros/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +o2_add_test_root_macro(defineIOTOFGeo.C + LABELS alice3) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C b/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C new file mode 100644 index 0000000000000..4f97a6e30c830 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C @@ -0,0 +1,129 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void defineIOTOFGeo(const double rAvg = 21, // cm, average radius of the layer (used for stave size calculations) + const int nStaves = 24, // Number of staves + const double staveWidth = 5.42, // cm, Stave width (arc length at avg radius at 0 degrees) + const double staveHeightX2X0 = 0.02, // Stave height (radial at 0 degrees) + const double staveTilt = 10 // Stave tilt angle in degrees +) +{ + const double Si_X0 = 9.5f; // cm, radiation length of silicon + const double staveHeight = staveHeightX2X0 * Si_X0; + + + // 1. Define inner and outer radii for the disk. + // The radius corresponds to the distance of the center of the stave to the origin + const double rInner = rAvg - staveHeight / 2.0; + const double rOuter = rAvg + staveHeight / 2.0; + + const double alpha = staveTilt * TMath::DegToRad(); // Tilt angle in radians + const double H = staveHeight; + const double W = staveWidth; + + // 2. Analytical calculation of Inscribed and Outscribed Radii + // We project the global origin (0,0) into the local, unrotated coordinate + // system of a single stave centered at (0,0). + const double u0 = -rAvg * TMath::Cos(alpha); + const double v0 = rAvg * TMath::Sin(alpha); + + // Inscribed Radius: Distance to the closest point on the stave rectangle + const double uc = std::max(-H / 2.0, std::min(H / 2.0, u0)); + const double vc = std::max(-W / 2.0, std::min(W / 2.0, v0)); + const double rInscribed = TMath::Sqrt((uc - u0) * (uc - u0) + (vc - v0) * (vc - v0)); + + // Outscribed Radius: Maximum distance to one of the 4 corners + double rOutscribed = 0; + const double uCorners[4] = {-H / 2.0, H / 2.0, H / 2.0, -H / 2.0}; + const double vCorners[4] = {-W / 2.0, -W / 2.0, W / 2.0, W / 2.0}; + for (int i = 0; i < 4; ++i) { + const double dist = std::hypot(uCorners[i] - u0, vCorners[i] - v0); + if (dist > rOutscribed){ + rOutscribed = dist; + } + } + + // 3. Visualization + new TCanvas("DiskWithStaves", "Disk with Staves", 800, 800); + gPad->SetGrid(); + gPad->SetLeftMargin(0.15); + gPad->SetBottomMargin(0.15); + gPad->SetRightMargin(0.05); + gPad->SetTopMargin(0.05); + + const double maxR = std::max(rOuter, rOutscribed) * 1.5; + gPad->DrawFrame(-maxR, -maxR, maxR, maxR, ";X (cm);Y (cm)"); + + // Draw Inner and Outer Disk Radii (Reference) + TArc* arcInner = new TArc(0, 0, rInner); + arcInner->SetLineStyle(2); + arcInner->SetLineColor(kGray + 1); + arcInner->SetFillStyle(0); + arcInner->Draw("same"); + + TArc* arcOuter = new TArc(0, 0, rOuter); + arcOuter->SetLineStyle(2); + arcOuter->SetLineColor(kGray + 1); + arcOuter->SetFillStyle(0); + arcOuter->Draw("same"); + + // Draw Inscribed and Outscribed circles + TArc* arcInscribed = new TArc(0, 0, rInscribed); + arcInscribed->SetLineColor(kBlue); + arcInscribed->SetLineWidth(2); + arcInscribed->SetFillStyle(0); + arcInscribed->Draw("same"); + + TArc* arcOutscribed = new TArc(0, 0, rOutscribed); + arcOutscribed->SetLineColor(kRed); + arcOutscribed->SetLineWidth(2); + arcOutscribed->SetFillStyle(0); + arcOutscribed->Draw("same"); + + // Generate and Draw Staves + for (int i = 0; i < nStaves; ++i) { + double phi = i * TMath::TwoPi() / nStaves; + double xPts[5], yPts[5]; + for (int j = 0; j < 4; ++j) { + double u = uCorners[j]; + double v = vCorners[j]; + // Apply stave tilt (alpha) around its own center + double uRot = u * TMath::Cos(alpha) - v * TMath::Sin(alpha); + double vRot = u * TMath::Sin(alpha) + v * TMath::Cos(alpha); + // Move stave to rAvg and apply azimuthal rotation (phi) + double x_phi0 = rAvg + uRot; + double y_phi0 = vRot; + xPts[j] = x_phi0 * TMath::Cos(phi) - y_phi0 * TMath::Sin(phi); + yPts[j] = x_phi0 * TMath::Sin(phi) + y_phi0 * TMath::Cos(phi); + } + // Close the geometric polygon + xPts[4] = xPts[0]; + yPts[4] = yPts[0]; + TGraph* gStave = new TGraph(5, xPts, yPts); + gStave->SetFillColorAlpha(kGreen + 2, 0.4); + gStave->SetLineColor(kBlack); + gStave->SetLineWidth(1); + gStave->Draw("f same"); // Fill + gStave->Draw("l same"); // Outline + } + + // 7. Add Legend / Parameter Text + TLatex* tex = new TLatex(); + tex->SetNDC(); + tex->SetTextSize(0.028); + tex->SetTextFont(42); + tex->SetTextColor(kBlack); + tex->DrawLatex(0.12, 0.88, Form("R_{inner} = %.1f, R_{outer} = %.1f", rInner, rOuter)); + tex->DrawLatex(0.12, 0.84, Form("Staves: %d, Tilt: %.1f#circ", nStaves, staveTilt)); + tex->SetTextColor(kBlue); + tex->DrawLatex(0.12, 0.80, Form("Inscribed Radius = %.2f", rInscribed)); + tex->SetTextColor(kRed); + tex->DrawLatex(0.12, 0.76, Form("Outscribed Radius = %.2f", rOutscribed)); +} \ No newline at end of file From e689705465941e85a94a7d073f96c5e5843d5d35 Mon Sep 17 00:00:00 2001 From: ALICE Builder Date: Fri, 3 Apr 2026 11:55:07 +0200 Subject: [PATCH 2/4] Please consider the following formatting changes (#40) --- .../Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C b/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C index 4f97a6e30c830..111500c2bd7a6 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C +++ b/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C @@ -8,17 +8,16 @@ #include #include -void defineIOTOFGeo(const double rAvg = 21, // cm, average radius of the layer (used for stave size calculations) - const int nStaves = 24, // Number of staves - const double staveWidth = 5.42, // cm, Stave width (arc length at avg radius at 0 degrees) +void defineIOTOFGeo(const double rAvg = 21, // cm, average radius of the layer (used for stave size calculations) + const int nStaves = 24, // Number of staves + const double staveWidth = 5.42, // cm, Stave width (arc length at avg radius at 0 degrees) const double staveHeightX2X0 = 0.02, // Stave height (radial at 0 degrees) - const double staveTilt = 10 // Stave tilt angle in degrees + const double staveTilt = 10 // Stave tilt angle in degrees ) { const double Si_X0 = 9.5f; // cm, radiation length of silicon const double staveHeight = staveHeightX2X0 * Si_X0; - // 1. Define inner and outer radii for the disk. // The radius corresponds to the distance of the center of the stave to the origin const double rInner = rAvg - staveHeight / 2.0; @@ -45,7 +44,7 @@ void defineIOTOFGeo(const double rAvg = 21, // cm, average radius of t const double vCorners[4] = {-W / 2.0, -W / 2.0, W / 2.0, W / 2.0}; for (int i = 0; i < 4; ++i) { const double dist = std::hypot(uCorners[i] - u0, vCorners[i] - v0); - if (dist > rOutscribed){ + if (dist > rOutscribed) { rOutscribed = dist; } } From 336494932facc1da64fd06b6579c4c9675dff61d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 7 Apr 2026 12:56:16 +0200 Subject: [PATCH 3/4] Add copyright and licensing information Added copyright notice and license information to the file. --- .../Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C b/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C index 111500c2bd7a6..d9583264625f6 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C +++ b/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C @@ -1,3 +1,15 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + + #include #include #include @@ -125,4 +137,4 @@ void defineIOTOFGeo(const double rAvg = 21, // cm, average radius o tex->DrawLatex(0.12, 0.80, Form("Inscribed Radius = %.2f", rInscribed)); tex->SetTextColor(kRed); tex->DrawLatex(0.12, 0.76, Form("Outscribed Radius = %.2f", rOutscribed)); -} \ No newline at end of file +} From e998a18f8e77ef48385c72b377e05a7a7eccc160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 7 Apr 2026 13:00:32 +0200 Subject: [PATCH 4/4] Change copyright comments to C++ style Updated copyright comments to use C++ style. --- .../ALICE3/IOTOF/macros/defineIOTOFGeo.C | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C b/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C index d9583264625f6..f096fc85aec7a 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C +++ b/Detectors/Upgrades/ALICE3/IOTOF/macros/defineIOTOFGeo.C @@ -1,14 +1,13 @@ -# Copyright 2019-2020 CERN and copyright holders of ALICE O2. -# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -# All rights not expressly granted are reserved. -# -# This software is distributed under the terms of the GNU General Public -# License v3 (GPL Version 3), copied verbatim in the file "COPYING". -# -# In applying this license CERN does not waive the privileges and immunities -# granted to it by virtue of its status as an Intergovernmental Organization -# or submit itself to any jurisdiction. - +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. #include #include