diff --git a/App/inc/AppOptionsDescription.h b/App/inc/AppOptionsDescription.h index 666df739205be0c120c424273125aec1f6038862..93a1547c4b531480b7696e6230bd02f9f15b7a20 100644 --- a/App/inc/AppOptionsDescription.h +++ b/App/inc/AppOptionsDescription.h @@ -1,5 +1,5 @@ // ************************************************************************** // -// +// // BornAgain: simulate and fit scattering at grazing incidence // //! @file App/inc/AppOptionsDescription.h @@ -17,9 +17,10 @@ #define APPOPTIONSDESCRIPTION_H class ProgramOptions; +class FunctionalTestFactory; //! Adds command line and config file options -void AddApplicationOptions(ProgramOptions *p_options); +void AddApplicationOptions(ProgramOptions *p_options, FunctionalTestFactory *p_test_factory); #endif // APPPROGRAMOPTIONS_H diff --git a/App/inc/FunctionalTestFactory.h b/App/inc/FunctionalTestFactory.h index 374d49e8344298e37536a9a5b41f0905853f9f62..1a3a3ca6c0e32a76e3295d4f9a12f721a12c0275 100644 --- a/App/inc/FunctionalTestFactory.h +++ b/App/inc/FunctionalTestFactory.h @@ -1,5 +1,5 @@ // ************************************************************************** // -// +// // BornAgain: simulate and fit scattering at grazing incidence // //! @file App/inc/FunctionalTestFactory.h @@ -25,46 +25,36 @@ class TBenchmark; class ProgramOptions; -class FunctionalTestFactory : public ISingleton<FunctionalTestFactory>, - public IFactory<std::string, IFunctionalTest> +class FunctionalTestFactory : public IFactory<std::string, IFunctionalTest> { - public: + public: FunctionalTestFactory(); virtual ~FunctionalTestFactory(); //! execute specified test - static void execute(std::string name, ProgramOptions *p_options) - { instance().this_execute(name, p_options); } + void execute(std::string name, ProgramOptions *p_options); //! profile specified test - static void profile(std::string name, ProgramOptions *p_options) - { instance().this_profile(name, p_options); } + void profile(std::string name, ProgramOptions *p_options); //! execute all registered tests - static void execute_all(ProgramOptions *p_options) - { instance().this_execute_all(p_options); } + void execute_all(ProgramOptions *p_options); //! Prints names of registered tests - static void print_testnames() - { instance().this_print_testnames(); } + void print_testnames(); //! Prints benchmark summary - static void print_benchmarks() - { instance().this_print_benchmarks(); } - - static iterator begin() { return instance().m_descriptions.begin(); } - static iterator end() { return instance().m_descriptions.end(); } + void print_benchmarks(); - private: - void this_execute(std::string name, ProgramOptions *p_options); - void this_profile(std::string name, ProgramOptions *p_options); - void this_execute_all(ProgramOptions *p_options); - void this_print_testnames(); - void this_print_benchmarks(); + iterator begin() { return m_descriptions.begin(); } + iterator end() { return m_descriptions.end(); } + private: TBenchmark *m_benchmark; }; +void RegisterFunctionalTests(FunctionalTestFactory *p_test_factory); + #endif // FUNCTIONALTESTFACTORY_H diff --git a/App/src/AppOptionsDescription.cpp b/App/src/AppOptionsDescription.cpp index 3041399844bf283eb820b09422c097bc7659daad..d3631615393ff2b1eedf66c81298abf9bab5d465 100644 --- a/App/src/AppOptionsDescription.cpp +++ b/App/src/AppOptionsDescription.cpp @@ -1,5 +1,5 @@ // ************************************************************************** // -// +// // BornAgain: simulate and fit scattering at grazing incidence // //! @file App/src/AppOptionsDescription.cpp @@ -23,7 +23,7 @@ namespace bpo = boost::program_options; //! Adds command line and config file options. -void AddApplicationOptions(ProgramOptions* p_options) +void AddApplicationOptions(ProgramOptions* p_options, FunctionalTestFactory *p_test_factory) { // general options bpo::options_description general_options("General options"); @@ -45,8 +45,8 @@ void AddApplicationOptions(ProgramOptions* p_options) // functional tests options constructed from information carried by FunctionalTestFactory bpo::options_description functional_test_options("Functional tests"); - FunctionalTestFactory::iterator it = FunctionalTestFactory::begin(); - for(; it!= FunctionalTestFactory::end(); ++it) { + FunctionalTestFactory::iterator it = p_test_factory->begin(); + for(; it!= p_test_factory->end(); ++it) { // it.first - test name, it.second - test description functional_test_options.add_options()((*it).first.c_str(), (*it).second.c_str()); } diff --git a/App/src/FunctionalTestFactory.cpp b/App/src/FunctionalTestFactory.cpp index 6078b6e33c11155bd0db9a905af77ab7a0a5db90..4ce7b9451045305d1cae33fad25a3fa13fc21754 100644 --- a/App/src/FunctionalTestFactory.cpp +++ b/App/src/FunctionalTestFactory.cpp @@ -1,5 +1,5 @@ // ************************************************************************** // -// +// // BornAgain: simulate and fit scattering at grazing incidence // //! @file App/src/FunctionalTestFactory.cpp @@ -56,231 +56,247 @@ FunctionalTestFactory::FunctionalTestFactory() : m_benchmark(0) { setOwnObjects(true); + m_benchmark = new TBenchmark(); +} + + +FunctionalTestFactory::~FunctionalTestFactory() +{ + delete m_benchmark; +} + + +// print benchmark summary on the screen +void FunctionalTestFactory::print_benchmarks() +{ + std::cout << "--- TestFactory::print_benchmarks() ---" << std::endl; + Float_t rp, cp; + m_benchmark->Summary(rp, cp); +} + + +// execute specific functional tests +void FunctionalTestFactory::execute(std::string name, ProgramOptions *p_options) +{ + IFunctionalTest *test(0); + try { + test = createItem( name ); + } catch (std::runtime_error& e) { + std::cout << e.what() << std::endl; + std::cout << "TestFactory::execute() -> Warning. No test with name '" + << name << "' is defined." << std::endl; + return; + } + + test->initialise(p_options); + m_benchmark->Start(name.c_str()); + test->execute(); + m_benchmark->Stop(name.c_str()); + m_benchmark->Show(name.c_str()); + test->finalise(); +} + - registerItem( +// run tests in profile mode +void FunctionalTestFactory::profile(std::string name, ProgramOptions *p_options) +{ + IFunctionalTest *test(0); + try { + test = createItem( name ); + } catch (std::runtime_error& e) { + std::cout << e.what() << std::endl; + std::cout << "TestFactory::execute() -> Warning. No test with name '" + << name << "' is defined." << std::endl; + return; + } + + test->initialise(p_options); + for(int i=0; i<1; i++) test->execute(); + +} + + +// execute all registered functional tests +void FunctionalTestFactory::execute_all(ProgramOptions *p_options) +{ + CallbackMap_t::const_iterator it; + for(it=m_callbacks.begin(); it != m_callbacks.end(); ++it ) { + execute( it->first , p_options); + //createItem( it->first )->execute(); + } + print_benchmarks(); +} + + +// print on the screen names of registered tests +void FunctionalTestFactory::print_testnames() +{ + std::string help; + help += "TestFactory::print_testnames() -> Info. \n"; + help += "You can run few functional tests by running './App testname'\n"; + help += "List of available tests are below:"; + std::cout << help << std::endl; + CallbackMap_t::const_iterator it; + for(it=m_callbacks.begin(); it != m_callbacks.end(); ++it ) { + std::cout << it->first << std::endl; + } +} + + +void RegisterFunctionalTests(FunctionalTestFactory *p_test_factory) +{ + p_test_factory->registerItem( "roughness", IFactoryCreateFunction<TestRoughness, IFunctionalTest>, "functional test: roughness parameters"); - registerItem( + p_test_factory->registerItem( "Fresnel", IFactoryCreateFunction<TestFresnelCoeff, IFunctionalTest>, "functional test: Fresnel coefficients calculations"); - registerItem( + p_test_factory->registerItem( "formfactor", IFactoryCreateFunction<TestFormFactor, IFunctionalTest>, "functional test: some formfactor"); - registerItem( + p_test_factory->registerItem( "diffuse", IFactoryCreateFunction<TestDiffuseReflection, IFunctionalTest>, - "functional test: diffuse scattering from multilayer with roughness (obsolete)"); - registerItem( + "functional test: diffuse scattering from multilayer with roughness " + "(obsolete)"); + p_test_factory->registerItem( "isgisaxs01", IFactoryCreateFunction<TestIsGISAXS1, IFunctionalTest>, - "functional test: isgisaxs ex-1 (2 types of particles without inteference on top of substrate)"); - registerItem( + "functional test: isgisaxs ex-1 (2 types of particles without " + "interference on top of substrate)"); + p_test_factory->registerItem( "isgisaxs02", IFactoryCreateFunction<TestIsGISAXS2, IFunctionalTest>, - "functional test: isgisaxs ex-2 (mean form factors for particles with shape size distribution)"); - registerItem( + "functional test: isgisaxs ex-2 (mean form factors for particles with " + "shape size distribution)"); + p_test_factory->registerItem( "isgisaxs03", IFactoryCreateFunction<TestIsGISAXS3, IFunctionalTest>, "functional test: isgisaxs ex-3 (cylinder FF)"); - registerItem( + p_test_factory->registerItem( "isgisaxs04", IFactoryCreateFunction<TestIsGISAXS4, IFunctionalTest>, "functional test: isgisaxs ex-4 (paracrystal 1d structure factors)"); - registerItem( + p_test_factory->registerItem( "isgisaxs05", IFactoryCreateFunction<TestIsGISAXS5, IFunctionalTest>, - "functional test: isgisaxs ex-5 (fit with paracrystal 1d structure factor)"); - registerItem( + "functional test: isgisaxs ex-5 (fit with paracrystal 1d structure " + "factor)"); + p_test_factory->registerItem( "isgisaxs06", IFactoryCreateFunction<TestIsGISAXS6, IFunctionalTest>, - "functional test: isgisaxs ex-6 (cylinders with lattice interference function)"); - registerItem( + "functional test: isgisaxs ex-6 (cylinders with lattice interference " + "function)"); + p_test_factory->registerItem( "isgisaxs07", IFactoryCreateFunction<TestIsGISAXS7, IFunctionalTest>, - "functional test: isgisaxs ex-7 (particle mixture from morphology file)"); - registerItem( + "functional test: isgisaxs ex-7 (particle mixture from morphology " + "file)"); + p_test_factory->registerItem( "isgisaxs08", IFactoryCreateFunction<TestIsGISAXS8, IFunctionalTest>, - "functional test: isgisaxs ex-8 (paracrystal lattice structure factors)"); - registerItem( + "functional test: isgisaxs ex-8 (paracrystal lattice structure " + "factors)"); + p_test_factory->registerItem( "isgisaxs09", IFactoryCreateFunction<TestIsGISAXS9, IFunctionalTest>, "functional test: isgisaxs ex-9 (rotated pyramid FF)"); - registerItem( + p_test_factory->registerItem( "isgisaxs10", IFactoryCreateFunction<TestIsGISAXS10, IFunctionalTest>, - "functional test: isgisaxs ex-10 (cylinders with interference on top of substrate)"); - registerItem( + "functional test: isgisaxs ex-10 (cylinders with interference on top " + "of substrate)"); + p_test_factory->registerItem( "isgisaxs11", IFactoryCreateFunction<TestIsGISAXS11, IFunctionalTest>, - "functional test: isgisaxs ex-11 (core shell parallelopiped islands on top of substrate)"); - registerItem( + "functional test: isgisaxs ex-11 (core shell parallelopiped islands " + "on top of substrate)"); + p_test_factory->registerItem( "isgisaxs12", IFactoryCreateFunction<TestIsGISAXS12, IFunctionalTest>, "functional test: isgisaxs ex-12 (constrained fit example)"); - registerItem( + p_test_factory->registerItem( "isgisaxs13", IFactoryCreateFunction<TestIsGISAXS13, IFunctionalTest>, "functional test: isgisaxs ex-13 (simulated annealing fit)"); - registerItem( + p_test_factory->registerItem( "isgisaxs14", IFactoryCreateFunction<TestIsGISAXS14, IFunctionalTest>, - "functional test: isgisaxs ex-14 (multilayered sphere on graded interface)"); - registerItem( + "functional test: isgisaxs ex-14 (multilayered sphere on graded " + "interface)"); + p_test_factory->registerItem( "isgisaxs15", IFactoryCreateFunction<TestIsGISAXS15, IFunctionalTest>, - "functional test: isgisaxs ex-15 (size-spacing correlation approximation)"); - registerItem( + "functional test: isgisaxs ex-15 (size-spacing correlation " + "approximation)"); + p_test_factory->registerItem( "convolution", IFactoryCreateFunction<TestConvolution, IFunctionalTest>, "functional test: test of convolution via fft"); - registerItem( + p_test_factory->registerItem( "detectorresolution", IFactoryCreateFunction<TestDetectorResolution, IFunctionalTest>, "functional test: detector resolution function"); - registerItem( + p_test_factory->registerItem( "mesocrystal1", IFactoryCreateFunction<TestMesoCrystal1, IFunctionalTest>, "functional test: mesocrystal"); - registerItem( + p_test_factory->registerItem( "mesocrystal2", IFactoryCreateFunction<TestMesoCrystal2, IFunctionalTest>, "functional test: mesocrystal fit"); - registerItem( + p_test_factory->registerItem( "roottree", IFactoryCreateFunction<TestRootTree, IFunctionalTest>, "functional test: using root trees to read/write data from/to disk"); - registerItem( + p_test_factory->registerItem( "fitting1", IFactoryCreateFunction<TestFittingModule1, IFunctionalTest>, "functional test: fit module 2 params"); - registerItem( + p_test_factory->registerItem( "fitting2", IFactoryCreateFunction<TestFittingModule2, IFunctionalTest>, "functional test: fit module 5 params"); - registerItem( + p_test_factory->registerItem( "fitting3", IFactoryCreateFunction<TestFittingModule3, IFunctionalTest>, "functional test: fit module 4 params, 1d scans"); - registerItem( + p_test_factory->registerItem( "performance", IFactoryCreateFunction<TestPerformance, IFunctionalTest>, "functional test: run performance test for several predefined tasks"); - registerItem( + p_test_factory->registerItem( "roughdwba", IFactoryCreateFunction<TestMultiLayerRoughness, IFunctionalTest>, "functional test: diffuse scattering from multi layer with roughness"); - registerItem( + p_test_factory->registerItem( "testmisc", IFactoryCreateFunction<TestMiscellaneous, IFunctionalTest>, "functional test: test of different miscellaneous issues"); - registerItem( + p_test_factory->registerItem( "fitbench", IFactoryCreateFunction<TestFittingBenchmark, IFunctionalTest>, - "functional test: test of minimizers with hard-to-minimize test functions"); - registerItem( + "functional test: test of minimizers with hard-to-minimize test " + "functions"); + p_test_factory->registerItem( "Fourier", IFactoryCreateFunction<TestFourier, IFunctionalTest>, "functional test: test of Fourier transformation of OutputData maps"); - registerItem( + p_test_factory->registerItem( "fumili", IFactoryCreateFunction<TestFumiliLMA, IFunctionalTest>, - "functional test: test of ROOT's LMA-based minimizers Fumili and GSLMultiFit"); - registerItem( + "functional test: test of ROOT's LMA-based minimizers Fumili and " + "GSLMultiFit"); + p_test_factory->registerItem( "toyexp", IFactoryCreateFunction<TestToySimulation, IFunctionalTest>, "functional test: test fitting algorithms with toy simulation"); - registerItem( + p_test_factory->registerItem( "FormFactors", IFactoryCreateFunction<TestFormFactors, IFunctionalTest>, "functional test: FormFactors"); - - m_benchmark = new TBenchmark(); -} - - -FunctionalTestFactory::~FunctionalTestFactory() -{ - delete m_benchmark; -} - - -// print benchmark summary on the screen -void FunctionalTestFactory::this_print_benchmarks() -{ - std::cout << "--- TestFactory::print_benchmarks() ---" << std::endl; - Float_t rp, cp; - m_benchmark->Summary(rp, cp); -} - - -// execute specific functional tests -void FunctionalTestFactory::this_execute(std::string name, ProgramOptions *p_options) -{ - IFunctionalTest *test(0); - try { - test = createItem( name ); - } catch (std::runtime_error& e) { - std::cout << e.what() << std::endl; - std::cout << "TestFactory::execute() -> Warning. No test with name '" << name << "' is defined." << std::endl; - return; - } - - test->initialise(p_options); - m_benchmark->Start(name.c_str()); - test->execute(); - m_benchmark->Stop(name.c_str()); - m_benchmark->Show(name.c_str()); - test->finalise(); - -} - - -// run tests in profile mode -void FunctionalTestFactory::this_profile(std::string name, ProgramOptions *p_options) -{ - IFunctionalTest *test(0); - try { - test = createItem( name ); - } catch (std::runtime_error& e) { - std::cout << e.what() << std::endl; - std::cout << "TestFactory::execute() -> Warning. No test with name '" << name << "' is defined." << std::endl; - return; - } - - test->initialise(p_options); - for(int i=0; i<1; i++) test->execute(); - } - -// execute all registered functional tests -void FunctionalTestFactory::this_execute_all(ProgramOptions *p_options) -{ - CallbackMap_t::const_iterator it; - for(it=m_callbacks.begin(); it != m_callbacks.end(); ++it ) { - execute( it->first , p_options); - //createItem( it->first )->execute(); - } - print_benchmarks(); -} - - -// print on the screen names of registered tests -void FunctionalTestFactory::this_print_testnames() -{ - std::string help; - help += "TestFactory::print_testnames() -> Info. \n"; - help += "You can run few functional tests by running './App testname'\n"; - help += "List of available tests are below:"; - std::cout << help << std::endl; - CallbackMap_t::const_iterator it; - for(it=m_callbacks.begin(); it != m_callbacks.end(); ++it ) { - std::cout << it->first << std::endl; - } -} - - diff --git a/App/src/TestIsGISAXS13.cpp b/App/src/TestIsGISAXS13.cpp index 75c38778eb62bbecd3b04ebd763065230f7b9117..b698a40ed4e1fd3cbf8061ff725d478827916bf2 100644 --- a/App/src/TestIsGISAXS13.cpp +++ b/App/src/TestIsGISAXS13.cpp @@ -1,5 +1,5 @@ // ************************************************************************** // -// +// // BornAgain: simulate and fit scattering at grazing incidence // //! @file App/src/TestIsGISAXS13.cpp @@ -61,7 +61,8 @@ TestIsGISAXS13::TestIsGISAXS13() , mp_fitSuite(0) { - setOutputPath(Utils::FileSystem::GetHomePath()+"./Examples/IsGISAXS_examples/ex-13/"); + setOutputPath(Utils::FileSystem::GetHomePath()+ + "./Examples/IsGISAXS_examples/ex-13/"); } @@ -93,29 +94,44 @@ void TestIsGISAXS13::run_isgisaxs_fit() // m_fitSuite->setMinimizer( MinimizerFactory::createMinimizer("Scan") ); // observers - mp_fitSuite->attachObserver( FitSuiteObserverFactory::createPrintObserver(10) ); - mp_fitSuite->attachObserver( FitSuiteObserverFactory::createDrawObserver(50) ); + mp_fitSuite->attachObserver( FitSuiteObserverFactory:: + createPrintObserver(10) ); + mp_fitSuite->attachObserver( FitSuiteObserverFactory:: + createDrawObserver(50) ); // fit parameters - mp_fitSuite->addFitParameter("*Normalizer/scale", 1e5, 1e3, AttLimits::limited(1e4, 2e5)); - mp_fitSuite->addFitParameter("*Normalizer/shift", 10, 0.1, AttLimits::limited(0., 20.)); - mp_fitSuite->addFitParameter("*SampleBuilder/particle_radius", 4.0e+00*Units::nanometer, 0.04*Units::nanometer, AttLimits::limited(2.0, 8.0) ); - mp_fitSuite->addFitParameter("*SampleBuilder/dispersion_radius", 0.2, 0.002, AttLimits::limited(0.01, 1.0) ); - mp_fitSuite->addFitParameter("*SampleBuilder/height_aspect_ratio", 0.8, 0.08, AttLimits::limited(0.5, 1.5) ); - mp_fitSuite->addFitParameter("*SampleBuilder/interf_distance", 15*Units::nanometer, 0.015*Units::nanometer, AttLimits::limited(0.01, 50.0) ); - mp_fitSuite->addFitParameter("*SampleBuilder/interf_width", 3*Units::nanometer, 0.03*Units::nanometer, AttLimits::limited(0.01, 10.) ); + mp_fitSuite->addFitParameter("*Normalizer/scale", 1e5, 1e3, + AttLimits::limited(1e4, 2e5)); + mp_fitSuite->addFitParameter("*Normalizer/shift", 10, 0.1, + AttLimits::limited(0., 20.)); + mp_fitSuite->addFitParameter("*SampleBuilder/particle_radius", + 4.0e+00*Units::nanometer, 0.04*Units::nanometer, + AttLimits::limited(2.0, 8.0) ); + mp_fitSuite->addFitParameter("*SampleBuilder/dispersion_radius", + 0.2, 0.002, AttLimits::limited(0.01, 1.0) ); + mp_fitSuite->addFitParameter("*SampleBuilder/height_aspect_ratio", + 0.8, 0.08, AttLimits::limited(0.5, 1.5) ); + mp_fitSuite->addFitParameter("*SampleBuilder/interf_distance", + 15*Units::nanometer, 0.015*Units::nanometer, + AttLimits::limited(0.01, 50.0) ); + mp_fitSuite->addFitParameter("*SampleBuilder/interf_width", + 3*Units::nanometer, 0.03*Units::nanometer, + AttLimits::limited(0.01, 10.) ); // reading 1D data scans defined in isgisaxs example IsGISAXSData::DataSet_t isgi_scans; - IsGISAXSData::read_datfile(getOutputPath()+"isgi_simulated_annealing.dat", isgi_scans); + IsGISAXSData::read_datfile(getOutputPath()+"isgi_simulated_annealing.dat", + isgi_scans); // chi squared module ChiSquaredModule chiModule; chiModule.setChiSquaredFunction( SquaredFunctionWithSystematicError(0.08) ); chiModule.setOutputDataNormalizer( OutputDataNormalizer() ); //chiModule.setIntensityFunction( IntensityFunctionLog() ); - for(IsGISAXSData::DataSet_t::iterator it=isgi_scans.begin(); it!= isgi_scans.end(); ++it) { - mp_fitSuite->addSimulationAndRealData(*mp_simulation, *(*it), chiModule); + for(IsGISAXSData::DataSet_t::iterator it=isgi_scans.begin(); + it!= isgi_scans.end(); ++it) { + mp_fitSuite->addSimulationAndRealData(*mp_simulation, *(*it), + chiModule); } mp_fitSuite->runFit(); @@ -148,8 +164,10 @@ void TestIsGISAXS13::run_isgisaxs_fit() for(size_t i_set=0; i_set<mp_fitSuite->getFitObjects()->size(); ++i_set) { c2->cd((int)i_set+1); const FitObject *obj = mp_fitSuite->getFitObjects()->getObject(i_set); - TH1D *hreal = IsGISAXSTools::getOutputDataScanHist(*obj->getChiSquaredModule()->getRealData(),"BornAgain_real"); - TH1D *hsimul = IsGISAXSTools::getOutputDataScanHist(*obj->getChiSquaredModule()->getSimulationData(),"BornAgain_simul"); + TH1D *hreal = IsGISAXSTools::getOutputDataScanHist(*obj-> + getChiSquaredModule()->getRealData(),"BornAgain_real"); + TH1D *hsimul = IsGISAXSTools::getOutputDataScanHist(*obj-> + getChiSquaredModule()->getSimulationData(),"BornAgain_simul"); hreal->SetLineColor(kBlue); gPad->SetLogy(); hreal->DrawCopy(); @@ -167,12 +185,15 @@ void TestIsGISAXS13::run_isgisaxs_fit() for(size_t i_set=0; i_set<mp_fitSuite->getFitObjects()->size(); ++i_set) { c2->cd(3+1); const FitObject *obj = mp_fitSuite->getFitObjects()->getObject(i_set); - OutputData<double > *real = obj->getChiSquaredModule()->getRealData()->clone(); - OutputData<double > *simul = obj->getChiSquaredModule()->getSimulationData()->clone(); + OutputData<double > *real = obj->getChiSquaredModule()-> + getRealData()->clone(); + OutputData<double > *simul = obj->getChiSquaredModule()-> + getSimulationData()->clone(); c2->cd((int)(i_set+3)); *simul /= *real; - TH1D *hratio = IsGISAXSTools::getOutputDataScanHist(*simul,"BornAgain_real_simul_ratio"); + TH1D *hratio = IsGISAXSTools::getOutputDataScanHist(*simul, + "BornAgain_real_simul_ratio"); hratio->DrawCopy(); if(i_set==0) { leg2->AddEntry(hratio,"BornAgain simul/real","lp"); @@ -197,8 +218,11 @@ void TestIsGISAXS13::initializeSimulation() delete mp_simulation; mp_simulation = new Simulation(mp_options); mp_simulation->setSampleBuilder(mp_sample_builder); - mp_simulation->setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true); - mp_simulation->setBeamParameters(1.0*Units::angstrom, -0.2*Units::degree, 0.0*Units::degree); + mp_simulation->setDetectorParameters( + 100, 0.0*Units::degree, 2.0*Units::degree, + 100, 0.0*Units::degree, 2.0*Units::degree, true); + mp_simulation->setBeamParameters(1.0*Units::angstrom, + -0.2*Units::degree, 0.0*Units::degree); } diff --git a/App/src/main.cpp b/App/src/main.cpp index 2344f60e3e4f16d1ca32195c58ffcb0430b854c1..185ff88ff198c91b87dc78b89b80502fbc434436 100644 --- a/App/src/main.cpp +++ b/App/src/main.cpp @@ -1,5 +1,5 @@ // ************************************************************************** // -// +// // BornAgain: simulate and fit scattering at grazing incidence // //! @file App/src/main.cpp @@ -36,8 +36,11 @@ int main(int argc, char **argv) std::cout << AppVersion::g_app_name << " " << AppVersion::g_app_version_number << std::endl; + FunctionalTestFactory test_factory; + RegisterFunctionalTests(&test_factory); + ProgramOptions command_line_options; - AddApplicationOptions(&command_line_options); + AddApplicationOptions(&command_line_options, &test_factory); AddCoreOptions(&command_line_options); command_line_options.parseCommandLine(argc, argv); @@ -57,15 +60,15 @@ int main(int argc, char **argv) // run functional tests if( command_line_options.find("all") ) { // run all registered tests - FunctionalTestFactory::execute_all(&command_line_options); + test_factory.execute_all(&command_line_options); } else { // loop over functional tests, // run test if its name is present in command line - FunctionalTestFactory::iterator it = FunctionalTestFactory::begin(); - for(; it!= FunctionalTestFactory::end(); ++it) { + FunctionalTestFactory::iterator it = test_factory.begin(); + for(; it!= test_factory.end(); ++it) { if( command_line_options.find( (*it).first ) ) - FunctionalTestFactory::execute( + test_factory.execute( (*it).first, &command_line_options ); } }