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] [ 10.5 ] [ 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 /processes/electromagnetic/standard/src/G4WentzelVIRelModel.cc (Version 11.3.0) and /processes/electromagnetic/standard/src/G4WentzelVIRelModel.cc (Version 11.0.p1)


  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 //                                                 26 //
 27 // -------------------------------------------     27 // -------------------------------------------------------------------
 28 //                                                 28 //
 29 // GEANT4 Class file                               29 // GEANT4 Class file
 30 //                                                 30 //
 31 //                                                 31 //
 32 // File name:   G4WentzelVIRelModel                32 // File name:   G4WentzelVIRelModel
 33 //                                                 33 //
 34 // Author:      V.Ivanchenko                       34 // Author:      V.Ivanchenko 
 35 //                                                 35 //
 36 // Creation date: 08.06.2012 from G4WentzelVIR     36 // Creation date: 08.06.2012 from G4WentzelVIRelModel
 37 //                                                 37 //
 38 // Modifications:                                  38 // Modifications:
 39 //                                                 39 //
 40 // Class Description:                              40 // Class Description:
 41 //                                                 41 //
 42 // Implementation of the model of multiple sca     42 // Implementation of the model of multiple scattering based on
 43 // G.Wentzel, Z. Phys. 40 (1927) 590.              43 // G.Wentzel, Z. Phys. 40 (1927) 590.
 44 // H.W.Lewis, Phys Rev 78 (1950) 526.              44 // H.W.Lewis, Phys Rev 78 (1950) 526.
 45 // J.M. Fernandez-Varea et al., NIM B73 (1993)     45 // J.M. Fernandez-Varea et al., NIM B73 (1993) 447.
 46 // L.Urban, CERN-OPEN-2006-077.                    46 // L.Urban, CERN-OPEN-2006-077.
 47                                                    47 
 48 // -------------------------------------------     48 // -------------------------------------------------------------------
 49 //                                                 49 //
 50                                                    50 
 51 //....oooOO0OOooo........oooOO0OOooo........oo     51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 52 //....oooOO0OOooo........oooOO0OOooo........oo     52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 53                                                    53 
 54 #include "G4WentzelVIRelModel.hh"                  54 #include "G4WentzelVIRelModel.hh"
 55 #include "G4WentzelVIRelXSection.hh"               55 #include "G4WentzelVIRelXSection.hh"
 56 #include "G4WentzelOKandVIxSection.hh"             56 #include "G4WentzelOKandVIxSection.hh"
 57 #include "G4PhysicalConstants.hh"                  57 #include "G4PhysicalConstants.hh"
 58 #include "G4SystemOfUnits.hh"                      58 #include "G4SystemOfUnits.hh"
 59 #include "G4Material.hh"                           59 #include "G4Material.hh"
 60 #include "G4ElementVector.hh"                      60 #include "G4ElementVector.hh"
 61 #include "G4ProductionCutsTable.hh"                61 #include "G4ProductionCutsTable.hh"
 62 #include "G4NistManager.hh"                        62 #include "G4NistManager.hh"
 63 #include "G4EmParameters.hh"                       63 #include "G4EmParameters.hh"
 64 #include "G4AutoLock.hh"                       << 
 65                                                    64 
 66 //....oooOO0OOooo........oooOO0OOooo........oo     65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 67                                                    66 
 68 std::vector<G4double> G4WentzelVIRelModel::eff     67 std::vector<G4double> G4WentzelVIRelModel::effMass;
 69                                                    68 
 70 namespace                                      <<  69 #ifdef G4MULTITHREADED
 71 {                                              <<  70 G4Mutex G4WentzelVIRelModel::WentzelVIRelModelMutex  = G4MUTEX_INITIALIZER;
 72   G4Mutex theWVIRelMutex = G4MUTEX_INITIALIZER <<  71 #endif
 73 }                                              << 
 74                                                    72 
 75 G4WentzelVIRelModel::G4WentzelVIRelModel() :       73 G4WentzelVIRelModel::G4WentzelVIRelModel() :
 76   G4WentzelVIModel(true, "WentzelVIRel")           74   G4WentzelVIModel(true, "WentzelVIRel")
 77 {                                                  75 {
 78   fNistManager = G4NistManager::Instance();        76   fNistManager = G4NistManager::Instance();
 79   auto ptr = new G4WentzelVIRelXSection();     <<  77   G4WentzelVIRelXSection* ptr = new G4WentzelVIRelXSection();
 80   SetWVICrossSection(static_cast<G4WentzelOKan     78   SetWVICrossSection(static_cast<G4WentzelOKandVIxSection*>(ptr));
 81 }                                                  79 }
 82                                                    80 
 83 //....oooOO0OOooo........oooOO0OOooo........oo     81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 84                                                    82 
 85 G4WentzelVIRelModel::~G4WentzelVIRelModel() =  <<  83 G4WentzelVIRelModel::~G4WentzelVIRelModel()
                                                   >>  84 {}
 86                                                    85 
 87 //....oooOO0OOooo........oooOO0OOooo........oo     86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 88                                                    87 
 89 void G4WentzelVIRelModel::Initialise(const G4P     88 void G4WentzelVIRelModel::Initialise(const G4ParticleDefinition* p,
 90                                      const G4D     89                                      const G4DataVector& cuts)
 91 {                                                  90 {
 92   // Access to materials                           91   // Access to materials
 93   const G4ProductionCutsTable* theCoupleTable      92   const G4ProductionCutsTable* theCoupleTable =
 94     G4ProductionCutsTable::GetProductionCutsTa     93     G4ProductionCutsTable::GetProductionCutsTable();
 95   if(theCoupleTable->GetTableSize() != effMass     94   if(theCoupleTable->GetTableSize() != effMass.size()) {
 96     ComputeEffectiveMass();                        95     ComputeEffectiveMass();
 97   }                                                96   }
 98                                                    97 
 99   G4WentzelVIModel::Initialise(p, cuts);           98   G4WentzelVIModel::Initialise(p, cuts);
100 }                                                  99 }
101                                                   100 
102 //....oooOO0OOooo........oooOO0OOooo........oo    101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
103                                                   102 
104 void G4WentzelVIRelModel::DefineMaterial(const    103 void G4WentzelVIRelModel::DefineMaterial(const G4MaterialCutsCouple* cup) 
105 {                                                 104 { 
106   if(cup != currentCouple) {                      105   if(cup != currentCouple) {
107     currentCouple = cup;                          106     currentCouple = cup;
108     SetCurrentCouple(cup);                        107     SetCurrentCouple(cup); 
109     currentMaterial = cup->GetMaterial();         108     currentMaterial = cup->GetMaterial();
110     currentMaterialIndex = currentCouple->GetI    109     currentMaterialIndex = currentCouple->GetIndex(); 
111     GetWVICrossSection()->SetTargetMass(effMas    110     GetWVICrossSection()->SetTargetMass(effMass[currentMaterialIndex]);
112   }                                               111   }
113 }                                                 112 }
114                                                   113 
115 //....oooOO0OOooo........oooOO0OOooo........oo    114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
116                                                   115 
117 G4double G4WentzelVIRelModel::ComputeCrossSect    116 G4double G4WentzelVIRelModel::ComputeCrossSectionPerAtom( 
118                              const G4ParticleD    117                              const G4ParticleDefinition* p,
119                              G4double kinEnerg    118                              G4double kinEnergy,
120                              G4double Z, G4dou    119                              G4double Z, G4double,
121                              G4double cutEnerg    120                              G4double cutEnergy, G4double)
122 {                                                 121 {
123   G4double cross = 0.0;                           122   G4double cross = 0.0;
124   if(p != particle) { SetupParticle(p); }         123   if(p != particle) { SetupParticle(p); }
125   if(kinEnergy < lowEnergyLimit) { return cros    124   if(kinEnergy < lowEnergyLimit) { return cross; }
126   if(nullptr == CurrentCouple()) {                125   if(nullptr == CurrentCouple()) {
127     G4Exception("G4WentzelVIRelModel::ComputeC    126     G4Exception("G4WentzelVIRelModel::ComputeCrossSectionPerAtom", "em0011",
128                 FatalException, " G4MaterialCu    127                 FatalException, " G4MaterialCutsCouple is not defined");
129     return cross;                                 128     return cross;
130   }                                               129   }
131   DefineMaterial(CurrentCouple());                130   DefineMaterial(CurrentCouple());
132   G4int iz = G4lrint(Z);                          131   G4int iz = G4lrint(Z);
133   G4double tmass = (1 == iz) ? CLHEP::proton_m    132   G4double tmass = (1 == iz) ? CLHEP::proton_mass_c2
134     : fNistManager->GetAtomicMassAmu(iz)*amu_c    133     : fNistManager->GetAtomicMassAmu(iz)*amu_c2;
135   wokvi->SetTargetMass(tmass);                    134   wokvi->SetTargetMass(tmass);
136   cosTetMaxNuc = wokvi->SetupKinematic(kinEner    135   cosTetMaxNuc = wokvi->SetupKinematic(kinEnergy, currentMaterial);
137   if(cosTetMaxNuc < 1.0) {                        136   if(cosTetMaxNuc < 1.0) {
138     G4double cost = wokvi->SetupTarget(iz, cut    137     G4double cost = wokvi->SetupTarget(iz, cutEnergy);
139     cross = wokvi->ComputeTransportCrossSectio    138     cross = wokvi->ComputeTransportCrossSectionPerAtom(cost);
140     /*                                            139     /*    
141     //if(p->GetParticleName() == "e-")            140     //if(p->GetParticleName() == "e-")      
142     G4cout << "G4WentzelVIRelModel::CS: Z= " <    141     G4cout << "G4WentzelVIRelModel::CS: Z= " << G4int(Z) 
143            << " e(MeV)= " << kinEnergy            142            << " e(MeV)= " << kinEnergy 
144            << " 1-cosN= " << 1 - cosTetMaxNuc     143            << " 1-cosN= " << 1 - cosTetMaxNuc << " cross(bn)= " << cross/barn
145            << " " << particle->GetParticleName    144            << " " << particle->GetParticleName() << G4endl;
146     */                                            145     */
147   }                                               146   }
148   return cross;                                   147   return cross;
149 }                                                 148 }
150                                                   149 
151 //....oooOO0OOooo........oooOO0OOooo........oo    150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152                                                   151 
153 void G4WentzelVIRelModel::ComputeEffectiveMass    152 void G4WentzelVIRelModel::ComputeEffectiveMass()
154 {                                                 153 {
155   const G4ProductionCutsTable* theCoupleTable     154   const G4ProductionCutsTable* theCoupleTable =
156     G4ProductionCutsTable::GetProductionCutsTa    155     G4ProductionCutsTable::GetProductionCutsTable();
157   std::size_t ncouples = (G4int)theCoupleTable << 156   size_t ncouples = theCoupleTable->GetTableSize();
158   if(ncouples == effMass.size()) { return; }   << 157 #ifdef G4MULTITHREADED
159                                                << 158   G4MUTEXLOCK(&G4WentzelVIRelModel::WentzelVIRelModelMutex);
160   G4AutoLock l(&theWVIRelMutex);               << 
161   if(ncouples != effMass.size()) {                159   if(ncouples != effMass.size()) {
                                                   >> 160 #endif
162     effMass.resize(ncouples, 0.0);                161     effMass.resize(ncouples, 0.0);
163     for(std::size_t i=0; i<ncouples; ++i) {    << 162     for(size_t i=0; i<ncouples; ++i) {
164       const G4Material* mat =                     163       const G4Material* mat = 
165   theCoupleTable->GetMaterialCutsCouple((G4int << 164   theCoupleTable->GetMaterialCutsCouple(i)->GetMaterial();
166       const G4ElementVector* elmVector = mat->    165       const G4ElementVector* elmVector = mat->GetElementVector();
167       std::size_t nelm = mat->GetNumberOfEleme << 166       G4int nelm = mat->GetNumberOfElements();
168       G4double sum = 0.0;                         167       G4double sum = 0.0;
169       G4double norm= 0.0;                         168       G4double norm= 0.0;
170       for(std::size_t j=0; j<nelm; ++j) {      << 169       for(G4int j=0; j<nelm; ++j) {
171   G4int Z = (*elmVector)[j]->GetZasInt();         170   G4int Z = (*elmVector)[j]->GetZasInt();
172   G4double mass = fNistManager->GetAtomicMassA    171   G4double mass = fNistManager->GetAtomicMassAmu(Z)*CLHEP::amu_c2;
173   G4int Z2 = Z*Z;                                 172   G4int Z2 = Z*Z;
174   sum += mass*Z2;                                 173   sum += mass*Z2;
175   norm += Z2;                                     174   norm += Z2;
176       }                                           175       }
177       effMass[i] = (0.0 < norm) ? sum/norm : s << 176       effMass[i] = sum/norm;
178     }                                             177     }
                                                   >> 178 #ifdef G4MULTITHREADED
179   }                                               179   }
180   l.unlock();                                  << 180   G4MUTEXUNLOCK(&G4WentzelVIRelModel::WentzelVIRelModelMutex);
                                                   >> 181 #endif
181 }                                                 182 }
182                                                   183 
183 //....oooOO0OOooo........oooOO0OOooo........oo    184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
184                                                   185