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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/hadronic/cross_sections/src/G4HadronXSDataTable.cc (Version 11.3.0) and /processes/hadronic/cross_sections/src/G4HadronXSDataTable.cc (Version 11.0.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27 //--------------------------------------------     27 //---------------------------------------------------------------------------
 28 //                                                 28 //
 29 // GEANT4 Class file                               29 // GEANT4 Class file
 30 //                                                 30 //
 31 // Description: Data structure for registratio <<  31 // Description: Data structure for cross sections per materials
 32 //                                                 32 //
 33 // Author:      V.Ivanchenko 31.05.2018            33 // Author:      V.Ivanchenko 31.05.2018
 34 //                                                 34 //
 35 // Modifications:                                  35 // Modifications:
 36 //                                                 36 //
 37 //--------------------------------------------     37 //----------------------------------------------------------------------------
 38 //                                                 38 //
 39                                                    39 
 40 //....oooOO0OOooo........oooOO0OOooo........oo     40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 41                                                    41 
 42 #include "G4HadronXSDataTable.hh"                  42 #include "G4HadronXSDataTable.hh"
                                                   >>  43 #include "G4PhysicsLogVector.hh"
                                                   >>  44 #include "G4Material.hh"
                                                   >>  45 #include "G4MaterialTable.hh"
                                                   >>  46 #include "G4DynamicParticle.hh"
                                                   >>  47 #include "G4CrossSectionDataStore.hh"
 43                                                    48 
 44 G4HadronXSDataTable* G4HadronXSDataTable::sIns <<  49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >>  50 
                                                   >>  51 G4HadElementSelector::G4HadElementSelector(G4DynamicParticle* dp, 
                                                   >>  52              G4CrossSectionDataStore* xs, 
                                                   >>  53              const G4Material* mat, 
                                                   >>  54              G4int bins, G4double emin, 
                                                   >>  55              G4double emax, G4bool)
                                                   >>  56 {
                                                   >>  57   G4int n = mat->GetNumberOfElements();
                                                   >>  58   nElmMinusOne = n - 1;
                                                   >>  59   theElementVector = mat->GetElementVector();
                                                   >>  60   if(nElmMinusOne > 0) {
                                                   >>  61     G4PhysicsVector* first = nullptr;
                                                   >>  62     xSections.resize(n, first);
                                                   >>  63     first = new G4PhysicsLogVector(emin,emax,bins,false);
                                                   >>  64     xSections[0] = first;
                                                   >>  65     for(G4int i=1; i<n; ++i) {
                                                   >>  66       xSections[i] = new G4PhysicsVector(*first);
                                                   >>  67     }
                                                   >>  68     std::vector<G4double> temp;
                                                   >>  69     temp.resize(n, 0.0);
                                                   >>  70     for(G4int j=0; j<=bins; ++j) {
                                                   >>  71       G4double cross = 0.0;
                                                   >>  72       G4double e = first->Energy(j);
                                                   >>  73       dp->SetKineticEnergy(e);
                                                   >>  74       for(G4int i=0; i<n; ++i) {
                                                   >>  75   cross += xs->GetCrossSection(dp, (*theElementVector)[i], mat);
                                                   >>  76         temp[i] = cross;
                                                   >>  77       }
                                                   >>  78       G4double fact = (cross > 0.0) ? 1.0/cross : 0.0;
                                                   >>  79       for(G4int i=0; i<n; ++i) {
                                                   >>  80   G4double y = (i<n-1) ? temp[i]*fact : 1.0; 
                                                   >>  81         xSections[i]->PutValue(j, y);
                                                   >>  82       }
                                                   >>  83     }
                                                   >>  84   }
                                                   >>  85 }
 45                                                    86 
 46 //....oooOO0OOooo........oooOO0OOooo........oo     87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 47                                                    88 
 48 G4HadronXSDataTable* G4HadronXSDataTable::Inst <<  89 G4HadElementSelector::~G4HadElementSelector()
 49   if ( sInstance == nullptr ) {                <<  90 {
 50     static G4HadronXSDataTable theObject;      <<  91   if(nElmMinusOne > 0) {
 51     sInstance = &theObject;                    <<  92     for(G4int i=0; i<=nElmMinusOne; ++i) { delete xSections[i]; }
 52   }                                                93   }
 53   return sInstance;                            << 
 54 }                                                  94 }
 55                                                    95 
 56 //....oooOO0OOooo........oooOO0OOooo........oo     96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 57                                                    97 
 58 G4HadronXSDataTable::G4HadronXSDataTable()     <<  98 void G4HadElementSelector::Dump()
 59 {}                                                 99 {}
 60                                                   100 
 61 //....oooOO0OOooo........oooOO0OOooo........oo    101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 62                                                   102 
 63 G4HadronXSDataTable::~G4HadronXSDataTable()    << 103 G4HadronXSDataTable::G4HadronXSDataTable() : nMaterials(0)
                                                   >> 104 {}
                                                   >> 105 
                                                   >> 106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 107 
                                                   >> 108 void G4HadronXSDataTable::Initialise(G4DynamicParticle* dp, 
                                                   >> 109              G4CrossSectionDataStore* xs, 
                                                   >> 110              G4int bins, G4double emin, G4double emax, 
                                                   >> 111              G4bool spline)
 64 {                                                 112 {
 65   for (std::size_t i = 0; i < fPiData.size();  << 113   size_t nn = G4Material::GetNumberOfMaterials();
 66     auto ptr = fPiData[i];                     << 114   if(nn > nMaterials) {
 67     for (std::size_t j = 0; j < ptr->size(); + << 115     if(0 == nMaterials) {
 68       auto p = (*ptr)[j];                      << 116       xsData.reserve(nn);
 69       for (std::size_t k = i + 1; k < fPiData. << 117       elmSelectors.reserve(nn);
 70   auto qtr = fPiData[k];                       << 118     }
 71   for (std::size_t l = 0; l < qtr->size(); ++l << 119     G4PhysicsLogVector* first = nullptr;
 72     if ((*qtr)[l] == p) { (*qtr)[l] = nullptr; << 120     G4int sbins = std::max(10, bins/5);
                                                   >> 121     const G4MaterialTable* mtable = G4Material::GetMaterialTable();
                                                   >> 122     for(size_t i=nMaterials; i<nn; ++i) {
                                                   >> 123       const G4Material* mat = (*mtable)[i];
                                                   >> 124       G4PhysicsVector* v = nullptr;
                                                   >> 125       G4HadElementSelector* es = nullptr;
                                                   >> 126       // create real vector only for complex materials
                                                   >> 127       if(mat->GetNumberOfElements() > 1) {
                                                   >> 128   if(nullptr == first) {
                                                   >> 129           first = new G4PhysicsLogVector(emin, emax, bins, spline);
                                                   >> 130     v = first;
                                                   >> 131   } else {
                                                   >> 132     v = new G4PhysicsVector(*first);
                                                   >> 133   }
                                                   >> 134         for(G4int j=0; j<=bins; ++j) {
                                                   >> 135           G4double e = first->Energy(j);
                                                   >> 136           dp->SetKineticEnergy(e);
                                                   >> 137           G4double cros = xs->ComputeCrossSection(dp, mat);
                                                   >> 138           v->PutValue(j, cros);
 73   }                                               139   }
                                                   >> 140         if(spline) v->FillSecondDerivatives();
                                                   >> 141   elmSelectors[i] = new G4HadElementSelector(dp, xs, mat, sbins, emin, emax, spline);
 74       }                                           142       }
 75       delete p;                                << 143       xsData.push_back(v);
 76       (*ptr)[j] = nullptr;                     << 144       elmSelectors.push_back(es);
 77     }                                             145     }
 78     delete ptr;                                << 146     nMaterials = nn;
 79   }                                            << 
 80   fPiData.clear();                             << 
 81   for (auto const & ptr : fTable) {            << 
 82     ptr->clearAndDestroy();                    << 
 83     delete ptr;                                << 
 84   }                                               147   }
 85   fTable.clear();                              << 
 86 }                                                 148 }
 87                                                   149 
 88 //....oooOO0OOooo........oooOO0OOooo........oo    150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 89                                                   151 
 90 void G4HadronXSDataTable::AddPiData(std::vecto << 152 G4HadronXSDataTable::~G4HadronXSDataTable()
 91 {                                                 153 {
 92   if (nullptr == ptr || ptr->empty()) { return << 154   for(size_t i=0; i<nMaterials; ++i) {
 93   for (auto & d : fPiData) {                   << 155     delete xsData[i];
 94     if (ptr == d) { return; }                  << 156     delete elmSelectors[i];
 95   }                                               157   }
 96   fPiData.push_back(ptr);                      << 
 97 }                                                 158 }
 98                                                   159 
 99 //....oooOO0OOooo........oooOO0OOooo........oo    160 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
100                                                   161 
101 void G4HadronXSDataTable::AddTable(G4PhysicsTa << 162 void G4HadronXSDataTable::Dump()
102 {                                              << 163 {}
103   if (nullptr != ptr) {                        << 
104     for (auto & p : fTable) { if (p == ptr) {  << 
105     fTable.push_back(ptr);                     << 
106   }                                            << 
107 }                                              << 
108                                                   164 
109 //....oooOO0OOooo........oooOO0OOooo........oo    165 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
110                                                   166