From bb15f5afebcca4511c0b62b6267d860d71290801 Mon Sep 17 00:00:00 2001 From: Bertram Kopf <bertram@ep1.rub.de> Date: Tue, 16 Jan 2024 15:27:01 +0100 Subject: [PATCH] some modifications in TensorDecAmps for better performance --- PwaUtils/AbsXdecAmp.cc | 2 ++ PwaUtils/AbsXdecAmp.hh | 1 + PwaUtils/TensorDecAmps.cc | 51 +++++++-------------------------------- PwaUtils/TensorDecAmps.hh | 6 ++--- 4 files changed, 14 insertions(+), 46 deletions(-) diff --git a/PwaUtils/AbsXdecAmp.cc b/PwaUtils/AbsXdecAmp.cc index 8fdcf0de..5d3b92f0 100644 --- a/PwaUtils/AbsXdecAmp.cc +++ b/PwaUtils/AbsXdecAmp.cc @@ -64,6 +64,7 @@ AbsXdecAmp::AbsXdecAmp(std::shared_ptr<AbsDecay> theDec, ChannelID channelID) : ,_enabledlamFsDaughter2(false) ,_J(theDec->motherJPC()->J) ,_isFormationAmp(false) + ,_withDecayAmps(true) { if(theDec->type() =="FormationDecay"){ _isFormationAmp=true; @@ -72,6 +73,7 @@ AbsXdecAmp::AbsXdecAmp(std::shared_ptr<AbsDecay> theDec, ChannelID channelID) : else{ _jpcDecsName=_JPCPtr->jpcname()+"To"+theDec->daughter1Part()->name()+"_"+theDec->daughter2Part()->name(); } + if(_daughter1IsStable && _daughter2IsStable) _withDecayAmps=false; } AbsXdecAmp::~AbsXdecAmp() diff --git a/PwaUtils/AbsXdecAmp.hh b/PwaUtils/AbsXdecAmp.hh index 7a448df0..96f2c567 100644 --- a/PwaUtils/AbsXdecAmp.hh +++ b/PwaUtils/AbsXdecAmp.hh @@ -130,5 +130,6 @@ protected: intUShortShortComplFloatMap _cachedAmpIdMap; // std::map<std::thread::id, std::map<unsigned short, complex<float> > > _cachedDynIdMap; std::map<unsigned short, complex<float> > _cachedDynIdMap; + bool _withDecayAmps; virtual void initialize(); }; diff --git a/PwaUtils/TensorDecAmps.cc b/PwaUtils/TensorDecAmps.cc index 61836dfb..b2928f98 100644 --- a/PwaUtils/TensorDecAmps.cc +++ b/PwaUtils/TensorDecAmps.cc @@ -106,7 +106,7 @@ complex<double> TensorDecAmps::XdecAmp(const Spin& lamX, EvtData* theData, AbsXd result=lsLoop(grandmaAmp, lamX, theData, _lam1MinProj, _lam1MaxProj, _lam2MinProj, - _lam2MaxProj, true); + _lam2MaxProj, _withDecayAmps); if ( _cacheAmps){ // _cachedAmpMap[evtNo][_absDyn->grandMaKey(grandmaAmp)][currentSpinIndex]=result; @@ -140,9 +140,9 @@ complex<double> TensorDecAmps::lsLoop(AbsXdecAmp* grandmaAmp, Spin lamX, EvtData complex<double> tmpResult(0.,0.); for(Spin lambda1=lam1Min; lambda1<=lam1Max; ++lambda1){ for(Spin lambda2=lam2Min; lambda2<=lam2Max; ++lambda2){ - Id3StringType IdLamXLam1Lam2=FunctionUtils::spin3Index(lamX, lambda1, lambda2); - complex<double> amp = theMagExpi*current3SpinMap.at(IdLamXLam1Lam2); - if(withDecs) amp *=dAmps.at(lambda1 - lam1Min).at(lambda2 - lam2Min); + Id3StringType IdLamXLam1Lam2=FunctionUtils::spin3Index(lamX, lambda1, lambda2); + complex<double> amp = theMagExpi*current3SpinMap.at(IdLamXLam1Lam2); + if(withDecs) amp *=dAmps.at(lambda1 - lam1Min).at(lambda2 - lam2Min); tmpResult+=amp; } } @@ -159,34 +159,6 @@ complex<double> TensorDecAmps::lsLoop(AbsXdecAmp* grandmaAmp, Spin lamX, EvtData } -// void TensorDecAmps::getDefaultParams(fitParCol& fitVal, fitParCol& fitErr){ - -// std::map< std::shared_ptr<const LScomb>, double, pawian::Collection::SharedPtrLess > currentMagValMap; -// std::map< std::shared_ptr<const LScomb>, double, pawian::Collection::SharedPtrLess > currentPhiValMap; -// std::map< std::shared_ptr<const LScomb>, double, pawian::Collection::SharedPtrLess > currentMagErrMap; -// std::map< std::shared_ptr<const LScomb>, double, pawian::Collection::SharedPtrLess > currentPhiErrMap; - -// std::vector< std::shared_ptr<const LScomb> >::const_iterator itLS; -// for(itLS=_LSs.begin(); itLS!=_LSs.end(); ++itLS){ -// currentMagValMap[*itLS]=_factorMag; -// currentPhiValMap[*itLS]=0.; -// currentMagErrMap[*itLS]=_factorMag/3.; -// currentPhiErrMap[*itLS]=0.3; -// } - -// fitVal.MagsLS[_key]=currentMagValMap; -// fitVal.PhisLS[_key]=currentPhiValMap; -// fitErr.MagsLS[_key]=currentMagErrMap; -// fitErr.PhisLS[_key]=currentPhiErrMap; - -// _absDyn->getDefaultParams(fitVal, fitErr); - - -// if(!_daughter1IsStable) _decAmpDaughter1->getDefaultParams(fitVal, fitErr); -// if(!_daughter2IsStable) _decAmpDaughter2->getDefaultParams(fitVal, fitErr); -// } - - void TensorDecAmps::fillDefaultParams(std::shared_ptr<AbsPawianParameters> fitPar){ std::vector< std::shared_ptr<const LScomb> >::const_iterator itLS; @@ -220,9 +192,11 @@ void TensorDecAmps::fillParamNameList(){ for(itLS=_LSs.begin(); itLS!=_LSs.end(); ++itLS){ std::string magName=(*itLS)->name()+_key+"Mag"; _paramNameList.push_back(magName); + _lsMagNameMap[*itLS]=magName; std::string phiName=(*itLS)->name()+_key+"Phi"; _paramNameList.push_back(phiName); + _lsPhiNameMap[*itLS]=phiName; } } @@ -235,16 +209,9 @@ void TensorDecAmps::updateFitParams(std::shared_ptr<AbsPawianParameters> fitPar) std::vector< std::shared_ptr<const LScomb> >::const_iterator itLS; for(itLS=_LSs.begin(); itLS!=_LSs.end(); ++itLS){ //magnitude - std::string magName=(*itLS)->name()+_key+"Mag"; - std::string phiName=(*itLS)->name()+_key+"Phi"; - double theMag=fabs(fitPar->Value(magName)); - double thePhi=fitPar->Value(phiName); - - _currentParamMags[*itLS]=theMag; - _currentParamPhis[*itLS]=thePhi; - - complex<double> expi(cos(thePhi), sin(thePhi)); - _currentParamMagExpi[*itLS]=theMag*expi; + double theMag=fabs(fitPar->Value(_lsMagNameMap.at(*itLS))); + double thePhi=fitPar->Value(_lsPhiNameMap.at(*itLS)); + _currentParamMagExpi[*itLS]=std::polar(theMag, thePhi); } _absDyn->updateFitParams(fitPar); diff --git a/PwaUtils/TensorDecAmps.hh b/PwaUtils/TensorDecAmps.hh index f41d9abd..bb9d822f 100644 --- a/PwaUtils/TensorDecAmps.hh +++ b/PwaUtils/TensorDecAmps.hh @@ -74,12 +74,10 @@ public: protected: std::vector< std::shared_ptr<const LScomb> > _LSs; double _factorMag; - std::map< std::shared_ptr<const LScomb>, double, pawian::Collection::SharedPtrLess > _currentParamMags; - std::map< std::shared_ptr<const LScomb>, double, pawian::Collection::SharedPtrLess > _currentParamPhis; + std::map< std::shared_ptr<const LScomb>, std::string, pawian::Collection::SharedPtrLess > _lsMagNameMap; + std::map< std::shared_ptr<const LScomb>, std::string, pawian::Collection::SharedPtrLess > _lsPhiNameMap; std::map< std::shared_ptr<const LScomb>, complex<double>, pawian::Collection::SharedPtrLess > _currentParamMagExpi; - // std::map<std::thread::id, std::map<Spin, complex<double> > > _cachedDynLSMap; std::map<unsigned short, std::map<Spin, complex<double> > > _cachedDynIdLSMap; - virtual complex<double> lsLoop(AbsXdecAmp* grandmaAmp, Spin lamX, EvtData* theData, Spin lam1Min, Spin lam1Max, Spin lam2Min, Spin lam2Max, bool withDecs); private: -- GitLab