source: trunk/source/particles/management/src/G4ParticleDefinition.cc@ 891

Last change on this file since 891 was 850, checked in by garnier, 17 years ago

geant4.8.2 beta

File size: 10.4 KB
Line 
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//
27// $Id: G4ParticleDefinition.cc,v 1.31 2008/06/08 12:43:19 kurasige Exp $
28// GEANT4 tag $Name: HEAD $
29//
30//
31// --------------------------------------------------------------
32// GEANT 4 class implementation file
33//
34// History: first implementation, based on object model of
35// 2nd December 1995, G.Cosmo
36// ---------------- G4ParticleDefinition -----------------
37// first implementation by Makoto Asai, 29 January 1996
38// revised by G.Cosmo, 29 February 1996
39// revised by H.Kurashige, 19 April 1996
40// Code uses operators (+=, *=, ++, -> etc.) correctly, P. Urban, 26/6/96
41// revised by H.Kurashige, 4 July 1996
42// revised by H.Kurashige, 16 Feb 1997
43// revised by H.Kurashige, 10 Nov 1997
44// remove new/delete G4ProcessManager by H.Kurashige 06 June 1998
45// added Resonance flag and ApplyCuts flag H.Kurashige 27 June 1998
46// modify FillQuarkContents() for quarks/diquarks H.Kurashige 30 June 1998
47// modify encoding rule H.Kurashige 23 Oct. 98
48// modify FillQuarkContents() for deltas 25 Nov.,98 H.Kurashige
49//
50// modify FillQuarkContents() to use G4PDGCodeChecker 17 Aug. 99 H.Kurashige
51// --------------------------------------------------------------
52
53
54#include "G4ParticleDefinition.hh"
55#include "G4ParticleTable.hh"
56#include "G4DecayTable.hh"
57#include "G4PDGCodeChecker.hh"
58
59G4ParticleDefinition::G4ParticleDefinition(
60 const G4String& aName,
61 G4double mass,
62 G4double width,
63 G4double charge,
64 G4int iSpin,
65 G4int iParity,
66 G4int iConjugation,
67 G4int iIsospin,
68 G4int iIsospin3,
69 G4int gParity,
70 const G4String& pType,
71 G4int lepton,
72 G4int baryon,
73 G4int encoding,
74 G4bool stable,
75 G4double lifetime,
76 G4DecayTable *decaytable,
77 G4bool shortlived,
78 const G4String& subType,
79 G4int anti_encoding,
80 G4double magneticMoment)
81
82 : theParticleName(aName),
83 thePDGMass(mass),
84 thePDGWidth(width),
85 thePDGCharge(charge),
86 thePDGiSpin(iSpin),
87 thePDGSpin(iSpin*0.5),
88 thePDGiParity(iParity),
89 thePDGiConjugation(iConjugation),
90 thePDGiGParity(gParity),
91 thePDGiIsospin(iIsospin),
92 thePDGiIsospin3(iIsospin3),
93 thePDGIsospin(iIsospin*0.5),
94 thePDGIsospin3(iIsospin3*0.5),
95 thePDGMagneticMoment(magneticMoment),
96 theLeptonNumber(lepton),
97 theBaryonNumber(baryon),
98 theParticleType(pType),
99 theParticleSubType(subType),
100 thePDGEncoding(encoding),
101 theAntiPDGEncoding(-1*encoding),
102 fShortLivedFlag(shortlived),
103 thePDGStable(stable),
104 thePDGLifeTime(lifetime),
105 theDecayTable(decaytable),
106 theProcessManager(0),
107 theAtomicNumber(0),
108 theAtomicMass(0),
109 verboseLevel(1),
110 fApplyCutsFlag(false)
111{
112 // check name and register this particle into ParticleTable
113 theParticleTable = G4ParticleTable::GetParticleTable();
114 theParticleTable->Insert(this);
115
116 //set verboseLevel equal to ParticleTable
117 verboseLevel = theParticleTable->GetVerboseLevel();
118
119 if (anti_encoding !=0) theAntiPDGEncoding = anti_encoding;
120
121 // check quark contents
122 if (this->FillQuarkContents() != thePDGEncoding) {
123#ifdef G4VERBOSE
124 if (verboseLevel>0) {
125 // Using G4cerr expecting that it is available in construction of static objects
126 G4cerr << "Particle " << aName << " has a strange PDGEncoding " <<G4endl;
127 }
128#endif
129 }
130}
131
132G4ParticleDefinition::G4ParticleDefinition(const G4ParticleDefinition &)
133{
134 G4Exception("G4ParticleDefinition::G4ParticleDefinition()",
135 "illegal constructor call", FatalException,
136 "You call Copy Constructor of G4ParticleDefinition ");
137}
138
139G4ParticleDefinition::G4ParticleDefinition()
140{
141 G4Exception("G4ParticleDefinition::G4ParticleDefinition()",
142 "illegal constructor call", FatalException,
143 "You call Default Constructor of G4ParticleDefinition ");
144}
145
146
147G4ParticleDefinition::~G4ParticleDefinition()
148{
149 if (theDecayTable!= 0) delete theDecayTable;
150}
151
152
153const G4ParticleDefinition & G4ParticleDefinition::operator=(const G4ParticleDefinition &right)
154{
155 if (this != &right) {
156 }
157 return *this;
158}
159
160G4int G4ParticleDefinition::operator==(const G4ParticleDefinition &right) const
161{
162 return (this->theParticleName == right.theParticleName);
163}
164
165G4int G4ParticleDefinition::operator!=(const G4ParticleDefinition &right) const
166{
167 return (this->theParticleName != right.theParticleName);
168}
169
170
171
172G4int G4ParticleDefinition::FillQuarkContents()
173 // calculate quark and anti-quark contents
174 // return value is PDG encoding for this particle.
175 // It means error if the return value is differnt from
176 // this->thePDGEncoding.
177{
178 G4int flavor;
179 for (flavor= 0; flavor<NumberOfQuarkFlavor; flavor++){
180 theQuarkContent[flavor] = 0;
181 theAntiQuarkContent[flavor] = 0;
182 }
183
184 G4PDGCodeChecker checker;
185 checker.SetVerboseLevel(verboseLevel);
186
187 G4int temp = checker.CheckPDGCode(thePDGEncoding, theParticleType);
188
189 if ( temp != 0) {
190 for (flavor= 0; flavor<NumberOfQuarkFlavor; flavor++){
191 theQuarkContent[flavor] = checker.GetQuarkContent(flavor);
192 theAntiQuarkContent[flavor] = checker.GetAntiQuarkContent(flavor);
193 }
194 if ((theParticleType == "meson")||(theParticleType == "baryon")) {
195 // check charge
196 if (!checker.CheckCharge(thePDGCharge) ){
197 temp = 0;
198#ifdef G4VERBOSE
199 if (verboseLevel>0) {
200 G4cout << "G4ParticleDefinition::FillQuarkContents : ";
201 G4cout << " illegal charge (" << thePDGCharge/eplus;
202 G4cout << " PDG code=" << thePDGEncoding <<G4endl;
203 }
204#endif
205 }
206 // check spin
207 if (checker.GetSpin() != thePDGiSpin) {
208 temp=0;
209#ifdef G4VERBOSE
210 if (verboseLevel>0) {
211 G4cout << "G4ParticleDefinition::FillQuarkContents : ";
212 G4cout << " illegal SPIN (" << thePDGiSpin << "/2";
213 G4cout << " PDG code=" << thePDGEncoding <<G4endl;
214 }
215#endif
216 }
217 }
218 }
219 return temp;
220}
221
222void G4ParticleDefinition::DumpTable() const
223{
224 G4cout << G4endl;
225 G4cout << "--- G4ParticleDefinition ---" << G4endl;
226 G4cout << " Particle Name : " << theParticleName << G4endl;
227 G4cout << " PDG particle code : " << thePDGEncoding;
228 G4cout << " [PDG anti-particle code: " << this->GetAntiPDGEncoding() << "]"<< G4endl;
229 G4cout << " Mass [GeV/c2] : " << thePDGMass/GeV ;
230 G4cout << " Width : " << thePDGWidth/GeV << G4endl;
231 G4cout << " Lifetime [nsec] : " << thePDGLifeTime/ns << G4endl;
232 G4cout << " Charge [e]: " << thePDGCharge/eplus << G4endl;
233 G4cout << " Spin : " << thePDGiSpin << "/2" << G4endl;
234 G4cout << " Parity : " << thePDGiParity << G4endl;
235 G4cout << " Charge conjugation : " << thePDGiConjugation << G4endl;
236 G4cout << " Isospin : (I,Iz): (" << thePDGiIsospin <<"/2";
237 G4cout << " , " << thePDGiIsospin3 << "/2 ) " << G4endl;
238 G4cout << " GParity : " << thePDGiGParity << G4endl;
239 if (thePDGMagneticMoment != 0.0) {
240 G4cout << " MagneticMoment [MeV/T] : " << thePDGMagneticMoment/MeV*tesla << G4endl;
241 }
242 G4cout << " Quark contents (d,u,s,c,b,t) : " << theQuarkContent[0];
243 G4cout << ", " << theQuarkContent[1];
244 G4cout << ", " << theQuarkContent[2];
245 G4cout << ", " << theQuarkContent[3];
246 G4cout << ", " << theQuarkContent[4];
247 G4cout << ", " << theQuarkContent[5] << G4endl;
248 G4cout << " AntiQuark contents : " << theAntiQuarkContent[0];
249 G4cout << ", " << theAntiQuarkContent[1];
250 G4cout << ", " << theAntiQuarkContent[2];
251 G4cout << ", " << theAntiQuarkContent[3];
252 G4cout << ", " << theAntiQuarkContent[4];
253 G4cout << ", " << theAntiQuarkContent[5] << G4endl;
254 G4cout << " Lepton number : " << theLeptonNumber;
255 G4cout << " Baryon number : " << theBaryonNumber << G4endl;
256 G4cout << " Particle type : " << theParticleType ;
257 G4cout << " [" << theParticleSubType << "]" << G4endl;
258
259 if ( fShortLivedFlag ){
260 G4cout << " ShortLived : ON" << G4endl;
261 }
262
263 if ( thePDGStable ){
264 G4cout << " Stable : stable" << G4endl;
265 } else {
266 if( theDecayTable != 0 ){
267 theDecayTable->DumpInfo();
268 } else {
269 G4cout << "Decay Table is not defined !!" <<G4endl;
270 }
271 }
272
273}
274
275void G4ParticleDefinition::SetApplyCutsFlag(G4bool flg)
276{
277 if(theParticleName=="gamma"
278 || theParticleName=="e-"
279 || theParticleName=="e+")
280 { fApplyCutsFlag = flg; }
281 else
282 {
283 G4cerr
284 << "G4ParticleDefinition::SetApplyCutsFlag() for " << theParticleName
285 << G4endl;
286 G4cerr
287 << "becomes obsolete. Production threshold is applied only for "
288 << "gamma, e- and e+." << G4endl;
289 }
290}
291
292
293
294
295
296
297
298
299
300
301
302
303
Note: See TracBrowser for help on using the repository browser.