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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /particles/management/src/G4ParticlePropertyTable.cc (Version 11.3.0) and /particles/management/src/G4ParticlePropertyTable.cc (Version 9.1.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4ParticlePropertyTable class implementatio <<  26 // $Id: G4ParticlePropertyTable.cc,v 1.4 2007/03/11 07:17:35 kurasige Exp $
 27 //                                                 27 //
 28 // Author: H.Kurashige, 9 June 2003 - First im <<  28 // class G4ParticlePropertyTable
 29 // ------------------------------------------- <<  29 //
 30                                                <<  30 // Implementation
 31 #include "G4ParticlePropertyTable.hh"          <<  31 //
                                                   >>  32 // History:
                                                   >>  33 // first implementation by H Kurashige 9 June 2003
                                                   >>  34 // Add   magnetic moment    by H Kurashige   Mar 2007
 32                                                    35 
 33 #include "G4ParticleTable.hh"                  << 
 34 #include "G4StateManager.hh"                   << 
 35 #include "G4ios.hh"                                36 #include "G4ios.hh"
 36 #include "globals.hh"                              37 #include "globals.hh"
                                                   >>  38 #include "G4StateManager.hh"
                                                   >>  39 #include "G4ParticleTable.hh"
                                                   >>  40 #include "G4ParticlePropertyTable.hh"
 37                                                    41 
 38 // Static class variable: ptr to single instan     42 // Static class variable: ptr to single instance of class
 39 //                                             <<  43 G4ParticlePropertyTable* G4ParticlePropertyTable::fgParticlePropertyTable =0;
 40 G4ThreadLocal G4ParticlePropertyTable* G4Parti << 
 41                                                    44 
                                                   >>  45 ////////////////////
 42 G4ParticlePropertyTable* G4ParticlePropertyTab     46 G4ParticlePropertyTable* G4ParticlePropertyTable::GetParticlePropertyTable()
 43 {                                                  47 {
 44   if (fgParticlePropertyTable == nullptr) {    <<  48   static G4ParticlePropertyTable theParticlePropertyTable;
 45     fgParticlePropertyTable = new G4ParticlePr <<  49   if (!fgParticlePropertyTable){
                                                   >>  50     fgParticlePropertyTable =  &theParticlePropertyTable;
 46   }                                                51   }
 47   return fgParticlePropertyTable;                  52   return fgParticlePropertyTable;
 48 }                                                  53 }
 49                                                    54 
                                                   >>  55 /////////////////////////////////////////////////////////////
 50 G4ParticlePropertyTable::~G4ParticlePropertyTa     56 G4ParticlePropertyTable::~G4ParticlePropertyTable()
 51 {                                                  57 {
 52   for (const auto& idx : arrayDataObject) {    <<  58   for (size_t idx=0; idx<arrayDataObject.size(); idx++){
 53     delete idx;                                <<  59     delete arrayDataObject[idx];
 54   }                                                60   }
 55   arrayDataObject.clear();                         61   arrayDataObject.clear();
 56 }                                                  62 }
 57                                                    63 
 58 G4ParticlePropertyTable::G4ParticlePropertyTab <<  64 /////////////////////////////////////////////////////////////
                                                   >>  65 G4ParticlePropertyTable::G4ParticlePropertyTable():
                                                   >>  66   verboseLevel(1)
                                                   >>  67 {
                                                   >>  68   fParticleTable = G4ParticleTable::GetParticleTable();   
                                                   >>  69 }
                                                   >>  70 
                                                   >>  71 ////////////////////////
                                                   >>  72 G4ParticlePropertyTable::G4ParticlePropertyTable(const G4ParticlePropertyTable &right)
                                                   >>  73 {
                                                   >>  74   *this = right;
                                                   >>  75 }
                                                   >>  76       
                                                   >>  77 ////////////////////////
                                                   >>  78 const G4ParticlePropertyTable & G4ParticlePropertyTable::operator=(const G4ParticlePropertyTable &right)
                                                   >>  79 {
                                                   >>  80   if (this != &right) {
                                                   >>  81     fParticleTable = right.fParticleTable;
                                                   >>  82     verboseLevel   = right.verboseLevel; 
                                                   >>  83   }
                                                   >>  84   return *this;
                                                   >>  85 }
                                                   >>  86   
                                                   >>  87 ////////////////////////
                                                   >>  88 G4int G4ParticlePropertyTable::operator==(const G4ParticlePropertyTable &) const
                                                   >>  89 {
                                                   >>  90   return true;
                                                   >>  91 }
                                                   >>  92 
                                                   >>  93 ////////////////////////
                                                   >>  94 G4int G4ParticlePropertyTable::operator!=(const G4ParticlePropertyTable &) const
 59 {                                                  95 {
 60   fParticleTable = G4ParticleTable::GetParticl <<  96   return false;
 61 }                                                  97 }
 62                                                    98 
                                                   >>  99 /////////////////////////////////////////////////////////////
 63 void G4ParticlePropertyTable::Clear()             100 void G4ParticlePropertyTable::Clear()
 64 {                                                 101 {
 65   for (const auto& idx : arrayDataObject) {    << 102   for (size_t idx=0; idx<arrayDataObject.size(); idx++){
 66     delete idx;                                << 103     delete arrayDataObject[idx];
 67   }                                               104   }
 68   arrayDataObject.clear();                        105   arrayDataObject.clear();
 69 }                                                 106 }
 70                                                   107 
                                                   >> 108 /////////////////////////////////////////////////////////////////////
 71 G4ParticlePropertyData* G4ParticlePropertyTabl    109 G4ParticlePropertyData* G4ParticlePropertyTable::GetParticleProperty(const G4String& aParticleName)
 72 {                                                 110 {
 73   G4ParticleDefinition* aParticle = fParticleT    111   G4ParticleDefinition* aParticle = fParticleTable->FindParticle(aParticleName);
 74   if (aParticle == nullptr) return nullptr;    << 112   if (aParticle ==0 ) return 0;
 75                                                   113 
 76   return GetParticleProperty(aParticle);          114   return GetParticleProperty(aParticle);
 77 }                                                 115 }
 78                                                   116 
 79 G4ParticlePropertyData*                        << 117 //////////////////////////////////////
 80 G4ParticlePropertyTable::GetParticleProperty(c << 118 G4ParticlePropertyData*  G4ParticlePropertyTable::GetParticleProperty(const G4ParticleDefinition* aParticle)
 81 {                                                 119 {
 82   if (aParticle == nullptr) return nullptr;    << 120   if (aParticle ==0 ) return 0;
 83   auto pData = new G4ParticlePropertyData(aPar << 121   G4ParticlePropertyData* pData = new G4ParticlePropertyData(aParticle->GetParticleName());
 84   pData->thePDGMass = aParticle->GetPDGMass(); << 122   pData->thePDGMass        = aParticle->GetPDGMass();
 85   pData->thePDGWidth = aParticle->GetPDGWidth( << 123   pData->thePDGWidth       = aParticle->GetPDGWidth();
 86   pData->thePDGCharge = aParticle->GetPDGCharg << 124   pData->thePDGCharge      = aParticle->GetPDGCharge();
 87   pData->thePDGiSpin = aParticle->GetPDGiSpin( << 125   pData->thePDGiSpin       = aParticle->GetPDGiSpin();
 88   pData->thePDGiParity = aParticle->GetPDGiPar << 126   pData->thePDGiParity     = aParticle->GetPDGiParity();
 89   pData->thePDGiConjugation = aParticle->GetPD << 127   pData->thePDGiConjugation  = aParticle->GetPDGiConjugation();
 90   pData->thePDGiGParity = aParticle->GetPDGiGP << 128   pData->thePDGiGParity    = aParticle->GetPDGiGParity();
 91   pData->thePDGiIsospin = aParticle->GetPDGiIs << 129   pData->thePDGiIsospin    = aParticle->GetPDGiIsospin();
 92   pData->thePDGiIsospin3 = aParticle->GetPDGiI << 130   pData->thePDGiIsospin3   = aParticle->GetPDGiIsospin3();
 93   pData->thePDGMagneticMoment = aParticle->Get << 131   pData->thePDGMagneticMoment   = aParticle->GetPDGMagneticMoment();
 94   pData->theLeptonNumber = aParticle->GetLepto << 132   pData->theLeptonNumber   = aParticle->GetLeptonNumber();
 95   pData->theBaryonNumber = aParticle->GetBaryo << 133   pData->theBaryonNumber   = aParticle->GetBaryonNumber();
 96   pData->thePDGEncoding = aParticle->GetPDGEnc << 134   pData->thePDGEncoding    = aParticle->GetPDGEncoding();
 97   pData->theAntiPDGEncoding = aParticle->GetAn << 135   pData->theAntiPDGEncoding  = aParticle->GetAntiPDGEncoding();
 98   pData->thePDGLifeTime = aParticle->GetPDGLif << 136   pData->thePDGLifeTime    = aParticle->GetPDGLifeTime(); 
 99   for (std::size_t flv = 0; flv < G4ParticlePr << 137   for (size_t flv=0; flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
100     pData->theQuarkContent[flv] = aParticle->t << 138     pData->theQuarkContent[flv]     = aParticle->theQuarkContent[flv];
101     pData->theAntiQuarkContent[flv] = aParticl    139     pData->theAntiQuarkContent[flv] = aParticle->theAntiQuarkContent[flv];
102   }                                               140   }
103                                                   141 
104   arrayDataObject.push_back(pData);               142   arrayDataObject.push_back(pData);
105                                                << 143  
106   return pData;                                   144   return pData;
107 }                                                 145 }
108                                                   146 
                                                   >> 147 ////////////////////////// 
109 G4bool G4ParticlePropertyTable::SetParticlePro    148 G4bool G4ParticlePropertyTable::SetParticleProperty(const G4ParticlePropertyData& pData)
110 {                                                 149 {
111   G4StateManager* pStateMan = G4StateManager::    150   G4StateManager* pStateMan = G4StateManager::GetStateManager();
112   if (pStateMan->GetCurrentState() != G4State_ << 151   if (pStateMan->GetCurrentState() != G4State_PreInit){
113 #ifdef G4VERBOSE                                  152 #ifdef G4VERBOSE
114     if (verboseLevel > 0) {                    << 153     if (verboseLevel>0){
115       G4cout << "G4ParticlePropertyTable::GetP    154       G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
116       G4cout << " for " << pData.theParticleNa    155       G4cout << " for " << pData.theParticleName << G4endl;
117       G4cout << " Particle properties can be m    156       G4cout << " Particle properties can be modified only in Pre_Init state";
118       G4cout << G4endl;                           157       G4cout << G4endl;
119     }                                             158     }
120 #endif                                            159 #endif
121     return false;                                 160     return false;
122   }                                            << 161   } 
123                                                   162 
124   G4ParticleDefinition* aParticle = fParticleT    163   G4ParticleDefinition* aParticle = fParticleTable->FindParticle(pData.theParticleName);
125   if (aParticle == nullptr) {                  << 164   if (aParticle ==0 ) {
126 #ifdef G4VERBOSE                                  165 #ifdef G4VERBOSE
127     if (verboseLevel > 1) {                    << 166     if (verboseLevel>1){
128       G4cout << "G4ParticlePropertyTable::GetP    167       G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
129       G4cout << " for " << pData.theParticleNa    168       G4cout << " for " << pData.theParticleName << G4endl;
130       G4cout << " Particle does not exist" <<     169       G4cout << " Particle does not exist" << G4endl;
131     }                                             170     }
132 #endif                                            171 #endif
133     return false;                                 172     return false;
134   }                                               173   }
135                                                   174 
136   if (pData.fPDGMassModified) {                << 175   if (pData.fPDGMassModified) { 
137     aParticle->thePDGMass = pData.thePDGMass;     176     aParticle->thePDGMass = pData.thePDGMass;
138   }                                               177   }
139   if (pData.fPDGWidthModified) {                  178   if (pData.fPDGWidthModified) {
140     aParticle->thePDGMass = pData.thePDGMass;     179     aParticle->thePDGMass = pData.thePDGMass;
141   }                                               180   }
142   if (pData.fPDGChargeModified) {                 181   if (pData.fPDGChargeModified) {
143     aParticle->thePDGCharge = pData.thePDGChar << 182     aParticle->thePDGCharge  = pData.thePDGCharge;
144   }                                               183   }
145   if (pData.fPDGiSpinModified) {                  184   if (pData.fPDGiSpinModified) {
146     aParticle->thePDGiSpin = pData.thePDGiSpin    185     aParticle->thePDGiSpin = pData.thePDGiSpin;
147     aParticle->thePDGSpin = 0.5 * pData.thePDG << 186     aParticle->thePDGSpin  = 0.5*pData.thePDGiSpin;
148   }                                               187   }
149   if (pData.fPDGiParityModified) {                188   if (pData.fPDGiParityModified) {
150     aParticle->thePDGiParity = pData.thePDGiPa    189     aParticle->thePDGiParity = pData.thePDGiParity;
151   }                                               190   }
152   if (pData.fPDGiConjugationModified) {           191   if (pData.fPDGiConjugationModified) {
153     aParticle->thePDGiConjugation = pData.theP    192     aParticle->thePDGiConjugation = pData.thePDGiConjugation;
154   }                                               193   }
155   if (pData.fPDGiGParityModified) {               194   if (pData.fPDGiGParityModified) {
156     aParticle->thePDGiGParity = pData.thePDGiG    195     aParticle->thePDGiGParity = pData.thePDGiGParity;
157   }                                               196   }
158   if (pData.fPDGiIsospinModified) {               197   if (pData.fPDGiIsospinModified) {
159     aParticle->thePDGiIsospin = pData.thePDGiI    198     aParticle->thePDGiIsospin = pData.thePDGiIsospin;
160     aParticle->thePDGIsospin = 0.5 * pData.the << 199     aParticle->thePDGIsospin  = 0.5*pData.thePDGiIsospin;
161   }                                               200   }
162   if (pData.fPDGiIsospin3Modified) {              201   if (pData.fPDGiIsospin3Modified) {
163     aParticle->thePDGiIsospin3 = pData.thePDGi    202     aParticle->thePDGiIsospin3 = pData.thePDGiIsospin3;
164     aParticle->thePDGIsospin3 = 0.5 * pData.th << 203     aParticle->thePDGIsospin3  = 0.5*pData.thePDGiIsospin3;
165   }                                               204   }
166   if (pData.fPDGMagneticMomentModified) {         205   if (pData.fPDGMagneticMomentModified) {
167     aParticle->thePDGMagneticMoment = pData.th    206     aParticle->thePDGMagneticMoment = pData.thePDGMagneticMoment;
168   }                                            << 207    }
169   if (pData.fLeptonNumberModified) {              208   if (pData.fLeptonNumberModified) {
170     aParticle->theLeptonNumber = pData.theLept << 209     aParticle->theLeptonNumber   = pData.theLeptonNumber;
171   }                                               210   }
172   if (pData.fBaryonNumberModified) {              211   if (pData.fBaryonNumberModified) {
173     aParticle->theBaryonNumber = pData.theBary << 212     aParticle->theBaryonNumber   = pData.theBaryonNumber;
174   }                                               213   }
175   if (pData.fPDGEncodingModified) {               214   if (pData.fPDGEncodingModified) {
176     aParticle->thePDGEncoding = pData.thePDGEn << 215     aParticle->thePDGEncoding   =  pData.thePDGEncoding;
177   }                                               216   }
178   if (pData.fAntiPDGEncodingModified) {           217   if (pData.fAntiPDGEncodingModified) {
179     aParticle->theAntiPDGEncoding = pData.theA << 218     aParticle->theAntiPDGEncoding   =  pData.theAntiPDGEncoding;
180   }                                               219   }
181   if (pData.fPDGLifeTimeModified) {               220   if (pData.fPDGLifeTimeModified) {
182     aParticle->thePDGLifeTime = pData.thePDGLi << 221     aParticle->thePDGLifeTime = pData.thePDGLifeTime; 
183   }                                               222   }
184   for (std::size_t flv = 0; flv < G4ParticlePr << 223   for (size_t flv=0; flv<<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
185     if (pData.fQuarkContentModified) {         << 224     if (pData.fQuarkContentModified){
186       aParticle->theQuarkContent[flv] = pData.    225       aParticle->theQuarkContent[flv] = pData.theQuarkContent[flv];
187     }                                             226     }
188     if (pData.fAntiQuarkContentModified) {     << 227     if (pData.fAntiQuarkContentModified){
189       aParticle->theAntiQuarkContent[flv] = pD    228       aParticle->theAntiQuarkContent[flv] = pData.theAntiQuarkContent[flv];
190     }                                             229     }
191   }                                               230   }
192                                                << 231   
193   return true;                                    232   return true;
194 }                                                 233 }
                                                   >> 234 
                                                   >> 235 
                                                   >> 236 
                                                   >> 237 
                                                   >> 238 
                                                   >> 239 
195                                                   240