G4NeutronHPAngularP.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 #ifndef G4NeutronHPAngularP_h
00030 #define G4NeutronHPAngularP_h 1
00031 
00032 #include <CLHEP/Units/SystemOfUnits.h>
00033 
00034 #include "globals.hh"
00035 #include "G4InterpolationManager.hh"
00036 
00037 class G4NeutronHPAngularP
00038 {
00039   public:
00040   
00041   G4NeutronHPAngularP()
00042   {
00043     theCosTh = 0;
00044     theProb = 0;
00045   }
00046   ~G4NeutronHPAngularP()
00047   {
00048     if(theCosTh!=0) delete [] theCosTh;
00049     if(theProb!=0) delete [] theProb;
00050   }
00051   
00052   inline void Init(std::ifstream & aDataFile)
00053   {
00054     G4double eNeu, cosTheta, probDist;
00055     G4int nProb;
00056     aDataFile >> eNeu >> nProb;
00057     theManager.Init(aDataFile);
00058     eNeu *= CLHEP::eV;
00059     Init(eNeu, nProb);
00060     for (G4int iii=0; iii<nProb; iii++)
00061     {
00062       aDataFile >> cosTheta >> probDist;
00063       SetCosTh(iii, cosTheta);
00064       SetProb(iii,probDist);
00065     }  
00066   }
00067   
00068   inline void Init(G4double e, G4int n)
00069   {
00070     theCosTh = new G4double[n];
00071     theProb = new G4double[n];
00072     theEnergy = e;
00073     nCoeff = n;
00074   }
00075   
00076   inline void SetEnergy(G4double energy){ theEnergy = energy; }
00077   inline void SetCosTh(G4int l, G4double coeff) {theCosTh[l]=coeff;}
00078   inline void SetProb(G4int l, G4double coeff) {theProb[l]=coeff;}
00079   
00080   inline G4double GetCosTh(G4int l) {return theCosTh[l];}
00081   inline G4double GetProb(G4int l) {return theProb[l];}
00082   inline G4double GetEnergy(){return theEnergy;}
00083   inline G4int GetNumberOfPoints(){ return nCoeff; }
00084   inline G4double GetCosTh()
00085   {
00086     G4int i;
00087     G4double rand = G4UniformRand();
00088     G4double run=0, runo=0;
00089     for (i=0; i<GetNumberOfPoints(); i++)
00090     {
00091       runo=run;
00092       run += GetProb(i);
00093       if(run>rand) break;
00094     }
00095     if(i == GetNumberOfPoints()) i--;
00096     G4double costh = theInt.Interpolate(theManager.GetScheme(i), rand, 
00097                                         runo, run, GetCosTh(i-1), GetCosTh(i));
00098     return costh;
00099   }
00100   
00101   private:
00102   
00103   G4double theEnergy; // neutron energy
00104   G4NeutronHPInterpolator theInt; // knows tointerpolate
00105   G4int nCoeff;
00106   G4InterpolationManager theManager; // knows the interpolation between stores
00107   G4double * theCosTh;
00108   G4double * theProb; // probability distribution as fcn of theta
00109                       // integral normalised to 1.
00110 };
00111 #endif

Generated on Mon May 27 17:48:59 2013 for Geant4 by  doxygen 1.4.7