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
src
EvtGenBase
EvtParticleFactory.cpp
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
#include "
EvtGenBase/EvtParticleFactory.hh
"
22
23
#include "
EvtGenBase/EvtDiracParticle.hh
"
24
#include "
EvtGenBase/EvtHighSpinParticle.hh
"
25
#include "
EvtGenBase/EvtId.hh
"
26
#include "
EvtGenBase/EvtNeutrinoParticle.hh
"
27
#include "
EvtGenBase/EvtPDL.hh
"
28
#include "
EvtGenBase/EvtParticle.hh
"
29
#include "
EvtGenBase/EvtPhotonParticle.hh
"
30
#include "
EvtGenBase/EvtRaritaSchwingerParticle.hh
"
31
#include "
EvtGenBase/EvtReport.hh
"
32
#include "
EvtGenBase/EvtScalarParticle.hh
"
33
#include "
EvtGenBase/EvtStringParticle.hh
"
34
#include "
EvtGenBase/EvtTensorParticle.hh
"
35
#include "
EvtGenBase/EvtVectorParticle.hh
"
36
37
#include <sys/stat.h>
38
39
#include <iostream>
40
#include <stdio.h>
41
#include <stdlib.h>
42
using
std::endl;
43
44
EvtParticle
*
EvtParticleFactory::particleFactory
(
EvtSpinType::spintype
spinType )
45
{
46
if
( spinType ==
EvtSpinType::SCALAR
) {
47
return
new
EvtScalarParticle
;
48
}
49
50
if
( spinType ==
EvtSpinType::VECTOR
) {
51
return
new
EvtVectorParticle
;
52
}
53
if
( spinType ==
EvtSpinType::DIRAC
) {
54
return
new
EvtDiracParticle
;
55
}
56
if
( spinType ==
EvtSpinType::NEUTRINO
) {
57
return
new
EvtNeutrinoParticle
;
58
}
59
if
( spinType ==
EvtSpinType::PHOTON
) {
60
return
new
EvtPhotonParticle
;
61
}
62
if
( spinType ==
EvtSpinType::TENSOR
) {
63
return
new
EvtTensorParticle
;
64
}
65
if
( spinType ==
EvtSpinType::STRING
) {
66
return
new
EvtStringParticle
;
67
}
68
if
( spinType ==
EvtSpinType::RARITASCHWINGER
) {
69
return
new
EvtRaritaSchwingerParticle
;
70
}
71
if
( spinType ==
EvtSpinType::SPIN5HALF
) {
72
return
new
EvtHighSpinParticle
;
73
}
74
if
( spinType ==
EvtSpinType::SPIN3
) {
75
return
new
EvtHighSpinParticle
;
76
}
77
if
( spinType ==
EvtSpinType::SPIN7HALF
) {
78
return
new
EvtHighSpinParticle
;
79
}
80
if
( spinType ==
EvtSpinType::SPIN4
) {
81
return
new
EvtHighSpinParticle
;
82
}
83
84
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
85
<<
"Error in EvtParticleFactory::particleFactory"
<< endl;
86
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
87
<<
"Tried to create non-existing particle"
88
<<
" with spin type:"
<< spinType << endl;
89
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
) <<
"Will terminate execution"
<< endl;
90
91
::abort();
92
93
return
nullptr
;
94
}
95
96
EvtParticle
*
EvtParticleFactory::particleFactory
(
EvtId
id
,
EvtVector4R
p4,
97
EvtSpinDensity
rho )
98
{
99
EvtSpinType::spintype
thisSpin =
EvtPDL::getSpinType
(
id
);
100
101
if
( thisSpin ==
EvtSpinType::SCALAR
) {
102
EvtScalarParticle
* myPart;
103
myPart =
new
EvtScalarParticle
;
104
myPart->
init
(
id
, p4 );
105
myPart->
setSpinDensityForward
( rho );
106
return
myPart;
107
}
108
109
if
( thisSpin ==
EvtSpinType::VECTOR
) {
110
EvtVectorParticle
* myPart;
111
myPart =
new
EvtVectorParticle
;
112
myPart->
init
(
id
, p4 );
113
myPart->
setSpinDensityForward
( rho );
114
return
myPart;
115
}
116
if
( thisSpin ==
EvtSpinType::DIRAC
) {
117
EvtDiracParticle
* myPart;
118
myPart =
new
EvtDiracParticle
;
119
myPart->
init
(
id
, p4 );
120
myPart->
setSpinDensityForward
( rho );
121
return
myPart;
122
}
123
if
( thisSpin ==
EvtSpinType::NEUTRINO
) {
124
EvtNeutrinoParticle
* myPart;
125
myPart =
new
EvtNeutrinoParticle
;
126
myPart->
init
(
id
, p4 );
127
myPart->
setSpinDensityForward
( rho );
128
return
myPart;
129
}
130
if
( thisSpin ==
EvtSpinType::PHOTON
) {
131
EvtPhotonParticle
* myPart;
132
myPart =
new
EvtPhotonParticle
;
133
myPart->
init
(
id
, p4 );
134
myPart->
setSpinDensityForward
( rho );
135
return
myPart;
136
}
137
if
( thisSpin ==
EvtSpinType::TENSOR
) {
138
EvtTensorParticle
* myPart;
139
myPart =
new
EvtTensorParticle
;
140
myPart->
init
(
id
, p4 );
141
myPart->
setSpinDensityForward
( rho );
142
return
myPart;
143
}
144
if
( thisSpin ==
EvtSpinType::STRING
) {
145
EvtStringParticle
* myPart;
146
myPart =
new
EvtStringParticle
;
147
myPart->
init
(
id
, p4 );
148
myPart->
setSpinDensityForward
( rho );
149
return
myPart;
150
}
151
if
( thisSpin ==
EvtSpinType::SPIN3
) {
152
EvtHighSpinParticle
* myPart;
153
myPart =
new
EvtHighSpinParticle
;
154
myPart->
init
(
id
, p4 );
155
myPart->
setSpinDensityForward
( rho );
156
return
myPart;
157
}
158
if
( thisSpin ==
EvtSpinType::SPIN5HALF
) {
159
EvtHighSpinParticle
* myPart;
160
myPart =
new
EvtHighSpinParticle
;
161
myPart->
init
(
id
, p4 );
162
myPart->
setSpinDensityForward
( rho );
163
return
myPart;
164
}
165
if
( thisSpin ==
EvtSpinType::SPIN7HALF
) {
166
EvtHighSpinParticle
* myPart;
167
myPart =
new
EvtHighSpinParticle
;
168
myPart->
init
(
id
, p4 );
169
myPart->
setSpinDensityForward
( rho );
170
return
myPart;
171
}
172
if
( thisSpin ==
EvtSpinType::RARITASCHWINGER
) {
173
EvtRaritaSchwingerParticle
* myPart;
174
myPart =
new
EvtRaritaSchwingerParticle
;
175
myPart->
init
(
id
, p4 );
176
myPart->
setSpinDensityForward
( rho );
177
return
myPart;
178
}
179
if
( thisSpin ==
EvtSpinType::SPIN4
) {
180
EvtHighSpinParticle
* myPart;
181
myPart =
new
EvtHighSpinParticle
;
182
myPart->
init
(
id
, p4 );
183
myPart->
setSpinDensityForward
( rho );
184
return
myPart;
185
}
186
187
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
188
<<
"Error in EvtParticleFactory::particleFactory"
<< endl;
189
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
190
<<
"Tried to create non-existing particle"
191
<<
" with spin type:"
<< thisSpin
192
<<
" and name:"
<<
EvtPDL::name
(
id
).c_str() << endl;
193
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
) <<
"Will terminate execution"
<< endl;
194
195
::abort();
196
197
return
nullptr
;
198
}
199
200
EvtParticle
*
EvtParticleFactory::particleFactory
(
EvtId
id
,
EvtVector4R
p4 )
201
{
202
EvtSpinDensity
rho;
203
rho.
setDiag
(
EvtSpinType::getSpinStates
(
EvtPDL::getSpinType
(
id
) ) );
204
205
return
particleFactory
(
id
, p4, rho );
206
}
EvtDiracParticle.hh
EvtHighSpinParticle.hh
EvtId.hh
EvtNeutrinoParticle.hh
EvtPDL.hh
EvtParticleFactory.hh
EvtParticle.hh
EvtPhotonParticle.hh
EvtRaritaSchwingerParticle.hh
EvtReport.hh
EvtGenReport
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=nullptr)
Definition
EvtReport.cpp:32
EVTGEN_ERROR
@ EVTGEN_ERROR
Definition
EvtReport.hh:49
EvtScalarParticle.hh
EvtStringParticle.hh
EvtTensorParticle.hh
EvtVectorParticle.hh
EvtDiracParticle
Definition
EvtDiracParticle.hh:30
EvtDiracParticle::init
void init(EvtId part_n, const EvtVector4R &p4) override
Definition
EvtDiracParticle.cpp:35
EvtHighSpinParticle
Definition
EvtHighSpinParticle.hh:28
EvtHighSpinParticle::init
void init(EvtId id, const EvtVector4R &p) override
Definition
EvtHighSpinParticle.cpp:32
EvtId
Definition
EvtId.hh:27
EvtNeutrinoParticle
Definition
EvtNeutrinoParticle.hh:29
EvtNeutrinoParticle::init
void init(EvtId part_n, const EvtVector4R &p4) override
Definition
EvtNeutrinoParticle.cpp:33
EvtPDL::getSpinType
static EvtSpinType::spintype getSpinType(EvtId i)
Definition
EvtPDL.cpp:371
EvtPDL::name
static std::string name(EvtId i)
Definition
EvtPDL.cpp:376
EvtParticleFactory::particleFactory
static EvtParticle * particleFactory(EvtSpinType::spintype spinType)
Definition
EvtParticleFactory.cpp:44
EvtParticle
Definition
EvtParticle.hh:45
EvtParticle::setSpinDensityForward
void setSpinDensityForward(const EvtSpinDensity &rho)
Definition
EvtParticle.hh:341
EvtPhotonParticle
Definition
EvtPhotonParticle.hh:30
EvtPhotonParticle::init
void init(EvtId part_n, double e, double px, double py, double pz)
Definition
EvtPhotonParticle.cpp:37
EvtRaritaSchwingerParticle
Definition
EvtRaritaSchwingerParticle.hh:30
EvtRaritaSchwingerParticle::init
void init(EvtId id, const EvtVector4R &p4) override
Definition
EvtRaritaSchwingerParticle.cpp:34
EvtScalarParticle
Definition
EvtScalarParticle.hh:27
EvtScalarParticle::init
void init(EvtId part_n, double e, double px, double py, double pz)
Definition
EvtScalarParticle.cpp:28
EvtSpinDensity
Definition
EvtSpinDensity.hh:28
EvtSpinDensity::setDiag
void setDiag(int n)
Definition
EvtSpinDensity.cpp:118
EvtSpinType::spintype
spintype
Definition
EvtSpinType.hh:29
EvtSpinType::SPIN4
@ SPIN4
Definition
EvtSpinType.hh:39
EvtSpinType::SPIN7HALF
@ SPIN7HALF
Definition
EvtSpinType.hh:41
EvtSpinType::NEUTRINO
@ NEUTRINO
Definition
EvtSpinType.hh:35
EvtSpinType::SPIN5HALF
@ SPIN5HALF
Definition
EvtSpinType.hh:40
EvtSpinType::SCALAR
@ SCALAR
Definition
EvtSpinType.hh:30
EvtSpinType::RARITASCHWINGER
@ RARITASCHWINGER
Definition
EvtSpinType.hh:37
EvtSpinType::DIRAC
@ DIRAC
Definition
EvtSpinType.hh:33
EvtSpinType::TENSOR
@ TENSOR
Definition
EvtSpinType.hh:32
EvtSpinType::SPIN3
@ SPIN3
Definition
EvtSpinType.hh:38
EvtSpinType::PHOTON
@ PHOTON
Definition
EvtSpinType.hh:34
EvtSpinType::VECTOR
@ VECTOR
Definition
EvtSpinType.hh:31
EvtSpinType::STRING
@ STRING
Definition
EvtSpinType.hh:36
EvtSpinType::getSpinStates
static int getSpinStates(spintype stype)
Definition
EvtSpinType.cpp:56
EvtStringParticle
Definition
EvtStringParticle.hh:31
EvtStringParticle::init
void init(EvtId id, const EvtVector4R &p4) override
Definition
EvtStringParticle.cpp:30
EvtTensorParticle
Definition
EvtTensorParticle.hh:29
EvtTensorParticle::init
void init(EvtId part_n, double e, double px, double py, double pz)
Definition
EvtTensorParticle.cpp:41
EvtVector4R
Definition
EvtVector4R.hh:29
EvtVectorParticle
Definition
EvtVectorParticle.hh:33
EvtVectorParticle::init
void init(EvtId part_n, double e, double px, double py, double pz)
Definition
EvtVectorParticle.cpp:32
Generated by
1.17.0