Skip to content

Commit

Permalink
Merge pull request #98 from rest-for-physics/lobis-working-on-veto-re…
Browse files Browse the repository at this point in the history
…adout

Making veto readouts work
  • Loading branch information
lobis authored Sep 28, 2023
2 parents 401ac76 + e745984 commit ba29df4
Show file tree
Hide file tree
Showing 37 changed files with 3,070 additions and 3,336 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ jobs:
source ${{ env.REST_PATH }}/thisREST.sh
cd ${{ env.DETECTOR_LIB_PATH }}/pipeline/readout
restManager --c generateReadout.rml --o readout.root
echo "Generating print.txt"
restRoot -b -q PrintReadout.C'("readout.root")'
ls
echo "Validating"
python3 compareFiles.py
- name: Basic Readout repository tests
run: |
Expand Down
24 changes: 12 additions & 12 deletions inc/TRestDetectorElectronDiffusionProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
#include <TRestDetectorGas.h>
#include <TRestDetectorHitsEvent.h>
#include <TRestDetectorReadout.h>

#include "TRestEventProcess.h"
#include <TRestEventProcess.h>

class TRestDetectorElectronDiffusionProcess : public TRestEventProcess {
private:
Expand All @@ -39,15 +38,14 @@ class TRestDetectorElectronDiffusionProcess : public TRestEventProcess {
Double_t fElectricField;
Double_t fAttachment;
Double_t fGasPressure;
Double_t fWvalue;
Double_t fLonglDiffCoeff;
Double_t fTransDiffCoeff;
Double_t fWValue;
Double_t fLongitudinalDiffusionCoefficient;
Double_t fTransversalDiffusionCoefficient;
Bool_t fPoissonElectronExcitation;
Bool_t fUnitElectronEnergy;

Int_t fMaxHits;

UInt_t fMaxHits;
Double_t fSeed = 0;
Bool_t fCheckIsInside = true;

public:
RESTValue GetInputEvent() const override { return fInputHitsEvent; }
Expand All @@ -65,9 +63,11 @@ class TRestDetectorElectronDiffusionProcess : public TRestEventProcess {
RESTMetadata << " eField : " << fElectricField * units("V/cm") << " V/cm" << RESTendl;
RESTMetadata << " attachment coeficient : " << fAttachment << " V/cm" << RESTendl;
RESTMetadata << " gas pressure : " << fGasPressure << " atm" << RESTendl;
RESTMetadata << " longitudinal diffusion coefficient : " << fLonglDiffCoeff << " cm^1/2" << RESTendl;
RESTMetadata << " transversal diffusion coefficient : " << fTransDiffCoeff << " cm^1/2" << RESTendl;
RESTMetadata << " W value : " << fWvalue << " eV" << RESTendl;
RESTMetadata << " longitudinal diffusion coefficient : " << fLongitudinalDiffusionCoefficient
<< " cm^1/2" << RESTendl;
RESTMetadata << " transversal diffusion coefficient : " << fTransversalDiffusionCoefficient
<< " cm^1/2" << RESTendl;
RESTMetadata << " W value : " << fWValue << " eV" << RESTendl;

RESTMetadata << " Maximum number of hits : " << fMaxHits << RESTendl;

Expand All @@ -90,7 +90,7 @@ class TRestDetectorElectronDiffusionProcess : public TRestEventProcess {
// Destructor
~TRestDetectorElectronDiffusionProcess();

ClassDefOverride(TRestDetectorElectronDiffusionProcess, 3); // Template for a REST "event process" class
ClassDefOverride(TRestDetectorElectronDiffusionProcess, 4); // Template for a REST "event process" class
// inherited from TRestEventProcess
};
#endif
3 changes: 1 addition & 2 deletions inc/TRestDetectorHitsAnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
#include <TRestDetectorHitsEvent.h>
#include <TRestDetectorReadout.h>
#include <TRestDetectorSignalEvent.h>

#include "TRestEventProcess.h"
#include <TRestEventProcess.h>

//! An analysis REST process to extract valuable information from Hits type of data.
class TRestDetectorHitsAnalysisProcess : public TRestEventProcess {
Expand Down
4 changes: 3 additions & 1 deletion inc/TRestDetectorHitsEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TRestDetectorHitsEvent : public TRestEvent {

public:
void AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t t = 0, REST_HitType type = XYZ);
void AddHit(const TVector3& pos, Double_t en, Double_t t = 0, REST_HitType type = XYZ);
void AddHit(const TVector3& position, Double_t energy, Double_t time, REST_HitType type = XYZ);

void Sort(bool(compareCondition)(const TRestHits::iterator& hit1,
const TRestHits::iterator& hit2) = nullptr);
Expand Down Expand Up @@ -123,6 +123,8 @@ class TRestDetectorHitsEvent : public TRestEvent {
inline Double_t GetEnergyX() const { return fHits->GetEnergyX(); }
inline Double_t GetEnergyY() const { return fHits->GetEnergyY(); }
inline Double_t GetTotalEnergy() const { return fHits->GetTotalEnergy(); }
inline Double_t GetEnergy() const { return fHits->GetTotalEnergy(); }

inline Double_t GetEnergy(int n) const { return fHits->GetEnergy(n); }
inline Double_t GetTime(int n) const { return GetHits()->GetTime(n); } // return value in us

Expand Down
54 changes: 54 additions & 0 deletions inc/TRestDetectorHitsReadoutAnalysisProcess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// Created by lobis on 03-Sep-23.
//

#ifndef REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H
#define REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H

#include <TCanvas.h>
#include <TH1D.h>
#include <TRestDetectorGas.h>
#include <TRestDetectorHitsEvent.h>
#include <TRestDetectorReadout.h>
#include <TRestDetectorSignalEvent.h>
#include <TRestEventProcess.h>

//! An analysis REST process to extract valuable information from Hits type of data.
class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess {
private:
TRestDetectorHitsEvent* fInputHitsEvent; //!
TRestDetectorHitsEvent* fOutputHitsEvent; //!

void InitFromConfigFile() override;
void Initialize() override;
void LoadDefaultConfig(){};

/// \brief This process will only work on hits corresponding to this channel type (using readout)
std::string fChannelType;
TVector3 fFiducialPosition;
Double_t fFiducialDiameter = 0;
bool fRemoveZeroEnergyEvents = false;

TRestDetectorReadout* fReadout = nullptr; //!

public:
RESTValue GetInputEvent() const override { return fInputHitsEvent; }
RESTValue GetOutputEvent() const override { return fOutputHitsEvent; }

void InitProcess() override;
TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
void EndProcess() override;

void PrintMetadata() override;

const char* GetProcessName() const override { return "readoutHitsAnalysis"; }

TRestDetectorHitsReadoutAnalysisProcess() = default;
TRestDetectorHitsReadoutAnalysisProcess(const char* configFilename) {}

~TRestDetectorHitsReadoutAnalysisProcess() override = default;

ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 2);
};

#endif // REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H
5 changes: 3 additions & 2 deletions inc/TRestDetectorHitsToSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "TRestDetectorHitsEvent.h"
#include "TRestDetectorReadout.h"
#include "TRestDetectorSignalEvent.h"
#include "TRestPhysics.h"

//! A process to transform a x,y,z coordinate hits into daq identified physical time signals
class TRestDetectorHitsToSignalProcess : public TRestEventProcess {
Expand All @@ -39,7 +40,7 @@ class TRestDetectorHitsToSignalProcess : public TRestEventProcess {
/// A pointer to the specific TRestDetectorHitsEvent input
TRestDetectorSignalEvent* fSignalEvent; //!

/// A pointer to the detector readout definition accesible to TRestRun
/// A pointer to the detector readout definition available to TRestRun
TRestDetectorReadout* fReadout; //!

/// A pointer to the detector gas definition accessible to TRestRun
Expand Down Expand Up @@ -90,6 +91,6 @@ class TRestDetectorHitsToSignalProcess : public TRestEventProcess {
TRestDetectorHitsToSignalProcess(const char* configFilename);
~TRestDetectorHitsToSignalProcess();

ClassDefOverride(TRestDetectorHitsToSignalProcess, 1);
ClassDefOverride(TRestDetectorHitsToSignalProcess, 3);
};
#endif
53 changes: 53 additions & 0 deletions inc/TRestDetectorLightAttenuationProcess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Created by lobis on 25-Aug-23.
//

#ifndef REST_TRESTDETECTORLIGHTATTENUATIONPROCESS_H
#define REST_TRESTDETECTORLIGHTATTENUATIONPROCESS_H

#include <TRandom3.h>
#include <TRestEventProcess.h>

#include "TRestDetectorHitsEvent.h"
#include "TRestDetectorReadout.h"

/// A process to include detector energy resolution in a TRestDetectorHitsEvent
class TRestDetectorLightAttenuationProcess : public TRestEventProcess {
private:
TRestDetectorHitsEvent* fInputEvent; //!
TRestDetectorHitsEvent* fOutputEvent; //!

TRestDetectorReadout* fReadout; //!

/// Length of the light attenuation in the veto. One length reduces the signal amplitude to 1/e of the
/// original
Double_t fVetoLightAttenuationLength = 0.0; // mm
/// Effective light speed for veto signals. Used to compute travel time from the interaction point to the
/// veto readout.
Double_t fVetoEffectiveLightSpeed = REST_Physics::lightSpeed; // mm/us

void Initialize() override {}
void LoadDefaultConfig() {}

public:
RESTValue GetInputEvent() const override { return fInputEvent; }
RESTValue GetOutputEvent() const override { return fOutputEvent; }

void InitProcess() override;
void EndProcess() override {}

TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;

void PrintMetadata() override;

TRestDetectorLightAttenuationProcess() = default;
explicit TRestDetectorLightAttenuationProcess(const char* configFilename){};

const char* GetProcessName() const override { return "lightAttenuation"; }

~TRestDetectorLightAttenuationProcess() override = default;

ClassDefOverride(TRestDetectorLightAttenuationProcess, 1);
};

#endif // REST_TRESTDETECTORLIGHTATTENUATIONPROCESS_H
27 changes: 18 additions & 9 deletions inc/TRestDetectorReadout.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class TRestDetectorReadout : public TRestMetadata {

void Initialize() override;

Int_t fNReadoutPlanes; ///< Number of readout planes present on the readout
std::vector<TRestDetectorReadoutPlane>
fReadoutPlanes; ///< A std::vector storing the TRestDetectorReadoutPlane definitions.

Expand All @@ -45,32 +44,42 @@ class TRestDetectorReadout : public TRestMetadata {
std::vector<TRestDetectorReadoutModule> fModuleDefinitions; //!///< A std::vector storing the different
//! TRestDetectorReadoutModule definitions.

void ValidateReadout();
void ValidateReadout() const;

public:
TRestDetectorReadoutPlane& operator[](int p) { return fReadoutPlanes[p]; }

TRestDetectorReadoutPlane* GetReadoutPlane(int p);
void AddReadoutPlane(TRestDetectorReadoutPlane plane);
void AddReadoutPlane(const TRestDetectorReadoutPlane& plane);

/////////////////////////////////////
TRestDetectorReadoutPlane* GetReadoutPlaneWithID(int id);
TRestDetectorReadoutModule* GetReadoutModuleWithID(int id);
TRestDetectorReadoutChannel* GetReadoutChannelWithDaqID(int daqId);
/////////////////////////////////////

Int_t GetNumberOfReadoutPlanes();
Int_t GetNumberOfReadoutPlanes() const { return fReadoutPlanes.size(); }
Int_t GetNumberOfModules();
Int_t GetNumberOfChannels();

Int_t GetModuleDefinitionId(TString name);
Int_t GetModuleDefinitionId(const TString& name);

/////////////////////////////////////
TRestDetectorReadoutModule* ParseModuleDefinition(TiXmlElement* moduleDefinition);
void GetPlaneModuleChannel(Int_t daqID, 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);

/// Returns a tuple with the DaqID, ModuleID, ChannelID
std::tuple<Int_t, Int_t, Int_t> GetHitsDaqChannelAtReadoutPlane(const TVector3& position,
Int_t planeId = 0);

/// \brief Returns the DaqID of the channel for position. If no channel is found returns -1
Int_t GetDaqId(const TVector3& position, bool check = true);

std::string GetTypeForChannelDaqId(Int_t daqId);

std::set<Int_t> GetAllDaqIds();

Double_t GetX(Int_t signalID);
Double_t GetY(Int_t signalID);
/////////////////////////////////////
Expand All @@ -94,10 +103,10 @@ class TRestDetectorReadout : public TRestMetadata {
// Constructor
TRestDetectorReadout();
explicit TRestDetectorReadout(const char* configFilename);
TRestDetectorReadout(const char* configFilename, std::string name);
TRestDetectorReadout(const char* configFilename, const std::string& name);
// Destructor
~TRestDetectorReadout() override;

ClassDefOverride(TRestDetectorReadout, 2);
ClassDefOverride(TRestDetectorReadout, 3);
};
#endif
42 changes: 22 additions & 20 deletions inc/TRestDetectorReadoutChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@

#include "TRestDetectorReadoutPixel.h"

enum TRestDetectorReadoutChannelType {
Channel_NoType = 0,
Channel_Pixel = 1,
Channel_X = 2,
Channel_Y = 3,
Channel_U = 4,
Channel_V = 5,
Channel_W = 6,
};

/// A class to store the readout channel definition used in TRestDetectorReadoutModule.
/// It allows to integrate any number of independent readout pixels.
class TRestDetectorReadoutChannel {
Expand All @@ -50,15 +40,30 @@ class TRestDetectorReadoutChannel {

Short_t fChannelId = -1; ///< It stores the corresponding physical readout channel

std::string fName; // Name of the signal
std::string fType; // Type of the signal

void Initialize();

public:
/// Returns the corresponding daq channel id
inline Int_t GetDaqID() const { return fDaqID; }

/// Returns the channel name
inline std::string GetName() const { return fName; }

/// Returns the channel type
inline std::string GetType() const { return fType; }

/// Returns the corresponding channel id
inline Int_t GetChannelId() const { return fChannelId; }

std::string GetChannelName() const { return fName; }
std::string GetChannelType() const { return fType; }

void SetChannelName(const std::string& name) { fName = name; }
void SetChannelType(const std::string& type) { fType = type; }

/// Returns the total number of pixels inside the readout channel
Int_t GetNumberOfPixels() { return fReadoutPixel.size(); }

Expand All @@ -70,15 +75,6 @@ class TRestDetectorReadoutChannel {
return &fReadoutPixel[n];
}

void SetType(TRestDetectorReadoutChannelType type) {
// in future we may implement this
}

TRestDetectorReadoutChannelType GetType() {
// in future we may implement this
return Channel_NoType;
}

/// Sets the daq channel number id
void SetDaqID(Int_t id) { fDaqID = id; }

Expand All @@ -88,6 +84,12 @@ class TRestDetectorReadoutChannel {
/// Adds a new pixel to the readout channel
void AddPixel(const TRestDetectorReadoutPixel& pixel) { fReadoutPixel.emplace_back(pixel); }

/// Sets the channel name
void SetName(const std::string& name) { fName = name; }

/// Sets the channel type
void SetType(const std::string& type) { fType = type; }

Int_t isInside(Double_t x, Double_t y);

void Print(int DetailLevel = 0);
Expand All @@ -97,6 +99,6 @@ class TRestDetectorReadoutChannel {
// Destructor
virtual ~TRestDetectorReadoutChannel();

ClassDef(TRestDetectorReadoutChannel, 4); // REST run class
ClassDef(TRestDetectorReadoutChannel, 6); // REST run class
};
#endif
Loading

0 comments on commit ba29df4

Please sign in to comment.