bool WignerDStrategy::execute(ParameterList& paras, std::shared_ptr<AbsParameter>& out) { #ifdef DEBUG if( checkType != out->type() ) { throw( WrongParType( std::string("Output Type ") +ParNames[out->type()]+std::string(" conflicts expected type ") +ParNames[checkType]+std::string(" of ")+name+" Wigner strat") ); return false; } #endif double _inSpin = paras.GetDoubleParameter(0)->GetValue(); double _outSpin1 = paras.GetDoubleParameter(1)->GetValue(); double _outSpin2 = paras.GetDoubleParameter(2)->GetValue(); ComPWA::Physics::DPKinematics::DalitzKinematics* kin = dynamic_cast<ComPWA::Physics::DPKinematics::DalitzKinematics*>( Kinematics::instance() ); std::shared_ptr<MultiDouble> _angle = paras.GetMultiDouble(0); std::vector<double> results(_angle->GetNValues(), 0.); for(unsigned int ele=0; ele<_angle->GetNValues(); ele++){ try{ results.at(ele)=AmpWigner2::dynamicalFunction( _inSpin,_outSpin1,_outSpin2,_angle->GetValue(ele) ); } catch (std::exception &ex) { BOOST_LOG_TRIVIAL(error) << "WignerDStrategy::execute() | " <<ex.what(); throw std::runtime_error("WignerDStrategy::execute() | " "Evaluation of dynamical function failed!"); } }//end element loop out = std::shared_ptr<AbsParameter>( new MultiDouble(out->GetName(),results)); return true; }
void FormFactorStrategy::execute(ParameterList ¶s, std::shared_ptr<Parameter> &out) { if (out && checkType != out->type()) throw BadParameter( "FormFactorStrat::execute() | Parameter type mismatch!"); #ifndef NDEBUG // Check parameter type if (checkType != out->type()) throw(WrongParType("FormFactorStrat::execute() | " "Output parameter is of type " + std::string(ParNames[out->type()]) + " and conflicts with expected type " + std::string(ParNames[checkType]))); // How many parameters do we expect? size_t check_nInt = 0; size_t nInt = paras.intValues().size(); //L, MesonRadius, FFType, Daughter1Mass, Daughter2Mass size_t check_nDouble = 5; size_t nDouble = paras.doubleValues().size(); nDouble += paras.doubleParameters().size(); size_t check_nComplex = 0; size_t nComplex = paras.complexValues().size(); size_t check_nMInteger = 0; size_t nMInteger = paras.mIntValues().size(); // DataSample.mDoubleValue(pos) (mSq) size_t check_nMDouble = 1; size_t nMDouble = paras.mDoubleValues().size(); size_t check_nMComplex = 0; size_t nMComplex = paras.mComplexValues().size(); // Check size of parameter list if (nInt != check_nInt) throw(BadParameter("FormFactorStrat::execute() | " "Number of IntParameters does not match: " + std::to_string(nInt) + " given but " + std::to_string(check_nInt) + " expected.")); if (nDouble != check_nDouble) throw(BadParameter("FormFactorStrat::execute() | " "Number of FitParameters does not match: " + std::to_string(nDouble) + " given but " + std::to_string(check_nDouble) + " expected.")); if (nComplex != check_nComplex) throw(BadParameter("FormFactorStrat::execute() | " "Number of ComplexParameters does not match: " + std::to_string(nComplex) + " given but " + std::to_string(check_nComplex) + " expected.")); if (nMInteger != check_nMInteger) throw(BadParameter("FormFactorStrat::execute() | " "Number of MultiInt does not match: " + std::to_string(nMInteger) + " given but " + std::to_string(check_nMInteger) + " expected.")); if (nMDouble != check_nMDouble) throw(BadParameter("FormFactorStrat::execute() | " "Number of MultiDoubles does not match: " + std::to_string(nMDouble) + " given but " + std::to_string(check_nMDouble) + " expected.")); if (nMComplex != check_nMComplex) throw(BadParameter("FormFactorStrat::execute() | " "Number of MultiComplexes does not match: " + std::to_string(nMComplex) + " given but " + std::to_string(check_nMComplex) + " expected.")); #endif size_t n = paras.mDoubleValue(0)->values().size(); if (!out) out = MDouble("", n); auto par = std::static_pointer_cast<Value<std::vector<double>>>(out); auto &results = par->values(); // reference // Get parameters from ParameterList: // We use the same order of the parameters as was used during tree // construction. unsigned int orbitL = paras.doubleValue(0)->value(); double MesonRadius = paras.doubleParameter(0)->value(); FormFactorType ffType = FormFactorType(paras.doubleValue(1)->value()); double ma = paras.doubleParameter(1)->value(); double mb = paras.doubleParameter(2)->value(); // calc function for each point for (unsigned int ele = 0; ele < n; ele++) { try { results.at(ele) = FormFactorDecorator::formFactor( paras.mDoubleValue(0)->values().at(ele), ma, mb, orbitL, MesonRadius, ffType); } catch (std::exception &ex) { LOG(ERROR) << "FormFactorStrategy::execute() | " << ex.what(); throw(std::runtime_error("FormFactorStrategy::execute() | " "Evaluation of dynamic function failed!")); } } }