Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ParticleDefinition.cc
이 파일의 문서화 페이지로 가기
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 110257 2018-05-17 14:20:12Z gcosmo $
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 // modified for thread-safety for MT - G.Cosmo, A.Dotti - January 2013
51 // added support for MuonicAtom - K.L.Genser - June 2017
52 // --------------------------------------------------------------
53 
54 
55 #include "G4ParticleDefinition.hh"
56 #include "G4PhysicalConstants.hh"
57 #include "G4SystemOfUnits.hh"
58 #include "G4ParticleTable.hh"
59 #include "G4IonTable.hh"
60 #include "G4DecayTable.hh"
61 #include "G4PDGCodeChecker.hh"
62 #include "G4StateManager.hh"
63 #include "G4UnitsTable.hh"
64 
65 // This new field helps to use the class G4PDefManager.
66 //
68 
69 // This macro changes the references to fields that are now encapsulated
70 // in the class G4PDefData.
71 //
72 #define G4MT_pmanager ((subInstanceManager.offset()[g4particleDefinitionInstanceID]).theProcessManager)
73 
75  const G4String& aName,
76  G4double mass,
78  G4double charge,
79  G4int iSpin,
80  G4int iParity,
81  G4int iConjugation,
82  G4int iIsospin,
83  G4int iIsospin3,
84  G4int gParity,
85  const G4String& pType,
86  G4int lepton,
87  G4int baryon,
89  G4bool stable,
90  G4double lifetime,
91  G4DecayTable *decaytable,
92  G4bool shortlived,
93  const G4String& subType,
94  G4int anti_encoding,
95  G4double magneticMoment)
96 
97  : theParticleName(aName),
98  thePDGMass(mass),
99  thePDGWidth(width),
100  thePDGCharge(charge),
101  thePDGiSpin(iSpin),
102  thePDGSpin(iSpin*0.5),
103  thePDGiParity(iParity),
104  thePDGiConjugation(iConjugation),
105  thePDGiGParity(gParity),
106  thePDGiIsospin(iIsospin),
107  thePDGiIsospin3(iIsospin3),
108  thePDGIsospin(iIsospin*0.5),
109  thePDGIsospin3(iIsospin3*0.5),
110  thePDGMagneticMoment(magneticMoment),
111  theLeptonNumber(lepton),
112  theBaryonNumber(baryon),
113  theParticleType(pType),
114  theParticleSubType(subType),
115  thePDGEncoding(encoding),
116  theAntiPDGEncoding(-1*encoding),
117  fShortLivedFlag(shortlived),
118  thePDGStable(stable),
119  thePDGLifeTime(lifetime),
120  theDecayTable(decaytable),
121  theAtomicNumber(0),
122  theAtomicMass(0),
123  verboseLevel(1),
124  fApplyCutsFlag(false),
125  isGeneralIon(false),
126  isMuonicAtom(false)
127 {
128  static const G4String nucleus("nucleus");
129  static const G4String muAtom("MuonicAtom");
130 
133 
135 
136  //set verboseLevel equal to ParticleTable
138 
139  if (anti_encoding !=0) theAntiPDGEncoding = anti_encoding;
140 
141  // check quark contents
142  if (this->FillQuarkContents() != thePDGEncoding) {
143 #ifdef G4VERBOSE
144  if (verboseLevel>0) {
145  // Using G4cout expecting that it is available in construction of static objects
146  G4cout << "Particle " << aName << " has a strange PDGEncoding " <<G4endl;
147  }
148 #endif
149  G4Exception( "G4ParticleDefintion::G4ParticleDefintion",
150  "PART102", JustWarning,
151  "Strange PDGEncoding ");
152  }
153 
154  // check initialization is in Pre_Init state except for ions
156 
157  if ( !fShortLivedFlag && (theParticleType!=nucleus) && (theParticleType!=muAtom) && (currentState!=G4State_PreInit)){
158 #ifdef G4VERBOSE
159  if (GetVerboseLevel()>0) {
160  G4cout << "G4ParticleDefintion (other than ions and shortlived) should be created in Pre_Init state "
161  << aName << G4endl;
162  }
163 #endif
164  G4Exception( "G4ParticleDefintion::G4ParticleDefintion",
165  "PART101", JustWarning,
166  "G4ParticleDefinition should be created in PreInit state");
167  }
168 
169 
170  if (theParticleTable->GetIonTable()->IsIon(this)) {
173  }
174 
175  if (theParticleTable->GetIonTable()->IsAntiIon(this)) {
176  SetAtomicNumber( std::abs(G4int(GetPDGCharge()/eplus)) );
177  SetAtomicMass( std::abs(GetBaryonNumber()) );
178  }
179 
180  // check name and register this particle into ParticleTable
181  theParticleTable->Insert(this);
182 
183 }
184 
186 {
187  G4Exception("G4ParticleDefinition::G4ParticleDefinition()",
188  "PART001", FatalException,
189  "Illegal call of copy Constructor for G4ParticleDefinition ");
190 }
191 
193 {
194  G4Exception("G4ParticleDefinition::G4ParticleDefinition()",
195  "PART001", FatalException,
196  "Illegal call of default Constructor for G4ParticleDefinition ");
197 }
198 
199 
201 {
202  if (G4ParticleTable::GetParticleTable()->GetReadiness()) {
204  G4ApplicationState currentState = pStateManager->GetCurrentState();
205  if (currentState != G4State_PreInit) {
206  G4String msg = "Request of deletion for ";
207  msg += GetParticleName();
208  msg += " has No effects because readyToUse is true.";
209  G4Exception("G4ParticleDefinition::~G4ParticleDefinition()",
210  "PART117", JustWarning, msg);
211  return ;
212  } else {
213 #ifdef G4VERBOSE
214  if (verboseLevel>0){
216  << " will be deleted " << G4endl;
217  }
218 #endif
219  }
220  }
221 
222  if (theDecayTable!= 0) delete theDecayTable;
223 }
224 
225 
227 {
228  if (this != &right) {
229  }
230  return *this;
231 }
232 
234 {
235  return (this->theParticleName == right.theParticleName);
236 }
237 
239 {
240  return (this->theParticleName != right.theParticleName);
241 }
242 
243 
245  // Returns the private data instance manager.
246 {
247  return subInstanceManager;
248 }
249 
250 
252  // Clears memory allocated by sub-instance manager
253 {
255 }
256 
257 
259 {
260  if(g4particleDefinitionInstanceID<0) return 0;
261  return G4MT_pmanager;
262 }
263 
265  // calculate quark and anti-quark contents
266  // return value is PDG encoding for this particle.
267  // It means error if the return value is differnt from
268  // this->thePDGEncoding.
269 {
270  G4int flavor;
271  for (flavor= 0; flavor<NumberOfQuarkFlavor; flavor++){
272  theQuarkContent[flavor] = 0;
273  theAntiQuarkContent[flavor] = 0;
274  }
275 
276  G4PDGCodeChecker checker;
277  checker.SetVerboseLevel(verboseLevel);
278 
280 
281  if ( temp != 0) {
282  for (flavor= 0; flavor<NumberOfQuarkFlavor; flavor++){
283  theQuarkContent[flavor] = checker.GetQuarkContent(flavor);
284  theAntiQuarkContent[flavor] = checker.GetAntiQuarkContent(flavor);
285  }
286  if ((theParticleType == "meson")||(theParticleType == "baryon")) {
287  // check charge
288  if (!checker.CheckCharge(thePDGCharge) ){
289  temp = 0;
290  G4Exception( "G4ParticleDefintion::G4ParticleDefintion",
291  "PART103", JustWarning,
292  "Inconsistent charge against PDG code ");
293 #ifdef G4VERBOSE
294  if (verboseLevel>0) {
295  G4cout << "G4ParticleDefinition::FillQuarkContents : "
296  << " illegal charge (" << thePDGCharge/eplus
297  << " PDG code=" << thePDGEncoding <<G4endl;
298  }
299 #endif
300  }
301  // check spin
302  if (checker.GetSpin() != thePDGiSpin) {
303  temp=0;
304  G4Exception( "G4ParticleDefintion::G4ParticleDefintion",
305  "PART104", JustWarning,
306  "Inconsistent spin against PDG code ");
307 #ifdef G4VERBOSE
308  if (verboseLevel>0) {
309  G4cout << "G4ParticleDefinition::FillQuarkContents : "
310  << " illegal SPIN (" << thePDGiSpin << "/2"
311  << " PDG code=" << thePDGEncoding <<G4endl;
312  }
313 #endif
314  }
315  }
316  }
317  return temp;
318 }
319 
320 //-- No longer needed to access to G4IonTable.
321 //-- Method GetIonLifeTime() itself is kept for compatibility
322 //-- but moved to icc file as an inlined method.
323 //G4double G4ParticleDefinition::GetIonLifeTime() const
324 //{
325 // if(!isGeneralIon) return thePDGLifeTime;
326 //
327 // G4IonTable* ionTable = G4IonTable::GetIonTable();
328 // return ionTable->GetLifeTime(this);
329 //}
330 
332 {
333  G4cout << G4endl;
334  G4cout << "--- G4ParticleDefinition ---" << G4endl;
335  G4cout << " Particle Name : " << theParticleName << G4endl;
336  G4cout << " PDG particle code : " << thePDGEncoding;
337  G4cout << " [PDG anti-particle code: " << this->GetAntiPDGEncoding() << "]"<< G4endl;
338  G4cout << " Mass [GeV/c2] : " << thePDGMass/GeV ;
339  G4cout << " Width : " << thePDGWidth/GeV << G4endl;
340  G4cout << " Lifetime [nsec] : " << thePDGLifeTime/ns << G4endl;
341  G4cout << " Charge [e]: " << thePDGCharge/eplus << G4endl;
342  G4cout << " Spin : " << thePDGiSpin << "/2" << G4endl;
343  G4cout << " Parity : " << thePDGiParity << G4endl;
344  G4cout << " Charge conjugation : " << thePDGiConjugation << G4endl;
345  G4cout << " Isospin : (I,Iz): (" << thePDGiIsospin <<"/2";
346  G4cout << " , " << thePDGiIsospin3 << "/2 ) " << G4endl;
347  G4cout << " GParity : " << thePDGiGParity << G4endl;
348  if (thePDGMagneticMoment != 0.0) {
349  G4cout << " MagneticMoment [MeV/T] : " << thePDGMagneticMoment/MeV*tesla << G4endl;
350  }
351  G4cout << " Quark contents (d,u,s,c,b,t) : " << theQuarkContent[0];
352  G4cout << ", " << theQuarkContent[1];
353  G4cout << ", " << theQuarkContent[2];
354  G4cout << ", " << theQuarkContent[3];
355  G4cout << ", " << theQuarkContent[4];
356  G4cout << ", " << theQuarkContent[5] << G4endl;
357  G4cout << " AntiQuark contents : " << theAntiQuarkContent[0];
358  G4cout << ", " << theAntiQuarkContent[1];
359  G4cout << ", " << theAntiQuarkContent[2];
360  G4cout << ", " << theAntiQuarkContent[3];
361  G4cout << ", " << theAntiQuarkContent[4];
362  G4cout << ", " << theAntiQuarkContent[5] << G4endl;
363  G4cout << " Lepton number : " << theLeptonNumber;
364  G4cout << " Baryon number : " << theBaryonNumber << G4endl;
365  G4cout << " Particle type : " << theParticleType ;
366  G4cout << " [" << theParticleSubType << "]" << G4endl;
367 
368  if ( (theParticleTable->GetIonTable()->IsIon(this))
369  || (theParticleTable->GetIonTable()->IsAntiIon(this)) ) {
370  G4cout << " Atomic Number : " << GetAtomicNumber();
371  G4cout << " Atomic Mass : " << GetAtomicMass() << G4endl;
372  }
373  if ( fShortLivedFlag ){
374  G4cout << " ShortLived : ON" << G4endl;
375  }
376 
377  if ( IsGeneralIon() ) {
378  G4double lftm = GetIonLifeTime();
379  if(lftm<-1000.)
380  { G4cout << " Stable : No data found -- unknown" << G4endl; }
381  else if(lftm<0.)
382  { G4cout << " Stable : stable" << G4endl; }
383  else
384  {
385  G4cout << " Stable : unstable -- lifetime = " << G4BestUnit(lftm,"Time")
386  << "\n Decay table should be consulted to G4RadioactiveDecayProcess."
387  << G4endl;
388  }
389  }
390  else
391  {
392  if ( thePDGStable ){
393  G4cout << " Stable : stable" << G4endl;
394  } else {
395  if( theDecayTable != 0 ){
397  } else {
398  G4cout << "Decay Table is not defined !!" <<G4endl;
399  }
400  }
401  }
402 }
403 
405 {
406  if(theParticleName=="gamma"
407  || theParticleName=="e-"
408  || theParticleName=="e+"
409  || theParticleName=="proton")
410  { fApplyCutsFlag = flg; }
411  else
412  {
413  G4cout
414  << "G4ParticleDefinition::SetApplyCutsFlag() for " << theParticleName
415  << G4endl;
416  G4cout
417  << "becomes obsolete. Production threshold is applied only for "
418  << "gamma, e- ,e+ and proton." << G4endl;
419  }
420 }
421 
423 {
424  G4Exception( "G4ParticleDefintion::G4ParticleDefintion",
425  "PART114", JustWarning,
426  "CalculateAnomaly() method will be removed in next release");
427 
428  // gives the anomaly of magnetic moment for spin 1/2 particles
429  if (thePDGiSpin==1) {
431  return 0.5*std::fabs(thePDGMagneticMoment/muB - 2.*thePDGCharge/CLHEP::eplus);
432  } else {
433  return 0.0;
434  }
435 }
436 
438 {
439  if(id<0)
440  {
442  G4MT_pmanager = 0;
443  }
444  else
445  {
446  if( isGeneralIon || isMuonicAtom )
448  else
449  {
451  ed << "ParticleDefinitionID should not be set for the particles <"
452  << theParticleName << ">.";
453  G4Exception( "G4ParticleDefintion::SetParticleDefinitionID","PART10114",
454  FatalException,ed);
455  }
456  }
457 }
458 
459 #include "G4Threading.hh"
460 
462 {
464  {
465  if(G4Threading::G4GetThreadId() >= 0)
466  {
468  ed << "ProcessManager is being set to " << theParticleName
469  << " without proper initialization of TLS pointer vector.\n"
470  << "This operation is thread-unsafe.";
471  G4Exception( "G4ParticleDefintion::SetProcessManager","PART10116",
472  JustWarning,ed);
473  }
475  }
476  G4MT_pmanager = aProcessManager;
477 }
static G4bool IsIon(const G4ParticleDefinition *)
Definition: G4IonTable.cc:1148
#define G4MT_pmanager
G4int GetAtomicNumber() const
void SetVerboseLevel(G4int verbose)
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
G4double CalculateAnomaly() const
static constexpr double hbar_Planck
G4bool IsGeneralIon() const
static G4ParticleTable * GetParticleTable()
static constexpr double MeV
Definition: G4SIunits.hh:214
G4int GetSpin() const
#define G4endl
Definition: G4ios.hh:61
void SetParticleDefinitionID(G4int id=-1)
const G4String & GetParticleName() const
G4int CheckPDGCode(G4int code, G4String type)
G4IonTable * GetIonTable() const
G4double GetPDGCharge() const
void SetAtomicMass(G4int)
G4int operator!=(const G4ParticleDefinition &right) const
G4int GetAntiQuarkContent(G4int flavor) const
static constexpr double c_squared
G4bool CheckCharge(G4double charge) const
void SetAtomicNumber(G4int)
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
const G4ParticleDefinition & operator=(const G4ParticleDefinition &r)
#define width
void SetProcessManager(G4ProcessManager *aProcessManager)
static G4PART_DLL G4PDefManager subInstanceManager
G4int theAntiQuarkContent[NumberOfQuarkFlavor]
static G4bool IsAntiIon(const G4ParticleDefinition *)
Definition: G4IonTable.cc:1173
G4int GetVerboseLevel() const
void DumpInfo() const
G4int GetAntiPDGEncoding() const
G4ProcessManager * theProcessManagerShadow
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4double GetIonLifeTime() const
static constexpr double eplus
Definition: G4SIunits.hh:199
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
G4int theQuarkContent[NumberOfQuarkFlavor]
G4ApplicationState GetCurrentState() const
G4ProcessManager * GetProcessManager() const
G4ParticleDefinition * Insert(G4ParticleDefinition *particle)
G4int GetAtomicMass() const
G4GLOB_DLL std::ostream G4cout
G4int operator==(const G4ParticleDefinition &right) const
static const G4PDefManager & GetSubInstanceManager()
G4int GetQuarkContent(G4int flavor) const
G4ApplicationState
G4ParticleTable * theParticleTable
G4int CreateSubInstance()
static constexpr double GeV
Definition: G4SIunits.hh:217
#define ns
Definition: xmlparse.cc:614
static constexpr double eplus
G4int GetVerboseLevel() const
static constexpr double tesla
Definition: G4SIunits.hh:268
static G4StateManager * GetStateManager()
G4int G4GetThreadId()
Definition: G4Threading.cc:128