[824] | 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 | // |
---|
[1315] | 27 | // $Id: G4ParticleDefinition.cc,v 1.36 2010/05/20 01:01:07 kurasige Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ |
---|
[824] | 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" |
---|
[1196] | 56 | #include "G4IonTable.hh" |
---|
[824] | 57 | #include "G4DecayTable.hh" |
---|
| 58 | #include "G4PDGCodeChecker.hh" |
---|
[1196] | 59 | #include "G4StateManager.hh" |
---|
[824] | 60 | |
---|
| 61 | G4ParticleDefinition::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 | { |
---|
[1196] | 114 | static G4String nucleus("nucleus"); |
---|
| 115 | theParticleTable = G4ParticleTable::GetParticleTable(); |
---|
[850] | 116 | |
---|
| 117 | //set verboseLevel equal to ParticleTable |
---|
| 118 | verboseLevel = theParticleTable->GetVerboseLevel(); |
---|
[824] | 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 | } |
---|
[1196] | 131 | |
---|
| 132 | // check initialization is in Pre_Init state except for ions |
---|
| 133 | G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState(); |
---|
| 134 | |
---|
[1315] | 135 | if ( !fShortLivedFlag && (theParticleType!=nucleus) && (currentState!=G4State_PreInit)){ |
---|
[1196] | 136 | #ifdef G4VERBOSE |
---|
| 137 | if (GetVerboseLevel()>0) { |
---|
[1315] | 138 | G4cerr << "G4ParticleDefintion (other than ions and shortlived) should be created in Pre_Init state " |
---|
| 139 | << aName << G4endl; |
---|
[1196] | 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 | |
---|
| 154 | // check name and register this particle into ParticleTable |
---|
| 155 | theParticleTable->Insert(this); |
---|
| 156 | |
---|
[824] | 157 | } |
---|
| 158 | |
---|
| 159 | G4ParticleDefinition::G4ParticleDefinition(const G4ParticleDefinition &) |
---|
| 160 | { |
---|
| 161 | G4Exception("G4ParticleDefinition::G4ParticleDefinition()", |
---|
| 162 | "illegal constructor call", FatalException, |
---|
| 163 | "You call Copy Constructor of G4ParticleDefinition "); |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | G4ParticleDefinition::G4ParticleDefinition() |
---|
| 167 | { |
---|
| 168 | G4Exception("G4ParticleDefinition::G4ParticleDefinition()", |
---|
| 169 | "illegal constructor call", FatalException, |
---|
| 170 | "You call Default Constructor of G4ParticleDefinition "); |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | |
---|
| 174 | G4ParticleDefinition::~G4ParticleDefinition() |
---|
| 175 | { |
---|
| 176 | if (theDecayTable!= 0) delete theDecayTable; |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | |
---|
| 180 | const G4ParticleDefinition & G4ParticleDefinition::operator=(const G4ParticleDefinition &right) |
---|
| 181 | { |
---|
| 182 | if (this != &right) { |
---|
| 183 | } |
---|
| 184 | return *this; |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | G4int G4ParticleDefinition::operator==(const G4ParticleDefinition &right) const |
---|
| 188 | { |
---|
| 189 | return (this->theParticleName == right.theParticleName); |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | G4int G4ParticleDefinition::operator!=(const G4ParticleDefinition &right) const |
---|
| 193 | { |
---|
| 194 | return (this->theParticleName != right.theParticleName); |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | |
---|
| 198 | |
---|
| 199 | G4int G4ParticleDefinition::FillQuarkContents() |
---|
| 200 | // calculate quark and anti-quark contents |
---|
| 201 | // return value is PDG encoding for this particle. |
---|
| 202 | // It means error if the return value is differnt from |
---|
| 203 | // this->thePDGEncoding. |
---|
| 204 | { |
---|
| 205 | G4int flavor; |
---|
| 206 | for (flavor= 0; flavor<NumberOfQuarkFlavor; flavor++){ |
---|
| 207 | theQuarkContent[flavor] = 0; |
---|
| 208 | theAntiQuarkContent[flavor] = 0; |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | G4PDGCodeChecker checker; |
---|
[850] | 212 | checker.SetVerboseLevel(verboseLevel); |
---|
[824] | 213 | |
---|
| 214 | G4int temp = checker.CheckPDGCode(thePDGEncoding, theParticleType); |
---|
| 215 | |
---|
| 216 | if ( temp != 0) { |
---|
| 217 | for (flavor= 0; flavor<NumberOfQuarkFlavor; flavor++){ |
---|
| 218 | theQuarkContent[flavor] = checker.GetQuarkContent(flavor); |
---|
| 219 | theAntiQuarkContent[flavor] = checker.GetAntiQuarkContent(flavor); |
---|
| 220 | } |
---|
| 221 | if ((theParticleType == "meson")||(theParticleType == "baryon")) { |
---|
| 222 | // check charge |
---|
| 223 | if (!checker.CheckCharge(thePDGCharge) ){ |
---|
| 224 | temp = 0; |
---|
| 225 | #ifdef G4VERBOSE |
---|
[850] | 226 | if (verboseLevel>0) { |
---|
[1315] | 227 | G4cerr << "G4ParticleDefinition::FillQuarkContents : " |
---|
| 228 | << " illegal charge (" << thePDGCharge/eplus |
---|
| 229 | << " PDG code=" << thePDGEncoding <<G4endl; |
---|
[824] | 230 | } |
---|
| 231 | #endif |
---|
| 232 | } |
---|
| 233 | // check spin |
---|
| 234 | if (checker.GetSpin() != thePDGiSpin) { |
---|
| 235 | temp=0; |
---|
| 236 | #ifdef G4VERBOSE |
---|
[850] | 237 | if (verboseLevel>0) { |
---|
[1315] | 238 | G4cerr << "G4ParticleDefinition::FillQuarkContents : " |
---|
| 239 | << " illegal SPIN (" << thePDGiSpin << "/2" |
---|
| 240 | << " PDG code=" << thePDGEncoding <<G4endl; |
---|
[824] | 241 | } |
---|
| 242 | #endif |
---|
| 243 | } |
---|
| 244 | } |
---|
| 245 | } |
---|
| 246 | return temp; |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | void G4ParticleDefinition::DumpTable() const |
---|
| 250 | { |
---|
| 251 | G4cout << G4endl; |
---|
| 252 | G4cout << "--- G4ParticleDefinition ---" << G4endl; |
---|
| 253 | G4cout << " Particle Name : " << theParticleName << G4endl; |
---|
| 254 | G4cout << " PDG particle code : " << thePDGEncoding; |
---|
| 255 | G4cout << " [PDG anti-particle code: " << this->GetAntiPDGEncoding() << "]"<< G4endl; |
---|
| 256 | G4cout << " Mass [GeV/c2] : " << thePDGMass/GeV ; |
---|
| 257 | G4cout << " Width : " << thePDGWidth/GeV << G4endl; |
---|
| 258 | G4cout << " Lifetime [nsec] : " << thePDGLifeTime/ns << G4endl; |
---|
| 259 | G4cout << " Charge [e]: " << thePDGCharge/eplus << G4endl; |
---|
| 260 | G4cout << " Spin : " << thePDGiSpin << "/2" << G4endl; |
---|
| 261 | G4cout << " Parity : " << thePDGiParity << G4endl; |
---|
| 262 | G4cout << " Charge conjugation : " << thePDGiConjugation << G4endl; |
---|
| 263 | G4cout << " Isospin : (I,Iz): (" << thePDGiIsospin <<"/2"; |
---|
| 264 | G4cout << " , " << thePDGiIsospin3 << "/2 ) " << G4endl; |
---|
| 265 | G4cout << " GParity : " << thePDGiGParity << G4endl; |
---|
| 266 | if (thePDGMagneticMoment != 0.0) { |
---|
| 267 | G4cout << " MagneticMoment [MeV/T] : " << thePDGMagneticMoment/MeV*tesla << G4endl; |
---|
| 268 | } |
---|
| 269 | G4cout << " Quark contents (d,u,s,c,b,t) : " << theQuarkContent[0]; |
---|
| 270 | G4cout << ", " << theQuarkContent[1]; |
---|
| 271 | G4cout << ", " << theQuarkContent[2]; |
---|
| 272 | G4cout << ", " << theQuarkContent[3]; |
---|
| 273 | G4cout << ", " << theQuarkContent[4]; |
---|
| 274 | G4cout << ", " << theQuarkContent[5] << G4endl; |
---|
| 275 | G4cout << " AntiQuark contents : " << theAntiQuarkContent[0]; |
---|
| 276 | G4cout << ", " << theAntiQuarkContent[1]; |
---|
| 277 | G4cout << ", " << theAntiQuarkContent[2]; |
---|
| 278 | G4cout << ", " << theAntiQuarkContent[3]; |
---|
| 279 | G4cout << ", " << theAntiQuarkContent[4]; |
---|
| 280 | G4cout << ", " << theAntiQuarkContent[5] << G4endl; |
---|
| 281 | G4cout << " Lepton number : " << theLeptonNumber; |
---|
| 282 | G4cout << " Baryon number : " << theBaryonNumber << G4endl; |
---|
| 283 | G4cout << " Particle type : " << theParticleType ; |
---|
| 284 | G4cout << " [" << theParticleSubType << "]" << G4endl; |
---|
| 285 | |
---|
| 286 | if ( fShortLivedFlag ){ |
---|
| 287 | G4cout << " ShortLived : ON" << G4endl; |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | if ( thePDGStable ){ |
---|
| 291 | G4cout << " Stable : stable" << G4endl; |
---|
| 292 | } else { |
---|
| 293 | if( theDecayTable != 0 ){ |
---|
| 294 | theDecayTable->DumpInfo(); |
---|
| 295 | } else { |
---|
| 296 | G4cout << "Decay Table is not defined !!" <<G4endl; |
---|
| 297 | } |
---|
| 298 | } |
---|
| 299 | |
---|
| 300 | } |
---|
| 301 | |
---|
| 302 | void G4ParticleDefinition::SetApplyCutsFlag(G4bool flg) |
---|
| 303 | { |
---|
| 304 | if(theParticleName=="gamma" |
---|
| 305 | || theParticleName=="e-" |
---|
| 306 | || theParticleName=="e+") |
---|
| 307 | { fApplyCutsFlag = flg; } |
---|
| 308 | else |
---|
| 309 | { |
---|
| 310 | G4cerr |
---|
| 311 | << "G4ParticleDefinition::SetApplyCutsFlag() for " << theParticleName |
---|
| 312 | << G4endl; |
---|
| 313 | G4cerr |
---|
| 314 | << "becomes obsolete. Production threshold is applied only for " |
---|
| 315 | << "gamma, e- and e+." << G4endl; |
---|
| 316 | } |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | |
---|
| 320 | |
---|
| 321 | |
---|
| 322 | |
---|
| 323 | |
---|
| 324 | |
---|
| 325 | |
---|
| 326 | |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | |
---|
| 330 | |
---|