Ignore:
Timestamp:
Nov 5, 2010, 3:45:55 PM (14 years ago)
Author:
garnier
Message:

update ti head

Location:
trunk/source/global/management
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/global/management/GNUmakefile

    r1058 r1340  
    1 # $Id: GNUmakefile,v 1.6 2009/01/27 08:45:28 gcosmo Exp $
     1# $Id: GNUmakefile,v 1.8 2010/10/27 07:40:06 gcosmo Exp $
    22# --------------------------------------------------------------
    33# GNUmakefile for global management.  Gabriele Cosmo, 26/9/96.
     
    1212include $(G4INSTALL)/config/architecture.gmk
    1313
    14 CPPFLAGS += -DG4IOS_EXPORT
     14CPPFLAGS += -DG4IOS_ALLOC_EXPORT
    1515ifdef G4RF_DEBUG
    1616  CPPFLAGS += -DG4RF_DEBUG
  • trunk/source/global/management/include/G4Allocator.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4Allocator.hh,v 1.20 2010/03/30 08:17:24 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4Allocator.hh,v 1.21 2010/04/01 12:43:12 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    6666
    6767    inline void ResetStorage();
    68       // Returns allocated storage to the free store, resets
    69       // allocator and page sizes.
     68      // Returns allocated storage to the free store, resets allocator.
    7069      // Note: contents in memory are lost using this call !
    7170
    7271    inline size_t GetAllocatedSize() const;
    7372      // Returns the size of the total memory allocated
     73    inline int GetNoPages() const;
     74      // Returns the total number of allocated pages
     75    inline size_t GetPageSize() const;
     76      // Returns the current size of a page
     77    inline void IncreasePageSize( unsigned int sz );
     78      // Resets allocator and increases default page size of a given factor
    7479
    7580  public:  // without description
     
    213218
    214219// ************************************************************
     220// GetNoPages
     221// ************************************************************
     222//
     223template <class Type>
     224int G4Allocator<Type>::GetNoPages() const
     225{
     226  return mem.GetNoPages();
     227}
     228
     229// ************************************************************
     230// GetPageSize
     231// ************************************************************
     232//
     233template <class Type>
     234size_t G4Allocator<Type>::GetPageSize() const
     235{
     236  return mem.GetPageSize();
     237}
     238
     239// ************************************************************
     240// IncreasePageSize
     241// ************************************************************
     242//
     243template <class Type>
     244void G4Allocator<Type>::IncreasePageSize( unsigned int sz )
     245{
     246  ResetStorage();
     247  mem.GrowPageSize(sz);
     248}
     249
     250// ************************************************************
    215251// operator==
    216252// ************************************************************
  • trunk/source/global/management/include/G4AllocatorPool.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4AllocatorPool.hh,v 1.5 2006/06/29 19:01:18 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4AllocatorPool.hh,v 1.7 2010/07/14 10:45:46 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    5858      // Destructor. Return storage to the free store
    5959
    60     G4AllocatorPool(const G4AllocatorPool& right);
    61       // Copy constructor
    62 
    6360    inline void* Alloc();
    6461      // Allocate one element
     
    7168      // Return storage to the free store
    7269
     70    inline int  GetNoPages() const;
     71      // Return the total number of allocated pages
     72    inline unsigned int  GetPageSize() const;
     73      // Accessor for default page size
     74    inline void GrowPageSize( unsigned int factor );
     75      // Increase default page size by a given factor
     76
    7377  private:
    7478
     79    G4AllocatorPool(const G4AllocatorPool& right);
     80      // Provate copy constructor
    7581    G4AllocatorPool& operator= (const G4AllocatorPool& right);
    7682      // Private equality operator
     
    97103
    98104    const unsigned int esize;
    99     const unsigned int csize;
     105    unsigned int csize;
    100106    G4PoolChunk* chunks;
    101107    G4PoolLink* head;
     
    142148}
    143149
     150// ************************************************************
     151// GetNoPages
     152// ************************************************************
     153//
     154inline int
     155G4AllocatorPool::GetNoPages() const
     156{
     157  return nchunks;
     158}
     159
     160// ************************************************************
     161// GetPageSize
     162// ************************************************************
     163//
     164inline unsigned int
     165G4AllocatorPool::GetPageSize() const
     166{
     167  return csize;
     168}
     169
     170// ************************************************************
     171// GrowPageSize
     172// ************************************************************
     173//
     174inline void
     175G4AllocatorPool::GrowPageSize( unsigned int sz )
     176{
     177  csize = (sz) ? sz*csize : csize;
     178}
     179
    144180#endif
  • trunk/source/global/management/include/G4FPEDetection.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4FPEDetection.hh,v 1.2 2006/11/15 16:00:18 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4FPEDetection.hh,v 1.5 2010/10/14 17:02:52 mkelsey Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    3232//
    3333// -----------------------------------------------------------------------
    34 // This global method should be used on LINUX platforms with gcc compiler
    35 // for activating NaN detection and FPE signals, and forcing abortion of
    36 // the application at the time these are detected.
     34// This global method should be used on LINUX or MacOSX platforms with gcc
     35// compiler for activating NaN detection and FPE signals, and forcing
     36// abortion of the application at the time these are detected.
    3737// Meant to be used for debug purposes, can be activated by compiling the
    3838// "run" module with the flag G4FPE_DEBUG set in the environment.
     
    4141#ifndef G4FPEDetection_h
    4242#define G4FPEDetection_h 1
     43
     44#include <iostream>
     45#include <stdlib.h>  /* abort(), exit() */
    4346
    4447#ifdef __linux__
     
    4851  #include <csignal>
    4952
    50   #include <iostream>
    51 
    5253  struct sigaction termaction, oldaction;
    5354
    54   void TerminationSignalHandler(int sig)
     55  static void TerminationSignalHandler(int sig, siginfo_t* sinfo, void* /* context */)
    5556  {
    5657    std::cerr << "ERROR: " << sig;
    57     std::string message;
    58     switch (SIGFPE)
    59     {
     58    std::string message = "Floating-point exception (FPE).";
     59
     60    if (sinfo) {
     61      switch (sinfo->si_code) {
     62#ifdef FPE_NOOP         /* BUG: MacOSX uses this instead of INTDIV */
     63      case FPE_NOOP:
     64#endif
    6065      case FPE_INTDIV:
    6166        message = "Integer divide by zero.";
     
    8590        message = "Unknown error.";
    8691        break;
    87     }
     92      }
     93    }
     94
    8895    std::cerr << " - " << message << std::endl;
    89 
     96   
    9097    ::abort();
    9198  }
    9299
    93   void InvalidOperationDetection()
     100  static void InvalidOperationDetection()
    94101  {
    95102    std::cout << std::endl
     
    106113    //(void) feenableexcept( FE_UNDERFLOW );
    107114
    108     sigset_t *def_set;
    109     def_set=&termaction.sa_mask;
    110     sigfillset(def_set);
    111     sigdelset(def_set,SIGFPE);
    112     termaction.sa_handler=TerminationSignalHandler;
    113     termaction.sa_flags=0;
    114     sigaction(SIGFPE, &termaction,&oldaction);
    115   }
    116 #endif
    117 #else
    118   void InvalidOperationDetection() {;}
    119 #endif
    120 
    121 #endif
     115    sigdelset(&termaction.sa_mask,SIGFPE);
     116    termaction.sa_sigaction=TerminationSignalHandler;
     117    termaction.sa_flags=SA_SIGINFO;
     118    sigaction(SIGFPE, &termaction, &oldaction);
     119  }
     120#endif
     121#elif __MACH__      /* MacOSX */
     122
     123  #include <fenv.h>
     124  #include <signal.h>
     125
     126  #define DEFINED_PPC      (defined(__ppc__) || defined(__ppc64__))
     127  #define DEFINED_INTEL    (defined(__i386__) || defined(__x86_64__))
     128
     129  #if DEFINED_PPC
     130
     131    #define FE_EXCEPT_SHIFT 22  // shift flags right to get masks
     132    #define FM_ALL_EXCEPT    FE_ALL_EXCEPT >> FE_EXCEPT_SHIFT
     133
     134    static inline int feenableexcept (unsigned int excepts)
     135    {
     136      static fenv_t fenv;
     137      unsigned int new_excepts = (excepts & FE_ALL_EXCEPT) >> FE_EXCEPT_SHIFT,
     138                   old_excepts;  // all previous masks
     139
     140      if ( fegetenv (&fenv) )  { return -1; }
     141      old_excepts = (fenv & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
     142      fenv = (fenv & ~new_excepts) | new_excepts;
     143
     144      return ( fesetenv (&fenv) ? -1 : old_excepts );
     145    }
     146
     147    static inline int fedisableexcept (unsigned int excepts)
     148    {
     149      static fenv_t fenv;
     150      unsigned int still_on = ~((excepts & FE_ALL_EXCEPT) >> FE_EXCEPT_SHIFT),
     151                   old_excepts;  // previous masks
     152
     153      if ( fegetenv (&fenv) )  { return -1; }
     154      old_excepts = (fenv & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
     155      fenv &= still_on;
     156
     157      return ( fesetenv (&fenv) ? -1 : old_excepts );
     158    }
     159
     160  #elif DEFINED_INTEL
     161
     162    static inline int feenableexcept (unsigned int excepts)
     163    {
     164      static fenv_t fenv;
     165      unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
     166                   old_excepts;  // previous masks
     167
     168      if ( fegetenv (&fenv) )  { return -1; }
     169      old_excepts = fenv.__control & FE_ALL_EXCEPT;
     170
     171      // unmask
     172      //
     173      fenv.__control &= ~new_excepts;
     174      fenv.__mxcsr   &= ~(new_excepts << 7);
     175
     176      return ( fesetenv (&fenv) ? -1 : old_excepts );
     177    }
     178
     179    static inline int fedisableexcept (unsigned int excepts)
     180    {
     181      static fenv_t fenv;
     182      unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
     183                   old_excepts;  // all previous masks
     184
     185      if ( fegetenv (&fenv) )  { return -1; }
     186      old_excepts = fenv.__control & FE_ALL_EXCEPT;
     187
     188      // mask
     189      //
     190      fenv.__control |= new_excepts;
     191      fenv.__mxcsr   |= new_excepts << 7;
     192
     193      return ( fesetenv (&fenv) ? -1 : old_excepts );
     194    }
     195
     196  #endif  /* PPC or INTEL enabling */
     197
     198  static void TerminationSignalHandler(int sig, siginfo_t* sinfo, void* /* context */)
     199  {
     200    std::cerr << "ERROR: " << sig;
     201    std::string message = "Floating-point exception (FPE).";
     202
     203    if (sinfo) {
     204      switch (sinfo->si_code) {
     205#ifdef FPE_NOOP         /* BUG: MacOSX uses this instead of INTDIV */
     206      case FPE_NOOP:
     207#endif
     208      case FPE_INTDIV:
     209        message = "Integer divide by zero.";
     210        break;
     211      case FPE_INTOVF:
     212        message = "Integer overflow.";
     213        break;
     214      case FPE_FLTDIV:
     215        message = "Floating point divide by zero.";
     216        break;
     217      case FPE_FLTOVF:
     218        message = "Floating point overflow.";
     219        break;
     220      case FPE_FLTUND:
     221        message = "Floating point underflow.";
     222        break;
     223      case FPE_FLTRES:
     224        message = "Floating point inexact result.";
     225        break;
     226      case FPE_FLTINV:
     227        message = "Floating point invalid operation.";
     228        break;
     229      case FPE_FLTSUB:
     230        message = "Subscript out of range.";
     231        break;
     232      default:
     233        message = "Unknown error.";
     234        break;
     235      }
     236    }
     237
     238    std::cerr << " - " << message << std::endl;
     239   
     240    ::abort();
     241  }
     242
     243  static void InvalidOperationDetection()
     244  {
     245    struct sigaction termaction, oldaction;
     246
     247    std::cout << std::endl
     248              << "        "
     249              << "############################################" << std::endl
     250              << "        "
     251              << "!!! WARNING - FPE detection is activated !!!" << std::endl
     252              << "        "
     253              << "############################################" << std::endl;
     254
     255    feenableexcept ( FE_DIVBYZERO );
     256    feenableexcept ( FE_INVALID   );
     257    // fedisableexcept( FE_OVERFLOW  );
     258    // fedisableexcept( FE_UNDERFLOW );
     259
     260    sigdelset(&termaction.sa_mask,SIGFPE);
     261    termaction.sa_sigaction=TerminationSignalHandler;
     262    termaction.sa_flags=SA_SIGINFO;
     263    sigaction(SIGFPE, &termaction, &oldaction);
     264  }
     265#else  /* Not Linux, nor MacOSX ... */
     266
     267  static void InvalidOperationDetection() {;}
     268
     269#endif
     270
     271#endif
  • trunk/source/global/management/include/G4PhysicsVector.icc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4PhysicsVector.icc,v 1.28 2010/05/28 05:13:43 kurasige Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4PhysicsVector.icc,v 1.30 2010/09/20 16:22:56 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
  • trunk/source/global/management/include/G4Pow.hh

    r1337 r1340  
    2424// ********************************************************************
    2525//
    26 // $Id: G4Pow.hh,v 1.5 2010/05/28 08:18:03 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     26// $Id: G4Pow.hh,v 1.7 2010/08/24 08:12:08 gcosmo Exp $
     27// GEANT4 tag $Name: global-V09-03-22 $
    2828//
    2929//
     
    8282    inline G4double powZ(G4int Z, G4double y);
    8383    inline G4double powA(G4double A, G4double y);
     84           G4double powN(G4double x, G4int n);
    8485
    8586    // Fast factorial
    8687    //
    8788    inline G4double factorial(G4int Z);
     89    inline G4double logfactorial(G4int Z);
    8890
    8991  private:
     
    101103    G4DataVector lz;
    102104    G4DataVector fact;
     105    G4DataVector logfact;
    103106};
    104107
     
    190193}
    191194
     195inline G4double G4Pow::logfactorial(G4int Z)
     196{
     197  return logfact[Z];
     198}
     199
    192200// -------------------------------------------------------------------
    193201
  • trunk/source/global/management/include/G4ios.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4ios.hh,v 1.10 2006/06/29 19:03:43 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4ios.hh,v 1.12 2010/10/27 07:40:06 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    4242#include <iostream>
    4343
    44 #if defined G4IOS_EXPORT
     44#if defined G4IOS_ALLOC_EXPORT
    4545  extern G4DLLEXPORT std::ostream G4cout;
    4646  extern G4DLLEXPORT std::ostream G4cerr;
  • trunk/source/global/management/include/G4strstreambuf.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4strstreambuf.hh,v 1.16 2007/11/13 17:35:06 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4strstreambuf.hh,v 1.18 2010/10/27 07:40:06 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929// ====================================================================
    3030//
     
    4141class G4strstreambuf;
    4242
    43 #if defined G4IOS_EXPORT
     43#if defined G4IOS_ALLOC_EXPORT
    4444extern G4DLLEXPORT G4strstreambuf G4coutbuf;
    4545extern G4DLLEXPORT G4strstreambuf G4cerrbuf;
  • trunk/source/global/management/include/templates.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: templates.hh,v 1.13 2008/08/15 12:15:53 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: templates.hh,v 1.14 2010/07/16 15:48:51 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    109109#endif
    110110
     111#ifndef INT_MAX   /* Max decimal value of a int */
     112#define INT_MAX   std::numeric_limits<int>::max()   // 2147483647
     113#endif
     114
     115#ifndef INT_MIN   /* Min decimal value of a int */
     116#define INT_MIN   std::numeric_limits<int>::min()   // -2147483648
     117#endif
     118
    111119//---------------------------------
    112120
  • trunk/source/global/management/src/G4AllocatorPool.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4AllocatorPool.cc,v 1.4 2006/06/29 19:03:57 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4AllocatorPool.cc,v 1.6 2010/07/14 10:45:46 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    5555//
    5656G4AllocatorPool::G4AllocatorPool(const G4AllocatorPool& right)
    57   : esize(right.esize), csize(right.csize)
     57  : esize(right.esize), csize(right.csize),
     58    chunks(right.chunks), head(right.head), nchunks(right.nchunks)
    5859{
    59   *this = right;
    6060}
    6161
  • trunk/source/global/management/src/G4DataVector.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4DataVector.cc,v 1.9 2007/11/13 17:35:06 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4DataVector.cc,v 1.12 2010/11/01 13:55:53 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    8888{
    8989  clear();
    90   size_t sizeV=0;
     90  G4int sizeV=0;
    9191 
    9292  // retrieve in ascii mode
     
    9696    fIn >> sizeV;
    9797    if (fIn.fail())  { return false; }
    98    
     98    if (sizeV<=0)
     99    {
     100#ifdef G4VERBOSE 
     101      G4cerr << "G4DataVector::Retrieve():";
     102      G4cerr << " Invalid vector size: " << sizeV << G4endl;
     103#endif
     104      return false;
     105    }
     106
    99107    reserve(sizeV);
    100     for(size_t i = 0; i < sizeV ; i++)
     108    for(G4int i = 0; i < sizeV ; i++)
    101109    {
    102110      G4double vData=0.0;
     
    120128
    121129  reserve(sizeV);
    122   for(size_t i = 0; i < sizeV; i++)
     130  for(G4int i = 0; i < sizeV; i++)
    123131  {
    124132    push_back(value[i]);
     
    130138std::ostream& operator<<(std::ostream& out, const G4DataVector& pv)
    131139{
    132   out << pv.size() << G4endl;
     140  out << pv.size() << std::setprecision(12) << G4endl;
    133141  for(size_t i = 0; i < pv.size(); i++)
    134142  {
    135     out << std::setprecision(12) << pv[i] << G4endl;
     143    out << pv[i] << G4endl;
    136144  }
     145  out << std::setprecision(6);
    137146
    138147  return out;
  • trunk/source/global/management/src/G4ErrorPropagatorData.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4ErrorPropagatorData.cc,v 1.5 2009/05/19 13:31:47 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4ErrorPropagatorData.cc,v 1.7 2010/10/01 16:36:31 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    3838
    3939G4ErrorPropagatorData* G4ErrorPropagatorData::theErrorPropagatorData = 0;
    40 
    4140G4int G4ErrorPropagatorData::theVerbosity = 0;
    4241
    4342//-------------------------------------------------------------------
    4443
    45 G4ErrorPropagatorData::~G4ErrorPropagatorData()
     44G4ErrorPropagatorData::G4ErrorPropagatorData()
     45  : theMode(G4ErrorMode_PropTest), theState(G4ErrorState_PreInit),
     46    theStage(G4ErrorStage_Inflation), theTarget(0)
    4647{
    4748}
    4849
    49 G4ErrorPropagatorData::G4ErrorPropagatorData()
     50G4ErrorPropagatorData::~G4ErrorPropagatorData()
    5051{
    51   theStage = G4ErrorStage_Inflation;
    5252}
    5353
  • trunk/source/global/management/src/G4OrderedTable.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4OrderedTable.cc,v 1.6 2007/11/13 17:35:06 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4OrderedTable.cc,v 1.8 2010/11/01 13:55:53 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    7171  {
    7272#ifdef G4VERBOSE 
    73     G4cerr << "G4OrderedTable::::Store  ";
    74     G4cerr << " Can not open file " << fileName << G4endl;
     73    G4cerr << "G4OrderedTable::::Store():";
     74    G4cerr << " Cannot open file: " << fileName << G4endl;
    7575#endif
    7676    fOut.close();
     
    123123  {
    124124#ifdef G4VERBOSE 
    125     G4cerr << "G4OrderedTable::Retrieve  ";
    126     G4cerr << " Can not open file " << fileName << G4endl;
     125    G4cerr << "G4OrderedTable::Retrieve():";
     126    G4cerr << " Cannot open file: " << fileName << G4endl;
    127127#endif
    128128    fIn.close();
     
    134134 
    135135  // Number of elements
    136   size_t tableSize=0;
     136  G4int tableSize=0;
    137137  if (!ascii)
    138138  {
     
    143143    fIn >> tableSize;
    144144  }
     145  if (tableSize<=0)
     146  {
     147#ifdef G4VERBOSE 
     148    G4cerr << "G4OrderedTable::Retrieve():";
     149    G4cerr << " Invalid table size: " << tableSize << G4endl;
     150#endif
     151    return false;
     152  }
    145153  reserve(tableSize);
    146154
    147155  // Physics Vector
    148   for (size_t idx=0; idx<tableSize; ++idx)
     156  for (G4int idx=0; idx<tableSize; ++idx)
    149157  {
    150158    G4int vType=0;
     
    160168    {
    161169#ifdef G4VERBOSE 
    162       G4cerr << "G4OrderedTable::Retrieve  ";
    163       G4cerr << " illegal Data Vector type " << vType << " in  ";
     170      G4cerr << "G4OrderedTable::Retrieve():";
     171      G4cerr << " Illegal Data Vector type: " << vType << " in  ";
    164172      G4cerr << fileName << G4endl;
    165173#endif         
     
    173181    {
    174182#ifdef G4VERBOSE 
    175       G4cerr << "G4OrderedTable::Retrieve  ";
    176       G4cerr << " error in retreiving " << idx
    177              << "-th Physics Vector from file ";
     183      G4cerr << "G4OrderedTable::Retrieve(): ";
     184      G4cerr << " Rrror in retreiving " << idx
     185             << "-th Physics Vector from file: ";
    178186      G4cerr << fileName << G4endl;
    179187#endif         
    180188      fIn.close();
     189      delete pVec;
    181190      return false;
    182191    }
  • trunk/source/global/management/src/G4PhysicsTable.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4PhysicsTable.cc,v 1.15 2007/11/13 17:35:06 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4PhysicsTable.cc,v 1.17 2010/11/01 13:55:53 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    3636// ------------------------------------------------------------
    3737
    38 #include "G4PhysicsVector.hh"
    39 #include "G4PhysicsTable.hh"
    4038#include <iostream>
    4139#include <fstream>
    4240#include <iomanip>
    4341
    44 G4PhysicsTable::G4PhysicsTable()
    45   : G4PhysCollection()
    46 {
    47 }
    48 
    49 G4PhysicsTable::G4PhysicsTable(size_t cap)
    50   : G4PhysCollection()
    51 {
    52   reserve(cap);
    53   vecFlag.reserve(cap);
    54 }
    55 
    56 G4PhysicsTable::G4PhysicsTable(const G4PhysicsTable& right)
    57   : G4PhysCollection()
    58 {
    59   *this = right;
    60 }
    61 
    62 G4PhysicsTable& G4PhysicsTable::operator=(const G4PhysicsTable& right)
    63 {
    64   if (this != &right)
    65   {
    66     size_t idx = 0;
    67     for (G4PhysCollection::const_iterator itr=right.begin();
    68          itr!=right.end(); ++itr )
    69     {
    70       G4PhysCollection::push_back(*itr);
    71       vecFlag.push_back(right.GetFlag(idx));
    72       idx +=1;
    73     }
    74   }
    75   return *this;
    76 }
    77 
    78 G4PhysicsTable::~G4PhysicsTable()
    79 {
    80   G4PhysCollection::clear();
    81   vecFlag.clear();
    82 }
    83  
    84 void   G4PhysicsTable::resize(size_t siz, G4PhysicsVector* vec)
    85 {
    86   G4PhysCollection::resize(siz, vec);
    87   vecFlag.resize(siz, true);
    88 }
    89 
    90 G4bool G4PhysicsTable::StorePhysicsTable(const G4String& fileName,
    91                                          G4bool          ascii)
    92 {
    93   std::ofstream fOut; 
    94  
    95   // open output file //
    96   if (!ascii)
    97     { fOut.open(fileName, std::ios::out|std::ios::binary); }
    98   else
    99     { fOut.open(fileName, std::ios::out); }
    100 
    101   // check if the file has been opened successfully
    102   if (!fOut)
    103   {
    104 #ifdef G4VERBOSE 
    105     G4cerr << "G4PhysicsTable::StorePhysicsTable  ";
    106     G4cerr << " Can not open file " << fileName << G4endl;
    107 #endif
    108     fOut.close();
    109     return false;
    110   }
    111 
    112   // Number of elements
    113   size_t tableSize = size();
    114   if (!ascii)
    115   {
    116     fOut.write( (char*)(&tableSize), sizeof tableSize);
    117   }
    118   else
    119   {
    120     fOut << tableSize << G4endl;
    121   }
    122 
    123   // Physics Vector
    124   for (G4PhysicsTableIterator itr=begin(); itr!=end(); ++itr)
    125   {
    126     G4int vType = (*itr)->GetType();
    127     if (!ascii)
    128     {
    129       fOut.write( (char*)(&vType), sizeof vType);
    130     }
    131     else
    132     {
    133       fOut << vType << G4endl;
    134     }
    135     (*itr)->Store(fOut,ascii);
    136   }
    137   fOut.close();
    138   return true;
    139 }
    140 
    141 
    142 G4bool G4PhysicsTable::ExistPhysicsTable(const G4String& fileName) const
    143 {
    144   std::ifstream fIn; 
    145   G4bool value=true;
    146   // open input file
    147   fIn.open(fileName,std::ios::in);
    148 
    149   // check if the file has been opened successfully
    150   if (!fIn)
    151   {
    152     value = false;
    153   }
    154   fIn.close();
    155   return value;
    156 }
    157    
    158 G4bool G4PhysicsTable::RetrievePhysicsTable(const G4String& fileName,
    159                                             G4bool          ascii)
    160 {
    161   std::ifstream fIn; 
    162   // open input file
    163   if (ascii)
    164     { fIn.open(fileName,std::ios::in|std::ios::binary); }
    165   else
    166     { fIn.open(fileName,std::ios::in);}
    167 
    168   // check if the file has been opened successfully
    169   if (!fIn)
    170   {
    171 #ifdef G4VERBOSE 
    172     G4cerr << "G4PhysicsTable::RetrievePhysicsTable  ";
    173     G4cerr << " Can not open file " << fileName << G4endl;
    174 #endif
    175     fIn.close();
    176     return false;
    177   }
    178 
    179   // clear
    180   clearAndDestroy();
    181  
    182   // Number of elements
    183   size_t tableSize=0;
    184   if (!ascii)
    185   {
    186     fIn.read((char*)(&tableSize), sizeof tableSize);
    187   }
    188   else
    189   {
    190     fIn >> tableSize;
    191   }
    192   reserve(tableSize);
    193   vecFlag.clear();
    194 
    195   // Physics Vector
    196   for (size_t idx=0; idx<tableSize; ++idx)
    197   {
    198     G4int vType=0;
    199     if (!ascii)
    200     {
    201       fIn.read( (char*)(&vType), sizeof vType);
    202     }
    203     else
    204     {
    205       fIn >>  vType;
    206     }
    207     G4PhysicsVector* pVec = CreatePhysicsVector(vType);
    208     if (pVec==0)
    209     {
    210 #ifdef G4VERBOSE 
    211       G4cerr << "G4PhysicsTable::RetrievePhysicsTable  ";
    212       G4cerr << " illegal Physics Vector type " << vType << " in  ";
    213       G4cerr << fileName << G4endl;
    214 #endif         
    215       fIn.close();
    216       return false;
    217     }
    218 
    219     if (! (pVec->Retrieve(fIn,ascii)) )
    220     {
    221 #ifdef G4VERBOSE 
    222       G4cerr << "G4PhysicsTable::RetrievePhysicsTable  ";
    223       G4cerr << " error in retreiving " << idx << "-th Physics Vector from file ";
    224       G4cerr << fileName << G4endl;
    225 #endif         
    226       fIn.close();
    227       return false;
    228     }
    229 
    230     // add a PhysicsVector to this PhysicsTable
    231     G4PhysCollection::push_back(pVec);
    232     vecFlag.push_back(true);
    233    
    234   }
    235   fIn.close();
    236   return true;
    237 }
    238 
    239 std::ostream& operator<<(std::ostream& out,
    240                          G4PhysicsTable& right)
    241 {
    242   // Printout Physics Vector
    243   size_t i=0;
    244   for (G4PhysicsTableIterator itr=right.begin(); itr!=right.end(); ++itr)
    245   {
    246     out << std::setw(8) << i << "-th Vector   ";
    247     out << ": Type    " << G4int((*itr)->GetType()) ;
    248     out << ": Flag    ";
    249     if (right.GetFlag(i))
    250     {
    251       out << " T";
    252     }
    253     else
    254     {
    255       out << " F";
    256     }
    257     out << G4endl;
    258     out << *(*itr);
    259     i +=1;
    260   }
    261   out << G4endl;
    262   return out;
    263 }
    264 
    265 void G4PhysicsTable::ResetFlagArray()
    266 {
    267   size_t tableSize = G4PhysCollection::size();
    268   vecFlag.clear();
    269   for (size_t idx=0; idx<tableSize; idx++)
    270   {
    271     vecFlag.push_back(true);
    272   }
    273 }
    274 
     42#include "G4PhysicsVector.hh"
     43#include "G4PhysicsTable.hh"
    27544#include "G4PhysicsVectorType.hh"
    27645#include "G4LPhysicsFreeVector.hh"
     
    28150#include "G4PhysicsLnVector.hh"
    28251 
     52G4PhysicsTable::G4PhysicsTable()
     53  : G4PhysCollection()
     54{
     55}
     56
     57G4PhysicsTable::G4PhysicsTable(size_t cap)
     58  : G4PhysCollection()
     59{
     60  reserve(cap);
     61  vecFlag.reserve(cap);
     62}
     63
     64G4PhysicsTable::G4PhysicsTable(const G4PhysicsTable& right)
     65  : G4PhysCollection()
     66{
     67  *this = right;
     68}
     69
     70G4PhysicsTable& G4PhysicsTable::operator=(const G4PhysicsTable& right)
     71{
     72  if (this != &right)
     73  {
     74    size_t idx = 0;
     75    for (G4PhysCollection::const_iterator itr=right.begin();
     76         itr!=right.end(); ++itr )
     77    {
     78      G4PhysCollection::push_back(*itr);
     79      vecFlag.push_back(right.GetFlag(idx));
     80      idx +=1;
     81    }
     82  }
     83  return *this;
     84}
     85
     86G4PhysicsTable::~G4PhysicsTable()
     87{
     88  G4PhysCollection::clear();
     89  vecFlag.clear();
     90}
     91 
     92void   G4PhysicsTable::resize(size_t siz, G4PhysicsVector* vec)
     93{
     94  G4PhysCollection::resize(siz, vec);
     95  vecFlag.resize(siz, true);
     96}
     97
     98G4bool G4PhysicsTable::StorePhysicsTable(const G4String& fileName,
     99                                         G4bool          ascii)
     100{
     101  std::ofstream fOut; 
     102 
     103  // open output file //
     104  if (!ascii)
     105    { fOut.open(fileName, std::ios::out|std::ios::binary); }
     106  else
     107    { fOut.open(fileName, std::ios::out); }
     108
     109  // check if the file has been opened successfully
     110  if (!fOut)
     111  {
     112#ifdef G4VERBOSE 
     113    G4cerr << "G4PhysicsTable::StorePhysicsTable():";
     114    G4cerr << " Cannot open file: " << fileName << G4endl;
     115#endif
     116    fOut.close();
     117    return false;
     118  }
     119
     120  // Number of elements
     121  size_t tableSize = size();
     122  if (!ascii)
     123  {
     124    fOut.write( (char*)(&tableSize), sizeof tableSize);
     125  }
     126  else
     127  {
     128    fOut << tableSize << G4endl;
     129  }
     130
     131  // Physics Vector
     132  for (G4PhysicsTableIterator itr=begin(); itr!=end(); ++itr)
     133  {
     134    G4int vType = (*itr)->GetType();
     135    if (!ascii)
     136    {
     137      fOut.write( (char*)(&vType), sizeof vType);
     138    }
     139    else
     140    {
     141      fOut << vType << G4endl;
     142    }
     143    (*itr)->Store(fOut,ascii);
     144  }
     145  fOut.close();
     146  return true;
     147}
     148
     149
     150G4bool G4PhysicsTable::ExistPhysicsTable(const G4String& fileName) const
     151{
     152  std::ifstream fIn; 
     153  G4bool value=true;
     154  // open input file
     155  fIn.open(fileName,std::ios::in);
     156
     157  // check if the file has been opened successfully
     158  if (!fIn)
     159  {
     160    value = false;
     161  }
     162  fIn.close();
     163  return value;
     164}
     165   
     166G4bool G4PhysicsTable::RetrievePhysicsTable(const G4String& fileName,
     167                                            G4bool          ascii)
     168{
     169  std::ifstream fIn; 
     170  // open input file
     171  if (ascii)
     172    { fIn.open(fileName,std::ios::in|std::ios::binary); }
     173  else
     174    { fIn.open(fileName,std::ios::in);}
     175
     176  // check if the file has been opened successfully
     177  if (!fIn)
     178  {
     179#ifdef G4VERBOSE 
     180    G4cerr << "G4PhysicsTable::RetrievePhysicsTable():";
     181    G4cerr << " Cannot open file: " << fileName << G4endl;
     182#endif
     183    fIn.close();
     184    return false;
     185  }
     186
     187  // clear
     188  clearAndDestroy();
     189 
     190  // Number of elements
     191  G4int tableSize=0;
     192  if (!ascii)
     193  {
     194    fIn.read((char*)(&tableSize), sizeof tableSize);
     195  }
     196  else
     197  {
     198    fIn >> tableSize;
     199  }
     200  if (tableSize<=0)
     201  {
     202#ifdef G4VERBOSE 
     203    G4cerr << "G4PhysicsTable::RetrievePhysicsTable():";
     204    G4cerr << " Invalid table size: " << tableSize << G4endl;
     205#endif
     206    return false;
     207  }
     208  reserve(tableSize);
     209  vecFlag.clear();
     210
     211  // Physics Vector
     212  for (G4int idx=0; idx<tableSize; ++idx)
     213  {
     214    G4int vType=0;
     215    if (!ascii)
     216    {
     217      fIn.read( (char*)(&vType), sizeof vType);
     218    }
     219    else
     220    {
     221      fIn >>  vType;
     222    }
     223    G4PhysicsVector* pVec = CreatePhysicsVector(vType);
     224    if (pVec==0)
     225    {
     226#ifdef G4VERBOSE 
     227      G4cerr << "G4PhysicsTable::RetrievePhysicsTable():";
     228      G4cerr << " Illegal Physics Vector type: " << vType << " in: ";
     229      G4cerr << fileName << G4endl;
     230#endif         
     231      fIn.close();
     232      return false;
     233    }
     234
     235    if (! (pVec->Retrieve(fIn,ascii)) )
     236    {
     237#ifdef G4VERBOSE 
     238      G4cerr << "G4PhysicsTable::RetrievePhysicsTable():";
     239      G4cerr << " Rrror in retreiving " << idx
     240             << "-th Physics Vector from file: ";
     241      G4cerr << fileName << G4endl;
     242#endif         
     243      fIn.close();
     244      return false;
     245    }
     246
     247    // add a PhysicsVector to this PhysicsTable
     248    G4PhysCollection::push_back(pVec);
     249    vecFlag.push_back(true);
     250   
     251  }
     252  fIn.close();
     253  return true;
     254}
     255
     256std::ostream& operator<<(std::ostream& out,
     257                         G4PhysicsTable& right)
     258{
     259  // Printout Physics Vector
     260  size_t i=0;
     261  for (G4PhysicsTableIterator itr=right.begin(); itr!=right.end(); ++itr)
     262  {
     263    out << std::setw(8) << i << "-th Vector   ";
     264    out << ": Type    " << G4int((*itr)->GetType()) ;
     265    out << ": Flag    ";
     266    if (right.GetFlag(i))
     267    {
     268      out << " T";
     269    }
     270    else
     271    {
     272      out << " F";
     273    }
     274    out << G4endl;
     275    out << *(*itr);
     276    i +=1;
     277  }
     278  out << G4endl;
     279  return out;
     280}
     281
     282void G4PhysicsTable::ResetFlagArray()
     283{
     284  size_t tableSize = G4PhysCollection::size();
     285  vecFlag.clear();
     286  for (size_t idx=0; idx<tableSize; idx++)
     287  {
     288    vecFlag.push_back(true);
     289  }
     290}
     291
    283292G4PhysicsVector* G4PhysicsTable::CreatePhysicsVector(G4int type)
    284293{
  • trunk/source/global/management/src/G4PhysicsVector.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4PhysicsVector.cc,v 1.46 2010/05/28 05:13:43 kurasige Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4PhysicsVector.cc,v 1.49 2010/11/01 13:55:53 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    205205    if (fIn.fail())  { return false; }
    206206    // contents
    207     size_t size=0;
    208     fIn >> size;
     207    G4int siz=0;
     208    fIn >> siz;
    209209    if (fIn.fail())  { return false; }
    210 
    211     binVector.reserve(size);
    212     dataVector.reserve(size);
     210    if (siz<=0)
     211    {
     212#ifdef G4VERBOSE 
     213      G4cerr << "G4PhysicsVector::Retrieve():";
     214      G4cerr << " Invalid vector size: " << siz << G4endl;
     215#endif
     216      return false;
     217    }
     218
     219    binVector.reserve(siz);
     220    dataVector.reserve(siz);
    213221    G4double vBin, vData;
    214222
    215     for(size_t i = 0; i < size ; i++)
     223    for(G4int i = 0; i < siz ; i++)
    216224    {
    217225      vBin = 0.;
     
    445453  // or not ordered than spline cannot be applied
    446454{
    447   if(!useSpline) return useSpline;
     455  if(!useSpline)  { return useSpline; }
    448456  secDerivative.clear();
    449457  secDerivative.reserve(numberOfNodes);
     
    464472{
    465473  // binning
    466   out << std::setprecision(12) << pv.edgeMin;
    467   out <<" " << pv.edgeMax <<" " << pv.numberOfNodes << G4endl;
     474  out << std::setprecision(12) << pv.edgeMin << " "
     475      << pv.edgeMax << " " << pv.numberOfNodes << G4endl;
    468476
    469477  // contents
     
    471479  for(size_t i = 0; i < pv.dataVector.size(); i++)
    472480  {
    473     out << std::setprecision(12) << pv.binVector[i] << "  "
    474         << pv.dataVector[i] << G4endl;
    475   }
     481    out << pv.binVector[i] << "  " << pv.dataVector[i] << G4endl;
     482  }
     483  out << std::setprecision(6);
     484
    476485  return out;
    477486}
  • trunk/source/global/management/src/G4Pow.cc

    r1337 r1340  
    2424// ********************************************************************
    2525//
    26 // $Id: G4Pow.cc,v 1.2 2009/07/03 11:35:06 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     26// $Id: G4Pow.cc,v 1.4 2010/08/24 08:12:08 gcosmo Exp $
     27// GEANT4 tag $Name: global-V09-03-22 $
    2828//
    2929// -------------------------------------------------------------------
     
    6565  lz.resize(maxZ,0.0);
    6666  fact.resize(maxZ,0.0);
     67  logfact.resize(maxZ,0.0);
    6768
    6869  onethird = 1.0/3.0;
    6970  G4double f = 1.0;
    7071
    71   for(G4int i=1; i<maxZ; i++)
     72  for(G4int i=1; i<maxZ; ++i)
    7273  {
    7374    G4double x  = G4double(i);
     
    7677    f      *= x;
    7778    fact[i] = f;
     79    logfact[i] = std::log(f);
    7880  }
    7981  fact[0] = 1.0;
     82  logfact[0] = 0.0;
    8083}
    8184
     
    8689
    8790// -------------------------------------------------------------------
     91
     92G4double G4Pow::powN(G4double x, G4int n)
     93{
     94  G4double res = 1.0;
     95  if(n >= 0) { for(G4int i=0; i<n; ++i) { res *= x; } }
     96  else if((n < 0) && (x != 0.0))
     97  {
     98    G4double y = 1.0/x;
     99    G4int nn = -n;
     100    for(G4int i=0; i<nn; ++i) { res *= y; }
     101  }
     102  return res;
     103}
  • trunk/source/global/management/src/G4SliceTimer.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4SliceTimer.cc,v 1.2 2006/11/02 15:39:39 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4SliceTimer.cc,v 1.3 2010/10/01 16:36:31 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    6666
    6767G4SliceTimer::G4SliceTimer()
    68   : fValidTimes(true)
     68  : fValidTimes(true), fRealElapsed(0.), fSystemElapsed(0.), fUserElapsed(0.)
    6969{
    7070  Clear();
  • trunk/source/global/management/src/G4StateManager.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4StateManager.cc,v 1.13 2006/11/23 00:41:56 asaim Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4StateManager.cc,v 1.15 2010/10/01 16:36:31 gcosmo Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//
     
    6161    theDependentsList.pop_back();
    6262    for (std::vector<G4VStateDependent*>::iterator
    63          i=theDependentsList.begin(); i!=theDependentsList.end(); i++)
     63         i=theDependentsList.begin(); i!=theDependentsList.end();)
    6464    {
    6565      if (*i==state)
    6666      {
    67         theDependentsList.erase(i);
    68         i--;
     67        i = theDependentsList.erase(i);
     68      }
     69      else
     70      {
     71        ++i;
    6972      }
    7073    }
     
    153156  G4VStateDependent* tmp = 0;
    154157  for (std::vector<G4VStateDependent*>::iterator i=theDependentsList.begin();
    155        i!=theDependentsList.end(); i++)
    156     {
    157       if (**i==*aDependent)
    158         {
    159           tmp = *i;
    160           theDependentsList.erase(i);
    161         }
    162     }
     158       i!=theDependentsList.end();)
     159  {
     160    if (**i==*aDependent)
     161    {
     162      tmp = *i;
     163      i = theDependentsList.erase(i);
     164    }
     165    else
     166    {
     167      ++i;
     168    }
     169  }
    163170  return (tmp != 0);
    164171}
     
    216223  G4VStateDependent* tmp = 0;
    217224  for (std::vector<G4VStateDependent*>::iterator i=theDependentsList.begin();
    218        i!=theDependentsList.end(); i++)
    219     {
    220       if (**i==*aDependent)
    221         {
    222           tmp = *i;
    223           theDependentsList.erase(i);
    224         }
    225     }
     225       i!=theDependentsList.end();)
     226  {
     227    if (**i==*aDependent)
     228    {
     229      tmp = *i;
     230      i = theDependentsList.erase(i);
     231    }
     232    else
     233    {
     234      ++i;
     235    }
     236  }
    226237  return tmp;
    227238}
  • trunk/source/global/management/src/G4UnitsTable.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4UnitsTable.cc,v 1.37 2008/05/06 17:17:08 maire Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4UnitsTable.cc,v 1.38 2010/08/09 15:21:14 maire Exp $
     28// GEANT4 tag $Name: global-V09-03-22 $
    2929//
    3030//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
     
    4343// 18-08-06: remove symbol mum (mma)
    4444// 06-05-08: V/m ("Electric field")  (mma)
     45// 09-08-10: new category "Solid angle"  (mma)
    4546//
    4647//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
     
    217218 new G4UnitDefinition(     "radian","rad"    ,"Angle",radian);
    218219 new G4UnitDefinition("milliradian","mrad"   ,"Angle",milliradian);
    219  new G4UnitDefinition(  "steradian","sr"     ,"Angle",steradian);
    220220 new G4UnitDefinition(     "degree","deg"    ,"Angle",degree);
    221221 
     222 //Solid angle
     223 new G4UnitDefinition(  "steradian","sr"     ,"Solid angle",steradian);
     224 new G4UnitDefinition("millisteradian","msr" ,"Solid angle",steradian*0.001);
     225   
    222226 //Time
    223227 new G4UnitDefinition(     "second","s"      ,"Time",second);
Note: See TracChangeset for help on using the changeset viewer.