1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // $Id: G4InuclElementaryParticle.cc,v 1.10 2010/09/23 05:33:56 mkelsey Exp $ |
---|
27 | // Geant4 tag: $Name: hadr-casc-V09-03-85 $ |
---|
28 | // |
---|
29 | // 20100428 M. Kelsey -- Use G4InuclParticleNames enums instead of numbers, |
---|
30 | // add Omega and antinucleons. |
---|
31 | // 20100429 M. Kelsey -- Change "case gamma:" to "case photon:" |
---|
32 | // 20100923 M. Kelsey -- Drop "uups" message when converting G4PartDef to code |
---|
33 | |
---|
34 | #include "G4InuclElementaryParticle.hh" |
---|
35 | |
---|
36 | #include "G4ParticleDefinition.hh" |
---|
37 | #include "G4Proton.hh" |
---|
38 | #include "G4Neutron.hh" |
---|
39 | #include "G4PionPlus.hh" |
---|
40 | #include "G4PionMinus.hh" |
---|
41 | #include "G4PionZero.hh" |
---|
42 | #include "G4Gamma.hh" |
---|
43 | #include "G4KaonPlus.hh" |
---|
44 | #include "G4KaonMinus.hh" |
---|
45 | #include "G4KaonZero.hh" |
---|
46 | #include "G4AntiKaonZero.hh" |
---|
47 | #include "G4Lambda.hh" |
---|
48 | #include "G4SigmaPlus.hh" |
---|
49 | #include "G4SigmaZero.hh" |
---|
50 | #include "G4SigmaMinus.hh" |
---|
51 | #include "G4XiZero.hh" |
---|
52 | #include "G4XiMinus.hh" |
---|
53 | #include "G4OmegaMinus.hh" |
---|
54 | #include "G4AntiProton.hh" |
---|
55 | #include "G4AntiNeutron.hh" |
---|
56 | #include "G4Diproton.hh" |
---|
57 | #include "G4UnboundPN.hh" |
---|
58 | #include "G4Dineutron.hh" |
---|
59 | |
---|
60 | #include "G4InuclParticleNames.hh" |
---|
61 | using namespace G4InuclParticleNames; |
---|
62 | |
---|
63 | |
---|
64 | G4ParticleDefinition* |
---|
65 | G4InuclElementaryParticle::makeDefinition(G4int ityp) { |
---|
66 | switch(ityp) { |
---|
67 | case proton: return G4Proton::Definition(); break; |
---|
68 | case neutron: return G4Neutron::Definition(); break; |
---|
69 | case pionPlus: return G4PionPlus::Definition(); break; |
---|
70 | case pionMinus: return G4PionMinus::Definition(); break; |
---|
71 | case pionZero: return G4PionZero::Definition(); break; |
---|
72 | case photon: return G4Gamma::Definition(); break; |
---|
73 | case kaonPlus: return G4KaonPlus::Definition(); break; |
---|
74 | case kaonMinus: return G4KaonMinus::Definition(); break; |
---|
75 | case kaonZero: return G4KaonZero::Definition(); break; |
---|
76 | case kaonZeroBar: return G4AntiKaonZero::Definition(); break; |
---|
77 | case lambda: return G4Lambda::Definition(); break; |
---|
78 | case sigmaPlus: return G4SigmaPlus::Definition(); break; |
---|
79 | case sigmaZero: return G4SigmaZero::Definition(); break; |
---|
80 | case sigmaMinus: return G4SigmaMinus::Definition(); break; |
---|
81 | case xiZero: return G4XiZero::Definition(); break; |
---|
82 | case xiMinus: return G4XiMinus::Definition(); break; |
---|
83 | case omegaMinus: return G4OmegaMinus::Definition(); break; |
---|
84 | case antiProton: return G4AntiProton::Definition(); break; |
---|
85 | case antiNeutron: return G4AntiNeutron::Definition(); break; |
---|
86 | case diproton: return G4Diproton::Definition(); break; // Bertini class! |
---|
87 | case unboundPN: return G4UnboundPN::Definition(); break; // Bertini class! |
---|
88 | case dineutron: return G4Dineutron::Definition(); break; // Bertini class! |
---|
89 | default: |
---|
90 | G4cerr << " uups, unknown particle type " << ityp << G4endl; |
---|
91 | } |
---|
92 | |
---|
93 | return 0; |
---|
94 | } |
---|
95 | |
---|
96 | // This is the inverse mapping to makeDefinition above |
---|
97 | |
---|
98 | G4int G4InuclElementaryParticle::type(const G4ParticleDefinition *pd) { |
---|
99 | if (pd == 0) return 0; |
---|
100 | if (pd == G4Proton::Definition()) return proton; |
---|
101 | if (pd == G4Neutron::Definition()) return neutron; |
---|
102 | if (pd == G4PionPlus::Definition()) return pionPlus; |
---|
103 | if (pd == G4PionMinus::Definition()) return pionMinus; |
---|
104 | if (pd == G4PionZero::Definition()) return pionZero; |
---|
105 | if (pd == G4Gamma::Definition()) return photon; |
---|
106 | if (pd == G4KaonPlus::Definition()) return kaonPlus; |
---|
107 | if (pd == G4KaonMinus::Definition()) return kaonMinus; |
---|
108 | if (pd == G4KaonZero::Definition()) return kaonZero; |
---|
109 | if (pd == G4AntiKaonZero::Definition()) return kaonZeroBar; |
---|
110 | if (pd == G4Lambda::Definition()) return lambda; |
---|
111 | if (pd == G4SigmaPlus::Definition()) return sigmaPlus; |
---|
112 | if (pd == G4SigmaZero::Definition()) return sigmaZero; |
---|
113 | if (pd == G4SigmaMinus::Definition()) return sigmaMinus; |
---|
114 | if (pd == G4XiZero::Definition()) return xiZero; |
---|
115 | if (pd == G4XiMinus::Definition()) return xiMinus; |
---|
116 | if (pd == G4OmegaMinus::Definition()) return omegaMinus; |
---|
117 | if (pd == G4AntiProton::Definition()) return antiProton; |
---|
118 | if (pd == G4AntiNeutron::Definition()) return antiNeutron; |
---|
119 | if (pd == G4Diproton::Definition()) return diproton; // Bertini class! |
---|
120 | if (pd == G4UnboundPN::Definition()) return unboundPN; // Bertini class! |
---|
121 | if (pd == G4Dineutron::Definition()) return dineutron; // Bertini class! |
---|
122 | |
---|
123 | return 0; // Unknown objects return zero (e.g., nuclei) |
---|
124 | } |
---|
125 | |
---|
126 | void G4InuclElementaryParticle::setType(G4int ityp) { |
---|
127 | setDefinition(makeDefinition(ityp)); |
---|
128 | } |
---|
129 | |
---|
130 | |
---|
131 | // Assignment operator for use with std::sort() |
---|
132 | G4InuclElementaryParticle& |
---|
133 | G4InuclElementaryParticle::operator=(const G4InuclElementaryParticle& right) { |
---|
134 | generation = right.generation; |
---|
135 | G4InuclParticle::operator=(right); |
---|
136 | return *this; |
---|
137 | } |
---|
138 | |
---|
139 | |
---|
140 | G4double G4InuclElementaryParticle::getStrangeness(G4int type) { |
---|
141 | G4ParticleDefinition* pd = makeDefinition(type); |
---|
142 | return pd ? (pd->GetQuarkContent(3) - pd->GetAntiQuarkContent(3)) : 0.; |
---|
143 | } |
---|
144 | |
---|
145 | G4double G4InuclElementaryParticle::getParticleMass(G4int type) { |
---|
146 | G4ParticleDefinition* pd = makeDefinition(type); |
---|
147 | return pd ? pd->GetPDGMass()*MeV/GeV : 0.0; // From G4 to Bertini units |
---|
148 | } |
---|
149 | |
---|
150 | |
---|
151 | // Print particle parameters |
---|
152 | |
---|
153 | void G4InuclElementaryParticle::printParticle() const { |
---|
154 | G4InuclParticle::printParticle(); |
---|
155 | G4cout << " Particle: " << getDefinition()->GetParticleName() |
---|
156 | << " type " << type() << " mass " << getMass() |
---|
157 | << " ekin " << getKineticEnergy() << G4endl; |
---|
158 | } |
---|
159 | |
---|