880{
882
889
894
895 G4double maximumEnergyTransfer1 = 0;
896 G4double maximumEnergyTransfer2 = 0;
897 G4double maximumEnergyTransferP = 4.* (electron_mass_c2 / proton_mass_c2) * k;
899
901 {
902
903 auto k2 = std::upper_bound(eTdummyVec.begin(),
904 eTdummyVec.end(),
905 k);
906 auto k1 = k2 - 1;
907
908
909
910
911
912
913
914
915
916
917
918
919
920 if (random <= eProbaShellMap[ionizationLevelIndex][(*k1)].back()
921 && random <= eProbaShellMap[ionizationLevelIndex][(*k2)].back())
922 {
923 auto prob12 =
924 std::upper_bound(eProbaShellMap[ionizationLevelIndex][(*k1)].begin(),
925 eProbaShellMap[ionizationLevelIndex][(*k1)].end(),
926 random);
927 auto prob11 = prob12 - 1;
928 auto prob22 =
929 std::upper_bound(eProbaShellMap[ionizationLevelIndex][(*k2)].begin(),
930 eProbaShellMap[ionizationLevelIndex][(*k2)].end(),
931 random);
932 auto prob21 = prob22 - 1;
933
934 valueK1 = *k1;
935 valueK2 = *k2;
936 valuePROB21 = *prob21;
937 valuePROB22 = *prob22;
938 valuePROB12 = *prob12;
939 valuePROB11 = *prob11;
940
941
943 else nrjTransf11 = eNrjTransfData[ionizationLevelIndex][valueK1][valuePROB11];
944 if(valuePROB12 == 1)
945 {
946 if ((valueK1+bindingEnergy)/2. > valueK1) maximumEnergyTransfer1=valueK1;
948
949 nrjTransf12 = maximumEnergyTransfer1;
950 }
951 else nrjTransf12 = eNrjTransfData[ionizationLevelIndex][valueK1][valuePROB12];
952
954 else nrjTransf21 = eNrjTransfData[ionizationLevelIndex][valueK2][valuePROB21];
955 if(valuePROB22 == 1)
956 {
957 if ((valueK2+bindingEnergy)/2. > valueK2) maximumEnergyTransfer2=valueK2;
959
960 nrjTransf22 = maximumEnergyTransfer2;
961 }
962 else
963 nrjTransf22 = eNrjTransfData[ionizationLevelIndex][valueK2][valuePROB22];
964 }
965
966 if (random > eProbaShellMap[ionizationLevelIndex][(*k1)].back())
967 {
968 auto prob22 =
969 std::upper_bound(eProbaShellMap[ionizationLevelIndex][(*k2)].begin(),
970 eProbaShellMap[ionizationLevelIndex][(*k2)].end(),
971 random);
972
973 auto prob21 = prob22 - 1;
974
975 valueK1 = *k1;
976 valueK2 = *k2;
977 valuePROB21 = *prob21;
978 valuePROB22 = *prob22;
979
980 nrjTransf21 = eNrjTransfData[ionizationLevelIndex][valueK2][valuePROB21];
981 nrjTransf22 = eNrjTransfData[ionizationLevelIndex][valueK2][valuePROB22];
982
983 G4double interpolatedvalue2 = Interpolate(valuePROB21,
984 valuePROB22,
985 random,
986 nrjTransf21,
987 nrjTransf22);
988
989
990 G4double value = Interpolate(valueK1, valueK2, k, 0., interpolatedvalue2);
991 return value;
992 }
993 }
994
996 {
997
998 auto k2 = std::upper_bound(pTdummyVec.begin(),
999 pTdummyVec.end(),
1000 k);
1001
1002 auto k1 = k2 - 1;
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017 if (random <= pProbaShellMap[ionizationLevelIndex][(*k1)].back()
1018 && random <= pProbaShellMap[ionizationLevelIndex][(*k2)].back())
1019 {
1020 auto prob12 =
1021 std::upper_bound(pProbaShellMap[ionizationLevelIndex][(*k1)].begin(),
1022 pProbaShellMap[ionizationLevelIndex][(*k1)].end(),
1023 random);
1024
1025 auto prob11 = prob12 - 1;
1026
1027 auto prob22 =
1028 std::upper_bound(pProbaShellMap[ionizationLevelIndex][(*k2)].begin(),
1029 pProbaShellMap[ionizationLevelIndex][(*k2)].end(),
1030 random);
1031
1032 auto prob21 = prob22 - 1;
1033
1034 valueK1 = *k1;
1035 valueK2 = *k2;
1036 valuePROB21 = *prob21;
1037 valuePROB22 = *prob22;
1038 valuePROB12 = *prob12;
1039 valuePROB11 = *prob11;
1040
1041
1043 else nrjTransf11 = pNrjTransfData[ionizationLevelIndex][valueK1][valuePROB11];
1044 if(valuePROB12 == 1) nrjTransf12 = maximumEnergyTransferP;
1045 else nrjTransf12 = pNrjTransfData[ionizationLevelIndex][valueK1][valuePROB12];
1047 else nrjTransf21 = pNrjTransfData[ionizationLevelIndex][valueK2][valuePROB21];
1048 if(valuePROB22 == 1) nrjTransf22 = maximumEnergyTransferP;
1049 else nrjTransf22 = pNrjTransfData[ionizationLevelIndex][valueK2][valuePROB22];
1050
1051 }
1052
1053
1054 if (random > pProbaShellMap[ionizationLevelIndex][(*k1)].back())
1055 {
1056 auto prob22 =
1057 std::upper_bound(pProbaShellMap[ionizationLevelIndex][(*k2)].begin(),
1058 pProbaShellMap[ionizationLevelIndex][(*k2)].end(),
1059 random);
1060
1061 auto prob21 = prob22 - 1;
1062
1063 valueK1 = *k1;
1064 valueK2 = *k2;
1065 valuePROB21 = *prob21;
1066 valuePROB22 = *prob22;
1067
1068 nrjTransf21 = pNrjTransfData[ionizationLevelIndex][valueK2][valuePROB21];
1069 nrjTransf22 = pNrjTransfData[ionizationLevelIndex][valueK2][valuePROB22];
1070
1071 G4double interpolatedvalue2 = Interpolate(valuePROB21,
1072 valuePROB22,
1073 random,
1074 nrjTransf21,
1075 nrjTransf22);
1076
1077
1078 G4double value = Interpolate(valueK1, valueK2, k, 0., interpolatedvalue2);
1079
1080 return value;
1081 }
1082 }
1083
1084
1085 G4double nrjTransfProduct = nrjTransf11 * nrjTransf12 * nrjTransf21
1086 * nrjTransf22;
1087
1088 if (nrjTransfProduct != 0.)
1089 {
1090 nrj = QuadInterpolator(valuePROB11,
1091 valuePROB12,
1092 valuePROB21,
1093 valuePROB22,
1094 nrjTransf11,
1095 nrjTransf12,
1096 nrjTransf21,
1097 nrjTransf22,
1098 valueK1,
1099 valueK2,
1100 k,
1101 random);
1102 }
1103
1104 return nrj;
1105}