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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/utils/src/G4EmDataHandler.cc (Version 11.3.0) and /processes/electromagnetic/utils/src/G4EmDataHandler.cc (Version 10.4.p3)


  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 // $Id: G4EmDataHandler.cc 73844 2013-09-13 14:16:30Z vnivanch $
 26 //                                                 27 //
 27 // -------------------------------------------     28 // -------------------------------------------------------------------
 28 //                                                 29 //
 29 // GEANT4 Class file                               30 // GEANT4 Class file
 30 //                                                 31 //
 31 // File name:     G4EmDataHandler                  32 // File name:     G4EmDataHandler
 32 //                                                 33 //
 33 // Author:        V. Ivanchenko                    34 // Author:        V. Ivanchenko 
 34 //                                                 35 // 
 35 // Creation date: 16 August 2017                   36 // Creation date: 16 August 2017
 36 //                                                 37 //
 37 // Modifications:                                  38 // Modifications: 
 38 //                                                 39 //
 39 // -------------------------------------------     40 // -------------------------------------------------------------------
 40 //                                                 41 //
 41 //                                                 42 //    
 42                                                    43 
 43 #include "G4EmDataHandler.hh"                      44 #include "G4EmDataHandler.hh"
 44 #include "G4EmDataRegistry.hh"                 << 
 45 #include "G4ParticleDefinition.hh"                 45 #include "G4ParticleDefinition.hh"
 46 #include "G4EmParameters.hh"                       46 #include "G4EmParameters.hh"
 47 #include "G4PhysicsTableHelper.hh"                 47 #include "G4PhysicsTableHelper.hh"
 48 #include "G4VEmProcess.hh"                     << 
 49 #include "G4VEnergyLossProcess.hh"             << 
 50                                                    48 
 51 //....oooOO0OOooo........oooOO0OOooo........oo     49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 52                                                    50 
 53 G4EmDataHandler::G4EmDataHandler(std::size_t n <<  51 G4EmDataHandler::G4EmDataHandler(size_t n) : tLength(0)
 54   : tLength(n), fName(nam)                     << 
 55 {                                                  52 {
 56   data.resize(n, nullptr);                     <<  53   data.reserve(n);
 57   fMaxXS = new std::vector<G4double>;          << 
 58   fXSpeaks = new std::vector<G4TwoPeaksXS*>;   << 
 59   G4EmDataRegistry::Instance()->Register(this) << 
 60 }                                                  54 }
 61                                                    55 
 62 //....oooOO0OOooo........oooOO0OOooo........oo     56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 63                                                    57 
 64 G4EmDataHandler::~G4EmDataHandler()                58 G4EmDataHandler::~G4EmDataHandler() 
 65 {                                                  59 {
 66   if (!fUseBaseParticleTable) {                <<  60   for(auto & table : data) { 
 67     for (std::size_t i=0; i<tLength; ++i) {    <<  61     if(table) {
 68       CleanTable(i);                           <<  62       table->clearAndDestroy();
                                                   >>  63       delete table;
 69     }                                              64     }
 70     delete fMaxXS;                             << 
 71     delete fXSpeaks;                           << 
 72   }                                                65   }
 73   if (!fElemSelectors.empty()) {               <<  66   data.clear();
 74     for (auto const & ptr : fElemSelectors) {  << 
 75       if (nullptr != ptr) {                    << 
 76   for (auto const & p : *ptr) { delete p; }    << 
 77       }                                        << 
 78     }                                          << 
 79   }                                            << 
 80                                                << 
 81 }                                                  67 }
 82                                                    68 
 83 //....oooOO0OOooo........oooOO0OOooo........oo     69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 84                                                    70 
 85 std::size_t G4EmDataHandler::SetTable(G4Physic <<  71 size_t G4EmDataHandler::SetTable(G4PhysicsTable* ptr)
 86 {                                                  72 {
 87   for (std::size_t i=0; i<tLength; ++i) {      << 
 88     if (ptr == data[i]) { return i; }          << 
 89   }                                            << 
 90   data.push_back(ptr);                             73   data.push_back(ptr);
 91   ++tLength;                                       74   ++tLength;
 92   return tLength-1;                                75   return tLength-1; 
 93 }                                                  76 }
 94                                                    77 
 95 //....oooOO0OOooo........oooOO0OOooo........oo     78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 96                                                    79 
 97 void G4EmDataHandler::UpdateTable(G4PhysicsTab <<  80 G4PhysicsTable* G4EmDataHandler::MakeTable()
 98 {                                              << 
 99   // update table pointer but not delete previ << 
100   if (idx < tLength) {                         << 
101     if (ptr != data[idx]) { data[idx] = ptr; } << 
102     data[idx] = G4PhysicsTableHelper::PrepareP << 
103   } else {                                     << 
104     G4cout << "### G4EmDataHandler::UpdateTabl << 
105            << " length=" << tLength << G4endl; << 
106   }                                            << 
107 }                                              << 
108                                                << 
109 //....oooOO0OOooo........oooOO0OOooo........oo << 
110                                                << 
111 void G4EmDataHandler::SaveTable(G4PhysicsTable << 
112 {                                              << 
113   if (idx < tLength) {                         << 
114     data[idx] = ptr;                           << 
115   }                                            << 
116 }                                              << 
117                                                << 
118 //....oooOO0OOooo........oooOO0OOooo........oo << 
119                                                << 
120 G4PhysicsTable* G4EmDataHandler::MakeTable(std << 
121 {                                              << 
122   std::size_t idx = i;                         << 
123   if (idx >= tLength) {                        << 
124     data.push_back(nullptr);                   << 
125     idx = tLength;                             << 
126     ++tLength;                                 << 
127   }                                            << 
128   data[idx] = G4PhysicsTableHelper::PreparePhy << 
129   return data[idx];                            << 
130 }                                              << 
131                                                << 
132 //....oooOO0OOooo........oooOO0OOooo........oo << 
133                                                << 
134 G4PhysicsTable* G4EmDataHandler::MakeTable(G4P << 
135 {                                              << 
136   std::size_t idx = i;                         << 
137   // create new table only if index correspond << 
138   // position in the vector                    << 
139   if (idx < tLength) {                         << 
140     if (ptr != data[idx]) {                    << 
141       CleanTable(idx);                         << 
142       data[idx] = ptr;                         << 
143     }                                          << 
144   } else {                                     << 
145     data.push_back(ptr);                       << 
146     idx = tLength;                             << 
147     ++tLength;                                 << 
148   }                                            << 
149   data[idx] = G4PhysicsTableHelper::PreparePhy << 
150   return data[idx];                            << 
151 }                                              << 
152                                                << 
153 //....oooOO0OOooo........oooOO0OOooo........oo << 
154                                                << 
155 void G4EmDataHandler::CleanTable(std::size_t i << 
156 {                                                  81 {
157   if (i < tLength && nullptr != data[i]) {     <<  82   G4PhysicsTable* table = nullptr;
158     auto ptr = data[i];                        <<  83   table = G4PhysicsTableHelper::PreparePhysicsTable(table);
159     ptr->clearAndDestroy();                    <<  84   data.push_back(table);
160     delete ptr;                                <<  85   ++tLength;
161     for (std::size_t j=0; j<tLength; ++j) {    <<  86   return table;
162       if (ptr == data[j]) { data[j] = nullptr; << 
163     }                                          << 
164   }                                            << 
165 }                                                  87 }
166                                                    88 
167 //....oooOO0OOooo........oooOO0OOooo........oo     89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168                                                    90 
169 G4bool G4EmDataHandler::StorePhysicsTable(std: <<  91 G4bool G4EmDataHandler::StorePhysicsTable(size_t idx,
170                            const G4ParticleDef     92                            const G4ParticleDefinition* part,
171          const G4String& fname,                <<  93          const G4String& namet, 
                                                   >>  94          const G4String& procname, 
172          G4bool ascii)                             95          G4bool ascii)
173 {                                                  96 {
174   G4bool yes = true;                               97   G4bool yes = true;
175   if(nullptr != data[idx]) {                   <<  98   if(data[idx]) {
176     yes = data[idx]->StorePhysicsTable(fname,  <<  99     yes = data[idx]->StorePhysicsTable(namet, ascii);
177                                                   100 
178     if ( yes ) {                                  101     if ( yes ) {
179       G4cout << "### Physics table is stored f << 102       G4cout << "Physics table is stored for " 
180        << part->GetParticleName()                 103        << part->GetParticleName()
181              << " <" << fname << "> " << G4end << 104              << " and process " << procname
                                                   >> 105              << " <" << namet << "> " << G4endl;
182     } else {                                      106     } else {
183       G4cout << "### Fail to store Physics Tab << 107       G4cout << "Fail to store Physics Table for " 
184              << part->GetParticleName()           108              << part->GetParticleName()
185              << " <" << fname << "> " << G4end << 109              << " and process " << procname
                                                   >> 110              << " <" << namet << "> " << G4endl;
186     }                                             111     }
187   }                                               112   }
188   return yes;                                     113   return yes;
189 }                                                 114 }
190                                                   115 
191 //....oooOO0OOooo........oooOO0OOooo........oo    116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
192                                                   117 
193 G4bool G4EmDataHandler::RetrievePhysicsTable(s << 118 G4bool G4EmDataHandler::RetrievePhysicsTable(size_t idx,
194                            const G4ParticleDef    119                            const G4ParticleDefinition* part,
195          const G4String& fname,                << 120          const G4String& namet, 
196          G4bool ascii, G4bool spline)          << 121          const G4String& procname, 
                                                   >> 122          G4bool ascii)
197 {                                                 123 {
198   G4PhysicsTable* table = Table(idx);          << 124   G4bool yes = 
199   G4bool yes = G4PhysicsTableHelper::RetrieveP << 125     G4PhysicsTableHelper::RetrievePhysicsTable(data[idx],
                                                   >> 126                  namet, ascii);
200   G4EmParameters* param = G4EmParameters::Inst    127   G4EmParameters* param = G4EmParameters::Instance();
201   if ( yes ) {                                    128   if ( yes ) {
202     if (0 < param->Verbose()) {                   129     if (0 < param->Verbose()) {
203       G4cout << "### Physics table " << idx << << 130       G4cout << "Physics table for "  
204        << part->GetParticleName()                 131        << part->GetParticleName()
205        << " is retrieved from <" << fname << " << 132        << " and " << procname
                                                   >> 133        << " is retrieved from <" << namet << ">"
206        << G4endl;                                 134        << G4endl;
207     }                                             135     }
                                                   >> 136     if(param->Spline()) {
                                                   >> 137       G4PhysicsTable* table = data[idx];
                                                   >> 138       size_t n = table->length();
                                                   >> 139       for(size_t i=0; i<n; ++i) {
                                                   >> 140   if((*table)[i]) { (*table)[i]->SetSpline(true); } 
                                                   >> 141       }
                                                   >> 142     }
208   } else if (1 < param->Verbose()) {              143   } else if (1 < param->Verbose()) {
209     G4cout << "### Fail to retrieve physics ta << 144     G4cout << "Fail to retrieve physics table for " 
210      << part->GetParticleName() << " from <"   << 145      << part->GetParticleName()
211      << fname << ">" << G4endl;                << 146      << " and " << procname << " from <"
                                                   >> 147      << namet << ">" << G4endl;
212   }                                               148   }
213   return yes;                                     149   return yes;
214 }                                              << 
215                                                << 
216 //....oooOO0OOooo........oooOO0OOooo........oo << 
217                                                << 
218 void G4EmDataHandler::SetMasterProcess(const G << 
219 {                                              << 
220   masterProcess.push_back(ptr);                << 
221 }                                              << 
222                                                << 
223 //....oooOO0OOooo........oooOO0OOooo........oo << 
224                                                << 
225 const G4VEmProcess* G4EmDataHandler::GetMaster << 
226 {                                              << 
227   return (idx < masterProcess.size()) ? master << 
228 }                                              << 
229                                                << 
230 //....oooOO0OOooo........oooOO0OOooo........oo << 
231                                                << 
232 void G4EmDataHandler::SetElementSelectors(std: << 
233             std::size_t i)                     << 
234 {                                              << 
235   if (i < eLength) {                           << 
236     if (fElemSelectors[i] != p) {              << 
237       delete fElemSelectors[i];                << 
238     }                                          << 
239     fElemSelectors[i] = p;                     << 
240   } else {                                     << 
241     fElemSelectors.push_back(p);               << 
242     ++eLength;                                 << 
243   }                                            << 
244 }                                                 150 }
245                                                   151 
246 //....oooOO0OOooo........oooOO0OOooo........oo    152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
247                                                   153