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

Implementing generic analysis methods inside detectorlib #75

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
21 changes: 6 additions & 15 deletions inc/TRestDetectorSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,7 @@ class TRestDetectorSignal {
public:
TGraph* fGraph; //!

std::vector<Int_t> fPointsOverThreshold; //!

void IncreaseAmplitude(TVector2 p);
void SetPoint(TVector2 p);

// TODO other objects should probably skip using GetMaxIndex direclty
Int_t GetMaxIndex(Int_t from = 0, Int_t to = 0);
Int_t GetMaxIndex();

TVector2 GetMaxGauss();
TVector2 GetMaxLandau();
Expand Down Expand Up @@ -87,16 +81,13 @@ class TRestDetectorSignal {

void Normalize(Double_t scale = 1.);

std::vector<Int_t> GetPointsOverThreshold() { return fPointsOverThreshold; }

Double_t GetAverage(Int_t start = 0, Int_t end = 0);
Int_t GetMaxPeakWidth();
Double_t GetMaxPeakWithTime(Double_t startTime, Double_t endTime);

Double_t GetMaxPeakValue();
Double_t GetMinPeakValue();

Double_t GetMaxPeakTime(Int_t from = 0, Int_t to = 0);
Double_t GetMaxPeakTime();

Double_t GetMaxValue() { return GetMaxPeakValue(); }
Double_t GetMinValue() { return GetMinPeakValue(); }
Expand All @@ -112,16 +103,16 @@ class TRestDetectorSignal {
void SetID(Int_t sID) { fSignalID = sID; }

void NewPoint(Float_t time, Float_t data);
void IncreaseAmplitude(const TVector2& p);
void IncreaseAmplitude(Double_t t, Double_t d);

void SetPoint(Double_t t, Double_t d);
void SetPoint(const TVector2& p);
void SetPoint(Int_t index, Double_t t, Double_t d);

Double_t GetStandardDeviation(Int_t startBin, Int_t endBin);
Double_t GetBaseLine(Int_t startBin, Int_t endBin);
Double_t GetBaseLineSigma(Int_t startBin, Int_t endBin, Double_t baseline = 0);
void CalculateBaseLineAndSigma(Int_t startBin, Int_t endBin, Double_t& baseline, Double_t& baseLineSigma);
Copy link
Member

@jgalan jgalan Mar 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it makes no sense to have a baseline at the detector signal level. This is a stage where we have already applied data reduction. And in the best case reduced our waveforms into physical times and amplitudes.

It was kind of first approach to take all points from raw to detector signal. But we should move towards a reconstruction that reduces the data.

I understand the issue with short_t precision in rawlib, that's why I think having a std::vector <float_t> or even std::vector <double> implemented inside TRestRawSignal would solve this problem, so it this vector is not empty it means a process has filled it, and then processing will continue at float_t or double_t levels.

That way you leave also all time-signal processing routines contained within rawlib, which was one of the duties of the raw library. To compile all those codes used for time signal processing into a single entity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions can be indeed deleted, however I don't know if it is a good idea to define a std::vector <float_t> inside rawlib since it could be misleading. Which data is supposse to hold? Data with baseline substracted, points over threshold or smoothed data?

There are as well signal processing functions that can be used in other context, e.g. tripleMax, GausFit and many others are currently implemented inside detectorlib (actually tripleMax was duplicated inside rawlib). But in principle one could try to perform a gaussian fit to a TRestRawSignalEvent.

I believe that to make a generic class or namespace inside framework for signal analysis or processing is the way to go...


Double_t SubstractBaseline(Int_t startBin, Int_t endBin);
void SubstractBaseline(Int_t startBin, Int_t endBin);
void AddOffset(Double_t offset);

void MultiplySignalBy(Double_t factor);
Expand Down
8 changes: 8 additions & 0 deletions inc/TRestDetectorSignalToHitsProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ class TRestDetectorSignalToHitsProcess : public TRestEventProcess {

void LoadConfig(const std::string& configFilename, const std::string& name = "");

/// Returns the Z coordinate from the hitTime, drifVelocity, fieldZDirection and zPositon (relative to the
/// readout)
inline Double_t GetHitZCoordinate(Double_t hitTime, Double_t driftVelocity, Double_t fieldZDirection,
Double_t zPosition) const {
const Double_t distanceToPlane = hitTime * fDriftVelocity;
return zPosition + fieldZDirection * distanceToPlane;
}

/// It prints out the process parameters stored in the metadata structure
void PrintMetadata() override {
BeginPrintProcess();
Expand Down
Loading