G4NeutronHPDeExGammas.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 // 080801 Prohibit level transition to oneself by T. Koi
00031 //
00032 #include "G4NeutronHPDeExGammas.hh"
00033 #include "G4SystemOfUnits.hh"
00034 
00035 void G4NeutronHPDeExGammas::Init(std::ifstream & aDataFile)
00036 {
00037   G4NeutronHPGamma ** theGammas = new G4NeutronHPGamma * [50];
00038   G4int nGammas = 0;
00039   G4int nBuff = 50;
00040   for(;;)
00041   {
00042     G4NeutronHPGamma * theNew = new G4NeutronHPGamma;
00043     if(!theNew->Init(aDataFile))
00044     {
00045       delete theNew;
00046       break;
00047     }
00048     else
00049     {
00050       if(nGammas==nBuff)
00051       {
00052         nBuff+=50;
00053         G4NeutronHPGamma ** buffer = new G4NeutronHPGamma * [nBuff];
00054         for(G4int i=0;i<nGammas;i++) buffer[i] = theGammas[i];
00055         delete [] theGammas;
00056         theGammas = buffer;
00057       }
00058       theGammas[nGammas] = theNew;
00059       nGammas++;
00060     }
00061   }
00062   // all gammas are in. Now sort them into levels.
00063 
00064   // count the levels
00065 
00066   G4double currentE = 0;
00067   G4double nextE = 0;
00068   G4int i;
00069   G4double epsilon = 0.01*keV;
00070   for(i=0; i<nGammas; i++)
00071   {
00072     nextE = theGammas[i]->GetLevelEnergy();
00073     if(std::abs(currentE-nextE)>epsilon) nLevels++;
00074     currentE = nextE;
00075   }
00076 
00077   // Build the levels
00078 
00079   theLevels = new G4NeutronHPLevel[nLevels];
00080   levelStart = new G4int [nLevels];
00081   levelSize = new G4int [nLevels];
00082 
00083   // fill the levels
00084 
00085   currentE = 0;
00086   nextE = 0;
00087   G4int levelCounter=-1;
00088   for(i=0; i<nGammas; i++)
00089   {
00090     nextE = theGammas[i]->GetLevelEnergy();
00091     if(std::abs(currentE-nextE)>epsilon) 
00092     {
00093       levelCounter++;
00094       levelStart[levelCounter] = i;
00095       levelSize[levelCounter] = 0;
00096     }
00097     levelSize[levelCounter]++;
00098     currentE = nextE;
00099   }
00100 
00101   for(i=0; i<nLevels; i++)
00102   {
00103     theLevels[i].SetNumberOfGammas(levelSize[i]);
00104     for(G4int ii=levelStart[i]; ii<levelStart[i]+levelSize[i]; ii++)
00105     {
00106       theLevels[i].SetGamma(ii-levelStart[i], theGammas[ii]);
00107     }
00108   }
00109 
00110 // set the next relation in the gammas.
00111   G4double levelE, gammaE, currentLevelE;
00112   G4double min; 
00113   for(i=0; i<nGammas; i++)
00114   {
00115     G4int it=-1;
00116     gammaE = theGammas[i]->GetGammaEnergy();
00117     currentLevelE = theGammas[i]->GetLevelEnergy();
00118     min = currentLevelE-gammaE-epsilon;
00119     for(G4int ii=0; ii<nLevels; ii++)
00120     {
00121       levelE = theLevels[ii].GetLevelEnergy();
00122       if(std::abs(currentLevelE-(levelE+gammaE))<min)
00123       {
00124         min = std::abs(currentLevelE-(levelE+gammaE));
00125         it = ii;
00126       }
00127     }
00128 //080728
00129     if ( it != -1 && currentLevelE == theLevels[it].GetLevelEnergy() )
00130     {
00131        //TK Comment; Some data file in /Inelastic/Gammas has inconsistent level data (no level to transit)
00132        //G4cout << "DeExGammas Transition level error: it " << it << " " << currentLevelE << " " << gammaE << " " << theLevels[it-1].GetLevelEnergy() << " " << currentLevelE - theLevels[it-1].GetLevelEnergy() << G4endl;
00133        // Forced to connect the next(previous) level 
00134        it +=-1;
00135     }
00136 //080728
00137     if(it!=-1) theGammas[i]->SetNext(&theLevels[it]);
00138   }
00139   // some garbage collection
00140 
00141   delete [] theGammas;
00142 
00143   // and we are Done.
00144 }

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