diff --git a/inc/Lau1DCubicSpline.hh b/inc/Lau1DCubicSpline.hh index eda0fe1..374411a 100644 --- a/inc/Lau1DCubicSpline.hh +++ b/inc/Lau1DCubicSpline.hh @@ -1,312 +1,313 @@ /* Copyright 2015 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file Lau1DCubicSpline.hh \brief File containing declaration of Lau1DCubicSpline class. */ /*! \class Lau1DCubicSpline \brief Class for defining a 1D cubic spline based on a set of knots. Class for defining a 1D cubic spline based on a set of knots. Interpolation between the knots is performed either by one of two types of cubic spline (standard or Akima) or by linear interpolation. The splines are defined by a piecewise cubic function which, between knots i and i+1, has the form f_i(x) = (1 - t)*y_i + t*y_i+1 + t*(1 - t)(a*(1 - t) + b*t) where t = (x - x_i)/(x_i+1 - x_i), a = k_i *(x_i+1 - x_i) - (y_i+1 - y_i), b = -k_i+1*(x_i+1 - x_i) + (y_i+1 - y_i) and k_i is (by construction) the first derivative at knot i. f(x) and f'(x) are continuous at the internal knots by construction. For the standard splines, f''(x) is required to be continuous at all internal knots placing n-2 constraints on the n parameters, k_i. The final two constraints are set by the boundary conditions. At each boundary, the function may be: (i) Clamped : f'(x) = C at the last knot (ii) Natural : f''(x) = 0 at the last knot (iii) Not a knot : f'''(x) continuous at the second last knot The algorithms used in these splines can be found on: http://en.wikipedia.org/wiki/Spline_interpolation#Algorithm_to_find_the_interpolating_cubic_spline http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm For the Akima splines, the values of k_i are determined from the slopes of the four nearest segments (a_i-1, a_i, a_i+1 and a_i+2) as k_i = ( | a_i+2 - a_i+1 | a_i + | a_i - a_i-1 | a_i+1 ) / ( | a_i+2 - a_i+1 | + | a_i - a_i-1 | ) and as k_i = ( a_i + a_i+1 ) / 2 in the special case a_i-1 == a_i != a_i+1 == a_i+2. Boundary conditions are specified by the relations a_2 - a_1 = a_1 - a_0 = a_0 - a_-1 and a_n-1 - a_n-2 = a_n - a_n-1 = a_n+1 - a_n The algorithms used in these splines can be found in: J.ACM vol. 17 no. 4 pp 589-602 */ #ifndef LAU_1DCUBICSPLINE #define LAU_1DCUBICSPLINE #include #include #include #include #include "Rtypes.h" #include "TF1.h" #include "TFitResultPtr.h" #include "LauPrint.hh" class TH1; class LauAbsRValue; class LauParameter; class Lau1DCubicSpline final { public: //! Define the allowed interpolation types enum class SplineType { StandardSpline, /*!< standard cubic splines with f''(x) continuous at all internal knots */ AkimaSpline, /*!< Akima cubic splines with f'(x) at each knot defined locally by the positions of only five knots */ LinearInterpolation /*! Linear interpolation between each pair of knots */ }; //! Define the allowed boundary condition types /*! These are only supported by standard splines */ enum class BoundaryType { Clamped, /*!< clamped boundary - f'(x) = C */ Natural, /*!< natural boundary - f''(x) = 0 */ NotAKnot /*!< 'not a knot' boundary - f'''(x) continuous at second last knot */ }; //! Constructor /*! \param [in] xs the x-values of the knots \param [in] ys the y-values of the knots \param [in] type the type of spline (Standard, Akima, Linear) \param [in] leftBound the left-hand boundary condition \param [in] rightBound the right-hand boundary condition \param [in] dydx0 the gradient at the left-hand boundary of a clamped spline \param [in] dydxn the gradient at the right-hand boundary of a clamped spline */ Lau1DCubicSpline(const std::vector& xs, const std::vector& ys, const SplineType type = SplineType::StandardSpline, const BoundaryType leftBound = BoundaryType::NotAKnot, const BoundaryType rightBound = BoundaryType::NotAKnot, const Double_t dydx0 = 0.0, const Double_t dydxn = 0.0); //! Evaluate the function at given point /*! \param [in] x the x-coordinate \return the value of the spline at x */ Double_t evaluate(const Double_t x) const; //! Update the y-values of the knots /*! \param [in] ys the y-values of the knots */ void updateYValues(const std::vector& ys); //! Update the y-values of the knots /*! \param [in] ys the y-values of the knots */ void updateYValues(const std::vector& ys); //! Update the y-values of the knots /*! \param [in] ys the y-values of the knots */ void updateYValues(const std::vector& ys); //! Update the type of interpolation to perform /*! \param [in] type the type of interpolation */ void updateType(const SplineType type); //! Update the boundary conditions for the spline /*! \param [in] leftBound the left-hand boundary condition \param [in] rightBound the right-hand boundary condition \param [in] dydx0 the gradient at the left-hand boundary of a clamped spline \param [in] dydxn the gradient at the right-hand boundary of a clamped spline */ void updateBoundaryConditions(const BoundaryType leftBound, const BoundaryType rightBound, const Double_t dydx0 = 0.0, const Double_t dydxn = 0.0); //! Get the number of knots std::size_t getnKnots() const {return nKnots_;} //! Get y values const std::vector& getYValues() const {return y_;} //! Get x values const std::vector& getXValues() const {return x_;} //! Get the coefficients of a given spline segment in the form a + bx + cx^2 + dx^3 /*! \param [in] segIndex refers to the index of the knot at the left end of the segment (segIndex = 0 gets the coefficients of the the segment between x_0 and x_1) \param [in] normalise if true, the coefficients returned will be normalised by the integral of the complete spline (defaults to false) \return coefficients {a, b, c, d} */ std::array getCoefficients(const std::size_t segIndex, const bool normalise = false) const; //! Get the integral over all the spline segments Double_t integral() const; //! Make a TF1 showing the spline with its current knot values /*! \param [in] normalise whether or not you want the spline normalised \return 1D function object */ TF1* makeTF1(const bool normalise = false) const; //! Fit the the normalisation of the spline to a TH1 /*! \param [in] hist the histogram to be fitted \param [in] printLevel the level of printout desired from fit \return a TF1 fit to the histogram */ TF1* normaliseToTH1(TH1* hist, const LauOutputLevel printLevel = LauOutputLevel::Standard) const; //! Fit the spline to a TH1 /*! \param [in] hist the histogram to be fitted \param [in] printLevel the level of printout desired from fit \param [in] doWL If true do a weighted likelihood fit, else chi2 \param [in] fixedParams Provide a map of knots to be fixed and to what values \return a shared-ownership smart pointer to the fit results */ TFitResultPtr fitToTH1(TH1* hist, const LauOutputLevel printLevel = LauOutputLevel::Standard, const bool doWL = false, std::map fixedParams = {}); //! Write the spline to a json file /*! - \param[in] fileName the name of the file to which the JSON should be written - \param[in] splineName the (optional) name of the entry in the JSON to which the spline should be written - \param[in] append if true, append the spline to the existing JSON within the file - if using this option it is then mandatory to provide splineName + \param [in] fileName the name of the file to which the JSON should be written + \param [in] splineName the (optional) name of the entry in the JSON to which the spline should be written + \param [in] append if true, append the spline to the existing JSON within the file - if using this option it is then mandatory to provide splineName + \param [in] indent the indentation level to use in the output in number of spaces (defaults to 4) */ - void writeToJson(const TString& fileName, const TString& splineName = "", const bool append = false) const; + void writeToJson(const TString& fileName, const TString& splineName = "", const bool append = false, const int indent = 4) const; //! Construct a new Lau1DCubicSpline object based on values read from a json file /*! - \param[in] fileName the name of the file from which the JSON should be read - \param[in] splineName the (optional) name of the entry in the JSON from which the spline should be read + \param [in] fileName the name of the file from which the JSON should be read + \param [in] splineName the (optional) name of the entry in the JSON from which the spline should be read \return the newly constructed spline */ static std::unique_ptr readFromJson(const TString& fileName, const TString& splineName = ""); //! Find the maximum of the spline /*! \return the maximum of the spline */ Double_t findMaximum() const; private: //! Default constructor - only for use in readFromJson Lau1DCubicSpline() = default; //! Initialise the class void init(); //! Calculate the first derivative at each knot void calcDerivatives(); //! Calculate the first derivatives according to the standard method void calcDerivativesStandard(); //! Calculate the first derivatives according to the Akima method void calcDerivativesAkima(); //! The number of knots in the spline std::size_t nKnots_{0}; //! The x-value at each knot std::vector x_; //! The y-value at each knot std::vector y_; //! The first derivative at each knot std::vector dydx_; //! The 'a' coefficients used to determine the derivatives std::vector a_; //! The 'b' coefficients used to determine the derivatives std::vector b_; //! The 'c' coefficients used to determine the derivatives std::vector c_; //! The 'd' coefficients used to determine the derivatives std::vector d_; //! The type of interpolation to be performed SplineType type_{SplineType::StandardSpline}; //! The left-hand boundary condition on the spline BoundaryType leftBound_{BoundaryType::NotAKnot}; //! The right-hand boundary condition on the spline BoundaryType rightBound_{BoundaryType::NotAKnot}; //! The gradient at the left boundary for a clamped spline Double_t dydx0_{0.0}; //! The gradient at the right boundary for a clamped spline Double_t dydxn_{0.0}; // enable JSON serialisation of this class NLOHMANN_DEFINE_TYPE_INTRUSIVE(Lau1DCubicSpline, nKnots_, x_, y_, type_, leftBound_, rightBound_, dydx0_, dydxn_) ClassDef(Lau1DCubicSpline, 0) // Class for defining a 1D cubic spline }; //! \cond DOXYGEN_IGNORE // map Lau1DCubicSpline::SplineType values to JSON as strings NLOHMANN_JSON_SERIALIZE_ENUM( Lau1DCubicSpline::SplineType, { {Lau1DCubicSpline::SplineType::StandardSpline, "StandardSpline"}, {Lau1DCubicSpline::SplineType::AkimaSpline, "AkimaSpline"}, {Lau1DCubicSpline::SplineType::LinearInterpolation, "LinearInterpolation"}, }) // map Lau1DCubicSpline::BoundaryType values to JSON as strings NLOHMANN_JSON_SERIALIZE_ENUM( Lau1DCubicSpline::BoundaryType, { {Lau1DCubicSpline::BoundaryType::Clamped, "Clamped"}, {Lau1DCubicSpline::BoundaryType::Natural, "Natural"}, {Lau1DCubicSpline::BoundaryType::NotAKnot, "NotAKnot"}, }) std::ostream& operator<<(std::ostream& out, const Lau1DCubicSpline::SplineType type); std::ostream& operator<<(std::ostream& out, const Lau1DCubicSpline::BoundaryType type); //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauAbsCoeffSet.hh b/inc/LauAbsCoeffSet.hh index 5eb5b62..e417f0b 100644 --- a/inc/LauAbsCoeffSet.hh +++ b/inc/LauAbsCoeffSet.hh @@ -1,514 +1,517 @@ /* Copyright 2006 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauAbsCoeffSet.hh \brief File containing declaration of LauAbsCoeffSet class. */ #ifndef LAU_ABS_COEFF_SET #define LAU_ABS_COEFF_SET #include "TString.h" #include #include #include #include #include class TRandom; class LauComplex; class LauParameter; /*! \brief Types of coefficient sets The different forms that are implemented for the complex coefficients. Each form is represented by a class that inherits from LauAbsCoeffSet. The corresponding class is named in a simlar manner, replacing "Abs" with the enum label. */ enum class LauCoeffType { MagPhase, /*!< \see LauMagPhaseCoeffSet */ RealImag, /*!< \see LauRealImagCoeffSet */ BelleCP, /*!< \see LauBelleCPCoeffSet */ CartesianCP, /*!< \see LauCartesianCPCoeffSet */ CartesianGammaCP, /*!< \see LauCartesianGammaCPCoeffSet */ CleoCP, /*!< \see LauCleoCPCoeffSet */ MagPhaseCP, /*!< \see LauMagPhaseCPCoeffSet */ NSCCartesianCP, /*!< \see LauNSCCartesianCPCoeffSet */ PolarGammaCP, /*!< \see LauPolarGammaCPCoeffSet */ RealImagCP, /*!< \see LauRealImagCPCoeffSet */ RealImagGammaCP /*!< \see LauRealImagGammaCPCoeffSet */ }; //! Output stream operator std::ostream& operator<<( std::ostream& os, const LauCoeffType type ); /*! \class LauAbsCoeffSet \brief Class for defining the abstract interface for complex coefficient classes. Class for defining the abstract interface for complex coefficient classes. Some common code is implemented but most methods are not. */ class LauAbsCoeffSet { public: //! Options for cloning operation enum class CloneOption { All, /*!< no special operation, all parameters cloned */ TiePhase, /*!< phase cloned, magnitude free to vary */ TieMagnitude, /*!< magnitude cloned, phase free to vary */ TieRealPart, /*!< real part cloned, imaginary part free to vary */ TieImagPart, /*!< imaginary part cloned, real part free to vary */ TieCPPars /*!< CP-violating parameters cloned, CP-conserving ones free to vary */ }; //! Construct a collection of coefficient objects based on values read from a JSON file /*! - \param[in] fileName the name of the file from which the JSON should be read + \param [in] fileName the name of the file from which the JSON should be read \param [in] elementName the optional name of the JSON element that contains the coefficient definitions (defaults to using the root record) \return the collection of newly constructed coefficients */ static std::vector> readFromJson( const TString& fileName, const TString& elementName = "" ); //! Write a collection of coefficient objects to a JSON file /*! - \param[in] fileName the name of the file to which the JSON should be written - \param[in] coeffs the collection of coefficients to be written out + \param [in] coeffs the collection of coefficients to be written out + \param [in] fileName the name of the file to which the JSON should be written + \param [in] elementName the (optional) name of the JSON element to which the coefficients should be written + \param [in] append if true, append the spline to the existing JSON within the file - if using this option it is then mandatory to provide elementName + \param [in] indent the indentation level to use in the output in number of spaces (defaults to 4) */ - static void writeToJson( const TString& fileName, const std::vector>& coeffs ); + static void writeToJson( const std::vector>& coeffs, const TString& fileName, const TString& elementName = "", const bool append = false, const int indent = 4 ); //! Destructor virtual ~LauAbsCoeffSet() = default; //! Determine the type of the coefficient /*! \return the type of the coefficient */ virtual LauCoeffType type() const = 0; //! Retrieve the parameters of the coefficient so that they can be loaded into a fit /*! \return the parameters of the coefficient */ virtual std::vector getParameters() = 0; //! Retrieve the (const) parameters of the coefficient, e.g. so that they can be queried /*! \return the (const) parameters of the coefficient */ virtual std::vector getParameters() const = 0; //! Retrieve the names of the parameters of the coefficient (in the same order as the parameters in getParameters) /*! \return the parameter names */ virtual std::vector getParNames() const = 0; //! Print the current values of the parameters virtual void printParValues() const = 0; //! Print the column headings for a results table /*! \param [out] stream the stream to print to */ virtual void printTableHeading(std::ostream& stream) const = 0; //! Print the parameters of the complex coefficient as a row in the results table /*! \param [out] stream the stream to print to */ virtual void printTableRow(std::ostream& stream) const = 0; //! Randomise the starting values of the parameters for a fit virtual void randomiseInitValues() = 0; //! Make sure values are in "standard" ranges, e.g. phases should be between -pi and pi virtual void finaliseValues() = 0; //! Retrieve the complex coefficient for a particle /*! \return the complex coefficient for a particle */ virtual const LauComplex& particleCoeff() = 0; //! Retrieve the complex coefficient for an antiparticle /*! \return the complex coefficient for an antiparticle */ virtual const LauComplex& antiparticleCoeff() = 0; //! Set the parameters based on the complex coefficients for particles and antiparticles /*! \param [in] coeff the complex coefficient for a particle \param [in] coeffBar the complex coefficient for an antiparticle \param [in] init whether or not the initial and generated values should also be adjusted */ virtual void setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar, const Bool_t init ) = 0; //! Calculate the CP asymmetry /*! \return the CP asymmetry */ virtual LauParameter acp() = 0; //! Write state to a JSON record /*! \param [in,out] j the JSON record to write to */ virtual void serialiseToJson( nlohmann::json& j ) const; //! Apply the blinding information in the JSON record to all parameters /*! \param [in] j the JSON record to read from */ virtual void applyBlinding( const nlohmann::json& j ); //! Create a clone of the coefficient set /*! \param [in] newName the clone's name \param [in] cloneOption special option for the cloning operation \param [in] constFactor a constant factor by which to multiply the cloned parameters \param [in] coeffInfo an optional JSON entry that contains the values of any non-cloned parameters (depending on the CloneOption) \return a clone of the coefficient set */ std::unique_ptr createClone(const TString& newName, const CloneOption cloneOption = CloneOption::All, const Double_t constFactor = 1.0, const nlohmann::json& coeffInfo = {}) const { return std::unique_ptr{this->createClone_impl(newName,cloneOption,constFactor,coeffInfo)}; } //! Retrieve the name of the coefficient set /*! The name should correspond to the name of the resonance in the model. \return the name of the coefficient set */ TString name() const {return name_;} //! Set the name of the coefficient set /*! The name should correspond to the name of the resonance in the model. \param [in] theName the name to set */ void name(const TString& theName) {name_ = theName;} //! Retrieve the base name of the coefficient set /*! The base name is generally of the form "Ai", where i is an integer. This is used in the fit results ntuple. \return the base name of the coefficient set */ const TString& baseName() const {return basename_;} //! Set the base name of the coefficient set /*! The base name is generally of the form "Ai", where i is an integer. This is used in the fit results ntuple. \param [in] theBasename the base name to set */ void baseName(const TString& theBasename) {basename_ = theBasename;} //! Retrieve the index number of the coefficient set /*! \return the index number of the coefficient set */ UInt_t index() const {return index_;} //! Set the index number of the coefficient set /*! \param [in] newIndex the new index */ void index(const UInt_t newIndex); //! Is this coefficient set a clone of another? /*! \return whether this coefficient set is a clone */ Bool_t clone() const {return parent_ != nullptr;} //! From which coefficient set was this one cloned? /*! \return the parent of this coefficient set, or nullptr if this isn't a clone */ const LauAbsCoeffSet* parent() const {return parent_;} //! What clone option was this cloned with? /*! \return the clone option with which this was cloned */ CloneOption cloneOption() const {return cloneOption_;} //! What constant factor was this cloned with? /*! \return the constant factor with which this was cloned */ Double_t constFactor() const {return constFactor_;} //! Set the value of the named parameter /*! \param [in] parName the name of the parameter to adjust \param [in] value the new value for the parameter to take \param [in] init whether or not the initial and generated values should also be adjusted */ void setParameterValue(const TString& parName, const Double_t value, const Bool_t init); //! Set the error of the named parameter /*! This is particularly useful for tuning the step size used by MINUIT \param [in] parName the name of the parameter to adjust \param [in] error the new error value for the parameter to take */ void setParameterError(const TString& parName, const Double_t error); //! Set the named parameter to be fixed in the fit /*! \param [in] parName the name of the parameter to adjust */ void fixParameter(const TString& parName); //! Set the named parameter to float in the fit /*! \param [in] parName the name of the parameter to adjust */ void floatParameter(const TString& parName); //! Blind the named parameter /*! See LauBlind documentation for details of blinding procedure \param [in] parName the name of the parameter to adjust \param [in] blindingString the unique blinding string used to seed the random number generator \param [in] width the width of the Gaussian from which the offset should be sampled */ void blindParameter(const TString& parName, const TString& blindingString, const Double_t width); //! Add Gaussian constraint to the named parameter /*! \param [in] parName the name of the parameter to adjust \param [in] mean the mean of the Gaussian constraint \param [in] width the width of the Gaussian constraint */ void addGaussianConstraint(const TString& parName, const Double_t mean, const Double_t width); //! Add suffix to the name of the given parameter /*! \param [in] parName the name of the parameter to adjust \param [in] suffix the suffix to add to the parameter name */ void addSuffixToParameterName(const TString& parName, const TString& suffix); //! Set the allowed range for magnitude parameters /*! \param [in] minMag the lower edge of the range \param [in] maxMag the upper edge of the range */ static void setMagnitudeRange(const Double_t minMag, const Double_t maxMag) { minMagnitude_ = minMag; maxMagnitude_ = maxMag; } //! Set the allowed range for phase parameters /*! \param [in] minPhase the lower edge of the range \param [in] maxPhase the upper edge of the range */ static void setPhaseRange(const Double_t minPhase, const Double_t maxPhase) { minPhase_ = minPhase; maxPhase_ = maxPhase; } //! Set the allowed range for real/imaginary part parameters /*! \param [in] minPar the lower edge of the range \param [in] maxPar the upper edge of the range */ static void setRealImagRange(const Double_t minPar, const Double_t maxPar) { minRealImagPart_ = minPar; maxRealImagPart_ = maxPar; } //! Set the allowed range for CP-violating parameters /*! \param [in] minPar the lower edge of the range \param [in] maxPar the upper edge of the range */ static void setCPParRange(const Double_t minPar, const Double_t maxPar) { minDelta_ = minPar; maxDelta_ = maxPar; } //! Set the randomiser /*! Set the random number generator to use for randomising parameter starting values. Will default to LauRandom::zeroSeedRandom if not explicitly supplied via this function. \param [in] randomiser the random number generator to use for randomising parameter starting values */ static void setRandomiser(TRandom* randomiser) { randomiser_ = randomiser; } //! Access the randomiser /*! \return the random number generator to use for randomising parameter starting values */ static TRandom* getRandomiser(); protected: //! Constructor /*! \param [in] theName the name of the coefficient set \param [in] theBaseName the single character base for the parameter names \param [in] parent the coefficient set from which this one has been cloned (or nullptr if we are not a clone) \param [in] cloneOption the cloning option that was used (if applicable) \param [in] constFactor the constant factor that was used when cloning (if applicable) */ LauAbsCoeffSet(const TString& theName, const TString& theBaseName = "A", const LauAbsCoeffSet* parent = nullptr, const CloneOption cloneOption = CloneOption::All, const Double_t constFactor = 1.0); //! Copy constructor /*! \param [in] rhs the coefficient to clone */ LauAbsCoeffSet(const LauAbsCoeffSet& rhs) = default; //! Move constructor /*! \param [in] rhs the coefficient to clone */ LauAbsCoeffSet(LauAbsCoeffSet&& rhs) = default; //! Copy assignment operator /*! \param [in] rhs the coefficient to clone */ LauAbsCoeffSet& operator=(const LauAbsCoeffSet& rhs) = delete; //! Move assignment operator /*! \param [in] rhs the coefficient to clone */ LauAbsCoeffSet& operator=(LauAbsCoeffSet&& rhs) = delete; //! Find the parameter with the given name /*! \param [in] parName the name of the parameter to be found return the retrieved parameter */ LauParameter* findParameter(const TString& parName); //! Prepend the base name and index to the name of a parameter /*! \param [in,out] par the parameter to be renamed \param [in] oldBaseName the old base name, which might need to be removed before adding the new one */ virtual void adjustName(LauParameter& par, const TString& oldBaseName); //! Minimum allowed value of magnitude parameters static Double_t minMagnitude_; //! Maximum allowed value of magnitude parameters static Double_t maxMagnitude_; //! Minimum allowed value of phase parameters static Double_t minPhase_; //! Maximum allowed value of phase parameters static Double_t maxPhase_; //! Minimum allowed value of real/imaginary part parameters static Double_t minRealImagPart_; //! Maximum allowed value of real/imaginary part parameters static Double_t maxRealImagPart_; //! Minimum allowed value of CP-violating real/imaginary part parameters static Double_t minDelta_; //! Maximum allowed value of CP-violating real/imaginary part parameters static Double_t maxDelta_; private: //! Create a clone of the coefficient set /*! \param [in] newName the clone's name \param [in] cloneOption special option for the cloning operation \param [in] constFactor a constant factor by which to multiply the cloned parameters \param [in] coeffInfo an optional JSON entry that contains the values of any non-cloned parameters (depending on the CloneOption) \return a clone of the coefficient set */ virtual LauAbsCoeffSet* createClone_impl(const TString& newName, const CloneOption cloneOption, const Double_t constFactor, const nlohmann::json& coeffInfo) const = 0; //! Random number generator to use for randomising parameter starting values static TRandom* randomiser_; //! The name of the coefficient set TString name_; //! The base name of the coefficient set TString basename_; //! The index number of the coefficient set UInt_t index_{0}; //! The parent of this coefficient set, if this is a clone const LauAbsCoeffSet* const parent_{nullptr}; //! The clone option used, if applicable const CloneOption cloneOption_{CloneOption::All}; //! The constant factor used, if applicable const Double_t constFactor_{1.0}; ClassDef(LauAbsCoeffSet, 0) }; //! \cond DOXYGEN_IGNORE // map LauCoeffType values to JSON as strings NLOHMANN_JSON_SERIALIZE_ENUM( LauCoeffType, { {LauCoeffType::MagPhase, "MagPhase"}, {LauCoeffType::RealImag, "RealImag"}, {LauCoeffType::BelleCP, "BelleCP"}, {LauCoeffType::CartesianCP, "CartesianCP"}, {LauCoeffType::CartesianGammaCP, "CartesianGammaCP"}, {LauCoeffType::CleoCP, "CleoCP"}, {LauCoeffType::MagPhaseCP, "MagPhaseCP"}, {LauCoeffType::NSCCartesianCP, "NSCCartesianCP"}, {LauCoeffType::PolarGammaCP, "PolarGammaCP"}, {LauCoeffType::RealImagCP, "RealImagCP"}, {LauCoeffType::RealImagGammaCP, "RealImagGammaCP"}, }) // map Lau1DCubicSpline::BoundaryType values to JSON as strings NLOHMANN_JSON_SERIALIZE_ENUM( LauAbsCoeffSet::CloneOption, { {LauAbsCoeffSet::CloneOption::All, "All"}, {LauAbsCoeffSet::CloneOption::TiePhase, "TiePhase"}, {LauAbsCoeffSet::CloneOption::TieMagnitude, "TieMagnitude"}, {LauAbsCoeffSet::CloneOption::TieRealPart, "TieRealPart"}, {LauAbsCoeffSet::CloneOption::TieImagPart, "TieImagPart"}, {LauAbsCoeffSet::CloneOption::TieCPPars, "TieCPPars"}, }) // exceptions to be thrown in case of JSON type issues class LauWrongCoeffType : public std::runtime_error { public: LauWrongCoeffType(const std::string& what) : std::runtime_error(what) {} }; class LauClonedCoeff : public std::runtime_error { public: LauClonedCoeff(const std::string& what) : std::runtime_error(what) {} }; namespace nlohmann { template <> struct adl_serializer { static void to_json(json& j, const LauAbsCoeffSet& t) { t.serialiseToJson(j); } }; } //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauAbsIncohRes.hh b/inc/LauAbsIncohRes.hh index 9fbc4d4..9876c37 100644 --- a/inc/LauAbsIncohRes.hh +++ b/inc/LauAbsIncohRes.hh @@ -1,82 +1,85 @@ /* Copyright 2014 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauAbsIncohRes.hh \brief File containing declaration of LauAbsIncohRes class. */ /*! \class LauAbsIncohRes \brief Abstract class for defining incoherent resonant amplitude models */ #ifndef LAU_ABS_INCOH_RES #define LAU_ABS_INCOH_RES #include "TString.h" #include "LauAbsResonance.hh" class LauKinematics; class LauAbsIncohRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauAbsIncohRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauAbsIncohRes(); //! Get intensity factor /*! /param [in] kinematics kinematic parameters of the parent and daughter particles /return the intensity factor */ virtual Double_t intensityFactor(const LauKinematics* kinematics)=0; + //! Create a JSON object containing the current settings + virtual nlohmann::json writeSettingsToJson() const; + protected: //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); private: //! Copy constructor (not implemented) LauAbsIncohRes(const LauAbsIncohRes& rhs); //! Copy assignment operator (not implemented) LauAbsIncohRes& operator=(const LauAbsIncohRes& rhs); ClassDef(LauAbsIncohRes,0) // Abstract incoherent resonance class }; #endif diff --git a/inc/LauAbsModIndPartWave.hh b/inc/LauAbsModIndPartWave.hh index a4859e0..f49a4d1 100644 --- a/inc/LauAbsModIndPartWave.hh +++ b/inc/LauAbsModIndPartWave.hh @@ -1,254 +1,259 @@ /* Copyright 2014 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauAbsModIndPartWave.hh \brief File containing declaration of LauAbsModIndPartWave class. */ /*! \class LauAbsModIndPartWave \brief Abstract base class for defining a model independent partial wave component Abstract base class for defining a model independent partial wave component. This model uses splines to produce a partial wave from two sets of real numbers that represent the amplitude at a series of points in the phase space. These real numbers at each point can be floated in the fit. Classes inheriting from this define whether these real numbers are e.g. the magnitude and phase or e.g. the real and imaginary part of the amplitude. */ #ifndef LAU_ABSMODINDPARTWAVE #define LAU_ABSMODINDPARTWAVE -#include -#include - #include "LauComplex.hh" #include "LauAbsResonance.hh" #include "Lau1DCubicSpline.hh" +#include + +#include +#include + class LauAbsModIndPartWave : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles \param [in] spline1Name the name of the 1st spline, e.g. "Magnitude" or "Real Part" \param [in] spline2Name the name of the 2nd spline, e.g. "Phase" or "Imaginary Part" */ LauAbsModIndPartWave(LauResonanceInfo* resInfo, Int_t resPairAmpInt, const LauDaughters* daughters, const TString& spline1Name, const TString& spline2Name); //! Initialise the model virtual void initialise(); //! Define the knot positions /*! If absent from the set provided, knots are added automatically at the upper and lower kinematic limits \param [in] masses the mass values at which the knots are placed */ void defineKnots(const std::set& masses); //! Return the number of knots that have been defined (including those at the upper and lower kinematic limits) /*! \return the number of knots */ UInt_t nKnots() const { return nKnots_; } //! Set the values of the two real parameters that define the amplitude at a given knot /*! \param [in] knot the knot to be updated \param [in] ampVal1 the value of first real parameter representing the amplitude at the knot \param [in] ampVal2 the value of second real parameter representing the amplitude at the knot \param [in] fixAmpVal1 whether the first real parameter should be fixed \param [in] fixAmpVal2 whether the second real parameter should be fixed */ virtual void setKnotAmp(const UInt_t knot, const Double_t ampVal1, const Double_t ampVal2, const Bool_t fixAmpVal1, const Bool_t fixAmpVal2) = 0; //! Set whether the parameters should be floated only in the second-stage of a two-stage fit /*! By default, the parameters describing the amplitude at each knot will float from the outset of a fit. If, however, a good estimate of these is already known, it can be more efficient to initially fix them and then to float them only in a second stage (as is done for other resonance lineshape parameters). This function allows the toggling of this behaviour. \param secondStage whether the parameters should float only in the second stage */ void floatKnotsSecondStage(const Bool_t secondStage); //! Retrieve the value of the second stage flag - Bool_t floatKnotsSecondStage() const {return secondStage_;}; + [[nodiscard]] Bool_t floatKnotsSecondStage() const {return secondStage_;}; //! Method to set the type of interpolation used for the splines /*! \param [in] type1 the type of interpolation for the first spline \param [in] type2 the type of interpolation for the second spline */ virtual void setSplineType(Lau1DCubicSpline::SplineType type1, Lau1DCubicSpline::SplineType type2); //! Method to set the boundary conditions of the splines /*! \param [in] leftBound1 the type of boundary condition for the left edge of the first spline \param [in] rightBound1 the type of boundary condition for the right edge of the first spline \param [in] leftBound2 the type of boundary condition for the left edge of the second spline \param [in] rightBound2 the type of boundary condition for the right edge of the second spline \param [in] leftGrad1 the gradient at the left edge of the first spline if clamped \param [in] rightGrad1 the gradient at the right edge of the first spline if clamped \param [in] leftGrad2 the gradient at the left edge of the second spline if clamped \param [in] rightGrad2 the gradient at the right edge of the second spline if clamped */ virtual void setSplineBoundaryConditions(Lau1DCubicSpline::BoundaryType leftBound1, Lau1DCubicSpline::BoundaryType rightBound1, Lau1DCubicSpline::BoundaryType leftBound2, Lau1DCubicSpline::BoundaryType rightBound2, Double_t leftGrad1 = 0.0, Double_t rightGrad1 = 0.0, Double_t leftGrad2 = 0.0, Double_t rightGrad2 = 0.0); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); + //! Create a JSON object containing the current settings + virtual nlohmann::json writeSettingsToJson() const; + protected: //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); //! Evaluate the amplitude at the given point from the splines /*! \param [in] mass appropriate invariant mass for the resonance */ virtual void evaluateAmplitude(const Double_t mass) = 0; //! Method to check that the supplied knot positions are valid /*! \param [in] masses the mass values at which the knots are placed */ virtual std::set checkKnots(const std::set& masses); //! Method to create the parameter objects for the given knot /*! \param [in] iKnot the index of the knot */ virtual void createAmpParameters(const UInt_t iKnot) = 0; //! Helper function to set the current amplitude value /*! \param [in] realPart the real part of the amplitude \param [in] imagPart the imaginary part of the amplitude */ void setAmp(const Double_t realPart, const Double_t imagPart) { amp_.setRealImagPart(realPart,imagPart); } //! Helper function to access the masses const std::vector& getMasses() {return masses_;} //! Helper function to access the 1st parameter set std::vector& getAmp1Vals() {return amp1Vals_;} //! Helper function to access the 2nd parameter set std::vector& getAmp2Vals() {return amp2Vals_;} //! Helper function to access the 1st parameter set std::vector& getAmp1Pars() {return amp1Pars_;} //! Helper function to access the 2nd parameter set std::vector& getAmp2Pars() {return amp2Pars_;} //! Helper function to access the 1st spline const Lau1DCubicSpline& getSpline1() const {return *spline1_;} //! Helper function to access the 1st spline const Lau1DCubicSpline& getSpline2() const {return *spline2_;} private: //! Name of spline 1 TString spline1Name_; //! Name of spline 2 TString spline2Name_; //! The number of knots UInt_t nKnots_{0}; //! The masses at which knots are defined in the magnitude and phase splines std::vector masses_; //! The values of the first real parameter at each knot std::vector amp1Vals_; //! The values of the second real parameter at each knot std::vector amp2Vals_; //! The parameters for the first real value at the knots std::vector amp1Pars_; //! The parameters for the second real value at the knots std::vector amp2Pars_; //! The spline used to interpolate the values of the first real parameter std::unique_ptr spline1_; //! The spline used to interpolate the values of the second real parameter std::unique_ptr spline2_; //! The type of interpolation used for the first spline Lau1DCubicSpline::SplineType type1_{Lau1DCubicSpline::SplineType::StandardSpline}; //! The type of interpolation used for the second spline Lau1DCubicSpline::SplineType type2_{Lau1DCubicSpline::SplineType::StandardSpline}; //! The lower boundary condition type for the first spline Lau1DCubicSpline::BoundaryType leftBound1_{Lau1DCubicSpline::BoundaryType::NotAKnot}; //! The upper boundary condition type for the first spline Lau1DCubicSpline::BoundaryType rightBound1_{Lau1DCubicSpline::BoundaryType::NotAKnot}; //! The lower boundary condition type for the second spline Lau1DCubicSpline::BoundaryType leftBound2_{Lau1DCubicSpline::BoundaryType::NotAKnot}; //! The upper boundary condition type for the second spline Lau1DCubicSpline::BoundaryType rightBound2_{Lau1DCubicSpline::BoundaryType::NotAKnot}; //! The gradient at the left boundary for the first spline if clamped Double_t leftGrad1_{0.0}; //! The gradient at the right boundary for the first spline if clamped Double_t rightGrad1_{0.0}; //! The gradient at the left boundary for the second spline if clamped Double_t leftGrad2_{0.0}; //! The gradient at the right boundary for the second spline if clamped Double_t rightGrad2_{0.0}; //! Flag to determine if the parameters should be floated only in the second stage of the fit Bool_t secondStage_{kFALSE}; //! The current value of the amplitude LauComplex amp_; ClassDef(LauAbsModIndPartWave,0) // model independent partial wave }; #endif diff --git a/inc/LauAbsResonance.hh b/inc/LauAbsResonance.hh index 1cde038..05c8f7e 100644 --- a/inc/LauAbsResonance.hh +++ b/inc/LauAbsResonance.hh @@ -1,637 +1,650 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauAbsResonance.hh \brief File containing declaration of LauAbsResonance class. */ /*! \class LauAbsResonance \brief Abstract class for defining type for resonance amplitude models (Breit-Wigner, Flatte etc.) Abstract Class for defining the type for all classes used to model resonances in the Dalitz plot, such as Breit-Wigner functions. In addition, some common functionality is implemented, including data such as the mass and width of the desired state. */ #ifndef LAU_ABS_RESONANCE #define LAU_ABS_RESONANCE #include "LauBlattWeisskopfFactor.hh" #include "LauComplex.hh" #include "LauParameter.hh" #include "TString.h" #include class LauDaughters; class LauKinematics; class LauResonanceInfo; class LauAbsResonance { public: //! Define the allowed resonance types enum class ResonanceModel { BW, /*!< simple Breit-Wigner */ RelBW, /*!< relativistic Breit-Wigner */ GS, /*!< a modified Breit-Wigner from Gounaris-Sakurai */ Flatte, /*!< Flatte or coupled-channel Breit-Wigner */ Sigma, /*!< special shape for the sigma or f_0(600) */ Bugg, /*!< special shape for the sigma or f_0(600) */ Kappa, /*!< special shape for the kappa, a low-mass Kpi scalar */ Dabba, /*!< special shape for the dabba, a low-mass Dpi scalar */ LASS, /*!< the LASS amplitude to describe the Kpi S-wave */ LASS_BW, /*!< the resonant part of the LASS amplitude */ LASS_NR, /*!< the nonresonant part of the LASS amplitude */ EFKLLM, /*!< a form-factor-based description of the Kpi S-wave */ - KMatrix, /*!< description using K-matrix and P-vector */ + KMatrix_Pole, /*!< description using K-matrix and P-vector */ + KMatrix_SVP, /*!< description using K-matrix and P-vector */ FlatNR, /*!< a uniform nonresonant amplitude */ NRModel, /*!< a theoretical model nonresonant amplitude */ BelleNR, /*!< an empirical exponential nonresonant amplitude */ PowerLawNR, /*!< an empirical power law nonresonant amplitude */ BelleSymNR, /*!< an empirical exponential nonresonant amplitude for symmetrised DPs */ BelleSymNRNoInter, /*!< an empirical exponential nonresonant amplitude for symmetrised DPs without interference */ LHCbNR, /*!< an empirical exponential nonresonant amplitude with phase */ TaylorNR, /*!< an empirical Taylor expansion nonresonant amplitude for symmetrised DPs */ PolNR, /*!< an empirical polynomial nonresonant amplitude */ Pole, /*!< scalar Pole lineshape */ PolarFFNR, /*!< Polar Form Factor nonresonant amplitude */ PolarFFSymNR, /*!< Polar Form Factor nonresonant amplitude for symmetrised DPs */ PolarFFSymNRNoInter, /*!< Polar Form Factor nonresonant amplitude for symmetrised DPs without interference */ Rescattering, /*!< KK-PiPi inelastic scattering amplitude */ Rescattering2, /*!< KK-PiPi inelastic scattering amplitude */ RescatteringNoInter, /*!< KK-PiPi inelastic scattering amplitude */ MIPW_MagPhase, /*!< a model independent partial wave - magnitude and phase representation */ MIPW_RealImag, /*!< a model independent partial wave - real and imaginary part representation */ GaussIncoh, /*!< an incoherent Gaussian shape */ RhoOmegaMix_GS, /*!< mass mixing model using GS for res 1 and RBW for res 2 */ RhoOmegaMix_RBW, /*!< mass mixing model using two RBWs */ RhoOmegaMix_GS_1, /*!< mass mixing model using GS for res 1 and RBW for res 2, with denominator factor = 1 */ RhoOmegaMix_RBW_1 /*!< mass mixing model using two RBWs, with denominator factor = 1 */ }; //! Define the allowed spin formalisms enum class SpinType { Zemach_P, /*!< Zemach tensor formalism, bachelor momentum in resonance rest frame */ Zemach_Pstar, /*!< Zemach tensor formalism, bachelor momentum in parent rest frame */ Covariant, /*!< Covariant tensor formalism, bachelor momentum in parent rest frame */ Covariant_P, /*!< Covariant tensor formalism, bachelor momentum in resonance rest frame */ Legendre /*!< Legendre polynomials only */ }; //! Is the resonance model incoherent? /*! \param [in] model the resonance model \return true if the model is incoherent */ static bool isIncoherentModel(ResonanceModel model); //! Constructor (for use by standard resonances) /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauAbsResonance(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Constructor (for use by K-matrix components) /*! \param [in] resName the name of the component \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles \param [in] resSpin the spin of the final channel into which the K-matrix scatters */ LauAbsResonance(const TString& resName, const Int_t resPairAmpInt, const LauDaughters* daughters, const Int_t resSpin); //! Destructor virtual ~LauAbsResonance(); //! Initialise the model virtual void initialise() = 0; //! Calculate the complex amplitude /*! \param [in] kinematics the kinematic variables of the current event \return the complex amplitude */ virtual LauComplex amplitude(const LauKinematics* kinematics); //! Get the resonance model type /*! \return the resonance model type */ virtual ResonanceModel getResonanceModel() const = 0; //! Get the spin type /*! \return the spin formalism */ SpinType getSpinType() const {return spinType_;} //! Get the name of the resonance /*! \return the resonance name */ const TString& getResonanceName() const {return resName_;} //! Get the name of the resonance /*! \return the resonance name */ const TString& getSanitisedName() const {return sanitisedName_;} //! Get the integer to identify which DP axis the resonance belongs to /*! \return the DP axis identification number, the ID of the bachelor */ Int_t getPairInt() const {return resPairAmpInt_;} //! Get the spin of the resonance /*! \return the resonance spin */ Int_t getSpin() const {return resSpin_;} //! Get the charge of the resonance /*! \return the resonance charge */ Int_t getCharge() const {return resCharge_;} //! Get the mass of the resonance /*! \return the resonance mass */ Double_t getMass() const {return (resMass_!=nullptr) ? resMass_->unblindValue() : -1.0;} //! Get the width of the resonance /*! \return the resonance width */ Double_t getWidth() const {return (resWidth_!=nullptr) ? resWidth_->unblindValue() : -1.0;} //! Get the mass parameter of the resonance /*! \return the resonance mass parameter */ LauParameter* getMassPar() {return resMass_;} //! Get the width parameter of the resonance /*! \return the resonance width parameter */ LauParameter* getWidthPar() {return resWidth_;} //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters() { return this->getParameters(); }; //! Is the amplitude pre-symmetrised? /*! The default value is kFALSE, so pre-symmetrised lineshapes should override this. \return whether the amplitude is already symmetrised */ virtual Bool_t preSymmetrised() const {return kFALSE;} //! Get the helicity flip flag /*! \return the flip helicity flag */ Bool_t flipHelicity() const {return flipHelicity_;} //! Set the helicity flip flag /*! \param [in] boolean the helicity flip status */ void flipHelicity(const Bool_t boolean) {flipHelicity_ = boolean;} //! Get the ignore momenta flag /*! Whether to ignore the momentum factors in both the spin factor and the mass-dependent width \return the ignore momenta flag */ Bool_t ignoreMomenta() const {return ignoreMomenta_;} //! Set the ignore momenta flag /*! Whether to ignore the momentum factors in both the spin factor and the mass-dependent width \param [in] boolean the ignore momenta status */ void ignoreMomenta(const Bool_t boolean) {ignoreMomenta_ = boolean;} //! Get the ignore spin flag /*! Whether to set the spinTerm to unity always \return the ignore spin flag */ Bool_t ignoreSpin() const {return ignoreSpin_;} //! Set the ignore spin flag /*! Whether to set the spinTerm to unity always \param [in] boolean the ignore spin status */ void ignoreSpin(const Bool_t boolean) {ignoreSpin_ = boolean;} //! Get the ignore barrier factor scaling flag /*! Whether to ignore barrier factor scaling in the amplitude numerator, they are still used for the mass-dependent width \return the ignore barrier amplitude scaling flag */ Bool_t ignoreBarrierScaling() const {return ignoreBarrierScaling_;} //! Set the ignore barrier factor scaling flag /*! Whether to ignore barrier factor scaling in the amplitude numerator, they are still used for the mass-dependent width \param [in] boolean the ignore barrier factor scaling status */ void ignoreBarrierScaling(const Bool_t boolean) {ignoreBarrierScaling_ = boolean;} //! Allow the mass, width and spin of the resonance to be changed /*! Negative values wil be ignored, so if, for example, you want to only change the spin you can provide negative values for the mass and width \param [in] newMass new value of the resonance mass \param [in] newWidth new value of the resonance width \param [in] newSpin new value of the resonance spin */ void changeResonance(const Double_t newMass, const Double_t newWidth, const Int_t newSpin); //! Allow the Blatt-Weisskopf radius for the resonance and parent factors to be changed /*! Negative values wil be ignored, so if, for example, you want to only change the parent radius you can provide a negative value for the resonance radius \param [in] resRadius new value of the resonance radius \param [in] parRadius new value of the parent radius */ void changeBWBarrierRadii(const Double_t resRadius, const Double_t parRadius); //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Fix or release the resonance mass /*! \param [in] parFixed new status of mass */ void fixMass(const Bool_t parFixed) { if (resMass_!=nullptr) { resMass_->fixed(parFixed); } } //! Fix or release the resonance width /*! \param [in] parFixed new status of width */ void fixWidth(const Bool_t parFixed) { if (resWidth_!=nullptr) { resWidth_->fixed(parFixed); } } //! Get the status of resonance mass (fixed or released) /*! \return the status of resonance mass (fixed or released) */ Bool_t fixMass() const { return (resMass_!=nullptr) ? resMass_->fixed() : kTRUE; } //! Get the status of resonance width (fixed or released) /*! \return the status of resonance width (fixed or released) */ Bool_t fixWidth() const { return (resWidth_!=nullptr) ? resWidth_->fixed() : kTRUE; } //! Set the spin formalism to be used /*! \param [in] spinType the spin formalism */ void setSpinType(const SpinType spinType) {spinType_ = spinType;} //! Set the form factor model and parameters /*! \param [in] resFactor the barrier factor for the resonance decay \param [in] parFactor the barrier factor for the parent decay */ void setBarrierRadii(LauBlattWeisskopfFactor* resFactor, LauBlattWeisskopfFactor* parFactor) { resBWFactor_ = resFactor; parBWFactor_ = parFactor; } //! Fix or release the Blatt-Weisskopf barrier radii void fixBarrierRadii(const Bool_t fixResRadius, const Bool_t fixParRadius); //! Get the status of resonance barrier radius (fixed or released) Bool_t fixResRadius() const; //! Get the status of parent barrier radius (fixed or released) Bool_t fixParRadius() const; //! Get the radius of the resonance barrier factor Double_t getResRadius() const; //! Get the radius of the parent barrier factor Double_t getParRadius() const; + //! Access the resonance info object + const LauResonanceInfo* getResInfo() const {return resInfo_;} + + //! Get the centrifugal barrier for the parent decay + const LauBlattWeisskopfFactor* getParBWFactor() const {return parBWFactor_;} + + //! Get the centrifugal barrier for the resonance decay + const LauBlattWeisskopfFactor* getResBWFactor() const {return resBWFactor_;} + + //! Create a JSON object containing the current settings + virtual nlohmann::json writeSettingsToJson() const; + protected: //! Get the name of the parent particle TString getNameParent() const; //! Get the name of the first daughter of the resonance TString getNameDaug1() const; //! Get the name of the second daughter of the resonance TString getNameDaug2() const; //! Get the name of the daughter that does not originate form the resonance TString getNameBachelor() const; //! Get the parent particle mass Double_t getMassParent() const; //! Get the mass of daughter 1 Double_t getMassDaug1() const; //! Get the mass of daughter 2 Double_t getMassDaug2() const; //! Get the mass of the bachelor daughter Double_t getMassBachelor() const; //! Get the Charge of the parent particle Int_t getChargeParent() const; //! Get the charge of daughter 1 Int_t getChargeDaug1() const; //! Get the charge of daughter 2 Int_t getChargeDaug2() const; //! Get the charge of the bachelor daughter Int_t getChargeBachelor() const; //! Get the current value of the daughter momentum in the resonance rest frame Double_t getQ() const {return q_;} //! Get the current value of the bachelor momentum in the resonance rest frame Double_t getP() const {return p_;} //! Get the current value of the bachelor momentum in the parent rest frame Double_t getPstar() const {return pstar_;} //! Get the current value of the full spin-dependent covariant factor Double_t getCovFactor() const {return covFactor_;} //! Get the centrifugal barrier for the parent decay LauBlattWeisskopfFactor* getParBWFactor() {return parBWFactor_;} - //! Get the centrifugal barrier for the parent decay - const LauBlattWeisskopfFactor* getParBWFactor() const {return parBWFactor_;} //! Get the centrifugal barrier for the resonance decay LauBlattWeisskopfFactor* getResBWFactor() {return resBWFactor_;} - //! Get the centrifugal barrier for the resonance decay - const LauBlattWeisskopfFactor* getResBWFactor() const {return resBWFactor_;} //! Access the resonance info object - LauResonanceInfo* getResInfo() const {return resInfo_;} + LauResonanceInfo* getResInfo() {return resInfo_;} //! Access the daughters object const LauDaughters* getDaughters() const {return daughters_;} //! Calculate the amplitude spin term using the Zemach tensor formalism /*! \param [in] pProd the momentum factor (either q * p or q * pstar) */ Double_t calcZemachSpinFactor( const Double_t pProd ) const; //! Calculate the amplitude spin term using the covariant tensor formalism /*! \param [in] pProd the momentum factor (q * pstar) */ Double_t calcCovSpinFactor( const Double_t pProd ); //! Calculate the spin-dependent covariant factor /*! \param [in] erm E_ij in the parent rest-frame divided by m_ij (equivalent to sqrt(1 + p^2/mParent^2)) */ void calcCovFactor( const Double_t erm ); //! Calculate the Legendre polynomial for the spin factor /*! Uses the current-event value of cosHel_ */ Double_t calcLegendrePoly() const; //! Calculate the Legendre polynomial for the spin factor (specifying the cosHel value) /*! \param [in] cosHel the cosine of the helicity angle */ Double_t calcLegendrePoly( const Double_t cosHel ); //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm) = 0; //! Clear list of floating parameters void clearFloatingParameters() { resParameters_.clear(); } //! Add parameter to the list of floating parameters /*! \param [in] param the parameter to be added to the list */ void addFloatingParameter( LauParameter* param ); //! Access the list of floating parameters std::vector& getParameters() { return resParameters_; } + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return {}; } + private: //! Copy constructor (not implemented) LauAbsResonance(const LauAbsResonance& rhs); //! Copy assignment operator (not implemented) LauAbsResonance& operator=(const LauAbsResonance& rhs); //! Information on the resonance LauResonanceInfo* resInfo_{nullptr}; //! Information on the particles const LauDaughters* daughters_; //! Parent name TString nameParent_{""}; //! Daughter 1 name TString nameDaug1_{""}; //! Daughter 2 name TString nameDaug2_{""}; //! Bachelor name TString nameBachelor_{""}; //! Parent charge Int_t chargeParent_{0}; //! Daughter 1 charge Int_t chargeDaug1_{0}; //! Daughter 2 charge Int_t chargeDaug2_{0}; //! Bachelor charge Int_t chargeBachelor_{0}; //! Parent mass Double_t massParent_{0.0}; //! Daughter 1 mass Double_t massDaug1_{0.0}; //! Daughter 2 mass Double_t massDaug2_{0.0}; //! Bachelor mass Double_t massBachelor_{0.0}; //! Resonance name TString resName_; //! Resonance name with illegal characters removed TString sanitisedName_; //! Resonance mass LauParameter* resMass_{nullptr}; //! Resonance width LauParameter* resWidth_{nullptr}; //! All parameters of the resonance std::vector resParameters_; //! Resonance spin Int_t resSpin_; //! Resonance charge Int_t resCharge_{0}; //! DP axis identifier Int_t resPairAmpInt_; //! Blatt Weisskopf barrier for parent decay LauBlattWeisskopfFactor* parBWFactor_{nullptr}; //! Blatt Weisskopf barrier for resonance decay LauBlattWeisskopfFactor* resBWFactor_{nullptr}; //! Spin formalism SpinType spinType_{SpinType::Zemach_P}; //! Boolean to flip helicity Bool_t flipHelicity_{kFALSE}; //! Boolean to ignore the momentum factors in both the spin factor and the mass-dependent width Bool_t ignoreMomenta_{kFALSE}; //! Boolean to set the spinTerm to unity always Bool_t ignoreSpin_{kFALSE}; //! Boolean to ignore barrier factor scaling in the amplitude numerator, they are still used for the mass-dependent width Bool_t ignoreBarrierScaling_{kFALSE}; // Event kinematics information //! Invariant mass Double_t mass_{0.0}; //! Helicity angle cosine Double_t cosHel_{0.0}; //! Daughter momentum in resonance rest frame Double_t q_{0.0}; //! Bachelor momentum in resonance rest frame Double_t p_{0.0}; //! Bachelor momentum in parent rest frame Double_t pstar_{0.0}; //! Covariant factor /*! sqrt(1 + z*z), where z = p / mParent Can also be expressed as E_ij in the parent rest-frame divided by m_ij - indeed this is how LauKinematics calculates it. \see LauKinematics::getcov12 \see LauKinematics::getcov13 \see LauKinematics::getcov23 */ Double_t erm_{1.0}; //! Covariant factor (full spin-dependent expression) Double_t covFactor_{1.0}; ClassDef(LauAbsResonance,0) // Abstract resonance class }; //! \cond DOXYGEN_IGNORE // map LauAbsResonance::ResonanceModel values to JSON as strings NLOHMANN_JSON_SERIALIZE_ENUM( LauAbsResonance::ResonanceModel, { {LauAbsResonance::ResonanceModel::BW, "BW"}, {LauAbsResonance::ResonanceModel::RelBW, "RelBW"}, {LauAbsResonance::ResonanceModel::GS, "GS"}, {LauAbsResonance::ResonanceModel::Flatte, "Flatte"}, {LauAbsResonance::ResonanceModel::Sigma, "Sigma"}, {LauAbsResonance::ResonanceModel::Bugg, "Bugg"}, {LauAbsResonance::ResonanceModel::Kappa, "Kappa"}, {LauAbsResonance::ResonanceModel::Dabba, "Dabba"}, {LauAbsResonance::ResonanceModel::LASS, "LASS"}, {LauAbsResonance::ResonanceModel::LASS_BW, "LASS_BW"}, {LauAbsResonance::ResonanceModel::LASS_NR, "LASS_NR"}, {LauAbsResonance::ResonanceModel::EFKLLM, "EFKLLM"}, - {LauAbsResonance::ResonanceModel::KMatrix, "KMatrix"}, + {LauAbsResonance::ResonanceModel::KMatrix_Pole, "KMatrix_Pole"}, + {LauAbsResonance::ResonanceModel::KMatrix_SVP, "KMatrix_SVP"}, {LauAbsResonance::ResonanceModel::FlatNR, "FlatNR"}, {LauAbsResonance::ResonanceModel::NRModel, "NRModel"}, {LauAbsResonance::ResonanceModel::BelleNR, "BelleNR"}, {LauAbsResonance::ResonanceModel::PowerLawNR, "PowerLawNR"}, {LauAbsResonance::ResonanceModel::BelleSymNR, "BelleSymNR"}, {LauAbsResonance::ResonanceModel::BelleSymNRNoInter, "BelleSymNRNoInter"}, {LauAbsResonance::ResonanceModel::LHCbNR, "LHCbNR"}, {LauAbsResonance::ResonanceModel::TaylorNR, "TaylorNR"}, {LauAbsResonance::ResonanceModel::PolNR, "PolNR"}, {LauAbsResonance::ResonanceModel::Pole, "Pole"}, {LauAbsResonance::ResonanceModel::PolarFFNR, "PolarFFNR"}, {LauAbsResonance::ResonanceModel::PolarFFSymNR, "PolarFFSymNR"}, {LauAbsResonance::ResonanceModel::PolarFFSymNRNoInter, "PolarFFSymNRNoInter"}, {LauAbsResonance::ResonanceModel::Rescattering, "Rescattering"}, {LauAbsResonance::ResonanceModel::Rescattering2, "Rescattering2"}, {LauAbsResonance::ResonanceModel::RescatteringNoInter, "RescatteringNoInter"}, {LauAbsResonance::ResonanceModel::MIPW_MagPhase, "MIPW_MagPhase"}, {LauAbsResonance::ResonanceModel::MIPW_RealImag, "MIPW_RealImag"}, {LauAbsResonance::ResonanceModel::GaussIncoh, "GaussIncoh"}, {LauAbsResonance::ResonanceModel::RhoOmegaMix_GS, "RhoOmegaMix_GS"}, {LauAbsResonance::ResonanceModel::RhoOmegaMix_RBW, "RhoOmegaMix_RBW"}, {LauAbsResonance::ResonanceModel::RhoOmegaMix_GS_1, "RhoOmegaMix_GS_1"}, {LauAbsResonance::ResonanceModel::RhoOmegaMix_RBW_1, "RhoOmegaMix_RBW_1"}, }) // map LauAbsResonance::SpinType values to JSON as strings NLOHMANN_JSON_SERIALIZE_ENUM( LauAbsResonance::SpinType, { {LauAbsResonance::SpinType::Zemach_P, "Zemach_P"}, {LauAbsResonance::SpinType::Zemach_Pstar, "Zemach_Pstar"}, {LauAbsResonance::SpinType::Covariant, "Covariant"}, {LauAbsResonance::SpinType::Covariant_P, "Covariant_P"}, {LauAbsResonance::SpinType::Legendre, "Legendre"}, }) //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauBelleNR.hh b/inc/LauBelleNR.hh index 3d03870..e7392d1 100644 --- a/inc/LauBelleNR.hh +++ b/inc/LauBelleNR.hh @@ -1,155 +1,164 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauBelleNR.hh \brief File containing declaration of LauBelleNR class. */ /*! \class LauBelleNR \brief Class for defining the Belle nonresonant model. Defines the nonresonant model from the Belle collaboration. arXiv:hep-ex/0412066 */ #ifndef LAU_BELLE_NR #define LAU_BELLE_NR #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauKinematics; class LauParameter; class LauBelleNR : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resType the model of the resonance \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauBelleNR(LauResonanceInfo* resInfo, const LauAbsResonance::ResonanceModel resType, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauBelleNR(); //! Override the enforcement of pure Legendre polynomial spin factors /*! By default this model uses pure Legendre polynomial spin factors, regardless of the default type set in LauResonanceMaker or any specific request from the user. This function allows the enforcement to be overridden. \param [in] forceLegendre boolean flag (kTRUE, the default, implies enforcement of pure Legendre spin factors, kFALSE overrides this to allow use of other formalisms) */ void enforceLegendreSpinFactors( const Bool_t forceLegendre ) { forceLegendre_ = forceLegendre; } + //! Check if we are enforcing pure Legendre polynomial spin factors + [[nodiscard]] Bool_t enforceLegendreSpinFactors() const { return forceLegendre_; } + //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return model_;} //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); + //! Create a JSON object containing the current settings + virtual nlohmann::json writeSettingsToJson() const; + protected: //! Set the parameter alpha, the effective range /*! \param [in] alpha the new effective range parameter value */ void setAlpha(const Double_t alpha); //! Get the effective range parameter /*! \return the effective range parameter */ Double_t getAlpha() const {return (alpha_!=0) ? alpha_->unblindValue() : 0.0;} //! See if the alpha parameter is fixed or floating /*! \return kTRUE if the effective range parameter is fixed, kFALSE otherwise */ Bool_t fixAlpha() const {return (alpha_!=0) ? alpha_->fixed() : kTRUE;} //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { alpha_ }; } + private: //! Copy constructor (not implemented) LauBelleNR(const LauBelleNR& rhs); //! Copy assignment operator (not implemented) LauBelleNR& operator=(const LauBelleNR& rhs); //! The range parameter LauParameter* alpha_; //! The model to use LauAbsResonance::ResonanceModel model_; //! Force use of Legendre spin factors Bool_t forceLegendre_; ClassDef(LauBelleNR,0) }; #endif diff --git a/inc/LauBelleSymNR.hh b/inc/LauBelleSymNR.hh index 320162f..63a5c69 100644 --- a/inc/LauBelleSymNR.hh +++ b/inc/LauBelleSymNR.hh @@ -1,147 +1,150 @@ /* Copyright 2013 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauBelleSymNR.hh \brief File containing declaration of LauBelleSymNR class. */ /*! \class LauBelleSymNR \brief Class for defining the symmetric Belle Non Resonant model Defines the Non Resonant model from the Belle collaboration for the case of a symmetrical DP */ #ifndef LAU_BELLE_SYM_NR #define LAU_BELLE_SYM_NR #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauKinematics; class LauBelleSymNR : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resType the model of the resonance \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauBelleSymNR(LauResonanceInfo* resInfo, const LauAbsResonance::ResonanceModel resType, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauBelleSymNR(); //! Initialise virtual void initialise(); //! Get the complex dynamical amplitude /*! \param [in] kinematics the kinematic variables of the current event \return the complex amplitude */ virtual LauComplex amplitude(const LauKinematics* kinematics); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return model_;} //! Is the amplitude pre-symmetrised? /*! \return kTRUE, indicating that the amplitude is already symmetrised */ virtual Bool_t preSymmetrised() const {return kTRUE;} //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the parameter alpha, the effective range /*! \param [in] alpha the new effective range parameter */ void setAlpha(const Double_t alpha); //! Get the effective range parameter /*! \return the effective range parameter */ Double_t getAlpha() const {return (alpha_!=0) ? alpha_->unblindValue() : 0.0;} //! See if the alpha parameter is fixed or floating Bool_t fixAlpha() const {return (alpha_!=0) ? alpha_->fixed() : kTRUE;} //! This is not called, amplitude is used directly instead virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { alpha_ }; } + private: //! Copy constructor (not implemented) LauBelleSymNR(const LauBelleSymNR& rhs); //! Copy assignment operator (not implemented) LauBelleSymNR& operator=(const LauBelleSymNR& rhs); //! The range parameter LauParameter* alpha_; //! The model to use LauAbsResonance::ResonanceModel model_; ClassDef(LauBelleSymNR,0) // Belle Non-resonant model }; #endif diff --git a/inc/LauBlattWeisskopfFactor.hh b/inc/LauBlattWeisskopfFactor.hh index a32a84a..84f2d78 100644 --- a/inc/LauBlattWeisskopfFactor.hh +++ b/inc/LauBlattWeisskopfFactor.hh @@ -1,183 +1,236 @@ /* Copyright 2014 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauBlattWeisskopfFactor.hh \brief File containing declaration of LauBlattWeisskopfFactor class. */ /*! \class LauBlattWeisskopfFactor \brief Class that implements the Blatt-Weisskopf barrier factor This factor is used in resonance models such as the Relativistic Breit-Wigner. */ #ifndef LAU_BLATTWEISSKOPFFACTOR #define LAU_BLATTWEISSKOPFFACTOR #include "Rtypes.h" #include "TString.h" #include +#include +#include + class LauParameter; class LauResonanceInfo; class LauBlattWeisskopfFactor final { public: //! Define the allowed types of barrier factors enum class BarrierType { BWBarrier, /*!< Blatt-Weisskopf barrier factor (for use when momentum terms not used in angular term) */ BWPrimeBarrier, /*!< Blatt-Weisskopf barrier factor (for use when momentum terms are used in angular term) - the default */ ExpBarrier /*!< expoential barrier factor (mostly used for virtual contributions) */ }; //! Define the rest frame in which the momentum should be calculated (only relevant for bachelor) enum class RestFrame { Covariant, /*!< use expression from Covariant spin factor */ ParentFrame, /*!< momentum calculated in parent rest frame */ ResonanceFrame /*!< momentum calculated in resonance rest frame */ }; //! Define resonance categories that will share common barrier factor radii enum class Category { Default, //*!< indicates that LauResonanceMaker should use the appropriate category for the given resonance */ Parent, //*!< indicates that this is the factor for the decay of the parent particle */ Indep, //*!< indicates that this resonance should be independent of all others */ Light, //*!< default category for light unflavoured states, e.g. rho(77), f0(980), etc. */ Kstar, //*!< default category for K* states */ Charm, //*!< default category for D* states */ StrangeCharm, //*!< default category for Ds* states */ Charmonium, //*!< default category for ccbar states */ Beauty, //*!< default category for B* states */ StrangeBeauty, //*!< default category for Bs* states */ CharmBeauty, //*!< default category for Bc* states */ Custom1, //*!< user-defined category */ Custom2, //*!< user-defined category */ Custom3, //*!< user-defined category */ Custom4 //*!< user-defined category */ }; //! Constructor LauBlattWeisskopfFactor( const LauResonanceInfo& resInfo, const BarrierType barrierType, const RestFrame restFrame, const Category category ); //! Constructor LauBlattWeisskopfFactor( const LauResonanceInfo& resInfo, const Double_t resRadius, const BarrierType barrierType, const RestFrame restFrame, const Category category ); //! Constructor - LauBlattWeisskopfFactor( const Int_t spin, const Double_t resRadius, const BarrierType barrierType, const RestFrame restFrame, const Category category ); + LauBlattWeisskopfFactor( const UInt_t spin, const Double_t resRadius, const BarrierType barrierType, const RestFrame restFrame, const Category category ); + + //! Copy constructor (deleted) + LauBlattWeisskopfFactor( const LauBlattWeisskopfFactor& other ) = delete; + + //! Move constructor (deleted) + LauBlattWeisskopfFactor( LauBlattWeisskopfFactor&& other ) = delete; + + //! Copy assignment operator (deleted) + LauBlattWeisskopfFactor& operator=( const LauBlattWeisskopfFactor& other ) = delete; + + //! Move assignment operator (deleted) + LauBlattWeisskopfFactor& operator=( LauBlattWeisskopfFactor&& other ) = delete; + + //! Destructor + ~LauBlattWeisskopfFactor() noexcept; //! Method to create a new factor with cloned radius parameter /*! \param newSpin the value of the spin to use for the created instance \param newBarrierType the BarrierType to use for the created instance */ LauBlattWeisskopfFactor* createClone( const UInt_t newSpin , const BarrierType newBarrierType ); + //! Check whether is a clone or not + Bool_t clone() const { return parent_ != nullptr; } + + //! Get the parent factor + const LauBlattWeisskopfFactor* getParent() const { return parent_; } + + //! Get the parent factor + LauBlattWeisskopfFactor* getParent() { return parent_; } + //! Retrieve the radius parameter - const LauParameter* getRadiusParameter() const { return radius_; } + const LauParameter* getRadiusParameter() const { return radius_.get(); } //! Retrieve the radius parameter - LauParameter* getRadiusParameter() { return radius_; } + LauParameter* getRadiusParameter() { return radius_.get(); } //! Retrieve the barrier type BarrierType getBarrierType() const { return barrierType_; } //! Retrieve the rest frame information RestFrame getRestFrame() const { return restFrame_; } //! Calculate form factor value /*! \param p the value of the momentum */ Double_t calcFormFactor( const Double_t p ) const; private: - //! Copy constructor - LauBlattWeisskopfFactor( const LauBlattWeisskopfFactor& other, const UInt_t newSpin, const BarrierType newBarrierType ); + //! Copy constructor (with options) + LauBlattWeisskopfFactor( LauBlattWeisskopfFactor& other, const UInt_t newSpin, const BarrierType newBarrierType ); - //! Copy assignment operator (not implemented) - LauBlattWeisskopfFactor& operator=( const LauBlattWeisskopfFactor& other ); + //! Mark this as a clone of the given parent + /*! + \param theparent the parent parameter + */ + void setParent(LauBlattWeisskopfFactor* theparent) + { + parent_ = theparent; + } + + //! Method to remove a clone from the list of clones + /*! + This is used in the destructor to allow a clone to inform its parent it is no longer around + + \param [in] clone the clone to be removed from the list + */ + void removeFromCloneList(LauBlattWeisskopfFactor* clone) + { + auto iter = clones_.find( clone ); + if ( iter != clones_.end() ) { + clones_.erase( iter ); + } + } //! Set the name of the radius parameter TString setRadiusName( const LauResonanceInfo& resInfo, const Category category ); //! Set the name of the radius parameter TString setRadiusName( const Category category ); //! Set the name of the radius parameter TString setRadiusName( const TString& categoryName ); + //! The parent factor (nullptr if this is not a clone) + LauBlattWeisskopfFactor* parent_{nullptr}; + + //! The clones of this factor + std::set clones_; + //! Resonance spin const UInt_t spin_; //! Radius parameter - LauParameter* radius_; + std::unique_ptr radius_; //! Barrier type const BarrierType barrierType_; //! Rest frame const RestFrame restFrame_; ClassDef(LauBlattWeisskopfFactor, 0) }; //! \cond DOXYGEN_IGNORE // map LauBlattWeisskopfFactor::BarrierType values to JSON as strings NLOHMANN_JSON_SERIALIZE_ENUM( LauBlattWeisskopfFactor::BarrierType, { {LauBlattWeisskopfFactor::BarrierType::BWPrimeBarrier, "BWPrimeBarrier"}, {LauBlattWeisskopfFactor::BarrierType::BWBarrier, "BWBarrier"}, {LauBlattWeisskopfFactor::BarrierType::ExpBarrier, "ExpBarrier"}, }) // map LauBlattWeisskopfFactor::RestFrame values to JSON as strings NLOHMANN_JSON_SERIALIZE_ENUM( LauBlattWeisskopfFactor::RestFrame, { {LauBlattWeisskopfFactor::RestFrame::ResonanceFrame, "ResonanceFrame"}, {LauBlattWeisskopfFactor::RestFrame::Covariant, "Covariant"}, {LauBlattWeisskopfFactor::RestFrame::ParentFrame, "ParentFrame"}, }) // map LauBlattWeisskopfFactor::Category values to JSON as strings NLOHMANN_JSON_SERIALIZE_ENUM( LauBlattWeisskopfFactor::Category, { {LauBlattWeisskopfFactor::Category::Default, "Default"}, {LauBlattWeisskopfFactor::Category::Parent, "Parent"}, {LauBlattWeisskopfFactor::Category::Indep, "Indep"}, {LauBlattWeisskopfFactor::Category::Light, "Light"}, {LauBlattWeisskopfFactor::Category::Kstar, "Kstar"}, {LauBlattWeisskopfFactor::Category::Charm, "Charm"}, {LauBlattWeisskopfFactor::Category::StrangeCharm, "StrangeCharm"}, {LauBlattWeisskopfFactor::Category::Charmonium, "Charmonium"}, {LauBlattWeisskopfFactor::Category::Beauty, "Beauty"}, {LauBlattWeisskopfFactor::Category::StrangeBeauty, "StrangeBeauty"}, {LauBlattWeisskopfFactor::Category::CharmBeauty, "CharmBeauty"}, {LauBlattWeisskopfFactor::Category::Custom1, "Custom1"}, {LauBlattWeisskopfFactor::Category::Custom2, "Custom2"}, {LauBlattWeisskopfFactor::Category::Custom3, "Custom3"}, {LauBlattWeisskopfFactor::Category::Custom4, "Custom4"}, }) //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauBuggRes.hh b/inc/LauBuggRes.hh index 24ab3c9..09d4fda 100644 --- a/inc/LauBuggRes.hh +++ b/inc/LauBuggRes.hh @@ -1,208 +1,211 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauBuggRes.hh \brief File containing declaration of LauBuggRes class. */ /*! \class LauBuggRes \brief Class for defining the Bugg resonance model Class for defining the Bugg resonance model. Formulae and data values from Phys.Lett.B 572, 1 (2003) - author D.V.Bugg */ #ifndef LAU_BUGG_RES #define LAU_BUGG_RES #include "TString.h" #include "LauAbsResonance.hh" #include "LauComplex.hh" class LauBuggRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauBuggRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauBuggRes(); //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::Bugg;} //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the b1 parameter /*! \param [in] b1 new value for b1 parameter */ void setB1Value(const Double_t b1); //! Set the b2 parameter /*! \param [in] b2 new value for b2 parameter */ void setB2Value(const Double_t b2); //! Set the A parameter /*! \param [in] A new value for A parameter */ void setAValue(const Double_t A); //! Set the m0 parameter /*! \param [in] m0 new value for m0 parameter */ void setM0Value(const Double_t m0); //! Get the b1 parameter value /*! \return value of the b1 parameter */ Double_t getB1Value() const { return (b1_!=0) ? b1_->unblindValue() : 0.0; } //! Get the b2 parameter value /*! \return value of the b2 parameter */ Double_t getB2Value() const { return (b2_!=0) ? b2_->unblindValue() : 0.0; } //! Get the A parameter value /*! \return value of the A parameter */ Double_t getAValue() const { return (a_!=0) ? a_->unblindValue() : 0.0; } //! Get the m0 parameter value /*! \return value of the m0 parameter */ Double_t getM0Value() const { return (m0_!=0) ? m0_->unblindValue() : 0.0; } //! Fix the b1 parameter value /*! \return kTRUE if the b1 parameter is fixed, kFALSE otherwise */ Bool_t fixB1Value() const { return (b1_!=0) ? b1_->fixed() : 0.0; } //! Fix the b2 parameter value /*! \return kTRUE if the b2 parameter is fixed, kFALSE otherwise */ Bool_t fixB2Value() const { return (b2_!=0) ? b2_->fixed() : 0.0; } //! Fix the A parameter value /*! \return kTRUE if the A parameter is fixed, kFALSE otherwise */ Bool_t fixAValue() const { return (a_!=0) ? a_->fixed() : 0.0; } //! Fix the m0 parameter value /*! \return kTRUE if the m0 parameter is fixed, kFALSE otherwise */ Bool_t fixM0Value() const { return (m0_!=0) ? m0_->fixed() : 0.0; } //! Complex resonant ampltiude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); //! Check that both daughters are the same type of particle void checkDaughterTypes() const; + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { b1_, b2_, a_, m0_ }; } + private: //! Copy constructor (not implemented) LauBuggRes(const LauBuggRes& rhs); //! Copy assignment operator (not implemented) LauBuggRes& operator=(const LauBuggRes& rhs); Double_t mPiSq; Double_t mKSq; Double_t mEtaSq; Double_t alpha; Double_t g4; Double_t sA; Double_t rho_pi0; Double_t rho_4pi0; Double_t j0; //! Factor from BES data LauParameter* b1_; //! Factor from BES data LauParameter* b2_; //! Factor from BES data LauParameter* a_; //! Factor from BES data LauParameter* m0_; ClassDef(LauBuggRes,0) // Bugg resonance model }; #endif diff --git a/inc/LauDabbaRes.hh b/inc/LauDabbaRes.hh index 7165411..92471a4 100644 --- a/inc/LauDabbaRes.hh +++ b/inc/LauDabbaRes.hh @@ -1,182 +1,185 @@ /* Copyright 2010 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauDabbaRes.hh \brief File containing declaration of LauDabbaRes class. */ /*! \class LauDabbaRes \brief Class for defining the Dabba resonance model Class for defining the Dabba resonance model Formulae and data values from arXiv:0901.2217 - author D.V.Bugg */ #ifndef LAU_DABBA_RES #define LAU_DABBA_RES #include "TString.h" #include "LauAbsResonance.hh" #include "LauComplex.hh" class LauDabbaRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauDabbaRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauDabbaRes(); //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::Dabba;} //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the b parameter /*! \param [in] b new value for b parameter */ void setBValue(const Double_t b); //! Set the alpha parameter /*! \param [in] alpha new value for alpha parameter */ void setAlphaValue(const Double_t alpha); //! Set the beta parameter /*! \param [in] beta new value for beta parameter */ void setBetaValue(const Double_t beta); //! Get the b parameter value /*! \return value of the b parameter */ Double_t getBValue() const { return (b_!=0) ? b_->unblindValue() : 0.0; } //! Get the alpha parameter value /*! \return value of the alpha parameter */ Double_t getAlphaValue() const { return (alpha_!=0) ? alpha_->unblindValue() : 0.0; } //! Get the beta parameter value /*! \return value of the beta parameter */ Double_t getBetaValue() const { return (beta_!=0) ? beta_->unblindValue() : 0.0; } //! Fix the b parameter value /*! \return kTRUE if the b parameter is fixed, kFALSE otherwise */ Bool_t fixBValue() const { return (b_!=0) ? b_->fixed() : 0.0; } //! Fix the alpha parameter value /*! \return kTRUE if the alpha parameter is fixed, kFALSE otherwise */ Bool_t fixAlphaValue() const { return (alpha_!=0) ? alpha_->fixed() : 0.0; } //! Fix the beta parameter value /*! \return kTRUE if the beta parameter is fixed, kFALSE otherwise */ Bool_t fixBetaValue() const { return (beta_!=0) ? beta_->fixed() : 0.0; } //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); //! Check that the daughter particles are D and pi void checkDaughterTypes() const; + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { b_, alpha_, beta_ }; } + private: //! Copy constructor (not implemented) LauDabbaRes(const LauDabbaRes& rhs); //! Copy assignment operator (not implemented) LauDabbaRes& operator=(const LauDabbaRes& rhs); //! Defined as mD + mPi all squared Double_t mSumSq_; //! Defined as mD*mD - 0.5*mPi*mPi Double_t sAdler_; //! Constant factor LauParameter* b_; //! Constant factor LauParameter* alpha_; //! Constant factor LauParameter* beta_; ClassDef(LauDabbaRes,0) // Dabba resonance model }; #endif diff --git a/inc/LauEFKLLMRes.hh b/inc/LauEFKLLMRes.hh index c1c16f9..3e7b185 100644 --- a/inc/LauEFKLLMRes.hh +++ b/inc/LauEFKLLMRes.hh @@ -1,146 +1,154 @@ /* Copyright 2015 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauEFKLLMRes.hh \brief File containing declaration of LauEFKLLMRes class. */ /*! \class LauEFKLLMRes \brief Class for defining the EFKLLM K-pi S-wave model Class for defining the EFKLLM form-factor model for the K-pi S-wave. The model consists of a tabulated form-factor, which is interpolated using cubic splines (one for magnitude values and one for phase values), multiplied by a mass-dependence (e.g. constant, 1/m^2, etc.). The massFactor resonance parameter is the power of the mass dependence - defaults to zero, i.e. constant. For more details see B. El-Bennich et al. Phys. Rev. D 79, 094005 (2009), arXiv:0902.3645 [hep-ph]. (The acronym EFKLLM is constructed from the surnames of the authors of the above paper.) */ #ifndef LAU_EFKLLM_RES #define LAU_EFKLLM_RES #include #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class Lau1DCubicSpline; class LauEFKLLMRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauEFKLLMRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Read the form factor information from text file /*! Creates the splines from the tabulated form factor data. These are shared between all instances of this class. \param [in] inputFile the name of the file to be read */ static void setupFormFactor(const TString& inputFile); + //! Retrieve the name of the file from which the form factor information was read + static TString getFormFactorFileName() { return ffFileName_; } + //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::EFKLLM;} //! Set value of a resonance parameter /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the power of the mass dependence /*! \param [in] massFactor the new power of the mass dependence */ void setMassFactor(const Double_t massFactor); //! Get the power of the mass dependence /*! \return the power of the mass dependence */ Double_t getMassFactor() const {return (massFactor_!=nullptr) ? massFactor_->unblindValue() : 0.0;} //! See if the mass factor parameter is fixed or floating /*! \return kTRUE if the mass factor parameter is fixed, kFALSE otherwise */ Bool_t fixMassFactor() const {return (massFactor_!=nullptr) ? massFactor_->fixed() : kTRUE;} //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { massFactor_ }; } + private: + //! The name of the file from which the form-factor information has been read + static TString ffFileName_; //! Spline describing the magnitude variation of the form-factor static std::unique_ptr magSpline_; //! Spline describing the phase variation of the form-factor static std::unique_ptr phaseSpline_; //! The power of the mass dependence LauParameter* massFactor_{nullptr}; ClassDef(LauEFKLLMRes,0) // EFKLLM resonance model }; #endif diff --git a/inc/LauFlatteRes.hh b/inc/LauFlatteRes.hh index 5fff828..3c34690 100644 --- a/inc/LauFlatteRes.hh +++ b/inc/LauFlatteRes.hh @@ -1,171 +1,174 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauFlatteRes.hh \brief File containing declaration of LauFlatteRes class. */ /*! \class LauFlatteRes \brief Class for defining the Flatte resonance model Class for defining the Flatte resonance model. For use with the f_0(980) resonance. */ #ifndef LAU_FLATTE_RES #define LAU_FLATTE_RES #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauFlatteRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauFlatteRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauFlatteRes(); //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::Flatte;} //! Set value of a resonance parameter /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the g1 parameter /*! \param [in] g1 constant factor */ void setg1Parameter(const Double_t g1); //! Set the g2 parameter /*! \param [in] g2 constant factor */ void setg2Parameter(const Double_t g2); //! Get the g1 parameter /*! \return constant factor g1 */ Double_t getg1Parameter() const {return (g1_!=0) ? g1_->unblindValue() : 0.0;} //! Get the g2 parameter /*! \return constant factor g2 */ Double_t getg2Parameter() const {return (g2_!=0) ? g2_->unblindValue() : 0.0;} //! See if the g1 parameter is fixed or floating /*! \return kTRUE if the g1 parameter is fixed, kFALSE otherwise */ Double_t fixg1Parameter() const {return (g1_!=0) ? g1_->fixed() : kTRUE;} //! See if the g2 parameter is fixed or floating /*! \return kTRUE if the g2 parameter is fixed, kFALSE otherwise */ Double_t fixg2Parameter() const {return (g2_!=0) ? g2_->fixed() : kTRUE;} //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { g1_, g2_ }; } + private: //! Copy constructor (not implemented) LauFlatteRes(const LauFlatteRes& rhs); //! Copy assignment operator (not implemented) LauFlatteRes& operator=(const LauFlatteRes& rhs); //! Channel 1 coupling parameter LauParameter* g1_; //! Channel 1 coupling parameter LauParameter* g2_; //! Channel 1, subchannel 1 invariant mass Double_t mSumSq0_; //! Channel 1, subchannel 2 invariant mass Double_t mSumSq1_; //! Channel 2, subchannel 1 invariant mass Double_t mSumSq2_; //! Channel 2, subchannel 2 invariant mass Double_t mSumSq3_; //! Flag to turn on Adler term in the width Bool_t useAdlerTerm_; //! The Adler zero Double_t sA_; //! Flag to specify whether the couplings absorb the m_0 factor Bool_t absorbM0_; ClassDef(LauFlatteRes,0) }; #endif diff --git a/inc/LauGounarisSakuraiRes.hh b/inc/LauGounarisSakuraiRes.hh index 9ab7dd5..eed0f62 100644 --- a/inc/LauGounarisSakuraiRes.hh +++ b/inc/LauGounarisSakuraiRes.hh @@ -1,140 +1,143 @@ /* Copyright 2006 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauGounarisSakuraiRes.hh \brief File containing declaration of LauGounarisSakuraiRes class. */ /*! \class LauGounarisSakuraiRes \brief Class for defininf the Gounaris-Sakurai resonance model Class for defining the relativistic Gounaris-Sakurai resonance model, which includes the use of Blatt-Weisskopf barrier factors. */ #ifndef LAU_GOUNARIS_SAKURAI_RES #define LAU_GOUNARIS_SAKURAI_RES #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauGounarisSakuraiRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauGounarisSakuraiRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauGounarisSakuraiRes(); //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::GS;} //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); //! Optionally disable scaling Gamma(m) by the Blatt-Weisskopf factor /*! Equation 11 of the original paper does not contain such a factor, so we allow here the option to switch it off to better match the original formulation. It is switched on by default for backward compatibility. \param [in] flag if true, disable the scaling, if false, revert to default behaviour */ - static void disableBWScalingOfWidth( const Bool_t flag = kTRUE ); + static void disableBWScalingOfWidth( const Bool_t flag ); + + //! Check whether scaling of Gamma(m) by the Blatt-Weisskopf factor is disabled + [[nodiscard]] static Bool_t disableBWScalingOfWidth() { return disableBWScalingOfWidth_; } protected: //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); private: //! Copy constructor (not implemented) LauGounarisSakuraiRes(const LauGounarisSakuraiRes& rhs); //! Copy assignment operator (not implemented) LauGounarisSakuraiRes& operator=(const LauGounarisSakuraiRes& rhs); //! Momentum of the daughters in the resonance rest frame (at pole mass) Double_t q0_; //! The resonance mass Double_t resMass_; //! Square of the resonance mass Double_t resMassSq_; //! The resonance width Double_t resWidth_; //! The resonance barrier radius Double_t resRadius_; //! The parent barrier radius Double_t parRadius_; //! Sum of the two daughter masses Double_t mDaugSum_; //! Square of the sum of the two daughter masses Double_t mDaugSumSq_; //! Difference between the two daughter masses Double_t mDaugDiff_; //! Square of the difference of the two daughter masses Double_t mDaugDiffSq_; //! Square of the parent mass Double_t mParentSq_; //! Square of the bachelor mass Double_t mBachSq_; //! Extra parameter required by GS shape Double_t h0_; //! Extra parameter required by GS shape Double_t dhdm0_; //! Extra parameter required by GS shape Double_t d_; //! Value of the form factor for resonance decay (at pole mass) Double_t FR0_; //! Optionally disable scaling Gamma(m) by Blatt-Weisskopf factor static Bool_t disableBWScalingOfWidth_; ClassDef(LauGounarisSakuraiRes,0) // Gounaris-Sakurai resonance model }; #endif diff --git a/inc/LauIsobarDynamics.hh b/inc/LauIsobarDynamics.hh index 1e2fbd7..0816f3a 100644 --- a/inc/LauIsobarDynamics.hh +++ b/inc/LauIsobarDynamics.hh @@ -1,1199 +1,1216 @@ /* Copyright 2005 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauIsobarDynamics.hh \brief File containing declaration of LauIsobarDynamics class. */ /*! \class LauIsobarDynamics \brief Class for defining signal dynamics using the isobar model. */ #ifndef LAU_ISOBAR_DYNAMICS #define LAU_ISOBAR_DYNAMICS #include "LauAbsResonance.hh" #include "LauComplex.hh" #include "TString.h" #include #include #include class LauAbsEffModel; class LauAbsIncohRes; class LauAbsModIndPartWave; class LauCacheData; class LauDaughters; class LauDPPartialIntegralInfo; class LauFitDataTree; class LauKMatrixPropagator; class LauKinematics; class LauResonanceMaker; class LauIsobarDynamics { public: //! The type used for containing multiple self cross feed fraction models for different categories (e.g. tagging categories) typedef std::map LauTagCatScfFractionModelMap; //! The possible statuses for toy MC generation enum ToyMCStatus { GenOK, /*!< Generation completed OK */ MaxIterError, /*!< Maximum allowed number of iterations completed without success (ASqMax is too high) */ ASqMaxError /*!< An amplitude squared value was returned that was larger than the maximum expected (ASqMax is too low) */ }; //! Constructor /*! \param [in] daughters the daughters of the decay \param [in] effModel the model to describe the efficiency across the Dalitz plot \param [in] scfFractionModel the model to describe the fraction of poorly constructed events (the self cross feed fraction) across the Dalitz plot */ LauIsobarDynamics(LauDaughters* daughters, LauAbsEffModel* effModel, LauAbsEffModel* scfFractionModel = 0); //! Constructor /*! \param [in] daughters the daughters of the decay \param [in] effModel the model to describe the efficiency across the Dalitz plot \param [in] scfFractionModel the models to describe the fraction of poorly constructed events (the self cross feed fraction) across the Dalitz plot for various tagging categories */ LauIsobarDynamics(LauDaughters* daughters, LauAbsEffModel* effModel, LauTagCatScfFractionModelMap scfFractionModel); //! Destructor virtual ~LauIsobarDynamics(); //! Initialise the Dalitz plot dynamics /*! \param [in] coeffs the complex coefficients for the resonances */ void initialise(const std::vector& coeffs); //! recalculate Normalization void recalculateNormalisation(); //! Set the name of the file to which to save the results of the integrals /*! \param [in] fileName the name of the file */ inline void setIntFileName(const TString& fileName) {intFileName_ = fileName;} // Integration //! Set the widths of the bins to use when integrating across the Dalitz plot or square Dalitz plot /*! Specify the bin widths required when performing the DP integration. Note that the integration is not performed in m13^2 vs m23^2 space but in either m13 vs m23 space or mPrime vs thetaPrime space, with the appropriate Jacobian applied. The default bin widths in m13 vs m23 space are 0.005 GeV. The default bin widths in mPrime vs thetaPrime space are 0.001. \param [in] m13BinWidth the bin width to use when integrating over m13 \param [in] m23BinWidth the bin width to use when integrating over m23 \param [in] mPrimeBinWidth the bin width to use when integrating over mPrime \param [in] thPrimeBinWidth the bin width to use when integrating over thetaPrime */ void setIntegralBinWidths(const Double_t m13BinWidth, const Double_t m23BinWidth, const Double_t mPrimeBinWidth = 0.001, const Double_t thPrimeBinWidth = 0.001); //! Set the value below which a resonance width is considered to be narrow /*! Narrow resonances trigger different integration behaviour - dividing the DP into regions where a finer binning is used. This can cause high memory usage, so use this method and LauIsobarDynamics::setIntegralBinningFactor to tune this behaviour, if needed. \param [in] narrowWidth the value below which a resonance is considered to be narrow (defaults to 0.02 GeV/c2) */ void setNarrowResonanceThreshold(const Double_t narrowWidth) { narrowWidth_ = narrowWidth; } //! Set the factor relating the width of a narrow resonance and the binning size in its integration region /*! Narrow resonances trigger different integration behaviour - dividing the DP into regions where a finer binning is used. This can cause high memory usage, so use this method and LauIsobarDynamics::setNarrowResonanceThreshold to tune this behaviour, if needed. \param [in] binningFactor the factor by which the resonance width is divided to obtain the bin size (defaults to 100) */ void setIntegralBinningFactor(const Double_t binningFactor) { binningFactor_ = binningFactor; } //! Force the symmetrisation of the integration in m13 <-> m23 for non-symmetric but flavour-conjugate final states /*! This can be necessary for time-dependent fits (where interference terms between A and Abar need to be integrated) \param [in] force toggle forcing symmetrisation of the integration for apparently flavour-conjugate final states */ void forceSymmetriseIntegration(const Bool_t force) { forceSymmetriseIntegration_ = force; } //! Construct a set of resonances based on the contents of a JSON file /*! In the following documentation, the types of JSON elements refer to the LauJsonTools::JsonType enumeration. The JSON element (specified via the elementName argument, or otherwise the root element) should be an Object, which can contain the following elements: - "commonSettings" (mandatory), an Object, which contains any settings that need to be given to LauResonanceMaker (or are otherwise provided via static member functions of resonance classes, etc.) prior to building the model - "resonances" (mandatory), an Array, which contains an object for each (non K-matrix) component to be added to the model - "kmatrix" (optional), an Array, which contains settings needed to define any K-matrix components of the model \par The "commonSettings" object \parblock This object must exist but can be empty. If not empty, the allowed elements are: - "setBWType", a String that must match one of the states of LauBlattWeisskopfFactor::BarrierType - "setBWBachelorRestFrame", a String that must match one of the states of LauBlattWeisskopfFactor::RestFrame - "setSpinFormalism", a String that must match one of the states of LauAbsResonance::SpinType - "setDefaultBWRadius", an Array containing settings objects for each Blatt-Weisskopf category for which the default settings are to be supplied, each can contain: + "category" (mandatory), a String giving the name of the category (musts match one of the states of LauBlattWeisskopfFactor::Category) + "value (mandatory)", a Number giving the value of the radius parameter + "fix" (optional), a Boolean indicating whether the radius parameter should be fixed (true) or float (false) in the fit - "setupEFKLLMFormFactor", a String that specifies the name of the file from which the EFKLLM model form factor data should be read - "disableGSScalingOfWidthByBWFactors", a Boolean that specifies whether to disable scaling of the width by Blatt-Weisskopf factors in the Gounaris-Sakurai model \see LauResonanceMaker::setBWType, LauResonanceMaker::setBWBachelorRestFrame, LauResonanceMaker::setSpinFormalism, LauResonanceMaker::setDefaultBWRadius, LauResonanceMaker::fixBWRadius, LauEFKLLMRes::setupFormFactor, LauGounarisSakuraiRes::disableBWScalingOfWidth \endparblock \par The "resonances" array \parblock This must exist but can be empty. If not empty, it should contain an object for each component to be added to the model. Each of the resonance-defining objects in the array can contain the following elements: - "resName" (mandatory), a String that specifies the name of the component - "resPairAmpInt" (mandatory), a Number_Unsigned that specifies which of the three final-state particles is the companion to this state - "resType" (mandatory), a String that must match one of the states of LauAbsResonance::ResonanceModel - "coherent" (optional), a Boolean that governs whether addResonance or addIncoherentResonance is called to construct the entry, defaults to true (i.e. use addResonance) - "bwCategory" (optional), a String that specifies the Blatt-Weisskopf barrier factor category (so must match one of the states of LauBlattWeisskopfFactor::Category), defaults to "Default" (i.e. LauBlattWeisskopfFactor::Category::Default) - "changeResonance" (optional), an Object that can modify the mass, width, and spin of a resonance, the object can contain: + "mass" (optional), an Object that itself can contain: - "value" (optional), a Number that specifies the new value for the mass - "fix" (optional), a Boolean that specifies whether the mass should be fixed (true) or float (false) in the fit + "width" (optional), an Object that itself can contain: - "value" (optional), a Number that specifies the new value for the width - "fix" (optional), a Boolean that specifies whether the width should be fixed (true) or float (false) in the fit + "spin" (optional), an Object that itself can contain: - "value" (optional), a Number that specifies the new value for the spin - "changeBWBarrierRadii" (optional), an Object that can modify the Blatt-Weisskopf barrier factors of the resonance, the object can contain: + "resRadius" (optional), an Object that refers to the resonance barrier factor and itself can contain: - "value" (optional), a Number that specifies the new value for the radius - "fix" (optional), a Boolean that specifies whether the radius should be fixed (true) or float (false) in the fit + "parRadius" (optional), an Object that refers to the parent barrier factor and itself can contain: - "value" (optional), a Number that specifies the new value for the radius - "fix" (optional), a Boolean that specifies whether the radius should be fixed (true) or float (false) in the fit - "ignoreMomenta" (optional), a Boolean, see LauAbsResonance::ignoreMomenta - "ignoreSpin" (optional), a Boolean, see LauAbsResonance::ignoreSpin - "ignoreBarrierScaling" (optional), a Boolean, see LauAbsResonance::ignoreBarrierScaling - "setSpinType" (optional), a String that must match one of the states of LauAbsResonance::SpinType, see LauAbsResonance::setSpinType - "parameters" (optional), an Array of settings objects to modify resonance model parameters, each can contain: + "name" (mandatory), a String specifying the name of the parameter to modify + "value" (mandatory), a Number specifying the new value of the parameter + "float" (optional), a Boolean specifying whether the parameter should float in the fit (true) or be fixed (false) For certain resonance models there are also the following optional elements: - "enforceLegendreSpinFactors", a Boolean, see LauBelleNR::enforceLegendreSpinFactors and LauLHCbNR::enforceLegendreSpinFactors - "defineKnots", an Array, see LauAbsModIndPartWave::defineKnots - - "setKnotAmp", an Array, see LauAbsModIndPartWave::defineKnots + - "setKnotAmp", an Array, see LauAbsModIndPartWave::setKnotAmp - "setSplineType", a two-element Array, see LauAbsModIndPartWave::setSplineType - "setSplineBoundaryConditions", a four- or eight-element Array, see LauAbsModIndPartWave::setSplineBoundaryConditions - "floatKnotsSecondStage", a Boolean, see LauAbsModIndPartWave::floatKnotsSecondStage \see addResonance, addIncoherentResonance, LauAbsResonance::ignoreMomenta, LauAbsResonance::ignoreSpin, LauAbsResonance::ignoreBarrierScaling, LauAbsResonance::setSpinType LauAbsResonance::setResonanceParameter, LauAbsResonance::floatResonanceParameter, LauBelleNR::enforceLegendreSpinFactors, LauLHCbNR::enforceLegendreSpinFactors, LauAbsModIndPartWave::defineKnots, LauAbsModIndPartWave::setKnotAmp, LauAbsModIndPartWave::setSplineType, LauAbsModIndPartWave::setSplineBoundaryConditions, LauAbsModIndPartWave::floatKnotsSecondStage \endparblock \par The "kmatrix" array \parblock This Array should contain an object for each K-matrix propagator to be defined, each of which must contain the following elements: - "propagator", an Object that defines the propagator, which can contain the following elements: + "propName" (mandatory), a String that defines the name of the propagator + "paramFileName" (mandatory), a String that defines the name of the file from which the propagator parameters should be read + "resPairAmpInt" (mandatory), a Number_Unsigned that specifies which of the three final-state particles is the companion to this state + "nChannels" (mandatory), a Number_Unsigned that specifies the number of channels + "nPoles" (mandatory), a Number_Unsigned that specifies the number of poles + "rowIndex" (optional), a Number_Unsigned that specifies the row index - defaults to 1 + "ignoreBWBarrierFactor" (optional), a Boolean that specifies whether to ignore Blatt-Weisskopf barrier factors - defaults to false - "poles", an Array that contains an Object for each pole to be added to the propagator, each object can contain: + "poleName" (mandatory), a String that defines the name of the pole + "poleIndex" (mandatory), a Number_Unsigned that defines the index of the pole + "useProdAdler" (optional), a Boolean that specifies whether to use the production Adler zero factor - defaults to false - "svps", an Array that contains an Object for each SVP to be added to the propagator, each object can contain: + "svpName" (mandatory), a String that defines the name of the SVP + "channelIndex" (mandatory), a Number_Unsigned that specifies the index of the channel within the propagator + "useProdAdler" (optional), a Boolean that specifies whether to use the production Adler zero factor - defaults to false \see defineKMatrixPropagator, addKMatrixProdPole, addKMatrixProdSVP \endparblock \param [in] jsonFileName the name of the JSON file - \param [in] elementName the optional name of the JSON element that contains the array of resonance definitions (defaults to using the root record) + \param [in] elementName the optional name of the JSON element that contains the model definition (defaults to using the root record) */ void constructModelFromJson(const TString& jsonFileName, const TString& elementName = ""); + /*! Write the model configuration to a JSON file + \param [in] jsonFileName the name of the JSON file + \param [in] elementName the (optional) name of the JSON element to which to write the model (defaults to using the root record) + \param [in] append if true, append the model to the existing JSON within the file - if using this option it is then mandatory to provide elementName + \param [in] indent the indentation level to use in the output in number of spaces (defaults to 4) + */ + void writeModelToJson(const TString& jsonFileName, const TString& elementName = "", const bool append = false, const int indent = 4) const; + //! Add a resonance to the Dalitz plot /*! NB the stored order of resonances is: - Firstly, all coherent resonances (i.e. those added using addResonance() or addKMatrixProdPole() or addKMatrixProdSVP()) in order of addition - Followed by all incoherent resonances (i.e. those added using addIncoherentResonance()) in order of addition \param [in] resName the name of the resonant particle \param [in] resPairAmpInt the index of the daughter not produced by the resonance \param [in] resType the model for the resonance dynamics \param [in] bwCategory the Blatt-Weisskopf barrier factor category \return the newly created resonance */ LauAbsResonance* addResonance(const TString& resName, const Int_t resPairAmpInt, const LauAbsResonance::ResonanceModel resType, const LauBlattWeisskopfFactor::Category bwCategory = LauBlattWeisskopfFactor::Category::Default); //! Add an incoherent resonance to the Dalitz plot /*! NB the stored order of resonances is: - Firstly, all coherent resonances (i.e. those added using addResonance() or addKMatrixProdPole() or addKMatrixProdSVP()) in order of addition - Followed by all incoherent resonances (i.e. those added using addIncoherentResonance()) in order of addition \param [in] resName the name of the resonant particle \param [in] resPairAmpInt the index of the daughter not produced by the resonance \param [in] resType the model for the resonance dynamics \return the newly created resonance */ LauAbsResonance* addIncoherentResonance(const TString& resName, const Int_t resPairAmpInt, const LauAbsResonance::ResonanceModel resType); //! Define a new K-matrix Propagator /*! \param [in] propName the name of the propagator \param [in] paramFileName the file that defines the propagator \param [in] resPairAmpInt the index of the bachelor \param [in] nChannels the number of channels \param [in] nPoles the number of poles \param [in] rowIndex the index of the row to be used when summing over all amplitude channels: S-wave corresponds to rowIndex = 1. */ LauKMatrixPropagator* defineKMatrixPropagator( const TString& propName, const TString& paramFileName, Int_t resPairAmpInt, Int_t nChannels, Int_t nPoles, Int_t rowIndex = 1); //! Add a K-matrix production pole term to the model /*! NB the stored order of resonances is: - Firstly, all coherent resonances (i.e. those added using addResonance() or addKMatrixProdPole() or addKMatrixProdSVP()) in order of addition - Followed by all incoherent resonances (i.e. those added using addIncoherentResonance()) in order of addition \param [in] poleName the name of the pole \param [in] propName the name of the propagator to use \param [in] poleIndex the index of the pole within the propagator \param [in] useProdAdler boolean to turn on/off the production Adler zero factor (default = off) */ void addKMatrixProdPole(const TString& poleName, const TString& propName, Int_t poleIndex, Bool_t useProdAdler = kFALSE); //! Add a K-matrix slowly-varying part (SVP) term to the model /*! NB the stored order of resonances is: - Firstly, all coherent resonances (i.e. those added using addResonance() or addKMatrixProdPole() or addKMatrixProdSVP()) in order of addition - Followed by all incoherent resonances (i.e. those added using addIncoherentResonance()) in order of addition \param [in] SVPName the name of the term \param [in] propName the name of the propagator to use \param [in] channelIndex the index of the channel within the propagator \param [in] useProdAdler boolean to turn on/off the production Adler zero factor (default = off) */ void addKMatrixProdSVP(const TString& SVPName, const TString& propName, Int_t channelIndex, Bool_t useProdAdler = kFALSE); //! Set the maximum value of A squared to be used in the accept/reject /*! \param [in] value the new value */ inline void setASqMaxValue(Double_t value) {aSqMaxSet_ = value;} //! Retrieve the maximum value of A squared to be used in the accept/reject /*! \return the maximum value of A squared */ inline Double_t getASqMaxSetValue() const { return aSqMaxSet_; } //! Retrieve the maximum of A squared that has been found while generating /*! \return the maximum of A squared that has been found */ inline Double_t getASqMaxVarValue() const { return aSqMaxVar_; } //! Generate a toy MC signal event /*! \return kTRUE if the event is successfully generated, kFALSE otherwise */ Bool_t generate(); //! Check the status of the toy MC generation /*! \param [in] printErrorMessages whether error messages should be printed \param [in] printInfoMessages whether info messages should be printed \return the status of the toy MC generation */ ToyMCStatus checkToyMC(Bool_t printErrorMessages = kTRUE, Bool_t printInfoMessages = kFALSE); //! Retrieve the maximum number of iterations allowed when generating an event /*! \return the maximum number of iterations allowed */ inline Int_t maxGenIterations() const {return iterationsMax_;} //! Calculate the likelihood (and all associated information) for the given event number /*! \param [in] iEvt the event number */ void calcLikelihoodInfo(const UInt_t iEvt); //! Calculate the likelihood (and all associated information) given values of the Dalitz plot coordinates /*! \param [in] m13Sq the invariant mass squared of the first and third daughters \param [in] m23Sq the invariant mass squared of the second and third daughters */ void calcLikelihoodInfo(const Double_t m13Sq, const Double_t m23Sq); //! Calculate the likelihood (and all associated information) given values of the Dalitz plot coordinates and the tagging category /*! Also obtain the self cross feed fraction to cache with the rest of the Dalitz plot quantities. \param [in] m13Sq the invariant mass squared of the first and third daughters \param [in] m23Sq the invariant mass squared of the second and third daughters \param [in] tagCat the tagging category */ void calcLikelihoodInfo(const Double_t m13Sq, const Double_t m23Sq, const Int_t tagCat); //! Calculate the fit fractions, mean efficiency and total DP rate /*! \param [in] init whether the calculated values should be stored as the initial/generated values or the fitted values */ void calcExtraInfo(const Bool_t init = kFALSE); //! Calculates whether an event with the current kinematics should be accepted in order to produce a distribution of events that matches the model e.g. when reweighting embedded data /*! Uses the accept/reject method. \return kTRUE if the event has been accepted, kFALSE otherwise */ Bool_t gotReweightedEvent(); //! Calculate the acceptance rate, for events with the current kinematics, when generating events according to the model /*! \return the weight for the current kinematics */ Double_t getEventWeight(); //! Retrieve the total amplitude for the current event /*! \return the total amplitude */ inline const LauComplex& getEvtDPAmp() const {return totAmp_;} //! Retrieve the invariant mass squared of the first and third daughters in the current event /*! \return the invariant mass squared of the first and third daughters in the current event */ inline Double_t getEvtm13Sq() const {return m13Sq_;} //! Retrieve the invariant mass squared of the second and third daughters in the current event /*! \return the invariant mass squared of the second and third daughters in the current event */ inline Double_t getEvtm23Sq() const {return m23Sq_;} //! Retrieve the square Dalitz plot coordinate, m', for the current event /*! \return the square Dalitz plot coordinate, m', for the current event */ inline Double_t getEvtmPrime() const {return mPrime_;} //! Retrieve the square Dalitz plot coordinate, theta', for the current event /*! \return the square Dalitz plot coordinate, theta', for the current event */ inline Double_t getEvtthPrime() const {return thPrime_;} //! Retrieve the efficiency for the current event /*! \return the efficiency for the current event */ inline Double_t getEvtEff() const {return eff_;} //! Retrieve the fraction of events that are poorly reconstructed (the self cross feed fraction) for the current event /*! \return the self cross feed fraction for the current event */ inline Double_t getEvtScfFraction() const {return scfFraction_;} //! Retrieve the Jacobian, for the transformation into square DP coordinates, for the current event /*! \return the Jacobian for the current event */ inline Double_t getEvtJacobian() const {return jacobian_;} //! Retrieve the total intensity multiplied by the efficiency for the current event /*! \return the total intensity multiplied by the efficiency for the current event */ inline Double_t getEvtIntensity() const {return ASq_;} //! Retrieve the likelihood for the current event /*! The likelihood is the normalised total intensity: evtLike_ = ASq_/DPNorm_ \return the likelihood for the current event */ inline Double_t getEvtLikelihood() const {return evtLike_;} //! Retrieve the normalised dynamic part of the amplitude of the given amplitude component at the current point in the Dalitz plot /*! \param [in] resID the index of the component within the model \return the amplitude of the given component */ inline LauComplex getDynamicAmp(const Int_t resID) const {return ff_[resID].scale(fNorm_[resID]);} //! Retrieve the Amplitude of resonance resID /*! \param [in] resID the index of the component within the model \return the amplitude of the given component */ inline LauComplex getFullAmplitude(const Int_t resID) const {return Amp_[resID] * this->getDynamicAmp(resID);} //! Retrieve the event-by-event running totals of amplitude cross terms for all pairs of amplitude components /*! \return the event-by-event running totals of amplitude cross terms */ inline const std::vector< std::vector >& getFiFjSum() const {return fifjSum_;} //! Retrieve the event-by-event running totals of efficiency corrected amplitude cross terms for all pairs of amplitude components /*! \return the event-by-event running totals of amplitude cross terms with efficiency corrections applied */ inline const std::vector< std::vector >& getFiFjEffSum() const {return fifjEffSum_;} //! Retrieve the normalisation factors for the dynamic parts of the amplitudes for all of the amplitude components /*! \return the normalisation factors */ inline const std::vector& getFNorm() const {return fNorm_;} //! Retrieve the integration information objects /*! \return the integration information objects */ inline const std::vector& getIntegralInfos() const {return dpPartialIntegralInfo_;} //! Fill the internal data structure that caches the resonance dynamics /*! \param [in] fitDataTree the data source */ void fillDataTree(const LauFitDataTree& fitDataTree); //! Recache the amplitude values for those that have changed void modifyDataTree(); //! Check whether this model includes a named resonance /*! \param [in] resName the resonance \return true if the resonance is present, false otherwise */ Bool_t hasResonance(const TString& resName) const; //! Retrieve the index for the given resonance /*! \param [in] resName the resonance \return the index of the resonance if it is present, -1 otherwise */ Int_t resonanceIndex(const TString& resName) const; //! Retrieve the name of the charge conjugate of a named resonance /*! \param [in] resName the resonance \return the name of the charge conjugate */ TString getConjResName(const TString& resName) const; //! Retrieve the named resonance /*! \param [in] resName the name of the resonance to retrieve \return the requested resonance */ const LauAbsResonance* findResonance(const TString& resName) const; //! Retrieve a resonance by its index /*! \param [in] resIndex the index of the resonance to retrieve \return the requested resonance */ const LauAbsResonance* getResonance(const UInt_t resIndex) const; //! Update the complex coefficients for the resonances /*! \param [in] coeffs the new set of coefficients */ void updateCoeffs(const std::vector& coeffs); //! Collate the resonance parameters to initialise (or re-initialise) the model /*! NB: This has been factored out of the initialise() method to allow for use in the importation of parameters in LauAbsFitModel */ void collateResonanceParameters(); //! Set the helicity flip flag for new amplitude components /*! \param [in] boolean the helicity flip flag */ inline void flipHelicityForCPEigenstates(const Bool_t boolean) {flipHelicity_ = boolean;} //! Retrieve the mean efficiency across the Dalitz plot /*! \return the mean efficiency across the Dalitz plot */ inline const LauParameter& getMeanEff() const {return meanDPEff_;} //! Retrieve the overall Dalitz plot rate /*! \return the overall Dalitz plot rate */ inline const LauParameter& getDPRate() const {return DPRate_;} //! Retrieve the fit fractions for the amplitude components /*! \return the fit fractions */ inline const LauParArray& getFitFractions() const {return fitFrac_;} //! Retrieve the fit fractions for the amplitude components /*! \return the fit fractions */ inline const LauParArray& getFitFractionsEfficiencyUncorrected() const {return fitFracEffUnCorr_;} //! Retrieve the total number of amplitude components /*! \return the total number of amplitude components */ inline UInt_t getnTotAmp() const {return nAmp_+nIncohAmp_;} //! Retrieve the number of coherent amplitude components /*! \return the number of coherent amplitude components */ inline UInt_t getnCohAmp() const {return nAmp_;} //! Retrieve the number of incoherent amplitude components /*! \return the number of incoherent amplitude components */ inline UInt_t getnIncohAmp() const {return nIncohAmp_;} //! Retrieve the normalisation factor for the log-likelihood function /*! \return the normalisation factor */ inline Double_t getDPNorm() const {return DPNorm_;} //! Retrieve the daughters /*! \return the daughters */ inline const LauDaughters* getDaughters() const {return daughters_;} //! Retrieve the Dalitz plot kinematics /*! \return the Dalitz plot kinematics */ inline const LauKinematics* getKinematics() const {return kinematics_;} //! Retrieve the Dalitz plot kinematics /*! \return the Dalitz plot kinematics */ inline LauKinematics* getKinematics() {return kinematics_;} //! Retrieve the model for the efficiency across the Dalitz plot /*! \return the efficiency model */ inline const LauAbsEffModel* getEffModel() const {return effModel_;} //! Check whether a self cross feed fraction model is being used /*! \return true if a self cross feed fraction model is being used, false otherwise */ inline Bool_t usingScfModel() const { return ! scfFractionModel_.empty(); } //! Retrieve any extra parameters/quantities (e.g. K-matrix total fit fractions) /*! \return any extra parameters */ inline const std::vector& getExtraParameters() const {return extraParameters_;} //! Retrieve the floating parameters of the resonance models /*! \return the list of floating parameters */ inline std::vector& getFloatingParameters() {return resonancePars_;} //! Whether to calculate separate rho and omega fit-fractions from LauRhoOmegaMix inline void calculateRhoOmegaFitFractions(const Bool_t calcFF) { calculateRhoOmegaFitFractions_ = calcFF; } protected: //! Print a summary of the model to be used void initSummary(); //! Initialise the internal storage for this model void initialiseVectors(); //! Zero the various values used to store integrals info void resetNormVectors(); //! Calculate the Dalitz plot normalisation integrals across the whole Dalitz plot void calcDPNormalisation(); //! Form the regions that are produced by the spaces between narrow resonances /*! \param [in] regions the regions defined around narrow resonances \param [in] min the minimum value of the invariant mass \param [in] max the maximum value of the invariant mass \return vector of pointers to LauDPPartialIntegralInfo objects that contain the individual coarse regions */ std::vector< std::pair > formGapsFromRegions(const std::vector< std::pair >& regions, const Double_t min, const Double_t max) const; //! Removes entries in the vector of LauDPPartialIntegralInfo* that are null /*! \param [in] regions the list of region pointers */ void cullNullRegions(std::vector& regions) const; //! Wrapper for LauDPPartialIntegralInfo constructor /*! \param [in] minm13 the minimum of the m13 range \param [in] maxm13 the maximum of the m13 range \param [in] minm23 the minimum of the m23 range \param [in] maxm23 the maximum of the m23 range \param [in] m13BinWidth the m13 bin width \param [in] m23BinWidth the m23 bin width \param [in] precision the precision required for the Gauss-Legendre weights \param [in] nAmp the number of coherent amplitude components \param [in] nIncohAmp the number of incoherent amplitude components \return 0 if the integration region has no internal points, otherwise returns a pointer to the newly constructed LauDPPartialIntegralInfo object */ LauDPPartialIntegralInfo* newDPIntegrationRegion(const Double_t minm13, const Double_t maxm13, const Double_t minm23, const Double_t maxm23, const Double_t m13BinWidth, const Double_t m23BinWidth, const Double_t precision, const UInt_t nAmp, const UInt_t nIncohAmp) const; //! Correct regions to ensure that the finest integration grid takes precedence /*! \param [in] regions the windows in invariant mass \param [in] binnings the corresponding binnings for each window */ void correctDPOverlap(std::vector< std::pair >& regions, const std::vector& binnings) const; //! Create the integration grid objects for the m23 narrow resonance regions, including the overlap regions with the m13 narrow resonances /*! The overlap regions will have an m13Binnings x m23Binnings grid. The other regions will have a defaultBinning x m23Binnings grid. \param [in] m13Regions the limits of each narrow-resonance region in m13 \param [in] m23Regions the limits of each narrow-resonance region in m23 \param [in] m13Binnings the binning of each narrow-resonance region in m13 \param [in] m23Binnings the binning of each narrow-resonance region in m23 \param [in] precision the precision required for the Gauss-Legendre weights \param [in] defaultBinning the binning used in the bulk of the phase space \return vector of pointers to LauDPPartialIntegralInfo objects that contain the individual regions */ std::vector m23IntegrationRegions(const std::vector< std::pair >& m13Regions, const std::vector< std::pair >& m23Regions, const std::vector& m13Binnings, const std::vector& m23Binnings, const Double_t precision, const Double_t defaultBinning) const; //! Create the integration grid objects for the m13 narrow resonance regions, excluding the overlap regions with the m23 narrow resonances /*! The regions will have a m13Binnings x defaultBinning grid. The overlap regions are created by the m23IntegrationRegions function. \param [in] m13Regions the limits of each narrow-resonance region in m13 \param [in] m23Regions the limits of each narrow-resonance region in m23 \param [in] m13Binnings the binning of each narrow-resonance region in m13 \param [in] precision the precision required for the Gauss-Legendre weights \param [in] defaultBinning the binning used in the bulk of the phase space \return vector of pointers to LauDPPartialIntegralInfo objects that contain the individual regions */ std::vector m13IntegrationRegions(const std::vector< std::pair >& m13Regions, const std::vector< std::pair >& m23Regions, const std::vector& m13Binnings, const Double_t precision, const Double_t defaultBinning) const; //! Calculate the Dalitz plot normalisation integrals across the whole Dalitz plot void calcDPNormalisationScheme(); //! Determine which amplitudes and integrals need to be recalculated void findIntegralsToBeRecalculated(); //! Calculate the Dalitz plot normalisation integrals over a given range /*! \param [in] intInfo the integration information object */ void calcDPPartialIntegral(LauDPPartialIntegralInfo* intInfo); //! Write the results of the integrals (and related information) to a file void writeIntegralsFile(); //! Set the dynamic part of the amplitude for a given amplitude component at the current point in the Dalitz plot /*! \param [in] index the index of the amplitude component \param [in] realPart the real part of the amplitude \param [in] imagPart the imaginary part of the amplitude */ void setFFTerm(const UInt_t index, const Double_t realPart, const Double_t imagPart); //! Set the dynamic part of the intensity for a given incoherent amplitude component at the current point in the Dalitz plot /*! \param [in] index the index of the incoherent amplitude component \param [in] value the intensity */ void setIncohIntenTerm(const UInt_t index, const Double_t value); //! Calculate the amplitudes for all resonances for the current kinematics void calculateAmplitudes(); //! Calculate or retrieve the cached value of the amplitudes for all resonances at the specified integration grid point /*! \param [in,out] intInfo the integration information object \param [in] m13Point the grid index in m13 \param [in] m23Point the grid index in m23 */ void calculateAmplitudes( LauDPPartialIntegralInfo* intInfo, const UInt_t m13Point, const UInt_t m23Point ); //! Add the amplitude values (with the appropriate weight) at the current grid point to the running integral values /*! \param [in] weight the weight to apply */ void addGridPointToIntegrals(const Double_t weight); //! Calculate the total Dalitz plot amplitude at the current point in the Dalitz plot /*! \param [in] useEff whether to apply efficiency corrections */ void calcTotalAmp(const Bool_t useEff); //! Obtain the efficiency of the current event from the model /*! \return the efficiency */ Double_t retrieveEfficiency(); //! Obtain the self cross feed fraction of the current event from the model /*! \param [in] tagCat the tagging category of the current event \return the self cross feed fraction */ Double_t retrieveScfFraction(Int_t tagCat); //! Set the maximum of A squared that has been found /*! \param [in] value the new value */ inline void setASqMaxVarValue(Double_t value) {aSqMaxVar_ = value;} //! Calculate the normalisation factor for the log-likelihood function /*! \return the normalisation factor */ Double_t calcSigDPNorm(); //! Calculate the dynamic part of the amplitude for a given component at the current point in the Dalitz plot /*! \param [in] index the index of the amplitude component within the model */ LauComplex resAmp(const UInt_t index); //! Calculate the dynamic part of the intensity for a given incoherent component at the current point in the Dalitz plot /*! \param [in] index the index of the incoherent component within the model */ Double_t incohResAmp(const UInt_t index); //! Load the data for a given event /*! \param [in] iEvt the number of the event */ void setDataEventNo(UInt_t iEvt); //! Retrieve the named resonance /*! \param [in] resName the name of the resonance to retrieve \return the requested resonance */ LauAbsResonance* findResonance(const TString& resName); //! Retrieve a resonance by its index /*! \param [in] resIndex the index of the resonance to retrieve \return the requested resonance */ LauAbsResonance* getResonance(const UInt_t resIndex); //! Remove the charge from the given particle name /*! \param [in,out] string the particle name */ void removeCharge(TString& string) const; //! Check whether a resonance is a K-matrix component of a given propagator /*! \param [in] resAmpInt the index of the resonance within the model \param [in] propName the name of the K-matrix propagator \return true if the resonance is a component of the given propagator, otherwise return false */ Bool_t gotKMatrixMatch(UInt_t resAmpInt, const TString& propName) const; //! Process the "commonSettings" section of the model-definition JSON /*! \param [in] commonSettings the JSON object to be processed \param [in] jsonFileName the file from which the JSON has been read - used only in error messages */ void processJsonCommonSettings( const nlohmann::json& commonSettings, const TString& jsonFileName ); //! Process the "resonances" section of the model-definition JSON /*! \param [in] resonances the JSON array to be processed \param [in] jsonFileName the file from which the JSON has been read - used only in error messages */ void processJsonResonances( const nlohmann::json& resonances, const TString& jsonFileName ); //! Process the "kmatrix" section of the model-definition JSON /*! \param [in] kmatrix the JSON array to be processed \param [in] jsonFileName the file from which the JSON has been read - used only in error messages */ void processJsonKMatrix( const nlohmann::json& kmatrix, const TString& jsonFileName ); //! Process the "propagator" section of the K-matrix model-definition JSON /*! \param [in] propagator the JSON object to be processed \param [in] jsonFileName the file from which the JSON has been read - used only in error messages \return the K-matrix propagator that has been created */ const LauKMatrixPropagator* processJsonKMatrixPropagator( const nlohmann::json& propagator, const TString& jsonFileName ); //! Process the "poles" section of the K-matrix model-definition JSON /*! \param [in] poles the JSON array to be processed \param [in] propagator the K-matrix propagator object to which the poles should be associated \param [in] jsonFileName the file from which the JSON has been read - used only in error messages */ void processJsonKMatrixPoles( const nlohmann::json& poles, const LauKMatrixPropagator& propagator, const TString& jsonFileName ); //! Process the "svps" section of the K-matrix model-definition JSON /*! \param [in] svps the JSON array to be processed \param [in] propagator the K-matrix propagator object to which the SVPs should be associated \param [in] jsonFileName the file from which the JSON has been read - used only in error messages */ void processJsonKMatrixSVPs( const nlohmann::json& svps, const LauKMatrixPropagator& propagator, const TString& jsonFileName ); //! Process the "setDefaultBWRadius" section of the "commonSettings" section of the model-definition JSON /*! \param [in] j the JSON array to be processed \param [in,out] resMaker the resonance-maker object to be modified \param [in] jsonFileName the file from which the JSON has been read - used only in error messages */ void processJsonSetDefaultBWRadius( const nlohmann::json& j, LauResonanceMaker& resMaker, const TString& jsonFileName ); //! Process the "changeResonance" section of the "resonances" section of the model-definition JSON /*! \param [in] j the JSON array to be processed \param [in,out] res the resonance object to be modified */ void processJsonChangeResonance( const nlohmann::json& j, LauAbsResonance& res ); //! Process the "changeBWBarrierRadii" section of the "resonances" section of the model-definition JSON /*! \param [in] j the JSON array to be processed \param [in,out] res the resonance object to be modified */ void processJsonChangeBWBarrierRadii( const nlohmann::json& j, LauAbsResonance& res ); //! Process the "parameters" section of the "resonances" section of the model-definition JSON /*! \param [in] j the JSON array to be processed \param [in,out] res the resonance object to be modified */ void processJsonResonanceParameters( const nlohmann::json& j, LauAbsResonance& res ); //! Process the "setKnotAmp" section of the "resonances" section of the model-definition JSON /*! \param [in] j the JSON array to be processed \param [in] resType the type of MIPW object \param [in,out] mipw the MIPW object to be modified */ void processJsonSetMIPWKnotAmps( const nlohmann::json& j, const LauAbsResonance::ResonanceModel resType, LauAbsModIndPartWave& mipw ); + //! Create a JSON object containing the common settings + nlohmann::json createJsonCommonSettings() const; + + //! Create a JSON array containing the resonance settings + nlohmann::json createJsonResonances() const; + + //! Create a JSON array containing the K-matrix settings + nlohmann::json createJsonKMatrix() const; + private: //! Copy constructor (not implemented) LauIsobarDynamics(const LauIsobarDynamics& rhs); //! Copy assignment operator (not implemented) LauIsobarDynamics& operator=(const LauIsobarDynamics& rhs); //! The type used for containing the K-matrix propagators typedef std::map KMPropMap; //! The type used for mapping K-matrix components to their propagators typedef std::map KMStringMap; //! The daughters of the decay LauDaughters* daughters_; //! The kinematics of the decay LauKinematics* kinematics_; //! The efficiency model across the Dalitz plot LauAbsEffModel* effModel_; //! The self cross feed fraction models across the Dalitz plot /*! These model the fraction of signal events that are poorly reconstructed (the self cross feed fraction) as a function of Dalitz plot position. If the self cross feed is depependent on the tagging category then seperate models can be defined. */ LauTagCatScfFractionModelMap scfFractionModel_; //! The number of amplitude components UInt_t nAmp_; //! The number of incoherent amplitude components UInt_t nIncohAmp_; //! The complex coefficients for the amplitude components std::vector Amp_; //! The normalisation factor for the log-likelihood function Double_t DPNorm_; //! The fit fractions for the amplitude components LauParArray fitFrac_; //! The efficiency-uncorrected fit fractions for the amplitude components LauParArray fitFracEffUnCorr_; //! The overall Dalitz plot rate LauParameter DPRate_; //! The mean efficiency across the Dalitz plot LauParameter meanDPEff_; //! The cached data for all events std::vector data_; //! The cached data for the current event LauCacheData* currentEvent_; //! any extra parameters/quantities (e.g. K-matrix total fit fractions) std::vector extraParameters_; //! The resonances in the model std::vector sigResonances_; //! The incoherent resonances in the model std::vector sigIncohResonances_; //! The K-matrix propagators KMPropMap kMatrixPropagators_; //! The names of the M-matrix components in the model mapped to their propagators KMStringMap kMatrixPropSet_; //! The resonance types of all of the amplitude components std::vector resTypAmp_; //! The index of the daughter not produced by the resonance for each amplitude component std::vector resPairAmp_; //! The resonance types of all of the incoherent amplitude components std::vector incohResTypAmp_; //! The index of the daughter not produced by the resonance for each incoherent amplitude component std::vector incohResPairAmp_; //! The PDG codes of the daughters std::vector typDaug_; //! Whether the Dalitz plot is symmetrical Bool_t symmetricalDP_; //! Whether the Dalitz plot is fully symmetric Bool_t fullySymmetricDP_; //! Whether the Dalitz plot is a flavour-conjugate final state Bool_t flavConjDP_; //! Whether the integrals have been performed Bool_t integralsDone_; //! Whether the scheme for the integration has been determined Bool_t normalizationSchemeDone_; //! Force the symmetrisation of the integration in m13 <-> m23 for non-symmetric but flavour-conjugate final states Bool_t forceSymmetriseIntegration_; //! The storage of the integration scheme std::vector dpPartialIntegralInfo_; //! The name of the file to save integrals to TString intFileName_; //! The bin width to use when integrating over m13 Double_t m13BinWidth_; //! The bin width to use when integrating over m23 Double_t m23BinWidth_; //! The bin width to use when integrating over mPrime Double_t mPrimeBinWidth_; //! The bin width to use when integrating over thetaPrime Double_t thPrimeBinWidth_; //! The value below which a resonance width is considered to be narrow Double_t narrowWidth_; //! The factor relating the width of the narrowest resonance and the binning size Double_t binningFactor_; //! The invariant mass squared of the first and third daughters Double_t m13Sq_; //! The invariant mass squared of the second and third daughters Double_t m23Sq_; //! The square Dalitz plot coordinate, m' Double_t mPrime_; //! The square Dalitz plot coordinate theta' Double_t thPrime_; //! The tagging category Int_t tagCat_; //! The efficiency at the current point in the Dalitz plot Double_t eff_; //!The fraction of events that are poorly reconstructed (the self cross feed fraction) at the current point in the Dalitz plot Double_t scfFraction_; //! The Jacobian, for the transformation into square DP coordinates at the current point in the Dalitz plot Double_t jacobian_; //! The value of A squared for the current event Double_t ASq_; //! The normalised likelihood for the current event Double_t evtLike_; //! The total amplitude for the current event LauComplex totAmp_; //! The event-by-event running total of efficiency corrected amplitude cross terms for each pair of amplitude components /*! Calculated as the sum of ff_[i]*ff_[j]*efficiency for all events */ std::vector< std::vector > fifjEffSum_; //! The event-by-event running total of the amplitude cross terms for each pair of amplitude components /*! Calculated as the sum of ff_[i]*ff_[j] for all events */ std::vector< std::vector > fifjSum_; //! The dynamic part of the amplitude for each amplitude component at the current point in the Dalitz plot std::vector ff_; //! The dynamic part of the intensity for each incoherent amplitude component at the current point in the Dalitz plot std::vector incohInten_; //! The event-by-event running total of the dynamical amplitude squared for each amplitude component std::vector fSqSum_; //! The event-by-event running total of the dynamical amplitude squared for each amplitude component std::vector fSqEffSum_; //! The normalisation factors for the dynamic parts of the amplitude for each amplitude component std::vector fNorm_; //! The maximum allowed number of attempts when generating an event Int_t iterationsMax_; //! The number of unsucessful attempts to generate an event so far Int_t nSigGenLoop_; //! The maximum allowed value of A squared Double_t aSqMaxSet_; //! The maximum value of A squared that has been seen so far while generating Double_t aSqMaxVar_; //! The helicity flip flag for new amplitude components Bool_t flipHelicity_; //! Flag to recalculate the normalisation Bool_t recalcNormalisation_; //! List of floating resonance parameters std::vector resonancePars_; //! List of floating resonance parameter values from previous calculation std::vector resonanceParValues_; //! Indices in sigResonances_ to point to the corresponding signal resonance(s) for each floating parameter std::vector< std::vector > resonanceParResIndex_; //! Resonance indices for which the amplitudes and integrals should be recalculated std::set integralsToBeCalculated_; //! Whether to calculate separate rho and omega fit fractions from the LauRhoOmegaMix model Bool_t calculateRhoOmegaFitFractions_; ClassDef(LauIsobarDynamics,0) }; #endif diff --git a/inc/LauJsonTools.hh b/inc/LauJsonTools.hh index 4b92eba..871b29b 100644 --- a/inc/LauJsonTools.hh +++ b/inc/LauJsonTools.hh @@ -1,150 +1,152 @@ /* Copyright 2023 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ #ifndef LAU_JSON_TOOLS_HH #define LAU_JSON_TOOLS_HH #include #include #include /*! \file LauJsonTools.hh \brief File containing LauJsonTools namespace */ /*! \namespace LauJsonTools \brief Namespace containing tools for reading/writing JSON files */ namespace LauJsonTools { /*! \enum JsonType \brief Define types that can be found in JSON fields and that we can handle */ enum class JsonType { Null, //!< JSON value is null Object, //!< JSON value is an object Array, //!< JSON value is an array String, //!< JSON value is a string Boolean, //!< JSON value is a boolean Number_Integer, //!< JSON value is an integer (signed or unsigned) Number_Unsigned, //!< JSON value is an unsigned integer Number_Float, //!< JSON value is a floating point value Number, //!< JSON value is any number (integer, unsigned or float) Primitive, //!< JSON value is any primative type (null, string, boolean, integer, unsigned, float) Structured, //!< JSON value is any structured type (object, array) Any //!< JSON value is any of the above }; //! Typedef to define a combination of a JSON element's name and type using ElementNameType = std::pair< std::string, JsonType >; //! Exception object to be thrown in case of a missing element class MissingJsonElement : public std::runtime_error { public: //! Constructor /*! \param [in] what the message explaining the precise error that has occurred */ MissingJsonElement(const std::string& what) : std::runtime_error(what) {} }; //! Deserialise a JSON file to a JSON value /*! \param [in] fileName the name of the file to read \param [in] elementName the optional name of the element within the root object to retrieve - by default retrieve the root structure \param [in] expectedType the expected type of the value */ nlohmann::json readJsonFile(const std::string& fileName, const std::string& elementName = "", const JsonType expectedType = JsonType::Any); //! Serialise a JSON value to a JSON file /*! - \param [in] fileName the name of the file to be written \param [in] value the JSON value to serialise + \param [in] fileName the name of the file to be written + \param [in] elementName the (optional) name of the JSON element to which the coefficients should be written + \param [in] append if true, append the spline to the existing JSON within the file - if using this option it is then mandatory to provide elementName \param [in] indent the indentation level to use in the output in number of spaces (defaults to 4)\n From the nlohmann::json::dump documentation:\n If indent is nonnegative, then array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. A value of -1 selects the most compact representation. \return true if file successfully written, false otherwise */ - bool writeJsonFile(const std::string& fileName, const nlohmann::json& value, const int indent = 4); + bool writeJsonFile(const nlohmann::json& value, const std::string& fileName, const std::string& elementName = "", const bool append = false, const int indent = 4); //! Check that the type of a JSON value is as expected /*! \param [in] value the JSON value to check \param [in] expectedType the expected type of the value */ bool checkValueType(const nlohmann::json& value, const JsonType expectedType); //! Check that the expected JSON elements are present in the supplied object /*! \param [in] obj the JSON object to check \param [in] expectedElements the elements (names and types) that are expected \return true if all expected elements are present, false otherwise */ bool checkObjectElements( const nlohmann::json& obj, const std::vector& expectedElements ); //! Access the value of an element that should be present in an object (no checking is done) /*! \param [in] obj the JSON object to access \param [in] elementName the name of the element within the object to retrieve \return the value of the element */ template T getValue( const nlohmann::json& obj, const std::string& elementName ) { return obj.at( elementName ).get(); } //! Access an element that may or may not be present in an object /*! \param [in] obj the JSON object to access \param [in] elementName the name of the element within the object to retrieve \param [in] expectedType the expected type of the element \return a pointer to the element, or nullptr if it is not present */ const nlohmann::json* getOptionalElement( const nlohmann::json& obj, const std::string& elementName, const JsonType expectedType = JsonType::Any ); //! Access the value of an element that may or may not be present in an object /*! \param [in] obj the JSON object to access \param [in] elementName the name of the element within the object to retrieve \param [in] expectedType the expected type of the element \return the value of the element as a std::optional */ template std::optional getOptionalValue( const nlohmann::json& obj, const std::string& elementName, const JsonType expectedType = JsonType::Any ); } template std::optional LauJsonTools::getOptionalValue( const nlohmann::json& obj, const std::string& elementName, const JsonType expectedType ) { auto elem { getOptionalElement( obj, elementName, expectedType ) }; if ( ! elem ) { return {}; } return elem->get(); } #endif diff --git a/inc/LauKMatrixProdPole.hh b/inc/LauKMatrixProdPole.hh index 69bd0e9..08483d7 100644 --- a/inc/LauKMatrixProdPole.hh +++ b/inc/LauKMatrixProdPole.hh @@ -1,107 +1,113 @@ /* Copyright 2008 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauKMatrixProdPole.hh \brief File containing declaration of LauKMatrixProdPole class. */ /*! \class LauKMatrixProdPole \brief Class for defining a K-matrix production pole amplitude term. Class for defining a K-matrix production pole amplitude term */ #ifndef LAU_KMATRIX_PROD_POLE #define LAU_KMATRIX_PROD_POLE -#include "LauAbsResonance.hh" +#include "LauAbsKMatrixProdComp.hh" #include "TString.h" class LauKMatrixPropagator; class LauDaughters; class LauKinematics; -class LauKMatrixProdPole : public LauAbsResonance { +class LauKMatrixProdPole : public LauAbsKMatrixProdComp { public: //! Constructor /*! \param [in] poleName name of the pole \param [in] poleIndex number of pole \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] propagator a K-matrix propagator \param [in] daughters the daughter particles \param [in] useProdAdler boolean to turn on/off the production Adler zero factor */ - LauKMatrixProdPole( const TString& poleName, Int_t poleIndex, Int_t resPairAmpInt, - LauKMatrixPropagator* propagator, const LauDaughters* daughters, - Bool_t useProdAdler = kFALSE); + LauKMatrixProdPole( const TString& poleName, Int_t poleIndex, Int_t resPairAmpInt, + LauKMatrixPropagator* propagator, const LauDaughters* daughters, + Bool_t useProdAdler = kFALSE); //! Destructor virtual ~LauKMatrixProdPole(); // Initialise the model virtual void initialise() {return;} //! Get the resonance model type /*! \return the resonance model type */ - virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::KMatrix;} + virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::KMatrix_Pole;} //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); + //! Retrieve the propagator with which this component is associated + virtual const LauKMatrixPropagator* getPropagator() const { return thePropagator_; } + + //! Create a JSON object containing the current settings + virtual nlohmann::json writeSettingsToJson() const; + protected: //! The amplitude calculation /*! \param [in] mass the invariant-mass for the channel \param [in] spinTerm the spin-term for the final channel \return the complex amplitude */ virtual LauComplex resAmp(const Double_t mass, const Double_t spinTerm); private: //! Copy constructor (not implemented) LauKMatrixProdPole(const LauKMatrixProdPole& rhs); //! Copy assignment operator (not implemented) LauKMatrixProdPole& operator=(const LauKMatrixProdPole& rhs); //! The K-matrix propagator LauKMatrixPropagator* thePropagator_; //! The number of the pole Int_t poleIndex_; //! Boolean to turn on/off the production Adler zero factor Bool_t useProdAdler_; ClassDef(LauKMatrixProdPole, 0) // K-matrix production pole }; #endif diff --git a/inc/LauKMatrixProdSVP.hh b/inc/LauKMatrixProdSVP.hh index db254aa..260f2a3 100644 --- a/inc/LauKMatrixProdSVP.hh +++ b/inc/LauKMatrixProdSVP.hh @@ -1,107 +1,113 @@ /* Copyright 2008 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauKMatrixProdSVP.hh \brief File containing declaration of LauKMatrixProdSVP class. */ /*! \class LauKMatrixProdSVP \brief Class for defining a K-matrix production "slowly-varying part" (SVP) amplitude Class for defining a K-matrix production "slowly-varying part" (SVP) amplitude */ #ifndef LAU_KMATRIX_PROD_SVP #define LAU_KMATRIX_PROD_SVP -#include "LauAbsResonance.hh" +#include "LauAbsKMatrixProdComp.hh" #include "TString.h" class LauKMatrixPropagator; class LauDaughters; class LauKinematics; -class LauKMatrixProdSVP : public LauAbsResonance { +class LauKMatrixProdSVP : public LauAbsKMatrixProdComp { public: //! Constructor /*! \param [in] SVPName name of the slowly varying part (SVP) \param [in] channelIndex the channel number \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] propagator a K-matrix propagator \param [in] daughters the daughter particles \param [in] useProdAdler boolean to turn on/off the production Adler zero factor */ - LauKMatrixProdSVP( const TString& SVPName, Int_t channelIndex, Int_t resPairAmpInt, - LauKMatrixPropagator* propagator, const LauDaughters* daughters, - Bool_t useProdAdler = kFALSE); + LauKMatrixProdSVP( const TString& SVPName, Int_t channelIndex, Int_t resPairAmpInt, + LauKMatrixPropagator* propagator, const LauDaughters* daughters, + Bool_t useProdAdler = kFALSE); //! Destructor virtual ~LauKMatrixProdSVP(); //! Initialise the model virtual void initialise() {return;} //! Get the resonance model type /*! \return the resonance model type */ - virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::KMatrix;} + virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::KMatrix_SVP;} //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ - const std::vector& getFloatingParameters(); + virtual const std::vector& getFloatingParameters(); + + //! Retrieve the propagator with which this component is associated + virtual const LauKMatrixPropagator* getPropagator() const { return thePropagator_; } + + //! Create a JSON object containing the current settings + virtual nlohmann::json writeSettingsToJson() const; protected: //! The amplitude calculation /*! \param [in] mass the invariant-mass for the channel \param [in] spinTerm the spin-term for the final channel \return the complex amplitude */ virtual LauComplex resAmp(const Double_t mass, const Double_t spinTerm); private: //! Copy constructor (not implemented) LauKMatrixProdSVP(const LauKMatrixProdSVP& rhs); //! Copy assignment operator (not implemented) LauKMatrixProdSVP& operator=(const LauKMatrixProdSVP& rhs); //! The K-matrix propagator LauKMatrixPropagator* thePropagator_; //! The number of the channel Int_t channelIndex_; //! Boolean to turn on/off the production Adler zero factor Bool_t useProdAdler_; ClassDef(LauKMatrixProdSVP, 0) // K-matrix production SVP term }; #endif diff --git a/inc/LauKMatrixPropagator.hh b/inc/LauKMatrixPropagator.hh index 3c11acd..21fedd1 100644 --- a/inc/LauKMatrixPropagator.hh +++ b/inc/LauKMatrixPropagator.hh @@ -1,637 +1,642 @@ /* Copyright 2008 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauKMatrixPropagator.hh \brief File containing declaration of LauKMatrixPropagator class. */ /*! \class LauKMatrixPropagator \brief Class for defining a K-matrix propagator. Class used to define a K-matrix propagator. See the following papers for info: hep-ph/0204328, hep-ex/0312040, [hep-ex]0804.2089 and hep-ph/9705401. */ #ifndef LAU_KMATRIX_PROPAGATOR #define LAU_KMATRIX_PROPAGATOR #include "LauConstants.hh" #include "LauResonanceMaker.hh" #include "LauResonanceInfo.hh" #include "TMatrixD.h" #include "TString.h" +#include + #include #include class LauParameter; class LauKinematics; class LauComplex; class LauKMatrixPropagator { public: //! Constructor /*! \param [in] name name of the propagator \param [in] paramFileName the parameter file name \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] nChannels the number of channels \param [in] nPoles the number of poles \param [in] rowIndex this specifies which row of the propagator should be used when summing over the amplitude channels */ LauKMatrixPropagator( const TString& name, const TString& paramFileName, const Int_t resPairAmpInt, const Int_t nChannels, const Int_t nPoles, const Int_t rowIndex = 1 ); //! Destructor virtual ~LauKMatrixPropagator(); //! Calculate the K-matrix propagator for the given s value /*! \param [in] s the invariant mass squared */ void updatePropagator(const Double_t s); //! Read an input file to set parameters /*! \param [in] inputFile name of the input file */ void setParameters(const TString& inputFile); //! Set flag to ignore Blatt-Weisskopf-like barrier factor void ignoreBWBarrierFactor() {includeBWBarrierFactor_=kFALSE;} //! Get the scattering K matrix /*! \return the real, symmetric scattering K matrix */ TMatrixD getKMatrix() const {return ScattKMatrix_;} //! Get the real part of the propagator full matrix /*! \return the real part of the propagator full matrix */ TMatrixD getRealPropMatrix() const {return realProp_;} //! Get the negative imaginary part of the full propagator matrix /*! \return the negative imaginary part of the full propagator matrix */ TMatrixD getNegImagPropMatrix() const {return negImagProp_;} //! Get the real part of the term of the propagator /*! \param [in] channelIndex the channel number \return the real part of the propagator term */ Double_t getRealPropTerm(const Int_t channelIndex) const; //! Get the imaginary part of the term of the propagator /*! \param [in] channelIndex the channel number \return the imaginiary part of the propagator term */ Double_t getImagPropTerm(const Int_t channelIndex) const; //! Get the 1/(m_pole^2 -s) terms for the scattering and production K-matrix formulae /*! \param [in] poleIndex the number of the pole required \return the value of 1/(m_pole^2 -s) */ Double_t getPoleDenomTerm(const Int_t poleIndex) const; //! Get spin of K-matrix /*! \param [in] iChannel the index of the channel \return the value of the orbital angular momentum, L_, for this channel */ Int_t getL(const Int_t iChannel) const {return L_[iChannel];} //! Get index of final channel /*! \return the index of the channel into which the scattering happens */ Int_t getIndex() const {return index_;}; //! Get pole mass parameters, set according to the input file /*! \param [in] poleIndex number of the required pole \return the parameter of the pole mass */ LauParameter& getPoleMassSqParameter(const Int_t poleIndex); //! Get coupling constants that were loaded from the input file /*! \param [in] poleIndex number of the required pole \param [in] channelIndex number of the required channel \return the value of the coupling constant */ Double_t getCouplingConstant(const Int_t poleIndex, const Int_t channelIndex) const; //! Get coupling parameters, set according to the input file /*! \param [in] poleIndex number of the required pole \param [in] channelIndex number of the required channel \return the parameter of the coupling constant */ LauParameter& getCouplingParameter(const Int_t poleIndex, const Int_t channelIndex); //! Get scattering constants that were loaded from the input file /*! \param [in] channel1Index number of the first channel index \param [in] channel2Index number of the second channel index \return the value of the scattering constant */ Double_t getScatteringConstant(const Int_t channel1Index, const Int_t channel2Index) const; //! Get scattering parameters, set according to the input file /*! \param [in] channel1Index number of the first channel index \param [in] channel2Index number of the second channel index \return the parameter of the scattering constant */ LauParameter& getScatteringParameter(const Int_t channel1Index, const Int_t channel2Index); //! Get mSq0 production parameter /*! \return the mSq0 parameter */ LauParameter& getmSq0() {return mSq0_;} //! Get s0Scatt production parameter /*! \return the s0Scatt parameter */ LauParameter& gets0Scatt() {return s0Scatt_;} //! Get s0 production parameter /*! \return the s0Prod parameter */ LauParameter& gets0Prod() {return s0Prod_;} //! Get sA production parameter /*! \return the sA parameter */ LauParameter& getsA() {return sA_;} //! Get sA0 production parameter /*! \return the sA0 parameter */ LauParameter& getsA0() {return sA0_;} //! Get the "slowly-varying part" term of the amplitude /*! \return the svp term */ Double_t getProdSVPTerm() const {return prodSVP_;} //! Get the full complex propagator term for a given channel /*! \param [in] channelIndex the number of the required channel \return the complex propagator term */ LauComplex getPropTerm(const Int_t channelIndex) const; //! Get the DP axis identifier /*! \return the value to identify the DP axis in question */ Int_t getResPairAmpInt() const {return resPairAmpInt_;} //! Get the number of channels /*! \return the number of channels */ Int_t getNChannels() const {return nChannels_;} //! Get the number of poles /*! \return the number of poles */ Int_t getNPoles() const {return nPoles_;} //! Get the propagator name /*! \return the name of the propagator */ TString getName() const {return name_;} //! Get the unitary transition amplitude for the given channel /*! \param [in] s The invariant mass squared \param [in] channel The index number of the channel process \return the complex amplitude T */ LauComplex getTransitionAmp(const Double_t s, const Int_t channel); //! Get the complex phase space term for the given channel and invariant mass squared /*! \param [in] s The invariant mass squared \param [in] channel The index number of the channel process \return the complex phase space term rho(channel, channel) */ LauComplex getPhaseSpaceTerm(const Double_t s, const Int_t channel); //! Get the Adler zero factor, which is set when updatePropagator is called /*! \return the Adler zero factor */ Double_t getAdlerZero() const {return adlerZeroFactor_;} //! Get the THat amplitude for the given s and channel number /*! \param [in] s The invariant mass squared \param [in] channel The index number of the channel process \return the complex THat amplitude */ LauComplex getTHat(const Double_t s, const Int_t channel); + //! Create a JSON object containing the current settings + nlohmann::json writeSettingsToJson() const; + protected: // Integers to specify the allowed channels for the phase space calculations. // Please keep Zero at the start and leave TotChannels at the end // whenever more channels are added to this. //! Integers to specify the allowed channels for the phase space calculations enum class KMatrixChannels {Zero, PiPi, KK, FourPi, EtaEta, EtaEtaP, KPi, KEtaP, KThreePi, D0K, Dstar0K, TotChannels}; //! Calculate the scattering K-matrix for the given value of s /*! \param [in] s the invariant mass squared */ void calcScattKMatrix(const Double_t s); //! Calculate the real and imaginary part of the phase space density diagonal matrix /*! \param [in] s the invariant mass squared */ void calcRhoMatrix(const Double_t s); //! Retrieve the complex phasespace density for a given channel /*! \param [in] s the invariant mass squared \param [in] phaseSpaceIndex the phasespace index of the channel \return the complex phasespace density */ LauComplex getRho(const Double_t s, const LauKMatrixPropagator::KMatrixChannels) const; //! Calculate the (real) gamma angular-momentum barrier matrix /*! \param [in] s the invariant mass squared */ void calcGammaMatrix(const Double_t s); //! Calculate the gamma angular-momentum barrier /*! \param [in] iCh the channel index \param [in] s the invariant mass squared \return the centrifugal barrier factor for L=0,1, or 2 */ Double_t calcGamma(const Int_t iCh, const Double_t s) const; //! Calulate the term 1/(m_pole^2 - s) for the scattering and production K-matrix formulae /*! \param [in] s the invariant mass squared */ void calcPoleDenomVect(const Double_t s); //! Calculate the D0K+ phase space factor /*! \param [in] s the invariant mass squared \return the complex phase space factor */ LauComplex calcD0KRho(const Double_t s) const; //! Calculate the D*0K+ phase space factor /*! \param [in] s the invariant mass squared \return the complex phase space factor */ LauComplex calcDstar0KRho(const Double_t s) const; //! Calculate the pipi phase space factor /*! \param [in] s the invariant mass squared \return the complex phase space factor */ LauComplex calcPiPiRho(const Double_t s) const; //! Calculate the KK phase space factor /*! \param [in] s the invariant mass squared \return the complex phase space factor */ LauComplex calcKKRho(const Double_t s) const; //! Calculate the 4 pi phase space factor /*! \param [in] s the invariant mass squared \return the complex phase space factor */ LauComplex calcFourPiRho(const Double_t s) const; //! Calculate the eta-eta phase space factor /*! \param [in] s the invariant mass squared \return the complex phase space factor */ LauComplex calcEtaEtaRho(const Double_t s) const; //! Calculate the eta-eta' phase space factor /*! \param [in] s the invariant mass squared \return the complex phase space factor */ LauComplex calcEtaEtaPRho(const Double_t s) const; //! Calculate the Kpi phase space factor /*! \param [in] s the invariant mass squared \return the complex phase space factor */ LauComplex calcKPiRho(const Double_t s) const; //! Calculate the K-eta' phase space factor /*! \param [in] s the invariant mass squared \return the complex phase space factor */ LauComplex calcKEtaPRho(const Double_t s) const; //! Calculate the Kpipipi phase space factor /*! \param [in] s the invariant mass squared \return the complex phase space factor */ LauComplex calcKThreePiRho(const Double_t s) const; //! Calculate the "slow-varying part" /*! \param [in] s the invariant mass squared \param [in] s0 the invariant mass squared at the Adler zero \return the SVP term */ Double_t calcSVPTerm(const Double_t s, const Double_t s0) const; //! Update the scattering "slowly-varying part" /*! \param [in] s the invariant mass squared */ void updateScattSVPTerm(const Double_t s); //! Update the production "slowly-varying part" /*! \param [in] s the invariant mass squared */ void updateProdSVPTerm(const Double_t s); //! Calculate the multiplicative factor containing severa Adler zero constants /*! \param [in] s the invariant mass squared */ void updateAdlerZeroFactor(const Double_t s); //! Check the phase space factors that need to be used /*! \param [in] phaseSpaceInt phase space types \return true of false */ Bool_t checkPhaseSpaceType(const Int_t phaseSpaceInt) const; //! Get the unitary transition amplitude matrix for the given kinematics /*! \param [in] kinematics The pointer to the constant kinematics */ void getTMatrix(const LauKinematics* kinematics); //! Get the unitary transition amplitude matrix for the given kinematics /*! \param [in] s The invariant mass squared of the system */ void getTMatrix(const Double_t s); //! Get the square root of the phase space matrix void getSqrtRhoMatrix(); private: //! Copy constructor (not implemented) LauKMatrixPropagator(const LauKMatrixPropagator& rhs)=delete; //! Copy assignment operator (not implemented) LauKMatrixPropagator& operator=(const LauKMatrixPropagator& rhs)=delete; //! Initialise and set the dimensions for the internal matrices and parameter arrays void initialiseMatrices(); //! Store the (phase space) channel indices from a line in the parameter file /*! \param [in] theLine Vector of strings corresponding to the line from the parameter file */ void storeChannels(const std::vector& theLine); //! Store the pole mass and couplings from a line in the parameter file /*! \param [in] theLine Vector of strings corresponding to the line from the parameter file */ void storePole(const std::vector& theLine); //! Store the scattering coefficients from a line in the parameter file /*! \param [in] theLine Vector of strings corresponding to the line from the parameter file */ void storeScattering(const std::vector& theLine); //! Store the channels' characteristic radii from a line in the parameter file /*! \param [in] theLine Vector of strings corresponding to the line from the parameter file */ void storeRadii(const std::vector& theLine); //! Store the channels' angular momenta from a line in the parameter file /*! \param [in] theLine Vector of strings corresponding to the line from the parameter file \param [in] a Vector of integers corresponding to parameter in the propagator denominator */ void storeOrbitalAngularMomenta(const std::vector& theLine, std::vector& a); //! Store the barrier-factor parameter from a line in the parameter file /*! \param [in] theLine Vector of strings corresponding to the line from the parameter file \param [in] a Vector of integers corresponding to parameter in the propagator denominator */ void storeBarrierFactorParameter(const std::vector& theLine, std::vector& a); //! Store miscelleanous parameters from a line in the parameter file /*! \param [in] keyword the name of the parameter to be set \param [in] parString the string containing the value of the parameter */ void storeParameter(const TString& keyword, const TString& parString); //! String to store the propagator name TString name_; //! Name of the input parameter file TString paramFileName_; //! Number to identify the DP axis in question Int_t resPairAmpInt_; //! Row index - 1 Int_t index_; //! s value of the previous pole Double_t previousS_{0.0}; //! "slowly-varying part" for the scattering K-matrix Double_t scattSVP_{0.0}; //! "slowly-varying part" for the production K-matrix Double_t prodSVP_{0.0}; //! Real part of the propagator matrix TMatrixD realProp_; //! Imaginary part of the propagator matrix TMatrixD negImagProp_; //! Scattering K-matrix TMatrixD ScattKMatrix_; //! Real part of the phase space density diagonal matrix TMatrixD ReRhoMatrix_; //! Imaginary part of the phase space density diagonal matrix TMatrixD ImRhoMatrix_; //! Gamma angular-momentum barrier matrix TMatrixD GammaMatrix_; //! Identity matrix TMatrixD IMatrix_; //! Null matrix TMatrixD zeroMatrix_; //! Real part of the square root of the phase space density diagonal matrix TMatrixD ReSqrtRhoMatrix_; //! Imaginary part of the square root of the phase space density diagonal matrix TMatrixD ImSqrtRhoMatrix_; //! Real part of the unitary T matrix TMatrixD ReTMatrix_; //! Imaginary part of the unitary T matrix TMatrixD ImTMatrix_; //! Number of channels Int_t nChannels_; //! Number of poles Int_t nPoles_; //! Vector of orbital angular momenta std::vector L_; //! Boolean to indicate whether storeBarrierFactorParameter has been called Bool_t haveCalled_storeBarrierFactorParameter{kFALSE}; //! Boolean to dictate whether to include Blatt-Weisskopf-like denominator in K-matrix centrifugal barrier factor Bool_t includeBWBarrierFactor_{kTRUE}; //! Vector of squared pole masses std::vector mSqPoles_; //! Array of coupling constants LauParArray gCouplings_; //! Array of scattering SVP values LauParArray fScattering_; //! Vector of characteristic radii std::vector radii_; //! Vector of ratio a/R^2 std::vector gamAInvRadSq_; //! Vector of phase space types std::vector phaseSpaceTypes_; //! Vector of squared masses std::vector mSumSq_; //! Vector of mass differences std::vector mDiffSq_; //! Vector of 1/(m_pole^2 - s) terms for scattering and production K-matrix formulae std::vector poleDenomVect_; //! Constant from input file LauParameter mSq0_; //! Constant from input file LauParameter s0Scatt_; //! Constant from input file LauParameter s0Prod_; //! Constant from input file LauParameter sA_; //! Constant from input file LauParameter sA0_; //! Defined as 0.5*sA*mPi*mPi Double_t sAConst_{0.0}; //! Defined as 4*mPi*mPi const Double_t m2piSq_{4.0*LauConstants::mPiSq}; //! Defined as 4*mK*mK const Double_t m2KSq_{4.0*LauConstants::mKSq}; //! Defined as 4*mEta*mEta const Double_t m2EtaSq_{4.0*LauConstants::mEtaSq}; //! Defined as (mEta+mEta')^2 const Double_t mEtaEtaPSumSq_{(LauConstants::mEta + LauConstants::mEtaPrime)*(LauConstants::mEta + LauConstants::mEtaPrime)}; //! Defined as (mEta-mEta')^2 const Double_t mEtaEtaPDiffSq_{(LauConstants::mEta - LauConstants::mEtaPrime)*(LauConstants::mEta - LauConstants::mEtaPrime)}; //! Defined as (mK+mPi)^2 const Double_t mKpiSumSq_{(LauConstants::mK + LauConstants::mPi)*(LauConstants::mK + LauConstants::mPi)}; //! Defined as (mK-mPi)^2 const Double_t mKpiDiffSq_{(LauConstants::mK - LauConstants::mPi)*(LauConstants::mK - LauConstants::mPi)}; //! Defined as (mK+mEta')^2 const Double_t mKEtaPSumSq_{(LauConstants::mK + LauConstants::mEtaPrime)*(LauConstants::mK + LauConstants::mEtaPrime)}; //! Defined as (mK-mEta')^2 const Double_t mKEtaPDiffSq_{(LauConstants::mK - LauConstants::mEtaPrime)*(LauConstants::mK - LauConstants::mEtaPrime)}; //! Defined as (mK-3*mPi)^2 const Double_t mK3piDiffSq_{(LauConstants::mK - 3.0*LauConstants::mPi)*(LauConstants::mK - 3.0*LauConstants::mPi)}; //! Factor used to calculate the Kpipipi phase space term const Double_t k3piFactor_{TMath::Power((1.44 - mK3piDiffSq_)/1.44, -2.5)}; //! Factor used to calculate the pipipipi phase space term const Double_t fourPiFactor1_{16.0*LauConstants::mPiSq}; //! Factor used to calculate the pipipipi phase space term const Double_t fourPiFactor2_{TMath::Sqrt(1.0 - fourPiFactor1_)}; //! Defined as (mD0+mK)^2 const Double_t mD0KSumSq_{(LauConstants::mD0 + LauConstants::mK)*(LauConstants::mD0 + LauConstants::mK)}; //! Defined as (mD0-mK)^2 const Double_t mD0KDiffSq_{(LauConstants::mD0 - LauConstants::mK)*(LauConstants::mD0 - LauConstants::mK)}; //! Defined as (mD*0+mK)^2 const Double_t mDstar0KSumSq_{(LauResonanceMaker::get().getResInfo("D*0")->getMass()->value() + LauConstants::mK)*(LauResonanceMaker::get().getResInfo("D*0")->getMass()->value() + LauConstants::mK)}; //! Defined as (mD*0-mK)^2 const Double_t mDstar0KDiffSq_{(LauResonanceMaker::get().getResInfo("D*0")->getMass()->value() - LauConstants::mK)*(LauResonanceMaker::get().getResInfo("D*0")->getMass()->value() - LauConstants::mK)}; //! Multiplicative factor containing various Adler zero constants Double_t adlerZeroFactor_{0.0}; //! Tracks if all params have been set Bool_t parametersSet_{kFALSE}; //! Control the output of the functions static constexpr Bool_t verbose_{kFALSE}; //! Control if scattering constants are channel symmetric: f_ji = f_ij Bool_t scattSymmetry_{kFALSE}; ClassDef(LauKMatrixPropagator,0) // K-matrix amplitude model }; #endif diff --git a/inc/LauKappaRes.hh b/inc/LauKappaRes.hh index bfedd37..7faaca7 100644 --- a/inc/LauKappaRes.hh +++ b/inc/LauKappaRes.hh @@ -1,203 +1,206 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauKappaRes.hh \brief File containing declaration of LauKappaRes class. */ /*! \class LauKappaRes \brief Class for defining the Kappa resonance model Class for defining the Kappa resonance model. Formulae and data values from Phys.Lett.B 572, 1 (2003) - author D.V.Bugg */ #ifndef LAU_KAPPA_RES #define LAU_KAPPA_RES #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauKappaRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauKappaRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauKappaRes(); //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::Kappa;} //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the b1 parameter /*! \param [in] b1 new value for b1 parameter */ void setB1Value(const Double_t b1); //! Set the b2 parameter /*! \param [in] b2 new value for b2 parameter */ void setB2Value(const Double_t b2); //! Set the A parameter /*! \param [in] A new value for A parameter */ void setAValue(const Double_t A); //! Set the m0 parameter /*! \param [in] m0 new value for m0 parameter */ void setM0Value(const Double_t m0); //! Get the b1 parameter value /*! \return value of the b1 parameter */ Double_t getB1Value() const { return (b1_!=0) ? b1_->unblindValue() : 0.0; } //! Get the b2 parameter value /*! \return value of the b2 parameter */ Double_t getB2Value() const { return (b2_!=0) ? b2_->unblindValue() : 0.0; } //! Get the A parameter value /*! \return value of the A parameter */ Double_t getAValue() const { return (a_!=0) ? a_->unblindValue() : 0.0; } //! Get the m0 parameter value /*! \return value of the m0 parameter */ Double_t getM0Value() const { return (m0_!=0) ? m0_->unblindValue() : 0.0; } //! Fix the b1 parameter value /*! \return kTRUE if the b1 parameter is fixed, kFALSE otherwise */ Bool_t fixB1Value() const { return (b1_!=0) ? b1_->fixed() : 0.0; } //! Fix the b2 parameter value /*! \return kTRUE if the b2 parameter is fixed, kFALSE otherwise */ Bool_t fixB2Value() const { return (b2_!=0) ? b2_->fixed() : 0.0; } //! Fix the A parameter value /*! \return kTRUE if the A parameter is fixed, kFALSE otherwise */ Bool_t fixAValue() const { return (a_!=0) ? a_->fixed() : 0.0; } //! Fix the m0 parameter value /*! \return kTRUE if the m0 parameter is fixed, kFALSE otherwise */ Bool_t fixM0Value() const { return (m0_!=0) ? m0_->fixed() : 0.0; } //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); //! Check that Kappa daughters are K and pi void checkDaughterTypes() const; + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { b1_, b2_, a_, m0_ }; } + private: //! Copy constructor (not implemented) LauKappaRes(const LauKappaRes& rhs); //! Copy assignment operator (not implemented) LauKappaRes& operator=(const LauKappaRes& rhs); //! Square of (mK + mPi) const Double_t mSumSq_; //! Defined as mK*mK - 0.5*mPi*mPi const Double_t sAdler_; //! Factor from BES data LauParameter* b1_; //! Factor from BES data LauParameter* b2_; //! Factor from BES data LauParameter* a_; //! Factor from BES data LauParameter* m0_; ClassDef(LauKappaRes,0) // Kappa resonance model }; #endif diff --git a/inc/LauLASSBWRes.hh b/inc/LauLASSBWRes.hh index 25c6dcc..c240bf1 100644 --- a/inc/LauLASSBWRes.hh +++ b/inc/LauLASSBWRes.hh @@ -1,171 +1,174 @@ /* Copyright 2008 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauLASSBWRes.hh \brief File containing declaration of LauLASSBWRes class. */ /*! \class LauLASSBWRes \brief Class for defining the resonant part of the LASS model. Class for defining the LASS resonance model, which includes a resonant part, plus an effective range term. This class is the resonant part only. */ #ifndef LAU_LASS_BW_RES #define LAU_LASS_BW_RES #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauLASSBWRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauLASSBWRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); // Destructor virtual ~LauLASSBWRes(); //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::LASS_BW;} //! Set value of a resonance parameter /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the effective range parameter value /*! \param [in] r the new effective range parameter value */ void setEffectiveRange(const Double_t r); //! Set the scattering length parameter value /*! \param [in] a the new scattering length parameter value */ void setScatteringLength(const Double_t a); //! Get the effective range parameter /*! \return the effective range parameter */ Double_t getEffectiveRange() const {return (r_!=0) ? r_->unblindValue() : 0.0;} //! Get the scattering length range parameter /*! \return the scattering length parameter */ Double_t getScatteringLength() const {return (a_!=0) ? a_->unblindValue() : 0.0;} //! See if the effective range parameter is fixed or floating /*! \return kTRUE if the effective range parameter is fixed, kFALSE otherwise */ Bool_t fixEffectiveRange() const {return (r_!=0) ? r_->fixed() : kTRUE;} //! See if the scattering length parameter is fixed or floating /*! \return kTRUE if the scattering length parameter is fixed, kFALSE otherwise */ Bool_t fixScatteringLength() const {return (a_!=0) ? a_->fixed() : kTRUE;} //! Utility function to calculate the q0 value void calcQ0(); //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { r_, a_ }; } + private: //! Copy constructor (not implemented) LauLASSBWRes(const LauLASSBWRes& rhs); //! Copy assignment operator (not implemented) LauLASSBWRes& operator=(const LauLASSBWRes& rhs); //! Decay momentum of either daughter in the resonance rest frame Double_t q0_; //! Sum of the daughter masses Double_t mDaugSum_; //! Square of mDaugSum Double_t mDaugSumSq_; //! Difference between the daughter masses Double_t mDaugDiff_; //! Square of mDaugDiff Double_t mDaugDiffSq_; //! The resonance mass Double_t resMass_; //! Square of the resonance mass Double_t resMassSq_; //! LASS effective range parameter LauParameter* r_; //! LASS scattering length parameter LauParameter* a_; ClassDef(LauLASSBWRes,0) }; #endif diff --git a/inc/LauLASSNRRes.hh b/inc/LauLASSNRRes.hh index 45ff325..15cb0fc 100644 --- a/inc/LauLASSNRRes.hh +++ b/inc/LauLASSNRRes.hh @@ -1,170 +1,173 @@ /* Copyright 2008 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauLASSNRRes.hh \brief File containing declaration of LauLASSNRRes class. */ /*! \class LauLASSNRRes \brief Class for defining the non resonant part of the LASS model Class for defining the LASS resonance model, which includes a resonant part, plus an effective range term. This class is the nonresonant part only. */ #ifndef LAU_LASS_NR_RES #define LAU_LASS_NR_RES #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauLASSNRRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauLASSNRRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::LASS_NR;} //! Set value of a resonance parameter /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the effective range parameter value /*! \param [in] r the new effective range parameter value */ void setEffectiveRange(const Double_t r); //! Set the scattering length parameter value /*! \param [in] a the new scattering length parameter value */ void setScatteringLength(const Double_t a); //! Set the cut off parameter value /*! \param [in] cutOff the new cut off parameter value */ void setCutOff(const Double_t cutOff); //! Get the effective range parameter value /*! \return the effective range parameter value */ Double_t getEffectiveRange() const {return (r_!=0) ? r_->unblindValue() : 0.0;} //! Get the scattering length parameter value /*! \return the scattering length parameter value */ Double_t getScatteringLength() const {return (a_!=0) ? a_->unblindValue() : 0.0;} //! Get the cut off parameter value /*! \return the cut off parameter value */ Double_t getCutOff() const {return (cutOff_!=nullptr) ? cutOff_->unblindValue() : 0.0;} //! See if the effective range parameter is fixed or floating /*! \return kTRUE if the effective range parameter is fixed, kFALSE otherwise */ Bool_t fixEffectiveRange() const {return (r_!=0) ? r_->fixed() : kTRUE;} //! See if the scattering length parameter is fixed or floating /*! \return kTRUE if the scattering length parameter is fixed, kFALSE otherwise */ Bool_t fixScatteringLength() const {return (a_!=0) ? a_->fixed() : kTRUE;} //! See if the cut off parameter is fixed or floating /*! \return kTRUE if the cut off parameter is fixed, kFALSE otherwise */ Bool_t fixCutOff() const {return (cutOff_!=nullptr) ? cutOff_->fixed() : kTRUE;} //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { r_, a_, cutOff_ }; } + private: //! Copy constructor (not implemented) LauLASSNRRes(const LauLASSNRRes& rhs); //! Copy assignment operator (not implemented) LauLASSNRRes& operator=(const LauLASSNRRes& rhs); //! LASS effective range parameter LauParameter* r_{nullptr}; //! LASS scattering length parameter LauParameter* a_{nullptr}; //! LASS cut off parameter LauParameter* cutOff_{nullptr}; ClassDef(LauLASSNRRes,0) }; #endif diff --git a/inc/LauLASSRes.hh b/inc/LauLASSRes.hh index 24b6e82..88081bb 100644 --- a/inc/LauLASSRes.hh +++ b/inc/LauLASSRes.hh @@ -1,188 +1,191 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauLASSRes.hh \brief File containing declaration of LauLASSRes class. */ /*! \class LauLASSRes \brief Class for defining the LASS resonance model. Class for defining the LASS resonance model, which includes a resonant part, plus an effective range term. This class is the coherent sum of the two. */ #ifndef LAU_LASS_RES #define LAU_LASS_RES #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauLASSRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauLASSRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::LASS;} //! Set value of a resonance parameter /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the effective range parameter value /*! \param [in] r the new effective range parameter value */ void setEffectiveRange(const Double_t r); //! Set the scattering length parameter value /*! \param [in] a the new scattering length parameter value */ void setScatteringLength(const Double_t a); //! Set the cut off parameter value /*! \param [in] cutOff the new cut off parameter value */ void setCutOff(const Double_t cutOff); //! Get the effective range parameter value /*! \return the effective range parameter value */ Double_t getEffectiveRange() const {return (r_!=nullptr) ? r_->unblindValue() : 0.0;} //! Get the scattering length parameter value /*! \return the scattering length parameter value */ Double_t getScatteringLength() const {return (a_!=nullptr) ? a_->unblindValue() : 0.0;} //! Get the cut off parameter value /*! \return the cut off parameter value */ Double_t getCutOff() const {return (cutOff_!=nullptr) ? cutOff_->unblindValue() : 0.0;} //! See if the effective range parameter is fixed or floating /*! \return kTRUE if the effective range parameter is fixed, kFALSE otherwise */ Bool_t fixEffectiveRange() const {return (r_!=nullptr) ? r_->fixed() : kTRUE;} //! See if the scattering length parameter is fixed or floating /*! \return kTRUE if the scattering length parameter is fixed, kFALSE otherwise */ Bool_t fixScatteringLength() const {return (a_!=nullptr) ? a_->fixed() : kTRUE;} //! See if the cut off parameter is fixed or floating /*! \return kTRUE if the cut off parameter is fixed, kFALSE otherwise */ Bool_t fixCutOff() const {return (cutOff_!=nullptr) ? cutOff_->fixed() : kTRUE;} //! Utility function to calculate the q0 value void calcQ0(); //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { r_, a_, cutOff_ }; } + private: //! Copy constructor (not implemented) LauLASSRes(const LauLASSRes& rhs); //! Copy assignment operator (not implemented) LauLASSRes& operator=(const LauLASSRes& rhs); //! Decay momentum of either daughter in the resonance rest frame Double_t q0_{0.0}; //! Sum of the daughter masses Double_t mDaugSum_{0.0}; //! Square of mDaugSum Double_t mDaugSumSq_{0.0}; //! Difference between the daughter masses Double_t mDaugDiff_{0.0}; //! Square of mDaugDiff Double_t mDaugDiffSq_{0.0}; //! The resonance mass Double_t resMass_{0.0}; //! Square of the resonance mass Double_t resMassSq_{0.0}; //! LASS effective range parameter LauParameter* r_{nullptr}; //! LASS scattering length parameter LauParameter* a_{nullptr}; //! LASS cut off parameter LauParameter* cutOff_{nullptr}; ClassDef(LauLASSRes,0) }; #endif diff --git a/inc/LauLHCbNR.hh b/inc/LauLHCbNR.hh index ebff770..c29011d 100644 --- a/inc/LauLHCbNR.hh +++ b/inc/LauLHCbNR.hh @@ -1,191 +1,200 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauLHCbNR.hh \brief File containing declaration of LauLHCbNR class. */ /*! \class LauLHCbNR \brief Class for defining the LHCb nonresonant model. Defines the nonresonant model from the LHCb collaboration. */ #ifndef LAU_LHCB_NR #define LAU_LHCB_NR #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauKinematics; class LauParameter; class LauLHCbNR : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauLHCbNR(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauLHCbNR(); //! Override the enforcement of pure Legendre polynomial spin factors /*! By default this model uses pure Legendre polynomial spin factors, regardless of the default type set in LauResonanceMaker or any specific request from the user. This function allows the enforcement to be overridden. \param [in] forceLegendre boolean flag (kTRUE, the default, implies enforcement of pure Legendre spin factors, kFALSE overrides this to allow use of other formalisms) */ void enforceLegendreSpinFactors( const Bool_t forceLegendre ) { forceLegendre_ = forceLegendre; } + //! Check if we are enforcing pure Legendre polynomial spin factors + [[nodiscard]] Bool_t enforceLegendreSpinFactors() const { return forceLegendre_; } + //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::LHCbNR;} //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); + //! Create a JSON object containing the current settings + virtual nlohmann::json writeSettingsToJson() const; + protected: //! Set the parameter alpha, the effective range /*! \param [in] alpha the new effective range parameter value */ void setAlpha(const Double_t alpha); //! Set the parameter beta, the phase /*! \param [in] beta the phase parameter value */ void setBeta(const Double_t beta); //! Set the parameter delta, the shift in mass /*! \param [in] delta the mass shift value */ void setDelta(const Double_t delta); //! Get the effective range parameter /*! \return the effective range parameter */ Double_t getAlpha() const {return (alpha_!=0) ? alpha_->unblindValue() : 0.0;} //! Get the phase parameter /*! \return the phase parameter */ Double_t getBeta() const {return (beta_!=0) ? beta_->unblindValue() : 0.0;} //! Get the shift parameter /*! \return the shift parameter */ Double_t getDelta() const {return (delta_!=0) ? delta_->unblindValue() : 0.0;} //! See if the alpha parameter is fixed or floating /*! \return kTRUE if the effective range parameter is fixed, kFALSE otherwise */ Bool_t fixAlpha() const {return (alpha_!=0) ? alpha_->fixed() : kTRUE;} //! See if the beta parameter is fixed or floating /*! \return kTRUE if the phase parameter is fixed, kFALSE otherwise */ Bool_t fixBeta() const {return (beta_!=0) ? beta_->fixed() : kTRUE;} //! See if the delta parameter is fixed or floating /*! \return kTRUE if the delta parameter is fixed, kFALSE otherwise */ Bool_t fixDelta() const {return (delta_!=0) ? delta_->fixed() : kTRUE;} //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { alpha_, beta_, delta_ }; } + private: //! Copy constructor (not implemented) LauLHCbNR(const LauLHCbNR& rhs); //! Copy assignment operator (not implemented) LauLHCbNR& operator=(const LauLHCbNR& rhs); //! The range parameter LauParameter* alpha_; //! The phase parameter LauParameter* beta_; //! The shift parameter LauParameter* delta_; //! Force use of Legendre spin factors Bool_t forceLegendre_; ClassDef(LauLHCbNR,0) }; #endif diff --git a/inc/LauNRAmplitude.hh b/inc/LauNRAmplitude.hh index 26b5a0b..f78e039 100644 --- a/inc/LauNRAmplitude.hh +++ b/inc/LauNRAmplitude.hh @@ -1,227 +1,230 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauNRAmplitude.hh \brief File containing declaration of LauNRAmplitude class. */ /*! \class LauNRAmplitude \brief Class for defining the NR amplitude model. Class for defining the NR amplitude model. Formulae and data values from arXiv:0709.0075v1 [hep-ph]. */ #ifndef LAU_NR_AMPLITUDE #define LAU_NR_AMPLITUDE #include "TString.h" #include "LauAbsResonance.hh" #include "LauComplex.hh" class LauKinematics; class LauNRAmplitude : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauNRAmplitude(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauNRAmplitude(); //! Initialise the model virtual void initialise(); //! Complex resonant amplitude /*! /param [in] kinematics kinematic parameters of the parent and daughter particles /return the complex amplitude */ virtual LauComplex amplitude(const LauKinematics* kinematics); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::NRModel;} //! Set value of a resonance parameter /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! This is not meant to be called virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); //! Evaluate the expression 1.0 / (1.0 + TMath::Exp( c * (s-p) )) /*! \param [in] s invariant mass squared \param [in] c parameter from arXiv:0709.0075v1 [hep-ph] \param [in] p parameter from arXiv:0709.0075v1 [hep-ph] \return the value of the expression 1.0 / (1.0 + TMath::Exp( c * (s-p) )) */ Double_t f(const Double_t s, const Double_t c, const Double_t p) const; //! Set the d parameter value /*! \param [in] d the new d parameter value */ void setdParameter(const Double_t d); //! Set the c1 parameter value /*! \param [in] c1 the new c1 parameter value */ void setc1Parameter(const Double_t c1); //! Set the c2 parameter value /*! \param [in] c2 the new c2 parameter value */ void setc2Parameter(const Double_t c2); //! Set the p1 parameter value /*! \param [in] p1 the new p1 parameter value */ void setp1Parameter(const Double_t p1); //! Set the p2 parameter value /*! \param [in] p2 the new p2 parameter value */ void setp2Parameter(const Double_t p2); //! Get the d parameter value /*! \return the new d parameter value */ Double_t getdParameter() const {return (d_!=0) ? d_->unblindValue() : 0.0;} //! Get the c1 parameter value /*! \return the new c1 parameter value */ Double_t getc1Parameter() const {return (c1_!=0) ? c1_->unblindValue() : 0.0;} //! Get the c2 parameter value /*! \return the new c2 parameter value */ Double_t getc2Parameter() const {return (c2_!=0) ? c2_->unblindValue() : 0.0;} //! Get the p1 parameter value /*! \return the new p1 parameter value */ Double_t getp1Parameter() const {return (p1_!=0) ? p1_->unblindValue() : 0.0;} //! Get the p2 parameter value /*! \return the new p2 parameter value */ Double_t getp2Parameter() const {return (p2_!=0) ? p2_->unblindValue() : 0.0;} //! See if the d parameter is fixed or floating /*! \return kTRUE if the d parameter is fixed, kFALSE otherwise */ Bool_t fixdParameter() const {return (d_!=0) ? d_->fixed() : kTRUE;} //! See if the c1 parameter is fixed or floating /*! \return kTRUE if the c1 parameter is fixed, kFALSE otherwise */ Bool_t fixc1Parameter() const {return (c1_!=0) ? c1_->fixed() : kTRUE;} //! See if the c2 parameter is fixed or floating /*! \return kTRUE if the c2 parameter is fixed, kFALSE otherwise */ Bool_t fixc2Parameter() const {return (c2_!=0) ? c2_->fixed() : kTRUE;} //! See if the p1 parameter is fixed or floating /*! \return kTRUE if the p1 parameter is fixed, kFALSE otherwise */ Bool_t fixp1Parameter() const {return (p1_!=0) ? p1_->fixed() : kTRUE;} //! See if the p2 parameter is fixed or floating /*! \return kTRUE if the p2 parameter is fixed, kFALSE otherwise */ Bool_t fixp2Parameter() const {return (p2_!=0) ? p2_->fixed() : kTRUE;} + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { d_, c1_, c2_, p1_, p2_ }; } + private: //! Copy constructor (not implemented) LauNRAmplitude(const LauNRAmplitude& rhs); //! Copy assignment operator (not implemented) LauNRAmplitude& operator=(const LauNRAmplitude& rhs); //! Parameter from arXiv:0709.0075v1 [hep-ph] LauParameter* d_; //! Parameter from arXiv:0709.0075v1 [hep-ph] LauParameter* c1_; //! Parameter from arXiv:0709.0075v1 [hep-ph] LauParameter* c2_; //! Parameter from arXiv:0709.0075v1 [hep-ph] LauParameter* p1_; //! Parameter from arXiv:0709.0075v1 [hep-ph] LauParameter* p2_; ClassDef(LauNRAmplitude,0) // Non-resonant amplitude model }; #endif diff --git a/inc/LauPolarFormFactorNR.hh b/inc/LauPolarFormFactorNR.hh index 7553914..147f40a 100644 --- a/inc/LauPolarFormFactorNR.hh +++ b/inc/LauPolarFormFactorNR.hh @@ -1,142 +1,145 @@ /* Copyright 2018 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauPolarFormFactorNR.hh \brief File containing declaration of LauPolarFormFactorNR class. */ /*! \class LauPolarFormFactorNR \brief Class for defining a nonresonant form factor model Defines the nonresonant form factor model from: Nogueira, Bediaga, Cavalcante, Frederico, Lorenco: Phys. Rev. D92 (2015) 054010, arXiv:1506.08332 [hep-ph] Pelaez, Yndurain: Phys. Rev. D71 (2005) 074016, arXiv:hep-ph/0411334 */ #ifndef LAU_POLAR_FORM_FACTOR_NR #define LAU_POLAR_FORM_FACTOR_NR #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauKinematics; class LauParameter; class LauPolarFormFactorNR : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resType the model of the resonance \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauPolarFormFactorNR(LauResonanceInfo* resInfo, const LauAbsResonance::ResonanceModel resType, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauPolarFormFactorNR(); //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return model_;} //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the parameter lambda, the NR shape parameter /*! \param [in] lambda the NR shape parameter */ void setLambda(const Double_t lambda); //! Get the parameter lambda, the NR shape parameter /*! \return lambda, the NR shape parameter */ Double_t getLambda() const {return (lambda_!=0) ? lambda_->value() : 0.0;} //! See if the lambda parameter is fixed or floating /*! \return kTRUE if the lambda parameter is fixed, kFALSE otherwise */ Bool_t fixLambda() const {return (lambda_!=0) ? lambda_->fixed() : kTRUE;} //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm Zemach spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { lambda_ }; } + private: //! Copy constructor (not implemented) LauPolarFormFactorNR(const LauPolarFormFactorNR& rhs); //! Copy assignment operator (not implemented) LauPolarFormFactorNR& operator=(const LauPolarFormFactorNR& rhs); //! The parameter of the model LauParameter* lambda_; //! The model to use LauAbsResonance::ResonanceModel model_; ClassDef(LauPolarFormFactorNR,0) }; #endif diff --git a/inc/LauPolarFormFactorSymNR.hh b/inc/LauPolarFormFactorSymNR.hh index 3c0afa6..7605d39 100644 --- a/inc/LauPolarFormFactorSymNR.hh +++ b/inc/LauPolarFormFactorSymNR.hh @@ -1,150 +1,153 @@ /* Copyright 2018 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauPolarFormFactorSymNR.hh \brief File containing declaration of LauPolarFormFactorSymNR class. */ /*! \class LauPolarFormFactorSymNR \brief Class for defining a nonresonant form factor model Defines the nonresonant form factor model from: Nogueira, Bediaga, Cavalcante, Frederico, Lorenco: Phys. Rev. D92 (2015) 054010, arXiv:1506.08332 [hep-ph] Pelaez, Yndurain: Phys. Rev. D71 (2005) 074016, arXiv:hep-ph/0411334 modified for symmetric DPs. */ #ifndef LAU_POLAR_FORM_FACTOR_SYM_NR #define LAU_POLAR_FORM_FACTOR_SYM_NR #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauKinematics; class LauParameter; class LauPolarFormFactorSymNR : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resType the model of the resonance \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauPolarFormFactorSymNR(LauResonanceInfo* resInfo, const LauAbsResonance::ResonanceModel resType, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauPolarFormFactorSymNR(); //! Initialise the model virtual void initialise(); //! Get the complex dynamical amplitude /*! \param [in] kinematics the kinematic variables of the current event \return the complex amplitude */ virtual LauComplex amplitude(const LauKinematics* kinematics); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return model_;} //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the parameter lambda, the NR shape parameter /*! \param [in] lambda the NR shape parameter */ void setLambda(const Double_t lambda); //! Get the parameter lambda, the NR shape parameter /*! \return lambda the NR shape parameter */ Double_t getLambda() const {return (lambda_!=0) ? lambda_->value() : 0.0;} //! See if the lambda parameter is fixed or floating /*! \return kTRUE if the lambda parameter is fixed, kFALSE otherwise */ Bool_t fixLambda() const {return (lambda_!=0) ? lambda_->fixed() : kTRUE;} //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm Zemach spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { lambda_ }; } + private: //! Copy constructor (not implemented) LauPolarFormFactorSymNR(const LauPolarFormFactorSymNR& rhs); //! Copy assignment operator (not implemented) LauPolarFormFactorSymNR& operator=(const LauPolarFormFactorSymNR& rhs); //! The parameter of the model LauParameter* lambda_; //! The model to use LauAbsResonance::ResonanceModel model_; ClassDef(LauPolarFormFactorSymNR,0) }; #endif diff --git a/inc/LauRescattering2Res.hh b/inc/LauRescattering2Res.hh index 8e4a50f..2986024 100644 --- a/inc/LauRescattering2Res.hh +++ b/inc/LauRescattering2Res.hh @@ -1,187 +1,190 @@ /* Copyright 2018 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauRescattering2Res.hh \brief File containing declaration of LauRescattering2Res class. */ /*! \class LauRescattering2Res \brief Class for defining an alternative rescattering model. Model for pipi SWave proposed by J.Schechter as used by Cleo (PRD76,01200(2007) to replace the sigma and f0(980) contributions. */ #ifndef LAU_RESCATTERING2_RES #define LAU_RESCATTERING2_RES #include "TString.h" #include "LauAbsResonance.hh" #include "LauComplex.hh" class LauKinematics; class LauRescattering2Res : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauRescattering2Res(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauRescattering2Res(); //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::Rescattering2;} //! Set value of a resonance parameter /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! This is not meant to be called virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); Double_t pn(const Double_t x, const Double_t n) const; Double_t x(const Double_t sqr_t, const Int_t i) const; Double_t phi00(const Double_t sqr_t, const Int_t i) const; Double_t g00(const Double_t sqr_t, const Int_t i) const; void setB1Parameter(const Double_t B1); void setB2Parameter(const Double_t B2); void setB3Parameter(const Double_t B3); void setC1Parameter(const Double_t C1); void setC2Parameter(const Double_t C2); void setC3Parameter(const Double_t C3); void setC4Parameter(const Double_t C4); void setC5Parameter(const Double_t C5); void setD0Parameter(const Double_t D0); void setD1Parameter(const Double_t D1); void setD2Parameter(const Double_t D2); void setD3Parameter(const Double_t D3); void setF1Parameter(const Double_t F1); void setF2Parameter(const Double_t F2); void setF3Parameter(const Double_t F3); void setF4Parameter(const Double_t F4); Double_t getB1Parameter() const {return (B1_!=0) ? B1_->value() : 0.0;} Bool_t fixB1Parameter() const {return (B1_!=0) ? B1_->fixed() : kTRUE;} Double_t getB2Parameter() const {return (B2_!=0) ? B2_->value() : 0.0;} Bool_t fixB2Parameter() const {return (B2_!=0) ? B2_->fixed() : kTRUE;} Double_t getB3Parameter() const {return (B3_!=0) ? B3_->value() : 0.0;} Bool_t fixB3Parameter() const {return (B3_!=0) ? B3_->fixed() : kTRUE;} Double_t getC1Parameter() const {return (C1_!=0)? C1_->value() : 0.0;} Bool_t fixC1Parameter() const {return (C1_!=0) ?C1_->fixed() : kTRUE;} Double_t getC2Parameter() const {return (C2_!=0)? C2_->value() : 0.0;} Bool_t fixC2Parameter() const {return (C2_!=0) ?C2_->fixed() : kTRUE;} Double_t getC3Parameter() const {return (C3_!=0)? C3_->value() : 0.0;} Bool_t fixC3Parameter() const {return (C3_!=0) ?C3_->fixed() : kTRUE;} Double_t getC4Parameter() const {return (C4_!=0)? C4_->value() : 0.0;} Bool_t fixC4Parameter() const {return (C4_!=0) ?C4_->fixed() : kTRUE;} Double_t getC5Parameter() const {return (C5_!=0)? C5_->value() : 0.0;} Bool_t fixC5Parameter() const {return (C5_!=0) ?C5_->fixed() : kTRUE;} Double_t getD0Parameter() const {return (D0_!=0) ? D0_->value() : 0.0;} Bool_t fixD0Parameter() const {return (D0_!=0) ? D0_->fixed() : kTRUE;} Double_t getD1Parameter() const {return (D1_!=0) ? D1_->value() : 0.0;} Bool_t fixD1Parameter() const {return (D1_!=0) ? D1_->fixed() : kTRUE;} Double_t getD2Parameter() const {return (D2_!=0) ? D2_->value() : 0.0;} Bool_t fixD2Parameter() const {return (D2_!=0) ? D2_->fixed() : kTRUE;} Double_t getD3Parameter() const {return (D3_!=0) ? D3_->value() : 0.0;} Bool_t fixD3Parameter() const {return (D3_!=0) ? D3_->fixed() : kTRUE;} Double_t getF1Parameter() const {return (F1_!=0) ? F1_->value() : 0.0;} Bool_t fixF1Parameter() const {return (F1_!=0) ? F1_->fixed() : kTRUE;} Double_t getF2Parameter() const {return (F2_!=0) ? F2_->value() : 0.0;} Bool_t fixF2Parameter() const {return (F2_!=0) ? F2_->fixed() : kTRUE;} Double_t getF3Parameter() const {return (F3_!=0) ? F3_->value() : 0.0;} Bool_t fixF3Parameter() const {return (F3_!=0) ? F3_->fixed() : kTRUE;} Double_t getF4Parameter() const {return (F4_!=0) ? F4_->value() : 0.0;} Bool_t fixF4Parameter() const {return (F4_!=0) ? F4_->fixed() : kTRUE;} + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { B1_, B2_, B3_, C1_, C2_, C3_, C4_, C5_, D0_, D1_, D2_, D3_, F1_, F2_, F3_, F4_ }; } + private: //! Copy constructor (not implemented) LauRescattering2Res(const LauRescattering2Res& rhs); //! Copy assignment operator (not implemented) LauRescattering2Res& operator=(const LauRescattering2Res& rhs); //! Parameter LauParameter* B1_; LauParameter* B2_; LauParameter* B3_; LauParameter* C1_; LauParameter* C2_; LauParameter* C3_; LauParameter* C4_; LauParameter* C5_; LauParameter* D0_; LauParameter* D1_; LauParameter* D2_; LauParameter* D3_; LauParameter* F1_; LauParameter* F2_; LauParameter* F3_; LauParameter* F4_; Double_t sqr_tmin[3], sqr_tmax[3]; Double_t B0_, C0_, F0_; ClassDef(LauRescattering2Res,0) // pipi S wave model by Schechter amplitude model }; #endif diff --git a/inc/LauRescatteringRes.hh b/inc/LauRescatteringRes.hh index ea1840d..9c92220 100644 --- a/inc/LauRescatteringRes.hh +++ b/inc/LauRescatteringRes.hh @@ -1,304 +1,307 @@ /* Copyright 2018 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauRescatteringRes.hh \brief File containing declaration of LauRescatteringRes class. */ /*! \class LauRescatteringRes \brief Class for defining the rescattering model. Defines the Rescatering models from PiPi-KK Inelastic Scatering : 2005: J.R. Pelaez, F. J. Ynduráin: PHYSICAL REVIEW D 71, 074016 (2005) 2015: J. H. Alvarenga Nogueira, I. Bediaga, A. B. R. Cavalcante, T. Frederico, and O. Lourenço: PHYSICAL REVIEW D 92, 054010 (2015) 2018: J.R. Pelaez, A.Rodas: Unpublished yet PiPi -> KK scattering up to 1.47 GeV with hyperbolic dispersion relations. */ #ifndef LAU_RESCATTERING_RES #define LAU_RESCATTERING_RES #include "TString.h" #include "LauComplex.hh" #include "LauAbsResonance.hh" class LauKinematics; class LauParameter; class LauRescatteringRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resType the model of the resonance \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauRescatteringRes(LauResonanceInfo* resInfo, const LauAbsResonance::ResonanceModel resType, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauRescatteringRes(); //! Initialise the model virtual void initialise(); //! Get the complex dynamical amplitude /*! \param [in] kinematics the kinematic variables of the current event \return the complex amplitude */ virtual LauComplex amplitude(const LauKinematics* kinematics); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return model_;} //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the parameter lambdaPiPi, the term for the PiPi /*! \param [in] lambda the term for the PiPi */ void setLambdaPiPi(const Double_t lambda); //! Get the lambdaPiPi, the term for the PiPi /*! \return lambdaPiPi, the term for the PiPi */ Double_t getLambdaPiPi() const {return (lambdaPiPi_!=0) ? lambdaPiPi_->value() : 0.0;} //! See if the lambdaPiPi parameter is fixed or floating /*! \return kTRUE if the lambdaPiPi parameter is fixed, kFALSE otherwise */ Bool_t fixLambdaPiPi() const {return (lambdaPiPi_!=0) ? lambdaPiPi_->fixed() : kTRUE;} //! Set the parameter lambdaKK, the term for the KK /*! \param [in] lambda the term for the KK */ void setLambdaKK(const Double_t lambda); //! Get the lambdaKK, the term for the KK /*! \return lambdaKK, the term for the KK */ Double_t getLambdaKK() const {return (lambdaKK_!=0) ? lambdaKK_->value() : 0.0;} //! See if the lambdaKK parameter is fixed or floating /*! \return kTRUE if the lambdaKK parameter is fixed, kFALSE otherwise */ Bool_t fixLambdaKK() const {return (lambdaKK_!=0) ? lambdaKK_->fixed() : kTRUE;} //! Set the parameter Ms /*! \param [in] Ms */ void setMs(const Double_t Ms); //! Get the Ms /*! \return the Ms */ Double_t getMs() const {return (Ms_!=0) ? Ms_->value() : 0.0;} //! See if the Ms parameter is fixed or floating /*! \return kTRUE if the Ms parameter is fixed, kFALSE otherwise */ Bool_t fixMs() const {return (Ms_!=0) ? Ms_->fixed() : kTRUE;} //! Set the parameter Mf /*! \param [in] Mf */ void setMf(const Double_t Mf); //! Get the Mf /*! \return the Mf */ Double_t getMf() const {return (Mf_!=0) ? Mf_->value() : 0.0;} //! See if the Mf parameter is fixed or floating /*! \return kTRUE if the Mf parameter is fixed, kFALSE otherwise */ Bool_t fixMf() const {return (Mf_!=0) ? Mf_->fixed() : kTRUE;} //! Set the parameter Mprime /*! \param [in] Mprime */ void setMprime(const Double_t Mprime); //! Get the Mprime /*! \return the Mprime */ Double_t getMprime() const {return (Mprime_!=0) ? Mprime_->value() : 0.0;} //! See if the Mprime parameter is fixed or floating /*! \return kTRUE if the Mprime parameter is fixed, kFALSE otherwise */ Bool_t fixMprime() const {return (Mprime_!=0) ? Mprime_->fixed() : kTRUE;} //! Set the parameter Eps1 /*! \param [in] Eps1 */ void setEps1(const Double_t Eps1); //! Get the Eps1 /*! \return the Eps1 */ Double_t getEps1() const {return (Eps1_!=0) ? Eps1_->value() : 0.0;} //! See if the Eps1 parameter is fixed or floating /*! \return kTRUE if the Eps1 parameter is fixed, kFALSE otherwise */ Bool_t fixEps1() const {return (Eps1_!=0) ? Eps1_->fixed() : kTRUE;} //! Set the parameter Eps2 /*! \param [in] Eps2 */ void setEps2(const Double_t Eps2); //! Get the Eps2 /*! \return the Eps2 */ Double_t getEps2() const {return (Eps2_!=0) ? Eps2_->value() : 0.0;} //! See if the Eps2 parameter is fixed or floating /*! \return kTRUE if the Eps2 parameter is fixed, kFALSE otherwise */ Bool_t fixEps2() const {return (Eps2_!=0) ? Eps2_->fixed() : kTRUE;} //! Set the parameter C0 /*! \param [in] C0 */ void setC0(const Double_t C0); //! Get the C0 /*! \return the C0 */ Double_t getC0() const {return (C0_!=0) ? C0_->value() : 0.0;} //! See if the C0 parameter is fixed or floating /*! \return kTRUE if the C0 parameter is fixed, kFALSE otherwise */ Bool_t fixC0() const {return (C0_!=0) ? C0_->fixed() : kTRUE;} //! Complex resonant amplitude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm Zemach spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { lambdaPiPi_, lambdaKK_, Mf_, Ms_, Mprime_, Eps1_, Eps2_, C0_ }; } + private: //! Copy constructor (not implemented) LauRescatteringRes(const LauRescatteringRes& rhs); //! Copy assignment operator (not implemented) LauRescatteringRes& operator=(const LauRescatteringRes& rhs); //! the term for the PiPi LauParameter* lambdaPiPi_; //! the term for the KK LauParameter* lambdaKK_; //! the term for the Mf_ LauParameter* Mf_; //! the term for the Ms LauParameter* Ms_; //! the term for the Mprime LauParameter* Mprime_; //! the term for the Eps1 LauParameter* Eps1_; //! the term for the Eps2 LauParameter* Eps2_; //! the term for the C0 LauParameter* C0_; //! The model to use LauAbsResonance::ResonanceModel model_; ClassDef(LauRescatteringRes,0) }; #endif diff --git a/inc/LauResonanceMaker.hh b/inc/LauResonanceMaker.hh index 970fc0d..be37576 100644 --- a/inc/LauResonanceMaker.hh +++ b/inc/LauResonanceMaker.hh @@ -1,206 +1,226 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauResonanceMaker.hh \brief File containing declaration of LauResonanceMaker class. */ /*! \class LauResonanceMaker \brief Singleton factory class for creating resonances. Singleton factory class for creating resonances. Information records for all known resonances are stored within this class. */ #ifndef LAU_RESONANCE_MAKER #define LAU_RESONANCE_MAKER #include "LauAbsResonance.hh" #include "TString.h" +#include + #include #include #include class LauDaughters; class LauResonanceInfo; class LauResonanceMaker final { public: //! Get the factory instance static LauResonanceMaker& get(); //! Destructor ~LauResonanceMaker(); + //! Get the type of BW factor + LauBlattWeisskopfFactor::BarrierType getBWType() const { return bwBarrierType_; } + + //! Get the rest frame in which the bachelor momentum should be calculated (for all BW categories) + LauBlattWeisskopfFactor::RestFrame getBWBachelorRestFrame() const { return bwRestFrame_; } + + //! Get the spin formalism + LauAbsResonance::SpinType getSpinFormalism() const { return spinFormalism_; } + //! Set the type of BW factor (for all categories) /*! This must be used before creating any resonances \param [in] bwType the Blatt-Weisskopf barrier type */ void setBWType(const LauBlattWeisskopfFactor::BarrierType bwType); //! Set the rest frame in which the bachelor momentum should be calculated (for all BW categories) /*! This must be used before creating any resonances \param [in] restFrame the rest frame in which the bachelor momentum should be calculated for the Blatt-Weisskopf factors */ void setBWBachelorRestFrame(const LauBlattWeisskopfFactor::RestFrame restFrame); //! Set the spin formalism to be used for all resonances /*! This must be used before creating any resonances \param [in] spinType the spin formalism to be used */ void setSpinFormalism(const LauAbsResonance::SpinType spinType); //! Set the BW radius for the given category /*! \param [in] bwCategory the Blatt-Weisskopf barrier factor category \param [in] bwRadius the radius value to be used for the given category */ void setDefaultBWRadius(const LauBlattWeisskopfFactor::Category bwCategory, const Double_t bwRadius); //! Fix or release the Blatt-Weisskopf barrier radius for the given category /*! \param [in] bwCategory the Blatt-Weisskopf barrier factor category \param [in] fixRadius new status of the radius (kTRUE = fixed, kFALSE = floating) */ void fixBWRadius(const LauBlattWeisskopfFactor::Category bwCategory, const Bool_t fixRadius); //! Create a resonance /*! \param [in] daughters defines the Dalitz plot in which the resonance should be created \param [in] resName the name of the resonant particle \param [in] resPairAmpInt the index of the daughter not produced by the resonance \param [in] resType the type of the resonance \param [in] bwCategory the Blatt-Weisskopf barrier factor category \return the resonance */ LauAbsResonance* getResonance(const LauDaughters* daughters, const TString& resName, const Int_t resPairAmpInt, const LauAbsResonance::ResonanceModel resType, const LauBlattWeisskopfFactor::Category bwCategory = LauBlattWeisskopfFactor::Category::Default); //! Retrieve the integer index for the specified resonance /*! \param [in] name the name of the resonant particle \return the index */ Int_t resTypeInt(const TString& name) const; //! Retrieve the number of defined resonances /*! \return the number of defined resonances */ UInt_t getNResDefMax() const {return nResDefMax_;} //! Print the information records, one per line, to the requested stream /*! \param [in,out] stream the stream to which to print the info */ void printAll( std::ostream& stream ) const; //! Get the information for the given resonance name /*! \param [in] resName the name of the resonant particle \return the LauResonanceInfo pointer if we can find the resonance name */ LauResonanceInfo* getResInfo(const TString& resName) const; //! Retrieve parent Blatt-Weisskopf factor (for use by K-matrix pole/SVP which doesn't have a `resInfo') LauBlattWeisskopfFactor* getParentBWFactor(Int_t newSpin, LauBlattWeisskopfFactor::BarrierType barrierType); + //! Find BW category for a given BW factor + LauBlattWeisskopfFactor::Category getBWCategory(const LauBlattWeisskopfFactor* bwFactor) const; + + //! Find the default radius for a given BW category + Double_t getDefaultBWRadius(const LauBlattWeisskopfFactor::Category category) const; + + //! Create a JSON object containing the current settings + nlohmann::json writeSettingsToJson() const; + protected: //! Create the list of known resonances void createResonanceVector(); //! Retrieve Blatt-Weisskopf factor for the given category LauBlattWeisskopfFactor* getBWFactor(const LauBlattWeisskopfFactor::Category bwCategory, const LauResonanceInfo* resInfo); private: /*! \struct BlattWeisskopfCategoryInfo \brief Data structure to store information on a given Blatt-Weisskopf category */ struct BlattWeisskopfCategoryInfo { //! The BW factor object LauBlattWeisskopfFactor* bwFactor_; //! The default value for the radius in this category Double_t defaultRadius_; //! Whether or not the radius value for this category should be fixed in the fit Bool_t radiusFixed_; }; //! Define a type to hold information on each BW category typedef std::map BWFactorCategoryMap; //! Constructor LauResonanceMaker(); //! Copy constructor (deleted) LauResonanceMaker( const LauResonanceMaker& other ) = delete; //! Move constructor (deleted) LauResonanceMaker( LauResonanceMaker&& other ) = delete; //! Copy assignment (deleted) LauResonanceMaker& operator=( const LauResonanceMaker& other ) = delete; //! Move assignment (deleted) LauResonanceMaker& operator=( LauResonanceMaker&& other ) = delete; //! The singleton instance static LauResonanceMaker* resonanceMaker_; //! The number of known resonances UInt_t nResDefMax_{0}; //! The known resonances std::vector> resInfo_; //! The type of the Blatt-Weisskopf barrier to use for all resonances LauBlattWeisskopfFactor::BarrierType bwBarrierType_{LauBlattWeisskopfFactor::BarrierType::BWPrimeBarrier}; //! The rest frame in which the bachelor momentum used in the Blatt-Weisskopf factors should be calculated LauBlattWeisskopfFactor::RestFrame bwRestFrame_{LauBlattWeisskopfFactor::RestFrame::ResonanceFrame}; //! The spin formalism that should be used for all resonances LauAbsResonance::SpinType spinFormalism_{LauAbsResonance::SpinType::Zemach_P}; //! The Blatt-Weisskopf factor objects (and related information) for each category BWFactorCategoryMap bwFactors_; //! The Blatt-Weisskopf factor objects for resonances in the independent category std::vector bwIndepFactors_; //! Boolean flag to control printing a summary of the formalism to be used when the first resonance is created Bool_t summaryPrinted_{kFALSE}; ClassDef(LauResonanceMaker,0) // Kinematic routines }; #endif diff --git a/inc/LauRhoOmegaMix.hh b/inc/LauRhoOmegaMix.hh index ec40a19..0d9b8b9 100644 --- a/inc/LauRhoOmegaMix.hh +++ b/inc/LauRhoOmegaMix.hh @@ -1,285 +1,288 @@ /* Copyright 2016 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauRhoOmegaMix.hh \brief File containing declaration of LauRhoOmegaMix class. */ /*! \class LauRhoOmegaMix \brief Class for defining the rho-omega resonance mixing model Formulae from Paul Rensing thesis, SLAC Report 421 and Bill Dunwoodie's note http://www.slac.stanford.edu/~wmd/omega-rho_mixing/omega-rho_mixing.note */ #ifndef LAU_RHO_OMEGA_MIX #define LAU_RHO_OMEGA_MIX #include "TString.h" #include "LauAbsResonance.hh" #include "LauComplex.hh" #include class LauResonanceInfo; class LauDaughters; class LauParameter; class LauRhoOmegaMix : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resType the model of the resonance \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauRhoOmegaMix(LauResonanceInfo* resInfo, const LauAbsResonance::ResonanceModel resType, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauRhoOmegaMix(); //! Initialise the model virtual void initialise(); //! Initialise the rho resonance void initialiseRho(); //! Initialise the omega resonance void initialiseOmega(); //! Get the complex dynamical amplitude /*! \param [in] kinematics the kinematic variables of the current event \return the complex amplitude */ virtual LauComplex amplitude(const LauKinematics* kinematics); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return model_;} //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); //! Set which rho/omega amplitude to calculate for FF void setWhichAmpSq(Int_t which) { whichAmpSq_ = which; } protected: //! Set the omega pole mass parameter /*! \param [in] mOmega new value for the omega mass parameter */ void setmOmegaValue(const Double_t mOmega); //! Get the omega pole mass parameter value /*! \return value of the omega pole mass parameter */ Double_t getmOmegaValue() const { return (mOmega_!=0) ? mOmega_->unblindValue() : 0.0; } //! Fix the omega pole mass parameter value /*! \return kTRUE if the omega pole mass parameter is fixed, kFALSE otherwise */ Bool_t fixmOmegaValue() const { return (mOmega_!=0) ? mOmega_->fixed() : 0.0; } //! Set the omega pole width parameter /*! \param [in] wOmega new value for the omega width parameter */ void setwOmegaValue(const Double_t wOmega); //! Get the omega pole width parameter value /*! \return value of the omega pole width parameter */ Double_t getwOmegaValue() const { return (wOmega_!=0) ? wOmega_->unblindValue() : 0.0; } //! Fix the omega pole width parameter value /*! \return kTRUE if the omega pole width parameter is fixed, kFALSE otherwise */ Bool_t fixwOmegaValue() const { return (wOmega_!=0) ? wOmega_->fixed() : 0.0; } //! Set the omega B magnitude mixing parameter /*! \param [in] magB new value for the omega B magnitude mixing parameter */ void setmagBValue(const Double_t magB); //! Get the omega B magnitude mixing parameter /*! \return value of the omega B magnitude mixing parameter */ Double_t getmagBValue() const { return (magB_!=0) ? magB_->unblindValue() : 0.0; } //! Fix the omega B magnitude mixing parameter value /*! \return kTRUE if the omega B magnitude mixing parameter is fixed, kFALSE otherwise */ Bool_t fixmagBValue() const { return (magB_!=0) ? magB_->fixed() : 0.0; } //! Set the omega B phase mixing parameter /*! \param [in] phiB new value for the omega B phase mixing parameter */ void setphiBValue(const Double_t phiB); //! Get the omega B phase mixing parameter /*! \return value of the omega B phase mixing parameter */ Double_t getphiBValue() const { return (phiB_!=0) ? phiB_->unblindValue() : 0.0; } //! Fix the omega B phase mixing parameter value /*! \return kTRUE if the omega B phase mixing parameter is fixed, kFALSE otherwise */ Bool_t fixphiBValue() const { return (phiB_!=0) ? phiB_->fixed() : 0.0; } //! Set the omega mixing parameter delta /*! \param [in] delta new value for the omega mixing parameter delta */ void setdeltaValue(const Double_t delta); //! Get the omega mixing parameter delta /*! \return value of the omega mixing parameter delta */ Double_t getdeltaValue() const { return (delta_!=0) ? delta_->unblindValue() : 0.0; } //! Fix the omega mixing parameter delta value /*! \return kTRUE if the omega mixing parameter delta is fixed, kFALSE otherwise */ Bool_t fixdeltaValue() const { return (delta_!=0) ? delta_->fixed() : 0.0; } //! This is not called, amplitude is used directly instead virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); //! Check that both daughters are the same type of particle void checkDaughterTypes() const; + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { mOmega_, wOmega_, magB_, phiB_, delta_ }; } + private: //! Copy constructor (not implemented) LauRhoOmegaMix(const LauRhoOmegaMix& rhs); //! Copy assignment operator (not implemented) LauRhoOmegaMix& operator=(const LauRhoOmegaMix& rhs); //! The model to use LauAbsResonance::ResonanceModel model_; //! Previous value of the pole mass of the rho resonance Double_t rhoMass_; //! Previous value of the barrier radius of the rho resonance Double_t rhoResRadius_; //! Previous value of the parents barrier radius of the rho resonance Double_t rhoParRadius_; //! Pole mass of the omega contribution LauParameter* mOmega_; //! Initial default value of the omega pole mass from LauResonanceMaker Double_t mOmega0_; //! Current value of the omega pole mass (floating or fixed) Double_t mOmegaCur_; //! Pole width of the omega contribution LauParameter* wOmega_; //! Initial default value of the omega pole width from LauResonanceMaker Double_t wOmega0_; //! Current value of the omega pole mass (floating or fixed) Double_t wOmegaCur_; //! B magnitude parameter of the omega mixing contribution LauParameter* magB_; //! B phase parameter of the omega mixing contribution LauParameter* phiB_; //! delta parameter of the omega mixing contribution LauParameter* delta_; //! Boolean to specify if we want to use the denominator factor Bool_t useDenom_; //! Boolean to specify if we have performed the first initialisation Bool_t doneFirstInit_; //! Pointer to the rho (or first) resonance lineshape LauAbsResonance* rhoRes_; //! Pointer to the omega (second) resonance lineshape LauAbsResonance* omegaRes_; //! Which amplitude to calculate for rho/omega fit fractions Int_t whichAmpSq_; ClassDef(LauRhoOmegaMix,0) // Rho-omega mixing model }; #endif diff --git a/inc/LauSigmaRes.hh b/inc/LauSigmaRes.hh index c9f0124..a5eea70 100644 --- a/inc/LauSigmaRes.hh +++ b/inc/LauSigmaRes.hh @@ -1,202 +1,205 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauSigmaRes.hh \brief File containing declaration of LauSigmaRes class. */ /*! \class LauSigmaRes \brief Class for defining the Sigma resonance model Class for defining the Sigma resonance model. Formulae and data values from Phys.Lett.B 572, 1 (2003) - author D.V.Bugg */ #ifndef LAU_SIGMA_RES #define LAU_SIGMA_RES #include "TString.h" #include "LauAbsResonance.hh" #include "LauComplex.hh" class LauSigmaRes : public LauAbsResonance { public: //! Constructor /*! \param [in] resInfo the object containing information on the resonance name, mass, width, spin, charge, etc. \param [in] resPairAmpInt the number of the daughter not produced by the resonance \param [in] daughters the daughter particles */ LauSigmaRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters); //! Destructor virtual ~LauSigmaRes(); //! Initialise the model virtual void initialise(); //! Get the resonance model type /*! \return the resonance model type */ virtual LauAbsResonance::ResonanceModel getResonanceModel() const {return ResonanceModel::Sigma;} //! Set value of the various parameters /*! \param [in] name the name of the parameter to be changed \param [in] value the new parameter value */ virtual void setResonanceParameter(const TString& name, const Double_t value); //! Allow the various parameters to float in the fit /*! \param [in] name the name of the parameter to be floated */ virtual void floatResonanceParameter(const TString& name); //! Access the given resonance parameter /*! \param [in] name the name of the parameter \return the corresponding parameter */ virtual LauParameter* getResonanceParameter(const TString& name); //! Retrieve the resonance parameters, e.g. so that they can be loaded into a fit /*! \return floating parameters of the resonance */ virtual const std::vector& getFloatingParameters(); protected: //! Set the b1 parameter /*! \param [in] b1 new value for b1 parameter */ void setB1Value(const Double_t b1); //! Set the b2 parameter /*! \param [in] b2 new value for b2 parameter */ void setB2Value(const Double_t b2); //! Set the A parameter /*! \param [in] A new value for A parameter */ void setAValue(const Double_t A); //! Set the m0 parameter /*! \param [in] m0 new value for m0 parameter */ void setM0Value(const Double_t m0); //! Get the b1 parameter value /*! \return value of the b1 parameter */ Double_t getB1Value() const { return (b1_!=0) ? b1_->unblindValue() : 0.0; } //! Get the b2 parameter value /*! \return value of the b2 parameter */ Double_t getB2Value() const { return (b2_!=0) ? b2_->unblindValue() : 0.0; } //! Get the A parameter value /*! \return value of the A parameter */ Double_t getAValue() const { return (a_!=0) ? a_->unblindValue() : 0.0; } //! Get the m0 parameter value /*! \return value of the m0 parameter */ Double_t getM0Value() const { return (m0_!=0) ? m0_->unblindValue() : 0.0; } //! Fix the b1 parameter value /*! \return kTRUE if the b1 parameter is fixed, kFALSE otherwise */ Bool_t fixB1Value() const { return (b1_!=0) ? b1_->fixed() : 0.0; } //! Fix the b2 parameter value /*! \return kTRUE if the b2 parameter is fixed, kFALSE otherwise */ Bool_t fixB2Value() const { return (b2_!=0) ? b2_->fixed() : 0.0; } //! Fix the A parameter value /*! \return kTRUE if the A parameter is fixed, kFALSE otherwise */ Bool_t fixAValue() const { return (a_!=0) ? a_->fixed() : 0.0; } //! Fix the m0 parameter value /*! \return kTRUE if the m0 parameter is fixed, kFALSE otherwise */ Bool_t fixM0Value() const { return (m0_!=0) ? m0_->fixed() : 0.0; } //! Complex resonant ampltiude /*! \param [in] mass appropriate invariant mass for the resonance \param [in] spinTerm spin term */ virtual LauComplex resAmp(Double_t mass, Double_t spinTerm); //! Check that both daughters are the same type of particle void checkDaughterTypes() const; + //! Retrieve all resonance parameters (excluding mass and width), so that they can be saved to JSON + virtual std::vector getResonanceParameters() const { return { b1_, b2_, a_, m0_ }; } + private: //! Copy constructor (not implemented) LauSigmaRes(const LauSigmaRes& rhs); //! Copy assignment operator (not implemented) LauSigmaRes& operator=(const LauSigmaRes& rhs); //! Defined as 4*mPi*mPi Double_t mPiSq4_; //! Defined as 0.5*mPi*mPi Double_t sAdler_; //! Factor from BES data LauParameter* b1_; //! Factor from BES data LauParameter* b2_; //! Factor from BES data LauParameter* a_; //! Factor from BES data LauParameter* m0_; ClassDef(LauSigmaRes,0) // Sigma resonance model }; #endif diff --git a/inc/Laura++_LinkDef.h b/inc/Laura++_LinkDef.h index bd91d56..59613cc 100644 --- a/inc/Laura++_LinkDef.h +++ b/inc/Laura++_LinkDef.h @@ -1,188 +1,189 @@ /* Copyright 2013 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ #ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class Lau1DCubicSpline+; #pragma link C++ class Lau1DHistPdf+; #pragma link C++ class Lau2DAbsDP+; #pragma link C++ class Lau2DAbsDPPdf+; #pragma link C++ class Lau2DAbsHistDP+; #pragma link C++ class Lau2DAbsHistDPPdf+; #pragma link C++ class Lau2DCubicSpline+; #pragma link C++ class Lau2DHistDP+; #pragma link C++ class Lau2DHistDPPdf+; #pragma link C++ class Lau2DHistPdf+; #pragma link C++ class Lau2DSplineDP+; #pragma link C++ class Lau2DSplineDPPdf+; #pragma link C++ class LauAbsBkgndDPModel+; #pragma link C++ class LauAbsCoeffSet+; #pragma link C++ class LauAbsEffModel+; #pragma link C++ class LauAbsFitter+; #pragma link C++ class LauAbsFitModel+; #pragma link C++ class LauAbsIncohRes+; +#pragma link C++ class LauAbsKMatrixProdComp+; #pragma link C++ class LauAbsModIndPartWave+; #pragma link C++ class LauAbsPdf+; #pragma link C++ class LauAbsResonance+; #pragma link C++ class LauAbsRValue+; #pragma link C++ class LauArgusPdf+; #pragma link C++ class LauAsymmCalc+; #pragma link C++ class LauBelleCPCoeffSet+; #pragma link C++ class LauBelleNR+; #pragma link C++ class LauBelleSymNR+; #pragma link C++ class LauBifurcatedGaussPdf+; #pragma link C++ class LauBkgndDPModel+; #pragma link C++ class LauBlattWeisskopfFactor+; #pragma link C++ class LauBlind+; #pragma link C++ class LauBreitWignerRes+; #pragma link C++ class LauBsCPFitModel+; #pragma link C++ class LauBuggRes+; #pragma link C++ class LauCacheData+; #pragma link C++ class LauCalcChiSq+; #pragma link C++ class LauCartesianCPCoeffSet+; #pragma link C++ class LauCartesianGammaCPCoeffSet+; #pragma link C++ class LauCategoryFlavTag+; #pragma link C++ class LauChebychevPdf+; #pragma link C++ class LauCleoCPCoeffSet+; #pragma link C++ class LauComplex+; #pragma link C++ class LauCPFitModel+; #pragma link C++ class LauCruijffPdf+; #pragma link C++ class LauCrystalBallPdf+; #pragma link C++ class LauDabbaRes+; #pragma link C++ class LauDatabasePDG+; #pragma link C++ class LauDaughters+; #pragma link C++ class LauDecayTimePdf+; #pragma link C++ class LauDPDepBifurGaussPdf+; #pragma link C++ class LauDPDepCruijffPdf+; #pragma link C++ class LauDPDepGaussPdf+; #pragma link C++ class LauDPDepMapPdf+; #pragma link C++ class LauDPDepSumPdf+; #pragma link C++ class LauEffModel+; #pragma link C++ class LauEFKLLMRes+; #pragma link C++ class LauEmbeddedData+; #pragma link C++ class LauExponentialPdf+; #pragma link C++ class LauFitDataTree+; #pragma link C++ class LauFitNtuple+; #pragma link C++ class LauFitter+; #pragma link C++ class LauFitObject+; #pragma link C++ class LauFlatteRes+; #pragma link C++ class LauFlatNR+; #pragma link C++ class LauFlavTag+; #pragma link C++ class LauFormulaPar+; #pragma link C++ class LauGaussIncohRes+; #pragma link C++ class LauGaussPdf+; #pragma link C++ class LauGenNtuple+; #pragma link C++ class LauGounarisSakuraiRes+; #pragma link C++ class LauIntegrals+; #pragma link C++ class LauDPPartialIntegralInfo+; #pragma link C++ class LauIsobarDynamics+; #pragma link C++ class LauKappaRes+; #pragma link C++ class LauKinematics+; #pragma link C++ class LauKMatrixProdPole+; #pragma link C++ class LauKMatrixProdSVP+; #pragma link C++ class LauKMatrixPropagator+; #pragma link C++ class LauKMatrixPropFactory+; #pragma link C++ class LauLASSBWRes+; #pragma link C++ class LauLASSNRRes+; #pragma link C++ class LauLASSRes+; #pragma link C++ class LauLinearPdf+; #pragma link C++ class LauLHCbNR+; #pragma link C++ class LauMagPhaseCoeffSet+; #pragma link C++ class LauMagPhaseCPCoeffSet+; #pragma link C++ class LauMergeDataFiles+; #pragma link C++ class LauMinuit+; #pragma link C++ class LauModIndPartWaveMagPhase+; #pragma link C++ class LauModIndPartWaveRealImag+; #pragma link C++ class LauNovosibirskPdf+; #pragma link C++ class LauNRAmplitude+; #pragma link C++ class LauNSCCartesianCPCoeffSet+; #pragma link C++ class LauParameter+; #pragma link C++ class LauParametricStepFuncPdf+; #pragma link C++ class LauParamFixed+; #pragma link C++ class LauParticlePDG+; #pragma link C++ class LauPolNR+; #pragma link C++ class LauPoleRes+; #pragma link C++ class LauPolarFormFactorNR+; #pragma link C++ class LauPolarFormFactorSymNR+; #pragma link C++ class LauPolarGammaCPCoeffSet+; #pragma link C++ class LauPrint+; #pragma link C++ class LauRealImagCoeffSet+; #pragma link C++ class LauRealImagCPCoeffSet+; #pragma link C++ class LauRealImagGammaCPCoeffSet+; #pragma link C++ class LauRelBreitWignerRes+; #pragma link C++ class LauResonanceInfo+; #pragma link C++ class LauRescatteringRes+; #pragma link C++ class LauRescattering2Res+; #pragma link C++ class LauResonanceMaker+; #pragma link C++ class LauResultsExtractor+; #pragma link C++ class LauRhoOmegaMix+; #ifdef DOLAUROOFITTASK #pragma link C++ class LauRooFitTask+; #endif #pragma link C++ class LauScfMap+; #pragma link C++ class LauSigmaRes+; #pragma link C++ class LauSigmoidPdf+; #pragma link C++ class LauSimpleFitModel+; #pragma link C++ class LauSimFitCoordinator+; #pragma link C++ class LauSimFitTask+; #pragma link C++ class LauSPlot+; #pragma link C++ class LauString+; #pragma link C++ class LauSumPdf+; #pragma link C++ class LauTextFileParser+; #pragma link C++ class LauTimeDepFlavModel+; #pragma link C++ class LauTimeDepFitModel+; #pragma link C++ class LauTimeDepNonFlavModel+; #pragma link C++ class LauVetoes+; #pragma link C++ class LauWeightedSumEffModel+; #pragma link C++ class LauAbsDecayTimeCalculator+; #pragma link C++ class LauAbsDecayTimeEfficiency+; #pragma link C++ class LauAbsDecayTimeIntegrator+; #pragma link C++ class LauBinnedDecayTimeEfficiency+; #pragma link C++ class LauDecayTimePhysicsModel+; #pragma link C++ class LauDecayTimeResolution+; #pragma link C++ class LauNonSmearedDecayTimeCalculator+; #pragma link C++ class LauNonSmearedBinnedEfficiencyDecayTimeIntegrator+; #pragma link C++ class LauNonSmearedSplineEfficiencyDecayTimeIntegrator+; #pragma link C++ class LauNonSmearedSplineEfficiencyDecayTimeIntegrator+; #pragma link C++ class LauNonSmearedUniformEfficiencyDecayTimeIntegrator+; #pragma link C++ class LauSmearedDecayTimeCalculator+; #pragma link C++ class LauSmearedBinnedEfficiencyDecayTimeIntegrator+; #pragma link C++ class LauSmearedSplineEfficiencyDecayTimeIntegrator+; #pragma link C++ class LauSmearedSplineEfficiencyDecayTimeIntegrator+; #pragma link C++ class LauSmearedUniformEfficiencyDecayTimeIntegrator+; #pragma link C++ class LauSplineDecayTimeEfficiency+; #pragma link C++ class LauSplineDecayTimeEfficiency+; #pragma link C++ class LauUniformDecayTimeEfficiency+; #pragma link C++ namespace LauConstants+; #pragma link C++ namespace LauDecayTime+; #pragma link C++ namespace LauJsonTools+; #pragma link C++ namespace LauRandom+; #endif diff --git a/src/Lau1DCubicSpline.cc b/src/Lau1DCubicSpline.cc index f525163..0183b6d 100644 --- a/src/Lau1DCubicSpline.cc +++ b/src/Lau1DCubicSpline.cc @@ -1,743 +1,721 @@ /* Copyright 2015 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file Lau1DCubicSpline.cc \brief File containing implementation of Lau1DCubicSpline class. */ #include #include #include #include #include #include #include #include #include "Lau1DCubicSpline.hh" #include "LauAbsRValue.hh" #include "LauJsonTools.hh" #include "LauParameter.hh" ClassImp(Lau1DCubicSpline) Lau1DCubicSpline::Lau1DCubicSpline(const std::vector& xs, const std::vector& ys, const SplineType type, const BoundaryType leftBound, const BoundaryType rightBound, const Double_t dydx0, const Double_t dydxn) : nKnots_{xs.size()}, x_{xs}, y_{ys}, type_{type}, leftBound_{leftBound}, rightBound_{rightBound}, dydx0_{dydx0}, dydxn_{dydxn} { init(); } std::unique_ptr Lau1DCubicSpline::readFromJson(const TString& fileName, const TString& splineName) { // NB deliberately not using uniform initialisation here because of this issue: // https://json.nlohmann.me/home/faq/#brace-initialization-yields-arrays const nlohmann::json j = LauJsonTools::readJsonFile( fileName.Data(), splineName.Data(), LauJsonTools::JsonType::Object ); if ( j.is_null() ) { if ( splineName != "" ) { std::cerr << "ERROR in Lau1DCubicSpline::readFromJson : unable to retrieve JSON object from element \"" << splineName << "\" in file \"" << fileName << "\"" << std::endl; } else { std::cerr << "ERROR in Lau1DCubicSpline::readFromJson : unable to retrieve JSON object from root element of file \"" << fileName << "\"" << std::endl; } return {}; } // NB can't use std::make_unique here because the default constructor is private std::unique_ptr spline{ new Lau1DCubicSpline }; j.get_to(*spline); spline->init(); return spline; } -void Lau1DCubicSpline::writeToJson(const TString& fileName, const TString& splineName, const bool append) const +void Lau1DCubicSpline::writeToJson(const TString& fileName, const TString& splineName, const bool append, const int indent) const { - // if appending we must have a name, so check that first - if ( append && splineName == "" ) { - std::cerr << "ERROR in Lau1DCubicSpline::writeToJson : when appending to a file it is mandatory to give a name to the spline" << std::endl; - return; - } - - nlohmann::json j; - - // if we're appending, we need to first load in the exising JSON from the file - if ( append ) { - j = LauJsonTools::readJsonFile( fileName.Data(), "", LauJsonTools::JsonType::Object ); - if ( j.is_null() ) { - std::cerr << "ERROR in Lau1DCubicSpline::writeToJson : couldn't open file \"" << fileName << "\" for initial reading" << std::endl; - return; - } - } - - if ( splineName == "" ) { - j = *this; - } else { - j[ splineName.Data() ] = *this; - } + const nlohmann::json j = *this; - // now we can overwrite the file - const bool writeOK { LauJsonTools::writeJsonFile( fileName.Data(), j ) }; + const bool writeOK { LauJsonTools::writeJsonFile( j, fileName.Data(), splineName.Data(), append, indent ) }; if ( ! writeOK ) { - std::cerr << "ERROR in Lau1DCubicSpline::writeToJson : couldn't successfully write to file \"" << fileName << std::endl; + std::cerr << "ERROR in Lau1DCubicSpline::writeToJson : could not successfully write to file \"" << fileName << std::endl; } } Double_t Lau1DCubicSpline::evaluate(const Double_t x) const { // do not attempt to extrapolate the spline if( xx_[nKnots_-1] ) { std::cerr << "WARNING in Lau1DCubicSpline::evaluate : function is only defined between " << x_[0] << " and " << x_[nKnots_-1] << std::endl; std::cerr << " value at " << x << " returned as 0" << std::endl; return 0.; } // first determine which 'cell' of the spline x is in // cell i runs from knot i to knot i+1 std::size_t cell{0}; while( x > x_[cell+1] ) { ++cell; } // obtain x- and y-values of the neighbouring knots const Double_t xLow { x_[cell] }; const Double_t xHigh { x_[cell+1] }; const Double_t yLow { y_[cell] }; const Double_t yHigh { y_[cell+1] }; if(type_ == SplineType::LinearInterpolation) { return yHigh*(x-xLow)/(xHigh-xLow) + yLow*(xHigh-x)/(xHigh-xLow); } // obtain t, the normalised x-coordinate within the cell, // and the coefficients a and b, which are defined in cell i as: // // a_i = k_i *(x_i+1 - x_i) - (y_i+1 - y_i), // b_i = -k_i+1*(x_i+1 - x_i) + (y_i+1 - y_i) // // where k_i is (by construction) the first derivative at knot i const Double_t t { (x - xLow) / (xHigh - xLow) }; const Double_t a { dydx_[cell] * (xHigh - xLow) - (yHigh - yLow) }; const Double_t b { -1.*dydx_[cell+1] * (xHigh - xLow) + (yHigh - yLow) }; const Double_t retVal { (1 - t) * yLow + t * yHigh + t * (1 - t) * ( a * (1 - t) + b * t ) }; return retVal; } void Lau1DCubicSpline::updateYValues(const std::vector& ys) { y_ = ys; this->calcDerivatives(); } void Lau1DCubicSpline::updateYValues(const std::vector& ys) { for (std::size_t i{0}; iunblindValue(); } this->calcDerivatives(); } void Lau1DCubicSpline::updateYValues(const std::vector& ys) { for (std::size_t i{0}; iunblindValue(); } this->calcDerivatives(); } void Lau1DCubicSpline::updateType(const SplineType type) { if(type_ != type) { type_ = type; this->calcDerivatives(); } } void Lau1DCubicSpline::updateBoundaryConditions(const BoundaryType leftBound, const BoundaryType rightBound, const Double_t dydx0, const Double_t dydxn) { bool updateDerivatives{false}; if(leftBound_ != leftBound || rightBound_ != rightBound) { leftBound_ = leftBound; rightBound_ = rightBound; updateDerivatives = true; } if(dydx0_ != dydx0) { dydx0_ = dydx0; if(leftBound_ == BoundaryType::Clamped) updateDerivatives = true; } if(dydxn_ != dydxn) { dydxn_ = dydxn; if(rightBound_ == BoundaryType::Clamped) updateDerivatives = true; } if(updateDerivatives) { this->calcDerivatives(); } } std::array Lau1DCubicSpline::getCoefficients(const std::size_t segIndex, const bool normalise) const { std::array result = {0.,0.,0.,0.}; if(segIndex >= nKnots_-1) { std::cerr << "ERROR in Lau1DCubicSpline::getCoefficients requested for too high a knot value" << std::endl; return result; } Double_t xL = x_[segIndex] , xH = x_[segIndex+1]; Double_t yL = y_[segIndex] , yH = y_[segIndex+1]; Double_t h = xH-xL; //This number comes up a lot switch(type_) { case SplineType::StandardSpline: case SplineType::AkimaSpline: { Double_t kL = dydx_[segIndex], kH = dydx_[segIndex+1]; //a and b based on definitions from https://en.wikipedia.org/wiki/Spline_interpolation#Algorithm_to_find_the_interpolating_cubic_spline Double_t a = kL*h-(yH-yL); Double_t b =-kH*h+(yH-yL); Double_t denom = -h*h*h;//The terms have a common demoninator result[0] = -b*xL*xL*xH + a*xL*xH*xH + h*h*(xL*yH - xH*yL); result[1] = -a*xH*(2*xL+xH) + b*xL*(xL+2*xH) + h*h*(yL-yH); result[2] = -b*(2*xL+xH) + a*(xL+2*xH); result[3] = -a+b; for(auto& res : result){res /= denom;} break; } /* case SplineType::AkimaSpline: // Double check the Akima description of splines (in evaluate) right now they're the same except for the first derivatives { //using fomulae from https://asmquantmacro.com/2015/09/01/akima-spline-interpolation-in-excel/ std::function m = [&](Int_t j) //formula to get the straight line gradient { if(j < 0){return 2*m(j+1)-m(j+2);} if(j >= nKnots_){return 2*m(j-1)-m(j-2);} return (y_[j+1]-y_[j]) / (x_[j+1]-x_[j]); }; auto t = [&](Int_t j) { Double_t res = 0.; //originally res was called 't' but that produced a shadow warning Double_t denom = TMath::Abs(m(j+1)-m(j)) + TMath::Abs(m(j-1)-m(j-2)); if(denom == 0){res = (m(j)-m(j-1))/2;} //Special case for when denom = 0 else { res = TMath::Abs(m(j+1)-m(j))*m(j-1) + TMath::Abs(m(j-1)-m(j-2))*m(j); res /= denom; } return res; }; //These are the p's to get the spline in the form p_k(x-xL)^k Double_t pDenom = x_[segIndex+1]/x_[segIndex]; //a denominator used for p[2] and p[3] std::array p = {y_[segIndex],t(segIndex),0.,0.}; //we'll do the last 2 below p[2] = 3*m(segIndex)-2*t(segIndex)-t(segIndex+1); p[2]/= pDenom; p[3] = t(segIndex)+t(segIndex+1)-2*m(segIndex); p[3]/= pDenom*pDenom; //Now finally rearranging the p's into the desired results result[0] = p[0]-p[1]*xL+p[2]*xL*xL-p[3]*xL*xL*xL; result[1] = p[1]-2*p[2]*xL+3*p[3]*xL*xL; result[2] = p[2]-3*p[3]*xL; result[3] = p[3]; break; }*/ case SplineType::LinearInterpolation: { result[0] = xH*yL-xL*yH; result[1] = yH-yL; for(auto& res : result){res /= h;} break; } } if (normalise) { const Double_t integral { this->integral() }; for(auto& res : result){res /= integral;} } return result; } Double_t Lau1DCubicSpline::integral() const { Double_t integral{0.0}; for(std::size_t iKnot{0}; iKnot < nKnots_ -1; ++iKnot) { const Double_t minAbs { x_[iKnot] }; const Double_t maxAbs { x_[iKnot+1] }; const std::array coeffs { this->getCoefficients(iKnot, false) }; auto integralFunc = [&coeffs](Double_t x){return coeffs[0]*x + coeffs[1]*x*x/2.0 + coeffs[2]*x*x*x/3.0 + coeffs[3]*x*x*x*x/4.0;}; integral += integralFunc(maxAbs); integral -= integralFunc(minAbs); } return integral; } TF1* Lau1DCubicSpline::makeTF1(const bool normalise) const { auto fitf = [this](Double_t* x, Double_t* par) {//there is only 1 x (the abscissa) and 1 par (a scaling of the entire thing for normalisation) return this->evaluate( x[0] ) * par[0]; }; //Make the function TF1* func = new TF1("FittedFunc",fitf,x_.front(),x_.back(),1); func -> SetParNames("Normalisation"); if(normalise) { func->SetParameter(0, 1./func->Integral(x_.front(),x_.back())); } else{func->SetParameter(0,1.);} return func; } TF1* Lau1DCubicSpline::normaliseToTH1(TH1* hist, const LauOutputLevel printLevel) const { //first define the fit function auto fitf = [this](Double_t* x, Double_t* par) {//there is only 1 x (the abscissa) and 1 par (a scaling of the entire thing) return this->evaluate( x[0] ) * par[0]; }; //Make the function TF1* FittedFunc = new TF1("FittedFunc",fitf,x_.front(),x_.back(),1); //Set the parameter name FittedFunc -> SetParNames("Constant"); //Set the parameter limits and default value FittedFunc -> SetParLimits(0,0.,10.); FittedFunc -> SetParameter(0,1.); // Options to: // - N = do not store the graphics function // - 0 = do not plot the fit result TString fitOptions {"N 0"}; switch ( printLevel ) { case LauOutputLevel::Verbose : fitOptions += " V"; break; case LauOutputLevel::Quiet : fitOptions += " Q"; break; case LauOutputLevel::Standard : break; } hist->Fit( "FittedFunc", fitOptions ); return FittedFunc; } TFitResultPtr Lau1DCubicSpline::fitToTH1(TH1* hist, const LauOutputLevel printLevel, const bool doWL, std::map fixedParams) { auto fitf = [this](Double_t* x, Double_t* par) { this -> updateYValues( std::vector(par, par + nKnots_) ); return this -> evaluate( x[0] ); }; TF1 FittedFunc("FittedFunc",fitf,x_.front(),x_.back(),nKnots_); const Double_t knotMax { hist->GetMaximum() * 1.5 }; for(std::size_t knot{0}; knot <= nKnots_ ; ++knot) { FittedFunc.SetParName(knot, Form("Knot%lu",knot)); FittedFunc.SetParLimits(knot, 0., knotMax); FittedFunc.SetParameter(knot, y_[knot]); } for(auto& [knot, val] : fixedParams) { FittedFunc.FixParameter(knot, val); } // Options to: // - N = do not store the graphics function // - 0 = do not plot the fit result // - S = save the result of the fit // - WL= do a weighted likelihood fit (not chi2) TString fitOptions {"N 0 S"}; if(doWL){fitOptions += " WL";} switch ( printLevel ) { case LauOutputLevel::Verbose : fitOptions += " V"; break; case LauOutputLevel::Quiet : fitOptions += " Q"; break; case LauOutputLevel::Standard : break; } return hist->Fit( "FittedFunc", fitOptions ); } void Lau1DCubicSpline::init() { if( y_.size() != x_.size()) { std::cerr << "ERROR in Lau1DCubicSpline::init : The number of y-values given does not match the number of x-values" << std::endl; std::cerr << " Found " << y_.size() << ", expected " << x_.size() << std::endl; gSystem->Exit(EXIT_FAILURE); } if( nKnots_ < 3 ) { std::cerr << "ERROR in Lau1DCubicSpline::init : The number of knots is too small" << std::endl; std::cerr << " Found " << nKnots_ << ", expected at least 3 (to have at least 1 internal knot)" << std::endl; gSystem->Exit(EXIT_FAILURE); } dydx_.assign(nKnots_,0.0); a_.assign(nKnots_,0.0); b_.assign(nKnots_,0.0); c_.assign(nKnots_,0.0); d_.assign(nKnots_,0.0); this->calcDerivatives(); } void Lau1DCubicSpline::calcDerivatives() { switch ( type_ ) { case SplineType::StandardSpline : this->calcDerivativesStandard(); break; case SplineType::AkimaSpline : this->calcDerivativesAkima(); break; case SplineType::LinearInterpolation : //derivatives not needed for linear interpolation break; } } void Lau1DCubicSpline::calcDerivativesStandard() { // derivatives are determined such that the second derivative is continuous at internal knots // derivatives, k_i, are the solutions to a set of linear equations of the form: // a_i * k_i-1 + b_i * k+i + c_i * k_i+1 = d_i with a_0 = 0, c_n-1 = 0 // this is solved using the tridiagonal matrix algorithm as on en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm // first and last equations give boundary conditions // - for natural boundary, require f''(x) = 0 at end knot // - for 'not a knot' boundary, require f'''(x) continuous at second knot // - for clamped boundary, require predefined value of f'(x) at end knot // non-zero values of a_0 and c_n-1 would give cyclic boundary conditions a_[0] = 0.; c_[nKnots_-1] = 0.; // set left boundary condition switch ( leftBound_ ) { case BoundaryType::Natural : { b_[0] = 2./(x_[1]-x_[0]); c_[0] = 1./(x_[1]-x_[0]); d_[0] = 3.*(y_[1]-y_[0])/((x_[1]-x_[0])*(x_[1]-x_[0])); break; } case BoundaryType::NotAKnot : { // define the width, h, and the 'slope', delta, of the first cell const Double_t h1{x_[1]-x_[0]}; const Double_t h2{x_[2]-x_[0]}; const Double_t delta1{(y_[1]-y_[0])/h1}; const Double_t delta2{(y_[2]-y_[1])/h2}; // these coefficients can be determined by requiring f'''_0(x_1) = f'''_1(x_1) // the requirement f''_0(x_1) = f''_1(x_1) has been used to remove the dependence on k_2 b_[0] = h2; c_[0] = h1+h2; d_[0] = delta1*(2.*h2*h2 + 3.*h1*h2)/(h1+h2) + delta2*5.*h1*h1/(h1+h2); break; } case BoundaryType::Clamped : { b_[0] = 1.; c_[0] = 0.; d_[0] = dydx0_; break; } } // set right boundary condition switch ( rightBound_ ) { case BoundaryType::Natural : { a_[nKnots_-1] = 1./(x_[nKnots_-1]-x_[nKnots_-2]); b_[nKnots_-1] = 2./(x_[nKnots_-1]-x_[nKnots_-2]); d_[nKnots_-1] = 3.*(y_[nKnots_-1]-y_[nKnots_-2])/((x_[nKnots_-1]-x_[nKnots_-2])*(x_[nKnots_-1]-x_[nKnots_-2])); break; } case BoundaryType::NotAKnot : { // define the width, h, and the 'slope', delta, of the last cell const Double_t hnm1{x_[nKnots_-1]-x_[nKnots_-2]}; const Double_t hnm2(x_[nKnots_-2]-x_[nKnots_-3]); const Double_t deltanm1{(y_[nKnots_-1]-y_[nKnots_-2])/hnm1}; const Double_t deltanm2{(y_[nKnots_-2]-y_[nKnots_-3])/hnm2}; // these coefficients can be determined by requiring f'''_n-3(x_n-2) = f'''_n-2(x_n-2) // the requirement f''_n-3(x_n-2) = f''_n-2(x_n-2) has been used to remove // the dependence on k_n-3 a_[nKnots_-1] = hnm2 + hnm1; b_[nKnots_-1] = hnm1; d_[nKnots_-1] = deltanm2*hnm1*hnm1/(hnm2+hnm1) + deltanm1*(2.*hnm2*hnm2 + 3.*hnm2*hnm1)/(hnm2+hnm1); break; } case BoundaryType::Clamped : { a_[nKnots_-1] = 0.; b_[nKnots_-1] = 1.; d_[nKnots_-1] = dydxn_; break; } } // the remaining equations ensure that f_i-1''(x_i) = f''_i(x_i) for all internal knots for(std::size_t i{1}; i(nKnots_-2)}; i>=0; --i) { dydx_[i] = d_[i] - c_[i]*dydx_[i+1]; } } void Lau1DCubicSpline::calcDerivativesAkima() { //derivatives are calculated according to the Akima method // J.ACM vol. 17 no. 4 pp 589-602 Double_t am1{0.0}, an{0.0}, anp1{0.0}; // a[i] is the slope of the segment from point i-1 to point i // // n.b. segment 0 is before point 0 and segment n is after point n-1 // internal segments are numbered 1 - n-1 for(std::size_t i{1}; i coeffs { this->getCoefficients(iSegment, false) }; // first derivative is a parabola const Double_t a { coeffs[3]*3.0 }; const Double_t b { coeffs[2]*2.0 }; const Double_t c { coeffs[1] }; const Double_t discriminant { b*b - 4.0*a*c }; // if no real roots, skip this segment if ( discriminant < 0.0) { continue; } const Double_t x1 { (-b + TMath::Sqrt(discriminant))/(2.0*a) }; if ( x1 > x_[iSegment] and x1 < x_[iSegment+1] ) { // this root is within the segment - check the 2nd derivative const Double_t secondDeriv { 2.0 * a * x1 + b }; if ( secondDeriv < 0.0 ) { // evaluate the function and update max if appropriate const Double_t y1 { this->evaluate(x1) }; if ( y1 > max ) { max = y1; } } } const Double_t x2 { (-b - TMath::Sqrt(discriminant))/(2.0*a) }; if ( x2 > x_[iSegment] and x2 < x_[iSegment+1] ) { // this root is within the segment - check the 2nd derivative const Double_t secondDeriv { 2.0 * a * x2 + b }; if ( secondDeriv < 0.0 ) { // evaluate the function and update max if appropriate const Double_t y2 { this->evaluate(x2) }; if ( y2 > max ) { max = y2; } } } } return max; } //! \cond DOXYGEN_IGNORE std::ostream& operator<<(std::ostream& out, const Lau1DCubicSpline::SplineType type) { switch (type) { case Lau1DCubicSpline::SplineType::StandardSpline : out << "StandardSpline"; break; case Lau1DCubicSpline::SplineType::AkimaSpline : out << "AkimaSpline"; break; case Lau1DCubicSpline::SplineType::LinearInterpolation : out << "LinearInterpolation"; break; } return out; } std::ostream& operator<<(std::ostream& out, const Lau1DCubicSpline::BoundaryType type) { switch (type) { case Lau1DCubicSpline::BoundaryType::Clamped: out << "Clamped"; break; case Lau1DCubicSpline::BoundaryType::Natural : out << "Natural"; break; case Lau1DCubicSpline::BoundaryType::NotAKnot : out << "NotAKnot"; break; } return out; } //! \endcond DOXYGEN_IGNORE diff --git a/src/LauAbsCoeffSet.cc b/src/LauAbsCoeffSet.cc index 0be6cf7..75f5ed0 100644 --- a/src/LauAbsCoeffSet.cc +++ b/src/LauAbsCoeffSet.cc @@ -1,484 +1,482 @@ /* Copyright 2006 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauAbsCoeffSet.cc \brief File containing implementation of LauAbsCoeffSet class. */ #include #include #include "TString.h" #include "LauAbsCoeffSet.hh" #include "LauConstants.hh" #include "LauParameter.hh" #include "LauRandom.hh" ClassImp(LauAbsCoeffSet); TRandom* LauAbsCoeffSet::randomiser_ = nullptr; Double_t LauAbsCoeffSet::minMagnitude_ = -10.0; Double_t LauAbsCoeffSet::maxMagnitude_ = 10.0; Double_t LauAbsCoeffSet::minPhase_ = -LauConstants::threePi; Double_t LauAbsCoeffSet::maxPhase_ = LauConstants::threePi; Double_t LauAbsCoeffSet::minRealImagPart_ = -10.0; Double_t LauAbsCoeffSet::maxRealImagPart_ = 10.0; Double_t LauAbsCoeffSet::minDelta_ = -2.0; Double_t LauAbsCoeffSet::maxDelta_ = 2.0; LauAbsCoeffSet::LauAbsCoeffSet(const TString& theName, const TString& theBaseName, const LauAbsCoeffSet* parent, const CloneOption cloneOption, const Double_t constFactor) : name_{theName}, basename_{theBaseName}, parent_{parent}, cloneOption_{cloneOption}, constFactor_{constFactor} { } TRandom* LauAbsCoeffSet::getRandomiser() { if ( randomiser_ == nullptr ) { randomiser_ = LauRandom::zeroSeedRandom(); } return randomiser_; } void LauAbsCoeffSet::index(const UInt_t newIndex) { index_ = newIndex; const TString oldBaseName{ this->baseName() }; TString basename{ oldBaseName }; basename += newIndex; basename += "_"; this->baseName(basename); std::vector pars { this->getParameters() }; for ( LauParameter* par : pars ) { this->adjustName( *par, oldBaseName ); } } void LauAbsCoeffSet::adjustName(LauParameter& par, const TString& oldBaseName) { TString theName{ par.name() }; if ( theName.BeginsWith( oldBaseName ) && theName != oldBaseName ) { theName.Remove(0,oldBaseName.Length()); } theName.Prepend(this->baseName()); par.name(theName); } void LauAbsCoeffSet::setParameterValue(const TString& parName, const Double_t value, const Bool_t init) { LauParameter* par { this->findParameter( parName ) }; if ( par == nullptr ) { std::cerr << "ERROR in LauAbsCoeffSet::setParameterValue : Unable to find parameter \"" << parName << "\"" << std::endl; return; } par->value( value ); if ( init ) { par->genValue( value ); par->initValue( value ); } } void LauAbsCoeffSet::setParameterError(const TString& parName, const Double_t error) { LauParameter* par { this->findParameter( parName ) }; if ( par == nullptr ) { std::cerr << "ERROR in LauAbsCoeffSet::setParameterError : Unable to find parameter \"" << parName << "\"" << std::endl; return; } par->error( error ); } void LauAbsCoeffSet::fixParameter(const TString& parName) { LauParameter* par { this->findParameter( parName ) }; if ( par == nullptr ) { std::cerr << "ERROR in LauAbsCoeffSet::fixParameter : Unable to find parameter \"" << parName << "\"" << std::endl; return; } par->fixed( kTRUE ); } void LauAbsCoeffSet::floatParameter(const TString& parName) { LauParameter* par { this->findParameter( parName ) }; if ( par == nullptr ) { std::cerr << "ERROR in LauAbsCoeffSet::floatParameter : Unable to find parameter \"" << parName << "\"" << std::endl; return; } par->fixed( kFALSE ); } void LauAbsCoeffSet::blindParameter(const TString& parName, const TString& blindingString, const Double_t width) { LauParameter* par { this->findParameter( parName ) }; if ( par == nullptr ) { std::cerr << "ERROR in LauAbsCoeffSet::blindParameter : Unable to find parameter \"" << parName << "\"" << std::endl; return; } par->blindParameter( blindingString, width ); } void LauAbsCoeffSet::addGaussianConstraint(const TString& parName, const Double_t mean, const Double_t width) { LauParameter* par { this->findParameter( parName ) }; if ( par == nullptr ) { std::cerr << "ERROR in LauAbsCoeffSet::addGaussianConstraint : Unable to find parameter \"" << parName << "\"" << std::endl; return; } par->addGaussianConstraint( mean, width ); } void LauAbsCoeffSet::addSuffixToParameterName(const TString& parName, const TString& suffix) { LauParameter* par { this->findParameter( parName ) }; if ( par == nullptr ) { std::cerr << "ERROR in LauAbsCoeffSet::addSuffixToParameterName : Unable to find parameter \"" << parName << "\"" << std::endl; return; } TString newName{ par->name() }; if ( ! suffix.BeginsWith('_') ) { newName += "_"; } newName += suffix; par->name( newName ); } LauParameter* LauAbsCoeffSet::findParameter(const TString& parName) { std::vector pars { this->getParameters() }; for ( LauParameter* par : pars ) { const TString& iName { par->name() }; if ( iName.EndsWith( parName ) ) { return par; } } return nullptr; } void LauAbsCoeffSet::serialiseToJson( nlohmann::json& j ) const { // Check that the number of parameters and names match up const auto pars = this->getParameters(); const auto parNames = this->getParNames(); const std::size_t nPars { pars.size() }; if ( parNames.size() != nPars ) { std::cerr << "ERROR in LauAbsCoeffSet::to_json : Wrong number of parameter names supplied for coefficient set of type " << this->type() << std::endl; return; } // Serialise the type, name, and clone status j["type"] = this->type(); j["name"] = this->name(); if ( this->clone() ) { j["clone"] = true; j["parent"] = this->parent()->name(); j["cloneOption"] = this->cloneOption(); j["constFactor"] = this->constFactor(); } else { j["clone"] = false; } // Serialise all non-cloned parameters for ( std::size_t i{0}; i < nPars; ++i ) { const auto& par = pars[i]; if ( par->clone() ) { continue; } // Serialise the value, fixed/float flag, second-stage flag, blind flag // Prepare the names of each key const TString& parName { parNames[i] }; const TString parNameFixed {parName+"Fixed"}; const TString parNameSecondStage {parName+"SecondStage"}; const TString parNameBlind {parName+"Blind"}; j[parName.Data()] = par->value(); j[parNameFixed.Data()] = par->fixed(); j[parNameSecondStage.Data()] = par->secondStage(); j[parNameBlind.Data()] = par->blind(); if ( par->blind() ) { // For blinded parameters also serialise the blinding string and width const TString parNameBlindingString {parName+"BlindingString"}; const TString parNameBlindingWidth {parName+"BlindingWidth"}; j[parNameBlindingString.Data()] = par->blinder()->blindingString(); j[parNameBlindingWidth.Data()] = par->blinder()->blindingWidth(); } } } void LauAbsCoeffSet::applyBlinding( const nlohmann::json& j ) { // Reads blinding information for each parameter from the JSON record for ( const auto& parName : this->getParNames() ) { const TString parNameBlind {parName+"Blind"}; const TString parNameBlindingString {parName+"BlindingString"}; const TString parNameBlindingWidth {parName+"BlindingWidth"}; // If the Blind field is present and is true, // retrieve also the blinding string and width, // and apply the blinding to the parameter if ( j.contains(parNameBlind.Data()) && j.at(parNameBlind.Data()).get() ) { const std::string blindingString { j.at(parNameBlindingString.Data()).get() }; const Double_t blindingWidth { j.at(parNameBlindingWidth.Data()).get() }; this->blindParameter(parName, blindingString, blindingWidth); } } } #include "LauBelleCPCoeffSet.hh" #include "LauCartesianCPCoeffSet.hh" #include "LauCartesianGammaCPCoeffSet.hh" #include "LauCleoCPCoeffSet.hh" #include "LauMagPhaseCoeffSet.hh" #include "LauMagPhaseCPCoeffSet.hh" #include "LauNSCCartesianCPCoeffSet.hh" #include "LauPolarGammaCPCoeffSet.hh" #include "LauRealImagCoeffSet.hh" #include "LauRealImagCPCoeffSet.hh" #include "LauRealImagGammaCPCoeffSet.hh" #include "LauJsonTools.hh" std::vector> LauAbsCoeffSet::readFromJson( const TString& fileName, const TString& elementName ) { using nlohmann::json; using LauJsonTools::JsonType; using LauJsonTools::ElementNameType; using LauJsonTools::checkObjectElements; using LauJsonTools::getValue; using LauJsonTools::getOptionalValue; // NB deliberately not using uniform initialisation here because of this issue: // https://json.nlohmann.me/home/faq/#brace-initialization-yields-arrays const json j = LauJsonTools::readJsonFile( fileName.Data(), elementName.Data(), JsonType::Object ); if ( j.is_null() ) { if ( elementName != "" ) { std::cerr << "ERROR in LauAbsCoeffSet::readFromJson : unable to retrieve JSON object from element \"" << elementName << "\" in file \"" << fileName << "\"" << std::endl; } else { std::cerr << "ERROR in LauAbsCoeffSet::readFromJson : unable to retrieve JSON object from root element of file \"" << fileName << "\"" << std::endl; } return {}; } std::vector mandatoryElements { std::make_pair("nCoeffs", JsonType::Number_Integer), std::make_pair("coeffs", JsonType::Array) }; if ( ! checkObjectElements( j, mandatoryElements ) ) { std::cerr << "ERROR in LauAbsCoeffSet::readFromJson : aborting processing due to mis-formatted elements" << std::endl; return {}; } mandatoryElements = { std::make_pair("clone", JsonType::Boolean), std::make_pair("name", JsonType::String), std::make_pair("type", JsonType::String) }; Bool_t allOK{kTRUE}; for ( auto& coeff : j.at("coeffs") ) { allOK &= checkObjectElements( coeff, mandatoryElements ); } if ( ! allOK ) { std::cerr << "ERROR in LauAbsCoeffSet::readFromJson : aborting processing due to mis-formatted elements" << std::endl; return {}; } const auto nCoeffs { getValue( j, "nCoeffs") }; std::vector> coeffs; coeffs.reserve( nCoeffs ); std::vector clonedCoeffs; clonedCoeffs.reserve( nCoeffs ); for ( auto& coeff : j.at("coeffs") ) { // If it's a cloned coeff, we save it for later if ( getValue( coeff, "clone" ) ) { clonedCoeffs.emplace_back( coeff ); continue; } // Otherwise create and store an instance of the appropriate type, // constructed from the JSON record switch ( getValue( coeff, "type" ) ) { case LauCoeffType::MagPhase : coeffs.emplace_back( std::make_unique( coeff.get() ) ); break; case LauCoeffType::RealImag : coeffs.emplace_back( std::make_unique( coeff.get() ) ); break; case LauCoeffType::BelleCP : coeffs.emplace_back( std::make_unique( coeff.get() ) ); break; case LauCoeffType::CartesianCP : coeffs.emplace_back( std::make_unique( coeff.get() ) ); break; case LauCoeffType::CartesianGammaCP : coeffs.emplace_back( std::make_unique( coeff.get() ) ); break; case LauCoeffType::CleoCP : coeffs.emplace_back( std::make_unique( coeff.get() ) ); break; case LauCoeffType::MagPhaseCP : coeffs.emplace_back( std::make_unique( coeff.get() ) ); break; case LauCoeffType::NSCCartesianCP : coeffs.emplace_back( std::make_unique( coeff.get() ) ); break; case LauCoeffType::PolarGammaCP : coeffs.emplace_back( std::make_unique( coeff.get() ) ); break; case LauCoeffType::RealImagCP : coeffs.emplace_back( std::make_unique( coeff.get() ) ); break; case LauCoeffType::RealImagGammaCP : coeffs.emplace_back( std::make_unique( coeff.get() ) ); break; } } mandatoryElements = { std::make_pair("parent", JsonType::String), std::make_pair("cloneOption", JsonType::String), std::make_pair("constFactor", JsonType::Number) }; allOK = kTRUE; for ( auto& coeff : clonedCoeffs ) { allOK &= checkObjectElements( coeff, mandatoryElements ); } if ( ! allOK ) { std::cerr << "ERROR in LauAbsCoeffSet::readFromJson : aborting processing due to mis-formatted elements" << std::endl; return {}; } // Now construct the clones for ( auto& coeff : clonedCoeffs ) { const auto name { getValue( coeff, "name" ) }; const auto parentName { getValue( coeff, "parent" ) }; // Find the parent of this coefficient set auto parent = std::find_if( coeffs.begin(), coeffs.end(), [&parentName](const std::unique_ptr& c){ return c->name() == parentName; } ); if ( parent == coeffs.end() ) { throw LauClonedCoeff{"Cannot locate parent (" + parentName + ") for cloned coefficient set " + name}; } const auto cloneOption { getValue( coeff, "cloneOption" ) }; const auto constFactor { getValue( coeff, "constFactor" ) }; // Create a clone from the parent, passing the json // entry for this coeffset to allow any parameters that // are not cloned (depending on the CloneOption) to // have their values etc. set correctly coeffs.emplace_back( (*parent)->createClone( name, cloneOption, constFactor, coeff ) ); } return coeffs; } -void LauAbsCoeffSet::writeToJson( const TString& fileName, const std::vector>& coeffs ) +void LauAbsCoeffSet::writeToJson( const std::vector>& coeffs, const TString& fileName, const TString& elementName, const bool append, const int indent ) { using nlohmann::json; json j; j["nCoeffs"] = coeffs.size(); j["coeffs"] = json::array(); for ( auto& coeffset : coeffs ) { - j["coeffs"].push_back( *coeffset ); - } - const bool writeOK { LauJsonTools::writeJsonFile( fileName.Data(), j ) }; + const bool writeOK { LauJsonTools::writeJsonFile( j, fileName.Data(), elementName.Data(), append, indent ) }; if ( ! writeOK ) { - std::cerr << "ERROR in LauAbsCoeffSet::writeToJson : couldn't successfully write to file \"" << fileName << std::endl; + std::cerr << "ERROR in LauAbsCoeffSet::writeToJson : could not successfully write to file \"" << fileName << std::endl; } } std::ostream& operator<<( std::ostream& os, const LauCoeffType type ) { switch ( type ) { case LauCoeffType::MagPhase : os << "MagPhase"; break; case LauCoeffType::RealImag : os << "RealImag"; break; case LauCoeffType::BelleCP : os << "BelleCP"; break; case LauCoeffType::CartesianCP : os << "CartesianCP"; break; case LauCoeffType::CartesianGammaCP : os << "CartesianGammaCP"; break; case LauCoeffType::CleoCP : os << "CleoCP"; break; case LauCoeffType::MagPhaseCP : os << "MagPhaseCP"; break; case LauCoeffType::NSCCartesianCP : os << "NSCCartesianCP"; break; case LauCoeffType::PolarGammaCP : os << "PolarGammaCP"; break; case LauCoeffType::RealImagCP : os << "RealImagCP"; break; case LauCoeffType::RealImagGammaCP : os << "RealImagGammaCP"; break; } return os; } diff --git a/src/LauAbsIncohRes.cc b/src/LauAbsIncohRes.cc index 7f9123f..79d96d7 100644 --- a/src/LauAbsIncohRes.cc +++ b/src/LauAbsIncohRes.cc @@ -1,49 +1,58 @@ /* Copyright 2014 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauAbsIncohRes.cc \brief File containing implementation of LauAbsIncohRes class. */ #include "LauAbsIncohRes.hh" #include "LauDaughters.hh" #include "LauResonanceInfo.hh" ClassImp(LauAbsIncohRes) // Constructor LauAbsIncohRes::LauAbsIncohRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters) : LauAbsResonance(resInfo, resPairAmpInt, daughters) {} // Destructor LauAbsIncohRes::~LauAbsIncohRes() { } LauComplex LauAbsIncohRes::resAmp(Double_t /*mass*/, Double_t spinTerm) { return LauComplex(spinTerm, 0.0); } + +nlohmann::json LauAbsIncohRes::writeSettingsToJson() const +{ + nlohmann::json resObj = LauAbsResonance::writeSettingsToJson(); + + resObj[ "coherent" ] = false; + + return resObj; +} diff --git a/src/LauAbsModIndPartWave.cc b/src/LauAbsModIndPartWave.cc index fc9c0e4..395ff1f 100644 --- a/src/LauAbsModIndPartWave.cc +++ b/src/LauAbsModIndPartWave.cc @@ -1,233 +1,297 @@ /* Copyright 2014 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauAbsModIndPartWave.cc \brief File containing implementation of LauAbsModIndPartWave class. */ -#include -#include - +#include "LauAbsModIndPartWave.hh" #include "LauConstants.hh" #include "LauKinematics.hh" -#include "LauAbsModIndPartWave.hh" #include "LauResonanceInfo.hh" +#include + +#include +#include + ClassImp(LauAbsModIndPartWave) LauAbsModIndPartWave::LauAbsModIndPartWave(LauResonanceInfo* resInfo, Int_t resPairAmpInt, const LauDaughters* daughters, const TString& spline1Name, const TString& spline2Name) : LauAbsResonance{resInfo, resPairAmpInt, daughters}, spline1Name_{spline1Name}, spline2Name_{spline2Name} { } void LauAbsModIndPartWave::floatKnotsSecondStage(const Bool_t secondStage) { secondStage_ = secondStage; // if the parameters have not yet been created we can now just return if ( amp1Pars_.size() != nKnots_ ) { return; } // otherwise we need to toggle their second-stage parameter for ( UInt_t i(0); i < nKnots_; ++i ) { amp1Pars_[i]->secondStage(secondStage_); amp2Pars_[i]->secondStage(secondStage_); } } std::set LauAbsModIndPartWave::checkKnots(const std::set& masses) { std::set knots = masses; const std::set::const_iterator first = knots.begin(); const std::set::const_reverse_iterator last = knots.rbegin(); const Double_t lower_limit = this->getMassDaug1() + this->getMassDaug2(); const Double_t upper_limit = this->getMassParent() - this->getMassBachelor(); // check whether we have been given knots at unphysical masses if ( *first < lower_limit ) { std::cerr << "WARNING in LauAbsModIndPartWave::checkKnots : Knot found at mass " << *first << " is below the lower kinematic limit." << std::endl; std::cerr << " : Lower kinematic limit is at mass " << lower_limit << std::endl; std::cerr << " : Aborting definition of knot positions." << std::endl; knots.clear(); return knots; } if ( *last > upper_limit ) { std::cerr << "WARNING in LauAbsModIndPartWave::checkKnots : Knot found at mass " << *last << " is above the upper kinematic limit." << std::endl; std::cerr << " : Upper kinematic limit is at mass " << upper_limit << std::endl; std::cerr << " : Aborting definition of knot positions." << std::endl; knots.clear(); return knots; } // check if we have knots at each extreme - if not, add them in if ( (*first) != lower_limit ) { knots.insert( lower_limit ); } if ( (*last) != upper_limit ) { knots.insert( upper_limit ); } return knots; } void LauAbsModIndPartWave::defineKnots(const std::set& masses) { if ( ! masses_.empty() ) { std::cerr << "WARNING in LauAbsModIndPartWave::defineKnots : Knot positions have already been defined, not making any changes." << std::endl; return; } const std::set knots = this->checkKnots( masses ); nKnots_ = knots.size(); if ( nKnots_ == 0 ) { return; } masses_.reserve(nKnots_); amp1Vals_.reserve(nKnots_); amp2Vals_.reserve(nKnots_); amp1Pars_.reserve(nKnots_); amp2Pars_.reserve(nKnots_); UInt_t counter(0); for ( std::set::const_iterator iter = knots.begin(); iter != knots.end(); ++iter ) { masses_.push_back( *iter ); amp1Vals_.push_back(1.0); amp2Vals_.push_back(1.0); this->createAmpParameters(counter); ++counter; } for ( std::vector::const_iterator iter = masses_.begin(); iter != masses_.end(); ++iter ) { std::cout << "INFO in LauAbsModIndPartWave::defineKnots : Knot added to resonance " << this->getResonanceName() << " at mass " << *iter << std::endl; } } void LauAbsModIndPartWave::initialise() { for ( UInt_t i(0); i < nKnots_; ++i ) { amp1Vals_[i] = amp1Pars_[i]->unblindValue(); amp2Vals_[i] = amp2Pars_[i]->unblindValue(); } spline1_ = std::make_unique(masses_, amp1Vals_, type1_, leftBound1_, rightBound1_, leftGrad1_, rightGrad1_); spline2_ = std::make_unique(masses_, amp2Vals_, type2_, leftBound2_, rightBound2_, leftGrad2_, rightGrad2_); } LauComplex LauAbsModIndPartWave::resAmp(Double_t mass, Double_t spinTerm) { amp_.zero(); Bool_t paramChanged1(kFALSE), paramChanged2(kFALSE); for ( UInt_t i(0); i < nKnots_; ++i ) { if ( !amp1Pars_[i]->fixed() && amp1Pars_[i]->unblindValue() != amp1Vals_[i] ) { paramChanged1 = kTRUE; amp1Vals_[i] = amp1Pars_[i]->unblindValue(); } if ( !amp2Pars_[i]->fixed() && amp2Pars_[i]->unblindValue() != amp2Vals_[i] ) { paramChanged2 = kTRUE; amp2Vals_[i] = amp2Pars_[i]->unblindValue(); } } if ( spline1_ == nullptr || spline2_ == nullptr) { std::cerr << "ERROR in LauAbsModIndPartWave::resAmp : One or both of the splines is null" << std::endl; return amp_; } if ( paramChanged1 ) { spline1_->updateYValues(amp1Vals_); } if ( paramChanged2 ) { spline2_->updateYValues(amp2Vals_); } this->evaluateAmplitude( mass ); amp_.rescale( spinTerm ); return amp_; } void LauAbsModIndPartWave::setSplineType(Lau1DCubicSpline::SplineType type1, Lau1DCubicSpline::SplineType type2) { type1_ = type1; type2_ = type2; std::cout << "INFO in LauAbsModIndPartWave::setSplineType : Setting types to " << type1_ << " for " << spline1Name_ << " spline and " << type2_ << " for " << spline2Name_ << " spline" << std::endl; } void LauAbsModIndPartWave::setSplineBoundaryConditions(Lau1DCubicSpline::BoundaryType leftBound1, Lau1DCubicSpline::BoundaryType rightBound1, Lau1DCubicSpline::BoundaryType leftBound2, Lau1DCubicSpline::BoundaryType rightBound2, Double_t leftGrad1, Double_t rightGrad1, Double_t leftGrad2, Double_t rightGrad2) { leftBound1_ = leftBound1; rightBound1_ = rightBound1; leftBound2_ = leftBound2; rightBound2_ = rightBound2; leftGrad1_ = leftGrad1; rightGrad1_ = rightGrad1; leftGrad2_ = leftGrad2; rightGrad2_ = rightGrad2; std::cout << "INFO in LauAbsModIndPartWave::setSplineBoundaryConditions : Setting boundary types for " << spline1Name_ << " spline to left: " << leftBound1_ << " and right: " << rightBound1_ << std::endl; if ( leftBound1_ == Lau1DCubicSpline::BoundaryType::Clamped || rightBound1_ == Lau1DCubicSpline::BoundaryType::Clamped ) { std::cout << "INFO in LauAbsModIndPartWave::setSplineBoundaryConditions : Setting boundary gradients for " << spline1Name_ << " spline to left: " << leftGrad1_ << " and right: " << rightGrad1_ << std::endl; } std::cout << "INFO in LauAbsModIndPartWave::setSplineBoundaryConditions : Setting boundary types for " << spline2Name_ << " spline to left: " << leftBound2_ << " and right: " << rightBound2_ << std::endl; if ( leftBound2_ == Lau1DCubicSpline::BoundaryType::Clamped || rightBound2_ == Lau1DCubicSpline::BoundaryType::Clamped ) { std::cout << "INFO in LauAbsModIndPartWave::setSplineBoundaryConditions : Setting boundary gradients for " << spline2Name_ << " spline to left: " << leftGrad2_ << " and right: " << rightGrad2_ << std::endl; } } const std::vector& LauAbsModIndPartWave::getFloatingParameters() { this->clearFloatingParameters(); for ( UInt_t i(0); i < nKnots_; ++i ) { if ( !amp1Pars_[i]->fixed() ) { this->addFloatingParameter( amp1Pars_[i] ); } if ( !amp2Pars_[i]->fixed() ) { this->addFloatingParameter( amp2Pars_[i] ); } } return this->getParameters(); } +nlohmann::json LauAbsModIndPartWave::writeSettingsToJson() const +{ + using nlohmann::json; + + json j = LauAbsResonance::writeSettingsToJson(); + + // "defineKnots", an Array, see LauAbsModIndPartWave::defineKnots + json knots = json::array(); + for ( UInt_t i{1}; i < nKnots_-1; ++i ) { + knots.push_back( masses_[i] ); + } + j[ "defineKnots" ] = knots; + + // "setKnotAmp", an Array, see LauAbsModIndPartWave::setKnotAmp + json amps = json::array(); + + const auto resType { this->getResonanceModel() }; + const std::array elementNames { + (resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase) ? "mag" : "real", + (resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase) ? "phase" : "imag", + (resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase) ? "fixMag" : "fixReal", + (resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase) ? "fixPhase" : "fixImag" + }; + + for ( UInt_t i{0}; i < nKnots_; ++i ) { + json obj = json::object(); + + obj[ elementNames[0] ] = amp1Vals_[i]; + obj[ elementNames[1] ] = amp2Vals_[i]; + obj[ elementNames[2] ] = amp1Pars_[i]->fixed(); + obj[ elementNames[3] ] = amp2Pars_[i]->fixed(); + + amps.push_back( obj ); + } + j[ "setKnotAmp" ] = amps; + + // "setSplineType", a two-element Array, see LauAbsModIndPartWave::setSplineType + json splineType = json::array(); + splineType.push_back( type1_ ); + splineType.push_back( type2_ ); + j[ "setSplineType" ] = splineType; + + // "setSplineBoundaryConditions", a four- or eight-element Array, see LauAbsModIndPartWave::setSplineBoundaryConditions + json splineBoundaries = json::array(); + splineBoundaries.push_back( leftBound1_ ); + splineBoundaries.push_back( rightBound1_ ); + splineBoundaries.push_back( leftBound2_ ); + splineBoundaries.push_back( rightBound2_ ); + constexpr auto clamped {Lau1DCubicSpline::BoundaryType::Clamped}; + if ( leftBound1_ == clamped || rightBound1_ == clamped || leftBound2_ == clamped || rightBound2_ == clamped ) { + splineBoundaries.push_back( leftGrad1_ ); + splineBoundaries.push_back( rightGrad1_ ); + splineBoundaries.push_back( leftGrad2_ ); + splineBoundaries.push_back( rightGrad2_ ); + } + j[ "setSplineBoundaryConditions" ] = splineBoundaries; + + // "floatKnotsSecondStage", a Boolean, see LauAbsModIndPartWave::floatKnotsSecondStage + j[ "floatKnotsSecondStage" ] = this->floatKnotsSecondStage(); + + return j; +} diff --git a/src/LauAbsResonance.cc b/src/LauAbsResonance.cc index 20dcca8..80dc148 100644 --- a/src/LauAbsResonance.cc +++ b/src/LauAbsResonance.cc @@ -1,689 +1,778 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauAbsResonance.cc \brief File containing implementation of LauAbsResonance class. */ #include #include "TSystem.h" #include "LauAbsResonance.hh" #include "LauConstants.hh" #include "LauDaughters.hh" #include "LauKinematics.hh" #include "LauParameter.hh" #include "LauResonanceInfo.hh" +#include "LauResonanceMaker.hh" ClassImp(LauAbsResonance) bool LauAbsResonance::isIncoherentModel(ResonanceModel model) { switch(model) { case ResonanceModel::BW: case ResonanceModel::RelBW: case ResonanceModel::GS: case ResonanceModel::Flatte: case ResonanceModel::Sigma: case ResonanceModel::Bugg: case ResonanceModel::Kappa: case ResonanceModel::Dabba: case ResonanceModel::LASS: case ResonanceModel::LASS_BW: case ResonanceModel::LASS_NR: case ResonanceModel::EFKLLM: - case ResonanceModel::KMatrix: + case ResonanceModel::KMatrix_Pole: + case ResonanceModel::KMatrix_SVP: case ResonanceModel::FlatNR: case ResonanceModel::NRModel: case ResonanceModel::BelleNR: case ResonanceModel::PowerLawNR: case ResonanceModel::BelleSymNR: case ResonanceModel::BelleSymNRNoInter: case ResonanceModel::LHCbNR: case ResonanceModel::TaylorNR: case ResonanceModel::PolNR: case ResonanceModel::Pole: case ResonanceModel::PolarFFNR: case ResonanceModel::PolarFFSymNR: case ResonanceModel::PolarFFSymNRNoInter: case ResonanceModel::Rescattering: case ResonanceModel::Rescattering2: case ResonanceModel::RescatteringNoInter: case ResonanceModel::MIPW_MagPhase: case ResonanceModel::MIPW_RealImag: case ResonanceModel::RhoOmegaMix_GS: case ResonanceModel::RhoOmegaMix_RBW: case ResonanceModel::RhoOmegaMix_GS_1: case ResonanceModel::RhoOmegaMix_RBW_1: break; case ResonanceModel::GaussIncoh: return true; } return false; } // Constructor LauAbsResonance::LauAbsResonance(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters) : resInfo_(resInfo), daughters_(daughters), resName_( (resInfo!=nullptr) ? resInfo->getName() : "" ), sanitisedName_( (resInfo!=nullptr) ? resInfo->getSanitisedName() : "" ), resMass_( (resInfo!=nullptr) ? resInfo->getMass() : nullptr ), resWidth_( (resInfo!=nullptr) ? resInfo->getWidth() : nullptr ), resSpin_( (resInfo!=nullptr) ? resInfo->getSpin() : 0 ), resCharge_( (resInfo!=nullptr) ? resInfo->getCharge() : 0 ), resPairAmpInt_(resPairAmpInt) { if ( resInfo == nullptr ) { std::cerr << "ERROR in LauAbsResonance constructor : null LauResonanceInfo object provided" << std::endl; gSystem->Exit(EXIT_FAILURE); } if ( daughters_ == nullptr ) { std::cerr << "ERROR in LauAbsResonance constructor : null LauDaughters object provided" << std::endl; gSystem->Exit(EXIT_FAILURE); } nameParent_ = this->getNameParent(); nameDaug1_ = this->getNameDaug1(); nameDaug2_ = this->getNameDaug2(); nameBachelor_ = this->getNameBachelor(); massParent_ = this->getMassParent(); massDaug1_ = this->getMassDaug1(); massDaug2_ = this->getMassDaug2(); massBachelor_ = this->getMassBachelor(); chargeParent_ = this->getChargeParent(); chargeDaug1_ = this->getChargeDaug1(); chargeDaug2_ = this->getChargeDaug2(); chargeBachelor_ = this->getChargeBachelor(); // check that the total charge adds up to that of the resonance Int_t totalCharge = chargeDaug1_ + chargeDaug2_; if ( (totalCharge != resCharge_) && (resPairAmpInt_ != 0) ) { std::cerr << "ERROR in LauAbsResonance : Total charge of daughters = " << totalCharge << ". Resonance charge = " << resCharge_ << "." << std::endl; gSystem->Exit(EXIT_FAILURE); } } // Constructor LauAbsResonance::LauAbsResonance(const TString& resName, const Int_t resPairAmpInt, const LauDaughters* daughters, const Int_t resSpin) : daughters_(daughters), resName_(resName), sanitisedName_(resName), resSpin_(resSpin), resPairAmpInt_(resPairAmpInt) { if ( daughters_ == nullptr ) { std::cerr << "ERROR in LauAbsResonance constructor : null LauDaughters object provided" << std::endl; gSystem->Exit(EXIT_FAILURE); } nameParent_ = this->getNameParent(); nameDaug1_ = this->getNameDaug1(); nameDaug2_ = this->getNameDaug2(); nameBachelor_ = this->getNameBachelor(); massParent_ = this->getMassParent(); massDaug1_ = this->getMassDaug1(); massDaug2_ = this->getMassDaug2(); massBachelor_ = this->getMassBachelor(); chargeParent_ = this->getChargeParent(); chargeDaug1_ = this->getChargeDaug1(); chargeDaug2_ = this->getChargeDaug2(); chargeBachelor_ = this->getChargeBachelor(); // Since we haven't been provided with a LauResonanceInfo object we can just // set the change of the resonance to be the sum of the daughter charges resCharge_ = chargeDaug1_ + chargeDaug2_; } // Destructor LauAbsResonance::~LauAbsResonance() { } LauComplex LauAbsResonance::amplitude(const LauKinematics* kinematics) { // Use LauKinematics interface for amplitude // For resonance made from tracks i, j, we need the momenta // of tracks i and k in the i-j rest frame for spin helicity calculations // in the Zemach tensor formalism. // Also need the momentum of track k in the parent rest-frame for // calculation of the Blatt-Weisskopf factors. mass_ = 0.0; cosHel_ = 0.0; q_ = 0.0; p_ = 0.0; pstar_ = 0.0; erm_ = 1.0; covFactor_ = 1.0; if (resPairAmpInt_ == 1) { mass_ = kinematics->getm23(); cosHel_ = kinematics->getc23(); q_ = kinematics->getp2_23(); p_ = kinematics->getp1_23(); pstar_ = kinematics->getp1_Parent(); erm_ = kinematics->getcov23(); } else if (resPairAmpInt_ == 2) { mass_ = kinematics->getm13(); cosHel_ = kinematics->getc13(); q_ = kinematics->getp1_13(); p_ = kinematics->getp2_13(); pstar_ = kinematics->getp2_Parent(); erm_ = kinematics->getcov13(); } else if (resPairAmpInt_ == 3) { mass_ = kinematics->getm12(); cosHel_ = kinematics->getc12(); q_ = kinematics->getp1_12(); p_ = kinematics->getp3_12(); pstar_ = kinematics->getp3_Parent(); erm_ = kinematics->getcov12(); } else { std::cerr << "ERROR in LauAbsResonance::amplitude : Nonsense setup of resPairAmp array." << std::endl; gSystem->Exit(EXIT_FAILURE); } if (this->flipHelicity()) { cosHel_ *= -1.0; } if (this->ignoreMomenta()) { q_ = 1.0; p_ = 1.0; pstar_ = 1.0; erm_ = 1.0; } // Calculate the spin factors Double_t spinTerm(1.0); Double_t pProd(1.0); if (!this->ignoreSpin()) { switch ( this->getSpinType() ) { case SpinType::Zemach_P: pProd = q_*p_; spinTerm = this->calcZemachSpinFactor( pProd ); break; case SpinType::Zemach_Pstar: pProd = q_*pstar_; spinTerm = this->calcZemachSpinFactor( pProd ); break; case SpinType::Covariant: pProd = q_*pstar_; spinTerm = this->calcCovSpinFactor( pProd ); break; case SpinType::Covariant_P: pProd = q_*p_; spinTerm = this->calcCovSpinFactor( pProd ); break; case SpinType::Legendre: spinTerm = this->calcLegendrePoly(); break; } } // Calculate the full amplitude LauComplex resAmplitude = this->resAmp(mass_, spinTerm); return resAmplitude; } void LauAbsResonance::calcCovFactor( const Double_t erm ) { if (resSpin_ == 0) { covFactor_ = 1.0; } else if (resSpin_ == 1) { covFactor_ = erm; } else if (resSpin_ == 2) { covFactor_ = erm*erm + 0.5; } else if (resSpin_ == 3) { covFactor_ = erm*(erm*erm + 1.5); } else if (resSpin_ == 4) { covFactor_ = (8.*erm*erm*erm*erm + 24.*erm*erm + 3.)/35.; } else if (resSpin_ > 4) { std::cerr << "WARNING in LauAbsResonance::calcCovFactor : covariant spin factor cannot (yet) be fully calculated for spin >= 5" << std::endl; std::cerr << " : the function of sqrt(1 + (p/mParent)^2) part will be missing" << std::endl; covFactor_ = 1.0; } } Double_t LauAbsResonance::calcCovSpinFactor( const Double_t pProd ) { if (resSpin_ == 0) { covFactor_ = 1.0; return 1.0; } // Covariant spin factor is (p* q)^L * f_L(erm) * P_L(cosHel) Double_t spinFactor(pProd); for ( Int_t i(1); i < resSpin_; ++i ) { spinFactor *= pProd; } this->calcCovFactor( erm_ ); spinFactor *= covFactor_; spinFactor *= this->calcLegendrePoly(); return spinFactor; } Double_t LauAbsResonance::calcZemachSpinFactor( const Double_t pProd ) const { // Calculate the spin factors // // These are calculated as follows // // -2^j * (q*p)^j * cj * Pj(cosHel) // // where Pj(coshHel) is the jth order Legendre polynomial and // // cj = j! / (2j-1)!! if (resSpin_ == 0) { return 1.0; } Double_t spinFactor(pProd); for ( Int_t i(1); i < resSpin_; ++i ) { spinFactor *= pProd; } spinFactor *= this->calcLegendrePoly(); return spinFactor; } Double_t LauAbsResonance::calcLegendrePoly( const Double_t cosHel ) { cosHel_ = cosHel; return this->calcLegendrePoly(); } Double_t LauAbsResonance::calcLegendrePoly() const { Double_t legPol = 1.0; if (resSpin_ == 1) { // Calculate vector resonance Legendre polynomial legPol = -2.0*cosHel_; } else if (resSpin_ == 2) { // Calculate tensor resonance Legendre polynomial legPol = 4.0*(3.0*cosHel_*cosHel_ - 1.0)/3.0; } else if (resSpin_ == 3) { // Calculate spin 3 resonance Legendre polynomial legPol = -8.0*(5.0*cosHel_*cosHel_*cosHel_ - 3.0*cosHel_)/5.0; } else if (resSpin_ == 4) { // Calculate spin 4 resonance Legendre polynomial legPol = 16.0*(35.0*cosHel_*cosHel_*cosHel_*cosHel_ - 30.0*cosHel_*cosHel_ + 3.0)/35.0; } else if (resSpin_ == 5) { // Calculate spin 5 resonance Legendre polynomial legPol = -32.0*(63.0*cosHel_*cosHel_*cosHel_*cosHel_*cosHel_ - 70.0*cosHel_*cosHel_*cosHel_ + 15.0*cosHel_)/63.0; } else if (resSpin_ > 5) { std::cerr << "WARNING in LauAbsResonance::calcLegendrePoly : Legendre polynomials not (yet) implemented for spin > 5" << std::endl; } return legPol; } void LauAbsResonance::changeResonance(const Double_t newMass, const Double_t newWidth, const Int_t newSpin) { if (newMass > 0.0) { resMass_->valueAndRange(newMass,0.0,3.0*newMass); resMass_->initValue(newMass); resMass_->genValue(newMass); std::cout << "INFO in LauAbsResonance::changeResonance : Setting mass to " << resMass_->value() << std::endl; } if (newWidth > 0.0) { resWidth_->valueAndRange(newWidth,0.0,3.0*newWidth); resWidth_->initValue(newWidth); resWidth_->genValue(newWidth); std::cout << "INFO in LauAbsResonance::changeResonance : Setting width to " << resWidth_->value() << std::endl; } if (newSpin > -1) { resSpin_ = newSpin; std::cout << "INFO in LauAbsResonance::changeResonance : Setting spin to " << resSpin_ << std::endl; } } void LauAbsResonance::changeBWBarrierRadii(const Double_t resRadius, const Double_t parRadius) { if ( resRadius >= 0.0 && resBWFactor_ != nullptr ) { LauParameter* resBWRadius = resBWFactor_->getRadiusParameter(); resBWRadius->value(resRadius); resBWRadius->initValue(resRadius); resBWRadius->genValue(resRadius); std::cout << "INFO in LauAbsResonance::changeBWBarrierRadii : Setting resonance factor radius to " << resBWRadius->value() << std::endl; } if ( parRadius >= 0.0 && parBWFactor_ != nullptr ) { LauParameter* parBWRadius = parBWFactor_->getRadiusParameter(); parBWRadius->value(parRadius); parBWRadius->initValue(parRadius); parBWRadius->genValue(parRadius); std::cout << "INFO in LauAbsResonance::changeBWBarrierRadii : Setting parent factor radius to " << parBWRadius->value() << std::endl; } } void LauAbsResonance::setResonanceParameter(const TString& name, const Double_t value) { //This function should always be overwritten if needed in classes inheriting from LauAbsResonance. std::cerr << "WARNING in LauAbsResonance::setResonanceParameter : Unable to set parameter \"" << name << "\" to value: " << value << "." << std::endl; } void LauAbsResonance::floatResonanceParameter(const TString& name) { //This function should always be overwritten if needed in classes inheriting from LauAbsResonance. std::cerr << "WARNING in LauAbsResonance::floatResonanceParameter : Unable to release parameter \"" << name << "\"." << std::endl; } LauParameter* LauAbsResonance::getResonanceParameter(const TString& name) { //This function should always be overwritten if needed in classes inheriting from LauAbsResonance. std::cerr << "WARNING in LauAbsResonance::getResonanceParameter : Unable to get parameter \"" << name << "\"." << std::endl; return 0; } void LauAbsResonance::addFloatingParameter( LauParameter* param ) { if ( param == nullptr ) { return; } if ( param->clone() ) { resParameters_.push_back( param->parent() ); } else { resParameters_.push_back( param ); } } void LauAbsResonance::fixBarrierRadii(const Bool_t fixResRad, const Bool_t fixParRad) { if ( resBWFactor_ == nullptr ) { std::cerr << "WARNING in LauAbsResonance::fixBarrierRadii : resonance barrier factor not present, cannot fix/float it" << std::endl; return; } if ( parBWFactor_ == nullptr ) { std::cerr << "WARNING in LauAbsResonance::fixBarrierRadii : parent barrier factor not present, cannot fix/float it" << std::endl; return; } LauParameter* resBWRadius = resBWFactor_->getRadiusParameter(); resBWRadius->fixed(fixResRad); LauParameter* parBWRadius = parBWFactor_->getRadiusParameter(); parBWRadius->fixed(fixParRad); } Bool_t LauAbsResonance::fixResRadius() const { if ( resBWFactor_ == nullptr ) { std::cerr << "WARNING in LauAbsResonance::fixResRadius : resonance barrier factor not present" << std::endl; return kTRUE; } LauParameter* bwRadius = resBWFactor_->getRadiusParameter(); return bwRadius->fixed(); } Bool_t LauAbsResonance::fixParRadius() const { if ( parBWFactor_ == nullptr ) { std::cerr << "WARNING in LauAbsResonance::fixParRadius : parent barrier factor not present" << std::endl; return kTRUE; } LauParameter* bwRadius = parBWFactor_->getRadiusParameter(); return bwRadius->fixed(); } Double_t LauAbsResonance::getResRadius() const { if ( resBWFactor_ == nullptr ) { std::cerr << "WARNING in LauAbsResonance::getResRadius : resonance barrier factor not present" << std::endl; return -1.0; } LauParameter* bwRadius = resBWFactor_->getRadiusParameter(); return bwRadius->unblindValue(); } Double_t LauAbsResonance::getParRadius() const { if ( parBWFactor_ == nullptr ) { std::cerr << "WARNING in LauAbsResonance::getParRadius : parent barrier factor not present" << std::endl; return -1.0; } LauParameter* bwRadius = parBWFactor_->getRadiusParameter(); return bwRadius->unblindValue(); } Double_t LauAbsResonance::getMassParent() const { // Get the parent mass Double_t mass(LauConstants::mB); if (daughters_) { mass = daughters_->getMassParent(); } return mass; } Double_t LauAbsResonance::getMassDaug1() const { // Get the daughter mass Double_t mass(LauConstants::mPi); if (daughters_) { if (resPairAmpInt_ == 1) { mass = daughters_->getMassDaug2(); } else if (resPairAmpInt_ == 2) { mass = daughters_->getMassDaug1(); } else if (resPairAmpInt_ == 3) { mass = daughters_->getMassDaug1(); } } return mass; } Double_t LauAbsResonance::getMassDaug2() const { // Get the daughter mass Double_t mass(LauConstants::mPi); if (daughters_) { if (resPairAmpInt_ == 1) { mass = daughters_->getMassDaug3(); } else if (resPairAmpInt_ == 2) { mass = daughters_->getMassDaug3(); } else if (resPairAmpInt_ == 3) { mass = daughters_->getMassDaug2(); } } return mass; } Double_t LauAbsResonance::getMassBachelor() const { // Get the bachelor mass Double_t mass(LauConstants::mPi); if (daughters_) { if (resPairAmpInt_ == 1) { mass = daughters_->getMassDaug1(); } else if (resPairAmpInt_ == 2) { mass = daughters_->getMassDaug2(); } else if (resPairAmpInt_ == 3) { mass = daughters_->getMassDaug3(); } } return mass; } Int_t LauAbsResonance::getChargeParent() const { // Get the parent charge Int_t charge(0); if (daughters_) { charge = daughters_->getChargeParent(); } return charge; } Int_t LauAbsResonance::getChargeDaug1() const { // Get the daughter charge Int_t charge(0); if (daughters_) { if (resPairAmpInt_ == 1) { charge = daughters_->getChargeDaug2(); } else if (resPairAmpInt_ == 2) { charge = daughters_->getChargeDaug1(); } else if (resPairAmpInt_ == 3) { charge = daughters_->getChargeDaug1(); } } return charge; } Int_t LauAbsResonance::getChargeDaug2() const { // Get the daughter charge Int_t charge(0); if (daughters_) { if (resPairAmpInt_ == 1) { charge = daughters_->getChargeDaug3(); } else if (resPairAmpInt_ == 2) { charge = daughters_->getChargeDaug3(); } else if (resPairAmpInt_ == 3) { charge = daughters_->getChargeDaug2(); } } return charge; } Int_t LauAbsResonance::getChargeBachelor() const { // Get the bachelor charge Int_t charge(0); if (daughters_) { if (resPairAmpInt_ == 1) { charge = daughters_->getChargeDaug1(); } else if (resPairAmpInt_ == 2) { charge = daughters_->getChargeDaug2(); } else if (resPairAmpInt_ == 3) { charge = daughters_->getChargeDaug3(); } } return charge; } TString LauAbsResonance::getNameParent() const { // Get the parent name TString name(""); if (daughters_) { name = daughters_->getNameParent(); } return name; } TString LauAbsResonance::getNameDaug1() const { // Get the daughter name TString name(""); if (daughters_) { if (resPairAmpInt_ == 1) { name = daughters_->getNameDaug2(); } else if (resPairAmpInt_ == 2) { name = daughters_->getNameDaug1(); } else if (resPairAmpInt_ == 3) { name = daughters_->getNameDaug1(); } } return name; } TString LauAbsResonance::getNameDaug2() const { // Get the daughter name TString name(""); if (daughters_) { if (resPairAmpInt_ == 1) { name = daughters_->getNameDaug3(); } else if (resPairAmpInt_ == 2) { name = daughters_->getNameDaug3(); } else if (resPairAmpInt_ == 3) { name = daughters_->getNameDaug2(); } } return name; } TString LauAbsResonance::getNameBachelor() const { // Get the bachelor name TString name(""); if (daughters_) { if (resPairAmpInt_ == 1) { name = daughters_->getNameDaug1(); } else if (resPairAmpInt_ == 2) { name = daughters_->getNameDaug2(); } else if (resPairAmpInt_ == 3) { name = daughters_->getNameDaug3(); } } return name; } +nlohmann::json LauAbsResonance::writeSettingsToJson() const +{ + using nlohmann::json; + + const LauResonanceMaker& resMaker = LauResonanceMaker::get(); + + json resObj = json::object(); + + resObj[ "resName" ] = this->getResonanceName(); + resObj[ "resPairAmpInt" ] = this->getPairInt(); + resObj[ "resType" ] = this->getResonanceModel(); + + json changeResonance = json::object(); + changeResonance[ "mass" ] = json::object( { {"value", this->getMass()}, {"fix", this->fixMass()} } ); + changeResonance[ "width" ] = json::object( { {"value", this->getWidth()}, {"fix", this->fixWidth()} } ); + changeResonance[ "spin" ] = json::object( { {"value", this->getSpin()} } ); + resObj[ "changeResonance" ] = changeResonance; + + json changeBWBarrierRadii = json::object(); + + const LauBlattWeisskopfFactor* resBWFactor { this->getResBWFactor() }; + if ( resBWFactor ) { + const LauResonanceInfo* resInfo { this->getResInfo() }; + const auto defaultBWCategory { resInfo->getBWCategory() }; + const auto bwCategory { resMaker.getBWCategory( resBWFactor ) }; + if ( bwCategory == LauBlattWeisskopfFactor::Category::Default ) { + std::cerr << "WARNING in LauAbsResonance::writeSettingsToJson : strange barrier factor for resonance: " << this->getResonanceName() << std::endl; + } + if ( bwCategory != defaultBWCategory ) { + resObj[ "bwCategory" ] = bwCategory; + } + if ( bwCategory == LauBlattWeisskopfFactor::Category::Indep || + this->getResRadius() != resMaker.getDefaultBWRadius( bwCategory ) || + ! this->fixResRadius() ) { + changeBWBarrierRadii[ "resRadius" ] = json::object( { {"value", this->getResRadius()}, {"fix", this->fixResRadius()} } ); + } + } + const LauBlattWeisskopfFactor* parBWFactor { this->getParBWFactor() }; + if ( parBWFactor ) { + if ( this->getParRadius() != resMaker.getDefaultBWRadius( LauBlattWeisskopfFactor::Category::Parent ) || + ! this->fixParRadius() ) { + changeBWBarrierRadii[ "parRadius" ] = json::object( { {"value", this->getParRadius()}, {"fix", this->fixParRadius()} } ); + } + } + + if ( ! changeBWBarrierRadii.empty() ) { + resObj[ "changeBWBarrierRadii" ] = changeBWBarrierRadii; + } + + if ( this->ignoreMomenta() ) { + resObj[ "ignoreMomenta" ] = true; + } + + if ( this->ignoreSpin() ) { + resObj[ "ignoreSpin" ] = true; + } + + if ( this->ignoreBarrierScaling() ) { + resObj[ "ignoreBarrierScaling" ] = true; + } + + const auto spinType { this->getSpinType() }; + const auto commonSpinType { resMaker.getSpinFormalism() }; + if ( spinType != commonSpinType ) { + resObj[ "setSpinType" ] = spinType; + } + + json parameters = json::array(); + const TString parNameBase { this->getSanitisedName() + "_" }; + for ( const LauParameter* par : this->getResonanceParameters() ) { + TString parName { par->name() }; + parName.ReplaceAll( parNameBase, "" ); + + json parObj = json::object( { + {"name", parName}, + {"value", par->value()}, + {"float", ! par->fixed()} + } ); + parameters.push_back( parObj ); + } + + if ( ! parameters.empty() ) { + resObj[ "parameters" ] = parameters; + } + + return resObj; +} diff --git a/src/LauBelleNR.cc b/src/LauBelleNR.cc index 2baf1c3..994744c 100644 --- a/src/LauBelleNR.cc +++ b/src/LauBelleNR.cc @@ -1,150 +1,158 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauBelleNR.cc \brief File containing implementation of LauBelleNR class. */ #include #include "TMath.h" #include "LauBelleNR.hh" #include "LauDaughters.hh" #include "LauParameter.hh" #include "LauResonanceInfo.hh" ClassImp(LauBelleNR) LauBelleNR::LauBelleNR(LauResonanceInfo* resInfo, const ResonanceModel resType, const Int_t resPairAmpInt, const LauDaughters* daughters) : LauAbsResonance(resInfo, resPairAmpInt, daughters), alpha_(0), model_(resType), forceLegendre_(kTRUE) { TString parName = this->getSanitisedName(); parName += "_alpha"; alpha_ = resInfo->getExtraParameter( parName ); if ( alpha_ == 0 ) { alpha_ = new LauParameter( parName, 0.0, -2.0, 10.0, kTRUE ); alpha_->secondStage(kTRUE); resInfo->addExtraParameter( alpha_ ); } } LauBelleNR::~LauBelleNR() { } void LauBelleNR::initialise() { const LauDaughters* daughters = this->getDaughters(); Int_t resPairAmpInt = this->getPairInt(); if ( daughters->gotSymmetricalDP() && resPairAmpInt != 3 ) { std::cerr << "WARNING in LauBelleNR::initialise : Dalitz plot is symmetric - this lineshape is not appropriate." << std::endl; } if ( model_ != ResonanceModel::BelleNR && model_ != ResonanceModel::PowerLawNR ) { std::cerr << "WARNING in LauBelleNR::initialise : Unknown model requested, defaulting to exponential." << std::endl; model_ = ResonanceModel::BelleNR; } // Make the spin term purely the Legendre polynomial of the cos(helicity angle) if ( forceLegendre_ ) { this->setSpinType( SpinType::Legendre ); } } LauComplex LauBelleNR::resAmp(Double_t mass, Double_t spinTerm) { Double_t magnitude(1.0); Double_t alpha = this->getAlpha(); if ( model_ == ResonanceModel::BelleNR ) { magnitude = spinTerm * TMath::Exp(-alpha*mass*mass); } else if ( model_ == ResonanceModel::PowerLawNR ) { magnitude = spinTerm * TMath::Power(mass*mass, -alpha); } LauComplex resAmplitude(magnitude, 0.0); return resAmplitude; } const std::vector& LauBelleNR::getFloatingParameters() { this->clearFloatingParameters(); if ( ! this->fixAlpha() ) { this->addFloatingParameter( alpha_ ); } return this->getParameters(); } void LauBelleNR::setResonanceParameter(const TString& name, const Double_t value) { // Set various parameters for the lineshape if (name == "alpha") { this->setAlpha(value); std::cout << "INFO in LauBelleNR::setResonanceParameter : Setting parameter alpha = " << this->getAlpha() << std::endl; } else { std::cerr << "WARNING in LauBelleNR::setResonanceParameter: Parameter name not reconised. No parameter changes made." << std::endl; } } void LauBelleNR::floatResonanceParameter(const TString& name) { if (name == "alpha") { if ( alpha_->fixed() ) { alpha_->fixed( kFALSE ); this->addFloatingParameter( alpha_ ); } else { std::cerr << "WARNING in LauBelleNR::floatResonanceParameter: Parameter already floating. No parameter changes made." << std::endl; } } else { std::cerr << "WARNING in LauBelleNR::fixResonanceParameter: Parameter name not reconised. No parameter changes made." << std::endl; } } LauParameter* LauBelleNR::getResonanceParameter(const TString& name) { if (name == "alpha") { return alpha_; } else { std::cerr << "WARNING in LauBelleNR::getResonanceParameter: Parameter name not reconised." << std::endl; return 0; } } void LauBelleNR::setAlpha(const Double_t alpha) { alpha_->value( alpha ); alpha_->genValue( alpha ); alpha_->initValue( alpha ); } +nlohmann::json LauBelleNR::writeSettingsToJson() const +{ + nlohmann::json resObj = LauAbsResonance::writeSettingsToJson(); + + resObj[ "enforceLegendreSpinFactors" ] = this->enforceLegendreSpinFactors(); + + return resObj; +} diff --git a/src/LauBlattWeisskopfFactor.cc b/src/LauBlattWeisskopfFactor.cc index 7af0456..fd9e2d1 100644 --- a/src/LauBlattWeisskopfFactor.cc +++ b/src/LauBlattWeisskopfFactor.cc @@ -1,202 +1,244 @@ /* Copyright 2014 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauBlattWeisskopfFactor.cc \brief File containing implementation of LauBlattWeisskopfFactor class. */ -#include - -#include "TMath.h" - #include "LauBlattWeisskopfFactor.hh" #include "LauParameter.hh" #include "LauResonanceInfo.hh" +#include "TMath.h" + +#include +#include + ClassImp(LauBlattWeisskopfFactor) // Constructor LauBlattWeisskopfFactor::LauBlattWeisskopfFactor( const LauResonanceInfo& resInfo, const BarrierType barrierType, const RestFrame restFrame, const Category category ) : - spin_(resInfo.getSpin()), - radius_(new LauParameter("NEED_A_GOOD_NAME",resInfo.getBWRadius(),0.0,10.0,kTRUE)), - barrierType_(barrierType), - restFrame_(restFrame) + spin_{resInfo.getSpin()}, + radius_{std::make_unique("NEED_A_GOOD_NAME",resInfo.getBWRadius(),0.0,10.0,kTRUE)}, + barrierType_{barrierType}, + restFrame_{restFrame} { - TString categoryName = this->setRadiusName( resInfo, category ); - std::cout << "INFO in LauBlattWeisskopfFactor constructor : creating radius parameter for category \"" << categoryName << "\", with initial value " << resInfo.getBWRadius() << std::endl; + const TString categoryName { this->setRadiusName( resInfo, category ) }; + const Double_t radiusVal { resInfo.getBWRadius() }; + std::cout << "INFO in LauBlattWeisskopfFactor constructor : creating radius parameter for category \"" << categoryName << "\", with initial value " << radiusVal << std::endl; } LauBlattWeisskopfFactor::LauBlattWeisskopfFactor( const LauResonanceInfo& resInfo, const Double_t resRadius, const BarrierType barrierType, const RestFrame restFrame, const Category category ) : - spin_(resInfo.getSpin()), - radius_(new LauParameter("NEED_A_GOOD_NAME",resRadius,0.0,10.0,kTRUE)), - barrierType_(barrierType), - restFrame_(restFrame) + spin_{resInfo.getSpin()}, + radius_{std::make_unique("NEED_A_GOOD_NAME",resRadius,0.0,10.0,kTRUE)}, + barrierType_{barrierType}, + restFrame_{restFrame} { - TString categoryName = this->setRadiusName( resInfo, category ); + const TString categoryName { this->setRadiusName( resInfo, category ) }; std::cout << "INFO in LauBlattWeisskopfFactor constructor : creating radius parameter for category \"" << categoryName << "\", with initial value " << resRadius << std::endl; } -LauBlattWeisskopfFactor::LauBlattWeisskopfFactor( const Int_t spin, const Double_t resRadius, const BarrierType barrierType, const RestFrame restFrame, const Category category ) : - spin_(spin), - radius_(new LauParameter("NEED_A_GOOD_NAME",resRadius,0.0,10.0,kTRUE)), - barrierType_(barrierType), - restFrame_(restFrame) +LauBlattWeisskopfFactor::LauBlattWeisskopfFactor( const UInt_t spin, const Double_t resRadius, const BarrierType barrierType, const RestFrame restFrame, const Category category ) : + spin_{spin}, + radius_{std::make_unique("NEED_A_GOOD_NAME",resRadius,0.0,10.0,kTRUE)}, + barrierType_{barrierType}, + restFrame_{restFrame} { - TString categoryName = this->setRadiusName( category ); + const TString categoryName { this->setRadiusName( category ) }; std::cout << "INFO in LauBlattWeisskopfFactor constructor : creating radius parameter for category \"" << categoryName << "\", with initial value " << resRadius << std::endl; } -LauBlattWeisskopfFactor::LauBlattWeisskopfFactor( const LauBlattWeisskopfFactor& other, const UInt_t newSpin, const BarrierType newBarrierType ) : - spin_(newSpin), - radius_(other.radius_->createClone()), - barrierType_(newBarrierType), - restFrame_(other.restFrame_) +LauBlattWeisskopfFactor::LauBlattWeisskopfFactor( LauBlattWeisskopfFactor& other, const UInt_t newSpin, const BarrierType newBarrierType ) : + parent_{&other}, + spin_{newSpin}, + radius_{other.radius_->createClone()}, + barrierType_{newBarrierType}, + restFrame_{other.restFrame_} +{ +} + +LauBlattWeisskopfFactor* LauBlattWeisskopfFactor::createClone( const UInt_t newSpin, const BarrierType newBarrierType ) { + if ( parent_ ) { + return parent_->createClone( newSpin, newBarrierType ); + } + + LauBlattWeisskopfFactor* clone = new LauBlattWeisskopfFactor( *this, newSpin, newBarrierType ); + clones_.insert(clone); + return clone; +} + +LauBlattWeisskopfFactor::~LauBlattWeisskopfFactor() noexcept +{ + // if we're a clone, we just need to inform our parent of our demise + if ( this->clone() ) { + parent_->removeFromCloneList(this); + return; + } + + // if we have no clones there's nothing to do + if ( clones_.empty() ) { + return; + } + + // otherwise if we have clones we need to make one of them the new parent and inform the rest of the change + + // let's (arbitrarily) make the first entry in the set the new parent + auto iter = clones_.begin(); + LauBlattWeisskopfFactor* newParent { *iter }; + + // remove that entry in the map + clones_.erase(iter); + + // for all the other entries, we need to tell them they are clones of the new parent + for ( auto theClone : clones_ ) { + theClone->setParent(newParent); + } + + // transfer the list of clones to the new parent + newParent->clones_ = std::move(clones_); + + // finally, the new parent has to be told that it isn't a clone anymore + newParent->setParent(nullptr); } TString LauBlattWeisskopfFactor::setRadiusName( const LauResonanceInfo& resInfo, const Category category ) { switch (category) { case Category::Indep : return this->setRadiusName( resInfo.getSanitisedName() ); default : return this->setRadiusName( category ); } } TString LauBlattWeisskopfFactor::setRadiusName( const Category category ) { switch (category) { case Category::Default : return this->setRadiusName("Unknown"); case Category::Indep : // We shouldn't ever end up here return this->setRadiusName("Unknown"); case Category::Parent : return this->setRadiusName("Parent"); case Category::Light : return this->setRadiusName("Light"); case Category::Kstar : return this->setRadiusName("Kstar"); case Category::Charm : return this->setRadiusName("Charm"); case Category::StrangeCharm : return this->setRadiusName("StrangeCharm"); case Category::Charmonium : return this->setRadiusName("Charmonium"); case Category::Beauty : return this->setRadiusName("Beauty"); case Category::StrangeBeauty : return this->setRadiusName("StrangeBeauty"); case Category::CharmBeauty : return this->setRadiusName("CharmBeauty"); case Category::Custom1 : return this->setRadiusName("Custom1"); case Category::Custom2 : return this->setRadiusName("Custom2"); case Category::Custom3 : return this->setRadiusName("Custom3"); case Category::Custom4 : return this->setRadiusName("Custom4"); } // We should never get here but gcc seems to think we can return this->setRadiusName("Unknown"); } TString LauBlattWeisskopfFactor::setRadiusName( const TString& categoryName ) { TString name = "BarrierRadius_"; name.Append(categoryName); radius_->name(name); return categoryName; } -LauBlattWeisskopfFactor* LauBlattWeisskopfFactor::createClone( const UInt_t newSpin, const BarrierType newBarrierType ) -{ - LauBlattWeisskopfFactor* clone = new LauBlattWeisskopfFactor( *this, newSpin, newBarrierType ); - return clone; -} - Double_t LauBlattWeisskopfFactor::calcFormFactor( const Double_t p ) const { // Calculate the requested form factor for the resonance, given the momentum value Double_t fFactor(1.0); // For scalars the form factor is always unity // TODO: and we currently don't have formulae for spin > 5 if ( (spin_ == 0) || (spin_ > 5) ) { return fFactor; } const Double_t radius = radius_->unblindValue(); const Double_t z = radius*radius*p*p; switch ( barrierType_ ) { case BarrierType::BWBarrier : if (spin_ == 1) { fFactor = TMath::Sqrt(2.0*z/(z + 1.0)); } else if (spin_ == 2) { fFactor = TMath::Sqrt(13.0*z*z/(z*z + 3.0*z + 9.0)); } else if (spin_ == 3) { fFactor = TMath::Sqrt(277.0*z*z*z/(z*z*z + 6.0*z*z + 45.0*z + 225.0)); } else if (spin_ == 4) { fFactor = TMath::Sqrt(12746.0*z*z*z*z/(z*z*z*z + 10.0*z*z*z + 135.0*z*z + 1575.0*z + 11025.0)); } else if (spin_ == 5) { fFactor = TMath::Sqrt(998881.0*z*z*z*z*z/(z*z*z*z*z + 15.0*z*z*z*z + 315.0*z*z*z + 6300.0*z*z + 99225.0*z + 893025.0)); } break; case BarrierType::BWPrimeBarrier : if (spin_ == 1) { fFactor = TMath::Sqrt(1.0/(z + 1.0)); } else if (spin_ == 2) { fFactor = TMath::Sqrt(1.0/(z*z + 3.0*z + 9.0)); } else if (spin_ == 3) { fFactor = TMath::Sqrt(1.0/(z*z*z + 6.0*z*z + 45.0*z + 225.0)); } else if (spin_ == 4) { fFactor = TMath::Sqrt(1.0/(z*z*z*z + 10.0*z*z*z + 135.0*z*z + 1575.0*z + 11025.0)); } else if (spin_ == 5) { fFactor = TMath::Sqrt(1.0/(z*z*z*z*z + 15.0*z*z*z*z + 315.0*z*z*z + 6300.0*z*z + 99225.0*z + 893025.0)); } break; case BarrierType::ExpBarrier : if (spin_ == 1) { fFactor = TMath::Exp( -TMath::Sqrt(z) ); } else if (spin_ == 2) { fFactor = TMath::Exp( -z ); } else if (spin_ == 3) { fFactor = TMath::Exp( -TMath::Sqrt(z*z*z) ); } else if (spin_ == 4) { fFactor = TMath::Exp( -z*z ); } else if (spin_ == 5) { fFactor = TMath::Exp( -TMath::Sqrt(z*z*z*z*z) ); } break; } return fFactor; } diff --git a/src/LauEFKLLMRes.cc b/src/LauEFKLLMRes.cc index 8d8949e..62ff339 100644 --- a/src/LauEFKLLMRes.cc +++ b/src/LauEFKLLMRes.cc @@ -1,169 +1,173 @@ /* Copyright 2015 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauEFKLLMRes.cc \brief File containing implementation of LauEFKLLMRes class. */ #include #include "Lau1DCubicSpline.hh" #include "LauKinematics.hh" #include "LauEFKLLMRes.hh" #include "LauResonanceInfo.hh" #include "LauTextFileParser.hh" ClassImp(LauEFKLLMRes); +TString LauEFKLLMRes::ffFileName_; std::unique_ptr LauEFKLLMRes::magSpline_; std::unique_ptr LauEFKLLMRes::phaseSpline_; LauEFKLLMRes::LauEFKLLMRes(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters) : LauAbsResonance(resInfo, resPairAmpInt, daughters) { const Double_t massFactorVal{0.0}; const TString& parNameBase { this->getSanitisedName() }; TString massFactorName{parNameBase}; massFactorName += "_massFactor"; massFactor_ = resInfo->getExtraParameter( massFactorName ); if ( massFactor_ == nullptr ) { massFactor_ = new LauParameter( massFactorName, massFactorVal, -10.0, 10.0, kTRUE ); massFactor_->secondStage(kTRUE); resInfo->addExtraParameter( massFactor_ ); } } void LauEFKLLMRes::initialise() { } void LauEFKLLMRes::setResonanceParameter(const TString& name, const Double_t value) { if(name=="massFactor") { this->setMassFactor(value); std::cout << "INFO in LauEFKLLMRes::setResonanceParameter: Mass factor set to " << value << std::endl; } else { std::cerr << "WARNING in LauEFKLLMRes::setResonanceParameter: Parameter name not reconised." << std::endl; } } void LauEFKLLMRes::floatResonanceParameter(const TString& name) { if(name=="massFactor") { if ( massFactor_->fixed() ) { massFactor_->fixed( kFALSE ); this->addFloatingParameter( massFactor_ ); } else { std::cerr << "WARNING in LauEFKLLMRes::floatResonanceParameter: Parameter already floating. No parameter changes made." << std::endl; } } else { std::cerr << "WARNING in LauEFKLLMRes::floatResonanceParameter: Parameter name not reconised." << std::endl; } } LauParameter* LauEFKLLMRes::getResonanceParameter(const TString& name) { if(name=="massFactor") { return massFactor_; } else { std::cerr << "WARNING in LauEFKLLMRes::getResonanceParameter: Parameter name not reconised." << std::endl; return nullptr; } } const std::vector& LauEFKLLMRes::getFloatingParameters() { this->clearFloatingParameters(); if ( ! this->fixMassFactor() ) { this->addFloatingParameter( massFactor_ ); } return this->getParameters(); } LauComplex LauEFKLLMRes::resAmp(Double_t mass, Double_t /*spinTerm*/) { LauComplex amp{0.0, 0.0}; if (magSpline_ == nullptr || phaseSpline_ == nullptr) { std::cerr << "ERROR in LauEFKLLMRes::resAmp : One or both of the splines is null." << std::endl; return amp; } const Double_t massSq { mass * mass }; const Double_t mag { magSpline_->evaluate(massSq) }; const Double_t phase { TMath::DegToRad() * phaseSpline_->evaluate(massSq) }; LauComplex ff{mag*TMath::Cos(phase), mag*TMath::Sin(phase)}; amp = ff.scale(TMath::Power(mass,this->getMassFactor())); return amp; } void LauEFKLLMRes::setupFormFactor(const TString& inputFile) { LauTextFileParser readFile(inputFile); readFile.processFile(); std::vector mSqVals; std::vector magVals; std::vector phaseVals; std::vector line; line = readFile.getNextLine(); while ( ! line.empty() ) { if ( line.size() != 3 ) { std::cerr << "ERROR in LauEFKLLMRes::setupFormFactor : Unexpected number of fields in text file, aborting reading of form-factor information." << std::endl; return; } mSqVals.push_back( std::stod(line[0]) ); magVals.push_back( std::stod(line[1]) ); phaseVals.push_back( std::stod(line[2]) ); line = readFile.getNextLine(); } // Destroy any splines we already had defined but issue a warning just in case if ( magSpline_ != nullptr || phaseSpline_ != nullptr ) { std::cerr << "WARNING in LauEFKLLMRes::setupFormFactor : Overwriting previous form-factor splines with newly read values." << std::endl; } magSpline_ = std::make_unique(mSqVals, magVals, Lau1DCubicSpline::SplineType::AkimaSpline); phaseSpline_ = std::make_unique(mSqVals, phaseVals, Lau1DCubicSpline::SplineType::AkimaSpline); + + // Store the name of the file from which the form factor info was read + ffFileName_ = inputFile; } void LauEFKLLMRes::setMassFactor(const Double_t massFactor) { massFactor_->value( massFactor ); massFactor_->genValue( massFactor ); massFactor_->initValue( massFactor ); } diff --git a/src/LauIsobarDynamics.cc b/src/LauIsobarDynamics.cc index ee79bef..76340c7 100644 --- a/src/LauIsobarDynamics.cc +++ b/src/LauIsobarDynamics.cc @@ -1,3195 +1,3299 @@ /* Copyright 2005 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauIsobarDynamics.cc \brief File containing implementation of LauIsobarDynamics class. */ #include "LauIsobarDynamics.hh" #include "LauAbsEffModel.hh" #include "LauAbsModIndPartWave.hh" #include "LauAbsResonance.hh" #include "LauAbsIncohRes.hh" #include "LauBelleNR.hh" #include "LauCacheData.hh" #include "LauConstants.hh" #include "LauDaughters.hh" #include "LauDPPartialIntegralInfo.hh" #include "LauEFKLLMRes.hh" #include "LauFitDataTree.hh" #include "LauGounarisSakuraiRes.hh" #include "LauJsonTools.hh" #include "LauKinematics.hh" #include "LauKMatrixProdPole.hh" #include "LauKMatrixProdSVP.hh" #include "LauKMatrixPropagator.hh" #include "LauKMatrixPropFactory.hh" #include "LauLHCbNR.hh" #include "LauNRAmplitude.hh" #include "LauPrint.hh" #include "LauRandom.hh" #include "LauResonanceInfo.hh" #include "LauResonanceMaker.hh" #include "LauRhoOmegaMix.hh" #include "TFile.h" #include "TRandom.h" #include "TSystem.h" #include #include #include #include #include ClassImp(LauIsobarDynamics) using json = nlohmann::json; // for Kpipi: only one scfFraction 2D histogram is needed LauIsobarDynamics::LauIsobarDynamics(LauDaughters* daughters, LauAbsEffModel* effModel, LauAbsEffModel* scfFractionModel) : daughters_(daughters), kinematics_(daughters_ ? daughters_->getKinematics() : 0), effModel_(effModel), nAmp_(0), nIncohAmp_(0), DPNorm_(0.0), DPRate_("DPRate", 0.0, 0.0, 1000.0), meanDPEff_("meanDPEff", 0.0, 0.0, 1.0), currentEvent_(0), symmetricalDP_(kFALSE), fullySymmetricDP_(kFALSE), flavConjDP_(kFALSE), integralsDone_(kFALSE), normalizationSchemeDone_(kFALSE), forceSymmetriseIntegration_(kFALSE), intFileName_("integ.dat"), m13BinWidth_(0.005), m23BinWidth_(0.005), mPrimeBinWidth_(0.001), thPrimeBinWidth_(0.001), narrowWidth_(0.020), binningFactor_(100.0), m13Sq_(0.0), m23Sq_(0.0), mPrime_(0.0), thPrime_(0.0), tagCat_(-1), eff_(1.0), scfFraction_(0.0), jacobian_(0.0), ASq_(0.0), evtLike_(0.0), iterationsMax_(100000), nSigGenLoop_(0), aSqMaxSet_(1.25), aSqMaxVar_(0.0), flipHelicity_(kTRUE), recalcNormalisation_(kFALSE), calculateRhoOmegaFitFractions_(kFALSE) { if (daughters != 0) { symmetricalDP_ = daughters->gotSymmetricalDP(); fullySymmetricDP_ = daughters->gotFullySymmetricDP(); flavConjDP_ = daughters->gotFlavourConjugateDP(); typDaug_.push_back(daughters->getTypeDaug1()); typDaug_.push_back(daughters->getTypeDaug2()); typDaug_.push_back(daughters->getTypeDaug3()); } if (scfFractionModel != 0) { scfFractionModel_[0] = scfFractionModel; } sigResonances_.clear(); sigIncohResonances_.clear(); kMatrixPropagators_.clear(); kMatrixPropSet_.clear(); extraParameters_.clear(); } // for Kspipi, we need a scfFraction 2D histogram for each tagging category. They are provided by the map. // Also, we need to know the place that the tagging category of the current event occupies in the data structure inputFitTree LauIsobarDynamics::LauIsobarDynamics(LauDaughters* daughters, LauAbsEffModel* effModel, LauTagCatScfFractionModelMap scfFractionModel) : daughters_(daughters), kinematics_(daughters_ ? daughters_->getKinematics() : 0), effModel_(effModel), scfFractionModel_(scfFractionModel), nAmp_(0), nIncohAmp_(0), DPNorm_(0.0), DPRate_("DPRate", 0.0, 0.0, 1000.0), meanDPEff_("meanDPEff", 0.0, 0.0, 1.0), currentEvent_(0), symmetricalDP_(kFALSE), fullySymmetricDP_(kFALSE), flavConjDP_(kFALSE), integralsDone_(kFALSE), normalizationSchemeDone_(kFALSE), forceSymmetriseIntegration_(kFALSE), intFileName_("integ.dat"), m13BinWidth_(0.005), m23BinWidth_(0.005), mPrimeBinWidth_(0.001), thPrimeBinWidth_(0.001), narrowWidth_(0.020), binningFactor_(100.0), m13Sq_(0.0), m23Sq_(0.0), mPrime_(0.0), thPrime_(0.0), tagCat_(-1), eff_(1.0), scfFraction_(0.0), jacobian_(0.0), ASq_(0.0), evtLike_(0.0), iterationsMax_(100000), nSigGenLoop_(0), aSqMaxSet_(1.25), aSqMaxVar_(0.0), flipHelicity_(kTRUE), recalcNormalisation_(kFALSE), calculateRhoOmegaFitFractions_(kFALSE) { // Constructor for the isobar signal model if (daughters != 0) { symmetricalDP_ = daughters->gotSymmetricalDP(); fullySymmetricDP_ = daughters->gotFullySymmetricDP(); flavConjDP_ = daughters->gotFlavourConjugateDP(); typDaug_.push_back(daughters->getTypeDaug1()); typDaug_.push_back(daughters->getTypeDaug2()); typDaug_.push_back(daughters->getTypeDaug3()); } sigResonances_.clear(); sigIncohResonances_.clear(); kMatrixPropagators_.clear(); kMatrixPropSet_.clear(); extraParameters_.clear(); } LauIsobarDynamics::~LauIsobarDynamics() { extraParameters_.clear(); for ( std::vector::iterator iter = data_.begin(); iter != data_.end(); ++iter ) { delete (*iter); } data_.clear(); for (std::vector::iterator it = dpPartialIntegralInfo_.begin(); it != dpPartialIntegralInfo_.end(); ++it) { delete (*it); } dpPartialIntegralInfo_.clear(); } void LauIsobarDynamics::resetNormVectors() { for (UInt_t i = 0; i < nAmp_; i++) { fSqSum_[i] = 0.0; fSqEffSum_[i] = 0.0; fNorm_[i] = 0.0; ff_[i].zero(); for (UInt_t j = 0; j < nAmp_; j++) { fifjEffSum_[i][j].zero(); fifjSum_[i][j].zero(); } } for (UInt_t i = 0; i < nIncohAmp_; i++) { fSqSum_[i+nAmp_] = 0.0; fSqEffSum_[i+nAmp_] = 0.0; fNorm_[i+nAmp_] = 0.0; incohInten_[i] = 0.0; } } void LauIsobarDynamics::recalculateNormalisation() { if ( recalcNormalisation_ == kFALSE ) { return; } // We need to calculate the normalisation constants for the // Dalitz plot generation/fitting. integralsDone_ = kFALSE; this->resetNormVectors(); this->findIntegralsToBeRecalculated(); this->calcDPNormalisation(); integralsDone_ = kTRUE; } void LauIsobarDynamics::findIntegralsToBeRecalculated() { // Loop through the resonance parameters and see which ones have changed // For those that have changed mark the corresponding resonance(s) as needing to be re-evaluated integralsToBeCalculated_.clear(); const UInt_t nResPars = resonancePars_.size(); for ( UInt_t iPar(0); iPar < nResPars; ++iPar ) { const Double_t newValue = resonancePars_[iPar]->value(); if ( newValue != resonanceParValues_[iPar] ) { resonanceParValues_[iPar] = newValue; const std::vector& indices = resonanceParResIndex_[iPar]; std::vector::const_iterator indexIter = indices.begin(); const std::vector::const_iterator indexEnd = indices.end(); for( ; indexIter != indexEnd; ++indexIter) { integralsToBeCalculated_.insert(*indexIter); } } } } void LauIsobarDynamics::collateResonanceParameters() { // Initialise all resonance models resonancePars_.clear(); resonanceParValues_.clear(); resonanceParResIndex_.clear(); std::set uniqueResPars; UInt_t resIndex(0); for ( std::vector::iterator resIter = sigResonances_.begin(); resIter != sigResonances_.end(); ++resIter ) { (*resIter)->initialise(); // Check if this resonance has floating parameters // Append all unique parameters to our list const std::vector& resPars = (*resIter)->getFloatingParameters(); for ( std::vector::const_iterator parIter = resPars.begin(); parIter != resPars.end(); ++parIter ) { if ( uniqueResPars.insert( *parIter ).second ) { // This parameter has not already been added to // the list of unique ones. Add it, its value // and its associated resonance ID to the // appropriate lists. resonancePars_.push_back( *parIter ); resonanceParValues_.push_back( (*parIter)->value() ); std::vector resIndices( 1, resIndex ); resonanceParResIndex_.push_back( resIndices ); } else { // This parameter has already been added to the // list of unique ones. However, we still need // to indicate that this resonance should be // associated with it. std::vector::const_iterator uniqueParIter = resonancePars_.begin(); std::vector >::iterator indicesIter = resonanceParResIndex_.begin(); while( (*uniqueParIter) != (*parIter) ) { ++uniqueParIter; ++indicesIter; } ( *indicesIter ).push_back( resIndex ); } } ++resIndex; } for ( std::vector::iterator resIter = sigIncohResonances_.begin(); resIter != sigIncohResonances_.end(); ++resIter ) { (*resIter)->initialise(); // Check if this resonance has floating parameters // Append all unique parameters to our list const std::vector& resPars = (*resIter)->getFloatingParameters(); for ( std::vector::const_iterator parIter = resPars.begin(); parIter != resPars.end(); ++parIter ) { if ( uniqueResPars.insert( *parIter ).second ) { // This parameter has not already been added to // the list of unique ones. Add it, its value // and its associated resonance ID to the // appropriate lists. resonancePars_.push_back( *parIter ); resonanceParValues_.push_back( (*parIter)->value() ); std::vector resIndices( 1, resIndex ); resonanceParResIndex_.push_back( resIndices ); } else { // This parameter has already been added to the // list of unique ones. However, we still need // to indicate that this resonance should be // associated with it. std::vector::const_iterator uniqueParIter = resonancePars_.begin(); std::vector >::iterator indicesIter = resonanceParResIndex_.begin(); while( (*uniqueParIter) != (*parIter) ) { ++uniqueParIter; ++indicesIter; } ( *indicesIter ).push_back( resIndex ); } } ++resIndex; } } void LauIsobarDynamics::initialise(const std::vector& coeffs) { // Check whether we have a valid set of integration constants for // the normalisation of the signal likelihood function. this->initialiseVectors(); // Mark the DP integrals as undetermined integralsDone_ = kFALSE; this->collateResonanceParameters(); if ( resonancePars_.empty() ) { recalcNormalisation_ = kFALSE; } else { recalcNormalisation_ = kTRUE; } // Print summary of what we have so far to screen this->initSummary(); if ( nAmp_+nIncohAmp_ == 0 ) { std::cout << "INFO in LauIsobarDynamics::initialise : No contributions to DP model, not performing normalisation integrals." << std::endl; } else { // We need to calculate the normalisation constants for the Dalitz plot generation/fitting. std::cout<<"INFO in LauIsobarDynamics::initialise : Starting special run to generate the integrals for normalising the PDF..."<calcDPNormalisation(); // Write the integrals to a file (mainly for debugging purposes) this->writeIntegralsFile(); } integralsDone_ = kTRUE; std::cout << std::setprecision(10); std::cout<<"INFO in LauIsobarDynamics::initialise : Summary of the integrals:"<( theResonance->getResonanceModel() ); getChar << resModelInt << " "; } getChar << std::endl; // Write out the track pairings for each resonance. This is specified // by the resPairAmpInt integer in the addResonance function. for (i = 0; i < nAmp_; i++) { getChar << resPairAmp_[i] << " "; } getChar << std::endl; // Write out the fSqSum = |ff|^2, where ff = resAmp() for (i = 0; i < nAmp_; i++) { getChar << fSqSum_[i] << " "; } getChar << std::endl; // Similar to fSqSum, but with the efficiency term included. for (i = 0; i < nAmp_; i++) { getChar << fSqEffSum_[i] << " "; } getChar << std::endl; // Write out the f_i*f_j_conj*eff values = resAmp_i*resAmp_j_conj*eff. // Note that only the top half of the i*j "matrix" is required, as it // is symmetric w.r.t i, j. for (i = 0; i < nAmp_; i++) { for (j = i; j < nAmp_; j++) { getChar << fifjEffSum_[i][j] << " "; } } getChar << std::endl; // Similar to fifjEffSum, but without the efficiency term included. for (i = 0; i < nAmp_; i++) { for (j = i; j < nAmp_; j++) { getChar << fifjSum_[i][j] << " "; } } getChar << std::endl; // Write out number of incoherent resonances in the Dalitz plot model getChar << nIncohAmp_ << std::endl; // Write out the incoherent resonances for (i = 0; i < nIncohAmp_; i++) { getChar << incohResTypAmp_[i] << " "; } getChar << std::endl; // Write out the incoherent resonance model types (BW, RelBW etc...) for (i = 0; i < nIncohAmp_; i++) { LauAbsResonance* theResonance = sigIncohResonances_[i]; Int_t resModelInt = static_cast( theResonance->getResonanceModel() ); getChar << resModelInt << " "; } getChar << std::endl; // Write out the track pairings for each incoherent resonance. This is specified // by the resPairAmpInt integer in the addIncohResonance function. for (i = 0; i < nIncohAmp_; i++) { getChar << incohResPairAmp_[i] << " "; } getChar << std::endl; // Write out the fSqSum = |ff|^2, where |ff|^2 = incohResAmp() for (i = nAmp_; i < nAmp_+nIncohAmp_; i++) { getChar << fSqSum_[i] << " "; } getChar << std::endl; // Similar to fSqSum, but with the efficiency term included. for (i = nAmp_; i < nAmp_+nIncohAmp_; i++) { getChar << fSqEffSum_[i] << " "; } getChar << std::endl; } +void LauIsobarDynamics::writeModelToJson(const TString& jsonFileName, const TString& elementName, const bool append, const int indent) const +{ + using nlohmann::json; + + json j = json::object(); + j[ "commonSettings" ] = this->createJsonCommonSettings(); + j[ "resonances" ] = this->createJsonResonances(); + if ( ! kMatrixPropagators_.empty() ) { + j[ "kmatrix" ] = this->createJsonKMatrix(); + } + + const bool writeOK { LauJsonTools::writeJsonFile( j, jsonFileName.Data(), elementName.Data(), append, indent ) }; + if ( ! writeOK ) { + std::cerr << "ERROR in LauIsobarDynamics::writeModelToJson : could not successfully write to file \"" << jsonFileName << std::endl; + } +} + +nlohmann::json LauIsobarDynamics::createJsonCommonSettings() const +{ + // Store the general settings + const LauResonanceMaker& resMaker = LauResonanceMaker::get(); + nlohmann::json j = resMaker.writeSettingsToJson(); + + // Store any "static" model-specific settings + for ( const LauAbsResonance* res : sigResonances_ ) { + const auto resModel { res->getResonanceModel() }; + if ( resModel == LauAbsResonance::ResonanceModel::EFKLLM ) { + j[ "setupEFKLLMFormFactor" ] = LauEFKLLMRes::getFormFactorFileName(); + } else if ( resModel == LauAbsResonance::ResonanceModel::GS ) { + j[ "disableGSScalingOfWidthByBWFactors" ] = LauGounarisSakuraiRes::disableBWScalingOfWidth(); + } + } + + return j; +} + +nlohmann::json LauIsobarDynamics::createJsonResonances() const +{ + using nlohmann::json; + + json j = json::array(); + + for ( const LauAbsResonance* res : sigResonances_ ) { + + const auto resModel { res->getResonanceModel() }; + if ( resModel == LauAbsResonance::ResonanceModel::KMatrix_Pole || resModel == LauAbsResonance::ResonanceModel::KMatrix_SVP ) { + continue; + } + + j.push_back( res->writeSettingsToJson() ); + } + + for ( const LauAbsIncohRes* res : sigIncohResonances_ ) { + j.push_back( res->writeSettingsToJson() ); + } + + return j; +} + +nlohmann::json LauIsobarDynamics::createJsonKMatrix() const +{ + using nlohmann::json; + + json j = json::array(); + + for ( auto [ _, prop ] : kMatrixPropagators_ ) { + + json obj = json::object(); + + obj[ "propagator" ] = prop->writeSettingsToJson(); + + json poles = json::array(); + json svps = json::array(); + + for ( const LauAbsResonance* res : sigResonances_ ) { + + const auto resModel { res->getResonanceModel() }; + if ( resModel != LauAbsResonance::ResonanceModel::KMatrix_Pole && resModel != LauAbsResonance::ResonanceModel::KMatrix_SVP ) { + continue; + } + + auto prodVecComp { dynamic_cast(res) }; + if ( ! prodVecComp || prodVecComp->getPropagator() != prop ) { + continue; + } + + json comp = prodVecComp->writeSettingsToJson(); + + if ( resModel == LauAbsResonance::ResonanceModel::KMatrix_Pole ) { + poles.push_back( comp ); + } else { + svps.push_back( comp ); + } + } + + obj[ "poles" ] = poles; + obj[ "svps" ] = svps; + + j.push_back( obj ); + } + + return j; +} + void LauIsobarDynamics::constructModelFromJson(const TString& jsonFileName, const TString& elementName) { using JsonType = LauJsonTools::JsonType; // load the JSON from the file // NB deliberately not using uniform initialisation here because of this issue: // https://json.nlohmann.me/home/faq/#brace-initialization-yields-arrays const json j = LauJsonTools::readJsonFile( jsonFileName.Data(), elementName.Data(), JsonType::Object ); if ( j.is_null() ) { if ( elementName != "" ) { std::cerr << "ERROR in LauIsobarDynamics::constructModelFromJson : unable to retrieve JSON object from element \"" << elementName << "\" in file \"" << jsonFileName << "\"" << std::endl; } else { std::cerr << "ERROR in LauIsobarDynamics::constructModelFromJson : unable to retrieve JSON object from root element of file \"" << jsonFileName << "\"" << std::endl; } return; } // the object should have the following elements: // - an object for the LauResonanceMaker settings (possibly empty) // - an array of resonance settings objects const std::vector mandatoryElements { std::make_pair("commonSettings", JsonType::Object), std::make_pair("resonances", JsonType::Array) }; if ( ! LauJsonTools::checkObjectElements( j, mandatoryElements ) ) { if ( elementName != "" ) { std::cerr << "ERROR in LauIsobarDynamics::constructModelFromJson : JSON object from element \"" << elementName << "\" in file \"" << jsonFileName << "\" does not contain required elements: \"commonSettings\" (object) and \"resonances\" (array)" << std::endl; } else { std::cerr << "ERROR in LauIsobarDynamics::constructModelFromJson : JSON object from root element of file \"" << jsonFileName << "\" does not contain required elements: \"commonSettings\" (object) and \"resonances\" (array)" << std::endl; } return; } this->processJsonCommonSettings( j.at("commonSettings"), jsonFileName ); this->processJsonResonances( j.at("resonances"), jsonFileName ); auto kmatrix { LauJsonTools::getOptionalElement( j, "kmatrix", JsonType::Array ) }; if ( kmatrix ) { this->processJsonKMatrix( *kmatrix, jsonFileName ); } } void LauIsobarDynamics::processJsonCommonSettings( const json& commonSettings, const TString& jsonFileName ) { using JsonType = LauJsonTools::JsonType; LauResonanceMaker& resMaker = LauResonanceMaker::get(); // deal with all possible settings for LauResonanceMaker auto bwType { LauJsonTools::getOptionalValue( commonSettings, "setBWType", JsonType::String ) }; if ( bwType ) { resMaker.setBWType( bwType.value() ); } auto bwRestFrame { LauJsonTools::getOptionalValue( commonSettings, "setBWBachelorRestFrame", JsonType::String ) }; if ( bwRestFrame ) { resMaker.setBWBachelorRestFrame( bwRestFrame.value() ); } auto spinFormalism { LauJsonTools::getOptionalValue( commonSettings, "setSpinFormalism", JsonType::String ) }; if ( spinFormalism ) { resMaker.setSpinFormalism( spinFormalism.value() ); } auto defaultBWRadius { LauJsonTools::getOptionalElement( commonSettings, "setDefaultBWRadius", JsonType::Array ) }; if ( defaultBWRadius ) { this->processJsonSetDefaultBWRadius( *defaultBWRadius, resMaker, jsonFileName ); } // deal with disabling BW scaling of width in G-S lineshape auto disableGSScalingOfWidthByBWFactors { LauJsonTools::getOptionalValue( commonSettings, "disableGSScalingOfWidthByBWFactors", JsonType::Boolean ) }; if ( disableGSScalingOfWidthByBWFactors ) { LauGounarisSakuraiRes::disableBWScalingOfWidth( disableGSScalingOfWidthByBWFactors.value() ); } // deal with reading EFKLLM form factor from file auto ffFile { LauJsonTools::getOptionalValue( commonSettings, "setupEFKLLMFormFactor", JsonType::String ) }; if ( ffFile ) { LauEFKLLMRes::setupFormFactor( ffFile.value() ); } } void LauIsobarDynamics::processJsonKMatrix( const json& kmatrix, const TString& jsonFileName ) { using JsonType = LauJsonTools::JsonType; // check that all mandatory elements are present const std::vector mandatoryElements { std::make_pair("propagator", JsonType::Object), std::make_pair("poles", JsonType::Array), std::make_pair("svps", JsonType::Array) }; for ( const auto& obj : kmatrix ) { if ( ! LauJsonTools::checkObjectElements( obj, mandatoryElements ) ) { std::cerr << "ERROR in LauIsobarDynamics::processJsonKMatrix : \"kmatrix\" array of JSON file \"" << jsonFileName << "\" contains objects that do not have all mandatory elements - aborting processing of this array" << std::endl; return; } } for ( const auto& obj : kmatrix ) { const LauKMatrixPropagator* propagator { this->processJsonKMatrixPropagator( obj.at("propagator"), jsonFileName ) }; if ( propagator ) { this->processJsonKMatrixPoles( obj.at("poles"), *propagator, jsonFileName ); this->processJsonKMatrixSVPs( obj.at("svps"), *propagator, jsonFileName ); } } } const LauKMatrixPropagator* LauIsobarDynamics::processJsonKMatrixPropagator( const json& propagator, const TString& jsonFileName ) { using JsonType = LauJsonTools::JsonType; // check that all mandatory elements are present const std::vector mandatoryElements { std::make_pair("propName", JsonType::String), std::make_pair("paramFileName", JsonType::String), std::make_pair("resPairAmpInt", JsonType::Number_Unsigned), std::make_pair("nChannels", JsonType::Number_Unsigned), std::make_pair("nPoles", JsonType::Number_Unsigned) }; if ( ! LauJsonTools::checkObjectElements( propagator, mandatoryElements ) ) { std::cerr << "ERROR in LauIsobarDynamics::processJsonKMatrixPropagator : \"propagator\" object of JSON file \"" << jsonFileName << "\" does not contain all mandatory elements - aborting processing of this object" << std::endl; return nullptr; } // Get the mandatory elements const TString propName { LauJsonTools::getValue( propagator, "propName" ) }; const TString paramFileName { LauJsonTools::getValue( propagator, "paramFileName" ) }; const auto resPairAmpInt { LauJsonTools::getValue( propagator, "resPairAmpInt" ) }; const auto nChannels { LauJsonTools::getValue( propagator, "nChannels" ) }; const auto nPoles { LauJsonTools::getValue( propagator, "nPoles" ) }; // Get optional elements const auto rowIndex { LauJsonTools::getOptionalValue( propagator, "rowIndex", JsonType::Number_Unsigned ).value_or( 1 ) }; LauKMatrixPropagator* prop { this->defineKMatrixPropagator( propName, paramFileName, resPairAmpInt, nChannels, nPoles, rowIndex ) }; // Optionally ignore BW barrier factor auto ignoreBWBarrierFactor { LauJsonTools::getOptionalValue( propagator, "ignoreBWBarrierFactor", JsonType::Boolean ) }; if ( ignoreBWBarrierFactor && ignoreBWBarrierFactor.value() ) { prop->ignoreBWBarrierFactor(); } return prop; } void LauIsobarDynamics::processJsonKMatrixPoles( const json& poles, const LauKMatrixPropagator& propagator, const TString& jsonFileName ) { using JsonType = LauJsonTools::JsonType; // check that all mandatory elements are present for all K-matrix pole settings objects in the array const std::vector mandatoryElements { std::make_pair("poleName", JsonType::String), std::make_pair("poleIndex", JsonType::Number_Unsigned), }; for ( const auto& poleDef : poles ) { if ( ! LauJsonTools::checkObjectElements( poleDef, mandatoryElements ) ) { std::cerr << "ERROR in LauIsobarDynamics::processJsonKMatrixPoles : \"poles\" array of JSON file \"" << jsonFileName << "\" has elements that are mis-formatted - aborting processing of this array" << std::endl; return; } } const TString propName { propagator.getName() }; for ( const auto& poleDef : poles ) { // Get the mandatory elements const TString poleName { LauJsonTools::getValue( poleDef, "poleName" ) }; const auto poleIndex { LauJsonTools::getValue( poleDef, "poleIndex" ) }; // Get optional elements const auto useProdAdler { LauJsonTools::getOptionalValue( poleDef, "useProdAdler", JsonType::Boolean ).value_or( kFALSE ) }; this->addKMatrixProdPole( poleName, propName, poleIndex, useProdAdler ); } } void LauIsobarDynamics::processJsonKMatrixSVPs( const json& svps, const LauKMatrixPropagator& propagator, const TString& jsonFileName ) { using JsonType = LauJsonTools::JsonType; // check that all mandatory elements are present for all K-matrix SVP settings objects in the array const std::vector mandatoryElements { std::make_pair("svpName", JsonType::String), std::make_pair("channelIndex", JsonType::Number_Unsigned), }; for ( const auto& svpDef : svps ) { if ( ! LauJsonTools::checkObjectElements( svpDef, mandatoryElements ) ) { std::cerr << "ERROR in LauIsobarDynamics::processJsonKMatrixSVPs : \"svps\" array of JSON file \"" << jsonFileName << "\" has elements that are mis-formatted - aborting processing of this array" << std::endl; return; } } const TString propName { propagator.getName() }; for ( const auto& svpDef : svps ) { // Get the mandatory elements const TString svpName { LauJsonTools::getValue( svpDef, "svpName" ) }; const auto channelIndex { LauJsonTools::getValue( svpDef, "channelIndex" ) }; // Get optional elements const auto useProdAdler { LauJsonTools::getOptionalValue( svpDef, "useProdAdler", JsonType::Boolean ).value_or( kFALSE ) }; this->addKMatrixProdSVP( svpName, propName, channelIndex, useProdAdler ); } } void LauIsobarDynamics::processJsonResonances( const json& resonances, const TString& jsonFileName ) { using JsonType = LauJsonTools::JsonType; // check that all mandatory elements are present for all resonance settings objects in the array const std::vector mandatoryElements { std::make_pair("resName", JsonType::String), std::make_pair("resPairAmpInt", JsonType::Number_Unsigned), std::make_pair("resType", JsonType::String) }; for ( const auto& resDef : resonances ) { if ( ! LauJsonTools::checkObjectElements( resDef, mandatoryElements ) ) { std::cerr << "ERROR in LauIsobarDynamics::processJsonResonances : \"resonances\" array of JSON file \"" << jsonFileName << "\" has elements that are mis-formatted - aborting processing of this array" << std::endl; return; } } // If so, we can safely loop through all the entries and process them for ( const auto& resDef : resonances ) { // Get the mandatory elements const TString resName { LauJsonTools::getValue( resDef, "resName" ) }; const auto resPairAmpInt { LauJsonTools::getValue( resDef, "resPairAmpInt" ) }; const auto resType { LauJsonTools::getValue( resDef, "resType" ) }; // Get optional elements needed for addResonance/addIncoherentResonance const auto bwCategory { LauJsonTools::getOptionalValue( resDef, "bwCategory", JsonType::String ).value_or( LauBlattWeisskopfFactor::Category::Default ) }; const auto coherent { LauJsonTools::getOptionalValue( resDef, "coherent", JsonType::Boolean ).value_or( kTRUE ) }; LauAbsResonance* res{nullptr}; if ( coherent ) { res = this->addResonance( resName, resPairAmpInt, resType, bwCategory ); } else { res = this->addIncoherentResonance( resName, resPairAmpInt, resType ); } if ( ! res ) { std::cerr << "ERROR in LauIsobarDynamics::processJsonResonances : problem constructing component " << resName << std::endl; continue; } auto changeResonance { LauJsonTools::getOptionalElement( resDef, "changeResonance", JsonType::Object ) }; if ( changeResonance ) { this->processJsonChangeResonance( *changeResonance, *res ); } auto changeBWBarrierRadii { LauJsonTools::getOptionalElement( resDef, "changeBWBarrierRadii", JsonType::Object ) }; if ( changeBWBarrierRadii ) { this->processJsonChangeBWBarrierRadii( *changeBWBarrierRadii, *res ); } auto ignoreMomenta { LauJsonTools::getOptionalValue( resDef, "ignoreMomenta", JsonType::Boolean ) }; if ( ignoreMomenta ) { res->ignoreMomenta( ignoreMomenta.value() ); } auto ignoreSpin { LauJsonTools::getOptionalValue( resDef, "ignoreSpin", JsonType::Boolean ) }; if ( ignoreSpin ) { res->ignoreSpin( ignoreSpin.value() ); } auto ignoreBarrierScaling { LauJsonTools::getOptionalValue( resDef, "ignoreBarrierScaling", JsonType::Boolean ) }; if ( ignoreBarrierScaling ) { res->ignoreBarrierScaling( ignoreBarrierScaling.value() ); } auto setSpinType { LauJsonTools::getOptionalValue( resDef, "setSpinType", JsonType::String ) }; if ( setSpinType ) { res->setSpinType( setSpinType.value() ); } auto enforceLegendreSpinFactors { LauJsonTools::getOptionalValue( resDef, "enforceLegendreSpinFactors", JsonType::Boolean ) }; if ( enforceLegendreSpinFactors ) { if ( ( resType == LauAbsResonance::ResonanceModel::BelleNR || resType == LauAbsResonance::ResonanceModel::PowerLawNR ) && dynamic_cast(res) ) { static_cast(res)->enforceLegendreSpinFactors( enforceLegendreSpinFactors.value() ); } else if ( resType == LauAbsResonance::ResonanceModel::LHCbNR && dynamic_cast(res) ) { static_cast(res)->enforceLegendreSpinFactors( enforceLegendreSpinFactors.value() ); } } auto defineKnots { LauJsonTools::getOptionalValue>( resDef, "defineKnots", JsonType::Array ) }; if ( defineKnots && ( resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase || resType == LauAbsResonance::ResonanceModel::MIPW_RealImag ) && dynamic_cast(res) ) { static_cast(res)->defineKnots( defineKnots.value() ); } auto knotAmps { LauJsonTools::getOptionalElement( resDef, "setKnotAmp", JsonType::Array ) }; if ( knotAmps && ( resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase || resType == LauAbsResonance::ResonanceModel::MIPW_RealImag ) && dynamic_cast(res) ) { this->processJsonSetMIPWKnotAmps( *knotAmps, resType, *static_cast(res) ); } auto splineTypes { LauJsonTools::getOptionalElement( resDef, "setSplineType", JsonType::Array ) }; if ( splineTypes && splineTypes->size() == 2 && ( resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase || resType == LauAbsResonance::ResonanceModel::MIPW_RealImag ) && dynamic_cast(res) ) { static_cast(res)->setSplineType( splineTypes->at(0).get(), splineTypes->at(1).get() ); } auto splineBoundaryConditions { LauJsonTools::getOptionalElement( resDef, "setSplineBoundaryConditions", JsonType::Array ) }; if ( splineBoundaryConditions && ( resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase || resType == LauAbsResonance::ResonanceModel::MIPW_RealImag ) && dynamic_cast(res) ) { if ( splineBoundaryConditions->size() == 4 ) { static_cast(res)->setSplineBoundaryConditions( splineBoundaryConditions->at(0).get(), splineBoundaryConditions->at(1).get(), splineBoundaryConditions->at(2).get(), splineBoundaryConditions->at(3).get() ); } else if ( splineBoundaryConditions->size() == 8 ) { static_cast(res)->setSplineBoundaryConditions( splineBoundaryConditions->at(0).get(), splineBoundaryConditions->at(1).get(), splineBoundaryConditions->at(2).get(), splineBoundaryConditions->at(3).get(), splineBoundaryConditions->at(4).get(), splineBoundaryConditions->at(5).get(), splineBoundaryConditions->at(6).get(), splineBoundaryConditions->at(7).get() ); } } auto floatKnotsSecondStage { LauJsonTools::getOptionalValue( resDef, "floatKnotsSecondStage", JsonType::Boolean ) }; if ( floatKnotsSecondStage && ( resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase || resType == LauAbsResonance::ResonanceModel::MIPW_RealImag ) && dynamic_cast(res) ) { static_cast(res)->floatKnotsSecondStage( floatKnotsSecondStage.value() ); } auto pars { LauJsonTools::getOptionalElement( resDef, "parameters", JsonType::Array ) }; if ( pars ) { this->processJsonResonanceParameters( *pars, *res ); } } } void LauIsobarDynamics::processJsonSetDefaultBWRadius( const json& j, LauResonanceMaker& resMaker, const TString& jsonFileName ) { using JsonType = LauJsonTools::JsonType; const std::vector mandatoryElements { std::make_pair("category", JsonType::String), std::make_pair("value", JsonType::Number) }; for ( const auto& obj : j ) { if ( ! LauJsonTools::checkObjectElements( obj, mandatoryElements ) ) { std::cerr << "ERROR in LauIsobarDynamics::processJsonSetDefaultBWRadius : \"setDefaultBWRadius\" array of JSON file \"" << jsonFileName << "\" has elements that are mis-formatted - aborting processing of this array" << std::endl; return; } } for ( const auto& obj : j ) { const auto category { LauJsonTools::getValue( obj, "category" ) }; const auto radiusVal { LauJsonTools::getValue( obj, "value" ) }; resMaker.setDefaultBWRadius( category, radiusVal ); const auto fixRadius { LauJsonTools::getOptionalValue( obj, "fix", JsonType::Boolean ) }; if ( fixRadius ) { resMaker.fixBWRadius( category, fixRadius.value() ); } } } void LauIsobarDynamics::processJsonChangeResonance( const json& j, LauAbsResonance& res ) { using LauJsonTools::JsonType; using LauJsonTools::getOptionalValue; Double_t newMass{-1.0}; Double_t newWidth{-1.0}; Int_t newSpin{-1}; Bool_t fixMass{kTRUE}; Bool_t fixWidth{kTRUE}; if ( j.contains("mass") ) { const json& mass { j.at("mass") }; newMass = getOptionalValue( mass, "value", JsonType::Number ).value_or(-1.0); fixMass = getOptionalValue( mass, "fix", JsonType::Boolean ).value_or(kTRUE); } if ( j.contains("width") ) { const json& width { j.at("width") }; newWidth = getOptionalValue( width, "value", JsonType::Number ).value_or(-1.0); fixWidth = getOptionalValue( width, "fix", JsonType::Boolean ).value_or(kTRUE); } if ( j.contains("spin") ) { const json& spin { j.at("spin") }; newSpin = getOptionalValue( spin, "value", JsonType::Number_Integer ).value_or(-1); } res.changeResonance( newMass, newWidth, newSpin ); res.fixMass(fixMass); res.fixWidth(fixWidth); } void LauIsobarDynamics::processJsonChangeBWBarrierRadii( const json& j, LauAbsResonance& res ) { Double_t newResRadius{-1.0}; Double_t newParRadius{-1.0}; Bool_t fixResRadius{kTRUE}; Bool_t fixParRadius{kTRUE}; if ( j.contains("resRadius") ) { const json& resRadius { j.at("resRadius") }; if ( resRadius.contains("value") && resRadius.at("value").is_number() ) { newResRadius = resRadius.at("value").get(); } if ( resRadius.contains("fix") && resRadius.at("fix").is_boolean() ) { fixResRadius = resRadius.at("fix").get(); } } if ( j.contains("parRadius") ) { const json& parRadius { j.at("parRadius") }; if ( parRadius.contains("value") && parRadius.at("value").is_number() ) { newParRadius = parRadius.at("value").get(); } if ( parRadius.contains("fix") && parRadius.at("fix").is_boolean() ) { fixParRadius = parRadius.at("fix").get(); } } res.changeBWBarrierRadii( newResRadius, newParRadius ); res.fixBarrierRadii( fixResRadius, fixParRadius ); } void LauIsobarDynamics::processJsonSetMIPWKnotAmps( const json& j, const LauAbsResonance::ResonanceModel resType, LauAbsModIndPartWave& mipw ) { using JsonType = LauJsonTools::JsonType; const std::size_t nKnots { j.size() }; if ( nKnots != mipw.nKnots() ) { std::cerr << "ERROR in LauIsobarDynamics::processJsonSetMIPWKnotAmps : number of entries in \"setKnotAmp\" array does not match number of knots in MIPW" << std::endl; return; } const std::array elementNames { (resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase) ? "mag" : "real", (resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase) ? "phase" : "imag", (resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase) ? "fixMag" : "fixReal", (resType == LauAbsResonance::ResonanceModel::MIPW_MagPhase) ? "fixPhase" : "fixImag" }; const std::vector mandatoryElements{ std::make_pair( elementNames[0], JsonType::Number_Float), std::make_pair( elementNames[1], JsonType::Number_Float), std::make_pair( elementNames[2], JsonType::Boolean), std::make_pair( elementNames[3], JsonType::Boolean) }; for ( std::size_t iKnot{0}; iKnot < nKnots; ++iKnot ) { if ( ! LauJsonTools::checkObjectElements( j.at(iKnot), mandatoryElements ) ) { std::cerr << "ERROR in LauIsobarDynamics::processJsonSetMIPWKnotAmps : entries in \"setKnotAmp\" array do not have all mandatory elements" << std::endl; return; } } for ( std::size_t iKnot{0}; iKnot < nKnots; ++iKnot ) { mipw.setKnotAmp( iKnot, j.at(iKnot).at( elementNames[0] ).get(), j.at(iKnot).at( elementNames[1] ).get(), j.at(iKnot).at( elementNames[2] ).get(), j.at(iKnot).at( elementNames[3] ).get() ); } } void LauIsobarDynamics::processJsonResonanceParameters( const json& j, LauAbsResonance& res ) { using JsonType = LauJsonTools::JsonType; const std::vector mandatoryElements{ std::make_pair("name", JsonType::String), std::make_pair("value", JsonType::Number), }; for ( const auto& par : j ) { if ( ! LauJsonTools::checkObjectElements( par, mandatoryElements ) ) { std::cerr << "ERROR in LauIsobarDynamics::processJsonResonanceParameters : problem with parameter entry \"" << par << "\", will not modify" << std::endl; continue; } const TString parName { LauJsonTools::getValue( par, "name" ) }; const auto parValue { LauJsonTools::getValue( par, "value" ) }; res.setResonanceParameter( parName, parValue ); const auto floatPar { LauJsonTools::getOptionalValue( par, "float", JsonType::Boolean ) }; if ( floatPar && floatPar.value() ) { res.floatResonanceParameter( parName ); } } } LauAbsResonance* LauIsobarDynamics::addResonance(const TString& resName, const Int_t resPairAmpInt, const LauAbsResonance::ResonanceModel resType, const LauBlattWeisskopfFactor::Category bwCategory) { // Function to add a resonance in a Dalitz plot. // No check is made w.r.t flavour and charge conservation rules, and so // the user is responsible for checking the internal consistency of // their function statements with these laws. For example, the program // will not prevent the user from asking for a rho resonance in a K-pi // pair or a K* resonance in a pi-pi pair. // However, to assist the user, a summary of the resonant structure requested // by the user is printed before the program runs. It is important to check this // information when you first define your Dalitz plot model before doing // any fitting/generating. // Arguments are: resonance name, integer to specify the resonance track pairing // (1 => m_23, 2 => m_13, 3 => m_12), i.e. the bachelor track number. // The third argument resType specifies whether the resonance is a Breit-Wigner (BW) // Relativistic Breit-Wigner (RelBW) or Flatte distribution (Flatte), for example. if( LauAbsResonance::isIncoherentModel(resType) == true ) { std::cerr<<"ERROR in LauIsobarDynamics::addResonance : Resonance type \""<(resType)<<"\" not allowed for a coherent resonance"<getCharge(resPairAmpInt) == 0 && daughters_->getChargeParent() == 0 && daughters_->getTypeParent() > 0 ) { if ( ( resPairAmpInt == 1 && TMath::Abs(daughters_->getTypeDaug2()) == TMath::Abs(daughters_->getTypeDaug3()) ) || ( resPairAmpInt == 2 && TMath::Abs(daughters_->getTypeDaug1()) == TMath::Abs(daughters_->getTypeDaug3()) ) || ( resPairAmpInt == 3 && TMath::Abs(daughters_->getTypeDaug1()) == TMath::Abs(daughters_->getTypeDaug2()) ) ) { theResonance->flipHelicity(kTRUE); } } // Set the resonance name and what track is the bachelor TString resonanceName = theResonance->getResonanceName(); resTypAmp_.push_back(resonanceName); // Always force the non-resonant amplitude pair to have resPairAmp = 0 // in case the user chooses the wrong number. if ( resType == LauAbsResonance::ResonanceModel::FlatNR || resType == LauAbsResonance::ResonanceModel::NRModel ) { std::cout<<"INFO in LauIsobarDynamics::addResonance : Setting resPairAmp to 0 for "<(resType)<<"\" not allowed for an incoherent resonance"<( resonanceMaker.getResonance(daughters_, resName, resPairAmpInt, resType) ); if (theResonance == nullptr) { std::cerr<<"ERROR in LauIsobarDynamics::addIncohResonance : Couldn't create the resonance \""<getResonanceName(); incohResTypAmp_.push_back(resonanceName); incohResPairAmp_.push_back(resPairAmpInt); // Increment the number of resonance amplitudes we have so far ++nIncohAmp_; // Finally, add the resonance object to the internal array sigIncohResonances_.push_back(theResonance); std::cout<<"INFO in LauIsobarDynamics::addIncohResonance : Successfully added incoherent resonance. Total number of incoherent resonances so far = "< nChannels) { std::cerr << "ERROR in LauIsobarDynamics::defineKMatrixPropagator. The rowIndex, which is set to " << rowIndex << ", must be between 1 and the number of channels " << nChannels << std::endl; gSystem->Exit(EXIT_FAILURE); } TString propagatorName(propName), parameterFile(paramFileName); LauKMatrixPropagator* thePropagator = LauKMatrixPropFactory::getInstance()->getPropagator(propagatorName, parameterFile, resPairAmpInt, nChannels, nPoles, rowIndex); kMatrixPropagators_[propagatorName] = thePropagator; return thePropagator; } void LauIsobarDynamics::addKMatrixProdPole(const TString& poleName, const TString& propName, Int_t poleIndex, Bool_t useProdAdler) { // Add a K-matrix production pole term, using the K-matrix propagator given by the propName. // Here, poleIndex is the integer specifying the pole number. // First, find the K-matrix propagator. KMPropMap::iterator mapIter = kMatrixPropagators_.find(propName); if (mapIter != kMatrixPropagators_.end()) { LauKMatrixPropagator* thePropagator = mapIter->second; // Make sure the pole index is valid Int_t nPoles = thePropagator->getNPoles(); if (poleIndex < 1 || poleIndex > nPoles) { std::cerr<<"ERROR in LauIsobarDynamics::addKMatrixProdPole : The pole index "<getResPairAmpInt(); LauAbsResonance* prodPole = new LauKMatrixProdPole(poleName, poleIndex, resPairAmpInt, thePropagator, daughters_, useProdAdler); prodPole->setSpinType( LauAbsResonance::SpinType::Legendre ); resTypAmp_.push_back(poleName); resPairAmp_.push_back(resPairAmpInt); ++nAmp_; sigResonances_.push_back(prodPole); // Also store the propName-poleName pair for calculating total fit fractions later on // (avoiding the need to use dynamic casts to check which resonances are of the K-matrix type) kMatrixPropSet_[poleName] = propName; std::cout<<"INFO in LauIsobarDynamics::addKMatrixProdPole : Successfully added K-matrix production pole term. Total number of resonances so far = "<second; // Make sure the channel index is valid Int_t nChannels = thePropagator->getNChannels(); if (channelIndex < 1 || channelIndex > nChannels) { std::cerr<<"ERROR in LauIsobarDynamics::addKMatrixProdSVP : The channel index "<getResPairAmpInt(); LauAbsResonance* prodSVP = new LauKMatrixProdSVP(SVPName, channelIndex, resPairAmpInt, thePropagator, daughters_, useProdAdler); prodSVP->setSpinType( LauAbsResonance::SpinType::Legendre ); resTypAmp_.push_back(SVPName); resPairAmp_.push_back(resPairAmpInt); ++nAmp_; sigResonances_.push_back(prodSVP); // Also store the SVPName-propName pair for calculating total fit fractions later on // (avoiding the need to use dynamic casts to check which resonances are of the K-matrix type) kMatrixPropSet_[SVPName] = propName; std::cout<<"INFO in LauIsobarDynamics::addKMatrixProdSVP : Successfully added K-matrix production slowly-varying (SVP) term. Total number of resonances so far = "<::const_iterator iter=sigResonances_.begin(); iter!=sigResonances_.end(); ++iter) { theResonance = (*iter); if (theResonance != 0) { const TString& resString = theResonance->getResonanceName(); if (resString == resName) { return index; } } ++index; } for (std::vector::const_iterator iter=sigIncohResonances_.begin(); iter!=sigIncohResonances_.end(); ++iter) { theResonance = (*iter); if (theResonance != 0) { const TString& resString = theResonance->getResonanceName(); if (resString == resName) { return index; } } ++index; } return -1; } Bool_t LauIsobarDynamics::hasResonance(const TString& resName) const { const Int_t index = this->resonanceIndex(resName); if (index < 0) { return kFALSE; } else { return kTRUE; } } const LauAbsResonance* LauIsobarDynamics::getResonance(const UInt_t resIndex) const { if ( resIndex < this->getnCohAmp() ) { return sigResonances_[resIndex]; } else if ( resIndex < this->getnTotAmp() ) { return sigIncohResonances_[ resIndex - nAmp_ ]; } else { std::cerr<<"ERROR in LauIsobarDynamics::getResonance : Couldn't find resonance with index \""<getnCohAmp() ) { return sigResonances_[resIndex]; } else if ( resIndex < this->getnTotAmp() ) { return sigIncohResonances_[ resIndex - nAmp_ ]; } else { std::cerr<<"ERROR in LauIsobarDynamics::getResonance : Couldn't find resonance with index \""<resonanceIndex( resName ); if ( index < 0 ) { std::cerr<<"ERROR in LauIsobarDynamics::findResonance : Couldn't find resonance with name \""<getResonance( index ); } } const LauAbsResonance* LauIsobarDynamics::findResonance(const TString& resName) const { const Int_t index = this->resonanceIndex( resName ); if ( index < 0 ) { std::cerr<<"ERROR in LauIsobarDynamics::findResonance : Couldn't find resonance with name \""<getResonance( index ); } } void LauIsobarDynamics::removeCharge(TString& string) const { Ssiz_t index = string.Index("+"); if (index != -1) { string.Remove(index,1); } index = string.Index("-"); if (index != -1) { string.Remove(index,1); } } void LauIsobarDynamics::calcDPNormalisation() { if (!normalizationSchemeDone_) { this->calcDPNormalisationScheme(); } for (std::vector::iterator it = dpPartialIntegralInfo_.begin(); it != dpPartialIntegralInfo_.end(); ++it) { this->calcDPPartialIntegral( *it ); } for (UInt_t i = 0; i < nAmp_+nIncohAmp_; ++i) { fNorm_[i] = 0.0; if (fSqSum_[i] > 0.0) {fNorm_[i] = TMath::Sqrt(1.0/(fSqSum_[i]));} } } std::vector< std::pair > LauIsobarDynamics::formGapsFromRegions( const std::vector< std::pair >& regions, const Double_t min, const Double_t max ) const { std::vector< std::pair > gaps(regions.size() + 1, std::make_pair(0., 0.)); // Given some narrow resonance regions, find the regions that correspond to the gaps between them gaps[0].first = min; for (UInt_t i = 0; i < regions.size(); ++i) { gaps[i].second = regions[i].first; gaps[i + 1].first = regions[i].second; } gaps[gaps.size() - 1].second = max; return gaps; } void LauIsobarDynamics::cullNullRegions( std::vector& regions ) const { LauDPPartialIntegralInfo* tmp(0); regions.erase( std::remove(regions.begin(), regions.end(), tmp), regions.end() ); } void LauIsobarDynamics::correctDPOverlap( std::vector< std::pair >& regions, const std::vector& binnings ) const { if (regions.empty()) { return; } // If the regions overlap, ensure that the one with the finest binning takes precedence (i.e., extends its full width) for (UInt_t i = 0; i < regions.size() - 1; ++i) { if ( regions[i + 1].first <= regions[i].second ) { if ((binnings[i] < binnings[i + 1])) { regions[i + 1] = std::make_pair(regions[i].second, regions[i + 1].second); } else { regions[i] = std::make_pair(regions[i].first, regions[i + 1].first); } } } } std::vector LauIsobarDynamics::m13IntegrationRegions( const std::vector< std::pair >& m13Regions, const std::vector< std::pair >& m23Regions, const std::vector& m13Binnings, const Double_t precision, const Double_t defaultBinning ) const { // Create integration regions for all narrow resonances in m13 except for the overlaps with narrow resonances in m23 std::vector integrationRegions; const Double_t m23Min = kinematics_->getm23Min(); const Double_t m23Max = kinematics_->getm23Max(); // Loop over narrow resonances in m13 for (UInt_t m13i = 0; m13i < m13Regions.size(); ++m13i) { const Double_t m13Binning = m13Binnings[m13i]; const Double_t resMin13 = m13Regions[m13i].first; const Double_t resMax13 = m13Regions[m13i].second; // Initialise to the full height of the DP in case there are no narrow resonances in m23 Double_t lastResMax23 = m23Min; // Loop over narrow resonances in m23 for (UInt_t m23i = 0; m23i < m23Regions.size(); m23i++) { const Double_t resMin23 = m23Regions[m23i].first; const Double_t resMax23 = m23Regions[m23i].second; // For the first entry, add the area between m23 threshold and this first entry if (m23i == 0) { integrationRegions.push_back(this->newDPIntegrationRegion(resMin13, resMax13, m23Min, resMin23, m13Binning, defaultBinning, precision, nAmp_, nIncohAmp_)); } // For all entries except the last one, add the area between this and the next entry if (m23i != (m23Regions.size() - 1)) { const Double_t nextResMin23 = m23Regions[m23i + 1].first; integrationRegions.push_back(this->newDPIntegrationRegion(resMin13, resMax13, resMax23, nextResMin23, m13Binning, defaultBinning, precision, nAmp_, nIncohAmp_)); } else { lastResMax23 = resMax23; } } // Add the area between the last entry and the maximum m23 (which could be the whole strip if there are no entries in m23Regions) integrationRegions.push_back(this->newDPIntegrationRegion(resMin13, resMax13, lastResMax23, m23Max, m13Binning, defaultBinning, precision, nAmp_, nIncohAmp_)); } return integrationRegions; } std::vector LauIsobarDynamics::m23IntegrationRegions( const std::vector >& m13Regions, const std::vector >& m23Regions, const std::vector& m13Binnings, const std::vector& m23Binnings, const Double_t precision, const Double_t defaultBinning ) const { // Create integration regions for all narrow resonances in m23 (including the overlap regions with m13 narrow resonances) std::vector integrationRegions; const Double_t m13Min = kinematics_->getm13Min(); const Double_t m13Max = kinematics_->getm13Max(); // Loop over narrow resonances in m23 for (UInt_t m23i = 0; m23i < m23Regions.size(); m23i++) { const Double_t m23Binning = m23Binnings[m23i]; const Double_t resMin23 = m23Regions[m23i].first; const Double_t resMax23 = m23Regions[m23i].second; // Initialise to the full width of the DP in case there are no narrow resonances in m13 Double_t lastResMax13 = m13Min; // Loop over narrow resonances in m13 for (UInt_t m13i = 0; m13i < m13Regions.size(); m13i++){ const Double_t m13Binning = m13Binnings[m23i]; const Double_t resMin13 = m13Regions[m13i].first; const Double_t resMax13 = m13Regions[m13i].second; // Overlap region (only needed in m23) integrationRegions.push_back(this->newDPIntegrationRegion(resMin13, resMax13, resMin23, resMax23, m13Binning, m23Binning, precision, nAmp_, nIncohAmp_)); // For the first entry, add the area between m13 threshold and this first entry if (m13i == 0) { integrationRegions.push_back(this->newDPIntegrationRegion(m13Min, resMin13, resMin23, resMax23, defaultBinning, m23Binning, precision, nAmp_, nIncohAmp_)); } // For all entries except the last one, add the area between this and the next entry if (m13i != m13Regions.size() - 1) { const Double_t nextResMin13 = m23Regions[m13i + 1].first; integrationRegions.push_back(this->newDPIntegrationRegion(resMax13, nextResMin13, resMin23, resMax23, defaultBinning, m23Binning, precision, nAmp_, nIncohAmp_)); } else { lastResMax13 = resMax13; } } // Add the area between the last entry and the maximum m13 (which could be the whole strip if there are no entries in m13Regions) integrationRegions.push_back(this->newDPIntegrationRegion(lastResMax13, m13Max, resMin23, resMax23, defaultBinning, m23Binning, precision, nAmp_, nIncohAmp_)); } return integrationRegions; } LauDPPartialIntegralInfo* LauIsobarDynamics::newDPIntegrationRegion( const Double_t minm13, const Double_t maxm13, const Double_t minm23, const Double_t maxm23, const Double_t m13BinWidth, const Double_t m23BinWidth, const Double_t precision, const UInt_t nAmp, const UInt_t nIncohAmp ) const { const UInt_t nm13Points = static_cast((maxm13-minm13)/m13BinWidth); const UInt_t nm23Points = static_cast((maxm23-minm23)/m23BinWidth); // If we would create a region with no interior points, just return a null pointer if (nm13Points == 0 || nm23Points == 0) { return 0; } return new LauDPPartialIntegralInfo(minm13, maxm13, minm23, maxm23, m13BinWidth, m23BinWidth, precision, nAmp, nIncohAmp); } void LauIsobarDynamics::calcDPNormalisationScheme() { if ( ! dpPartialIntegralInfo_.empty() ) { std::cerr << "ERROR in LauIsobarDynamics::calcDPNormalisationScheme : Scheme already stored!" << std::endl; return; } // The precision for the Gauss-Legendre weights const Double_t precision(1e-6); // Get the rectangle that encloses the DP const Double_t minm13 = kinematics_->getm13Min(); const Double_t maxm13 = kinematics_->getm13Max(); const Double_t minm23 = kinematics_->getm23Min(); const Double_t maxm23 = kinematics_->getm23Max(); const Double_t minm12 = kinematics_->getm12Min(); const Double_t maxm12 = kinematics_->getm12Max(); // Find out whether we have narrow resonances in the DP (defined here as width < 20 MeV). std::vector< std::pair > m13NarrowRes; std::vector< std::pair > m23NarrowRes; std::vector< std::pair > m12NarrowRes; // Rho-omega mixing models implicitly contains omega(782) model, but width is of rho(770) - handle as a special case LauResonanceMaker& resonanceMaker = LauResonanceMaker::get(); LauResonanceInfo* omega_info = resonanceMaker.getResInfo("omega(782)"); const Double_t omegaMass = (omega_info!=0) ? omega_info->getMass()->unblindValue() : 0.78265; const Double_t omegaWidth = (omega_info!=0) ? omega_info->getWidth()->unblindValue() : 0.00849; for ( std::vector::const_iterator iter = sigResonances_.begin(); iter != sigResonances_.end(); ++iter ) { LauAbsResonance::ResonanceModel model = (*iter)->getResonanceModel(); const TString& name = (*iter)->getResonanceName(); Int_t pair = (*iter)->getPairInt(); Double_t mass = (*iter)->getMass(); Double_t width = (*iter)->getWidth(); if ( model == LauAbsResonance::ResonanceModel::RhoOmegaMix_GS || model == LauAbsResonance::ResonanceModel::RhoOmegaMix_GS_1 || model == LauAbsResonance::ResonanceModel::RhoOmegaMix_RBW || model == LauAbsResonance::ResonanceModel::RhoOmegaMix_RBW_1 ) { mass = omegaMass; width = omegaWidth; } if ( width > narrowWidth_ || width <= 0.0 ) { continue; } std::cout << "INFO in LauIsobarDynamics::calcDPNormalisationScheme : Found narrow resonance: " << name << ", mass = " << mass << ", width = " << width << ", pair int = " << pair << std::endl; if ( pair == 1 ) { if ( mass < minm23 || mass > maxm23 ){ std::cout << std::string(53, ' ') << ": But its pole is outside the kinematically allowed range, so will not consider it narrow for the purposes of integration" << std::endl; } else { m23NarrowRes.push_back( std::make_pair(mass,width) ); if ( fullySymmetricDP_ ) { m13NarrowRes.push_back( std::make_pair(mass,width) ); m12NarrowRes.push_back( std::make_pair(mass,width) ); } else if ( symmetricalDP_ || ( flavConjDP_ && forceSymmetriseIntegration_ ) ) { m13NarrowRes.push_back( std::make_pair(mass,width) ); } } } else if ( pair == 2 ) { if ( mass < minm13 || mass > maxm13 ){ std::cout << std::string(53, ' ') << ": But its pole is outside the kinematically allowed range, so will not consider it narrow for the purposes of integration" << std::endl; } else { m13NarrowRes.push_back( std::make_pair(mass,width) ); if ( fullySymmetricDP_ ) { m23NarrowRes.push_back( std::make_pair(mass,width) ); m12NarrowRes.push_back( std::make_pair(mass,width) ); } else if ( symmetricalDP_ || ( flavConjDP_ && forceSymmetriseIntegration_ ) ) { m23NarrowRes.push_back( std::make_pair(mass,width) ); } } } else if ( pair == 3 ) { if ( mass < minm12 || mass > maxm12 ){ std::cout << std::string(53, ' ') << ": But its pole is outside the kinematically allowed range, so will not consider it narrow for the purposes of integration" << std::endl; } else { m12NarrowRes.push_back( std::make_pair(mass,width) ); if ( fullySymmetricDP_ ) { m13NarrowRes.push_back( std::make_pair(mass,width) ); m12NarrowRes.push_back( std::make_pair(mass,width) ); } } } else { std::cerr << "WARNING in LauIsobarDynamics::calcDPNormalisationScheme : strange pair integer, " << pair << ", for resonance \"" << (*iter)->getResonanceName() << std::endl; } } for ( std::vector::const_iterator iter = sigIncohResonances_.begin(); iter != sigIncohResonances_.end(); ++iter ) { const TString& name = (*iter)->getResonanceName(); Int_t pair = (*iter)->getPairInt(); Double_t mass = (*iter)->getMass(); Double_t width = (*iter)->getWidth(); if ( width > narrowWidth_ || width == 0.0 ) { continue; } std::cout<<"INFO in LauIsobarDynamics::calcDPNormalisationScheme : Found narrow resonance: " << name << ", mass = " << mass << ", width = " << width << ", pair int = " << pair << std::endl; if ( pair == 1 ) { if ( mass < minm23 || mass > maxm23 ){ std::cout << std::string(53, ' ') << ": But its pole is outside the kinematically allowed range, so will not consider it narrow for the purposes of integration" << std::endl; } else { m23NarrowRes.push_back( std::make_pair(mass,width) ); if ( fullySymmetricDP_ ) { m13NarrowRes.push_back( std::make_pair(mass,width) ); m12NarrowRes.push_back( std::make_pair(mass,width) ); } else if ( symmetricalDP_ || ( flavConjDP_ && forceSymmetriseIntegration_ ) ) { m13NarrowRes.push_back( std::make_pair(mass,width) ); } } } else if ( pair == 2 ) { if ( mass < minm13 || mass > maxm13 ){ std::cout << std::string(53, ' ') << ": But its pole is outside the kinematically allowed range, so will not consider it narrow for the purposes of integration" << std::endl; } else { m13NarrowRes.push_back( std::make_pair(mass,width) ); if ( fullySymmetricDP_ ) { m23NarrowRes.push_back( std::make_pair(mass,width) ); m12NarrowRes.push_back( std::make_pair(mass,width) ); } else if ( symmetricalDP_ || ( flavConjDP_ && forceSymmetriseIntegration_ ) ) { m23NarrowRes.push_back( std::make_pair(mass,width) ); } } } else if ( pair == 3 ) { if ( mass < minm12 || mass > maxm12 ){ std::cout << std::string(53, ' ') << ": But its pole is outside the kinematically allowed range, so will not consider it narrow for the purposes of integration" << std::endl; } else { m12NarrowRes.push_back( std::make_pair(mass,width) ); if ( fullySymmetricDP_ ) { m13NarrowRes.push_back( std::make_pair(mass,width) ); m12NarrowRes.push_back( std::make_pair(mass,width) ); } } } else { std::cerr << "WARNING in LauIsobarDynamics::calcDPNormalisationScheme : strange pair integer, " << pair << ", for resonance \"" << (*iter)->getResonanceName() << std::endl; } } // Depending on how many narrow resonances we have and where they are // we adopt different approaches if ( ! m12NarrowRes.empty() ) { // We have at least one narrow resonance in m12 // Switch to using the square DP for the integration // TODO - for the time being just use a single, reasonably fine by default and tunable, grid // - can later consider whether there's a need to split up the mPrime axis into regions around particularly narrow resonances in m12 // - but it seems that this isn't really needed since even the default tune gives a good resolution for most narrow resonances such as phi / chi_c0 std::cout<<"INFO in LauIsobarDynamics::calcDPNormalisationScheme : One or more narrow resonances found in m12, integrating over whole square Dalitz plot with bin widths of "<squareDP() ) { std::cerr << "WARNING in LauIsobarDynamics::calcDPNormalisationScheme : forcing kinematics to calculate the required square DP co-ordinates" << std::endl; kinematics_->squareDP(kTRUE); } dpPartialIntegralInfo_.push_back(new LauDPPartialIntegralInfo(0.0, 1.0, 0.0, 1.0, mPrimeBinWidth_, thPrimeBinWidth_, precision, nAmp_, nIncohAmp_, kTRUE, kinematics_)); } else if (m13NarrowRes.empty() && m23NarrowRes.empty()) { // There are no narrow resonances, so we just do a single grid over the whole DP std::cout << "INFO in LauIsobarDynamics::calcDPNormalisationScheme : No narrow resonances found, integrating over whole Dalitz plot..." << std::endl; dpPartialIntegralInfo_.push_back(new LauDPPartialIntegralInfo(minm13, maxm13, minm23, maxm23, m13BinWidth_, m23BinWidth_, precision, nAmp_, nIncohAmp_)); } else { // Get regions in that correspond to narrow resonances in m13 and m23, and correct for overlaps in each dimension (to use the finest binning) // Sort resonances by ascending mass to calculate regions properly std::sort(m13NarrowRes.begin(), m13NarrowRes.end()); std::sort(m23NarrowRes.begin(), m23NarrowRes.end()); // For each narrow resonance in m13, determine the corresponding window and its binning std::vector > m13Regions; std::vector m13Binnings; for ( std::vector >::const_iterator iter = m13NarrowRes.begin(); iter != m13NarrowRes.end(); ++iter ) { Double_t mass = iter->first; Double_t width = iter->second; Double_t regionBegin = mass - 5.0 * width; Double_t regionEnd = mass + 5.0 * width; Double_t binning = width / binningFactor_; // check if we ought to extend the region to the edge of the phase space (in either direction) if ( regionBegin < (minm13+50.0*m13BinWidth_) ) { std::cout << "INFO in LauIsobarDynamics::calcDPNormalisationScheme : Resonance at m13 = " << mass << " is close to threshold, extending integration region" << std::endl; regionBegin = minm13; } if ( regionEnd > (maxm13-50.0*m13BinWidth_) ) { std::cout << "INFO in LauIsobarDynamics::calcDPNormalisationScheme : Resonance at m13 = " << mass << " is close to upper edge of phase space, extending integration region" << std::endl; regionEnd = maxm13; } m13Regions.push_back(std::make_pair(regionBegin, regionEnd)); m13Binnings.push_back(binning); } // For each narrow resonance in m23, determine the corresponding window and its binning std::vector > m23Regions; std::vector m23Binnings; for ( std::vector >::const_iterator iter = m23NarrowRes.begin(); iter != m23NarrowRes.end(); ++iter ) { Double_t mass = iter->first; Double_t width = iter->second; Double_t regionBegin = mass - 5.0 * width; Double_t regionEnd = mass + 5.0 * width; Double_t binning = width / binningFactor_; // check if we ought to extend the region to the edge of the phase space (in either direction) if ( regionBegin < (minm23+50.0*m23BinWidth_) ) { std::cout << "INFO in LauIsobarDynamics::calcDPNormalisationScheme : Resonance at m23 = " << mass << " is close to threshold, extending integration region" << std::endl; regionBegin = minm23; } if ( regionEnd > (maxm23-50.0*m23BinWidth_) ) { std::cout << "INFO in LauIsobarDynamics::calcDPNormalisationScheme : Resonance at m23 = " << mass << " is close to upper edge of phase space, extending integration region" << std::endl; regionEnd = maxm23; } m23Regions.push_back(std::make_pair(regionBegin, regionEnd)); m23Binnings.push_back(binning); } // Sort out overlaps between regions in the same mass pairing this->correctDPOverlap(m13Regions, m13Binnings); this->correctDPOverlap(m23Regions, m23Binnings); // Get the narrow resonance regions plus any overlap region std::vector fineScheme13 = this->m13IntegrationRegions(m13Regions, m23Regions, m13Binnings, precision, m13BinWidth_); std::vector fineScheme23 = this->m23IntegrationRegions(m13Regions, m23Regions, m13Binnings, m23Binnings, precision, m23BinWidth_); // Get coarse regions by calculating the gaps between the // narrow resonances and using the same functions to create // the integration grid object for each std::vector< std::pair > coarseRegions = this->formGapsFromRegions(m13Regions, minm13, maxm13); std::vector coarseBinning( fineScheme13.size()+1, m13BinWidth_ ); std::vector coarseScheme = this->m13IntegrationRegions(coarseRegions, m23Regions, coarseBinning, precision, m13BinWidth_); dpPartialIntegralInfo_.insert(dpPartialIntegralInfo_.end(), fineScheme13.begin(), fineScheme13.end()); dpPartialIntegralInfo_.insert(dpPartialIntegralInfo_.end(), fineScheme23.begin(), fineScheme23.end()); dpPartialIntegralInfo_.insert(dpPartialIntegralInfo_.end(), coarseScheme.begin(), coarseScheme.end()); // Remove any null pointer entries in the integral list // (that are produced when an integration region with no // interior points is defined) this->cullNullRegions(dpPartialIntegralInfo_); } normalizationSchemeDone_ = kTRUE; } void LauIsobarDynamics::setIntegralBinWidths(const Double_t m13BinWidth, const Double_t m23BinWidth, const Double_t mPrimeBinWidth, const Double_t thPrimeBinWidth) { // Set the bin widths for the m13 vs m23 integration grid m13BinWidth_ = m13BinWidth; m23BinWidth_ = m23BinWidth; // Set the bin widths for the m' vs theta' integration grid mPrimeBinWidth_ = mPrimeBinWidth; thPrimeBinWidth_ = thPrimeBinWidth; } void LauIsobarDynamics::calcDPPartialIntegral(LauDPPartialIntegralInfo* intInfo) { // Calculate the integrals for all parts of the amplitude in the given region of the DP const Bool_t squareDP = intInfo->getSquareDP(); const UInt_t nm13Points = intInfo->getnm13Points(); const UInt_t nm23Points = intInfo->getnm23Points(); //Double_t dpArea(0.0); for (UInt_t i = 0; i < nm13Points; ++i) { const Double_t m13 = intInfo->getM13Value(i); const Double_t m13Sq = m13*m13; for (UInt_t j = 0; j < nm23Points; ++j) { const Double_t m23 = intInfo->getM23Value(j); const Double_t m23Sq = m23*m23; const Double_t weight = intInfo->getWeight(i,j); // Calculate the integral contributions for each resonance. // Only points within the DP area contribute. // This also calculates the total DP area as a check. // NB if squareDP is true, m13 and m23 are actually mPrime and thetaPrime Bool_t withinDP = squareDP ? kinematics_->withinSqDPLimits(m13, m23) : kinematics_->withinDPLimits(m13Sq, m23Sq); if (withinDP == kTRUE) { if ( squareDP ) { // NB m13 and m23 are actually mPrime and thetaPrime kinematics_->updateSqDPKinematics(m13, m23); } else { kinematics_->updateKinematics(m13Sq, m23Sq); } this->calculateAmplitudes(intInfo, i, j); this->addGridPointToIntegrals(weight); // Increment total DP area //dpArea += weight; } } // j weights loop } // i weights loop // Print out DP area to check whether we have a sensible output //std::cout<<" : dpArea = "<::const_iterator intEnd = integralsToBeCalculated_.end(); for (UInt_t iAmp = 0; iAmp < nAmp_; ++iAmp) { if ( integralsToBeCalculated_.find(iAmp) != intEnd ) { // Calculate the dynamics for this resonance ff_[iAmp] = this->resAmp(iAmp); // Store the new value in the integration info object intInfo->storeAmplitude( m13Point, m23Point, iAmp, ff_[iAmp] ); } else { // Retrieve the cached value of the amplitude ff_[iAmp] = intInfo->getAmplitude( m13Point, m23Point, iAmp ); } } for (UInt_t iAmp = 0; iAmp < nIncohAmp_; ++iAmp) { if ( integralsToBeCalculated_.find(iAmp+nAmp_) != intEnd ) { // Calculate the dynamics for this resonance incohInten_[iAmp] = this->incohResAmp(iAmp); // Store the new value in the integration info object intInfo->storeIntensity( m13Point, m23Point, iAmp, incohInten_[iAmp] ); } else { // Retrieve the cached value of the amplitude incohInten_[iAmp] = intInfo->getIntensity( m13Point, m23Point, iAmp ); } } // If symmetric, do as above with flipped kinematics and add to amplitude // (No need to retrive the cache if this was done in the first case) if ( symmetricalDP_ == kTRUE ) { kinematics_->flipAndUpdateKinematics(); for (UInt_t iAmp = 0; iAmp < nAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance ff_[iAmp] += this->resAmp(iAmp); // Store the new value in the integration info object intInfo->storeAmplitude( m13Point, m23Point, iAmp, ff_[iAmp] ); } } for (UInt_t iAmp = 0; iAmp < nIncohAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp+nAmp_) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance incohInten_[iAmp] += this->incohResAmp(iAmp); // Store the new value in the integration info object intInfo->storeIntensity( m13Point, m23Point, iAmp, incohInten_[iAmp] ); } } kinematics_->flipAndUpdateKinematics(); } if (fullySymmetricDP_ == kTRUE) { // rotate and evaluate kinematics_->rotateAndUpdateKinematics(); for (UInt_t iAmp = 0; iAmp < nAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance ff_[iAmp] += this->resAmp(iAmp); // Store the new value in the integration info object intInfo->storeAmplitude( m13Point, m23Point, iAmp, ff_[iAmp] ); } } for (UInt_t iAmp = 0; iAmp < nIncohAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp+nAmp_) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance incohInten_[iAmp] += this->incohResAmp(iAmp); // Store the new value in the integration info object intInfo->storeIntensity( m13Point, m23Point, iAmp, incohInten_[iAmp] ); } } // rotate and evaluate kinematics_->rotateAndUpdateKinematics(); for (UInt_t iAmp = 0; iAmp < nAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance ff_[iAmp] += this->resAmp(iAmp); // Store the new value in the integration info object intInfo->storeAmplitude( m13Point, m23Point, iAmp, ff_[iAmp] ); } } for (UInt_t iAmp = 0; iAmp < nIncohAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp+nAmp_) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance incohInten_[iAmp] += this->incohResAmp(iAmp); // Store the new value in the integration info object intInfo->storeIntensity( m13Point, m23Point, iAmp, incohInten_[iAmp] ); } } // rotate, flip and evaluate kinematics_->rotateAndUpdateKinematics(); kinematics_->flipAndUpdateKinematics(); for (UInt_t iAmp = 0; iAmp < nAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance ff_[iAmp] += this->resAmp(iAmp); // Store the new value in the integration info object intInfo->storeAmplitude( m13Point, m23Point, iAmp, ff_[iAmp] ); } } for (UInt_t iAmp = 0; iAmp < nIncohAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp+nAmp_) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance incohInten_[iAmp] += this->incohResAmp(iAmp); // Store the new value in the integration info object intInfo->storeIntensity( m13Point, m23Point, iAmp, incohInten_[iAmp] ); } } // rotate and evaluate kinematics_->rotateAndUpdateKinematics(); for (UInt_t iAmp = 0; iAmp < nAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance ff_[iAmp] += this->resAmp(iAmp); // Store the new value in the integration info object intInfo->storeAmplitude( m13Point, m23Point, iAmp, ff_[iAmp] ); } } for (UInt_t iAmp = 0; iAmp < nIncohAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp+nAmp_) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance incohInten_[iAmp] += this->incohResAmp(iAmp); // Store the new value in the integration info object intInfo->storeIntensity( m13Point, m23Point, iAmp, incohInten_[iAmp] ); } } // rotate and evaluate kinematics_->rotateAndUpdateKinematics(); for (UInt_t iAmp = 0; iAmp < nAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance ff_[iAmp] += this->resAmp(iAmp); // Store the new value in the integration info object intInfo->storeAmplitude( m13Point, m23Point, iAmp, ff_[iAmp] ); } } for (UInt_t iAmp = 0; iAmp < nIncohAmp_; ++iAmp) { if ( (integralsToBeCalculated_.find(iAmp+nAmp_) != intEnd) && !sigResonances_[iAmp]->preSymmetrised() ) { // Calculate the dynamics for this resonance incohInten_[iAmp] += this->incohResAmp(iAmp); // Store the new value in the integration info object intInfo->storeIntensity( m13Point, m23Point, iAmp, incohInten_[iAmp] ); } } // rotate and flip to get us back to where we started kinematics_->rotateAndUpdateKinematics(); kinematics_->flipAndUpdateKinematics(); } // If we haven't cached the data, then we need to find out the efficiency. eff_ = this->retrieveEfficiency(); intInfo->storeEfficiency( m13Point, m23Point, eff_ ); } void LauIsobarDynamics::calculateAmplitudes() { std::set::const_iterator iter = integralsToBeCalculated_.begin(); const std::set::const_iterator intEnd = integralsToBeCalculated_.end(); for ( iter = integralsToBeCalculated_.begin(); iter != intEnd; ++iter) { // Calculate the dynamics for this resonance if(*iter < nAmp_) { ff_[*iter] = this->resAmp(*iter); } else { incohInten_[*iter-nAmp_] = this->incohResAmp(*iter-nAmp_); } } if ( symmetricalDP_ == kTRUE ) { kinematics_->flipAndUpdateKinematics(); for ( iter = integralsToBeCalculated_.begin(); iter != intEnd; ++iter) { // Calculate the dynamics for this resonance if(*iter < nAmp_ && !sigResonances_[*iter]->preSymmetrised() ) { ff_[*iter] += this->resAmp(*iter); } else if (*iter >= nAmp_ && !sigResonances_[*iter-nAmp_]->preSymmetrised() ){ incohInten_[*iter-nAmp_] += this->incohResAmp(*iter-nAmp_); } } kinematics_->flipAndUpdateKinematics(); } if ( fullySymmetricDP_ == kTRUE ) { // rotate and evaluate kinematics_->rotateAndUpdateKinematics(); for ( iter = integralsToBeCalculated_.begin(); iter != intEnd; ++iter) { if(*iter < nAmp_ && !sigResonances_[*iter]->preSymmetrised() ) { ff_[*iter] += this->resAmp(*iter); } else if (*iter >= nAmp_ && !sigResonances_[*iter-nAmp_]->preSymmetrised() ){ incohInten_[*iter-nAmp_] += this->incohResAmp(*iter-nAmp_); } } // rotate and evaluate kinematics_->rotateAndUpdateKinematics(); for ( iter = integralsToBeCalculated_.begin(); iter != intEnd; ++iter) { if(*iter < nAmp_ && !sigResonances_[*iter]->preSymmetrised() ) { ff_[*iter] += this->resAmp(*iter); } else if (*iter >= nAmp_ && !sigResonances_[*iter-nAmp_]->preSymmetrised() ){ incohInten_[*iter-nAmp_] += this->incohResAmp(*iter-nAmp_); } } // rotate, flip and evaluate kinematics_->rotateAndUpdateKinematics(); kinematics_->flipAndUpdateKinematics(); for ( iter = integralsToBeCalculated_.begin(); iter != intEnd; ++iter) { if(*iter < nAmp_ && !sigResonances_[*iter]->preSymmetrised() ) { ff_[*iter] += this->resAmp(*iter); } else if (*iter >= nAmp_ && !sigResonances_[*iter-nAmp_]->preSymmetrised() ){ incohInten_[*iter-nAmp_] += this->incohResAmp(*iter-nAmp_); } } // rotate and evaluate kinematics_->rotateAndUpdateKinematics(); for ( iter = integralsToBeCalculated_.begin(); iter != intEnd; ++iter) { if(*iter < nAmp_ && !sigResonances_[*iter]->preSymmetrised() ) { ff_[*iter] += this->resAmp(*iter); } else if (*iter >= nAmp_ && !sigResonances_[*iter-nAmp_]->preSymmetrised() ){ incohInten_[*iter-nAmp_] += this->incohResAmp(*iter-nAmp_); } } // rotate and evaluate kinematics_->rotateAndUpdateKinematics(); for ( iter = integralsToBeCalculated_.begin(); iter != intEnd; ++iter) { if(*iter < nAmp_ && !sigResonances_[*iter]->preSymmetrised() ) { ff_[*iter] += this->resAmp(*iter); } else if (*iter >= nAmp_ && !sigResonances_[*iter-nAmp_]->preSymmetrised() ){ incohInten_[*iter-nAmp_] += this->incohResAmp(*iter-nAmp_); } } // rotate and flip to get us back to where we started kinematics_->rotateAndUpdateKinematics(); kinematics_->flipAndUpdateKinematics(); } // If we haven't cached the data, then we need to find out the efficiency. eff_ = this->retrieveEfficiency(); } void LauIsobarDynamics::calcTotalAmp(const Bool_t useEff) { // Reset the total amplitude to zero totAmp_.zero(); // Loop over all signal amplitudes LauComplex ATerm; for (UInt_t i = 0; i < nAmp_; ++i) { // Get the partial complex amplitude - (mag, phase)*(resonance dynamics) ATerm = Amp_[i]*ff_[i]; // Scale this contribution by its relative normalisation w.r.t. the whole dynamics ATerm.rescale(fNorm_[i]); // Add this partial amplitude to the sum totAmp_ += ATerm; } // Loop over amplitudes // |Sum of partial amplitudes|^2 ASq_ = totAmp_.abs2(); for (UInt_t i = 0; i < nIncohAmp_; ++i) { // Get the partial complex amplitude - (mag, phase) ATerm = Amp_[i+nAmp_]; // Scale this contribution by its relative normalisation w.r.t. the whole dynamics ATerm.rescale(fNorm_[i+nAmp_]); // Add this partial amplitude to the sum ASq_ += ATerm.abs2()*incohInten_[i]; } // Apply the efficiency correction for this event. // Multiply the amplitude squared sum by the DP efficiency if ( useEff ) { ASq_ *= eff_; } } void LauIsobarDynamics::addGridPointToIntegrals(const Double_t weight) { // Combine the Gauss-Legendre weight with the efficiency const Double_t effWeight = eff_*weight; LauComplex fifjEffSumTerm; LauComplex fifjSumTerm; // Calculates the half-matrix of amplitude-squared and interference // terms (dynamical part only) // Add the values at this point on the integration grid to the sums // (one weighted only by the integration weights, one also weighted by // the efficiency) for (UInt_t i = 0; i < nAmp_; ++i) { // Add the dynamical amplitude squared for this resonance. Double_t fSqVal = ff_[i].abs2(); fSqSum_[i] += fSqVal*weight; fSqEffSum_[i] += fSqVal*effWeight; for (UInt_t j = i; j < nAmp_; ++j) { fifjEffSumTerm = fifjSumTerm = ff_[i]*ff_[j].conj(); fifjEffSumTerm.rescale(effWeight); fifjEffSum_[i][j] += fifjEffSumTerm; fifjSumTerm.rescale(weight); fifjSum_[i][j] += fifjSumTerm; } } for (UInt_t i = 0; i < nIncohAmp_; ++i) { // Add the dynamical amplitude squared for this resonance. Double_t fSqVal = incohInten_[i]; fSqSum_[i+nAmp_] += fSqVal*weight; fSqEffSum_[i+nAmp_] += fSqVal*effWeight; } } LauComplex LauIsobarDynamics::resAmp(const UInt_t index) { // Routine to calculate the resonance dynamics (amplitude) // using the appropriate Breit-Wigner/Form Factors. LauComplex amp = LauComplex(0.0, 0.0); if ( index >= nAmp_ ) { std::cerr<<"ERROR in LauIsobarDynamics::resAmp : index = "<= nIncohAmp_ ) { std::cerr<<"ERROR in LauIsobarDynamics::setFFTerm : index = "<= nAmp_) { //Set off-diagonal incoherent terms to zero fitFrac_[i][j].value(0.); fitFracEffUnCorr_[i][j].value(0.); continue; } LauComplex AmpjConj = Amp_[j].conj(); LauComplex AmpTerm = Amp_[i]*AmpjConj; Double_t crossTerm = 2.0*(AmpTerm*fifjSum_[i][j]).re()*fNorm_[i]*fNorm_[j]; fifjTot += crossTerm; Double_t crossEffTerm = 2.0*(AmpTerm*fifjEffSum_[i][j]).re()*fNorm_[i]*fNorm_[j]; fifjEffTot += crossEffTerm; fitFrac_[i][j].value(crossTerm); fitFracEffUnCorr_[i][j].value(crossEffTerm); } } for (i = nAmp_; i < nAmp_+nIncohAmp_; i++) { // Calculate the incoherent terms TString name = "A"; name += i; name += "Sq_FitFrac"; fitFrac_[i][i].name(name); name += "EffUnCorr"; fitFracEffUnCorr_[i][i].name(name); Double_t sumTerm = Amp_[i].abs2()*fSqSum_[i]*fNorm_[i]*fNorm_[i]; fifjTot += sumTerm; Double_t sumEffTerm = Amp_[i].abs2()*fSqEffSum_[i]*fNorm_[i]*fNorm_[i]; fifjEffTot += sumEffTerm; fitFrac_[i][i].value(sumTerm); fitFracEffUnCorr_[i][i].value(sumEffTerm); } for (i = nAmp_; i < nAmp_+nIncohAmp_; i++) { for (j = i+1; j < nAmp_+nIncohAmp_; j++) { //Set off-diagonal incoherent terms to zero TString name = "A"; name += i; name += "A"; name += j; name += "_FitFrac"; fitFrac_[i][j].name(name); name += "EffUnCorr"; fitFracEffUnCorr_[i][j].name(name); fitFrac_[i][j].value(0.); fitFracEffUnCorr_[i][j].value(0.); } } if (TMath::Abs(fifjTot) > 1e-10) { meanDPEff_.value(fifjEffTot/fifjTot); if (init) { meanDPEff_.genValue( meanDPEff_.value() ); meanDPEff_.initValue( meanDPEff_.value() ); } } DPRate_.value(fifjTot); if (init) { DPRate_.genValue( DPRate_.value() ); DPRate_.initValue( DPRate_.value() ); } // Now divide the fitFraction sums by the overall integral for (i = 0; i < nAmp_+nIncohAmp_; i++) { for (j = i; j < nAmp_+nIncohAmp_; j++) { // Get the actual fractions by dividing by the total DP rate Double_t fitFracVal = fitFrac_[i][j].value(); fitFracVal /= fifjTot; fitFrac_[i][j].value( fitFracVal ); Double_t fitFracEffUnCorrVal = fitFracEffUnCorr_[i][j].value(); fitFracEffUnCorrVal /= fifjEffTot; fitFracEffUnCorr_[i][j].value( fitFracEffUnCorrVal ); if (init) { fitFrac_[i][j].genValue( fitFrac_[i][j].value() ); fitFrac_[i][j].initValue( fitFrac_[i][j].value() ); fitFracEffUnCorr_[i][j].genValue( fitFracEffUnCorr_[i][j].value() ); fitFracEffUnCorr_[i][j].initValue( fitFracEffUnCorr_[i][j].value() ); } } } // Work out total fit fraction over all K-matrix components (for each propagator) KMPropMap::iterator mapIter; Int_t propInt(0); for (mapIter = kMatrixPropagators_.begin(); mapIter != kMatrixPropagators_.end(); ++mapIter) { LauKMatrixPropagator* thePropagator = mapIter->second; TString propName = thePropagator->getName(); // Now loop over all resonances and find those which are K-matrix components for this propagator Double_t kMatrixTotFitFrac(0.0); for (i = 0; i < nAmp_; i++) { Bool_t gotKMRes1 = this->gotKMatrixMatch(i, propName); if (gotKMRes1 == kFALSE) {continue;} Double_t fifjSumReal = fifjSum_[i][i].re(); Double_t sumTerm = Amp_[i].abs2()*fifjSumReal*fNorm_[i]*fNorm_[i]; //Double_t fifjEffSumReal = fifjEffSum_[i][i].re(); //Double_t sumEffTerm = Amp_[i].abs2()*fifjEffSumReal*fNorm_[i]*fNorm_[i]; kMatrixTotFitFrac += sumTerm; for (j = i+1; j < nAmp_; j++) { Bool_t gotKMRes2 = this->gotKMatrixMatch(j, propName); if (gotKMRes2 == kFALSE) {continue;} LauComplex AmpjConj = Amp_[j].conj(); LauComplex AmpTerm = Amp_[i]*AmpjConj; Double_t crossTerm = 2.0*(AmpTerm*fifjSum_[i][j]).re()*fNorm_[i]*fNorm_[j]; //Double_t crossEffTerm = 2.0*(AmpTerm*fifjEffSum_[i][j]).re()*fNorm_[i]*fNorm_[j]; kMatrixTotFitFrac += crossTerm; } } kMatrixTotFitFrac /= fifjTot; TString parName("KMatrixTotFF_"); parName += propInt; extraParameters_[propInt].name( parName ); extraParameters_[propInt].value(kMatrixTotFitFrac); if (init) { extraParameters_[propInt].genValue(kMatrixTotFitFrac); extraParameters_[propInt].initValue(kMatrixTotFitFrac); } std::cout<<"INFO in LauIsobarDynamics::calcExtraInfo : Total K-matrix fit fraction for propagator "<calculateRhoOmegaFitFractions_ && !init) { int omegaID = 0; int storeID = 1; // Check which B flavour (and therefore which rho_COPY we are) by whether the FF is non-zero // Only for CP fit though - for a 'simple' fit this is more complicated if (fitFrac_[omegaID][omegaID].value() < 1E-4) { omegaID = 1; storeID = 0; } // Check this is really the correct model LauRhoOmegaMix * rhomega = dynamic_cast(getResonance(omegaID)); if (rhomega != NULL) { // Bail out std::cout << "INFO in LauIsobarDynamics::calcExtraInfo : Calculating omega fit fraction from resonance " << omegaID << std::endl; std::cout << "INFO in LauIsobarDynamics::calcExtraInfo : Storing omega fit fraction in resonance " << storeID << std::endl; // Tell the RhoOmegaMix model only to give us the omega amplitude-squared rhomega->setWhichAmpSq(1); // Recalculate the integrals for the omega fit-fraction integralsDone_ = kFALSE; this->resetNormVectors(); for ( UInt_t k(0); k < nAmp_+nIncohAmp_; ++k ) { integralsToBeCalculated_.insert(k); } this->calcDPNormalisation(); integralsDone_ = kTRUE; Double_t fifjSumRealOmega = fifjSum_[omegaID][omegaID].re(); // Recalculate the integrals for the rho fit-fraction rhomega->setWhichAmpSq(2); integralsDone_ = kFALSE; this->resetNormVectors(); for ( UInt_t k(0); k < nAmp_+nIncohAmp_; ++k ) { integralsToBeCalculated_.insert(k); } this->calcDPNormalisation(); integralsDone_ = kTRUE; Double_t fitFracPartRho = Amp_[omegaID].abs2()*fifjSum_[omegaID][omegaID].re(); // Reset the RhoOmegaMix model and the integrals rhomega->setWhichAmpSq(0); integralsDone_ = kFALSE; this->resetNormVectors(); for ( UInt_t k(0); k < nAmp_+nIncohAmp_; ++k ) { integralsToBeCalculated_.insert(k); } this->calcDPNormalisation(); integralsDone_ = kTRUE; // Store the omega fit-fraction in the rho_COPY location (which is otherwise empty) // Store the rho fit-fraction in the rho location (overwriting the combined FF) Double_t omegaFF = fifjSumRealOmega * fitFrac_[omegaID][omegaID].value(); fitFrac_[storeID][storeID].value(omegaFF); fitFrac_[omegaID][omegaID].value(fitFracPartRho * fNorm_[omegaID] * fNorm_[omegaID] / DPRate_.value()); } else { std::cout << "INFO in LauIsobarDynamics::calcExtraInfo : calculateRhoOmegaFitFractions is set, but the RhoOmegaMix model isn't in the right place. Ignoring this option." << std::endl; } } } Bool_t LauIsobarDynamics::gotKMatrixMatch(const UInt_t resAmpInt, const TString& propName) const { Bool_t gotMatch{kFALSE}; if (resAmpInt >= nAmp_) {return kFALSE;} const LauAbsResonance* theResonance { sigResonances_[resAmpInt] }; if (theResonance == nullptr) {return kFALSE;} const LauAbsResonance::ResonanceModel resModel { theResonance->getResonanceModel() }; - if (resModel == LauAbsResonance::ResonanceModel::KMatrix) { + if (resModel == LauAbsResonance::ResonanceModel::KMatrix_Pole || resModel == LauAbsResonance::ResonanceModel::KMatrix_SVP) { const TString resName { theResonance->getResonanceName() }; KMStringMap::const_iterator kMPropSetIter { kMatrixPropSet_.find(resName) }; if ( kMPropSetIter != kMatrixPropSet_.end() ) { const TString kmPropString { kMPropSetIter->second }; if (kmPropString == propName) {gotMatch = kTRUE;} } } return gotMatch; } Double_t LauIsobarDynamics::calcSigDPNorm() { // Calculate the normalisation for the log-likelihood function. DPNorm_ = 0.0; for (UInt_t i = 0; i < nAmp_; i++) { // fifjEffSum is the contribution from the term involving the resonance // dynamics (f_i for resonance i) and the efficiency term. Double_t fifjEffSumReal = fifjEffSum_[i][i].re(); // We need to normalise this contribution w.r.t. the complete dynamics in the DP. // Hence we scale by the fNorm_i factor (squared), which is calculated by the // initialise() function, when the normalisation integrals are calculated and cached. // We also include the complex amplitude squared to get the total normalisation // contribution from this resonance. DPNorm_ += Amp_[i].abs2()*fifjEffSumReal*fNorm_[i]*fNorm_[i]; } // We now come to the cross-terms (between resonances i and j) in the normalisation. for (UInt_t i = 0; i < nAmp_; i++) { for (UInt_t j = i+1; j < nAmp_; j++) { LauComplex AmpjConj = Amp_[j].conj(); LauComplex AmpTerm = Amp_[i]*AmpjConj; // Again, fifjEffSum is the contribution from the term involving the resonance // dynamics (f_i*f_j_conjugate) and the efficiency cross term. // Also include the relative normalisation between these two resonances w.r.t. the // total DP dynamical structure (fNorm_i and fNorm_j) and the complex // amplitude squared (mag,phase) part. DPNorm_ += 2.0*(AmpTerm*fifjEffSum_[i][j]).re()*fNorm_[i]*fNorm_[j]; } } for (UInt_t i = 0; i < nIncohAmp_; i++) { DPNorm_ += Amp_[i+nAmp_].abs2()*fSqEffSum_[i+nAmp_]*fNorm_[i+nAmp_]*fNorm_[i+nAmp_]; } return DPNorm_; } Bool_t LauIsobarDynamics::generate() { // Routine to generate a signal event according to the Dalitz plot // model we have defined. // We need to make sure to calculate everything for every resonance integralsToBeCalculated_.clear(); for ( UInt_t i(0); i < nAmp_+nIncohAmp_; ++i ) { integralsToBeCalculated_.insert(i); } nSigGenLoop_ = 0; Bool_t generatedSig(kFALSE); while (generatedSig == kFALSE && nSigGenLoop_ < iterationsMax_) { // Generates uniform DP phase-space distribution Double_t m13Sq(0.0), m23Sq(0.0); kinematics_->genFlatPhaseSpace(m13Sq, m23Sq); // If we're in a symmetrical DP then we should only generate events in one half // TODO - what do we do for fully symmetric? if ( symmetricalDP_ && !fullySymmetricDP_ && m13Sq > m23Sq ) { Double_t tmpSq = m13Sq; m13Sq = m23Sq; m23Sq = tmpSq; } // Calculate the amplitudes and total amplitude for the given DP point this->calcLikelihoodInfo(m13Sq, m23Sq); // Throw the random number and check it against the ratio of ASq and the accept/reject ceiling const Double_t randNo = LauRandom::randomFun()->Rndm(); if (randNo > ASq_/aSqMaxSet_) { ++nSigGenLoop_; } else { generatedSig = kTRUE; nSigGenLoop_ = 0; // Keep a note of the maximum ASq that we've found if (ASq_ > aSqMaxVar_) {aSqMaxVar_ = ASq_;} } } // while loop // Check that all is well with the generation Bool_t sigGenOK(kTRUE); if (GenOK != this->checkToyMC(kTRUE,kFALSE)) { sigGenOK = kFALSE; } return sigGenOK; } LauIsobarDynamics::ToyMCStatus LauIsobarDynamics::checkToyMC(Bool_t printErrorMessages, Bool_t printInfoMessages) { // Check whether we have generated the toy MC OK. ToyMCStatus ok(GenOK); if (nSigGenLoop_ >= iterationsMax_) { // Exceeded maximum allowed iterations - the generation is too inefficient if (printErrorMessages) { std::cerr<<"WARNING in LauIsobarDynamics::checkToyMC : More than "< 1.01 * aSqMaxVar_ ) { if (printErrorMessages) { std::cerr<<" : |A|^2 maximum was set to "< aSqMaxSet_) { // Found a value of ASq higher than the accept/reject ceiling - the generation is biased if (printErrorMessages) { std::cerr<<"WARNING in LauIsobarDynamics::checkToyMC : |A|^2 maximum was set to "< "<= "<retrievem13Sq(); m23Sq_ = currentEvent_->retrievem23Sq(); mPrime_ = currentEvent_->retrievemPrime(); thPrime_ = currentEvent_->retrievethPrime(); tagCat_ = currentEvent_->retrieveTagCat(); eff_ = currentEvent_->retrieveEff(); scfFraction_ = currentEvent_->retrieveScfFraction(); // These two are necessary, even though the dynamics don't actually use scfFraction_ or jacobian_, jacobian_ = currentEvent_->retrieveJacobian(); // since this is at the heart of the caching mechanism. } void LauIsobarDynamics::calcLikelihoodInfo(const UInt_t iEvt) { // Calculate the likelihood and associated info // for the given event using cached information evtLike_ = 0.0; // retrieve the cached dynamics from the tree: // realAmp, imagAmp for each resonance plus efficiency, scf fraction and jacobian this->setDataEventNo(iEvt); // use realAmp and imagAmp to create the resonance amplitudes const std::vector& realAmp = currentEvent_->retrieveRealAmp(); const std::vector& imagAmp = currentEvent_->retrieveImagAmp(); const std::vector& incohInten = currentEvent_->retrieveIncohIntensities(); for (UInt_t i = 0; i < nAmp_; i++) { this->setFFTerm(i, realAmp[i], imagAmp[i]); } for (UInt_t i = 0; i < nIncohAmp_; i++) { this->setIncohIntenTerm(i, incohInten[i]); } // Update the dynamics - calculates totAmp_ and then ASq_ = totAmp_.abs2() * eff_ // All calculated using cached information on the individual amplitudes and efficiency. this->calcTotalAmp(kTRUE); // Calculate the normalised matrix element squared value if (DPNorm_ > 1e-10) { evtLike_ = ASq_/DPNorm_; } } void LauIsobarDynamics::calcLikelihoodInfo(const Double_t m13Sq, const Double_t m23Sq) { this->calcLikelihoodInfo(m13Sq, m23Sq, -1); } void LauIsobarDynamics::calcLikelihoodInfo(const Double_t m13Sq, const Double_t m23Sq, const Int_t tagCat) { // Calculate the likelihood and associated info // for the given point in the Dalitz plot // Also retrieves the SCF fraction in the bin where the event lies (done // here to cache it along with the the rest of the DP quantities, like eff) // The jacobian for the square DP is calculated here for the same reason. evtLike_ = 0.0; // update the kinematics for the specified DP point kinematics_->updateKinematics(m13Sq, m23Sq); // calculate the jacobian and the scfFraction to cache them later scfFraction_ = this->retrieveScfFraction(tagCat); if (kinematics_->squareDP() == kTRUE) { jacobian_ = kinematics_->calcSqDPJacobian(); } // calculate the ff_ terms and retrieves eff_ from the efficiency model this->calculateAmplitudes(); // then calculate totAmp_ and finally ASq_ = totAmp_.abs2() * eff_ this->calcTotalAmp(kTRUE); // Calculate the normalised matrix element squared value if (DPNorm_ > 1e-10) { evtLike_ = ASq_/DPNorm_; } } void LauIsobarDynamics::modifyDataTree() { if ( recalcNormalisation_ == kFALSE ) { return; } const UInt_t nEvents = data_.size(); std::set::const_iterator iter = integralsToBeCalculated_.begin(); const std::set::const_iterator intEnd = integralsToBeCalculated_.end(); for (UInt_t iEvt = 0; iEvt < nEvents; ++iEvt) { currentEvent_ = data_[iEvt]; std::vector& realAmp = currentEvent_->retrieveRealAmp(); std::vector& imagAmp = currentEvent_->retrieveImagAmp(); std::vector& incohInten = currentEvent_->retrieveIncohIntensities(); const Double_t m13Sq = currentEvent_->retrievem13Sq(); const Double_t m23Sq = currentEvent_->retrievem23Sq(); const Int_t tagCat = currentEvent_->retrieveTagCat(); this->calcLikelihoodInfo(m13Sq, m23Sq, tagCat); for ( iter = integralsToBeCalculated_.begin(); iter != intEnd; ++iter) { const UInt_t i = *iter; if(*iter < nAmp_) { realAmp[i] = ff_[i].re(); imagAmp[i] = ff_[i].im(); } else { incohInten[i-nAmp_] = incohInten_[i-nAmp_]; } } } } void LauIsobarDynamics::fillDataTree(const LauFitDataTree& inputFitTree) { // In LauFitDataTree, the first two variables should always be m13^2 and m23^2. // Other variables follow thus: charge/flavour tag prob, etc. // Since this is the first caching, we need to make sure to calculate everything for every resonance integralsToBeCalculated_.clear(); for ( UInt_t i(0); i < nAmp_+nIncohAmp_; ++i ) { integralsToBeCalculated_.insert(i); } UInt_t nBranches = inputFitTree.nBranches(); if (nBranches < 2) { std::cerr<<"ERROR in LauIsobarDynamics::fillDataTree : Expecting at least 2 variables " <<"in input data tree, but there are "<Exit(EXIT_FAILURE); } // Data structure that will cache the variables required to // calculate the signal likelihood for this experiment for ( std::vector::iterator iter = data_.begin(); iter != data_.end(); ++iter ) { delete (*iter); } data_.clear(); Double_t m13Sq(0.0), m23Sq(0.0); Double_t mPrime(0.0), thPrime(0.0); Int_t tagCat(-1); std::vector realAmp(nAmp_), imagAmp(nAmp_); Double_t eff(0.0), scfFraction(0.0), jacobian(0.0); UInt_t nEvents = inputFitTree.nEvents() + inputFitTree.nFakeEvents(); data_.reserve(nEvents); for (UInt_t iEvt = 0; iEvt < nEvents; ++iEvt) { const LauFitData& dataValues = inputFitTree.getData(iEvt); LauFitData::const_iterator iter = dataValues.find("m13Sq"); m13Sq = iter->second; iter = dataValues.find("m23Sq"); m23Sq = iter->second; // is there more than one tagging category? // if so then we need to know the category from the data if (scfFractionModel_.size()>1) { iter = dataValues.find("tagCat"); tagCat = static_cast(iter->second); } // calculates the amplitudes and total amplitude for the given DP point // tagging category not needed by dynamics, but to find out the scfFraction this->calcLikelihoodInfo(m13Sq, m23Sq, tagCat); // extract the real and imaginary parts of the ff_ terms for storage for (UInt_t i = 0; i < nAmp_; i++) { realAmp[i] = ff_[i].re(); imagAmp[i] = ff_[i].im(); } if ( kinematics_->squareDP() ) { mPrime = kinematics_->getmPrime(); thPrime = kinematics_->getThetaPrime(); } eff = this->getEvtEff(); scfFraction = this->getEvtScfFraction(); jacobian = this->getEvtJacobian(); // store the data for each event in the list data_.push_back( new LauCacheData() ); data_[iEvt]->storem13Sq(m13Sq); data_[iEvt]->storem23Sq(m23Sq); data_[iEvt]->storemPrime(mPrime); data_[iEvt]->storethPrime(thPrime); data_[iEvt]->storeTagCat(tagCat); data_[iEvt]->storeEff(eff); data_[iEvt]->storeScfFraction(scfFraction); data_[iEvt]->storeJacobian(jacobian); data_[iEvt]->storeRealAmp(realAmp); data_[iEvt]->storeImagAmp(imagAmp); data_[iEvt]->storeIncohIntensities(incohInten_); } } Bool_t LauIsobarDynamics::gotReweightedEvent() { // Select the event (kinematics_) using an accept/reject method based on the // ratio of the current value of ASq to the maximal value. Bool_t accepted(kFALSE); // calculate the ff_ terms and retrieves eff_ from the efficiency model this->calculateAmplitudes(); // then calculate totAmp_ and finally ASq_ = totAmp_.abs2() (without the efficiency correction!) this->calcTotalAmp(kFALSE); // Compare the ASq value with the maximal value (set by the user) if (LauRandom::randomFun()->Rndm() < ASq_/aSqMaxSet_) { accepted = kTRUE; } if (ASq_ > aSqMaxVar_) {aSqMaxVar_ = ASq_;} return accepted; } Double_t LauIsobarDynamics::getEventWeight() { // calculate the ff_ terms and retrieves eff_ from the efficiency model this->calculateAmplitudes(); // then calculate totAmp_ and finally ASq_ = totAmp_.abs2() (without the efficiency correction!) this->calcTotalAmp(kFALSE); // return the event weight = the value of the squared amplitude return ASq_; } void LauIsobarDynamics::updateCoeffs(const std::vector& coeffs) { // Check that the number of coeffs is correct if (coeffs.size() != this->getnTotAmp()) { std::cerr << "ERROR in LauIsobarDynamics::updateCoeffs : Expected " << this->getnTotAmp() << " but got " << coeffs.size() << std::endl; gSystem->Exit(EXIT_FAILURE); } // Now check if the coeffs have changed Bool_t changed = (Amp_ != coeffs); if (changed) { // Copy the coeffs Amp_ = coeffs; } // TODO should perhaps keep track of whether the resonance parameters have changed here and if none of those and none of the coeffs have changed then we don't need to update the norm // Update the total normalisation for the signal likelihood this->calcSigDPNorm(); } TString LauIsobarDynamics::getConjResName(const TString& resName) const { // Get the name of the charge conjugate resonance TString conjName(resName); Ssiz_t index1 = resName.Index("+"); Ssiz_t index2 = resName.Index("-"); if (index1 != -1) { conjName.Replace(index1, 1, "-"); } else if (index2 != -1) { conjName.Replace(index2, 1, "+"); } return conjName; } Double_t LauIsobarDynamics::retrieveEfficiency() { Double_t eff(1.0); if (effModel_ != 0) { eff = effModel_->calcEfficiency(kinematics_); } return eff; } Double_t LauIsobarDynamics::retrieveScfFraction(Int_t tagCat) { Double_t scfFraction(0.0); // scf model and eff model are exactly the same, functionally // so we use an instance of LauAbsEffModel, and the method // calcEfficiency actually calculates the scf fraction if (tagCat == -1) { if (!scfFractionModel_.empty()) { scfFraction = scfFractionModel_[0]->calcEfficiency(kinematics_); } } else { scfFraction = scfFractionModel_[tagCat]->calcEfficiency(kinematics_); } return scfFraction; } diff --git a/src/LauJsonTools.cc b/src/LauJsonTools.cc index 0dec575..ce2e808 100644 --- a/src/LauJsonTools.cc +++ b/src/LauJsonTools.cc @@ -1,162 +1,186 @@ /* Copyright 2023 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauJsonTools.cc \brief File containing implementation of functions in the LauJsonTools namespace */ #include "LauJsonTools.hh" #include #include #include #include nlohmann::json LauJsonTools::readJsonFile(const std::string& fileName, const std::string& elementName, const JsonType expectedType) { // load the JSON from the file std::ifstream in{ fileName }; if ( ! in ) { std::cerr << "ERROR in LauJsonTools::readJsonFile : unable to open file \"" << fileName << "\"" << std::endl; return {}; } // NB deliberately not using uniform initialisation here because of this issue: // https://json.nlohmann.me/home/faq/#brace-initialization-yields-arrays nlohmann::json j = nlohmann::json::parse(in); // optionally retrieve a particular element, otherwise just stick with the root structure if ( ! elementName.empty() ) { if ( ! j.is_object() ) { std::cerr << "ERROR in LauJsonTools::readJsonFile : root structure in JSON file \"" << fileName << "\" is not an object, so cannot retrieve the specified element \"" << elementName << "\"" << std::endl; return {}; } if ( ! j.contains( elementName ) ) { std::cerr << "ERROR in LauJsonTools::readJsonFile : root object in JSON file \"" << fileName << "\" does not contain specified element \"" << elementName << "\"" << std::endl; return {}; } j = j.at( elementName ); } // check type is as expected if ( ! checkValueType( j, expectedType ) ) { if ( ! elementName.empty() ) { std::cerr << "ERROR in LauJsonTools::readJsonFile : element \"" << elementName << "\" of JSON file \"" << fileName << "\" is not expected type" << std::endl; } else { std::cerr << "ERROR in LauJsonTools::readJsonFile : root element of JSON file \"" << fileName << "\" is not expected type" << std::endl; } return {}; } return j; } -bool LauJsonTools::writeJsonFile(const std::string& fileName, const nlohmann::json& value, const int indent) +bool LauJsonTools::writeJsonFile(const nlohmann::json& value, const std::string& fileName, const std::string& elementName, const bool append, const int indent) { + // if appending we must have a name, so check that first + if ( append && elementName.empty() ) { + std::cerr << "ERROR in LauJsonTools::writeJsonFile : when appending to a file it is mandatory to supply a name for the new element" << std::endl; + return false; + } + + // initialise an empty JSON value + nlohmann::json j; + + // if we're appending, we need to first load in the exising JSON from the file, which must be an object + if ( append ) { + j = readJsonFile( fileName, "", LauJsonTools::JsonType::Object ); + if ( j.is_null() ) { + std::cerr << "ERROR in LauJsonTools::writeJsonFile : could not open file \"" << fileName << "\" for initial reading" << std::endl; + return false; + } + } + + if ( elementName.empty() ) { + j = value; + } else { + j[ elementName ] = value; + } + std::ofstream out{fileName, std::ios_base::out}; - if ( not out ) { - std::cerr << "ERROR in LauJsonTools::writeJsonFile : couldn't open file \"" << fileName << "\" for writing. No file will be written!" << std::endl; + if ( ! out ) { + std::cerr << "ERROR in LauJsonTools::writeJsonFile : could not open file \"" << fileName << "\" for writing. No file will be written!" << std::endl; return false; } - out << value.dump(indent); + out << j.dump(indent); out << std::endl; out.close(); return true; } bool LauJsonTools::checkValueType(const nlohmann::json& value, const JsonType expectedType) { switch ( expectedType ) { case JsonType::Null : return value.is_null(); case JsonType::Object : return value.is_object(); case JsonType::Array : return value.is_array(); case JsonType::String : return value.is_string(); case JsonType::Boolean : return value.is_boolean(); case JsonType::Number_Integer : return value.is_number_integer(); case JsonType::Number_Unsigned : return value.is_number_unsigned(); case JsonType::Number_Float : return value.is_number_float(); case JsonType::Number : return value.is_number(); case JsonType::Primitive : return value.is_primitive(); case JsonType::Structured : return value.is_structured(); case JsonType::Any : return true; } return false; } bool LauJsonTools::checkObjectElements( const nlohmann::json& j, const std::vector& expectedElements ) { if ( ! j.is_object() ) { std::cerr << "ERROR in LauJsonTools::checkObjectElements : supplied JSON value is not an object" << std::endl; } bool allElementsOK{ true }; for ( const auto& [ name, type ] : expectedElements ) { if ( ! j.contains( name ) ) { std::cerr << "ERROR in LauJsonTools::checkObjectElements : JSON object does not contain required element: " << name << std::endl; allElementsOK = false; continue; } else if ( ! checkValueType( j.at( name ), type ) ) { std::cerr << "ERROR in LauJsonTools::checkObjectElements : JSON object does not contain required type for element: " << name << std::endl; allElementsOK = false; continue; } } return allElementsOK; } const nlohmann::json* LauJsonTools::getOptionalElement( const nlohmann::json& obj, const std::string& elementName, const JsonType expectedType ) { if ( ! obj.contains( elementName ) ) { return nullptr; } const nlohmann::json& elem { obj.at( elementName ) }; if ( ! checkValueType( elem, expectedType ) ) { std::cerr << "WARNING in LauJsonTools::getOptionalElement : element \"" << elementName << "\" exists within the supplied object but it is not of the expected type - therefore it will not be returned" << std::endl; return nullptr; } return &elem; } diff --git a/src/LauKMatrixProdPole.cc b/src/LauKMatrixProdPole.cc index ef118b2..3914453 100644 --- a/src/LauKMatrixProdPole.cc +++ b/src/LauKMatrixProdPole.cc @@ -1,168 +1,183 @@ /* Copyright 2008 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauKMatrixProdPole.cc \brief File containing implementation of LauKMatrixProdPole class. */ #include "LauKMatrixProdPole.hh" #include "LauKMatrixPropagator.hh" #include "LauResonanceMaker.hh" #include ClassImp(LauKMatrixProdPole) LauKMatrixProdPole::LauKMatrixProdPole( const TString& poleName, Int_t poleIndex, Int_t resPairAmpInt, LauKMatrixPropagator* propagator, const LauDaughters* daughters, Bool_t useProdAdler) : - LauAbsResonance( poleName, resPairAmpInt, daughters, propagator->getL(propagator->getIndex()) ), + LauAbsKMatrixProdComp( poleName, resPairAmpInt, daughters, propagator->getL(propagator->getIndex()) ), thePropagator_(propagator), poleIndex_(poleIndex - 1), // poleIndex goes from 1 to nPoles useProdAdler_(useProdAdler) { if (useProdAdler_) { std::cout <<"Creating K matrix production pole "<setBarrierRadii( nullptr,LauResonanceMaker::get().getParentBWFactor( propagator->getL(propagator->getIndex()), LauBlattWeisskopfFactor::BarrierType::BWBarrier ) ); } LauKMatrixProdPole::~LauKMatrixProdPole() { } LauComplex LauKMatrixProdPole::resAmp(const Double_t mass, const Double_t spinTerm) { // Calculate the amplitude for the K-matrix production pole. LauComplex amp(0.0, 0.0); if (thePropagator_ == 0) { std::cerr << "ERROR in LauKMatrixProdPole::amplitude : The propagator is null" << std::endl; return amp; } // Get barrier factors ('resonance' factor is already accounted for internally via propagator 'Gamma' matrix) Double_t fFactorB(1.0); const Int_t resSpin = this->getSpin(); const Double_t pstar = this->getPstar(); if ( resSpin > 0 ) { const LauBlattWeisskopfFactor* parBWFactor = this->getParBWFactor(); if ( parBWFactor != nullptr ) { switch ( parBWFactor->getRestFrame() ) { case LauBlattWeisskopfFactor::RestFrame::ResonanceFrame: fFactorB = parBWFactor->calcFormFactor(this->getP()); break; case LauBlattWeisskopfFactor::RestFrame::ParentFrame: fFactorB = parBWFactor->calcFormFactor(pstar); break; case LauBlattWeisskopfFactor::RestFrame::Covariant: { Double_t covFactor = this->getCovFactor(); if ( resSpin > 2 ) { covFactor = TMath::Power( covFactor, 1.0/resSpin ); } else if ( resSpin == 2 ) { covFactor = TMath::Sqrt( covFactor ); } fFactorB = parBWFactor->calcFormFactor(pstar*covFactor); break; } } } } // Make sure the K-matrix propagator is up-to-date for // the given centre-of-mass squared value ("s") thePropagator_->updatePropagator(mass*mass); // Sum the pole denominator terms over all channels j, multiplying by // the propagator terms. Note that we do not sum over poles, since we // only want one of the production pole terms. Int_t nChannels = thePropagator_->getNChannels(); Int_t jChannel; for (jChannel = 0; jChannel < nChannels; jChannel++) { Double_t gj = thePropagator_->getCouplingConstant(poleIndex_, jChannel); LauComplex prodTerm = thePropagator_->getPropTerm(jChannel); prodTerm.rescale(gj); amp += prodTerm; } Double_t poleDenom = thePropagator_->getPoleDenomTerm(poleIndex_); // Include Adler zero factor if requested Double_t adlerZero(1.0); if (useProdAdler_) {adlerZero = thePropagator_->getAdlerZero();} amp.rescale(poleDenom*adlerZero); // Scale by the spin term Double_t scale = spinTerm; // Include Blatt-Weisskopf barrier factor for parent scale *= fFactorB; amp.rescale(scale); return amp; } const std::vector& LauKMatrixProdPole::getFloatingParameters() { this->clearFloatingParameters(); Int_t nChannels = thePropagator_->getNChannels(); for (int jChannel = 0 ; jChannel < nChannels ; jChannel++) { LauParameter& par_gj_ = thePropagator_->getCouplingParameter(poleIndex_, jChannel); if ( !par_gj_.fixed() ) { this->addFloatingParameter( &par_gj_ ); } } LauParameter& par_polemasssq_ = thePropagator_->getPoleMassSqParameter(poleIndex_); if ( !par_polemasssq_.fixed() ) { this->addFloatingParameter( &par_polemasssq_ ); } return this->getParameters(); } + +nlohmann::json LauKMatrixProdPole::writeSettingsToJson() const +{ + using nlohmann::json; + + json j = json::object(); + + j[ "poleName" ] = this->getResonanceName().Data(); + j[ "poleIndex" ] = poleIndex_+1; + if ( useProdAdler_ ) { + j[ "useProdAdler" ] = true; + } + + return j; +} diff --git a/src/LauKMatrixProdSVP.cc b/src/LauKMatrixProdSVP.cc index b597bdf..0023506 100644 --- a/src/LauKMatrixProdSVP.cc +++ b/src/LauKMatrixProdSVP.cc @@ -1,177 +1,192 @@ /* Copyright 2008 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauKMatrixProdSVP.cc \brief File containing implementation of LauKMatrixProdSVP class. */ #include "LauKMatrixProdSVP.hh" #include "LauKMatrixPropagator.hh" #include ClassImp(LauKMatrixProdSVP) LauKMatrixProdSVP::LauKMatrixProdSVP( const TString& SVPName, Int_t channelIndex, Int_t resPairAmpInt, LauKMatrixPropagator* propagator, const LauDaughters* daughters, Bool_t useProdAdler) : - LauAbsResonance( SVPName, resPairAmpInt, daughters, propagator->getL(propagator->getIndex()) ), + LauAbsKMatrixProdComp( SVPName, resPairAmpInt, daughters, propagator->getL(propagator->getIndex()) ), thePropagator_(propagator), channelIndex_(channelIndex - 1), // channelIndex goes from 1 to nChannels. useProdAdler_(useProdAdler) { // Constructor if (useProdAdler_) { std::cout <<"Creating K matrix production SVP "<getSpin(); const Double_t pstar = this->getPstar(); if ( resSpin > 0 ) { const LauBlattWeisskopfFactor* parBWFactor = this->getParBWFactor(); if ( parBWFactor != nullptr ) { switch ( parBWFactor->getRestFrame() ) { case LauBlattWeisskopfFactor::RestFrame::ResonanceFrame: fFactorB = parBWFactor->calcFormFactor(this->getP()); break; case LauBlattWeisskopfFactor::RestFrame::ParentFrame: fFactorB = parBWFactor->calcFormFactor(pstar); break; case LauBlattWeisskopfFactor::RestFrame::Covariant: { Double_t covFactor = this->getCovFactor(); if ( resSpin > 2 ) { covFactor = TMath::Power( covFactor, 1.0/resSpin ); } else if ( resSpin == 2 ) { covFactor = TMath::Sqrt( covFactor ); } fFactorB = parBWFactor->calcFormFactor(pstar*covFactor); break; } } } } thePropagator_->updatePropagator(mass*mass); Double_t SVPTerm = thePropagator_->getProdSVPTerm(); amp = thePropagator_->getPropTerm(channelIndex_); // Include Adler zero factor if requested Double_t adlerZero(1.0); if (useProdAdler_) {adlerZero = thePropagator_->getAdlerZero();} amp.rescale(SVPTerm*adlerZero); // Scale by the spin term Double_t scale = spinTerm; // Include Blatt-Weisskopf barrier factor for parent scale *= fFactorB; amp.rescale(scale); return amp; } const std::vector& LauKMatrixProdSVP::getFloatingParameters() { this->clearFloatingParameters(); Int_t nChannels = thePropagator_->getNChannels(); for (int jChannel = 0 ; jChannel < nChannels ; jChannel++) { LauParameter& par_f_ = thePropagator_->getScatteringParameter(channelIndex_, jChannel); if ( !par_f_.fixed() ) { this->addFloatingParameter( &par_f_ ); } } LauParameter& par_mSq0_ = thePropagator_->getmSq0(); if ( !par_mSq0_.fixed() ) { this->addFloatingParameter( &par_mSq0_ ); } LauParameter& par_s0Scatt_ = thePropagator_->gets0Scatt(); if ( !par_s0Scatt_.fixed() ) { this->addFloatingParameter( &par_s0Scatt_ ); } LauParameter& par_s0Prod_ = thePropagator_->gets0Prod(); if ( !par_s0Prod_.fixed() ) { this->addFloatingParameter( &par_s0Prod_ ); } LauParameter& par_sA_ = thePropagator_->getsA(); if ( !par_sA_.fixed() ) { this->addFloatingParameter( &par_sA_ ); } LauParameter& par_sA0_ = thePropagator_->getsA0(); if ( !par_sA0_.fixed() ) { this->addFloatingParameter( &par_sA0_ ); } return this->getParameters(); } + +nlohmann::json LauKMatrixProdSVP::writeSettingsToJson() const +{ + using nlohmann::json; + + json j = json::object(); + + j[ "svpName" ] = this->getResonanceName().Data(); + j[ "channelIndex" ] = channelIndex_+1; + if ( useProdAdler_ ) { + j[ "useProdAdler" ] = true; + } + + return j; +} diff --git a/src/LauKMatrixPropagator.cc b/src/LauKMatrixPropagator.cc index 0955961..511bd03 100644 --- a/src/LauKMatrixPropagator.cc +++ b/src/LauKMatrixPropagator.cc @@ -1,1425 +1,1447 @@ /* Copyright 2008 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauKMatrixPropagator.cc \brief File containing implementation of LauKMatrixPropagator class. */ #include "LauKMatrixPropagator.hh" #include "LauTextFileParser.hh" #include "LauKinematics.hh" #include "LauComplex.hh" #include "TMath.h" #include "TSystem.h" +#include + #include #include #include #include using std::cout; using std::endl; using std::cerr; ClassImp(LauKMatrixPropagator) LauKMatrixPropagator::LauKMatrixPropagator(const TString& name, const TString& paramFile, Int_t resPairAmpInt, Int_t nChannels, Int_t nPoles, Int_t rowIndex) : name_(name), paramFileName_(paramFile), resPairAmpInt_(resPairAmpInt), index_(rowIndex - 1), nChannels_(nChannels), nPoles_(nPoles) { // Constructor // Check that the index is OK if (index_ < 0 || index_ >= nChannels_) { std::cerr << "ERROR in LauKMatrixPropagator constructor. The rowIndex, which is set to " << rowIndex << ", must be between 1 and the number of channels " << nChannels_ << std::endl; gSystem->Exit(EXIT_FAILURE); } this->setParameters(paramFile); } LauKMatrixPropagator::~LauKMatrixPropagator() { // Destructor realProp_.Clear(); negImagProp_.Clear(); ScattKMatrix_.Clear(); ReRhoMatrix_.Clear(); ImRhoMatrix_.Clear(); GammaMatrix_.Clear(); ReTMatrix_.Clear(); ImTMatrix_.Clear(); IMatrix_.Clear(); zeroMatrix_.Clear(); } LauComplex LauKMatrixPropagator::getPropTerm(const Int_t channel) const { // Get the (i,j) = (index_, channel) term of the propagator // matrix. This allows us not to return the full propagator matrix. Double_t realTerm = this->getRealPropTerm(channel); Double_t imagTerm = this->getImagPropTerm(channel); LauComplex propTerm(realTerm, imagTerm); return propTerm; } Double_t LauKMatrixPropagator::getRealPropTerm(const Int_t channel) const { // Get the real part of the (i,j) = (index_, channel) term of the propagator // matrix. This allows us not to return the full propagator matrix. if (parametersSet_ == kFALSE) {return 0.0;} Double_t propTerm = realProp_[index_][channel]; return propTerm; } Double_t LauKMatrixPropagator::getImagPropTerm(const Int_t channel) const { // Get the imaginary part of the (i,j) = (index_, channel) term of the propagator // matrix. This allows us not to return the full propagator matrix. if (parametersSet_ == kFALSE) {return 0.0;} Double_t imagTerm = -1.0*negImagProp_[index_][channel]; return imagTerm; } void LauKMatrixPropagator::updatePropagator(const Double_t s) { // Calculate the K-matrix propagator for the given s value. // The K-matrix amplitude is given by // T_i = sum_{ij} (I - iK*rho)^-1 * P_j, where P is the production K-matrix. // i = index for the state (e.g. S-wave index = 0). // Here, we only find the (I - iK*rho)^-1 matrix part. // Check if we have almost the same s value as before. If so, don't re-calculate // the propagator nor any of the pole mass summation terms. if (TMath::Abs(s - previousS_) < 1e-6*s) { //cout<<"Already got propagator for s = "<calcPoleDenomVect(s); this->updateAdlerZeroFactor(s); // Calculate the scattering K-matrix (real and symmetric) this->calcScattKMatrix(s); // Calculate the phase space density matrix, which is diagonal, but can be complex // if the quantity s is below various threshold values (analytic continuation). this->calcRhoMatrix(s); // Calculate the angular momentum barrier matrix, which is real and diagonal this->calcGammaMatrix(s); // Calculate K*rho*(gamma^2) (real and imaginary parts, since rho can be complex) TMatrixD GammaMatrixSq = (GammaMatrix_*GammaMatrix_); TMatrixD K_realRhoGammaSq(ScattKMatrix_); K_realRhoGammaSq *= ReRhoMatrix_; K_realRhoGammaSq *= GammaMatrixSq; TMatrixD K_imagRhoGammaSq(ScattKMatrix_); K_imagRhoGammaSq *= ImRhoMatrix_; K_imagRhoGammaSq *= GammaMatrixSq; // A = I + K*Imag(rho)Gamma^2, B = -K*Real(Rho)Gamma^2 // Calculate C and D matrices such that (A + iB)*(C + iD) = I, // ie. C + iD = (I - i K*rhoGamma^2)^-1, separated into real and imaginary parts. // realProp C = (A + B A^-1 B)^-1, imagProp D = -A^-1 B C TMatrixD A(IMatrix_); A += K_imagRhoGammaSq; TMatrixD B(zeroMatrix_); B -= K_realRhoGammaSq; TMatrixD invA(TMatrixD::kInverted, A); TMatrixD invA_B(invA); invA_B *= B; TMatrixD B_invA_B(B); B_invA_B *= invA_B; TMatrixD invC(A); invC += B_invA_B; // Set the real part of the propagator matrix ("C") realProp_ = TMatrixD(TMatrixD::kInverted, invC); // Set the (negative) imaginary part of the propagator matrix ("-D") TMatrixD BC(B); BC *= realProp_; negImagProp_ = TMatrixD(invA); negImagProp_ *= BC; // Pre-multiply by the Gamma matrix: realProp_ = GammaMatrix_ * realProp_; negImagProp_ = GammaMatrix_ * negImagProp_; if(verbose_) { std::cout << "In LauKMatrixPropagator::updatePropagator(s). D[1-iKrhoD^2]^-1: " << std::endl; TString realOutput("Real part:"), imagOutput("Imag part:"); for (int iChannel = 0; iChannel < nChannels_; iChannel++) { for (int jChannel = 0; jChannel < nChannels_; jChannel++) { realOutput += Form("\t%.6f",realProp_[iChannel][jChannel]); imagOutput += Form("\t%.6f",-1*negImagProp_[iChannel][jChannel]); } realOutput += "\n "; imagOutput += "\n "; } std::cout << realOutput << std::endl; std::cout << imagOutput << std::endl; } // Also calculate the production SVP term, since this uses Adler-zero parameters // defined in the parameter file. this->updateProdSVPTerm(s); // Finally, keep track of the value of s we just used. previousS_ = s; } void LauKMatrixPropagator::setParameters(const TString& inputFile) { // Read an input file that specifies the values of the coupling constants g_i for // the given number of poles and their (bare) masses. Also provided are the f_{ab} // slow-varying constants. The input file should also provide the Adler zero // constants s_0, s_A and s_A0. parametersSet_ = kFALSE; cout<<"Initialising K-matrix propagator "<Exit(EXIT_FAILURE); } UInt_t iLine(0); for (iLine = 1; iLine <= nTotLines; iLine++) { // Get the line of strings std::vector theLine = readFile.getLine(iLine); // There should always be at least two strings: a keyword and at least 1 value if (theLine.size() < 2) {continue;} TString keyword(theLine[0].c_str()); keyword.ToLower(); // Use lowercase if (!keyword.CompareTo("channels")) { // Channel indices for phase-space factors this->storeChannels(theLine); } else if (!keyword.CompareTo("pole")) { // Pole terms this->storePole(theLine); } else if (!keyword.CompareTo("scatt")) { // Scattering terms this->storeScattering(theLine); } else if (!keyword.CompareTo("angularmomentum")) { // Orbital angular momentum state for each channel & set default a values if called before storeBarrierFactorParameter this->storeOrbitalAngularMomenta(theLine, a); } else if (!keyword.CompareTo("barrierfactorparameter")) { // Value of parameter "a" in denominator of centrifugal barrier factor, gamma this->storeBarrierFactorParameter(theLine, a); } else if (!keyword.CompareTo("radii")) { // Values of characteristic radius this->storeRadii(theLine); } else { // Usually Adler-zero constants TString parString(theLine[1].c_str()); this->storeParameter(keyword, parString); } } sAConst_ = 0.5*sA_.unblindValue()*LauConstants::mPiSq; // Symmetrise scattering parameters if enabled if (scattSymmetry_ == kTRUE) { for (Int_t iChannel = 0; iChannel < nChannels_; iChannel++) { for (Int_t jChannel = iChannel; jChannel < nChannels_; jChannel++) { LauParameter fPar = fScattering_[iChannel][jChannel]; fScattering_[jChannel][iChannel] = LauParameter(fPar); } } } // Now that radii and barrier-factor-denominator parameters have been set, cache the value of "a/(R*R)" for (Int_t iChannel = 0; iChannel < nChannels_; iChannel++) { gamAInvRadSq_[iChannel] = a[iChannel]/(radii_[iChannel]*radii_[iChannel]); } // All required parameters have been set parametersSet_ = kTRUE; cout<<"Finished initialising K-matrix propagator "< >. // Set their sizes using the number of poles and channels defined in the constructor gCouplings_.clear(); gCouplings_.resize(nPoles_); for (Int_t iPole = 0; iPole < nPoles_; iPole++) { gCouplings_[iPole].resize(nChannels_); } fScattering_.clear(); fScattering_.resize(nChannels_); for (Int_t iChannel = 0; iChannel < nChannels_; iChannel++) { fScattering_[iChannel].resize(nChannels_); } // Clear other vectors phaseSpaceTypes_.clear(); phaseSpaceTypes_.resize(nChannels_); mSqPoles_.clear(); mSqPoles_.resize(nPoles_); haveCalled_storeBarrierFactorParameter = kFALSE; } void LauKMatrixPropagator::storeChannels(const std::vector& theLine) { // Get the list of channel indices to specify what phase space factors should be used // e.g. pipi, Kpi, eta eta', 4pi etc.. // Check that the line has nChannels_+1 strings Int_t nTypes = static_cast(theLine.size()) - 1; if (nTypes != nChannels_) { cerr<<"Error in LauKMatrixPropagator::storeChannels. The input file defines " <checkPhaseSpaceType(phaseSpaceInt); if (checkChannel == kTRUE) { cout<<"Adding phase space channel index "<(phaseSpaceInt); } else { cerr<<"Phase space channel index "<(LauKMatrixPropagator::KMatrixChannels::TotChannels)-1<& theLine) { // Store the pole mass and its coupling constants for each channel. // Each line will contain: Pole poleNumber poleMass poleCouplingsPerChannel // Check that the line has nChannels_ + 3 strings Int_t nWords = static_cast(theLine.size()); Int_t nExpect = nChannels_ + 3; if (nWords == nExpect) { Int_t poleIndex = std::atoi(theLine[1].c_str()) - 1; if (poleIndex >= 0 && poleIndex < nPoles_) { Double_t poleMass = std::atof(theLine[2].c_str()); Double_t poleMassSq = poleMass*poleMass; LauParameter mPoleParam(Form("KM_%s_poleMassSq_%i",name_.Data(),poleIndex),poleMassSq); mSqPoles_[poleIndex] = mPoleParam; cout<<"Added bare pole mass "<& theLine) { // Store the scattering constants (along one of the channel rows). // Each line will contain: Scatt ScattIndex ScattConstantsPerChannel // Check that the line has nChannels_ + 2 strings Int_t nWords = static_cast(theLine.size()); Int_t nExpect = nChannels_ + 2; if (nWords == nExpect) { Int_t scattIndex = std::atoi(theLine[1].c_str()) - 1; if (scattIndex >= 0 && scattIndex < nChannels_) { for (Int_t iChannel = 0; iChannel < nChannels_; iChannel++) { Double_t scattConst = std::atof(theLine[iChannel+2].c_str()); LauParameter scattParam(Form("KM_%s_fScatteringConst_%i_%i",name_.Data(),scattIndex,iChannel),scattConst); fScattering_[scattIndex][iChannel] = scattParam; cout<<"Added scattering parameter f("<& theLine, std::vector& a) { // Store the orbital angular momentum for each channel // Each line will contain: angularmomentum OrbitalAngularMomentumPerChannel // Check that the line has nChannels_ + 1 strings Int_t nWords = static_cast(theLine.size()); Int_t nExpect = nChannels_ + 1; if (nWords == nExpect) { for (Int_t iChannel = 0; iChannel < nChannels_; iChannel++) { Int_t angularMomentum = std::atoi(theLine[iChannel+1].c_str()); L_[iChannel] = angularMomentum; cout<<"Defined K-matrix orbital angular momentum "<Exit(EXIT_FAILURE); } } } } void LauKMatrixPropagator::storeRadii(const std::vector& theLine) { // Store the characteristic radii (measured in GeV^{-1}) // Each line will contain: Radii RadiusConstantsPerChannel // Check that the line has nChannels_ + 1 strings Int_t nWords = static_cast(theLine.size()); Int_t nExpect = nChannels_ + 1; if (nWords == nExpect) { for (Int_t iChannel = 0; iChannel < nChannels_; iChannel++) { Double_t radiusConst = std::atof(theLine[iChannel+1].c_str()); radii_[iChannel] = radiusConst; cout<<"Added K-matrix radius "<& theLine, std::vector& a) { // Store the parameter of the barrier factor // Each line will contain: barrierfactorparameter ParameterValuePerchannel // Check that the line has nChannels_ + 1 strings Int_t nWords = static_cast(theLine.size()); Int_t nExpect = nChannels_ + 1; if (nWords == nExpect) { for (Int_t iChannel = 0; iChannel < nChannels_; iChannel++) { Double_t parameterValue = std::atof(theLine[iChannel+1].c_str()); a[iChannel] = parameterValue; cout<<"Added K-matrix barrier factor parameter value "<updateScattSVPTerm(s); // Now loop over iChannel, jChannel to calculate Kij = Kji. for (iChannel = 0; iChannel < nChannels_; iChannel++) { // Scattering matrix is real and symmetric. Start j loop from i. for (jChannel = iChannel; jChannel < nChannels_; jChannel++) { Double_t Kij(0.0); // Calculate pole mass summation term for (iPole = 0; iPole < nPoles_; iPole++) { Double_t g_i = this->getCouplingConstant(iPole, iChannel); Double_t g_j = this->getCouplingConstant(iPole, jChannel); Kij += poleDenomVect_[iPole]*g_i*g_j; if (verbose_) {cout<<"1: Kij for i = "<getScatteringConstant(iChannel, jChannel); Kij += fij*scattSVP_; Kij *= adlerZeroFactor_; if (verbose_) {cout<<"2: Kij for i = "< 1.0e-6) {invPoleTerm = 1.0/poleTerm;} poleDenomVect_.push_back(invPoleTerm); } } Double_t LauKMatrixPropagator::getPoleDenomTerm(const Int_t poleIndex) const { if (parametersSet_ == kFALSE) {return 0.0;} Double_t poleDenom(0.0); poleDenom = poleDenomVect_[poleIndex]; return poleDenom; } LauParameter& LauKMatrixPropagator::getPoleMassSqParameter(const Int_t poleIndex) { if ( (parametersSet_ == kFALSE) || (poleIndex < 0 || poleIndex >= nPoles_) ) { std::cerr << "ERROR from LauKMatrixPropagator::getPoleMassSqParameter(). Invalid pole." << std::endl; gSystem->Exit(EXIT_FAILURE); } return mSqPoles_[poleIndex]; } Double_t LauKMatrixPropagator::getCouplingConstant(const Int_t poleIndex, const Int_t channelIndex) const { if (parametersSet_ == kFALSE) {return 0.0;} if (poleIndex < 0 || poleIndex >= nPoles_) {return 0.0;} if (channelIndex < 0 || channelIndex >= nChannels_) {return 0.0;} Double_t couplingConst = gCouplings_[poleIndex][channelIndex].unblindValue(); return couplingConst; } LauParameter& LauKMatrixPropagator::getCouplingParameter(const Int_t poleIndex, const Int_t channelIndex) { if ( (parametersSet_ == kFALSE) || (poleIndex < 0 || poleIndex >= nPoles_) || (channelIndex < 0 || channelIndex >= nChannels_) ) { std::cerr << "ERROR from LauKMatrixPropagator::getCouplingParameter(). Invalid coupling." << std::endl; gSystem->Exit(EXIT_FAILURE); } //std::cout << "Minvalue + range for " << poleIndex << ", " << channelIndex << ": " << gCouplings_[poleIndex][channelIndex].minValue() << " => + " << gCouplings_[poleIndex][channelIndex].range() << // " and init value: " << gCouplings_[poleIndex][channelIndex].initValue() << std::endl; return gCouplings_[poleIndex][channelIndex]; } Double_t LauKMatrixPropagator::getScatteringConstant(const Int_t channel1Index, const Int_t channel2Index) const { if (parametersSet_ == kFALSE) {return 0.0;} if (channel1Index < 0 || channel1Index >= nChannels_) {return 0.0;} if (channel2Index < 0 || channel2Index >= nChannels_) {return 0.0;} Double_t scatteringConst = fScattering_[channel1Index][channel2Index].unblindValue(); return scatteringConst; } LauParameter& LauKMatrixPropagator::getScatteringParameter(const Int_t channel1Index, const Int_t channel2Index) { if ( (parametersSet_ == kFALSE) || (channel1Index < 0 || channel1Index >= nChannels_) || (channel2Index < 0 || channel2Index >= nChannels_) ) { std::cerr << "ERROR from LauKMatrixPropagator::getScatteringParameter(). Invalid chanel index." << std::endl; gSystem->Exit(EXIT_FAILURE); } return fScattering_[channel1Index][channel2Index]; } Double_t LauKMatrixPropagator::calcSVPTerm(const Double_t s, const Double_t s0) const { if (parametersSet_ == kFALSE) {return 0.0;} // Calculate the "slowly-varying part" (SVP) Double_t result(0.0); Double_t deltaS = s - s0; if (TMath::Abs(deltaS) > 1.0e-6) { result = (mSq0_.unblindValue() - s0)/deltaS; } return result; } void LauKMatrixPropagator::updateScattSVPTerm(const Double_t s) { // Update the scattering "slowly-varying part" (SVP) Double_t s0Scatt = s0Scatt_.unblindValue(); scattSVP_ = this->calcSVPTerm(s, s0Scatt); } void LauKMatrixPropagator::updateProdSVPTerm(const Double_t s) { // Update the production "slowly-varying part" (SVP) Double_t s0Prod = s0Prod_.unblindValue(); prodSVP_ = this->calcSVPTerm(s, s0Prod); } void LauKMatrixPropagator::updateAdlerZeroFactor(const Double_t s) { // Calculate the multiplicative factor containing various Adler zero // constants. adlerZeroFactor_ = 0.0; Double_t sA0Val = sA0_.unblindValue(); Double_t deltaS = s - sA0Val; if (TMath::Abs(deltaS) > 1e-6) { adlerZeroFactor_ = (s - sAConst_)*(1.0 - sA0Val)/deltaS; } } void LauKMatrixPropagator::calcGammaMatrix(const Double_t s) { // Calculate the gamma angular momentum barrier matrix // for the given invariant mass squared quantity, s. // Initialise all entries to zero GammaMatrix_.Zero(); Double_t gamma(0.0); for (Int_t iChannel (0); iChannel < nChannels_; ++iChannel) { if ( L_[iChannel] != 0 ) { gamma = this->calcGamma(iChannel,s); } else { gamma = 1.0; // S-wave } if (verbose_) { cout<<"GammaMatrix("<Exit(EXIT_FAILURE); } return rho; } LauComplex LauKMatrixPropagator::calcD0KRho(const Double_t s) const { // Calculate the D0K+ phase space factor LauComplex rho(0.0, 0.0); if (TMath::Abs(s) < 1e-10) {return rho;} Double_t sqrtTerm1 = (-mD0KSumSq_/s) + 1.0; Double_t sqrtTerm2 = (-mD0KDiffSq_/s) + 1.0; Double_t sqrtTerm = sqrtTerm1*sqrtTerm2; if (sqrtTerm < 0.0) { rho.setImagPart( TMath::Sqrt(-sqrtTerm) ); } else { rho.setRealPart( TMath::Sqrt(sqrtTerm) ); } return rho; } LauComplex LauKMatrixPropagator::calcDstar0KRho(const Double_t s) const { // Calculate the Dstar0K+ phase space factor LauComplex rho(0.0, 0.0); if (TMath::Abs(s) < 1e-10) {return rho;} Double_t sqrtTerm1 = (-mDstar0KSumSq_/s) + 1.0; Double_t sqrtTerm2 = (-mDstar0KDiffSq_/s) + 1.0; Double_t sqrtTerm = sqrtTerm1*sqrtTerm2; if (sqrtTerm < 0.0) { rho.setImagPart( TMath::Sqrt(-sqrtTerm) ); } else { rho.setRealPart( TMath::Sqrt(sqrtTerm) ); } return rho; } LauComplex LauKMatrixPropagator::calcPiPiRho(const Double_t s) const { // Calculate the pipi phase space factor LauComplex rho(0.0, 0.0); if (TMath::Abs(s) < 1e-10) {return rho;} Double_t sqrtTerm = (-m2piSq_/s) + 1.0; if (sqrtTerm < 0.0) { rho.setImagPart( TMath::Sqrt(-sqrtTerm) ); } else { rho.setRealPart( TMath::Sqrt(sqrtTerm) ); } return rho; } LauComplex LauKMatrixPropagator::calcKKRho(const Double_t s) const { // Calculate the KK phase space factor LauComplex rho(0.0, 0.0); if (TMath::Abs(s) < 1e-10) {return rho;} Double_t sqrtTerm = (-m2KSq_/s) + 1.0; if (sqrtTerm < 0.0) { rho.setImagPart( TMath::Sqrt(-sqrtTerm) ); } else { rho.setRealPart( TMath::Sqrt(sqrtTerm) ); } return rho; } LauComplex LauKMatrixPropagator::calcFourPiRho(const Double_t s) const { // Calculate the 4pi phase space factor. This uses a 6th-order polynomial // parameterisation that approximates the multi-body phase space double integral // defined in Eq 4 of the A&S paper hep-ph/0204328. This form agrees with the // BaBar model (another 6th order polynomial from s^4 down to 1/s^2), but avoids the // exponential increase at small values of s (~< 0.1) arising from 1/s and 1/s^2. // Eq 4 is evaluated for each value of s by assuming incremental steps of 1e-3 GeV^2 // for s1 and s2, the invariant energy squared of each of the di-pion states, // with the integration limits of s1 = (2*mpi)^2 to (sqrt(s) - 2*mpi)^2 and // s2 = (2*mpi)^2 to (sqrt(s) - sqrt(s1))^2. The mass M of the rho is taken to be // 0.775 GeV and the energy-dependent width of the 4pi system // Gamma(s) = gamma_0*rho1^3(s), where rho1 = sqrt(1.0 - 4*mpiSq/s) and gamma_0 is // the "width" of the 4pi state at s = 1, which is taken to be 0.3 GeV // (~75% of the total width from PDG estimates of the f0(1370) -> 4pi state). // The normalisation term rho_0 is found by ensuring that the phase space integral // at s = 1 is equal to sqrt(1.0 - 16*mpiSq/s). Note that the exponent for this // factor in hep-ph/0204328 is wrong; it should be 0.5, i.e. sqrt, not n = 1 to 5. // Plotting the value of this double integral as a function of s can then be fitted // to a 6th-order polynomial (for s < 1), which is the result used below LauComplex rho(0.0, 0.0); if (TMath::Abs(s) < 1e-10) {return rho;} if (s <= 1.0) { Double_t rhoTerm = ((1.07885*s + 0.13655)*s - 0.29744)*s - 0.20840; rhoTerm = ((rhoTerm*s + 0.13851)*s - 0.01933)*s + 0.00051; // For some values of s (below 2*mpi), this term is a very small // negative number. Check for this and set the rho term to zero. if (rhoTerm < 0.0) {rhoTerm = 0.0;} rho.setRealPart( rhoTerm ); } else { rho.setRealPart( TMath::Sqrt(1.0 - (fourPiFactor1_/s)) ); } return rho; } LauComplex LauKMatrixPropagator::calcEtaEtaRho(const Double_t s) const { // Calculate the eta-eta phase space factor LauComplex rho(0.0, 0.0); if (TMath::Abs(s) < 1e-10) {return rho;} Double_t sqrtTerm = (-m2EtaSq_/s) + 1.0; if (sqrtTerm < 0.0) { rho.setImagPart( TMath::Sqrt(-sqrtTerm) ); } else { rho.setRealPart( TMath::Sqrt(sqrtTerm) ); } return rho; } LauComplex LauKMatrixPropagator::calcEtaEtaPRho(const Double_t s) const { // Calculate the eta-eta' phase space factor. Note that the // mass difference term m_eta - m_eta' is not included, // since this corresponds to a "t or u-channel crossing", // which means that we cannot simply analytically continue // this part of the phase space factor below threshold, which // we can do for s-channel contributions. This is actually an // unsolved problem, e.g. see Guo et al 1409.8652, and // Danilkin et al 1409.7708. Anisovich and Sarantsev in // hep-ph/0204328 "solve" this issue by setting the mass // difference term to unity, which is what we do here... LauComplex rho(0.0, 0.0); if (TMath::Abs(s) < 1e-10) {return rho;} Double_t sqrtTerm = (-mEtaEtaPSumSq_/s) + 1.0; if (sqrtTerm < 0.0) { rho.setImagPart( TMath::Sqrt(-sqrtTerm) ); } else { rho.setRealPart( TMath::Sqrt(sqrtTerm) ); } return rho; } LauComplex LauKMatrixPropagator::calcKPiRho(const Double_t s) const { // Calculate the K-pi phase space factor LauComplex rho(0.0, 0.0); if (TMath::Abs(s) < 1e-10) {return rho;} Double_t sqrtTerm1 = (-mKpiSumSq_/s) + 1.0; Double_t sqrtTerm2 = (-mKpiDiffSq_/s) + 1.0; Double_t sqrtTerm = sqrtTerm1*sqrtTerm2; if (sqrtTerm < 0.0) { rho.setImagPart( TMath::Sqrt(-sqrtTerm) ); } else { rho.setRealPart( TMath::Sqrt(sqrtTerm) ); } return rho; } LauComplex LauKMatrixPropagator::calcKEtaPRho(const Double_t s) const { // Calculate the K-eta' phase space factor LauComplex rho(0.0, 0.0); if (TMath::Abs(s) < 1e-10) {return rho;} Double_t sqrtTerm1 = (-mKEtaPSumSq_/s) + 1.0; Double_t sqrtTerm2 = (-mKEtaPDiffSq_/s) + 1.0; Double_t sqrtTerm = sqrtTerm1*sqrtTerm2; if (sqrtTerm < 0.0) { rho.setImagPart( TMath::Sqrt(-sqrtTerm) ); } else { rho.setRealPart( TMath::Sqrt(sqrtTerm) ); } return rho; } LauComplex LauKMatrixPropagator::calcKThreePiRho(const Double_t s) const { // Calculate the Kpipipi + multimeson phase space factor. // Use the simplest definition in hep-ph/9705401 (Eq 14), which is the form // used for the rest of that paper (thankfully, the amplitude does not depend // significantly on the form used for the K3pi phase space factor). LauComplex rho(0.0, 0.0); if (TMath::Abs(s) < 1e-10) {return rho;} if (s < 1.44) { Double_t powerTerm = (-mK3piDiffSq_/s) + 1.0; if (powerTerm < 0.0) { rho.setImagPart( k3piFactor_*TMath::Power(-powerTerm, 2.5) ); } else { rho.setRealPart( k3piFactor_*TMath::Power(powerTerm, 2.5) ); } } else { rho.setRealPart( 1.0 ); } return rho; } Bool_t LauKMatrixPropagator::checkPhaseSpaceType(const Int_t phaseSpaceInt) const { Bool_t passed(kFALSE); if (phaseSpaceInt >= 1 && phaseSpaceInt < static_cast(LauKMatrixPropagator::KMatrixChannels::TotChannels)) { passed = kTRUE; } return passed; } LauComplex LauKMatrixPropagator::getTransitionAmp(const Double_t s, const Int_t channel) { // Get the complex (unitary) transition amplitude T for the given channel LauComplex TAmp(0.0, 0.0); if (channel <= 0 || channel > nChannels_) {return TAmp;} this->getTMatrix(s); TAmp.setRealPart(ReTMatrix_[index_][channel-1]); TAmp.setImagPart(ImTMatrix_[index_][channel-1]); return TAmp; } LauComplex LauKMatrixPropagator::getPhaseSpaceTerm(const Double_t s, const Int_t channel) { // Get the complex (unitary) transition amplitude T for the given channel LauComplex rho(0.0, 0.0); if (channel <= 0 || channel > nChannels_) {return rho;} // If s has changed from the previous value, recalculate rho if (TMath::Abs(s - previousS_) > 1e-6*s) { this->calcRhoMatrix(s); } rho.setRealPart(ReRhoMatrix_[channel][channel-1]); rho.setImagPart(ImRhoMatrix_[channel][channel-1]); return rho; } void LauKMatrixPropagator::getTMatrix(const LauKinematics* kinematics) { // Find the unitary T matrix, where T = [sqrt(rho)]^{*} T_hat sqrt(rho), // and T_hat = (I - i K rho)^-1 * K is the Lorentz-invariant T matrix, // which has phase-space factors included (rho). This function is not // needed to calculate the K-matrix amplitudes, but allows us // to check the variation of T as a function of s (kinematics) if (!kinematics) {return;} // Get the invariant mass squared (s) from the kinematics object. // Use the resPairAmpInt to find which mass-squared combination to use. Double_t s(0.0); if (resPairAmpInt_ == 1) { s = kinematics->getm23Sq(); } else if (resPairAmpInt_ == 2) { s = kinematics->getm13Sq(); } else if (resPairAmpInt_ == 3) { s = kinematics->getm12Sq(); } this->getTMatrix(s); } void LauKMatrixPropagator::getTMatrix(const Double_t s) { // Find the unitary transition T matrix, where // T = [sqrt(rho)]^{*} T_hat sqrt(rho), and // T_hat = (I - i K rho)^-1 * K is the Lorentz-invariant T matrix, // which has phase-space factors included (rho). Note that the first // sqrt of the rho matrix is complex conjugated. // This function is not needed to calculate the K-matrix amplitudes, but // allows us to check the variation of T as a function of s (kinematics) // Initialse the real and imaginary parts of the T matrix to zero ReTMatrix_.Zero(); ImTMatrix_.Zero(); if (parametersSet_ == kFALSE) {return;} // Update K, rho and the propagator (I - i K rho)^-1 this->updatePropagator(s); // Find the real and imaginary T_hat matrices TMatrixD THatReal = realProp_*ScattKMatrix_; TMatrixD THatImag(zeroMatrix_); THatImag -= negImagProp_*ScattKMatrix_; // Find the square-root of the phase space matrix this->getSqrtRhoMatrix(); // Let sqrt(rho) = A + iB and T_hat = C + iD // => T = A(CA-DB) + B(DA+CB) + i[A(DA+CB) + B(DB-CA)] TMatrixD CA(THatReal); CA *= ReSqrtRhoMatrix_; TMatrixD DA(THatImag); DA *= ReSqrtRhoMatrix_; TMatrixD CB(THatReal); CB *= ImSqrtRhoMatrix_; TMatrixD DB(THatImag); DB *= ImSqrtRhoMatrix_; TMatrixD CAmDB(CA); CAmDB -= DB; TMatrixD DApCB(DA); DApCB += CB; TMatrixD DBmCA(DB); DBmCA -= CA; // Find the real and imaginary parts of the transition matrix T ReTMatrix_ = ReSqrtRhoMatrix_*CAmDB + ImSqrtRhoMatrix_*DApCB; ImTMatrix_ = ReSqrtRhoMatrix_*DApCB + ImSqrtRhoMatrix_*DBmCA; } void LauKMatrixPropagator::getSqrtRhoMatrix() { // Find the square root of the (current) phase space matrix so that // we can find T = [sqrt(rho)}^{*} T_hat sqrt(rho), where T_hat is the // Lorentz-invariant T matrix = (I - i K rho)^-1 * K; note that the first // sqrt of rho matrix is complex conjugated // If rho = rho_i + i rho_r = a + i b, then sqrt(rho) = c + i d, where // c = sqrt(0.5*(r+a)) and d = sqrt(0.5(r-a)), where r = sqrt(a^2 + b^2). // Since rho is diagonal, then the square root of rho will also be diagonal, // with its real and imaginary matrix elements equal to c and d, respectively // Initialise the real and imaginary parts of the square root of // the rho matrix to zero ReSqrtRhoMatrix_.Zero(); ImSqrtRhoMatrix_.Zero(); for (Int_t iChannel (0); iChannel < nChannels_; ++iChannel) { Double_t realRho = ReRhoMatrix_[iChannel][iChannel]; Double_t imagRho = ImRhoMatrix_[iChannel][iChannel]; Double_t rhoMag = sqrt(realRho*realRho + imagRho*imagRho); Double_t rhoSum = rhoMag + realRho; Double_t rhoDiff = rhoMag - realRho; Double_t reSqrtRho(0.0), imSqrtRho(0.0); if (rhoSum > 0.0) {reSqrtRho = sqrt(0.5*rhoSum);} if (rhoDiff > 0.0) {imSqrtRho = sqrt(0.5*rhoDiff);} ReSqrtRhoMatrix_[iChannel][iChannel] = reSqrtRho; ImSqrtRhoMatrix_[iChannel][iChannel] = imSqrtRho; } } LauComplex LauKMatrixPropagator::getTHat(const Double_t s, const Int_t channel) { LauComplex THat(0.0, 0.0); if (channel <= 0 || channel > nChannels_) {return THat;} this->updatePropagator(s); // Find the real and imaginary T_hat matrices TMatrixD THatReal = realProp_*ScattKMatrix_; TMatrixD THatImag(zeroMatrix_); THatImag -= negImagProp_*ScattKMatrix_; // Return the specific THat component THat.setRealPart(THatReal[index_][channel-1]); THat.setImagPart(THatImag[index_][channel-1]); return THat; } +nlohmann::json LauKMatrixPropagator::writeSettingsToJson() const +{ + using nlohmann::json; + + json j = json::object(); + + j[ "propName" ] = name_.Data(); + j[ "paramFileName" ] = paramFileName_.Data(); + j[ "resPairAmpInt" ] = resPairAmpInt_; + j[ "nChannels" ] = nChannels_; + j[ "nPoles" ] = nPoles_; + if ( index_ > 0 ) { + j[ "rowIndex" ] = index_+1; + } + if ( ! includeBWBarrierFactor_ ) { + j[ "ignoreBWBarrierFactor" ] = true; + } + + return j; +} diff --git a/src/LauLHCbNR.cc b/src/LauLHCbNR.cc index 2fc28a6..06d1d28 100644 --- a/src/LauLHCbNR.cc +++ b/src/LauLHCbNR.cc @@ -1,210 +1,218 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauLHCbNR.cc \brief File containing implementation of LauLHCbNR class. */ #include #include "TMath.h" #include "LauLHCbNR.hh" #include "LauDaughters.hh" #include "LauParameter.hh" #include "LauResonanceInfo.hh" ClassImp(LauLHCbNR) LauLHCbNR::LauLHCbNR(LauResonanceInfo* resInfo, const Int_t resPairAmpInt, const LauDaughters* daughters) : LauAbsResonance(resInfo, resPairAmpInt, daughters), alpha_(0), beta_(0), delta_(0), forceLegendre_(kTRUE) { TString parName = this->getSanitisedName(); parName += "_alpha"; alpha_ = resInfo->getExtraParameter( parName ); if ( alpha_ == 0 ) { alpha_ = new LauParameter( parName, 0.0, 0.0, 10.0, kTRUE ); alpha_->secondStage(kTRUE); resInfo->addExtraParameter( alpha_ ); } TString parNameb = this->getSanitisedName(); parNameb += "_beta"; beta_ = resInfo->getExtraParameter( parNameb ); if ( beta_ == 0 ) { beta_ = new LauParameter( parNameb, 0.0, -10.0, 10.0, kTRUE ); beta_->secondStage(kTRUE); resInfo->addExtraParameter( beta_ ); } TString parNamed = this->getSanitisedName(); parNamed += "_delta"; delta_ = resInfo->getExtraParameter( parNamed ); if ( delta_ == 0 ) { delta_ = new LauParameter( parNamed, 0.0, 0.0, 10.0, kTRUE ); delta_->secondStage(kTRUE); resInfo->addExtraParameter( delta_ ); } } LauLHCbNR::~LauLHCbNR() { } void LauLHCbNR::initialise() { const LauDaughters* daughters = this->getDaughters(); Int_t resPairAmpInt = this->getPairInt(); if ( daughters->gotSymmetricalDP() && resPairAmpInt != 3 ) { std::cerr << "WARNING in LauLHCbNR::initialise : Dalitz plot is symmetric - this lineshape is not appropriate." << std::endl; } // Make the spin term purely the Legendre polynomial of the cos(helicity angle) if ( forceLegendre_ ) { this->setSpinType( SpinType::Legendre ); } } LauComplex LauLHCbNR::resAmp(Double_t mass, Double_t spinTerm) { Double_t magnitude(1.0); Double_t phase(0.0); Double_t real(1.0); Double_t imag(0.0); Double_t alpha = this->getAlpha(); Double_t beta = this->getBeta(); Double_t delta = this->getDelta(); // exp( - alpha*(mass*mass-delta) - i*beta*(mass*mass-delta) ) magnitude = spinTerm * TMath::Exp(-alpha*(mass*mass-delta)); phase = -beta*(mass*mass-delta); real = magnitude*TMath::Cos(phase); imag = magnitude*TMath::Sin(phase); LauComplex resAmplitude(real, imag); return resAmplitude; } const std::vector& LauLHCbNR::getFloatingParameters() { this->clearFloatingParameters(); if ( ! this->fixAlpha() ) { this->addFloatingParameter( alpha_ ); } if ( ! this->fixBeta() ) { this->addFloatingParameter( beta_ ); } if ( ! this->fixDelta() ) { this->addFloatingParameter( delta_ ); } return this->getParameters(); } void LauLHCbNR::setResonanceParameter(const TString& name, const Double_t value) { // Set various parameters for the lineshape if (name == "alpha") { this->setAlpha(value); std::cout << "INFO in LauLHCbNR::setResonanceParameter : Setting parameter alpha = " << this->getAlpha() << std::endl; } else if (name == "beta") { this->setBeta(value); std::cout << "INFO in LauLHCbNR::setResonanceParameter : Setting parameter beta = " << this->getBeta() << std::endl; } else if (name == "delta") { this->setDelta(value); std::cout << "INFO in LauLHCbNR::setResonanceParameter : Setting parameter delta = " << this->getDelta() << std::endl; } else { std::cerr << "WARNING in LauLHCbNR::setResonanceParameter: Parameter name not reconised. No parameter changes made." << std::endl; } } void LauLHCbNR::floatResonanceParameter(const TString& name) { if (name == "alpha") { if ( alpha_->fixed() ) { alpha_->fixed( kFALSE ); this->addFloatingParameter( alpha_ ); } else { std::cerr << "WARNING in LauLHCbNR::floatResonanceParameter: Parameter already floating. No parameter changes made." << std::endl; } } else if (name == "beta") { if ( beta_->fixed() ) { beta_->fixed( kFALSE ); this->addFloatingParameter( beta_ ); } else { std::cerr << "WARNING in LauLHCbNR::floatResonanceParameter: Parameter already floating. No parameter changes made." << std::endl; } } else if (name == "delta") { if ( delta_->fixed() ) { delta_->fixed( kFALSE ); this->addFloatingParameter( delta_ ); } else { std::cerr << "WARNING in LauLHCbNR::floatResonanceParameter: Parameter already floating. No parameter changes made." << std::endl; } } else { std::cerr << "WARNING in LauLHCbNR::fixResonanceParameter: Parameter name not reconised. No parameter changes made." << std::endl; } } LauParameter* LauLHCbNR::getResonanceParameter(const TString& name) { if (name == "alpha") { return alpha_; } else if (name == "beta") { return beta_; } else if (name == "delta") { return delta_; } else { std::cerr << "WARNING in LauLHCbNR::getResonanceParameter: Parameter name not reconised." << std::endl; return 0; } } void LauLHCbNR::setAlpha(const Double_t alpha) { alpha_->value( alpha ); alpha_->genValue( alpha ); alpha_->initValue( alpha ); } void LauLHCbNR::setBeta(const Double_t beta) { beta_->value( beta ); beta_->genValue( beta ); beta_->initValue( beta ); } void LauLHCbNR::setDelta(const Double_t delta) { delta_->value( delta ); delta_->genValue( delta ); delta_->initValue( delta ); } +nlohmann::json LauLHCbNR::writeSettingsToJson() const +{ + nlohmann::json resObj = LauAbsResonance::writeSettingsToJson(); + + resObj[ "enforceLegendreSpinFactors" ] = this->enforceLegendreSpinFactors(); + + return resObj; +} diff --git a/src/LauResonanceMaker.cc b/src/LauResonanceMaker.cc index 46dccd0..08cf8c4 100644 --- a/src/LauResonanceMaker.cc +++ b/src/LauResonanceMaker.cc @@ -1,1064 +1,1134 @@ /* Copyright 2004 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauResonanceMaker.cc \brief File containing implementation of LauResonanceMaker class. */ #include "LauAbsResonance.hh" #include "LauBelleNR.hh" #include "LauBelleSymNR.hh" #include "LauBreitWignerRes.hh" #include "LauBuggRes.hh" #include "LauDabbaRes.hh" #include "LauDaughters.hh" #include "LauEFKLLMRes.hh" #include "LauFlatteRes.hh" #include "LauFlatNR.hh" #include "LauGaussIncohRes.hh" #include "LauGounarisSakuraiRes.hh" #include "LauKappaRes.hh" #include "LauLASSRes.hh" #include "LauLASSBWRes.hh" #include "LauLASSNRRes.hh" #include "LauLHCbNR.hh" #include "LauModIndPartWaveMagPhase.hh" #include "LauModIndPartWaveRealImag.hh" #include "LauNRAmplitude.hh" #include "LauRescatteringRes.hh" #include "LauRescattering2Res.hh" #include "LauPolNR.hh" #include "LauPoleRes.hh" #include "LauPolarFormFactorNR.hh" #include "LauPolarFormFactorSymNR.hh" #include "LauRelBreitWignerRes.hh" #include "LauResonanceInfo.hh" #include "LauResonanceMaker.hh" #include "LauRhoOmegaMix.hh" #include "LauSigmaRes.hh" +#include + #include ClassImp(LauResonanceMaker); LauResonanceMaker* LauResonanceMaker::resonanceMaker_{nullptr}; LauResonanceMaker::LauResonanceMaker() { this->createResonanceVector(); this->setDefaultBWRadius( LauBlattWeisskopfFactor::Category::Parent, 4.0 ); } LauResonanceMaker::~LauResonanceMaker() { for ( std::vector::iterator iter = bwIndepFactors_.begin(); iter != bwIndepFactors_.end(); ++iter ) { delete *iter; } bwIndepFactors_.clear(); for ( BWFactorCategoryMap::iterator iter = bwFactors_.begin(); iter != bwFactors_.end(); ++iter ) { delete iter->second.bwFactor_; } bwFactors_.clear(); } LauResonanceMaker& LauResonanceMaker::get() { if ( resonanceMaker_ == nullptr ) { resonanceMaker_ = new LauResonanceMaker; } return *resonanceMaker_; } void LauResonanceMaker::createResonanceVector() { // Function to create all possible resonances that this class supports. // Also add in the sigma and kappa - but a special paramterisation is used // instead of the PDG "pole mass and width" values. std::cout << "INFO in LauResonanceMaker::createResonanceVector : Setting up possible resonance states..." << std::endl; std::unique_ptr neutral; std::unique_ptr positve; std::unique_ptr negatve; using BWCategory = LauBlattWeisskopfFactor::Category; // Define the resonance names and store them in the array resInfo_.clear(); resInfo_.reserve(100); // rho resonances name, mass, width, spin, charge, default BW category, BW radius parameter (defaults to 4.0) // rho(770) neutral = std::make_unique("rho0(770)", 0.77526, 0.1478, 1, 0, BWCategory::Light, 5.3); positve = std::make_unique("rho+(770)", 0.77511, 0.1491, 1, 1, BWCategory::Light, 5.3); negatve = positve->createChargeConjugate(); // The following line is placed here in order to allow the following, rather niche, scenario: // The LauRhoOmegaMix code permits (through the use of the optional independentPar argument of LauResonanceInfo::addExtraParameter) the magnitude and phase of the rho/omega mixing to potentially differ between the decay of the parent particle to rho0 X and the parent antiparticle to rho0 Xbar. // This can be acheived by using the rho0(770) record in one case and the rho0(770)_COPY record in the other. std::unique_ptr rho_copy { neutral->createSharedParameterRecord("rho0(770)_COPY") }; resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); resInfo_.push_back( std::move(rho_copy) ); // rho(1450) neutral = std::make_unique("rho0(1450)", 1.465, 0.400, 1, 0, BWCategory::Light ); positve = std::make_unique("rho+(1450)", 1.465, 0.400, 1, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // rho_3(1690) neutral = std::make_unique("rho0_3(1690)", 1.686, 0.186, 3, 0, BWCategory::Light ); positve = std::make_unique("rho+_3(1690)", 1.686, 0.186, 3, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // rho(1700) neutral = std::make_unique("rho0(1700)", 1.720, 0.250, 1, 0, BWCategory::Light ); positve = std::make_unique("rho+(1700)", 1.720, 0.250, 1, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // rho(1900) neutral = std::make_unique("rho0(1900)", 1.909, 0.130, 1, 0, BWCategory::Light ); positve = std::make_unique("rho+(1900)", 1.909, 0.130, 1, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // rho_3(1990) neutral = std::make_unique("rho0_3(1990)", 1.982, 0.188, 3, 0, BWCategory::Light ); positve = std::make_unique("rho+_3(1990)", 1.982, 0.188, 3, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // K* resonances name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // K*(892) neutral = std::make_unique("K*0(892)", 0.89555, 0.0473, 1, 0, BWCategory::Kstar, 3.0); positve = std::make_unique("K*+(892)", 0.89166, 0.0508, 1, 1, BWCategory::Kstar, 3.0); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // K*(1410) neutral = std::make_unique("K*0(1410)", 1.414, 0.232, 1, 0, BWCategory::Kstar ); positve = std::make_unique("K*+(1410)", 1.414, 0.232, 1, 1, BWCategory::Kstar ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // K*_0(1430) neutral = std::make_unique("K*0_0(1430)", 1.425, 0.270, 0, 0, BWCategory::Kstar ); positve = std::make_unique("K*+_0(1430)", 1.425, 0.270, 0, 1, BWCategory::Kstar ); negatve = positve->createChargeConjugate(); // LASS nonresonant model std::unique_ptr lassNRz { neutral->createSharedParameterRecord("LASSNR0") }; std::unique_ptr lassNRp { positve->createSharedParameterRecord("LASSNR+") }; std::unique_ptr lassNRn { negatve->createSharedParameterRecord("LASSNR-") }; resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); resInfo_.push_back( std::move(lassNRz) ); resInfo_.push_back( std::move(lassNRp) ); resInfo_.push_back( std::move(lassNRn) ); // K*_2(1430) neutral = std::make_unique("K*0_2(1430)", 1.4324, 0.109, 2, 0, BWCategory::Kstar ); positve = std::make_unique("K*+_2(1430)", 1.4273, 0.100, 2, 1, BWCategory::Kstar ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // K*(1680) neutral = std::make_unique("K*0(1680)", 1.718, 0.322, 1, 0, BWCategory::Kstar ); positve = std::make_unique("K*+(1680)", 1.718, 0.322, 1, 1, BWCategory::Kstar ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // K*(1950) neutral = std::make_unique("K*0_0(1950)", 1.945, 0.201, 0, 0, BWCategory::Kstar ); positve = std::make_unique("K*+_0(1950)", 1.945, 0.201, 0, 1, BWCategory::Kstar ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // phi resonances name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // phi(1020) neutral = std::make_unique("phi(1020)", 1.019461, 0.004249, 1, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // phi(1680) neutral = std::make_unique("phi(1680)", 1.680, 0.150, 1, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f resonances name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // f_0(980) neutral = std::make_unique("f_0(980)", 0.990, 0.070, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_2(1270) neutral = std::make_unique("f_2(1270)", 1.2755, 0.1867, 2, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_0(1370) neutral = std::make_unique("f_0(1370)", 1.370, 0.350, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f'_0(1300), from Belle's Kspipi paper neutral = std::make_unique("f'_0(1300)", 1.449, 0.126, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_2(1430) neutral = std::make_unique("f_2(1430)", 1.430, 0.150, 2, 0, BWCategory::Light ); // PDG width in the range 13 - 150 resInfo_.push_back( std::move(neutral) ); // f_0(1500) neutral = std::make_unique("f_0(1500)", 1.506, 0.112, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f'_2(1525) neutral = std::make_unique("f'_2(1525)", 1.5174, 0.086, 2, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_2(1565) neutral = std::make_unique("f_2(1565)", 1.542, 0.122, 2, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_2(1640) neutral = std::make_unique("f_2(1640)", 1.639, 0.099, 2, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_0(1710) neutral = std::make_unique("f_0(1710)", 1.704, 0.123, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_2(1810) neutral = std::make_unique("f_2(1810)", 1.815, 0.197, 2, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_2(1910) neutral = std::make_unique("f_2(1910)", 1.900, 0.167, 2, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_2(1950) neutral = std::make_unique("f_2(1950)", 1.936, 0.464, 2, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_2(2010) neutral = std::make_unique("f_2(2010)", 2.011, 0.202, 2, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_0(2020) neutral = std::make_unique("f_0(2020)", 1.992, 0.442, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_4(2050) neutral = std::make_unique("f_4(2050)", 2.018, 0.237, 4, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // f_0(2100) neutral = std::make_unique("f_0(2100)", 2.086, 0.284, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // omega resonances name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // omega(782) neutral = std::make_unique("omega(782)", 0.78265, 0.00849, 1, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // a resonances name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // a_0(980) neutral = std::make_unique("a0_0(980)", 0.980, 0.092, 0, 0, BWCategory::Light ); positve = std::make_unique("a+_0(980)", 0.980, 0.092, 0, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // a_0(1450) neutral = std::make_unique("a0_0(1450)", 1.474, 0.265, 0, 0, BWCategory::Light ); positve = std::make_unique("a+_0(1450)", 1.474, 0.265, 0, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // a_2(1320) neutral = std::make_unique("a0_2(1320)", 1.3169, 0.1050, 2, 0, BWCategory::Light ); positve = std::make_unique("a+_2(1320)", 1.3169, 0.1050, 2, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // charmonium resonances name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // chi_c0 neutral = std::make_unique("chi_c0", 3.41471, 0.0108, 0, 0, BWCategory::Charmonium ); resInfo_.push_back( std::move(neutral) ); // chi_c1 neutral = std::make_unique("chi_c1", 3.51067, 0.00084, 0, 0, BWCategory::Charmonium ); resInfo_.push_back( std::move(neutral) ); // chi_c2 neutral = std::make_unique("chi_c2", 3.55617, 0.00197, 2, 0, BWCategory::Charmonium ); resInfo_.push_back( std::move(neutral) ); // psi(3770) neutral = std::make_unique("psi(3770)", 3.7737, 0.0272, 1, 0, BWCategory::Charmonium ); resInfo_.push_back( std::move(neutral) ); // X(3872) neutral = std::make_unique("X(3872)", 3.87169, 0.0012, 1, 0, BWCategory::Charmonium ); resInfo_.push_back( std::move(neutral) ); // chi_c2(2P) neutral = std::make_unique("chi_c2(2P)", 3.9222, 0.0353, 2, 0, BWCategory::Charmonium ); resInfo_.push_back( std::move(neutral) ); // unknown scalars name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // sigma neutral = std::make_unique("sigma0", 0.475, 0.550, 0, 0, BWCategory::Light ); positve = std::make_unique("sigma+", 0.475, 0.550, 0, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // kappa neutral = std::make_unique("kappa0", 0.824, 0.478, 0, 0, BWCategory::Kstar ); positve = std::make_unique("kappa+", 0.824, 0.478, 0, 1, BWCategory::Kstar ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // dabba neutral = std::make_unique("dabba0", 2.098, 0.520, 0, 0, BWCategory::Charm ); positve = std::make_unique("dabba+", 2.098, 0.520, 0, 1, BWCategory::Charm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // excited charm states name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // D* neutral = std::make_unique("D*0", 2.00685, 0.0021, 1, 0, BWCategory::Charm ); positve = std::make_unique("D*+", 2.01026, 83.4e-6, 1, 1, BWCategory::Charm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // D*_0 neutral = std::make_unique("D*0_0", 2.300, 0.274, 0, 0, BWCategory::Charm ); positve = std::make_unique("D*+_0", 2.349, 0.221, 0, 1, BWCategory::Charm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // D*_2 //AVERAGE--neutral = std::make_unique("D*0_2", 2.4618, 0.049, 2, 0 ); neutral = std::make_unique("D*0_2", 2.4607, 0.0475, 2, 0, BWCategory::Charm ); positve = std::make_unique("D*+_2", 2.4654, 0.0467, 2, 1, BWCategory::Charm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // D1(2420) neutral = std::make_unique("D0_1(2420)", 2.4208, 0.0317, 1, 0, BWCategory::Charm ); positve = std::make_unique("D+_1(2420)", 2.4232, 0.025, 1, 1, BWCategory::Charm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // D(2600) //OLD--neutral = std::make_unique("D0(2600)", 2.6087, 0.093, 0, 0 ); //OLD--positve = std::make_unique("D+(2600)", 2.6213, 0.093, 0, 1 ); neutral = std::make_unique("D0(2600)", 2.623, 0.139, 0, 0, BWCategory::Charm ); positve = std::make_unique("D+(2600)", 2.623, 0.139, 0, 1, BWCategory::Charm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // D(2680) neutral = std::make_unique("D*0_1(2680)", 2.6811, 0.1867, 1, 0, BWCategory::Charm ); resInfo_.push_back( std::move(neutral) ); // D(2760) //OLD-- neutral = std::make_unique("D0(2760)", 2.7633, 0.061, 1, 0 ); //OLD-- positve = std::make_unique("D+(2760)", 2.7697, 0.061, 1, 1 ); neutral = std::make_unique("D0(2760)", 2.761, 0.063, 1, 0, BWCategory::Charm ); positve = std::make_unique("D+(2760)", 2.761, 0.063, 1, 1, BWCategory::Charm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); neutral = std::make_unique("D*0_3(2760)", 2.7755, 0.0953, 3, 0, BWCategory::Charm ); resInfo_.push_back( std::move(neutral) ); // D(2900) neutral = std::make_unique("D0(3000)", 3.214, 0.186, 0, 0, BWCategory::Charm ); resInfo_.push_back( std::move(neutral) ); // D(3400) neutral = std::make_unique("D0(3400)", 3.4, 0.15, 0, 0, BWCategory::Charm ); resInfo_.push_back( std::move(neutral) ); // excited strange charm name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // Ds* positve = std::make_unique("Ds*+", 2.1121, 0.0019, 1, 1, BWCategory::StrangeCharm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // Ds0*(2317) positve = std::make_unique("Ds*+_0(2317)", 2.3178, 0.0038, 0, 1, BWCategory::StrangeCharm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // Ds2*(2573) positve = std::make_unique("Ds*+_2(2573)", 2.5691, 0.0169, 2, 1, BWCategory::StrangeCharm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // Ds1*(2700) positve = std::make_unique("Ds*+_1(2700)", 2.7083, 0.120, 1, 1, BWCategory::StrangeCharm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // Ds1*(2860) positve = std::make_unique("Ds*+_1(2860)", 2.859, 0.159, 1, 1, BWCategory::StrangeCharm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // Ds3*(2860) positve = std::make_unique("Ds*+_3(2860)", 2.860, 0.053, 3, 1, BWCategory::StrangeCharm ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // excited bottom states name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // B* neutral = std::make_unique("B*0", 5.3247, 0.00, 1, 0, BWCategory::Beauty, 6.0); positve = std::make_unique("B*+", 5.3247, 0.00, 1, 1, BWCategory::Beauty, 6.0); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(neutral) ); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // excited strange bottom name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // Bs* neutral = std::make_unique("Bs*0", 5.4154, 0.00, 1, 0, BWCategory::StrangeBeauty, 6.0); resInfo_.push_back( std::move(neutral) ); // nonresonant models name, mass, width, spin, charge, BW category, BW radius parameter (defaults to 4.0) // Phase-space nonresonant model neutral = std::make_unique("NonReson", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // Theory-based nonresonant model neutral = std::make_unique("NRModel", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // Belle nonresonant models neutral = std::make_unique("BelleSymNR", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); neutral = std::make_unique("BelleNR", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); positve = std::make_unique("BelleNR+", 0.0, 0.0, 0, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); neutral = std::make_unique("BelleNR_Swave", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); positve = std::make_unique("BelleNR_Swave+",0.0, 0.0, 0, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); neutral = std::make_unique("BelleNR_Pwave", 0.0, 0.0, 1, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); positve = std::make_unique("BelleNR_Pwave+",0.0, 0.0, 1, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); neutral = std::make_unique("BelleNR_Dwave", 0.0, 0.0, 2, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); positve = std::make_unique("BelleNR_Dwave+",0.0, 0.0, 2, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); neutral = std::make_unique("BelleNR_Fwave", 0.0, 0.0, 3, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); positve = std::make_unique("BelleNR_Fwave+",0.0, 0.0, 3, 1, BWCategory::Light ); negatve = positve->createChargeConjugate(); resInfo_.push_back( std::move(positve) ); resInfo_.push_back( std::move(negatve) ); // Taylor expansion nonresonant model neutral = std::make_unique("NRTaylor", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // Polynomial nonresonant models neutral = std::make_unique("PolNR_S0", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); neutral = std::make_unique("PolNR_S1", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); neutral = std::make_unique("PolNR_S2", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); neutral = std::make_unique("PolNR_P0", 0.0, 0.0, 1, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); neutral = std::make_unique("PolNR_P1", 0.0, 0.0, 1, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); neutral = std::make_unique("PolNR_P2", 0.0, 0.0, 1, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // Fake resonances for S-Wave splines neutral = std::make_unique("Spline_S0", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); neutral = std::make_unique("Spline_S0_Bar", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // Polar Form Factor nonresonant model neutral = std::make_unique("PolarFFSymNR", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); neutral = std::make_unique("PolarFFNR", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); // PiPi-KK Inelastic Scattering neutral = std::make_unique("Rescattering", 0.0, 0.0, 0, 0, BWCategory::Light ); resInfo_.push_back( std::move(neutral) ); nResDefMax_ = resInfo_.size(); } void LauResonanceMaker::setBWType(const LauBlattWeisskopfFactor::BarrierType bwType) { // No need to check or do anything if the setting isn't going to change, so just return immediately if ( bwBarrierType_ == bwType ) { return; } // Check whether any BW factors have been created and bail out if so if ( ! bwIndepFactors_.empty() ) { std::cerr << "ERROR in LauResonanceMaker::setBWType : some barrier factors have already been created - cannot change the barrier type now!" << std::endl; return; } for ( BWFactorCategoryMap::const_iterator iter = bwFactors_.begin(); iter != bwFactors_.end(); ++iter ) { if ( iter->second.bwFactor_ != 0 ) { std::cerr << "ERROR in LauResonanceMaker::setBWType : some barrier factors have already been created - cannot change the barrier type now!" << std::endl; return; } } bwBarrierType_ = bwType; } void LauResonanceMaker::setBWBachelorRestFrame(const LauBlattWeisskopfFactor::RestFrame restFrame) { // No need to check or do anything if the setting isn't going to change, so just return immediately if ( bwRestFrame_ == restFrame ) { return; } // Check whether any BW factors have been created and bail out if so if ( ! bwIndepFactors_.empty() ) { std::cerr << "ERROR in LauResonanceMaker::setBWBachelorRestFrame : some barrier factors have already been created - cannot change the rest frame now!" << std::endl; return; } for ( BWFactorCategoryMap::const_iterator iter = bwFactors_.begin(); iter != bwFactors_.end(); ++iter ) { if ( iter->second.bwFactor_ != 0 ) { std::cerr << "ERROR in LauResonanceMaker::setBWBachelorRestFrame : some barrier factors have already been created - cannot change the rest frame now!" << std::endl; return; } } bwRestFrame_ = restFrame; } void LauResonanceMaker::setSpinFormalism(const LauAbsResonance::SpinType spinType) { // If the formalism is already frozen, print an error if this was an attempt to change it if ( summaryPrinted_ && spinType != spinFormalism_ ) { std::cerr << "ERROR in LauResonanceMaker::setSpinFormalism : cannot redefine the spin formalism after creating one or more resonances" << std::endl; return; } spinFormalism_ = spinType; } void LauResonanceMaker::setDefaultBWRadius(const LauBlattWeisskopfFactor::Category bwCategory, const Double_t bwRadius) { if ( bwCategory == LauBlattWeisskopfFactor::Category::Default || bwCategory == LauBlattWeisskopfFactor::Category::Indep ) { std::cerr << "WARNING in LauResonanceMaker::setDefaultBWRadius : cannot set radius values for Default or Indep categories" << std::endl; return; } // Check if we have an information object for this category BWFactorCategoryMap::iterator factor_iter = bwFactors_.find( bwCategory ); if ( factor_iter != bwFactors_.end() ) { // If so, we can set the value in the information object BlattWeisskopfCategoryInfo& categoryInfo = factor_iter->second; categoryInfo.defaultRadius_ = bwRadius; // Then we can check if a LauBlattWeisskopfFactor object has been created for this category LauBlattWeisskopfFactor* bwFactor = categoryInfo.bwFactor_; if ( bwFactor != 0 ) { // If it has then we can also set its radius value directly LauParameter* radius = bwFactor->getRadiusParameter(); radius->value(bwRadius); radius->initValue(bwRadius); radius->genValue(bwRadius); } } else { // If not then we just store the value to be used later BlattWeisskopfCategoryInfo& categoryInfo = bwFactors_[bwCategory]; categoryInfo.bwFactor_ = 0; categoryInfo.defaultRadius_ = bwRadius; categoryInfo.radiusFixed_ = kTRUE; } } void LauResonanceMaker::fixBWRadius(const LauBlattWeisskopfFactor::Category bwCategory, const Bool_t fixRadius) { if ( bwCategory == LauBlattWeisskopfFactor::Category::Default || bwCategory == LauBlattWeisskopfFactor::Category::Indep ) { std::cerr << "WARNING in LauResonanceMaker::fixBWRadius : cannot fix/float radius values for Default or Indep categories" << std::endl; return; } // Check if we have an information object for this category BWFactorCategoryMap::iterator factor_iter = bwFactors_.find( bwCategory ); if ( factor_iter != bwFactors_.end() ) { // If so, we can set the value in the information object BlattWeisskopfCategoryInfo& categoryInfo = factor_iter->second; categoryInfo.radiusFixed_ = fixRadius; // Then we can check if a LauBlattWeisskopfFactor object has been created for this category LauBlattWeisskopfFactor* bwFactor = categoryInfo.bwFactor_; if ( bwFactor != 0 ) { // If it has then we can also fix/float its radius value directly LauParameter* radius = bwFactor->getRadiusParameter(); radius->fixed(fixRadius); } } else { // If not then we just store the value to be used later BlattWeisskopfCategoryInfo& categoryInfo = bwFactors_[bwCategory]; categoryInfo.bwFactor_ = 0; categoryInfo.defaultRadius_ = -1.0; categoryInfo.radiusFixed_ = fixRadius; } } LauBlattWeisskopfFactor* LauResonanceMaker::getParentBWFactor(Int_t resSpin, LauBlattWeisskopfFactor::BarrierType barrierType) { LauBlattWeisskopfFactor* bwFactor(0); // Look up the category in the category information map BWFactorCategoryMap::iterator factor_iter = bwFactors_.find( LauBlattWeisskopfFactor::Category::Parent ); if ( factor_iter == bwFactors_.end() ) { // If the category is currently undefined we need to create it bwFactor = new LauBlattWeisskopfFactor( resSpin, 4.0, bwBarrierType_, bwRestFrame_, LauBlattWeisskopfFactor::Category::Parent ); std::cerr<<"WARNING in LauResonanceMaker::getParentBWFactor : Default radius 4.0 set for Blatt-Weisskopf factor category: Parent"<getRadiusParameter()->value(); categoryInfo.radiusFixed_ = kTRUE; } else { // If it exists, we can check if the factor object has been created BlattWeisskopfCategoryInfo& categoryInfo = factor_iter->second; if ( categoryInfo.bwFactor_ != 0 ) { // If so, simply clone it bwFactor = categoryInfo.bwFactor_->createClone( resSpin, barrierType ); } else { // Otherwise we need to create it, using the default value if it has been set if ( categoryInfo.defaultRadius_ >= 0.0 ) { bwFactor = new LauBlattWeisskopfFactor( resSpin, categoryInfo.defaultRadius_, bwBarrierType_, bwRestFrame_, LauBlattWeisskopfFactor::Category::Parent ); } else { bwFactor = new LauBlattWeisskopfFactor( resSpin, 4.0, bwBarrierType_, bwRestFrame_, LauBlattWeisskopfFactor::Category::Parent ); std::cerr<<"WARNING in LauResonanceMaker::getParentBWFactor : Default radius 4.0 set for Blatt-Weisskopf factor category: Parent"<getRadiusParameter(); radius->fixed( categoryInfo.radiusFixed_ ); } } return bwFactor; } LauBlattWeisskopfFactor* LauResonanceMaker::getBWFactor( const LauBlattWeisskopfFactor::Category bwCategory, const LauResonanceInfo* resInfo ) { LauBlattWeisskopfFactor* bwFactor(0); // If this is an independent factor, create it and add it to the list of independent factors, then return it if ( bwCategory == LauBlattWeisskopfFactor::Category::Indep ) { bwFactor = new LauBlattWeisskopfFactor( *resInfo, bwBarrierType_, bwRestFrame_, bwCategory ); bwIndepFactors_.push_back(bwFactor); return bwFactor; } // Otherwise, look up the category in the category information map BWFactorCategoryMap::iterator factor_iter = bwFactors_.find( bwCategory ); if ( factor_iter == bwFactors_.end() ) { // If the category is currently undefined we need to create it bwFactor = new LauBlattWeisskopfFactor( *resInfo, bwBarrierType_, bwRestFrame_, bwCategory ); BlattWeisskopfCategoryInfo& categoryInfo = bwFactors_[bwCategory]; categoryInfo.bwFactor_ = bwFactor; categoryInfo.defaultRadius_ = bwFactor->getRadiusParameter()->value(); categoryInfo.radiusFixed_ = kTRUE; } else { // If it exists, we can check if the factor object has been created BlattWeisskopfCategoryInfo& categoryInfo = factor_iter->second; if ( categoryInfo.bwFactor_ != 0 ) { // If so, simply clone it const UInt_t resSpin = resInfo->getSpin(); bwFactor = categoryInfo.bwFactor_->createClone( resSpin, categoryInfo.bwFactor_->getBarrierType() ); } else { // Otherwise we need to create it, using the default value if it has been set if ( categoryInfo.defaultRadius_ >= 0.0 ) { bwFactor = new LauBlattWeisskopfFactor( *resInfo, categoryInfo.defaultRadius_, bwBarrierType_, bwRestFrame_, bwCategory ); } else { bwFactor = new LauBlattWeisskopfFactor( *resInfo, bwBarrierType_, bwRestFrame_, bwCategory ); } categoryInfo.bwFactor_ = bwFactor; // Set whether the radius should be fixed/floated LauParameter* radius = bwFactor->getRadiusParameter(); radius->fixed( categoryInfo.radiusFixed_ ); } } return bwFactor; } LauAbsResonance* LauResonanceMaker::getResonance(const LauDaughters* daughters, const TString& resName, const Int_t resPairAmpInt, const LauAbsResonance::ResonanceModel resType, const LauBlattWeisskopfFactor::Category bwCategory) { // Routine to return the appropriate LauAbsResonance object given the resonance // name (resName), which daughter is the bachelor track (resPairAmpInt = 1,2 or 3), // and the resonance type ("BW" = Breit-Wigner, "Flatte" = Flatte distribution). using LauSpinType = LauAbsResonance::SpinType; using ResonanceModel = LauAbsResonance::ResonanceModel; // If this is the first resonance we are making, first print a summary of the formalism if ( ! summaryPrinted_ ) { std::cout << "INFO in LauResonanceMaker::getResonance : Freezing amplitude formalism:" << std::endl; switch ( spinFormalism_ ) { case LauSpinType::Zemach_P : std::cout << " : Spin factors use Zemach spin tensors, with bachelor momentum in resonance rest frame" << std::endl; break; case LauSpinType::Zemach_Pstar : std::cout << " : Spin factors use Zemach spin tensors, with bachelor momentum in parent rest frame" << std::endl; break; case LauSpinType::Covariant : std::cout << " : Spin factors use Covariant spin tensors, with bachelor momentum in parent rest frame" << std::endl; break; case LauSpinType::Covariant_P : std::cout << " : Spin factors use Covariant spin tensors, with bachelor momentum in resonance rest frame" << std::endl; break; case LauSpinType::Legendre : std::cout << " : Spin factors are just Legendre polynomials" << std::endl; break; } switch ( bwBarrierType_ ) { case LauBlattWeisskopfFactor::BarrierType::BWBarrier : std::cout << " : Blatt-Weisskopf barrier factors are the 'non-primed' form" << std::endl; break; case LauBlattWeisskopfFactor::BarrierType::BWPrimeBarrier : std::cout << " : Blatt-Weisskopf barrier factors are the 'primed' form" << std::endl; break; case LauBlattWeisskopfFactor::BarrierType::ExpBarrier : std::cout << " : Blatt-Weisskopf barrier factors are the exponential form" << std::endl; break; } switch ( bwRestFrame_ ) { case LauBlattWeisskopfFactor::RestFrame::ParentFrame : std::cout << " : Blatt-Weisskopf barrier factors use bachelor momentum in parent rest frame" << std::endl; break; case LauBlattWeisskopfFactor::RestFrame::ResonanceFrame : std::cout << " : Blatt-Weisskopf barrier factors use bachelor momentum in resonance rest frame" << std::endl; break; case LauBlattWeisskopfFactor::RestFrame::Covariant : std::cout << " : Blatt-Weisskopf barrier factors use covariant expression" << std::endl; break; } summaryPrinted_ = kTRUE; } // Loop over all possible resonance states we have defined in // createResonanceVector() until we get a match with the name of the resonance LauResonanceInfo* resInfo{nullptr}; for ( auto& info : resInfo_ ) { if ( resName == info->getName() ) { // We have recognised the resonance name. std::cout<<"INFO in LauResonanceMaker::getResonance : Creating resonance: "<getBWCategory(); } LauBlattWeisskopfFactor* resBWFactor = this->getBWFactor( resCategory, resInfo ); LauBlattWeisskopfFactor* parBWFactor = this->getBWFactor( parCategory, resInfo ); theResonance->setBarrierRadii( resBWFactor, parBWFactor ); break; } case ResonanceModel::GS : { // Gounaris-Sakurai function to try and model the rho(770) better std::cout<<" : Using Gounaris-Sakurai lineshape. "<getBWCategory(); } LauBlattWeisskopfFactor* resBWFactor = this->getBWFactor( resCategory, resInfo ); LauBlattWeisskopfFactor* parBWFactor = this->getBWFactor( parCategory, resInfo ); theResonance->setBarrierRadii( resBWFactor, parBWFactor ); break; } case ResonanceModel::Flatte : // Flatte distribution - coupled channel Breit-Wigner std::cout<<" : Using Flatte lineshape. "<getBWCategory(); } LauBlattWeisskopfFactor* resBWFactor = this->getBWFactor( resCategory, resInfo ); LauBlattWeisskopfFactor* parBWFactor = this->getBWFactor( parCategory, resInfo ); theResonance->setBarrierRadii( resBWFactor, parBWFactor ); break; } // Set the spin formalism choice theResonance->setSpinType( spinFormalism_ ); return theResonance; } Int_t LauResonanceMaker::resTypeInt(const TString& name) const { // Internal function that returns the resonance integer, specified by the // order of the resonance vector defined in createResonanceVector(), // for a given resonance name. Int_t i{0}; for ( const auto& info : resInfo_ ) { if ( name.BeginsWith( info->getName(), TString::kExact ) ) { // We have recognised the resonance from those that are available return i; } ++i; } return -99; } void LauResonanceMaker::printAll( std::ostream& stream ) const { for ( const auto& info : resInfo_ ) { stream << (*info) << std::endl; } } LauResonanceInfo* LauResonanceMaker::getResInfo(const TString& resName) const { for ( const auto& info : resInfo_ ) { if (resName == info->getName()) { // We have recognised the resonance name. return info.get(); } } return nullptr; } + +LauBlattWeisskopfFactor::Category LauResonanceMaker::getBWCategory(const LauBlattWeisskopfFactor* bwFactor) const +{ + // Make sure we have the parent factor, rather than a clone + const LauBlattWeisskopfFactor* theFactor { bwFactor->clone() ? bwFactor->getParent() : bwFactor }; + + for ( auto& [ category, info ] : bwFactors_ ) { + if ( info.bwFactor_ == theFactor ) { + return category; + } + } + + for ( auto factor : bwIndepFactors_ ) { + if ( factor == theFactor ) { + return LauBlattWeisskopfFactor::Category::Indep; + } + } + + // We should never get here! + // Use Default as an error flag, since that shouldn't be returned from here normally + std::cerr << "ERROR in LauResonanceMaker::getBWCategory : supplied barrier factor is unknown to us!" << std::endl; + return LauBlattWeisskopfFactor::Category::Default; +} + +Double_t LauResonanceMaker::getDefaultBWRadius(const LauBlattWeisskopfFactor::Category category) const +{ + auto iter { bwFactors_.find( category ) }; + if ( iter == bwFactors_.end() ) { + std::cerr << "ERROR in LauResonanceMaker::getDefaultBWRadius : supplied barrier factor category has no stored information!" << std::endl; + return -1.0; + } + + const auto& info { iter->second }; + + return info.defaultRadius_; +} + +nlohmann::json LauResonanceMaker::writeSettingsToJson() const +{ + using nlohmann::json; + + json j = json::object(); + + j[ "setBWType" ] = bwBarrierType_; + j[ "setBWBachelorRestFrame" ] = bwRestFrame_; + j[ "setSpinFormalism" ] = spinFormalism_; + + // if there aren't any BW factor categories, there's nothing more to do + if ( bwFactors_.empty() ) { + return j; + } + + // otherwise create the empty array and then fill it + j[ "setDefaultBWRadius" ] = json::array(); + + for ( auto& [ category, info ] : bwFactors_ ) { + json obj = json::object(); + + obj[ "category" ] = category; + obj[ "value" ] = info.defaultRadius_; + obj[ "fix" ] = info.radiusFixed_; + + j[ "setDefaultBWRadius" ].push_back( obj ); + } + + return j; +} diff --git a/test/TestWriteCoeffSetToJson.cc b/test/TestWriteCoeffSetToJson.cc index a3f80c8..aadbaa9 100644 --- a/test/TestWriteCoeffSetToJson.cc +++ b/test/TestWriteCoeffSetToJson.cc @@ -1,104 +1,104 @@ #include "LauAbsCoeffSet.hh" #include "LauBelleCPCoeffSet.hh" #include "LauCartesianCPCoeffSet.hh" #include "LauCartesianGammaCPCoeffSet.hh" #include "LauCleoCPCoeffSet.hh" #include "LauMagPhaseCoeffSet.hh" #include "LauMagPhaseCPCoeffSet.hh" #include "LauNSCCartesianCPCoeffSet.hh" #include "LauPolarGammaCPCoeffSet.hh" #include "LauRealImagCoeffSet.hh" #include "LauRealImagCPCoeffSet.hh" #include "LauRealImagGammaCPCoeffSet.hh" #include #include #include #include #include #include int main() { std::vector> coeffs; coeffs.push_back( std::make_unique("K*0(892)", 1.00, 0.00, 0.00, 0.00, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.back()->blindParameter("B", "hellothere", 0.1); coeffs.back()->blindParameter("Phi", "rebelscum", 3.0); coeffs.push_back( coeffs.back()->createClone("K*0_0(1430)", LauAbsCoeffSet::CloneOption::TieCPPars) ); coeffs.back()->setParameterValue( "A", 2.0, kTRUE ); coeffs.back()->setParameterValue( "Delta", 3.1415926, kTRUE ); coeffs.back()->blindParameter("Delta", "noiamyourfather", 3.0); coeffs.push_back( std::make_unique("rho0(770)", 1.00, 0.00, 0.00, 0.00, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("rho+(770)", 1.00, 0.00, 0.00, 0.00, 0.00, 0.00, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("rho0_3(1690)", 1.00, 0.00, 0.00, 0.00, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("rho0(1450)", 1.00, 0.00, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("rho0(1700)", 1.00, 0.00, 1.00, 0.00, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("K*0(1410)", kTRUE, 1.00, 0.00, 0.00, 0.00, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, 1.00, 0.00, 0.00, 0.00, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::GLW_CPOdd, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::GLW_CPEven, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::ADS_Favoured, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::ADS_Suppressed, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::GLW_CPOdd_btouOnly, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::GLW_CPEven_btouOnly, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::ADS_Favoured_btouOnly, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::ADS_Suppressed_btouOnly, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::GLW_CPOdd, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kFALSE, kFALSE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::GLW_CPEven, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kFALSE, kFALSE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::ADS_Favoured, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kFALSE, kFALSE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::ADS_Suppressed, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kFALSE, kFALSE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::GLW_CPOdd_btouOnly, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kFALSE, kFALSE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::GLW_CPEven_btouOnly, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kFALSE, kFALSE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::ADS_Favoured_btouOnly, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kFALSE, kFALSE) ); coeffs.push_back( std::make_unique("K*0_2(1430)", LauPolarGammaCPCoeffSet::DecayType::ADS_Suppressed_btouOnly, 1.00, 0.00, 0.10, 0.00, 1.20, 0.10, 1.60, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kFALSE, kFALSE) ); coeffs.push_back( std::make_unique("K*0(1680)", 1.00, 0.00, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("phi(1020)", 1.00, 0.00, 1.00, 0.00, kTRUE, kTRUE, kTRUE, kTRUE) ); coeffs.push_back( std::make_unique("f_0(980)", 1.00, 0.00, 0.00, 0.00, 0.00, 0.00, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE, kTRUE) ); - LauAbsCoeffSet::writeToJson( "coeffset.json", coeffs ); + LauAbsCoeffSet::writeToJson( coeffs, "coeffset.json" ); for ( auto& coeffset : coeffs ) { nlohmann::json j; j = *coeffset; std::stringstream filename; filename << j.at("type").get(); if ( j.contains("decayType") ) { filename << "_" << j.at("decayType").get(); } if ( j.contains("useGlobalGamma") ) { filename << "_useGlobalGamma=" << std::boolalpha << j.at("useGlobalGamma").get(); } if ( j.contains("useGlobalADSPars") ) { filename << "_useGlobalADSPars=" << std::boolalpha << j.at("useGlobalADSPars").get(); } if ( coeffset->clone() ) { filename << "_clone"; } filename << ".json"; std::ofstream out{filename.str(), std::ios_base::out}; if ( ! out ) { std::cerr << "ERROR : couldn't open file \"" << filename.str() << "\" for writing. No file will be written!" << std::endl; return 1; } out << j.dump(4); out << std::endl; } }