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