Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
IPNL_GAMMA
gammaware
Commits
5882a2d2
Commit
5882a2d2
authored
Sep 11, 2020
by
Jérémie Dudouet
Browse files
Merge branch 'Cubix' into 'Cubix'
Cubix See merge request
!56
parents
effda121
feb2829f
Pipeline
#82957
passed with stage
in 6 minutes and 56 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
525 additions
and
69 deletions
+525
-69
src/root/gui/cubix/src/CXArrow.cpp
src/root/gui/cubix/src/CXArrow.cpp
+12
-2
src/root/gui/cubix/src/CXArrow.h
src/root/gui/cubix/src/CXArrow.h
+6
-0
src/root/gui/cubix/src/CXBgdFit.cpp
src/root/gui/cubix/src/CXBgdFit.cpp
+255
-0
src/root/gui/cubix/src/CXBgdFit.h
src/root/gui/cubix/src/CXBgdFit.h
+43
-0
src/root/gui/cubix/src/CXCanvas.cpp
src/root/gui/cubix/src/CXCanvas.cpp
+0
-2
src/root/gui/cubix/src/CXFileList.h
src/root/gui/cubix/src/CXFileList.h
+2
-2
src/root/gui/cubix/src/CXFit.cpp
src/root/gui/cubix/src/CXFit.cpp
+62
-55
src/root/gui/cubix/src/CXHist1DPlayer.cpp
src/root/gui/cubix/src/CXHist1DPlayer.cpp
+112
-3
src/root/gui/cubix/src/CXHist1DPlayer.h
src/root/gui/cubix/src/CXHist1DPlayer.h
+14
-1
src/root/gui/cubix/src/CXMainWindow.cpp
src/root/gui/cubix/src/CXMainWindow.cpp
+7
-2
src/root/gui/cubix/src/CXMainWindow.h
src/root/gui/cubix/src/CXMainWindow.h
+2
-0
src/root/gui/cubix/src/Cubix.cpp
src/root/gui/cubix/src/Cubix.cpp
+9
-2
src/root/gui/cubix/src/LinkDef.h
src/root/gui/cubix/src/LinkDef.h
+1
-0
No files found.
src/root/gui/cubix/src/CXArrow.cpp
View file @
5882a2d2
...
...
@@ -7,6 +7,7 @@
#include "TFrame.h"
#include "CXFit.h"
#include "CXBgdFit.h"
CXArrow
::
CXArrow
(
CXFit
*
fit
,
Double_t
E
,
Double_t
y1
,
Double_t
y2
,
Float_t
arrowsize
,
Float_t
textsize
,
Option_t
*
option
)
:
TArrow
(
E
,
y1
,
E
,
y2
,
arrowsize
,
option
)
{
...
...
@@ -14,11 +15,19 @@ CXArrow::CXArrow(CXFit *fit, Double_t E,Double_t y1 ,Double_t y2,Float_t arrowsi
fTextSize
=
textsize
;
}
CXArrow
::
CXArrow
(
CXBgdFit
*
fit
,
Double_t
E
,
Double_t
y1
,
Double_t
y2
,
Float_t
arrowsize
,
Float_t
textsize
,
Option_t
*
option
)
:
TArrow
(
E
,
y1
,
E
,
y2
,
arrowsize
,
option
)
{
fBgdFit
=
fit
;
fTextSize
=
textsize
;
}
void
CXArrow
::
SetEnergy
(
Float_t
E
)
{
SetX1
(
E
);
SetX2
(
E
);
if
(
fFit
)
fFit
->
Update
();
if
(
fBgdFit
)
fBgdFit
->
Update
();
}
void
CXArrow
::
Set
(
Double_t
X
,
Double_t
Y1
,
Double_t
Y2
)
...
...
@@ -31,13 +40,14 @@ void CXArrow::Set(Double_t X, Double_t Y1, Double_t Y2)
void
CXArrow
::
RemoveArrow
()
{
if
(
fFit
)
f
Fit
->
RemoveArrow
(
this
);
if
(
fFit
)
fFit
->
RemoveArrow
(
this
);
if
(
fBgdFit
)
fBgd
Fit
->
RemoveArrow
(
this
);
}
void
CXArrow
::
RemoveFit
()
{
delete
fFit
;
delete
fBgdFit
;
}
Int_t
CXArrow
::
Compare
(
const
TObject
*
obj
)
const
...
...
src/root/gui/cubix/src/CXArrow.h
View file @
5882a2d2
...
...
@@ -5,6 +5,8 @@
#include "TBox.h"
class
CXFit
;
class
CXBgdFit
;
class
TLatex
;
class
TBox
;
class
TH1
;
...
...
@@ -19,6 +21,7 @@ private:
TList
*
fList
=
nullptr
;
CXFit
*
fFit
=
nullptr
;
CXBgdFit
*
fBgdFit
=
nullptr
;
TLatex
*
fLatex
=
nullptr
;
CXArrowBox
*
fBox
=
nullptr
;
...
...
@@ -28,9 +31,12 @@ private:
public:
CXArrow
(
CXFit
*
fit
,
Double_t
E
,
Double_t
y1
,
Double_t
y2
,
Float_t
arrowsize
=
0.05
,
Float_t
textsize
=
0.03
,
Option_t
*
option
=
">"
);
CXArrow
(
CXBgdFit
*
fit
,
Double_t
E
,
Double_t
y1
,
Double_t
y2
,
Float_t
arrowsize
=
0.05
,
Float_t
textsize
=
0.03
,
Option_t
*
option
=
">"
);
~
CXArrow
()
=
default
;
CXFit
*
GetFit
(){
return
fFit
;}
CXBgdFit
*
GetBgdFit
(){
return
fBgdFit
;}
//! Energy
void
SetEnergy
(
Float_t
E
);
// *MENU* *ARGS={E=>fX1}*
...
...
src/root/gui/cubix/src/CXBgdFit.cpp
0 → 100644
View file @
5882a2d2
#include "CXBgdFit.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include "TMath.h"
#include "TF1.h"
#include "TH1.h"
#include "TFitResultPtr.h"
#include "TFitResult.h"
#include "TPad.h"
#include "TGNumberEntry.h"
#include "TGButton.h"
#include "Fit/Fitter.h"
#include "CXHist1DPlayer.h"
#include "CXArrow.h"
#include "CXMainWindow.h"
using
namespace
std
;
CXBgdFit
::
CXBgdFit
(
TH1
*
hist
,
TVirtualPad
*
pad
,
CXHist1DPlayer
*
player
)
:
TObject
()
{
fHistogram
=
hist
;
fPad
=
pad
;
fPlayer
=
player
;
fListOfArrows
=
new
TList
;
fListOfArrows
->
SetOwner
();
}
CXBgdFit
::~
CXBgdFit
()
{
Clear
(
fPad
);
delete
fListOfArrows
;
delete
fBackFunction
;
fPlayer
->
GetMainWindow
()
->
RefreshPads
();
}
void
CXBgdFit
::
AddArrow
(
Double_t
Energy
)
{
Int_t
Bin
=
fHistogram
->
FindBin
(
Energy
);
Double_t
Value
=
fHistogram
->
GetBinContent
(
Bin
);
for
(
int
i
=
fHistogram
->
FindBin
(
Energy
)
-
2
;
i
<=
fHistogram
->
FindBin
(
Energy
)
+
2
;
i
++
){
if
(
i
>
0
&&
fHistogram
->
GetBinContent
(
i
)
>
Value
){
Value
=
fHistogram
->
GetBinContent
(
i
);
Bin
=
i
;
}
}
Energy
=
fHistogram
->
GetBinCenter
(
Bin
);
Double_t
MaxGlob
=
fHistogram
->
GetMaximum
();
auto
*
arrow
=
new
CXArrow
(
this
,
Energy
,(
Value
+
MaxGlob
/
100.
)
,(
Value
+
MaxGlob
/
15.
),
0.01
,
0.03
,
"<|"
);
arrow
->
SetAngle
(
30
);
arrow
->
SetLineWidth
(
2
);
arrow
->
Draw
();
fListOfArrows
->
Add
(
arrow
);
Update
();
}
void
CXBgdFit
::
RemoveArrow
(
CXArrow
*
arrow
)
{
if
(
arrow
==
nullptr
)
{
fListOfArrows
->
RemoveLast
();
fPad
->
GetListOfPrimitives
()
->
RemoveLast
();
}
else
{
fListOfArrows
->
Remove
(
arrow
);
fPad
->
GetListOfPrimitives
()
->
Remove
(
arrow
);
}
Update
();
}
void
CXBgdFit
::
Update
()
{
fBackgd
.
clear
();
fListOfArrows
->
Sort
();
TList
back
,
Ener
;
if
(
!
fPlayer
->
DoNewBgdFit
&&
(
fListOfArrows
->
GetEntries
()
%
2
)
==
1
)
{
Clear
(
fPad
);
WARN_MESS
<<
"Setts of two ranges are needed for a bgd fit --> command ignored"
<<
ENDL
;
return
;
}
for
(
int
i
=
0
;
i
<
fListOfArrows
->
GetEntries
()
;
i
++
)
{
auto
*
arr
=
dynamic_cast
<
CXArrow
*>
(
fListOfArrows
->
At
(
i
));
back
.
Add
(
arr
);
}
for
(
int
i
=
0
;
i
<
back
.
GetEntries
()
;
i
++
)
{
auto
*
arr
=
dynamic_cast
<
CXArrow
*>
(
back
.
At
(
i
));
Double_t
E
=
arr
->
GetEnergy
();
Double_t
MaxGlob
=
fHistogram
->
GetMaximum
();
Double_t
Value
=
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
E
));
arr
->
Set
(
E
,(
Value
+
MaxGlob
/
100.
),
(
Value
+
MaxGlob
/
15.
));
arr
->
SetLineColor
(
kBlue
);
arr
->
SetFillColor
(
kBlue
);
fBackgd
.
push_back
(
E
);
cout
<<
E
<<
endl
;
}
fPlayer
->
GetMainWindow
()
->
RefreshPads
();
}
void
CXBgdFit
::
Clear
(
TVirtualPad
*
pad
)
{
fPlayer
->
EndFit
();
if
(
pad
==
nullptr
)
pad
=
fPad
;
TList
*
list
=
pad
->
GetListOfPrimitives
();
list
->
Remove
(
fBackFunction
);
for
(
int
i
=
0
;
i
<
fListOfArrows
->
GetEntries
()
;
i
++
)
list
->
Remove
(
fListOfArrows
->
At
(
i
));
fPlayer
->
RemoveBgdFit
(
this
);
fPlayer
->
GetMainWindow
()
->
RefreshPads
();
}
void
CXBgdFit
::
Fit
()
{
if
(
fListOfArrows
->
GetEntries
()
<
4
||
(
fListOfArrows
->
GetEntries
()
%
2
)
!=
0
)
{
return
;
}
if
(
fPad
==
nullptr
)
{
WARN_MESS
<<
"No selected pad, ignored"
<<
ENDL
;
return
;
}
fPad
->
cd
();
if
(
fPlayer
==
nullptr
)
{
WARN_MESS
<<
"1DPlayer not defined, ignored"
<<
ENDL
;
return
;
}
if
(
fHistogram
==
nullptr
||
fHistogram
->
InheritsFrom
(
"TH2"
))
{
WARN_MESS
<<
"No 1D histogram found, ignored"
<<
ENDL
;
return
;
}
ROOT
::
Math
::
MinimizerOptions
::
SetDefaultMinimizer
(
fPlayer
->
GetMinimizer
(),
fPlayer
->
GetAlgorithm
());
ROOT
::
Math
::
MinimizerOptions
::
SetDefaultTolerance
(
fPlayer
->
GetTolerance
());
ROOT
::
Math
::
MinimizerOptions
::
SetDefaultPrintLevel
(
fPlayer
->
GetPrintLevel
());
Int_t
NPars
=
3
;
delete
fBackFunction
;
fBackFunction
=
new
TF1
(
"MyFit"
,
this
,
&
CXBgdFit
::
FuncBackground
,
fBackgd
.
front
(),
fBackgd
.
back
(),
NPars
,
"CXBgdFit"
,
"FuncBackground"
);
fBackFunction
->
SetParName
(
0
,
"BkgConst"
);
fBackFunction
->
SetParName
(
1
,
"BkgSlope"
);
fBackFunction
->
SetParName
(
2
,
"BkgExp"
);
fBackFunction
->
SetNpx
(
1000
);
fBackFunction
->
SetLineColor
(
kRed
);
// Copy only the ranges contains within the arrows
TH1
*
HistoToFit
=
dynamic_cast
<
TH1
*>
(
fHistogram
->
Clone
());
HistoToFit
->
Reset
();
for
(
size_t
i
=
0
;
i
<
fBackgd
.
size
()
;
i
+=
2
)
{
Int_t
binmin
=
fHistogram
->
GetXaxis
()
->
FindBin
(
fBackgd
.
at
(
i
));
Int_t
binmax
=
fHistogram
->
GetXaxis
()
->
FindBin
(
fBackgd
.
at
(
i
+
1
));
for
(
int
ibin
=
binmin
;
ibin
<=
binmax
;
ibin
++
)
HistoToFit
->
SetBinContent
(
ibin
,
fHistogram
->
GetBinContent
(
ibin
));
}
HistoToFit
->
GetXaxis
()
->
SetRangeUser
(
fBackgd
.
front
(),
fBackgd
.
back
());
//Calc Bckd
fBackFunction
->
SetParameter
(
0
,
HistoToFit
->
GetBinContent
(
HistoToFit
->
FindBin
(
fBackgd
.
front
())));
fBackFunction
->
SetParLimits
(
0
,
0.
,
HistoToFit
->
GetMaximum
());
fBackFunction
->
SetParameter
(
1
,
0
);
fBackFunction
->
SetParLimits
(
1
,
-
50.
,
0.
);
fBackFunction
->
SetParameter
(
2
,
0.
);
// fBackFunction->SetParLimits(2, -1., 0.);
if
(
!
fPlayer
->
fUseBgdPol1
)
fBackFunction
->
FixParameter
(
1
,
0
);
if
(
!
fPlayer
->
fUseBgdExp
)
fBackFunction
->
FixParameter
(
2
,
0
);
TString
FitOpt
=
"R0S"
;
if
(
fPlayer
->
GetPrintLevel
()
>
0
)
FitOpt
+=
"V"
;
TFitResultPtr
r
=
HistoToFit
->
Fit
(
fBackFunction
,
FitOpt
.
Data
());
ostringstream
text
;
text
<<
"Fit results :"
;
cout
<<
text
.
str
()
<<
endl
;
fPlayer
->
PrintInListBox
(
text
.
str
(),
kPrint
);
text
.
str
(
""
);
text
<<
"Status: "
;
if
(
r
->
Status
()
==
0
)
text
<<
" Successeful"
<<
endl
;
else
text
<<
" Failed"
<<
endl
;
cout
<<
text
.
str
();
if
(
r
->
Status
()
==
0
)
fPlayer
->
PrintInListBox
(
text
.
str
(),
kPrint
);
else
fPlayer
->
PrintInListBox
(
text
.
str
(),
kError
);
text
.
str
(
""
);
Float_t
Area
=
fHistogram
->
Integral
(
fHistogram
->
GetXaxis
()
->
FindBin
(
fBackgd
.
front
()),
fHistogram
->
GetXaxis
()
->
FindBin
(
fBackgd
.
back
()));
Float_t
BgdArea
=
fBackFunction
->
Integral
(
fBackgd
.
front
(),
fBackgd
.
back
(),
1e-6
);
Float_t
CorrArea
=
Area
-
BgdArea
;
text
<<
left
<<
setw
(
11
)
<<
"Integral"
<<
": "
<<
setprecision
(
7
)
<<
setw
(
10
)
<<
Area
<<
" ("
<<
setprecision
(
7
)
<<
setw
(
10
)
<<
sqrt
(
Area
)
<<
")"
;
cout
<<
text
.
str
()
<<
endl
;
fPlayer
->
PrintInListBox
(
text
.
str
(),
kInfo
);
text
.
str
(
""
);
text
<<
left
<<
setw
(
11
)
<<
"Bgd Area"
<<
": "
<<
setprecision
(
7
)
<<
setw
(
10
)
<<
BgdArea
<<
" ("
<<
setprecision
(
7
)
<<
setw
(
10
)
<<
sqrt
(
BgdArea
)
<<
")"
;
cout
<<
text
.
str
()
<<
endl
;
fPlayer
->
PrintInListBox
(
text
.
str
(),
kInfo
);
text
.
str
(
""
);
text
<<
left
<<
setw
(
11
)
<<
"Peak Area"
<<
": "
<<
setprecision
(
7
)
<<
setw
(
10
)
<<
CorrArea
<<
" ("
<<
setprecision
(
7
)
<<
setw
(
10
)
<<
sqrt
(
CorrArea
)
<<
")"
;
cout
<<
text
.
str
()
<<
endl
;
fPlayer
->
PrintInListBox
(
text
.
str
(),
kInfo
);
text
.
str
(
""
);
fBackFunction
->
Draw
(
"same"
);
fPlayer
->
GetMainWindow
()
->
RefreshPads
();
delete
HistoToFit
;
}
Double_t
CXBgdFit
::
FuncBackground
(
Double_t
*
xx
,
Double_t
*
pp
)
{
Double_t
x
=
xx
[
0
];
Double_t
Back_const
=
pp
[
0
];
Double_t
Back_slope
=
pp
[
1
];
Double_t
Back_Exp
=
pp
[
2
];
Double_t
f_tot
=
(
Back_const
+
(
x
-
fBackgd
.
front
())
*
Back_slope
)
*
exp
((
x
-
fBackgd
.
front
())
*
Back_Exp
);
return
f_tot
;
}
src/root/gui/cubix/src/CXBgdFit.h
0 → 100644
View file @
5882a2d2
#ifndef CXBgdFit_H
#define CXBgdFit_H
#include "TObject.h"
#include <vector>
class
CXHist1DPlayer
;
class
TVirtualPad
;
class
TH1
;
class
TF1
;
class
CXArrow
;
class
CXBgdFit
:
public
TObject
{
private:
CXHist1DPlayer
*
fPlayer
=
nullptr
;
TList
*
fListOfArrows
=
nullptr
;
TVirtualPad
*
fPad
=
nullptr
;
TH1
*
fHistogram
=
nullptr
;
TF1
*
fBackFunction
=
nullptr
;
std
::
vector
<
Double_t
>
fBackgd
;
public:
CXBgdFit
(
TH1
*
hist
,
TVirtualPad
*
pad
,
CXHist1DPlayer
*
player
);
~
CXBgdFit
();
void
AddArrow
(
Double_t
Energy
);
void
RemoveArrow
(
CXArrow
*
arrow
=
nullptr
);
void
Update
();
void
Fit
();
Double_t
FuncBackground
(
Double_t
*
xx
,
Double_t
*
pp
);
void
Clear
(
TVirtualPad
*
pad
=
nullptr
);
ClassDef
(
CXBgdFit
,
0
);
};
#endif
src/root/gui/cubix/src/CXCanvas.cpp
View file @
5882a2d2
...
...
@@ -919,7 +919,6 @@ Bool_t CXCanvas::HandleKey(Int_t px, Int_t py)
TH1
*
CurrentHist
=
nullptr
;
TH1
*
CurrentHist1D
=
nullptr
;
TH2
*
CurrentHist2D
=
nullptr
;
TPad
*
CurrentPad
=
nullptr
;
TF1
*
CurrentTF1
=
nullptr
;
if
(
fSelected
->
InheritsFrom
(
TH2
::
Class
()))
fSelected
=
FindHisto
();
...
...
@@ -932,7 +931,6 @@ Bool_t CXCanvas::HandleKey(Int_t px, Int_t py)
if
(
fSelected
->
InheritsFrom
(
TH2
::
Class
()))
CurrentHist2D
=
dynamic_cast
<
TH2
*>
(
fSelected
);
else
if
(
fSelected
->
InheritsFrom
(
TH1
::
Class
()))
CurrentHist1D
=
dynamic_cast
<
TH1
*>
(
fSelected
);
else
if
(
fSelected
->
InheritsFrom
(
TPad
::
Class
()))
CurrentPad
=
dynamic_cast
<
TPad
*>
(
fSelected
);
if
(
fSelected
->
InheritsFrom
(
TH1
::
Class
()))
CurrentHist
=
dynamic_cast
<
TH1
*>
(
fSelected
);
if
(
fSelected
->
InheritsFrom
(
TF1
::
Class
()))
CurrentTF1
=
dynamic_cast
<
TF1
*>
(
fSelected
);
...
...
src/root/gui/cubix/src/CXFileList.h
View file @
5882a2d2
...
...
@@ -77,12 +77,12 @@ public:
void
DoMenu
(
Int_t
);
void
CloseWindow
();
void
D
oubleClicked
(
TGListTreeItem
*
item
,
Int_t
);
void
D
isplayFile
(
const
TString
&
fname
);
void
DoubleClicked
(
TGListTreeItem
*
item
,
Int_t
);
void
SetMainWindow
(
CXMainWindow
*
w
){
fMainWindow
=
w
;}
private:
void
DisplayFile
(
const
TString
&
fname
);
void
DisplayRadCube
(
const
TString
&
fname
);
void
DisplayRadSpe
(
const
TString
&
fname
);
...
...
src/root/gui/cubix/src/CXFit.cpp
View file @
5882a2d2
...
...
@@ -198,7 +198,7 @@ void CXFit::Fit()
Double_t
StepValMin
=
-
1.
;
Double_t
StepValMax
=
1.
;
Int_t
NPars
=
3
+
6
*
fEnergies
.
size
();
Int_t
NPars
=
4
+
6
*
fEnergies
.
size
();
delete
fFitFunction
;
fFitFunction
=
new
TF1
(
"MyFit"
,
this
,
&
CXFit
::
DoubleTailedStepedGaussian
,
fBackgd
[
0
],
fBackgd
[
1
],
NPars
,
"CXFit"
,
"DoubleTailedStepedGaussian"
);
...
...
@@ -206,14 +206,15 @@ void CXFit::Fit()
fFitFunction
->
SetParName
(
0
,
"NumberOfPeaks"
);
fFitFunction
->
SetParName
(
1
,
"BkgConst"
);
fFitFunction
->
SetParName
(
2
,
"BkgSlope"
);
fFitFunction
->
SetParName
(
3
,
"BkgExp"
);
for
(
auto
i
=
0U
;
i
<
fEnergies
.
size
()
;
i
++
)
{
fFitFunction
->
SetParName
(
3
+
i
*
6
+
0
,
Form
(
"Height_%d"
,
i
));
fFitFunction
->
SetParName
(
3
+
i
*
6
+
1
,
Form
(
"Position_%d"
,
i
));
fFitFunction
->
SetParName
(
3
+
i
*
6
+
2
,
Form
(
"FWHM_%d"
,
i
));
fFitFunction
->
SetParName
(
3
+
i
*
6
+
3
,
Form
(
"LeftTail_%d"
,
i
));
fFitFunction
->
SetParName
(
3
+
i
*
6
+
4
,
Form
(
"RightTail_%d"
,
i
));
fFitFunction
->
SetParName
(
3
+
i
*
6
+
5
,
Form
(
"AmplitudeStep_%d"
,
i
));
fFitFunction
->
SetParName
(
4
+
i
*
6
+
0
,
Form
(
"Height_%d"
,
i
));
fFitFunction
->
SetParName
(
4
+
i
*
6
+
1
,
Form
(
"Position_%d"
,
i
));
fFitFunction
->
SetParName
(
4
+
i
*
6
+
2
,
Form
(
"FWHM_%d"
,
i
));
fFitFunction
->
SetParName
(
4
+
i
*
6
+
3
,
Form
(
"LeftTail_%d"
,
i
));
fFitFunction
->
SetParName
(
4
+
i
*
6
+
4
,
Form
(
"RightTail_%d"
,
i
));
fFitFunction
->
SetParName
(
4
+
i
*
6
+
5
,
Form
(
"AmplitudeStep_%d"
,
i
));
}
fFitFunction
->
SetNpx
(
1000
);
...
...
@@ -232,43 +233,47 @@ void CXFit::Fit()
fFitFunction
->
SetParameter
(
2
,
0
);
fFitFunction
->
SetParLimits
(
2
,
-
50.
,
0.
);
fFitFunction
->
SetParameter
(
3
,
0.
);
// fFitFunction->SetParLimits(3, -50., 0.);
if
(
!
fPlayer
->
fUsePol1
)
fFitFunction
->
FixParameter
(
2
,
0
);
if
(
!
fPlayer
->
fUseExp
)
fFitFunction
->
FixParameter
(
3
,
0
);
for
(
auto
i
=
0U
;
i
<
fEnergies
.
size
()
;
i
++
)
{
//Height
fFitFunction
->
SetParameter
(
3
+
i
*
6
+
0
,
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
fEnergies
[
i
]))
-
(
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
fBackgd
[
0
]))
+
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
fBackgd
[
1
])))
*
0.5
);
fFitFunction
->
SetParLimits
(
3
+
i
*
6
+
0
,
fHistogram
->
GetBinContent
((
fHistogram
->
FindBin
(
fEnergies
[
i
]))
-
(
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
fBackgd
[
0
]))
+
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
fBackgd
[
1
])))
*
0.5
)
*
0.5
,
fHistogram
->
GetBinContent
(
fHistogram
->
GetMaximumBin
())
*
1.5
);
fFitFunction
->
SetParameter
(
4
+
i
*
6
+
0
,
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
fEnergies
[
i
]))
-
(
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
fBackgd
[
0
]))
+
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
fBackgd
[
1
])))
*
0.5
);
fFitFunction
->
SetParLimits
(
4
+
i
*
6
+
0
,
fHistogram
->
GetBinContent
((
fHistogram
->
FindBin
(
fEnergies
[
i
]))
-
(
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
fBackgd
[
0
]))
+
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
fBackgd
[
1
])))
*
0.5
)
*
0.5
,
fHistogram
->
GetBinContent
(
fHistogram
->
GetMaximumBin
())
*
1.5
);
//Position
fFitFunction
->
SetParameter
(
3
+
i
*
6
+
1
,
fEnergies
[
i
]);
fFitFunction
->
SetParLimits
(
3
+
i
*
6
+
1
,
fEnergies
[
i
]
-
DefFWHM
,
fEnergies
[
i
]
+
DefFWHM
);
fFitFunction
->
SetParameter
(
4
+
i
*
6
+
1
,
fEnergies
[
i
]);
fFitFunction
->
SetParLimits
(
4
+
i
*
6
+
1
,
fEnergies
[
i
]
-
DefFWHM
,
fEnergies
[
i
]
+
DefFWHM
);
if
(
fPlayer
->
fFixMean
->
GetState
()
==
kButtonDown
)
fFitFunction
->
FixParameter
(
3
+
i
*
6
+
1
,
fEnergies
[
i
]);
fFitFunction
->
FixParameter
(
4
+
i
*
6
+
1
,
fEnergies
[
i
]);
//FWHM
fFitFunction
->
SetParameter
(
3
+
i
*
6
+
2
,
DefFWHM
);
fFitFunction
->
SetParLimits
(
3
+
i
*
6
+
2
,
DefFWHM_min
,
DefFWHM_max
);
fFitFunction
->
SetParameter
(
4
+
i
*
6
+
2
,
DefFWHM
);
fFitFunction
->
SetParLimits
(
4
+
i
*
6
+
2
,
DefFWHM_min
,
DefFWHM_max
);
if
(
fPlayer
->
fFixFWHM
->
GetState
()
==
kButtonDown
)
fFitFunction
->
FixParameter
(
3
+
i
*
6
+
2
,
DefFWHM
);
fFitFunction
->
FixParameter
(
4
+
i
*
6
+
2
,
DefFWHM
);
//LeftTail
fFitFunction
->
SetParameter
(
3
+
i
*
6
+
3
,
LeftTailVal
);
fFitFunction
->
SetParLimits
(
3
+
i
*
6
+
3
,
LeftTailValMin
,
LeftTailValMax
);
fFitFunction
->
SetParameter
(
4
+
i
*
6
+
3
,
LeftTailVal
);
fFitFunction
->
SetParLimits
(
4
+
i
*
6
+
3
,
LeftTailValMin
,
LeftTailValMax
);
if
(
fPlayer
->
fUseLT
->
GetState
()
==
kButtonUp
)
fFitFunction
->
FixParameter
(
3
+
i
*
6
+
3
,
-
5
);
fFitFunction
->
FixParameter
(
4
+
i
*
6
+
3
,
-
5
);
else
if
(
fPlayer
->
fFixLT
->
GetState
()
==
kButtonDown
)
fFitFunction
->
FixParameter
(
3
+
i
*
6
+
3
,
LeftTailVal
);
fFitFunction
->
FixParameter
(
4
+
i
*
6
+
3
,
LeftTailVal
);
//RightTail
fFitFunction
->
SetParameter
(
3
+
i
*
6
+
4
,
RightTailVal
);
fFitFunction
->
SetParLimits
(
3
+
i
*
6
+
4
,
RightTailValMin
,
RightTailValMax
);
fFitFunction
->
SetParameter
(
4
+
i
*
6
+
4
,
RightTailVal
);
fFitFunction
->
SetParLimits
(
4
+
i
*
6
+
4
,
RightTailValMin
,
RightTailValMax
);
if
(
fPlayer
->
fUseRT
->
GetState
()
==
kButtonUp
)
fFitFunction
->
FixParameter
(
3
+
i
*
6
+
4
,
5
);
fFitFunction
->
FixParameter
(
4
+
i
*
6
+
4
,
5
);
else
if
(
fPlayer
->
fFixRT
->
GetState
()
==
kButtonDown
)
fFitFunction
->
FixParameter
(
3
+
i
*
6
+
4
,
RightTailVal
);
fFitFunction
->
FixParameter
(
4
+
i
*
6
+
4
,
RightTailVal
);
//AmplitudeStep
fFitFunction
->
SetParameter
(
3
+
i
*
6
+
5
,
StepVal
);
fFitFunction
->
SetParLimits
(
3
+
i
*
6
+
5
,
StepValMin
,
StepValMax
);
fFitFunction
->
SetParameter
(
4
+
i
*
6
+
5
,
StepVal
);
fFitFunction
->
SetParLimits
(
4
+
i
*
6
+
5
,
StepValMin
,
StepValMax
);
if
(
!
fPlayer
->
fUseStep
)
fFitFunction
->
FixParameter
(
3
+
i
*
6
+
5
,
0
);
fFitFunction
->
FixParameter
(
4
+
i
*
6
+
5
,
0
);
}
fHistogram
->
GetXaxis
()
->
SetRangeUser
(
x
,
y
);
...
...
@@ -286,7 +291,7 @@ void CXFit::Fit()
for
(
auto
i
=
0U
;
i
<
fEnergies
.
size
()
;
i
++
)
{
Double_t
Ampli
=
fHistogram
->
GetBinContent
(
fHistogram
->
FindBin
(
fEnergies
[
i
]))
-
fBackFunction
->
Eval
(
fEnergies
[
i
]);
fFitFunction
->
FixParameter
(
3
+
i
*
6
+
0
,
Ampli
);
fFitFunction
->
FixParameter
(
4
+
i
*
6
+
0
,
Ampli
);
}
r
=
fHistogram
->
Fit
(
fFitFunction
,
FitOpt
.
Data
());
...
...
@@ -355,18 +360,18 @@ void CXFit::Fit()
Double_t
Area
=
(
peak
->
Integral
(
fBackgd
[
0
],
fBackgd
[
1
],
1e-6
)
-
fBackFunction
->
Integral
(
fBackgd
[
0
],
fBackgd
[
1
],
1e-6
))
/
fHistogram
->
GetBinWidth
(
1
);
Double_t
AreaErr
=
2
*
sqrt
(
Area
);
Double_t
Mean
=
peak
->
GetParameter
(
3
+
i
*
6
+
1
);
Double_t
MeanErr
=
peak
->
GetParError
(
3
+
i
*
6
+
1
);
Double_t
FWHM
=
peak
->
GetParameter
(
3
+
i
*
6
+
2
);
Double_t
FWHMErr
=
peak
->
GetParError
(
3
+
i
*
6
+
2
);
Double_t
LeftT
=
TMath
::
Abs
(
peak
->
GetParameter
(
3
+
i
*
6
+
3
));
Double_t
LeftTErr
=
peak
->
GetParError
(
3
+
i
*
6
+
3
);
Double_t
Right
=
peak
->
GetParameter
(
3
+
i
*
6
+
4
);
Double_t
RightErr
=
peak
->
GetParError
(
3
+
i
*
6
+
4
);
Double_t
Mean
=
peak
->
GetParameter
(
4
+
i
*
6
+
1
);
Double_t
MeanErr
=
peak
->
GetParError
(
4
+
i
*
6
+
1
);
Double_t
FWHM
=
peak
->
GetParameter
(
4
+
i
*
6
+
2
);
Double_t
FWHMErr
=
peak
->
GetParError
(
4
+
i
*
6
+
2
);
Double_t
LeftT
=
TMath
::
Abs
(
peak
->
GetParameter
(
4
+
i
*
6
+
3
));
Double_t
LeftTErr
=
peak
->
GetParError
(
4
+
i
*
6
+
3
);
Double_t
Right
=
peak
->
GetParameter
(
4
+
i
*
6
+
4
);
Double_t
RightErr
=
peak
->
GetParError
(
4
+
i
*
6
+
4
);
peak
->
SetParameter
(
1
,
0
);
//without backgroud
Double_t
Max
=
peak
->
GetParameter
(
3
+
i
*
6
+
0
);
Double_t
MaxErr
=
peak
->
GetParError
(
3
+
i
*
6
+
0
);
Double_t
Max
=
peak
->
GetParameter
(
4
+
i
*
6
+
0
);
Double_t
MaxErr
=
peak
->
GetParError
(
4
+
i
*
6
+
0
);
Double_t
FWHM_L
=
peak
->
GetX
(
Max
/
2
,
fBackgd
[
0
],
Mean
,
1e-6
);
Double_t
FWHM_L_err
=
peak
->
GetX
((
Max
-
MaxErr
)
/
2
,
fBackgd
[
0
],
Mean
,
1e-6
);
...
...
@@ -431,16 +436,17 @@ Double_t CXFit::DoubleTailedStepedGaussian(Double_t*xx,Double_t*pp)
Double_t
Back_const
=
pp
[
1
];
Double_t
Back_slope
=
pp
[
2
];
Double_t
Back_Exp
=
pp
[
3
];
f_tot
+=
Back_const
+
x
*
Back_slope
;
f_tot
+=
(
Back_const
+
(
x
-
fBackgd
[
0
])
*
Back_slope
)
*
exp
((
x
-
fBackgd
[
0
])
*
Back_Exp
)
;
for
(
int
i
=
0
;
i
<
NSubPeaks
;
i
++
)
{
Double_t
Ampli
=
pp
[
3
+
i
*
Npar
+
0
];
Double_t
Mean
=
pp
[
3
+
i
*
Npar
+
1
];
Double_t
Sigma
=
pp
[
3
+
i
*
Npar
+
2
]
*
1.
/
sqrt
(
8.
*
log
(
2.
));
Double_t
Lambda
=
pp
[
3
+
i
*
Npar
+
3
];
Double_t
Rho
=
pp
[
3
+
i
*
Npar
+
4
];
Double_t
S
=
pp
[
3
+
i
*
Npar
+
5
];
Double_t
Ampli
=
pp
[
4
+
i
*
Npar
+
0
];
Double_t
Mean
=
pp
[
4
+
i
*
Npar
+
1
];
Double_t
Sigma
=
pp
[
4
+
i
*
Npar
+
2
]
*
1.
/
sqrt
(
8.
*
log
(
2.
));
Double_t
Lambda
=
pp
[
4
+
i
*
Npar
+
3
];
Double_t
Rho
=
pp
[
4
+
i
*
Npar
+
4
];
Double_t
S
=
pp
[
4
+
i
*
Npar
+
5
];
Double_t
U
=
(
x
-
Mean
)
/
Sigma
;
Double_t
f_g
=
Ampli
*
TMath
::
Exp
(
-
U
*
U
*
0.5
);
...
...
@@ -468,16 +474,17 @@ Double_t CXFit::StepedBackground(Double_t*xx,Double_t*pp)
Double_t
Back_const
=
pp
[
1
];
Double_t
Back_slope
=
pp
[
2
];
Double_t
Back_Exp
=
pp
[
3
];
Int_t
Npar
=
6
;
f_tot
+=
Back_const
+
x
*
Back_slope
;
f_tot
+=
(
Back_const
+
(
x
-
fBackgd
[
0
])
*
Back_slope
)
*
exp
((
x
-
fBackgd
[
0
])
*
Back_Exp
)
;