[819] | 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 | // neutron_hp -- source file |
---|
| 27 | // J.P. Wellisch, Nov-1996 |
---|
| 28 | // A prototype of the low energy neutron transport model. |
---|
| 29 | // |
---|
| 30 | // 070523 bug fix for G4FPE_DEBUG on by A. Howard ( and T. Koi) |
---|
| 31 | // |
---|
| 32 | #include "G4NeutronHPAngular.hh" |
---|
| 33 | |
---|
| 34 | void G4NeutronHPAngular::Init(std::ifstream & aDataFile) |
---|
| 35 | { |
---|
| 36 | // G4cout << "here we are entering the Angular Init"<<G4endl; |
---|
| 37 | aDataFile >> theAngularDistributionType >> targetMass; |
---|
| 38 | aDataFile >> frameFlag; |
---|
| 39 | if(theAngularDistributionType == 0) |
---|
| 40 | { |
---|
| 41 | theIsoFlag = true; |
---|
| 42 | } |
---|
| 43 | else if(theAngularDistributionType==1) |
---|
| 44 | { |
---|
| 45 | G4int nEnergy; |
---|
| 46 | aDataFile >> nEnergy; |
---|
| 47 | theCoefficients = new G4NeutronHPLegendreStore(nEnergy); |
---|
| 48 | theCoefficients->InitInterpolation(aDataFile); |
---|
| 49 | G4double temp, energy; |
---|
| 50 | G4int tempdep, nLegendre; |
---|
| 51 | G4int i, ii; |
---|
| 52 | for (i=0; i<nEnergy; i++) |
---|
| 53 | { |
---|
| 54 | aDataFile >> temp >> energy >> tempdep >> nLegendre; |
---|
| 55 | energy *=eV; |
---|
| 56 | theCoefficients->Init(i, energy, nLegendre); |
---|
| 57 | theCoefficients->SetTemperature(i, temp); |
---|
| 58 | G4double coeff=0; |
---|
| 59 | for(ii=0; ii<nLegendre; ii++) |
---|
| 60 | { |
---|
| 61 | aDataFile >> coeff; |
---|
| 62 | theCoefficients->SetCoeff(i, ii+1, coeff); |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | else if (theAngularDistributionType==2) |
---|
| 67 | { |
---|
| 68 | G4int nEnergy; |
---|
| 69 | aDataFile >> nEnergy; |
---|
| 70 | theProbArray = new G4NeutronHPPartial(nEnergy, nEnergy); |
---|
| 71 | theProbArray->InitInterpolation(aDataFile); |
---|
| 72 | G4double temp, energy; |
---|
| 73 | G4int tempdep; |
---|
| 74 | for(G4int i=0; i<nEnergy; i++) |
---|
| 75 | { |
---|
| 76 | aDataFile >> temp >> energy >> tempdep; |
---|
| 77 | energy *= eV; |
---|
| 78 | theProbArray->SetT(i, temp); |
---|
| 79 | theProbArray->SetX(i, energy); |
---|
| 80 | theProbArray->InitData(i, aDataFile); |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | else |
---|
| 84 | { |
---|
| 85 | theIsoFlag = false; |
---|
| 86 | G4cout << "unknown distribution found for Angular"<<G4endl; |
---|
| 87 | throw G4HadronicException(__FILE__, __LINE__, "unknown distribution needs implementation!!!"); |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | void G4NeutronHPAngular::SampleAndUpdate(G4ReactionProduct & aHadron) |
---|
| 92 | { |
---|
| 93 | if(theIsoFlag) |
---|
| 94 | { |
---|
| 95 | // G4cout << "Angular result "<<aHadron.GetTotalMomentum()<<" "; |
---|
| 96 | // @@@ add code for isotropic emission in CMS. |
---|
| 97 | G4double costheta = 2.*G4UniformRand()-1; |
---|
| 98 | G4double theta = std::acos(costheta); |
---|
| 99 | G4double phi = twopi*G4UniformRand(); |
---|
| 100 | G4double sinth = std::sin(theta); |
---|
| 101 | G4double en = aHadron.GetTotalMomentum(); |
---|
| 102 | G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) ); |
---|
| 103 | aHadron.SetMomentum( temp ); |
---|
| 104 | aHadron.Lorentz(aHadron, -1.*theTarget); |
---|
| 105 | } |
---|
| 106 | else |
---|
| 107 | { |
---|
| 108 | if(theAngularDistributionType == 1) // LAB |
---|
| 109 | { |
---|
| 110 | G4double en = aHadron.GetTotalMomentum(); |
---|
| 111 | G4ReactionProduct boosted; |
---|
| 112 | boosted.Lorentz(theNeutron, theTarget); |
---|
| 113 | G4double kineticEnergy = boosted.GetKineticEnergy(); |
---|
| 114 | G4double cosTh = theCoefficients->SampleMax(kineticEnergy); |
---|
| 115 | G4double theta = std::acos(cosTh); |
---|
| 116 | G4double phi = twopi*G4UniformRand(); |
---|
| 117 | G4double sinth = std::sin(theta); |
---|
| 118 | G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) ); |
---|
| 119 | aHadron.SetMomentum( temp ); |
---|
| 120 | } |
---|
| 121 | else if(theAngularDistributionType == 2) // costh in CMS |
---|
| 122 | { |
---|
| 123 | G4ReactionProduct boostedN; |
---|
| 124 | boostedN.Lorentz(theNeutron, theTarget); |
---|
| 125 | G4double kineticEnergy = boostedN.GetKineticEnergy(); |
---|
| 126 | G4double cosTh = theProbArray->Sample(kineticEnergy); |
---|
| 127 | G4double theta = std::acos(cosTh); |
---|
| 128 | G4double phi = twopi*G4UniformRand(); |
---|
| 129 | G4double sinth = std::sin(theta); |
---|
| 130 | |
---|
| 131 | G4ThreeVector temp(sinth*std::cos(phi), sinth*std::sin(phi), std::cos(theta) ); //CMS |
---|
| 132 | G4double en = aHadron.GetTotalEnergy(); // Target rest |
---|
| 133 | |
---|
| 134 | // get trafo from Target rest frame to CMS |
---|
| 135 | G4ReactionProduct boostedT; |
---|
| 136 | boostedT.Lorentz(theTarget, theTarget); |
---|
| 137 | |
---|
| 138 | G4ThreeVector the3Neutron = boostedN.GetMomentum(); |
---|
| 139 | G4double nEnergy = boostedN.GetTotalEnergy(); |
---|
| 140 | G4ThreeVector the3Target = boostedT.GetMomentum(); |
---|
| 141 | G4double tEnergy = boostedT.GetTotalEnergy(); |
---|
| 142 | G4double totE = nEnergy+tEnergy; |
---|
| 143 | G4ThreeVector the3trafo = -the3Target-the3Neutron; |
---|
| 144 | G4ReactionProduct trafo; // for transformation from CMS to target rest frame |
---|
| 145 | trafo.SetMomentum(the3trafo); |
---|
| 146 | G4double cmsMom = std::sqrt(the3trafo*the3trafo); |
---|
| 147 | G4double sqrts = std::sqrt((totE-cmsMom)*(totE+cmsMom)); |
---|
| 148 | trafo.SetMass(sqrts); |
---|
| 149 | trafo.SetTotalEnergy(totE); |
---|
| 150 | |
---|
| 151 | G4double gamma = trafo.GetTotalEnergy()/trafo.GetMass(); |
---|
| 152 | G4double cosalpha = temp*trafo.GetMomentum()/trafo.GetTotalMomentum()/temp.mag(); |
---|
| 153 | G4double fac = cosalpha*trafo.GetTotalMomentum()/trafo.GetMass(); |
---|
| 154 | fac*=gamma; |
---|
| 155 | |
---|
| 156 | G4double mom; |
---|
| 157 | // For G4FPE_DEBUG ON |
---|
| 158 | G4double mom2 = ( en*fac*en*fac - |
---|
| 159 | (fac*fac - gamma*gamma)* |
---|
| 160 | (en*en - gamma*gamma*aHadron.GetMass()*aHadron.GetMass()) |
---|
| 161 | ); |
---|
| 162 | if ( mom2 > 0.0 ) |
---|
| 163 | mom = std::sqrt( mom2 ); |
---|
| 164 | else |
---|
| 165 | mom = 0.0; |
---|
| 166 | |
---|
| 167 | mom = -en*fac - mom; |
---|
| 168 | mom /= (fac*fac-gamma*gamma); |
---|
| 169 | temp = mom*temp; |
---|
| 170 | |
---|
| 171 | aHadron.SetMomentum( temp ); // now all in CMS |
---|
| 172 | aHadron.SetTotalEnergy( std::sqrt( mom*mom + aHadron.GetMass()*aHadron.GetMass() ) ); |
---|
| 173 | aHadron.Lorentz(aHadron, trafo); // now in target rest frame |
---|
| 174 | } |
---|
| 175 | else |
---|
| 176 | { |
---|
| 177 | throw G4HadronicException(__FILE__, __LINE__, "Tried to sample non isotropic neutron angular"); |
---|
| 178 | } |
---|
| 179 | } |
---|
| 180 | aHadron.Lorentz(aHadron, -1.*theTarget); |
---|
| 181 | // G4cout << aHadron.GetMomentum()<<" "; |
---|
| 182 | // G4cout << aHadron.GetTotalMomentum()<<G4endl; |
---|
| 183 | } |
---|