EvtGen
2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Toggle main menu visibility
Loading...
Searching...
No Matches
EvtGenBase
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
24
#include "
EvtGenBase/EvtAmpPdf.hh
"
25
#include "
EvtGenBase/EvtAmplitudeSum.hh
"
26
#include "
EvtGenBase/EvtMacros.hh
"
27
#include "
EvtGenBase/EvtMultiChannelParser.hh
"
28
#include "
EvtGenBase/EvtPdfMax.hh
"
29
#include "
EvtGenBase/EvtPdfSum.hh
"
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
39
template
<
class
T>
40
class
EvtAmpFactory
{
41
public
:
42
EvtAmpFactory
() =
default
;
43
44
protected
:
45
EvtAmpFactory
(
EvtAmpFactory<T>
&& ) =
default
;
46
EvtAmpFactory
(
const
EvtAmpFactory<T>
& other ) :
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
EvtAmpPdf.hh
EvtAmplitudeSum.hh
conj
EvtComplex conj(const EvtComplex &c)
Definition
EvtComplex.hh:198
imag
double imag(const EvtComplex &c)
Definition
EvtComplex.hh:237
real
double real(const EvtComplex &c)
Definition
EvtComplex.hh:232
abs2
double abs2(const EvtComplex &c)
Definition
EvtComplex.hh:211
EvtMacros.hh
EvtMultiChannelParser.hh
EvtPdfMax.hh
EvtPdfSum.hh
EvtAmpFactory::EvtAmpFactory
EvtAmpFactory(const EvtAmpFactory< T > &other)
Definition
EvtAmpFactory.hh:46
EvtAmpFactory::dm
double dm() const
Definition
EvtAmpFactory.hh:100
EvtAmpFactory::getAmp
EvtAmplitude< T > * getAmp(int i) const
Definition
EvtAmpFactory.hh:109
EvtAmpFactory::build
virtual void build(const EvtMultiChannelParser &parser, int nItg)
Definition
EvtAmpFactory.hh:62
EvtAmpFactory::getCoeff
EvtComplex getCoeff(int i) const
Definition
EvtAmpFactory.hh:113
EvtAmpFactory::m_ampConj
std::unique_ptr< EvtAmplitudeSum< T > > m_ampConj
Definition
EvtAmpFactory.hh:136
EvtAmpFactory::mixAmpli
double mixAmpli() const
Definition
EvtAmpFactory.hh:101
EvtAmpFactory::EvtAmpFactory
EvtAmpFactory()=default
EvtAmpFactory::m_mixAmpli
double m_mixAmpli
Definition
EvtAmpFactory.hh:142
EvtAmpFactory::m_pc
std::unique_ptr< EvtPdfSum< T > > m_pc
Definition
EvtAmpFactory.hh:137
EvtAmpFactory::getAmpConj
EvtAmplitudeSum< T > * getAmpConj() const
Definition
EvtAmpFactory.hh:107
EvtAmpFactory::getTermCoeff
double getTermCoeff(int i) const
Definition
EvtAmpFactory.hh:115
EvtAmpFactory::mixPhase
double mixPhase() const
Definition
EvtAmpFactory.hh:102
EvtAmpFactory::getPC
EvtPdf< T > * getPC(int i) const
Definition
EvtAmpFactory.hh:110
EvtAmpFactory::m_amp
std::unique_ptr< EvtAmplitudeSum< T > > m_amp
Definition
EvtAmpFactory.hh:135
EvtAmpFactory::compName
const char * compName(int i) const
Definition
EvtAmpFactory.hh:111
EvtAmpFactory::setVerbose
void setVerbose()
Definition
EvtAmpFactory.hh:104
EvtAmpFactory::getPC
EvtPdfSum< T > * getPC() const
Definition
EvtAmpFactory.hh:108
EvtAmpFactory::m_names
std::vector< std::string > m_names
Definition
EvtAmpFactory.hh:138
EvtAmpFactory::clone
virtual EvtAmpFactory< T > * clone() const =0
EvtAmpFactory::m_verbose
bool m_verbose
Definition
EvtAmpFactory.hh:143
EvtAmpFactory::m_mixPhase
double m_mixPhase
Definition
EvtAmpFactory.hh:141
EvtAmpFactory::EvtAmpFactory
EvtAmpFactory(EvtAmpFactory< T > &&)=default
EvtAmpFactory::isCPModel
bool isCPModel() const
Definition
EvtAmpFactory.hh:96
EvtAmpFactory::processAmp
virtual void processAmp(EvtComplex c, std::vector< std::string > v, bool conj=false)=0
EvtAmpFactory::~EvtAmpFactory
virtual ~EvtAmpFactory()=default
EvtAmpFactory::getTermCoeff
double getTermCoeff(int type, int i, int j) const
Definition
EvtAmpFactory.hh:116
EvtAmpFactory::m_dm
double m_dm
Definition
EvtAmpFactory.hh:140
EvtAmpFactory::getAmp
EvtAmplitudeSum< T > * getAmp() const
Definition
EvtAmpFactory.hh:106
EvtAmplitudeSum
Definition
EvtAmplitudeSum.hh:31
EvtAmplitude
Definition
EvtAmplitude.hh:29
EvtComplex
Definition
EvtComplex.hh:29
EvtMultiChannelParser
Definition
EvtMultiChannelParser.hh:40
EvtMultiChannelParser::getNAmp
int getNAmp() const
Definition
EvtMultiChannelParser.hh:72
EvtMultiChannelParser::getNAmpConj
int getNAmpConj() const
Definition
EvtMultiChannelParser.hh:73
EvtMultiChannelParser::mixAmpli
double mixAmpli() const
Definition
EvtMultiChannelParser.hh:59
EvtMultiChannelParser::ampConj
std::vector< std::string > ampConj(int i) const
Definition
EvtMultiChannelParser.hh:62
EvtMultiChannelParser::dm
double dm() const
Definition
EvtMultiChannelParser.hh:57
EvtMultiChannelParser::ampConjCoef
EvtComplex ampConjCoef(int i) const
Definition
EvtMultiChannelParser.hh:67
EvtMultiChannelParser::amp
std::vector< std::string > amp(int i) const
Definition
EvtMultiChannelParser.hh:61
EvtMultiChannelParser::mixPhase
double mixPhase() const
Definition
EvtMultiChannelParser.hh:58
EvtMultiChannelParser::ampCoef
EvtComplex ampCoef(int i) const
Definition
EvtMultiChannelParser.hh:66
EvtPdfSum
Definition
EvtPdfSum.hh:32
EvtPdf
Definition
EvtPdf.hh:72
Generated by
1.17.0