549{
550 static const G4double third = 1./3.;
557
559 static const G4double mNeut2= mNeut*mNeut;
561 static const G4double mProt2= mProt*mProt;
562 static const G4double dM=mProt+mNeut;
567 static const G4double mPi0s= mPi0*mPi0;
569
574 static const G4double tmPi = mPi+mPi;
575 static const G4double stmPi= tmPi*tmPi;
576 static const G4double mPPi = mPi+mProt;
577 static const G4double mPPi2= mPPi*mPPi;
578
579
580 static const G4double meN = mNeut+me;
581 static const G4double meN2= meN*meN;
582 static const G4double fmeN= 4*mNeut2*me2;
583 static const G4double mesN= mNeut2+me2;
584 static const G4double meP = mProt+me;
585 static const G4double meP2= meP*meP;
586 static const G4double fmeP= 4*mProt2*me2;
587 static const G4double mesP= mProt2+me2;
589 static const G4double meD = mPPi+me;
590 static const G4double meD2= meD*meD;
591
592 static const G4double muN = mNeut+mu;
593 static const G4double muN2= muN*muN;
594 static const G4double fmuN= 4*mNeut2*mu2;
595 static const G4double musN= mNeut2+mu2;
596 static const G4double muP = mProt+mu;
597 static const G4double muP2= muP*muP;
598 static const G4double fmuP= 4*mProt2*mu2;
599 static const G4double musP= mProt2+mu2;
601 static const G4double muD = mPPi+mu;
602 static const G4double muD2= muD*muD;
603
604
605
606
607
608
609
610
611
612
613
614
616
617 static G4bool CWinit =
true;
618 if(CWinit)
619 {
620 CWinit=false;
622 }
623
626#ifdef debug
627 G4cout<<
"G4QInelastic::PostStepDoIt: Before the GetMeanFreePath is called"<<
G4endl;
628#endif
631#ifdef debug
632 G4cout<<
"G4QInelastic::PostStepDoIt: After the GetMeanFreePath is called"<<
G4endl;
633#endif
640 if(std::fabs(Momentum-momentum)>.001)
641 G4cerr<<
"*G4QInelastic::PostStepDoIt: P="<<Momentum<<
"#"<<momentum<<
G4endl;
642#ifdef debug
644 G4cout<<
"-->G4QInel::PostStDoIt:*called*, 4M="<<proj4M<<
", P="<<Momentum<<
"="<<momentum
646#endif
648 {
649 G4cerr<<
"G4QInelastic::PostStepDoIt:Only gam,e+,e-,mu+,mu-,t+,t-,p are implemented."
651 return 0;
652 }
657#ifdef debug
658 G4cout<<
"G4QInelastic::PostStepDoIt: "<<nE<<
" elements in the material."<<
G4endl;
659#endif
673 {
675 else projPDG= -311;
676 }
677 else if ( pZ > 0 && pA > 1 ) projPDG = 90000000+999*pZ+pA;
707 G4int aProjPDG=std::abs(projPDG);
708#ifdef debug
710 G4cout<<
"G4QInelastic::PostStepDoIt: projPDG="<<projPDG<<
", stPDG="<<prPDG<<
G4endl;
711#endif
712 if(!projPDG)
713 {
714 G4cerr<<
"---Warning---G4QInelastic::PostStepDoIt:Undefined interacting hadron"<<
G4endl;
715 return 0;
716 }
717 G4int EPIM=ElProbInMat.size();
718#ifdef debug
719 G4cout<<
"G4QInel::PostStDoIt: m="<<EPIM<<
",n="<<nE<<
",T="<<ElProbInMat[EPIM-1]<<
G4endl;
720#endif
722 if(EPIM>1)
723 {
725 for(i=0; i<nE; ++i)
726 {
727#ifdef debug
728 G4cout<<
"G4QInelastic::PostStepDoIt:E["<<i<<
"]="<<ElProbInMat[i]<<
",r="<<rnd<<
G4endl;
729#endif
730 if (rnd<ElProbInMat[i]) break;
731 }
732 if(i>=nE) i=nE-1;
733 }
734 G4Element* pElement=(*theElementVector)[i];
736#ifdef debug
737 G4cout<<
"G4QInelastic::PostStepDoIt: i="<<i<<
", Z(element)="<<Z<<
G4endl;
738#endif
739 if(Z<=0)
740 {
741 G4cerr<<
"---Warning---G4QInelastic::PostStepDoIt: Element with Z="<<Z<<
G4endl;
742 if(Z<0) return 0;
743 }
744 std::vector<G4double>* SPI = IsoProbInEl[i];
745 std::vector<G4int>* IsN = ElIsoN[i];
746 G4int nofIsot=SPI->size();
747#ifdef debug
748 G4cout<<
"G4QInel::PosStDoIt:n="<<nofIsot<<
",T="<<(*SPI)[nofIsot-1]<<
G4endl;
749#endif
751 if(nofIsot>1)
752 {
754 for(j=0; j<nofIsot; ++j)
755 {
756#ifdef debug
757 G4cout<<
"G4QInelastic::PostStepDoIt: SP["<<j<<
"]="<<(*SPI)[j]<<
", r="<<rndI<<
G4endl;
758#endif
759 if(rndI < (*SPI)[j]) break;
760 }
761 if(j>=nofIsot) j=nofIsot-1;
762 }
763 G4int N =(*IsN)[j]; ;
764#ifdef debug
765 G4cout<<
"G4QInelastic::PostStepDoIt: Z="<<Z<<
", j="<<i<<
", N(isotope)="<<N<<
G4endl;
766#endif
769 if(projPDG==22 && Z==1 && !N && Momentum<150.)
770 {
771#ifdef debug
772 G4cerr<<
"---LowPHOTON---G4QInelastic::PSDoIt: Called for zero Cross-section"<<
G4endl;
773#endif
774
780 }
781 if(N<0)
782 {
783 G4cerr<<
"-Warning-G4QInelastic::PostStepDoIt: Isotope with Z="<<Z<<
", 0>N="<<N<<
G4endl;
784 return 0;
785 }
786 nOfNeutrons=N;
787
789
790
791
792
793
796
797
798
799
800
801
802#ifdef debug
803 G4cout<<
"G4QInelastic::PostStepDoIt: N="<<N<<
" for element with Z="<<Z<<
G4endl;
804#endif
806 G4double weight = track.GetWeight();
807#ifdef debug
808 G4cout<<
"G4QInelastic::PostStepDoIt: weight="<<weight<<
G4endl;
809#endif
810 if(photNucBias!=1.) weight/=photNucBias;
811 else if(weakNucBias!=1.) weight/=weakNucBias;
812 G4double localtime = track.GetGlobalTime();
813#ifdef debug
814 G4cout<<
"G4QInelastic::PostStepDoIt: localtime="<<localtime<<
G4endl;
815#endif
818#ifdef debug
820#endif
821
822 G4int targPDG=90000000+Z*1000+N;
830#ifdef debug
831 G4cout<<
"G4QInelastic::PostStepDoIt: projPDG="<<aProjPDG<<
", targPDG="<<targPDG<<
G4endl;
832#endif
833
834
835
836
837 if (aProjPDG == 11 || aProjPDG == 13 || aProjPDG == 15)
838 {
839#ifdef debug
841#endif
845 if(aProjPDG== 13)
846 {
848 ml=mu;
849 ml2=mu2;
850 }
851 if(aProjPDG== 15)
852 {
854 ml=mt;
855 ml2=mt2;
856 }
857
858 if(!aProjPDG)
G4cout<<
"-Warning-G4QInelast::PostStepDoIt:(2) projectile PDG=0"<<
G4endl;
860
861 if(Z==1 && !N && Momentum<150.) xSec=0.;
862#ifdef debug
863 G4cout<<
"-Forse-G4QInel::PStDoIt:P="<<Momentum<<
",PDG="<<projPDG<<
",xS="<<xSec<<
G4endl;
864#endif
865 if(xSec <= 0.)
866 {
867#ifdef debug
868 G4cerr<<
"---OUT---G4QInelastic::PSDoIt: Called for zero Cross-section"<<
G4endl;
869#endif
870
875 delete output;
877 }
879#ifdef debug
880 G4cout<<
"G4QInel::PStDoIt:kE="<<kinEnergy<<
",dir="<<dir<<
",phE="<<photonEnergy<<
G4endl;
881#endif
882 if( kinEnergy < photonEnergy || photonEnergy < 0.)
883 {
884
885 G4cerr<<
"--G4QInelastic::PSDoIt: photE="<<photonEnergy<<
">leptE="<<kinEnergy<<
G4endl;
890 delete output;
892 }
894 G4double W=photonEnergy-photonQ2/dM;
895 if(tM<999.) W-=mPi0+mPi0s/dM;
896 if(W<0.)
897 {
898
899#ifdef debug
900 G4cout<<
"--G4QInelastic::PostStepDoIt:(lN) negative equivalent energy W="<<W<<
G4endl;
901#endif
906 delete output;
908 }
909
915 {
916
917#ifdef debug
918 G4cout<<
"-DoNoth-G4QInelastic::PostStepDoIt: probab. correction - DoNothing"<<
G4endl;
919#endif
924 delete output;
926 }
929#ifdef pdebug
930 G4cout<<
"G4QInelastic::PoStDoIt:E="<<iniE<<
",lE="<<finE<<
"-"<<ml<<
"="<<finE-ml<<
G4endl;
931#endif
933 if(finE<=ml)
934 {
939 }
941 G4double iniP=std::sqrt(iniE*iniE-ml2);
942 G4double finP=std::sqrt(finE*finE-ml2);
943 G4double cost=(iniE*finE-ml2-photonQ2/2)/iniP/finP;
944#ifdef pdebug
945 G4cout<<
"G4QI::PSDoIt:Q2="<<photonQ2<<
",ct="<<cost<<
",Pi="<<iniP<<
",Pf="<<finP<<
G4endl;
946#endif
947 if(cost>1.) cost=1.;
948 if(cost<-1.) cost=-1.;
949
950
951
953
954 if(am>1 && absEn < photonEnergy)
955
956 {
960 G4double phEn2 = photonEnergy*photonEnergy;
963 absMom = std::sqrt(abMo2);
964 if(absMom < phMo)
965 {
966 G4double dEn = photonEnergy - absEn;
969#ifdef ppdebug
970 G4cout<<
"-PhotoAbsorption-G4QIn::PStDoIt: sF="<<sF<<
",phEn="<<photonEnergy<<
G4endl;
971#endif
972 if(sF > stmPi)
973 {
974 photonEnergy = absEn;
975 photonQ2=abMo2-absEn*absEn;
976 absEn = dEn;
977 }
978 else absMom=0.;
979 }
980 else absMom=0.;
981 }
982
983
984
988 G4double sint=std::sqrt(1.-cost*cost);
994#ifdef pdebug
997#endif
999 if(absMom)
1000 {
1002#ifdef ppdebug
1003 G4cout<<
"-Absorption-G4QInelastic::PostStepDoIt: ph3M="<<photon3M<<
", eIn3M="
1004 <<iniP*dir<<
", eFin3M="<<finP*findir<<
", abs3M="<<absMom<<
"<ptm="<<ptm<<
G4endl;
1005#endif
1007 photon3M-=lead3M;
1009#ifdef ppdebug
1010 G4cout<<
"-->G4QI::PoStDoIt: new sF="<<proj4M.
m2()<<
", lead4M="<<proj4M<<
G4endl;
1011#endif
1012 lead4M=proj4M;
1014 try
1015 {
1016 if(leadhs) delete leadhs;
1019 }
1021 {
1022 G4cerr<<
"***G4QInelastic::PostStepDoIt: G4Quasmon Exception is catched"<<
G4endl;
1023
1024 G4Exception(
"G4QInelastic::PostStepDoIt()",
"HAD_CHPS_0072",
1026 }
1027 delete pan;
1028#ifdef ppdebug
1029 G4cout<<
"G4QInel::PStDoIt: l4M="<<proj4M<<proj4M.
m2()<<
", N="<<leadhs->size()<<
",pt="
1030 <<ptm<<
",pa="<<absMom<<
",El="<<absEn<<
",Pl="<<ptm-absMom<<
G4endl;
1031#endif
1032 }
1033 else
1034 {
1036 if(leadhs) qNH=leadhs->size();
1037 if(qNH)
for(
G4int iq=0; iq<qNH; iq++)
delete (*leadhs)[iq];
1038 if(leadhs) delete leadhs;
1039 leadhs=0;
1040 }
1041 projPDG=22;
1043#ifdef debug
1045 <<proj4M<<
", lE="<<finE<<
", lP="<<finP*findir<<
", d="<<findir.
mag2()<<
G4endl;
1046#endif
1047
1048
1049
1050
1051 }
1052 else if (aProjPDG == 12 || aProjPDG == 14)
1053 {
1055 G4double dKinE=kinEnergy+kinEnergy;
1056#ifdef debug
1057 G4cout<<
"G4QInelastic::PostStDoIt: 2*nuEnergy="<<dKinE<<
"(MeV), PDG="<<projPDG<<
G4endl;
1058#endif
1062
1066
1071
1073 if(aProjPDG==12)
1074 {
1075 ml = me;
1076 ml2 = me2;
1077
1078 mlN2= meN2;
1079 fmlN= fmeN;
1080 mlsN= mesN;
1081
1082 mlP2= meP2;
1083 fmlP= fmeP;
1084 mlsP= mesP;
1085 mldM= medM;
1086
1087 mlD2= meD2;
1088 }
1093 scatPDG=13;
1094 if(projPDG==-14)
1095 {
1096 nuanu=false;
1099 scatPDG=-13;
1100 }
1101 else if(projPDG==12)
1102 {
1104 scatPDG=11;
1105 }
1106 else if(projPDG==-12)
1107 {
1108 nuanu=false;
1111 scatPDG=-11;
1112 }
1113
1114 if(!projPDG)
G4cout<<
"-Warning-G4QInelastic::PostStepDoIt:(3)projectile PDG=0"<<
G4endl;
1118
1119 if(xSec <= 0.)
1120 {
1121 G4cerr<<
"G4QInelastic::PSDoIt:nuE="<<kinEnergy<<
",X1="<<xSec1<<
",X2="<<xSec2<<
G4endl;
1122
1127 delete output;
1129 }
1132 {
1133 if(scatPDG>0) scatPDG++;
1134 else scatPDG--;
1135 secnu=true;
1136 }
1137 scat=true;
1141 if(std::fabs(xSec-totCS*millibarn)/xSec>.0001)
1142 G4cout<<
"-Warning-G4QInelastic::PostStepDoIt: xS="<<xSec<<
"# CS="<<totCS<<
G4endl;
1146 if(totCS - qelCS < 0.)
1147 {
1148 totCS = qelCS;
1149 totCS1 = qelCS1;
1150 totCS2 = qelCS2;
1151 }
1152
1156
1159 if(secnu)
1160 {
1162 {
1163 targPDG-=1;
1164 projPDG=2112;
1165 mIN =mNeut;
1166 OT =mNeut2;
1167
1168 mlOT=0.;
1169 mlsOT=mNeut2;
1170 }
1171 else
1172 {
1173 targPDG-=1000;
1174 projPDG=2212;
1175 mOT =mProt;
1176 OT =mProt2;
1177
1178 mlOT =0.;
1179 mlsOT=mProt2;
1180 }
1181 ml=0.;
1182 ml2=0.;
1183 mldM=0.;
1184 mlD2=mPPi2;
1186 targQPDG = temporary_targQPDG;
1188 mIN=tM-rM;
1189 tM=rM;
1190 }
1191 else if(nuanu)
1192 {
1193 targPDG-=1;
1195 targQPDG = temporary_targQPDG;
1197 mIN=tM-rM;
1198 tM=rM;
1199 mOT=mProt;
1200 OT=mlP2;
1201
1202 mlOT=fmlP;
1203 mlsOT=mlsP;
1204 projPDG=2212;
1205 }
1206 else
1207 {
1208 if(Z>1||N>0)
1209 {
1210 targPDG-=1000;
1212 targQPDG = temporary_targQPDG;
1214 mIN=tM-rM;
1215 tM=rM;
1216 }
1217 else
1218 {
1219 targPDG=0;
1220 mIN=tM;
1221 tM=0.;
1222 }
1223 projPDG=2112;
1224 }
1226#ifdef debug
1227 G4cout<<
"G4QInelastic::PostStDoIt: s="<<s_value<<
" >? OT="<<OT<<
", mlD2="<<mlD2<<
G4endl;
1228#endif
1229 if(s_value<=OT)
1230 {
1231
1232 G4cout<<
"G4QInelastic::PostStepDoIt: tooSmallFinalMassOfCompound: DoNothing"<<
G4endl;
1237 delete output;
1239 }
1240#ifdef debug
1241 G4cout<<
"G4QInelastic::PostStDoIt: Stop and kill the projectile neutrino"<<
G4endl;
1242#endif
1245
1246 if ( ((secnu || !nuanu || N) && totCS*
G4UniformRand() < qelCS) || s_value < mlD2 )
1247 {
1251#ifdef debug
1252 G4cout<<
"G4QInelastic::PostStDoIt:QuasiEl(nu="<<secnu<<
"),s="<<s_value<<
",Q2="<<Q2<<
G4endl;
1253#endif
1254
1257 G4double p_init=(s_value-mIN*mIN)/dsqs;
1262 G4double cost=(dpi*std::sqrt(qo2+ml2)-Q2-ml2)/dpi/qo;
1267 if(!
G4QHadron(c4M).RelDecayIn2(scat4M, t4M, proj4M, cost, cost))
1268 {
1269 G4cerr<<
"G4QIn::PStD:c4M="<<c4M<<sqs<<
",mM="<<ml<<
",tM="<<mOT<<
",c="<<cost<<
G4endl;
1270
1271 G4Exception(
"G4QInelastic::PostStepDoIt()",
"HAD_CHPS_0000",
1272 FatalException,
"Hadronize quasmon: Can't dec QE nu,lept Compound");
1273 }
1274 proj4M=t4M;
1275 }
1276 else
1277 {
1278
1279 if ( (secnu && projPDG == 2212) || (!secnu && projPDG == 2112) ) targPDG+=1;
1280 else if ( (secnu && projPDG == 2112) || (!secnu && projPDG == 2212) ) targPDG+=1000;
1284#ifdef debug
1285 G4cout<<
"G4QInel::PStDoIt: MultiPeriferal s="<<s_value<<
",Q2="<<Q2<<
",T="<<targPDG<<
G4endl;
1286#endif
1289
1290
1293 if(r<0.5) r1=std::sqrt(r+r)*(.5+.1579*(r-.5));
1294 else if(r>0.5) r1=1.-std::sqrt(2.-r-r)*(.5+.1579*(.5-r));
1298
1301 if(we>=kinEnergy-ml-.001) we=kinEnergy-ml-.0001;
1304 G4double cost=(pot-mlQ2/dKinE)/std::sqrt(pot*pot-ml2);
1305 if(std::fabs(cost)>1)
1306 {
1307#ifdef debug
1308 G4cout<<
"*G4QInelastic::PostStDoIt: cost="<<cost<<
", Q2="<<Q2<<
", nu="<<we<<
", mx="
1309 <<mx<<
", pot="<<pot<<
", 2KE="<<dKinE<<
G4endl;
1310#endif
1311 if(cost>1.) cost=1.;
1312 else cost=-1.;
1313 pot=mlQ2/dKinE+dKinE*ml2/mlQ2;
1314 }
1315 G4double lEn=std::sqrt(pot*pot+ml2);
1317 G4double lPt=pot*std::sqrt(1.-cost*cost);
1318 std::pair<G4double,G4double> d2d=Random2DDirection();
1328 proj4M-=scat4M;
1329#ifdef debug
1330 G4cout<<
"G4QInelastic::PostStDoIt: proj4M="<<proj4M<<
", ml="<<ml<<
G4endl;
1331#endif
1332
1333 G4int fintPDG=targPDG;
1334 if(!secnu)
1335 {
1336 if(projPDG<0) fintPDG-= 999;
1337 else fintPDG+= 999;
1338 }
1343#ifdef debug
1344 G4cout<<
"G4QInelastic::PSDI:fM2="<<fM2<<
"<? mc4M="<<c4M.
m2()<<
",dM="<<fM-tgM<<
G4endl;
1345#endif
1347 {
1352 G4double hQ2max=(fs*fs/2-fMl-fMl)/s_value;
1353 cost=1.-Q2/hQ2max;
1354#ifdef debug
1355 G4cout<<
"G4QI::PSDI:ct="<<cost<<
",Q2="<<Q2<<
",hQ2="<<hQ2max<<
",4M="<<tot4M<<
G4endl;
1356#endif
1358 if(acost>1.)
1359 {
1360 if(acost>1.001)
G4cout<<
"-Warning-G4QInelastic::PostStDoIt: cost="<<cost<<
G4endl;
1361 if (cost> 1.) cost= 1.;
1362 else if(cost<-1.) cost=-1.;
1363 }
1367 if(!
G4QHadron(tot4M).RelDecayIn2(scat4M, reco4M, dir4M, cost, cost))
1368 {
1369 G4cerr<<
"G4QI::PSDI:t4M="<<tot4M<<
",lM="<<ml<<
",rM="<<fM<<
",cost="<<cost<<
G4endl;
1370
1371 }
1372#ifdef debug
1373 G4cout<<
"G4QIn::PStDoI:l4M="<<scat4M<<
"+r4M="<<reco4M<<
"="<<scat4M+reco4M<<
G4endl;
1374#endif
1375
1377
1382
1383
1388
1389
1390 else G4cout<<
"-Warning-G4QInelastic::PostStDoIt: UnknownLepton="<<scatPDG<<
G4endl;
1396
1399 else
1400 {
1401 G4int fm=
static_cast<G4int>(fintPDG/1000000);
1402 G4int ZN=fintPDG-1000000*fm;
1406 }
1412 delete output;
1414 }
1415 }
1416
1417
1418
1419 }
1420
1421 else if(2>3)
1422 {
1423 if(momentum<500. && projPDG == 2112)
1424 {
1429 if(projPDG == 2212) tZ++;
1430 else tN++;
1431 if(momentum<100.)
1432 {
1434
1436
1437
1438 G4double mR2N= FakeP.GetNuclMass(tZ,m2n,0);
1439
1440
1442
1443 if(totM2 < minM*minM)
1444 {
1450 }
1451 }
1452 }
1453
1455 std::pair<G4double,G4double> fief=qfMan->
GetRatios(momentum, projPDG, Z, N);
1456 G4double qepart=fief.first*fief.second;
1457
1459 G4double clProb[lCl]={.65,.85,.95};
1460 if(qepart>0.45) qepart=.45;
1461
1462 qepart=qepart/clProb[0]-qepart;
1465
1466 if(momentum > thresh) pickup*=50./momentum/
G4QThd(Z+N);
1467
1468 if (N) pickup+=qepart;
1469 else pickup =qepart;
1471#ifdef ldebug
1472 G4cout<<
"-->G4QInelastic::PSD:QE[p("<<proj4M<<
")+(Z="<<Z<<
",N="<<N<<
")]="<<qepart
1473 <<
", pickup="<<pickup<<
G4endl;
1474#endif
1475 if(rnd<pickup)
1476 {
1479 if(Z>1||N>1) dmom=fmm*std::pow(-std::log(
G4UniformRand()),third);
1480
1483 G4int nPDG=90000001;
1484 G4int restPDG=targPDG;
1491 if(rnd<qepart)
1492 {
1493
1494
1497
1498 if(Z<2 || N<2 || A < 6) base = clProb[--max];
1499 if((Z > 1 && N < 2) || (Z < 2 && N > 1)) base=(clProb[max]+clProb[max-1])/2;
1500 if ( (Z < 2 && N < 2) || A < 5) base=clProb[--max];
1501 if(A<3) base=clProb[--max];
1502
1504
1505 if(max>1)
1506 {
1507 base-=clProb[0];
1510 if(max>1) while(ic<max) if(ran>clProb[ic++]) cln=ic;
1511 }
1514 if(!cln || cp1)
1515 {
1517 if(cln==2) nln=1;
1518
1519 if ( ((!cln || cln == 2) &&
G4UniformRand()*(A-cln) > (N-nln)) ||
1520 ((cln == 3 || cln == 1) && Z > N) )
1521 {
1522 nPDG=90001000;
1523 nZ=1;
1524 qM=mProt;
1525 rZ--;
1526 restPDG-=1000;
1527 }
1528 else restPDG--;
1533 G4double nM=std::sqrt(rM2+tM*tM-(tM+tM)*std::sqrt(rM2+dmom*dmom));
1535#ifdef qedebug
1536 G4cout<<
"G4QInel::PStDoIt:QE,p="<<dmom<<
",tM="<<tM<<
",R="<<rM<<
",N="<<nM<<
G4endl;
1537#endif
1539 {
1540
1541
1542
1543 G4cerr<<
"-W-G4QInel::PoStDoI:M="<<tM<<
"<rM="<<rM<<
"+nM="<<nM<<
"="<<rM+nM<<
G4endl;
1549 }
1550#ifdef qedebug
1551 G4cout<<
"G4QIn::PStDoIt:QE-N, RA="<<r4M.rho()<<r4M<<
",QN="<<n4M.rho()<<n4M<<
G4endl;
1552#endif
1553 if(cp1 && cln)
1554 {
1555 qM=rM;
1556 nln=nPDG;
1557 nPDG=restPDG;
1558 restPDG=nln;
1559 t4M=n4M;
1560 n4M=r4M;
1561 r4M=t4M;
1562 nln=nZ;
1563 nZ=rZ;
1564 rZ=nln;
1565 nln=nA;
1566 nA=rA;
1567 rA=nln;
1568 }
1569 }
1570 else
1571 {
1572 if(cln==1)
1573 {
1574 nPDG=90001001;
1575 qM=mDeut;
1576 nA=2;
1577 nZ=1;
1578 restPDG-=1001;
1579
1583 }
1584 else if(cln==2)
1585 {
1586 nA=3;
1588 {
1589 nPDG=90002001;
1590 qM=mHel3;
1591 nZ=2;
1592 restPDG-=2001;
1593 }
1594 else
1595 {
1596 nPDG=90001002;
1597 qM=mTrit;
1598 nZ=1;
1599 restPDG-=1002;
1600 }
1601
1606 }
1607 else
1608 {
1609 nPDG=90002002;
1610 qM=mAlph;
1611 nA=4;
1612 nZ=2;
1613 restPDG-=2002;
1619 }
1620 rA=A-nA;
1621 rZ=Z-nZ;
1622
1623
1624
1625
1626
1627
1632 G4double nM=std::sqrt(rM2+tM*tM-(tM+tM)*std::sqrt(rM2+dmom*dmom));
1634#ifdef qedebug
1635 G4cout<<
"G4QInel::PStDoIt:QEC, p="<<dmom<<
",T="<<tM<<
",R="<<rM<<
",N="<<nM<<
G4endl;
1636#endif
1638 {
1639
1640
1641
1642 G4cerr<<
"-W-G4QInel::PoStDoI:M="<<tM<<
"<rM="<<rM<<
"+cM="<<nM<<
"="<<rM+nM<<
G4endl;
1648 }
1649
1650#ifdef qedebug
1651 G4cout<<
"G4QIn::PStDoIt:QEC, RN="<<r4M.rho()<<r4M<<
",QCl="<<n4M.rho()<<n4M<<
G4endl;
1652#endif
1653 }
1659 if(cmM2>minM*minM)
1660 {
1661#ifdef qedebug
1662 G4cout<<
"G4QInel::PStDoIt:***Enter***,cmM2="<<cmM2<<
" > minM2="<<minM*minM<<
G4endl;
1663#endif
1664
1667
1668
1669 if(2>3)
1670 {
1671#ifdef qedebug
1672 G4cout<<
"G4QIn::PStDoIt:-Enter, P="<<projPDG<<
",cln="<<cln<<
",cp1="<<cp1<<
G4endl;
1673#endif
1677 G4int tresPDG=restPDG+999;
1678 if(projPDG==2212)
1679 {
1681 tprM=mNeut;
1682 tprM2=mNeut2;
1683 tprPDG=2112;
1684 tresPDG=restPDG-999;
1685 }
1686 minM=tprM+qM;
1687 G4double efE=(cmM2-tprM2-qM*qM)/(qM+qM);
1688 G4double efP=std::sqrt(efE*efE-tprM2);
1690#ifdef qedebug
1691 G4cout<<
"G4QInel::PStDoIt:chl="<<chl<<
",P="<<efP<<
",nZ="<<nZ<<
",nA="<<nA<<
G4endl;
1692#endif
1694 {
1695 projPDG=tprPDG;
1696 prjM=tprM;
1700 chex=true;
1701 }
1702 }
1703
1704 std::pair<G4LorentzVector,G4LorentzVector> sctout=qfMan->
Scatter(nPDG, n4M,
1705 projPDG, proj4M);
1706#ifdef qedebug
1707 G4cout<<
"G4QInelastic::PStDoIt:QElS,proj="<<prjM<<sctout.second<<
",qfCl="<<qM
1708 <<sctout.first<<
",chex="<<chex<<
",nA="<<nA<<
",nZ="<<nZ<<
G4endl;
1709#endif
1711
1712 if(chex)
1713 {
1722 }
1723 else
1724 {
1726 G4double ldT=(sctout.second).e()-prjM;
1731 }
1732
1733
1736 else if(nZ>0 && nA>1)
1738#ifdef debug
1739 else G4cout<<
"-Warning_G4QIn::PSD:scatqfPDG="<<nPDG<<
", Z="<<nZ<<
",A="<<nA<<
G4endl;
1740#endif
1741 if(nZ>0 && nA>0)
1742 {
1748 }
1749
1750
1753 else if(rZ>0 && rA>1)
1755#ifdef debug
1756 else G4cout<<
"-Warning_G4QIn::PSD: resPDG="<<restPDG<<
",Z="<<rZ<<
",A="<<rA<<
G4endl;
1757#endif
1758 if(rZ>0 && rA>0)
1759 {
1765 }
1766 delete output;
1768 }
1769#ifdef qedebug
1770 else G4cout<<
"G4QInel::PSD:OUT,M2="<<s4M.
m2()<<
"<"<<minM*minM<<
", N="<<nPDG<<
G4endl;
1771#endif
1772 }
1773 else
1774 {
1775 if(projPDG==2212) restPDG--;
1776 else
1777 {
1778 restPDG-=1000;
1779 rZ--;
1780 }
1783
1789 if(N>2 && frn > 0.95)
1790 {
1791 if(projPDG==2212)
1792 {
1794 {
1796 mPUF=mTrit;
1797 restPDG--;
1798 din=true;
1799 }
1800 else
1801 {
1803 mPUF=mHel3;
1804 restPDG-=1000;
1805 rZ--;
1806 pin=true;
1807 }
1808 }
1809 else
1810 {
1812 {
1814 mPUF=mHel3;
1815 restPDG-=1000;
1816 rZ--;
1817 dip=true;
1818 }
1819 else
1820 {
1822 mPUF=mTrit;
1823 restPDG--;
1824 pin=true;
1825 }
1826 }
1827 rA--;
1828
1832 if(Z>1 && frn > 0.99)
1833 {
1835 if((din && projPDG==2212) || (pin && projPDG==2112))
1836 {
1837 restPDG-=1000;
1838 rZ--;
1839 }
1840 else if((pin && projPDG==2212) || (dip && projPDG==2112)) restPDG--;
1841 else G4cout<<
"-Warning-G4QIn::PSD: PickUp logic error, proj="<<projPDG<<
G4endl;
1842 hin=true;
1843 mPUF=mAlph;
1844 rA--;
1845
1848 }
1849 }
1854 G4double nM2=rM2+tM*tM-(tM+tM)*std::sqrt(rM2+dmom*dmom);
1855 if(nM2 < 0) nM2=0.;
1858#ifdef qedebug
1860 G4cout<<
"G4QInel::PStDoIt:PiU, p="<<dmom<<
",tM="<<tM<<
", R="<<rM<<
",N="<<nM<<
G4endl;
1861#endif
1865 if(projPDG == 2112) mNucl2=mNeut2;
1866 G4double cost=(nM2+mNucl2+srm+srm-mPUF2)/(qp+qp);
1868 while(std::fabs(cost)>1. && ict<3)
1869 {
1870 dmom=91.;
1871 if(Z>1||N>1) dmom=fmm*std::pow(-std::log(
G4UniformRand()),third);
1872 if(din || pin || dip)
1873 {
1876 if(hin)
1879 }
1880 nM2=rM2+tM*tM-(tM+tM)*std::sqrt(rM2+dmom*dmom);
1881 if(nM2 < 0) nM2=0.;
1882
1883 den2=(dmom*dmom+nM2);
1884 den=std::sqrt(den2);
1885 qp=momentum*dmom;
1886 srm=proj4M.e()*den;
1887 cost=(nM2+mNucl2+srm+srm-mPUF2)/(qp+qp);
1888 ict++;
1889#ifdef ldebug
1890 if(ict>2)
G4cout<<
"G4QInelast::PStDoIt:i="<<ict<<
",d="<<dmom<<
",ct="<<cost<<
G4endl;
1891#endif
1892 }
1893 if(std::fabs(cost)<=1.)
1894 {
1899 if(vdir.
mag2() > 0.)
1900 {
1905 }
1906
1907 G4double tdom=dmom*std::sqrt(1-cost*cost);
1909 G4ThreeVector vedm=vx*dmom*cost+vy*tdom*std::sin(phi)+vz*tdom*std::cos(phi);
1911 r4M=t4M-bqf;
1912#ifdef debug
1913 if(std::fabs(r4M.m()-rM)>.001)
G4cout<<
"G4QIn::PSD: rM="<<rM<<
"#"<<r4M.m()<<
G4endl;
1914#endif
1916#ifdef debug
1917 if(std::fabs(f4M.
m()-mPUF)>.001)
G4cout<<
"G4QI::PSD:m="<<mPUF<<
"#"<<f4M.
m()<<
G4endl;
1918#endif
1922
1928#ifdef pickupd
1929 G4cout<<
"G4QInelastic::PStDoIt: f="<<theDefinition<<
",f4M="<<f4M.
m()<<f4M<<
G4endl;
1930#endif
1931
1932
1941#ifdef pickupd
1942 G4cout<<
"G4QInelastic::PStDoIt:rZ="<<rZ<<
",rA="<<rA<<
",r4M="<<r4M.m()<<r4M<<
G4endl;
1943#endif
1944 delete output;
1946 }
1947 }
1948 }
1949 }
1951 if(absMom) EnMomConservation+=lead4M;
1952#ifdef debug
1954#endif
1955
1956
1957
1958
1959
1960#ifdef debug
1961 G4cout<<
"^^G4QInelastic::PostStepDoIt: projPDG="<<projPDG<<
", targPDG="<<targPDG<<
G4endl;
1962#endif
1964 if(projPDG>9000000)
1965 {
1966 delete output;
1969#ifdef debug
1970 G4cout<<
"G4QInel::PStDoIt: ProjNuc="<<projPDG<<proj4M<<
", TargNuc="<<targPDG<<
G4endl;
1971#endif
1972 try {output = IonIon.Fragment();}
1974 {
1975 G4cerr<<
"***G4QInelastic::PostStepDoIt: G4QE Exception is catched in hA"<<
G4endl;
1976
1977 G4Exception(
"G4QInelastic::PostStepDoIt()",
"HAD_CHPS_0027",
1979 }
1980 }
1981 else
1982 {
1983
1984#ifdef debug
1986#endif
1988
1989
1990
1991#ifdef debug
1992 G4cout<<
"G4QInelastic::PStDoIt: atCn="<<atCn<<
" <= maxCn="<<maxCn<<
G4endl;
1993#endif
1994 G4int outN=output->size();
1995 if(outN)
1996 {
1997 std::for_each(output->begin(), output->end(),
DeleteQHadron());
1998 output->clear();
1999 }
2000 delete output;
2002#ifdef debug
2003 G4cout<<
"G4QInelastic::PStDoIt: Before Fragmentation"<<
G4endl;
2004#endif
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2016#ifdef debug
2017 G4cout<<
"G4QInelastic::PStDoIt:Proj="<<projPDG<<proj4M<<
",TgNuc="<<targPDG<<
G4endl;
2018#endif
2019 try {output = DINR.Fragment();}
2021 {
2022 G4cerr<<
"***G4QInelastic::PostStepDoIt: G4QE Exception is catched in hA"<<
G4endl;
2023
2024 G4Exception(
"G4QInelastic::PostStepDoIt()",
"HAD_CHPS_0027",
2026 }
2027
2028 outN=output->size();
2029#ifdef debug
2030 G4cout<<
"G4QInelastic::PostStepDoIt: At# "<<atCn<<
", nSec="<<outN<<
", fPDG="
2031 <<(*output)[0]->GetPDGCode()<<
", pPDG="<< projPDG<<
G4endl;
2032#endif
2033
2034 if(outN < 2)
2035 {
2036 G4cout<<
"-Warning-G4QInelastic::PostStepDoIt: nSec="<<outN<<
", At# "<<atCn<<
G4endl;
2037
2038 }
2039
2040#ifdef debug
2041 if(atCn==maxCn)
G4cout<<
"-Warning-G4QI::PostStDoIt:mAt="<<atCn<<
" is reached"<<
G4endl;
2042#endif
2043
2044 }
2045
2046
2047 if(scat)
2048 {
2050 output->push_back(scatHadron);
2051 }
2053 if(leadhs) qNH=leadhs->size();
2054 if(absMom)
2055 {
2056 if(qNH)
for(
G4int iq=0; iq<qNH; iq++)
2057 {
2059 output->push_back(loh);
2060 }
2061 if(leadhs) delete leadhs;
2062 leadhs=0;
2063 }
2064 else
2065 {
2066 if(qNH)
for(
G4int iq=0; iq<qNH; iq++)
delete (*leadhs)[iq];
2067 if(leadhs) delete leadhs;
2068 leadhs=0;
2069 }
2070
2071 G4int tNH = output->size();
2073
2074#ifdef debug
2075 G4cout<<
"G4QInelastic::PostStepDoIt: "<<tNH<<
" particles are generated"<<
G4endl;
2076#endif
2077#ifdef ppdebug
2078 if(absMom)
G4cout<<
"G4QInelastic::PostStepDoIt: t="<<tNH<<
", q="<<qNH<<
G4endl;
2079#endif
2080 G4int nOut=output->size();
2081 if(tNH==1 && !scat)
2082 {
2083 G4cout<<
"-Warning-G4QInelastic::PostStepDoIt: 1 secondary! absMom="<<absMom;
2084 if(absMom)
G4cout<<
", qNH="<<qNH;
2085 G4cout<<
", PDG0="<<(*output)[0]->GetPDGCode();
2087 tNH=0;
2088 delete output->operator[](0);
2089 output->pop_back();
2090 }
2091 if(tNH==2&&2!=nOut)
G4cout<<
"--Warning--G4QInelastic::PostStepDoIt: 2 # "<<nOut<<
G4endl;
2092
2093
2094 if(tNH) for(i=0; i<tNH; i++)
2095 {
2096
2097
2098
2102#ifdef pdebug
2103 G4cout<<
"G4QInelastic::PostStepDoIt: H#"<<i<<
",PDG="<<PDGCode<<
",nF="<<nFrag
2105#endif
2106 if(nFrag)
2107 {
2108#ifdef debug
2109 G4cout<<
"G4QInelastic::PostStepDoIt: Intermediate particle is found i="<<i<<
G4endl;
2110#endif
2111 delete hadr;
2112 continue;
2113 }
2119 else if(PDGCode==311 || PDGCode==-311)
2120 {
2123 }
2129 else if(PDGCode==90000000)
2130 {
2131#ifdef pdebug
2132 G4cout<<
"-Warning-G4QInelastic::PostStepDoIt:Vacuum PDG="<<PDGCode
2134#endif
2137 if(std::fabs(hM2)>.01)
G4cout<<
"-Warning-G4QInel::PoStDoIt:90000000M2="<<hM2<<
G4endl;
2139 {
2140 delete hadr;
2141 continue;
2142 }
2143 }
2144 else if(PDGCode >80000000)
2145 {
2148#ifdef pdebug
2149 G4cout<<
"G4QInelastic::PostStepDoIt:Ion Z="<<aZ<<
", A="<<aA<<
G4endl;
2150#endif
2152 }
2153
2154 else if(PDGCode==89999998 || PDGCode==89998000 || PDGCode==88000000)
2155 {
2159 if (PDGCode==89998000)
2160 {
2161 rM=mProt;
2162 rPDG=-2212;
2164 }
2165 else if(PDGCode==88000000)
2166 {
2167 rM=mLamb;
2168 rPDG=-3122;
2170 }
2174#ifdef qedebug
2175 G4cout<<
"G4QInel::PStDoIt:AntiDiBar,t4M="<<tM<<
",m="<<rM<<
",PDG="<<PDGCode<<
G4endl;
2176#endif
2178 {
2179 G4cerr<<
"G4QIn::PostStDoIt: ADB, M="<<t4M.
m()<<
" < 2*rM="<<rM<<
" = "<<2*rM<<
G4endl;
2180
2181 G4Exception(
"G4QInelastic::PostStepDoIt()",
"HAD_CHPS_0004",
2183 }
2184
2185#ifdef qedebug
2186 G4cout<<
"G4QInelastic::PStDoIt: ADB, H1="<<rM<<f4M<<
", H2="<<rM<<s4M<<
G4endl;
2187#endif
2191 theDefinition=BarDef;
2192#ifdef debug
2193 G4cout<<
"G4QInel::PostStDoIt:Anti-DiBar, DecayIn2, h1="<<rPDG<<f4M<<
G4endl;
2194#endif
2196 output->push_back(sH);
2197 ++tNH;
2198#ifdef debug
2199 G4cout<<
"G4QInel::PostStDoIt:Anti-DiBar, DecayIn2, h2="<<rPDG<<s4M<<
G4endl;
2200#endif
2201 }
2202 else if(PDGCode==90000997 || PDGCode==89997001)
2203 {
2209 if(PDGCode==90000997)
2210 {
2211 rM=mProt;
2212 rPDG=-2212;
2213 iPDG=-211;
2215 }
2220#ifdef qedebug
2221 G4cout<<
"G4QInel::PStDoIt:AntiNDelta, t4M="<<tM<<
",m="<<rM<<
",PDG="<<PDGCode<<
G4endl;
2222#endif
2223 if(!
G4QHadron(t4M).DecayIn3(f4M, s4M, u4M))
2224 {
2225 G4cerr<<
"G4QIn::PostStDoIt: AND, tM="<<t4M.
m()<<
" < 2*mB+mPi="<<2*rM+iM<<
G4endl;
2226
2227 G4Exception(
"G4QInelastic::PostStepDoIt()",
"HAD_CHPS_0005",
2229 }
2230
2231#ifdef qedebug
2232 G4cout<<
"G4QInel::PStDoI:AND,B1="<<rM<<f4M<<
",B2="<<rM<<s4M<<
",Pi="<<iM<<u4M<<
G4endl;
2233#endif
2237 theDefinition=BarDef;
2238#ifdef debug
2239 G4cout<<
"G4QInel::PostStDoIt:Anti-NDelta, DecayIn2, h1="<<rPDG<<f4M<<
G4endl;
2240#endif
2242 output->push_back(sH);
2243 ++tNH;
2244#ifdef debug
2245 G4cout<<
"G4QInel::PostStDoIt:Anti-NDelta, DecayIn2, h2="<<rPDG<<s4M<<
G4endl;
2246#endif
2248 output->push_back(uH);
2249 ++tNH;
2250#ifdef debug
2251 G4cout<<
"G4QInel::PostStDoIt:Anti-NDelta, DecayIn2, h2="<<rPDG<<s4M<<
G4endl;
2252#endif
2253 }
2254 else
2255 {
2256#ifdef pdebug
2257 G4cout<<
"G4QInelastic::PostStepDoIt:Define particle with PDG="<<PDGCode<<
G4endl;
2258#endif
2260#ifdef pdebug
2261 G4cout<<
"G4QInelastic::PostStepDoIt:AfterParticleDefinition PDG="<<PDGCode<<
G4endl;
2262#endif
2263 }
2264 if(!theDefinition)
2265 {
2266 if(PDGCode!=90000000 || hadr->
Get4Momentum()!=vacuum4M)
2267 G4cout<<
"---Warning---G4QInelastic::PostStepDoIt: drop PDG="<<PDGCode<<
", 4Mom="
2269 delete hadr;
2270 continue;
2271 }
2272#ifdef pdebug
2274#endif
2277 EnMomConservation-=h4M;
2278#ifdef tdebug
2279 G4cout<<
"G4QInelast::PSDI: "<<i<<
","<<PDGCode<<h4M<<h4M.
m()<<EnMomConservation<<
G4endl;
2280#endif
2281#ifdef debug
2282 G4cout<<
"G4QInelastic::PostStepDoIt:#"<<i<<
",PDG="<<PDGCode<<
",4M="<<h4M<<
G4endl;
2283#endif
2285 delete hadr;
2286#ifdef debug
2290 G4cout<<
"G4QInelast::PSDoIt:p="<<curD<<curD.
mag()<<
",e="<<curE<<
",m="<<curM<<
G4endl;
2291#endif
2296#ifdef debug
2297 G4cout<<
"G4QInelastic::PostStepDoIt:#"<<i<<
" is done."<<
G4endl;
2298#endif
2299 }
2300 delete output;
2301 if(leadhs)
2302 {
2303 qNH=leadhs->size();
2304 if(qNH)
for(
G4int iq=0; iq<qNH; iq++)
delete (*leadhs)[iq];
2305 delete leadhs;
2306 leadhs=0;
2307 }
2308#ifdef debug
2310#endif
2311 if(aProjPDG!=11 && aProjPDG!=13 && aProjPDG!=15)
2313#ifdef pdebug
2316#endif
2317#ifdef ldebug
2318 G4cout<<
"G4QInelastic::PostStepDoIt:*** PostStepDoIt is done ***, P="<<aProjPDG<<
", St="
2320#endif
2322}
std::vector< G4QHadron * > G4QHadronVector
G4ThreeVector G4RandomDirection()
CLHEP::Hep3Vector G4ThreeVector
Hep3Vector orthogonal() const
Hep3Vector cross(const Hep3Vector &) const
static G4Deuteron * Deuteron()
const G4ThreeVector & GetMomentumDirection() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
G4LorentzVector Get4Momentum() const
G4double GetKineticEnergy() const
void Set4Momentum(const G4LorentzVector &momentum)
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
void AddSecondary(G4Track *aSecondary)
G4double GetEnergy() const
const G4ThreeVector * GetMomentumDirection() const
void ProposeEnergy(G4double finalEnergy)
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
virtual void Initialize(const G4Track &)
G4double GetPDGMass() const
const G4String & GetParticleName() const
G4ParticleDefinition * FindIon(G4int atomicNumber, G4int atomicMass, G4double excitationEnergy)
static G4ParticleTable * GetParticleTable()
static G4QCHIPSWorld * Get()
G4QParticleVector * GetParticles(G4int nOfParts=0)
G4LorentzVector Get4Momentum() const
G4int GetBaryonNumber() const
void SetQPDG(const G4QPDGCode &QPDG)
G4int GetNFragments() const
void Set4Momentum(const G4LorentzVector &aMom)
G4double GetMeanFreePath(const G4Track &aTrack, G4double previousStepSize, G4ForceCondition *condition)
G4double GetNuclMass(G4int Z, G4int N, G4int S)
G4ParticleDefinition * GetParticleDefinition(G4int PDGCode)
static G4QPDGToG4Particle * Get()
G4double ChExElCoef(G4double p, G4int Z, G4int N, G4int pPDG)
std::pair< G4LorentzVector, G4LorentzVector > Scatter(G4int NPDG, G4LorentzVector N4M, G4int pPDG, G4LorentzVector p4M)
static G4QuasiFreeRatios * GetPointer()
std::pair< G4double, G4double > GetRatios(G4double pIU, G4int prPDG, G4int tgZ, G4int tgN)
G4QHadronVector * Fragment(G4QNucleus &nucEnviron, G4int nQ=1)
void SetWeight(G4double aValue)
void SetTouchableHandle(const G4TouchableHandle &apValue)
static G4Triton * Triton()
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
void SetNumberOfSecondaries(G4int totSecondaries)
G4TrackStatus GetTrackStatus() const
G4ParticleChange aParticleChange
virtual G4double GetExchangeEnergy()
virtual G4double GetQEL_ExchangeQ2()
virtual G4double GetNQE_ExchangeQ2()
virtual G4double GetLastQELCS()
virtual G4double GetLastTOTCS()
virtual G4double GetVirtualFactor(G4double nu, G4double Q2)
virtual G4int GetExchangePDGCode()
virtual G4double GetExchangeQ2(G4double nu=0)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)