3535// / allows to integrate any number of independent readout channels.
3636class TRestDetectorReadoutModule {
3737 private:
38- Int_t fModuleID ; // /< The module id given by the readout definition.
38+ Int_t fId = - 1 ; // /< The module id given by the readout definition.
3939
40- TString fModuleName ; // /< The assigned module name.
40+ std::string fName ; // /< The assigned module name.
4141
42- TVector2 fModuleOrigin ; // /< The module (x, y) position relative to the readout plane position.
42+ TVector2 fOrigin = { 0 , 0 } ; // /< The module (x, y) position relative to the readout plane position.
4343
44- TVector2 fModuleSize ; // /< The module (x, y) size. All pixels should be contained within this size.
44+ TVector2 fSize = { 0 , 0 } ; // /< The module (x, y) size. All pixels should be contained within this size.
4545
46- Double_t fModuleRotation ; // /< The rotation of the module around the
47- // /< position=(fModuleOriginX, fModuleOriginY) in
48- // /< degrees.
46+ // / The rotation of the module around the module origin (fModuleOriginX, fModuleOriginY) in radians.
47+ Double_t fRotation = 0 ; // <
4948
50- Int_t fMinimumDaqId ; // /< The minimum daq channel id associated to the
51- // /< module.
52- Int_t fMaximumDaqId ; // /< The maximum daq channel id associated to the module.
49+ std::pair<Int_t, Int_t> fDaqIdRange = {
50+ -1 , -1 }; // /< The minimum and maximum daq channel ids associated to the module.
5351
5452 std::vector<TRestDetectorReadoutChannel>
5553 fReadoutChannel ; // /< A std::vector of the instances of TRestDetectorReadoutChannel
@@ -68,8 +66,8 @@ class TRestDetectorReadoutModule {
6866 // / Converts the coordinates (xPhys,yPhys) in the readout plane reference
6967 // / system to the readout module reference system.
7068 inline TVector2 TransformToModuleCoordinates (const TVector2& xyPhysical) const {
71- auto coords = xyPhysical - fModuleOrigin ;
72- TVector2 rot = coords.Rotate (-fModuleRotation * TMath::Pi () / 180 . );
69+ auto coords = xyPhysical - fOrigin ;
70+ TVector2 rot = coords.Rotate (-fRotation );
7371
7472 return rot;
7573 }
@@ -79,8 +77,8 @@ class TRestDetectorReadoutModule {
7977 inline TVector2 TransformToPlaneCoordinates (Double_t xMod, Double_t yMod) const {
8078 TVector2 coords (xMod, yMod);
8179
82- coords = coords.Rotate (fModuleRotation * TMath::Pi () / 180 . );
83- coords += fModuleOrigin ;
80+ coords = coords.Rotate (fRotation );
81+ coords += fOrigin ;
8482
8583 return coords;
8684 }
@@ -90,22 +88,19 @@ class TRestDetectorReadoutModule {
9088 // Setters
9189
9290 // / Sets the module by id definition
93- inline void SetModuleID (Int_t modID) { fModuleID = modID; }
91+ inline void SetModuleID (Int_t modID) { fId = modID; }
9492
9593 // / Sets the module size by definition using TVector2 input
96- inline void SetSize (const TVector2& size) { fModuleSize = size; }
94+ inline void SetSize (const TVector2& size) { fSize = size; }
9795
9896 // / Sets the module origin by definition using TVector2 input
99- inline void SetOrigin (const TVector2& origin) { fModuleOrigin = origin; }
100-
101- // / Sets the module origin by definition using (x,y) coordinates
102- inline void SetOrigin (Double_t x, Double_t y) { SetOrigin ({x, y}); }
97+ inline void SetOrigin (const TVector2& origin) { fOrigin = origin; }
10398
10499 // / Sets the module rotation in degrees
105- inline void SetRotation (Double_t rotation) { fModuleRotation = rotation; }
100+ inline void SetRotation (Double_t rotation) { fRotation = rotation; }
106101
107102 // / Sets the name of the readout module
108- inline void SetName (const TString & name) { fModuleName = name; }
103+ inline void SetName (const std::string & name) { fName = name; }
109104
110105 // / Sets the tolerance for independent pixel overlaps
111106 inline void SetTolerance (Double_t tolerance) { fTolerance = tolerance; }
@@ -114,42 +109,32 @@ class TRestDetectorReadoutModule {
114109 inline Double_t GetTolerance () const { return fTolerance ; }
115110
116111 // / Returns the minimum daq id number
117- inline Int_t GetMinDaqID () const { return fMinimumDaqId ; }
112+ inline Int_t GetMinDaqID () const { return fDaqIdRange . first ; }
118113
119114 // / Returns the maximum daq id number
120- inline Int_t GetMaxDaqID () const { return fMaximumDaqId ; }
115+ inline Int_t GetMaxDaqID () const { return fDaqIdRange . second ; }
121116
122- // / Returns the physical readout channel index for a given daq id channel
123- // / number
117+ // / Returns the physical readout channel index for a given daq id channel number
124118 inline Int_t DaqToReadoutChannel (Int_t daqChannel) {
125- for (size_t n = 0 ; n < GetNumberOfChannels (); n++)
126- if (GetChannel (n)->GetDaqID () == daqChannel) return n;
119+ for (size_t n = 0 ; n < GetNumberOfChannels (); n++) {
120+ if (GetChannel (n)->GetDaqID () == daqChannel) {
121+ return n;
122+ }
123+ }
127124 return -1 ;
128125 }
129126
130127 // / Returns the module id
131- inline Int_t GetModuleID () const { return fModuleID ; }
132-
133- // / Returns the module x-coordinate origin
134- inline Double_t GetModuleOriginX () const { return fModuleOrigin .X (); }
135-
136- // / Returns the module y-coordinate origin
137- inline Double_t GetModuleOriginY () const { return fModuleOrigin .Y (); }
138-
139- // / Returns the module x-coordinate origin
140- inline Double_t GetOriginX () const { return fModuleOrigin .X (); }
141-
142- // / Returns the module y-coordinate origin
143- inline Double_t GetOriginY () const { return fModuleOrigin .Y (); }
128+ inline Int_t GetModuleID () const { return fId ; }
144129
145- // / Returns the module size x-coordinate
146- inline Double_t GetModuleSizeX () const { return fModuleSize . X () ; }
130+ // / Returns the module origin position
131+ inline TVector2 GetOrigin () const { return fOrigin ; }
147132
148- // / Returns the module size y-coordinate
149- inline Double_t GetModuleSizeY () const { return fModuleSize . Y () ; }
133+ // / Returns the module size (x, y) in mm
134+ inline TVector2 GetSize () const { return fSize ; }
150135
151136 // / Returns the module rotation in degrees
152- inline Double_t GetModuleRotation () const { return fModuleRotation ; }
137+ inline Double_t GetRotation () const { return fRotation ; }
153138
154139 // / Converts the coordinates given by TVector2 in the readout plane reference
155140 // / system to the readout module reference system.
@@ -160,7 +145,7 @@ class TRestDetectorReadoutModule {
160145 TVector2 GetPlaneCoordinates (const TVector2& p) { return TransformToPlaneCoordinates (p.X (), p.Y ()); }
161146
162147 // / Returns the module name
163- inline const char * GetName () const { return fModuleName . Data (); }
148+ inline const char * GetName () const { return fName . c_str (); }
164149
165150 // / Returns a pointer to the readout mapping
166151 inline TRestDetectorReadoutMapping* GetMapping () { return &fMapping ; }
@@ -169,7 +154,9 @@ class TRestDetectorReadoutModule {
169154
170155 // / Returns a pointer to a readout channel by index
171156 inline TRestDetectorReadoutChannel* GetChannel (size_t n) {
172- if (n >= GetNumberOfChannels ()) return nullptr ;
157+ if (n >= GetNumberOfChannels ()) {
158+ return nullptr ;
159+ }
173160 return &fReadoutChannel [n];
174161 }
175162
@@ -226,6 +213,6 @@ class TRestDetectorReadoutModule {
226213 // Destructor
227214 virtual ~TRestDetectorReadoutModule ();
228215
229- ClassDef (TRestDetectorReadoutModule, 2 );
216+ ClassDef (TRestDetectorReadoutModule, 3 );
230217};
231218#endif
0 commit comments