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
BAORadio
AnaPAON4
Commits
f797d4b5
Commit
f797d4b5
authored
Feb 26, 2019
by
Reza ANSARI
Browse files
Debug de la partie fit avec minuit, ca semble OK , ca s'execute et resultats ~ OK , Reza 26/02/2019
parent
ab771117
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
13 deletions
+47
-13
gacfit.h
gacfit.h
+1
-0
makefile
makefile
+1
-1
tkfit_minuit.h
tkfit_minuit.h
+45
-12
No files found.
gacfit.h
View file @
f797d4b5
...
...
@@ -214,6 +214,7 @@ public:
{
nbparam_
=
3
+
2
*
v_time_data_
.
size
();
myparam_
=
new
double
[
nbparam_
];
//DBG cout << " *DBG*MyAC_Xi2_Minuit::MyAC_Xi2_Minuit() nbparam_="<<nbparam_<<hex<<" pointer myparam_="<<myparam_<<dec<<endl;
}
virtual
~
MyAC_Xi2_Minuit
()
...
...
makefile
View file @
f797d4b5
...
...
@@ -13,7 +13,7 @@ MINUITINC = -I${MINUITDIR}/include/
# List of include files of this package, and .o files to handle dependencies
MYINCLISTHERE
=
p4autils.h visip4reader.h visp4winreader.h p4gnugain.h p4gvcor.h p4phcor.h p4freqselmgr.h
MYINCLISTHEREFIT
=
acbeam.h gacfit.h cxbeam.h gcxfit.h gcxfitbaseline.h trkfit.h
MYINCLISTHEREFIT
=
acbeam.h gacfit.h cxbeam.h gcxfit.h gcxfitbaseline.h trkfit.h
tkfit_minuit.h
MYOLISTHERE
=
$(OBJ)
/p4autils.o
$(OBJ)
/visip4reader.o
$(OBJ)
/visp4winreader.o
$(OBJ)
/p4gnugain.o
$(OBJ)
/p4gvcor.o
$(OBJ)
/p4phcor.o
$(OBJ)
/p4freqselmgr.o
MYOLISTHEREFIT
=
$(OBJ)
/trkfit.o
MYOLISTHEREFITMN
=
$(OBJ)
/mn_trkfit.o
...
...
tkfit_minuit.h
View file @
f797d4b5
...
...
@@ -41,34 +41,53 @@ public :
class
TkF_Fitter
{
public:
TkF_Fitter
(
Trk_FCNBase
&
gxi2
)
:
gxi2_
(
gxi2
),
minxi2_p_
(
NULL
)
TkF_Fitter
(
Trk_FCNBase
&
gxi2
)
:
gxi2_
(
gxi2
),
minxi2_p_
(
NULL
)
,
my_max_step_
(
1000
)
{
my_max_step_
=
1200
;
v_pname
.
resize
(
gxi2_
.
getNbParams
());
char
buff
[
32
];
for
(
size_t
i
=
0
;
i
<
gxi2_
.
getNbParams
();
i
++
)
{
sprintf
(
buff
,
"P%d"
,(
int
)
i
);
v_pname
[
i
]
=
buff
;
upar_
.
Add
(
v_pname
[
i
],
0.
);
upar_
.
Add
(
v_pname
[
i
],
0.
,
0.1
);
}
max_step_
=
1000
;
tolerance_
=
0.001
;
for
(
size_t
i
=
0
;
i
<
gxi2_
.
getNbParams
();
i
++
)
upar_
.
Release
(
i
);
my_max_step_
=
1000
;
tolerance_
=
0.05
;
bestxi2red_
=-
1.
;
rcfit_
=-
9999
;
nstepdone_
=
0
;
// cout << "TkF_Fitter::TkF_Fitter() max_step="<<my_max_step_<<" Tolerance="<<tolerance_
// << " upar_.NParam()="<<upar_.Params().size()<<" VariableParameters()="<<upar_.VariableParameters()<<endl;
}
virtual
~
TkF_Fitter
()
{
if
(
minxi2_p_
)
delete
minxi2_p_
;
}
void
SetData
(
GeneralFitData
*
gd
)
{
return
;
}
void
SetParam
(
size_t
num
,
string
const
&
pname
,
double
value
,
double
err
,
double
min
=
1.
,
double
max
=-
1.
)
{
if
(
num
>=
v_pname
.
size
())
{
cout
<<
" kF_Fitter::SetParam(num, string ...) ERROR Out of range num="
<<
num
<<
endl
;
throw
RangeCheckError
(
"TkF_Fitter::SetParam(num, string ...) Out of range num"
);
}
v_pname
[
num
]
=
pname
;
return
SetParam
(
num
,
value
,
err
,
min
,
max
);
}
void
SetParam
(
size_t
num
,
double
value
,
double
err
,
double
min
=
1.
,
double
max
=-
1.
)
{
if
(
num
>=
v_pname
.
size
())
{
cout
<<
" kF_Fitter::SetParam(num, double ...) ERROR Out of range num="
<<
num
<<
endl
;
throw
RangeCheckError
(
"TkF_Fitter::SetParam(num, double ...) Out of range num"
);
}
upar_
.
SetValue
((
unsigned
int
)
num
,
value
);
upar_
.
SetError
((
unsigned
int
)
num
,
err
);
if
(
max
>
min
)
upar_
.
SetLimits
((
unsigned
int
)
num
,
min
,
max
);
...
...
@@ -77,6 +96,10 @@ public:
void
SetFix
(
size_t
num
,
double
value
)
{
if
(
num
>=
v_pname
.
size
())
{
cout
<<
" kF_Fitter::SetFix(num, double) ERROR Out of range num="
<<
num
<<
endl
;
throw
RangeCheckError
(
"TkF_Fitter::SetFix(num, double) Out of range num"
);
}
upar_
.
SetValue
((
unsigned
int
)
num
,
value
);
upar_
.
Fix
((
unsigned
int
)
num
);
return
;
...
...
@@ -84,11 +107,15 @@ public:
void
SetFix
(
size_t
num
)
{
if
(
num
>=
v_pname
.
size
())
{
cout
<<
" kF_Fitter::SetFix(num) ERROR Out of range num="
<<
num
<<
endl
;
throw
RangeCheckError
(
"TkF_Fitter::SetFix(num) Out of range num"
);
}
upar_
.
Fix
((
unsigned
int
)
num
);
return
;
}
void
SetMaxStep
(
int
maxstep
)
{
max_step_
=
maxstep
;
}
void
SetMaxStep
(
int
maxstep
=
1000
)
{
my_
max_step_
=
maxstep
;
}
static
string
Num2String
(
double
v
)
{
...
...
@@ -100,14 +127,17 @@ public:
void
PrintFit
()
{
int
pr
=
cout
.
precision
();
int
PRECISION
=
1
3
;
int
WIDTH
=
1
2
;
int
PRECISION
=
1
2
;
int
WIDTH
=
1
5
;
size_t
i
=
0
;
for
(
std
::
vector
<
MinuitParameter
>::
const_iterator
ipar
=
upar_
.
Parameters
().
begin
();
ipar
!=
upar_
.
Parameters
().
end
();
ipar
++
)
{
cout
<<
std
::
setw
(
4
)
<<
(
*
ipar
).
Number
()
<<
std
::
setw
(
5
)
<<
"||"
;
cout
<<
std
::
setw
(
10
)
<<
(
*
ipar
).
Name
()
<<
std
::
setw
(
3
)
<<
"||"
;
// cout << std::setw(10) << (*ipar).Name() << std::setw(3) << "||";
cout
<<
std
::
setw
(
15
)
<<
v_pname
[
i
]
<<
std
::
setw
(
3
)
<<
"||"
;
i
++
;
if
((
*
ipar
).
IsConst
())
{
cout
<<
" const ||"
<<
std
::
setprecision
(
PRECISION
)
<<
std
::
setw
(
WIDTH
)
<<
(
*
ipar
).
Value
()
<<
" ||"
<<
std
::
endl
;
}
else
if
((
*
ipar
).
IsFixed
())
{
...
...
@@ -139,10 +169,13 @@ public:
int
doFit
()
{
MnMigrad
migrad
(
gxi2_
,
upar_
);
//DBG PrintFit();
// unsigned int nparFree = migrad.VariableParameters();
cout
<<
"TkF_Fitter::doFit() - Calling Minuit MnMigard minimisationn, NbFreeParam= "
<<
migrad
.
VariableParameters
()
<<
" max_step="
<<
max_step_
<<
" Tolerance="
<<
tolerance_
<<
endl
;
minxi2_p_
=
new
FunctionMinimum
(
migrad
(
max_step_
,
tolerance_
));
//DBG cout << "TkF_Fitter::doFit() - Calling Minuit MnMigard minimisationn, NbFreeParam= " << migrad.VariableParameters()
// << " max_step="<<my_max_step_<<" Tolerance="<<tolerance_<<endl;
minxi2_p_
=
new
FunctionMinimum
(
migrad
(
my_max_step_
,
tolerance_
));
cout
<<
"TkF_Fitter::doFit() initialised minxi2_p_ "
<<
endl
;
nstepdone_
=
rcfit_
=
minxi2_p_
->
NFcn
();
bestxi2red_
=
minxi2_p_
->
Fval
()
/
(
double
)
gxi2_
.
getNbDataPoints
();
// cout << "Minimizer..." << endl;
...
...
@@ -185,7 +218,7 @@ public:
Trk_FCNBase
&
gxi2_
;
MnUserParameters
upar_
;
std
::
vector
<
std
::
string
>
v_pname
;
int
max_step_
;
int
my_
max_step_
;
double
tolerance_
;
FunctionMinimum
*
minxi2_p_
;
int
rcfit_
;
...
...
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