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

Adding generic methods for signal analysis inside framework #379

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5014251
New namespace for a generic signal analysis using templates
juanangp Feb 15, 2023
1cc427e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 15, 2023
498f226
Addressing compilation warning
juanangp Feb 15, 2023
64e9609
Moving TRestSignalAnalysis implementation to source file
juanangp Feb 15, 2023
b3bbf90
Addressing pipeline issue
juanangp Feb 16, 2023
d18699e
Commenting the code for documentation
juanangp Feb 16, 2023
3b0e94d
Implementing changes after moving pointsOverThreshold to a pair
juanangp Feb 16, 2023
c219a17
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 16, 2023
847856d
Adding further generic methods to TRestSignalAnalysis
juanangp Mar 31, 2023
bb7ef4f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 31, 2023
5013b6a
Merge branch 'master' into signal-ana
juanangp Mar 31, 2023
6467f33
Adding new function to get maxBin and minBin in a given range
juanangp Mar 31, 2023
b545262
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 31, 2023
18135b3
Addressing pipeline failure
juanangp Mar 31, 2023
405ccf0
Merge branch 'signal-ana' of github.com:rest-for-physics/framework in…
juanangp Mar 31, 2023
e30118f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 31, 2023
70e5a9a
Simplifiying points over threshold calculation inside TRestSignalAnal…
juanangp Mar 31, 2023
0e4c1e7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 31, 2023
70550f4
Addressing bug
juanangp Mar 31, 2023
894a54b
Renaming TRestSignalAnalysis to TRestPulseShapeAnalysis
juanangp Apr 3, 2023
0fda20c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 3, 2023
0cce44f
Merge branch 'master' into signal-ana
juanangp Apr 20, 2023
b782c07
Merge branch 'master' into signal-ana
juanangp Apr 20, 2023
6030dea
Merge branch 'master' into signal-ana
jgalan Apr 28, 2023
abd75ef
Merge branch 'master' into signal-ana
juanangp May 9, 2023
cbd5edb
Merge branch 'master' into signal-ana
juanangp May 9, 2023
d091003
Merge branch 'master' into signal-ana
jgalan May 15, 2023
da5b7e1
Merge branch 'master' into signal-ana
juanangp May 19, 2023
383bdfe
Merge branch 'master' into signal-ana
juanangp May 23, 2023
f4843cd
Merge branch 'master' into signal-ana
juanangp May 23, 2023
97020b9
Merge branch 'master' into signal-ana
juanangp May 23, 2023
5b620cd
Moving GetPointsOverThreshold from ´std::pair<Float_t, Float_t>´ to ´…
juanangp May 25, 2023
47ed4ff
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 25, 2023
1d78071
Merge branch 'master' into signal-ana
juanangp May 30, 2023
85b8e43
Merge branch 'master' into signal-ana
juanangp Jun 20, 2023
0c33f0d
Merge branch 'master' into signal-ana
juanangp Jun 23, 2023
963b37e
Merge branch 'master' into signal-ana
juanangp Jul 6, 2023
48c4fae
Merge branch 'master' into signal-ana
juanangp Sep 8, 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
103 changes: 103 additions & 0 deletions source/framework/analysis/inc/TRestPulseShapeAnalysis.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*************************************************************************
* This file is part of the REST software framework. *
* *
* Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
* For more information see http://gifna.unizar.es/trex *
* *
* REST is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* REST is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have a copy of the GNU General Public License along with *
* REST in $REST_PATH/LICENSE. *
* If not, see http://www.gnu.org/licenses/. *
* For the list of contributors see $REST_PATH/CREDITS. *
*************************************************************************/

#ifndef RestCore_TRestPulseShapeAnalysis
#define RestCore_TRestPulseShapeAnalysis

#include <Rtypes.h>
#include <TGraph.h>
#include <TMath.h>
#include <TVector2.h>

#include <iostream>
#include <numeric>
#include <vector>

/// This namespace define generic functions to calculate different signal parameters
namespace TRestPulseShapeAnalysis {

template <typename T>
void CalculateBaselineAndSigmaSD(const std::vector<T>& signal, Int_t startBin, Int_t endBin,
Double_t& baseLine, Double_t& baseLineSigma);

template <typename T>
void CalculateBaselineAndSigmaIQR(const std::vector<T>& signal, Int_t startBin, Int_t endBin,
Double_t& baseLine, Double_t& baseLineSigma);

template <typename T>
Double_t GetAverage(const std::vector<T>& signal, Int_t startBin, Int_t endBin);

template <typename T>
std::vector<Float_t> GetSignalSmoothed(const std::vector<T>& signal, int averagingPoints = 3);

template <typename T>
std::vector<Float_t> GetSignalSmoothed_ExcludeOutliers(const std::vector<T>& signal, int averagingPoints,
Double_t& baseLine, Double_t& baseLineSigma);

template <typename T>
std::vector<Float_t> GetDerivative(const std::vector<T>& signal);

template <typename T>
std::vector<std::pair<Float_t, Float_t> > GetPointsOverThreshold(const std::vector<T>& signal,
TVector2& range, const TVector2& thrPar,
Int_t nPointsOver, Int_t nPointsFlat,
Double_t baseLineSigma);

template <typename T>
Int_t GetMaxBin(const std::vector<T>& signal, int startBin = 0, int endBin = 0) {
if (endBin <= 0 || endBin > (int)signal.size()) endBin = signal.size();
if (startBin < 0) startBin = 0;

return std::distance(signal.begin(),
std::max_element(signal.begin() + startBin, signal.begin() + endBin));
}

template <typename T>
Int_t GetMinBin(const std::vector<T>& signal, int startBin = 0, int endBin = 0) {
if (endBin <= 0 || endBin > (int)signal.size()) endBin = signal.size();
if (startBin < 0) startBin = 0;

return std::distance(signal.begin(),
std::min_element(signal.begin() + startBin, signal.begin() + endBin));
}

template <typename T>
Double_t GetIntegral(const std::vector<T>& signal, Int_t startBin, Int_t endBin);

template <typename T>
Double_t GetMaxPeakWidth(const std::vector<T>& signal);

Double_t GetSlopeIntegral(const std::vector<std::pair<Float_t, Float_t> >& signal);
Double_t GetRiseSlope(const std::vector<std::pair<Float_t, Float_t> >& signal);
Double_t GetRiseTime(const std::vector<std::pair<Float_t, Float_t> >& signal);

std::vector<std::pair<double, double> > GetIntWindow(TGraph* signal, double intWindow);
std::array<std::pair<Double_t, Double_t>, 3> GetTripleMax(TGraph* signal);
TVector2 GetTripleMaxAverage(TGraph* signal);
Double_t GetTripleMaxIntegral(TGraph* signal);
TVector2 GetMaxGauss(TGraph* signal);
TVector2 GetMaxLandau(TGraph* signal);
TVector2 GetMaxAget(TGraph* signal);

} // namespace TRestPulseShapeAnalysis

#endif
Loading