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

Peak Analysis #117

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions inc/TRestRawFFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TRestRawFFT : public TObject {

inline Int_t GetNfft() const { return fNfft; }

void GetSignal(TRestRawSignal* sgnl);
void GetSignal(TRestRawSignal* signal);

// Setters
void SetNfft(Int_t n);
Expand All @@ -56,7 +56,7 @@ class TRestRawFFT : public TObject {
void GaussianSecondOrderResponse(Double_t f1, Double_t f2, Double_t Ao, Double_t sigma);

// FFT processing
void ForwardSignalFFT(TRestRawSignal* sgnl, Int_t fNStart = 0, Int_t fNEnd = 0);
void ForwardSignalFFT(TRestRawSignal* signal, Int_t fNStart = 0, Int_t fNEnd = 0);
void BackwardFFT();

void RenormalizeNode(Int_t n, Double_t factor);
Expand Down
10 changes: 8 additions & 2 deletions inc/TRestRawSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <iostream>
#include <string>
#include <utility>
#include <vector>

//! It defines a Short_t array with a physical parameter that evolves in time using a fixed time bin.
Expand Down Expand Up @@ -87,7 +88,7 @@ class TRestRawSignal {
inline Int_t GetID() const { return fSignalID; }

/// Returns the actual number of points, or size of the signal
inline Int_t GetNumberOfPoints() const { return fSignalData.size(); }
inline size_t GetNumberOfPoints() const { return fSignalData.size(); }

/// Returns a std::vector containing the indexes of data points over threshold
inline std::vector<Int_t> GetPointsOverThreshold() const { return fPointsOverThreshold; }
Expand Down Expand Up @@ -118,11 +119,16 @@ class TRestRawSignal {
/// Returns false if the baseline and its baseline fluctuation was not initialized.
inline Bool_t isBaseLineInitialized() const { return !(fBaseLineSigma == 0 && fBaseLine == 0); }

/// Returns the (time, amplitude) of the peaks in the signal.
/// Peaks are defined as the points that are above the threshold and are separated by a minimum distance
/// in time bin units. The threshold must be set in absolute value (regardless of the baseline)
std::vector<std::pair<UShort_t, double>> GetPeaks(double threshold, UShort_t distance = 5) const;

Double_t GetData(Int_t n) const;

Double_t GetRawData(Int_t n) const;

Short_t operator[](Int_t n);
Short_t operator[](size_t n);

/// It sets the id number of the signal
inline void SetSignalID(Int_t sID) { fSignalID = sID; }
Expand Down
6 changes: 3 additions & 3 deletions inc/TRestRawSignalEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class TRestRawSignalEvent : public TRestEvent {

void RemoveSignalWithId(Int_t sId);

void AddChargeToSignal(Int_t sgnlID, Int_t bin, Short_t value);
void AddChargeToSignal(Int_t signalID, Int_t bin, Short_t value);

void SetTailPoints(Int_t p) {
for (int n = 0; n < GetNumberOfSignals(); n++) fSignal[n].SetTailPoints(p);
Expand Down Expand Up @@ -146,8 +146,8 @@ class TRestRawSignalEvent : public TRestEvent {

Double_t GetMaxValue();
Double_t GetMinValue();
Double_t GetMinTime();
Double_t GetMaxTime();
Double_t GetMinTime() const;
Double_t GetMaxTime() const;

// Default
void Initialize();
Expand Down
2 changes: 1 addition & 1 deletion inc/TRestRawUSTCToSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct USTCDataFrame {
class TRestRawUSTCToSignalProcess : public TRestRawToSignalProcess {
private:
#ifndef __CINT__
TRestRawSignal sgnl; //!
TRestRawSignal signal; //!

UChar_t fHeader[64];
UChar_t fEnding[32];
Expand Down
4 changes: 2 additions & 2 deletions inc/TRestRawVetoAnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class TRestRawVetoAnalysisProcess : public TRestEventProcess {
return output;
}

Int_t GetGroupIndex(std::string groupName);
std::string GetGroupIds(std::string groupName);
Int_t GetGroupIndex(const std::string& groupName);
std::string GetGroupIds(const std::string& groupName);

TRestRawVetoAnalysisProcess();
TRestRawVetoAnalysisProcess(const char* configFilename);
Expand Down
8 changes: 4 additions & 4 deletions pipeline/processes/commonNoise/commonNoise.C
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Int_t commonNoise() {
TRestRawSignalEvent* ev = new TRestRawSignalEvent();

TRestRawSignal* sgnl = new TRestRawSignal();
for (int n = 0; n < 512; n++) sgnl->AddPoint((Short_t)(50 * TMath::Sin(2 * TMath::Pi() * n / 200)));
TRestRawSignal* signal = new TRestRawSignal();
for (int n = 0; n < 512; n++) signal->AddPoint((Short_t)(50 * TMath::Sin(2 * TMath::Pi() * n / 200)));

for (int n = 0; n < 205; n++) {
sgnl->SetID(n);
ev->AddSignal(*sgnl);
signal->SetID(n);
ev->AddSignal(*signal);
}

string cfgFile = "metadata.rml";
Expand Down
8 changes: 4 additions & 4 deletions pipeline/processes/fit/GeneralFit.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ using namespace std;
Int_t GeneralFit(Bool_t draw = false) {
TRestRawSignalEvent* ev = new TRestRawSignalEvent();

TRestRawSignal* sgnl = new TRestRawSignal();
TRestRawSignal* signal = new TRestRawSignal();
for (int n = 0; n < 512; n++) {
sgnl->AddPoint((Double_t)0);
signal->AddPoint((Double_t)0);
}
sgnl->IncreaseBinBy(70, 100);
ev->AddSignal(*sgnl);
signal->IncreaseBinBy(70, 100);
ev->AddSignal(*signal);

///// Initializing processes through metadata definition
string cfgFile = "metadata.rml";
Expand Down
8 changes: 4 additions & 4 deletions pipeline/processes/fit/fit.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ using namespace std;
Int_t fit(Bool_t draw = false) {
TRestRawSignalEvent* ev = new TRestRawSignalEvent();

TRestRawSignal* sgnl = new TRestRawSignal();
for (int n = 0; n < 512; n++) sgnl->AddPoint(0);
sgnl->IncreaseBinBy(70, 100);
ev->AddSignal(*sgnl);
TRestRawSignal* signal = new TRestRawSignal();
for (int n = 0; n < 512; n++) signal->AddPoint(0);
signal->IncreaseBinBy(70, 100);
ev->AddSignal(*signal);

///// Initializing processes through metadata definition
string cfgFile = "metadata.rml";
Expand Down
6 changes: 3 additions & 3 deletions pipeline/processes/noise/addNoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

rawEv = ROOT.TRestRawSignalEvent()

sgnl = ROOT.TRestRawSignal()
signal = ROOT.TRestRawSignal()

for x in range(0, 512):
sgnl.AddPoint(0)
signal.AddPoint(0)

rawEv.AddSignal(sgnl)
rawEv.AddSignal(signal)

addNoiseProcess = ROOT.TRestRawSignalAddNoiseProcess("metadata.rml")

Expand Down
28 changes: 14 additions & 14 deletions pipeline/processes/shaping/shaping.C
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Int_t shaping(Bool_t draw = false) {
TRestRawSignalEvent* ev = new TRestRawSignalEvent();

TRestRawSignal* sgnl = new TRestRawSignal(512);
TRestRawSignal* signal = new TRestRawSignal(512);

sgnl->IncreaseBinBy(170, 100);
sgnl->IncreaseBinBy(250, 250);
signal->IncreaseBinBy(170, 100);
signal->IncreaseBinBy(250, 250);

ev->AddSignal(*sgnl);
ev->AddSignal(*signal);

// Initializing processes
string cfgFile1 = "gaus.rml";
Expand Down Expand Up @@ -37,17 +37,17 @@ Int_t shaping(Bool_t draw = false) {
if (draw) {
TRestRawSignalEvent* combinedEv = new TRestRawSignalEvent();

TRestRawSignal sgnl1 = *ev->GetSignal(0);
sgnl1.SetID(0);
combinedEv->AddSignal(sgnl1);
TRestRawSignal signal1 = *ev->GetSignal(0);
signal1.SetID(0);
combinedEv->AddSignal(signal1);

TRestRawSignal sgnl2 = *gausEvent->GetSignal(0);
sgnl2.SetID(1);
combinedEv->AddSignal(sgnl2);
TRestRawSignal signal2 = *gausEvent->GetSignal(0);
signal2.SetID(1);
combinedEv->AddSignal(signal2);

TRestRawSignal sgnl3 = *agetEvent->GetSignal(0);
sgnl3.SetID(2);
combinedEv->AddSignal(sgnl3);
TRestRawSignal signal3 = *agetEvent->GetSignal(0);
signal3.SetID(2);
combinedEv->AddSignal(signal3);

TCanvas* c = new TCanvas("c0", "", 800, 600);
combinedEv->DrawEvent();
Expand Down Expand Up @@ -75,7 +75,7 @@ Int_t shaping(Bool_t draw = false) {
}

delete shaper1, shaper2;
delete sgnl;
delete signal;
delete ev;

cout << "[\033[92m OK \x1b[0m]" << endl;
Expand Down
34 changes: 17 additions & 17 deletions pipeline/processes/veto/vetoValidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@

rawEv = ROOT.TRestRawSignalEvent()

sgnl1 = ROOT.TRestRawSignal()
sgnl1.SetID(4688)
sgnl2 = ROOT.TRestRawSignal()
sgnl2.SetID(4705)
sgnl3 = ROOT.TRestRawSignal()
sgnl3.SetID(4676)
sgnl4 = ROOT.TRestRawSignal()
sgnl4.SetID(4)
signal1 = ROOT.TRestRawSignal()
signal1.SetID(4688)
signal2 = ROOT.TRestRawSignal()
signal2.SetID(4705)
signal3 = ROOT.TRestRawSignal()
signal3.SetID(4676)
signal4 = ROOT.TRestRawSignal()
signal4.SetID(4)

for x in range(0, 512):
sgnl1.AddPoint(0)
sgnl2.AddPoint(0)
sgnl3.AddPoint(0)
sgnl4.AddPoint(0)

rawEv.AddSignal(sgnl1)
rawEv.AddSignal(sgnl2)
rawEv.AddSignal(sgnl3)
rawEv.AddSignal(sgnl4)
signal1.AddPoint(0)
signal2.AddPoint(0)
signal3.AddPoint(0)
signal4.AddPoint(0)

rawEv.AddSignal(signal1)
rawEv.AddSignal(signal2)
rawEv.AddSignal(signal3)
rawEv.AddSignal(signal4)

addVetoProcess = ROOT.TRestRawVetoAnalysisProcess("veto.rml")

Expand Down
14 changes: 7 additions & 7 deletions src/TRestRawBaseLineCorrectionProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ TRestEvent* TRestRawBaseLineCorrectionProcess::ProcessEvent(TRestEvent* evInput)
fInputEvent = (TRestRawSignalEvent*)evInput;

for (int s = 0; s < fInputEvent->GetNumberOfSignals(); s++) {
TRestRawSignal* sgnl = fInputEvent->GetSignal(s);
TRestRawSignal* signal = fInputEvent->GetSignal(s);

if (fRangeEnabled && (sgnl->GetID() < fSignalsRange.X() || sgnl->GetID() > fSignalsRange.Y())) {
fOutputEvent->AddSignal(*sgnl);
if (fRangeEnabled && (signal->GetID() < fSignalsRange.X() || signal->GetID() > fSignalsRange.Y())) {
fOutputEvent->AddSignal(*signal);
continue;
}

TRestRawSignal sgnl2;
sgnl->GetBaseLineCorrected(&sgnl2, fSmoothingWindow);
sgnl2.SetID(sgnl->GetID());
fOutputEvent->AddSignal(sgnl2);
TRestRawSignal signal2;
signal->GetBaseLineCorrected(&signal2, fSmoothingWindow);
signal2.SetID(signal->GetID());
fOutputEvent->AddSignal(signal2);
}

return fOutputEvent;
Expand Down
14 changes: 7 additions & 7 deletions src/TRestRawBiPoToSignalProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ TRestEvent* TRestRawBiPoToSignalProcess::ProcessEvent(TRestEvent* inputEvent) {

RESTDebug << "Number of channels : " << fMatacqBoard[bIndex].nChannels << RESTendl;
for (int nch = 0; nch < fMatacqBoard[bIndex].nChannels; nch++) {
TRestRawSignal sgnl;
sgnl.Initialize();
sgnl.SetSignalID(100 * boardAddress + nch);
TRestRawSignal signal;
signal.Initialize();
signal.SetSignalID(100 * boardAddress + nch);

Int_t nBins = fBiPoSettings[bIndex].t1_window + fBiPoSettings[bIndex].t2_window;

Expand All @@ -195,12 +195,12 @@ TRestEvent* TRestRawBiPoToSignalProcess::ProcessEvent(TRestEvent* inputEvent) {
v = TMath::Power(2, 12);
}

if (sgnl.GetSignalID() >= 0) sgnl.AddPoint(v);
if (signal.GetSignalID() >= 0) signal.AddPoint(v);
}

RESTDebug << "Adding signal with id : " << sgnl.GetID() << RESTendl;
RESTDebug << "Number of points: " << sgnl.GetNumberOfPoints() << RESTendl;
fSignalEvent->AddSignal(sgnl);
RESTDebug << "Adding signal with id : " << signal.GetID() << RESTendl;
RESTDebug << "Number of points: " << signal.GetNumberOfPoints() << RESTendl;
fSignalEvent->AddSignal(signal);
}

return fSignalEvent;
Expand Down
Loading