Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4QuasiElRatios.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28//
29// G4 Physics class: G4QuasiElRatios for N+A elastic cross sections
30// Created: M.V. Kossov, CERN/ITEP(Moscow), 10-OCT-01
31// The last update: M.V. Kossov, CERN/ITEP (Moscow) 15-Oct-06
32//
33// ----------------------------------------------------------------------
34// This class has been extracted from the CHIPS model.
35// All the dependencies on CHIPS classes have been removed.
36// Short description: Provides percentage of quasi-free and quasi-elastic
37// reactions in the inelastic reactions.
38// ----------------------------------------------------------------------
39
40
41#include "G4QuasiElRatios.hh"
43#include "G4SystemOfUnits.hh"
44#include "G4Proton.hh"
45#include "G4Neutron.hh"
46#include "G4Deuteron.hh"
47#include "G4Triton.hh"
48#include "G4He3.hh"
49#include "G4Alpha.hh"
50#include "G4ThreeVector.hh"
52#include "G4Pow.hh"
53#include "G4Log.hh"
54#include "G4Exp.hh"
55
56namespace {
57 const G4int nps=150; // Number of steps in the R(s) LinTable
58 const G4int mps=nps+1; // Number of elements in the R(s) LinTable
59 const G4double sma=150.; // The first LinTabEl(s=0)=1., s>sma -> logTab
60 const G4double ds=sma/nps; // Step of the linear Table
61 const G4int nls=100; // Number of steps in the R(lns) logTable
62 const G4int mls=nls+1; // Number of elements in the R(lns) logTable
63 const G4double lsi=5.; // The min ln(s) logTabEl(s=148.4 < sma=150.)
64 const G4double lsa=9.; // The max ln(s) logTabEl(s=148.4 - 8103. mb)
65 const G4double mi=G4Exp(lsi);// The min s of logTabEl(~ 148.4 mb)
66 const G4double min_s=G4Exp(lsa);// The max s of logTabEl(~ 8103. mb)
67 const G4double dls=(lsa-lsi)/nls;// Step of the logarithmic Table
68 const G4double edls=G4Exp(dls);// Multiplication step of the logarithmic Table
69 const G4double toler=.01; // The tolarence mb defining the same cross-section
70 const G4double C=1.246;
71 const G4double lmi=3.5; // min of (lnP-lmi)^2 parabola
72 const G4double pbe=.0557; // elastic (lnP-lmi)^2 parabola coefficient
73 const G4double pbt=.3; // total (lnP-lmi)^2 parabola coefficient
74 const G4double pmi=.1; // Below that fast LE calculation is made
75 const G4double pma=1000.; // Above that fast HE calculation is made
76 const G4int nlp=300; // Number of steps in the S(lnp) logTable(5% step)
77 const G4int mlp=nlp+1; // Number of elements in the S(lnp) logTable
78 const G4double lpi=-5.; // The min ln(p) logTabEl(p=6.7 MeV/c - 22. TeV/c)
79 const G4double lpa=10.; // The max ln(p) logTabEl(p=6.7 MeV/c - 22. TeV/c)
80 const G4double mip=G4Exp(lpi);// The min p of logTabEl(~ 6.7 MeV/c)
81 const G4double map=G4Exp(lpa);// The max p of logTabEl(~ 22. TeV)
82 const G4double dlp=(lpa-lpi)/nlp;// Step of the logarithmic Table
83 const G4double edlp=G4Exp(dlp);// Multiplication step of the logarithmic Table
84}
85
86
88{
89 vT = new std::vector<G4double*>;
90 vL = new std::vector<G4double*>;
91 vX = new std::vector<std::pair<G4double,G4double>*>;
92
93 lastSRatio=0.; // The last sigma value for which R was calculated
94 lastRRatio=0.; // The last ratio R which was calculated
95 lastARatio=0; // theLast of calculated A
96 lastHRatio=0.; // theLast of max s initialized in the LinTable
97 lastNRatio=0; // theLast of topBin number initialized in LinTable
98 lastMRatio=0.; // theLast of rel max ln(s) initialized in LogTable
99 lastKRatio=0; // theLast of topBin number initialized in LogTable
100 lastTRatio=0; // theLast of pointer to LinTable in the C++ heap
101 lastLRatio=0; // theLast of pointer to LogTable in the C++ heap
102 lastPtot=0.; // The last momentum for which XS was calculated
103 lastHtot=0; // The last projPDG for which XS was calculated
104 lastFtot=true; // The last nucleon for which XS was calculated
105 lastItot=0; // The Last index for which XS was calculated
106 lastMtot=0.; // The Last rel max ln(p) initialized in LogTable
107 lastKtot=0; // The Last topBin number initialized in LogTable
108 lastXtot = nullptr; // The Last ETPointers to LogTable in heap
109
111
113}
114
116{
117 std::vector<G4double*>::iterator pos;
118 for(pos=vT->begin(); pos<vT->end(); pos++)
119 { delete [] *pos; }
120 vT->clear();
121 delete vT;
122
123 for(pos=vL->begin(); pos<vL->end(); pos++)
124 { delete [] *pos; }
125 vL->clear();
126 delete vL;
127
128 std::vector<std::pair<G4double,G4double>*>::iterator pos2;
129 for(pos2=vX->begin(); pos2<vX->end(); pos2++)
130 { delete [] *pos2; }
131 vX->clear();
132 delete vX;
133}
134
135// Calculation of pair(QuasiFree/Inelastic,QuasiElastic/QuasiFree)
136std::pair<G4double,G4double> G4QuasiElRatios::GetRatios(G4double pIU, G4int pPDG,
137 G4int tgZ, G4int tgN)
138{
139 G4double R=0.;
140 G4double QF2In=1.; // Prototype of QuasiFree/Inel ratio for hN_tot
141 G4int tgA=tgZ+tgN;
142 if(tgA<2) return std::make_pair(QF2In,R); // No quasi-elastic on the only nucleon
143 std::pair<G4double,G4double> ElTot=GetElTot(pIU, pPDG, tgZ, tgN); // mean hN El&Tot(IU)
144 //if( ( (pPDG>999 && pIU<227.) || pIU<27.) && tgA>1) R=1.; // @@ TMP to accelerate @lowE
145 if(pPDG>999 && pIU<227. && tgZ+tgN>1) R=1.; // To accelerate @lowE
146 else if(ElTot.second>0.)
147 {
148 R=ElTot.first/ElTot.second; // El/Total ratio (does not depend on units
149 QF2In=GetQF2IN_Ratio(ElTot.second/millibarn, tgZ+tgN); // QuasiFree/Inelastic ratio
150 }
151 return std::make_pair(QF2In,R);
152}
153
154// Calculatio QasiFree/Inelastic Ratio as a function of total hN cross-section (mb) and A
155G4double G4QuasiElRatios::GetQF2IN_Ratio(G4double m_s, G4int A)
156{
157 // LogTable is created only if necessary. The ratio R(s>8100 mb) = 0 for any nuclei
158 if(m_s<toler || A<2) return 1.;
159 if(m_s>min_s) return 0.;
160
161 //if(A>238)
162 //{
163 // G4cout<<"-Warning-G4QuasiElRatio::GetQF2IN_Ratio:A="<<A<<">238, return zero"<<G4endl;
164 // return 0.;
165 //}
166 G4int nDB=vARatio.size(); // A number of nuclei already initialized in AMDB
167 if(nDB && lastARatio==A && m_s==lastSRatio) return lastRRatio; // VI do not use tolerance
168 G4bool found=false;
169 G4int i=-1;
170 if(nDB) for (i=0; i<nDB; i++) if(A==vARatio[i]) // Search for this A in AMDB
171 {
172 found=true; // The A value is found
173 break;
174 }
175 if(!nDB || !found) // Create new line in the AMDB
176 {
177 lastARatio = A;
178 lastTRatio = new G4double[mps]; // Create the linear Table
179 lastNRatio = static_cast<int>(m_s/ds)+1; // MaxBin to be initialized
180 if(lastNRatio>nps)
181 {
182 lastNRatio=nps;
183 lastHRatio=sma;
184 }
185 else lastHRatio = lastNRatio*ds; // Calculate max initialized s for LinTab
186 G4double sv=0;
187 lastTRatio[0]=1.;
188 for(G4int j=1; j<=lastNRatio; j++) // Calculate LogTab values
189 {
190 sv+=ds;
191 lastTRatio[j]=CalcQF2IN_Ratio(sv,A);
192 }
193 lastLRatio=new G4double[mls]; // Create the logarithmic Table
194 if(m_s>sma) // Initialize the logarithmic Table
195 {
196 G4double ls=G4Log(m_s);
197 lastKRatio = static_cast<int>((ls-lsi)/dls)+1; // MaxBin to be initialized in LogTaB
198 if(lastKRatio>nls)
199 {
200 lastKRatio=nls;
201 lastMRatio=lsa-lsi;
202 }
203 else lastMRatio = lastKRatio*dls; // Calculate max initialized ln(s)-lsi for LogTab
204 sv=mi;
205 for(G4int j=0; j<=lastKRatio; j++) // Calculate LogTab values
206 {
207 lastLRatio[j]=CalcQF2IN_Ratio(sv,A);
208 if(j!=lastKRatio) sv*=edls;
209 }
210 }
211 else // LogTab is not initialized
212 {
213 lastKRatio = 0;
214 lastMRatio = 0.;
215 }
216 i++; // Make a new record to AMDB and position on it
217 vARatio.push_back(lastARatio);
218 vHRatio.push_back(lastHRatio);
219 vNRatio.push_back(lastNRatio);
220 vMRatio.push_back(lastMRatio);
221 vKRatio.push_back(lastKRatio);
222 vT->push_back(lastTRatio);
223 vL->push_back(lastLRatio);
224 }
225 else // The A value was found in AMDB
226 {
227 lastARatio=vARatio[i];
228 lastHRatio=vHRatio[i];
229 lastNRatio=vNRatio[i];
230 lastMRatio=vMRatio[i];
231 lastKRatio=vKRatio[i];
232 lastTRatio=(*vT)[i];
233 lastLRatio=(*vL)[i];
234 if(m_s>lastHRatio) // At least LinTab must be updated
235 {
236 G4int nextN=lastNRatio+1; // The next bin to be initialized
237 if(lastNRatio<nps)
238 {
239 G4double sv=lastHRatio; // bug fix by WP
240
241 lastNRatio = static_cast<int>(m_s/ds)+1;// MaxBin to be initialized
242 if(lastNRatio>nps)
243 {
244 lastNRatio=nps;
245 lastHRatio=sma;
246 }
247 else lastHRatio = lastNRatio*ds; // Calculate max initialized s for LinTab
248
249 for(G4int j=nextN; j<=lastNRatio; j++)// Calculate LogTab values
250 {
251 sv+=ds;
252 lastTRatio[j]=CalcQF2IN_Ratio(sv,A);
253 }
254 } // End of LinTab update
255 if(lastNRatio>=nextN)
256 {
257 vHRatio[i]=lastHRatio;
258 vNRatio[i]=lastNRatio;
259 }
260 G4int nextK=lastKRatio+1;
261 if(!lastKRatio) nextK=0;
262 if(m_s>sma && lastKRatio<nls) // LogTab must be updated
263 {
264 G4double sv=G4Exp(lastMRatio+lsi); // Define starting poit (lastM will be changed)
265 G4double ls=G4Log(m_s);
266 lastKRatio = static_cast<int>((ls-lsi)/dls)+1; // MaxBin to be initialized in LogTaB
267 if(lastKRatio>nls)
268 {
269 lastKRatio=nls;
270 lastMRatio=lsa-lsi;
271 }
272 else lastMRatio = lastKRatio*dls; // Calculate max initialized ln(s)-lsi for LogTab
273 for(G4int j=nextK; j<=lastKRatio; j++)// Calculate LogTab values
274 {
275 sv*=edls;
276 lastLRatio[j]=CalcQF2IN_Ratio(sv,A);
277 }
278 } // End of LogTab update
279 if(lastKRatio>=nextK)
280 {
281 vMRatio[i]=lastMRatio;
282 vKRatio[i]=lastKRatio;
283 }
284 }
285 }
286 // Now one can use tabeles to calculate the value
287 if(m_s<sma) // Use linear table
288 {
289 G4int n=static_cast<int>(m_s/ds); // Low edge number of the bin
290 G4double d=m_s-n*ds; // Linear shift
291 G4double v=lastTRatio[n]; // Base
292 lastRRatio=v+d*(lastTRatio[n+1]-v)/ds; // Result
293 }
294 else // Use log table
295 {
296 G4double ls=G4Log(m_s)-lsi; // ln(s)-l_min
297 G4int n=static_cast<int>(ls/dls); // Low edge number of the bin
298 G4double d=ls-n*dls; // Log shift
299 G4double v=lastLRatio[n]; // Base
300 lastRRatio=v+d*(lastLRatio[n+1]-v)/dls; // Result
301 }
302 if(lastRRatio<0.) lastRRatio=0.;
303 if(lastRRatio>1.) lastRRatio=1.;
304 return lastRRatio;
305} // End of CalcQF2IN_Ratio
306
307// Calculatio QasiFree/Inelastic Ratio as a function of total hN cross-section and A
308G4double G4QuasiElRatios::CalcQF2IN_Ratio(G4double m_s, G4int A)
309{
310 G4double s2=m_s*m_s;
311 G4double s4=s2*s2;
312 G4double ss=std::sqrt(std::sqrt(m_s));
313 G4double P=7.48e-5*s2/(1.+8.77e12/s4/s4/s2);
314 G4double E=.2644+.016/(1.+G4Exp((29.54-m_s)/2.49));
315 G4double F=ss*.1526*G4Exp(-s2*ss*.0000859);
316 return C*G4Exp(-E*G4Pow::GetInstance()->powA(G4double(A-1.),F))/G4Pow::GetInstance()->powA(G4double(A),P);
317} // End of CalcQF2IN_Ratio
318
319// Calculatio pair(hN_el,hN_tot) (mb): p in GeV/c, index(PDG,F) (see FetchElTot)
320std::pair<G4double,G4double> G4QuasiElRatios::CalcElTot(G4double p, G4int I)
321{
322 // ---------> Each parameter set can have not more than nPoints=128 parameters
323
324 G4double El=0.; // prototype of the elastic hN cross-section
325 G4double To=0.; // prototype of the total hN cross-section
326 if(p<=0.)
327 {
328 G4cout<<"-Warning-G4QuasiElRatios::CalcElTot: p="<<p<<" is zero or negative"<<G4endl;
329 return std::make_pair(El,To);
330 }
331 if (!I) // pp/nn
332 {
333 if(p<pmi)
334 {
335 G4double p2=p*p;
336 El=1./(.00012+p2*.2);
337 To=El;
338 }
339 else if(p>pma)
340 {
341 G4double lp=G4Log(p)-lmi;
342 G4double lp2=lp*lp;
343 El=pbe*lp2+6.72;
344 To=pbt*lp2+38.2;
345 }
346 else
347 {
348 G4double p2=p*p;
349 G4double LE=1./(.00012+p2*.2);
350 G4double lp=G4Log(p)-lmi;
351 G4double lp2=lp*lp;
352 G4double rp2=1./p2;
353 El=LE+(pbe*lp2+6.72+32.6/p)/(1.+rp2/p);
354 To=LE+(pbt*lp2+38.2+52.7*rp2)/(1.+2.72*rp2*rp2);
355 }
356 }
357 else if(I==1) // np/pn
358 {
359 if(p<pmi)
360 {
361 G4double p2=p*p;
362 El=1./(.00012+p2*(.051+.1*p2));
363 To=El;
364 }
365 else if(p>pma)
366 {
367 G4double lp=G4Log(p)-lmi;
368 G4double lp2=lp*lp;
369 El=pbe*lp2+6.72;
370 To=pbt*lp2+38.2;
371 }
372 else
373 {
374 G4double p2=p*p;
375 G4double LE=1./(.00012+p2*(.051+.1*p2));
376 G4double lp=G4Log(p)-lmi;
377 G4double lp2=lp*lp;
378 G4double rp2=1./p2;
379 El=LE+(pbe*lp2+6.72+30./p)/(1.+.49*rp2/p);
380 To=LE+(pbt*lp2+38.2)/(1.+.54*rp2*rp2);
381 }
382 }
383 else if(I==2) // pimp/pipn
384 {
385 G4double lp=G4Log(p);
386 if(p<pmi)
387 {
388 G4double lr=lp+1.27;
389 El=1.53/(lr*lr+.0676);
390 To=El*3;
391 }
392 else if(p>pma)
393 {
394 G4double ld=lp-lmi;
395 G4double ld2=ld*ld;
396 G4double sp=std::sqrt(p);
397 El=pbe*ld2+2.4+7./sp;
398 To=pbt*ld2+22.3+12./sp;
399 }
400 else
401 {
402 G4double lr=lp+1.27; // p1
403 G4double LE=1.53/(lr*lr+.0676); // p2, p3
404 G4double ld=lp-lmi; // p4 (lmi=3.5)
405 G4double ld2=ld*ld;
406 G4double p2=p*p;
407 G4double p4=p2*p2;
408 G4double sp=std::sqrt(p);
409 G4double lm=lp+.36; // p5
410 G4double md=lm*lm+.04; // p6
411 G4double lh=lp-.017; // p7
412 G4double hd=lh*lh+.0025; // p8
413 El=LE+(pbe*ld2+2.4+7./sp)/(1.+.7/p4)+.6/md+.05/hd;//p9(pbe=.0557),p10,p11,p12,p13,p14
414 To=LE*3+(pbt*ld2+22.3+12./sp)/(1.+.4/p4)+1./md+.06/hd;
415 }
416 }
417 else if(I==3) // pipp/pimn
418 {
419 G4double lp=G4Log(p);
420 if(p<pmi)
421 {
422 G4double lr=lp+1.27;
423 G4double lr2=lr*lr;
424 El=13./(lr2+lr2*lr2+.0676);
425 To=El;
426 }
427 else if(p>pma)
428 {
429 G4double ld=lp-lmi;
430 G4double ld2=ld*ld;
431 G4double sp=std::sqrt(p);
432 El=pbe*ld2+2.4+6./sp;
433 To=pbt*ld2+22.3+5./sp;
434 }
435 else
436 {
437 G4double lr=lp+1.27; // p1
438 G4double lr2=lr*lr;
439 G4double LE=13./(lr2+lr2*lr2+.0676); // p2, p3
440 G4double ld=lp-lmi; // p4 (lmi=3.5)
441 G4double ld2=ld*ld;
442 G4double p2=p*p;
443 G4double p4=p2*p2;
444 G4double sp=std::sqrt(p);
445 G4double lm=lp-.32; // p5
446 G4double md=lm*lm+.0576; // p6
447 El=LE+(pbe*ld2+2.4+6./sp)/(1.+3./p4)+.7/md; // p7(pbe=.0557), p8, p9, p10, p11
448 To=LE+(pbt*ld2+22.3+5./sp)/(1.+1./p4)+.8/md;
449 }
450 }
451 else if(I==4) // Kmp/Kmn/K0p/K0n
452 {
453
454 if(p<pmi)
455 {
456 G4double psp=p*std::sqrt(p);
457 El=5.2/psp;
458 To=14./psp;
459 }
460 else if(p>pma)
461 {
462 G4double ld=G4Log(p)-lmi;
463 G4double ld2=ld*ld;
464 El=pbe*ld2+2.23;
465 To=pbt*ld2+19.5;
466 }
467 else
468 {
469 G4double ld=G4Log(p)-lmi;
470 G4double ld2=ld*ld;
471 G4double sp=std::sqrt(p);
472 G4double psp=p*sp;
473 G4double p2=p*p;
474 G4double p4=p2*p2;
475 G4double lm=p-.39;
476 G4double md=lm*lm+.000156;
477 G4double lh=p-1.;
478 G4double hd=lh*lh+.0156;
479 El=5.2/psp+(pbe*ld2+2.23)/(1.-.7/sp+.075/p4)+.004/md+.15/hd;
480 To=14./psp+(pbt*ld2+19.5)/(1.-.21/sp+.52/p4)+.006/md+.30/hd;
481 }
482 }
483 else if(I==5) // Kpp/Kpn/aKp/aKn
484 {
485 if(p<pmi)
486 {
487 G4double lr=p-.38;
488 G4double lm=p-1.;
489 G4double md=lm*lm+.372;
490 El=.7/(lr*lr+.0676)+2./md;
491 To=El+.6/md;
492 }
493 else if(p>pma)
494 {
495 G4double ld=G4Log(p)-lmi;
496 G4double ld2=ld*ld;
497 El=pbe*ld2+2.23;
498 To=pbt*ld2+19.5;
499 }
500 else
501 {
502 G4double ld=G4Log(p)-lmi;
503 G4double ld2=ld*ld;
504 G4double lr=p-.38;
505 G4double LE=.7/(lr*lr+.0676);
506 G4double sp=std::sqrt(p);
507 G4double p2=p*p;
508 G4double p4=p2*p2;
509 G4double lm=p-1.;
510 G4double md=lm*lm+.372;
511 El=LE+(pbe*ld2+2.23)/(1.-.7/sp+.1/p4)+2./md;
512 To=LE+(pbt*ld2+19.5)/(1.+.46/sp+1.6/p4)+2.6/md;
513 }
514 }
515 else if(I==6) // hyperon-N
516 {
517 if(p<pmi)
518 {
519 G4double p2=p*p;
520 El=1./(.002+p2*(.12+p2));
521 To=El;
522 }
523 else if(p>pma)
524 {
525 G4double lp=G4Log(p)-lmi;
526 G4double lp2=lp*lp;
527 G4double sp=std::sqrt(p);
528 El=(pbe*lp2+6.72)/(1.+2./sp);
529 To=(pbt*lp2+38.2+900./sp)/(1.+27./sp);
530 }
531 else
532 {
533 G4double p2=p*p;
534 G4double LE=1./(.002+p2*(.12+p2));
535 G4double lp=G4Log(p)-lmi;
536 G4double lp2=lp*lp;
537 G4double p4=p2*p2;
538 G4double sp=std::sqrt(p);
539 El=LE+(pbe*lp2+6.72+99./p2)/(1.+2./sp+2./p4);
540 To=LE+(pbt*lp2+38.2+900./sp)/(1.+27./sp+3./p4);
541 }
542 }
543 else if(I==7) // antibaryon-N
544 {
545 if(p>pma)
546 {
547 G4double lp=G4Log(p)-lmi;
548 G4double lp2=lp*lp;
549 El=pbe*lp2+6.72;
550 To=pbt*lp2+38.2;
551 }
552 else
553 {
554 G4double ye=G4Pow::GetInstance()->powA(p,1.25);
555 G4double yt=G4Pow::GetInstance()->powA(p,.35);
556 G4double lp=G4Log(p)-lmi;
557 G4double lp2=lp*lp;
558 El=80./(ye+1.)+pbe*lp2+6.72;
559 To=(80./yt+.3)/yt+pbt*lp2+38.2;
560 }
561 }
562 else
563 {
564 G4cout<<"*Error*G4QuasiElRatios::CalcElTot:ind="<<I<<" is not defined (0-7)"<<G4endl;
565 G4Exception("G4QuasiElRatios::CalcElTot:","23",FatalException,"QEcrash");
566 }
567 if(El>To) El=To;
568 return std::make_pair(El,To);
569} // End of CalcElTot
570
571// For hadron PDG with momentum Mom (GeV/c) on N (p/n) calculate <sig_el,sig_tot> pair (mb)
572std::pair<G4double,G4double> G4QuasiElRatios::GetElTotXS(G4double p, G4int PDG, G4bool F)
573{
574 G4int ind=0; // Prototype of the reaction index
575 G4bool kfl=true; // Flag of K0/aK0 oscillation
576 G4bool kf=false;
577 if(PDG==130||PDG==310)
578 {
579 kf=true;
580 if(G4UniformRand()>.5) kfl=false;
581 }
582 if ( (PDG == 2212 && F) || (PDG == 2112 && !F) ) ind=0; // pp/nn
583 else if ( (PDG == 2112 && F) || (PDG == 2212 && !F) ) ind=1; // np/pn
584 else if ( (PDG == -211 && F) || (PDG == 211 && !F) ) ind=2; // pimp/pipn
585 else if ( (PDG == 211 && F) || (PDG == -211 && !F) ) ind=3; // pipp/pimn
586 //AR-Jul2020: Extended to charmed and bottom hadrons:
587 // - treat mesons with constituent c quark or b quark as a meson with s quark (e.g. K-);
588 // - treat mesons with constituent cbar antiquark or bbar antiquark as a meson with sbar antiquark (e.g. K+);
589 // - treat all heavy baryons (i.e. hyperons, charmed and bottom baryons) as lambda;
590 // - treat all heavy anti-baryons (i.e. anti-hyperons, charmed and bottom anti-baryons) as anti-p/anti-n.
591 else if ( PDG == -321 || PDG == -311 || (kf && !kfl) || // mesons with s quark
592 PDG == 411 || PDG == 421 || PDG == 431 || // mesons with c quark
593 PDG == -521 || PDG == -511 || PDG == -531 || PDG == -541 ) ind=4; // mesons with b quark
594 else if ( PDG == 321 || PDG == 311 || (kf && kfl) || // mesons with sbar antiquark
595 PDG == -411 || PDG == -421 || PDG == -431 || // mesons with cbar antiquark
596 PDG == 521 || PDG == 511 || PDG == 531 || PDG == 541 ) ind=5; // mesons with bbar antiquark
597 else if ( PDG > 3000 && PDG < 5333 ) ind=6; // @@ for all heavy baryons - take Lambda
598 else if ( PDG > -5333 && PDG < -2000 ) ind=7; // @@ for all anti-baryons (anti-p/anti-n)
599 else {
600 G4cout<<"*Error*G4QuasiElRatios::CalcElTotXS: PDG="<<PDG
601 <<", while it is defined only for p,n,hyperons,anti-baryons,pi,K/antiK"<<G4endl;
602 G4Exception("G4QuasiElRatio::CalcElTotXS:","22",FatalException,"QEcrash");
603 }
604 return CalcElTot(p,ind);
605}
606
607// Calculatio pair(hN_el,hN_tot)(mb): p in GeV/c, F=true -> N=proton, F=false -> N=neutron
608std::pair<G4double,G4double> G4QuasiElRatios::FetchElTot(G4double p, G4int PDG, G4bool F)
609{
610 // LogTable is created only if necessary. The ratio R(s>8100 mb) = 0 for any nuclei
611 G4int nDB=vItot.size(); // A number of hadrons already initialized in AMDB
612 if(nDB && lastHtot==PDG && lastFtot==F && p>0. && p==lastPtot) return lastRtot;// VI don't use toler.
613 // if(nDB && lastH==PDG && lastF==F && p>0. && std::fabs(p-lastP)/p<toler) return lastR;
614 lastHtot=PDG;
615 lastFtot=F;
616 G4int ind=-1; // Prototipe of the index of the PDG/F combination
617 // i=0: pp(nn), i=1: np(pn), i=2: pimp(pipn), i=3: pipp(pimn), i=4: Kmp(Kmn,K0n,K0p),
618 // i=5: Kpp(Kpn,aK0n,aK0p), i=6: Hp(Hn), i=7: app(apn,ann,anp)
619 G4bool kfl=true; // Flag of K0/aK0 oscillation
620 G4bool kf=false;
621 if(PDG==130||PDG==310)
622 {
623 kf=true;
624 if(G4UniformRand()>.5) kfl=false;
625 }
626 if ( (PDG == 2212 && F) || (PDG == 2112 && !F) ) ind=0; // pp/nn
627 else if ( (PDG == 2112 && F) || (PDG == 2212 && !F) ) ind=1; // np/pn
628 else if ( (PDG == -211 && F) || (PDG == 211 && !F) ) ind=2; // pimp/pipn
629 else if ( (PDG == 211 && F) || (PDG == -211 && !F) ) ind=3; // pipp/pimn
630 //AR-Jul2020: Extended to charmed and bottom hadrons:
631 // - treat mesons with constituent c quark or b quark as a meson with s quark (e.g. K-);
632 // - treat mesons with constituent cbar antiquark or bbar antiquark as a meson with sbar antiquark (e.g. K+);
633 // - treat all heavy baryons (i.e. hyperons, charmed and bottom baryons) as lambda;
634 // - treat all heavy anti-baryons (i.e. anti-hyperons, charmed and bottom anti-baryons) as anti-p/anti-n.
635 else if ( PDG == -321 || PDG == -311 || (kf && !kfl) || // mesons with s quark
636 PDG == 411 || PDG == 421 || PDG == 431 || // mesons with c quark
637 PDG == -521 || PDG == -511 || PDG == -531 || PDG == -541 ) ind=4; // mesons with b quark
638 else if ( PDG == 321 || PDG == 311 || (kf && kfl) || // mesons with sbar antiquark
639 PDG == -411 || PDG == -421 || PDG == -431 || // mesons with cbar antiquark
640 PDG == 521 || PDG == 511 || PDG == 531 || PDG == 541 ) ind=5; // mesons with bbar antiquark
641 else if ( PDG > 3000 && PDG < 5333 ) ind=6; // @@ for all heavy baryons - take Lambda
642 else if ( PDG > -5333 && PDG < -2000 ) ind=7; // @@ for all anti-baryons (anti-p/anti-n)
643 else {
644 G4cout<<"*Error*G4QuasiElRatios::FetchElTot: PDG="<<PDG
645 <<", while it is defined only for p,n,hyperons,anti-baryons,pi,K/antiK"<<G4endl;
646 G4Exception("G4QuasiELRatio::FetchElTot:","22",FatalException,"QECrash");
647 }
648 if(nDB && lastItot==ind && p>0. && p==lastPtot) return lastRtot; // VI do not use toler
649 // if(nDB && lastI==ind && p>0. && std::fabs(p-lastP)/p<toler) return lastR;
650 if(p<=mip || p>=map) return CalcElTot(p,ind); // @@ Slow calculation ! (Warning?)
651 G4bool found=false;
652 G4int i=-1;
653 if(nDB) for (i=0; i<nDB; i++) if(ind==vItot[i]) // Sirch for this index in AMDB
654 {
655 found=true; // The index is found
656 break;
657 }
658 G4double lp=G4Log(p);
659 if(!nDB || !found) // Create new line in the AMDB
660 {
661 lastXtot = new std::pair<G4double,G4double>[mlp]; // Create logarithmic Table for ElTot
662 lastItot = ind; // Remember the initialized inex
663 lastKtot = static_cast<int>((lp-lpi)/dlp)+1; // MaxBin to be initialized in LogTaB
664 if(lastKtot>nlp)
665 {
666 lastKtot=nlp;
667 lastMtot=lpa-lpi;
668 }
669 else lastMtot = lastKtot*dlp; // Calculate max initialized ln(p)-lpi for LogTab
670 G4double pv=mip;
671 for(G4int j=0; j<=lastKtot; j++) // Calculate LogTab values
672 {
673 lastXtot[j]=CalcElTot(pv,ind);
674 if(j!=lastKtot) pv*=edlp;
675 }
676 i++; // Make a new record to AMDB and position on it
677 vItot.push_back(lastItot);
678 vMtot.push_back(lastMtot);
679 vKtot.push_back(lastKtot);
680 vX->push_back(lastXtot);
681 }
682 else // The A value was found in AMDB
683 {
684 lastItot=vItot[i];
685 lastMtot=vMtot[i];
686 lastKtot=vKtot[i];
687 lastXtot=(*vX)[i];
688 G4int nextK=lastKtot+1;
689 G4double lpM=lastMtot+lpi;
690 if(lp>lpM && lastKtot<nlp) // LogTab must be updated
691 {
692 lastKtot = static_cast<int>((lp-lpi)/dlp)+1; // MaxBin to be initialized in LogTab
693 if(lastKtot>nlp)
694 {
695 lastKtot=nlp;
696 lastMtot=lpa-lpi;
697 }
698 else lastMtot = lastKtot*dlp; // Calculate max initialized ln(p)-lpi for LogTab
699 G4double pv=G4Exp(lpM); // momentum of the last calculated beam
700 for(G4int j=nextK; j<=lastKtot; j++)// Calculate LogTab values
701 {
702 pv*=edlp;
703 lastXtot[j]=CalcElTot(pv,ind);
704 }
705 } // End of LogTab update
706 if(lastKtot>=nextK) // The AMDB was apdated
707 {
708 vMtot[i]=lastMtot;
709 vKtot[i]=lastKtot;
710 }
711 }
712 // Now one can use tabeles to calculate the value
713 G4double dlpp=lp-lpi; // Shifted log(p) value
714 G4int n=static_cast<int>(dlpp/dlp); // Low edge number of the bin
715 G4double d=dlpp-n*dlp; // Log shift
716 G4double e=lastXtot[n].first; // E-Base
717 lastRtot.first=e+d*(lastXtot[n+1].first-e)/dlp; // E-Result
718 if(lastRtot.first<0.) lastRtot.first = 0.;
719 G4double t=lastXtot[n].second; // T-Base
720 lastRtot.second=t+d*(lastXtot[n+1].second-t)/dlp; // T-Result
721 if(lastRtot.second<0.) lastRtot.second= 0.;
722 if(lastRtot.first>lastRtot.second) lastRtot.first = lastRtot.second;
723 return lastRtot;
724} // End of FetchElTot
725
726// (Mean Elastic and Mean Total) Cross-Sections (mb) for PDG+(Z,N) at P=p[GeV/c]
727std::pair<G4double,G4double> G4QuasiElRatios::GetElTot(G4double pIU, G4int hPDG,
728 G4int Z, G4int N)
729{
730 G4double pGeV=pIU/gigaelectronvolt;
731 if(Z<1 && N<1)
732 {
733 G4cout<<"-Warning-G4QuasiElRatio::GetElTot:Z="<<Z<<",N="<<N<<", return zero"<<G4endl;
734 return std::make_pair(0.,0.);
735 }
736 std::pair<G4double,G4double> hp=FetchElTot(pGeV, hPDG, true);
737 std::pair<G4double,G4double> hn=FetchElTot(pGeV, hPDG, false);
738 G4double A=(Z+N)/millibarn; // To make the result in independent units(IU)
739 return std::make_pair((Z*hp.first+N*hn.first)/A,(Z*hp.second+N*hn.second)/A);
740} // End of GetElTot
741
742// (Mean Elastic and Mean Total) Cross-Sections (mb) for PDG+(Z,N) at P=p[GeV/c]
743std::pair<G4double,G4double> G4QuasiElRatios::GetChExFactor(G4double pIU, G4int hPDG,
744 G4int Z, G4int N)
745{
746 G4double pGeV=pIU/gigaelectronvolt;
747 G4double resP=0.;
748 G4double resN=0.;
749 if(Z<1 && N<1)
750 {
751 G4cout<<"-Warning-G4QuasiElRatio::GetChExF:Z="<<Z<<",N="<<N<<", return zero"<<G4endl;
752 return std::make_pair(resP,resN);
753 }
754 G4double A=Z+N;
755 G4double pf=0.; // Possibility to interact with a proton
756 G4double nf=0.; // Possibility to interact with a neutron
757 if (hPDG==-211||hPDG==-321||hPDG==3112||hPDG==3212||hPDG==3312) pf=Z/(A+N);
758 else if(hPDG==211||hPDG==321||hPDG==3222||hPDG==3212||hPDG==3322) nf=N/(A+Z);
759 else if(hPDG==-311||hPDG==311||hPDG==130||hPDG==310)
760 {
761 G4double dA=A+A;
762 pf=Z/(dA+N+N);
763 nf=N/(dA+Z+Z);
764 }
765 G4double mult=1.; // Factor of increasing multiplicity ( ? @@)
766 if(pGeV>.5)
767 {
768 mult=1./(1.+G4Log(pGeV+pGeV))/pGeV;
769 if(mult>1.) mult=1.;
770 }
771 if(pf)
772 {
773 std::pair<G4double,G4double> hp=FetchElTot(pGeV, hPDG, true);
774 resP=pf*(hp.second/hp.first-1.)*mult;
775 }
776 if(nf)
777 {
778 std::pair<G4double,G4double> hn=FetchElTot(pGeV, hPDG, false);
779 resN=nf*(hn.second/hn.first-1.)*mult;
780 }
781 return std::make_pair(resP,resN);
782} // End of GetChExFactor
783
784// scatter (pPDG,p4M) on a virtual nucleon (NPDG,N4M), result: final pair(newN4M,newp4M)
785// if(newN4M.e()==0.) - below threshold, XS=0, no scattering of the progectile happened
786std::pair<G4LorentzVector,G4LorentzVector> G4QuasiElRatios::Scatter(G4int NPDG,
788{
789 static const G4double mNeut= G4Neutron::Neutron()->GetPDGMass();
790 static const G4double mProt= G4Proton::Proton()->GetPDGMass();
791 static const G4double mDeut= G4Deuteron::Deuteron()->GetPDGMass();
792 static const G4double mTrit= G4Triton::Triton()->GetPDGMass();
793 static const G4double mHel3= G4He3::He3()->GetPDGMass();
794 static const G4double mAlph= G4Alpha::Alpha()->GetPDGMass();
795
796 G4LorentzVector pr4M=p4M/megaelectronvolt; // Convert 4-momenta in MeV (keep p4M)
797 N4M/=megaelectronvolt;
798 G4LorentzVector tot4M=N4M+p4M;
799 G4double mT=mNeut;
800 G4int Z=0;
801 G4int N=1;
802 if(NPDG==2212||NPDG==90001000)
803 {
804 mT=mProt;
805 Z=1;
806 N=0;
807 }
808 else if(NPDG==90001001)
809 {
810 mT=mDeut;
811 Z=1;
812 N=1;
813 }
814 else if(NPDG==90002001)
815 {
816 mT=mHel3;
817 Z=2;
818 N=1;
819 }
820 else if(NPDG==90001002)
821 {
822 mT=mTrit;
823 Z=1;
824 N=2;
825 }
826 else if(NPDG==90002002)
827 {
828 mT=mAlph;
829 Z=2;
830 N=2;
831 }
832 else if(NPDG!=2112&&NPDG!=90000001)
833 {
834 G4cout<<"Error:G4QuasiElRatios::Scatter:NPDG="<<NPDG<<" is not 2212 or 2112"<<G4endl;
835 G4Exception("G4QuasiElRatios::Scatter:","21",FatalException,"QEcomplain");
836 //return std::make_pair(G4LorentzVector(0.,0.,0.,0.),p4M);// Use this if not exception
837 }
838 G4double mT2=mT*mT;
839 G4double mP2=pr4M.m2();
840 G4double E=(tot4M.m2()-mT2-mP2)/(mT+mT);
841 G4double E2=E*E;
842 if(E<0. || E2<mP2)
843 {
844 return std::make_pair(G4LorentzVector(0.,0.,0.,0.),p4M); // Do Nothing Action
845 }
846 G4double P=std::sqrt(E2-mP2); // Momentum in pseudo laboratory system
847 // @@ Temporary NN t-dependence for all hadrons
848 //if(pPDG>3400 || pPDG<-3400) G4cout<<"-Warning-G4QE::Scatter: pPDG="<<pPDG<<G4endl;
849 G4int PDG=2212; // *TMP* instead of pPDG
850 if(pPDG==2112||pPDG==-211||pPDG==-321) PDG=2112; // *TMP* instead of pPDG
851 if(!Z && N==1) // Change for Quasi-Elastic on neutron
852 {
853 Z=1;
854 N=0;
855 if (PDG==2212) PDG=2112;
856 else if(PDG==2112) PDG=2212;
857 }
858 G4double xSec=0.; // Prototype of Recalculated Cross Section *TMP*
859 if(PDG==2212) xSec=PCSmanager->GetChipsCrossSection(P, Z, N, PDG); // P CrossSect *TMP*
860 else xSec=NCSmanager->GetChipsCrossSection(P, Z, N, PDG); // N CrossSect *TMP*
861 // @@ check a possibility to separate p, n, or alpha (!)
862 if(xSec <= 0.) // The cross-section iz 0 -> Do Nothing
863 {
864 return std::make_pair(G4LorentzVector(0.,0.,0.,0.),p4M); //Do Nothing Action
865 }
866 G4double mint=0.; // Prototype of functional rand -t (MeV^2) *TMP*
867 if(PDG==2212) mint=PCSmanager->GetExchangeT(Z,N,PDG);// P functional rand -t(MeV^2) *TMP*
868 else mint=NCSmanager->GetExchangeT(Z,N,PDG);// N functional rand -t(MeV^2) *TMP*
869 G4double maxt=0.; // Prototype of max possible -t
870 if(PDG==2212) maxt=PCSmanager->GetHMaxT(); // max possible -t
871 else maxt=NCSmanager->GetHMaxT(); // max possible -t
872 G4double cost=1.-(mint+mint)/maxt; // cos(theta) in CMS
873 if(cost>1. || cost<-1. || !(cost>-1. || cost<=1.))
874 {
875 if (cost>1.) cost=1.;
876 else if(cost<-1.) cost=-1.;
877 else
878 {
879 G4double tm=0.;
880 if(PDG==2212) tm=PCSmanager->GetHMaxT();
881 else tm=NCSmanager->GetHMaxT();
882 G4cerr<<"G4QuasiFreeRatio::Scat:*NAN* cost="<<cost<<",-t="<<mint<<",tm="<<tm<<G4endl;
883 return std::make_pair(G4LorentzVector(0.,0.,0.,0.),p4M); // Do Nothing Action
884 }
885 }
886 G4LorentzVector reco4M=G4LorentzVector(0.,0.,0.,mT); // 4mom of the recoil nucleon
887 G4LorentzVector dir4M=tot4M-G4LorentzVector(0.,0.,0.,(tot4M.e()-mT)*.01);
888 if(!RelDecayIn2(tot4M, pr4M, reco4M, dir4M, cost, cost))
889 {
890 G4cerr<<"G4QFR::Scat:t="<<tot4M<<tot4M.m()<<",mT="<<mT<<",mP="<<std::sqrt(mP2)<<G4endl;
891 //G4Exception("G4QFR::Scat:","009",FatalException,"Decay of ElasticComp");
892 return std::make_pair(G4LorentzVector(0.,0.,0.,0.),p4M); // Do Nothing Action
893 }
894 return std::make_pair(reco4M*megaelectronvolt,pr4M*megaelectronvolt); // Result
895} // End of Scatter
896
897// scatter (pPDG,p4M) on a virtual nucleon (NPDG,N4M), result: final pair(newN4M,newp4M)
898// if(newN4M.e()==0.) - below threshold, XS=0, no scattering of the progectile happened
899// User should himself change the charge (PDG) (e.g. pn->np, pi+n->pi0p, pi-p->pi0n etc.)
900//AR-Jul2020: No need to change this method in order to extended quasi-elastic to
901// charmed and bottom mesons, because it is not used anywhere !
902std::pair<G4LorentzVector,G4LorentzVector> G4QuasiElRatios::ChExer(G4int NPDG,
904{
905 static const G4double mNeut= G4Neutron::Neutron()->GetPDGMass();
906 static const G4double mProt= G4Proton::Proton()->GetPDGMass();
907 G4LorentzVector pr4M=p4M/megaelectronvolt; // Convert 4-momenta in MeV(keep p4M)
908 N4M/=megaelectronvolt;
909 G4LorentzVector tot4M=N4M+p4M;
910 G4int Z=0;
911 G4int N=1;
912 G4int sPDG=0; // PDG code of the scattered hadron
913 G4double mS=0.; // proto of mass of scattered hadron
914 G4double mT=mProt; // mass of the recoil nucleon
915 if(NPDG==2212)
916 {
917 mT=mNeut;
918 Z=1;
919 N=0;
920 if(pPDG==-211) sPDG=111; // pi+ -> pi0
921 else if(pPDG==-321)
922 {
923 sPDG=310; // K+ -> K0S
924 if(G4UniformRand()>.5) sPDG=130; // K+ -> K0L
925 }
926 else if(pPDG==-311||pPDG==311||pPDG==130||pPDG==310) sPDG=321; // K0 -> K+ (?)
927 else if(pPDG==3112) sPDG=3212; // Sigma- -> Sigma0
928 else if(pPDG==3212) sPDG=3222; // Sigma0 -> Sigma+
929 else if(pPDG==3312) sPDG=3322; // Xi- -> Xi0
930 }
931 else if(NPDG==2112) // Default
932 {
933 if(pPDG==211) sPDG=111; // pi+ -> pi0
934 else if(pPDG==321)
935 {
936 sPDG=310; // K+ -> K0S
937 if(G4UniformRand()>.5) sPDG=130; // K+ -> K0L
938 }
939 else if(pPDG==-311||pPDG==311||pPDG==130||pPDG==310) sPDG=-321; // K0 -> K- (?)
940 else if(pPDG==3222) sPDG=3212; // Sigma+ -> Sigma0
941 else if(pPDG==3212) sPDG=3112; // Sigma0 -> Sigma-
942 else if(pPDG==3322) sPDG=3312; // Xi0 -> Xi-
943 }
944 else
945 {
946 G4cout<<"Error:G4QuasiElRatios::ChExer: NPDG="<<NPDG<<" is not 2212 or 2112"<<G4endl;
947 G4Exception("G4QuasiElRatios::ChExer:","21",FatalException,"QE complain");
948 //return std::make_pair(G4LorentzVector(0.,0.,0.,0.),p4M);// Use this if not exception
949 }
950 if(sPDG) mS=mNeut;
951 else
952 {
953 G4cout<<"Error:G4QuasiElRatios::ChExer: BAD pPDG="<<pPDG<<", NPDG="<<NPDG<<G4endl;
954 G4Exception("G4QuasiElRatios::ChExer:","21",FatalException,"QE complain");
955 //return std::make_pair(G4LorentzVector(0.,0.,0.,0.),p4M);// Use this if not exception
956 }
957 G4double mT2=mT*mT;
958 G4double mS2=mS*mS;
959 G4double E=(tot4M.m2()-mT2-mS2)/(mT+mT);
960 G4double E2=E*E;
961 if(E<0. || E2<mS2)
962 {
963 return std::make_pair(G4LorentzVector(0.,0.,0.,0.),p4M); // Do Nothing Action
964 }
965 G4double P=std::sqrt(E2-mS2); // Momentum in pseudo laboratory system
966 // @@ Temporary NN t-dependence for all hadrons
967 G4int PDG=2212; // *TMP* instead of pPDG
968 if(pPDG==2112||pPDG==-211||pPDG==-321) PDG=2112; // *TMP* instead of pPDG
969 if(!Z && N==1) // Change for Quasi-Elastic on neutron
970 {
971 Z=1;
972 N=0;
973 if (PDG==2212) PDG=2112;
974 else if(PDG==2112) PDG=2212;
975 }
976 G4double xSec=0.; // Prototype of Recalculated Cross Section *TMP*
977 if(PDG==2212) xSec=PCSmanager->GetChipsCrossSection(P, Z, N, PDG); // P CrossSect *TMP*
978 else xSec=NCSmanager->GetChipsCrossSection(P, Z, N, PDG); // N CrossSect *TMP*
979 // @@ check a possibility to separate p, n, or alpha (!)
980 if(xSec <= 0.) // The cross-section iz 0 -> Do Nothing
981 {
982 return std::make_pair(G4LorentzVector(0.,0.,0.,0.),p4M); //Do Nothing Action
983 }
984 G4double mint=0.; // Prototype of functional rand -t (MeV^2) *TMP*
985 if(PDG==2212) mint=PCSmanager->GetExchangeT(Z,N,PDG);// P functional rand -t(MeV^2) *TMP*
986 else mint=NCSmanager->GetExchangeT(Z,N,PDG);// N functional rand -t(MeV^2) *TMP*
987 G4double maxt=0.; // Prototype of max possible -t
988 if(PDG==2212) maxt=PCSmanager->GetHMaxT(); // max possible -t
989 else maxt=NCSmanager->GetHMaxT(); // max possible -t
990 G4double cost=1.-mint/maxt; // cos(theta) in CMS
991 if(cost>1. || cost<-1. || !(cost>-1. || cost<=1.))
992 {
993 if (cost>1.) cost=1.;
994 else if(cost<-1.) cost=-1.;
995 else
996 {
997 G4cerr<<"G4QuasiFreeRatio::ChExer:*NAN* c="<<cost<<",t="<<mint<<",tm="<<maxt<<G4endl;
998 return std::make_pair(G4LorentzVector(0.,0.,0.,0.),p4M); // Do Nothing Action
999 }
1000 }
1001 G4LorentzVector reco4M=G4LorentzVector(0.,0.,0.,mT); // 4mom of the recoil nucleon
1002 pr4M=G4LorentzVector(0.,0.,0.,mS); // 4mom of the scattered hadron
1003 G4LorentzVector dir4M=tot4M-G4LorentzVector(0.,0.,0.,(tot4M.e()-mT)*.01);
1004 if(!RelDecayIn2(tot4M, pr4M, reco4M, dir4M, cost, cost))
1005 {
1006 G4cerr<<"G4QFR::ChEx:t="<<tot4M<<tot4M.m()<<",mT="<<mT<<",mP="<<mS<<G4endl;
1007 //G4Exception("G4QFR::ChExer:","009",FatalException,"Decay of ElasticComp");
1008 return std::make_pair(G4LorentzVector(0.,0.,0.,0.),p4M); // Do Nothing Action
1009 }
1010 return std::make_pair(reco4M*megaelectronvolt,pr4M*megaelectronvolt); // Result
1011} // End of ChExer
1012
1013// Calculate ChEx/El ratio (p is in independent units, (Z,N) is target, pPDG is projectile)
1015{
1016
1017 p/=MeV; // Converted from independent units
1018 G4double A=Z+N;
1019 if(A<1.5) return 0.;
1020 G4double Cex=0.;
1021 if (pPDG==2212) Cex=N/(A+Z);
1022 else if(pPDG==2112) Cex=Z/(A+N);
1023 else G4cout<<"*Warning*G4CohChrgExchange::ChExElCoef: wrong PDG="<<pPDG<<G4endl;
1024 Cex*=Cex; // Coherent processes squares the amplitude
1025 // @@ This is true only for nucleons: other projectiles must be treated differently
1026 G4double sp=std::sqrt(p);
1027 G4double p2=p*p;
1028 G4double p4=p2*p2;
1029 G4double dl1=G4Log(p)-5.;
1030 G4double T=(6.75+.14*dl1*dl1+13./p)/(1.+.14/p4)+.6/(p4+.00013);
1031 G4double U=(6.25+8.33e-5/p4/p)*(p*sp+.34)/p2/p;
1032 G4double R=U/T;
1033 return Cex*R*R;
1034}
1035
1036// Decay of Hadron In2Particles f&s, f is in respect to the direction of HadronMomentumDir
1038 G4LorentzVector& dir, G4double maxCost, G4double minCost)
1039{
1040 G4double fM2 = f4Mom.m2();
1041 G4double fM = std::sqrt(fM2); // Mass of the 1st Hadron
1042 G4double sM2 = s4Mom.m2();
1043 G4double sM = std::sqrt(sM2); // Mass of the 2nd Hadron
1044 G4double iM2 = theMomentum.m2();
1045 G4double iM = std::sqrt(iM2); // Mass of the decaying hadron
1046 G4double vP = theMomentum.rho(); // Momentum of the decaying hadron
1047 G4double dE = theMomentum.e(); // Energy of the decaying hadron
1048 if(dE<vP)
1049 {
1050 G4cerr<<"***G4QHad::RelDecIn2: Tachionic 4-mom="<<theMomentum<<", E-p="<<dE-vP<<G4endl;
1051 G4double accuracy=.000001*vP;
1052 G4double emodif=std::fabs(dE-vP);
1053 //if(emodif<accuracy)
1054 //{
1055 G4cerr<<"G4QHadron::RelDecIn2: *Boost* E-p shift is corrected to "<<emodif<<G4endl;
1056 theMomentum.setE(vP+emodif+.01*accuracy);
1057 //}
1058 }
1059 G4ThreeVector ltb = theMomentum.boostVector();// Boost vector for backward Lorentz Trans.
1060 G4ThreeVector ltf = -ltb; // Boost vector for forward Lorentz Trans.
1061 G4LorentzVector cdir = dir; // A copy to make a transformation to CMS
1062 cdir.boost(ltf); // Direction transpormed to CMS of the Momentum
1063 G4ThreeVector vdir = cdir.vect(); // 3-Vector of the direction-particle
1064 G4ThreeVector vx(0.,0.,1.); // Ort in the direction of the reference particle
1065 G4ThreeVector vy(0.,1.,0.); // First ort orthogonal to the direction
1066 G4ThreeVector vz(1.,0.,0.); // Second ort orthoganal to the direction
1067 if(vdir.mag2() > 0.) // the refference particle isn't at rest in CMS
1068 {
1069 vx = vdir.unit(); // Ort in the direction of the reference particle
1070 G4ThreeVector vv= vx.orthogonal(); // Not normed orthogonal vector (!)
1071 vy = vv.unit(); // First ort orthogonal to the direction
1072 vz = vx.cross(vy); // Second ort orthoganal to the direction
1073 }
1074 if(maxCost> 1.) maxCost= 1.;
1075 if(minCost<-1.) minCost=-1.;
1076 if(maxCost<-1.) maxCost=-1.;
1077 if(minCost> 1.) minCost= 1.;
1078 if(minCost> maxCost) minCost=maxCost;
1079 if(std::fabs(iM-fM-sM)<.00000001)
1080 {
1081 G4double fR=fM/iM;
1082 G4double sR=sM/iM;
1083 f4Mom=fR*theMomentum;
1084 s4Mom=sR*theMomentum;
1085 return true;
1086 }
1087 else if (iM+.001<fM+sM || iM==0.)
1088 {//@@ Later on make a quark content check for the decay
1089 G4cerr<<"***G4QH::RelDecIn2: fM="<<fM<<"+sM="<<sM<<">iM="<<iM<<",d="<<iM-fM-sM<<G4endl;
1090 return false;
1091 }
1092 G4double d2 = iM2-fM2-sM2;
1093 G4double p2 = (d2*d2/4.-fM2*sM2)/iM2; // Decay momentum(^2) in CMS of Quasmon
1094 if(p2<0.)
1095 {
1096 p2=0.;
1097 }
1098 G4double p = std::sqrt(p2);
1099 G4double ct = maxCost;
1100 if(maxCost>minCost)
1101 {
1102 G4double dcost=maxCost-minCost;
1103 ct = minCost+dcost*G4UniformRand();
1104 }
1105 G4double phi= twopi*G4UniformRand(); // @@ Change 360.*deg to M_TWOPI (?)
1106 G4double pss=0.;
1107 if(std::fabs(ct)<1.) pss = p * std::sqrt(1.-ct*ct);
1108 else
1109 {
1110 if(ct>1.) ct=1.;
1111 if(ct<-1.) ct=-1.;
1112 }
1113 G4ThreeVector pVect=(pss*std::sin(phi))*vz+(pss*std::cos(phi))*vy+p*ct*vx;
1114
1115 f4Mom.setVect(pVect);
1116 f4Mom.setE(std::sqrt(fM2+p2));
1117 s4Mom.setVect((-1)*pVect);
1118 s4Mom.setE(std::sqrt(sM2+p2));
1119
1120 if(f4Mom.e()+.001<f4Mom.rho())G4cerr<<"*G4QH::RDIn2:*Boost* f4M="<<f4Mom<<",e-p="
1121 <<f4Mom.e()-f4Mom.rho()<<G4endl;
1122 f4Mom.boost(ltb); // Lor.Trans. of 1st hadron back to LS
1123 if(s4Mom.e()+.001<s4Mom.rho())G4cerr<<"*G4QH::RDIn2:*Boost* s4M="<<s4Mom<<",e-p="
1124 <<s4Mom.e()-s4Mom.rho()<<G4endl;
1125 s4Mom.boost(ltb); // Lor.Trans. of 2nd hadron back to LS
1126 return true;
1127} // End of "RelDecayIn2"
1128
1129
1130
1131
1132
1133
@ LE
Definition: Evaluator.cc:65
double C(double temp)
double A(double temperature)
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:179
G4double G4Log(G4double x)
Definition: G4Log.hh:226
CLHEP::HepLorentzVector G4LorentzVector
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:52
Hep3Vector unit() const
Hep3Vector orthogonal() const
double mag2() const
Hep3Vector cross(const Hep3Vector &) const
Hep3Vector boostVector() const
HepLorentzVector & boost(double, double, double)
Hep3Vector vect() const
void setVect(const Hep3Vector &)
static G4Alpha * Alpha()
Definition: G4Alpha.cc:88
G4double GetExchangeT(G4int tZ, G4int tN, G4int pPDG)
static const char * Default_Name()
virtual G4double GetChipsCrossSection(G4double momentum, G4int Z, G4int N, G4int pdg)
G4double GetExchangeT(G4int tZ, G4int tN, G4int pPDG)
virtual G4double GetChipsCrossSection(G4double momentum, G4int Z, G4int N, G4int pdg)
static const char * Default_Name()
G4VCrossSectionDataSet * GetCrossSectionDataSet(const G4String &name, G4bool warning=true)
static G4CrossSectionDataSetRegistry * Instance()
static G4Deuteron * Deuteron()
Definition: G4Deuteron.cc:93
static G4He3 * He3()
Definition: G4He3.cc:93
static G4Neutron * Neutron()
Definition: G4Neutron.cc:103
static G4Pow * GetInstance()
Definition: G4Pow.cc:41
G4double powA(G4double A, G4double y) const
Definition: G4Pow.hh:230
static G4Proton * Proton()
Definition: G4Proton.cc:92
std::pair< G4double, G4double > GetChExFactor(G4double pIU, G4int pPDG, G4int Z, G4int N)
G4double ChExElCoef(G4double p, G4int Z, G4int N, G4int pPDG)
G4bool RelDecayIn2(G4LorentzVector &theMomentum, G4LorentzVector &f4Mom, G4LorentzVector &s4Mom, G4LorentzVector &dir, G4double maxCost=1., G4double minCost=-1.)
std::pair< G4double, G4double > FetchElTot(G4double pGeV, G4int PDG, G4bool F)
std::pair< G4LorentzVector, G4LorentzVector > ChExer(G4int NPDG, G4LorentzVector N4M, G4int pPDG, G4LorentzVector p4M)
std::pair< G4double, G4double > GetElTot(G4double pIU, G4int hPDG, G4int Z, G4int N)
std::pair< G4double, G4double > GetRatios(G4double pIU, G4int prPDG, G4int tgZ, G4int tgN)
std::pair< G4double, G4double > GetElTotXS(G4double Mom, G4int PDG, G4bool F)
std::pair< G4LorentzVector, G4LorentzVector > Scatter(G4int NPDG, G4LorentzVector N4M, G4int pPDG, G4LorentzVector p4M)
static G4Triton * Triton()
Definition: G4Triton.cc:94