00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "globals.hh"
00043 #include "G4CrossSectionPatch.hh"
00044 #include "G4VCrossSectionSource.hh"
00045 #include "G4KineticTrack.hh"
00046 #include "G4CrossSectionVector.hh"
00047
00048 G4CrossSectionPatch::G4CrossSectionPatch()
00049 { }
00050
00051
00052 G4CrossSectionPatch::~G4CrossSectionPatch()
00053 { }
00054
00055
00056 G4bool G4CrossSectionPatch::operator==(const G4CrossSectionPatch &right) const
00057 {
00058 return (this == (G4CrossSectionPatch*) &right);
00059 }
00060
00061
00062 G4bool G4CrossSectionPatch::operator!=(const G4CrossSectionPatch &right) const
00063 {
00064 return (this != (G4CrossSectionPatch*) &right);
00065 }
00066
00067
00068 G4double G4CrossSectionPatch::CrossSection(const G4KineticTrack& trk1,
00069 const G4KineticTrack& trk2) const
00070 {
00071
00072
00073
00074 G4double crossSection = 0.;
00075 G4double ecm = (trk1.Get4Momentum() + trk2.Get4Momentum()).mag();
00076
00077 const G4CrossSectionVector* components = GetComponents();
00078 if (components != 0)
00079 {
00080 G4int nComponents = this->GetComponents()->size();
00081
00082
00083 G4int i;
00084 for (i=0; i<nComponents; i++)
00085 {
00086 G4CrossSectionSourcePtr componentPtr = (*components)[i];
00087 G4VCrossSectionSource* component = componentPtr();
00088 if (component->IsValid(ecm))
00089 {
00090 crossSection = component->CrossSection(trk1,trk2);
00091 }
00092 else if (i < (nComponents - 1) )
00093 {
00094 G4CrossSectionSourcePtr nextPtr = (*components)[i+1];
00095 G4VCrossSectionSource* next = nextPtr();
00096 if (ecm > component->HighLimit() && ecm < next->LowLimit())
00097 {
00098
00099 crossSection = Transition(trk1,trk2,component,next);
00100 }
00101 }
00102 }
00103 }
00104
00105 return crossSection;
00106 }
00107
00108
00109 G4bool G4CrossSectionPatch::IsValid(G4double e) const
00110 {
00111
00112 G4bool answer = false;
00113 const G4CrossSectionVector* components = GetComponents();
00114 if (components != 0)
00115 {
00116 G4int n = components->size();
00117 G4int i;
00118 for (i=0; i<n; i++)
00119 {
00120 G4CrossSectionSourcePtr componentPtr = (*components)[i];
00121 G4VCrossSectionSource* component = componentPtr();
00122 if (component->IsValid(e))
00123 {
00124 answer = true;
00125 break;
00126 }
00127 }
00128 }
00129 return answer;
00130 }
00131
00132
00133 G4double G4CrossSectionPatch::Transition(const G4KineticTrack& trk1, const G4KineticTrack& trk2,
00134 const G4VCrossSectionSource* comp1,
00135 const G4VCrossSectionSource* comp2) const
00136 {
00137
00138
00139 G4double crossSection = 0.;
00140
00141 G4double ecm = (trk1.Get4Momentum() + trk2.Get4Momentum()).mag();
00142 G4double sigma1 = comp1->CrossSection(trk1,trk2);
00143 G4double sigma2 = comp2->CrossSection(trk1,trk2);
00144 G4double denom = comp2->LowLimit() - comp1->HighLimit();
00145 G4double diff = ecm - comp1->HighLimit();
00146 if (denom > 0. && diff > 0.)
00147 {
00148 G4double ratio = diff / denom;
00149 crossSection = (1.- ratio) * sigma1 + ratio * sigma2;
00150 }
00151
00152 return crossSection;
00153 }
00154
00155
00156 G4double G4CrossSectionPatch::Transition(G4double ecm,
00157 G4double sigma1, G4double sigma2,
00158 G4double e1, G4double e2) const
00159 {
00160
00161
00162 G4double crossSection = 0.;
00163
00164 G4double denom = e2 - e1;
00165 G4double diff = ecm - e1;
00166 if (denom > 0. && diff > 0.)
00167 {
00168 G4double ratio = diff / denom;
00169 crossSection = (1.- ratio) * sigma1 + ratio * sigma2;
00170 }
00171
00172 return crossSection;
00173 }
00174