86 #include "TPaveText.h"
88 #include "St_base/StMessMgr.h"
91 #include "PeakWindow.h"
98 PeakAna(
int size,
double* xvals,
double* yvals );
105 virtual void Copy(TObject& obj)
const;
106 virtual TObject*
Clone(
const char* newname)
const;
117 virtual void AddPeakStats(TPaveText* pave,
const char* opt=
"");
155 virtual Int_t
SearchForPeak(
const std::vector<PeakWindow> &PossiblePeaks );
157 Int_t
SearchForPeak(
const std::vector<PeakWindow> &PossiblePeaks, Double_t peak, Double_t width);
167 virtual Int_t AnalyzeForNoisyPeak();
175 virtual void MergeByChirality(std::vector<PeakWindow>& newpeaks)
const;
176 virtual short MergeLeftOrRight(UInt_t index)
const;
212 virtual void Draw(Option_t *opt=
"");
213 virtual void Paint(Option_t *opt=
"");
216 void ForceInternal(){ mInternalSignal=
true; }
234 virtual void GetXYMax(Double_t xmin, Double_t xmax);
253 void PeakXY(Double_t &xval, Double_t &yval);
272 virtual void Print(Option_t* opt=
"")
const;
281 virtual void SetData(TGraph* graph);
289 virtual void SetData(TH1* hist, UInt_t numavgs=1);
302 void SetFilter( UInt_t filter, Int_t scale, Double_t sigma=0 );
312 void SetRange( Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax);
327 Double_t ChiralityPeakScale()
const {
return mChiralityPeakScale; }
328 Double_t ChiralityScale()
const {
return mChiralityScale; }
329 Double_t ChiralityProbScale()
const {
return mChiralityProbScale; }
330 Double_t ChiralityThreshold()
const {
return mChiralityThreshold; }
331 void SetChiralityPeakScale(Double_t v) { mChiralityPeakScale=v; }
332 void SetChiralityScale(Double_t v) { mChiralityScale=v;}
333 void SetChiralityProbScale(Double_t v){ mChiralityProbScale=v;}
334 void SetChiralityThreshold(Double_t v){
if(v<1){mChiralityThreshold=v;} }
336 void SetPeak(
const Int_t peakpoint,
const Double_t peakx );
337 void SetWindow(
const Int_t start,
const Int_t end );
341 Color_t GetLineColor()
const;
342 Style_t GetLineStyle()
const;
343 Width_t GetLineWidth()
const;
345 Color_t GetFillColor()
const;
346 Style_t GetFillStyle()
const;
348 Color_t GetMarkerColor()
const;
349 Size_t GetMarkerSize()
const;
350 Style_t GetMarkerStyle()
const;
352 void SetLineColor(Color_t color);
353 void SetLineColorAlpha(Color_t color, Float_t alpha);
354 void SetLineStyle(Style_t style);
355 void SetLineWidth(Width_t width);
357 void SetFillColor(Color_t color);
358 void SetFillColorAlpha(Color_t color, Float_t alpha);
359 void SetFillStyle(Style_t style);
361 void SetMarkerColor(Color_t color=1);
362 void SetMarkerColorAlpha(Color_t color, Float_t alpha);
363 void SetMarkerSize(Size_t size=1);
364 void SetMarkerStyle(Style_t style=1);
367 Color_t GetBaseLineColor()
const;
368 Style_t GetBaseLineStyle()
const;
369 Width_t GetBaseLineWidth()
const;
371 Color_t GetHitLineColor()
const;
372 Style_t GetHitLineStyle()
const;
373 Width_t GetHitLineWidth()
const;
375 void SetBaseLineColor(Color_t color);
376 void SetBaseLineColorAlpha(Color_t color,Float_t alpha);
377 void SetBaseLineStyle(Style_t style);
378 void SetBaseLineWidth(Width_t width);
380 void SetHitLineColor(Color_t color);
381 void SetHitLineColorAlpha(Color_t color,Float_t alpha);
382 void SetHitLineStyle(Style_t style);
383 void SetHitLineWidth(Width_t width);
385 Color_t GetPeakLineColorS(UInt_t peakidx)
const;
386 Color_t GetPeakLineColorE(UInt_t peakidx)
const;
387 Style_t GetPeakStyleS(UInt_t peakidx)
const;
388 Style_t GetPeakStyleE(UInt_t peakidx)
const;
389 Width_t GetPeakWidthS(UInt_t peakidx)
const;
390 Width_t GetPeakWidthE(UInt_t peakidx)
const;
392 Color_t GetFoundPeakLineColorS()
const;
393 Color_t GetFoundPeakLineColorE()
const;
394 Style_t GetFoundPeakStyleS()
const;
395 Style_t GetFoundPeakStyleE()
const;
396 Width_t GetFoundPeakWidthS()
const;
397 Width_t GetFoundPeakWidthE()
const;
399 void SetFoundPeakLineColorS(Color_t s_color);
400 void SetFoundPeakLineColorE(Color_t e_color);
401 void SetFoundPeakLineColor(Color_t s_color, Color_t e_color);
402 void SetFoundPeakStyleS(Style_t s_style);
403 void SetFoundPeakStyleE(Style_t e_style);
404 void SetFoundPeakStyle(Style_t s_style,Style_t e_style);
405 void SetFoundPeakWidthS(Width_t s_width);
406 void SetFoundPeakWidthE(Width_t e_width);
407 void SetFoundPeakWidth(Width_t s_width, Width_t e_width);
409 void SetPeakLineColorS(UInt_t peakidx, Color_t s_color);
410 void SetPeakLineColorE(UInt_t peakidx, Color_t e_color);
411 void SetPeakLineColor(UInt_t peakidx, Color_t s_color, Color_t e_color);
412 void SetPeakLineColorAlphaS(UInt_t peakidx, Color_t s_color,Float_t s_alpha);
413 void SetPeakLineColorAlphaE(UInt_t peakidx, Color_t e_color,Float_t e_alpha);
414 void SetPeakLineColorAlpha(UInt_t peakidx, Color_t s_color,Float_t s_alpha, Color_t e_color, Float_t e_alpha);
415 void SetPeakLineStyleS(UInt_t peakidx, Style_t s_style);
416 void SetPeakLineStyleE(UInt_t peakidx, Style_t e_style);
417 void SetPeakLineStyle(UInt_t peakidx, Style_t s_style, Style_t e_style);
418 void SetPeakLineWidthS(UInt_t peakidx, Width_t s_width);
419 void SetPeakLineWidthE(UInt_t peakidx, Width_t e_width);
420 void SetPeakLineWidth(UInt_t peakidx, Width_t s_width, Width_t e_width);
422 void SetAllPeakLineColor(Color_t s_color, Color_t e_color);
423 void SetAllPeakLineStyle(Style_t s_style, Color_t e_style);
424 void SetAllPeakLineWidth(Width_t s_width, Width_t e_width);
497 Double_t mChiralityPeakScale;
498 Double_t mChiralityScale;
499 Double_t mChiralityProbScale;
500 Double_t mChiralityThreshold;
525 static double*
GaussianMatrix2D(
int rx,
double sx=0,
int ry=0,
double sy=0,
bool kNorm=
true);
527 virtual bool MergeLeft(Double_t leftchir, Double_t thischir, Double_t rightchir)
const;
528 virtual std::vector< std::pair<int,int> > MergeIndices(std::vector<short>& vec)
const;
534 bool mInternalSignal;
virtual Int_t SearchForPeak(const std::vector< PeakWindow > &PossiblePeaks)
searches a vector of PeakWindow's for a specific peak based on input search criteria ...
Double_t TunnelThreshold() const
void SetTunnelPars(Double_t scale, Double_t sigma)
Int_t mComputedIndex
Index in mPeaks where a peak was found.
void SetWindow(const Int_t start, const Int_t end)
Overwrite peak start and end values in mFoundPeak. WARNING doesn't set peak values nor overwrite mCom...
virtual ~PeakAna()
Destructor.
static double * GaussianMatrix2D(int rx, double sx=0, int ry=0, double sy=0, bool kNorm=true)
Generates up to a 2D matrix of Gaussian weights.
Double_t SearchPeak() const
virtual void MergeByProbability(std::vector< PeakWindow > &newpeaks) const
Merges peaks in mPeaks using peak probability parameters.
virtual TObject * Clone(const char *newname) const
Clones internal graph as opposed to just copying the pointer.
Double_t mBaselineSigma
Error on PeakAna::mBaseline.
const PeakWindow & GetPeak(UInt_t peakidx) const
static TGraph * ConvertHistToGraph(TH1 *graph, UInt_t numavgs=1)
Converts a histogram to a graph.
Int_t FoundPeakIndex() const
void SetSearchWindow(Double_t peak, Double_t width)
Sets peak search parameters.
Double_t PeakY()
y-value of found signal peak
void SetTunnelThreshold(Double_t value)
virtual void SetData(TGraph *graph)
sets new data for PeakAna
TGraph * mG_Data
TGraph that stores the x,y data.
Double_t PeakX()
x-value of found signal peak
virtual TGraph * GetData() const
PeakAna * MeanFilter(Int_t sizeavgs=0, bool copy=true)
Apply a Mean filter to the data.
Double_t mXRangeMax
Absolute possible x-value maximum of data.
void PeakXY(Double_t &xval, Double_t &yval)
get peak x, and y value directly by reference
PeakAna ConvertPeaksToAna()
same as ConvertPeaksToAna() but returns new PeakAna with same settings without modifying current one ...
Double_t PeakEnd()
Found Signal ending x-value.
virtual void Draw(Option_t *opt="")
Draw method for PeakAna.
TString mOption
Drawing option.
virtual void GetPossiblePeaks()
Finds all possible Peaks in signal with some criteria.
PeakWindow mFoundPeak
Copy of found peak in mPeaks.
Int_t GetFilterScale() const
virtual void Copy(TObject &obj) const
Internal method use Clone instead.
virtual void GetXYMax(Double_t xmin, Double_t xmax)
Finds and sets mMaxX and mMaxY.
void SetBaseline(Double_t base, Double_t sigma)
void SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax)
Sets the absolute range of the data.
Double_t mYRangeMin
Absolute possible y-value minimum of data.
void SetDebug(UInt_t level)
Double_t mTunnelSigma
Sigma for Gaussian for determining tunneling probability (default is 1) see #PeakWindow::PeakTunelPro...
void ResetPeak()
Resets values associated with peak finding.
virtual Int_t AnalyzeForPeak()
Main analysis method for finding peaks.
Double_t mMaxX
x-value where global maximum occurs
void SetTunnelScale(Double_t value)
Double_t PeakStart()
Found Signal starting x-value.
Double_t SearchWidth() const
void SetBaselineSigmaScale(Double_t scale)
virtual void AddPeakStats(TPaveText *pave, const char *opt="")
Add peak information to a "statistics" box.
PeakAnaPainter * mPainter
Painter for this class.
virtual void Print(Option_t *opt="") const
Print peak information.
Double_t BaselineSigma() const
PeakAna * GausFilter(Int_t sizeavgs=0, bool copy=true)
Apply a Gaussian filter to the data.
void SetContinuity(Double_t val)
PeakWindow & GetPeak(UInt_t peakidx)
Double_t * mFilterWeights
Array of weights to use in filtering, size is 2*mFilterScale+1.
Double_t TunnelScale() const
Double_t mMaxY
y-value of global maximum
Double_t mBaselineSigmaScale
scale on PeakAna::mBaselineSigma to determine final threshold
PeakAna()
Default constructor that always creates a new TGraph.
void SetFilter(UInt_t filter, Int_t scale, Double_t sigma=0)
Set the filter to use when peak finding.
Double_t PeakProb(const PeakWindow &window, Double_t scale, Double_t sigma) const
compute a given PeakWindow probability using internal graph
std::vector< PeakWindow > mPeaks
vector that stores all the found peaks in the data
Double_t mStartX
x value for start of the peak window
bool PeakTunnel(const PeakWindow &window) const
test whether a given peak satisifies peak tunnel parameters
bool ValidPeakIdx() const
Double_t Baseline() const
Double_t mTunnelScale
Scale on exponential for determining tunneling probability (default is 1) see #PeakWindow::PeakTunelP...
UInt_t mFilter
Filter to use in AnalyzeForPeak()
void Init()
Initialize internal varaibles.
Int_t mFilterScale
How many points to group together when applying filter.
Double_t mYRangeMax
Absolute possible y-value maximum of data.
Double_t mEndX
x value for end of the peak window
Double_t mBaseline
Minimum threshold to search for a peak.
Double_t BaselineSigmaScale() const
Double_t mTunnelThreshold
Cutoff probability for peak tunneling method. If threshold less than 0 (default) then skip peak tunne...
Double_t mDeltaX
graph known delta-x
PeakAna & operator=(const PeakAna &rhs)
Assignment operator doesn't clone graph.
void ConvertPeaksToGraph()
same as ConvertPeaksToGraph() but creates a new graph that replaces old one
Double_t TunnelSigma() const
Double_t mXRangeMin
Absolute possible x-value minimum of data.
PeakWindow mSearch
Variable that defines peak search parameters.
void SetTunnelSigma(Double_t value)
void SetPeak(const Int_t peakpoint, const Double_t peakx)
Overwrite peak location in #mFoundpeak. WARNING doesn't set start and end values nor overwrite mCompu...
bool GoodWindow()
Check if found peak is inside mXRangeMin, mYRangeMin, mXRangeMax, mYRangeMax and has logical values...