Skip to content

Commit ca1a86a

Browse files
committed
[ALICE3] IOTOF: Add geometry macros
1 parent 2cec687 commit ca1a86a

File tree

3 files changed

+144
-1
lines changed

3 files changed

+144
-1
lines changed

Detectors/Upgrades/ALICE3/IOTOF/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
# or submit itself to any jurisdiction.
1111

1212
add_subdirectory(base)
13-
add_subdirectory(simulation)
13+
add_subdirectory(simulation)
14+
add_subdirectory(macros)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
# All rights not expressly granted are reserved.
4+
#
5+
# This software is distributed under the terms of the GNU General Public
6+
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
#
8+
# In applying this license CERN does not waive the privileges and immunities
9+
# granted to it by virtue of its status as an Intergovernmental Organization
10+
# or submit itself to any jurisdiction.
11+
12+
o2_add_test_root_macro(defineIOTOFGeo.C
13+
LABELS alice3)
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#include <TCanvas.h>
2+
#include <TGraph.h>
3+
#include <TArc.h>
4+
#include <TH2F.h>
5+
#include <TMath.h>
6+
#include <TLatex.h>
7+
#include <TStyle.h>
8+
#include <algorithm>
9+
#include <cmath>
10+
11+
void defineIOTOFGeo(const double rAvg = 21, // cm, average radius of the layer (used for stave size calculations)
12+
const int nStaves = 24, // Number of staves
13+
const double staveWidth = 5.42, // cm, Stave width (arc length at avg radius at 0 degrees)
14+
const double staveHeightX2X0 = 0.02, // Stave height (radial at 0 degrees)
15+
const double staveTilt = 10 // Stave tilt angle in degrees
16+
)
17+
{
18+
const double Si_X0 = 9.5f; // cm, radiation length of silicon
19+
const double staveHeight = staveHeightX2X0 * Si_X0;
20+
21+
22+
// 1. Define inner and outer radii for the disk.
23+
// The radius corresponds to the distance of the center of the stave to the origin
24+
const double rInner = rAvg - staveHeight / 2.0;
25+
const double rOuter = rAvg + staveHeight / 2.0;
26+
27+
const double alpha = staveTilt * TMath::DegToRad(); // Tilt angle in radians
28+
const double H = staveHeight;
29+
const double W = staveWidth;
30+
31+
// 2. Analytical calculation of Inscribed and Outscribed Radii
32+
// We project the global origin (0,0) into the local, unrotated coordinate
33+
// system of a single stave centered at (0,0).
34+
const double u0 = -rAvg * TMath::Cos(alpha);
35+
const double v0 = rAvg * TMath::Sin(alpha);
36+
37+
// Inscribed Radius: Distance to the closest point on the stave rectangle
38+
const double uc = std::max(-H / 2.0, std::min(H / 2.0, u0));
39+
const double vc = std::max(-W / 2.0, std::min(W / 2.0, v0));
40+
const double rInscribed = TMath::Sqrt((uc - u0) * (uc - u0) + (vc - v0) * (vc - v0));
41+
42+
// Outscribed Radius: Maximum distance to one of the 4 corners
43+
double rOutscribed = 0;
44+
const double uCorners[4] = {-H / 2.0, H / 2.0, H / 2.0, -H / 2.0};
45+
const double vCorners[4] = {-W / 2.0, -W / 2.0, W / 2.0, W / 2.0};
46+
for (int i = 0; i < 4; ++i) {
47+
const double dist = std::hypot(uCorners[i] - u0, vCorners[i] - v0);
48+
if (dist > rOutscribed){
49+
rOutscribed = dist;
50+
}
51+
}
52+
53+
// 3. Visualization
54+
new TCanvas("DiskWithStaves", "Disk with Staves", 800, 800);
55+
gPad->SetGrid();
56+
gPad->SetLeftMargin(0.15);
57+
gPad->SetBottomMargin(0.15);
58+
gPad->SetRightMargin(0.05);
59+
gPad->SetTopMargin(0.05);
60+
61+
const double maxR = std::max(rOuter, rOutscribed) * 1.5;
62+
gPad->DrawFrame(-maxR, -maxR, maxR, maxR, ";X (cm);Y (cm)");
63+
64+
// Draw Inner and Outer Disk Radii (Reference)
65+
TArc* arcInner = new TArc(0, 0, rInner);
66+
arcInner->SetLineStyle(2);
67+
arcInner->SetLineColor(kGray + 1);
68+
arcInner->SetFillStyle(0);
69+
arcInner->Draw("same");
70+
71+
TArc* arcOuter = new TArc(0, 0, rOuter);
72+
arcOuter->SetLineStyle(2);
73+
arcOuter->SetLineColor(kGray + 1);
74+
arcOuter->SetFillStyle(0);
75+
arcOuter->Draw("same");
76+
77+
// Draw Inscribed and Outscribed circles
78+
TArc* arcInscribed = new TArc(0, 0, rInscribed);
79+
arcInscribed->SetLineColor(kBlue);
80+
arcInscribed->SetLineWidth(2);
81+
arcInscribed->SetFillStyle(0);
82+
arcInscribed->Draw("same");
83+
84+
TArc* arcOutscribed = new TArc(0, 0, rOutscribed);
85+
arcOutscribed->SetLineColor(kRed);
86+
arcOutscribed->SetLineWidth(2);
87+
arcOutscribed->SetFillStyle(0);
88+
arcOutscribed->Draw("same");
89+
90+
// Generate and Draw Staves
91+
for (int i = 0; i < nStaves; ++i) {
92+
double phi = i * TMath::TwoPi() / nStaves;
93+
double xPts[5], yPts[5];
94+
for (int j = 0; j < 4; ++j) {
95+
double u = uCorners[j];
96+
double v = vCorners[j];
97+
// Apply stave tilt (alpha) around its own center
98+
double uRot = u * TMath::Cos(alpha) - v * TMath::Sin(alpha);
99+
double vRot = u * TMath::Sin(alpha) + v * TMath::Cos(alpha);
100+
// Move stave to rAvg and apply azimuthal rotation (phi)
101+
double x_phi0 = rAvg + uRot;
102+
double y_phi0 = vRot;
103+
xPts[j] = x_phi0 * TMath::Cos(phi) - y_phi0 * TMath::Sin(phi);
104+
yPts[j] = x_phi0 * TMath::Sin(phi) + y_phi0 * TMath::Cos(phi);
105+
}
106+
// Close the geometric polygon
107+
xPts[4] = xPts[0];
108+
yPts[4] = yPts[0];
109+
TGraph* gStave = new TGraph(5, xPts, yPts);
110+
gStave->SetFillColorAlpha(kGreen + 2, 0.4);
111+
gStave->SetLineColor(kBlack);
112+
gStave->SetLineWidth(1);
113+
gStave->Draw("f same"); // Fill
114+
gStave->Draw("l same"); // Outline
115+
}
116+
117+
// 7. Add Legend / Parameter Text
118+
TLatex* tex = new TLatex();
119+
tex->SetNDC();
120+
tex->SetTextSize(0.028);
121+
tex->SetTextFont(42);
122+
tex->SetTextColor(kBlack);
123+
tex->DrawLatex(0.12, 0.88, Form("R_{inner} = %.1f, R_{outer} = %.1f", rInner, rOuter));
124+
tex->DrawLatex(0.12, 0.84, Form("Staves: %d, Tilt: %.1f#circ", nStaves, staveTilt));
125+
tex->SetTextColor(kBlue);
126+
tex->DrawLatex(0.12, 0.80, Form("Inscribed Radius = %.2f", rInscribed));
127+
tex->SetTextColor(kRed);
128+
tex->DrawLatex(0.12, 0.76, Form("Outscribed Radius = %.2f", rOutscribed));
129+
}

0 commit comments

Comments
 (0)