EvtGen 2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Loading...
Searching...
No Matches
EvtAmpFactory.hh
Go to the documentation of this file.
1
2/***********************************************************************
3* Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4* *
5* This file is part of EvtGen. *
6* *
7* EvtGen is free software: you can redistribute it and/or modify *
8* it under the terms of the GNU General Public License as published by *
9* the Free Software Foundation, either version 3 of the License, or *
10* (at your option) any later version. *
11* *
12* EvtGen is distributed in the hope that it will be useful, *
13* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15* GNU General Public License for more details. *
16* *
17* You should have received a copy of the GNU General Public License *
18* along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19***********************************************************************/
20
21#ifndef EVT_AMP_FACTORY_HH
22#define EVT_AMP_FACTORY_HH
23
30
31#include <stdio.h>
32#include <string>
33#include <vector>
34
35// Abstract amplitude factory parameterized by a vector of
36// strings. Derived classes construct the amplitude, and PDFs for sampling
37// points.
38
39template <class T>
41 public:
42 EvtAmpFactory() = default;
43
44 protected:
47 m_amp( other.m_amp ? other.m_amp->clone() : nullptr ),
48 m_ampConj( other.m_ampConj ? other.m_ampConj->clone() : nullptr ),
49 m_pc( other.m_pc ? other.m_pc->clone() : nullptr ),
50 m_names( other.m_names ),
51 m_dm( other.m_dm ),
52 m_mixPhase( other.m_mixPhase ),
53 m_verbose( other.m_verbose )
54 {
55 }
56
57 public:
58 virtual ~EvtAmpFactory() = default;
59
60 virtual EvtAmpFactory<T>* clone() const = 0;
61
62 virtual void build( const EvtMultiChannelParser& parser, int nItg )
63 {
64 m_amp = std::make_unique<EvtAmplitudeSum<T>>();
65 m_ampConj = std::make_unique<EvtAmplitudeSum<T>>();
66 m_pc = std::make_unique<EvtPdfSum<T>>();
67 m_dm = parser.dm();
68 m_mixAmpli = parser.mixAmpli();
69 m_mixPhase = parser.mixPhase();
70
71 printf( "Amplitude with %d terms\n", parser.getNAmp() );
72 int i;
73 for ( i = 0; i < parser.getNAmp(); i++ ) {
74 std::vector<std::string> v = parser.amp( i );
75 EvtComplex c = parser.ampCoef( i );
76 processAmp( c, v );
77 }
78
79 printf( "Conj. amplitude with %d terms\n", parser.getNAmpConj() );
80 for ( i = 0; i < parser.getNAmpConj(); i++ ) {
81 std::vector<std::string> v = parser.ampConj( i );
82 EvtComplex c = parser.ampConjCoef( i );
83 processAmp( c, v, true );
84 }
85
86 printf( "Calculating pole compensator integrals %d steps\n", nItg );
87 if ( nItg > 0 )
88 m_pc->getItg( nItg );
89
90 printf( "End build\n" );
91 }
92
93 virtual void processAmp( EvtComplex c, std::vector<std::string> v,
94 bool conj = false ) = 0;
95
96 inline bool isCPModel() const
97 {
98 return ( m_ampConj->nTerms() > 0 ? true : false );
99 }
100 inline double dm() const { return m_dm; }
101 inline double mixAmpli() const { return m_mixAmpli; }
102 inline double mixPhase() const { return m_mixPhase; }
103
104 void setVerbose() { m_verbose = true; }
105
106 EvtAmplitudeSum<T>* getAmp() const { return m_amp.get(); }
107 EvtAmplitudeSum<T>* getAmpConj() const { return m_ampConj.get(); }
108 EvtPdfSum<T>* getPC() const { return m_pc.get(); }
109 EvtAmplitude<T>* getAmp( int i ) const { return m_amp->getTerm( i ); }
110 EvtPdf<T>* getPC( int i ) const { return m_pc->getPdf( i ); }
111 const char* compName( int i ) const { return m_names[i].c_str(); }
112
113 EvtComplex getCoeff( int i ) const { return m_amp->c( i ); }
114
115 double getTermCoeff( int i ) const { return abs2( m_amp->c( i ) ); }
116 double getTermCoeff( int type, int i, int j ) const
117 {
118 switch ( type ) {
119 case 0:
120 return 2 * real( m_amp->c( i ) * conj( m_amp->c( j ) ) ); //posre
121 case 1:
122 return -2 *
123 real( m_amp->c( i ) * conj( m_amp->c( j ) ) ); //negre
124 case 2:
125 return -2 *
126 imag( m_amp->c( i ) * conj( m_amp->c( j ) ) ); //posim
127 case 3:
128 return 2 * imag( m_amp->c( i ) * conj( m_amp->c( j ) ) ); //negim
129 default:
130 assert( 0 );
131 }
132 }
133
134 protected:
135 std::unique_ptr<EvtAmplitudeSum<T>> m_amp; // _owned_ amplitude
136 std::unique_ptr<EvtAmplitudeSum<T>> m_ampConj; // _owned_ conjugate amplitude
137 std::unique_ptr<EvtPdfSum<T>> m_pc; // _owned_ pole compensator
138 std::vector<std::string> m_names; // names of partial amplitudes
139
140 double m_dm = 0; // Mass difference for conjugate amplitude
141 double m_mixPhase; // mixing phase
142 double m_mixAmpli; // cpv in mixing
143 bool m_verbose = false;
144};
145
146#endif
EvtComplex conj(const EvtComplex &c)
double imag(const EvtComplex &c)
double real(const EvtComplex &c)
double abs2(const EvtComplex &c)
EvtAmpFactory(const EvtAmpFactory< T > &other)
double dm() const
EvtAmplitude< T > * getAmp(int i) const
virtual void build(const EvtMultiChannelParser &parser, int nItg)
EvtComplex getCoeff(int i) const
std::unique_ptr< EvtAmplitudeSum< T > > m_ampConj
double mixAmpli() const
EvtAmpFactory()=default
std::unique_ptr< EvtPdfSum< T > > m_pc
EvtAmplitudeSum< T > * getAmpConj() const
double getTermCoeff(int i) const
double mixPhase() const
EvtPdf< T > * getPC(int i) const
std::unique_ptr< EvtAmplitudeSum< T > > m_amp
const char * compName(int i) const
EvtPdfSum< T > * getPC() const
std::vector< std::string > m_names
virtual EvtAmpFactory< T > * clone() const =0
EvtAmpFactory(EvtAmpFactory< T > &&)=default
bool isCPModel() const
virtual void processAmp(EvtComplex c, std::vector< std::string > v, bool conj=false)=0
virtual ~EvtAmpFactory()=default
double getTermCoeff(int type, int i, int j) const
EvtAmplitudeSum< T > * getAmp() const
std::vector< std::string > ampConj(int i) const
EvtComplex ampConjCoef(int i) const
std::vector< std::string > amp(int i) const
EvtComplex ampCoef(int i) const