CHeT Library
Loading...
Searching...
No Matches
CHeTGlobalSettings.hh
Go to the documentation of this file.
1#ifndef CHETGLOBALSETTINGS_HH
2#define CHETGLOBALSETTINGS_HH
3
4#include <algorithm> // for std::find if needed
5#include <cmath>
6#include <iostream>
7#include <map>
8#include <string>
9#include <vector>
10
15namespace CHeT
16{
17
23namespace Config
24{
25
26// --- Configuration Structures ---
27
32{
34 double radius;
35 double thickness;
36 double phiOffset;
39 int color;
40};
41
52
57{
59 int layerId;
60 double r;
61 double phi0;
62 int dir;
63 int color;
64};
65
70{
71 double z;
72 double x;
73 double y;
74 double z_loc;
75 double x_loc;
76 double y_loc;
78 double widthZ;
79};
80
81// --- Global Physical Constants ---
82
83// Kept as constexpr in header for compile-time optimization
84constexpr double L_HALF = 150.0;
85constexpr double FIBER_WIDTH = 0.5;
86constexpr int FIBERS_PER_SIPM = 4;
88
96inline double GetStereoAngle(double radius, double deltaPhi = M_PI, double length = 2.0 * L_HALF)
97{
98 return std::atan((radius * deltaPhi) / length);
99}
100
101// --- Experimental Offsets ---
102
107double GetOffsetExp();
108
115void SetOffsetExp(double val);
116
122double GetDeltaI(int cylIdx);
123
131void SetDeltaI(int cylIdx, double val);
132
139void SetDeltas(const std::vector<double> &deltas);
140
145std::vector<double> GetDeltas();
146
147// --- Rotation Settings ---
148
156void SetRotation(double rx, double ry, double rz);
157
164void GetRotation(double &rx, double &ry, double &rz);
165
172void SetTranslation(double tx, double ty, double tz);
173
180void GetTranslation(double &tx, double &ty, double &tz);
181
190void ApplyRotation(double &x, double &y, double &z);
191
200void ApplyInverseRotation(double &x, double &y, double &z);
201
210void ApplyTransformation(double &x, double &y, double &z);
211
220void ApplyInverseTransformation(double &x, double &y, double &z);
221
222// --- Function Declarations ---
223
229int GetBoardGlobalOffset(int board_id);
230
237void SetActiveCylinders(const std::vector<int> &active_ids);
238
243std::vector<int> GetActiveCylinders();
244
249const std::vector<CylinderConfig> &GetCylinders();
250
256double wrap0_2pi(double angle);
257
263FiberProp GetFiberProp(int b_id);
264
271int GetGlobalBundleId(int board_id, int channel_id);
272
278std::vector<BundlesIntersection> FindIntersections(const std::vector<int> &hit_ids);
279
280// --- Debug / Helper Functions ---
281
285int GetGlobalIdFromGeometry(int cyl_id, int layer_id, int layer_idx);
286
290void PrintBundleMapping(int global_id);
291
295void MapExplorer();
296
297} // namespace Config
298
299} // namespace CHeT
300
301#endif // CHETGLOBALSETTINGS_HH
#define M_PI
FiberProp GetFiberProp(int b_id)
Retrieves fiber properties given a global bundle ID.
constexpr int FIBERS_PER_SIPM
Number of fibers per SiPM (bundle)
int GetBoardGlobalOffset(int board_id)
Returns the global offset (bundle count) for a specific board.
void ApplyInverseTransformation(double &x, double &y, double &z)
Transforms a 3D POINT in-place from the Global Lab Frame to the Detector Local Frame....
double GetOffsetExp()
Retrieves the current experimental angular offset (OFFSET_EXP).
void SetDeltaI(int cylIdx, double val)
Sets the experimental parameter DELTA for a specific cylinder.
void ApplyRotation(double &x, double &y, double &z)
Rotates a 3D VECTOR in-place from the Detector Local Frame to the Global Lab Frame....
std::vector< BundlesIntersection > FindIntersections(const std::vector< int > &hit_ids)
Finds 3D intersections between a list of hit bundles.
constexpr double FIBER_WIDTH
Physical width of a single fiber [mm].
void SetDeltas(const std::vector< double > &deltas)
Sets the experimental parameter DELTA for all cylinders.
constexpr double BUNDLE_WIDTH
Physical width of a bundle [mm].
std::vector< int > GetActiveCylinders()
Retrieves the list of currently active cylinder IDs.
void ApplyTransformation(double &x, double &y, double &z)
Transforms a 3D POINT in-place from the Detector Local Frame to the Global Lab Frame....
void SetActiveCylinders(const std::vector< int > &active_ids)
Sets the list of active cylinder IDs. This defines the physical composition of the detector for the c...
void SetOffsetExp(double val)
Sets the experimental angular offset (OFFSET_EXP).
double wrap0_2pi(double angle)
Wraps an angle into the [0, 2*PI) range.
int GetGlobalBundleId(int board_id, int channel_id)
Converts Hardware Board/Channel to Global Bundle ID.
void SetTranslation(double tx, double ty, double tz)
Sets the global translation of the detector origin.
void MapExplorer()
Interactive CLI menu to explore the mapping.
const std::vector< CylinderConfig > & GetCylinders()
Retrieves the configuration for all active cylinders.
int GetGlobalIdFromGeometry(int cyl_id, int layer_id, int layer_idx)
Helper: Converts Geometry (Cyl, Layer, Index) to Global ID.
void PrintBundleMapping(int global_id)
Helper: Prints mapping details for a given Global ID to stdout.
double GetDeltaI(int cylIdx)
Retrieves the current experimental parameter DELTA for a specific cylinder.
constexpr double L_HALF
Half-length of the detector [mm].
std::vector< double > GetDeltas()
Gets the experimental parameter DELTA for all cylinders.
void ApplyInverseRotation(double &x, double &y, double &z)
Rotates a 3D VECTOR in-place from the Global Lab Frame to the Detector Local Frame....
void GetRotation(double &rx, double &ry, double &rz)
Retrieves the current global rotation angles.
void SetRotation(double rx, double ry, double rz)
Sets the global rotation of the detector using Euler angles. Rotations are applied in order: X,...
void GetTranslation(double &tx, double &ty, double &tz)
Retrieves the current global translation.
double GetStereoAngle(double radius, double deltaPhi=M_PI, double length=2.0 *L_HALF)
Computes the analytical stereo angle for a given radius.
Root namespace for the Cylindrical Helix Tracker (CHeT) project.
Represents a geometric intersection between two bundles.
double widthZ
Longitudinal uncertainty due to fiber thickness [mm].
int cylinderId
ID of the cylinder where intersection occurs.
double y
Transverse position Y [mm].
double z_loc
Longitudinal position [mm] (Local)
double x
Transverse position X [mm].
double y_loc
Transverse position Y [mm] (Local)
double x_loc
Transverse position X [mm] (Local)
double z
Longitudinal position [mm].
Configuration for a full cylinder (Inner + Outer layers).
LayerConfig outer
Configuration for the outer layer.
LayerConfig inner
Configuration for the inner layer.
double nominalRadius
Nominal radius in [mm].
Properties of a specific reconstructed fiber.
int layerId
0 for inner, 1 for outer
int dir
Winding direction.
int color
ROOT color index.
double phi0
Initial angle [rad].
Configuration for a single fiber layer.
double thickness
Thickness in [mm].
double radius
Radius in [mm].
int direction
Winding direction: +1 (CCW) or -1 (CW)
int color
ROOT color index for display.
int nBundles
Number of bundles in the layer.
double phiOffset
Angular offset in [rad].
double nominalStereoAngle
Nominal stereo angle in [rad].