G4InterpolationManager.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 "G4InterpolationManager.hh"
00031 #include "G4HadronicException.hh"
00032 
00033    G4InterpolationScheme G4InterpolationManager::MakeScheme(G4int it)
00034    {
00035      G4InterpolationScheme result(LINLIN);
00036      switch(it)
00037      {
00038       case 1:
00039         result = HISTO;
00040         break;
00041       case 2:
00042         result = LINLIN;
00043         break;
00044       case 3:
00045         result = LINLOG;
00046         break;
00047       case 4:
00048         result = LOGLIN;
00049         break;
00050       case 5:
00051         result = LOGLOG;
00052         break;
00053       case 11:
00054         result = CHISTO;
00055         break;
00056       case 12:
00057         result = CLINLIN;
00058         break;
00059       case 13:
00060         result = CLINLOG;
00061         break;
00062       case 14:
00063         result = CLOGLIN;
00064         break;
00065       case 15:
00066         result = CLOGLOG;
00067         break;
00068       case 21:
00069         result = UHISTO;
00070         break;
00071       case 22:
00072         result = ULINLIN;
00073         break;
00074       case 23:
00075         result = ULINLOG;
00076         break;
00077       case 24:
00078         result = ULOGLIN;
00079         break;
00080       case 25:
00081         result = ULOGLOG;
00082         break;
00083       default:
00084         throw G4HadronicException(__FILE__, __LINE__, "G4InterpolationManager: unknown interpolation scheme");
00085         break;        
00086      }
00087      return result;
00088    }
00089 
00090    void G4InterpolationManager::AppendScheme(G4int aPoint, const G4InterpolationScheme & aScheme)
00091    {
00092      if(aPoint!=nEntries) 
00093      {
00094        G4cout <<"G4InterpolationManager::AppendScheme - "<<aPoint<<" "<<nEntries<<G4endl;
00095        throw G4HadronicException(__FILE__, __LINE__, "Wrong usage of G4InterpolationManager::AppendScheme");
00096      }
00097      if(nEntries==0)
00098      {
00099        nEntries = 1;
00100        nRanges = 1;
00101        start[0] = 0;
00102        range [0] = 1;
00103        scheme[0] = aScheme;
00104      }
00105      else if(aScheme==scheme[nRanges-1])
00106      {
00107        ++range[nRanges-1];
00108        nEntries++;
00109      }
00110      else
00111      {
00112        nEntries++;
00113        nRanges++;
00114        G4int i;
00115        G4int * buffer = new G4int[nRanges];
00116        G4int * buffer1 = new G4int[nRanges];
00117        G4InterpolationScheme* buff2 = new G4InterpolationScheme[nRanges];
00118        for(i=0; i<nRanges-1; i++) 
00119        {
00120          buffer[i]  = start[i];
00121          buffer1[i] = range[i];
00122          buff2[i]   = scheme[i];
00123        }
00124        delete [] start;
00125        delete [] range;
00126        delete [] scheme;
00127        start  = buffer;
00128        range  = buffer1;
00129        scheme = buff2;
00130        start[nRanges-1]  = start[nRanges-2]+range[nRanges-2];
00131        range[nRanges-1]  = 1;
00132        scheme[nRanges-1] = aScheme;
00133      }
00134    }

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