From 38d0b6000d81ef349bbc7866059ecc49952814da Mon Sep 17 00:00:00 2001
From: Ali Hassan <ali@ali-HP-Pavilion-g6-Notebook-PC.(none)>
Date: Fri, 25 Jan 2013 13:41:35 -0500
Subject: [PATCH] commit for merging

---
 App/App.pro                                   |   6 +-
 App/inc/StandardSamples.h                     |  14 +-
 App/inc/TestFormFactors.h                     |  38 +++
 App/src/FunctionalTestFactory.cpp             |   6 +
 App/src/SampleFactory.cpp                     |  13 +-
 App/src/StandardSamples.cpp                   | 282 ++++++++++++++++++
 App/src/TestFormFactors.cpp                   | 118 ++++++++
 Core/Core.pro                                 |  18 +-
 Core/FormFactors/inc/FormFactorBox.h          |  59 ++++
 Core/FormFactors/inc/FormFactorCone.h         |  71 +++++
 Core/FormFactors/inc/FormFactorCylinder.h     |   2 -
 Core/FormFactors/inc/FormFactorEllipsoid.h    |  61 ++++
 Core/FormFactors/inc/FormFactorFullSphere.h   |   4 +-
 Core/FormFactors/inc/FormFactorFullSpheroid.h |  61 ++++
 Core/FormFactors/inc/FormFactorHemiSpheroid.h |  69 +++++
 Core/FormFactors/inc/FormFactorPrism3.h       |   4 +-
 Core/FormFactors/inc/FormFactorSphere.h       |  61 ++++
 Core/FormFactors/src/FormFactorBox.cpp        |  47 +++
 Core/FormFactors/src/FormFactorCone.cpp       | 111 +++++++
 Core/FormFactors/src/FormFactorCylinder.cpp   |  15 -
 Core/FormFactors/src/FormFactorEllipsoid.cpp  |  52 ++++
 Core/FormFactors/src/FormFactorFullSphere.cpp |   9 -
 .../src/FormFactorFullSpheroid.cpp            |  79 +++++
 .../src/FormFactorHemiSpheroid.cpp            | 119 ++++++++
 Core/FormFactors/src/FormFactorSphere.cpp     | 112 +++++++
 shared.pri                                    |   2 +-
 26 files changed, 1392 insertions(+), 41 deletions(-)
 create mode 100644 App/inc/TestFormFactors.h
 create mode 100644 App/src/TestFormFactors.cpp
 create mode 100644 Core/FormFactors/inc/FormFactorBox.h
 create mode 100644 Core/FormFactors/inc/FormFactorCone.h
 create mode 100644 Core/FormFactors/inc/FormFactorEllipsoid.h
 create mode 100644 Core/FormFactors/inc/FormFactorFullSpheroid.h
 create mode 100644 Core/FormFactors/inc/FormFactorHemiSpheroid.h
 create mode 100644 Core/FormFactors/inc/FormFactorSphere.h
 create mode 100644 Core/FormFactors/src/FormFactorBox.cpp
 create mode 100644 Core/FormFactors/src/FormFactorCone.cpp
 create mode 100644 Core/FormFactors/src/FormFactorEllipsoid.cpp
 create mode 100644 Core/FormFactors/src/FormFactorFullSpheroid.cpp
 create mode 100644 Core/FormFactors/src/FormFactorHemiSpheroid.cpp
 create mode 100644 Core/FormFactors/src/FormFactorSphere.cpp

diff --git a/App/App.pro b/App/App.pro
index cb555dc6d86..c5c81769280 100644
--- a/App/App.pro
+++ b/App/App.pro
@@ -50,7 +50,8 @@ SOURCES += \
     src/TestPerformance.cpp \
     src/TestRootTree.cpp \
     src/TestRoughness.cpp \
-    src/TreeEventStructure.cpp
+    src/TreeEventStructure.cpp \
+    src/TestFormFactors.cpp
 
 HEADERS += \
     inc/App.h \
@@ -91,7 +92,8 @@ HEADERS += \
     inc/TestPerformance.h \
     inc/TestRootTree.h \
     inc/TestRoughness.h \
-    inc/TreeEventStructure.h
+    inc/TreeEventStructure.h \
+    inc/TestFormFactors.h
 
 INCLUDEPATH += ./inc ../Core/Algorithms/inc ../Core/FormFactors/inc ../Core/Geometry/inc ../Core/Samples/inc ../Core/Tools/inc ../Core/PythonAPI/inc
 DEPENDPATH  += ./inc ../Core/Algorithms/inc ../Core/FormFactors/inc ../Core/Geometry/inc ../Core/Samples/inc ../Core/Tools/inc ../Core/PythonAPI/inc
diff --git a/App/inc/StandardSamples.h b/App/inc/StandardSamples.h
index 00e41f52040..caf1c14f4c6 100644
--- a/App/inc/StandardSamples.h
+++ b/App/inc/StandardSamples.h
@@ -29,9 +29,17 @@ ISample *IsGISAXS10_CylindersParacrystal1D();
 ISample *IsGISAXS11_CoreShellParticles();
 ISample *MesoCrystal1();
 ISample *MesoCrystal2();
+ISample *FormFactor_Box();
+ISample *FormFactor_Cone();
+ISample *FormFactor_Sphere();
+ISample *FormFactor_Ellipsoid();
+ISample *FormFactor_FullSpheroid();
+ISample *FormFactor_HemiSpheroid();
+ISample *FormFactor_Parallelpiped();
+ISample *FormFactor_Cylinder();
+ISample *FormFactor_Pyramid();
+ISample *FormFactor_FullSphere();
+ISample *FormFactor_Prism3();
 
 }
-
-
-
 #endif // STANDARDSAMPLES_H
diff --git a/App/inc/TestFormFactors.h b/App/inc/TestFormFactors.h
new file mode 100644
index 00000000000..58c884df066
--- /dev/null
+++ b/App/inc/TestFormFactors.h
@@ -0,0 +1,38 @@
+#ifndef TESTFORMFACTORS_H
+#define TESTFORMFACTORS_H
+// ********************************************************************
+// * The BornAgain project                                            *
+// * Simulation of neutron and x-ray scattering at grazing incidence  *
+// *                                                                  *
+// * LICENSE AND DISCLAIMER                                           *
+// * Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris *
+// * eget quam orci. Quisque  porta  varius  dui,  quis  posuere nibh *
+// * mollis quis. Mauris commodo rhoncus porttitor.                   *
+// ********************************************************************
+//! @file   TestFormFactors.h
+//! @brief  Definition of TestFormFactors class for FormFactors validation
+//! @author Scientific Computing Group at FRM II
+//! @date   Jun 28, 2012
+
+#include "IFunctionalTest.h"
+#include "OutputData.h"
+#include "ISample.h"
+
+
+//- -------------------------------------------------------------------
+//! @class TestFormFactors
+//! @brief Comparison with FormFactors ex-1: mean forfactor cylinder and prism
+//- -------------------------------------------------------------------
+class TestFormFactors : public IFunctionalTest
+{
+public:
+    TestFormFactors(){}
+    virtual ~TestFormFactors(){}
+
+    virtual void execute();
+    virtual void finalise();
+private:
+    std::string m_data_path;
+};
+
+#endif // TESTFORMFACTORS_H
diff --git a/App/src/FunctionalTestFactory.cpp b/App/src/FunctionalTestFactory.cpp
index 270d2025ec5..eb563714c8d 100644
--- a/App/src/FunctionalTestFactory.cpp
+++ b/App/src/FunctionalTestFactory.cpp
@@ -16,6 +16,9 @@
 #include "TestDetectorResolution.h"
 #include "TestMesoCrystal1.h"
 #include "TestMesoCrystal2.h"
+
+#include "TestFormFactors.h"
+
 #include "TestRootTree.h"
 #include "TestFittingModule1.h"
 #include "TestFittingModule2.h"
@@ -88,6 +91,9 @@ FunctionalTestFactory::FunctionalTestFactory() : m_benchmark(0)
     registerItem("fourier",    IFactoryCreateFunction<TestFourier, IFunctionalTest>,
                  "functional test: test of Fourier transformation of OutputData maps");
 
+    registerItem("FormFactors", IFactoryCreateFunction<TestFormFactors, IFunctionalTest>,
+                 "functional test: FormFactors");
+
     m_benchmark = new TBenchmark();
 }
 
diff --git a/App/src/SampleFactory.cpp b/App/src/SampleFactory.cpp
index f414cf5c0d3..7d43c2cdaf4 100644
--- a/App/src/SampleFactory.cpp
+++ b/App/src/SampleFactory.cpp
@@ -58,5 +58,16 @@ SampleFactory::SampleFactory()
     // mesocrystal's
     registerItem("MesoCrystal1", StandardSamples::MesoCrystal1);
     registerItem("MesoCrystal2", StandardSamples::MesoCrystal2);
-}
 
+    registerItem("FormFactor_Box", StandardSamples::FormFactor_Box);
+    registerItem("FormFactor_Cone", StandardSamples::FormFactor_Cone);
+    registerItem("FormFactor_Sphere", StandardSamples::FormFactor_Sphere);
+    registerItem("FormFactor_Ellipsoid", StandardSamples::FormFactor_Ellipsoid);
+    registerItem("FormFactor_FullSpheroid", StandardSamples::FormFactor_FullSpheroid);
+    registerItem("FormFactor_HemiSpheroid", StandardSamples::FormFactor_HemiSpheroid);
+    registerItem("FormFactor_Parallelpiped", StandardSamples::FormFactor_Parallelpiped);
+    registerItem("FormFactor_Cylinder", StandardSamples::FormFactor_Cylinder);
+    registerItem("FormFactor_Pyramid", StandardSamples::FormFactor_Pyramid);
+    registerItem("FormFactor_FullSphere", StandardSamples::FormFactor_FullSphere);
+    registerItem("FormFactor_Prism3", StandardSamples::FormFactor_Prism3);
+}
diff --git a/App/src/StandardSamples.cpp b/App/src/StandardSamples.cpp
index ab99100d650..76c08963070 100644
--- a/App/src/StandardSamples.cpp
+++ b/App/src/StandardSamples.cpp
@@ -21,6 +21,17 @@
 #include "ParticleBuilder.h"
 #include "StochasticSampledParameter.h"
 #include "ParticleCoreShell.h"
+#include "FormFactorBox.h"
+#include "FormFactorCone.h"
+#include "FormFactorSphere.h"
+#include "FormFactorEllipsoid.h"
+#include "FormFactorFullSpheroid.h"
+#include "FormFactorHemiSpheroid.h"
+#include "FormFactorFullSphere.h"
+#include "FormFactorPrism3.h"
+
+#include "Particle.h"
+
 
 
 /* ************************************************************************* */
@@ -728,3 +739,274 @@ ISample *StandardSamples::MesoCrystal2()
     return p_multi_layer;
 
 }
+
+/* ************************************************************************* */
+// functional test: Box
+/* ************************************************************************* */
+ISample *StandardSamples::FormFactor_Box()
+{
+    MultiLayer *p_multi_layer = new MultiLayer();
+    complex_t n_air(1.0, 0.0);
+    complex_t n_substrate(1.0-6e-6, 2e-8);
+    complex_t n_particle(1.0-6e-4, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    Layer air_layer;
+    air_layer.setMaterial(p_air_material);
+    Layer substrate_layer;
+    substrate_layer.setMaterial(p_substrate_material);
+    ParticleDecoration particle_decoration(new Particle(n_particle, new FormFactorBox(5*Units::nanometer, 5*Units::nanometer, 5*Units::nanometer)));
+    particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
+    LayerDecorator air_layer_decorator(air_layer, particle_decoration);
+
+    p_multi_layer->addLayer(air_layer_decorator);
+    p_multi_layer->addLayer(substrate_layer);
+    return p_multi_layer;
+}
+
+/* ************************************************************************* */
+//  functional test: Form Factor Cone
+/* ************************************************************************* */
+ISample *StandardSamples::FormFactor_Cone()
+{
+    MultiLayer *p_multi_layer = new MultiLayer();
+    complex_t n_air(1.0, 0.0);
+    complex_t n_substrate(1.0-6e-6, 2e-8);
+    complex_t n_particle(1.0-6e-4, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    Layer air_layer;
+    air_layer.setMaterial(p_air_material);
+    Layer substrate_layer;
+    substrate_layer.setMaterial(p_substrate_material);
+    ParticleDecoration particle_decoration(new Particle(n_particle, new FormFactorCone(5*Units::nanometer, 5*Units::nanometer, Units::deg2rad(54.73 ))));
+    particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
+    LayerDecorator air_layer_decorator(air_layer, particle_decoration);
+
+    p_multi_layer->addLayer(air_layer_decorator);
+    p_multi_layer->addLayer(substrate_layer);
+    return p_multi_layer;
+}
+
+
+/* ************************************************************************* */
+//  functional test: Form Factor Sphere
+/* ************************************************************************* */
+ISample *StandardSamples::FormFactor_Sphere()
+{
+    MultiLayer *p_multi_layer = new MultiLayer();
+    complex_t n_air(1.0, 0.0);
+    complex_t n_substrate(1.0-6e-6, 2e-8);
+    complex_t n_particle(1.0-6e-4, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    Layer air_layer;
+    air_layer.setMaterial(p_air_material);
+    Layer substrate_layer;
+    substrate_layer.setMaterial(p_substrate_material);
+    ParticleDecoration particle_decoration(new Particle(n_particle, new FormFactorSphere(5*Units::nanometer, 5*Units::nanometer)));
+    particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
+    LayerDecorator air_layer_decorator(air_layer, particle_decoration);
+
+    p_multi_layer->addLayer(air_layer_decorator);
+    p_multi_layer->addLayer(substrate_layer);
+    return p_multi_layer;
+}
+
+/* ************************************************************************* */
+//  functional test: Form Factor Ellipsoid
+/* ************************************************************************* */
+ISample *StandardSamples::FormFactor_Ellipsoid()
+{
+    MultiLayer *p_multi_layer = new MultiLayer();
+    complex_t n_air(1.0, 0.0);
+    complex_t n_substrate(1.0-6e-6, 2e-8);
+    complex_t n_particle(1.0-6e-4, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    Layer air_layer;
+    air_layer.setMaterial(p_air_material);
+    Layer substrate_layer;
+    substrate_layer.setMaterial(p_substrate_material);
+    ParticleDecoration particle_decoration(new Particle(n_particle, new FormFactorEllipsoid(5*Units::nanometer, 5*Units::nanometer, 5*Units::nanometer, Units::deg2rad(54.73 ))));
+    particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
+    LayerDecorator air_layer_decorator(air_layer, particle_decoration);
+
+    p_multi_layer->addLayer(air_layer_decorator);
+    p_multi_layer->addLayer(substrate_layer);
+    return p_multi_layer;
+}
+
+
+/* ************************************************************************* */
+//  functional test: Form Factor Full Spheroid
+/* ************************************************************************* */
+ISample *StandardSamples::FormFactor_FullSpheroid()
+{
+    MultiLayer *p_multi_layer = new MultiLayer();
+    complex_t n_air(1.0, 0.0);
+    complex_t n_substrate(1.0-6e-5, 2e-8);
+    complex_t n_particle(1.0-6e-4, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    Layer air_layer;
+    air_layer.setMaterial(p_air_material);
+    Layer substrate_layer;
+    substrate_layer.setMaterial(p_substrate_material);
+    ParticleDecoration particle_decoration(new Particle(n_particle, new FormFactorFullSpheroid(5*Units::nanometer, 7*Units::nanometer )));
+    particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
+    LayerDecorator air_layer_decorator(air_layer, particle_decoration);
+
+    p_multi_layer->addLayer(air_layer_decorator);
+    p_multi_layer->addLayer(substrate_layer);
+    return p_multi_layer;
+}
+
+
+/* ************************************************************************* */
+//  functional test: Form Factor Hemi Spheroid
+/* ************************************************************************* */
+ISample *StandardSamples::FormFactor_HemiSpheroid()
+{
+    MultiLayer *p_multi_layer = new MultiLayer();
+    complex_t n_air(1.0, 0.0);
+    complex_t n_substrate(1.0-6e-7, 2e-8);
+    complex_t n_particle(1.0-6e-5, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    Layer air_layer;
+    air_layer.setMaterial(p_air_material);
+    Layer substrate_layer;
+    substrate_layer.setMaterial(p_substrate_material);
+    ParticleDecoration particle_decoration(new Particle(n_particle, new FormFactorHemiSpheroid(5*Units::nanometer, 4*Units::nanometer, 2*Units::nanometer)));
+    particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
+    LayerDecorator air_layer_decorator(air_layer, particle_decoration);
+
+    p_multi_layer->addLayer(air_layer_decorator);
+    p_multi_layer->addLayer(substrate_layer);
+    return p_multi_layer;
+}
+
+/* ************************************************************************* */
+// functional test: Form Factor parallelepiped
+/* ************************************************************************* */
+ISample *StandardSamples::FormFactor_Parallelpiped()
+{
+    MultiLayer *p_multi_layer = new MultiLayer();
+    complex_t n_air(1.0, 0.0);
+    complex_t n_particle_shell(1.0-1e-4, 2e-8);
+    complex_t n_particle_core(1.0-6e-5, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air11", n_air);
+    Layer air_layer;
+    air_layer.setMaterial(p_air_material);
+    Particle shell_particle(n_particle_shell, new FormFactorParallelepiped(8*Units::nanometer, 8*Units::nanometer));
+    Particle core_particle(n_particle_core, new FormFactorParallelepiped(7*Units::nanometer, 6*Units::nanometer));
+    kvector_t core_position(0.0, 0.0, 0.0);
+    ParticleCoreShell particle(shell_particle, core_particle, core_position);
+    ParticleDecoration particle_decoration(particle.clone());
+    particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
+    LayerDecorator air_layer_decorator(air_layer, particle_decoration);
+
+    p_multi_layer->addLayer(air_layer_decorator);
+    return p_multi_layer;
+}
+
+
+/* ************************************************************************* */
+// functional test: Form Factor Cylinder
+/* ************************************************************************* */
+ISample *StandardSamples::FormFactor_Cylinder()
+{
+    MultiLayer *p_multi_layer = new MultiLayer();
+    complex_t n_air(1.0, 0.0);
+    complex_t n_particle_shell(1.0-1e-4, 2e-8);
+    complex_t n_particle_core(1.0-6e-5, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air11", n_air);
+    Layer air_layer;
+    air_layer.setMaterial(p_air_material);
+    Particle shell_particle(n_particle_shell, new FormFactorCylinder(8*Units::nanometer, 8*Units::nanometer));
+    Particle core_particle(n_particle_core, new FormFactorCylinder(7*Units::nanometer, 6*Units::nanometer));
+    kvector_t core_position(0.0, 0.0, 0.0);
+    ParticleCoreShell particle(shell_particle, core_particle, core_position);
+    ParticleDecoration particle_decoration(particle.clone());
+    particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
+    LayerDecorator air_layer_decorator(air_layer, particle_decoration);
+
+    p_multi_layer->addLayer(air_layer_decorator);
+    return p_multi_layer;
+}
+
+/* ************************************************************************* */
+// Functional test: Pyramid
+/* ************************************************************************* */
+ISample *StandardSamples::FormFactor_Pyramid()
+{
+    MultiLayer *p_multi_layer = new MultiLayer();
+    complex_t n_air(1.0, 0.0);
+    complex_t n_substrate(1.0-6e-6, 2e-8);
+    complex_t n_particle(1.0-6e-4, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    Layer air_layer;
+    air_layer.setMaterial(p_air_material);
+    Layer substrate_layer;
+    substrate_layer.setMaterial(p_substrate_material);
+    ParticleDecoration particle_decoration(
+                new Particle(n_particle, new FormFactorPyramid(5*Units::nanometer, 5*Units::nanometer, Units::deg2rad(54.73 ) ) ) );
+    particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
+    LayerDecorator air_layer_decorator(air_layer, particle_decoration);
+
+    p_multi_layer->addLayer(air_layer_decorator);
+    p_multi_layer->addLayer(substrate_layer);
+    return p_multi_layer;
+}
+
+
+/* ************************************************************************* */
+// functional test: Prism3
+/* ************************************************************************* */
+ISample *StandardSamples::FormFactor_Prism3()
+{
+    MultiLayer *p_multi_layer = new MultiLayer();
+    complex_t n_air(1.0, 0.0);
+    complex_t n_substrate(1.0-7e-6, 2e-8);
+    complex_t n_particle(1.0-8e-4, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    Layer air_layer;
+    air_layer.setMaterial(p_air_material);
+    Layer substrate_layer;
+    substrate_layer.setMaterial(p_substrate_material);
+    ParticleDecoration particle_decoration(new Particle(n_particle, new FormFactorPrism3(5*Units::nanometer, 5*Units::nanometer)));
+    particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
+    LayerDecorator air_layer_decorator(air_layer, particle_decoration);
+
+    p_multi_layer->addLayer(air_layer_decorator);
+    p_multi_layer->addLayer(substrate_layer);
+    return p_multi_layer;
+}
+
+ /************************************************************************** */
+ // Functional test: Full Sphere
+ /************************************************************************** */
+    ISample *StandardSamples::FormFactor_FullSphere()
+     {
+     MultiLayer *p_multi_layer = new MultiLayer();
+     complex_t n_air(1.0, 0.0);
+     complex_t n_substrate(1.0-6e-6, 2e-8);
+     complex_t n_particle(1.0-6e-4, 2e-8);
+     const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+     const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+     Layer air_layer;
+     air_layer.setMaterial(p_air_material);
+     Layer substrate_layer;
+     substrate_layer.setMaterial(p_substrate_material);
+     ParticleDecoration particle_decoration(
+                 new Particle(n_particle, new FormFactorFullSphere(5*Units::nanometer ) ) );
+     particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
+     LayerDecorator air_layer_decorator(air_layer, particle_decoration);
+
+     p_multi_layer->addLayer(air_layer_decorator);
+     p_multi_layer->addLayer(substrate_layer);
+     return p_multi_layer;
+     }
diff --git a/App/src/TestFormFactors.cpp b/App/src/TestFormFactors.cpp
new file mode 100644
index 00000000000..fa843c72e21
--- /dev/null
+++ b/App/src/TestFormFactors.cpp
@@ -0,0 +1,118 @@
+#include "TestFormFactors.h"
+#include "IsGISAXSTools.h"
+#include "Units.h"
+#include "Utils.h"
+#include "GISASExperiment.h"
+#include "MultiLayer.h"
+#include "SampleFactory.h"
+#include "DrawHelper.h"
+#include "TCanvas.h"
+
+
+void TestFormFactors::execute()
+{
+    MultiLayer *sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Box"));
+    GISASExperiment experiment(mp_options);
+    experiment.setSample(*sample);
+    experiment.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true);
+    experiment.setBeamParameters(1.0*Units::angstrom, -0.2*Units::degree, 0.0*Units::degree);
+    experiment.runSimulation();
+    m_data_path = std::string(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/");
+    IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Box.ima");
+
+     //Cone
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Cone"));
+     experiment.setSample(*sample);
+     experiment.runSimulation();
+     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Cone.ima");
+
+     //Ellipsoid
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Ellipsoid"));
+     experiment.setSample(*sample);
+     experiment.runSimulation();
+     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Ellipsoid.ima");
+
+     //Sphere
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Sphere"));
+     experiment.setSample(*sample);
+     experiment.runSimulation();
+     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Sphere.ima");
+
+
+     //Full Spheroid
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_FullSpheroid"));
+     experiment.setSample(*sample);
+     experiment.runSimulation();
+     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_FullSpheroid.ima");
+
+     //Hemi Spheroid
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_HemiSpheroid"));
+     experiment.setSample(*sample);
+     experiment.runSimulation();
+     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_HemiSpheroid.ima");
+
+
+     //Pyramid
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Pyramid"));
+     experiment.setSample(*sample);
+     experiment.runSimulation();
+     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Pyramid.ima");
+
+     //Cylinder
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Cylinder"));
+     experiment.setSample(*sample);
+     experiment.runSimulation();
+     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Cylinder.ima");
+
+     //Full Sphere
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_FullSphere"));
+     experiment.setSample(*sample);
+     experiment.runSimulation();
+     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_FullSphere.ima");
+
+
+     //Prism3
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Prism3"));
+     experiment.setSample(*sample);
+     experiment.runSimulation();
+     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Prism3.ima");
+
+
+    //OutputData<double > *mp_intensity_output = experiment.getOutputDataClone();
+}
+
+
+
+
+void TestFormFactors::finalise()
+{
+    std::vector<std::string > this_files;
+    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Box.ima");
+    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Cone.ima");
+    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Sphere.ima");
+    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Ellipsoid.ima");
+    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_FullSpheroid.ima");
+    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_HemiSpheroid.ima");
+    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Parallelpiped.ima");
+    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Cylinder.ima");
+    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Pyramid.ima");
+    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_FullSphere.ima");
+    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Prism3.ima");
+
+    int ncomparison = this_files.size();
+    TCanvas *c1 = DrawHelper::instance().createAndRegisterCanvas("Form Factors", "TestFormFactors");
+    c1->Divide(4,5);
+
+    for(int i=0; i<ncomparison; i++) {
+            OutputData<double> *our_data = IsGISAXSTools::readOutputDataFromFile(this_files[i], 10);
+
+            IsGISAXSTools::setMinimum(1.);
+            // our calculations
+            c1->cd(i+1); gPad->SetLogz();
+            IsGISAXSTools::drawOutputDataInPad(*our_data, "CONT4 Z", "Our Form Factors");
+
+            IsGISAXSTools::resetMinimum(); IsGISAXSTools::resetMaximum();
+            delete our_data;
+        }
+    }
+
diff --git a/Core/Core.pro b/Core/Core.pro
index 37af6fc53a3..791e5a11fa5 100644
--- a/Core/Core.pro
+++ b/Core/Core.pro
@@ -5,7 +5,7 @@ TARGET   = ScattCore
 TEMPLATE = lib
 CONFIG  += plugin # to remove versions from file name
 QT      -= core gui
-CONFIG  += BUILD_PYTHON_BOOST_MODULE # to  generate python interface
+#CONFIG  += BUILD_PYTHON_BOOST_MODULE # to  generate python interface
 
 # including common project properties
 include($$PWD/../shared.pri)
@@ -124,7 +124,13 @@ SOURCES += \
     PythonAPI/src/PythonListConverter.cpp \
     PythonAPI/src/PythonModule.cpp \
     PythonAPI/src/PythonPlusplusHelper.cpp \
-    PythonAPI/src/PythonOutputData.cpp
+    PythonAPI/src/PythonOutputData.cpp \
+    FormFactors/src/FormFactorBox.cpp \
+    FormFactors/src/FormFactorEllipsoid.cpp \
+    FormFactors/src/FormFactorCone.cpp \
+    FormFactors/src/FormFactorHemiSpheroid.cpp \
+    FormFactors/src/FormFactorFullSpheroid.cpp \
+    FormFactors/src/FormFactorSphere.cpp
 
 HEADERS += \
     Algorithms/inc/Beam.h \
@@ -274,7 +280,13 @@ HEADERS += \
     PythonAPI/inc/PythonOutputData.h \
     PythonAPI/inc/PythonPlusplusHelper.h \
     PythonAPI/inc/IPythonWrapper.h \
-    Algorithms/inc/IIntensityFunction.h
+    Algorithms/inc/IIntensityFunction.h \
+    FormFactors/inc/FormFactorBox.h \
+    FormFactors/inc/FormFactorEllipsoid.h \
+    FormFactors/inc/FormFactorCone.h \
+    FormFactors/inc/FormFactorHemiSpheroid.h \
+    FormFactors/inc/FormFactorFullSpheroid.h \
+    FormFactors/inc/FormFactorSphere.h
 
 INCLUDEPATH += ./Algorithms/inc ./FormFactors/inc ./Geometry/inc ./Samples/inc ./Tools/inc ./PythonAPI/inc
 DEPENDPATH  += ./Algorithms/inc ./FormFactors/inc ./Geometry/inc ./Samples/inc ./Tools/inc ./PythonAPI/inc
diff --git a/Core/FormFactors/inc/FormFactorBox.h b/Core/FormFactors/inc/FormFactorBox.h
new file mode 100644
index 00000000000..81fc8bde516
--- /dev/null
+++ b/Core/FormFactors/inc/FormFactorBox.h
@@ -0,0 +1,59 @@
+#ifndef FORMFACTORBOX_H
+#define FORMFACTORBOX_H
+// ********************************************************************
+// * The BornAgain project                                            *
+// * Simulation of neutron and x-ray scattering at grazing incidence  *
+// *                                                                  *
+// * LICENSE AND DISCLAIMER                                           *
+// * Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris *
+// * eget quam orci. Quisque  porta  varius  dui,  quis  posuere nibh *
+// * mollis quis. Mauris commodo rhoncus porttitor.                   *
+// ********************************************************************
+//! @file   FormFactorBox.h
+//! @brief  Definition of FormFactorBox class
+//! @author Scientific Computing Group at FRM II
+//! @date   Oct 1, 2012
+
+#include "IFormFactor.h"
+#include "IStochasticParameter.h"
+
+class FormFactorBox : public IFormFactorBorn
+{
+public:
+    FormFactorBox( double radius, double width, double height);
+    ~FormFactorBox();
+    virtual FormFactorBox *clone() const;
+
+    virtual int getNumberOfStochasticParameters() const { return 2; }
+
+    //! return radius of Box
+    double getRadius() const { return m_radius; }
+
+    //! return width of Box
+    double getwidth() const { return m_width; }
+
+    virtual double getVolume() const {
+        return 4.0*m_height*m_radius*m_width;
+    }
+
+    virtual double getHeight() const { return m_height; }
+
+
+protected:
+    virtual complex_t evaluate_for_q(const cvector_t &q) const;
+
+private:
+
+    //! initialize pool parameters, i.e. register some of class members for later access via parameter pool
+    virtual void init_parameters();
+
+    //! print class
+    void print(std::ostream &ostr) const;
+
+    double m_radius;
+    double m_width;
+    double m_height;
+
+};
+
+#endif // FORMFACTORBOX_H
diff --git a/Core/FormFactors/inc/FormFactorCone.h b/Core/FormFactors/inc/FormFactorCone.h
new file mode 100644
index 00000000000..f89704747b2
--- /dev/null
+++ b/Core/FormFactors/inc/FormFactorCone.h
@@ -0,0 +1,71 @@
+#ifndef FORMFACTORCONE_H
+#define FORMFACTORCONE_H
+// ********************************************************************
+// * The BornAgain project                                            *
+// * Simulation of neutron and x-ray scattering at grazing incidence  *
+// *                                                                  *
+// * LICENSE AND DISCLAIMER                                           *
+// * Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris *
+// * eget quam orci. Quisque  porta  varius  dui,  quis  posuere nibh *
+// * mollis quis. Mauris commodo rhoncus porttitor.                   *
+// ********************************************************************
+//! @file   FormFactorCone.h
+//! @brief  Definition of FormFactorCone
+//! @author Scientific Computing Group at FRM II
+//! @date   03.07.2012
+
+#include "IFormFactor.h"
+#include "IStochasticParameter.h"
+//#include "ConeIntegralReal.h"
+
+//- -------------------------------------------------------------------
+//! @class FormFactorCone
+//! @brief Form factor of Cone
+//- -------------------------------------------------------------------
+class FormFactorCone : public IFormFactorBorn
+{
+public:
+    //! @brief Cone constructor
+    //! @param height of Conee
+    //! @param radius half of Cone's base
+    //! @param angle in radians between base and facet
+    FormFactorCone(double radius, double height,  double alpha);
+
+
+//    FormFactorCone(StochasticParameter<double> *p_height, StochasticParameter<double> *p_radius, StochasticParameter<double> *p_alpha);
+    ~FormFactorCone();
+    virtual FormFactorCone* clone() const;
+
+    virtual int getNumberOfStochasticParameters() const { return 3; }
+
+    virtual double getHeight() const { return m_height; }
+
+protected:
+    virtual complex_t evaluate_for_q (const cvector_t &q) const;
+
+private:
+    //! copy constructor and assignment operator are hidden since there is a clone method
+    FormFactorCone(const FormFactorCone &);
+    FormFactorCone &operator=(const FormFactorCone &);
+
+    //    double ConeIntegral(double Z, void* params) const;
+    double evaluate_for_q_real() const;
+    complex_t evaluate_for_q_imag() const;
+    double ConeIntegralReal(double Z, void* params) const;
+    double ConeIntegralImaginary(double Z, void* params) const;
+
+
+    //! initialize pool parameters, i.e. register some of class members for later access via parameter pool
+    virtual void init_parameters();
+
+    //! print class
+    void print(std::ostream &ostr) const;
+
+    double m_radius;
+    double m_height;
+    double m_alpha;
+    mutable cvector_t m_q;
+
+};
+
+#endif // FORMFACTORCONE_H
diff --git a/Core/FormFactors/inc/FormFactorCylinder.h b/Core/FormFactors/inc/FormFactorCylinder.h
index a3e294af331..5ca5078625c 100644
--- a/Core/FormFactors/inc/FormFactorCylinder.h
+++ b/Core/FormFactors/inc/FormFactorCylinder.h
@@ -44,8 +44,6 @@ private:
     //! print class
     void print(std::ostream &ostr) const;
 
-//    StochasticParameter<double> *mp_height;
-//    StochasticParameter<double> *mp_radius;
     double m_height;
     double m_radius;
 };
diff --git a/Core/FormFactors/inc/FormFactorEllipsoid.h b/Core/FormFactors/inc/FormFactorEllipsoid.h
new file mode 100644
index 00000000000..55ff171cd46
--- /dev/null
+++ b/Core/FormFactors/inc/FormFactorEllipsoid.h
@@ -0,0 +1,61 @@
+#ifndef FORMFACTORELLIPSOID_H
+#define FORMFACTORELLIPSOID_H
+
+// ********************************************************************
+// * The BornAgain project                                            *
+// * Simulation of neutron and x-ray scattering at grazing incidence  *
+// *                                                                  *
+// * LICENSE AND DISCLAIMER                                           *
+// * Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris *
+// * eget quam orci. Quisque  porta  varius  dui,  quis  posuere nibh *
+// * mollis quis. Mauris commodo rhoncus porttitor.                   *
+// ********************************************************************
+//! @file   FormFactorEllipsoid.h
+//! @brief  Definition of FormFactorEllipsoid class
+//! @author Scientific Computing Group at FRM II
+//! @date   Oct 1, 2012
+
+#include "IFormFactor.h"
+#include "IStochasticParameter.h"
+
+class FormFactorEllipsoid : public IFormFactorBorn
+{
+public:
+    FormFactorEllipsoid( double radius, double width, double height, double alpha);
+    ~FormFactorEllipsoid();
+    virtual FormFactorEllipsoid *clone() const;
+
+    virtual int getNumberOfStochasticParameters() const { return 2; }
+
+    //! return radius of Ellipsoid
+    double getRadius() const { return m_radius; }
+
+    //! return width of Ellipsoid
+    double getwidth() const { return m_width; }
+
+    virtual double getVolume() const {
+        return 2.0*m_height*m_radius*m_width;
+    }
+
+    virtual double getHeight() const { return m_height; }
+
+
+protected:
+    virtual complex_t evaluate_for_q(const cvector_t &q) const;
+
+private:
+
+    //! initialize pool parameters, i.e. register some of class members for later access via parameter pool
+    virtual void init_parameters();
+
+    //! print class
+    void print(std::ostream &ostr) const;
+
+    double m_radius;
+    double m_width;
+    double m_height;
+    double m_alpha;
+
+};
+
+#endif // FORMFACTORELLIPSOID_H
diff --git a/Core/FormFactors/inc/FormFactorFullSphere.h b/Core/FormFactors/inc/FormFactorFullSphere.h
index 728077a7aba..d8f905c6fa4 100644
--- a/Core/FormFactors/inc/FormFactorFullSphere.h
+++ b/Core/FormFactors/inc/FormFactorFullSphere.h
@@ -21,7 +21,7 @@ class FormFactorFullSphere : public IFormFactorBorn
 {
 public:
     FormFactorFullSphere(double radius);
-//    FormFactorFullSphere(StochasticParameter<double> *p_radius);
+
     ~FormFactorFullSphere();
     virtual FormFactorFullSphere *clone() const;
 
@@ -44,7 +44,7 @@ private:
     void print(std::ostream &ostr) const;
 
     double m_radius;
-//    StochasticParameter<double> *mp_radius;
+
 };
 
 
diff --git a/Core/FormFactors/inc/FormFactorFullSpheroid.h b/Core/FormFactors/inc/FormFactorFullSpheroid.h
new file mode 100644
index 00000000000..43d5cc60dc2
--- /dev/null
+++ b/Core/FormFactors/inc/FormFactorFullSpheroid.h
@@ -0,0 +1,61 @@
+#ifndef FORMFACTORFULLSPHEROID_H
+#define FORMFACTORFULLSPHEROID_H
+// ********************************************************************
+// * The BornAgain project                                            *
+// * Simulation of neutron and x-ray scattering at grazing incidence  *
+// *                                                                  *
+// * LICENSE AND DISCLAIMER                                           *
+// * Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris *
+// * eget quam orci. Quisque  porta  varius  dui,  quis  posuere nibh *
+// * mollis quis. Mauris commodo rhoncus porttitor.                   *
+// ********************************************************************
+//! @file   FormFactorFullSpheroid.h
+//! @brief  Definition of FormFactorFullSpheroid
+//! @author Scientific Computing Group at FRM II
+//! @date   01.05.2012
+
+#include "IFormFactor.h"
+#include "IStochasticParameter.h"
+
+
+class FormFactorFullSpheroid : public IFormFactorBorn
+{
+public:
+    FormFactorFullSpheroid(double radius, double height);
+    double FullSpheroidIntegral(double Z, void* params) const;
+//    FormFactorFullSpheroid(StochasticParameter<double> *p_height, StochasticParameter<double> *p_radius);
+    ~FormFactorFullSpheroid();
+    virtual FormFactorFullSpheroid *clone() const;
+
+    virtual int getNumberOfStochasticParameters() const { return 2; }
+
+    virtual double getHeight() const { return m_height; }
+
+protected:
+    virtual complex_t evaluate_for_q(const cvector_t &q) const;
+
+private:
+    //! copy constructor and assignment operator are hidden since there is a clone method
+    FormFactorFullSpheroid(const FormFactorFullSpheroid &);
+    FormFactorFullSpheroid &operator=(const FormFactorFullSpheroid &);
+
+
+    double evaluate_for_q_real() const;
+    complex_t evaluate_for_q_imag() const;
+    double FullSpheroidIntegralReal(double Z, void* params) const;
+    double FullSpheroidIntegralImaginary(double Z, void* params) const;
+
+    //! initialize pool parameters, i.e. register some of class members for later access via parameter pool
+    virtual void init_parameters();
+
+    //! print class
+    void print(std::ostream &ostr) const;
+
+    double m_radius;
+    double m_height;
+    mutable cvector_t m_q;
+
+};
+
+
+#endif // FORMFACTORFULLSPHEROID_H
diff --git a/Core/FormFactors/inc/FormFactorHemiSpheroid.h b/Core/FormFactors/inc/FormFactorHemiSpheroid.h
new file mode 100644
index 00000000000..118d0571ead
--- /dev/null
+++ b/Core/FormFactors/inc/FormFactorHemiSpheroid.h
@@ -0,0 +1,69 @@
+#ifndef FORMFACTORHEMISPHEROID_H
+#define FORMFACTORHEMISPHEROID_H
+// ********************************************************************
+// * The BornAgain project                                            *
+// * Simulation of neutron and x-ray scattering at grazing incidence  *
+// *                                                                  *
+// * LICENSE AND DISCLAIMER                                           *
+// * Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris *
+// * eget quam orci. Quisque  porta  varius  dui,  quis  posuere nibh *
+// * mollis quis. Mauris commodo rhoncus porttitor.                   *
+// ********************************************************************
+//! @file   FormFactorHemiSpheroid.h
+//! @brief  Definition of FormFactorHemiSpheroid
+//! @author Scientific Computing Group at FRM II
+//! @date   03.07.2012
+
+#include "IFormFactor.h"
+#include "IStochasticParameter.h"
+
+//- -------------------------------------------------------------------
+//! @class FormFactorHemiSpheroid
+//! @brief Form factor of Cone
+//- -------------------------------------------------------------------
+class FormFactorHemiSpheroid : public IFormFactorBorn
+{
+public:
+    //! @brief Cone constructor
+    //! @param height of Conee
+    //! @param radius half of Cone's base
+    //! @param angle in radians between base and facet
+    FormFactorHemiSpheroid(double radius,  double width, double height);
+    double HemiSpheroidIntegral(double Z, void* params) const;
+
+    ~FormFactorHemiSpheroid();
+    virtual FormFactorHemiSpheroid* clone() const;
+
+    virtual int getNumberOfStochasticParameters() const { return 3; }
+
+    virtual double getHeight() const { return m_height; }
+
+protected:
+    virtual complex_t evaluate_for_q (const cvector_t &q) const;
+
+private:
+    //! copy constructor and assignment operator are hidden since there is a clone method
+    FormFactorHemiSpheroid(const FormFactorHemiSpheroid &);
+    FormFactorHemiSpheroid &operator=(const FormFactorHemiSpheroid &);
+
+    double evaluate_for_q_real() const;
+    complex_t evaluate_for_q_imag() const;
+    double HemiSpheroidIntegralReal(double Z, void* params) const;
+
+    double HemiSpheroidIntegralImaginary(double Z, void* params) const;
+
+    //! initialize pool parameters, i.e. register some of class members for later access via parameter pool
+    virtual void init_parameters();
+
+    //! print class
+    void print(std::ostream &ostr) const;
+
+    double m_radius;
+    double m_width;
+    double m_height;
+    mutable cvector_t m_q;
+
+};
+
+
+#endif // FormFactorHemiSpheroid_H
diff --git a/Core/FormFactors/inc/FormFactorPrism3.h b/Core/FormFactors/inc/FormFactorPrism3.h
index a6c215cc9e9..caf0c7e7097 100644
--- a/Core/FormFactors/inc/FormFactorPrism3.h
+++ b/Core/FormFactors/inc/FormFactorPrism3.h
@@ -47,9 +47,7 @@ private:
 
     double m_height;
     double m_half_side;
-//    StochasticParameter<double> *mp_height;
-//    StochasticParameter<double> *mp_half_side;
-    // Cached value of square root of 3
+
     double m_root3;
 };
 
diff --git a/Core/FormFactors/inc/FormFactorSphere.h b/Core/FormFactors/inc/FormFactorSphere.h
new file mode 100644
index 00000000000..75c684c23ee
--- /dev/null
+++ b/Core/FormFactors/inc/FormFactorSphere.h
@@ -0,0 +1,61 @@
+#ifndef FORMFACTORSPHERE_H
+#define FORMFACTORSPHERE_H
+// ********************************************************************
+// * The BornAgain project                                            *
+// * Simulation of neutron and x-ray scattering at grazing incidence  *
+// *                                                                  *
+// * LICENSE AND DISCLAIMER                                           *
+// * Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris *
+// * eget quam orci. Quisque  porta  varius  dui,  quis  posuere nibh *
+// * mollis quis. Mauris commodo rhoncus porttitor.                   *
+// ********************************************************************
+//! @file   FormFactorSphere.h
+//! @brief  Definition of FormFactorSphere
+//! @author Scientific Computing Group at FRM II
+//! @date   01.05.2012
+
+#include "IFormFactor.h"
+#include "IStochasticParameter.h"
+
+
+class FormFactorSphere : public IFormFactorBorn
+{
+public:
+    FormFactorSphere(double radius, double height);
+    double SphereIntegral(double Z, void* params) const;
+
+    ~FormFactorSphere();
+    virtual FormFactorSphere *clone() const;
+
+    virtual int getNumberOfStochasticParameters() const { return 2; }
+
+    virtual double getHeight() const { return m_height; }
+
+protected:
+    virtual complex_t evaluate_for_q(const cvector_t &q) const;
+
+private:
+    //! copy constructor and assignment operator are hidden since there is a clone method
+    FormFactorSphere(const FormFactorSphere &);
+    FormFactorSphere &operator=(const FormFactorSphere &);
+
+
+
+        double evaluate_for_q_real() const;
+        complex_t evaluate_for_q_imag() const;
+        double SphereIntegralImaginary(double Z, void* params) const;
+        double SphereIntegralReal(double Z, void* params) const;
+
+    //! initialize pool parameters, i.e. register some of class members for later access via parameter pool
+    virtual void init_parameters();
+
+    //! print class
+    void print(std::ostream &ostr) const;
+
+    double m_height;
+    double m_radius;
+    mutable cvector_t m_q;
+};
+
+
+#endif // FORMFACTORSPHERE_H
diff --git a/Core/FormFactors/src/FormFactorBox.cpp b/Core/FormFactors/src/FormFactorBox.cpp
new file mode 100644
index 00000000000..379f35e497d
--- /dev/null
+++ b/Core/FormFactors/src/FormFactorBox.cpp
@@ -0,0 +1,47 @@
+#include "FormFactorBox.h"
+#include "MathFunctions.h"
+
+FormFactorBox::FormFactorBox(double radius, double width, double height)
+
+ :m_radius(radius)
+ ,m_width(width)
+ ,m_height(height)
+{
+}
+
+FormFactorBox::~FormFactorBox()
+{
+}
+
+FormFactorBox* FormFactorBox::clone() const
+{
+    return new FormFactorBox(m_radius, m_width, m_height );
+}
+
+complex_t FormFactorBox::evaluate_for_q(const cvector_t& q) const
+{
+    complex_t qxR = q.x()*m_radius;
+    complex_t qyW = q.y()*m_width;
+    complex_t qzHdiv2 = q.z()*m_height/2.0;
+
+    complex_t phase_factor = std::exp(complex_t(0.0, 1.0)*qzHdiv2);
+       return getVolume() *phase_factor*MathFunctions::Sinc(qxR)*MathFunctions::Sinc(qyW)
+                          *MathFunctions::Sinc(qzHdiv2);
+   }
+
+
+
+  void FormFactorBox::init_parameters()
+   {
+       getParameterPool()->clear();
+       getParameterPool()->registerParameter("radius", &m_radius);
+       getParameterPool()->registerParameter( "width",  &m_width);
+       getParameterPool()->registerParameter("height", &m_height);
+
+   }
+
+   void FormFactorBox::print(std::ostream& ostr) const
+   {
+       ISample::print(ostr);
+   }
+
diff --git a/Core/FormFactors/src/FormFactorCone.cpp b/Core/FormFactors/src/FormFactorCone.cpp
new file mode 100644
index 00000000000..8ef09496259
--- /dev/null
+++ b/Core/FormFactors/src/FormFactorCone.cpp
@@ -0,0 +1,111 @@
+#include "FormFactorCone.h"
+#include "StochasticDiracDelta.h"
+#include "MathFunctions.h"
+#include "Numeric.h"
+#include "Units.h"
+#include "Exceptions.h"
+#include <iostream>
+#include "MemberFunctionIntegrator.h"
+
+FormFactorCone::FormFactorCone(double radius,double height,double alpha)
+{
+    setName("FormFactorCone");
+    m_radius = radius;
+    m_height = height;
+    m_alpha = alpha;
+    init_parameters();
+}
+
+
+FormFactorCone::~FormFactorCone()
+{
+}
+
+/* ************************************************************************* */
+// initialize pool parameters, i.e. register some of class members for later access via parameter pool
+/* ************************************************************************* */
+void FormFactorCone::init_parameters()
+{
+    getParameterPool()->clear();
+    getParameterPool()->registerParameter("radius", &m_radius);
+    getParameterPool()->registerParameter("height", &m_height);
+    getParameterPool()->registerParameter("alpha",  &m_alpha);
+}
+
+
+FormFactorCone* FormFactorCone::clone() const
+{
+   FormFactorCone* ffCone = new FormFactorCone(m_radius, m_height, m_alpha);
+   return ffCone;
+}
+
+
+//********************Real Part of the Integral*********************************//
+double FormFactorCone::evaluate_for_q_real() const
+
+{
+    double H = m_height;
+    MemberFunctionIntegrator<FormFactorCone>::mem_function p_mf = &FormFactorCone::ConeIntegralReal;
+    MemberFunctionIntegrator<FormFactorCone> integrator(p_mf,this);
+    double RealRadial = integrator.integrate(0, H, (void *)0);
+    return RealRadial;
+ }
+
+
+ double FormFactorCone::ConeIntegralReal(double Z, void* params) const
+ {
+    (void)params;
+    complex_t qz = m_q.z();
+    complex_t qx = m_q.x();
+    complex_t qy = m_q.y();
+    double R = m_radius;
+    double tan_alpha = std::tan(m_alpha);
+    double Rz  = R-(Z/tan_alpha);
+    double qrRz = std::abs(std::sqrt((qx)*(qx) + (qy)*(qy))*Rz);
+    double J1_qrRz_div_qrRz = std::abs(qrRz) > Numeric::double_epsilon ? MathFunctions::Bessel_J1(std::abs(qrRz))/qrRz : 0.5;
+    double exp_real = std::exp(complex_t(0.0, 1.0)*qz*Z).real();
+    return 2.0 * M_PI *Rz*Rz * J1_qrRz_div_qrRz * exp_real;
+      }
+
+
+ //*********************************Imaginary Part***************************//
+ complex_t FormFactorCone::evaluate_for_q_imag() const
+{
+    double H = m_height;
+    MemberFunctionIntegrator<FormFactorCone>::mem_function p_mf = &FormFactorCone::ConeIntegralImaginary;
+    MemberFunctionIntegrator<FormFactorCone> integrator(p_mf,this);
+    complex_t ImaginaryRadial = integrator.integrate(0, H, (void *)0);
+    return ImaginaryRadial;
+ }
+ double FormFactorCone::ConeIntegralImaginary(double Z, void* params) const
+ {
+    (void)params;
+    complex_t qz = m_q.z();
+    complex_t qx = m_q.x();
+    complex_t qy = m_q.y();
+
+    double R = m_radius;
+    double tan_alpha = std::tan(m_alpha);
+    double Rz  = R-(Z/tan_alpha);
+    double qrRz = std::abs(std::sqrt((qx)*(qx) + (qy)*(qy))*Rz);
+    double J1_qrRz_div_qrRz = std::abs(qrRz) > Numeric::double_epsilon ? MathFunctions::Bessel_J1(std::abs(qrRz))/qrRz : 0.5;
+    double exp_imag = std::exp(complex_t(0.0, 1.0)*qz*Z).imag();
+    return 2.0 * M_PI *Rz*Rz * J1_qrRz_div_qrRz * exp_imag;
+    }
+
+
+ //***************************Sum of Two Integrals*****************************//
+ complex_t FormFactorCone::evaluate_for_q(const cvector_t &q) const
+
+ {
+     m_q = q;
+     return complex_t(0.0, 1.0)*evaluate_for_q_imag() + evaluate_for_q_real();
+ }
+
+
+
+    void FormFactorCone::print(std::ostream &ostr) const
+    {
+        ISample::print(ostr);
+        //     ostr << " (height:"<< m_height << " radius:"<<m_radius << " " << "alpha: " << m_alpha << ")";
+    }
diff --git a/Core/FormFactors/src/FormFactorCylinder.cpp b/Core/FormFactors/src/FormFactorCylinder.cpp
index 69ddd7094bb..aa7548fed49 100644
--- a/Core/FormFactors/src/FormFactorCylinder.cpp
+++ b/Core/FormFactors/src/FormFactorCylinder.cpp
@@ -1,6 +1,5 @@
 #include "FormFactorCylinder.h"
 #include "StochasticDiracDelta.h"
-
 #include "MathFunctions.h"
 #include "Numeric.h"
 
@@ -10,20 +9,10 @@ FormFactorCylinder::FormFactorCylinder(double height, double radius)
     m_height = height;
     m_radius = radius;
     init_parameters();
-    //    mp_height = new StochasticDiracDelta<double>(height);
-    //    mp_radius = new StochasticDiracDelta<double>(radius);
 }
 
-//FormFactorCylinder::FormFactorCylinder(StochasticParameter<double> *p_height, StochasticParameter<double> *p_radius)
-//    : mp_height(p_height)
-//    , mp_radius(p_radius)
-//{
-//}
-
 FormFactorCylinder::~FormFactorCylinder()
 {
-//    delete mp_height;
-//    delete mp_radius;
 }
 
 
@@ -41,13 +30,10 @@ void FormFactorCylinder::init_parameters()
 FormFactorCylinder* FormFactorCylinder::clone() const
 {
     return new FormFactorCylinder(m_height, m_radius);
-//    return new FormFactorCylinder(mp_height->clone(), mp_radius->clone());
 }
 
 complex_t FormFactorCylinder::evaluate_for_q(const cvector_t &q) const
 {
-//    double R = mp_radius->getCurrent();
-//    double H = mp_height->getCurrent();
     double R = m_radius;
     double H = m_height;
 
@@ -66,5 +52,4 @@ complex_t FormFactorCylinder::evaluate_for_q(const cvector_t &q) const
 void FormFactorCylinder::print(std::ostream &ostr) const
 {
     ISample::print(ostr);
-//    ostr << " (height:"<<m_height << " radius:"<<m_radius << ")";
 }
diff --git a/Core/FormFactors/src/FormFactorEllipsoid.cpp b/Core/FormFactors/src/FormFactorEllipsoid.cpp
new file mode 100644
index 00000000000..80b5ce08477
--- /dev/null
+++ b/Core/FormFactors/src/FormFactorEllipsoid.cpp
@@ -0,0 +1,52 @@
+#include "FormFactorEllipsoid.h"
+#include "MathFunctions.h"
+
+FormFactorEllipsoid::FormFactorEllipsoid(double radius, double width , double height , double alpha)
+{
+    setName("FormFactorPyramid");
+    m_height = height;
+    m_radius = radius;
+    m_width  = width;
+    m_alpha = alpha;
+    init_parameters();
+}
+
+FormFactorEllipsoid::~FormFactorEllipsoid()
+{
+}
+
+FormFactorEllipsoid* FormFactorEllipsoid::clone() const
+{
+    return new FormFactorEllipsoid(m_radius, m_width, m_height, m_alpha );
+}
+
+complex_t FormFactorEllipsoid::evaluate_for_q(const cvector_t& q) const
+{
+    complex_t qxR = q.x()*m_radius;
+    complex_t qyW = q.y()*m_width;
+    complex_t qzHdiv2 = q.z()*m_height/2.0;
+
+    complex_t phase_factor = std::exp(complex_t(0.0, 1.0)*qzHdiv2);
+
+    complex_t gamma  = std::sqrt((qxR)*(qxR) + (qyW)*(qyW));
+    complex_t J1_gamma_div_gamma = std::abs(gamma) > Numeric::double_epsilon ? MathFunctions::Bessel_J1(std::abs(gamma))/gamma: 0.5;
+
+    return M_PI * getVolume() * phase_factor * J1_gamma_div_gamma *MathFunctions::Sinc(qzHdiv2);
+}
+
+
+  void FormFactorEllipsoid::init_parameters()
+   {
+       getParameterPool()->clear();
+       getParameterPool()->registerParameter("radius", &m_radius);
+       getParameterPool()->registerParameter("width",  &m_width);
+       getParameterPool()->registerParameter("height", &m_height);
+       getParameterPool()->registerParameter("alpha" , &m_alpha);
+   }
+
+   void FormFactorEllipsoid::print(std::ostream& ostr) const
+   {
+       ISample::print(ostr);
+   }
+
+
diff --git a/Core/FormFactors/src/FormFactorFullSphere.cpp b/Core/FormFactors/src/FormFactorFullSphere.cpp
index 150168d558d..2ccf8e5735b 100644
--- a/Core/FormFactors/src/FormFactorFullSphere.cpp
+++ b/Core/FormFactors/src/FormFactorFullSphere.cpp
@@ -10,17 +10,10 @@ FormFactorFullSphere::FormFactorFullSphere(double radius)
     setName("FormFactorFullSphere");
     m_radius = radius;
     init_parameters();
-//    mp_radius = new StochasticDiracDelta<double>(radius);
 }
 
-//FormFactorFullSphere::FormFactorFullSphere(StochasticParameter<double> *p_radius)
-//    : mp_radius(p_radius)
-//{
-//}
-
 FormFactorFullSphere::~FormFactorFullSphere()
 {
-//    delete mp_radius;
 }
 
 /* ************************************************************************* */
@@ -36,12 +29,10 @@ void FormFactorFullSphere::init_parameters()
 FormFactorFullSphere* FormFactorFullSphere::clone() const
 {
     return new FormFactorFullSphere(m_radius);
-//    return new FormFactorFullSphere(mp_radius->clone());
 }
 
 complex_t FormFactorFullSphere::evaluate_for_q(const cvector_t &q) const
 {
-//    double R = mp_radius->getCurrent();
     complex_t qz = q.z();
     double R = m_radius;
 
diff --git a/Core/FormFactors/src/FormFactorFullSpheroid.cpp b/Core/FormFactors/src/FormFactorFullSpheroid.cpp
new file mode 100644
index 00000000000..531e84193d1
--- /dev/null
+++ b/Core/FormFactors/src/FormFactorFullSpheroid.cpp
@@ -0,0 +1,79 @@
+#include "FormFactorFullSpheroid.h"
+#include "StochasticDiracDelta.h"
+#include "MathFunctions.h"
+#include "Numeric.h"
+#include "MemberFunctionIntegrator.h"
+
+FormFactorFullSpheroid::FormFactorFullSpheroid(double radius, double height )
+{
+    setName("FormFactorFullSpheroid");
+    m_radius = radius;
+    m_height = height;
+    init_parameters();
+ }
+
+FormFactorFullSpheroid::~FormFactorFullSpheroid()
+{
+}
+
+/* ************************************************************************* */
+// initialize pool parameters, i.e. register some of class members for later access via parameter pool
+/* ************************************************************************* */
+void FormFactorFullSpheroid::init_parameters()
+{
+    getParameterPool()->clear();
+    getParameterPool()->registerParameter("radius", &m_radius);
+    getParameterPool()->registerParameter("height", &m_height);
+
+}
+
+FormFactorFullSpheroid* FormFactorFullSpheroid::clone() const
+{
+   FormFactorFullSpheroid* ffFullSpheroid = new FormFactorFullSpheroid(m_radius, m_height);
+   return ffFullSpheroid;
+}
+complex_t FormFactorFullSpheroid::evaluate_for_q(const cvector_t &q) const
+
+{
+    double H = m_height;
+    double R = m_radius;
+    m_q = q;
+
+    complex_t qz = m_q.z();
+    complex_t qzH_half   = qz*H/2.0;
+    complex_t iqzH_half  = complex_t(0.0, 1.0)*qzH_half;
+    complex_t a_part     =  std::exp(iqzH_half);                          //a_part
+
+
+    MemberFunctionIntegrator<FormFactorFullSpheroid>::mem_function p_mf = &FormFactorFullSpheroid::FullSpheroidIntegral;
+    MemberFunctionIntegrator<FormFactorFullSpheroid> integrator(p_mf,this);
+    double radial = integrator.integrate(0.0, H/2.0, (void *)0);
+    return  a_part * radial;
+ }
+
+
+
+double FormFactorFullSpheroid::FullSpheroidIntegral(double Z, void* params) const
+{
+    (void)params;
+
+         double R = m_radius;
+         double H = m_height;
+         complex_t qz = m_q.z();
+         complex_t qx = m_q.x();
+         complex_t qy = m_q.y();
+
+         double Rz  = std::abs(R* std::sqrt(1-((4*Z*Z)/(H*H))));
+         double qrRz = std::abs(std::sqrt((qx)*(qx) + (qy)*(qy))*Rz);
+
+         double J1_qrRz_div_qrRz = std::abs(qrRz) > Numeric::double_epsilon ? MathFunctions::Bessel_J1(std::abs(qrRz))/qrRz : 0.5;
+         return   4.0* M_PI *Rz*Rz* J1_qrRz_div_qrRz * std::cos(qz.real()*Z);
+
+   }
+/* ************************************************************************* */
+// print class
+/* ************************************************************************* */
+void FormFactorFullSpheroid::print(std::ostream &ostr) const
+{
+    ISample::print(ostr);
+}
diff --git a/Core/FormFactors/src/FormFactorHemiSpheroid.cpp b/Core/FormFactors/src/FormFactorHemiSpheroid.cpp
new file mode 100644
index 00000000000..e4db682235f
--- /dev/null
+++ b/Core/FormFactors/src/FormFactorHemiSpheroid.cpp
@@ -0,0 +1,119 @@
+#include "FormFactorHemiSpheroid.h"
+#include "StochasticDiracDelta.h"
+#include "MathFunctions.h"
+#include "Numeric.h"
+#include "Units.h"
+#include "Exceptions.h"
+#include <iostream>
+#include "MemberFunctionIntegrator.h"
+
+FormFactorHemiSpheroid::FormFactorHemiSpheroid(double radius, double width, double height)
+{
+    setName("FormFactorHemiSpheroid");
+    m_radius = radius;
+    m_width  = width;
+    m_height = height;
+    init_parameters();
+}
+
+
+FormFactorHemiSpheroid::~FormFactorHemiSpheroid()
+{
+}
+
+/* ************************************************************************* */
+// initialize pool parameters, i.e. register some of class members for later access via parameter pool
+/* ************************************************************************* */
+void FormFactorHemiSpheroid::init_parameters()
+{
+    getParameterPool()->clear();
+    getParameterPool()->registerParameter("radius", &m_radius);
+    getParameterPool()->registerParameter("width",  &m_width);
+    getParameterPool()->registerParameter("height", &m_height);
+}
+
+FormFactorHemiSpheroid* FormFactorHemiSpheroid::clone() const
+{
+   FormFactorHemiSpheroid* ffSpheroid = new FormFactorHemiSpheroid(m_radius,  m_width, m_height);
+   return ffSpheroid;
+}
+
+
+//********************Real Part of the Integral*********************************/
+double FormFactorHemiSpheroid::evaluate_for_q_real() const
+
+{
+    double H = m_height;
+    MemberFunctionIntegrator<FormFactorHemiSpheroid>::mem_function p_mf = &FormFactorHemiSpheroid::HemiSpheroidIntegralReal;
+    MemberFunctionIntegrator<FormFactorHemiSpheroid> integrator(p_mf,this);
+    double RealRadial = integrator.integrate(0, H, (void *)0);
+    return RealRadial;
+ }
+
+ double FormFactorHemiSpheroid::HemiSpheroidIntegralReal(double Z, void* params) const
+ {
+
+    (void)params;
+     double R = m_radius;
+     double W = m_height;
+     double H = m_height;
+
+
+     complex_t qz = m_q.z();
+     complex_t qx = m_q.x();
+     complex_t qy = m_q.y();
+
+     double Wz    =  W * std::sqrt(1-((Z*Z)/(H*H)));
+     double Rz    =  R * std::sqrt(1-((Z*Z)/(H*H)));
+     double gamma = (std::sqrt ((( qx*Rz)*(qx*Rz)) + ((qy*Wz)*(qy*Wz)))).real();
+     double J1_gamma_div_gamma = std::abs(gamma) > Numeric::double_epsilon ? MathFunctions::Bessel_J1(std::abs(gamma))/gamma: 0.5;
+     double exp_real = std::exp(complex_t(0.0, 1.0)*qz*Z).real();
+     return  Rz *Wz * J1_gamma_div_gamma * exp_real;
+
+ }
+
+
+ //*********************************Imaginary Part***************************//
+ complex_t FormFactorHemiSpheroid::evaluate_for_q_imag() const
+{
+    double H = m_height;
+    MemberFunctionIntegrator<FormFactorHemiSpheroid>::mem_function p_mf = &FormFactorHemiSpheroid::HemiSpheroidIntegralImaginary;
+    MemberFunctionIntegrator<FormFactorHemiSpheroid> integrator(p_mf,this);
+    double ImaginaryRadial = integrator.integrate(0, H, (void *)0);
+    return ImaginaryRadial;
+ }
+ double FormFactorHemiSpheroid::HemiSpheroidIntegralImaginary(double Z, void* params) const
+ {
+     (void)params;
+      double R = m_radius;
+      double W = m_height;
+      double H = m_height;
+
+
+       complex_t qx = m_q.x();
+       complex_t qy = m_q.y();
+       complex_t qz = m_q.z();
+
+      double Wz    =  W * std::sqrt(1-((Z*Z)/(H*H)));
+      double Rz    =  R * std::sqrt(1-((Z*Z)/(H*H)));
+      double gamma = (std::sqrt ((( qx*Rz)*(qx*Rz)) + ((qy*Wz)*(qy*Wz)))).real();
+      double J1_gamma_div_gamma = std::abs(gamma) > Numeric::double_epsilon ? MathFunctions::Bessel_J1(std::abs(gamma))/gamma: 0.5;
+      double exp_imag = std::exp(complex_t(0.0,-1.0)*qz*Z).imag();
+      return  Rz *Wz * J1_gamma_div_gamma * exp_imag;
+    }
+
+
+ //***************************Sum of Two Integrals*****************************//
+ complex_t FormFactorHemiSpheroid::evaluate_for_q(const cvector_t &q) const
+
+ {
+     m_q = q;
+     return 2.0* M_PI* complex_t(0.0, 1.0)*evaluate_for_q_imag() + evaluate_for_q_real();
+ }
+
+
+
+    void FormFactorHemiSpheroid::print(std::ostream &ostr) const
+    {
+        ISample::print(ostr);
+            }
diff --git a/Core/FormFactors/src/FormFactorSphere.cpp b/Core/FormFactors/src/FormFactorSphere.cpp
new file mode 100644
index 00000000000..72d9d25ab9c
--- /dev/null
+++ b/Core/FormFactors/src/FormFactorSphere.cpp
@@ -0,0 +1,112 @@
+#include "FormFactorSphere.h"
+#include "StochasticDiracDelta.h"
+#include "Numeric.h"
+#include "MathFunctions.h"
+#include <cmath>
+#include "MemberFunctionIntegrator.h"
+
+FormFactorSphere::FormFactorSphere(double radius, double height)
+{
+    setName("FormFactorSphere");
+    m_radius = radius;
+    m_height = height,
+    init_parameters();
+}
+
+
+FormFactorSphere::~FormFactorSphere()
+{
+}
+
+/* ************************************************************************* */
+// initialize pool parameters, i.e. register some of class members for later access via parameter pool
+/* ************************************************************************* */
+void FormFactorSphere::init_parameters()
+{
+    getParameterPool()->clear();
+    getParameterPool()->registerParameter("radius", &m_radius);
+    getParameterPool()->registerParameter("height", &m_height);
+
+}
+
+FormFactorSphere* FormFactorSphere::clone() const
+{
+   FormFactorSphere* ffSphere = new FormFactorSphere(m_radius, m_height);
+   return ffSphere;
+}
+
+
+//********************Real Part of the Integral*********************************//
+double FormFactorSphere::evaluate_for_q_real() const
+
+{
+    double H = m_height;
+    MemberFunctionIntegrator<FormFactorSphere>::mem_function p_mf = &FormFactorSphere::SphereIntegralReal;
+    MemberFunctionIntegrator<FormFactorSphere> integrator(p_mf,this);
+    double RealRadial = integrator.integrate(0, H, (void *)0);
+    return RealRadial;
+ }
+
+
+ double FormFactorSphere::SphereIntegralReal(double Z, void* params) const
+ {
+     (void)params;
+      double R = m_radius;
+      complex_t qz = m_q.z();
+      complex_t qx = m_q.x();
+      complex_t qy = m_q.y();
+
+     double  Rz  = std::abs(std::sqrt((R*R)-(Z*Z)));
+     double qrRz = std::abs(std::sqrt((qx)*(qx) + (qy)*(qy))*Rz);
+     double  J1_qrRz_div_qrRz = std::abs(qrRz) > Numeric::double_epsilon ? MathFunctions::Bessel_J1(std::abs(qrRz))/qrRz : 0.5;
+     double exp_real = std::exp(complex_t(0.0, 1.0)*qz*Z).real();
+     return  2.0*M_PI*Rz*Rz*J1_qrRz_div_qrRz * exp_real;
+ }
+
+
+ //*********************************Imaginary Part***************************//
+ complex_t FormFactorSphere::evaluate_for_q_imag() const
+{
+    double H = m_height;
+    MemberFunctionIntegrator<FormFactorSphere>::mem_function p_mf = &FormFactorSphere::SphereIntegralImaginary;
+    MemberFunctionIntegrator<FormFactorSphere> integrator(p_mf,this);
+    complex_t ImaginaryRadial = integrator.integrate(0, H, (void *)0);
+    return ImaginaryRadial;
+ }
+ double FormFactorSphere::SphereIntegralImaginary(double Z, void* params) const
+ {
+     (void)params;
+      double R = m_radius;
+      complex_t qz = m_q.z();
+      complex_t qx = m_q.x();
+      complex_t qy = m_q.y();
+
+      double  Rz  = std::abs(std::sqrt((R*R)-(Z*Z)));
+     double qrRz = std::abs(std::sqrt((qx)*(qx) + (qy)*(qy))*Rz);
+     double  J1_qrRz_div_qrRz = std::abs(qrRz) > Numeric::double_epsilon ? MathFunctions::Bessel_J1(std::abs(qrRz))/qrRz : 0.5;
+     double exp_imag = std::exp(complex_t(0.0, 1.0)*qz*Z).imag();
+     return  2.0*M_PI*Rz*Rz*J1_qrRz_div_qrRz * exp_imag;
+    }
+
+
+ //***************************Sum of Two Integrals*****************************//
+ complex_t FormFactorSphere::evaluate_for_q(const cvector_t &q) const
+
+ {
+     m_q = q;
+     double H = m_height;
+     double R = m_radius;
+     complex_t qz = m_q.z();
+     double iqzHR = std::exp(complex_t(0.0, 1.0)*qz*(H-R)).real();
+
+     return complex_t(0.0, 1.0)*evaluate_for_q_imag() + evaluate_for_q_real() * iqzHR;    //* a_part;
+ }
+
+
+
+    void FormFactorSphere::print(std::ostream &ostr) const
+    {
+        ISample::print(ostr);
+        //     ostr << " (height:"<< m_height << " radius:"<<m_radius << " " << "alpha: " << m_alpha << ")";
+    }
+
diff --git a/shared.pri b/shared.pri
index 3b00e638fe7..3e117e18ca2 100644
--- a/shared.pri
+++ b/shared.pri
@@ -105,7 +105,7 @@ CONFIG(JCNS) {
 QMAKE_CXXFLAGS_DEBUG += -fdiagnostics-show-option # to find out in gcc which option control warning
 #QMAKE_CXXFLAGS_RELEASE += -O3 -ffast-math -msse3
 QMAKE_CXXFLAGS_RELEASE -= -O2
-QMAKE_CXXFLAGS_RELEASE += -g -O3 -ffast-math
+QMAKE_CXXFLAGS_RELEASE += -g -O0 -ffast-math
 # uncommenting line below produces non-stripped (very large) libraries
 #QMAKE_STRIP=:
 
-- 
GitLab