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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 10.4)


  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 72955 2013-08-14 14:23:14Z gcosmo $
 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 G4ThreadLocal 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   if (!fgParticlePropertyTable)
 45     fgParticlePropertyTable = new G4ParticlePr <<  49   {
                                                   >>  50     fgParticlePropertyTable = new  G4ParticlePropertyTable;
 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)
 59 {                                                  67 {
 60   fParticleTable = G4ParticleTable::GetParticl <<  68   fParticleTable = G4ParticleTable::GetParticleTable();   
 61 }                                                  69 }
 62                                                    70 
                                                   >>  71 ////////////////////////
                                                   >>  72 G4ParticlePropertyTable::G4ParticlePropertyTable(const G4ParticlePropertyTable &right)
                                                   >>  73 {
                                                   >>  74   fParticleTable = G4ParticleTable::GetParticleTable();   
                                                   >>  75   *this = right;
                                                   >>  76 }
                                                   >>  77       
                                                   >>  78 ////////////////////////
                                                   >>  79 G4ParticlePropertyTable & G4ParticlePropertyTable::operator=(const G4ParticlePropertyTable &right)
                                                   >>  80 {
                                                   >>  81   if (this != &right) {
                                                   >>  82     fParticleTable = right.fParticleTable;
                                                   >>  83     verboseLevel   = right.verboseLevel; 
                                                   >>  84   }
                                                   >>  85   return *this;
                                                   >>  86 }
                                                   >>  87   
                                                   >>  88 ////////////////////////
                                                   >>  89 G4int G4ParticlePropertyTable::operator==(const G4ParticlePropertyTable &) const
                                                   >>  90 {
                                                   >>  91   return true;
                                                   >>  92 }
                                                   >>  93 
                                                   >>  94 ////////////////////////
                                                   >>  95 G4int G4ParticlePropertyTable::operator!=(const G4ParticlePropertyTable &) const
                                                   >>  96 {
                                                   >>  97   return false;
                                                   >>  98 }
                                                   >>  99 
                                                   >> 100 /////////////////////////////////////////////////////////////
 63 void G4ParticlePropertyTable::Clear()             101 void G4ParticlePropertyTable::Clear()
 64 {                                                 102 {
 65   for (const auto& idx : arrayDataObject) {    << 103   for (size_t idx=0; idx<arrayDataObject.size(); idx++){
 66     delete idx;                                << 104     delete arrayDataObject[idx];
 67   }                                               105   }
 68   arrayDataObject.clear();                        106   arrayDataObject.clear();
 69 }                                                 107 }
 70                                                   108 
                                                   >> 109 /////////////////////////////////////////////////////////////////////
 71 G4ParticlePropertyData* G4ParticlePropertyTabl    110 G4ParticlePropertyData* G4ParticlePropertyTable::GetParticleProperty(const G4String& aParticleName)
 72 {                                                 111 {
 73   G4ParticleDefinition* aParticle = fParticleT    112   G4ParticleDefinition* aParticle = fParticleTable->FindParticle(aParticleName);
 74   if (aParticle == nullptr) return nullptr;    << 113   if (aParticle ==0 ) return 0;
 75                                                   114 
 76   return GetParticleProperty(aParticle);          115   return GetParticleProperty(aParticle);
 77 }                                                 116 }
 78                                                   117 
 79 G4ParticlePropertyData*                        << 118 //////////////////////////////////////
 80 G4ParticlePropertyTable::GetParticleProperty(c << 119 G4ParticlePropertyData*  G4ParticlePropertyTable::GetParticleProperty(const G4ParticleDefinition* aParticle)
 81 {                                                 120 {
 82   if (aParticle == nullptr) return nullptr;    << 121   if (aParticle ==0 ) return 0;
 83   auto pData = new G4ParticlePropertyData(aPar << 122   G4ParticlePropertyData* pData = new G4ParticlePropertyData(aParticle->GetParticleName());
 84   pData->thePDGMass = aParticle->GetPDGMass(); << 123   pData->thePDGMass        = aParticle->GetPDGMass();
 85   pData->thePDGWidth = aParticle->GetPDGWidth( << 124   pData->thePDGWidth       = aParticle->GetPDGWidth();
 86   pData->thePDGCharge = aParticle->GetPDGCharg << 125   pData->thePDGCharge      = aParticle->GetPDGCharge();
 87   pData->thePDGiSpin = aParticle->GetPDGiSpin( << 126   pData->thePDGiSpin       = aParticle->GetPDGiSpin();
 88   pData->thePDGiParity = aParticle->GetPDGiPar << 127   pData->thePDGiParity     = aParticle->GetPDGiParity();
 89   pData->thePDGiConjugation = aParticle->GetPD << 128   pData->thePDGiConjugation  = aParticle->GetPDGiConjugation();
 90   pData->thePDGiGParity = aParticle->GetPDGiGP << 129   pData->thePDGiGParity    = aParticle->GetPDGiGParity();
 91   pData->thePDGiIsospin = aParticle->GetPDGiIs << 130   pData->thePDGiIsospin    = aParticle->GetPDGiIsospin();
 92   pData->thePDGiIsospin3 = aParticle->GetPDGiI << 131   pData->thePDGiIsospin3   = aParticle->GetPDGiIsospin3();
 93   pData->thePDGMagneticMoment = aParticle->Get << 132   pData->thePDGMagneticMoment   = aParticle->GetPDGMagneticMoment();
 94   pData->theLeptonNumber = aParticle->GetLepto << 133   pData->theLeptonNumber   = aParticle->GetLeptonNumber();
 95   pData->theBaryonNumber = aParticle->GetBaryo << 134   pData->theBaryonNumber   = aParticle->GetBaryonNumber();
 96   pData->thePDGEncoding = aParticle->GetPDGEnc << 135   pData->thePDGEncoding    = aParticle->GetPDGEncoding();
 97   pData->theAntiPDGEncoding = aParticle->GetAn << 136   pData->theAntiPDGEncoding  = aParticle->GetAntiPDGEncoding();
 98   pData->thePDGLifeTime = aParticle->GetPDGLif << 137   pData->thePDGLifeTime    = aParticle->GetPDGLifeTime(); 
 99   for (std::size_t flv = 0; flv < G4ParticlePr << 138   for (size_t flv=0; flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
100     pData->theQuarkContent[flv] = aParticle->t << 139     pData->theQuarkContent[flv]     = aParticle->theQuarkContent[flv];
101     pData->theAntiQuarkContent[flv] = aParticl    140     pData->theAntiQuarkContent[flv] = aParticle->theAntiQuarkContent[flv];
102   }                                               141   }
103                                                   142 
104   arrayDataObject.push_back(pData);               143   arrayDataObject.push_back(pData);
105                                                << 144  
106   return pData;                                   145   return pData;
107 }                                                 146 }
108                                                   147 
                                                   >> 148 ////////////////////////// 
109 G4bool G4ParticlePropertyTable::SetParticlePro    149 G4bool G4ParticlePropertyTable::SetParticleProperty(const G4ParticlePropertyData& pData)
110 {                                                 150 {
111   G4StateManager* pStateMan = G4StateManager::    151   G4StateManager* pStateMan = G4StateManager::GetStateManager();
112   if (pStateMan->GetCurrentState() != G4State_ << 152   if (pStateMan->GetCurrentState() != G4State_PreInit){
113 #ifdef G4VERBOSE                                  153 #ifdef G4VERBOSE
114     if (verboseLevel > 0) {                    << 154     if (verboseLevel>0){
115       G4cout << "G4ParticlePropertyTable::GetP    155       G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
116       G4cout << " for " << pData.theParticleNa    156       G4cout << " for " << pData.theParticleName << G4endl;
117       G4cout << " Particle properties can be m    157       G4cout << " Particle properties can be modified only in Pre_Init state";
118       G4cout << G4endl;                           158       G4cout << G4endl;
119     }                                             159     }
120 #endif                                            160 #endif
121     return false;                                 161     return false;
122   }                                            << 162   } 
123                                                   163 
124   G4ParticleDefinition* aParticle = fParticleT    164   G4ParticleDefinition* aParticle = fParticleTable->FindParticle(pData.theParticleName);
125   if (aParticle == nullptr) {                  << 165   if (aParticle ==0 ) {
126 #ifdef G4VERBOSE                                  166 #ifdef G4VERBOSE
127     if (verboseLevel > 1) {                    << 167     if (verboseLevel>1){
128       G4cout << "G4ParticlePropertyTable::GetP    168       G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
129       G4cout << " for " << pData.theParticleNa    169       G4cout << " for " << pData.theParticleName << G4endl;
130       G4cout << " Particle does not exist" <<     170       G4cout << " Particle does not exist" << G4endl;
131     }                                             171     }
132 #endif                                            172 #endif
133     return false;                                 173     return false;
134   }                                               174   }
135                                                   175 
136   if (pData.fPDGMassModified) {                << 176   if (pData.fPDGMassModified) { 
137     aParticle->thePDGMass = pData.thePDGMass;     177     aParticle->thePDGMass = pData.thePDGMass;
138   }                                               178   }
139   if (pData.fPDGWidthModified) {                  179   if (pData.fPDGWidthModified) {
140     aParticle->thePDGMass = pData.thePDGMass;     180     aParticle->thePDGMass = pData.thePDGMass;
141   }                                               181   }
142   if (pData.fPDGChargeModified) {                 182   if (pData.fPDGChargeModified) {
143     aParticle->thePDGCharge = pData.thePDGChar << 183     aParticle->thePDGCharge  = pData.thePDGCharge;
144   }                                               184   }
145   if (pData.fPDGiSpinModified) {                  185   if (pData.fPDGiSpinModified) {
146     aParticle->thePDGiSpin = pData.thePDGiSpin    186     aParticle->thePDGiSpin = pData.thePDGiSpin;
147     aParticle->thePDGSpin = 0.5 * pData.thePDG << 187     aParticle->thePDGSpin  = 0.5*pData.thePDGiSpin;
148   }                                               188   }
149   if (pData.fPDGiParityModified) {                189   if (pData.fPDGiParityModified) {
150     aParticle->thePDGiParity = pData.thePDGiPa    190     aParticle->thePDGiParity = pData.thePDGiParity;
151   }                                               191   }
152   if (pData.fPDGiConjugationModified) {           192   if (pData.fPDGiConjugationModified) {
153     aParticle->thePDGiConjugation = pData.theP    193     aParticle->thePDGiConjugation = pData.thePDGiConjugation;
154   }                                               194   }
155   if (pData.fPDGiGParityModified) {               195   if (pData.fPDGiGParityModified) {
156     aParticle->thePDGiGParity = pData.thePDGiG    196     aParticle->thePDGiGParity = pData.thePDGiGParity;
157   }                                               197   }
158   if (pData.fPDGiIsospinModified) {               198   if (pData.fPDGiIsospinModified) {
159     aParticle->thePDGiIsospin = pData.thePDGiI    199     aParticle->thePDGiIsospin = pData.thePDGiIsospin;
160     aParticle->thePDGIsospin = 0.5 * pData.the << 200     aParticle->thePDGIsospin  = 0.5*pData.thePDGiIsospin;
161   }                                               201   }
162   if (pData.fPDGiIsospin3Modified) {              202   if (pData.fPDGiIsospin3Modified) {
163     aParticle->thePDGiIsospin3 = pData.thePDGi    203     aParticle->thePDGiIsospin3 = pData.thePDGiIsospin3;
164     aParticle->thePDGIsospin3 = 0.5 * pData.th << 204     aParticle->thePDGIsospin3  = 0.5*pData.thePDGiIsospin3;
165   }                                               205   }
166   if (pData.fPDGMagneticMomentModified) {         206   if (pData.fPDGMagneticMomentModified) {
167     aParticle->thePDGMagneticMoment = pData.th    207     aParticle->thePDGMagneticMoment = pData.thePDGMagneticMoment;
168   }                                            << 208    }
169   if (pData.fLeptonNumberModified) {              209   if (pData.fLeptonNumberModified) {
170     aParticle->theLeptonNumber = pData.theLept << 210     aParticle->theLeptonNumber   = pData.theLeptonNumber;
171   }                                               211   }
172   if (pData.fBaryonNumberModified) {              212   if (pData.fBaryonNumberModified) {
173     aParticle->theBaryonNumber = pData.theBary << 213     aParticle->theBaryonNumber   = pData.theBaryonNumber;
174   }                                               214   }
175   if (pData.fPDGEncodingModified) {               215   if (pData.fPDGEncodingModified) {
176     aParticle->thePDGEncoding = pData.thePDGEn << 216     aParticle->thePDGEncoding   =  pData.thePDGEncoding;
177   }                                               217   }
178   if (pData.fAntiPDGEncodingModified) {           218   if (pData.fAntiPDGEncodingModified) {
179     aParticle->theAntiPDGEncoding = pData.theA << 219     aParticle->theAntiPDGEncoding   =  pData.theAntiPDGEncoding;
180   }                                               220   }
181   if (pData.fPDGLifeTimeModified) {               221   if (pData.fPDGLifeTimeModified) {
182     aParticle->thePDGLifeTime = pData.thePDGLi << 222     aParticle->thePDGLifeTime = pData.thePDGLifeTime; 
183   }                                               223   }
184   for (std::size_t flv = 0; flv < G4ParticlePr << 224   for (size_t flv=0; flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
185     if (pData.fQuarkContentModified) {         << 225     if (pData.fQuarkContentModified){
186       aParticle->theQuarkContent[flv] = pData.    226       aParticle->theQuarkContent[flv] = pData.theQuarkContent[flv];
187     }                                             227     }
188     if (pData.fAntiQuarkContentModified) {     << 228     if (pData.fAntiQuarkContentModified){
189       aParticle->theAntiQuarkContent[flv] = pD    229       aParticle->theAntiQuarkContent[flv] = pData.theAntiQuarkContent[flv];
190     }                                             230     }
191   }                                               231   }
192                                                << 232   
193   return true;                                    233   return true;
194 }                                                 234 }
195                                                   235