Skip to content

Commit ba29df4

Browse files
authored
Merge pull request #98 from rest-for-physics/lobis-working-on-veto-readout
Making veto readouts work
2 parents 401ac76 + e745984 commit ba29df4

37 files changed

+3070
-3336
lines changed

.github/workflows/validation.yml

-3
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ jobs:
104104
source ${{ env.REST_PATH }}/thisREST.sh
105105
cd ${{ env.DETECTOR_LIB_PATH }}/pipeline/readout
106106
restManager --c generateReadout.rml --o readout.root
107-
echo "Generating print.txt"
108107
restRoot -b -q PrintReadout.C'("readout.root")'
109-
ls
110-
echo "Validating"
111108
python3 compareFiles.py
112109
- name: Basic Readout repository tests
113110
run: |

inc/TRestDetectorElectronDiffusionProcess.h

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
#include <TRestDetectorGas.h>
1717
#include <TRestDetectorHitsEvent.h>
1818
#include <TRestDetectorReadout.h>
19-
20-
#include "TRestEventProcess.h"
19+
#include <TRestEventProcess.h>
2120

2221
class TRestDetectorElectronDiffusionProcess : public TRestEventProcess {
2322
private:
@@ -39,15 +38,14 @@ class TRestDetectorElectronDiffusionProcess : public TRestEventProcess {
3938
Double_t fElectricField;
4039
Double_t fAttachment;
4140
Double_t fGasPressure;
42-
Double_t fWvalue;
43-
Double_t fLonglDiffCoeff;
44-
Double_t fTransDiffCoeff;
41+
Double_t fWValue;
42+
Double_t fLongitudinalDiffusionCoefficient;
43+
Double_t fTransversalDiffusionCoefficient;
4544
Bool_t fPoissonElectronExcitation;
4645
Bool_t fUnitElectronEnergy;
47-
48-
Int_t fMaxHits;
49-
46+
UInt_t fMaxHits;
5047
Double_t fSeed = 0;
48+
Bool_t fCheckIsInside = true;
5149

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

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

@@ -90,7 +90,7 @@ class TRestDetectorElectronDiffusionProcess : public TRestEventProcess {
9090
// Destructor
9191
~TRestDetectorElectronDiffusionProcess();
9292

93-
ClassDefOverride(TRestDetectorElectronDiffusionProcess, 3); // Template for a REST "event process" class
93+
ClassDefOverride(TRestDetectorElectronDiffusionProcess, 4); // Template for a REST "event process" class
9494
// inherited from TRestEventProcess
9595
};
9696
#endif

inc/TRestDetectorHitsAnalysisProcess.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
#include <TRestDetectorHitsEvent.h>
3030
#include <TRestDetectorReadout.h>
3131
#include <TRestDetectorSignalEvent.h>
32-
33-
#include "TRestEventProcess.h"
32+
#include <TRestEventProcess.h>
3433

3534
//! An analysis REST process to extract valuable information from Hits type of data.
3635
class TRestDetectorHitsAnalysisProcess : public TRestEventProcess {

inc/TRestDetectorHitsEvent.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class TRestDetectorHitsEvent : public TRestEvent {
5555

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

6060
void Sort(bool(compareCondition)(const TRestHits::iterator& hit1,
6161
const TRestHits::iterator& hit2) = nullptr);
@@ -123,6 +123,8 @@ class TRestDetectorHitsEvent : public TRestEvent {
123123
inline Double_t GetEnergyX() const { return fHits->GetEnergyX(); }
124124
inline Double_t GetEnergyY() const { return fHits->GetEnergyY(); }
125125
inline Double_t GetTotalEnergy() const { return fHits->GetTotalEnergy(); }
126+
inline Double_t GetEnergy() const { return fHits->GetTotalEnergy(); }
127+
126128
inline Double_t GetEnergy(int n) const { return fHits->GetEnergy(n); }
127129
inline Double_t GetTime(int n) const { return GetHits()->GetTime(n); } // return value in us
128130

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//
2+
// Created by lobis on 03-Sep-23.
3+
//
4+
5+
#ifndef REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H
6+
#define REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H
7+
8+
#include <TCanvas.h>
9+
#include <TH1D.h>
10+
#include <TRestDetectorGas.h>
11+
#include <TRestDetectorHitsEvent.h>
12+
#include <TRestDetectorReadout.h>
13+
#include <TRestDetectorSignalEvent.h>
14+
#include <TRestEventProcess.h>
15+
16+
//! An analysis REST process to extract valuable information from Hits type of data.
17+
class TRestDetectorHitsReadoutAnalysisProcess : public TRestEventProcess {
18+
private:
19+
TRestDetectorHitsEvent* fInputHitsEvent; //!
20+
TRestDetectorHitsEvent* fOutputHitsEvent; //!
21+
22+
void InitFromConfigFile() override;
23+
void Initialize() override;
24+
void LoadDefaultConfig(){};
25+
26+
/// \brief This process will only work on hits corresponding to this channel type (using readout)
27+
std::string fChannelType;
28+
TVector3 fFiducialPosition;
29+
Double_t fFiducialDiameter = 0;
30+
bool fRemoveZeroEnergyEvents = false;
31+
32+
TRestDetectorReadout* fReadout = nullptr; //!
33+
34+
public:
35+
RESTValue GetInputEvent() const override { return fInputHitsEvent; }
36+
RESTValue GetOutputEvent() const override { return fOutputHitsEvent; }
37+
38+
void InitProcess() override;
39+
TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
40+
void EndProcess() override;
41+
42+
void PrintMetadata() override;
43+
44+
const char* GetProcessName() const override { return "readoutHitsAnalysis"; }
45+
46+
TRestDetectorHitsReadoutAnalysisProcess() = default;
47+
TRestDetectorHitsReadoutAnalysisProcess(const char* configFilename) {}
48+
49+
~TRestDetectorHitsReadoutAnalysisProcess() override = default;
50+
51+
ClassDefOverride(TRestDetectorHitsReadoutAnalysisProcess, 2);
52+
};
53+
54+
#endif // REST_TRESTDETECTORHITSREADOUTANALYSISPROCESS_H

inc/TRestDetectorHitsToSignalProcess.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "TRestDetectorHitsEvent.h"
3030
#include "TRestDetectorReadout.h"
3131
#include "TRestDetectorSignalEvent.h"
32+
#include "TRestPhysics.h"
3233

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

42-
/// A pointer to the detector readout definition accesible to TRestRun
43+
/// A pointer to the detector readout definition available to TRestRun
4344
TRestDetectorReadout* fReadout; //!
4445

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

93-
ClassDefOverride(TRestDetectorHitsToSignalProcess, 1);
94+
ClassDefOverride(TRestDetectorHitsToSignalProcess, 3);
9495
};
9596
#endif
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// Created by lobis on 25-Aug-23.
3+
//
4+
5+
#ifndef REST_TRESTDETECTORLIGHTATTENUATIONPROCESS_H
6+
#define REST_TRESTDETECTORLIGHTATTENUATIONPROCESS_H
7+
8+
#include <TRandom3.h>
9+
#include <TRestEventProcess.h>
10+
11+
#include "TRestDetectorHitsEvent.h"
12+
#include "TRestDetectorReadout.h"
13+
14+
/// A process to include detector energy resolution in a TRestDetectorHitsEvent
15+
class TRestDetectorLightAttenuationProcess : public TRestEventProcess {
16+
private:
17+
TRestDetectorHitsEvent* fInputEvent; //!
18+
TRestDetectorHitsEvent* fOutputEvent; //!
19+
20+
TRestDetectorReadout* fReadout; //!
21+
22+
/// Length of the light attenuation in the veto. One length reduces the signal amplitude to 1/e of the
23+
/// original
24+
Double_t fVetoLightAttenuationLength = 0.0; // mm
25+
/// Effective light speed for veto signals. Used to compute travel time from the interaction point to the
26+
/// veto readout.
27+
Double_t fVetoEffectiveLightSpeed = REST_Physics::lightSpeed; // mm/us
28+
29+
void Initialize() override {}
30+
void LoadDefaultConfig() {}
31+
32+
public:
33+
RESTValue GetInputEvent() const override { return fInputEvent; }
34+
RESTValue GetOutputEvent() const override { return fOutputEvent; }
35+
36+
void InitProcess() override;
37+
void EndProcess() override {}
38+
39+
TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
40+
41+
void PrintMetadata() override;
42+
43+
TRestDetectorLightAttenuationProcess() = default;
44+
explicit TRestDetectorLightAttenuationProcess(const char* configFilename){};
45+
46+
const char* GetProcessName() const override { return "lightAttenuation"; }
47+
48+
~TRestDetectorLightAttenuationProcess() override = default;
49+
50+
ClassDefOverride(TRestDetectorLightAttenuationProcess, 1);
51+
};
52+
53+
#endif // REST_TRESTDETECTORLIGHTATTENUATIONPROCESS_H

inc/TRestDetectorReadout.h

+18-9
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class TRestDetectorReadout : public TRestMetadata {
3636

3737
void Initialize() override;
3838

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

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

48-
void ValidateReadout();
47+
void ValidateReadout() const;
4948

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

5352
TRestDetectorReadoutPlane* GetReadoutPlane(int p);
54-
void AddReadoutPlane(TRestDetectorReadoutPlane plane);
53+
void AddReadoutPlane(const TRestDetectorReadoutPlane& plane);
5554

5655
/////////////////////////////////////
5756
TRestDetectorReadoutPlane* GetReadoutPlaneWithID(int id);
5857
TRestDetectorReadoutModule* GetReadoutModuleWithID(int id);
5958
TRestDetectorReadoutChannel* GetReadoutChannelWithDaqID(int daqId);
6059
/////////////////////////////////////
6160

62-
Int_t GetNumberOfReadoutPlanes();
61+
Int_t GetNumberOfReadoutPlanes() const { return fReadoutPlanes.size(); }
6362
Int_t GetNumberOfModules();
6463
Int_t GetNumberOfChannels();
6564

66-
Int_t GetModuleDefinitionId(TString name);
65+
Int_t GetModuleDefinitionId(const TString& name);
6766

6867
/////////////////////////////////////
6968
TRestDetectorReadoutModule* ParseModuleDefinition(TiXmlElement* moduleDefinition);
7069
void GetPlaneModuleChannel(Int_t daqID, Int_t& planeID, Int_t& moduleID, Int_t& channelID);
7170
Int_t GetHitsDaqChannel(const TVector3& position, Int_t& planeID, Int_t& moduleID, Int_t& channelID);
72-
Int_t GetHitsDaqChannelAtReadoutPlane(const TVector3& hitPosition, Int_t& moduleID, Int_t& channelID,
73-
Int_t planeId = 0);
71+
72+
/// Returns a tuple with the DaqID, ModuleID, ChannelID
73+
std::tuple<Int_t, Int_t, Int_t> GetHitsDaqChannelAtReadoutPlane(const TVector3& position,
74+
Int_t planeId = 0);
75+
76+
/// \brief Returns the DaqID of the channel for position. If no channel is found returns -1
77+
Int_t GetDaqId(const TVector3& position, bool check = true);
78+
79+
std::string GetTypeForChannelDaqId(Int_t daqId);
80+
81+
std::set<Int_t> GetAllDaqIds();
82+
7483
Double_t GetX(Int_t signalID);
7584
Double_t GetY(Int_t signalID);
7685
/////////////////////////////////////
@@ -94,10 +103,10 @@ class TRestDetectorReadout : public TRestMetadata {
94103
// Constructor
95104
TRestDetectorReadout();
96105
explicit TRestDetectorReadout(const char* configFilename);
97-
TRestDetectorReadout(const char* configFilename, std::string name);
106+
TRestDetectorReadout(const char* configFilename, const std::string& name);
98107
// Destructor
99108
~TRestDetectorReadout() override;
100109

101-
ClassDefOverride(TRestDetectorReadout, 2);
110+
ClassDefOverride(TRestDetectorReadout, 3);
102111
};
103112
#endif

inc/TRestDetectorReadoutChannel.h

+22-20
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@
2929

3030
#include "TRestDetectorReadoutPixel.h"
3131

32-
enum TRestDetectorReadoutChannelType {
33-
Channel_NoType = 0,
34-
Channel_Pixel = 1,
35-
Channel_X = 2,
36-
Channel_Y = 3,
37-
Channel_U = 4,
38-
Channel_V = 5,
39-
Channel_W = 6,
40-
};
41-
4232
/// A class to store the readout channel definition used in TRestDetectorReadoutModule.
4333
/// It allows to integrate any number of independent readout pixels.
4434
class TRestDetectorReadoutChannel {
@@ -50,15 +40,30 @@ class TRestDetectorReadoutChannel {
5040

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

43+
std::string fName; // Name of the signal
44+
std::string fType; // Type of the signal
45+
5346
void Initialize();
5447

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

52+
/// Returns the channel name
53+
inline std::string GetName() const { return fName; }
54+
55+
/// Returns the channel type
56+
inline std::string GetType() const { return fType; }
57+
5958
/// Returns the corresponding channel id
6059
inline Int_t GetChannelId() const { return fChannelId; }
6160

61+
std::string GetChannelName() const { return fName; }
62+
std::string GetChannelType() const { return fType; }
63+
64+
void SetChannelName(const std::string& name) { fName = name; }
65+
void SetChannelType(const std::string& type) { fType = type; }
66+
6267
/// Returns the total number of pixels inside the readout channel
6368
Int_t GetNumberOfPixels() { return fReadoutPixel.size(); }
6469

@@ -70,15 +75,6 @@ class TRestDetectorReadoutChannel {
7075
return &fReadoutPixel[n];
7176
}
7277

73-
void SetType(TRestDetectorReadoutChannelType type) {
74-
// in future we may implement this
75-
}
76-
77-
TRestDetectorReadoutChannelType GetType() {
78-
// in future we may implement this
79-
return Channel_NoType;
80-
}
81-
8278
/// Sets the daq channel number id
8379
void SetDaqID(Int_t id) { fDaqID = id; }
8480

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

87+
/// Sets the channel name
88+
void SetName(const std::string& name) { fName = name; }
89+
90+
/// Sets the channel type
91+
void SetType(const std::string& type) { fType = type; }
92+
9193
Int_t isInside(Double_t x, Double_t y);
9294

9395
void Print(int DetailLevel = 0);
@@ -97,6 +99,6 @@ class TRestDetectorReadoutChannel {
9799
// Destructor
98100
virtual ~TRestDetectorReadoutChannel();
99101

100-
ClassDef(TRestDetectorReadoutChannel, 4); // REST run class
102+
ClassDef(TRestDetectorReadoutChannel, 6); // REST run class
101103
};
102104
#endif

0 commit comments

Comments
 (0)