Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
0d59ea7c
Commit
0d59ea7c
authored
12 years ago
by
pospelov
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of git.jcns.frm2:GISASFW
parents
b59ea58e
1f03e76b
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
App/App.pro
+2
-2
2 additions, 2 deletions
App/App.pro
App/inc/TestFittingModule.h
+10
-0
10 additions, 0 deletions
App/inc/TestFittingModule.h
App/src/TestFittingModule.cpp
+59
-3
59 additions, 3 deletions
App/src/TestFittingModule.cpp
ThirdParty/gtest/gtest.pro
+1
-1
1 addition, 1 deletion
ThirdParty/gtest/gtest.pro
with
72 additions
and
6 deletions
App/App.pro
+
2
−
2
View file @
0d59ea7c
...
...
@@ -129,14 +129,14 @@ CONFIG(JCNS) {
exists($$(ROOTSYS)/bin/root-config){
INCLUDEPATH += $$system($ROOTSYS/bin/root-config --incdir)
#LIBS += $$system($ROOTSYS/bin/root-config --glibs)
LIBS += -L$$system($ROOTSYS/bin/root-config --libdir ) -lGui -lCore -lCint -lRIO -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lpthread -lm -ldl
LIBS += -L$$system($ROOTSYS/bin/root-config --libdir ) -lGui -lCore -lCint -lRIO -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore
-lMathMore -lMinuit2
-lThread -lpthread -lm -ldl
MYROOTCINT = ${ROOTSYS}/bin/rootcint
}
# if it doesn't
exist
,
try
to
do
something
!
exists
(
$$
(
ROOTSYS
)
/
bin
/
root
-
config
){
INCLUDEPATH
+=
/
opt
/
local
/
include
/
root
LIBS
+=
-
L
/
opt
/
local
/
lib
/
root
-
lGui
-
lCore
-
lCint
-
lRIO
-
lNet
-
lHist
-
lGraf
-
lGraf3d
-
lGpad
-
lTree
-
lRint
-
lPostscript
-
lMatrix
-
lPhysics
-
lMathCore
-
lThread
-
lpthread
-
lm
-
ldl
LIBS
+=
-
L
/
opt
/
local
/
lib
/
root
-
lGui
-
lCore
-
lCint
-
lRIO
-
lNet
-
lHist
-
lGraf
-
lGraf3d
-
lGpad
-
lTree
-
lRint
-
lPostscript
-
lMatrix
-
lPhysics
-
lMathCore
-
lMathMore
-
lMinuit2
-
lThread
-
lpthread
-
lm
-
ldl
MYROOTCINT
=
/
opt
/
local
/
bin
/
rootcint
}
...
...
This diff is collapsed.
Click to expand it.
App/inc/TestFittingModule.h
+
10
−
0
View file @
0d59ea7c
...
...
@@ -17,6 +17,9 @@
#include
"IFunctionalTest.h"
#include
"OutputData.h"
#include
"ISample.h"
#include
"ChiSquaredModule.h"
#include
"FitMultiParameter.h"
#include
"GISASExperiment.h"
class
TestFittingModule
:
public
IFunctionalTest
{
...
...
@@ -34,5 +37,12 @@ private:
ISample
*
mp_sample
;
};
namespace
Fitting
{
extern
GISASExperiment
*
p_experiment
;
extern
ChiSquaredModule
*
p_chi_squared_module
;
extern
std
::
vector
<
FitMultiParameter
*>
fit_params
;
double
functionToMinimize
(
const
double
*
p_params
);
}
#endif
/* TESTFITTINGMODULE_H_ */
This diff is collapsed.
Click to expand it.
App/src/TestFittingModule.cpp
+
59
−
3
View file @
0d59ea7c
...
...
@@ -11,6 +11,12 @@
#include
"NanoParticle.h"
#include
"FormFactors.h"
#include
"Math/GSLMinimizer.h"
#include
"Minuit2/Minuit2Minimizer.h"
#include
"Math/Functor.h"
MultiLayer
*
gp_fit_sample
=
0
;
TestFittingModule
::
TestFittingModule
()
:
mp_exact_data
(
0
)
,
mp_real_data
(
0
)
...
...
@@ -32,6 +38,7 @@ void TestFittingModule::execute()
// Generate exact sample simulation
if
(
mp_exact_data
)
delete
mp_exact_data
;
initializeSample
();
gp_fit_sample
=
dynamic_cast
<
MultiLayer
*>
(
mp_sample
);
GISASExperiment
experiment
;
experiment
.
setSample
(
mp_sample
);
experiment
.
setDetectorParameters
(
100
,
0.0
*
Units
::
degree
,
2.0
*
Units
::
degree
...
...
@@ -41,6 +48,37 @@ void TestFittingModule::execute()
mp_exact_data
=
experiment
.
getOutputDataClone
();
// Generate noisy version
generateRealData
(
0.2
);
// Perform the actual fitting
// Initialize global data:
Fitting
::
p_experiment
=
&
experiment
;
ChiSquaredModule
csm
(
*
mp_real_data
);
Fitting
::
p_chi_squared_module
=
&
csm
;
ParameterPool
*
p_param_pool
=
mp_sample
->
createParameterTree
();
std
::
cout
<<
*
p_param_pool
;
FitMultiParameter
fmp1
;
fmp1
.
addParameterFromPool
(
"/multilayer/layer1/thickness"
,
p_param_pool
);
Fitting
::
fit_params
.
push_back
(
&
fmp1
);
// Execute the fitting with ROOT:
ROOT
::
Minuit2
::
Minuit2Minimizer
min
(
ROOT
::
Minuit2
::
kMigrad
);
// ROOT::Math::GSLMinimizer min;
min
.
SetMaxFunctionCalls
(
1000000
);
min
.
SetMaxIterations
(
100000
);
min
.
SetTolerance
(
0.001
);
ROOT
::
Math
::
Functor
f
(
&
Fitting
::
functionToMinimize
,
1
);
double
step
[
1
]
=
{
5
*
Units
::
nanometer
};
double
variable
[
1
]
=
{
12
*
Units
::
nanometer
};
min
.
SetFunction
(
f
);
// Set the free variables to be minimized!
min
.
SetVariable
(
0
,
"x"
,
variable
[
0
],
step
[
0
]);
min
.
Minimize
();
mp_simulated_data
=
experiment
.
getOutputDataClone
();
std
::
cout
<<
"Layer thickness fit: "
<<
min
.
X
()[
0
]
<<
" nanometer"
<<
std
::
endl
;
IsGISAXSTools
::
drawLogOutputData
(
*
mp_real_data
,
"c1_test_fitting"
,
"fitting"
,
"CONT4 Z"
);
// IsGISAXSTools::writeOutputDataToFile(*mp_real_data, Utils::FileSystem::GetHomePath()+"./Examples/IsGISAXS_examples/ex-10/para1dcyl.ima");
}
...
...
@@ -67,12 +105,12 @@ void TestFittingModule::initializeSample()
7
*
Units
::
nanometer
,
1e7
*
Units
::
nanometer
);
NanoParticleDecoration
particle_decoration
(
new
NanoParticle
(
n_particle
,
new
FormFactorCylinder
(
5
*
Units
::
nanometer
,
5
*
Units
::
nanometer
)),
1
0
*
Units
::
nanometer
,
1.0
);
0
*
Units
::
nanometer
,
1.0
);
particle_decoration
.
addInterferenceFunction
(
p_interference_funtion
);
LayerDecorator
layer_decorator
(
laye
r_layer
,
particle_decoration
);
LayerDecorator
layer_decorator
(
ai
r_layer
,
particle_decoration
);
p_multi_layer
->
addLayer
(
air_layer
);
p_multi_layer
->
addLayer
(
layer_decorator
);
p_multi_layer
->
addLayer
(
layer_layer
);
p_multi_layer
->
addLayer
(
substrate_layer
);
mp_sample
=
p_multi_layer
;
}
...
...
@@ -95,3 +133,21 @@ void TestFittingModule::generateRealData(double noise_factor)
mp_real_data
->
next
()
=
random
;
}
}
GISASExperiment
*
Fitting
::
p_experiment
=
0
;
ChiSquaredModule
*
Fitting
::
p_chi_squared_module
=
0
;
std
::
vector
<
FitMultiParameter
*>
Fitting
::
fit_params
;
double
Fitting
::
functionToMinimize
(
const
double
*
p_params
)
{
for
(
size_t
i
=
0
;
i
<
Fitting
::
fit_params
.
size
();
++
i
)
{
std
::
cout
<<
"param "
<<
i
+
1
<<
": "
<<
p_params
[
i
]
<<
std
::
endl
;
Fitting
::
fit_params
[
i
]
->
setValue
(
p_params
[
i
]);
}
std
::
cout
<<
"thickness of layer 1: "
<<
gp_fit_sample
->
getLayer
(
1
)
->
getThickness
()
<<
std
::
endl
;
Fitting
::
p_experiment
->
runSimulation
();
const
OutputData
<
double
>
*
p_simulated_data
=
Fitting
::
p_experiment
->
getOutputData
();
double
chi_squared
=
Fitting
::
p_chi_squared_module
->
calculateChiSquared
(
p_simulated_data
);
std
::
cout
<<
"chi squared = "
<<
chi_squared
<<
std
::
endl
;
return
chi_squared
;
}
This diff is collapsed.
Click to expand it.
ThirdParty/gtest/gtest.pro
+
1
−
1
View file @
0d59ea7c
...
...
@@ -8,7 +8,7 @@ QT -= gui core
QMAKE_EXTENSION_SHLIB
=
so
include
(
$$
PWD
/../
shared
.
pri
)
include
(
$$
PWD
/../
../
shared
.
pri
)
mygtest
=
gtest
-
1.6
.
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment