Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring TRestDetectorReadout classes. #86

Merged
merged 21 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4c31f70
remove dependency from TObject
lobis May 30, 2023
d954cf4
removed __CINT__ declarations
lobis May 30, 2023
c645a7d
using override keyword and remove virtual destructor declaration
lobis May 30, 2023
55f6460
TRestDetectorReadoutEventViewer. Marking virtual methods as override
jgalan May 31, 2023
903ce6c
TRestDetectorReadoutModule. Removing override
jgalan May 31, 2023
75c32d1
TRestDetectorReadoutPixel. Removing RESTMetadata
jgalan May 31, 2023
6f46066
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 31, 2023
ec95295
fix typos, variable names, const references
lobis May 30, 2023
2705b13
Fixing compilation issues with int - size_t comparisons
jgalan May 31, 2023
6147055
Merge branch 'jgalan-refactoring' of github.com:rest-for-physics/dete…
jgalan May 31, 2023
d115ae3
using TVector2/TVector3 for positions
lobis May 30, 2023
d2137a0
REST_Detector_CheckReadout.C. Fixing macro to new FindChannels prototype
jgalan Jun 1, 2023
87a7464
TRestDetectorReadoutModule. TransformToPhysicalCoordinates renamed to…
jgalan Jun 2, 2023
7a0aeff
TRestDetectorSignalToHitsProcess. Replacing GetPhysicalCoordinates by…
jgalan Jun 2, 2023
a112c5e
TRestDetectorReadout.cxx. Removed using namespace std
jgalan Jun 2, 2023
03a88b2
TRestDetectorReadout. Removing unnecessary output
jgalan Jun 2, 2023
317faf8
TRestDetectorReadout. Adding protection against seg.fault
jgalan Jun 3, 2023
e071640
Adding readout validation pipeline
jgalan Jun 3, 2023
99f6166
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 3, 2023
6b4e211
pipeline/readout now uses a bash script for validation
jgalan Jun 5, 2023
8bbdf87
Merge branch 'jgalan-refactoring' of github.com:rest-for-physics/dete…
jgalan Jun 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,51 @@ jobs:
run: |
source ${{ env.REST_PATH }}/thisREST.sh
restRoot -b -q

readout:
name: "Readout"
runs-on: ubuntu-latest
container:
image: ghcr.io/lobis/root-geant4-garfield:rest-for-physics
needs: [ build-detectorlib ]
steps:
- uses: rest-for-physics/framework/.github/actions/checkout@master
with:
branch: ${{ env.BRANCH_NAME }}
repository: rest-for-physics/detectorlib
path: ${{ env.DETECTOR_LIB_PATH }}
- name: Restore cache
uses: actions/cache@v3
id: detectorlib-install-cache
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
run: |
source ${{ env.REST_PATH }}/thisREST.sh
cd ${{ env.DETECTOR_LIB_PATH }}/pipeline/readout
restManager --c generateReadout.rml --o readout.root
restRoot -b -q PrintReadout.C'("readout.root")' > print.txt
source check_readout.sh
# We need to introduce basic validation here
# - diff validation.txt print.txt
# - name: Basic Readout
# run: |
# source ${{ env.REST_PATH }}/thisREST.sh
# cd framework/projects/basic-examples/
# git submodule update --init .
# cd basic-readouts
# git submodule update --init .
# restRoot -b -q GenerateReadouts.C'("basic.root")'
2 changes: 0 additions & 2 deletions inc/TRestDetectorElectronDiffusionProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@

class TRestDetectorElectronDiffusionProcess : public TRestEventProcess {
private:
#ifndef __CINT__
TRestDetectorHitsEvent* fInputHitsEvent; //!
TRestDetectorHitsEvent* fOutputHitsEvent; //!

TRestDetectorGas* fGas; //!
TRestDetectorReadout* fReadout; //!

TRandom3* fRandom; //!
#endif

void InitFromConfigFile() override;

Expand Down
2 changes: 0 additions & 2 deletions inc/TRestDetectorGas.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,8 @@ class TRestDetectorGas : public TRestDetectorDriftVolume {
return fGasComponentFraction[n];
}

#ifndef __CINT__
/// Return pointer to Garfield::MediumGas for gas properties
inline MediumMagboltz* GetGasMedium() const { return fGasMedium; };
#endif

/// Return reference name of the corresponding material in GDML file
inline TString GetGDMLMaterialRef() const { return fGDMLMaterialRef; };
Expand Down
5 changes: 1 addition & 4 deletions inc/TRestDetectorHitsShuffleProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@

class TRestDetectorHitsShuffleProcess : public TRestEventProcess {
private:
#ifndef __CINT__
TRestDetectorHitsEvent* fHitsEvent; //!

TRandom3* fRandom; //!
#endif
TRandom3* fRandom; //!

void InitFromConfigFile() override;

Expand Down
2 changes: 1 addition & 1 deletion inc/TRestDetectorPositionMappingProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class TRestDetectorPositionMappingProcess : public TRestEventProcess {
TRestDetectorPositionMappingProcess();
TRestDetectorPositionMappingProcess(const char* configFilename);

~TRestDetectorPositionMappingProcess();
~TRestDetectorPositionMappingProcess() override;

ClassDefOverride(TRestDetectorPositionMappingProcess, 1);
};
Expand Down
9 changes: 3 additions & 6 deletions inc/TRestDetectorReadout.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#ifndef RestCore_TRestDetectorReadout
#define RestCore_TRestDetectorReadout

#include <TObject.h>
#include <TRestMetadata.h>

#include <iostream>
Expand All @@ -44,12 +43,10 @@ class TRestDetectorReadout : public TRestMetadata {
std::vector<TRestDetectorReadoutPlane>
fReadoutPlanes; ///< A std::vector storing the TRestDetectorReadoutPlane definitions.

#ifndef __CINT__
Int_t fMappingNodes; //!///< Number of nodes per axis used on the readout
//! coordinate mapping. See also TRestDetectorReadoutMapping.
std::vector<TRestDetectorReadoutModule> fModuleDefinitions; //!///< A std::vector storing the different
//! TRestDetectorReadoutModule definitions.
#endif

void ValidateReadout();

Expand All @@ -74,7 +71,7 @@ class TRestDetectorReadout : public TRestMetadata {
/////////////////////////////////////
TRestDetectorReadoutModule* ParseModuleDefinition(TiXmlElement* moduleDefinition);
void GetPlaneModuleChannel(Int_t daqID, Int_t& planeID, Int_t& moduleID, Int_t& channelID);
Int_t GetHitsDaqChannel(const TVector3& hitPosition, Int_t& planeID, Int_t& moduleID, Int_t& channelID);
Int_t GetHitsDaqChannel(const TVector3& position, Int_t& planeID, Int_t& moduleID, Int_t& channelID);
Int_t GetHitsDaqChannelAtReadoutPlane(const TVector3& hitPosition, Int_t& moduleID, Int_t& channelID,
Int_t planeId = 0);
Double_t GetX(Int_t signalID);
Expand All @@ -97,10 +94,10 @@ class TRestDetectorReadout : public TRestMetadata {

// Constructor
TRestDetectorReadout();
TRestDetectorReadout(const char* configFilename);
explicit TRestDetectorReadout(const char* configFilename);
TRestDetectorReadout(const char* configFilename, std::string name);
// Destructor
virtual ~TRestDetectorReadout();
~TRestDetectorReadout() override;

ClassDefOverride(TRestDetectorReadout, 1);
};
Expand Down
7 changes: 3 additions & 4 deletions inc/TRestDetectorReadoutChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#ifndef RestCore_TRestDetectorReadoutChannel
#define RestCore_TRestDetectorReadoutChannel

#include <TObject.h>
#include <TRestMetadata.h>

#include <iostream>
Expand All @@ -42,7 +41,7 @@ enum TRestDetectorReadoutChannelType {

/// A class to store the readout channel definition used in TRestDetectorReadoutModule.
/// It allows to integrate any number of independent readout pixels.
class TRestDetectorReadoutChannel : public TObject {
class TRestDetectorReadoutChannel {
private:
Int_t fDaqID; ///< Defines the corresponding daq channel id. See decoding
///< details at TRestDetectorReadout.
Expand Down Expand Up @@ -87,7 +86,7 @@ class TRestDetectorReadoutChannel : public TObject {
void SetChannelID(Int_t id) { fChannelId = id; }

/// Adds a new pixel to the readout channel
void AddPixel(TRestDetectorReadoutPixel pix) { fReadoutPixel.push_back(pix); }
void AddPixel(const TRestDetectorReadoutPixel& pixel) { fReadoutPixel.emplace_back(pixel); }

Int_t isInside(Double_t x, Double_t y);

Expand All @@ -98,6 +97,6 @@ class TRestDetectorReadoutChannel : public TObject {
// Destructor
virtual ~TRestDetectorReadoutChannel();

ClassDef(TRestDetectorReadoutChannel, 3); // REST run class
ClassDef(TRestDetectorReadoutChannel, 4); // REST run class
};
#endif
18 changes: 8 additions & 10 deletions inc/TRestDetectorReadoutEventViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@

#include <TCanvas.h>
#include <TPad.h>
#include <TRestEventViewer.h>

#include "TRestDetectorSignalEvent.h"
#include "TRestEventViewer.h"
// #include "TRestDecoding.h"
#include "TH2Poly.h"
#include "TRestDetectorReadout.h"
#include "TRestDetectorSignalEvent.h"

class TRestDetectorReadoutEventViewer : public TRestEventViewer {
protected:
TCanvas* fCanvasXY;
TCanvas* fCanvasXZYZ;

// TRestDecoding *fDecoding;
TRestDetectorReadout* fReadout;

TRestDetectorSignalEvent* fSignalEvent;
Expand All @@ -38,26 +36,26 @@ class TRestDetectorReadoutEventViewer : public TRestEventViewer {
TH2D* fHistoXZ;
TH2D* fHistoYZ;

bool isfirstEvent;
bool isFirstevent;

double xmin, xmax, ymin, ymax, zmin, zmax;

public:
void Initialize();
void Initialize() override;
// Finalize initialization based on arg. TRestDetectorReadout
void SetReadout(TRestDetectorReadout* readout);

void AddEvent(TRestEvent* ev);
void AddEvent(TRestEvent* ev) override;
void DrawReadoutPulses();
TRestDetectorReadoutChannel* GetChannel(int readoutChannel);
TRestDetectorReadoutModule* GetModule(int readoutChannel);

// Constructor
TRestDetectorReadoutEventViewer();
// Destructor
~TRestDetectorReadoutEventViewer();
~TRestDetectorReadoutEventViewer() override;

ClassDef(TRestDetectorReadoutEventViewer, 1); // class inherited from
// TRestEventViewer
ClassDefOverride(TRestDetectorReadoutEventViewer, 1); // class inherited from
// TRestEventViewer
};
#endif
9 changes: 4 additions & 5 deletions inc/TRestDetectorReadoutMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
#define RestCore_TRestDetectorReadoutMapping

#include <TMatrixD.h>
#include <TObject.h>

#include <iostream>

/// This class defines a uniform 2-dimensional grid relating its nodes to the
/// pixels of a readout.
class TRestDetectorReadoutMapping : public TObject {
class TRestDetectorReadoutMapping {
private:
Int_t fNodesX; ///< The number of nodes in the x-axis.
Int_t fNodesY; ///< The number of nodes in the y-axis.
Expand All @@ -51,10 +50,10 @@ class TRestDetectorReadoutMapping : public TObject {
/// Returns the number of nodes in Y.
inline Int_t GetNumberOfNodesY() const { return fNodesY; }

/// Gets the channel id correspoding to a given node (i,j)
/// Gets the channel id corresponding to a given node (i,j)
Int_t GetChannelByNode(Int_t i, Int_t j) { return fChannel[i][j]; }

/// Gets the pixel id correspoding to a given node (i,j)
/// Gets the pixel id corresponding to a given node (i,j)
Int_t GetPixelByNode(Int_t i, Int_t j) { return fPixel[i][j]; }

Bool_t isNodeSet(Int_t i, Int_t j);
Expand Down Expand Up @@ -88,6 +87,6 @@ class TRestDetectorReadoutMapping : public TObject {
// Destructor
~TRestDetectorReadoutMapping();

ClassDef(TRestDetectorReadoutMapping, 1);
ClassDef(TRestDetectorReadoutMapping, 2);
};
#endif
Loading