G4NeutronHPLevel.cc

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 // neutron_hp -- source file
00027 // J.P. Wellisch, Nov-1996
00028 // A prototype of the low energy neutron transport model.
00029 //
00030 #include "G4NeutronHPLevel.hh"
00031 #include "G4NeutronHPGamma.hh"
00032 
00033   G4NeutronHPLevel::~G4NeutronHPLevel() 
00034   {
00035     if(theGammas != 0)
00036     {
00037       for(G4int i=0; i<nGammas; i++) delete theGammas[i];
00038     }
00039     delete [] theGammas;
00040   }
00041 
00042   void G4NeutronHPLevel::SetNumberOfGammas(G4int aGammas)
00043   {
00044     nGammas = aGammas;
00045     if(theGammas != 0)
00046     {
00047       for(G4int i=0; i<nGammas; i++) delete theGammas[i];
00048     }
00049     delete [] theGammas; 
00050     theGammas = new G4NeutronHPGamma * [nGammas];
00051   }
00052 
00053   void G4NeutronHPLevel::SetGamma(G4int i, G4NeutronHPGamma * aGamma)
00054   {
00055     theGammas[i] = aGamma;
00056     SetLevelEnergy(aGamma->GetLevelEnergy());
00057   }
00058 
00059   G4double G4NeutronHPLevel::GetGammaEnergy(G4int i)
00060   {
00061     return theGammas[i]->GetGammaEnergy();
00062   }
00063   
00064   G4DynamicParticleVector * G4NeutronHPLevel::GetDecayGammas()
00065   {
00066     G4DynamicParticleVector * theResult;
00067     G4double sum = 0;
00068     G4double * running = new G4double[nGammas];
00069     running[0] = 0;
00070     G4int i;
00071     for(i=0; i<nGammas; i++)
00072     {
00073       if(i!=0) running[i]=running[i-1];
00074       running[i]+=theGammas[i]->GetWeight();
00075     }
00076     sum = running[nGammas-1];
00077     G4int it(0);
00078     G4double random = G4UniformRand();
00079     for(i=0; i<nGammas; i++)
00080     {
00081       it = i;
00082       if(random*sum < running[i]) break;
00083     }
00084     delete [] running;
00085     theResult = theGammas[it]->GetDecayGammas();
00086     return theResult;
00087   }

Generated on Mon May 27 17:49:02 2013 for Geant4 by  doxygen 1.4.7