1 #include "PeakWindow.h"
5 PeakWindow::
PeakWindow():mStartX(0),mEndX(1),mStartY(0),mEndY(0),mP_Peak(-1),mPeakX(-1),mPeakY(-1),mStartLine(0),mPeakMarker(0),mEndLine(0)
25 if(
this == &rhs ){
return *
this; }
100 if( option.EqualTo(
"debug") ){
115 if(
mP_Peak>=gdata->GetN()){
return;}
116 Double_t x2=0; Double_t y2=0;
117 gdata->GetPoint(
mP_Peak,x2,y2);
123 Double_t x1=0; Double_t y1=0;
124 Double_t x3=0; Double_t y3=0;
125 gdata->GetPoint(
mP_Peak-1,x1,y1);
126 gdata->GetPoint(
mP_Peak+1,x3,y3);
127 Double_t x00 = (x1+x2)/2.0;
128 Double_t x11 = (x2+x3)/2.0;
129 Double_t PosSlope = (y2-y1)/(x2-x1);
130 Double_t NegSlope = (y3-y2)/(x3-x2);
131 mPeakX = (x00*NegSlope-x11*PosSlope)/(NegSlope-PosSlope);
185 Double_t ydiff_sigma = TMath::Sqrt2()*sigma;
186 return ydiff_sigma/xdiff;
198 Double_t mslope = ydiff/xdiff;
199 Double_t yint = mStartY-mslope*
mStartX;
202 Double_t peakx=0; Double_t peaky=0;
203 graph->GetPoint(
mP_Peak,peakx,peaky);
204 return mslope*peakx+yint;
206 else{
return mslope*
mPeakX+yint;}
209 Double_t PeakWindow::SlopeChirality(Double_t scale)
const
213 if( slope<0 ){
return -1.0*cosh(scale*slope); }
214 else{
return cosh(scale*slope); }
217 Double_t PeakWindow::PeakChirality(Double_t slopescale, Double_t scale)
const
219 if( scale==0 ){scale=1;}
220 if( scale<0 ){ scale = fabs(scale); }
225 Double_t deltaps = peakstartslope-startendslope;
226 Double_t deltape = peakendslope-startendslope;
230 return this->SlopeChirality(slopescale*startendslope)*((deltape*deltape)-(deltaps*deltaps)/(scale*scale));
234 Double_t PeakWindow::PeakChiralityProb(Double_t probscale,Double_t chirality)
const
236 if( probscale<0 ){ probscale = fabs(probscale); }
238 return static_cast<Double_t
>(1)/(probscale*chirality*chirality+static_cast<Double_t>(1));
241 Double_t PeakWindow::PeakChiralityProb(Double_t probscale, Double_t peakscale, Double_t chirscale )
const
243 Double_t chir = PeakChirality(peakscale, chirscale);
244 return this->PeakChiralityProb(peakscale,chir);
249 if( sigma<0 ){sigma = fabs(sigma);}
250 else if(sigma==0){LOG_ERROR <<
"PeakWindow::PeakTunnelProb - ERROR:sigma cannot be 0 - Returning probability of 0" << endm;
return 0;}
253 Double_t mslope = ydiff/xdiff;
254 Double_t yint = mStartY-mslope*
mStartX;
255 Double_t peakx=0; Double_t peaky=0;
256 graph->GetPoint(
mP_Peak,peakx,peaky);
257 Double_t yline = mslope*peakx+yint;
258 Double_t heightdiff = peaky-yline;
260 if( heightdiff<=0 ){
return 1; }
263 return (1.0/(scale*xdiff*xdiff+1.0))*(TMath::Erfc((heightdiff)/(TMath::Sqrt2()*sigma)));
297 bool drawstart =
false;
298 bool drawpeak =
false;
299 bool drawend =
false;
301 if( option.Length()==0 ){
307 if( option.Contains(
"s") ){ drawstart =
true; }
308 if( option.Contains(
"p") ){ drawpeak =
true; }
309 if( option.Contains(
"e") ){ drawend =
true; }
338 Color_t PeakWindow::GetStartLineColor()
const
340 Style_t PeakWindow::GetStartLineStyle()
const
342 Width_t PeakWindow::GetStartLineWidth()
const
344 void PeakWindow::SetStartLineColor(Color_t color){
GetStartLine()->SetLineColor(color); }
345 void PeakWindow::SetStartLineColorAlpha(Color_t color,Float_t alpha){
GetStartLine()->SetLineColorAlpha(color,alpha); }
346 void PeakWindow::SetStartLineStyle(Style_t style){
GetStartLine()->SetLineStyle(style); }
347 void PeakWindow::SetStartLineWidth(Width_t width){
GetStartLine()->SetLineWidth(width); }
362 Color_t PeakWindow::GetPeakMarkerColor()
const
364 Style_t PeakWindow::GetPeakMarkerStyle()
const
366 Size_t PeakWindow::GetPeakMarkerSize()
const
368 void PeakWindow::SetPeakMarkerColor(Color_t color){
GetPeakMarker()->SetMarkerColor(color); }
369 void PeakWindow::SetPeakMarkerColorAlpha(Color_t color, Float_t alpha){
GetPeakMarker()->SetMarkerColorAlpha(color,alpha); }
370 void PeakWindow::SetPeakMarkerStyle(Style_t style){
GetPeakMarker()->SetMarkerStyle(style); }
371 void PeakWindow::SetPeakMarkerSize(Size_t size){
GetPeakMarker()->SetMarkerSize(size); }
387 if( ymin==ymax ){
return mEndLine; }
394 Color_t PeakWindow::GetEndLineColor()
const
396 Style_t PeakWindow::GetEndLineStyle()
const
398 Width_t PeakWindow::GetEndLineWidth()
const
400 void PeakWindow::SetEndLineColor(Color_t color){
GetEndLine()->SetLineColor(color); }
401 void PeakWindow::SetEndLineColorAlpha(Color_t color,Float_t alpha){
GetEndLine()->SetLineColorAlpha(color,alpha); }
402 void PeakWindow::SetEndLineStyle(Style_t style){
GetEndLine()->SetLineStyle(style); }
403 void PeakWindow::SetEndLineWidth(Width_t width){
GetEndLine()->SetLineWidth(width); }
static PeakWindow Combine(const PeakWindow &leftpeak, const PeakWindow &rightpeak, bool keepleft=true)
combine two PeakWindow objects
PeakWindow & operator=(const PeakWindow &rhs)
Assignment operator.
TLine * GetStartLine(Double_t ymin=0, Double_t ymax=0)
Create and return a TLine for the start of the peak window.
TLine * mStartLine
TLine for drawing the start of the peak window.
void SetWindow(Double_t s, Double_t e)
PeakWindow()
Default Constructor.
Double_t StartEndLineYint() const
Computes the y-intercept of the line formed by the points (mStartX,mStartY) and (mEndX,mEndY)
virtual void Copy(TObject &obj) const
Only copies variables, to copy TLines use Clone()
Double_t StartEndLineSlope() const
Computes the slope of the line formed by the points (mStartX,mStartY) and (mEndX,mEndY) ...
TMarker * GetPeakMarker()
Create and return a TMarker to mark the location of the peak.
Double_t mPeakX
x-value of peak position as determined by SetPeak()
virtual ~PeakWindow()
Destructor.
virtual TObject * Clone(const char *newname="") const
Clone whole object, name is irrelevant.
Int_t mP_Peak
Point Number of peak in a TGraph object (P for point), point is such that slope with previous point w...
virtual void Print(Option_t *opt="") const
Prints information about PeakWindow.
void GetWindow(Double_t &s, Double_t &e) const
Double_t StartEndSlopeUncertainty(Double_t sigma) const
Uncertainty int the slope of the line formed by the points (mStartX,mStartY) and (mEndX,mEndY)
TLine * mEndLine
TLine for drawing the end of the peak window.
virtual void Reset(Double_t start, Double_t end)
Reset PeakWindow to constructor state.
Double_t mStartY
y value associated with mStartX
Double_t MidPoint(TGraph *graph=0) const
Computes the the line formed by the points (mStartX,mStartY) and (mEndX,mEndY) and evaluates that lin...
Double_t mStartX
x value for start of the peak window
void SetPeak(TGraph *gdata)
sets mPeakX based on mP_Peak using line of slopes from points (mP_Peak-1,mP_Peak) and (mP_Peak...
virtual void Paint(Option_t *opt="")
paint method see Draw() for options
virtual UShort_t CompareTo(const PeakWindow &other) const
compare two PeakWindow objects
Double_t mEndX
x value for end of the peak window
virtual void Draw(Option_t *opt="")
Draw the PeakWindow.
Double_t mEndY
y value associated with mEndX
Double_t mPeakY
y-value at mP_Peak
TLine * GetEndLine(Double_t ymin=0, Double_t ymax=0)
Create and return a TLine for the end of the peak window.
virtual Double_t PeakTunnelProb(TGraph *graph, Double_t scale=1.0, Double_t sigma=1.0) const
Compute probablity that a given PeakWindow is a real peak.
TMarker * mPeakMarker
TMarker for drawing the peak location.