Skip to content

Commit

Permalink
Merge pull request #92 from rest-for-physics/jgalan-readoutplane-update
Browse files Browse the repository at this point in the history
Readout plane upgrade, readout validation and new library version
  • Loading branch information
jgalan authored Jun 14, 2023
2 parents 06a1e0b + c912c30 commit 11822a7
Show file tree
Hide file tree
Showing 17 changed files with 3,257 additions and 3,055 deletions.
2 changes: 1 addition & 1 deletion .github/pr-badge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
message: "Ok: $additions"
color: "green"
when: "$additions < 100"
- imageUrl: "https://github.com/rest-for-physics/detectorlib/actions/workflows/validation.yml/badge.svg?branch=$branchName"
- imageUrl: "https://github.com/rest-for-physics/detectorlib/actions/workflows/frameworkValidation.yml/badge.svg?branch=$branchName"
url: "https://github.com/rest-for-physics/detectorlib/commits/$branchName"
37 changes: 23 additions & 14 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Build and install
uses: rest-for-physics/framework/.github/actions/build@master
with:
cmake-flags: "-DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DREST_WELCOME=ON -DRESTLIB_DETECTOR=ON"
cmake-flags: "-DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DREST_WELCOME=ON -DRESTLIB_DETECTOR=ON -DREST_GARFIELD=ON"
branch: ${{ env.BRANCH_NAME }}
- name: Load REST libraries
run: |
Expand All @@ -68,6 +68,19 @@ jobs:
key: ${{ env.BRANCH_NAME }}-${{ github.sha }}
path: ${{ env.REST_PATH }}

#- name: Load Gas
# run: |
#source ${{ env.REST_PATH }}/thisREST.sh
#cd framework/pipeline/metadata/gas/
#restRoot -b -q LoadGasFromServerAndValidate.C
# Not working, not used in gitlab pipeline
#- name: Generate Gas
# run: |
# source ${{ env.REST_PATH }}/thisREST.sh
# source $(root-config --bindir)/thisroot.sh
# cd framework/pipeline/metadata/gas/
# restRoot -b -q GenerateDummyGas.C

readout:
name: "Readout"
runs-on: ubuntu-latest
Expand All @@ -86,19 +99,7 @@ jobs:
with:
key: ${{ env.BRANCH_NAME }}-${{ github.sha }}
path: ${{ env.REST_PATH }}
#- name: Load Gas
# run: |
#source ${{ env.REST_PATH }}/thisREST.sh
#cd framework/pipeline/metadata/gas/
#restRoot -b -q LoadGasFromServerAndValidate.C
# Not working, not used in gitlab pipeline
#- name: Generate Gas
# run: |
# source ${{ env.REST_PATH }}/thisREST.sh
# source $(root-config --bindir)/thisroot.sh
# cd framework/pipeline/metadata/gas/
# restRoot -b -q GenerateDummyGas.C
- name: Generate Readout
- name: Manager readout generation
run: |
source ${{ env.REST_PATH }}/thisREST.sh
cd ${{ env.DETECTOR_LIB_PATH }}/pipeline/readout
Expand All @@ -108,6 +109,14 @@ jobs:
ls
echo "Validating"
python3 compareFiles.py
- name: Basic Readout repository tests
run: |
source ${{ env.REST_PATH }}/thisREST.sh
git clone https://github.com/rest-for-physics/basic-readouts.git
cd basic-readouts/
restRoot -b -q GenerateReadouts.C'("basic.root")'
restRoot -b -q BasicValidation.C'("basic.root", "pixelDecoding")'
# We need to introduce basic validation here
# - diff validation.txt print.txt
# - name: Basic Readout
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(LibraryVersion "1.9")
set(LibraryVersion "2.0")
add_definitions(-DLIBRARY_VERSION="${LibraryVersion}")

# find garfield libs and includes
Expand Down
85 changes: 36 additions & 49 deletions inc/TRestDetectorReadoutModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,19 @@
/// allows to integrate any number of independent readout channels.
class TRestDetectorReadoutModule {
private:
Int_t fModuleID; ///< The module id given by the readout definition.
Int_t fId = -1; ///< The module id given by the readout definition.

TString fModuleName; ///< The assigned module name.
std::string fName; ///< The assigned module name.

TVector2 fModuleOrigin; ///< The module (x, y) position relative to the readout plane position.
TVector2 fOrigin = {0, 0}; ///< The module (x, y) position relative to the readout plane position.

TVector2 fModuleSize; ///< The module (x, y) size. All pixels should be contained within this size.
TVector2 fSize = {0, 0}; ///< The module (x, y) size. All pixels should be contained within this size.

Double_t fModuleRotation; ///< The rotation of the module around the
///< position=(fModuleOriginX, fModuleOriginY) in
///< degrees.
/// The rotation of the module around the module origin (fModuleOriginX, fModuleOriginY) in radians.
Double_t fRotation = 0; //<

Int_t fMinimumDaqId; ///< The minimum daq channel id associated to the
///< module.
Int_t fMaximumDaqId; ///< The maximum daq channel id associated to the module.
std::pair<Int_t, Int_t> fDaqIdRange = {
-1, -1}; ///< The minimum and maximum daq channel ids associated to the module.

std::vector<TRestDetectorReadoutChannel>
fReadoutChannel; ///< A std::vector of the instances of TRestDetectorReadoutChannel
Expand All @@ -68,8 +66,8 @@ class TRestDetectorReadoutModule {
/// Converts the coordinates (xPhys,yPhys) in the readout plane reference
/// system to the readout module reference system.
inline TVector2 TransformToModuleCoordinates(const TVector2& xyPhysical) const {
auto coords = xyPhysical - fModuleOrigin;
TVector2 rot = coords.Rotate(-fModuleRotation * TMath::Pi() / 180.);
auto coords = xyPhysical - fOrigin;
TVector2 rot = coords.Rotate(-fRotation);

return rot;
}
Expand All @@ -79,8 +77,8 @@ class TRestDetectorReadoutModule {
inline TVector2 TransformToPlaneCoordinates(Double_t xMod, Double_t yMod) const {
TVector2 coords(xMod, yMod);

coords = coords.Rotate(fModuleRotation * TMath::Pi() / 180.);
coords += fModuleOrigin;
coords = coords.Rotate(fRotation);
coords += fOrigin;

return coords;
}
Expand All @@ -90,22 +88,19 @@ class TRestDetectorReadoutModule {
// Setters

/// Sets the module by id definition
inline void SetModuleID(Int_t modID) { fModuleID = modID; }
inline void SetModuleID(Int_t modID) { fId = modID; }

/// Sets the module size by definition using TVector2 input
inline void SetSize(const TVector2& size) { fModuleSize = size; }
inline void SetSize(const TVector2& size) { fSize = size; }

/// Sets the module origin by definition using TVector2 input
inline void SetOrigin(const TVector2& origin) { fModuleOrigin = origin; }

/// Sets the module origin by definition using (x,y) coordinates
inline void SetOrigin(Double_t x, Double_t y) { SetOrigin({x, y}); }
inline void SetOrigin(const TVector2& origin) { fOrigin = origin; }

/// Sets the module rotation in degrees
inline void SetRotation(Double_t rotation) { fModuleRotation = rotation; }
inline void SetRotation(Double_t rotation) { fRotation = rotation; }

/// Sets the name of the readout module
inline void SetName(const TString& name) { fModuleName = name; }
inline void SetName(const std::string& name) { fName = name; }

/// Sets the tolerance for independent pixel overlaps
inline void SetTolerance(Double_t tolerance) { fTolerance = tolerance; }
Expand All @@ -114,42 +109,32 @@ class TRestDetectorReadoutModule {
inline Double_t GetTolerance() const { return fTolerance; }

/// Returns the minimum daq id number
inline Int_t GetMinDaqID() const { return fMinimumDaqId; }
inline Int_t GetMinDaqID() const { return fDaqIdRange.first; }

/// Returns the maximum daq id number
inline Int_t GetMaxDaqID() const { return fMaximumDaqId; }
inline Int_t GetMaxDaqID() const { return fDaqIdRange.second; }

/// Returns the physical readout channel index for a given daq id channel
/// number
/// Returns the physical readout channel index for a given daq id channel number
inline Int_t DaqToReadoutChannel(Int_t daqChannel) {
for (size_t n = 0; n < GetNumberOfChannels(); n++)
if (GetChannel(n)->GetDaqID() == daqChannel) return n;
for (size_t n = 0; n < GetNumberOfChannels(); n++) {
if (GetChannel(n)->GetDaqID() == daqChannel) {
return n;
}
}
return -1;
}

/// Returns the module id
inline Int_t GetModuleID() const { return fModuleID; }

/// Returns the module x-coordinate origin
inline Double_t GetModuleOriginX() const { return fModuleOrigin.X(); }

/// Returns the module y-coordinate origin
inline Double_t GetModuleOriginY() const { return fModuleOrigin.Y(); }

/// Returns the module x-coordinate origin
inline Double_t GetOriginX() const { return fModuleOrigin.X(); }

/// Returns the module y-coordinate origin
inline Double_t GetOriginY() const { return fModuleOrigin.Y(); }
inline Int_t GetModuleID() const { return fId; }

/// Returns the module size x-coordinate
inline Double_t GetModuleSizeX() const { return fModuleSize.X(); }
/// Returns the module origin position
inline TVector2 GetOrigin() const { return fOrigin; }

/// Returns the module size y-coordinate
inline Double_t GetModuleSizeY() const { return fModuleSize.Y(); }
/// Returns the module size (x, y) in mm
inline TVector2 GetSize() const { return fSize; }

/// Returns the module rotation in degrees
inline Double_t GetModuleRotation() const { return fModuleRotation; }
inline Double_t GetRotation() const { return fRotation; }

/// Converts the coordinates given by TVector2 in the readout plane reference
/// system to the readout module reference system.
Expand All @@ -160,7 +145,7 @@ class TRestDetectorReadoutModule {
TVector2 GetPlaneCoordinates(const TVector2& p) { return TransformToPlaneCoordinates(p.X(), p.Y()); }

/// Returns the module name
inline const char* GetName() const { return fModuleName.Data(); }
inline const char* GetName() const { return fName.c_str(); }

/// Returns a pointer to the readout mapping
inline TRestDetectorReadoutMapping* GetMapping() { return &fMapping; }
Expand All @@ -169,7 +154,9 @@ class TRestDetectorReadoutModule {

/// Returns a pointer to a readout channel by index
inline TRestDetectorReadoutChannel* GetChannel(size_t n) {
if (n >= GetNumberOfChannels()) return nullptr;
if (n >= GetNumberOfChannels()) {
return nullptr;
}
return &fReadoutChannel[n];
}

Expand Down Expand Up @@ -226,6 +213,6 @@ class TRestDetectorReadoutModule {
// Destructor
virtual ~TRestDetectorReadoutModule();

ClassDef(TRestDetectorReadoutModule, 2);
ClassDef(TRestDetectorReadoutModule, 3);
};
#endif
Loading

0 comments on commit 11822a7

Please sign in to comment.