Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hdtv
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
9
Issues
9
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Staging
hdtv
Commits
d6ad5e77
Commit
d6ad5e77
authored
Apr 03, 2018
by
Nima Saed-Samii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix TheuerkaufFiter which was broken in
8b5330c8
parent
7b5f1468
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
31 deletions
+34
-31
hdtv/rootext/fit/EEFitter.hh
hdtv/rootext/fit/EEFitter.hh
+1
-1
hdtv/rootext/fit/Fitter.cc
hdtv/rootext/fit/Fitter.cc
+4
-4
hdtv/rootext/fit/Fitter.hh
hdtv/rootext/fit/Fitter.hh
+1
-1
hdtv/rootext/fit/Param.cc
hdtv/rootext/fit/Param.cc
+8
-8
hdtv/rootext/fit/Param.hh
hdtv/rootext/fit/Param.hh
+7
-1
hdtv/rootext/fit/TheuerkaufFitter.cc
hdtv/rootext/fit/TheuerkaufFitter.cc
+13
-16
No files found.
hdtv/rootext/fit/EEFitter.hh
View file @
d6ad5e77
...
...
@@ -43,10 +43,10 @@ class EEPeak {
friend
class
EEFitter
;
public:
EEPeak
()
=
default
;
EEPeak
(
const
Param
&
pos
,
const
Param
&
amp
,
const
Param
&
sigma1
,
const
Param
&
sigma2
,
const
Param
&
eta
,
const
Param
&
gamma
);
EEPeak
(
const
EEPeak
&
src
);
EEPeak
()
=
default
;
EEPeak
&
operator
=
(
const
EEPeak
&
src
);
double
Eval
(
const
double
*
x
,
const
double
*
p
)
const
;
...
...
hdtv/rootext/fit/Fitter.cc
View file @
d6ad5e77
...
...
@@ -29,10 +29,10 @@
namespace
HDTV
{
namespace
Fit
{
Fitter
::
Fitter
(
double
r1
,
double
r2
)
:
fNumParams
(
0
),
fFinal
(
false
),
fMin
(
std
::
min
(
r1
,
r2
))
,
fMax
(
std
::
max
(
r1
,
r2
)),
fNumPeaks
(
0
),
fIntBgDeg
(
-
1
)
,
fChisquare
(
std
::
numeric_limits
<
double
>::
quiet_NaN
())
{}
Fitter
::
Fitter
(
double
r1
,
double
r2
)
noexcept
:
fNumParams
{
0
},
fFinal
{
false
},
fMin
{
std
::
min
(
r1
,
r2
)}
,
fMax
{
std
::
max
(
r1
,
r2
)},
fNumPeaks
{
0
},
fIntBgDeg
{
-
1
}
,
fChisquare
{
std
::
numeric_limits
<
double
>::
quiet_NaN
()}
{}
Param
Fitter
::
AllocParam
()
{
return
Param
::
Free
(
fNumParams
++
);
}
...
...
hdtv/rootext/fit/Fitter.hh
View file @
d6ad5e77
...
...
@@ -34,7 +34,7 @@ namespace Fit {
//! Common base class for all different (foreground) fitters
class
Fitter
{
public:
Fitter
(
double
r1
,
double
r2
);
Fitter
(
double
r1
,
double
r2
)
noexcept
;
Param
AllocParam
();
Param
AllocParam
(
double
ival
);
...
...
hdtv/rootext/fit/Param.cc
View file @
d6ad5e77
...
...
@@ -22,6 +22,7 @@
#include "Param.hh"
#include <iostream>
#include <limits>
#include <TF1.h>
...
...
@@ -29,14 +30,6 @@
namespace
HDTV
{
namespace
Fit
{
Param
::
Param
(
int
id
,
double
value
,
bool
free
,
bool
hasIVal
,
bool
valid
)
{
fId
=
id
;
fValue
=
value
;
fFree
=
free
;
fHasIVal
=
hasIVal
;
fValid
=
valid
;
}
double
Param
::
Value
(
TF1
*
func
)
const
{
if
(
fFree
)
{
return
func
?
func
->
GetParameter
(
fId
)
...
...
@@ -56,5 +49,12 @@ double Param::Error(TF1 *func) const {
}
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
lhs
,
const
Param
&
rhs
)
{
lhs
<<
"[Id="
<<
rhs
.
_Id
()
<<
", Free="
<<
rhs
.
IsFree
()
<<
", IVal="
<<
rhs
.
HasIVal
()
<<
", Valid="
<<
static_cast
<
bool
>
(
rhs
)
<<
", Value="
<<
rhs
.
_Value
()
<<
']'
;
return
lhs
;
}
}
// end namespace Fit
}
// end namespace HDTV
hdtv/rootext/fit/Param.hh
View file @
d6ad5e77
...
...
@@ -23,6 +23,8 @@
#ifndef __Param_h__
#define __Param_h__
#include <iosfwd>
class
TF1
;
namespace
HDTV
{
...
...
@@ -53,12 +55,16 @@ public:
double
_Value
()
const
{
return
fValue
;
}
private:
Param
(
int
id
,
double
value
,
bool
free
,
bool
hasIVal
,
bool
valid
);
Param
(
int
id
,
double
value
,
bool
free
,
bool
hasIVal
,
bool
valid
)
noexcept
:
fFree
{
free
},
fHasIVal
{
hasIVal
},
fValid
{
valid
},
fId
{
id
},
fValue
{
value
}
{}
bool
fFree
,
fHasIVal
,
fValid
;
int
fId
;
double
fValue
;
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
lhs
,
const
Param
&
rhs
);
}
// end namespace Fit
}
// end namespace HDTV
...
...
hdtv/rootext/fit/TheuerkaufFitter.cc
View file @
d6ad5e77
...
...
@@ -38,6 +38,7 @@ namespace HDTV {
namespace
Fit
{
// *** TheuerkaufPeak ***
//! Constructor
//! Note that no tails correspond to tail parameters tl = tr = \infty. However,
//! all member functions are supposed to check fHasLeftTail and fHasRightTail
...
...
@@ -90,12 +91,11 @@ TheuerkaufPeak &TheuerkaufPeak::operator=(const TheuerkaufPeak &src) {
return
*
this
;
}
//! Restores parameters and error for fit function.
//! Warnings: Restore function of corresponding fitter has to be called
//! beforehand!
void
TheuerkaufPeak
::
RestoreParam
(
const
Param
&
param
,
double
value
,
double
error
)
{
//! Restores parameters and error for fit function.
//! Warnings: Restore function of corresponding fitter has to be called
//! beforehand!
if
(
fFunc
)
{
fFunc
->
SetParameter
(
param
.
_Id
(),
value
);
fFunc
->
SetParError
(
param
.
_Id
(),
error
);
...
...
@@ -230,8 +230,8 @@ double TheuerkaufFitter::Eval(const double *x, const double *p) const {
// Evaluate internal background
sum
+=
std
::
accumulate
(
std
::
reverse_iterator
<
const
double
*>
(
p
+
fNumParams
-
1
),
std
::
reverse_iterator
<
const
double
*>
(
p
+
fNumParams
-
fIntBgDeg
),
std
::
reverse_iterator
<
const
double
*>
(
p
+
fNumParams
),
std
::
reverse_iterator
<
const
double
*>
(
p
+
fNumParams
-
fIntBgDeg
-
1
),
0.0
,
[
x
=
*
x
](
double
bg
,
double
param
)
{
return
bg
*
x
+
param
;
});
// Evaluate peaks
...
...
@@ -249,8 +249,8 @@ double TheuerkaufFitter::EvalBg(const double *x, const double *p) const {
// Evaluate internal background
sum
+=
std
::
accumulate
(
std
::
reverse_iterator
<
const
double
*>
(
p
+
fNumParams
-
1
),
std
::
reverse_iterator
<
const
double
*>
(
p
+
fNumParams
-
fIntBgDeg
),
std
::
reverse_iterator
<
const
double
*>
(
p
+
fNumParams
),
std
::
reverse_iterator
<
const
double
*>
(
p
+
fNumParams
-
fIntBgDeg
-
1
),
0.0
,
[
x
=
*
x
](
double
bg
,
double
param
)
{
return
bg
*
x
+
param
;
});
// Evaluate steps in peaks
...
...
@@ -296,9 +296,8 @@ TF1 *TheuerkaufFitter::GetBgFunc() {
return
fBgFunc
.
get
();
}
//! Do the fit, using the given background function
void
TheuerkaufFitter
::
Fit
(
TH1
&
hist
,
const
Background
&
bg
)
{
//! Do the fit, using the given background function
// Refuse to fit twice
if
(
IsFinal
())
{
return
;
...
...
@@ -309,10 +308,9 @@ void TheuerkaufFitter::Fit(TH1 &hist, const Background &bg) {
_Fit
(
hist
);
}
//! Do the fit, fitting a polynomial of degree intBgDeg for the background at
//! the same time. Set intBgDeg to -1 to disable background completely.
void
TheuerkaufFitter
::
Fit
(
TH1
&
hist
,
int
intBgDeg
)
{
//! Do the fit, fitting a polynomial of degree intBgDeg for the background
//! at the same time. Set intBgDeg to -1 to disable background completely.
// Refuse to fit twice
if
(
IsFinal
())
{
return
;
...
...
@@ -323,9 +321,8 @@ void TheuerkaufFitter::Fit(TH1 &hist, int intBgDeg) {
_Fit
(
hist
);
}
//! Private: worker function to actually do the fit
void
TheuerkaufFitter
::
_Fit
(
TH1
&
hist
)
{
//! Private: worker function to actually do the fit
// Allocate additional parameters for internal polynomial background
// Note that a polynomial of degree n has n+1 parameters!
if
(
fIntBgDeg
>=
0
)
{
...
...
@@ -526,7 +523,7 @@ void TheuerkaufFitter::_Fit(TH1 &hist) {
double
sumFreeVol
=
sumVol
;
auto
ampIter
=
amps
.
begin
();
for
(
auto
&
peak
:
fPeaks
)
{
if
(
peak
.
fVol
.
IsFree
())
{
if
(
!
peak
.
fVol
.
IsFree
())
{
sumFreeAmp
-=
*
(
ampIter
++
);
sumFreeVol
-=
peak
.
fVol
.
_Value
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment