Ignore:
Timestamp:
May 28, 2009, 4:26:57 PM (15 years ago)
Author:
garnier
Message:

maj sur la beta de geant 4.9.3

Location:
trunk/source/processes/hadronic/models/management
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/hadronic/models/management/History

    r1007 r1055  
    1515     ---------------------------------------------------------------
    1616
     1725 February 2009 - V.Ivanchenko (hadr-modman-V09-02-03)
     18------------------------------------------------------
     19-  G4HadronicInteractionRegistry - added protection to the Clean method
     20
     2114 February 2009 - V.Ivanchenko (hadr-modman-V09-02-02)
     22------------------------------------------------------
     23-  G4HadronicInteractionRegistry - added Clean method
     24
     2506 February 2009 - V.Ivanchenko (hadr-modman-V09-02-01)
     26------------------------------------------------------
     27
     2823 January 2009 - V.Ivanchenko (hadr-modman-V09-02-00)
     29------------------------------------------------------
     30-  G4HadronicInteractionRegistry - make it as real singleton
     31-  G4HadronicInteraction, G4InelasticInteraction - move constructor,
     32       destructor and some header files from header to source
     33
    173419 June 2008 - G.Cosmo  (hadr-modman-V09-01-03)
    1835-----------------------------------------------
    1936-  included change introduced in hadr-modman-V09-01-01 and
    20    discarded by imstake in the last tag ...
     37   discarded by mistake in the last tag ...
    2138
    223919 June 2008 - V.Ivanchenko (hadr-modman-V09-01-02)
  • trunk/source/processes/hadronic/models/management/include/G4HadronicInteraction.hh

    r1007 r1055  
    2525//
    2626//
    27 // $Id: G4HadronicInteraction.hh,v 1.8 2007/01/11 05:30:01 dennis Exp $
    28 // GEANT4 tag $Name: geant4-09-02 $
     27// $Id: G4HadronicInteraction.hh,v 1.9 2009/01/24 11:56:27 vnivanch Exp $
     28// GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
    2929//
    30  // Hadronic Interaction  abstract base class
    31  // This class is the base class for the model classes.
    32  // It sorts out the energy-range for the models and provides
    33  // class utilities.
    34  // original by H.P. Wellisch
    35  // Modified by J.L.Chuma, TRIUMF, 21-Mar-1997
    36  // Last modified: 3-Apr-1997
    37  // Added units to energy initialization: J.L. Chuma  04-Apr-97
    38  // Modified by J.L.Chuma, 05-May-97  to Initialize theBlockedCounter
    39  // Modified by J.L.Chuma, 08-Jul-97 to implement the Nucleus changes
    40  // Adding a registry for memory management of hadronic models, HPW 22-Mar-99
     30// Hadronic Interaction  abstract base class
     31// This class is the base class for the model classes.
     32// It sorts out the energy-range for the models and provides
     33// class utilities.
     34// original by H.P. Wellisch
     35// Modified by J.L.Chuma, TRIUMF, 21-Mar-1997
     36// Last modified: 3-Apr-1997
     37// Added units to energy initialization: J.L. Chuma  04-Apr-97
     38// Modified by J.L.Chuma, 05-May-97  to Initialize theBlockedCounter
     39// Modified by J.L.Chuma, 08-Jul-97 to implement the Nucleus changes
     40// Adding a registry for memory management of hadronic models, HPW 22-Mar-99
     41// 23-Jan-2009 V.Ivanchenko move constructor and destructor to the body
     42//                          and reorder methods in the header
    4143
    4244// Class Description
    4345// This is the base class for all hadronic interaction models in geant4.
    44 // If you want to implement a new way of producing a final state, please inherit
    45 // from here.
     46// If you want to implement a new way of producing a final state, please,
     47//  inherit from here.
    4648// Class Description - End
    4749 
     
    5052 
    5153#include "G4HadFinalState.hh"
    52 #include "G4DynamicParticle.hh"
    5354#include "G4ReactionDynamics.hh"
    5455#include "G4Material.hh"
     
    5657#include "G4Track.hh"
    5758#include "G4HadProjectile.hh"
    58 #include "G4HadronicInteractionRegistry.hh"
    59 #include "G4HadronicException.hh"
    6059
    61  class G4HadronicInteraction
    62  {
    63  public:
     60class G4HadronicInteraction
     61{
     62public: // With description
     63
    6464   
    65     G4HadronicInteraction(const G4String& modelName = "HadronicModel") :
    66       verboseLevel(0), theMinEnergy(0.0*GeV), theMaxEnergy(25.0*GeV),
    67       isBlocked(false), theModelName(modelName)
    68     {
    69       G4HadronicInteractionRegistry::RegisterMe(this);
    70     }
     65  G4HadronicInteraction(const G4String& modelName = "HadronicModel");
    7166   
    72     virtual ~G4HadronicInteraction()
    73     {
    74       G4HadronicInteractionRegistry::RemoveMe(this);
    75     }
     67  virtual ~G4HadronicInteraction();
    7668   
    77  private:
     69  virtual G4HadFinalState *ApplyYourself(const G4HadProjectile &aTrack,
     70                                         G4Nucleus & targetNucleus ) = 0;
     71  // This is the interface to implement for final state production code.
     72   
     73  virtual G4bool IsApplicable(const G4HadProjectile &/*aTrack*/,
     74                              G4Nucleus & /*targetNucleus*/)
     75  {  return true;}
     76 
     77  inline G4double GetMinEnergy() const
     78  { return theMinEnergy; }
    7879   
    79     inline G4HadronicInteraction(
    80      const G4HadronicInteraction &right )
    81     { *this = right; }
     80  virtual G4double GetMinEnergy( const G4Material *aMaterial,
     81                                 const G4Element *anElement ) const;
     82   
     83  inline void SetMinEnergy( const G4double anEnergy )
     84  { theMinEnergy = anEnergy; }
    8285   
    83     inline const G4HadronicInteraction & operator=(
    84      const G4HadronicInteraction &right )
    85     {
    86      G4String text = "unintended use of G4HadronicInteraction::operator=";
    87      throw G4HadronicException(__FILE__, __LINE__, text);
    88      return right;
    89     }
     86  virtual void SetMinEnergy( G4double anEnergy, G4Element *anElement );
    9087   
    91  public:
     88  virtual void SetMinEnergy( G4double anEnergy, G4Material *aMaterial );
    9289   
    93     inline G4bool operator==(
    94      const G4HadronicInteraction &right ) const
    95     { return ( this == (G4HadronicInteraction *) &right ); }
     90  inline G4double GetMaxEnergy() const
     91  { return theMaxEnergy; }
    9692   
    97     inline G4bool operator!=(
    98      const G4HadronicInteraction &right ) const
    99     { return ( this != (G4HadronicInteraction *) &right ); }
     93  virtual G4double GetMaxEnergy( const G4Material *aMaterial,
     94                                 const G4Element *anElement ) const;
    10095   
    101     inline G4double GetMinEnergy() const
    102     { return theMinEnergy; }
     96  inline void SetMaxEnergy( const G4double anEnergy )
     97  { theMaxEnergy = anEnergy; }
    10398   
    104     virtual G4double GetMinEnergy( const G4Material *aMaterial,
    105                                   const G4Element *anElement ) const;
     99  virtual void SetMaxEnergy( G4double anEnergy, G4Element *anElement );
    106100   
    107     inline void SetMinEnergy( const G4double anEnergy )
    108     { theMinEnergy = anEnergy; }
    109    
    110     virtual void SetMinEnergy( G4double anEnergy, G4Element *anElement );
    111    
    112     virtual void SetMinEnergy( G4double anEnergy, G4Material *aMaterial );
    113    
    114     inline G4double GetMaxEnergy() const
    115     { return theMaxEnergy; }
    116    
    117     virtual G4double GetMaxEnergy( const G4Material *aMaterial,
    118                                   const G4Element *anElement ) const;
    119    
    120     inline void SetMaxEnergy( const G4double anEnergy )
    121     { theMaxEnergy = anEnergy; }
    122    
    123     virtual void SetMaxEnergy( G4double anEnergy, G4Element *anElement );
    124    
    125     virtual void SetMaxEnergy( G4double anEnergy, G4Material *aMaterial );
     101  virtual void SetMaxEnergy( G4double anEnergy, G4Material *aMaterial );
    126102 
    127     inline const G4HadronicInteraction *GetMyPointer() const
    128     { return this; }
     103  inline const G4HadronicInteraction *GetMyPointer() const
     104  { return this; }
    129105
    130     inline G4int GetVerboseLevel() const
    131     { return verboseLevel; }
     106  inline G4int GetVerboseLevel() const
     107  { return verboseLevel; }
    132108
    133     inline void SetVerboseLevel( G4int value )
    134     { verboseLevel = value; }
     109  inline void SetVerboseLevel( G4int value )
     110  { verboseLevel = value; }
    135111
    136     inline const G4String& GetModelName() const
    137     { return theModelName; }
    138 
    139 public: // With description
    140     // This is the interface to implement for final state production code.
    141    
    142     virtual G4HadFinalState *ApplyYourself(
    143             const G4HadProjectile &aTrack, G4Nucleus & targetNucleus ) = 0;
     112  inline const G4String& GetModelName() const
     113  { return theModelName; }
    144114   
    145115public: // Without description
    146116
    147     virtual void DeActivateFor( G4Material *aMaterial );
     117  virtual void DeActivateFor( G4Material *aMaterial );
    148118   
    149     virtual void ActivateFor( G4Material *aMaterial )
    150     {
    151       Block();
    152       SetMaxEnergy(GetMaxEnergy(), aMaterial);
    153       SetMinEnergy(GetMinEnergy(), aMaterial);
    154     }
     119  virtual void ActivateFor( G4Material *aMaterial )
     120  {
     121    Block();
     122    SetMaxEnergy(GetMaxEnergy(), aMaterial);
     123    SetMinEnergy(GetMinEnergy(), aMaterial);
     124  }
    155125
    156     virtual void DeActivateFor( G4Element *anElement );
    157     virtual void ActivateFor( G4Element *anElement )
    158     {
    159       Block();
    160       SetMaxEnergy(GetMaxEnergy(), anElement);
    161       SetMinEnergy(GetMinEnergy(), anElement);
    162     }
     126  virtual void DeActivateFor( G4Element *anElement );
     127  virtual void ActivateFor( G4Element *anElement )
     128  {
     129    Block();
     130    SetMaxEnergy(GetMaxEnergy(), anElement);
     131    SetMinEnergy(GetMinEnergy(), anElement);
     132  }
    163133
    164     virtual G4bool IsBlocked( const G4Material *aMaterial ) const;
     134  virtual G4bool IsBlocked( const G4Material *aMaterial ) const;
    165135
    166     virtual G4bool IsBlocked( const G4Element *anElement) const;
     136  virtual G4bool IsBlocked( const G4Element *anElement) const;
     137
     138  inline G4bool operator==(const G4HadronicInteraction &right ) const
     139  { return ( this == (G4HadronicInteraction *) &right ); }
    167140   
    168     virtual G4bool IsApplicable(const G4HadProjectile &/*aTrack*/,
    169                                G4Nucleus & /*targetNucleus*/){  return true;}
    170  protected:
     141  inline G4bool operator!=(const G4HadronicInteraction &right ) const
     142  { return ( this != (G4HadronicInteraction *) &right ); }
    171143   
    172     G4HadFinalState theParticleChange;
    173     // the G4HadFinalState object which is modified and returned
    174     // by address by the ApplyYourself method,
    175     // (instead of aParticleChange as found in G4VProcess)
     144private:
    176145   
    177     G4int verboseLevel;
    178     // control flag for output messages
    179     // 0: silent
    180     // 1: warning messages
    181     // 2: more
    182     // (instead of verboseLevel as found in G4VProcess)
     146  G4HadronicInteraction(const G4HadronicInteraction &right );
    183147   
    184     G4ReactionDynamics theReactionDynamics;
     148  const G4HadronicInteraction& operator=(const G4HadronicInteraction &right);
     149
     150protected:
     151
     152  inline G4bool IsBlocked() const { return isBlocked;}
     153  inline void Block() { isBlocked = true; }
    185154   
    186     // these two have global validity
    187     // units are assumed to be MeV
     155  G4HadFinalState theParticleChange;
     156  // the G4HadFinalState object which is modified and returned
     157  // by address by the ApplyYourself method,
     158  // (instead of aParticleChange as found in G4VProcess)
    188159   
    189     G4double theMinEnergy;
    190     G4double theMaxEnergy;
     160  G4int verboseLevel;
     161  // control flag for output messages
     162  // 0: silent
     163  // 1: warning messages
     164  // 2: more
     165  // (instead of verboseLevel as found in G4VProcess)
    191166   
    192     G4bool IsBlocked() const { return isBlocked;}
    193     void Block() { isBlocked = true; }
    194     G4bool isBlocked;
     167  G4ReactionDynamics theReactionDynamics;
     168   
     169  // these two have global validity
     170  // units are assumed to be MeV
     171   
     172  G4double theMinEnergy;
     173  G4double theMaxEnergy;
     174   
     175  G4bool isBlocked;
    195176
    196     G4String theModelName;
     177  G4String theModelName;
    197178   
    198  private:
     179private:
    199180       
    200     std::vector<std::pair<G4double, G4Material *> > theMinEnergyList;
    201     std::vector<std::pair<G4double, G4Material *> > theMaxEnergyList;
    202     std::vector<std::pair<G4double, G4Element *> > theMinEnergyListElements;
    203     std::vector<std::pair<G4double, G4Element *> > theMaxEnergyListElements;
    204     std::vector<G4Material *> theBlockedList;
    205     std::vector<G4Element *> theBlockedListElements;
    206  };
     181   std::vector<std::pair<G4double, G4Material *> > theMinEnergyList;
     182   std::vector<std::pair<G4double, G4Material *> > theMaxEnergyList;
     183   std::vector<std::pair<G4double, G4Element *> > theMinEnergyListElements;
     184   std::vector<std::pair<G4double, G4Element *> > theMaxEnergyListElements;
     185   std::vector<G4Material *> theBlockedList;
     186   std::vector<G4Element *> theBlockedListElements;
     187};
    207188 
    208189#endif
  • trunk/source/processes/hadronic/models/management/include/G4HadronicInteractionRegistry.hh

    r1007 r1055  
    2424// ********************************************************************
    2525//
     26// $Id: G4HadronicInteractionRegistry.hh,v 1.4 2009/02/14 19:24:52 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     28//
     29// 23-Jan-2009 V.Ivanchenko make the class to be a singleton
     30
     31// Class Description
     32// This is the a singleton class to store all hadronic interactions
     33// Class Description - End
     34
    2635#ifndef G4HadronicInteractionRegistry_h
    2736#define G4HadronicInteractionRegistry_h 1
     
    2938#include <vector>
    3039#include "globals.hh"
     40
    3141class G4HadronicInteraction;
    3242
    3343class G4HadronicInteractionRegistry
    3444{
    35   public:
     45public:
     46
     47  static G4HadronicInteractionRegistry* Instance();
     48  // access
    3649 
    3750  ~G4HadronicInteractionRegistry();
     51
     52  void Clean();
     53  //delete models
    3854 
    39   static void RegisterMe(G4HadronicInteraction * aModel);
    40   static void RemoveMe(G4HadronicInteraction * aModel);
     55  void RegisterMe(G4HadronicInteraction * aModel);
     56  //register new model
     57
     58  void RemoveMe(G4HadronicInteraction * aModel);
     59  //deregister model
    4160   
    42   protected:
     61private:
    4362
    44   G4HadronicInteractionRegistry(G4String );
    45   static G4HadronicInteractionRegistry & theRegistry();
     63  G4HadronicInteractionRegistry();
    4664
    47   private:
    48 
    49   //  !!!  can not use "copy constructor" nor "default constructor" !!!!
    50        G4HadronicInteractionRegistry(const G4HadronicInteractionRegistry &right)
    51        { nModels = right.nModels; }
    52        G4HadronicInteractionRegistry() {nModels = 0;}
    53 
    54   //  !!!  Assignment operation is forbidden !!!
    55       const G4HadronicInteractionRegistry & operator=(const G4HadronicInteractionRegistry &)
    56       { return *this;}
    57 
    58   void AddModel(G4HadronicInteraction * aModel);
     65  static G4HadronicInteractionRegistry* theInstance;
    5966 
    6067  G4int nModels;
  • trunk/source/processes/hadronic/models/management/include/G4InelasticInteraction.hh

    r1007 r1055  
    2525//
    2626//
    27 // $Id: G4InelasticInteraction.hh,v 1.5 2007/01/11 05:30:12 dennis Exp $
    28 // GEANT4 tag $Name: geant4-09-02 $
     27// $Id: G4InelasticInteraction.hh,v 1.6 2009/01/24 11:56:27 vnivanch Exp $
     28// GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
    2929//
    30  // Hadronic Process: Inelastic Interaction
    31  // This class is an abstract base class, since the pure virtual
    32  // function ApplyYourself has not been defined yet.
    33  // original by H.P. Wellisch
    34  // Modified by J.L. Chuma, TRIUMF, 22-Nov-1996
    35  // Modified by J.L. Chuma  27-Mar-1997
    36  // Modified by J.L. Chuma  30-Apr-1997
    37  // Modified by J.L. Chuma  05-Aug-1997  to pass the original incident particle to
    38  //                                      CalculateMomenta
    39  // Modified by J.L. Chuma  05-Jun-1998  to include quasiElastic flag to allow for
    40  //                                      TwoBody to be called directly, bypassing
    41  //                                      TwoCluster, and allowing TwoCluster to be
    42  //                                      called with no secondaries
     30// Hadronic Process: Inelastic Interaction
     31// This class is an abstract base class, since the pure virtual
     32// function ApplyYourself has not been defined yet.
     33// original by H.P. Wellisch
     34// Modified by J.L. Chuma, TRIUMF, 22-Nov-1996
     35// Modified by J.L. Chuma  27-Mar-1997
     36// Modified by J.L. Chuma  30-Apr-1997
     37// Modified by J.L. Chuma  05-Aug-1997  to pass the original incident particle to
     38//                                      CalculateMomenta
     39// Modified by J.L. Chuma  05-Jun-1998  to include quasiElastic flag to allow for
     40//                                      TwoBody to be called directly, bypassing
     41//                                      TwoCluster, and allowing TwoCluster to be
     42//                                      called with no secondaries
     43// 23-Jan-2009 V.Ivanchenko move constructor and destructor to the body
    4344 
    4445#ifndef G4InelasticInteraction_h
     
    5354#include "G4ReactionDynamics.hh"
    5455
    55  class G4InelasticInteraction : public G4HadronicInteraction
    56  {
    57  public:
     56class G4InelasticInteraction : public G4HadronicInteraction
     57{
     58public:
    5859   
    59     G4InelasticInteraction(const G4String& modelName = "LEInelastic")
    60      : G4HadronicInteraction(modelName)
    61     { cache = 0.0;}
     60    G4InelasticInteraction(const G4String& modelName = "LEInelastic");
    6261   
    63     virtual ~G4InelasticInteraction()
    64     { }
     62    virtual ~G4InelasticInteraction();
    6563   
    66  protected:
     64protected:
    6765   
    6866    G4double Pmltpc( G4int np, G4int nm, G4int nz, G4int n,
     
    10098                      G4ReactionProduct &targetParticle,
    10199                      G4bool &incidentHasChanged );
    102    private:
     100private:
    103101   
    104102      G4double cache;
    105103      G4ThreeVector what;
    106104
    107  };
     105};
    108106 
    109107#endif
  • trunk/source/processes/hadronic/models/management/src/G4HadronicInteraction.cc

    r1007 r1055  
    2424// ********************************************************************
    2525//
     26// $Id: G4HadronicInteraction.cc,v 1.4 2009/01/24 11:56:27 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
    2628//
    27  // Hadronic Interaction  base class
    28  // original by H.P. Wellisch
    29  // modified by J.L. Chuma, TRIUMF, 21-Mar-1997
    30  // Last modified: 04-Apr-1997
    31  // reimplemented 1.11.2003 JPW.
    32  
     29// Hadronic Interaction  base class
     30// original by H.P. Wellisch
     31// modified by J.L. Chuma, TRIUMF, 21-Mar-1997
     32// Last modified: 04-Apr-1997
     33// reimplemented 1.11.2003 JPW.
     34// 23-Jan-2009 V.Ivanchenko move constructor and destructor to the body
     35
    3336#include "G4HadronicInteraction.hh"
    34  
    35  G4double
    36   G4HadronicInteraction::GetMinEnergy(
     37#include "G4HadronicInteractionRegistry.hh"
     38#include "G4HadronicException.hh"
     39
     40G4HadronicInteraction::G4HadronicInteraction(const G4String& modelName) :
     41  verboseLevel(0), theMinEnergy(0.0*GeV), theMaxEnergy(25.0*GeV),
     42  isBlocked(false), theModelName(modelName)
     43{
     44  G4HadronicInteractionRegistry::Instance()->RegisterMe(this);
     45}
     46   
     47G4HadronicInteraction::~G4HadronicInteraction()
     48{
     49  G4HadronicInteractionRegistry::Instance()->RemoveMe(this);
     50}
     51 
     52G4double G4HadronicInteraction::GetMinEnergy(
    3753   const G4Material *aMaterial, const G4Element *anElement ) const
    38   {
    39     size_t i;
    40     if( IsBlocked(aMaterial) )return 0.*GeV;
    41     if( IsBlocked(anElement) )return 0.*GeV;
    42     for( i=0; i<theMinEnergyListElements.size(); ++i )
    43     {
    44       if( anElement == theMinEnergyListElements[i].second )return theMinEnergyListElements[i].first;
     54{
     55  size_t i;
     56  if( IsBlocked(aMaterial) )return 0.*GeV;
     57  if( IsBlocked(anElement) )return 0.*GeV;
     58  for( i=0; i<theMinEnergyListElements.size(); ++i )
     59    {
     60      if( anElement == theMinEnergyListElements[i].second )
     61        return theMinEnergyListElements[i].first;
    4562    }
    4663    for( i=0; i<theMinEnergyList.size(); ++i )
    4764    {
    48       if( aMaterial == theMinEnergyList[i].second )return theMinEnergyList[i].first;
     65      if( aMaterial == theMinEnergyList[i].second )
     66        return theMinEnergyList[i].first;
    4967    }
    5068    if(IsBlocked()) return 0.*GeV;
     
    5472           << " not found in min energy List" << G4endl;
    5573    return theMinEnergy;
    56   }
    57  
    58  void
    59   G4HadronicInteraction::SetMinEnergy(
    60    G4double anEnergy,
    61    G4Element *anElement )
    62   {
    63     if( IsBlocked(anElement) )
    64       G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl
     74}
     75 
     76void G4HadronicInteraction::SetMinEnergy(G4double anEnergy,
     77                                         G4Element *anElement )
     78{
     79  if( IsBlocked(anElement) )
     80    G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl
    6581           << "    The model is not active for the Element  "
    6682           << anElement->GetName() << "." << G4endl;
    6783   
    68     for( size_t i=0; i<theMinEnergyListElements.size(); ++i )
     84  for( size_t i=0; i<theMinEnergyListElements.size(); ++i )
    6985    {
    7086      if( anElement == theMinEnergyListElements[i].second )
     
    7490      }
    7591    }
    76     theMinEnergyListElements.push_back(std::pair<G4double, G4Element *>(anEnergy, anElement));
    77   }
    78  
    79  void
    80   G4HadronicInteraction::SetMinEnergy(
    81    G4double anEnergy,
    82    G4Material *aMaterial )
    83   {
    84     if( IsBlocked(aMaterial) )
    85       G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl
     92  theMinEnergyListElements.push_back(std::pair<G4double, G4Element *>(anEnergy, anElement));
     93}
     94 
     95void G4HadronicInteraction::SetMinEnergy(G4double anEnergy,
     96                                         G4Material *aMaterial )
     97{
     98  if( IsBlocked(aMaterial) )
     99    G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl
    86100           << "    The model is not active for the Material "
    87101           << aMaterial->GetName() << "." << G4endl;
    88102   
    89     for( size_t i=0; i<theMinEnergyList.size(); ++i )
     103  for( size_t i=0; i<theMinEnergyList.size(); ++i )
    90104    {
    91105      if( aMaterial == theMinEnergyList[i].second )
    92       {
    93         theMinEnergyList[i].first = anEnergy;
    94         return;
    95       }
    96     }
    97     theMinEnergyList.push_back(std::pair<G4double, G4Material *>(anEnergy, aMaterial));
    98   }
    99  
    100  G4double
    101   G4HadronicInteraction::GetMaxEnergy(
    102    const G4Material *aMaterial, const G4Element *anElement ) const
    103   {
    104     size_t i;
    105     if( IsBlocked(aMaterial) )return 0.0*GeV;
    106     if( IsBlocked(anElement) )return 0.0*GeV;
    107     for( i=0; i<theMaxEnergyListElements.size(); ++i )
    108     {
    109       if( anElement == theMaxEnergyListElements[i].second )return theMaxEnergyListElements[i].first;
     106        {
     107          theMinEnergyList[i].first = anEnergy;
     108          return;
     109        }
     110    }
     111  theMinEnergyList.push_back(std::pair<G4double, G4Material *>(anEnergy, aMaterial));
     112}
     113 
     114G4double G4HadronicInteraction::GetMaxEnergy(const G4Material *aMaterial,
     115                                             const G4Element *anElement ) const
     116{
     117  size_t i;
     118  if( IsBlocked(aMaterial) )return 0.0*GeV;
     119  if( IsBlocked(anElement) )return 0.0*GeV;
     120  for( i=0; i<theMaxEnergyListElements.size(); ++i )
     121    {
     122      if( anElement == theMaxEnergyListElements[i].second )
     123        return theMaxEnergyListElements[i].first;
    110124    }
    111125    for( i=0; i<theMaxEnergyList.size(); ++i )
    112126    {
    113       if( aMaterial == theMaxEnergyList[i].second )return theMaxEnergyList[i].first;
     127      if( aMaterial == theMaxEnergyList[i].second )
     128        return theMaxEnergyList[i].first;
    114129    }
    115130    if(IsBlocked()) return 0.*GeV;
    116131    if( verboseLevel > 0 )
    117132      G4cout << "*** Warning from HadronicInteraction::GetMaxEnergy" << G4endl
    118            << "    material " << aMaterial->GetName()
    119            << " not found in min energy List" << G4endl;
     133             << "    material " << aMaterial->GetName()
     134             << " not found in min energy List" << G4endl;
    120135   
    121136    return theMaxEnergy;
    122   }
    123  
    124  void
    125   G4HadronicInteraction::SetMaxEnergy(
    126    G4double anEnergy,
    127    G4Element *anElement )
    128   {
    129     if( IsBlocked(anElement) )
    130       G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl
     137}
     138 
     139void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy,
     140                                         G4Element *anElement )
     141{
     142  if( IsBlocked(anElement) )
     143    G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl
    131144           << "Warning: The model is not active for the Element  "
    132145           << anElement->GetName() << "." << G4endl;
    133146   
    134     for( size_t i=0; i<theMaxEnergyListElements.size(); ++i )
     147  for( size_t i=0; i<theMaxEnergyListElements.size(); ++i )
    135148    {
    136149      if( anElement == theMaxEnergyListElements[i].second )
     
    140153      }
    141154    }
    142     theMaxEnergyListElements.push_back(std::pair<G4double, G4Element *>(anEnergy, anElement));
    143   }
    144 
    145  void
    146   G4HadronicInteraction::SetMaxEnergy(
    147    G4double anEnergy,
    148    G4Material *aMaterial )
    149   {
    150     if( IsBlocked(aMaterial) )
    151       G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl
     155  theMaxEnergyListElements.push_back(std::pair<G4double, G4Element *>(anEnergy, anElement));
     156}
     157
     158void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy,
     159                                         G4Material *aMaterial )
     160{
     161  if( IsBlocked(aMaterial) )
     162    G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl
    152163           << "Warning: The model is not active for the Material "
    153164           << aMaterial->GetName() << "." << G4endl;
    154165   
    155     for( size_t i=0; i<theMaxEnergyList.size(); ++i )
     166  for( size_t i=0; i<theMaxEnergyList.size(); ++i )
    156167    {
    157168      if( aMaterial == theMaxEnergyList[i].second )
    158       {
     169        {
    159170        theMaxEnergyList[i].first = anEnergy;
    160171        return;
    161       }
    162     }
    163     theMaxEnergyList.push_back(std::pair<G4double, G4Material *>(anEnergy, aMaterial));
    164   }
    165 
    166  void
    167   G4HadronicInteraction::DeActivateFor( G4Material *aMaterial )
    168   {
    169     theBlockedList.push_back(aMaterial);
    170   }
    171 
    172  void
    173   G4HadronicInteraction::DeActivateFor( G4Element *anElement )
    174   {
    175     theBlockedListElements.push_back(anElement);
    176   }
    177 
    178  G4bool
    179   G4HadronicInteraction::IsBlocked( const G4Material *aMaterial ) const
    180   {
    181     for( size_t i=0; i<theBlockedList.size(); ++i )
     172        }
     173    }
     174  theMaxEnergyList.push_back(std::pair<G4double, G4Material *>(anEnergy, aMaterial));
     175}
     176
     177void G4HadronicInteraction::DeActivateFor( G4Material *aMaterial )
     178{
     179  theBlockedList.push_back(aMaterial);
     180}
     181
     182void G4HadronicInteraction::DeActivateFor( G4Element *anElement )
     183{
     184  theBlockedListElements.push_back(anElement);
     185}
     186
     187G4bool G4HadronicInteraction::IsBlocked( const G4Material *aMaterial ) const
     188{
     189  for( size_t i=0; i<theBlockedList.size(); ++i )
    182190    {
    183191      if( aMaterial == theBlockedList[i] )
    184       {
    185         return true;
    186       }
    187     }
    188     return false;
    189   }
    190  
    191  G4bool
    192   G4HadronicInteraction::IsBlocked( const G4Element *anElement ) const
    193   {
    194     for( size_t i=0; i<theBlockedListElements.size(); ++i )
     192        {
     193          return true;
     194        }
     195    }
     196  return false;
     197}
     198 
     199G4bool G4HadronicInteraction::IsBlocked( const G4Element *anElement ) const
     200{
     201  for( size_t i=0; i<theBlockedListElements.size(); ++i )
    195202    {
    196203      if( anElement == theBlockedListElements[i] )
    197       {
    198         return true;
    199       }
    200     }
    201     return false;
    202   }
    203  
    204  /* end of file */
    205  
     204        {
     205          return true;
     206        }
     207    }
     208  return false;
     209}
     210
     211G4HadronicInteraction::G4HadronicInteraction(const G4HadronicInteraction &right )
     212{
     213  *this = right;
     214}
     215   
     216const G4HadronicInteraction&
     217G4HadronicInteraction::operator=(const G4HadronicInteraction &right )
     218{
     219  G4String text = "unintended use of G4HadronicInteraction::operator=";
     220  throw G4HadronicException(__FILE__, __LINE__, text);
     221  return right;
     222}
     223 
     224/* end of file */
     225 
  • trunk/source/processes/hadronic/models/management/src/G4HadronicInteractionRegistry.cc

    r1007 r1055  
    2424// ********************************************************************
    2525//
     26// $Id: G4HadronicInteractionRegistry.cc,v 1.7 2009/02/25 16:30:18 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     28//
     29// 23-Jan-2009 V.Ivanchenko make the class to be a singleton
     30
    2631#include "G4HadronicInteractionRegistry.hh"
    2732#include "G4HadronicInteraction.hh"
    2833
    29 G4HadronicInteractionRegistry & G4HadronicInteractionRegistry::theRegistry()
     34G4HadronicInteractionRegistry* G4HadronicInteractionRegistry::theInstance = 0;
     35
     36G4HadronicInteractionRegistry* G4HadronicInteractionRegistry::Instance()
    3037{
    31   static G4HadronicInteractionRegistry theRegistryInstance;
    32   return theRegistryInstance;
     38  if(0 == theInstance) {
     39    static G4HadronicInteractionRegistry manager;
     40    theInstance = &manager;
     41  }
     42  return theInstance;
     43}
     44
     45G4HadronicInteractionRegistry::G4HadronicInteractionRegistry()
     46{
     47  nModels = 0;
     48}
     49
     50G4HadronicInteractionRegistry::~G4HadronicInteractionRegistry()
     51{
     52  Clean();
     53}
     54
     55void G4HadronicInteractionRegistry::Clean()
     56{
     57  //G4cout << "G4HadronicInteractionRegistry::Clean() start " << nModels << G4endl;
     58  if(0 < nModels) {
     59    for (G4int i=0; i<nModels; i++) {
     60      if( allModels[i] ) {
     61        //G4cout << "delete " << i << G4endl;
     62        //G4cout << allModels[i]->GetModelName() << G4endl;
     63        delete allModels[i];
     64        allModels[i] = 0;
     65      }
     66    }
     67  }
     68  //G4cout << "G4HadronicInteractionRegistry::Clean() is done " << G4endl;
     69  nModels = 0;
    3370}
    3471
     
    3673RegisterMe(G4HadronicInteraction * aModel)
    3774{
    38   theRegistry().AddModel(aModel);
     75  if(nModels > 0) {
     76    for (G4int i=0; i<nModels; i++) {
     77      if( aModel == allModels[i] ) return;
     78    }
     79  }
     80  //G4cout << "Register model <" << aModel->GetModelName()
     81  //<< ">  " << nModels << G4endl;
     82  allModels.push_back(aModel);
     83  nModels++;
    3984}
    4085
     
    4287RemoveMe(G4HadronicInteraction * aModel)
    4388{
    44   theRegistry().allModels.erase(std::find(theRegistry().allModels.begin(),
    45                                           theRegistry().allModels.end(), aModel));
    46   theRegistry().nModels = theRegistry().allModels.size();
    47 }
    48 
    49 G4HadronicInteractionRegistry::~G4HadronicInteractionRegistry()
    50 {
    51   /*
    52   while(allModels.size()!=0)
    53   {
    54     delete allModels.front();
    55   }
    56   */
    57 }
    58 
    59 void G4HadronicInteractionRegistry::
    60 AddModel(G4HadronicInteraction * aModel)
    61 {
    62   G4bool alreadyThere = false;
    63   for(G4int i=0; i<nModels; i++)
    64   {
    65     if(allModels[i]==aModel)
    66     {
    67       alreadyThere = true;
    68       break;
     89  if(nModels > 0) {
     90    for (G4int i=0; i<nModels; i++) {
     91      if( aModel == allModels[i] ) {
     92        //G4cout << "DeRegister model <" << aModel->GetModelName()
     93        //<< ">  " << i << G4endl;
     94        allModels[i] = 0;
     95        return;
     96      }
    6997    }
    7098  }
    71   if(!alreadyThere)
    72   {
    73     nModels++;
    74     allModels.push_back(aModel);
    75   }
    7699}
  • trunk/source/processes/hadronic/models/management/src/G4InelasticInteraction.cc

    r1007 r1055  
    2424// ********************************************************************
    2525//
     26// $Id: G4InelasticInteraction.cc,v 1.12 2009/01/24 11:56:27 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
    2628//
    27 //
    28  // Hadronic Process: Inelastic Interaction
    29  // original by H.P. Wellisch
    30  // modified by J.L. Chuma, TRIUMF, 22-Nov-1996
    31  // Last modified: 27-Mar-1997
    32  // J.P. Wellisch: 23-Apr-97: throw G4HadronicException(__FILE__, __LINE__,  removed
    33  // J.P. Wellisch: 24-Apr-97: correction for SetUpPions
    34  // Modified by J.L. Chuma, 30-Apr-97: added originalTarget to CalculateMomenta
    35  //                                    since TwoBody needed to reset the target particle
    36  // J.L. Chuma, 20-Jun-97: Modified CalculateMomenta to correct the decision process
    37  //                        for whether to use GenerateXandPt or TwoCluster
    38  // J.L. Chuma, 06-Aug-97: added original incident particle, before Fermi motion and
    39  //                        evaporation effects are included, needed for calculating
    40  //                        self absorption and corrections for single particle spectra
    41  // HPW removed misunderstanding of LocalEnergyDeposit, 11.04.98.
     29// Hadronic Process: Inelastic Interaction
     30// original by H.P. Wellisch
     31// modified by J.L. Chuma, TRIUMF, 22-Nov-1996
     32// Last modified: 27-Mar-1997
     33// J.P. Wellisch: 23-Apr-97: throw G4HadronicException(__FILE__, __LINE__,  removed
     34// J.P. Wellisch: 24-Apr-97: correction for SetUpPions
     35// Modified by J.L. Chuma, 30-Apr-97: added originalTarget to CalculateMomenta
     36//                                    since TwoBody needed to reset the target particle
     37// J.L. Chuma, 20-Jun-97: Modified CalculateMomenta to correct the decision process
     38//                        for whether to use GenerateXandPt or TwoCluster
     39// J.L. Chuma, 06-Aug-97: added original incident particle, before Fermi motion and
     40//                        evaporation effects are included, needed for calculating
     41//                        self absorption and corrections for single particle spectra
     42// HPW removed misunderstanding of LocalEnergyDeposit, 11.04.98.
     43// 23-Jan-2009 V.Ivanchenko move constructor and destructor to the body
    4244 
    4345#include "G4InelasticInteraction.hh"
    4446#include "Randomize.hh"
    4547#include "G4HadReentrentException.hh"
    46  
    47  G4double
     48
     49G4InelasticInteraction::G4InelasticInteraction(const G4String& modelName)
     50  : G4HadronicInteraction(modelName)
     51{ cache = 0.0;}
     52   
     53G4InelasticInteraction::~G4InelasticInteraction()
     54{}
     55 
     56G4double
    4857  G4InelasticInteraction::Pmltpc(      // used in Cascade functions
    4958   G4int np, G4int nm, G4int nz, G4int n, G4double b, G4double c )
     
    6372  }
    6473
    65  G4bool
     74G4bool
    6675  G4InelasticInteraction::MarkLeadingStrangeParticle(
    6776   const G4ReactionProduct &currentParticle,
     
    92101  }
    93102 
    94  void
     103void
    95104  G4InelasticInteraction::SetUpPions(
    96105   const G4int np,
     
    126135  }
    127136 
    128  void
     137void
    129138  G4InelasticInteraction::GetNormalizationConstant(
    130139   const G4double energy,  // MeV,  <0 means annihilation channels
     
    170179  }
    171180 
    172  void
     181void
    173182  G4InelasticInteraction::CalculateMomenta(
    174183   G4FastVector<G4ReactionProduct,GHADLISTSIZE> &vec,
     
    344353
    345354 
    346  void G4InelasticInteraction::
     355void G4InelasticInteraction::
    347356 Rotate(G4FastVector<G4ReactionProduct,GHADLISTSIZE> &vec, G4int &vecLen)
    348357 {
     
    358367 }     
    359368
    360  void
     369void
    361370  G4InelasticInteraction::SetUpChange(
    362371   G4FastVector<G4ReactionProduct,GHADLISTSIZE> &vec,
Note: See TracChangeset for help on using the changeset viewer.