Skip to content

Commit 11822a7

Browse files
authored
Merge pull request #92 from rest-for-physics/jgalan-readoutplane-update
Readout plane upgrade, readout validation and new library version
2 parents 06a1e0b + c912c30 commit 11822a7

17 files changed

+3257
-3055
lines changed

Diff for: .github/pr-badge.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
message: "Ok: $additions"
1414
color: "green"
1515
when: "$additions < 100"
16-
- imageUrl: "https://github.com/rest-for-physics/detectorlib/actions/workflows/validation.yml/badge.svg?branch=$branchName"
16+
- imageUrl: "https://github.com/rest-for-physics/detectorlib/actions/workflows/frameworkValidation.yml/badge.svg?branch=$branchName"
1717
url: "https://github.com/rest-for-physics/detectorlib/commits/$branchName"

Diff for: .github/workflows/validation.yml

+23-14
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: Build and install
5656
uses: rest-for-physics/framework/.github/actions/build@master
5757
with:
58-
cmake-flags: "-DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DREST_WELCOME=ON -DRESTLIB_DETECTOR=ON"
58+
cmake-flags: "-DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DREST_WELCOME=ON -DRESTLIB_DETECTOR=ON -DREST_GARFIELD=ON"
5959
branch: ${{ env.BRANCH_NAME }}
6060
- name: Load REST libraries
6161
run: |
@@ -68,6 +68,19 @@ jobs:
6868
key: ${{ env.BRANCH_NAME }}-${{ github.sha }}
6969
path: ${{ env.REST_PATH }}
7070

71+
#- name: Load Gas
72+
# run: |
73+
#source ${{ env.REST_PATH }}/thisREST.sh
74+
#cd framework/pipeline/metadata/gas/
75+
#restRoot -b -q LoadGasFromServerAndValidate.C
76+
# Not working, not used in gitlab pipeline
77+
#- name: Generate Gas
78+
# run: |
79+
# source ${{ env.REST_PATH }}/thisREST.sh
80+
# source $(root-config --bindir)/thisroot.sh
81+
# cd framework/pipeline/metadata/gas/
82+
# restRoot -b -q GenerateDummyGas.C
83+
7184
readout:
7285
name: "Readout"
7386
runs-on: ubuntu-latest
@@ -86,19 +99,7 @@ jobs:
8699
with:
87100
key: ${{ env.BRANCH_NAME }}-${{ github.sha }}
88101
path: ${{ env.REST_PATH }}
89-
#- name: Load Gas
90-
# run: |
91-
#source ${{ env.REST_PATH }}/thisREST.sh
92-
#cd framework/pipeline/metadata/gas/
93-
#restRoot -b -q LoadGasFromServerAndValidate.C
94-
# Not working, not used in gitlab pipeline
95-
#- name: Generate Gas
96-
# run: |
97-
# source ${{ env.REST_PATH }}/thisREST.sh
98-
# source $(root-config --bindir)/thisroot.sh
99-
# cd framework/pipeline/metadata/gas/
100-
# restRoot -b -q GenerateDummyGas.C
101-
- name: Generate Readout
102+
- name: Manager readout generation
102103
run: |
103104
source ${{ env.REST_PATH }}/thisREST.sh
104105
cd ${{ env.DETECTOR_LIB_PATH }}/pipeline/readout
@@ -108,6 +109,14 @@ jobs:
108109
ls
109110
echo "Validating"
110111
python3 compareFiles.py
112+
- name: Basic Readout repository tests
113+
run: |
114+
source ${{ env.REST_PATH }}/thisREST.sh
115+
git clone https://github.com/rest-for-physics/basic-readouts.git
116+
cd basic-readouts/
117+
restRoot -b -q GenerateReadouts.C'("basic.root")'
118+
restRoot -b -q BasicValidation.C'("basic.root", "pixelDecoding")'
119+
111120
# We need to introduce basic validation here
112121
# - diff validation.txt print.txt
113122
# - name: Basic Readout

Diff for: CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(LibraryVersion "1.9")
1+
set(LibraryVersion "2.0")
22
add_definitions(-DLIBRARY_VERSION="${LibraryVersion}")
33

44
# find garfield libs and includes

Diff for: inc/TRestDetectorReadoutModule.h

+36-49
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,19 @@
3535
/// allows to integrate any number of independent readout channels.
3636
class 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

Comments
 (0)