Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/hadronic/cross_sections/src/G4CrossSectionDataStore.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 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/hadronic/cross_sections/src/G4CrossSectionDataStore.cc (Version 11.3.0) and /processes/hadronic/cross_sections/src/G4CrossSectionDataStore.cc (Version 9.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 // ------------------------------------------- << 
 28 //                                             << 
 29 // GEANT4 Class file                           << 
 30 //                                             << 
 31 //                                             << 
 32 // File name:     G4CrossSectionDataStore      << 
 33 //                                             << 
 34 // Modifications:                              << 
 35 // 23.01.2009 V.Ivanchenko add destruction of  << 
 36 // 29.04.2010 G.Folger     modifictaions for i << 
 37 // 14.03.2011 V.Ivanchenko fixed DumpPhysicsTa << 
 38 // 15.08.2011 G.Folger, V.Ivanchenko, T.Koi, D << 
 39 // 07.03.2013 M.Maire cosmetic in DumpPhysicsT << 
 40 //                                             << 
 41 //....oooOO0OOooo........oooOO0OOooo........oo << 
 42 //....oooOO0OOooo........oooOO0OOooo........oo << 
 43                                                    27 
 44 #include "G4CrossSectionDataStore.hh"              28 #include "G4CrossSectionDataStore.hh"
 45 #include "G4SystemOfUnits.hh"                  <<  29 #include "G4HadronicException.hh"
 46 #include "G4UnitsTable.hh"                     <<  30 #include "G4StableIsotopes.hh"
                                                   >>  31 #include "G4HadTmpUtil.hh"
 47 #include "Randomize.hh"                            32 #include "Randomize.hh"
 48 #include "G4Nucleus.hh"                        << 
 49                                                    33 
 50 #include "G4DynamicParticle.hh"                << 
 51 #include "G4Isotope.hh"                        << 
 52 #include "G4Element.hh"                        << 
 53 #include "G4Material.hh"                       << 
 54 #include "G4MaterialTable.hh"                  << 
 55 #include "G4NistManager.hh"                    << 
 56 #include "G4HadronicParameters.hh"             << 
 57 #include <algorithm>                           << 
 58 #include <typeinfo>                            << 
 59                                                << 
 60 //....oooOO0OOooo........oooOO0OOooo........oo << 
 61                                                << 
 62 G4CrossSectionDataStore::G4CrossSectionDataSto << 
 63   : nist(G4NistManager::Instance())            << 
 64 {}                                             << 
 65                                                << 
 66 //....oooOO0OOooo........oooOO0OOooo........oo << 
 67                                                << 
 68 G4double                                       << 
 69 G4CrossSectionDataStore::ComputeCrossSection(c << 
 70                const G4Material* mat)          << 
 71 {                                              << 
 72   currentMaterial = mat;                       << 
 73   matParticle = dp->GetDefinition();           << 
 74   matKinEnergy = dp->GetKineticEnergy();       << 
 75   matCrossSection = 0.0;                       << 
 76                                                << 
 77   std::size_t nElements = mat->GetNumberOfElem << 
 78   const G4double* nAtomsPerVolume = mat->GetVe << 
 79                                                << 
 80   if(xsecelm.size() < nElements) { xsecelm.res << 
 81                                                << 
 82   for(G4int i=0; i<(G4int)nElements; ++i) {    << 
 83     G4double xs =                              << 
 84       nAtomsPerVolume[i]*GetCrossSection(dp, m << 
 85     matCrossSection += std::max(xs, 0.0);      << 
 86     xsecelm[i] = matCrossSection;              << 
 87   }                                            << 
 88   return matCrossSection;                      << 
 89 }                                              << 
 90                                                    34 
 91 //....oooOO0OOooo........oooOO0OOooo........oo <<  35 G4double
 92                                                <<  36 G4CrossSectionDataStore::GetCrossSection(const G4DynamicParticle* aParticle,
 93 G4double G4CrossSectionDataStore::GetCrossSect <<  37                                          const G4Element* anElement,
 94                                                <<  38            G4double aTemperature)
 95                                                << 
 96 {                                                  39 {
 97   // first check the most last cross section   <<  40   if (NDataSetList == 0) 
 98   G4int i = nDataSetList-1;                    << 
 99   G4int Z = elm->GetZasInt();                  << 
100                                                << 
101   if(elm->GetNaturalAbundanceFlag() &&         << 
102      dataSetList[i]->IsElementApplicable(dp, Z << 
103   {                                                41   {
104     // element wise cross section              <<  42     throw G4HadronicException(__FILE__, __LINE__, 
105     return dataSetList[i]->GetElementCrossSect <<  43      "G4CrossSectionDataStore: no data sets registered");
106   }                                            <<  44     return DBL_MIN;
107                                                <<  45   }
108   // isotope wise cross section                <<  46   for (G4int i = NDataSetList-1; i >= 0; i--) {
109   G4int nIso = (G4int)elm->GetNumberOfIsotopes <<  47     if (DataSetList[i]->IsApplicable(aParticle, anElement))
110                                                <<  48       return DataSetList[i]->GetCrossSection(aParticle,anElement,aTemperature);
111   // user-defined isotope abundances           <<  49   }
112   const G4double* abundVector = elm->GetRelati <<  50   throw G4HadronicException(__FILE__, __LINE__, 
113                                                <<  51                       "G4CrossSectionDataStore: no applicable data set found "
114   G4double sigma = 0.0;                        <<  52                       "for particle/element");
115                                                <<  53   return DBL_MIN;
116   // isotope and element wise cross sections   << 
117   for(G4int j = 0; j < nIso; ++j)              << 
118   {                                            << 
119     const G4Isotope* iso = elm->GetIsotope(j); << 
120     sigma += abundVector[j] *                  << 
121       GetIsoCrossSection(dp, Z, iso->GetN(), i << 
122   }                                            << 
123   return sigma;                                << 
124 }                                                  54 }
125                                                    55 
126 //....oooOO0OOooo........oooOO0OOooo........oo << 
127                                                    56 
128 G4double                                           57 G4double
129 G4CrossSectionDataStore::GetIsoCrossSection(co <<  58 G4CrossSectionDataStore::GetCrossSection(const G4DynamicParticle* aParticle,
130               G4int Z, G4int A,                <<  59                                          const G4Isotope* anIsotope,
131               const G4Isotope* iso,            <<  60            G4double aTemperature)
132               const G4Element* elm,            << 
133               const G4Material* mat,           << 
134               G4int idx)                       << 
135 {                                                  61 {
136   // this methods is called after the check th <<  62   if (NDataSetList == 0) 
137   // depend on isotopes, so first isotopes are <<  63   {
138   if(dataSetList[idx]->IsIsoApplicable(dp, Z,  <<  64     throw G4HadronicException(__FILE__, __LINE__, 
139     return dataSetList[idx]->GetIsoCrossSectio <<  65      "G4CrossSectionDataStore: no data sets registered");
140   }                                            <<  66     return DBL_MIN;
141                                                <<  67   }
142   // no isotope wise cross section - check oth <<  68   for (G4int i = NDataSetList-1; i >= 0; i--) {
143   for (G4int j = nDataSetList-1; j >= 0; --j)  <<  69     if (DataSetList[i]->IsZAApplicable(aParticle, anIsotope->GetZ(), anIsotope->GetN()))
144     if(dataSetList[j]->IsElementApplicable(dp, <<  70       return DataSetList[i]->GetIsoCrossSection(aParticle,anIsotope,aTemperature);
145       return dataSetList[j]->GetElementCrossSe <<  71   }
146     } else if (dataSetList[j]->IsIsoApplicable <<  72   throw G4HadronicException(__FILE__, __LINE__, 
147       return dataSetList[j]->GetIsoCrossSectio <<  73                       "G4CrossSectionDataStore: no applicable data set found "
148     }                                          <<  74                       "for particle/element");
149   }                                            <<  75   return DBL_MIN;
150   G4ExceptionDescription ed;                   << 
151   ed << "No isotope cross section found for "  << 
152      << dp->GetDefinition()->GetParticleName() << 
153      << " off target Element " << elm->GetName << 
154      << " Z= " << Z << " A= " << A;            << 
155   if(nullptr != mat) ed << " from " << mat->Ge << 
156   ed << " E(MeV)=" << dp->GetKineticEnergy()/M << 
157   G4Exception("G4CrossSectionDataStore::GetIso << 
158               FatalException, ed);             << 
159   return 0.0;                                  << 
160 }                                                  76 }
161                                                    77 
162 //....oooOO0OOooo........oooOO0OOooo........oo << 
163                                                    78 
164 G4double                                           79 G4double
165 G4CrossSectionDataStore::GetCrossSection(const <<  80 G4CrossSectionDataStore::GetCrossSection(const G4DynamicParticle* aParticle,
166                                          G4int <<  81                                          G4double Z, G4double A,
167            const G4Isotope* iso,               <<  82            G4double aTemperature)
168                                          const << 
169            const G4Material* mat)              << 
170 {                                                  83 {
171   for (G4int i = nDataSetList-1; i >= 0; --i)  <<  84   if (NDataSetList == 0) 
172     if (dataSetList[i]->IsIsoApplicable(dp, Z, <<  85   {
173       return dataSetList[i]->GetIsoCrossSectio <<  86     throw G4HadronicException(__FILE__, __LINE__, 
174     } else if(dataSetList[i]->IsElementApplica <<  87      "G4CrossSectionDataStore: no data sets registered");
175       return dataSetList[i]->GetElementCrossSe <<  88     return DBL_MIN;
176     }                                          <<  89   }
177   }                                            <<  90   for (G4int i = NDataSetList-1; i >= 0; i--) {
178   G4ExceptionDescription ed;                   <<  91       if (DataSetList[i]->IsZAApplicable(aParticle, Z, A))
179   ed << "No isotope cross section found for "  <<  92       return DataSetList[i]->GetIsoZACrossSection(aParticle,Z,A,aTemperature);
180      << dp->GetDefinition()->GetParticleName() <<  93   }
181      << " off target Element " << elm->GetName <<  94   throw G4HadronicException(__FILE__, __LINE__, 
182      << " Z= " << Z << " A= " << A;            <<  95                       "G4CrossSectionDataStore: no applicable data set found "
183   if(nullptr != mat) ed << " from " << mat->Ge <<  96                       "for particle/element");
184   ed << " E(MeV)=" << dp->GetKineticEnergy()/M <<  97   return DBL_MIN;
185   G4Exception("G4CrossSectionDataStore::GetCro << 
186               FatalException, ed);             << 
187   return 0.0;                                  << 
188 }                                                  98 }
189                                                    99 
190 //....oooOO0OOooo........oooOO0OOooo........oo << 
191                                                   100 
192 const G4Element*                               << 101 G4double
193 G4CrossSectionDataStore::SampleZandA(const G4D << 102 G4CrossSectionDataStore::GetCrossSection(const G4DynamicParticle* aParticle,
194                                      const G4M << 103                                          const G4Material* aMaterial)
195              G4Nucleus& target)                << 
196 {                                                 104 {
197   if(nullptr != forcedElement) { return forced << 105   G4double sigma(0);
198   std::size_t nElements = mat->GetNumberOfElem << 106   G4double aTemp = aMaterial->GetTemperature();
199   const G4Element* anElement = mat->GetElement << 107   G4int nElements = aMaterial->GetNumberOfElements();
200                                                << 108   const G4double* theAtomsPerVolumeVector = aMaterial->GetVecNbOfAtomsPerVolume();
201   // select element from a compound            << 109   G4double xSection(0);
202   if(1 < nElements) {                          << 110 
203     G4double cross = matCrossSection*G4Uniform << 111   for(G4int i=0; i<nElements; i++) {
204     for(G4int i=0; i<(G4int)nElements; ++i) {  << 112     xSection = GetCrossSection( aParticle, (*aMaterial->GetElementVector())[i], aTemp);
205       if(cross <= xsecelm[i]) {                << 113     sigma += theAtomsPerVolumeVector[i] * xSection;
206         anElement = mat->GetElement(i);        << 
207         break;                                 << 
208       }                                        << 
209     }                                          << 
210   }                                               114   }
211                                                   115 
212   G4int Z = anElement->GetZasInt();            << 116   return sigma;
213   const G4Isotope* iso = nullptr;              << 117 }
214                                                << 
215   G4int i = nDataSetList-1;                    << 
216   if (dataSetList[i]->IsElementApplicable(dp,  << 
217                                                   118 
218     //---------------------------------------- << 
219     // element-wise cross section              << 
220     // isotope cross section is not computed   << 
221     //---------------------------------------- << 
222     std::size_t nIso = anElement->GetNumberOfI << 
223     iso = anElement->GetIsotope(0);            << 
224                                                << 
225     // more than 1 isotope                     << 
226     if(1 < nIso) {                             << 
227       iso = dataSetList[i]->SelectIsotope(anEl << 
228                                           dp-> << 
229             dp->GetLogKineticEnergy());        << 
230     }                                          << 
231   } else {                                     << 
232                                                   119 
233     //---------------------------------------- << 120 std::pair<G4double, G4double> 
234     // isotope-wise cross section              << 121 G4CrossSectionDataStore::SelectRandomIsotope(const G4DynamicParticle* particle,
235     // isotope cross section is computed       << 122                                              const G4Material* aMaterial)
236     //---------------------------------------- << 123 {
237     std::size_t nIso = anElement->GetNumberOfI << 124   static G4StableIsotopes theDefaultIsotopes;  // natural abundances and 
238     iso = anElement->GetIsotope(0);            << 125                                                // stable isotopes
239                                                << 126   G4double aTemp = aMaterial->GetTemperature();
240     // more than 1 isotope                     << 127   G4int nElements = aMaterial->GetNumberOfElements();
241     if(1 < nIso) {                             << 128   const G4ElementVector* theElementVector = aMaterial->GetElementVector();
242       const G4double* abundVector = anElement- << 129   const G4double* theAtomsPerVolumeVector = aMaterial->GetVecNbOfAtomsPerVolume();
243       if(xseciso.size() < nIso) { xseciso.resi << 130   std::vector<std::vector<G4double> > awicsPerElement;
244                                                << 131   std::vector<std::vector<G4double> > AvaluesPerElement;
245       G4double cross = 0.0;                    << 132   G4Element* anElement;
246       G4int j;                                 << 133 
247       for (j = 0; j<(G4int)nIso; ++j) {        << 134   // Collect abundance weighted cross sections and A values for each isotope 
248   G4double xsec = 0.0;                         << 135   // in each element
249   if(abundVector[j] > 0.0) {                   << 136  
250     iso = anElement->GetIsotope(j);            << 137   for (G4int i = 0; i < nElements; i++) {
251     xsec = abundVector[j]*                     << 138     anElement = (*theElementVector)[i];
252       GetIsoCrossSection(dp, Z, iso->GetN(), i << 139     G4int nIsoPerElement = anElement->GetNumberOfIsotopes();
253   }                                            << 140     std::vector<G4double> isoholder;
254   cross += xsec;                               << 141     std::vector<G4double> aholder;
255   xseciso[j] = cross;                          << 142     G4double iso_xs;
                                                   >> 143 
                                                   >> 144     if (nIsoPerElement) { // user-defined isotope abundances
                                                   >> 145       G4IsotopeVector* isoVector = anElement->GetIsotopeVector();
                                                   >> 146       G4double* abundVector = anElement->GetRelativeAbundanceVector();
                                                   >> 147       for (G4int j = 0; j < nIsoPerElement; j++) {
                                                   >> 148         iso_xs = GetCrossSection(particle, (*isoVector)[j], aTemp);
                                                   >> 149         isoholder.push_back(abundVector[j]*iso_xs);
                                                   >> 150         aholder.push_back(G4double((*isoVector)[j]->GetN()));
256       }                                           151       }
257       cross *= G4UniformRand();                << 152 
258       for (j = 0; j<(G4int)nIso; ++j) {        << 153     } else { // natural abundances
259   if(cross <= xseciso[j]) {                    << 154       G4int ZZ = G4lrint(anElement->GetZ());
260     iso = anElement->GetIsotope(j);            << 155       nIsoPerElement = theDefaultIsotopes.GetNumberOfIsotopes(ZZ);
261     break;                                     << 156       G4int index = theDefaultIsotopes.GetFirstIsotope(ZZ);
262   }                                            << 157       G4double AA;
                                                   >> 158       G4double abundance;
                                                   >> 159       for (G4int j = 0; j < nIsoPerElement; j++) {
                                                   >> 160         AA = G4double(theDefaultIsotopes.GetIsotopeNucleonCount(index+j));
                                                   >> 161         aholder.push_back(AA);
                                                   >> 162         iso_xs = GetCrossSection(particle, G4double(ZZ), AA, aTemp);
                                                   >> 163         abundance = theDefaultIsotopes.GetAbundance(index+j)/100.0;
                                                   >> 164         isoholder.push_back(abundance*iso_xs);
263       }                                           165       }
264     }                                             166     }
265   }                                            << 
266   target.SetIsotope(iso);                      << 
267   return anElement;                            << 
268 }                                              << 
269                                                   167 
270 //....oooOO0OOooo........oooOO0OOooo........oo << 168     awicsPerElement.push_back(isoholder);
271                                                << 169     AvaluesPerElement.push_back(aholder);
272 void                                           << 
273 G4CrossSectionDataStore::BuildPhysicsTable(con << 
274 {                                              << 
275   if (nDataSetList == 0) {                     << 
276     G4ExceptionDescription ed;                 << 
277     ed << "No cross section is registered for  << 
278        << part.GetParticleName() << G4endl;    << 
279     G4Exception("G4CrossSectionDataStore::Buil << 
280                 FatalException, ed);           << 
281     return;                                    << 
282   }                                            << 
283   matParticle = &part;                         << 
284   for (G4int i=0; i<nDataSetList; ++i) {       << 
285     dataSetList[i]->BuildPhysicsTable(part);   << 
286   }                                               170   }
287   const G4MaterialTable* theMatTable = G4Mater << 
288   std::size_t nelm = 0;                        << 
289   std::size_t niso = 0;                        << 
290   for(auto mat : *theMatTable) {               << 
291     std::size_t nElements = mat->GetNumberOfEl << 
292     nelm = std::max(nelm, nElements);          << 
293     for(G4int j=0; j<(G4int)nElements; ++j) {  << 
294       niso = std::max(niso, mat->GetElement(j) << 
295     }                                          << 
296   }                                            << 
297   // define vectors for a run                  << 
298   xsecelm.resize(nelm, 0.0);                   << 
299   xseciso.resize(niso, 0.0);                   << 
300 }                                              << 
301                                                << 
302 //....oooOO0OOooo........oooOO0OOooo........oo << 
303                                                   171 
304 void                                           << 172   // Calculate running sums for isotope selection
305 G4CrossSectionDataStore::DumpPhysicsTable(cons << 
306 {                                              << 
307   // Print out all cross section data sets use << 
308   // which they apply                          << 
309                                                << 
310   if (nDataSetList == 0) {                     << 
311     G4cout << "WARNING - G4CrossSectionDataSto << 
312      << " no data sets registered" << G4endl;  << 
313     return;                                    << 
314   }                                            << 
315                                                   173 
316   for (G4int i = nDataSetList-1; i >= 0; --i)  << 174   G4double crossSectionTotal = 0;
317     G4double e1 = dataSetList[i]->GetMinKinEne << 175   G4double xSectionPerElement;
318     G4double e2 = dataSetList[i]->GetMaxKinEne << 176   std::vector<G4double> runningSum;
319     G4cout                                     << 177 
320       << "     Cr_sctns: " << std::setw(25) << << 178   for (G4int i=0; i < nElements; i++) {
321       << G4BestUnit(e1, "Energy") << " ---> "  << 179     xSectionPerElement = 0;
322       << G4BestUnit(e2, "Energy") << "\n";     << 180     for (G4int j=0; j < G4int(awicsPerElement[i].size()); j++)
323     if (dataSetList[i]->GetName() == "G4CrossS << 181                      xSectionPerElement += awicsPerElement[i][j];
324       dataSetList[i]->DumpPhysicsTable(part);  << 182     runningSum.push_back(theAtomsPerVolumeVector[i]*xSectionPerElement);
325       G4cout << G4endl;                        << 183     crossSectionTotal += runningSum[i];
                                                   >> 184   }
                                                   >> 185 
                                                   >> 186   // Compare random number to running sum over element xc to choose Z
                                                   >> 187 
                                                   >> 188   // Initialize Z and A to first element and first isotope in case 
                                                   >> 189   // cross section is zero
                                                   >> 190    
                                                   >> 191   G4double ZZ = (*theElementVector)[0]->GetZ();
                                                   >> 192   G4double AA = AvaluesPerElement[0][0];
                                                   >> 193   if (crossSectionTotal != 0.) {
                                                   >> 194     G4double random = G4UniformRand();
                                                   >> 195     for(G4int i=0; i < nElements; i++) {
                                                   >> 196       if(i!=0) runningSum[i] += runningSum[i-1];
                                                   >> 197       if(random <= runningSum[i]/crossSectionTotal) {
                                                   >> 198         ZZ = ((*theElementVector)[i])->GetZ();
                                                   >> 199 
                                                   >> 200         // Compare random number to running sum over isotope xc to choose A
                                                   >> 201 
                                                   >> 202         G4int nIso = awicsPerElement[i].size();
                                                   >> 203         G4double* running = new G4double[nIso];
                                                   >> 204         for (G4int j=0; j < nIso; j++) {
                                                   >> 205           running[j] = awicsPerElement[i][j];
                                                   >> 206           if(j!=0) running[j] += running[j-1];
                                                   >> 207         }
                                                   >> 208 
                                                   >> 209         G4double trial = G4UniformRand(); 
                                                   >> 210         for (G4int j=0; j < nIso; j++) {
                                                   >> 211           AA = AvaluesPerElement[i][j];
                                                   >> 212           if (trial <= running[j]/running[nIso-1]) break;
                                                   >> 213         }
                                                   >> 214         delete [] running;
                                                   >> 215         break;
                                                   >> 216       }
326     }                                             217     }
327   }                                               218   }
                                                   >> 219   return std::pair<G4double, G4double>(ZZ, AA);
328 }                                                 220 }
329                                                   221 
330 //....oooOO0OOooo........oooOO0OOooo........oo << 
331                                                << 
332 void G4CrossSectionDataStore::DumpHtml(const G << 
333                                        std::of << 
334 {                                              << 
335   // Write cross section data set info to html << 
336   // documentation page                        << 
337                                                << 
338   G4double ehi = 0;                            << 
339   G4double elo = 0;                            << 
340   auto param = G4HadronicParameters::Instance( << 
341   G4String physListName = param->GetPhysListNa << 
342   G4String dirName = param->GetPhysListDocDir( << 
343                                                << 
344   for (G4int i = nDataSetList-1; i > 0; i--) { << 
345     elo = dataSetList[i]->GetMinKinEnergy()/Ge << 
346     ehi = dataSetList[i]->GetMaxKinEnergy()/Ge << 
347     outFile << "      <li><b><a href=\"" << ph << 
348       << dataSetList[i]->GetName() << ".html\" << 
349             << dataSetList[i]->GetName() << "< << 
350             << elo << " GeV to " << ehi << " G << 
351     PrintCrossSectionHtml(dataSetList[i], phys << 
352   }                                            << 
353                                                << 
354   G4double defaultHi = dataSetList[0]->GetMaxK << 
355   if (ehi < defaultHi) {                       << 
356     outFile << "      <li><b><a href=\"" << da << 
357       << ".html\"> "                           << 
358             << dataSetList[0]->GetName() << "< << 
359             << ehi << " GeV to " << defaultHi  << 
360     PrintCrossSectionHtml(dataSetList[0], phys << 
361   }                                            << 
362 }                                              << 
363                                                << 
364 //....oooOO0OOooo........oooOO0OOooo........oo << 
365                                                << 
366 void G4CrossSectionDataStore::PrintCrossSectio << 
367                                                << 
368                                                << 
369 {                                              << 
370                                                << 
371   G4String pathName = dirName + "/" + physList << 
372   std::ofstream outCS;                         << 
373   outCS.open(pathName);                        << 
374   outCS << "<html>\n";                         << 
375   outCS << "<head>\n";                         << 
376   outCS << "<title>Description of " << cs->Get << 
377   << "</title>\n";                             << 
378   outCS << "</head>\n";                        << 
379   outCS << "<body>\n";                         << 
380                                                << 
381   cs->CrossSectionDescription(outCS);          << 
382                                                << 
383   outCS << "</body>\n";                        << 
384   outCS << "</html>\n";                        << 
385 }                                              << 
386                                                << 
387 //....oooOO0OOooo........oooOO0OOooo........oo << 
388                                                   222 
389 G4String G4CrossSectionDataStore::HtmlFileName << 223 void
                                                   >> 224 G4CrossSectionDataStore::AddDataSet(G4VCrossSectionDataSet* aDataSet)
390 {                                                 225 {
391    G4String str(in);                           << 226    if (NDataSetList == NDataSetMax) {
392    // replace blanks by _  C++11 version:      << 227       G4cout << "WARNING: G4CrossSectionDataStore::AddDataSet: "<<G4endl;
393    std::transform(str.begin(), str.end(), str. << 228       G4cout << "         reached maximum number of data sets";
394        return ch == ' ' ? '_' : ch;            << 229       G4cout << "         data set not added !!!!!!!!!!!!!!!!";
395    });                                         << 230       return;
396    str=str + ".html";                          << 231    }
397    return str;                                 << 232    DataSetList[NDataSetList] = aDataSet;
                                                   >> 233    NDataSetList++;
398 }                                                 234 }
399                                                   235 
400 //....oooOO0OOooo........oooOO0OOooo........oo << 
401                                                   236 
402 void G4CrossSectionDataStore::AddDataSet(G4VCr << 237 void
                                                   >> 238 G4CrossSectionDataStore::
                                                   >> 239 BuildPhysicsTable(const G4ParticleDefinition& aParticleType)
403 {                                                 240 {
404   if(p->ForAllAtomsAndEnergies()) {            << 241    if (NDataSetList == 0) 
405     dataSetList.clear();                       << 242    {
406     nDataSetList = 0;                          << 243      G4Exception("G4CrossSectionDataStore", "007", FatalException,
407   }                                            << 244                  "BuildPhysicsTable: no data sets registered");
408   dataSetList.push_back(p);                    << 245      return;
409   ++nDataSetList;                              << 246    }
                                                   >> 247    for (G4int i = NDataSetList-1; i >= 0; i--) {
                                                   >> 248       DataSetList[i]->BuildPhysicsTable(aParticleType);
                                                   >> 249    }
410 }                                                 250 }
411                                                   251 
412 //....oooOO0OOooo........oooOO0OOooo........oo << 
413                                                   252 
414 void G4CrossSectionDataStore::AddDataSet(G4VCr << 253 void
                                                   >> 254 G4CrossSectionDataStore::
                                                   >> 255 DumpPhysicsTable(const G4ParticleDefinition& aParticleType)
415 {                                                 256 {
416   if(p->ForAllAtomsAndEnergies()) {            << 257    if (NDataSetList == 0) {
417     dataSetList.clear();                       << 258       G4cout << "WARNING - G4CrossSectionDataStore::DumpPhysicsTable: no data sets registered"<<G4endl;
418     dataSetList.push_back(p);                  << 259       return;
419     nDataSetList = 1;                          << 260    }
420   } else if ( i >= dataSetList.size() ) {      << 261    for (G4int i = NDataSetList-1; i >= 0; i--) {
421     dataSetList.push_back(p);                  << 262       DataSetList[i]->DumpPhysicsTable(aParticleType);
422     ++nDataSetList;                            << 263    }
423   } else {                                     << 
424     std::vector< G4VCrossSectionDataSet* >::it << 
425     dataSetList.insert(it , p);                << 
426     ++nDataSetList;                            << 
427   }                                            << 
428 }                                                 264 }
429                                                << 
430 //....oooOO0OOooo........oooOO0OOooo........oo << 
431                                                   265