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

Last change on this file since 1355 was 1340, checked in by garnier, 14 years ago

update ti head

File size: 11.6 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.37 2010/10/11 03:33:56 kurasige Exp $
28// GEANT4 tag $Name: particles-V09-03-15 $
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 "G4IonTable.hh"
57#include "G4DecayTable.hh"
58#include "G4PDGCodeChecker.hh"
59#include "G4StateManager.hh"
60
61G4ParticleDefinition::G4ParticleDefinition(
62                     const G4String&     aName, 
63                     G4double            mass,
64                     G4double            width,
65                     G4double            charge,   
66                     G4int               iSpin,
67                     G4int               iParity,   
68                     G4int               iConjugation,
69                     G4int               iIsospin,   
70                     G4int               iIsospin3, 
71                     G4int               gParity,
72                     const G4String&     pType,
73                     G4int               lepton,     
74                     G4int               baryon,
75                     G4int               encoding,
76                     G4bool              stable,
77                     G4double            lifetime,
78                     G4DecayTable        *decaytable,
79                     G4bool              shortlived,
80                     const G4String&     subType,
81                     G4int               anti_encoding,
82                     G4double            magneticMoment)
83
84                 : theParticleName(aName), 
85                   thePDGMass(mass),
86                   thePDGWidth(width),
87                   thePDGCharge(charge),
88                   thePDGiSpin(iSpin),
89                   thePDGSpin(iSpin*0.5),
90                   thePDGiParity(iParity), 
91                   thePDGiConjugation(iConjugation),
92                   thePDGiGParity(gParity),
93                   thePDGiIsospin(iIsospin),
94                   thePDGiIsospin3(iIsospin3),
95                   thePDGIsospin(iIsospin*0.5),
96                   thePDGIsospin3(iIsospin3*0.5),
97                   thePDGMagneticMoment(magneticMoment),
98                   theLeptonNumber(lepton),
99                   theBaryonNumber(baryon),
100                   theParticleType(pType), 
101                   theParticleSubType(subType), 
102                   thePDGEncoding(encoding),
103                   theAntiPDGEncoding(-1*encoding),
104                   fShortLivedFlag(shortlived),
105                   thePDGStable(stable), 
106                   thePDGLifeTime(lifetime), 
107                   theDecayTable(decaytable),
108                   theProcessManager(0),
109                   theAtomicNumber(0),
110                   theAtomicMass(0),
111                   verboseLevel(1),
112                   fApplyCutsFlag(false)
113{
114  static G4String nucleus("nucleus");
115  theParticleTable = G4ParticleTable::GetParticleTable();
116   
117   //set verboseLevel equal to ParticleTable
118   verboseLevel = theParticleTable->GetVerboseLevel();
119
120   if (anti_encoding !=0) theAntiPDGEncoding = anti_encoding;
121
122   // check quark contents
123   if (this->FillQuarkContents() != thePDGEncoding) {
124#ifdef G4VERBOSE
125     if (verboseLevel>0) {
126       // Using G4cerr expecting that it is available in construction of static objects
127       G4cerr << "Particle " << aName << " has a strange PDGEncoding " <<G4endl;
128     }
129#endif
130   }
131
132   // check initialization is in Pre_Init state except for ions
133   G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState();
134
135   if ( !fShortLivedFlag && (theParticleType!=nucleus) && (currentState!=G4State_PreInit)){
136#ifdef G4VERBOSE
137     if (GetVerboseLevel()>0) {
138       G4cerr << "G4ParticleDefintion (other than ions and shortlived) should be created in Pre_Init state  " 
139              << aName << G4endl;
140     }
141#endif
142     G4Exception( "G4ParticleDefintion::G4ParticleDefintion",
143                  "Illegal operation", JustWarning, 
144                  "G4ParticleDefinition should be created in PreInit state");
145   }
146
147   
148   if (theParticleTable->GetIonTable()->IsIon(this)) {
149     SetAtomicNumber( G4int(GetPDGCharge()/eplus) );
150     SetAtomicMass( GetBaryonNumber() );
151   }
152 
153   if (theParticleTable->GetIonTable()->IsAntiIon(this)) {
154     SetAtomicNumber( abs(G4int(GetPDGCharge()/eplus)) );
155     SetAtomicMass( abs(GetBaryonNumber()) );
156   }
157   
158   // check name and register this particle into ParticleTable
159   theParticleTable->Insert(this);
160
161}
162
163G4ParticleDefinition::G4ParticleDefinition(const G4ParticleDefinition &)
164{
165  G4Exception("G4ParticleDefinition::G4ParticleDefinition()",
166              "illegal constructor call", FatalException,
167              "You call Copy Constructor of G4ParticleDefinition ");
168}
169
170G4ParticleDefinition::G4ParticleDefinition()
171{
172  G4Exception("G4ParticleDefinition::G4ParticleDefinition()",
173              "illegal constructor call", FatalException,
174              "You call Default Constructor of G4ParticleDefinition ");
175}
176
177
178G4ParticleDefinition::~G4ParticleDefinition() 
179{
180  if (theDecayTable!= 0) delete theDecayTable;
181}
182
183
184const G4ParticleDefinition & G4ParticleDefinition::operator=(const G4ParticleDefinition &right)
185{
186  if (this != &right)  {
187  } 
188  return *this;
189}
190
191G4int G4ParticleDefinition::operator==(const G4ParticleDefinition &right) const
192{
193  return (this->theParticleName == right.theParticleName);
194}
195
196G4int G4ParticleDefinition::operator!=(const G4ParticleDefinition &right) const
197{
198  return (this->theParticleName != right.theParticleName);
199}
200
201
202
203G4int G4ParticleDefinition::FillQuarkContents()
204      //  calculate quark and anti-quark contents
205      //  return value is PDG encoding for this particle.
206      //  It means error if the return value is differnt from
207      //  this->thePDGEncoding.
208{
209  G4int flavor;
210  for (flavor= 0; flavor<NumberOfQuarkFlavor; flavor++){
211    theQuarkContent[flavor]     = 0;
212    theAntiQuarkContent[flavor] = 0;
213  }
214
215  G4PDGCodeChecker checker;
216  checker.SetVerboseLevel(verboseLevel);
217
218  G4int temp = checker.CheckPDGCode(thePDGEncoding, theParticleType);
219
220  if ( temp != 0) {
221    for (flavor= 0; flavor<NumberOfQuarkFlavor; flavor++){
222      theQuarkContent[flavor]     = checker.GetQuarkContent(flavor);
223      theAntiQuarkContent[flavor] = checker.GetAntiQuarkContent(flavor);
224    }
225    if ((theParticleType == "meson")||(theParticleType == "baryon")) {
226      // check charge
227      if (!checker.CheckCharge(thePDGCharge) ){
228        temp = 0;
229#ifdef G4VERBOSE
230        if (verboseLevel>0) {
231          G4cerr << "G4ParticleDefinition::FillQuarkContents  : "
232                 << " illegal charge (" << thePDGCharge/eplus
233                 << " PDG code=" << thePDGEncoding <<G4endl;
234        }
235#endif
236      }
237      // check spin
238      if (checker.GetSpin() != thePDGiSpin) {
239        temp=0;
240#ifdef G4VERBOSE
241        if (verboseLevel>0) {
242          G4cerr << "G4ParticleDefinition::FillQuarkContents  : "
243                 << " illegal SPIN (" << thePDGiSpin << "/2"
244                 << " PDG code=" << thePDGEncoding <<G4endl;
245        }
246#endif
247      }
248    }
249  }
250  return temp;
251}
252
253void G4ParticleDefinition::DumpTable() const
254{
255  G4cout << G4endl;
256  G4cout << "--- G4ParticleDefinition ---" << G4endl;
257  G4cout << " Particle Name : " << theParticleName << G4endl;
258  G4cout << " PDG particle code : " << thePDGEncoding;
259  G4cout << " [PDG anti-particle code: " << this->GetAntiPDGEncoding() << "]"<< G4endl;
260  G4cout << " Mass [GeV/c2] : " << thePDGMass/GeV ;
261  G4cout << "     Width : " << thePDGWidth/GeV << G4endl;
262  G4cout << " Lifetime [nsec] : " << thePDGLifeTime/ns << G4endl;
263  G4cout << " Charge [e]: " << thePDGCharge/eplus << G4endl;
264  G4cout << " Spin : " << thePDGiSpin << "/2" << G4endl;
265  G4cout << " Parity : " << thePDGiParity << G4endl;
266  G4cout << " Charge conjugation : " << thePDGiConjugation << G4endl;
267  G4cout << " Isospin : (I,Iz): (" << thePDGiIsospin <<"/2";
268  G4cout << " , " << thePDGiIsospin3 << "/2 ) " << G4endl;
269  G4cout << " GParity : " << thePDGiGParity << G4endl;
270  if (thePDGMagneticMoment != 0.0) {
271    G4cout << " MagneticMoment [MeV/T] : " << thePDGMagneticMoment/MeV*tesla << G4endl;
272  }
273  G4cout << " Quark contents     (d,u,s,c,b,t) : " << theQuarkContent[0];
274  G4cout << ", " << theQuarkContent[1];
275  G4cout << ", " << theQuarkContent[2];
276  G4cout << ", " << theQuarkContent[3];
277  G4cout << ", " << theQuarkContent[4];
278  G4cout << ", " << theQuarkContent[5] << G4endl;
279  G4cout << " AntiQuark contents               : " << theAntiQuarkContent[0];
280  G4cout << ", " << theAntiQuarkContent[1];
281  G4cout << ", " << theAntiQuarkContent[2];
282  G4cout << ", " << theAntiQuarkContent[3];
283  G4cout << ", " << theAntiQuarkContent[4];
284  G4cout << ", " << theAntiQuarkContent[5] << G4endl;
285  G4cout << " Lepton number : " << theLeptonNumber;
286  G4cout << " Baryon number : " << theBaryonNumber << G4endl;
287  G4cout << " Particle type : " << theParticleType ;
288  G4cout << " [" << theParticleSubType << "]" << G4endl;
289
290  if (   (theParticleTable->GetIonTable()->IsIon(this)) 
291      || (theParticleTable->GetIonTable()->IsAntiIon(this)) ) {
292    G4cout << " Atomic Number : " << GetAtomicNumber();
293    G4cout << "  Atomic Mass : " << GetAtomicMass()  << G4endl;
294  }
295  if ( fShortLivedFlag ){
296    G4cout << " ShortLived : ON" << G4endl;
297  }
298
299  if ( thePDGStable ){
300    G4cout << " Stable : stable" << G4endl;
301  } else {
302    if( theDecayTable != 0 ){
303      theDecayTable->DumpInfo();
304    } else {
305      G4cout << "Decay Table is not defined !!" <<G4endl;
306    }
307  }
308
309}
310
311void G4ParticleDefinition::SetApplyCutsFlag(G4bool flg)
312{
313  if(theParticleName=="gamma"
314  || theParticleName=="e-"
315  || theParticleName=="e+")
316  { fApplyCutsFlag = flg; }
317  else
318  {
319    G4cerr
320     << "G4ParticleDefinition::SetApplyCutsFlag() for " << theParticleName
321     << G4endl;
322    G4cerr
323     << "becomes obsolete. Production threshold is applied only for "
324     << "gamma, e- and e+." << G4endl;
325  }
326}
Note: See TracBrowser for help on using the repository browser.