Changeset View
Changeset View
Standalone View
Standalone View
EvtGenBase/EvtAmpFactory.hh
Show All 38 Lines | |||||
template <class T> | template <class T> | ||||
class EvtAmpFactory { | class EvtAmpFactory { | ||||
public: | public: | ||||
EvtAmpFactory() = default; | EvtAmpFactory() = default; | ||||
protected: | protected: | ||||
EvtAmpFactory( EvtAmpFactory<T>&& ) = default; | EvtAmpFactory( EvtAmpFactory<T>&& ) = default; | ||||
EvtAmpFactory( const EvtAmpFactory<T>& other ) : | EvtAmpFactory( const EvtAmpFactory<T>& other ) : | ||||
_amp( other._amp ? other._amp->clone() : nullptr ), | m_amp( other.m_amp ? other.m_amp->clone() : nullptr ), | ||||
_ampConj( other._ampConj ? other._ampConj->clone() : nullptr ), | m_ampConj( other.m_ampConj ? other.m_ampConj->clone() : nullptr ), | ||||
_pc( other._pc ? other._pc->clone() : nullptr ), | m_pc( other.m_pc ? other.m_pc->clone() : nullptr ), | ||||
_names( other._names ), | m_names( other.m_names ), | ||||
_dm( other._dm ), | m_dm( other.m_dm ), | ||||
_mixPhase( other._mixPhase ), | m_mixPhase( other.m_mixPhase ), | ||||
_verbose( other._verbose ) | m_verbose( other.m_verbose ) | ||||
{ | { | ||||
} | } | ||||
public: | public: | ||||
virtual ~EvtAmpFactory() = default; | virtual ~EvtAmpFactory() = default; | ||||
virtual EvtAmpFactory<T>* clone() const = 0; | virtual EvtAmpFactory<T>* clone() const = 0; | ||||
virtual void build( const EvtMultiChannelParser& parser, int nItg ) | virtual void build( const EvtMultiChannelParser& parser, int nItg ) | ||||
{ | { | ||||
_amp = std::make_unique<EvtAmplitudeSum<T>>(); | m_amp = std::make_unique<EvtAmplitudeSum<T>>(); | ||||
_ampConj = std::make_unique<EvtAmplitudeSum<T>>(); | m_ampConj = std::make_unique<EvtAmplitudeSum<T>>(); | ||||
_pc = std::make_unique<EvtPdfSum<T>>(); | m_pc = std::make_unique<EvtPdfSum<T>>(); | ||||
_dm = parser.dm(); | m_dm = parser.dm(); | ||||
_mixAmpli = parser.mixAmpli(); | m_mixAmpli = parser.mixAmpli(); | ||||
_mixPhase = parser.mixPhase(); | m_mixPhase = parser.mixPhase(); | ||||
printf( "Amplitude with %d terms\n", parser.getNAmp() ); | printf( "Amplitude with %d terms\n", parser.getNAmp() ); | ||||
int i; | int i; | ||||
for ( i = 0; i < parser.getNAmp(); i++ ) { | for ( i = 0; i < parser.getNAmp(); i++ ) { | ||||
std::vector<std::string> v = parser.amp( i ); | std::vector<std::string> v = parser.amp( i ); | ||||
EvtComplex c = parser.ampCoef( i ); | EvtComplex c = parser.ampCoef( i ); | ||||
processAmp( c, v ); | processAmp( c, v ); | ||||
} | } | ||||
printf( "Conj. amplitude with %d terms\n", parser.getNAmpConj() ); | printf( "Conj. amplitude with %d terms\n", parser.getNAmpConj() ); | ||||
for ( i = 0; i < parser.getNAmpConj(); i++ ) { | for ( i = 0; i < parser.getNAmpConj(); i++ ) { | ||||
std::vector<std::string> v = parser.ampConj( i ); | std::vector<std::string> v = parser.ampConj( i ); | ||||
EvtComplex c = parser.ampConjCoef( i ); | EvtComplex c = parser.ampConjCoef( i ); | ||||
processAmp( c, v, true ); | processAmp( c, v, true ); | ||||
} | } | ||||
printf( "Calculating pole compensator integrals %d steps\n", nItg ); | printf( "Calculating pole compensator integrals %d steps\n", nItg ); | ||||
if ( nItg > 0 ) | if ( nItg > 0 ) | ||||
_pc->getItg( nItg ); | m_pc->getItg( nItg ); | ||||
printf( "End build\n" ); | printf( "End build\n" ); | ||||
} | } | ||||
virtual void processAmp( EvtComplex c, std::vector<std::string> v, | virtual void processAmp( EvtComplex c, std::vector<std::string> v, | ||||
bool conj = false ) = 0; | bool conj = false ) = 0; | ||||
inline bool isCPModel() const | inline bool isCPModel() const | ||||
{ | { | ||||
return ( _ampConj->nTerms() > 0 ? true : false ); | return ( m_ampConj->nTerms() > 0 ? true : false ); | ||||
} | } | ||||
inline double dm() const { return _dm; } | inline double dm() const { return m_dm; } | ||||
inline double mixAmpli() const { return _mixAmpli; } | inline double mixAmpli() const { return m_mixAmpli; } | ||||
inline double mixPhase() const { return _mixPhase; } | inline double mixPhase() const { return m_mixPhase; } | ||||
void setVerbose() { _verbose = true; } | void setVerbose() { m_verbose = true; } | ||||
EvtAmplitudeSum<T>* getAmp() const { return _amp.get(); } | EvtAmplitudeSum<T>* getAmp() const { return m_amp.get(); } | ||||
EvtAmplitudeSum<T>* getAmpConj() const { return _ampConj.get(); } | EvtAmplitudeSum<T>* getAmpConj() const { return m_ampConj.get(); } | ||||
EvtPdfSum<T>* getPC() const { return _pc.get(); } | EvtPdfSum<T>* getPC() const { return m_pc.get(); } | ||||
EvtAmplitude<T>* getAmp( int i ) const { return _amp->getTerm( i ); } | EvtAmplitude<T>* getAmp( int i ) const { return m_amp->getTerm( i ); } | ||||
EvtPdf<T>* getPC( int i ) const { return _pc->getPdf( i ); } | EvtPdf<T>* getPC( int i ) const { return m_pc->getPdf( i ); } | ||||
const char* compName( int i ) const { return _names[i].c_str(); } | const char* compName( int i ) const { return m_names[i].c_str(); } | ||||
EvtComplex getCoeff( int i ) const { return _amp->c( i ); } | EvtComplex getCoeff( int i ) const { return m_amp->c( i ); } | ||||
double getTermCoeff( int i ) const { return abs2( _amp->c( i ) ); } | double getTermCoeff( int i ) const { return abs2( m_amp->c( i ) ); } | ||||
double getTermCoeff( int type, int i, int j ) const | double getTermCoeff( int type, int i, int j ) const | ||||
{ | { | ||||
switch ( type ) { | switch ( type ) { | ||||
case 0: | case 0: | ||||
return 2 * real( _amp->c( i ) * conj( _amp->c( j ) ) ); //posre | return 2 * real( m_amp->c( i ) * conj( m_amp->c( j ) ) ); //posre | ||||
case 1: | case 1: | ||||
return -2 * real( _amp->c( i ) * conj( _amp->c( j ) ) ); //negre | return -2 * | ||||
real( m_amp->c( i ) * conj( m_amp->c( j ) ) ); //negre | |||||
case 2: | case 2: | ||||
return -2 * imag( _amp->c( i ) * conj( _amp->c( j ) ) ); //posim | return -2 * | ||||
imag( m_amp->c( i ) * conj( m_amp->c( j ) ) ); //posim | |||||
case 3: | case 3: | ||||
return 2 * imag( _amp->c( i ) * conj( _amp->c( j ) ) ); //negim | return 2 * imag( m_amp->c( i ) * conj( m_amp->c( j ) ) ); //negim | ||||
default: | default: | ||||
assert( 0 ); | assert( 0 ); | ||||
} | } | ||||
} | } | ||||
protected: | protected: | ||||
std::unique_ptr<EvtAmplitudeSum<T>> _amp; // _owned_ amplitude | std::unique_ptr<EvtAmplitudeSum<T>> m_amp; // _owned_ amplitude | ||||
std::unique_ptr<EvtAmplitudeSum<T>> _ampConj; // _owned_ conjugate amplitude | std::unique_ptr<EvtAmplitudeSum<T>> m_ampConj; // _owned_ conjugate amplitude | ||||
std::unique_ptr<EvtPdfSum<T>> _pc; // _owned_ pole compensator | std::unique_ptr<EvtPdfSum<T>> m_pc; // _owned_ pole compensator | ||||
std::vector<std::string> _names; // names of partial amplitudes | std::vector<std::string> m_names; // names of partial amplitudes | ||||
double _dm = 0; // Mass difference for conjugate amplitude | double m_dm = 0; // Mass difference for conjugate amplitude | ||||
double _mixPhase; // mixing phase | double m_mixPhase; // mixing phase | ||||
double _mixAmpli; // cpv in mixing | double m_mixAmpli; // cpv in mixing | ||||
bool _verbose = false; | bool m_verbose = false; | ||||
}; | }; | ||||
#endif | #endif |