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 #include "G4NeutronHPDiscreteTwoBody.hh"
00035 #include "G4PhysicalConstants.hh"
00036 #include "G4Gamma.hh"
00037 #include "G4Electron.hh"
00038 #include "G4Positron.hh"
00039 #include "G4Neutron.hh"
00040 #include "G4Proton.hh"
00041 #include "G4Deuteron.hh"
00042 #include "G4Triton.hh"
00043 #include "G4He3.hh"
00044 #include "G4Alpha.hh"
00045 #include "G4NeutronHPVector.hh"
00046 #include "G4NeutronHPLegendreStore.hh"
00047
00048 G4ReactionProduct * G4NeutronHPDiscreteTwoBody::Sample(G4double anEnergy, G4double massCode, G4double )
00049 {
00050 G4ReactionProduct * result = new G4ReactionProduct;
00051 G4int Z = static_cast<G4int>(massCode/1000);
00052 G4int A = static_cast<G4int>(massCode-1000*Z);
00053
00054 if(massCode==0)
00055 {
00056 result->SetDefinition(G4Gamma::Gamma());
00057 }
00058 else if(A==0)
00059 {
00060 result->SetDefinition(G4Electron::Electron());
00061 if(Z==1) result->SetDefinition(G4Positron::Positron());
00062 }
00063 else if(A==1)
00064 {
00065 result->SetDefinition(G4Neutron::Neutron());
00066 if(Z==1) result->SetDefinition(G4Proton::Proton());
00067 }
00068 else if(A==2)
00069 {
00070 result->SetDefinition(G4Deuteron::Deuteron());
00071 }
00072 else if(A==3)
00073 {
00074 result->SetDefinition(G4Triton::Triton());
00075 if(Z==2) result->SetDefinition(G4He3::He3());
00076 }
00077 else if(A==4)
00078 {
00079 result->SetDefinition(G4Alpha::Alpha());
00080 if(Z!=2) throw G4HadronicException(__FILE__, __LINE__, "Unknown ion case 1");
00081 }
00082 else
00083 {
00084 throw G4HadronicException(__FILE__, __LINE__, "G4NeutronHPDiscreteTwoBody: Unknown ion case 2");
00085 }
00086
00087
00088 G4int i(0), it(0);
00089 G4double cosTh(0);
00090 for(i=0; i<nEnergy; i++)
00091 {
00092 it = i;
00093 if(theCoeff[i].GetEnergy()>anEnergy) break;
00094 }
00095 if(it==0||it==nEnergy-1)
00096 {
00097 if(theCoeff[it].GetRepresentation()==0)
00098 {
00099
00100 G4NeutronHPLegendreStore theStore(1);
00101 theStore.SetCoeff(0, theCoeff);
00102 theStore.SetManager(theManager);
00103
00104
00105 cosTh = theStore.SampleDiscreteTwoBody(anEnergy);
00106 }
00107 else if(theCoeff[it].GetRepresentation()==12)
00108 {
00109 G4NeutronHPVector theStore;
00110 G4InterpolationManager aManager;
00111 aManager.Init(LINLIN, theCoeff[it].GetNumberOfPoly()/2);
00112 theStore.SetInterpolationManager(aManager);
00113 for(i=0;i<theCoeff[it].GetNumberOfPoly(); i++)
00114 {
00115
00116
00117
00118 theStore.SetX(i/2, theCoeff[it].GetCoeff(i));
00119 theStore.SetY(i/2, theCoeff[it].GetCoeff(i+1));
00120 i++;
00121 }
00122 cosTh = theStore.Sample();
00123 }
00124 else if(theCoeff[it].GetRepresentation()==14)
00125 {
00126 G4NeutronHPVector theStore;
00127 G4InterpolationManager aManager;
00128 aManager.Init(LOGLIN, theCoeff[it].GetNumberOfPoly()/2);
00129 theStore.SetInterpolationManager(aManager);
00130 for(i=0;i<theCoeff[it].GetNumberOfPoly(); i++)
00131 {
00132
00133
00134
00135 theStore.SetX(i/2, theCoeff[it].GetCoeff(i));
00136 theStore.SetY(i/2, theCoeff[it].GetCoeff(i+1));
00137 i++;
00138 }
00139 cosTh = theStore.Sample();
00140 }
00141 else
00142 {
00143 throw G4HadronicException(__FILE__, __LINE__, "unknown representation type in Two-body scattering");
00144 }
00145 }
00146 else
00147 {
00148 if(theCoeff[it].GetRepresentation() == theCoeff[it-1].GetRepresentation())
00149 {
00150 if(theCoeff[it].GetRepresentation()==0)
00151 {
00152
00153 G4NeutronHPLegendreStore theStore(2);
00154 theStore.SetCoeff(0, &(theCoeff[it-1]));
00155 theStore.SetCoeff(1, &(theCoeff[it]));
00156 G4InterpolationManager aManager;
00157 aManager.Init(theManager.GetScheme(it), 2);
00158 theStore.SetManager(aManager);
00159
00160
00161 cosTh = theStore.SampleDiscreteTwoBody(anEnergy);
00162 }
00163 else if(theCoeff[it].GetRepresentation()==12)
00164 {
00165 G4NeutronHPVector theBuff1;
00166 G4InterpolationManager aManager1;
00167 aManager1.Init(LINLIN, theCoeff[it-1].GetNumberOfPoly()/2);
00168 theBuff1.SetInterpolationManager(aManager1);
00169 for(i=0;i<theCoeff[it-1].GetNumberOfPoly(); i++)
00170 {
00171
00172
00173
00174 theBuff1.SetX(i/2, theCoeff[it-1].GetCoeff(i));
00175 theBuff1.SetY(i/2, theCoeff[it-1].GetCoeff(i+1));
00176 i++;
00177 }
00178 G4NeutronHPVector theBuff2;
00179 G4InterpolationManager aManager2;
00180 aManager2.Init(LINLIN, theCoeff[it].GetNumberOfPoly()/2);
00181 theBuff2.SetInterpolationManager(aManager2);
00182 for(i=0;i<theCoeff[it].GetNumberOfPoly(); i++)
00183 {
00184
00185
00186 theBuff2.SetX(i/2, theCoeff[it].GetCoeff(i));
00187 theBuff2.SetY(i/2, theCoeff[it].GetCoeff(i+1));
00188 i++;
00189 }
00190
00191 G4double x1 = theCoeff[it-1].GetEnergy();
00192 G4double x2 = theCoeff[it].GetEnergy();
00193 G4double x = anEnergy;
00194 G4double y1, y2, y, mu;
00195
00196 G4NeutronHPVector theStore1;
00197 theStore1.SetInterpolationManager(aManager1);
00198 G4NeutronHPVector theStore2;
00199 theStore2.SetInterpolationManager(aManager2);
00200 G4NeutronHPVector theStore;
00201
00202
00203 for(i=0; i<theBuff1.GetVectorLength(); i++)
00204 {
00205 mu = theBuff1.GetX(i);
00206 y1 = theBuff1.GetY(i);
00207 y2 = theBuff2.GetY(mu);
00208 y = theInt.Interpolate(theManager.GetScheme(it), x, x1,x2,y1,y2);
00209 theStore1.SetData(i, mu, y);
00210 }
00211 for(i=0; i<theBuff2.GetVectorLength(); i++)
00212 {
00213 mu = theBuff2.GetX(i);
00214 y1 = theBuff2.GetY(i);
00215 y2 = theBuff1.GetY(mu);
00216 y = theInt.Interpolate(theManager.GetScheme(it), x, x1,x2,y1,y2);
00217 theStore2.SetData(i, mu, y);
00218 }
00219 theStore.Merge(&theStore1, &theStore2);
00220 cosTh = theStore.Sample();
00221 }
00222 else if(theCoeff[it].GetRepresentation()==14)
00223 {
00224 G4NeutronHPVector theBuff1;
00225 G4InterpolationManager aManager1;
00226 aManager1.Init(LOGLIN, theCoeff[it-1].GetNumberOfPoly()/2);
00227 theBuff1.SetInterpolationManager(aManager1);
00228 for(i=0;i<theCoeff[it-1].GetNumberOfPoly(); i++)
00229 {
00230
00231
00232
00233 theBuff1.SetX(i/2, theCoeff[it-1].GetCoeff(i));
00234 theBuff1.SetY(i/2, theCoeff[it-1].GetCoeff(i+1));
00235 i++;
00236 }
00237
00238 G4NeutronHPVector theBuff2;
00239 G4InterpolationManager aManager2;
00240 aManager2.Init(LOGLIN, theCoeff[it].GetNumberOfPoly()/2);
00241 theBuff2.SetInterpolationManager(aManager2);
00242 for(i=0;i<theCoeff[it].GetNumberOfPoly(); i++)
00243 {
00244
00245
00246
00247 theBuff2.SetX(i/2, theCoeff[it].GetCoeff(i));
00248 theBuff2.SetY(i/2, theCoeff[it].GetCoeff(i+1));
00249 i++;
00250 }
00251
00252 G4double x1 = theCoeff[it-1].GetEnergy();
00253 G4double x2 = theCoeff[it].GetEnergy();
00254 G4double x = anEnergy;
00255 G4double y1, y2, y, mu;
00256
00257 G4NeutronHPVector theStore1;
00258 theStore1.SetInterpolationManager(aManager1);
00259 G4NeutronHPVector theStore2;
00260 theStore2.SetInterpolationManager(aManager2);
00261 G4NeutronHPVector theStore;
00262
00263
00264 for(i=0; i<theBuff1.GetVectorLength(); i++)
00265 {
00266 mu = theBuff1.GetX(i);
00267 y1 = theBuff1.GetY(i);
00268 y2 = theBuff2.GetY(mu);
00269 y = theInt.Interpolate(theManager.GetScheme(it), x, x1,x2,y1,y2);
00270 theStore1.SetData(i, mu, y);
00271 }
00272 for(i=0; i<theBuff2.GetVectorLength(); i++)
00273 {
00274 mu = theBuff2.GetX(i);
00275 y1 = theBuff2.GetY(i);
00276 y2 = theBuff1.GetY(mu);
00277 y = theInt.Interpolate(theManager.GetScheme(it), x, x1,x2,y1,y2);
00278 theStore2.SetData(i, mu, y);
00279 }
00280 theStore.Merge(&theStore1, &theStore2);
00281 cosTh = theStore.Sample();
00282 }
00283 else
00284 {
00285 throw G4HadronicException(__FILE__, __LINE__, "Two neighbouring distributions with different interpolation");
00286 }
00287 }
00288 else
00289 {
00290 throw G4HadronicException(__FILE__, __LINE__, "unknown representation type in Two-body scattering, case 2");
00291 }
00292 }
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304 G4double A1 = GetTarget()->GetMass()/GetNeutron()->GetMass();
00305 G4double A1prim = result->GetMass()/GetNeutron()->GetMass();
00306 G4double E1 = (A1+1)*(A1+1)/A1/A1*anEnergy;
00307 G4double kinE = (A1+1-A1prim)/(A1+1)/(A1+1)*(A1*E1+(1+A1)*GetQValue());
00308
00309 result->SetKineticEnergy(kinE);
00310 G4double phi = twopi*G4UniformRand();
00311 G4double theta = std::acos(cosTh);
00312 G4double sinth = std::sin(theta);
00313 G4double mtot = result->GetTotalMomentum();
00314 G4ThreeVector tempVector(mtot*sinth*std::cos(phi), mtot*sinth*std::sin(phi), mtot*std::cos(theta) );
00315 result->SetMomentum(tempVector);
00316
00317
00318
00319
00320 return result;
00321 }