Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ParticleDefinition.cc
Go to the documentation of this file.
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$
28 //
29 //
30 // --------------------------------------------------------------
31 // GEANT 4 class implementation file
32 //
33 // History: first implementation, based on object model of
34 // 2nd December 1995, G.Cosmo
35 // ---------------- G4ParticleDefinition -----------------
36 // first implementation by Makoto Asai, 29 January 1996
37 // revised by G.Cosmo, 29 February 1996
38 // revised by H.Kurashige, 19 April 1996
39 // Code uses operators (+=, *=, ++, -> etc.) correctly, P. Urban, 26/6/96
40 // revised by H.Kurashige, 4 July 1996
41 // revised by H.Kurashige, 16 Feb 1997
42 // revised by H.Kurashige, 10 Nov 1997
43 // remove new/delete G4ProcessManager by H.Kurashige 06 June 1998
44 // added Resonance flag and ApplyCuts flag H.Kurashige 27 June 1998
45 // modify FillQuarkContents() for quarks/diquarks H.Kurashige 30 June 1998
46 // modify encoding rule H.Kurashige 23 Oct. 98
47 // modify FillQuarkContents() for deltas 25 Nov.,98 H.Kurashige
48 //
49 // modify FillQuarkContents() to use G4PDGCodeChecker 17 Aug. 99 H.Kurashige
50 // --------------------------------------------------------------
51 
52 
53 #include "G4ParticleDefinition.hh"
54 #include "G4PhysicalConstants.hh"
55 #include "G4SystemOfUnits.hh"
56 #include "G4ParticleTable.hh"
57 #include "G4IonTable.hh"
58 #include "G4DecayTable.hh"
59 #include "G4PDGCodeChecker.hh"
60 #include "G4StateManager.hh"
61 
63  const G4String& aName,
64  G4double mass,
65  G4double width,
66  G4double charge,
67  G4int iSpin,
68  G4int iParity,
69  G4int iConjugation,
70  G4int iIsospin,
71  G4int iIsospin3,
72  G4int gParity,
73  const G4String& pType,
74  G4int lepton,
75  G4int baryon,
77  G4bool stable,
78  G4double lifetime,
79  G4DecayTable *decaytable,
80  G4bool shortlived,
81  const G4String& subType,
82  G4int anti_encoding,
83  G4double magneticMoment)
84 
85  : theParticleName(aName),
86  thePDGMass(mass),
87  thePDGWidth(width),
88  thePDGCharge(charge),
89  thePDGiSpin(iSpin),
90  thePDGSpin(iSpin*0.5),
91  thePDGiParity(iParity),
92  thePDGiConjugation(iConjugation),
93  thePDGiGParity(gParity),
94  thePDGiIsospin(iIsospin),
95  thePDGiIsospin3(iIsospin3),
96  thePDGIsospin(iIsospin*0.5),
97  thePDGIsospin3(iIsospin3*0.5),
98  thePDGMagneticMoment(magneticMoment),
99  theLeptonNumber(lepton),
100  theBaryonNumber(baryon),
101  theParticleType(pType),
102  theParticleSubType(subType),
103  thePDGEncoding(encoding),
104  theAntiPDGEncoding(-1*encoding),
105  fShortLivedFlag(shortlived),
106  thePDGStable(stable),
107  thePDGLifeTime(lifetime),
108  theDecayTable(decaytable),
109  theProcessManager(0),
110  theAtomicNumber(0),
111  theAtomicMass(0),
112  verboseLevel(1),
113  fApplyCutsFlag(false)
114 {
115  static G4String nucleus("nucleus");
116  theParticleTable = G4ParticleTable::GetParticleTable();
117 
118  //set verboseLevel equal to ParticleTable
119  verboseLevel = theParticleTable->GetVerboseLevel();
120 
121  if (anti_encoding !=0) theAntiPDGEncoding = anti_encoding;
122 
123  // check quark contents
124  if (this->FillQuarkContents() != thePDGEncoding) {
125 #ifdef G4VERBOSE
126  if (verboseLevel>0) {
127  // Using G4cerr expecting that it is available in construction of static objects
128  G4cerr << "Particle " << aName << " has a strange PDGEncoding " <<G4endl;
129  }
130 #endif
131  G4Exception( "G4ParticleDefintion::G4ParticleDefintion",
132  "PART102", JustWarning,
133  "Strange PDGEncoding ");
134  }
135 
136  // check initialization is in Pre_Init state except for ions
138 
139  if ( !fShortLivedFlag && (theParticleType!=nucleus) && (currentState!=G4State_PreInit)){
140 #ifdef G4VERBOSE
141  if (GetVerboseLevel()>0) {
142  G4cerr << "G4ParticleDefintion (other than ions and shortlived) should be created in Pre_Init state "
143  << aName << G4endl;
144  }
145 #endif
146  G4Exception( "G4ParticleDefintion::G4ParticleDefintion",
147  "PART101", JustWarning,
148  "G4ParticleDefinition should be created in PreInit state");
149  }
150 
151 
152  if (theParticleTable->GetIonTable()->IsIon(this)) {
155  }
156 
157  if (theParticleTable->GetIonTable()->IsAntiIon(this)) {
158  SetAtomicNumber( std::abs(G4int(GetPDGCharge()/eplus)) );
159  SetAtomicMass( std::abs(GetBaryonNumber()) );
160  }
161 
162  // check name and register this particle into ParticleTable
163  theParticleTable->Insert(this);
164 
165 }
166 
168 {
169  G4Exception("G4ParticleDefinition::G4ParticleDefinition()",
170  "PART001", FatalException,
171  "Illegal call of copy Constructor for G4ParticleDefinition ");
172 }
173 
175 {
176  G4Exception("G4ParticleDefinition::G4ParticleDefinition()",
177  "PART001", FatalException,
178  "Illegal call of default Constructor for G4ParticleDefinition ");
179 }
180 
181 
183 {
184  if (G4ParticleTable::GetParticleTable()->GetReadiness()) {
186  G4ApplicationState currentState = pStateManager->GetCurrentState();
187  if (currentState != G4State_PreInit) {
188  G4String msg = "Request of deletion for ";
189  msg += GetParticleName();
190  msg += " has No effects because readyToUse is true.";
191  G4Exception("G4ParticleDefinition::~G4ParticleDefinition()",
192  "PART117", JustWarning, msg);
193  return ;
194  } else {
195 #ifdef G4VERBOSE
196  if (verboseLevel>0){
198  << " will be deleted " << G4endl;
199  }
200 #endif
201  }
202  }
203 
204  if (theDecayTable!= 0) delete theDecayTable;
205 }
206 
207 
208 const G4ParticleDefinition & G4ParticleDefinition::operator=(const G4ParticleDefinition &right)
209 {
210  if (this != &right) {
211  }
212  return *this;
213 }
214 
216 {
217  return (this->theParticleName == right.theParticleName);
218 }
219 
221 {
222  return (this->theParticleName != right.theParticleName);
223 }
224 
225 
226 
228  // calculate quark and anti-quark contents
229  // return value is PDG encoding for this particle.
230  // It means error if the return value is differnt from
231  // this->thePDGEncoding.
232 {
233  G4int flavor;
234  for (flavor= 0; flavor<NumberOfQuarkFlavor; flavor++){
235  theQuarkContent[flavor] = 0;
236  theAntiQuarkContent[flavor] = 0;
237  }
238 
239  G4PDGCodeChecker checker;
240  checker.SetVerboseLevel(verboseLevel);
241 
242  G4int temp = checker.CheckPDGCode(thePDGEncoding, theParticleType);
243 
244  if ( temp != 0) {
245  for (flavor= 0; flavor<NumberOfQuarkFlavor; flavor++){
246  theQuarkContent[flavor] = checker.GetQuarkContent(flavor);
247  theAntiQuarkContent[flavor] = checker.GetAntiQuarkContent(flavor);
248  }
249  if ((theParticleType == "meson")||(theParticleType == "baryon")) {
250  // check charge
251  if (!checker.CheckCharge(thePDGCharge) ){
252  temp = 0;
253  G4Exception( "G4ParticleDefintion::G4ParticleDefintion",
254  "PART103", JustWarning,
255  "Inconsistent charge against PDG code ");
256 #ifdef G4VERBOSE
257  if (verboseLevel>0) {
258  G4cerr << "G4ParticleDefinition::FillQuarkContents : "
259  << " illegal charge (" << thePDGCharge/eplus
260  << " PDG code=" << thePDGEncoding <<G4endl;
261  }
262 #endif
263  }
264  // check spin
265  if (checker.GetSpin() != thePDGiSpin) {
266  temp=0;
267  G4Exception( "G4ParticleDefintion::G4ParticleDefintion",
268  "PART104", JustWarning,
269  "Inconsistent spin against PDG code ");
270 #ifdef G4VERBOSE
271  if (verboseLevel>0) {
272  G4cerr << "G4ParticleDefinition::FillQuarkContents : "
273  << " illegal SPIN (" << thePDGiSpin << "/2"
274  << " PDG code=" << thePDGEncoding <<G4endl;
275  }
276 #endif
277  }
278  }
279  }
280  return temp;
281 }
282 
284 {
285  G4cout << G4endl;
286  G4cout << "--- G4ParticleDefinition ---" << G4endl;
287  G4cout << " Particle Name : " << theParticleName << G4endl;
288  G4cout << " PDG particle code : " << thePDGEncoding;
289  G4cout << " [PDG anti-particle code: " << this->GetAntiPDGEncoding() << "]"<< G4endl;
290  G4cout << " Mass [GeV/c2] : " << thePDGMass/GeV ;
291  G4cout << " Width : " << thePDGWidth/GeV << G4endl;
292  G4cout << " Lifetime [nsec] : " << thePDGLifeTime/ns << G4endl;
293  G4cout << " Charge [e]: " << thePDGCharge/eplus << G4endl;
294  G4cout << " Spin : " << thePDGiSpin << "/2" << G4endl;
295  G4cout << " Parity : " << thePDGiParity << G4endl;
296  G4cout << " Charge conjugation : " << thePDGiConjugation << G4endl;
297  G4cout << " Isospin : (I,Iz): (" << thePDGiIsospin <<"/2";
298  G4cout << " , " << thePDGiIsospin3 << "/2 ) " << G4endl;
299  G4cout << " GParity : " << thePDGiGParity << G4endl;
300  if (thePDGMagneticMoment != 0.0) {
301  G4cout << " MagneticMoment [MeV/T] : " << thePDGMagneticMoment/MeV*tesla << G4endl;
302  }
303  G4cout << " Quark contents (d,u,s,c,b,t) : " << theQuarkContent[0];
304  G4cout << ", " << theQuarkContent[1];
305  G4cout << ", " << theQuarkContent[2];
306  G4cout << ", " << theQuarkContent[3];
307  G4cout << ", " << theQuarkContent[4];
308  G4cout << ", " << theQuarkContent[5] << G4endl;
309  G4cout << " AntiQuark contents : " << theAntiQuarkContent[0];
310  G4cout << ", " << theAntiQuarkContent[1];
311  G4cout << ", " << theAntiQuarkContent[2];
312  G4cout << ", " << theAntiQuarkContent[3];
313  G4cout << ", " << theAntiQuarkContent[4];
314  G4cout << ", " << theAntiQuarkContent[5] << G4endl;
315  G4cout << " Lepton number : " << theLeptonNumber;
316  G4cout << " Baryon number : " << theBaryonNumber << G4endl;
317  G4cout << " Particle type : " << theParticleType ;
318  G4cout << " [" << theParticleSubType << "]" << G4endl;
319 
320  if ( (theParticleTable->GetIonTable()->IsIon(this))
321  || (theParticleTable->GetIonTable()->IsAntiIon(this)) ) {
322  G4cout << " Atomic Number : " << GetAtomicNumber();
323  G4cout << " Atomic Mass : " << GetAtomicMass() << G4endl;
324  }
325  if ( fShortLivedFlag ){
326  G4cout << " ShortLived : ON" << G4endl;
327  }
328 
329  if ( thePDGStable ){
330  G4cout << " Stable : stable" << G4endl;
331  } else {
332  if( theDecayTable != 0 ){
333  theDecayTable->DumpInfo();
334  } else {
335  G4cout << "Decay Table is not defined !!" <<G4endl;
336  }
337  }
338 
339 }
340 
342 {
343  if(theParticleName=="gamma"
344  || theParticleName=="e-"
345  || theParticleName=="e+"
346  || theParticleName=="proton")
347  { fApplyCutsFlag = flg; }
348  else
349  {
350  G4cerr
351  << "G4ParticleDefinition::SetApplyCutsFlag() for " << theParticleName
352  << G4endl;
353  G4cerr
354  << "becomes obsolete. Production threshold is applied only for "
355  << "gamma, e- ,e+ and proton." << G4endl;
356  }
357 }