Date: Thu, 28 Mar 2019 17:41:19 +0100
Subject: [PATCH 043/250] Update README.md
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 578c0f59493..5ed2a882ed8 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[![Build Status][travis-badge]][https://travis-ci.org/GooFit/AmpGen]
+[![Build Status][travis-badge]][travis-link]
[![License: LGPL v3][license-badge]](./LICENSE)
@@ -316,4 +316,5 @@ The development of this software has been supported by the National Science Fou
[travis-badge]: https://travis-ci.org/GooFit/AmpGen.svg?branch=master
[license-badge]: https://img.shields.io/badge/License-GPL%20v2-blue.svg
+[travis-link]: https://travis-ci.org/GooFit/AmpGen
From 498c2c5e22220b914c2810be6f9b8e3aa3e246c9 Mon Sep 17 00:00:00 2001
From: tevans1260
Date: Thu, 28 Mar 2019 18:19:57 +0100
Subject: [PATCH 044/250] Fix UseCUDA flag in src/CompiledExpressionBase
---
src/CompiledExpressionBase.cpp | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/CompiledExpressionBase.cpp b/src/CompiledExpressionBase.cpp
index c4e70d99b86..fb0e8e7e7b2 100644
--- a/src/CompiledExpressionBase.cpp
+++ b/src/CompiledExpressionBase.cpp
@@ -80,31 +80,25 @@ void CompiledExpressionBase::to_stream( std::ostream& stream ) const
{
if( m_db.size() !=0 ) stream << "#include\n";
stream << "extern \"C\" const char* " << progName() << "_name() { return \"" << m_name << "\"; } \n";
- bool enable_cuda = NamedParameter("EnableCUDA",false);
+ bool enable_cuda = NamedParameter("UseCUDA",false);
- size_t sizeOfStream = 0;
+ INFO("Enabling CUDA ...");
+
+ size_t sizeOfStream = 0;
if( !enable_cuda ){
// Avoid a warning about std::complex not being C compatible (it is)
stream << "#pragma clang diagnostic push\n"
<< "#pragma clang diagnostic ignored \"-Wreturn-type-c-linkage\"\n";
-
stream << "extern \"C\" " << returnTypename() << " " << progName() << "(" << fcnSignature() << "){\n";
addDependentExpressions( stream , sizeOfStream );
- std::string objString = m_obj.to_string(m_resolver);
- stream << "return " << objString << ";\n}\n";
+ stream << "return " << m_obj.to_string(m_resolver) << ";\n}\n";
}
else {
- std::string rt_cpp = returnTypename();
- std::string rt_cuda = "";
- if( rt_cpp == "double" || rt_cpp == "float" || rt_cpp == "real_t" )
- rt_cuda = "float* r, const int N";
- if( rt_cpp == "std::complex" || rt_cpp == "std::complex" || rt_cpp == "complex_t" )
- rt_cuda = "ampgen_cuda::complex_t* r, const int N";
+ std::string rt_cuda = returnTypename() +"* r, const int N" ;
stream << "__global__ void " << progName() << "( " << rt_cuda << ", const float_t* x0, const float3* x1){\n";
stream << " int i = blockIdx.x * blockDim.x + threadIdx.x;\n";
addDependentExpressions( stream, sizeOfStream);
- std::string objString = m_obj.to_string(m_resolver);
- stream << " r[i] = " << objString << ";\n}\n";
+ stream << " r[i] = " << m_obj.to_string(m_resolver) << ";\n}\n";
}
if( NamedParameter("IncludePythonBindings", false) == true ){
From 85d9517f5c2d166566ed24db3488f78fe21a334b Mon Sep 17 00:00:00 2001
From: tevans1260
Date: Thu, 28 Mar 2019 21:28:01 +0100
Subject: [PATCH 045/250] Remove unnecessary statics in utilities
---
AmpGen/Utilities.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/AmpGen/Utilities.h b/AmpGen/Utilities.h
index 90d8f335854..61355707978 100644
--- a/AmpGen/Utilities.h
+++ b/AmpGen/Utilities.h
@@ -18,7 +18,7 @@
#include "AmpGen/MetaUtils.h"
namespace AmpGen {
template
- static bool isIn( const std::vector& container, const T& obj )
+ bool isIn( const std::vector& container, const T& obj )
{
for ( auto& it : container )
if ( obj == it ) return true;
@@ -26,7 +26,7 @@ namespace AmpGen {
}
template
- static bool isIn( const std::vector& container, const B& obj, F f )
+ bool isIn( const std::vector& container, const B& obj, F f )
{
for ( auto& it : container )
if ( f( it, obj ) ) return true;
From 3cefae9af192aad69cd6161c3e2af32efe25679c Mon Sep 17 00:00:00 2001
From: tevans1260
Date: Thu, 28 Mar 2019 21:39:38 +0100
Subject: [PATCH 046/250] Update .travis.yml
---
.travis.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index fdc65dec8c2..02705555df0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,3 @@
-This will run on Travis' 'new' container-based infrastructure
sudo: false
dist: xenial
From 4fc8ffa2a2238ca23bb22a05fe5fb7a2e53feb65 Mon Sep 17 00:00:00 2001
From: tevans1260
Date: Fri, 29 Mar 2019 13:40:54 +0100
Subject: [PATCH 047/250] Add LASS documentation
---
AmpGen/Lineshapes.h | 24 ++++++++++++++++++++++--
doc/doxyfile | 2 +-
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/AmpGen/Lineshapes.h b/AmpGen/Lineshapes.h
index 65db6cee353..3788c8fc5cb 100644
--- a/AmpGen/Lineshapes.h
+++ b/AmpGen/Lineshapes.h
@@ -183,8 +183,28 @@ namespace AmpGen
/** @ingroup Lineshapes class LASS
@brief Description of the @f$ K\pi @f$ S-wave, based on the fits to scattering data.
The LASS parameterisation of the @$$ K\pi@$f S-wave is derived from fits to ~ elastic @f$ K \pi @f$ scattering data, which is approximately up to the $f@ K \eta^\prime $f@ threshold.
- In this regime, unitarity implies that phases, rather than amplitudes should be summed. In this context, a slow varying nonresonant phases is summed with the phase of a Breit-Wigner,
- corresponding to the @f$ K_0*(1430) @f$.
+ In this regime, unitarity implies that phases, rather than amplitudes should be summed.
+ In this context, a slow varying nonresonant phase,
+ @f[
+ \tan(\phi_{NR}) = \frac{2 a q}{2 + arq^2},
+ @f]
+ where @f$a, r@f$ are parameters determined from scattering data, is added to the phase shift of a Breit-Wigner,
+ @f[
+ \tan(\phi_{BW}) = \frac{m\Gamma(s)}{m^2 -s },
+ @f]
+ normally associated to the @f$ K^*(1430)^{0} @f$ resonance.
+ The total amplitude is therefore:
+ @f[
+ \mathcal{A}(s) = \frac{2 a \sqrt{s} }{ 2 + arq^2 - 2iaq} + \frac{2+arq^2 + 2iaq}{2+arq^2 - 2iaq }\mathcal{A}_{BW}(s).
+ @f]
+ As this expression somewhat resembles the sum of a Breit-Wigner with a slowly varying nonresonant component, the two parts are sometimes split apart with an additional production amplitude placed on one or the other. These can be accessed separately using the modifiers LASS.BW and LASS.NR.
+
+ Parameter | User name | Description
+ -----------------------|--------------------------------------|------------------------------------------------------------------------
+ @f$m@f$ | particleName_mass | Breit-Wigner mass of the resonant component, defined as energy at which the self-energy of the resonance is purely imaginary (defaults to value in PDG)
+ @f$\Gamma_0@f$ | particleName_width | Breit-Wigner width of the resonant component, defined as the width of resonance at the Breit-Wigner mass
+ @f$a@f$ | LASS::a | Scattering length of the nonresonant component, defaults to @f$2.07\mathrm{G\kern -0.1em eV}^{-1}@f$
+ @f$a@f$ | LASS::r | Scattering length of the nonresonant component, defaults to @f$3.32\mathrm{G\kern -0.1em eV}^{-1}@f$
*/
DECLARE_LINESHAPE( LASS );
diff --git a/doc/doxyfile b/doc/doxyfile
index 95330c67c71..3d918f6044f 100644
--- a/doc/doxyfile
+++ b/doc/doxyfile
@@ -82,7 +82,7 @@ OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
EXTENSION_MAPPING =
-MARKDOWN_SUPPORT = NO
+MARKDOWN_SUPPORT = YES
AUTOLINK_SUPPORT = YES
BUILTIN_STL_SUPPORT = YES
CPP_CLI_SUPPORT = NO
From 44a6053e4b49678d02f6f91e6a1753908875bb31 Mon Sep 17 00:00:00 2001
From: tevans1260
Date: Mon, 1 Apr 2019 18:21:46 +0200
Subject: [PATCH 048/250] Add code to perform pade approximations, minor
improvements in some interfaces
---
AmpGen/ArgumentPack.h | 5 +-
AmpGen/Array.h | 7 +-
AmpGen/CoupledChannel.h | 6 ++
AmpGen/Expression.h | 2 -
AmpGen/FitResult.h | 1 +
AmpGen/Lineshapes.h | 70 +++++++------------
AmpGen/MetaUtils.h | 5 +-
AmpGen/MinuitParameterSet.h | 54 ++++++--------
AmpGen/Pade.h | 60 ++++++++++++++++
AmpGen/ThreeBodyCalculators.h | 1 -
AmpGen/Vertex.h | 63 ++++++++++++-----
AmpGen/kMatrix.h | 19 +++++
apps/Fitter.cpp | 7 +-
src/ASTResolver.cpp | 5 +-
src/CoherentSum.cpp | 13 ++--
src/CompiledExpressionBase.cpp | 12 +---
src/DalitzIntegrator.cpp | 3 +-
src/ErrorPropagator.cpp | 5 +-
src/Expression.cpp | 10 +--
src/FitResult.cpp | 24 +++----
src/Lineshapes.cpp | 12 ++--
src/Lineshapes/Flatte.cpp | 4 +-
src/Minimiser.cpp | 18 ++---
src/MinuitParameterSet.cpp | 124 ++++++++++++++++++---------------
src/Pade.cpp | 0
src/PhaseSpace.cpp | 11 ++-
src/PolarisedSum.cpp | 3 -
src/ThreeBodyCalculators.cpp | 11 +--
src/Vertex.cpp | 19 +++--
29 files changed, 322 insertions(+), 252 deletions(-)
create mode 100644 AmpGen/Pade.h
create mode 100644 src/Pade.cpp
diff --git a/AmpGen/ArgumentPack.h b/AmpGen/ArgumentPack.h
index 90b66758d0f..8ac69eb9dec 100644
--- a/AmpGen/ArgumentPack.h
+++ b/AmpGen/ArgumentPack.h
@@ -14,8 +14,9 @@ namespace AmpGen
virtual ~IArgument() = default;
};
/** @class Argument
+ @brief Structure to pass "named" parameters to functions.
Structure to flexibly pass blocks of "Named" parameters to functions, to
- approximate the behaviour of python's named arguments.
+ approximate the behaviour of Python's named arguments.
Typical usage is for constructors with variable arguments, such as
to read data from the disk. The interface for the user is typically
\code{cpp}
@@ -36,7 +37,7 @@ namespace AmpGen
auto applySym = args.getArg().val;
auto entryList = args.getArg().val;
\endcode
- @tparam: TYPE type of the argument, such as a string, a number, a bool etc.
+ @tparam TYPE Type of the argument, such as a string, a number, a bool etc.
*/
template struct Argument : public IArgument
{
diff --git a/AmpGen/Array.h b/AmpGen/Array.h
index 92aeae0310e..3074ea524cf 100644
--- a/AmpGen/Array.h
+++ b/AmpGen/Array.h
@@ -15,7 +15,12 @@
namespace AmpGen
{
class ASTResolver;
-
+
+ /** @ingroup ExpressionEngine class Array
+ @brief Expression for a fixed size array of values.
+ Expression for an array, i.e. a set of values with an index.
+ Can be used to return an expression from the array, which is resolved at (second) compile time.
+ */
class Array : public IExpression
{
public:
diff --git a/AmpGen/CoupledChannel.h b/AmpGen/CoupledChannel.h
index e72e1e8a68d..f9837963538 100644
--- a/AmpGen/CoupledChannel.h
+++ b/AmpGen/CoupledChannel.h
@@ -2,5 +2,11 @@
#include "AmpGen/Particle.h"
namespace AmpGen {
+
+ namespace Lineshape {
+ /** @ingroup Lineshapes class CoupledChannel
+ @brief Description of a resonance that decays to multiple two and three-body final states. */
+ DECLARE_LINESHAPE( CoupledChannel );
+ }
Expression phaseSpace(const Expression& s, const Particle& p, const size_t& l);
}
diff --git a/AmpGen/Expression.h b/AmpGen/Expression.h
index 9198ff061b8..4171a18111d 100644
--- a/AmpGen/Expression.h
+++ b/AmpGen/Expression.h
@@ -348,7 +348,6 @@ namespace AmpGen
/// @ingroup ExpressionEngine struct ACos
/// @brief Unary expression that returns \f$\cos^{-1}(z)\f$
DECLARE_UNARY_OPERATOR( ACos );
-
/// @ingroup ExpressionEngine struct ATan
/// @brief Unary expression that returns \f$\tan^{-1}(z)\f$
DECLARE_UNARY_OPERATOR( ATan );
@@ -412,7 +411,6 @@ namespace AmpGen
Expression exp( const Expression& expression );
Expression log( const Expression& expression );
Expression atan2( const Expression& y, const Expression& x);
-
}
template < class T > bool is( const Expression& expression ){
diff --git a/AmpGen/FitResult.h b/AmpGen/FitResult.h
index a518679836c..3098a44d8c8 100644
--- a/AmpGen/FitResult.h
+++ b/AmpGen/FitResult.h
@@ -64,6 +64,7 @@ namespace AmpGen
MinuitParameterSet* MPS() const { return &( *m_mps ); }
TMatrixD cov() const { return m_covarianceMatrix; }
double cov( const size_t& x, const size_t& y ) const { return m_covarianceMatrix( x, y ); }
+ double cov( const std::string& x, const std::string& y ) const { return m_covarianceMatrix( m_covMapping.at(x), m_covMapping.at(y) ); }
void print() const;
diff --git a/AmpGen/Lineshapes.h b/AmpGen/Lineshapes.h
index 3788c8fc5cb..72c2119ef49 100644
--- a/AmpGen/Lineshapes.h
+++ b/AmpGen/Lineshapes.h
@@ -39,7 +39,7 @@
*/
#define DECLARE_LINESHAPE( X ) \
- class X : public AmpGen::ILineshape { \
+ class X : public AmpGen::Lineshape::Base { \
static std::string _id; \
public: \
X(){ DEBUG("Constructing lineshape") ;} \
@@ -54,7 +54,7 @@
}
#define DEFINE_LINESHAPE( X ) \
- REGISTER_WITH_KEY( ILineshape, Lineshape::X, #X, std::string ); \
+ REGISTER_WITH_KEY( Lineshape::Base, Lineshape::X, #X, std::string ); \
AmpGen::Expression Lineshape::X::get( const AmpGen::Expression& s, const std::vector& p, \
const std::string& particleName, \
const unsigned int& L, const std::string& lineshapeModifier, \
@@ -67,7 +67,7 @@
AmpGen::DebugSymbols* dbexpressions ) const
#define DEFINE_GENERIC_SHAPE( X ) \
- REGISTER_WITH_KEY( ILineshape, Lineshape::X, #X, std::string ); \
+ REGISTER_WITH_KEY( Lineshape::Base, Lineshape::X, #X, std::string ); \
AmpGen::Expression Lineshape::X::get( const AmpGen::Expression& s, const AmpGen::Expression& s1, \
const AmpGen::Expression& s2, const std::string& particleName, \
const unsigned int& L, const std::string& lineshapeModifier, \
@@ -79,26 +79,25 @@
namespace AmpGen
{
- class ILineshape {
- public:
- virtual ~ILineshape() = default;
- virtual Expression get( const Expression& s, const Expression& s1, const Expression& s2,
- const std::string& particleName, const unsigned int& L,
- const std::string& lineshapeModifier, DebugSymbols* dbexpressions = nullptr ) const = 0;
-
- virtual Expression get( const Expression& s, const std::vector& p, const std::string& particleName,
- const unsigned int& L, const std::string& lineshapeModifier,
- AmpGen::DebugSymbols* dbexpressions = nullptr ) const = 0;
- ILineshape* create() { return this; }
- };
-
/** @ingroup Lineshapes namespace Lineshape
Namespace that contains all lineshapes, i.e. propagators for describing amplitudes and phases for resonances (and nonresonant) contributions to a total amplitude.
*/
namespace Lineshape
{
- class Factory : public AmpGen::Factory
+ class Base {
+ public:
+ virtual ~Base() = default;
+ virtual Expression get( const Expression& s, const Expression& s1, const Expression& s2,
+ const std::string& particleName, const unsigned int& L,
+ const std::string& lineshapeModifier, DebugSymbols* dbexpressions = nullptr ) const = 0;
+ virtual Expression get( const Expression& s, const std::vector& p, const std::string& particleName,
+ const unsigned int& L, const std::string& lineshapeModifier,
+ AmpGen::DebugSymbols* dbexpressions = nullptr ) const = 0;
+ Base* create() { return this; }
+ };
+
+ class Factory : public AmpGen::Factory
{
public:
static Expression get(const std::string& lineshape, const Expression& s, const Expression& s1,
@@ -134,7 +133,7 @@ namespace AmpGen
@f$r@f$ | particleName_radius | Hadronic radius for Blatt-Weisskopf form-factor (defaults to 1.5GeV for light resonances, 3.5GeV for charm)
BL : Use Blatt-Weisskopf factors normalised at @f$ \sqrt{s}=m @f$ (by default, normalised at @f$\sqrt{s}=0@f$)
- \image html BW_combined.png "Modulus and phase of the Relativistic Breit-Wigner propagator, for @f$l={0,4}@f$, using the mass and nominal width of the @f$\rho@f$ meson"
+ \image html BW_combined.png "Modulus and phase of the Relativistic Breit-Wigner propagator, for orbital momentum up-to four, using the mass and nominal width of the rho meson."
*/
DECLARE_LINESHAPE( BW );
@@ -182,7 +181,7 @@ namespace AmpGen
/** @ingroup Lineshapes class LASS
@brief Description of the @f$ K\pi @f$ S-wave, based on the fits to scattering data.
- The LASS parameterisation of the @$$ K\pi@$f S-wave is derived from fits to ~ elastic @f$ K \pi @f$ scattering data, which is approximately up to the $f@ K \eta^\prime $f@ threshold.
+ The LASS parameterisation of the @f$ K\pi @f$ S-wave is derived from fits to ~ elastic @f$ K \pi @f$ scattering data, which is approximately up to the @f$ K \eta^\prime @f$ threshold.
In this regime, unitarity implies that phases, rather than amplitudes should be summed.
In this context, a slow varying nonresonant phase,
@f[
@@ -204,7 +203,7 @@ namespace AmpGen
@f$m@f$ | particleName_mass | Breit-Wigner mass of the resonant component, defined as energy at which the self-energy of the resonance is purely imaginary (defaults to value in PDG)
@f$\Gamma_0@f$ | particleName_width | Breit-Wigner width of the resonant component, defined as the width of resonance at the Breit-Wigner mass
@f$a@f$ | LASS::a | Scattering length of the nonresonant component, defaults to @f$2.07\mathrm{G\kern -0.1em eV}^{-1}@f$
- @f$a@f$ | LASS::r | Scattering length of the nonresonant component, defaults to @f$3.32\mathrm{G\kern -0.1em eV}^{-1}@f$
+ @f$r@f$ | LASS::r | Scattering length of the nonresonant component, defaults to @f$3.32\mathrm{G\kern -0.1em eV}^{-1}@f$
*/
DECLARE_LINESHAPE( LASS );
@@ -220,11 +219,11 @@ namespace AmpGen
@f]
where the running width is given by
@f[
- \Gamma(s) = g_{\pi\pi} \left( \Lambda^{1/2}(s,m_{\pi}^2,m_{\pi}^2) + \frac{g_{KK}}{g_{\pi\pi}} \Lambda^{1/2}(s,m_K^2, m_K^2) \right)
+ \Gamma(s) = \frac{ g_{\pi\pi} }{s} \left( \Lambda^{1/2}(s,m_{\pi}^2,m_{\pi}^2) + \frac{g_{KK}}{g_{\pi\pi}} \Lambda^{1/2}(s,m_K^2, m_K^2) \right)
@f]
or
@f[
- \Gamma(s) = g_{\pi\eta} \left( \Lambda^{1/2}(s,m_{\pi}^2,m_{\eta}^2) + \frac{g_{KK}}{g_{\pi\eta}} \Lambda^{1/2}(s,m_K^2, m_K^2) \right)
+ \Gamma(s) = \frac{ g_{\pi\eta}}{s} \left( \Lambda^{1/2}(s,m_{\pi}^2,m_{\eta}^2) + \frac{g_{KK}}{g_{\pi\eta}} \Lambda^{1/2}(s,m_K^2, m_K^2) \right)
@f]
for the @f$f_0(980)^{0}@f$ and the @f$a_0(980)^{0}@f$, respectively.
@@ -240,7 +239,7 @@ namespace AmpGen
/** @ingroup Lineshapes class Gaussian
@brief Gaussian shape for (relatively) long lived states that are limited by experimental resolution, rather than natural width.
- @detail The gaussian lineshape has the form
+ The gaussian lineshape has the form
@f[
\mathcal{A}(s) = e^{ -(s-\mu)^2 / 2\sigma^2 },
@f]
@@ -258,22 +257,6 @@ namespace AmpGen
* @brief Polynominal shape \f$ \mathcal{A}(s) = \sum^n_i c_i s^{i} \f$ where the sum is to lineshapeModifier::Degree, and the free parameters of the shape are lineshapeModifier_ci
*/
DECLARE_LINESHAPE( Poly );
-
- /** @ingroup Lineshapes class kMatrix
- @brief Anisovich-Sarantsev Isoscalar K-matrix from https://arxiv.org/abs/hep-ph/0204328
-
- Describes the isoscalar @f$ \pi\pi, KK, 4\pi \eta\eta, \eta\eta^\prime@f$ S-wave in terms of a five-by-five K-matrix and corresponding P-vector couplings.
- Includes a large number of parameters that can be fixed from the above publication.
- These parameters can be found in the options directory, which in turn can be includes in the fit by adding
-
- \code{cpp}
- Import $AMPGENROOT/options/kMatrix.opt
- \endcode
-
- to the user configuration file.
- */
- DECLARE_LINESHAPE( kMatrix );
-
/** @ingroup Lineshapes class FOCUS
* @brief K matrix amplitudes used for I=1/2 and I=3/2 in the description of the \f$ K\pi \f$ S-wave in the analysis of @f$ D^{+}\rightarrow K^{-}\pi^{+}\pi^{+}@f$ https://arxiv.org/abs/0705.2248
*/
@@ -283,11 +266,10 @@ namespace AmpGen
DECLARE_LINESHAPE( PALANO );
/** @ingroup Lineshapes class ObelixRho
- * @brief Amplitude to describe the vector-isovector system, otherwise known as the @f$ \rho @f$ mesons. WARNING untested.
+ @brief Amplitude to describe the vector-isovector system, otherwise known as the @f$ \rho @f$ mesons. WARNING untested.
Vector-Isovector amplitude @f$(I=1, J=1)@f$ using a K-matrix to describe the @f$\pi\pi, KK, \pi\pi\pi\pi @f$ channels using three poles, commonly associated with
- the @f$ \rho(770), \rho(1450), \rho(1900) @f$ resonances.
- */
+ the @f$ \rho(770), \rho(1450), \rho(1900) @f$ resonances.*/
DECLARE_LINESHAPE( ObelixRho );
/// K matrix to describe \f$K_1(1270) / K_1(1400)\f$. WARNING incompleted.
@@ -326,10 +308,6 @@ namespace AmpGen
DECLARE_LINESHAPE( DecaySpline );
DECLARE_LINESHAPE( InelasticSpline );
- /** @ingroup Lineshapes class CoupledChannel
- @brief Description of a resonance that decays to multiple two and three-body final states.
- */
- DECLARE_LINESHAPE( CoupledChannel );
/** @ingroup Lineshapes class GenericKmatrix
@brief Implementation of a generic K-matrix
*/
diff --git a/AmpGen/MetaUtils.h b/AmpGen/MetaUtils.h
index 4d436d436fb..31985fe437e 100644
--- a/AmpGen/MetaUtils.h
+++ b/AmpGen/MetaUtils.h
@@ -10,9 +10,10 @@
namespace AmpGen
{
/** Utility classes for (library) compile-level metaprogramming, such as identifying the types of
- * arguments for generating source code, compile-time unrolling of tuples and loops, and identifying if a class can be constructed in different ways.
+ arguments for generating source code, compile-time unrolling of tuples and loops,
+ and identifying if a class can be constructed in different ways.
*/
-
+
template std::string typeof()
{
int status = 0;
diff --git a/AmpGen/MinuitParameterSet.h b/AmpGen/MinuitParameterSet.h
index 272b556c7fc..b726b9334a3 100644
--- a/AmpGen/MinuitParameterSet.h
+++ b/AmpGen/MinuitParameterSet.h
@@ -17,6 +17,9 @@ namespace AmpGen
class MinuitParameterSet
{
public:
+ typedef std::vector::iterator iterator;
+ typedef std::vector::const_iterator const_iterator;
+
MinuitParameterSet();
MinuitParameterSet( const MinuitParameterSet& other );
~MinuitParameterSet();
@@ -24,28 +27,23 @@ namespace AmpGen
MinuitParameterSet getFloating();
bool add( MinuitParameter* parPtr );
- MinuitParameter* add( const std::string& name, const unsigned int& flag, const double& mean, const double& sigma,
- const double& min = 0, const double& max = 0 );
+ MinuitParameter* add(const std::string& name, const unsigned int& flag, const double& mean, const double& sigma, const double& min = 0, const double& max = 0 );
bool unregister( MinuitParameter* patPtr );
- MinuitParameter* addOrGet( const std::string& name, const unsigned int& flag, const double& mean,
- const double& sigma, const double& min = 0, const double& max = 0 );
+ MinuitParameter* addOrGet(const std::string& name, const unsigned int& flag, const double& mean,
+ const double& sigma, const double& min = 0, const double& max = 0 );
void loadFromStream();
void loadFromFile( const std::string& name );
void resetToInit();
unsigned int size() const;
- MinuitParameter* getParPtr( unsigned int i ) const;
-
- std::map& map() { return _keyAccess; }
- const std::map& const_map() const { return _keyAccess; }
- std::vector::const_iterator cbegin() const { return _parPtrList.cbegin(); }
- std::vector::const_iterator cend() const { return _parPtrList.cend(); }
-
- std::vector parPtrs() { return _parPtrList; }
- std::vector::iterator begin() { return _parPtrList.begin(); }
- std::vector::iterator end() { return _parPtrList.end(); }
- std::vector::const_iterator begin() const { return _parPtrList.cbegin(); }
- std::vector::const_iterator end() const { return _parPtrList.cend(); }
+ std::map& map();
+ const std::map& const_map() const;
+ const_iterator cbegin() const;
+ const_iterator cend() const;
+ iterator begin();
+ iterator end();
+ const_iterator begin() const;
+ const_iterator end() const;
void deleteListAndObjects();
void deleteListKeepObjects();
@@ -55,28 +53,20 @@ namespace AmpGen
void set( const MinuitParameterSet& mps );
MinuitParameter* at( const std::string& key );
+ MinuitParameter* at( const size_t& index ) const;
MinuitParameter* operator[]( const std::string& key );
MinuitParameter* operator[]( const std::string& key ) const;
- MinuitParameter* operator[]( const unsigned int& key );
- MinuitParameter* find( const std::string& key ) const
- {
- auto it = _keyAccess.find(key);
- return it == _keyAccess.end() ? nullptr : it->second;
- }
- double operator()( const std::string& name )
- {
- if ( _keyAccess.find( name ) == _keyAccess.end() ) {
- std::cout << "Cannot find parameter " << name << std::endl;
- }
- return _keyAccess[name]->mean();
- }
+ MinuitParameter* operator[]( const size_t& key );
+ MinuitParameter* find( const std::string& key ) const;
+ double operator()( const std::string& name );
private:
void tryParameter( const std::vector& line );
void tryAlias( const std::vector& line );
- std::vector _parPtrList;
- std::vector _aliasList;
- std::map _keyAccess;
bool addToEnd( MinuitParameter* parPtr );
+
+ std::vector m_parameters;
+ std::vector m_expressions;
+ std::map m_keyAccess;
};
diff --git a/AmpGen/Pade.h b/AmpGen/Pade.h
new file mode 100644
index 00000000000..4e13fa9ca37
--- /dev/null
+++ b/AmpGen/Pade.h
@@ -0,0 +1,60 @@
+#ifndef AMPGEN_PADE_H
+#define AMPGEN_PADE_H
+
+#include "TMatrixD.h"
+#include "TVectorD.h"
+#include
+#include
+
+namespace AmpGen {
+ enum Strategy { linear, quadratic, cubic, quartic };
+ template
+ class Pade {
+ private:
+ std::function m_function;
+ std::array co_f;
+ std::array co_g;
+ T min;
+ T max;
+ T range;
+ public:
+
+ Pade(const std::function& fcn,
+ const double& min,
+ const double& max,
+ const Strategy& strat = Strategy::linear) :
+ m_function(fcn), min(min),max(max){
+ TMatrixD solver(2*N+1,2*N+1);
+ std::vector samples(2*N+1);
+ if( strat < 4 ){
+ for(size_t eq = 0 ; eq < 2*N+1; ++eq)
+ samples[eq] = pow( eq/double(2*N), strat + 1);
+ }
+ TVectorD rest(2*N+1);
+ for( int eq = 0 ; eq < 2*N+1; ++eq ){
+ rest(eq) = fcn( samples[eq]*(max-min) + min);
+ for(int i = 0; i <= N; ++i) solver(eq,i) = pow(samples[eq],i);
+ for(int i = 1; i <= N; ++i) solver(eq,i+N) = -rest(eq)* pow(samples[eq],i);
+ }
+ solver.Invert();
+ auto r = solver * rest;
+ for(size_t i = 0; i <= N; ++i ) co_f[i] = r[i];
+ for(size_t i = 0; i < N; ++i ) co_g[i] = r[i+(N+1)];
+ range = 1./(max-min);
+ }
+ T operator()(const T& s){
+ T x = (s-min)*range;
+ T f = 0;
+ T g = 1;
+ T acc = 1;
+ for(size_t i = 0; i < N; ++i){
+ f += co_f[i] * acc;
+ acc *= x;
+ g += co_g[i] * acc;
+ }
+ return (f + co_f[N]*acc)/g;
+ }
+ };
+}
+
+#endif
diff --git a/AmpGen/ThreeBodyCalculators.h b/AmpGen/ThreeBodyCalculators.h
index 4ff024ede6a..887baf2b958 100644
--- a/AmpGen/ThreeBodyCalculators.h
+++ b/AmpGen/ThreeBodyCalculators.h
@@ -10,7 +10,6 @@ class TGraph;
namespace AmpGen
{
-
class MinuitParameterSet;
class ThreeBodyCalculator
diff --git a/AmpGen/Vertex.h b/AmpGen/Vertex.h
index fb2cd7636c3..2f2101c273a 100644
--- a/AmpGen/Vertex.h
+++ b/AmpGen/Vertex.h
@@ -24,31 +24,31 @@
* Macro to declare a vertex
*/
#define DECLARE_VERTEX(NAME) \
- struct NAME : public VertexBase { \
+ struct NAME : public Base { \
NAME(){ DEBUG("Constructing vertex"); } \
- virtual Tensor operator()( const Tensor& P, const Tensor& Q, const Tensor& V1, const Tensor& V2, DebugSymbols* db = 0 ) override; \
+ virtual Tensor operator()(const Tensor& P, const Tensor& Q, const Tensor& V1, const Tensor& V2, DebugSymbols* db = 0 ) override; \
static std::string _id; \
}
#define DEFINE_VERTEX(VERTEX) \
- REGISTER_WITH_KEY( Vertex::VertexBase, Vertex::VERTEX, #VERTEX, std::string ); \
+ REGISTER_WITH_KEY( Vertex::Base, Vertex::VERTEX, #VERTEX, std::string ); \
Tensor Vertex::VERTEX::operator()( const Tensor& P, const Tensor& Q, const Tensor& V1, const Tensor& V2, DebugSymbols* db )
namespace AmpGen
{
/** @ingroup Vertices namespace Vertex
- Namespace that contains the base class for vertices, VertexBase, as well as the implementations
+ Namespace that contains the base class for vertices, Vertex::Base, as well as the implementations
of specific spin couplings and some helper functions such as the orbital operators.
*/
namespace Vertex
{
- /** @ingroup Vertices class VertexBase
+ /** @ingroup Vertices class Base
@brief Base class for all spin vertices.
Virtual base class from which all the other vertices derive, in essence this is
just a named function pointer that can create a pointer to itself, i.e. such
that it can be constructed using a Factory.
*/
- struct VertexBase {
+ struct Base {
/** Calculate the generalised current for this decay process, as a function of:
@param P The momentum of the decaying particle
@@ -64,8 +64,8 @@ namespace AmpGen
const AmpGen::Tensor& V2,
AmpGen::DebugSymbols* db = nullptr ) = 0;
- virtual ~VertexBase() = default;
- VertexBase* create() { return this; }
+ virtual ~Base() = default;
+ Base* create() { return this; }
};
/// \ingroup Vertices class S_SS_S
/// \brief \f$ S = S_1 S_2 \f$
@@ -153,7 +153,7 @@ namespace AmpGen
DECLARE_VERTEX( S_ff_S1 );
DECLARE_VERTEX( V_ff_P );
DECLARE_VERTEX( V_ff_P1 );
- class Factory : public AmpGen::Factory
+ class Factory : public AmpGen::Factory
{
public:
static Tensor getSpinFactor( const Tensor& P, const Tensor& Q, const Tensor& V1, const Tensor& V2,
@@ -164,14 +164,43 @@ namespace AmpGen
};
} // namespace Vertex
- /// \ingroup Vertices function Orbital_PWave
- /// Helper function that computes the L=1 orbital momentum operator, i.e.
- /// \f$ L_{\mu} = q_{\mu} - \frac{p_{\nu}q^{\nu} p_{\mu} }{ p_{\alpha} p^{\alpha}} \f$
- Tensor Orbital_PWave( const Tensor& A, const Tensor& B );
- Tensor Orbital_DWave( const Tensor& A, const Tensor& B );
- Tensor Spin1Projector( const Tensor& A );
- Tensor Spin2Projector( const Tensor& A );
-
+ /** @ingroup Vertices function Orbital_PWave
+ @brief Helper function that computes the @f$L=1@f$ orbital momentum operator.
+ Helper function that computes the @f$L=1@f$ orbital momentum operator, which is given by
+ @f[ L_{\mu} = q_{\mu} - p_{\mu} \frac{p_{\nu}q^{\nu}}{ p^2 }, @f]
+ where @f$ p @f$ is total momentum and @f$ q @f$ is the momentum difference between
+ the two particles in the state.
+ */
+ Tensor Orbital_PWave(const Tensor& p, const Tensor& q);
+
+ /** @ingroup Vertices function Orbital_DWave
+ @brief Helper function that computes the @f$L=2@f$ orbital momentum operator.
+ Helper function that computes the @f$L=2@f$ orbital momentum operator, which is given by
+ @f[ L_{\mu\nu} = L_{\mu}L_{\nu} - \frac{L^2}{3} S_{\mu\nu}, @f]
+ where @f$ L_{\mu} @f$ is the Orbital_PWave operator and @f$ S_{\mu\nu} @f$ is the
+ Spin1Projector. */
+ Tensor Orbital_DWave(const Tensor& p, const Tensor& q);
+
+ /** @ingroup Vertices function Spin1Projector
+ @brief Helper function that computes the projection operator onto a spin one state.
+ Helper function that projects some lorentz object onto the momentum @f$p_\mu @f$ of state,
+ and is given by
+ @f[ S_{\mu\nu} = g_{\mu\nu} - \frac{p_{\mu}p_{\nu}}{p^2}. @f] */
+ Tensor Spin1Projector(const Tensor& p);
+
+ /** @ingroup Vertices function Spin2Projector
+ @brief Helper function that computes the projection operator onto a spin one state.
+ Helper function that projects some lorentz object onto the momentum @f$p_\mu @f$ of state,
+ and is given by
+ @f[ S_{\mu\nu\alpha\beta} = \frac{1}{2}\left( S_{\mu\alpha} S_{\nu\beta} + S_{\mu\beta}S_{\nu\alpha} \right) - \frac{1}{3} S_{\mu\nu} S_{\alpha\beta}, @f]
+ where @f$ S_{\mu\nu} @f$ is the spin-one projection operator (see Spin1Projector). */
+ Tensor Spin2Projector(const Tensor& p);
+
+ /** @ingroup Vertices function Spin1hProjector
+ @brief Helper function that projects a spinor.
+ Helper function that projects out a spin-half state
+ @f[ S_{ab} = \frac{1}{2m}\left( {p\!\!\!/} + m I \right) @f]
+ */
Tensor Spin1hProjector( const Tensor& B );
Tensor Spin3hProjector( const Tensor& A );
diff --git a/AmpGen/kMatrix.h b/AmpGen/kMatrix.h
index ae4165af1fc..b242b36908b 100644
--- a/AmpGen/kMatrix.h
+++ b/AmpGen/kMatrix.h
@@ -3,9 +3,28 @@
#include "AmpGen/Expression.h"
#include "AmpGen/Tensor.h"
+#include "AmpGen/Lineshapes.h"
namespace AmpGen
{
+ namespace Lineshape {
+
+ /** @ingroup Lineshapes class kMatrix
+ @brief Anisovich-Sarantsev Isoscalar K-matrix from https://arxiv.org/abs/hep-ph/0204328
+
+ Describes the isoscalar @f$ \pi\pi, KK, 4\pi \eta\eta, \eta\eta^\prime@f$ S-wave in terms of a five-by-five K-matrix and corresponding P-vector couplings.
+ Includes a large number of parameters that can be fixed from the above publication.
+ These parameters can be found in the options directory, which in turn can be includes in the fit by adding
+
+ \code{cpp}
+ Import $AMPGENROOT/options/kMatrix.opt
+ \endcode
+
+ to the user configuration file.
+ */
+ DECLARE_LINESHAPE( kMatrix );
+ }
+
struct poleConfig {
Expression s;
std::vector couplings;
diff --git a/apps/Fitter.cpp b/apps/Fitter.cpp
index 406c20071ee..3e8396388ba 100644
--- a/apps/Fitter.cpp
+++ b/apps/Fitter.cpp
@@ -52,13 +52,12 @@ std::vector threeBodyCalculators( MinuitParameterSet& mps )
void randomizeStartingPoint( MinuitParameterSet& MPS, TRandom3& rand, bool SplineOnly = false )
{
double range = 5;
- for ( unsigned int i = 0; i < MPS.size(); ++i ) {
- auto param = MPS.getParPtr( i );
+ for (auto& param : MPS) {
if ( param->iFixInit() == 0 ) {
if ( SplineOnly && param->name().find( "::Spline::" ) == std::string::npos ) continue;
range = param->maxInit() - param->minInit();
- MPS.getParPtr( i )->setInit( range * rand.Rndm() + param->meanInit() );
- MPS.getParPtr( i )->print();
+ param->setInit( range * rand.Rndm() + param->meanInit() );
+ param->print();
std::cout << std::endl;
}
}
diff --git a/src/ASTResolver.cpp b/src/ASTResolver.cpp
index 39660b13686..69a0b644e8e 100644
--- a/src/ASTResolver.cpp
+++ b/src/ASTResolver.cpp
@@ -19,8 +19,7 @@ ASTResolver::ASTResolver(const std::map& evtMap,
nParameters(0)
{
enable_cuda = NamedParameter("UseCUDA",false);
- enable_compileTimeConstants = NamedParameter("ASTResolver::CompileTimeConstants",false);
- INFO("Flags: " << enableCuda() << " " << enableCompileConstants() );
+ enable_compileTimeConstants = NamedParameter("ASTResolver::CompileTimeConstants", false);
}
bool ASTResolver::hasSubExpressions() const
@@ -119,7 +118,7 @@ template <> void ASTResolver::resolve( const Parameter& parameter )
if( it != nullptr ){
if( enable_compileTimeConstants &&
it->iFixInit() == MinuitParameter::Flag::CompileTimeConstant ){
- addResolvedParameter( ¶meter, std::to_string(it->mean()) );
+ addResolvedParameter( ¶meter, "("+std::to_string(it->mean()) +")" );
}
else addResolvedParameter( ¶meter, addCacheFunction( parameter.name(), it ) );
return;
diff --git a/src/CoherentSum.cpp b/src/CoherentSum.cpp
index c69ac5b3d52..099e7808e45 100644
--- a/src/CoherentSum.cpp
+++ b/src/CoherentSum.cpp
@@ -61,8 +61,6 @@ void CoherentSum::addMatrixElement( std::pair& parti
if ( name == mE.decayTree.uniqueString() ) return;
}
m_matrixElements.emplace_back(protoParticle, coupling, mps, m_evtType.getEventFormat(), m_dbThis);
- m_matrixElements.rbegin()->pdf.print();
-
}
void CoherentSum::prepare()
@@ -178,7 +176,7 @@ std::vector CoherentSum::fitFractions(const LinearErrorPropagator&
return outputFractions;
}
-void CoherentSum::generateSourceCode( const std::string& fname, const double& normalisation, bool add_mt )
+void CoherentSum::generateSourceCode(const std::string& fname, const double& normalisation, bool add_mt)
{
std::ofstream stream( fname );
transferParameters();
@@ -188,11 +186,10 @@ void CoherentSum::generateSourceCode( const std::string& fname, const double& no
stream << "#include \n";
if ( add_mt ) stream << "#include \n";
bool includePythonBindings = NamedParameter("CoherentSum::IncludePythonBindings",false);
- bool enableCuda = NamedParameter("CoherentSum::EnableCuda",false);
for ( auto& p : m_matrixElements ){
stream << p.pdf << std::endl;
- if( ! enableCuda ) p.pdf.compileWithParameters( stream );
+ p.pdf.compileWithParameters( stream );
if( includePythonBindings ) p.pdf.compileDetails( stream );
}
Expression event = Parameter("x0",0,true,0);
@@ -203,10 +200,8 @@ void CoherentSum::generateSourceCode( const std::string& fname, const double& no
Expression this_amplitude = p.coupling() * Function( programatic_name( p.pdf.name() ) + "_wParams", {event} );
amplitude = amplitude + ( p.decayTree.finalStateParity() == 1 ? 1 : pa ) * this_amplitude;
}
- if( !enableCuda ){
- stream << CompiledExpression< std::complex, const double*, int>( amplitude , "AMP" ) << std::endl;
- stream << CompiledExpression< double, const double*, int>(fcn::norm(amplitude) / normalisation, "FCN" ) << std::endl;
- }
+ stream << CompiledExpression< std::complex, const double*, int>( amplitude , "AMP" ) << std::endl;
+ stream << CompiledExpression< double, const double*, int>(fcn::norm(amplitude) / normalisation, "FCN" ) << std::endl;
if( includePythonBindings ){
stream << CompiledExpression< unsigned int >( m_matrixElements.size(), "matrix_elements_n" ) << std::endl;
stream << CompiledExpression< double > ( normalisation, "normalization") << std::endl;
diff --git a/src/CompiledExpressionBase.cpp b/src/CompiledExpressionBase.cpp
index fb0e8e7e7b2..e6dc28c1dad 100644
--- a/src/CompiledExpressionBase.cpp
+++ b/src/CompiledExpressionBase.cpp
@@ -70,7 +70,7 @@ void CompiledExpressionBase::prepare()
void CompiledExpressionBase::addDependentExpressions( std::ostream& stream, size_t& sizeOfStream ) const
{
for ( auto& dep : m_dependentSubexpressions ) {
- std::string rt = "auto v" + std::to_string(dep.first) + " = " + dep.second.to_string(m_resolver) +";";
+ std::string rt = " auto v" + std::to_string(dep.first) + " = " + dep.second.to_string(m_resolver) +";";
stream << rt << "\n";
sizeOfStream += sizeof(char) * rt.size(); /// bytes ///
}
@@ -81,21 +81,15 @@ void CompiledExpressionBase::to_stream( std::ostream& stream ) const
if( m_db.size() !=0 ) stream << "#include\n";
stream << "extern \"C\" const char* " << progName() << "_name() { return \"" << m_name << "\"; } \n";
bool enable_cuda = NamedParameter("UseCUDA",false);
-
- INFO("Enabling CUDA ...");
-
size_t sizeOfStream = 0;
if( !enable_cuda ){
- // Avoid a warning about std::complex not being C compatible (it is)
- stream << "#pragma clang diagnostic push\n"
- << "#pragma clang diagnostic ignored \"-Wreturn-type-c-linkage\"\n";
+ stream << "#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wreturn-type-c-linkage\"\n";
stream << "extern \"C\" " << returnTypename() << " " << progName() << "(" << fcnSignature() << "){\n";
addDependentExpressions( stream , sizeOfStream );
stream << "return " << m_obj.to_string(m_resolver) << ";\n}\n";
}
else {
- std::string rt_cuda = returnTypename() +"* r, const int N" ;
- stream << "__global__ void " << progName() << "( " << rt_cuda << ", const float_t* x0, const float3* x1){\n";
+ stream << "__global__ void " << progName() << "( " << returnTypename() + "* r, const int N, " << fcnSignature() << "){\n";
stream << " int i = blockIdx.x * blockDim.x + threadIdx.x;\n";
addDependentExpressions( stream, sizeOfStream);
stream << " r[i] = " << m_obj.to_string(m_resolver) << ";\n}\n";
diff --git a/src/DalitzIntegrator.cpp b/src/DalitzIntegrator.cpp
index e06568ba8f2..6c7d7ac02fb 100644
--- a/src/DalitzIntegrator.cpp
+++ b/src/DalitzIntegrator.cpp
@@ -191,6 +191,5 @@ double DalitzIntegrator::integrate_internal( TF2& fcn ) const
ig.SetRelTolerance( 0.000001 );
double xmin[] = {0, 0};
double xmax[] = {1, 1};
- double v = ig.Integral( xmin, xmax );
- return v ;
+ return ig.Integral(xmin,xmax);
}
diff --git a/src/ErrorPropagator.cpp b/src/ErrorPropagator.cpp
index 3c62fdbb804..38cf12fb436 100644
--- a/src/ErrorPropagator.cpp
+++ b/src/ErrorPropagator.cpp
@@ -70,11 +70,10 @@ LinearErrorPropagator::LinearErrorPropagator( const std::vectoriFixInit() != MinuitParameter::Float ) continue;
if( param->err() == 0 ) continue;
- m_parameters.push_back( param );
+ m_parameters.push_back(param);
}
m_cov.ResizeTo( m_parameters.size(), m_parameters.size() );
for( size_t i = 0 ; i < m_parameters.size(); ++i )
diff --git a/src/Expression.cpp b/src/Expression.cpp
index b27342a22f2..6ad9d69f368 100644
--- a/src/Expression.cpp
+++ b/src/Expression.cpp
@@ -18,11 +18,11 @@
using namespace AmpGen;
-DEFINE_CAST( Constant )
-DEFINE_CAST( Parameter )
-DEFINE_CAST( SubTree )
-DEFINE_CAST( Ternary )
-DEFINE_CAST( Function )
+DEFINE_CAST(Constant )
+DEFINE_CAST(Parameter )
+DEFINE_CAST(SubTree )
+DEFINE_CAST(Ternary )
+DEFINE_CAST(Function )
Expression::Expression( const std::shared_ptr& expression ) : m_expression( expression ) {}
diff --git a/src/FitResult.cpp b/src/FitResult.cpp
index dfd54c36dc0..309a2213e57 100644
--- a/src/FitResult.cpp
+++ b/src/FitResult.cpp
@@ -48,8 +48,6 @@ bool FitResult::readFile( const std::string& fname )
return false;
}
CHECK.close();
-
- // auto lines = vectorFromFile( fname );
std::vector parameterLines;
processFile( fname, [this, ¶meterLines]( auto& line ) {
@@ -105,12 +103,12 @@ void FitResult::writeToFile( const std::string& fname )
std::ofstream outlog;
outlog.open( fname );
- for ( int i = 0; i < m_covarianceMatrix.GetNrows(); ++i ) {
- auto param = m_mps->getParPtr( i );
+ for (size_t i = 0; i < (size_t)m_covarianceMatrix.GetNrows(); ++i ) {
+ auto param = m_mps->at(i);
outlog << "Parameter"
<< " " << param->name() << " " << param->iFixInit() << " " << param->mean() << " "
- << m_mps->getParPtr( i )->err() << " ";
- for ( int j = 0; j < m_covarianceMatrix.GetNcols(); ++j ) outlog << m_covarianceMatrix[i][j] << " ";
+ << m_mps->at(i)->err() << " ";
+ for (size_t j = 0; j < (size_t)m_covarianceMatrix.GetNcols(); ++j ) outlog << m_covarianceMatrix[i][j] << " ";
outlog << std::endl;
}
outlog << std::setprecision( 8 );
@@ -134,9 +132,9 @@ FitResult::FitResult( const Minimiser& mini )
m_covarianceMatrix = M;
m_status = mini.status();
m_nParam = 0;
- for ( unsigned int i = 0; i < m_mps->size(); ++i ) {
- if ( m_mps->getParPtr( i )->iFixInit() == 0 ) m_nParam++;
- m_covMapping[ m_mps->getParPtr(i)->name() ] = i;
+ for (size_t i = 0; i < m_mps->size(); ++i ) {
+ if ( m_mps->at(i)->iFixInit() == 0 ) m_nParam++;
+ m_covMapping[ m_mps->at(i)->name() ] = i;
}
}
@@ -148,8 +146,8 @@ FitResult::FitResult( const MinuitParameterSet& mps, const TMatrixD& covMini ) :
}
m_covarianceMatrix.ResizeTo( covMini.GetNcols(), covMini.GetNrows() );
m_covarianceMatrix = covMini;
- for ( unsigned int i = 0; i < m_mps->size(); ++i ) {
- if ( m_mps->getParPtr( i )->iFixInit() == 0 ) m_nParam++;
+ for (size_t i = 0; i < m_mps->size(); ++i ) {
+ if ( m_mps->at(i)->iFixInit() == 0 ) m_nParam++;
}
}
@@ -203,8 +201,8 @@ std::vector FitResult::getFloating( const bool& extended ) con
TMatrixD FitResult::getReducedCovariance( const bool& extended ) const
{
std::vector floating_indices;
- for ( unsigned int i = 0; i < m_mps->size(); ++i ) {
- auto param = m_mps->getParPtr( i );
+ for (size_t i = 0; i < m_mps->size(); ++i ) {
+ auto param = m_mps->at(i);
if ( ( param->iFixInit() == 0 || extended ) && param->err() > 1e-6 ) floating_indices.push_back( i );
}
TMatrixD reducedCov( floating_indices.size(), floating_indices.size() );
diff --git a/src/Lineshapes.cpp b/src/Lineshapes.cpp
index 4215758bbb9..c61060562a7 100644
--- a/src/Lineshapes.cpp
+++ b/src/Lineshapes.cpp
@@ -103,9 +103,9 @@ bool Lineshape::Factory::isLineshape( const std::string& lineshape )
size_t pos = lineshape.find( "." );
if ( pos == std::string::npos )
- return AmpGen::Factory::get(lineshape, true) != nullptr;
+ return AmpGen::Factory::get(lineshape, true) != nullptr;
else
- return AmpGen::Factory::get(lineshape.substr(0, pos), true ) != nullptr;
+ return AmpGen::Factory::get(lineshape.substr(0, pos), true ) != nullptr;
}
Expression Lineshape::Factory::get( const std::string& lineshape, const Expression& s, const Expression& s1,
@@ -115,11 +115,11 @@ Expression Lineshape::Factory::get( const std::string& lineshape, const Expressi
size_t pos = lineshape.find( "." );
if ( pos == std::string::npos ) {
- auto it = AmpGen::Factory::get( lineshape );
+ auto it = AmpGen::Factory::get( lineshape );
if ( !it ) ERROR( "Lineshape : " << lineshape << " not found" );
return it->get( s, s1, s2, particleName, L, "", dbexpressions );
} else {
- return AmpGen::Factory::get(lineshape.substr(0, pos))->get( s, s1, s2, particleName, L, lineshape.substr( pos + 1 ), dbexpressions );
+ return AmpGen::Factory::get(lineshape.substr(0, pos))->get( s, s1, s2, particleName, L, lineshape.substr( pos + 1 ), dbexpressions );
}
}
@@ -130,11 +130,11 @@ Expression Lineshape::Factory::get(const std::string& lineshape, const Expressio
size_t pos = lineshape.find( "." );
if ( pos == std::string::npos ) {
- auto it = AmpGen::Factory::get( lineshape );
+ auto it = AmpGen::Factory::get( lineshape );
if ( !it ) ERROR( "Lineshape : " << lineshape << " not found" );
return it->get(s, p, particleName, L, "", dbexpressions );
} else {
- return AmpGen::Factory::get( lineshape.substr( 0, pos ) )->get(s, p, particleName, L, lineshape.substr( pos + 1 ), dbexpressions );
+ return AmpGen::Factory::get( lineshape.substr( 0, pos ) )->get(s, p, particleName, L, lineshape.substr( pos + 1 ), dbexpressions );
}
}
diff --git a/src/Lineshapes/Flatte.cpp b/src/Lineshapes/Flatte.cpp
index 220cdfc1f47..06827969cbf 100644
--- a/src/Lineshapes/Flatte.cpp
+++ b/src/Lineshapes/Flatte.cpp
@@ -10,12 +10,12 @@ using namespace std::complex_literals;
Expression aSqrtTerm( const Expression& s, const Expression& m0 )
{
Expression a2 = 1.0 - ( 4 * m0 * m0 ) / s;
- return Ternary( a2 > Constant( 0 ), sqrt( a2 ), Constant( 0 ) );
+ return Ternary( a2 > 0., sqrt( a2 ), Constant( 0 ) );
}
Expression fSqrtTerm( const Expression& s, const Expression& m0 )
{
- return complex_sqrt( 1.0 - ( 4 * m0 * m0 ) / s );
+ return complex_sqrt( 1.0 - 4*m0*m0/ s );
}
DEFINE_LINESHAPE( Flatte )
{
diff --git a/src/Minimiser.cpp b/src/Minimiser.cpp
index bd92ccfbc44..051e6ca676d 100644
--- a/src/Minimiser.cpp
+++ b/src/Minimiser.cpp
@@ -32,8 +32,8 @@ void Minimiser::print( const double& LL )
double Minimiser::operator()( const double* xx )
{
- for ( unsigned int i = 0; i < m_mapping.size(); ++i ) {
- m_parSet->getParPtr( m_mapping[i] )->setCurrentFitVal( xx[i] );
+ for(size_t i = 0; i < m_mapping.size(); ++i ) {
+ m_parSet->at( m_mapping[i] )->setCurrentFitVal( xx[i] );
}
double LL = m_theFunction();
for ( auto& extendTerm : m_extendedTerms ) {
@@ -44,8 +44,8 @@ double Minimiser::operator()( const double* xx )
void Minimiser::GradientTest()
{
- for ( unsigned int i = 0; i < m_mapping.size(); ++i ) {
- auto parameter = m_parSet->getParPtr( m_mapping[i] );
+ for (size_t i = 0; i < m_mapping.size(); ++i) {
+ auto parameter = m_parSet->at( m_mapping[i] );
double m = parameter->mean();
parameter->setCurrentFitVal( parameter->meanInit() + parameter->stepInit() );
double vp = FCN();
@@ -78,7 +78,7 @@ void Minimiser::prepare()
m_covMatrix.clear();
for(size_t i = 0 ; i < m_parSet->size(); ++i)
{
- auto par = m_parSet->getParPtr(i);
+ auto par = m_parSet->at(i);
if ( par->iFixInit() != 0 ) continue;
m_minimiser->SetVariable(m_mapping.size(), par->name(), par->mean(), par->stepInit());
if ( par->minInit() != 0 || par->maxInit() != 0 )
@@ -100,8 +100,8 @@ bool Minimiser::doFit()
{
m_lastPrint = 999;
ROOT::Math::Functor f( *this, m_nParams );
- for ( unsigned int i = 0; i < m_mapping.size(); ++i ) {
- MinuitParameter* par = m_parSet->getParPtr( m_mapping[i] );
+ for (size_t i = 0; i < m_mapping.size(); ++i ) {
+ MinuitParameter* par = m_parSet->at( m_mapping[i] );
m_minimiser->SetVariable( i, par->name(), par->mean(), par->stepInit() );
if ( par->minInit() != 0 || par->maxInit() != 0 )
m_minimiser->SetVariableLimits( i, par->minInit(), par->maxInit() );
@@ -109,8 +109,8 @@ bool Minimiser::doFit()
m_minimiser->SetFunction( f );
m_minimiser->Minimize();
- for ( unsigned int i = 0; i < m_nParams; ++i ) {
- auto par = m_parSet->getParPtr( m_mapping[i] );
+ for (size_t i = 0; i < m_nParams; ++i ) {
+ auto par = m_parSet->at( m_mapping[i] );
double error = *( m_minimiser->Errors() + i );
par->setResult( *( m_minimiser->X() + i ), error, error, error );
for ( unsigned int j = 0; j < m_nParams; ++j ) {
diff --git a/src/MinuitParameterSet.cpp b/src/MinuitParameterSet.cpp
index 72b23ba6b77..8c1f7ea8cc1 100644
--- a/src/MinuitParameterSet.cpp
+++ b/src/MinuitParameterSet.cpp
@@ -22,7 +22,7 @@ using namespace AmpGen;
MinuitParameterSet::MinuitParameterSet() = default;
MinuitParameterSet::MinuitParameterSet( const MinuitParameterSet& other )
- : _parPtrList( other._parPtrList ), _keyAccess( other._keyAccess )
+ : m_parameters( other.m_parameters ), m_keyAccess( other.m_keyAccess )
{
}
@@ -40,97 +40,98 @@ bool MinuitParameterSet::addToEnd( MinuitParameter* parPtr )
bool success = true;
if ( nullptr == parPtr ) return false;
- _parPtrList.push_back( parPtr );
+ m_parameters.push_back( parPtr );
- if ( _keyAccess.find( parPtr->name() ) != _keyAccess.end() ) {
+ if ( m_keyAccess.find( parPtr->name() ) != m_keyAccess.end() ) {
WARNING( "Parameter with name " << parPtr->name() << " already exists!" );
}
- _keyAccess[parPtr->name()] = parPtr;
+ m_keyAccess[parPtr->name()] = parPtr;
return success;
}
MinuitParameter* MinuitParameterSet::add( const std::string& name, const unsigned int& flag, const double& mean,
- const double& sigma, const double& min, const double& max )
+ const double& sigma, const double& min, const double& max )
{
addToEnd( new MinuitParameter( name, MinuitParameter::Flag(flag), mean, sigma, min, max ) );
- return _keyAccess[name];
+ return m_keyAccess[name];
}
bool MinuitParameterSet::add( MinuitParameter* parPtr ) { return addToEnd( parPtr ); }
bool MinuitParameterSet::unregister( MinuitParameter* parPtr )
{
- if ( _parPtrList.end() == std::find( _parPtrList.begin(), _parPtrList.end(), parPtr ) ) {
+ if ( m_parameters.end() == std::find( m_parameters.begin(), m_parameters.end(), parPtr ) ) {
WARNING( "parPtr you want to unregister is not part of this list!" );
return false;
}
- _parPtrList.erase( remove( _parPtrList.begin(), _parPtrList.end(), parPtr ), _parPtrList.end() );
+ m_parameters.erase( remove( m_parameters.begin(), m_parameters.end(), parPtr ), m_parameters.end() );
return true;
}
-unsigned int MinuitParameterSet::size() const { return _parPtrList.size(); }
-
-MinuitParameter* MinuitParameterSet::getParPtr( unsigned int i ) const
-{
- if ( i >= _parPtrList.size() ) return nullptr;
- return _parPtrList[i];
-}
+unsigned int MinuitParameterSet::size() const { return m_parameters.size(); }
void MinuitParameterSet::deleteListAndObjects()
{
- for ( auto it = _parPtrList.begin(); it != _parPtrList.end(); ++it ) {
- delete *it;
- }
- _parPtrList.clear();
+ for ( auto it = m_parameters.begin(); it != m_parameters.end(); ++it ) delete *it;
+ m_parameters.clear();
}
-void MinuitParameterSet::deleteListKeepObjects() { _parPtrList.clear(); }
+void MinuitParameterSet::deleteListKeepObjects() { m_parameters.clear(); }
void MinuitParameterSet::print( std::ostream& os ) const
{
- for ( unsigned int i = 0; i < size(); i++ ) {
- if ( nullptr == getParPtr( i ) ) continue;
+ for (size_t i = 0; i < size(); i++ ) {
os << '\n';
- getParPtr( i )->print( os );
+ m_parameters[i]->print(os);
}
os << '\n';
}
void MinuitParameterSet::printVariable( std::ostream& os ) const
{
- for ( unsigned int i = 0; i < size(); i++ ) {
- if ( nullptr == getParPtr( i ) ) continue;
- if ( getParPtr( i )->iFixInit() == 1 ) continue; /// hide parameter
+ for (size_t i = 0; i < size(); i++ ) {
+ if ( m_parameters[i]->iFixInit() == 1 ) continue; /// hide parameter
os << '\n';
- getParPtr( i )->print( os );
+ m_parameters[i]->print( os );
}
}
MinuitParameter* MinuitParameterSet::operator[]( const std::string& key )
{
- auto it = _keyAccess.find( key );
- if ( it == _keyAccess.end() ) {
+ auto it = m_keyAccess.find( key );
+ if ( it == m_keyAccess.end() ) {
WARNING( "Parameter: " << key << " not found" );
}
return it->second;
}
+
MinuitParameter* MinuitParameterSet::operator[]( const std::string& key ) const
{
- auto it = _keyAccess.find( key );
- if ( it == _keyAccess.end() ) {
+ auto it = m_keyAccess.find( key );
+ if ( it == m_keyAccess.end() ) {
WARNING( "Parameter: " << key << " not found" );
}
return it->second;
}
-MinuitParameter* MinuitParameterSet::operator[]( const unsigned int& key ) { return _parPtrList[key]; }
+
+MinuitParameter* MinuitParameterSet::operator[]( const size_t& key ) { return m_parameters[key]; }
+
MinuitParameter* MinuitParameterSet::at( const std::string& key )
{
- if ( _keyAccess.count( key ) == 0 ) {
+ if ( m_keyAccess.count( key ) == 0 ) {
ERROR( key << " not found" );
return nullptr;
} else
- return _keyAccess[key];
+ return m_keyAccess[key];
}
+MinuitParameter* MinuitParameterSet::at( const size_t& index ) const
+{
+ if( index >= m_parameters.size() )
+ ERROR( "Attempting to access parameter " << index << " when only " << m_parameters.size() << " have been defined" );
+ return index < m_parameters.size() ? m_parameters[index] : nullptr;
+}
+
+
void MinuitParameterSet::tryParameter( const std::vector& line )
{
if ( line.size() == 4 || line.size() == 6 ) {
@@ -145,7 +146,7 @@ void MinuitParameterSet::tryParameter( const std::vector& line )
if ( status ) {
if ( OptionsParser::printHelp() )
INFO( "MINUIT: Registered " << line[0] << " (flag " << flag << ") = " << mean << ", step=" << step << " ("
- << min << "," << max << ")" );
+ << min << "," << max << ")" );
add( new MinuitParameter( line[0], MinuitParameter::Flag(flag), mean, step, min, max ) );
}
return;
@@ -165,20 +166,11 @@ void MinuitParameterSet::tryParameter( const std::vector& line )
double min_im = 0;
double max_im = 0;
if ( !status ) return;
-
- if ( NamedParameter( "MinuitParameterSet::RegulateParameters", 0 ) == 1 ) {
- if ( mean_re < 0 ) {
- mean_re = -mean_re;
- mean_im = mean_im + M_PI;
- }
- mean_im = atan2( sin( mean_im ), cos( mean_im ) );
- max_re = 1000;
- }
if ( OptionsParser::printHelp() ) {
INFO( "MINUIT: Complex " << line[0] << "_Re (flag " << flag_re << ") = " << mean_re << ", step=" << step_re
- << " (" << min_re << "," << max_re << ")" );
+ << " (" << min_re << "," << max_re << ")" );
INFO( "MINUIT: Complex " << line[0] << "_Im (flag " << flag_im << ") = " << mean_im << ", step=" << step_im
- << " (" << min_im << "," << max_im << ")" );
+ << " (" << min_im << "," << max_im << ")" );
}
add( new MinuitParameter( line[0] + "_Re", MinuitParameter::Flag(flag_re), mean_re, step_re, min_re, max_re ) );
add( new MinuitParameter( line[0] + "_Im", MinuitParameter::Flag(flag_im), mean_im, step_im, min_im, max_im ) );
@@ -197,7 +189,6 @@ void MinuitParameterSet::tryParameter( const std::vector& line )
double min_im = lexical_cast( line[9], status );
double max_im = lexical_cast( line[10], status );
if ( !status ) return;
-
add( new MinuitParameter( line[0] + "_Re", MinuitParameter::Flag(flag_re), mean_re, step_re, min_re, max_re ) );
add( new MinuitParameter( line[0] + "_Im", MinuitParameter::Flag(flag_im), mean_im, step_im, min_im, max_im ) );
}
@@ -210,8 +201,8 @@ void MinuitParameterSet::tryAlias( const std::vector& line )
std::string name = line[0];
MinuitExpression* expr = new MinuitExpression( line, this );
if ( expr->isGood() ) {
- _aliasList.push_back( expr );
- _keyAccess[name] = expr;
+ m_expressions.push_back( expr );
+ m_keyAccess[name] = expr;
} else {
ERROR( "Expression is ill-formed: " << line[0] );
delete expr;
@@ -222,23 +213,20 @@ void MinuitParameterSet::tryAlias( const std::vector& line )
void MinuitParameterSet::loadFromStream()
{
auto ppfl = OptionsParser::getMe();
-
std::vector> protoAliases;
-
for ( auto it = ppfl->begin(); it != ppfl->end(); ++it ) {
tryParameter( it->second );
if ( it->second.size() >= 3 && it->second[1] == "=" ) protoAliases.push_back( it->second );
}
for ( auto& alias : protoAliases ) tryAlias( alias );
- // print();
}
void MinuitParameterSet::loadFromFile( const std::string& file )
{
processFile( file, [this]( auto& line ) {
- this->tryParameter( split( line, {' ', '\t'} ) );
- this->tryAlias( split( line, {' ', '\t'} ) );
- } );
+ this->tryParameter( split( line, {' ', '\t'} ) );
+ this->tryAlias( split( line, {' ', '\t'} ) );
+ } );
}
MinuitParameterSet::~MinuitParameterSet() = default;
@@ -257,8 +245,30 @@ void MinuitParameterSet::resetToInit()
}
MinuitParameter* MinuitParameterSet::addOrGet( const std::string& name, const unsigned int& flag, const double& mean,
- const double& sigma, const double& min, const double& max )
+ const double& sigma, const double& min, const double& max )
{
- if ( _keyAccess.count( name ) != 0 ) return _keyAccess[name];
+ if ( m_keyAccess.count( name ) != 0 ) return m_keyAccess[name];
return add( name, flag, mean, sigma, min, max );
}
+std::map& MinuitParameterSet::map() { return m_keyAccess; }
+const std::map& MinuitParameterSet::const_map() const { return m_keyAccess; }
+MinuitParameterSet::const_iterator MinuitParameterSet::cbegin() const { return m_parameters.cbegin(); }
+MinuitParameterSet::const_iterator MinuitParameterSet::cend() const { return m_parameters.cend(); }
+MinuitParameterSet::iterator MinuitParameterSet::begin() { return m_parameters.begin(); }
+MinuitParameterSet::iterator MinuitParameterSet::end() { return m_parameters.end(); }
+MinuitParameterSet::const_iterator MinuitParameterSet::begin() const { return m_parameters.cbegin(); }
+MinuitParameterSet::const_iterator MinuitParameterSet::end() const { return m_parameters.cend(); }
+
+MinuitParameter* MinuitParameterSet::find( const std::string& key ) const
+{
+ auto it = m_keyAccess.find(key);
+ return it == m_keyAccess.end() ? nullptr : it->second;
+}
+
+double MinuitParameterSet::operator()( const std::string& name )
+{
+ if ( m_keyAccess.find(name) == m_keyAccess.end() ) {
+ ERROR( "Cannot find parameter " << name );
+ }
+ return m_keyAccess[name]->mean();
+}
diff --git a/src/Pade.cpp b/src/Pade.cpp
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/src/PhaseSpace.cpp b/src/PhaseSpace.cpp
index 615767d8169..6caf2832251 100644
--- a/src/PhaseSpace.cpp
+++ b/src/PhaseSpace.cpp
@@ -59,14 +59,14 @@ Event PhaseSpace::makeEvent(const size_t& cacheSize)
rt.set(0, { 0, pd[0], 0, sqrt( pd[0] * pd[0] + m_mass[0] * m_mass[0] )} );
- for( unsigned int i = 1 ; i != m_nt ; ++i ){
+ for(size_t i = 1 ; i != m_nt ; ++i ){
rt.set( i, { 0, -pd[i-1], 0, sqrt( pd[i-1] * pd[i-1] + m_mass[i] * m_mass[i] ) } );
double cZ = 2 * rndm() - 1;
double sZ = sqrt( 1 - cZ * cZ );
double angY = 2 * M_PI * rndm();
double cY = cos(angY);
double sY = sin(angY);
- for ( unsigned int j = 0; j <= i; j++ ) {
+ for (size_t j = 0; j <= i; j++ ) {
double x = rt[4*j+0];
double y = rt[4*j+1];
double z = rt[4*j+2];
@@ -79,7 +79,7 @@ Event PhaseSpace::makeEvent(const size_t& cacheSize)
if ( i == ( m_nt - 1 ) ) break;
double beta = pd[i] / sqrt( pd[i] * pd[i] + invMas[i] * invMas[i] );
double gamma = 1./sqrt( 1 - beta*beta);
- for ( unsigned int j = 0; j <= i; j++ ){
+ for (size_t j = 0; j <= i; j++ ){
double E = rt[4*j+3];
double py = rt[4*j+1];
rt[4*j+1] = gamma*( py + beta * E );
@@ -93,10 +93,9 @@ Event PhaseSpace::makeEvent(const size_t& cacheSize)
bool PhaseSpace::setDecay( const double& m0, const std::vector& mass )
{
- unsigned int n;
m_nt = mass.size();
m_teCmTm = m0;
- for ( n = 0; n < m_nt; n++ ) {
+ for (size_t n = 0; n < m_nt; n++) {
m_mass[n] = mass[n];
m_teCmTm -= mass[n];
}
@@ -104,7 +103,7 @@ bool PhaseSpace::setDecay( const double& m0, const std::vector& mass )
double emmax = m_teCmTm + m_mass[0];
double emmin = 0;
double wtmax = 1;
- for ( n = 1; n < m_nt; n++ ) {
+ for (size_t n = 1; n < m_nt; n++) {
emmin += m_mass[n - 1];
emmax += m_mass[n];
wtmax *= q( emmax, emmin, m_mass[n] );
diff --git a/src/PolarisedSum.cpp b/src/PolarisedSum.cpp
index e7efc8aa0a4..ad406962d9e 100644
--- a/src/PolarisedSum.cpp
+++ b/src/PolarisedSum.cpp
@@ -342,8 +342,6 @@ Expression PolarisedSum::probExpression(const Tensor& T_matrix, const std::vecto
size_t it = T_matrix.dims()[0];
Tensor rho = Identity(it);
if(it == 2) rho = rho + Sigma[0] * p[0] + Sigma[1] * p[1] + Sigma[2]*p[2];
- rho.print();
-
Expression rt = rho(a,b) * TT(b,a);
return Real(rt);
}
@@ -411,6 +409,5 @@ real_t PolarisedSum::getValNoCache( const Event& evt )
return m_probExpression( copy.getCachePtr() );
}
-
void PolarisedSum::setWeight( MinuitParameter* param ){ m_weightParam = param ; }
double PolarisedSum::getWeight() const { return m_weightParam == nullptr ? 1.0 : m_weightParam->mean() ; }
diff --git a/src/ThreeBodyCalculators.cpp b/src/ThreeBodyCalculators.cpp
index d099bb7c5ef..2175a82aa8f 100644
--- a/src/ThreeBodyCalculators.cpp
+++ b/src/ThreeBodyCalculators.cpp
@@ -44,14 +44,9 @@ using namespace AmpGen;
template double dispersive( FCN& fcn , const double& s, double min , double max )
{
TF1 fcn_tf1 = TF1( "fcn_tf1",fcn, min, max, 0 );
- ROOT::Math::WrappedTF1* wf1 = new ROOT::Math::WrappedTF1( fcn_tf1 );
- ROOT::Math::GSLIntegrator ig( ROOT::Math::IntegrationOneDim::kADAPTIVE );
- ROOT::Math::IGenFunction& stupid = *( wf1->Clone() );
- ig.SetFunction( stupid );
- ig.SetRelTolerance( 0.001 );
- double rt = ig.IntegralCauchy(stupid,min,max,s);
- delete wf1;
- return rt;
+ ROOT::Math::GSLIntegrator ig(ROOT::Math::IntegrationOneDim::kADAPTIVE, 0.0001);
+ ig.SetFunction( ROOT::Math::WrappedTF1(fcn_tf1) );
+ return ig.IntegralCauchy(min,max,s);
}
TGraph* ThreeBodyCalculator::runningMass(
diff --git a/src/Vertex.cpp b/src/Vertex.cpp
index e788a56402a..4c0dfd756b8 100644
--- a/src/Vertex.cpp
+++ b/src/Vertex.cpp
@@ -19,7 +19,7 @@ const Tensor::Index nu = Tensor::Index();
const Tensor::Index alpha = Tensor::Index();
const Tensor::Index beta = Tensor::Index();
-template <> Factory* Factory::gImpl = nullptr;
+template <> Factory* Factory::gImpl = nullptr;
bool Vertex::Factory::isVertex( const std::string& hash ) { return get( hash ) != nullptr; }
@@ -54,19 +54,19 @@ const Tensor Metric4x4(){
return Tensor( {-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1}, {4, 4} );
}
-Tensor AmpGen::Orbital_PWave( const Tensor& P, const Tensor& Q )
+Tensor AmpGen::Orbital_PWave(const Tensor& p, const Tensor& q)
{
- auto is = 1./make_cse( dot(P,P) ,true);
- return Q - P * make_cse( dot( P, Q ) * is );
+ auto is = 1./make_cse( dot(p,p) ,true);
+ return q - p * make_cse( dot(p, q) * is );
}
-Tensor AmpGen::Orbital_DWave( const Tensor& P, const Tensor& Q )
+Tensor AmpGen::Orbital_DWave(const Tensor& p, const Tensor& q)
{
Tensor::Index mu;
Tensor::Index nu;
- Tensor L = Orbital_PWave( P, Q );
- Tensor f = L(mu) * L(nu) - make_cse( dot( L, L ) / 3. ) * Spin1Projector(P) ( mu, nu );
+ Tensor L = Orbital_PWave(p, q);
+ Tensor f = L(mu) * L(nu) - make_cse( dot( L, L ) / 3. ) * Spin1Projector(p) ( mu, nu );
f.imposeSymmetry(0,1);
f.st();
return f;
@@ -149,9 +149,8 @@ DEFINE_VERTEX( S_VV_S1 ) { return Spin1Projector(P)(mu,nu) * V1( -mu ) * V2( -nu
DEFINE_VERTEX( S_VV_D )
{
- Tensor L2 = Orbital_DWave( P, Q ) / ( GeV * GeV );
- Tensor vtol = V1( mu ) * L2( -mu, -nu ) * V2( nu );
- return vtol;
+ Tensor L2 = Orbital_DWave(P, Q);
+ return V1(mu)*L2(-mu,-nu)*V2(nu);
}
DEFINE_VERTEX( S_VV_P )
From 306bec44ba541304bad275beac83e60345b225e1 Mon Sep 17 00:00:00 2001
From: tevans1260
Date: Tue, 2 Apr 2019 10:00:33 +0200
Subject: [PATCH 049/250] Remove explicit linking of tbb
---
AmpGen/Plots.h | 1 -
Standalone.cmake | 2 --
src/FitResult.cpp | 30 ++++++++----------------------
src/PolarisedSum.cpp | 6 ------
4 files changed, 8 insertions(+), 31 deletions(-)
diff --git a/AmpGen/Plots.h b/AmpGen/Plots.h
index 7135c708329..15c5842d643 100644
--- a/AmpGen/Plots.h
+++ b/AmpGen/Plots.h
@@ -86,7 +86,6 @@ namespace AmpGen
return plot;
}
-
template
std::vector bandPlot( EventList& events, const std::string& prefix, FCN& fcn, LinearErrorPropagator& linProp )
{
diff --git a/Standalone.cmake b/Standalone.cmake
index de7da148eab..a9f9f1fb13d 100644
--- a/Standalone.cmake
+++ b/Standalone.cmake
@@ -129,8 +129,6 @@ target_compile_options(AmpGen
-Woverloaded-virtual
$<$:-Ofast>)
-target_link_libraries(AmpGen PUBLIC "tbb")
-
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lm -lstdc++")
else()
diff --git a/src/FitResult.cpp b/src/FitResult.cpp
index 309a2213e57..8d09be83938 100644
--- a/src/FitResult.cpp
+++ b/src/FitResult.cpp
@@ -32,8 +32,7 @@ FitResult::FitResult( const std::string& filename, const EventType& evtType )
std::string FitResult::getLastLine( std::ifstream& in ) const
{
std::string line;
- while ( in >> std::ws && std::getline( in, line ) )
- ;
+ while ( in >> std::ws && std::getline( in, line ) ) ;
return line;
}
@@ -52,25 +51,20 @@ bool FitResult::readFile( const std::string& fname )
processFile( fname, [this, ¶meterLines]( auto& line ) {
const std::string name = split( line, ' ' )[0];
- if ( name == "Parameter" )
- parameterLines.push_back( line );
- else if ( name == "FitQuality" )
- this->setFitQuality( line );
- else if ( name == "FitFraction" )
- this->m_fitFractions.emplace_back( line, m_eventType );
- else if ( name == "Observable" )
- this->addToObservables( line );
+ if ( name == "Parameter" ) parameterLines.push_back( line );
+ else if ( name == "FitQuality" ) this->setFitQuality( line );
+ else if ( name == "FitFraction" ) this->m_fitFractions.emplace_back( line, m_eventType );
+ else if ( name == "Observable" ) this->addToObservables( line );
} );
- unsigned int nParameters = parameterLines.size();
-
+ size_t nParameters = parameterLines.size();
m_covarianceMatrix.ResizeTo( parameterLines.size(), parameterLines.size() );
m_mps = std::make_shared();
- for ( unsigned int i = 0; i < nParameters; ++i ) {
+ for (size_t i = 0; i < nParameters; ++i ) {
auto tokens = split( parameterLines[i], ' ' );
m_covMapping[tokens[1]] = i;
m_mps->add( new MinuitParameter( tokens[1], MinuitParameter::Flag(stoi( tokens[2] ) ), stod( tokens[3] ), stod( tokens[4] ), 0, 0 ) );
- for ( unsigned int j = 0; j < nParameters; ++j ) m_covarianceMatrix( i, j ) = stod( tokens[5 + j] );
+ for (size_t j = 0; j < nParameters; ++j ) m_covarianceMatrix( i, j ) = stod( tokens[5 + j] );
}
return true;
@@ -187,14 +181,6 @@ std::vector FitResult::getFloating( const bool& extended ) con
for ( auto& param : *m_mps ) {
if ( ( param->iFixInit() == 0 || extended ) && param->err() > 1e-6 ) floating.push_back( param );
}
- /*
- if( extended ){
- DEBUG("Got extended error propagator:");
- for( auto& param : floating ){
- INFO( param->name() );
- }
- }
- */
return floating;
}
diff --git a/src/PolarisedSum.cpp b/src/PolarisedSum.cpp
index ad406962d9e..974a70d0859 100644
--- a/src/PolarisedSum.cpp
+++ b/src/PolarisedSum.cpp
@@ -159,7 +159,6 @@ void PolarisedSum::prepare()
for(size_t i = 0; i < m_matrixElements.size(); ++i){
for(size_t j = i; j < m_matrixElements.size(); ++j){
z += ((i==j) ? 1. : 2. ) * m_matrixElements[i].coupling()*std::conj(m_matrixElements[j].coupling())*norm(i,j);
-// z += m_matrixElements[i].coupling()*std::conj(m_matrixElements[j].coupling())*norm(i,j);
}
}
m_norm = std::real(z);
@@ -185,11 +184,6 @@ void PolarisedSum::debug_norm()
<< "; exact=" << norm_slow / m_integrator.sampleNorm()
<< "; d = " << m_norm - norm_slow / m_integrator.sampleNorm()
<< "; sample=" << m_integrator.sampleNorm() );
-// for( int i = 0 ; i < m_matrixElements.size(); ++i){
-// for( int j = 0 ; j < m_matrixElements.size(); ++j){
-// INFO( "Norm(i="<
Date: Wed, 3 Apr 2019 17:59:17 +0200
Subject: [PATCH 050/250] Synchronise version numbering system with Gaudi
version, remove unused parameter from Parameter
---
AmpGen/CompiledExpression.h | 6 +++---
AmpGen/Expression.h | 8 +++-----
AmpGen/Version.h.in | 5 +++--
Standalone.cmake | 4 ++--
src/CoherentSum.cpp | 8 ++++----
src/CompiledExpressionBase.cpp | 6 +++---
src/CompilerWrapper.cpp | 6 ++++--
src/Expression.cpp | 12 +-----------
src/Particle.cpp | 6 +++---
src/PolarisedSum.cpp | 2 +-
src/Utilities.cpp | 2 +-
11 files changed, 28 insertions(+), 37 deletions(-)
diff --git a/AmpGen/CompiledExpression.h b/AmpGen/CompiledExpression.h
index 94f0e08dfea..05519e197b6 100644
--- a/AmpGen/CompiledExpression.h
+++ b/AmpGen/CompiledExpression.h
@@ -122,8 +122,8 @@ namespace AmpGen
{
DEBUG( "Compiling " << name() << " = " << hash() );
// Avoid a warning about std::complex not being C compatible (it is)
- stream << "#pragma clang diagnostic push\n"
- << "#pragma clang diagnostic ignored \"-Wreturn-type-c-linkage\"\n";
+ // stream << "#pragma clang diagnostic push\n"
+ // << "#pragma clang diagnostic ignored \"-Wreturn-type-c-linkage\"\n";
stream << "extern \"C\" " << returnTypename() << " " << progName() << "_wParams"
<< "( const double*__restrict__ E ){" << std::endl;
stream << " double externalParameters [] = {";
@@ -134,7 +134,7 @@ namespace AmpGen
stream << m_externals[m_externals.size() - 1] << " }; " << std::endl;
} else stream << "0};" << std::endl;
stream << " return " << progName() << "( externalParameters, E ); // E is P \n}\n";
- stream << "#pragma clang diagnostic pop\n\n" << std::endl;
+ // stream << "#pragma clang diagnostic pop\n\n" << std::endl;
}
bool isReady() const override { return (m_readyFlag != nullptr && m_readyFlag->get() ) && m_fcn.isLinked(); }
diff --git a/AmpGen/Expression.h b/AmpGen/Expression.h
index 4171a18111d..3b5e88e9e8c 100644
--- a/AmpGen/Expression.h
+++ b/AmpGen/Expression.h
@@ -173,10 +173,9 @@ namespace AmpGen
such as cache states, but this currently requires manually specifying the argument ordering. */
class Parameter : public IExpression {
public:
- Parameter( const std::string& name = "",
- const double& defaultValue = 0 ,
- const bool& resolved = false,
- const unsigned int& fromArg = 0 );
+ Parameter(const std::string& name = "",
+ const double& defaultValue = 0 ,
+ const bool& resolved = false);
std::string to_string(const ASTResolver* resolver = nullptr) const override;
void resolve( ASTResolver& resolver ) override;
operator Expression() const;
@@ -189,7 +188,6 @@ namespace AmpGen
std::string m_name;
double m_defaultValue;
bool m_resolved;
- unsigned int m_fromArg;
};
/** @ingroup ExpressionEngine class Ternary
diff --git a/AmpGen/Version.h.in b/AmpGen/Version.h.in
index 9adbb1f3413..d80b4640bbf 100644
--- a/AmpGen/Version.h.in
+++ b/AmpGen/Version.h.in
@@ -1,2 +1,3 @@
-#define AMPGEN_VERSION_MAJOR @AmpGen_VERSION_MAJOR@
-#define AMPGEN_VERSION_MINOR @AmpGen_VERSION_MINOR@
+#define AMPGEN_MAJOR_VERSION @AmpGen_VERSION_MAJOR@
+#define AMPGEN_MINOR_VERSION @AmpGen_VERSION_MINOR@
+
diff --git a/Standalone.cmake b/Standalone.cmake
index a9f9f1fb13d..9a47e5a5cec 100644
--- a/Standalone.cmake
+++ b/Standalone.cmake
@@ -26,7 +26,7 @@ include(CMakePrintHelpers)
option(AMPGEN_DEBUG "AmpGen Debug printout")
option(AMPGEN_TRACE "AmpGen Trace printout")
-configure_file ("${PROJECT_SOURCE_DIR}/AmpGen/Version.h.in" "${PROJECT_SOURCE_DIR}/AmpGen/Version.h")
+configure_file ("${PROJECT_SOURCE_DIR}/AmpGen/Version.h.in" "${CMAKE_BINARY_DIR}/AmpGenVersion.h")
add_library(AmpGen SHARED ${AMPGEN_SRC} ${AMPGEN_HDR})
@@ -56,7 +56,7 @@ endif()
message( STATUS "ROOT_INCLUDE_DIRS = ${ROOT_INCLUDE_DIRS}")
target_include_directories(AmpGen PUBLIC "${CMAKE_SOURCE_DIR}")
-
+target_include_directories(AmpGen PUBLIC "${CMAKE_BINARY_DIR}")
target_include_directories(AmpGen SYSTEM PUBLIC "${ROOT_INCLUDE_DIRS}")
target_link_libraries(AmpGen PUBLIC ${ROOT_LIBRARIES} ${CMAKE_DL_LIBS})
diff --git a/src/CoherentSum.cpp b/src/CoherentSum.cpp
index 099e7808e45..1006cdee795 100644
--- a/src/CoherentSum.cpp
+++ b/src/CoherentSum.cpp
@@ -192,16 +192,16 @@ void CoherentSum::generateSourceCode(const std::string& fname, const double& nor
p.pdf.compileWithParameters( stream );
if( includePythonBindings ) p.pdf.compileDetails( stream );
}
- Expression event = Parameter("x0",0,true,0);
- Expression pa = Parameter("double(x1)",0,true,0);
+ Expression event = Parameter("x0",0,true);
+ Expression pa = Parameter("double(x1)",0,true);
Expression amplitude;
for( unsigned int i = 0 ; i < size(); ++i ){
auto& p = m_matrixElements[i];
Expression this_amplitude = p.coupling() * Function( programatic_name( p.pdf.name() ) + "_wParams", {event} );
amplitude = amplitude + ( p.decayTree.finalStateParity() == 1 ? 1 : pa ) * this_amplitude;
}
- stream << CompiledExpression< std::complex, const double*, int>( amplitude , "AMP" ) << std::endl;
- stream << CompiledExpression< double, const double*, int>(fcn::norm(amplitude) / normalisation, "FCN" ) << std::endl;
+ stream << CompiledExpression< std::complex, const double*, const int&>( amplitude , "AMP" ) << std::endl;
+ stream << CompiledExpression< double, const double*, const int&>(fcn::norm(amplitude) / normalisation, "FCN" ) << std::endl;
if( includePythonBindings ){
stream << CompiledExpression< unsigned int >( m_matrixElements.size(), "matrix_elements_n" ) << std::endl;
stream << CompiledExpression< double > ( normalisation, "normalization") << std::endl;
diff --git a/src/CompiledExpressionBase.cpp b/src/CompiledExpressionBase.cpp
index e6dc28c1dad..2dccb1bb01f 100644
--- a/src/CompiledExpressionBase.cpp
+++ b/src/CompiledExpressionBase.cpp
@@ -81,9 +81,9 @@ void CompiledExpressionBase::to_stream( std::ostream& stream ) const
if( m_db.size() !=0 ) stream << "#include\n";
stream << "extern \"C\" const char* " << progName() << "_name() { return \"" << m_name << "\"; } \n";
bool enable_cuda = NamedParameter("UseCUDA",false);
- size_t sizeOfStream = 0;
+ size_t sizeOfStream = 0;
if( !enable_cuda ){
- stream << "#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wreturn-type-c-linkage\"\n";
+// stream << "#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wreturn-type-c-linkage\"\n";
stream << "extern \"C\" " << returnTypename() << " " << progName() << "(" << fcnSignature() << "){\n";
addDependentExpressions( stream , sizeOfStream );
stream << "return " << m_obj.to_string(m_resolver) << ";\n}\n";
@@ -96,7 +96,7 @@ void CompiledExpressionBase::to_stream( std::ostream& stream ) const
}
if( NamedParameter("IncludePythonBindings", false) == true ){
- stream << "#pragma clang diagnostic pop\n\n";
+// stream << "#pragma clang diagnostic pop\n\n";
stream << "extern \"C\" void " << progName() << "_c" << "(double *real, double *imag, " << fcnSignature() << "){\n";
stream << " auto val = " << progName() << "(" << args() << ") ;\n";
stream << " *real = val.real();\n";
diff --git a/src/CompilerWrapper.cpp b/src/CompilerWrapper.cpp
index ff8bc927fc0..5aae70ebe37 100644
--- a/src/CompilerWrapper.cpp
+++ b/src/CompilerWrapper.cpp
@@ -18,7 +18,7 @@
#include "AmpGen/MsgService.h"
#include "AmpGen/Utilities.h"
#include "AmpGen/CompiledExpressionBase.h"
-#include "AmpGen/Version.h"
+#include "AmpGenVersion.h"
using namespace AmpGen;
@@ -128,6 +128,8 @@ void CompilerWrapper::compileSource( const std::string& fname, const std::string
"-rdynamic",
"-fPIC"};
for( auto& flag : compile_flags ) argp.push_back( flag.c_str() );
+ if( m_cxx.find("clang") != std::string::npos )
+ argp.push_back( "-Wno-return-type-c-linkage");
argp.push_back( fname.c_str() );
argp.push_back( "-o");
@@ -156,7 +158,7 @@ void CompilerWrapper::preamble( std::ostream& os ) const
time_t now = time(0);
char* dt = ctime(&now);
os << "/** Generated by " << getenv("USER") << " on " << dt ;
- os << " AmpGen v" << AMPGEN_VERSION_MAJOR << "." << AMPGEN_VERSION_MINOR << '\n';
+ os << " AmpGen v" << AMPGEN_MAJOR_VERSION << "." << AMPGEN_MINOR_VERSION << '\n';
#if defined(__clang__)
os << " clang v" << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
#elif defined(__ICC) || defined(__INTEL_COMPILER)
diff --git a/src/Expression.cpp b/src/Expression.cpp
index 6ad9d69f368..b1bec427576 100644
--- a/src/Expression.cpp
+++ b/src/Expression.cpp
@@ -148,14 +148,6 @@ Expression AmpGen::operator/( const Expression& A, const Expression& B )
if( is( as_prod.l() ) ) return ( Constant( 1./as_prod.l()() ) * A )/ as_prod.r();
if( is( as_prod.r() ) ) return ( Constant( 1./as_prod.r()() ) * A )/ as_prod.l();
}
-// else if( is(A) ) {
-// auto A_divide = cast(A);
-// if( is(B) ){
-// auto B_divide = cast(B);
-// return Divide( A_divide.l() * B_divide.r() , ( A_divide.r() * B_divide.l() ) );
-// }
-// return A_divide.l() * B / A_divide.r() ;
-// }
else if( is(B) ) return ( A * cast(B).r() ) / cast(B).l();
else if( is(B) ) return ( A * fcn::isqrt( cast(B).arg() ) );
return Expression( Divide( A, B ) );
@@ -166,12 +158,10 @@ Expression AmpGen::operator==( const Expression& A, const Expression& B ){ retur
Expression AmpGen::operator==( const double& A, const Expression& B ){ return Constant(A) == B ; }
Expression AmpGen::operator==( const Expression& A, const double& B ){ return A == Constant(B) ; }
-Parameter::Parameter( const std::string& name, const double& defaultValue, const bool& resolved,
- const unsigned int& fromArg )
+Parameter::Parameter( const std::string& name, const double& defaultValue, const bool& resolved)
: m_name( name )
, m_defaultValue( defaultValue )
, m_resolved( resolved )
- , m_fromArg( fromArg )
{
}
diff --git a/src/Particle.cpp b/src/Particle.cpp
index 900bfb04e52..f5b133f32f9 100644
--- a/src/Particle.cpp
+++ b/src/Particle.cpp
@@ -213,9 +213,9 @@ Tensor Particle::P() const
if ( m_index != 999 ) {
const std::string index = std::to_string( m_index );
Tensor rt( std::vector( {
- Parameter( index + "_Px", 0, false, 1 ),
- Parameter( index + "_Py", 0, false, 1 ),
- Parameter( index + "_Pz", 0, false, 1 ), 0 } ) , {4} );
+ Parameter(index + "_Px"),
+ Parameter(index + "_Py"),
+ Parameter(index + "_Pz"), 0 }) , Tensor::dim(4) );
rt[3] = make_cse( fcn::sqrt( mass()*mass() + rt[0]*rt[0] + rt[1]*rt[1] + rt[2]*rt[2] ) );
// Parameter( index + "_E" , 0, false, 1 )} ),
return rt;
diff --git a/src/PolarisedSum.cpp b/src/PolarisedSum.cpp
index 974a70d0859..43b3113a612 100644
--- a/src/PolarisedSum.cpp
+++ b/src/PolarisedSum.cpp
@@ -294,7 +294,7 @@ void PolarisedSum::generateSourceCode(const std::string& fname, const double& no
auto dim = m_eventType.dim();
size_t size = dim.first * dim.second;
CompilerWrapper().preamble( stream );
- Expression event = Parameter("x0",0,true,0);
+ Expression event = Parameter("x0",0,true);
std::vector expressions(size);
for( auto& p : m_matrixElements ){
p.pdf.prepare();
diff --git a/src/Utilities.cpp b/src/Utilities.cpp
index 8fe89b8f0a3..066d63c8d85 100644
--- a/src/Utilities.cpp
+++ b/src/Utilities.cpp
@@ -1,5 +1,5 @@
#include "AmpGen/Utilities.h"
-#include "AmpGen/Version.h"
+#include "AmpGenVersion.h"
#include
#include
#include
From 705a6f1aca432fd669b02d43165123ff26c55f89 Mon Sep 17 00:00:00 2001
From: tevans1260
Date: Wed, 3 Apr 2019 18:35:59 +0200
Subject: [PATCH 051/250] Fix AMPGEN_MAJOR/MINOR_VERSION and include fix for
gaudi builds
---
src/CompilerWrapper.cpp | 3 ++-
src/Utilities.cpp | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/CompilerWrapper.cpp b/src/CompilerWrapper.cpp
index 5aae70ebe37..14a9957d8c8 100644
--- a/src/CompilerWrapper.cpp
+++ b/src/CompilerWrapper.cpp
@@ -33,7 +33,8 @@ CompilerWrapper::CompilerWrapper( const bool& verbose ) :
INFO( "Using original compiler; set global variable CXX if another needed: " << AMPGEN_CXX );
m_cxx = AMPGEN_CXX;
#else
- ERROR( "No configured compiler; set global variable CXX" );
+ m_cxx = getenv("AMPGEN_CXX") != nullptr ? std::string( getenv( "AMPGEN_CXX" ) ) : "";
+ if( m_cxx == "" ) ERROR( "No configured compiler; set global variable CXX" );
#endif
}
}
diff --git a/src/Utilities.cpp b/src/Utilities.cpp
index 066d63c8d85..81c90ee59ab 100644
--- a/src/Utilities.cpp
+++ b/src/Utilities.cpp
@@ -271,7 +271,7 @@ void AmpGen::printSplash()
std::cout << " ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝" << std::endl;
std::cout << "\033[0m\n";
std::cout << bold_on <<
- " version " << AMPGEN_VERSION_MAJOR << "." << AMPGEN_VERSION_MINOR << std::endl;
+ " version " << AMPGEN_MAJOR_VERSION << "." << AMPGEN_MINOR_VERSION << std::endl;
std::cout << " build: " ;
#if defined(__clang__)
std::cout << "clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
From c4fe59bbaf6eb9ecda37d4c5f47f3bbc4e890c59 Mon Sep 17 00:00:00 2001
From: tevans1260
Date: Wed, 10 Apr 2019 22:47:24 +0200
Subject: [PATCH 052/250] Fixed problems with spin-one polarisation vectors,
improved LASS instructions
---
AmpGen/ASTResolver.h | 2 +-
AmpGen/Array.h | 2 +-
AmpGen/CompiledExpression.h | 6 +-
AmpGen/Expression.h | 18 ++--
AmpGen/ExpressionParser.h | 4 +-
AmpGen/Lineshapes.h | 31 ++++++-
AmpGen/Spline.h | 2 +-
AmpGen/Tensor.h | 5 +-
AmpGen/Utilities.h | 2 +-
AmpGen/Wigner.h | 7 +-
apps/DataConverter.cpp | 7 +-
apps/Fitter.cpp | 14 ++--
apps/Generator.cpp | 1 +
options/FitterExample.opt | 55 -------------
src/ASTResolver.cpp | 36 ++++----
src/Array.cpp | 2 +-
src/BinaryExpression.cpp | 2 +-
src/CompiledExpressionBase.cpp | 14 +++-
src/CompilerWrapper.cpp | 2 -
src/EventType.cpp | 22 +++--
src/Expression.cpp | 12 +--
src/ExpressionParser.cpp | 4 +-
src/Particle.cpp | 71 ++++++++--------
src/PolarisedSum.cpp | 5 +-
src/Spline.cpp | 2 +-
src/Tensor.cpp | 2 +-
src/Transform.cpp | 1 -
src/UnaryExpression.cpp | 2 +-
src/Wigner.cpp | 145 ++++++++++++++-------------------
29 files changed, 225 insertions(+), 253 deletions(-)
diff --git a/AmpGen/ASTResolver.h b/AmpGen/ASTResolver.h
index 9513347ac84..a12e3878466 100644
--- a/AmpGen/ASTResolver.h
+++ b/AmpGen/ASTResolver.h
@@ -29,7 +29,7 @@ namespace AmpGen {
bool hasSubExpressions() const;
void reduceSubTrees();
void cleanup();
- void getOrderedSubExpressions( Expression& expression, std::vector>& dependentSubexpressions );
+ std::vector> getOrderedSubExpressions( const Expression& expression);
template void resolve( const TYPE& obj ){}
template size_t addCacheFunction( const std::string& name, const ARGS&... args )
diff --git a/AmpGen/Array.h b/AmpGen/Array.h
index 3074ea524cf..f53d5ea39ab 100644
--- a/AmpGen/Array.h
+++ b/AmpGen/Array.h
@@ -26,7 +26,7 @@ namespace AmpGen
public:
Array( const Expression& top, const size_t& size, const Expression& address = 0 );
std::string to_string(const ASTResolver* resolver=nullptr) const override ;
- void resolve( ASTResolver& resolver ) override;
+ void resolve( ASTResolver& resolver ) const override;
operator Expression();
complex_t operator()() const override;
Expression operator[]( const Expression& address ) const;
diff --git a/AmpGen/CompiledExpression.h b/AmpGen/CompiledExpression.h
index 05519e197b6..16561600289 100644
--- a/AmpGen/CompiledExpression.h
+++ b/AmpGen/CompiledExpression.h
@@ -154,10 +154,10 @@ namespace AmpGen
void debug( const double* event ) const
{
if ( !m_fcn.isLinked() ) {
- ERROR( "Function " << name() << " not linked" );
+ FATAL( "Function " << name() << " not linked" );
}
if ( !m_fdb.isLinked() ) {
- ERROR( "Function" << name() << " debugging symbols not linked" );
+ FATAL( "Function" << name() << " debugging symbols not linked" );
}
auto debug_results = m_fdb( &( m_externals[0] ), event );
for( auto& debug_result : debug_results ){
@@ -174,7 +174,7 @@ namespace AmpGen
const std::string symbol = progName() ;
if ( m_fcn.set( handle, symbol ) == 0 ) {
ERROR( dlerror() );
- ERROR( name() << " (symbol = " << symbol << ") linking fails" );
+ FATAL( name() << " (symbol = " << symbol << ") linking fails" );
return false;
}
if ( m_db.size() ==0 ) return true;
diff --git a/AmpGen/Expression.h b/AmpGen/Expression.h
index 3b5e88e9e8c..b9856d6d100 100644
--- a/AmpGen/Expression.h
+++ b/AmpGen/Expression.h
@@ -114,7 +114,7 @@ namespace AmpGen
/// Resolve the dependencies of a tree using an ASTResolver,
/// which keeps track of parameters, dependent sub-trees, etc.
/// \param resolver resolver object to use
- virtual void resolve( ASTResolver& resolver ) = 0;
+ virtual void resolve( ASTResolver& resolver ) const = 0;
/// virtual descructor
virtual ~IExpression() = default;
/// Evaluate the expression using the tree,
@@ -134,7 +134,7 @@ namespace AmpGen
~Expression() = default;
std::string to_string(const ASTResolver* resolver=nullptr) const;
IExpression* get() const;
- void resolve( ASTResolver& resolver );
+ void resolve( ASTResolver& resolver ) const;
Expression operator+=( const Expression& other ) const;
Expression operator*=( const Expression& other ) const;
Expression operator-=( const Expression& other ) const;
@@ -157,7 +157,7 @@ namespace AmpGen
Constant( const complex_t& value ) : m_value(value) {}
std::string to_string(const ASTResolver* resolver=nullptr) const override;
- void resolve( ASTResolver& resolver ) override;
+ void resolve( ASTResolver& resolver ) const override;
operator Expression() const;
complex_t operator()() const override { return m_value; }
private:
@@ -177,7 +177,7 @@ namespace AmpGen
const double& defaultValue = 0 ,
const bool& resolved = false);
std::string to_string(const ASTResolver* resolver = nullptr) const override;
- void resolve( ASTResolver& resolver ) override;
+ void resolve( ASTResolver& resolver ) const override;
operator Expression() const;
complex_t operator()() const override { return complex_t( m_defaultValue, 0 ); }
std::string name() const { return m_name; }
@@ -200,7 +200,7 @@ namespace AmpGen
struct Ternary : public IExpression {
Ternary( const Expression& cond, const Expression& v1, const Expression& v2 );
std::string to_string(const ASTResolver* resolver = nullptr ) const override;
- void resolve( ASTResolver& resolver ) override;
+ void resolve( ASTResolver& resolver ) const override;
operator Expression() const ;
complex_t operator()() const override { return std::real(m_cond()) ? m_v1() : m_v2(); }
Expression m_cond;
@@ -212,7 +212,7 @@ namespace AmpGen
struct SubTree : public IExpression {
SubTree( const Expression& other ) ;
std::string to_string(const ASTResolver* resolver = nullptr ) const override ;
- void resolve( ASTResolver& resolver ) override;
+ void resolve( ASTResolver& resolver ) const override;
operator Expression() const ;
complex_t operator()() const override { return m_expression(); }
uint64_t key() const;
@@ -224,7 +224,7 @@ namespace AmpGen
struct Function : public IExpression {
Function( const std::string& name, const std::vector& args ) ;
std::string to_string(const ASTResolver* resolver = nullptr ) const override ;
- void resolve( ASTResolver& resolver ) override;
+ void resolve( ASTResolver& resolver ) const override;
operator Expression() const ;
complex_t operator()() const override { return 0; }
std::string m_name;
@@ -236,7 +236,7 @@ namespace AmpGen
class IBinaryExpression : public IExpression {
public:
IBinaryExpression( const Expression& l, const Expression& r ) : lval( l ), rval( r ){};
- void resolve( ASTResolver& resolver ) override;
+ void resolve( ASTResolver& resolver ) const override;
complex_t operator()() const override = 0;
Expression l() const { return lval ; }
Expression r() const { return rval ; }
@@ -288,7 +288,7 @@ namespace AmpGen
class IUnaryExpression : public IExpression {
public:
IUnaryExpression( const Expression& other ) : m_expression( other ){};
- void resolve( ASTResolver& resolver ) override;
+ void resolve( ASTResolver& resolver ) const override;
complex_t operator()() const override = 0;
virtual Expression d() const = 0;
Expression arg() const { return m_expression ;}
diff --git a/AmpGen/ExpressionParser.h b/AmpGen/ExpressionParser.h
index 5f18e924dc0..42c789575c0 100644
--- a/AmpGen/ExpressionParser.h
+++ b/AmpGen/ExpressionParser.h
@@ -20,7 +20,7 @@ namespace AmpGen
public:
MinuitParameterLink( MinuitParameter* param ) ;
std::string to_string(const ASTResolver* resolver=nullptr) const override ;
- void resolve( ASTResolver& resolver ) override ;
+ void resolve( ASTResolver& resolver ) const override ;
complex_t operator()() const override ;
operator Expression() const ;
std::string name() const;
@@ -33,7 +33,7 @@ namespace AmpGen
ExpressionPack( const std::vector& expressions ){ m_expressions = expressions ; }
ExpressionPack( const Expression& A, const Expression& B );
std::string to_string(const ASTResolver* resolver=nullptr) const override;
- void resolve( ASTResolver& resolver ) override;
+ void resolve( ASTResolver& resolver ) const override;
complex_t operator()() const override;
operator Expression() const ;
private:
diff --git a/AmpGen/Lineshapes.h b/AmpGen/Lineshapes.h
index 72c2119ef49..ecbe98d3a7c 100644
--- a/AmpGen/Lineshapes.h
+++ b/AmpGen/Lineshapes.h
@@ -194,9 +194,36 @@ namespace AmpGen
normally associated to the @f$ K^*(1430)^{0} @f$ resonance.
The total amplitude is therefore:
@f[
- \mathcal{A}(s) = \frac{2 a \sqrt{s} }{ 2 + arq^2 - 2iaq} + \frac{2+arq^2 + 2iaq}{2+arq^2 - 2iaq }\mathcal{A}_{BW}(s).
+ \mathcal{A}(s) = \frac{2 a \sqrt{s} }{ 2 + arq^2 - 2iaq} + \frac{2+arq^2 + 2iaq}{2+arq^2 - 2iaq }\mathcal{A}_{BW}(s) = \mathcal{A}_{NR}(s) + \mathcal{A}^{\prime}_{BW}(s).
+ @f]
+ As this expression somewhat resembles the sum of a Breit-Wigner with a slowly varying nonresonant component, the two parts are sometimes split apart with an additional production amplitude placed on one or the other.
+ These can be accessed separately using the modifiers LASS.BW and LASS.NR, and given independent coupling constants. From the user interface:
+ \code{.cpp}
+ K*(1430)bar0[LASS.NR]{K-,pi+} 0 2.0 0.1 0 -90 0.1
+ K*(1430)bar0[LASS.BW]{K-,pi+} 0 1.5 0.1 0 20 0.1
+ \endcode
+ Corresponds to the overall lineshape:
+ @f[
+ \mathcal{A}(s)
+ = \left(\texttt{K*(1430)bar0[LASS.NR]{K-,pi+}}\right) \mathcal{A}_{NR}(s) +
+ \left(\texttt{K*(1430)bar0[LASS.BW]{K-,pi+}}\right) \mathcal{A}^{\prime}_{BW}(s)
+ = 2.0 e^{-90^\mathrm{o}} \mathcal{A}_{NR}(s) + 1.5 e^{-20^\mathrm{o}} \mathcal{A}^{\prime}_{BW}(s).
+ @f]
+ An alternative way to introduce a different coupling between the two components is to fix one coupling and to introduce an additional production coupling.
+ In the user interface, this might for example in @f$ D^{0} \to K^{-} \pi^{+} \pi^{0} @f$ decays:
+ \code{.cpp}
+ D0{K*(1430)bar0,pi0} 0 1.3 0.0 0 15 0.1
+ K*(1430)bar0[LASS.NR]{K-,pi+} 0 2.0 0.1 0 -90 0.1
+ K*(1430)bar0[LASS.BW]{K-,pi+} 2 1.0 0.0 0 0 0.0
+ \endcode
+ Then the lineshape with production couplings will be:
+ @f[
+ \mathcal{A}(s)
+ = \left(\texttt{D0{K*(1430)bar0,pi0}}\right)\left(
+ = \left(\texttt{K*(1430)bar0[LASS.NR]{K-,pi+}}\right) \mathcal{A}_{NR}(s) +
+ \mathcal{A}^{\prime}_{BW}(s) \right)
+ = 1.3 e^{15^\mathrm{o}} \left( 2.0 e^{-90^\mathrm{o}} \mathcal{A}_{NR}(s) + \mathcal{A}^{\prime}_{BW}(s) \right).
@f]
- As this expression somewhat resembles the sum of a Breit-Wigner with a slowly varying nonresonant component, the two parts are sometimes split apart with an additional production amplitude placed on one or the other. These can be accessed separately using the modifiers LASS.BW and LASS.NR.
Parameter | User name | Description
-----------------------|--------------------------------------|------------------------------------------------------------------------
diff --git a/AmpGen/Spline.h b/AmpGen/Spline.h
index bed74747e21..30f44280ddd 100644
--- a/AmpGen/Spline.h
+++ b/AmpGen/Spline.h
@@ -63,7 +63,7 @@ namespace AmpGen{
const double& max );
Spline( const Spline& spline, const Expression& x );
- void resolve( ASTResolver& resolver ) override ;
+ void resolve( ASTResolver& resolver ) const override ;
std::string to_string(const ASTResolver* resolver=nullptr) const override;
operator Expression() ;
complex_t operator()() const override ;
diff --git a/AmpGen/Tensor.h b/AmpGen/Tensor.h
index f79646e9c1e..45d88b8a8e9 100644
--- a/AmpGen/Tensor.h
+++ b/AmpGen/Tensor.h
@@ -91,7 +91,6 @@ namespace AmpGen
Tensor operator-() const;
void st(const bool simplify=false);
-
bool rankMatches( const Tensor& other );
void imposeSymmetry( size_t indexA, size_t indexB);
@@ -137,7 +136,7 @@ namespace AmpGen
auto up = std::tuple(args...);
for_each(up, [&rt]( auto& f ) { rt.emplace_back(f); } );
return rt;
- }
+ }
private:
std::vector m_dim;
std::vector m_symmetrisedCoordinates;
@@ -173,7 +172,7 @@ namespace AmpGen
public:
TensorExpression( const Tensor& tensor );
std::string to_string(const ASTResolver* resolver) const override;
- void resolve( ASTResolver& resolver ) override;
+ void resolve( ASTResolver& resolver ) const override;
complex_t operator()() const override;
operator Expression() const;
diff --git a/AmpGen/Utilities.h b/AmpGen/Utilities.h
index 61355707978..72208c55c0f 100644
--- a/AmpGen/Utilities.h
+++ b/AmpGen/Utilities.h
@@ -111,7 +111,7 @@ namespace AmpGen {
auto size = std::snprintf(nullptr, 0, format.c_str(), std::forward(args)...);
std::string output(size+1,'\0');
std::sprintf(&output[0],format.c_str(), std::forward(args)...);
- return output;
+ return output.substr(0, output.size()-1);
}
diff --git a/AmpGen/Wigner.h b/AmpGen/Wigner.h
index be44e8a08b5..18dbe8ec5d6 100644
--- a/AmpGen/Wigner.h
+++ b/AmpGen/Wigner.h
@@ -22,17 +22,18 @@ class Particle;
const double& J,
const double& M );
- /** @ingroup Vertices function helicityTransformMatrix
- Generates a helicity transform tensor (matrix) that aligns tensor P (four-vector) to the +/- ve z-axis, then boosts to the rest frame.
+ /** @ingroup Vertices function wickTransform
+ Generates a wick transform sequence that aligns tensor P (four-vector) to the +/- ve z-axis, then boosts to the rest frame.
The mass may be seperately specified. The parameter ve specifies whether the initial Euler rotation is to the +/- z-axis.
In the case where ve =-1, a second rotation is applied about the x-axis that aligns P to the +ve z-axis.
This ensures that singly and doubly primed helicity frames remain orthonormal.
*/
- TransformSequence helicityTransformMatrix( const Tensor& P, const Expression& M, const int& ve =1, const bool& handleZeroCase = false );
+ TransformSequence wickTransform(const Tensor& P, const Expression& M, const int& ve =1, const bool& handleZeroCase = false);
Expression helicityAmplitude( const Particle& particle, const TransformSequence& parentFrame, const double& Mz, DebugSymbols* db , const int sgn=1);
Tensor basisSpinor(const int& polState, const int& id);
+ Tensor basisVector(const int& polState);
struct LS {
double factor;
diff --git a/apps/DataConverter.cpp b/apps/DataConverter.cpp
index 815e824599e..11081dc2a08 100644
--- a/apps/DataConverter.cpp
+++ b/apps/DataConverter.cpp
@@ -49,6 +49,7 @@ int main( int argc, char* argv[] )
std::vector particles = NamedParameter("ParticleNames" , std::vector() ).getVector();
std::vector monitorBranches = NamedParameter("Monitors" , std::vector() ).getVector();
std::vector branchFormat = NamedParameter("BranchFormat" , std::vector() ).getVector();
+ std::vector friends = NamedParameter("Friends" , std::vector() ).getVector();
bool usePIDCalib = NamedParameter("usePIDCalib" , false );
bool rejectMultipleCandidates = NamedParameter("rejectMultipleCandidates", true );
std::string cuts = vectorToString( NamedParameter("Cut","").getVector() , " && ");
@@ -61,6 +62,10 @@ int main( int argc, char* argv[] )
TTree* in_tree = (TTree*)f->Get( treeName.c_str() );
in_tree->SetBranchStatus( "*", 1 );
+ for( auto& frie : friends ){
+ auto tokens = split( frie, ':');
+ in_tree->AddFriend( tokens[1].c_str(), tokens[0].c_str() );
+ }
INFO( "Using cut = " << cuts );
@@ -125,7 +130,7 @@ int main( int argc, char* argv[] )
}
}
- EventList evts( in_tree, evtType, Branches(branches), EntryList(eventsToTake), GetGenPdf(false));
+ EventList evts( in_tree, evtType, Branches(branches), EntryList(eventsToTake), GetGenPdf(false), ApplySym(true) );
INFO( "Branches = ["<< vectorToString(branches, ", " ) << "]" );
diff --git a/apps/Fitter.cpp b/apps/Fitter.cpp
index 3e8396388ba..1a929991817 100644
--- a/apps/Fitter.cpp
+++ b/apps/Fitter.cpp
@@ -135,13 +135,14 @@ FitResult* doFit( PDF&& pdf, EventList& data, EventList& mc, MinuitParameterSet&
if ( makePlots ) {
auto ep = fr->getErrorPropagator();
+ const size_t NBins = NamedParameter ("nBins" , 100 , "Number of bins used for plotting.");
unsigned int counter = 1;
for_each( pdf.m_pdfs, [&]( auto& f ) {
std::function FCN_sig =
[&](const Event& evt){ return f.prob_unnormalised(evt) ; };
auto tStartIntegral2 = std::chrono::high_resolution_clock::now();
- auto mc_plot3 = mc.makeProjections( mc.eventType().defaultProjections(100), WeightFunction(f), Prefix("tMC_Category"+std::to_string(counter) ) );
+ auto mc_plot3 = mc.makeProjections( mc.eventType().defaultProjections(NBins), WeightFunction(f), Prefix("tMC_Category"+std::to_string(counter) ) );
// auto mc_plot3 = bandPlot<100>( mc, "tMC_Category" + std::to_string( counter ) + "_", f, ep );
auto tEndIntegral2 = std::chrono::high_resolution_clock::now();
@@ -233,10 +234,13 @@ int main( int argc, char* argv[] )
EventList events( dataFile, !BAR ? evtType : evtType.conj() , CacheSize(defaultCacheSize), Filter(cut) );
EventList eventsMC = mcFile == "" ? EventList( evtType) : EventList( mcFile, !BAR ? evtType : evtType.conj() , CacheSize(defaultCacheSize), Filter(simCut) ) ;
- auto scale_transform = [](auto& event){ for( size_t x = 0 ; x < event.size(); ++x ) event[x] /= 1000.; };
- INFO("Changing units from MeV -> GeV");
- events.transform( scale_transform );
- eventsMC.transform( scale_transform );
+
+ auto scale_transform = [](auto& event){ for( size_t x = 0 ; x < event.size(); ++x ) event[x] /= 1000.; };
+ if( NamedParameter("Units", "GeV").getVal() == "MeV") {
+ INFO("Changing units from MeV -> GeV");
+ events.transform( scale_transform );
+ }
+ eventsMC.transform( scale_transform );
INFO( "Data events: " << events.size() );
INFO( "MC events : " << eventsMC.size() );
diff --git a/apps/Generator.cpp b/apps/Generator.cpp
index a80592dfa41..804530fe7d0 100644
--- a/apps/Generator.cpp
+++ b/apps/Generator.cpp
@@ -107,6 +107,7 @@ int main( int argc, char** argv )
}
else if ( gen_type == "PolarisedSum" ){
PolarisedSum sig( eventType, MPS );
+
RecursivePhaseSpace phsp( sig.matrixElements()[0].decayTree.quasiStableTree() , eventType, &rand );
GenerateEvents( accepted, sig, phsp, nEvents, blockSize, &rand );
}
diff --git a/options/FitterExample.opt b/options/FitterExample.opt
index feeb9f67ece..7446b538bf3 100644
--- a/options/FitterExample.opt
+++ b/options/FitterExample.opt
@@ -106,58 +106,3 @@ a(1)(1260)+::Spline::Gamma::30 2 1.17885 0
a(1)(1260)+::Spline::Gamma::31 2 1.21615 0
a(1)(1260)+::Spline::Gamma::32 2 1.25246 0
a(1)(1260)+::Spline::Gamma::33 2 1.28789 0
-
-#K(1)(1270)bar-_mass 0 1270 1 1000 1500
-#K(1)(1270)bar-_width 0 90 1 50 200
-#
-#gLASS::F 0 1.0 1.34906e-01
-#gLASS::R 2 1.00000e+00 0
-#gLASS::a 2 0.224 3.46447e-03
-#gLASS::phiF 0 0.0 2.45733e-01
-#gLASS::phiR 0 0.0 3.14745e-02
-#gLASS::r 2 -15.01 1.49288e-01
-#
-#K(1)(1270)bar-::Spline::Min 0.613246
-#K(1)(1270)bar-::Spline::Max 2.95978
-#K(1)(1270)bar-::Spline::N 40
-#K(1)(1270)bar-::Spline::Gamma::0 2 0.000162404 0
-#K(1)(1270)bar-::Spline::Gamma::1 2 0.00386694 0
-#K(1)(1270)bar-::Spline::Gamma::2 2 0.0128833 0
-#K(1)(1270)bar-::Spline::Gamma::3 2 0.0276225 0
-#K(1)(1270)bar-::Spline::Gamma::4 2 0.048283 0
-#K(1)(1270)bar-::Spline::Gamma::5 2 0.0748626 0
-#K(1)(1270)bar-::Spline::Gamma::6 2 0.107234 0
-#K(1)(1270)bar-::Spline::Gamma::7 2 0.145263 0
-#K(1)(1270)bar-::Spline::Gamma::8 2 0.188929 0
-#K(1)(1270)bar-::Spline::Gamma::9 2 0.238422 0
-#K(1)(1270)bar-::Spline::Gamma::10 2 0.294211 0
-#K(1)(1270)bar-::Spline::Gamma::11 2 0.357122 0
-#K(1)(1270)bar-::Spline::Gamma::12 2 0.428445 0
-#K(1)(1270)bar-::Spline::Gamma::13 2 0.510093 0
-#K(1)(1270)bar-::Spline::Gamma::14 2 0.604757 0
-#K(1)(1270)bar-::Spline::Gamma::15 2 0.715757 0
-#K(1)(1270)bar-::Spline::Gamma::16 2 0.845719 0
-#K(1)(1270)bar-::Spline::Gamma::17 2 0.993541 0
-#K(1)(1270)bar-::Spline::Gamma::18 2 1.15281 0
-#K(1)(1270)bar-::Spline::Gamma::19 2 1.31566 0
-#K(1)(1270)bar-::Spline::Gamma::20 2 1.47718 0
-#K(1)(1270)bar-::Spline::Gamma::21 2 1.63572 0
-#K(1)(1270)bar-::Spline::Gamma::22 2 1.79135 0
-#K(1)(1270)bar-::Spline::Gamma::23 2 1.94481 0
-#K(1)(1270)bar-::Spline::Gamma::24 2 2.09696 0
-#K(1)(1270)bar-::Spline::Gamma::25 2 2.24862 0
-#K(1)(1270)bar-::Spline::Gamma::26 2 2.40051 0
-#K(1)(1270)bar-::Spline::Gamma::27 2 2.55328 0
-#K(1)(1270)bar-::Spline::Gamma::28 2 2.70744 0
-#K(1)(1270)bar-::Spline::Gamma::29 2 2.86345 0
-#K(1)(1270)bar-::Spline::Gamma::30 2 3.02171 0
-#K(1)(1270)bar-::Spline::Gamma::31 2 3.18254 0
-#K(1)(1270)bar-::Spline::Gamma::32 2 3.34625 0
-#K(1)(1270)bar-::Spline::Gamma::33 2 3.51307 0
-#K(1)(1270)bar-::Spline::Gamma::34 2 3.68324 0
-#K(1)(1270)bar-::Spline::Gamma::35 2 3.85695 0
-#K(1)(1270)bar-::Spline::Gamma::36 2 4.03437 0
-#K(1)(1270)bar-::Spline::Gamma::37 2 4.21566 0
-#K(1)(1270)bar-::Spline::Gamma::38 2 4.40095 0
-#K(1)(1270)bar-::Spline::Gamma::39 2 4.59036 0
-#
diff --git a/src/ASTResolver.cpp b/src/ASTResolver.cpp
index 69a0b644e8e..c48f5d7fe0f 100644
--- a/src/ASTResolver.cpp
+++ b/src/ASTResolver.cpp
@@ -40,37 +40,35 @@ void ASTResolver::reduceSubTrees()
tempTrees.clear();
}
-void ASTResolver::getOrderedSubExpressions(
- Expression& expression,
- std::vector< std::pair< uint64_t,Expression>>& dependentSubexpressions )
+std::vector> ASTResolver::getOrderedSubExpressions( const Expression& expression )
{
+ std::vector> subexpressions;
expression.resolve( *this );
- std::map< uint64_t , size_t> used_functions;
- for( size_t i = 0 ; i < dependentSubexpressions.size(); ++i )
- used_functions[ dependentSubexpressions[i].first ] = i;
+ std::map used_functions;
do {
reduceSubTrees();
- for( auto& expression : subTrees ) {
- expression.second.resolve( *this );
- auto stack_pos = used_functions.find( expression.first );
+ bool verbose = false;
+ for( auto& st : subTrees ) {
+ st.second.resolve( *this );
+ auto stack_pos = used_functions.find( st.first );
if ( stack_pos == used_functions.end() ) {
- dependentSubexpressions.emplace_back( expression.first , expression.second );
- used_functions[expression.first] = dependentSubexpressions.size() - 1;
+ if( verbose ) INFO("Function: " << st.first << " is at the end of stack");
+ subexpressions.emplace_back( st.first , st.second );
+ used_functions[st.first] = subexpressions.size() - 1;
continue;
}
- unsigned int oldPos = stack_pos->second;
- auto it = dependentSubexpressions.begin() + oldPos;
- if ( it == dependentSubexpressions.end() - 1 ) continue;
-
- std::rotate( it, it + 1, dependentSubexpressions.end() );
-
+ auto oldPos = stack_pos->second;
+ auto it = subexpressions.begin() + oldPos;
+ if ( it == subexpressions.end() - 1 ) continue;
+ std::rotate( it, it + 1, subexpressions.end() );
for ( auto uf = used_functions.begin(); uf != used_functions.end(); ++uf ) {
if ( uf->second >= oldPos ) uf->second = uf->second - 1;
}
- used_functions[expression.first] = dependentSubexpressions.size() - 1;
+ used_functions[st.first] = subexpressions.size() - 1;
}
} while ( hasSubExpressions() );
- std::reverse( dependentSubexpressions.begin(), dependentSubexpressions.end() );
+ std::reverse( subexpressions.begin(), subexpressions.end() );
+ return subexpressions;
}
template <> void ASTResolver::resolve( const SubTree& subTree )
diff --git a/src/Array.cpp b/src/Array.cpp
index c24cc378388..f4bdb97412a 100644
--- a/src/Array.cpp
+++ b/src/Array.cpp
@@ -31,7 +31,7 @@ std::string Array::to_string(const ASTResolver* resolver) const {
else return head +"[ int("+offset+")]";
}
-void Array::resolve( ASTResolver& resolver )
+void Array::resolve( ASTResolver& resolver ) const
{
m_top.resolve( resolver );
m_address.resolve( resolver );
diff --git a/src/BinaryExpression.cpp b/src/BinaryExpression.cpp
index eeb1c5e2d3a..f249e3bbdd9 100644
--- a/src/BinaryExpression.cpp
+++ b/src/BinaryExpression.cpp
@@ -64,7 +64,7 @@ std::string Pow::to_string(const ASTResolver* resolver) const { return "
std::string Fmod::to_string(const ASTResolver* resolver) const { return "fmod(" + lval.to_string(resolver) + "," + rval.to_string(resolver) +")"; }
std::string ATan2::to_string( const ASTResolver* resolver) const { return "atan2("+ lval.to_string(resolver) + "," + rval.to_string(resolver) +")"; }
-void IBinaryExpression::resolve( ASTResolver& resolver )
+void IBinaryExpression::resolve( ASTResolver& resolver ) const
{
lval.resolve( resolver );
rval.resolve( resolver );
diff --git a/src/CompiledExpressionBase.cpp b/src/CompiledExpressionBase.cpp
index 2dccb1bb01f..5edb7ee0049 100644
--- a/src/CompiledExpressionBase.cpp
+++ b/src/CompiledExpressionBase.cpp
@@ -30,10 +30,16 @@ void CompiledExpressionBase::resolve(const MinuitParameterSet* mps)
{
if( m_resolver != nullptr ) delete m_resolver ;
m_resolver = new ASTResolver( m_evtMap, mps );
- m_resolver->getOrderedSubExpressions( m_obj, m_dependentSubexpressions );
- for ( auto& sym : m_db ){
- sym.second.resolve( *m_resolver );
- m_resolver->getOrderedSubExpressions( sym.second, m_debugSubexpressions );
+ m_dependentSubexpressions = m_resolver->getOrderedSubExpressions( m_obj );
+ for ( auto& sym : m_db ){
+ auto expressions_for_this = m_resolver->getOrderedSubExpressions( sym.second);
+ for( auto& it : expressions_for_this ){
+ bool isAlreadyInStack = false;
+ for( auto& jt : m_debugSubexpressions ){
+ if( it.first == jt.first ){ isAlreadyInStack = true; break ; }
+ }
+ if( !isAlreadyInStack ) m_debugSubexpressions.push_back( it );
+ }
}
m_cacheTransfers.clear();
for( auto& expression : m_resolver->cacheFunctions() )
diff --git a/src/CompilerWrapper.cpp b/src/CompilerWrapper.cpp
index 14a9957d8c8..4401b198b4d 100644
--- a/src/CompilerWrapper.cpp
+++ b/src/CompilerWrapper.cpp
@@ -103,7 +103,6 @@ bool CompilerWrapper::compile( std::vector& expressions
for ( auto& include : m_includes ) output << "#include <" << include << ">\n";
for ( auto& expression : expressions ) output << *expression << std::endl;
output.close();
-
compileSource( cname, oname );
for( auto& expression : expressions ) expression->link( oname );
auto twall_end = std::chrono::high_resolution_clock::now();
@@ -169,6 +168,5 @@ void CompilerWrapper::preamble( std::ostream& os ) const
#endif
os << '\n';
os << "*/\n";
-
for ( auto& include : m_includes ) os << "#include <" << include << ">\n";
}
diff --git a/src/EventType.cpp b/src/EventType.cpp
index 8ee8d7d9faa..79f89b6a0b3 100644
--- a/src/EventType.cpp
+++ b/src/EventType.cpp
@@ -153,11 +153,12 @@ std::vector EventType::defaultProjections(const size_t& nBins) const
"s" + vectorToString( indices ),
"s_{" + label( indices, useRootLabelling ) + "}", nBins,
( mm.first - 0.05 ) , ( mm.second + 0.05 ) , gevcccc );
- else if( defaultObservable == "mass" )
+ else if( defaultObservable == "mass" ){
axes.emplace_back( [indices]( const Event& evt ) { return sqrt( evt.s( indices ) ); },
"m" + vectorToString( indices ),
"m_{" + label( indices, useRootLabelling ) + "}", nBins,
- sqrt( mm.first - 0.05 ) , sqrt( mm.second + 0.05 ) , gevcc );
+ mm.first > 0.05 ? sqrt(mm.first - 0.05) :0 , sqrt( mm.second + 0.05 ) , gevcc );
+ }
}
}
return axes;
@@ -165,12 +166,21 @@ std::vector EventType::defaultProjections(const size_t& nBins) const
Projection EventType::projection(const size_t& nBins, const std::vector& indices) const
{
+ std::string defaultObservable = NamedParameter( "EventType::Observable", "mass2");
auto mm = minmax( indices, true );
std::string gevcccc = "\\mathrm{GeV}^{2}/c^{4}";
- return Projection( [indices]( const Event& evt ) { return evt.s( indices ); },
- "s" + vectorToString(indices),
- "s_{" + label(indices, false) + "}\\, \\left[" + gevcccc + "\\right]", nBins,
- ( mm.first - 0.05 ) , ( mm.second + 0.05 ) , gevcccc );
+ std::string gevcc = "\\mathrm{GeV}/c^{2}";
+ if( defaultObservable == "mass2" )
+ return Projection( [indices]( const Event& evt ) { return evt.s( indices ); },
+ "s" + vectorToString( indices ),
+ "s_{" + label( indices ) + "}", nBins,
+ ( mm.first - 0.05 ) , ( mm.second + 0.05 ) , gevcccc );
+ else if( defaultObservable == "mass" ){
+ return Projection( [indices]( const Event& evt ) { return sqrt( evt.s( indices ) ); },
+ "m" + vectorToString( indices ),
+ "m_{" + label( indices ) + "}", nBins,
+ mm.first > 0.05 ? sqrt(mm.first - 0.05) :0 , sqrt( mm.second + 0.05 ) , gevcc );
+ }
}
bool EventType::operator==( const EventType& other ) const
diff --git a/src/Expression.cpp b/src/Expression.cpp
index b1bec427576..544bf5e111f 100644
--- a/src/Expression.cpp
+++ b/src/Expression.cpp
@@ -188,11 +188,11 @@ Expression::Expression( const double& value ) : m_expression( std::make_shared( value ) ) {}
Expression::Expression() : m_expression( std::make_shared( 0. ) ) {}
-void Expression::resolve( ASTResolver& resolver ) { m_expression->resolve( resolver ); }
+void Expression::resolve( ASTResolver& resolver ) const { m_expression->resolve( resolver ); }
-void Constant::resolve( ASTResolver& resolver ) {}
+void Constant::resolve( ASTResolver& resolver ) const {}
-void Parameter::resolve( ASTResolver& resolver )
+void Parameter::resolve( ASTResolver& resolver ) const
{
if( !m_resolved ) resolver.resolve(*this);
}
@@ -206,7 +206,7 @@ std::string Ternary::to_string(const ASTResolver* resolver) const
return "(" + m_cond.to_string(resolver) + "?" + m_v1.to_string(resolver) + ":" + m_v2.to_string(resolver) + ")";
}
-void Ternary::resolve( ASTResolver& resolver )
+void Ternary::resolve( ASTResolver& resolver ) const
{
m_cond.resolve( resolver );
m_v1.resolve( resolver );
@@ -229,14 +229,14 @@ std::string Function::to_string(const ASTResolver* resolver) const {
for( auto& arg : m_args ) rt += arg.to_string(resolver) + ", ";
return rt.substr(0,rt.size()-2) + ")";
}
-void Function::resolve( ASTResolver& resolver ) {}
+void Function::resolve( ASTResolver& resolver ) const {}
std::string SubTree::to_string(const ASTResolver* /*resolver*/) const
{
return "v"+ std::to_string(key());
}
-void SubTree::resolve( ASTResolver& resolver )
+void SubTree::resolve( ASTResolver& resolver ) const
{
resolver.resolve( *this );
m_expression.resolve( resolver );
diff --git a/src/ExpressionParser.cpp b/src/ExpressionParser.cpp
index 172281e7251..5e7850f7bdb 100644
--- a/src/ExpressionParser.cpp
+++ b/src/ExpressionParser.cpp
@@ -134,7 +134,7 @@ std::string MinuitParameterLink::name() const {
return m_parameter->name();
}
-void MinuitParameterLink::resolve( ASTResolver& resolver )
+void MinuitParameterLink::resolve( ASTResolver& resolver ) const
{
resolver.resolve(*this);
}
@@ -165,7 +165,7 @@ std::string ExpressionPack::to_string(const ASTResolver* resolver) const
return rt.substr( 0, rt.length() - 2 );
}
-void ExpressionPack::resolve( ASTResolver& resolver )
+void ExpressionPack::resolve( ASTResolver& resolver ) const
{
for ( auto& expr : m_expressions ) expr.resolve( resolver );
}
diff --git a/src/Particle.cpp b/src/Particle.cpp
index f5b133f32f9..f72291aa046 100644
--- a/src/Particle.cpp
+++ b/src/Particle.cpp
@@ -28,6 +28,7 @@
#include "AmpGen/Types.h"
using namespace AmpGen;
+using namespace std::complex_literals;
Particle::Particle()
{
@@ -390,7 +391,8 @@ Expression Particle::getExpression( DebugSymbols* db, const unsigned int& index
{
FATAL("Invalid value for SpinFormalism: " << spinFormalism << ", possible values are: " << italic_on << " Covariant, Canonical." << italic_off );
}
- Expression total( 0 );
+ Expression total = 0;
+ Tensor::Index a;
auto finalStateParticles = getFinalStateParticles();
auto orderings = identicalDaughterOrderings();
bool doSymmetrisation = !hasModifier("NoSym");
@@ -410,16 +412,20 @@ Expression Particle::getExpression( DebugSymbols* db, const unsigned int& index
Tensor is = Bar( externalSpinTensor(m_polState) );
ADD_DEBUG_TENSOR( externalSpinTensor(m_polState), db );
ADD_DEBUG_TENSOR( st, db );
- Tensor::Index a;
if( st.size() != 4 ){
ERROR("Spin tensor is the wrong rank = " << st.dimString() );
spinFactor = 1;
}
else { spinFactor = is(a) * st(a) ; }
}
+ if( m_props->twoSpin() == 2 ){
+ Tensor is = externalSpinTensor(m_polState).conjugate();
+ ADD_DEBUG_TENSOR(is, db );
+ spinFactor = dot(is,st);
+ }
}
if ( includeSpin && spinFormalism == "Canonical" ){
- spinFactor = helicityAmplitude( *this, TransformSequence(), double(polState())/2.0, db );
+ spinFactor = helicityAmplitude(*this, TransformSequence(), m_props->isBoson() ? polState() : double(polState())/2.0, db);
}
if( db != nullptr ){
std::string finalStateString="";
@@ -479,35 +485,33 @@ Tensor Particle::externalSpinTensor(const int& polState, DebugSymbols* db ) cons
if ( spin() == 0 )
return Tensor( std::vector( {1.} ), std::vector( {1} ) );
Tensor p = P();
- Expression pX = p.get(0) ;
- Expression pY = p.get(1) ;
- Expression pZ = p.get(2) ;
- Expression pE = p.get(3) ;
+ Expression pX = p.get(0);
+ Expression pY = p.get(1);
+ Expression pZ = p.get(2);
+ Expression pE = p.get(3);
Expression pP = fcn::sqrt( pX*pX + pY*pY + pZ*pZ );
- Expression m = fcn::sqrt( dot( p, p ) );
- complex_t I(0,1);
- Expression z = pX + I*pY;
- Expression zb = pX - I*pY;
+ Expression m = mass();
+ Expression z = pX + 1i*pY;
+ Expression zb = pX - 1i*pY;
auto id = props()->pdgID();
if ( m_props->twoSpin() == 2 && m_spinBasis == "Weyl" ) {
- Expression N = 1 / ( m * fcn::sqrt( 2 ) );
- Expression em = pE+m;
- if( polState == 0 ) return Tensor( { pX*pZ/(m*em), pY*pZ/(m*em), 1. + pZ*pZ/(m*em), pZ/m } );
- if( polState == 1 ) return -N*Tensor( { m + pX*zb/em, pY*zb/em -m*I, pZ*zb, zb } );
- if( polState == -1 ) return N*Tensor( { m + pX*z/em, pY*z/em + m*I, pZ*z, z } );
+ Expression N = 1./(sqrt(2));
+ Expression invPT2 = make_cse(Ternary( pX*pX + pY*pY > 1e-6, 1./(pX*pX+pY*pY), 0 ));
+ Expression invP = make_cse(Ternary( pP > 1e-6, 1./pP,0));
+ Expression pZoverP = make_cse(Ternary( pP > 1e-6, pZ/pP, 1) );
+ Expression f = (pP-pZ)*invPT2;
+ if(polState == 1) return N * Tensor({-pZoverP + 1i*z *pY*f*invP, -1i*pZoverP - 1i*z *pX*f*invP, z*invP , 0. });
+ if(polState == -1) return N * Tensor({ pZoverP + 1i*zb*pY*f*invP, -1i*pZoverP - 1i*zb*pX*f*invP,-zb*invP , 0. });
+ if(polState == 0) return Tensor({pX*pE*invP/m , pY*pE*invP/m , pZoverP*pE/m, pP/m});
}
if( m_props->twoSpin() == 2 && m_spinBasis == "Dirac" ){
- Expression invPT2 = Ternary( pX*pX + pY*pY > 1e-6, 1./(pX*pX+pY*pY), 0 );
- if( m_props->mass() == 0 ){
- Expression N = 1./(pP*sqrt(2));
- if( polState == 1 ) return N * Tensor({ -pZ - pY*invPT2*(pP-pZ)*(pY-I*pX),
- -I*pZ + pX*invPT2*(pP-pZ)*(pY-I*pX),
- ( pX + I*pY), 0 } );
- if( polState == -1 ) return N * Tensor({ pZ + pY*invPT2*(pP-pZ)*(pY+I*pX),
- I*pZ - pX*invPT2*(pP-pZ)*(pY+I*pX),
- ( -pX + I*pY), 0 } );
- if( polState == 0 ) ERROR("Photon should does not have a rest frame, cannot be in m=0 state");
- }
+ if( name() == "gamma0" ){
+ ERROR("Use the Weyl (helicity) basis for calculations involving photons, as they don't have a rest frame. This will result in ill-defined amplitudes.");
+ }
+ Expression N = make_cse(1./(m*(pE + m)));
+ if( polState == 1 ) return -Tensor({1.+ z *pX*N, 1i + z*pY*N, z*pZ*N , z*m })/sqrt(2);
+ if( polState == -1 ) return Tensor({1.+ zb*pX*N, -1i + zb*pY*N, zb*pZ*N , zb*m })/sqrt(2);
+ if( polState == -1 ) return Tensor({pX*pZ*N , pY*pZ*N, 1 + pZ*pZ*N, pZ/m });
}
if( m_props->twoSpin() == 1 && m_spinBasis == "Weyl" ){
Expression n = fcn::sqrt( 2 * pP*(pP+pZ) );
@@ -518,10 +522,10 @@ Tensor Particle::externalSpinTensor(const int& polState, DebugSymbols* db ) cons
Expression xi11 = make_cse(Ternary( aligned, 0, z/n ));
Expression xi00 = make_cse(Ternary( aligned, 0, -zb/n ));
Expression xi01 = make_cse(Ternary( aligned, 1, (pP+pZ)/n ));
- if(id > 0 && polState == 1 ) return Tensor({ fa*xi10, fa*xi11, fb*xi10, fb*xi11 } );
- if(id > 0 && polState == -1 ) return Tensor({ fa*xi00, fa*xi01, -fb*xi00, -fb*xi01 } );
- if(id < 0 && polState == 1 ) return Tensor({ fb*xi00, fb*xi01, -fa*xi00, -fa*xi01 } );
- if(id < 0 && polState == -1 ) return Tensor({ fb*xi10, fb*xi11, -fa*xi01, -fa*xi11 } );
+ if(id > 0 && polState == 1) return Tensor({ fa*xi10, fa*xi11, fb*xi10, fb*xi11 } );
+ if(id > 0 && polState == -1) return Tensor({ fa*xi00, fa*xi01, -fb*xi00, -fb*xi01 } );
+ if(id < 0 && polState == 1) return Tensor({ fb*xi00, fb*xi01, -fa*xi00, -fa*xi01 } );
+ if(id < 0 && polState == -1) return Tensor({ fb*xi10, fb*xi11, -fa*xi01, -fa*xi11 } );
}
if ( m_props->twoSpin() == 1 && m_spinBasis == "Dirac" )
{
@@ -563,17 +567,14 @@ std::pair Particle::orbitalRange( const bool& conserveParity ) c
const int S = m_props->twoSpin();
const int s1 = daughter( 0 )->props()->twoSpin();
const int s2 = daughter( 1 )->props()->twoSpin();
-
int min = std::abs( S - s1 - s2 );
if ( std::abs( S + s1 - s2 ) < min ) min = std::abs( S + s1 - s2 );
if ( std::abs( S - s1 + s2 ) < min ) min = std::abs( S - s1 + s2 );
int max = S + s1 + s2;
-
min /= 2;
max /= 2;
DEBUG( "Range = " << min << " -> " << max << " conserving parity ? " << conserveParity << " J = " << S << " s1= " << s1 << " s2= " << s2 );
- if ( conserveParity == false ) return {min, max};
-
+ if ( conserveParity == false ) return {min, max};
int l = min;
for ( ; l < max + 1; ++l ) if( conservesParity(l) ) break;
if ( l == max + 1 ) return {999, 999};
diff --git a/src/PolarisedSum.cpp b/src/PolarisedSum.cpp
index 43b3113a612..9d6acd2eb0a 100644
--- a/src/PolarisedSum.cpp
+++ b/src/PolarisedSum.cpp
@@ -44,7 +44,6 @@ PolarisedSum::PolarisedSum( const EventType& type,
std::string objCache = NamedParameter("PolarisedSum::ObjectCache","" );
m_verbosity = NamedParameter( "PolarisedSum::Verbosity" ,0 );
m_rules = AmplitudeRules(mps);
-
auto proto_amplitudes = m_rules.getMatchingRules( type, prefix);
auto production_polarisations = polarisations( type.mother() );
std::vector> allStates;
@@ -62,12 +61,12 @@ PolarisedSum::PolarisedSum( const EventType& type,
DebugSymbols syms;
for( auto& polState : allStates ){
set_polarisation_state( matrix_element, polState );
- thisExpression[ i++ ] = make_cse( matrix_element.first.getExpression(&syms) );
+ thisExpression[i++] = make_cse( matrix_element.first.getExpression(&syms) );
}
CompiledExpression< std::vector , const real_t*, const real_t* > expression(
TensorExpression( thisExpression),
matrix_element.first.decayDescriptor(),
- type.getEventFormat(),debug ? syms : DebugSymbols() ,&mps );
+ type.getEventFormat(), debug ? syms : DebugSymbols() ,&mps );
m_matrixElements.emplace_back(matrix_element.first, matrix_element.second, expression );
}
for( auto& polState : allStates){
diff --git a/src/Spline.cpp b/src/Spline.cpp
index f92461987b6..88d177fc789 100644
--- a/src/Spline.cpp
+++ b/src/Spline.cpp
@@ -154,7 +154,7 @@ void SplineTransfer::transfer( CompiledExpressionBase* destination )
}
}
-void Spline::resolve( ASTResolver& resolver )
+void Spline::resolve( ASTResolver& resolver ) const
{
resolver.resolve(*this);
m_x.resolve(resolver);
diff --git a/src/Tensor.cpp b/src/Tensor.cpp
index b53519571b4..f54fa7d9434 100644
--- a/src/Tensor.cpp
+++ b/src/Tensor.cpp
@@ -658,7 +658,7 @@ TensorExpression::TensorExpression( const Tensor& tensor ) :
std::string TensorExpression::to_string(const ASTResolver* resolver) const {
return m_tensor.to_string(resolver);
}
-void TensorExpression::resolve( ASTResolver& resolver ){
+void TensorExpression::resolve( ASTResolver& resolver ) const {
for( size_t i = 0 ; i < m_tensor.size(); ++i ) m_tensor[i].resolve( resolver );
}
diff --git a/src/Transform.cpp b/src/Transform.cpp
index c001be7ce19..4dbb48b3e33 100644
--- a/src/Transform.cpp
+++ b/src/Transform.cpp
@@ -112,7 +112,6 @@ Tensor TransformSequence::operator()( const Transform::Representation& repr ) co
else return Identity(4);
}
Tensor::Index a,b,c;
-
Tensor rt = m_transforms[0](repr);
rt.st();
for( size_t i = 1 ; i < m_transforms.size(); ++i )
diff --git a/src/UnaryExpression.cpp b/src/UnaryExpression.cpp
index d2d60afa5e9..a00563c6833 100644
--- a/src/UnaryExpression.cpp
+++ b/src/UnaryExpression.cpp
@@ -67,4 +67,4 @@ Expression Norm::d() const { return 0;}
Expression Real::d() const { return 0;}
Expression Imag::d() const { return 0;}
Expression LGamma::d() const { return 0;}
-void IUnaryExpression::resolve( ASTResolver& resolver ) { m_expression.resolve( resolver ); }
+void IUnaryExpression::resolve( ASTResolver& resolver ) const { m_expression.resolve( resolver ); }
diff --git a/src/Wigner.cpp b/src/Wigner.cpp
index 22dc9f5ad66..d39334b33c3 100644
--- a/src/Wigner.cpp
+++ b/src/Wigner.cpp
@@ -21,6 +21,7 @@
using namespace AmpGen;
using namespace AmpGen::fcn;
+using namespace std::complex_literals;
double fact( const double& z )
{
@@ -97,7 +98,7 @@ double AmpGen::CG(
return sqrt(norm) * sum ;
}
-TransformSequence AmpGen::helicityTransformMatrix( const Tensor& P,
+TransformSequence AmpGen::wickTransform( const Tensor& P,
const Expression& mass,
const int& ve,
const bool& handleZero )
@@ -112,12 +113,13 @@ TransformSequence AmpGen::helicityTransformMatrix( const Tensor& P,
Transform rot = ve == + 1 ? Transform( cos_theta, sin_phi*x - cos_phi*y, Transform::Type::Rotate) :
Transform(-cos_theta, -sin_phi*x + cos_phi*y, Transform::Type::Rotate) ;
-// Transform boost( P[3]/mass, (ve==+1) ? z : -z, Transform::Type::Boost );
- Transform boost( P[3]/mass, z, Transform::Type::Boost );
TransformSequence sequence;
- sequence.add( rot );
+ sequence.add(rot);
if( ve == -1 ) sequence.add( Transform( -1, x, Transform::Type::Rotate ) );
- sequence.add( boost ) ;
+ if( std::real(mass()) != 0. ){
+ Transform boost( P[3]/mass, z, Transform::Type::Boost );
+ sequence.add(boost);
+ }
return sequence;
}
@@ -130,12 +132,13 @@ Expression AmpGen::wigner_D(const Tensor& P,
{
Expression pz = make_cse( P[2] / sqrt( P[0]*P[0] + P[1] * P[1] + P[2]*P[2] ) );
Expression pt2 = make_cse( P[0]*P[0] + P[1]*P[1] );
- Expression px = P[0] / sqrt( pt2 );
- Expression py = P[1] / sqrt( pt2 );
+ Expression px = P[0] / sqrt(pt2);
+ Expression py = P[1] / sqrt(pt2);
- Expression I(std::complex(0,1));
auto little_d = make_cse ( wigner_d( pz, J, lA, lB ) );
if( J != 0 && db != nullptr ){
+ db->emplace_back("pt2", pt2 );
+ db->emplace_back("p2" , sqrt( P[0]*P[0] + P[1] * P[1] + P[2]*P[2] ) );
db->emplace_back("ϕ("+name+")", atan2( py, px ) );
db->emplace_back("θ("+name+")", pz );
db->emplace_back("d[" + std::to_string(J) +", " +
@@ -143,9 +146,9 @@ Expression AmpGen::wigner_D(const Tensor& P,
std::to_string(lB) +"](θ)", little_d );
db->emplace_back("D[" + std::to_string(J) +", " +
std::to_string(lA) +", " +
- std::to_string(lB) +"](Ω)", fpow(px+I*py,lB-lA) * little_d );
+ std::to_string(lB) +"](Ω)", fpow(px+1i*py,lB-lA) * little_d );
}
- return fpow( px + I * py, lB - lA ) * little_d;
+ return fpow( px + 1i* py, lB - lA ) * little_d;
}
std::vector AmpGen::calculate_recoupling_constants(
@@ -173,62 +176,38 @@ std::vector AmpGen::calculate_recoupling_constants(
return rt;
}
-/*
-Tensor AmpGen::basis_spinor(const Tensor& p, const int& polState, const int& id, DebugSymbols* db )
-{
- Expression pX = p.get(0) ;
- Expression pY = p.get(1) ;
- Expression pZ = p.get(2) ;
- Expression pE = p.get(3) ;
- Expression pP = fcn::sqrt( pX*pX + pY*pY + pZ*pZ );
- Expression m = fcn::sqrt( dot( p, p ) );
-
- complex_t I(0,1);
- Expression z = pX + I*pY;
- Expression zb = pX - I*pY;
- Expression n = fcn::sqrt( 2 * pP*(pP+pZ) );
- Expression fa = fcn::sqrt( (pE + m)/(2*m) );
- Expression fb = fcn::sqrt( (pE - m)/(2*m) );
- Expression aligned = make_cse( Abs(pP + pZ) < 10e-6 ) ;
-
- Expression xi10 = make_cse(Ternary( aligned, 1, (pP+pZ)/n ));
- Expression xi11 = make_cse(Ternary( aligned, 0, z/n ));
-
- Expression xi00 = make_cse(Ternary( aligned, 0, -zb/n ));
- Expression xi01 = make_cse(Ternary( aligned, 1, (pP+pZ)/n ));
-
- if(id > 0 && polState == 1 ) return Tensor({fa*xi10, fa*xi11, fb*xi10, fb*xi11});
- if(id > 0 && polState == -1 ) return Tensor({fa*xi00, fa*xi01, -fb*xi00, -fb*xi01});
- if(id < 0 && polState == 1 ) return Tensor({fb*xi00, fb*xi01, -fa*xi00, -fa*xi01});
- if(id < 0 && polState == -1 ) return Tensor({fb*xi10, fb*xi11, -fa*xi01, -fa*xi11});
-
- ERROR("Shouldn't reach here...");
- return Tensor();
-}
-*/
Tensor AmpGen::basisSpinor(const int& polState, const int& id)
{
if(id > 0 && polState == 1 ) return Tensor({1, 0, 0, 0}, Tensor::dim(4));
if(id > 0 && polState == -1 ) return Tensor({0, 1, 0, 0}, Tensor::dim(4));
if(id < 0 && polState == 1 ) return Tensor({0, 0, 1, 0}, Tensor::dim(4));
if(id < 0 && polState == -1 ) return Tensor({0, 0, 0, 1}, Tensor::dim(4));
- ERROR("Shouldn't reach here...");
+ ERROR("Shouldn't reach here..., polState = " << polState << " id = " << id );
return Tensor();
}
+Tensor AmpGen::basisVector(const int& polState)
+{
+ double N = 1./sqrt(2);
+ if( polState == 0 ) return Tensor(std::vector({0., 0.,1.,0.}), Tensor::dim(4));
+ if( polState == 1 ) return -N*Tensor(std::vector({1., 1i,0.,0.}), Tensor::dim(4));
+ if( polState == -1 ) return N*Tensor(std::vector({1.,-1i,0.,0.}), Tensor::dim(4));
+ ERROR("Shouldn't reach here..., polState = " << polState);
+ return Tensor();
+}
std::vector userHelicityCouplings( const std::string& key ){
std::vector couplings;
auto things = NamedParameter( key, 0).getVector();
- if( things.size() % 3 != 0 ) ERROR("Wrong number of tokens");
- for( size_t i = 0 ; i < things.size(); i+=3 ){
- LS coupling;
- coupling.factor = things[i+0];
- coupling.m1 = things[i+1];
- coupling.m2 = things[i+2];
- couplings.push_back(coupling);
- }
- return couplings;
+ if( things.size() % 3 != 0 ) ERROR("Wrong number of tokens");
+ for( size_t i = 0 ; i < things.size(); i+=3 ){
+ LS coupling;
+ coupling.factor = things[i+0];
+ coupling.m1 = things[i+1];
+ coupling.m2 = things[i+2];
+ couplings.push_back(coupling);
+ }
+ return couplings;
}
@@ -241,57 +220,55 @@ Expression AmpGen::helicityAmplitude(const Particle& particle,
if( particle.daughters().size() > 2 ) return 1;
if( particle.daughters().size() == 1 )
return helicityAmplitude( *particle.daughter(0), parentFrame, Mz, db, sgn );
-
Tensor::Index a,b,c;
auto myFrame = parentFrame;
if( particle.spin() == 0 ) myFrame.clear();
- Tensor pInParentFrame = parentFrame( particle.P() );
+ Tensor pInParentFrame = parentFrame(particle.P());
pInParentFrame.st();
- if( ! particle.isHead() ){
- auto my_sequence = helicityTransformMatrix( pInParentFrame,
- fcn::sqrt(particle.massSq()),
- sgn,
- true );
- myFrame.add( my_sequence );
- }
+ auto my_sequence = wickTransform(pInParentFrame, fcn::sqrt(particle.massSq()), sgn, true );
+ if( ! particle.isHead() ) myFrame.add( my_sequence );
if( particle.isStable() )
{
if( particle.spin() == 0 ) return Mz==0;
+ // polarisation spinor / vector etc. in the quantisation of the lab (i.e. along the z-axis or lab particle momentum)
+ auto labPol = particle.externalSpinTensor(particle.polState(), db);
+ ADD_DEBUG_TENSOR(labPol, db);
+ auto inverseMyTransform = myFrame.inverse();
if( particle.spin() == 0.5 )
{
- auto tensor = particle.externalSpinTensor(particle.polState(), db);
- auto helicity_tensor = basisSpinor( 2*Mz, particle.props()->pdgID() );
- auto it = myFrame.inverse();
- auto helicity_in_frame = it( helicity_tensor, Transform::Representation::Bispinor );
- auto w = Bar(helicity_in_frame)(a) * tensor(a);
- ADD_DEBUG_TENSOR( helicity_tensor, db );
- ADD_DEBUG_TENSOR( helicity_in_frame ,db);
- ADD_DEBUG_TENSOR( tensor ,db );
- ADD_DEBUG(w, db);
- return w;
+ auto basisSpinor_m1 = basisSpinor( 2*Mz, particle.props()->pdgID() );
+ auto labSpinor_m1 = inverseMyTransform( basisSpinor_m1, Transform::Representation::Bispinor );
+ ADD_DEBUG_TENSOR(labSpinor_m1, db);
+ return make_cse( Bar(labSpinor_m1)(a)*labPol(a) );
+ }
+ if( particle.spin() == 1 )
+ {
+ auto frameVector = basisVector(Mz);
+ auto labVector = inverseMyTransform( frameVector, Transform::Representation::Vector );
+ auto rp = dot( labVector.conjugate(), labPol );
+ ADD_DEBUG_TENSOR(labVector, db);
+ ADD_DEBUG(rp, db );
+ return rp;
}
}
-
auto particle_couplings = particle.spinOrbitCouplings(false);
auto L = particle.orbital();
- auto& d0 = *particle.daughter(0);
- auto& d1 = *particle.daughter(1);
-
+ auto& d1 = *particle.daughter(0);
+ auto& d2 = *particle.daughter(1);
double S = 999;
if( particle.S() == 0 ){
for( auto& l : particle_couplings ) if( l.first == L ){ S = l.second ; break; }
if( S == 999 ) ERROR("Spin orbital coupling impossible!");
}
- else S = particle.S() /2.;
-
- auto recoupling_constants = calculate_recoupling_constants( particle.spin(), Mz, L, S, d0.spin(), d1.spin() );
+ else S = particle.S()/2.;
+ auto recoupling_constants = calculate_recoupling_constants( particle.spin(), Mz, L, S, d1.spin(), d2.spin() );
auto mod = particle.attribute("helAmp");
if( mod != stdx::nullopt ) recoupling_constants = userHelicityCouplings( mod.value() );
if( recoupling_constants.size() == 0 ){
WARNING( particle.uniqueString() << " " << particle.spin() << " " <<
particle.orbitalRange(false).first << " " << particle.orbitalRange(false).second
- << " transition Mz="<< Mz << " to " << d0.spin() << " x " << d0.spin() << " cannot be coupled in (LS) = " << L << ", " << S );
+ << " transition Mz="<< Mz << " to " << d1.spin() << " x " << d2.spin() << " cannot be coupled in (LS) = " << L << ", " << S );
WARNING( "Possible (LS) combinations = " <<
vectorToString( particle_couplings, ", ", []( auto& ls ){ return "("+std::to_string(int(ls.first)) + ", " + std::to_string(ls.second) +")";} ) );
}
@@ -299,9 +276,11 @@ Expression AmpGen::helicityAmplitude(const Particle& particle,
for( auto& coupling : recoupling_constants )
{
auto dm = coupling.m1 - coupling.m2;
- auto term = wigner_D(myFrame(d0.P()), particle.spin(), Mz, dm,db, d0.name() );
- auto h1 = helicityAmplitude(d0, myFrame, coupling.m1, db, +1);
- auto h2 = helicityAmplitude(d1, myFrame, coupling.m2, db, -1);
+ if( (d1.name() == "gamma0" && coupling.m1 == 0) ||
+ (d2.name() == "gamma0" && coupling.m2 == 0) ) continue;
+ auto term = wigner_D(myFrame(d1.P()), particle.spin(), Mz, dm,db, d1.name());
+ auto h1 = helicityAmplitude(d1, myFrame, coupling.m1, db, +1);
+ auto h2 = helicityAmplitude(d2, myFrame, coupling.m2, db, -1);
if( db != nullptr ){
db->emplace_back( "coupling" , coupling.factor );
if( coupling.factor != 1 ) db->emplace_back( "C x DD'", coupling.factor * term * h1 * h2 );
From 4b0d3887171477539ac6639488a88a6eabefca64 Mon Sep 17 00:00:00 2001
From: tevans1260
Date: Wed, 10 Apr 2019 22:59:57 +0200
Subject: [PATCH 053/250] Remove NBins option that doesn't seem to play nicely
with travis ..
---
apps/Fitter.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/Fitter.cpp b/apps/Fitter.cpp
index 1a929991817..a7d0a07ec48 100644
--- a/apps/Fitter.cpp
+++ b/apps/Fitter.cpp
@@ -135,14 +135,14 @@ FitResult* doFit( PDF&& pdf, EventList& data, EventList& mc, MinuitParameterSet&
if ( makePlots ) {
auto ep = fr->getErrorPropagator();
- const size_t NBins = NamedParameter ("nBins" , 100 , "Number of bins used for plotting.");
+// const size_t NBins = NamedParameter ("nBins" , 100 , "Number of bins used for plotting.");
unsigned int counter = 1;
for_each( pdf.m_pdfs, [&]( auto& f ) {
std::function FCN_sig =
[&](const Event& evt){ return f.prob_unnormalised(evt) ; };
auto tStartIntegral2 = std::chrono::high_resolution_clock::now();
- auto mc_plot3 = mc.makeProjections( mc.eventType().defaultProjections(NBins), WeightFunction(f), Prefix("tMC_Category"+std::to_string(counter) ) );
+ auto mc_plot3 = mc.makeProjections( mc.eventType().defaultProjections(100), WeightFunction(f), Prefix("tMC_Category"+std::to_string(counter) ) );
// auto mc_plot3 = bandPlot<100>( mc, "tMC_Category" + std::to_string( counter ) + "_", f, ep );
auto tEndIntegral2 = std::chrono::high_resolution_clock::now();
From 8295397ab9a0c7248c20b5c1d853a1c60644b9ee Mon Sep 17 00:00:00 2001
From: tevans1260
Date: Tue, 23 Apr 2019 23:22:00 +0200
Subject: [PATCH 054/250] Reduce EDM precision, various patches for c++11
compatibility mode
---
AmpGen/SumPDF.h | 5 -----
AmpGen/kMatrix.h | 2 +-
apps/ConvertToSourceCode.cpp | 3 +++
options/D02piKpipi.opt | 24 ++++++++++++------------
options/mass_width.csv | 6 +++---
src/CoherenceFactor.cpp | 26 --------------------------
src/CoherentSum.cpp | 27 +++++++++++++++++++++++++++
src/Lineshapes/CoupledChannel.cpp | 2 +-
src/Lineshapes/kMatrix.cpp | 6 ++++--
src/Minimiser.cpp | 2 +-
src/OptionsParser.cpp | 6 ------
src/Particle.cpp | 13 +++++++------
src/Plots.cpp | 3 ++-
src/PolarisedSum.cpp | 2 +-
14 files changed, 62 insertions(+), 65 deletions(-)
diff --git a/AmpGen/SumPDF.h b/AmpGen/SumPDF.h
index 2cdcea39e62..4a6aa4c7fa3 100644
--- a/AmpGen/SumPDF.h
+++ b/AmpGen/SumPDF.h
@@ -31,18 +31,13 @@ namespace AmpGen
double getVal()
{
-// ProfileClock pc;
double LL = 0;
for_each( m_pdfs, []( auto& f ) { f.prepare(); } );
-// pc.stop();
-// ProfileClock eval;
#pragma omp parallel for reduction( +: LL )
for ( unsigned int i = 0; i < m_events->size(); ++i ) {
auto prob = ((*this))(( *m_events)[i] );
LL += log(prob);
}
-// eval.stop();
-// std::cout << "t [prepare] = " << pc << "; t[eval] = " << eval << "ms" << std::endl;
return -2 * LL;
}
double operator()( const Event& evt )
diff --git a/AmpGen/kMatrix.h b/AmpGen/kMatrix.h
index b242b36908b..a6fb78cc29d 100644
--- a/AmpGen/kMatrix.h
+++ b/AmpGen/kMatrix.h
@@ -51,7 +51,7 @@ namespace AmpGen
std::vector paramVector( const std::string& name, const unsigned int& nParam );
- Tensor getPropagator(const Tensor& kMatrix, const std::vector& phaseSpace);
+ Tensor getPropagator(const Tensor& kMatrix, const std::vector& phaseSpace, DebugSymbols* db = nullptr);
} // namespace AmpGen
diff --git a/apps/ConvertToSourceCode.cpp b/apps/ConvertToSourceCode.cpp
index 72783952716..5329b91bb6c 100644
--- a/apps/ConvertToSourceCode.cpp
+++ b/apps/ConvertToSourceCode.cpp
@@ -77,6 +77,9 @@ template void generate_source(T& pdf, EventList& normEvents, const std
double pMax = 0 ;
pdf.setEvents( normEvents );
pdf.prepare();
+ normEvents[0].print();
+ normEvents[0].printCache();
+ INFO( pdf.prob_unnormalised( normEvents[0] ) );
for ( auto& evt : normEvents ) {
if( type == "PolarisedSum" ){
double px, py, pz;
diff --git a/options/D02piKpipi.opt b/options/D02piKpipi.opt
index b81c4db0536..2ef30fe904d 100644
--- a/options/D02piKpipi.opt
+++ b/options/D02piKpipi.opt
@@ -3,19 +3,19 @@
Import $AMPGENROOT/options/Dbar02piKpipi.opt #necessary for K1 couplings / shape parameters
-D0_radius 2 3.7559 0
-D0{K*(892)0{K+,pi-},rho(770)0{pi+,pi-}} 0 0.205 0.019 0 -8.5 4.7
-D0[P]{K*(892)0{K+,pi-},rho(770)0{pi+,pi-}} 0 0.390 0.002 0 -91.4 0.4
-D0[D]{K*(892)0{K+,pi-},rho(770)0{pi+,pi-}} 2 1.000 0.000 2 0.0 0.0
-D0{rho(1450)0{pi+,pi-},K*(892)0{K+,pi-}} 0 0.541 0.042 0 -21.8 6.5
+D0_radius 2 3.7559 0
+D0{K*(892)0{K+,pi-},rho(770)0{pi+,pi-}} 2 0.205 0.019 2 -8.5 4.7
+D0[P]{K*(892)0{K+,pi-},rho(770)0{pi+,pi-}} 2 0.390 0.002 2 -91.4 0.4
+D0[D]{K*(892)0{K+,pi-},rho(770)0{pi+,pi-}} 2 1.000 0.000 2 0.0 0.0
+D0{rho(1450)0{pi+,pi-},K*(892)0{K+,pi-}} 2 0.541 0.042 2 -21.8 6.5
# There is an additional relative phase of 180 degrees here w.r.t
# what is written in the paper, due to a slightly different convention
# in how the K(1) couplings have been defined.
-D0{K(1)(1270)+,pi-} 0 0.653 0.040 0 69.3 5.1
-D0{K(1)(1400)+{K*(892)0{K+,pi-},pi+},pi-} 0 0.560 0.037 0 29.8 4.2
-D0{KPi40,PiPi40} 2 1.000 0.000 2 0.0 0.0
-KPi40[FOCUS.Kpi]{K+,pi-} 2 1.000 0.000 2 0.0 0.0
-KPi40[FOCUS.I32]{K+,pi-} 0 0.686 0.010 0 -149.4 4.3
-PiPi40[kMatrix.pole.1]{pi+,pi-} 0 0.438 0.009 0 -132.4 6.5
-PiPi40[kMatrix.prod.0]{pi+,pi-} 0 0.050 0.001 0 74.8 7.5
+D0{K(1)(1270)+,pi-} 2 0.653 0.040 2 69.3 5.1
+D0{K(1)(1400)+{K*(892)0{K+,pi-},pi+},pi-} 2 0.560 0.037 2 29.8 4.2
+D0{KPi40,PiPi40} 2 1.000 0.000 2 0.0 0.0
+KPi40[FOCUS.Kpi]{K+,pi-} 2 1.000 0.000 2 0.0 0.0
+KPi40[FOCUS.I32]{K+,pi-} 2 0.686 0.010 2 -149.4 4.3
+PiPi40[kMatrix.pole.1]{pi+,pi-} 2 0.438 0.009 2 -132.4 6.5
+PiPi40[kMatrix.prod.0]{pi+,pi-} 2 0.050 0.001 2 74.8 7.5
diff --git a/options/mass_width.csv b/options/mass_width.csv
index 6f6050db895..436b4bb6124 100644
--- a/options/mass_width.csv
+++ b/options/mass_width.csv
@@ -578,9 +578,9 @@
2.342E+03 ,3.0E+01,3.0E+01,1.6E+02 ,4.0E+01,4.0E+01,0 , ,3/2 ,-, ,F, , 0,1,S,Lambda(2325) ,uds
2.3500E+03 ,2.0E+01,1.0E+01,1.5E+02 ,1.0E+02,5.0E+01,0 , ,9/2 ,+, ,F, , 0,3,D,Lambda(2350) ,uds
2.530E+03 ,2.5E+01,2.5E+01,150 ,-1 ,-1 ,0 , ,? ,?, ,F, , 0,2,S,Lambda(2585) ,uds
-1.18937E+03 ,7.0E-02,7.0E-02,8.264E-12 ,2.7E-14,2.7E-14,1 , ,1/2 ,+, ,F, 3222, +,4,R,Sigma(P11) ,uus
-1.192642E+03 ,2.4E-02,2.4E-02,9.0E-03 ,8.0E-04,8.0E-04,1 , ,1/2 ,+, ,F, 3212, 0,4,R,Sigma(P11) ,uds
-1.197449E+03 ,3.0E-02,3.0E-02,4.480E-12 ,3.3E-14,3.3E-14,1 , ,1/2 ,+, ,F, 3112, -,4,R,Sigma(P11) ,dds
+1.18937E+03 ,7.0E-02,7.0E-02,8.264E-12 ,2.7E-14,2.7E-14,1 , ,1/2 ,+, ,F, 3222, +,4,R,Sigma ,uus
+1.192642E+03 ,2.4E-02,2.4E-02,9.0E-03 ,8.0E-04,8.0E-04,1 , ,1/2 ,+, ,F, 3212, 0,4,R,Sigma ,uds
+1.197449E+03 ,3.0E-02,3.0E-02,4.480E-12 ,3.3E-14,3.3E-14,1 , ,1/2 ,+, ,F, 3112, -,4,R,Sigma ,dds
1.3828E+03 ,4.0E-01,4.0E-01,3.58E+01 ,8.0E-01,8.0E-01,1 , ,3/2 ,+, ,F, 3224, +,4,R,Sigma(1385) ,uus
1.38370E+03 ,1.0E+00,1.0E+00,3.6E+01 ,5.0E+00,5.0E+00,1 , ,3/2 ,+, ,F, 3214, 0,4,R,Sigma(1385) ,uds
1.3872E+03 ,5.0E-01,5.0E-01,3.94E+01 ,2.1E+00,2.1E+00,1 , ,3/2 ,+, ,F, 3114, -,4,R,Sigma(1385) ,dds
diff --git a/src/CoherenceFactor.cpp b/src/CoherenceFactor.cpp
index 1da28335737..1e1eb6be5c3 100644
--- a/src/CoherenceFactor.cpp
+++ b/src/CoherenceFactor.cpp
@@ -517,32 +517,6 @@ void CoherenceFactor::calculateNorms()
id.flush();
}
-std::vector CoherentSum::cacheAddresses( const EventList& evts ) const
-{
- std::vector addresses;
- for ( auto& mE : m_matrixElements ) {
- addresses.push_back( evts.getCacheIndex( mE.pdf ) );
- }
- return addresses;
-}
-
-complex_t CoherentSum::getVal( const Event& evt ) const
-{
- complex_t value( 0., 0. );
- for ( auto& mE : m_matrixElements ) {
- value += mE.coefficient * evt.getCache( mE.addressData );
- }
- return value;
-}
-
-complex_t CoherentSum::getVal( const Event& evt, const std::vector& cacheAddresses ) const
-{
- complex_t value( 0., 0. );
- for ( unsigned int i = 0; i < m_matrixElements.size(); ++i )
- value += m_matrixElements[i].coefficient * evt.getCache( cacheAddresses[i] );
- return value;
-}
-
unsigned int CoherenceFactor::getBinNumber( const Event& event ) const
{
int voxelID = m_voxels.getBinNumber( event );
diff --git a/src/CoherentSum.cpp b/src/CoherentSum.cpp
index 1006cdee795..ce72c724f82 100644
--- a/src/CoherentSum.cpp
+++ b/src/CoherentSum.cpp
@@ -351,3 +351,30 @@ void CoherentSum::printVal(const Event& evt)
}
}
}
+
+std::vector CoherentSum::cacheAddresses( const EventList& evts ) const
+{
+ std::vector addresses;
+ for ( auto& mE : m_matrixElements ) {
+ addresses.push_back( evts.getCacheIndex( mE.pdf ) );
+ }
+ return addresses;
+}
+
+complex_t CoherentSum::getVal( const Event& evt ) const
+{
+ complex_t value( 0., 0. );
+ for ( auto& mE : m_matrixElements ) {
+ value += mE.coefficient * evt.getCache( mE.addressData );
+ }
+ return value;
+}
+
+complex_t CoherentSum::getVal( const Event& evt, const std::vector& cacheAddresses ) const
+{
+ complex_t value( 0., 0. );
+ for ( unsigned int i = 0; i < m_matrixElements.size(); ++i )
+ value += m_matrixElements[i].coefficient * evt.getCache( cacheAddresses[i] );
+ return value;
+}
+
diff --git a/src/Lineshapes/CoupledChannel.cpp b/src/Lineshapes/CoupledChannel.cpp
index 0ee3ad024e6..db183186e63 100644
--- a/src/Lineshapes/CoupledChannel.cpp
+++ b/src/Lineshapes/CoupledChannel.cpp
@@ -100,7 +100,7 @@ DEFINE_LINESHAPE( CoupledChannel )
ADD_DEBUG( s , dbexpressions );
for( size_t i = 0 ; i < channels.size(); i+=2 ){
Particle p( channels[i] );
- INFO( "Adding channel ... " << p.uniqueString() << " coupling = " << NamedParameter( channels[i+1] ) );
+ DEBUG( "Adding channel ... " << p.uniqueString() << " coupling = " << NamedParameter( channels[i+1] ) );
Expression coupling = Parameter(channels[i+1], 0);
totalWidth = totalWidth + coupling * phaseSpace(s , p, p.orbital());
totalWidthAtPole = totalWidthAtPole + coupling * phaseSpace(mass*mass, p, p.orbital());
diff --git a/src/Lineshapes/kMatrix.cpp b/src/Lineshapes/kMatrix.cpp
index 073406dd3be..86db4312e06 100644
--- a/src/Lineshapes/kMatrix.cpp
+++ b/src/Lineshapes/kMatrix.cpp
@@ -48,7 +48,7 @@ Expression AmpGen::gFromGamma( const Expression& m, const Expression& gamma, con
return fcn::sqrt( m * gamma / rho );
}
-Tensor AmpGen::getPropagator(const Tensor& kMatrix, const std::vector& phaseSpace)
+Tensor AmpGen::getPropagator(const Tensor& kMatrix, const std::vector& phaseSpace, DebugSymbols* db )
{
unsigned int nChannels = kMatrix.dims()[0];
Tensor T( Tensor::dim(nChannels, nChannels) );
@@ -57,6 +57,7 @@ Tensor AmpGen::getPropagator(const Tensor& kMatrix, const std::vector( "Minimiser::Algorithm", "Hesse");
size_t maxCalls = NamedParameter( "Minimiser::MaxCalls" , 100000);
- double tolerance = NamedParameter( "Minimiser::Tolerance" , 0.01);
+ double tolerance = NamedParameter