Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/hadronic/models/particle_hp/src/G4ParticleHPInelastic.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/models/particle_hp/src/G4ParticleHPInelastic.cc (Version 11.3.0) and /processes/hadronic/models/particle_hp/src/G4ParticleHPInelastic.cc (Version 11.1.2)


  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 // this code implementation is the intellectua     26 // this code implementation is the intellectual property of
 27 // neutron_hp -- source file                       27 // neutron_hp -- source file
 28 // J.P. Wellisch, Nov-1996                         28 // J.P. Wellisch, Nov-1996
 29 // A prototype of the low energy neutron trans     29 // A prototype of the low energy neutron transport model.
 30 //                                                 30 //
 31 // By copying, distributing or modifying the P     31 // By copying, distributing or modifying the Program (or any work
 32 // based on the Program) you indicate your acc     32 // based on the Program) you indicate your acceptance of this statement,
 33 // and all its terms.                              33 // and all its terms.
 34 //                                                 34 //
 35 //                                                 35 //
 36 // 070523 bug fix for G4FPE_DEBUG on by A. How     36 // 070523 bug fix for G4FPE_DEBUG on by A. Howard (and T. Koi)
 37 // 081203 limit maximum trial for creating fin     37 // 081203 limit maximum trial for creating final states add protection for 1H isotope case by T. Koi
 38 //                                                 38 //
 39 // P. Arce, June-2014 Conversion neutron_hp to     39 // P. Arce, June-2014 Conversion neutron_hp to particle_hp
 40 // V. Ivanchenko, July-2023 Basic revision of  << 
 41 //                                                 40 //
 42 #include "G4ParticleHPInelastic.hh"                41 #include "G4ParticleHPInelastic.hh"
 43                                                <<  42 #include "G4SystemOfUnits.hh"
                                                   >>  43 #include "G4ParticleHPManager.hh"
 44 #include "G4HadronicParameters.hh"                 44 #include "G4HadronicParameters.hh"
                                                   >>  45 #include "G4ParticleHPThermalBoost.hh"
                                                   >>  46 #include "G4Threading.hh"
                                                   >>  47 
 45 #include "G4ParticleHP2AInelasticFS.hh"            48 #include "G4ParticleHP2AInelasticFS.hh"
 46 #include "G4ParticleHP2N2AInelasticFS.hh"          49 #include "G4ParticleHP2N2AInelasticFS.hh"
 47 #include "G4ParticleHP2NAInelasticFS.hh"           50 #include "G4ParticleHP2NAInelasticFS.hh"
 48 #include "G4ParticleHP2NDInelasticFS.hh"           51 #include "G4ParticleHP2NDInelasticFS.hh"
 49 #include "G4ParticleHP2NInelasticFS.hh"            52 #include "G4ParticleHP2NInelasticFS.hh"
 50 #include "G4ParticleHP2NPInelasticFS.hh"           53 #include "G4ParticleHP2NPInelasticFS.hh"
 51 #include "G4ParticleHP2PInelasticFS.hh"            54 #include "G4ParticleHP2PInelasticFS.hh"
 52 #include "G4ParticleHP3AInelasticFS.hh"            55 #include "G4ParticleHP3AInelasticFS.hh"
 53 #include "G4ParticleHP3NAInelasticFS.hh"           56 #include "G4ParticleHP3NAInelasticFS.hh"
 54 #include "G4ParticleHP3NInelasticFS.hh"            57 #include "G4ParticleHP3NInelasticFS.hh"
 55 #include "G4ParticleHP3NPInelasticFS.hh"           58 #include "G4ParticleHP3NPInelasticFS.hh"
 56 #include "G4ParticleHP4NInelasticFS.hh"            59 #include "G4ParticleHP4NInelasticFS.hh"
 57 #include "G4ParticleHPAInelasticFS.hh"             60 #include "G4ParticleHPAInelasticFS.hh"
 58 #include "G4ParticleHPD2AInelasticFS.hh"           61 #include "G4ParticleHPD2AInelasticFS.hh"
 59 #include "G4ParticleHPDAInelasticFS.hh"            62 #include "G4ParticleHPDAInelasticFS.hh"
 60 #include "G4ParticleHPDInelasticFS.hh"             63 #include "G4ParticleHPDInelasticFS.hh"
 61 #include "G4ParticleHPHe3InelasticFS.hh"           64 #include "G4ParticleHPHe3InelasticFS.hh"
 62 #include "G4ParticleHPManager.hh"              << 
 63 #include "G4ParticleHPN2AInelasticFS.hh"           65 #include "G4ParticleHPN2AInelasticFS.hh"
 64 #include "G4ParticleHPN2PInelasticFS.hh"           66 #include "G4ParticleHPN2PInelasticFS.hh"
 65 #include "G4ParticleHPN3AInelasticFS.hh"           67 #include "G4ParticleHPN3AInelasticFS.hh"
 66 #include "G4ParticleHPNAInelasticFS.hh"            68 #include "G4ParticleHPNAInelasticFS.hh"
 67 #include "G4ParticleHPND2AInelasticFS.hh"          69 #include "G4ParticleHPND2AInelasticFS.hh"
 68 #include "G4ParticleHPNDInelasticFS.hh"            70 #include "G4ParticleHPNDInelasticFS.hh"
 69 #include "G4ParticleHPNHe3InelasticFS.hh"          71 #include "G4ParticleHPNHe3InelasticFS.hh"
 70 #include "G4ParticleHPNInelasticFS.hh"             72 #include "G4ParticleHPNInelasticFS.hh"
 71 #include "G4ParticleHPNPAInelasticFS.hh"           73 #include "G4ParticleHPNPAInelasticFS.hh"
 72 #include "G4ParticleHPNPInelasticFS.hh"            74 #include "G4ParticleHPNPInelasticFS.hh"
 73 #include "G4ParticleHPNT2AInelasticFS.hh"          75 #include "G4ParticleHPNT2AInelasticFS.hh"
 74 #include "G4ParticleHPNTInelasticFS.hh"            76 #include "G4ParticleHPNTInelasticFS.hh"
 75 #include "G4ParticleHPNXInelasticFS.hh"            77 #include "G4ParticleHPNXInelasticFS.hh"
 76 #include "G4ParticleHPPAInelasticFS.hh"            78 #include "G4ParticleHPPAInelasticFS.hh"
 77 #include "G4ParticleHPPDInelasticFS.hh"            79 #include "G4ParticleHPPDInelasticFS.hh"
 78 #include "G4ParticleHPPInelasticFS.hh"             80 #include "G4ParticleHPPInelasticFS.hh"
 79 #include "G4ParticleHPPTInelasticFS.hh"            81 #include "G4ParticleHPPTInelasticFS.hh"
 80 #include "G4ParticleHPT2AInelasticFS.hh"           82 #include "G4ParticleHPT2AInelasticFS.hh"
 81 #include "G4ParticleHPTInelasticFS.hh"             83 #include "G4ParticleHPTInelasticFS.hh"
 82 #include "G4ParticleHPThermalBoost.hh"         << 
 83 #include "G4SystemOfUnits.hh"                  << 
 84 #include "G4AutoLock.hh"                       << 
 85                                                << 
 86 G4bool G4ParticleHPInelastic::fLock[] = {true, << 
 87 std::vector<G4ParticleHPChannelList*>*         << 
 88 G4ParticleHPInelastic::theInelastic[] = {nullp << 
 89                                                    84 
 90 namespace                                      <<  85 G4ParticleHPInelastic::G4ParticleHPInelastic(G4ParticleDefinition* projectile,
                                                   >>  86                                              const char* name )
                                                   >>  87   : G4HadronicInteraction(name), theInelastic(nullptr), numEle(0)
                                                   >>  88   , theProjectile(projectile)
 91 {                                                  89 {
 92   G4Mutex theHPInelastic = G4MUTEX_INITIALIZER <<  90     G4String baseName; 
 93 }                                              <<  91     if ( G4FindDataDir("G4PARTICLEHPDATA") ) {
                                                   >>  92       baseName = G4FindDataDir( "G4PARTICLEHPDATA" );
                                                   >>  93     }
                                                   >>  94     //const char* dataDirVariable;
                                                   >>  95     G4String particleName;
                                                   >>  96     if ( theProjectile == G4Neutron::Neutron() ) {
                                                   >>  97       dataDirVariable = "G4NEUTRONHPDATA";
                                                   >>  98     } else if( theProjectile == G4Proton::Proton() ) {
                                                   >>  99       dataDirVariable = "G4PROTONHPDATA";
                                                   >> 100       particleName = "Proton";
                                                   >> 101     } else if( theProjectile == G4Deuteron::Deuteron() ) {
                                                   >> 102       dataDirVariable = "G4DEUTERONHPDATA";
                                                   >> 103       particleName = "Deuteron";
                                                   >> 104     } else if( theProjectile == G4Triton::Triton() ) {
                                                   >> 105       dataDirVariable = "G4TRITONHPDATA";
                                                   >> 106       particleName = "Triton";
                                                   >> 107     } else if( theProjectile == G4He3::He3() ) {
                                                   >> 108       dataDirVariable = "G4HE3HPDATA";
                                                   >> 109       particleName = "He3";
                                                   >> 110     } else if( theProjectile == G4Alpha::Alpha() ) {
                                                   >> 111       dataDirVariable = "G4ALPHAHPDATA";
                                                   >> 112       particleName = "Alpha";
                                                   >> 113     } else {
                                                   >> 114       G4String message("G4ParticleHPInelastic may only be called for neutron, proton, deuteron, triton, He3 or alpha, while it is called for " + theProjectile->GetParticleName());
                                                   >> 115       throw G4HadronicException(__FILE__, __LINE__,message.c_str());
                                                   >> 116     }
 94                                                   117 
 95 G4ParticleHPInelastic::G4ParticleHPInelastic(G << 118     SetMinEnergy( 0.0 );
 96   : G4HadronicInteraction(name), theProjectile << 119     SetMaxEnergy( 20.*MeV );
 97 {                                              << 
 98   fManager = G4ParticleHPManager::GetInstance( << 
 99   dirName = fManager->GetParticleHPPath(thePro << 
100   indexP = fManager->GetPHPIndex(theProjectile << 
101                                                   120 
                                                   >> 121     //G4cout << " entering G4ParticleHPInelastic constructor"<<G4endl;
                                                   >> 122     if ( !G4FindDataDir("G4PARTICLEHPDATA") && !G4FindDataDir(dataDirVariable) ) {
                                                   >> 123       G4String message("Please setenv G4PARTICLEHPDATA (recommended) or, at least setenv " +
                                                   >> 124            G4String(dataDirVariable) + " to point to the " + theProjectile->GetParticleName() + " cross-section files." );      
                                                   >> 125       throw G4HadronicException(__FILE__, __LINE__,message.c_str());
                                                   >> 126     }
                                                   >> 127     if ( G4FindDataDir(dataDirVariable) ) {
                                                   >> 128       dirName = G4FindDataDir(dataDirVariable);
                                                   >> 129     } else {
                                                   >> 130       dirName = baseName + "/" + particleName;
                                                   >> 131     }
                                                   >> 132     
102 #ifdef G4VERBOSE                                  133 #ifdef G4VERBOSE
103   if (fManager->GetVerboseLevel() > 1)         << 134     if ( G4HadronicParameters::Instance()->GetVerboseLevel() > 0 ) G4cout << dirName << G4endl;
104     G4cout << "@@@ G4ParticleHPInelastic insta << 
105            << p->GetParticleName() << " indexP << 
106      << "/n    data directory " << dirName <<  << 
107 #endif                                            135 #endif
108 }                                              << 136     
                                                   >> 137     G4String tString = "/Inelastic";
                                                   >> 138     dirName = dirName + tString;
109                                                   139 
110 G4ParticleHPInelastic::~G4ParticleHPInelastic( << 140 #ifdef G4VERBOSE
111 {                                              << 141     if ( G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
112   // Vector is shared, only one delete         << 142       G4cout << "@@@ G4ParticleHPInelastic instantiated for particle " << theProjectile->GetParticleName() << " data directory variable is " << dataDirVariable << " pointing to " << dirName << G4endl;
113   if (isFirst) {                               << 143 #endif
114     ClearData();                               << 
115   }                                               144   }
116 }                                              << 
117                                                   145 
118 void G4ParticleHPInelastic::ClearData()        << 146   G4ParticleHPInelastic::~G4ParticleHPInelastic()
119 {                                              << 147   {
120   if (theInelastic[indexP] != nullptr) {       << 148     //Vector is shared, only master deletes
121     for (auto const& p : *(theInelastic[indexP << 149     if ( !G4Threading::IsWorkerThread() ) {
122       delete p;                                << 150         if ( theInelastic != nullptr ) {
123     }                                          << 151             for ( auto it=theInelastic->cbegin(); it!=theInelastic->cend(); ++it ) {
124     delete theInelastic[indexP];               << 152                 delete *it;
125     theInelastic[indexP] = nullptr;            << 153             }
                                                   >> 154             theInelastic->clear();
                                                   >> 155         }
                                                   >> 156      }
126   }                                               157   }
127 }                                              << 158   
                                                   >> 159   G4HadFinalState * G4ParticleHPInelastic::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& aNucleus )
                                                   >> 160   {
                                                   >> 161     G4ParticleHPManager::GetInstance()->OpenReactionWhiteBoard();
                                                   >> 162     const G4Material * theMaterial = aTrack.GetMaterial();
                                                   >> 163     G4int n = (G4int)theMaterial->GetNumberOfElements();
                                                   >> 164     std::size_t index = theMaterial->GetElement(0)->GetIndex();
                                                   >> 165     G4int it=0;
                                                   >> 166     if(n!=1)
                                                   >> 167     {
                                                   >> 168       G4double* xSec = new G4double[n];
                                                   >> 169       G4double sum=0;
                                                   >> 170       G4int i;
                                                   >> 171       const G4double * NumAtomsPerVolume = theMaterial->GetVecNbOfAtomsPerVolume();
                                                   >> 172       G4double rWeight;    
                                                   >> 173       G4ParticleHPThermalBoost aThermalE;
                                                   >> 174       for (i=0; i<n; ++i)
                                                   >> 175       {
                                                   >> 176         index = theMaterial->GetElement(i)->GetIndex();
                                                   >> 177         rWeight = NumAtomsPerVolume[i];
                                                   >> 178   if ( aTrack.GetDefinition() == G4Neutron::Neutron() ) {
                                                   >> 179     xSec[i] = ((*theInelastic)[index])->GetXsec(aThermalE.GetThermalEnergy(aTrack,
                                                   >> 180                         theMaterial->GetElement(i),
                                                   >> 181                         theMaterial->GetTemperature()));
                                                   >> 182   } else {
                                                   >> 183     xSec[i] = ((*theInelastic)[index])->GetXsec(aTrack.GetKineticEnergy());
                                                   >> 184   }
                                                   >> 185         xSec[i] *= rWeight;
                                                   >> 186         sum+=xSec[i];
                                                   >> 187 #ifdef G4PHPDEBUG
                                                   >> 188   #ifdef G4VERBOSE
                                                   >> 189   if( std::getenv("G4ParticleHPDebug") && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
                                                   >> 190     G4cout << " G4ParticleHPInelastic XSEC ELEM " << i << " = " << xSec[i] << G4endl;
                                                   >> 191   #endif
                                                   >> 192 #endif
128                                                   193 
129 G4HadFinalState* G4ParticleHPInelastic::ApplyY << 
130                                                << 
131 {                                              << 
132   G4ParticleHPManager::GetInstance()->OpenReac << 
133   const G4Material* theMaterial = aTrack.GetMa << 
134   auto n = (G4int)theMaterial->GetNumberOfElem << 
135   auto elm = theMaterial->GetElement(0);       << 
136   std::size_t index = elm->GetIndex();         << 
137   G4int it = 0;                                << 
138   /*                                           << 
139   G4cout << "G4ParticleHPInelastic::ApplyYours << 
140    << " indexP=" << indexP << " "              << 
141          << aTrack.GetDefinition()->GetParticl << 
142   */                                           << 
143   if (n != 1) {                                << 
144     auto xSec = new G4double[n];               << 
145     G4double sum = 0;                          << 
146     G4int i;                                   << 
147     const G4double* NumAtomsPerVolume = theMat << 
148     G4double rWeight;                          << 
149     G4double xs;                               << 
150     G4ParticleHPThermalBoost aThermalE;        << 
151     for (i = 0; i < n; ++i) {                  << 
152       elm = theMaterial->GetElement(i);        << 
153       index = elm->GetIndex();                 << 
154       /*                                       << 
155       G4cout << "i=" << i << "  index=" << ind << 
156        << "  " << (*(theInelastic[indexP]))[in << 
157       */                                       << 
158       rWeight = NumAtomsPerVolume[i];          << 
159       if (aTrack.GetDefinition() == G4Neutron: << 
160         xs = (*(theInelastic[indexP]))[index]- << 
161                    theMaterial->GetTemperature << 
162       }                                           194       }
163       else {                                   << 195       G4double random = G4UniformRand();
164         xs = (*(theInelastic[indexP]))[index]- << 196       G4double running = 0;
                                                   >> 197       for (i=0; i<n; ++i)
                                                   >> 198       {
                                                   >> 199         running += xSec[i];
                                                   >> 200         index = theMaterial->GetElement(i)->GetIndex();
                                                   >> 201         it = i;
                                                   >> 202         //if(random<=running/sum) break;
                                                   >> 203         if( sum == 0 || random<=running/sum) break;
165       }                                           204       }
166       xs *= rWeight;                           << 205       delete [] xSec;
167       sum += xs;                               << 
168       xSec[i] = sum;                           << 
169 #ifdef G4VERBOSE                               << 
170       if (fManager->GetDEBUG())                << 
171         G4cout << " G4ParticleHPInelastic XSEC << 
172 #endif                                         << 
173     }                                          << 
174     sum *= G4UniformRand();                    << 
175     for (it = 0; it < n; ++it) {               << 
176       elm = theMaterial->GetElement(it);       << 
177       index = elm->GetIndex();                 << 
178       if (sum <= xSec[it]) break;              << 
179     }                                             206     }
180     delete[] xSec;                             << 
181   }                                            << 
182                                                   207 
183 #ifdef G4VERBOSE                               << 208 #ifdef G4PHPDEBUG
184   if (fManager->GetDEBUG())                    << 209     #ifdef G4VERBOSE
185     G4cout << " G4ParticleHPInelastic: Elem it << 210     if( std::getenv("G4ParticleHPDebug") && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
186            << elm->GetName() << " index=" << i << 211       G4cout << " G4ParticleHPInelastic SELECTED ELEM " << it << " = " << theMaterial->GetElement(it)->GetName() << " FROM MATERIAL " << theMaterial->GetName() << G4endl;
187      << " from material " << theMaterial->GetN << 212     #endif
188            << G4endl;                          << 
189 #endif                                            213 #endif
                                                   >> 214     //return theInelastic[index].ApplyYourself(theMaterial->GetElement(it), aTrack);
                                                   >> 215     G4HadFinalState* result = ((*theInelastic)[index])->ApplyYourself(theMaterial->GetElement(it), aTrack);
                                                   >> 216     //
                                                   >> 217     aNucleus.SetParameters(G4ParticleHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargA(),G4ParticleHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargZ());
                                                   >> 218     const G4Element* target_element = (*G4Element::GetElementTable())[index];
                                                   >> 219     const G4Isotope* target_isotope = nullptr;
                                                   >> 220     G4int iele = (G4int)target_element->GetNumberOfIsotopes();
                                                   >> 221     for ( G4int j = 0 ; j != iele ; ++j ) { 
                                                   >> 222        target_isotope=target_element->GetIsotope( j );
                                                   >> 223        if ( target_isotope->GetN() == G4ParticleHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargA() ) break; 
                                                   >> 224     }
                                                   >> 225     aNucleus.SetIsotope( target_isotope );
190                                                   226 
191   G4HadFinalState* result =                    << 227     G4ParticleHPManager::GetInstance()->CloseReactionWhiteBoard();
192     (*(theInelastic[indexP]))[index]->ApplyYou << 
193                                                   228 
194   aNucleus.SetParameters(fManager->GetReaction << 229     return result;
195                          fManager->GetReaction << 
196                                                << 
197   const G4Element* target_element = (*G4Elemen << 
198   const G4Isotope* target_isotope = nullptr;   << 
199   auto iele = (G4int)target_element->GetNumber << 
200   for (G4int j = 0; j != iele; ++j) {          << 
201     target_isotope = target_element->GetIsotop << 
202     if (target_isotope->GetN() == fManager->Ge << 
203       break;                                   << 
204   }                                               230   }
205   aNucleus.SetIsotope(target_isotope);         << 
206                                                << 
207   G4ParticleHPManager::GetInstance()->CloseRea << 
208                                                << 
209   return result;                               << 
210 }                                              << 
211                                                   231 
212 const std::pair<G4double, G4double> G4Particle    232 const std::pair<G4double, G4double> G4ParticleHPInelastic::GetFatalEnergyCheckLevels() const
213 {                                                 233 {
214   // max energy non-conservation is mass of he    234   // max energy non-conservation is mass of heavy nucleus
215   return std::pair<G4double, G4double>(10.0 *  << 235   return std::pair<G4double, G4double>(10.0*perCent, 350.0*CLHEP::GeV);
216 }                                                 236 }
217                                                   237 
218 void G4ParticleHPInelastic::BuildPhysicsTable( << 238 G4int G4ParticleHPInelastic::GetVerboseLevel() const
219 {                                                 239 {
220   if (fLock[indexP]) {                         << 240    return G4ParticleHPManager::GetInstance()->GetVerboseLevel();
221     G4AutoLock l(&theHPInelastic);             << 241 }
222     if (fLock[indexP]) {                       << 242 void G4ParticleHPInelastic::SetVerboseLevel( G4int newValue ) 
223       isFirst = true;                          << 243 {
224       fLock[indexP] = false;                   << 244    G4ParticleHPManager::GetInstance()->SetVerboseLevel(newValue);
225     }                                          << 245 }
226     l.unlock();                                << 
227   }                                            << 
228                                                   246 
229   G4int nelm = (G4int)G4Element::GetNumberOfEl << 247 void G4ParticleHPInelastic::BuildPhysicsTable(const G4ParticleDefinition& projectile) {
230   G4int n0 = numEle;                           << 
231   numEle = nelm;                               << 
232   if (!isFirst || nelm == n0) { return; }      << 
233                                                   248 
234   // extra elements should be initialized      << 249    G4ParticleHPManager* hpmanager = G4ParticleHPManager::GetInstance();
235   G4AutoLock l(&theHPInelastic);               << 
236                                                   250 
237   if (nullptr == theInelastic[indexP]) {       << 251    theInelastic = hpmanager->GetInelasticFinalStates( &projectile );
238     theInelastic[indexP] = new std::vector<G4P << 
239   }                                            << 
240                                                   252 
241   if (fManager->GetVerboseLevel() > 0 && isFir << 253    if ( G4Threading::IsMasterThread() ) {
242     fManager->DumpSetting();                   << 254 
243     G4cout << "@@@ G4ParticleHPInelastic insta << 255       if ( theInelastic == nullptr ) theInelastic = new std::vector<G4ParticleHPChannelList*>;
244      << theProjectile->GetParticleName() << "/ << 
245      << dirName << G4endl;                     << 
246   }                                            << 
247                                                   256 
248   auto table = G4Element::GetElementTable();   << 257       if ( numEle == (G4int)G4Element::GetNumberOfElements() ) return;
249   for (G4int i = n0; i < nelm; ++i) {          << 258 
250     auto clist = new G4ParticleHPChannelList(3 << 259       if ( theInelastic->size() == G4Element::GetNumberOfElements() ) {
251     theInelastic[indexP]->push_back(clist);    << 260          numEle = (G4int)G4Element::GetNumberOfElements();
252     clist->Init((*table)[i], dirName, theProje << 261          return;
253     clist->Register(new G4ParticleHPNInelastic << 262       }
254     clist->Register(new G4ParticleHPNXInelasti << 
255     clist->Register(new G4ParticleHP2NDInelast << 
256     clist->Register(new G4ParticleHP2NInelasti << 
257     clist->Register(new G4ParticleHP3NInelasti << 
258     clist->Register(new G4ParticleHPNAInelasti << 
259     clist->Register(new G4ParticleHPN3AInelast << 
260     clist->Register(new G4ParticleHP2NAInelast << 
261     clist->Register(new G4ParticleHP3NAInelast << 
262     clist->Register(new G4ParticleHPNPInelasti << 
263     clist->Register(new G4ParticleHPN2AInelast << 
264     clist->Register(new G4ParticleHP2N2AInelas << 
265     clist->Register(new G4ParticleHPNDInelasti << 
266     clist->Register(new G4ParticleHPNTInelasti << 
267     clist->Register(new G4ParticleHPNHe3Inelas << 
268     clist->Register(new G4ParticleHPND2AInelas << 
269     clist->Register(new G4ParticleHPNT2AInelas << 
270     clist->Register(new G4ParticleHP4NInelasti << 
271     clist->Register(new G4ParticleHP2NPInelast << 
272     clist->Register(new G4ParticleHP3NPInelast << 
273     clist->Register(new G4ParticleHPN2PInelast << 
274     clist->Register(new G4ParticleHPNPAInelast << 
275     clist->Register(new G4ParticleHPPInelastic << 
276     clist->Register(new G4ParticleHPDInelastic << 
277     clist->Register(new G4ParticleHPTInelastic << 
278     clist->Register(new G4ParticleHPHe3Inelast << 
279     clist->Register(new G4ParticleHPAInelastic << 
280     clist->Register(new G4ParticleHP2AInelasti << 
281     clist->Register(new G4ParticleHP3AInelasti << 
282     clist->Register(new G4ParticleHP2PInelasti << 
283     clist->Register(new G4ParticleHPPAInelasti << 
284     clist->Register(new G4ParticleHPD2AInelast << 
285     clist->Register(new G4ParticleHPT2AInelast << 
286     clist->Register(new G4ParticleHPPDInelasti << 
287     clist->Register(new G4ParticleHPPTInelasti << 
288     clist->Register(new G4ParticleHPDAInelasti << 
289 #ifdef G4VERBOSE                                  263 #ifdef G4VERBOSE
290     if (fManager->GetVerboseLevel() > 1) {     << 264       if ( G4HadronicParameters::Instance()->GetVerboseLevel() > 0 ) {
291       G4cout << "ParticleHP::Inelastic for "   << 265   hpmanager->DumpSetting();
292        << theProjectile->GetParticleName() <<  << 266   G4cout << "@@@ G4ParticleHPInelastic instantiated for particle " << projectile.GetParticleName() << " data directory variable is " << dataDirVariable << " pointing to " << dirName << G4endl;
293        << (*table)[i]->GetName() << G4endl;    << 267       }
294     }                                          << 
295 #endif                                            268 #endif
296   }                                            << 269       for (G4int i = numEle ; i < (G4int)G4Element::GetNumberOfElements(); ++i)
297   fManager->RegisterInelasticFinalStates( &pro << 270       {
298   l.unlock();                                  << 271         theInelastic->push_back( new G4ParticleHPChannelList );
                                                   >> 272         ((*theInelastic)[i])->Init((*(G4Element::GetElementTable()))[i], dirName, const_cast<G4ParticleDefinition*>(&projectile));
                                                   >> 273         G4int itry = 0;
                                                   >> 274         do
                                                   >> 275         {
                                                   >> 276           ((*theInelastic)[i])->Register( new G4ParticleHPNInelasticFS , "F01"); // has
                                                   >> 277           ((*theInelastic)[i])->Register( new G4ParticleHPNXInelasticFS , "F02");
                                                   >> 278           ((*theInelastic)[i])->Register( new G4ParticleHP2NDInelasticFS , "F03");
                                                   >> 279           ((*theInelastic)[i])->Register( new G4ParticleHP2NInelasticFS , "F04"); // has, E Done
                                                   >> 280           ((*theInelastic)[i])->Register( new G4ParticleHP3NInelasticFS , "F05"); // has, E Done
                                                   >> 281           ((*theInelastic)[i])->Register( new G4ParticleHPNAInelasticFS , "F06");
                                                   >> 282           ((*theInelastic)[i])->Register( new G4ParticleHPN3AInelasticFS , "F07");
                                                   >> 283           ((*theInelastic)[i])->Register( new G4ParticleHP2NAInelasticFS , "F08");
                                                   >> 284           ((*theInelastic)[i])->Register( new G4ParticleHP3NAInelasticFS , "F09");
                                                   >> 285           ((*theInelastic)[i])->Register( new G4ParticleHPNPInelasticFS , "F10");
                                                   >> 286           ((*theInelastic)[i])->Register( new G4ParticleHPN2AInelasticFS , "F11");
                                                   >> 287           ((*theInelastic)[i])->Register( new G4ParticleHP2N2AInelasticFS , "F12");
                                                   >> 288           ((*theInelastic)[i])->Register( new G4ParticleHPNDInelasticFS , "F13");
                                                   >> 289           ((*theInelastic)[i])->Register( new G4ParticleHPNTInelasticFS , "F14");
                                                   >> 290           ((*theInelastic)[i])->Register( new G4ParticleHPNHe3InelasticFS , "F15");
                                                   >> 291           ((*theInelastic)[i])->Register( new G4ParticleHPND2AInelasticFS , "F16");
                                                   >> 292           ((*theInelastic)[i])->Register( new G4ParticleHPNT2AInelasticFS , "F17");
                                                   >> 293           ((*theInelastic)[i])->Register( new G4ParticleHP4NInelasticFS , "F18"); // has, E Done
                                                   >> 294           ((*theInelastic)[i])->Register( new G4ParticleHP2NPInelasticFS , "F19");
                                                   >> 295           ((*theInelastic)[i])->Register( new G4ParticleHP3NPInelasticFS , "F20");
                                                   >> 296           ((*theInelastic)[i])->Register( new G4ParticleHPN2PInelasticFS , "F21");
                                                   >> 297           ((*theInelastic)[i])->Register( new G4ParticleHPNPAInelasticFS , "F22");
                                                   >> 298           ((*theInelastic)[i])->Register( new G4ParticleHPPInelasticFS , "F23");
                                                   >> 299           ((*theInelastic)[i])->Register( new G4ParticleHPDInelasticFS , "F24");
                                                   >> 300           ((*theInelastic)[i])->Register( new G4ParticleHPTInelasticFS , "F25");
                                                   >> 301           ((*theInelastic)[i])->Register( new G4ParticleHPHe3InelasticFS , "F26");
                                                   >> 302           ((*theInelastic)[i])->Register( new G4ParticleHPAInelasticFS , "F27");
                                                   >> 303           ((*theInelastic)[i])->Register( new G4ParticleHP2AInelasticFS , "F28");
                                                   >> 304           ((*theInelastic)[i])->Register( new G4ParticleHP3AInelasticFS , "F29");
                                                   >> 305           ((*theInelastic)[i])->Register( new G4ParticleHP2PInelasticFS , "F30");
                                                   >> 306           ((*theInelastic)[i])->Register( new G4ParticleHPPAInelasticFS , "F31");
                                                   >> 307           ((*theInelastic)[i])->Register( new G4ParticleHPD2AInelasticFS , "F32");
                                                   >> 308           ((*theInelastic)[i])->Register( new G4ParticleHPT2AInelasticFS , "F33");
                                                   >> 309           ((*theInelastic)[i])->Register( new G4ParticleHPPDInelasticFS , "F34");
                                                   >> 310           ((*theInelastic)[i])->Register( new G4ParticleHPPTInelasticFS , "F35");
                                                   >> 311           ((*theInelastic)[i])->Register( new G4ParticleHPDAInelasticFS , "F36");
                                                   >> 312           ((*theInelastic)[i])->RestartRegistration();
                                                   >> 313           itry++;
                                                   >> 314         }
                                                   >> 315         while( !((*theInelastic)[i])->HasDataInAnyFinalState() && itry < 6 ); // Loop checking, 11.05.2015, T. Koi
                                                   >> 316            // 6 is corresponding to the value(5) of G4ParticleHPChannel. TK  
                                                   >> 317 
                                                   >> 318         if ( itry == 6 ) {
                                                   >> 319            // No Final State at all.
                                                   >> 320 #ifdef G4VERBOSE
                                                   >> 321            if ( G4ParticleHPManager::GetInstance()->GetVerboseLevel() > 1 &&
                                                   >> 322     G4HadronicParameters::Instance()->GetVerboseLevel() > 0 ) {
                                                   >> 323               G4cout << "ParticleHP::Inelastic for " << projectile.GetParticleName() << ". Do not know what to do with element of \"" << (*(G4Element::GetElementTable()))[i]->GetName() << "\"." << G4endl;
                                                   >> 324               G4cout << "The components of the element are" << G4endl;
                                                   >> 325               for ( G4int ii = 0 ; ii < (G4int)( (*(G4Element::GetElementTable()))[i]->GetNumberOfIsotopes() ) ; ++ii ) { 
                                                   >> 326            G4cout << " Z: " << (*(G4Element::GetElementTable()))[i]->GetIsotope( ii )->GetZ() << ", A: " << (*(G4Element::GetElementTable()))[i]->GetIsotope( ii )->GetN() << G4endl;
                                                   >> 327               }
                                                   >> 328               G4cout << "No possible final state data of the element is found in " << dataDirVariable << "." << G4endl;
                                                   >> 329            }
                                                   >> 330 #endif
                                                   >> 331         }
                                                   >> 332       }
                                                   >> 333       hpmanager->RegisterInelasticFinalStates( &projectile , theInelastic );
                                                   >> 334    }
                                                   >> 335    numEle = (G4int)G4Element::GetNumberOfElements();
299 }                                                 336 }
300                                                   337 
301 void G4ParticleHPInelastic::ModelDescription(s    338 void G4ParticleHPInelastic::ModelDescription(std::ostream& outFile) const
302 {                                                 339 {
303   outFile << "High Precision (HP) model for in << 340    outFile << "Extension of High Precision model for inelastic reaction of proton,\n"
304     << theProjectile->GetParticleName() << " b << 341            << "deuteron, triton, He3 and alpha below 20MeV\n";
305 }                                                 342 }
306                                                   343