diff --git a/inc/LauAbsCoeffSet.hh b/inc/LauAbsCoeffSet.hh index 358e6fd..516a0e2 100644 --- a/inc/LauAbsCoeffSet.hh +++ b/inc/LauAbsCoeffSet.hh @@ -1,510 +1,513 @@ /* 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 + //! 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 \return the collection of newly constructed coefficients */ static std::vector> readFromJson( const TString& fileName ); - //! Write a collection of coefficient objects to a json file + //! 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 */ static void writeToJson( const TString& fileName, const std::vector>& coeffs ); //! 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) = default; + LauAbsCoeffSet& operator=(const LauAbsCoeffSet& rhs) = delete; //! Move assignment operator /*! \param [in] rhs the coefficient to clone */ - LauAbsCoeffSet& operator=(LauAbsCoeffSet&& rhs) = default; + 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* parent_{nullptr}; + const LauAbsCoeffSet* const parent_{nullptr}; //! The clone option used, if applicable - CloneOption cloneOption_{CloneOption::All}; + const CloneOption cloneOption_{CloneOption::All}; //! The constant factor used, if applicable - Double_t constFactor_{1.0}; + 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"}, }) // exception 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); + static void to_json(json& j, const LauAbsCoeffSet& t) + { + t.serialiseToJson(j); + } }; } //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauBelleCPCoeffSet.hh b/inc/LauBelleCPCoeffSet.hh index dcc1a38..b8fb217 100644 --- a/inc/LauBelleCPCoeffSet.hh +++ b/inc/LauBelleCPCoeffSet.hh @@ -1,246 +1,246 @@ /* 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 LauBelleCPCoeffSet.hh \brief File containing declaration of LauBelleCPCoeffSet class. */ #ifndef LAU_BELLECP_COEFF_SET #define LAU_BELLECP_COEFF_SET #include "LauAbsCoeffSet.hh" #include "LauComplex.hh" #include "LauParameter.hh" #include "Rtypes.h" #include #include #include /*! \class LauBelleCPCoeffSet \brief Class for defining a complex coefficient using the Belle CP convention. Holds a set of real values that define the complex coefficient of an amplitude component. The amplitude has the form a * exp(i*delta) * ( 1 +/- b * exp(i*phi) ) where a is a CP conserving magnitude, b is a CP violating magnitude, delta is the strong phase and phi is the weak phase. [Phys.Rev.Lett. 96 (2006) 251803] */ class LauBelleCPCoeffSet : public LauAbsCoeffSet { public: //! Constructor /*! \param [in] compName the name of the coefficient set \param [in] a the magnitude a \param [in] delta the strong phase \param [in] b the magnitude b \param [in] phi the weak phase \param [in] aFixed whether a is fixed \param [in] deltaFixed whether delta is fixed \param [in] bFixed whether b is fixed \param [in] phiFixed whether phi is fixed \param [in] bSecondStage whether b should be floated only in the second stage of the fit \param [in] phiSecondStage whether phi should be floated only in the second stage of the fit */ LauBelleCPCoeffSet(const TString& compName, const Double_t a, const Double_t delta, const Double_t b, const Double_t phi, const Bool_t aFixed, const Bool_t deltaFixed, const Bool_t bFixed, const Bool_t phiFixed, const Bool_t bSecondStage = kFALSE, const Bool_t phiSecondStage = kFALSE); //! Move constructor (default) /*! \param [in] rhs the coefficient to clone */ LauBelleCPCoeffSet(LauBelleCPCoeffSet&& rhs) = default; - //! Move assignment operator (default) + //! Move assignment operator (delete) /*! \param [in] rhs the coefficient to clone */ - LauBelleCPCoeffSet& operator=(LauBelleCPCoeffSet&& rhs) = default; + LauBelleCPCoeffSet& operator=(LauBelleCPCoeffSet&& rhs) = delete; //! Determine the type of the coefficient /*! \return the type of the coefficient */ LauCoeffType type() const override { return LauCoeffType::BelleCP; } //! Retrieve the parameters of the coefficient, e.g. so that they can be loaded into a fit /*! \return the parameters of the coefficient [ A, Delta, B, Phi ] */ std::vector getParameters() override { return { a_.get(), delta_.get(), b_.get(), phi_.get() }; } //! Retrieve the (const) parameters of the coefficient, e.g. so that they can be queried /*! \return the (const) parameters of the coefficient [ A, Delta, B, Phi ] */ std::vector getParameters() const override { return { a_.get(), delta_.get(), b_.get(), phi_.get() }; } //! Retrieve the names of the parameters of the coefficient (in the same order as the parameters in getParameters) /*! \return the parameter names [ A, Delta, B, Phi ] */ std::vector getParNames() const override { return { "A", "Delta", "B", "Phi" }; } //! Print the current values of the parameters void printParValues() const override; //! Print the column headings for a results table /*! \param [out] stream the stream to print to */ void printTableHeading(std::ostream& stream) const override; //! Print the parameters of the complex coefficient as a row in the results table /*! \param [out] stream the stream to print to */ void printTableRow(std::ostream& stream) const override; //! Randomise the starting values of the parameters for a fit void randomiseInitValues() override; //! Make sure values are in "standard" ranges, e.g. phases should be between -pi and pi void finaliseValues() override; //! Retrieve the complex coefficient for a particle /*! \return the complex coefficient for a particle */ const LauComplex& particleCoeff() override; //! Retrieve the complex coefficient for an antiparticle /*! \return the complex coefficient for an antiparticle */ const LauComplex& antiparticleCoeff() override; //! 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 */ void setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar, const Bool_t init ) override; //! Calculate the CP asymmetry /*! \return the CP asymmetry */ LauParameter acp() override; //! 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)}; } private: //! Copy constructor (with options) /*! This creates cloned parameters, not copies. \param [in] rhs the coefficient to clone \param [in] cloneOption special option for the cloning operation \param [in] constFactor a constant factor to multiply the clone's parameters by \param [in] coeffInfo an optional JSON entry that contains the values of any non-cloned parameters (depending on the CloneOption) */ LauBelleCPCoeffSet(const LauBelleCPCoeffSet& rhs, const CloneOption cloneOption = CloneOption::All, const Double_t constFactor = 1.0, const nlohmann::json& coeffInfo = {}); //! Copy constructor (deleted) /*! \param [in] rhs the coefficient to clone */ LauBelleCPCoeffSet(const LauBelleCPCoeffSet& rhs) = delete; //! Copy assignment operator (deleted) /*! \param [in] rhs the coefficient to clone */ LauBelleCPCoeffSet& operator=(const LauBelleCPCoeffSet& rhs) = delete; //! 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 */ LauBelleCPCoeffSet* createClone_impl(const TString& newName, const LauAbsCoeffSet::CloneOption cloneOption, const Double_t constFactor, const nlohmann::json& coeffInfo) const override; // the actual fit parameters // (need to be pointers so they can be cloned) //! The magnitude a std::unique_ptr a_; //! The magnitude b std::unique_ptr b_; //! The strong phase std::unique_ptr delta_; //! The weak phase std::unique_ptr phi_; //! The particle complex coefficient LauComplex particleCoeff_; //! The antiparticle complex coefficient LauComplex antiparticleCoeff_; //! The CP asymmetry LauParameter acp_; ClassDefOverride(LauBelleCPCoeffSet, 0) }; //! \cond DOXYGEN_IGNORE namespace nlohmann { template <> struct adl_serializer { static LauBelleCPCoeffSet from_json(const json& j); }; } //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauCartesianCPCoeffSet.hh b/inc/LauCartesianCPCoeffSet.hh index 67ed738..9f0b16a 100644 --- a/inc/LauCartesianCPCoeffSet.hh +++ b/inc/LauCartesianCPCoeffSet.hh @@ -1,242 +1,242 @@ /* 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 LauCartesianCPCoeffSet.hh \brief File containing declaration of LauCartesianCPCoeffSet class. */ /*! \class LauCartesianCPCoeffSet \brief Class for defining a complex coefficient using the Cartesian CP convention. Holds a set of real values that define the complex coefficient of an amplitude component. The amplitude has the form x +/- delta_x + i * ( y +/- delta_y ). [Phys.Rev. D78 (2008) 012004] */ #ifndef LAU_CARTESIANCP_COEFF_SET #define LAU_CARTESIANCP_COEFF_SET #include #include #include #include "Rtypes.h" #include "LauAbsCoeffSet.hh" #include "LauComplex.hh" #include "LauParameter.hh" class LauCartesianCPCoeffSet : public LauAbsCoeffSet { public: //! Constructor /*! \param [in] compName the name of the coefficient set \param [in] x the average real part \param [in] y the average imaginary part \param [in] deltaX the asymmetric real part \param [in] deltaY the asymmetric imaginary part \param [in] xFixed whether x is fixed \param [in] yFixed whether y is fixed \param [in] deltaXFixed whether deltaX is fixed \param [in] deltaYFixed whether deltaY is fixed \param [in] deltaXSecondStage whether deltaX should be floated only in the second stage of the fit \param [in] deltaYSecondStage whether deltaY should be floated only in the second stage of the fit */ LauCartesianCPCoeffSet(const TString& compName, const Double_t x, const Double_t y, const Double_t deltaX, const Double_t deltaY, const Bool_t xFixed, const Bool_t yFixed, const Bool_t deltaXFixed, const Bool_t deltaYFixed, const Bool_t deltaXSecondStage = kFALSE, const Bool_t deltaYSecondStage = kFALSE); //! Move constructor (default) /*! \param [in] rhs the coefficient to clone */ LauCartesianCPCoeffSet(LauCartesianCPCoeffSet&& rhs) = default; - //! Move assignment operator (default) + //! Move assignment operator (delete) /*! \param [in] rhs the coefficient to clone */ - LauCartesianCPCoeffSet& operator=(LauCartesianCPCoeffSet&& rhs) = default; + LauCartesianCPCoeffSet& operator=(LauCartesianCPCoeffSet&& rhs) = delete; //! Determine the type of the coefficient /*! \return the type of the coefficient */ LauCoeffType type() const override { return LauCoeffType::CartesianCP; } //! Retrieve the parameters of the coefficient, e.g. so that they can be loaded into a fit /*! \return the parameters of the coefficient [ X, Y, DeltaX, DeltaY ] */ std::vector getParameters() override { return { x_.get(), y_.get(), deltaX_.get(), deltaY_.get() }; } //! Retrieve the (const) parameters of the coefficient, e.g. so that they can be queried /*! \return the (const) parameters of the coefficient [ X, Y, DeltaX, DeltaY ] */ std::vector getParameters() const override { return { x_.get(), y_.get(), deltaX_.get(), deltaY_.get() }; } //! Retrieve the names of the parameters of the coefficient (in the same order as the parameters in getParameters) /*! \return the parameter names [ X, Y, DeltaX, DeltaY ] */ std::vector getParNames() const override { return { "X", "Y", "DeltaX", "DeltaY" }; } //! Print the current values of the parameters void printParValues() const override; //! Print the column headings for a results table /*! \param [out] stream the stream to print to */ void printTableHeading(std::ostream& stream) const override; //! Print the parameters of the complex coefficient as a row in the results table /*! \param [out] stream the stream to print to */ void printTableRow(std::ostream& stream) const override; //! Randomise the starting values of the parameters for a fit void randomiseInitValues() override; //! Make sure values are in "standard" ranges, e.g. phases should be between -pi and pi void finaliseValues() override; //! Retrieve the complex coefficient for a particle /*! \return the complex coefficient for a particle */ const LauComplex& particleCoeff() override; //! Retrieve the complex coefficient for an antiparticle /*! \return the complex coefficient for an antiparticle */ const LauComplex& antiparticleCoeff() override; //! 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 */ void setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar, const Bool_t init ) override; //! Calculate the CP asymmetry /*! \return the CP asymmetry */ LauParameter acp() override; //! 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 to multiply the clone's parameters by \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)}; } private: //! Copy constructor (with options) /*! This creates cloned parameters, not copies. \param [in] rhs the coefficient to clone \param [in] cloneOption special option for the cloning operation \param [in] constFactor a constant factor to multiply the clone's parameters by \param [in] coeffInfo an optional JSON entry that contains the values of any non-cloned parameters (depending on the CloneOption) */ LauCartesianCPCoeffSet(const LauCartesianCPCoeffSet& rhs, CloneOption cloneOption = CloneOption::All, Double_t constFactor = 1.0, const nlohmann::json& coeffInfo = {}); //! Copy constructor (deleted) /*! \param [in] rhs the coefficient to clone */ LauCartesianCPCoeffSet(const LauCartesianCPCoeffSet& rhs) = delete; //! Copy assignment operator (deleted) /*! \param [in] rhs the coefficient to clone */ LauCartesianCPCoeffSet& operator=(const LauCartesianCPCoeffSet& rhs) = delete; //! 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 */ LauCartesianCPCoeffSet* createClone_impl(const TString& newName, const LauAbsCoeffSet::CloneOption cloneOption, const Double_t constFactor, const nlohmann::json& coeffInfo) const override; // the actual fit parameters // (need to be pointers so they can be cloned) //! The average real part std::unique_ptr x_; //! The average imaginary part std::unique_ptr y_; //! The asymmetric real part std::unique_ptr deltaX_; //! The asymmetric imaginary part std::unique_ptr deltaY_; //! The particle complex coefficient LauComplex particleCoeff_; //! The antiparticle complex coefficient LauComplex antiparticleCoeff_; //! The CP asymmetry LauParameter acp_; ClassDefOverride(LauCartesianCPCoeffSet, 0) }; //! \cond DOXYGEN_IGNORE namespace nlohmann { template <> struct adl_serializer { static LauCartesianCPCoeffSet from_json(const json& j); }; } //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauCartesianGammaCPCoeffSet.hh b/inc/LauCartesianGammaCPCoeffSet.hh index 28872f8..1b00bbc 100644 --- a/inc/LauCartesianGammaCPCoeffSet.hh +++ b/inc/LauCartesianGammaCPCoeffSet.hh @@ -1,258 +1,258 @@ /* 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 LauCartesianGammaCPCoeffSet.hh \brief File containing declaration of LauCartesianGammaCPCoeffSet class. */ /*! \class LauCartesianGammaCPCoeffSet \brief Class for defining a complex coefficient using the Cartesian gamma CP convention. Holds a set of real values that define the complex coefficient of an amplitude component. The amplitude has the form ( x + i * y ) * ( 1 + xCP +/- delta_xCP + i * ( yCP +/- delta_yCP ) ). [Phys. Rev. D79, 051301 (2009)] */ #ifndef LAU_CARTESIANGAMMACP_COEFF_SET #define LAU_CARTESIANGAMMACP_COEFF_SET #include #include #include #include "Rtypes.h" #include "LauAbsCoeffSet.hh" #include "LauComplex.hh" #include "LauParameter.hh" class LauCartesianGammaCPCoeffSet : public LauAbsCoeffSet { public: //! Constructor /*! \param [in] compName the name of the coefficient set \param [in] x the real nonCP part \param [in] y the imaginary nonCP part \param [in] xCP the average real CP part \param [in] yCP the average imaginary CP part \param [in] deltaXCP the asymmetric real CP part \param [in] deltaYCP the asymmetric imaginary CP part \param [in] xFixed whether x is fixed \param [in] yFixed whether y is fixed \param [in] xCPFixed whether xCP is fixed \param [in] yCPFixed whether yCP is fixed \param [in] deltaXCPFixed whether deltaXCP is fixed \param [in] deltaYCPFixed whether deltaYCP is fixed \param [in] deltaXCPSecondStage whether deltaXCP should be floated only in the second stage of the fit \param [in] deltaYCPSecondStage whether deltaYCP should be floated only in the second stage of the fit */ LauCartesianGammaCPCoeffSet(const TString& compName, const Double_t x, const Double_t y, const Double_t xCP, const Double_t yCP, const Double_t deltaXCP, const Double_t deltaYCP, const Bool_t xFixed, const Bool_t yFixed, const Bool_t xCPFixed, const Bool_t yCPFixed, const Bool_t deltaXCPFixed, const Bool_t deltaYCPFixed, const Bool_t deltaXCPSecondStage = kFALSE, const Bool_t deltaYCPSecondStage = kFALSE); //! Move constructor (default) /*! \param [in] rhs the coefficient to clone */ LauCartesianGammaCPCoeffSet(LauCartesianGammaCPCoeffSet&& rhs) = default; - //! Move assignment operator (default) + //! Move assignment operator (delete) /*! \param [in] rhs the coefficient to clone */ - LauCartesianGammaCPCoeffSet& operator=(LauCartesianGammaCPCoeffSet&& rhs) = default; + LauCartesianGammaCPCoeffSet& operator=(LauCartesianGammaCPCoeffSet&& rhs) = delete; //! Determine the type of the coefficient /*! \return the type of the coefficient */ LauCoeffType type() const override { return LauCoeffType::CartesianGammaCP; } //! Retrieve the parameters of the coefficient, e.g. so that they can be loaded into a fit /*! \return the parameters of the coefficient [ X, Y, XCP, YCP, DeltaXCP, DeltaYCP ] */ std::vector getParameters() override { return { x_.get(), y_.get(), xCP_.get(), yCP_.get(), deltaXCP_.get(), deltaYCP_.get() }; } //! Retrieve the (const) parameters of the coefficient, e.g. so that they can be queried /*! \return the (const) parameters of the coefficient [ X, Y, XCP, YCP, DeltaXCP, DeltaYCP ] */ std::vector getParameters() const override { return { x_.get(), y_.get(), xCP_.get(), yCP_.get(), deltaXCP_.get(), deltaYCP_.get() }; } //! Retrieve the names of the parameters of the coefficient (in the same order as the parameters in getParameters) /*! \return the parameter names [ X, Y, XCP, YCP, DeltaXCP, DeltaYCP ] */ std::vector getParNames() const override { return { "X", "Y", "XCP", "YCP", "DeltaXCP", "DeltaYCP" }; } //! Print the current values of the parameters void printParValues() const override; //! Print the column headings for a results table /*! \param [out] stream the stream to print to */ void printTableHeading(std::ostream& stream) const override; //! Print the parameters of the complex coefficient as a row in the results table /*! \param [out] stream the stream to print to */ void printTableRow(std::ostream& stream) const override; //! Randomise the starting values of the parameters for a fit void randomiseInitValues() override; //! Make sure values are in "standard" ranges, e.g. phases should be between -pi and pi void finaliseValues() override; //! Retrieve the complex coefficient for a particle /*! \return the complex coefficient for a particle */ const LauComplex& particleCoeff() override; //! Retrieve the complex coefficient for an antiparticle /*! \return the complex coefficient for an antiparticle */ const LauComplex& antiparticleCoeff() override; //! Set the parameters based on the complex coefficients for particles and antiparticles /*! This method is not supported by this class because there are more than four parameters so there is not a unique solution. \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 */ void setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar, const Bool_t init ) override; //! Calculate the CP asymmetry /*! \return the CP asymmetry */ LauParameter acp() override; //! 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 to multiply the clone's parameters by \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)}; } private: //! Copy constructor (with options) /*! This creates cloned parameters, not copies. \param [in] rhs the coefficient to clone \param [in] cloneOption special option for the cloning operation \param [in] constFactor a constant factor to multiply the clone's parameters by \param [in] coeffInfo an optional JSON entry that contains the values of any non-cloned parameters (depending on the CloneOption) */ LauCartesianGammaCPCoeffSet(const LauCartesianGammaCPCoeffSet& rhs, const CloneOption cloneOption = CloneOption::All, const Double_t constFactor = 1.0, const nlohmann::json& coeffInfo = {}); //! Copy constructor (deleted) /*! \param [in] rhs the coefficient to clone */ LauCartesianGammaCPCoeffSet(const LauCartesianGammaCPCoeffSet& rhs) = delete; //! Copy assignment operator (deleted) /*! \param [in] rhs the coefficient to clone */ LauCartesianGammaCPCoeffSet& operator=(const LauCartesianGammaCPCoeffSet& rhs) = delete; //! 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 */ LauCartesianGammaCPCoeffSet* createClone_impl(const TString& newName, const LauAbsCoeffSet::CloneOption cloneOption, const Double_t constFactor, const nlohmann::json& coeffInfo) const override; // the actual fit parameters // (need to be pointers so they can be cloned) //! The nonCP real part std::unique_ptr x_; //! The nonCP imaginary part std::unique_ptr y_; //! The average CP real part std::unique_ptr xCP_; //! The average CP imaginary part std::unique_ptr yCP_; //! The asymmetric CP real part std::unique_ptr deltaXCP_; //! The asymmetric CP imaginary part std::unique_ptr deltaYCP_; //! The nonCP part of the complex coefficient LauComplex nonCPPart_; //! The CP part of the complex coefficient for the particle LauComplex cpPart_; //! The CP part of the complex coefficient for the antiparticle LauComplex cpAntiPart_; //! The particle complex coefficient LauComplex particleCoeff_; //! The antiparticle complex coefficient LauComplex antiparticleCoeff_; //! The CP asymmetry LauParameter acp_; ClassDefOverride(LauCartesianGammaCPCoeffSet, 0) }; //! \cond DOXYGEN_IGNORE namespace nlohmann { template <> struct adl_serializer { static LauCartesianGammaCPCoeffSet from_json(const json& j); }; } //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauCleoCPCoeffSet.hh b/inc/LauCleoCPCoeffSet.hh index c619c47..24fd5d5 100644 --- a/inc/LauCleoCPCoeffSet.hh +++ b/inc/LauCleoCPCoeffSet.hh @@ -1,246 +1,246 @@ /* 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 LauCleoCPCoeffSet.hh \brief File containing declaration of LauCleoCPCoeffSet class. */ /*! \class LauCleoCPCoeffSet \brief Class for defining a complex coefficient using the Cleo CP convention. Holds a set of real values that define the complex coefficient of an amplitude component. The amplitude has the form (a +/- b) * exp( i*(delta +/- phi) ) where a is the average magnitude, b is the asymmetric magnitude, delta is the strong phase and phi is the weak phase. [Phys.Rev. D70 (2004) 091101] */ #ifndef LAU_CLEOCP_COEFF_SET #define LAU_CLEOCP_COEFF_SET #include #include #include #include "Rtypes.h" #include "LauAbsCoeffSet.hh" #include "LauComplex.hh" #include "LauParameter.hh" class LauCleoCPCoeffSet : public LauAbsCoeffSet { public: //! Constructor /*! \param [in] compName the name of the coefficient set \param [in] a the magnitude a \param [in] delta the strong phase \param [in] b the magnitude b \param [in] phi the weak phase \param [in] aFixed whether a is fixed \param [in] deltaFixed whether delta is fixed \param [in] bFixed whether b is fixed \param [in] phiFixed whether phi is fixed \param [in] bSecondStage whether b should be floated only in the second stage of the fit \param [in] phiSecondStage whether phi should be floated only in the second stage of the fit */ LauCleoCPCoeffSet(const TString& compName, const Double_t a, const Double_t delta, const Double_t b, const Double_t phi, const Bool_t aFixed, const Bool_t deltaFixed, const Bool_t bFixed, const Bool_t phiFixed, const Bool_t bSecondStage = kFALSE, const Bool_t phiSecondStage = kFALSE); //! Move constructor (default) /*! \param [in] rhs the coefficient to clone */ LauCleoCPCoeffSet(LauCleoCPCoeffSet&& rhs) = default; - //! Move assignment operator (default) + //! Move assignment operator (delete) /*! \param [in] rhs the coefficient to clone */ - LauCleoCPCoeffSet& operator=(LauCleoCPCoeffSet&& rhs) = default; + LauCleoCPCoeffSet& operator=(LauCleoCPCoeffSet&& rhs) = delete; //! Determine the type of the coefficient /*! \return the type of the coefficient */ LauCoeffType type() const override { return LauCoeffType::CleoCP; } //! Retrieve the parameters of the coefficient, e.g. so that they can be loaded into a fit /*! \return the parameters of the coefficient [ A, Delta, B, Phi ] */ std::vector getParameters() override { return { a_.get(), delta_.get(), b_.get(), phi_.get() }; } //! Retrieve the (const) parameters of the coefficient, e.g. so that they can be queried /*! \return the (const) parameters of the coefficient [ A, Delta, B, Phi ] */ std::vector getParameters() const override { return { a_.get(), delta_.get(), b_.get(), phi_.get() }; } //! Retrieve the names of the parameters of the coefficient (in the same order as the parameters in getParameters) /*! \return the parameter names [ A, Delta, B, Phi ] */ std::vector getParNames() const override { return { "A", "Delta", "B", "Phi" }; } //! Print the current values of the parameters void printParValues() const override; //! Print the column headings for a results table /*! \param [out] stream the stream to print to */ void printTableHeading(std::ostream& stream) const override; //! Print the parameters of the complex coefficient as a row in the results table /*! \param [out] stream the stream to print to */ void printTableRow(std::ostream& stream) const override; //! Randomise the starting values of the parameters for a fit void randomiseInitValues() override; //! Make sure values are in "standard" ranges, e.g. phases should be between -pi and pi void finaliseValues() override; //! Retrieve the complex coefficient for a particle /*! return the complex coefficient for a particle */ const LauComplex& particleCoeff() override; //! Retrieve the complex coefficient for an antiparticle /*! \return the complex coefficient for an antiparticle */ const LauComplex& antiparticleCoeff() override; //! 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 */ void setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar, const Bool_t init ) override; //! Calculate the CP asymmetry /*! \return the CP asymmetry */ LauParameter acp() override; //! 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 to multiply the clone's parameters by \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)}; } private: //! Copy constructor (with options) /*! This creates cloned parameters, not copies. \param [in] rhs the coefficient to clone \param [in] cloneOption special option for the cloning operation \param [in] constFactor a constant factor to multiply the clone's parameters by \param [in] coeffInfo an optional JSON entry that contains the values of any non-cloned parameters (depending on the CloneOption) */ LauCleoCPCoeffSet(const LauCleoCPCoeffSet& rhs, const CloneOption cloneOption = CloneOption::All, const Double_t constFactor = 1.0, const nlohmann::json& coeffInfo = {}); //! Copy constructor (deleted) /*! \param [in] rhs the coefficient to clone */ LauCleoCPCoeffSet(const LauCleoCPCoeffSet& rhs) = delete; //! Copy assignment operator (deleted) /*! \param [in] rhs the coefficient to clone */ LauCleoCPCoeffSet& operator=(const LauCleoCPCoeffSet& rhs) = delete; //! 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 */ LauCleoCPCoeffSet* createClone_impl(const TString& newName, const LauAbsCoeffSet::CloneOption cloneOption, const Double_t constFactor, const nlohmann::json& coeffInfo) const override; // the actual fit parameters // (need to be pointers so they can be cloned) //! The magnitude a std::unique_ptr a_; //! The magnitude b std::unique_ptr b_; //! The strong phase std::unique_ptr delta_; //! The weak phase std::unique_ptr phi_; //! The particle complex coefficient LauComplex particleCoeff_; //! The antiparticle complex coefficient LauComplex antiparticleCoeff_; //! The CP asymmetry LauParameter acp_; ClassDefOverride(LauCleoCPCoeffSet, 0) }; //! \cond DOXYGEN_IGNORE namespace nlohmann { template <> struct adl_serializer { static LauCleoCPCoeffSet from_json(const json& j); }; } //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauMagPhaseCPCoeffSet.hh b/inc/LauMagPhaseCPCoeffSet.hh index a2255e9..3267719 100644 --- a/inc/LauMagPhaseCPCoeffSet.hh +++ b/inc/LauMagPhaseCPCoeffSet.hh @@ -1,242 +1,242 @@ /* Copyright 2011 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 LauMagPhaseCPCoeffSet.hh \brief File containing declaration of LauMagPhaseCPCoeffSet class. */ /*! \class LauMagPhaseCPCoeffSet \brief Class for defining a complex coefficient using seperate magnitudes and phases for particles and antiparticles. Holds a set of real values that define the complex coefficient of an amplitude component. The amplitudes have the form: c = mag * exp(i*phase) cBar = magBar * exp(i*phaseBar) where mag and magBar are the magnitudes for particle and antiparticle and phase and phaseBar are the phases for particle and antiparticle. */ #ifndef LAU_MAGPHASECP_COEFF_SET #define LAU_MAGPHASECP_COEFF_SET #include #include #include #include "Rtypes.h" #include "LauAbsCoeffSet.hh" #include "LauComplex.hh" #include "LauParameter.hh" class LauMagPhaseCPCoeffSet : public LauAbsCoeffSet { public: //! Constructor /*! \param [in] compName the name of the coefficient set \param [in] mag the magnitude for particles \param [in] phase the phase for particles \param [in] magBar the magnitude for antiparticles \param [in] phaseBar the phase for antiparticles \param [in] magFixed whether mag is fixed \param [in] phaseFixed whether phase is fixed \param [in] magBarFixed whether magBar is fixed \param [in] phaseBarFixed whether phaseBar is fixed */ LauMagPhaseCPCoeffSet(const TString& compName, const Double_t mag, const Double_t phase, const Double_t magBar, const Double_t phaseBar, const Bool_t magFixed, const Bool_t phaseFixed, const Bool_t magBarFixed, const Bool_t phaseBarFixed); //! Move constructor (default) /*! \param [in] rhs the coefficient to clone */ LauMagPhaseCPCoeffSet(LauMagPhaseCPCoeffSet&& rhs) = default; - //! Move assignment operator (default) + //! Move assignment operator (delete) /*! \param [in] rhs the coefficient to clone */ - LauMagPhaseCPCoeffSet& operator=(LauMagPhaseCPCoeffSet&& rhs) = default; + LauMagPhaseCPCoeffSet& operator=(LauMagPhaseCPCoeffSet&& rhs) = delete; //! Determine the type of the coefficient /*! \return the type of the coefficient */ LauCoeffType type() const override { return LauCoeffType::MagPhaseCP; } //! Retrieve the parameters of the coefficient, e.g. so that they can be loaded into a fit /*! \return the parameters of the coefficient [ Mag, Phase, MagBar, PhaseBar ] */ std::vector getParameters() override { return { mag_.get(), phase_.get(), magBar_.get(), phaseBar_.get() }; } //! Retrieve the (const) parameters of the coefficient, e.g. so that they can be queried /*! \return the (const) parameters of the coefficient [ Mag, Phase, MagBar, PhaseBar ] */ std::vector getParameters() const override { return { mag_.get(), phase_.get(), magBar_.get(), phaseBar_.get() }; } //! Retrieve the names of the parameters of the coefficient (in the same order as the parameters in getParameters) /*! \return the parameter names [ Mag, Phase, MagBar, PhaseBar ] */ std::vector getParNames() const override { return { "Mag", "Phase", "MagBar", "PhaseBar" }; } //! Print the current values of the parameters void printParValues() const override; //! Print the column headings for a results table /*! \param [out] stream the stream to print to */ void printTableHeading(std::ostream& stream) const override; //! Print the parameters of the complex coefficient as a row in the results table /*! \param [out] stream the stream to print to */ void printTableRow(std::ostream& stream) const override; //! Randomise the starting values of the parameters for a fit void randomiseInitValues() override; //! Make sure values are in "standard" ranges, e.g. phases should be between -pi and pi void finaliseValues() override; //! Retrieve the complex coefficient for a particle /*! \return the complex coefficient for a particle */ const LauComplex& particleCoeff() override; //! Retrieve the complex coefficient for an antiparticle /*! \return the complex coefficient for an antiparticle */ const LauComplex& antiparticleCoeff() override; //! 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 */ void setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar, Bool_t init ) override; //! Calculate the CP asymmetry /*! \return the CP asymmetry */ LauParameter acp() override; //! 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 to multiply the clone's parameters by \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)}; } private: //! Copy constructor (with options) /*! This creates cloned parameters, not copies. \param [in] rhs the coefficient to clone \param [in] cloneOption special option for the cloning operation \param [in] constFactor a constant factor to multiply the clone's parameters by \param [in] coeffInfo an optional JSON entry that contains the values of any non-cloned parameters (depending on the CloneOption) */ LauMagPhaseCPCoeffSet(const LauMagPhaseCPCoeffSet& rhs, CloneOption cloneOption = CloneOption::All, Double_t constFactor = 1.0, const nlohmann::json& coeffInfo = {}); //! Copy constructor (deleted) /*! \param [in] rhs the coefficient to clone */ LauMagPhaseCPCoeffSet(const LauMagPhaseCPCoeffSet& rhs) = delete; //! Copy assignment operator (deleted) /*! \param [in] rhs the coefficient to clone */ LauMagPhaseCPCoeffSet& operator=(const LauMagPhaseCPCoeffSet& rhs) = delete; //! 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 */ LauMagPhaseCPCoeffSet* createClone_impl(const TString& newName, const LauAbsCoeffSet::CloneOption cloneOption, const Double_t constFactor, const nlohmann::json& coeffInfo) const override; // the actual fit parameters // (need to be pointers so they can be cloned) //! The magnitude for particles std::unique_ptr mag_; //! The phase for particles std::unique_ptr phase_; //! The magnitude for antiparticles std::unique_ptr magBar_; //! The phase for antiparticles std::unique_ptr phaseBar_; //! The particle complex coefficient LauComplex particleCoeff_; //! The antiparticle complex coefficient LauComplex antiparticleCoeff_; //! The CP asymmetry LauParameter acp_; ClassDefOverride(LauMagPhaseCPCoeffSet, 0) }; //! \cond DOXYGEN_IGNORE namespace nlohmann { template <> struct adl_serializer { static LauMagPhaseCPCoeffSet from_json(const json& j); }; } //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauMagPhaseCoeffSet.hh b/inc/LauMagPhaseCoeffSet.hh index e13257a..ad8aa10 100644 --- a/inc/LauMagPhaseCoeffSet.hh +++ b/inc/LauMagPhaseCoeffSet.hh @@ -1,225 +1,225 @@ /* 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 LauMagPhaseCoeffSet.hh \brief File containing declaration of LauMagPhaseCoeffSet class. */ /*! \class LauMagPhaseCoeffSet \brief Class for defining a complex coefficient using a magnitude and a phase. Holds a set of real values that define the complex coefficient of an amplitude component. The amplitude has the form mag*exp(i*phase). */ #ifndef LAU_MAGPHASE_COEFF_SET #define LAU_MAGPHASE_COEFF_SET #include #include #include #include "Rtypes.h" #include "LauAbsCoeffSet.hh" #include "LauComplex.hh" #include "LauParameter.hh" class LauMagPhaseCoeffSet : public LauAbsCoeffSet { public: //! Constructor /*! \param [in] compName the name of the coefficient set \param [in] magnitude the magnitude \param [in] phase the phase \param [in] magFixed whether mag is fixed \param [in] phaseFixed whether phase is fixed */ LauMagPhaseCoeffSet(const TString& compName, const Double_t magnitude, const Double_t phase, const Bool_t magFixed, const Bool_t phaseFixed); //! Move constructor (default) /*! \param [in] rhs the coefficient to clone */ LauMagPhaseCoeffSet(LauMagPhaseCoeffSet&& rhs) = default; - //! Move assignment operator (default) + //! Move assignment operator (delete) /*! \param [in] rhs the coefficient to clone */ - LauMagPhaseCoeffSet& operator=(LauMagPhaseCoeffSet&& rhs) = default; + LauMagPhaseCoeffSet& operator=(LauMagPhaseCoeffSet&& rhs) = delete; //! Determine the type of the coefficient /*! \return the type of the coefficient */ LauCoeffType type() const override { return LauCoeffType::MagPhase; } //! Retrieve the parameters of the coefficient, e.g. so that they can be loaded into a fit /*! \return the parameters of the coefficient [ Mag, Phase ] */ std::vector getParameters() override { return { magnitude_.get(), phase_.get() }; } //! Retrieve the (const) parameters of the coefficient, e.g. so that they can be queried /*! \return the (const) parameters of the coefficient [ Mag, Phase ] */ std::vector getParameters() const override { return { magnitude_.get(), phase_.get() }; } //! Retrieve the names of the parameters of the coefficient (in the same order as the parameters in getParameters) /*! \return the parameter names [ Mag, Phase ] */ std::vector getParNames() const override { return { "Mag", "Phase" }; } //! Print the current values of the parameters void printParValues() const override; //! Print the column headings for a results table /*! \param [out] stream the stream to print to */ void printTableHeading(std::ostream& stream) const override; //! Print the parameters of the complex coefficient as a row in the results table /*! \param [out] stream the stream to print to */ void printTableRow(std::ostream& stream) const override; //! Randomise the starting values of the parameters for a fit void randomiseInitValues() override; //! Make sure values are in "standard" ranges, e.g. phases should be between -pi and pi void finaliseValues() override; //! Retrieve the complex coefficient for a particle /*! \return the complex coefficient for a particle */ const LauComplex& particleCoeff() override; //! Retrieve the complex coefficient for an antiparticle /*! \return the complex coefficient for an antiparticle */ const LauComplex& antiparticleCoeff() override; //! Set the parameters based on the complex coefficients for particles and antiparticles /*! This class does not support CP violation so this method takes the average of the two inputs. \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 */ void setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar, const Bool_t init ) override; //! Calculate the CP asymmetry /*! \return the CP asymmetry (zero by design) */ LauParameter acp() override; //! 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 to multiply the clone's parameters by \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)}; } private: //! Copy constructor (with options) /*! This creates cloned parameters, not copies. \param [in] rhs the coefficient to clone \param [in] cloneOption special option for the cloning operation \param [in] constFactor a constant factor to multiply the clone's parameters by \param [in] coeffInfo an optional JSON entry that contains the values of any non-cloned parameters (depending on the CloneOption) */ LauMagPhaseCoeffSet(const LauMagPhaseCoeffSet& rhs, const CloneOption cloneOption = CloneOption::All, const Double_t constFactor = 1.0, const nlohmann::json& coeffInfo = {}); //! Copy constructor (deleted) /*! \param [in] rhs the coefficient to clone */ LauMagPhaseCoeffSet(const LauMagPhaseCoeffSet& rhs) = delete; //! Copy assignment operator (deleted) /*! \param [in] rhs the coefficient to clone */ LauMagPhaseCoeffSet& operator=(const LauMagPhaseCoeffSet& rhs) = delete; //! 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 */ LauMagPhaseCoeffSet* createClone_impl(const TString& newName, const CloneOption cloneOption, const Double_t constFactor, const nlohmann::json& coeffInfo) const override; // the actual fit parameters // (need to be pointers so they can be cloned) //! The magnitude std::unique_ptr magnitude_; //! The phase std::unique_ptr phase_; //! The complex coefficient LauComplex coeff_; ClassDefOverride(LauMagPhaseCoeffSet, 0) }; //! \cond DOXYGEN_IGNORE namespace nlohmann { template <> struct adl_serializer { static LauMagPhaseCoeffSet from_json(const json& j); }; } //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauRealImagCPCoeffSet.hh b/inc/LauRealImagCPCoeffSet.hh index cf32f27..56affef 100644 --- a/inc/LauRealImagCPCoeffSet.hh +++ b/inc/LauRealImagCPCoeffSet.hh @@ -1,241 +1,241 @@ /* 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 LauRealImagCPCoeffSet.hh \brief File containing declaration of LauRealImagCPCoeffSet class. */ /*! \class LauRealImagCPCoeffSet \brief Class for defining a complex coefficient using a simple Cartesian CP convention. Holds a set of real values that define the complex coefficient of an amplitude component. The amplitudes have the form: c = x + i * y cbar = xbar + i * ybar */ #ifndef LAU_REALIMAGCP_COEFF_SET #define LAU_REALIMAGCP_COEFF_SET #include #include #include #include "Rtypes.h" #include "LauAbsCoeffSet.hh" #include "LauComplex.hh" #include "LauParameter.hh" class LauRealImagCPCoeffSet : public LauAbsCoeffSet { public: //! Constructor /*! \param [in] compName the name of the coefficient set \param [in] x the real part for the particle \param [in] y the imaginary part for the particle \param [in] xbar the real part for the antiparticle \param [in] ybar the imaginary part for the antiparticle \param [in] xFixed whether x is fixed \param [in] yFixed whether y is fixed \param [in] xbarFixed whether xbar is fixed \param [in] ybarFixed whether ybar is fixed */ LauRealImagCPCoeffSet(const TString& compName, const Double_t x, const Double_t y, const Double_t xbar, const Double_t ybar, const Bool_t xFixed, const Bool_t yFixed, const Bool_t xbarFixed, const Bool_t ybarFixed); //! Move constructor (default) /*! \param [in] rhs the coefficient to clone */ LauRealImagCPCoeffSet(LauRealImagCPCoeffSet&& rhs) = default; - //! Move assignment operator (default) + //! Move assignment operator (delete) /*! \param [in] rhs the coefficient to clone */ - LauRealImagCPCoeffSet& operator=(LauRealImagCPCoeffSet&& rhs) = default; + LauRealImagCPCoeffSet& operator=(LauRealImagCPCoeffSet&& rhs) = delete; //! Determine the type of the coefficient /*! \return the type of the coefficient */ LauCoeffType type() const override { return LauCoeffType::RealImagCP; } //! Retrieve the parameters of the coefficient, e.g. so that they can be loaded into a fit /*! \return the parameters of the coefficient [ X, Y, XBar, YBar ] */ std::vector getParameters() override { return { x_.get(), y_.get(), xbar_.get(), ybar_.get() }; } //! Retrieve the (const) parameters of the coefficient, e.g. so that they can be queried /*! \return the (const) parameters of the coefficient [ X, Y, XBar, YBar ] */ std::vector getParameters() const override { return { x_.get(), y_.get(), xbar_.get(), ybar_.get() }; } //! Retrieve the names of the parameters of the coefficient (in the same order as the parameters in getParameters) /*! \return the parameter names [ X, Y, XBar, YBar ] */ std::vector getParNames() const override { return { "X", "Y", "XBar", "YBar" }; } //! Print the current values of the parameters void printParValues() const override; //! Print the column headings for a results table /*! \param [out] stream the stream to print to */ void printTableHeading(std::ostream& stream) const override; //! Print the parameters of the complex coefficient as a row in the results table /*! \param [out] stream the stream to print to */ void printTableRow(std::ostream& stream) const override; //! Randomise the starting values of the parameters for a fit void randomiseInitValues() override; //! Make sure values are in "standard" ranges, e.g. phases should be between -pi and pi void finaliseValues() override; //! Retrieve the complex coefficient for a particle /*! \return the complex coefficient for a particle */ const LauComplex& particleCoeff() override; //! Retrieve the complex coefficient for an antiparticle /*! \return the complex coefficient for an antiparticle */ const LauComplex& antiparticleCoeff() override; //! 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 */ void setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar, Bool_t init ) override; //! Calculate the CP asymmetry /*! \return the CP asymmetry */ LauParameter acp() override; //! 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 to multiply the clone's parameters by \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)}; } private: //! Copy constructor (with options) /*! This creates cloned parameters, not copies. \param [in] rhs the coefficient to clone \param [in] cloneOption special option for the cloning operation \param [in] constFactor a constant factor to multiply the clone's parameters by \param [in] coeffInfo an optional JSON entry that contains the values of any non-cloned parameters (depending on the CloneOption) */ LauRealImagCPCoeffSet(const LauRealImagCPCoeffSet& rhs, CloneOption cloneOption = CloneOption::All, Double_t constFactor = 1.0, const nlohmann::json& coeffInfo = {}); //! Copy constructor (deleted) /*! \param [in] rhs the coefficient to clone */ LauRealImagCPCoeffSet(const LauRealImagCPCoeffSet& rhs) = delete; //! Copy assignment operator (deleted) /*! \param [in] rhs the coefficient to clone */ LauRealImagCPCoeffSet& operator=(const LauRealImagCPCoeffSet& rhs) = delete; //! 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 */ LauRealImagCPCoeffSet* createClone_impl(const TString& newName, const LauAbsCoeffSet::CloneOption cloneOption, const Double_t constFactor, const nlohmann::json& coeffInfo) const override; // the actual fit parameters // (need to be pointers so they can be cloned) //! The real part for the particle std::unique_ptr x_; //! The imaginary part for the particle std::unique_ptr y_; //! The real part for the antiparticle std::unique_ptr xbar_; //! The imaginary part for the antiparticle std::unique_ptr ybar_; //! The particle complex coefficient LauComplex particleCoeff_; //! The antiparticle complex coefficient LauComplex antiparticleCoeff_; //! The CP asymmetry LauParameter acp_; ClassDefOverride(LauRealImagCPCoeffSet, 0) }; //! \cond DOXYGEN_IGNORE namespace nlohmann { template <> struct adl_serializer { static LauRealImagCPCoeffSet from_json(const json& j); }; } //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauRealImagCoeffSet.hh b/inc/LauRealImagCoeffSet.hh index b0c8836..4f2945c 100644 --- a/inc/LauRealImagCoeffSet.hh +++ b/inc/LauRealImagCoeffSet.hh @@ -1,227 +1,227 @@ /* 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 LauRealImagCoeffSet.hh \brief File containing declaration of LauRealImagCoeffSet class. */ #ifndef LAU_REALIMAG_COEFF_SET #define LAU_REALIMAG_COEFF_SET #include "LauAbsCoeffSet.hh" #include "LauComplex.hh" #include "LauParameter.hh" #include "Rtypes.h" #include #include #include #include /*! \class LauRealImagCoeffSet \brief Class for defining a complex coefficient using real and imaginary parts. Holds a set of real values that define the complex coefficient of an amplitude component. The amplitude has the form x + i*y. */ class LauRealImagCoeffSet : public LauAbsCoeffSet { public: //! Constructor /*! \param [in] compName the name of the coefficient set \param [in] x the real part \param [in] y the imaginary part \param [in] xFixed whether x is fixed \param [in] yFixed whether y is fixed */ LauRealImagCoeffSet(const TString& compName, const Double_t x, const Double_t y, const Bool_t xFixed, const Bool_t yFixed); //! Move constructor (default) /*! \param [in] rhs the coefficient to clone */ LauRealImagCoeffSet(LauRealImagCoeffSet&& rhs) = default; - //! Move assignment operator (default) + //! Move assignment operator (delete) /*! \param [in] rhs the coefficient to clone */ - LauRealImagCoeffSet& operator=(LauRealImagCoeffSet&& rhs) = default; + LauRealImagCoeffSet& operator=(LauRealImagCoeffSet&& rhs) = delete; //! Determine the type of the coefficient /*! \return the type of the coefficient */ LauCoeffType type() const override { return LauCoeffType::RealImag; } //! Retrieve the parameters of the coefficient, e.g. so that they can be loaded into a fit /*! \return the parameters of the coefficient [ X, Y ] */ std::vector getParameters() override { return { x_.get(), y_.get() }; } //! Retrieve the (const) parameters of the coefficient, e.g. so that they can be queried /*! \return the (const) parameters of the coefficient [ X, Y ] */ std::vector getParameters() const override { return { x_.get(), y_.get() }; } //! Retrieve the names of the parameters of the coefficient (in the same order as the parameters in getParameters) /*! \return the parameter names [ X, Y ] */ std::vector getParNames() const override { return { "X", "Y" }; } //! Print the current values of the parameters void printParValues() const override; //! Print the column headings for a results table /*! \param [out] stream the stream to print to */ void printTableHeading(std::ostream& stream) const override; //! Print the parameters of the complex coefficient as a row in the results table /*! \param [out] stream the stream to print to */ void printTableRow(std::ostream& stream) const override; //! Randomise the starting values of the parameters for a fit void randomiseInitValues() override; //! Make sure values are in "standard" ranges, e.g. phases should be between -pi and pi void finaliseValues() override; //! Retrieve the complex coefficient for a particle /*! \return the complex coefficient for a particle */ const LauComplex& particleCoeff() override; //! Retrieve the complex coefficient for an antiparticle /*! \return the complex coefficient for an antiparticle */ const LauComplex& antiparticleCoeff() override; //! Set the parameters based on the complex coefficients for particles and antiparticles /*! This class does not support CP violation so this method takes the average of the two inputs. \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 */ void setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar, Bool_t init ) override; //! Calculate the CP asymmetry /*! \return the CP asymmetry (zero by design) */ LauParameter acp() override; //! 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 to multiply the clone's parameters by \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)}; } private: //! Copy constructor (with options) /*! This creates cloned parameters, not copies. \param [in] rhs the coefficient to clone \param [in] cloneOption special option for the cloning operation \param [in] constFactor a constant factor to multiply the clone's parameters by \param [in] coeffInfo an optional JSON entry that contains the values of any non-cloned parameters (depending on the CloneOption) */ LauRealImagCoeffSet(const LauRealImagCoeffSet& rhs, const CloneOption cloneOption = CloneOption::All, const Double_t constFactor = 1.0, const nlohmann::json& coeffInfo = {}); //! Copy constructor (deleted) /*! \param [in] rhs the coefficient to clone */ LauRealImagCoeffSet(const LauRealImagCoeffSet& rhs) = delete; //! Copy assignment operator (deleted) /*! \param [in] rhs the coefficient to clone */ LauRealImagCoeffSet& operator=(const LauRealImagCoeffSet& rhs) = delete; //! 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 */ LauRealImagCoeffSet* createClone_impl(const TString& newName, const LauAbsCoeffSet::CloneOption cloneOption, const Double_t constFactor, const nlohmann::json& coeffInfo) const override; // the actual fit parameters // (need to be pointers so they can be cloned) //! The real part std::unique_ptr x_; //! The imaginary part std::unique_ptr y_; //! The complex coefficient LauComplex coeff_; ClassDefOverride(LauRealImagCoeffSet, 0) }; //! \cond DOXYGEN_IGNORE namespace nlohmann { template <> struct adl_serializer { static LauRealImagCoeffSet from_json(const json& j); }; } //! \endcond DOXYGEN_IGNORE #endif diff --git a/inc/LauRealImagGammaCPCoeffSet.hh b/inc/LauRealImagGammaCPCoeffSet.hh index 82cc46d..5759c5e 100644 --- a/inc/LauRealImagGammaCPCoeffSet.hh +++ b/inc/LauRealImagGammaCPCoeffSet.hh @@ -1,278 +1,278 @@ /* 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 LauRealImagGammaCPCoeffSet.hh \brief File containing declaration of LauRealImagGammaCPCoeffSet class. */ /*! \class LauRealImagGammaCPCoeffSet \brief Class for defining a complex coefficient using a Cartesian nonCP part multiplied by a simple Cartesian CP convention. Holds a set of real values that define the complex coefficient of an amplitude component. The amplitudes have the form: c = ( x + i * y ) * ( 1 + xCP + i * yCP ) cbar = ( x + i * y ) * ( 1 + xbarCP + i * ybarCP ) [Phys. Rev. D79, 051301 (2009)] */ #ifndef LAU_REALIMAGGAMMACP_COEFF_SET #define LAU_REALIMAGGAMMACP_COEFF_SET #include #include #include #include "Rtypes.h" #include "LauAbsCoeffSet.hh" #include "LauComplex.hh" #include "LauParameter.hh" class LauRealImagGammaCPCoeffSet : public LauAbsCoeffSet { public: //! Constructor /*! \param [in] compName the name of the coefficient set \param [in] x the real nonCP part \param [in] y the imaginary nonCP part \param [in] xCP the real CP part for the particle \param [in] yCP the imaginary CP part for the particle \param [in] xbarCP the real CP part for the antiparticle \param [in] ybarCP the imaginary CP part for the antiparticle \param [in] xFixed whether x is fixed \param [in] yFixed whether y is fixed \param [in] xCPFixed whether x is fixed \param [in] yCPFixed whether y is fixed \param [in] xbarCPFixed whether xbar is fixed \param [in] ybarCPFixed whether ybar is fixed */ LauRealImagGammaCPCoeffSet(const TString& compName, const Double_t x, const Double_t y, const Double_t xCP, const Double_t yCP, const Double_t xbarCP, const Double_t ybarCP, const Bool_t xFixed, const Bool_t yFixed, const Bool_t xCPFixed, const Bool_t yCPFixed, const Bool_t xbarCPFixed, const Bool_t ybarCPFixed); //! Move constructor (default) /*! \param [in] rhs the coefficient to clone */ LauRealImagGammaCPCoeffSet(LauRealImagGammaCPCoeffSet&& rhs) = default; - //! Move assignment operator (default) + //! Move assignment operator (delete) /*! \param [in] rhs the coefficient to clone */ - LauRealImagGammaCPCoeffSet& operator=(LauRealImagGammaCPCoeffSet&& rhs) = default; + LauRealImagGammaCPCoeffSet& operator=(LauRealImagGammaCPCoeffSet&& rhs) = delete; //! Determine the type of the coefficient /*! \return the type of the coefficient */ LauCoeffType type() const override { return LauCoeffType::RealImagGammaCP; } //! Retrieve the parameters of the coefficient, e.g. so that they can be loaded into a fit /*! \return the parameters of the coefficient [ X, Y, XCP, YCP, XBarCP, YBarCP ] */ std::vector getParameters() override { return { x_.get(), y_.get(), xCP_.get(), yCP_.get(), xbarCP_.get(), ybarCP_.get() }; } //! Retrieve the (const) parameters of the coefficient, e.g. so that they can be queried /*! \return the (const) parameters of the coefficient [ X, Y, XCP, YCP, XBarCP, YBarCP ] */ std::vector getParameters() const override { return { x_.get(), y_.get(), xCP_.get(), yCP_.get(), xbarCP_.get(), ybarCP_.get() }; } //! Retrieve the names of the parameters of the coefficient (in the same order as the parameters in getParameters) /*! \return the parameter names [ X, Y, XCP, YCP, XBarCP, YBarCP ] */ std::vector getParNames() const override { return { "X", "Y", "XCP", "YCP", "XBarCP", "YBarCP" }; } //! Print the current values of the parameters void printParValues() const override; //! Print the column headings for a results table /*! \param [out] stream the stream to print to */ void printTableHeading(std::ostream& stream) const override; //! Print the parameters of the complex coefficient as a row in the results table /*! \param [out] stream the stream to print to */ void printTableRow(std::ostream& stream) const override; //! Randomise the starting values of the parameters for a fit void randomiseInitValues() override; //! Make sure values are in "standard" ranges, e.g. phases should be between -pi and pi void finaliseValues() override; //! Retrieve the complex coefficient for a particle /*! \return the complex coefficient for a particle */ const LauComplex& particleCoeff() override; //! Retrieve the complex coefficient for an antiparticle /*! \return the complex coefficient for an antiparticle */ const LauComplex& antiparticleCoeff() override; //! Set the parameters based on the complex coefficients for particles and antiparticles /*! This method is not supported by this class because there are more than four parameters so there is not a unique solution. \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 */ void setCoeffValues( const LauComplex& coeff, const LauComplex& coeffBar, Bool_t init ) override; //! Calculate the CP asymmetry /*! \return the CP asymmetry */ LauParameter acp() override; //! 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 to multiply the clone's parameters by \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)}; } private: //! Copy constructor (with options) /*! This creates cloned parameters, not copies. \param [in] rhs the coefficient to clone \param [in] cloneOption special option for the cloning operation \param [in] constFactor a constant factor to multiply the clone's parameters by \param [in] coeffInfo an optional JSON entry that contains the values of any non-cloned parameters (depending on the CloneOption) */ LauRealImagGammaCPCoeffSet(const LauRealImagGammaCPCoeffSet& rhs, const CloneOption cloneOption = CloneOption::All, const Double_t constFactor = 1.0, const nlohmann::json& coeffInfo = {}); //! Copy constructor (deleted) /*! \param [in] rhs the coefficient to clone */ LauRealImagGammaCPCoeffSet(const LauRealImagGammaCPCoeffSet& rhs) = delete; //! Copy assignment operator (deleted) /*! \param [in] rhs the coefficient to clone */ LauRealImagGammaCPCoeffSet& operator=(const LauRealImagGammaCPCoeffSet& rhs) = delete; //! 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 */ LauRealImagGammaCPCoeffSet* createClone_impl(const TString& newName, const CloneOption cloneOption, const Double_t constFactor, const nlohmann::json& coeffInfo) const override; // the actual fit parameters // (need to be pointers so they can be cloned) //! The real nonCP part std::unique_ptr x_; //! The imaginary nonCP part std::unique_ptr y_; //! The real CP part for the particle std::unique_ptr xCP_; //! The imaginary CP part for the particle std::unique_ptr yCP_; //! The real CP part for the antiparticle std::unique_ptr xbarCP_; //! The imaginary CP part for the antiparticle std::unique_ptr ybarCP_; //! The nonCP part of the complex coefficient LauComplex nonCPPart_; //! The CP part of the complex coefficient for the particle LauComplex cpPart_; //! The CP part of the complex coefficient for the antiparticle LauComplex cpAntiPart_; //! The particle complex coefficient LauComplex particleCoeff_; //! The antiparticle complex coefficient LauComplex antiparticleCoeff_; //! The CP asymmetry LauParameter acp_; ClassDefOverride(LauRealImagGammaCPCoeffSet, 0) }; //! \cond DOXYGEN_IGNORE namespace nlohmann { template <> struct adl_serializer { static LauRealImagGammaCPCoeffSet from_json(const json& j); }; } //! \endcond DOXYGEN_IGNORE #endif diff --git a/src/LauAbsCoeffSet.cc b/src/LauAbsCoeffSet.cc index 80051e1..d312dc1 100644 --- a/src/LauAbsCoeffSet.cc +++ b/src/LauAbsCoeffSet.cc @@ -1,436 +1,442 @@ /* 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, clone status and all non-cloned parameters + // 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]; - const auto& parName = parNames[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"}; - const TString parNameBlindingString {parName+"BlindingString"}; - const TString parNameBlindingWidth {parName+"BlindingWidth"}; 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" -//! \cond DOXYGEN_IGNORE -void nlohmann::adl_serializer::to_json( json& j, const LauAbsCoeffSet& t ) -{ - t.serialiseToJson(j); -} -//! \endcond DOXYGEN_IGNORE - std::vector> LauAbsCoeffSet::readFromJson( const TString& fileName ) { using nlohmann::json; std::ifstream in(fileName, std::ios_base::in); if ( ! in ) { std::cerr << "ERROR in LauAbsCoeffSet::readFromJson : couldn't open file \"" << fileName << "\"" << std::endl; return {}; } json j; in >> j; const auto nCoeffs { j.at("nCoeffs").get() }; 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 const Bool_t clone { coeff.at("clone").get() }; if ( clone ) { clonedCoeffs.emplace_back( coeff ); continue; } + // Otherwise create and store an instance of the appropriate type, + // constructed from the JSON record const LauCoeffType type { coeff.at("type").get() }; switch ( 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; } } + // Now construct the clones for ( auto& coeff : clonedCoeffs ) { const std::string name { coeff.at("name").get() }; const std::string parentName { coeff.at("parent").get() }; // 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 CloneOption cloneOption { coeff.at("cloneOption").get() }; const Double_t constFactor { coeff.at("constFactor").get() }; // 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 ) { using nlohmann::json; json j; j["nCoeffs"] = coeffs.size(); j["coeffs"] = json::array(); for ( auto& coeffset : coeffs ) { j["coeffs"].push_back( *coeffset ); } std::ofstream out{fileName, std::ios_base::out}; if ( ! out ) { std::cerr << "ERROR in LauAbsCoeffSet::writeToJson : couldn't open file \"" << fileName << "\" for writing. No file will be written!" << std::endl; return; } out << j.dump(4); out << 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; }