1818#define ALICEO2_FV0_GEOMETRY_H_
1919
2020#include < vector>
21+ #include < array>
2122
2223#include < TGeoMatrix.h>
2324#include < TGeoVolume.h>
2425#include < TVirtualMC.h>
26+ #include " MathUtils/Cartesian3D.h"
2527
2628namespace o2
2729{
@@ -32,9 +34,13 @@ class Geometry
3234{
3335 public:
3436 // / Geometry type options possible to be initialized. The type of the geometry will specify which components are
35- // / created.
37+ // / created. Geometry types
38+ // / -> eUnitialized => no parts
39+ // / -> eOnlySensitive => only sensitive detector parts
40+ // / -> eRough => sensitive parts and rough structural elements
41+ // / -> eFull => complete, detailed geometry (including screws, etc.)
3642 enum EGeoType {
37- eUninitilized ,
43+ eUninitialized ,
3844 eOnlySensitive,
3945 eRough,
4046 eFull
@@ -53,21 +59,15 @@ class Geometry
5359 // / Default constructor.
5460 // / It must be kept public for root persistency purposes,
5561 // / but should never be called by the outside world
56- Geometry () : mGeometryType (eUninitilized), mLeftTransformation (nullptr ), mRightTransformation (nullptr ){};
57-
58- // / Standard constructor
59- // / \param initType[in] The type of geometry, that will be initialized
60- // / -> initType == eUnitialized => no parts
61- // / -> initType == eOnlySensitive => only sensitive detector parts
62- // / -> initType == eRough => sensitive parts and rough structural elements
63- // / -> initType == eFull => complete, detailed geometry (including screws, etc.)
64- // / \return -
65- explicit Geometry (EGeoType initType);
62+ Geometry () : mGeometryType (eUninitialized), mLeftTransformation (nullptr ), mRightTransformation (nullptr ){};
6663
6764 // / Copy constructor.
6865 Geometry (const Geometry& geometry);
6966
70- // / Destructor
67+ // / Access to geometry instance
68+ // / \param initType The geometry type to be initialized - if the geometry already exists this parameter is ignored
69+ static Geometry* instance (EGeoType initType = eUninitialized);
70+
7171 ~Geometry ();
7272
7373 // / Get the unique ID of the current scintillator cell during simulation.
@@ -91,7 +91,24 @@ class Geometry
9191 // / Build the geometry.
9292 void buildGeometry () const ;
9393
94+ // / Utility functions to be accessed externally
95+
96+ // / Sets the input parameters to the position of the geometrical center of sensitive detector
97+ // / \param x x [cm].
98+ // / \param y y [cm].
99+ // / \param z z [cm].
100+ void getGlobalPosition (float & x, float & y, float & z);
101+ Point3D<float >& getCellCenter (UInt_t cellId);
102+ Point3D<float >& getReadoutCenter (UInt_t cellId);
103+
104+ // / Helper function to check if the cellId belongs to ring 5.
105+ // / \param cellId Id of the cell in range from 0 to 39.
106+ // / \return True if cellId belongs to ring 5.
107+ bool isRing5 (UInt_t cellId);
108+
94109 private:
110+ explicit Geometry (EGeoType initType);
111+
95112 inline static const std::string sDetectorName = " FV0" ;
96113
97114 // General geometry constants
@@ -110,6 +127,13 @@ class Geometry
110127 // / Cell and scintillator constants
111128 static constexpr int sNumberOfCellSectors = 4 ; // /< Number of cell sectors for one half of the detector
112129 static constexpr int sNumberOfCellRings = 5 ; // /< Number of cell rings
130+ static constexpr int sNumberOfCells = sNumberOfCellRings * sNumberOfCellSectors * 2 ; // /< Number of cells
131+ static constexpr int sNumberOfReadoutChannels = sNumberOfCells + sNumberOfCellSectors * 2 ; // /< Number of ch (2 ch per cell in r5)
132+
133+ // / Look-up tables converting cellId to the ring and sector number
134+ static constexpr int sCellToRing [sNumberOfCells ] = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 };
135+ static constexpr int sCellToSector [sNumberOfCells ] = {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 };
136+
113137 // / Average cell ring radii.
114138 static constexpr float sCellRingRadii [sNumberOfCellRings + 1 ]{4.01 , 7.3 , 12.9 , 21.25 , 38.7 , 72.115 };
115139 static constexpr char sCellTypes [sNumberOfCellSectors ]{' a' , ' b' , ' b' , ' a' }; // /< Ordered cell types per half a ring
@@ -386,6 +410,10 @@ class Geometry
386410 // / \return The volume name.
387411 const std::string createVolumeName (const std::string& volumeType, int number = -1 ) const ;
388412
413+ // / Utility methods
414+ void initializeCellCenters (); // /< To be called in constructor to initialize mCellCenter
415+ void initializeReadoutCenters (); // /< To be called in constructor to initialize mReadoutCenter
416+
389417 std::vector<std::string> mSensitiveVolumeNames ; // /< The names of all the sensitive volumes
390418
391419 // / Average ring radii
@@ -430,6 +458,12 @@ class Geometry
430458 TGeoMatrix* mLeftTransformation ; // /< Transformation for the left part of the detector
431459 TGeoMatrix* mRightTransformation ; // /< Transformation for the right part of the detector
432460
461+ // / Utility arrays derived from constants
462+ std::array<Point3D<float >, sNumberOfCells > mCellCenter ; // /< Center of each scintillator cell
463+ std::array<Point3D<float >, sNumberOfReadoutChannels > mReadoutCenter ; // /< Similar to mCellCenter, cells in r5 are additionally divided
464+
465+ static Geometry* sInstance ; // /< \brief Singleton instance
466+
433467 ClassDefNV (Geometry, 1 );
434468};
435469} // namespace fv0
0 commit comments