Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/hadronic/cross_sections/src/G4ChipsKaonPlusInelasticXS.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/G4ChipsKaonPlusInelasticXS.cc (Version 11.3.0) and /processes/hadronic/cross_sections/src/G4ChipsKaonPlusInelasticXS.cc (Version 9.6.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27 // The lust update: M.V. Kossov, CERN/ITEP(Mos     27 // The lust update: M.V. Kossov, CERN/ITEP(Moscow) 17-June-02
                                                   >>  28 // GEANT4 tag $Name: not supported by cvs2svn $
 28 //                                                 29 //
 29 //                                                 30 //
 30 // G4 Physics class: G4QKaonPlusNuclearCrossSe     31 // G4 Physics class: G4QKaonPlusNuclearCrossSection for gamma+A cross sections
 31 // Created: M.V. Kossov, CERN/ITEP(Moscow), 20     32 // Created: M.V. Kossov, CERN/ITEP(Moscow), 20-Dec-03
 32 // The last update: M.V. Kossov, CERN/ITEP (Mo     33 // The last update: M.V. Kossov, CERN/ITEP (Moscow) 15-Feb-04
 33 //                                                 34 //
 34 // -------------------------------------------     35 // --------------------------------------------------------------------------------
 35 // Short description: Cross-sections extracted     36 // Short description: Cross-sections extracted from the CHIPS package for 
 36 // kaon(minus)-nuclear interactions. Author: M     37 // kaon(minus)-nuclear interactions. Author: M. Kossov
 37 // -------------------------------------------     38 // -------------------------------------------------------------------------------------
 38 //                                                 39 //
 39                                                    40 
 40 #include "G4ChipsKaonPlusInelasticXS.hh"           41 #include "G4ChipsKaonPlusInelasticXS.hh"
 41 #include "G4SystemOfUnits.hh"                      42 #include "G4SystemOfUnits.hh"
 42 #include "G4DynamicParticle.hh"                    43 #include "G4DynamicParticle.hh"
 43 #include "G4ParticleDefinition.hh"                 44 #include "G4ParticleDefinition.hh"
 44 #include "G4KaonPlus.hh"                           45 #include "G4KaonPlus.hh"
 45 #include "G4Proton.hh"                             46 #include "G4Proton.hh"
 46 #include "G4PionPlus.hh"                           47 #include "G4PionPlus.hh"
 47 #include "G4AutoLock.hh"                       << 
 48                                                    48 
 49 // factory                                         49 // factory
 50 #include "G4CrossSectionFactory.hh"                50 #include "G4CrossSectionFactory.hh"
 51 //                                                 51 //
 52 G4_DECLARE_XS_FACTORY(G4ChipsKaonPlusInelastic     52 G4_DECLARE_XS_FACTORY(G4ChipsKaonPlusInelasticXS);
 53                                                    53 
 54 namespace {                                    << 
 55     const G4double THmin=27.;     // default m << 
 56     const G4double THmiG=THmin*.001; // minimu << 
 57     const G4double dP=10.;        // step for  << 
 58     const G4double dPG=dP*.001;   // step for  << 
 59     const G4int    nL=105;        // A#of LEN  << 
 60     const G4double Pmin=THmin+(nL-1)*dP; // mi << 
 61     const G4double Pmax=227000.;  // maxP for  << 
 62     const G4int    nH=224;        // A#of HEN  << 
 63     const G4double milP=std::log(Pmin);// Low  << 
 64     const G4double malP=std::log(Pmax);// High << 
 65     const G4double dlP=(malP-milP)/(nH-1); //  << 
 66     const G4double milPG=std::log(.001*Pmin);/ << 
 67     const G4double third=1./3.;                << 
 68     G4Mutex initM = G4MUTEX_INITIALIZER;       << 
 69     G4double prM;// = G4Proton::Proton()->GetP << 
 70     G4double piM;// = G4PionPlus::PionPlus()-> << 
 71     G4double pM;// =  G4KaonPlus::KaonPlus()-> << 
 72     G4double tpM;//= pM+pM;   // Doubled proje << 
 73 }                                              << 
 74                                                    54 
 75 G4ChipsKaonPlusInelasticXS::G4ChipsKaonPlusIne     55 G4ChipsKaonPlusInelasticXS::G4ChipsKaonPlusInelasticXS():G4VCrossSectionDataSet(Default_Name())
 76 {                                                  56 {
 77   G4AutoLock l(&initM);                        << 
 78   prM = G4Proton::Proton()->GetPDGMass(); // P << 
 79   piM = G4PionPlus::PionPlus()->GetPDGMass()+. << 
 80   pM  = G4KaonPlus::KaonPlus()->GetPDGMass();  << 
 81   tpM = pM+pM;   // Doubled projectile mass (M << 
 82   l.unlock();                                  << 
 83   // Initialization of the                         57   // Initialization of the
 84   lastLEN=0; // Pointer to the lastArray of Lo     58   lastLEN=0; // Pointer to the lastArray of LowEn CS
 85   lastHEN=0; // Pointer to the lastArray of Hi     59   lastHEN=0; // Pointer to the lastArray of HighEn CS
 86   lastN=0;   // The last N of calculated nucle     60   lastN=0;   // The last N of calculated nucleus
 87   lastZ=0;   // The last Z of calculated nucle     61   lastZ=0;   // The last Z of calculated nucleus
 88   lastP=0.;  // Last used in cross section Mom     62   lastP=0.;  // Last used in cross section Momentum
 89   lastTH=0.; // Last threshold momentum            63   lastTH=0.; // Last threshold momentum
 90   lastCS=0.; // Last value of the Cross Sectio     64   lastCS=0.; // Last value of the Cross Section
 91   lastI=0;   // The last position in the DAMDB     65   lastI=0;   // The last position in the DAMDB
 92   LEN = new std::vector<G4double*>;                66   LEN = new std::vector<G4double*>;
 93   HEN = new std::vector<G4double*>;                67   HEN = new std::vector<G4double*>;
 94 }                                                  68 }
 95                                                    69 
 96 G4ChipsKaonPlusInelasticXS::~G4ChipsKaonPlusIn     70 G4ChipsKaonPlusInelasticXS::~G4ChipsKaonPlusInelasticXS()
 97 {                                                  71 {
 98   std::size_t lens=LEN->size();                <<  72   G4int lens=LEN->size();
 99   for(std::size_t i=0; i<lens; ++i) delete[] ( <<  73   for(G4int i=0; i<lens; ++i) delete[] (*LEN)[i];
100   delete LEN;                                      74   delete LEN;
101                                                    75 
102   std::size_t hens=HEN->size();                <<  76   G4int hens=HEN->size();
103   for(std::size_t i=0; i<hens; ++i) delete[] ( <<  77   for(G4int i=0; i<hens; ++i) delete[] (*HEN)[i];
104   delete HEN;                                      78   delete HEN;
105 }                                                  79 }
106                                                    80 
107 void                                           << 
108 G4ChipsKaonPlusInelasticXS::CrossSectionDescri << 
109 {                                              << 
110     outFile << "G4ChipsKaonPlusInelasticXS pro << 
111             << "section for K+ nucleus scatter << 
112             << "momentum. The cross section is << 
113             << "CHIPS parameterization of cros << 
114 }                                              << 
115                                                    81 
116 G4bool G4ChipsKaonPlusInelasticXS::IsIsoApplic <<  82 G4bool G4ChipsKaonPlusInelasticXS::IsIsoApplicable(const G4DynamicParticle* Pt, G4int, G4int,    
117          const G4Element*,                         83          const G4Element*,
118          const G4Material*)                        84          const G4Material*)
119 {                                                  85 {
120   return true;                                 <<  86   G4ParticleDefinition* particle = Pt->GetDefinition();
                                                   >>  87   if (particle ==       G4KaonPlus::KaonPlus()      ) return true;
                                                   >>  88   return false;
121 }                                                  89 }
122                                                    90 
123                                                    91 
124 // The main member function giving the collisi     92 // The main member function giving the collision cross section (P is in IU, CS is in mb)
125 // Make pMom in independent units ! (Now it is     93 // Make pMom in independent units ! (Now it is MeV)
126 G4double G4ChipsKaonPlusInelasticXS::GetIsoCro     94 G4double G4ChipsKaonPlusInelasticXS::GetIsoCrossSection(const G4DynamicParticle* Pt, G4int tgZ, G4int A,  
127               const G4Isotope*,                    95               const G4Isotope*,
128               const G4Element*,                    96               const G4Element*,
129               const G4Material*)                   97               const G4Material*)
130 {                                                  98 {
131   G4double pMom=Pt->GetTotalMomentum();            99   G4double pMom=Pt->GetTotalMomentum();
132   G4int tgN = A - tgZ;                            100   G4int tgN = A - tgZ;
133                                                   101   
134   return GetChipsCrossSection(pMom, tgZ, tgN,     102   return GetChipsCrossSection(pMom, tgZ, tgN, 321);
135 }                                                 103 }
136                                                   104 
137 G4double G4ChipsKaonPlusInelasticXS::GetChipsC    105 G4double G4ChipsKaonPlusInelasticXS::GetChipsCrossSection(G4double pMom, G4int tgZ, G4int tgN, G4int )
138 {                                                 106 {
                                                   >> 107   static G4int j;                      // A#0f Z/N-records already tested in AMDB
                                                   >> 108   static std::vector <G4int>    colN;  // Vector of N for calculated nuclei (isotops)
                                                   >> 109   static std::vector <G4int>    colZ;  // Vector of Z for calculated nuclei (isotops)
                                                   >> 110   static std::vector <G4double> colP;  // Vector of last momenta for the reaction
                                                   >> 111   static std::vector <G4double> colTH; // Vector of energy thresholds for the reaction
                                                   >> 112   static std::vector <G4double> colCS; // Vector of last cross sections for the reaction
                                                   >> 113   // ***---*** End of the mandatory Static Definitions of the Associative Memory ***---***
139                                                   114 
140   G4bool in=false;                     // By d    115   G4bool in=false;                     // By default the isotope must be found in the AMDB
141   if(tgN!=lastN || tgZ!=lastZ)         // The     116   if(tgN!=lastN || tgZ!=lastZ)         // The nucleus was not the last used isotope
142   {                                               117   {
143     in = false;                        // By d    118     in = false;                        // By default the isotope haven't be found in AMDB  
144     lastP   = 0.;                      // New     119     lastP   = 0.;                      // New momentum history (nothing to compare with)
145     lastN   = tgN;                     // The     120     lastN   = tgN;                     // The last N of the calculated nucleus
146     lastZ   = tgZ;                     // The     121     lastZ   = tgZ;                     // The last Z of the calculated nucleus
147     lastI   = (G4int)colN.size();      // Size << 122     lastI   = colN.size();             // Size of the Associative Memory DB in the heap
148     j  = 0;                            // A#0f    123     j  = 0;                            // A#0f records found in DB for this projectile
149                                                   124 
150     if(lastI) for(G4int i=0; i<lastI; ++i) //  << 125     if(lastI) for(G4int i=0; i<lastI; i++) // AMDB exists, try to find the (Z,N) isotope
151     {                                             126     {
152       if(colN[i]==tgN && colZ[i]==tgZ) // Try     127       if(colN[i]==tgN && colZ[i]==tgZ) // Try the record "i" in the AMDB
153       {                                           128       {
154         lastI=i;                       // Reme    129         lastI=i;                       // Remember the index for future fast/last use
155         lastTH =colTH[i];              // The     130         lastTH =colTH[i];              // The last THreshold (A-dependent)
156                                                   131 
157         if(pMom<=lastTH)                          132         if(pMom<=lastTH)
158         {                                         133         {
159           return 0.;                   // Ener    134           return 0.;                   // Energy is below the Threshold value
160         }                                         135         }
161         lastP  =colP [i];              // Last    136         lastP  =colP [i];              // Last Momentum  (A-dependent)
162         lastCS =colCS[i];              // Last    137         lastCS =colCS[i];              // Last CrossSect (A-dependent)
163         in = true;                     // This    138         in = true;                     // This is the case when the isotop is found in DB
164         // Momentum pMom is in IU ! @@ Units      139         // Momentum pMom is in IU ! @@ Units
165         lastCS=CalculateCrossSection(-1,j,321,    140         lastCS=CalculateCrossSection(-1,j,321,lastZ,lastN,pMom); // read & update
166                                                   141 
167         if(lastCS<=0. && pMom>lastTH)  // Corr    142         if(lastCS<=0. && pMom>lastTH)  // Correct the threshold (@@ No intermediate Zeros)
168         {                                         143         {
169           lastCS=0.;                              144           lastCS=0.;
170           lastTH=pMom;                            145           lastTH=pMom;
171         }                                         146         }
172         break;                         // Go o    147         break;                         // Go out of the LOOP
173       }                                           148       }
174       j++;                             // Incr    149       j++;                             // Increment a#0f records found in DB
175     }                                             150     }
176     if(!in)                            // This    151     if(!in)                            // This isotope has not been calculated previously
177     {                                             152     {
178       //!!The slave functions must provide cro    153       //!!The slave functions must provide cross-sections in millibarns (mb) !! (not in IU)
179       lastCS=CalculateCrossSection(0,j,321,las    154       lastCS=CalculateCrossSection(0,j,321,lastZ,lastN,pMom); //calculate & create
180                                                   155 
181       //if(lastCS>0.)                   // It     156       //if(lastCS>0.)                   // It means that the AMBD was initialized
182       //{                                         157       //{
183                                                   158 
184       lastTH = 0; //ThresholdEnergy(tgZ, tgN);    159       lastTH = 0; //ThresholdEnergy(tgZ, tgN); // The Threshold Energy which is now the last
185         colN.push_back(tgN);                      160         colN.push_back(tgN);
186         colZ.push_back(tgZ);                      161         colZ.push_back(tgZ);
187         colP.push_back(pMom);                     162         colP.push_back(pMom);
188         colTH.push_back(lastTH);                  163         colTH.push_back(lastTH);
189         colCS.push_back(lastCS);                  164         colCS.push_back(lastCS);
190       //} // M.K. Presence of H1 with high thr    165       //} // M.K. Presence of H1 with high threshold breaks the syncronization
191       return lastCS*millibarn;                    166       return lastCS*millibarn;
192     } // End of creation of the new set of par    167     } // End of creation of the new set of parameters
193     else                                          168     else
194     {                                             169     {
195       colP[lastI]=pMom;                           170       colP[lastI]=pMom;
196       colCS[lastI]=lastCS;                        171       colCS[lastI]=lastCS;
197     }                                             172     }
198   } // End of parameters udate                    173   } // End of parameters udate
199   else if(pMom<=lastTH)                           174   else if(pMom<=lastTH)
200   {                                               175   {
201     return 0.;                         // Mome    176     return 0.;                         // Momentum is below the Threshold Value -> CS=0
202   }                                               177   }
203   else                                 // It i    178   else                                 // It is the last used -> use the current tables
204   {                                               179   {
205     lastCS=CalculateCrossSection(1,j,321,lastZ    180     lastCS=CalculateCrossSection(1,j,321,lastZ,lastN,pMom); // Only read and UpdateDB
206     lastP=pMom;                                   181     lastP=pMom;
207   }                                               182   }
208   return lastCS*millibarn;                        183   return lastCS*millibarn;
209 }                                                 184 }
210                                                   185 
211 // The main member function giving the gamma-A    186 // The main member function giving the gamma-A cross section (E in GeV, CS in mb)
212 G4double G4ChipsKaonPlusInelasticXS::Calculate    187 G4double G4ChipsKaonPlusInelasticXS::CalculateCrossSection(G4int F, G4int I,
213                                         G4int,    188                                         G4int, G4int targZ, G4int targN, G4double Momentum)
214 {                                                 189 {
                                                   >> 190   static const G4double THmin=27.;     // default minimum Momentum (MeV/c) Threshold
                                                   >> 191   static const G4double THmiG=THmin*.001; // minimum Momentum (GeV/c) Threshold
                                                   >> 192   static const G4double dP=10.;        // step for the LEN (Low ENergy) table MeV/c
                                                   >> 193   static const G4double dPG=dP*.001;   // step for the LEN (Low ENergy) table GeV/c
                                                   >> 194   static const G4int    nL=105;        // A#of LEN points in E (step 10 MeV/c)
                                                   >> 195   static const G4double Pmin=THmin+(nL-1)*dP; // minP for the HighE part with safety
                                                   >> 196   static const G4double Pmax=227000.;  // maxP for the HEN (High ENergy) part 227 GeV
                                                   >> 197   static const G4int    nH=224;        // A#of HEN points in lnE
                                                   >> 198   static const G4double milP=std::log(Pmin);// Low logarithm energy for the HEN part
                                                   >> 199   static const G4double malP=std::log(Pmax);// High logarithm energy (each 2.75 percent)
                                                   >> 200   static const G4double dlP=(malP-milP)/(nH-1); // Step in log energy in the HEN part
                                                   >> 201   static const G4double milPG=std::log(.001*Pmin);// Low logarithmEnergy for HEN part GeV/c
                                                   >> 202 
                                                   >> 203   G4double sigma=0.;
                                                   >> 204   if(F&&I) sigma=0.;                   // @@ *!* Fake line *!* to use F & I !!!Temporary!!!
215   G4double A=targN+targZ;              // A of    205   G4double A=targN+targZ;              // A of the target
216                                                   206 
217   if(F<=0)                             // This    207   if(F<=0)                             // This isotope was not the last used isotop
218   {                                               208   {
219     if(F<0)                            // This    209     if(F<0)                            // This isotope was found in DAMDB =-----=> RETRIEVE
220     {                                             210     {
221       G4int sync=(G4int)LEN->size();           << 211       G4int sync=LEN->size();
222       if(sync<=I) G4cerr<<"*!*G4ChipsKPlusNucl    212       if(sync<=I) G4cerr<<"*!*G4ChipsKPlusNuclCS::CalcCrosSect:Sync="<<sync<<"<="<<I<<G4endl;
223       lastLEN=(*LEN)[I];               // Poin    213       lastLEN=(*LEN)[I];               // Pointer to prepared LowEnergy cross sections
224       lastHEN=(*HEN)[I];               // Poin    214       lastHEN=(*HEN)[I];               // Pointer to prepared High Energy cross sections
225     }                                             215     }
226     else                               // This    216     else                               // This isotope wasn't calculated before => CREATE
227     {                                             217     {
228       lastLEN = new G4double[nL];      // Allo    218       lastLEN = new G4double[nL];      // Allocate memory for the new LEN cross sections
229       lastHEN = new G4double[nH];      // Allo    219       lastHEN = new G4double[nH];      // Allocate memory for the new HEN cross sections
230       // --- Instead of making a separate func    220       // --- Instead of making a separate function ---
231       G4double P=THmiG;                // Tabl    221       G4double P=THmiG;                // Table threshold in GeV/c
232       for(G4int k=0; k<nL; k++)                   222       for(G4int k=0; k<nL; k++)
233       {                                           223       {
234         lastLEN[k] = CrossSectionLin(targZ, ta    224         lastLEN[k] = CrossSectionLin(targZ, targN, P);
235         P+=dPG;                                   225         P+=dPG;
236       }                                           226       }
237       G4double lP=milPG;                          227       G4double lP=milPG;
238       for(G4int n=0; n<nH; n++)                   228       for(G4int n=0; n<nH; n++)
239       {                                           229       {
240         lastHEN[n] = CrossSectionLog(targZ, ta    230         lastHEN[n] = CrossSectionLog(targZ, targN, lP);
241         lP+=dlP;                                  231         lP+=dlP;
242       }                                           232       }
243       // --- End of possible separate function    233       // --- End of possible separate function
244       // *** The synchronization check ***        234       // *** The synchronization check ***
245       G4int sync=(G4int)LEN->size();           << 235       G4int sync=LEN->size();
246       if(sync!=I)                                 236       if(sync!=I)
247       {                                           237       {
248         G4cerr<<"***G4ChipsKPlusNuclCS::CalcCr    238         G4cerr<<"***G4ChipsKPlusNuclCS::CalcCrossSect: Sinc="<<sync<<"#"<<I<<", Z=" <<targZ
249               <<", N="<<targN<<", F="<<F<<G4en    239               <<", N="<<targN<<", F="<<F<<G4endl;
250         //G4Exception("G4PiMinusNuclearCS::Cal    240         //G4Exception("G4PiMinusNuclearCS::CalculateCS:","39",FatalException,"DBoverflow");
251       }                                           241       }
252       LEN->push_back(lastLEN);         // reme    242       LEN->push_back(lastLEN);         // remember the Low Energy Table
253       HEN->push_back(lastHEN);         // reme    243       HEN->push_back(lastHEN);         // remember the High Energy Table
254     } // End of creation of the new set of par    244     } // End of creation of the new set of parameters
255   } // End of parameters udate                    245   } // End of parameters udate
256   // =--------------------------= NOW the Magi    246   // =--------------------------= NOW the Magic Formula =---------------------------------=
257                                                   247 
258   G4double sigma;                              << 
259   if (Momentum<lastTH) return 0.;      // It m    248   if (Momentum<lastTH) return 0.;      // It must be already checked in the interface class
260   else if (Momentum<Pmin)              // Low     249   else if (Momentum<Pmin)              // Low Energy region
261   {                                               250   {
262     if(A<=1. && Momentum < 600.) sigma=0.; //     251     if(A<=1. && Momentum < 600.) sigma=0.; // Approximation tot/el uncertainty
263     else sigma=EquLinearFit(Momentum,nL,THmin,    252     else sigma=EquLinearFit(Momentum,nL,THmin,dP,lastLEN);
264   }                                               253   }
265   else if (Momentum<Pmax)              // High    254   else if (Momentum<Pmax)              // High Energy region
266   {                                               255   {
267     G4double lP=std::log(Momentum);               256     G4double lP=std::log(Momentum);
268     sigma=EquLinearFit(lP,nH,milP,dlP,lastHEN)    257     sigma=EquLinearFit(lP,nH,milP,dlP,lastHEN);
269   }                                               258   }
270   else                                 // UHE     259   else                                 // UHE region (calculation, not frequent)
271   {                                               260   {
272     G4double P=0.001*Momentum;         // Appr    261     G4double P=0.001*Momentum;         // Approximation formula is for P in GeV/c
273     sigma=CrossSectionFormula(targZ, targN, P,    262     sigma=CrossSectionFormula(targZ, targN, P, std::log(P));
274   }                                               263   }
275   if(sigma<0.) return 0.;                         264   if(sigma<0.) return 0.;
276   return sigma;                                   265   return sigma;
277 }                                                 266 }
278                                                   267 
279 // Electromagnetic momentum-threshold (in MeV/    268 // Electromagnetic momentum-threshold (in MeV/c) 
280 G4double G4ChipsKaonPlusInelasticXS::Threshold    269 G4double G4ChipsKaonPlusInelasticXS::ThresholdMomentum(G4int tZ, G4int tN)
281 {                                                 270 {
                                                   >> 271   static const G4double third=1./3.;
                                                   >> 272   static const G4double prM = G4Proton::Proton()->GetPDGMass(); // Proton mass in MeV
                                                   >> 273   static const G4double piM = G4PionPlus::PionPlus()->GetPDGMass()+.1; // Pion mass in MeV+Safety (WP)??
                                                   >> 274   static const G4double pM =  G4KaonPlus::KaonPlus()->GetPDGMass(); // Projectile mass in MeV
                                                   >> 275   static const G4double tpM= pM+pM;   // Doubled projectile mass (MeV)
282   G4double tA=tZ+tN;                              276   G4double tA=tZ+tN;
283   if(tZ<.99 || tN<0.) return 0.;                  277   if(tZ<.99 || tN<0.) return 0.;
284   G4double tM=931.5*tA;                           278   G4double tM=931.5*tA;
285   G4double dE=piM;                    // At le    279   G4double dE=piM;                    // At least one Pi0 must be created
286   if(tZ==1 && tN==0) tM=prM;          // A thr    280   if(tZ==1 && tN==0) tM=prM;          // A threshold on the free proton
287   else dE=tZ/(1.+std::pow(tA,third)); // Safet    281   else dE=tZ/(1.+std::pow(tA,third)); // Safety for diffused edge of the nucleus (QE)
288   //G4double dE=1.263*tZ/(1.+std::pow(tA,third    282   //G4double dE=1.263*tZ/(1.+std::pow(tA,third));
289   G4double T=dE+dE*(dE/2+pM)/tM;                  283   G4double T=dE+dE*(dE/2+pM)/tM;
290   return std::sqrt(T*(tpM+T));                    284   return std::sqrt(T*(tpM+T));
291 }                                                 285 }
292                                                   286 
293 // Calculation formula for piMinus-nuclear ine    287 // Calculation formula for piMinus-nuclear inelastic cross-section (mb) (P in GeV/c)
294 G4double G4ChipsKaonPlusInelasticXS::CrossSect    288 G4double G4ChipsKaonPlusInelasticXS::CrossSectionLin(G4int tZ, G4int tN, G4double P)
295 {                                                 289 {
296   G4double lP=std::log(P);                        290   G4double lP=std::log(P);
297   return CrossSectionFormula(tZ, tN, P, lP);      291   return CrossSectionFormula(tZ, tN, P, lP);
298 }                                                 292 }
299                                                   293 
300 // Calculation formula for piMinus-nuclear ine    294 // Calculation formula for piMinus-nuclear inelastic cross-section (mb) log(P in GeV/c)
301 G4double G4ChipsKaonPlusInelasticXS::CrossSect    295 G4double G4ChipsKaonPlusInelasticXS::CrossSectionLog(G4int tZ, G4int tN, G4double lP)
302 {                                                 296 {
303   G4double P=std::exp(lP);                        297   G4double P=std::exp(lP);
304   return CrossSectionFormula(tZ, tN, P, lP);      298   return CrossSectionFormula(tZ, tN, P, lP);
305 }                                                 299 }
306 // Calculation formula for piMinus-nuclear ine    300 // Calculation formula for piMinus-nuclear inelastic cross-section (mb) log(P in GeV/c)
307 G4double G4ChipsKaonPlusInelasticXS::CrossSect    301 G4double G4ChipsKaonPlusInelasticXS::CrossSectionFormula(G4int tZ, G4int tN,
308                                                   302                                                               G4double P, G4double lP)
309 {                                                 303 {
310   G4double sigma=0.;                              304   G4double sigma=0.;
311   if(tZ==1 && !tN)                        // K    305   if(tZ==1 && !tN)                        // KPlus-Proton interaction from G4QuasiElRatios
312   {                                               306   {
313     G4double ld=lP-3.5;                           307     G4double ld=lP-3.5;
314     G4double ld2=ld*ld;                           308     G4double ld2=ld*ld;
315     G4double sp=std::sqrt(P);                     309     G4double sp=std::sqrt(P);
316     G4double p2=P*P;                              310     G4double p2=P*P;
317     G4double p4=p2*p2;                            311     G4double p4=p2*p2;
318     G4double lm=P-1.;                             312     G4double lm=P-1.;
319     G4double md=lm*lm+.372;                       313     G4double md=lm*lm+.372;
320     G4double El=(.0557*ld2+2.23)/(1.-.7/sp+.1/    314     G4double El=(.0557*ld2+2.23)/(1.-.7/sp+.1/p4);
321     G4double To=(.3*ld2+19.5)/(1.+.46/sp+1.6/p    315     G4double To=(.3*ld2+19.5)/(1.+.46/sp+1.6/p4);
322     sigma=(To-El)+.6/md;                          316     sigma=(To-El)+.6/md;
323   }                                               317   }
324   else if(tZ<97 && tN<152)                // G    318   else if(tZ<97 && tN<152)                // General solution
325   {                                               319   {
326     G4double p2=P*P;                              320     G4double p2=P*P;
327     G4double p4=p2*p2;                            321     G4double p4=p2*p2;
328     G4double a=tN+tZ;                       //    322     G4double a=tN+tZ;                       // A of the target
329     G4double al=std::log(a);                      323     G4double al=std::log(a);
330     G4double sa=std::sqrt(a);                     324     G4double sa=std::sqrt(a);
331     G4double asa=a*sa;                            325     G4double asa=a*sa;
332     G4double a2=a*a;                              326     G4double a2=a*a;
333     G4double a3=a2*a;                             327     G4double a3=a2*a;
334     G4double a4=a2*a2;                            328     G4double a4=a2*a2;
335     G4double a8=a4*a4;                            329     G4double a8=a4*a4;
336     G4double a12=a8*a4;                           330     G4double a12=a8*a4;
337     G4double f=.6;                       // De    331     G4double f=.6;                       // Default values for deutrons
338     G4double r=.5;                                332     G4double r=.5;
339     G4double gg=3.7;                              333     G4double gg=3.7;
340     G4double c=36.;                               334     G4double c=36.;
341     G4double ss=3.5;                              335     G4double ss=3.5;
342     G4double t=3.;                                336     G4double t=3.;
343     G4double u=.44;                               337     G4double u=.44;
344     G4double v=5.E-9;                             338     G4double v=5.E-9;
345     if(tZ>1 && tN>1)                     // Mo    339     if(tZ>1 && tN>1)                     // More than deuteron
346     {                                             340     {
347       f=1.;                                       341       f=1.;
348       r=1./(1.+.007*a2);                          342       r=1./(1.+.007*a2);
349       gg=4.2;                                     343       gg=4.2;
350       c=52.*std::exp(al*.6)*(1.+95./a2)/(1.+9.    344       c=52.*std::exp(al*.6)*(1.+95./a2)/(1.+9./a)/(1.+46./a2);
351       ss=(40.+.14*a)/(1.+12./a);                  345       ss=(40.+.14*a)/(1.+12./a);
352       G4double y=std::exp(al*1.7);                346       G4double y=std::exp(al*1.7);
353       t=.185*y/(1.+.00012*y);                     347       t=.185*y/(1.+.00012*y);
354       u=(1.+80./asa)/(1.+200./asa);               348       u=(1.+80./asa)/(1.+200./asa);
355       v=(1.+3.E-6*a4*(1.+6.E-7*a3+4.E10/a12))/    349       v=(1.+3.E-6*a4*(1.+6.E-7*a3+4.E10/a12))/a3/20000.;
356     }                                             350     }
357     G4double d=lP-gg;                             351     G4double d=lP-gg;
358     G4double w=P-1.;                              352     G4double w=P-1.;
359     G4double rD=ss/(w*w+.36);                     353     G4double rD=ss/(w*w+.36);
360     G4double h=P-.44;                             354     G4double h=P-.44;
361     G4double rR=t/(h*h+u*u);                      355     G4double rR=t/(h*h+u*u);
362     sigma=(f*d*d+c)/(1.+r/std::sqrt(P)+1./p4)+    356     sigma=(f*d*d+c)/(1.+r/std::sqrt(P)+1./p4)+(rD+rR)/(1+v/p4/p4);
363   }                                               357   }
364   else                                            358   else
365   {                                               359   {
366     G4cerr<<"-Warning-G4ChipsKaonPlusNuclearCr    360     G4cerr<<"-Warning-G4ChipsKaonPlusNuclearCroSect::CSForm:Bad A, Z="<<tZ<<", N="<<tN<<G4endl;
367     sigma=0.;                                     361     sigma=0.;
368   }                                               362   }
369   if(sigma<0.) return 0.;                         363   if(sigma<0.) return 0.;
370   return sigma;                                   364   return sigma;  
371 }                                                 365 }
372                                                   366 
373 G4double G4ChipsKaonPlusInelasticXS::EquLinear    367 G4double G4ChipsKaonPlusInelasticXS::EquLinearFit(G4double X, G4int N, G4double X0, G4double DX, G4double* Y)
374 {                                                 368 {
375   if(DX<=0. || N<2)                               369   if(DX<=0. || N<2)
376     {                                             370     {
377       G4cerr<<"***G4ChipsKaonPlusInelasticXS::    371       G4cerr<<"***G4ChipsKaonPlusInelasticXS::EquLinearFit: DX="<<DX<<", N="<<N<<G4endl;
378       return Y[0];                                372       return Y[0];
379     }                                             373     }
380                                                   374   
381   G4int    N2=N-2;                                375   G4int    N2=N-2;
382   G4double d=(X-X0)/DX;                           376   G4double d=(X-X0)/DX;
383   G4int         jj=static_cast<int>(d);        << 377   G4int         j=static_cast<int>(d);
384   if     (jj<0)  jj=0;                         << 378   if     (j<0)  j=0;
385   else if(jj>N2) jj=N2;                        << 379   else if(j>N2) j=N2;
386   d-=jj; // excess                             << 380   d-=j; // excess
387   G4double yi=Y[jj];                           << 381   G4double yi=Y[j];
388   G4double sigma=yi+(Y[jj+1]-yi)*d;            << 382   G4double sigma=yi+(Y[j+1]-yi)*d;
389                                                   383   
390   return sigma;                                   384   return sigma;
391 }                                                 385 }
392                                                   386