G4INCLClusteringModelIntercomparison.hh

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 // INCL++ intra-nuclear cascade model
00027 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
00028 // Davide Mancusi, CEA
00029 // Alain Boudard, CEA
00030 // Sylvie Leray, CEA
00031 // Joseph Cugnon, University of Liege
00032 //
00033 #define INCLXX_IN_GEANT4_MODE 1
00034 
00035 #include "globals.hh"
00036 
00037 #ifndef G4INCLClusteringModelIntercomparison_hh
00038 #define G4INCLClusteringModelIntercomparison_hh 1
00039 
00040 #ifdef INCLXX_IN_GEANT4_MODE
00041 #define INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_Set 1
00042 #endif // INCLXX_IN_GEANT4_MODE
00043 
00044 #include "G4INCLIClusteringModel.hh"
00045 #include "G4INCLParticle.hh"
00046 #include "G4INCLParticleTable.hh"
00047 #include "G4INCLCluster.hh"
00048 #include "G4INCLNucleus.hh"
00049 #include "G4INCLKinematicsUtils.hh"
00050 #include "G4INCLHashing.hh"
00051 
00052 #include <set>
00053 #include <algorithm>
00054 
00055 namespace G4INCL {
00056 
00058   class ClusteringModelIntercomparison : public IClusteringModel {
00059   public:
00060     ClusteringModelIntercomparison(Config const * const theConfig) :
00061       theNucleus(NULL),
00062       selectedA(0),
00063       selectedZ(0),
00064       sqtot(0.),
00065       cascadingEnergyPool(0.),
00066       protonMass(ParticleTable::getRealMass(Proton)),
00067       neutronMass(ParticleTable::getRealMass(Neutron)),
00068       runningMaxClusterAlgorithmMass(theConfig->getClusterMaxMass()),
00069       nConsideredMax(0),
00070       nConsidered(0),
00071       consideredPartners(NULL),
00072       isInRunningConfiguration(NULL),
00073       maxMassConfigurationSkipping(ParticleTable::maxClusterMass)
00074     {
00075       // Set up the maximum charge and neutron number for clusters
00076       clusterZMaxAll = 0;
00077       clusterNMaxAll = 0;
00078       for(G4int A=0; A<=runningMaxClusterAlgorithmMass; ++A) {
00079         if(ParticleTable::clusterZMax[A]>clusterZMaxAll)
00080           clusterZMaxAll = ParticleTable::clusterZMax[A];
00081         if(A-ParticleTable::clusterZMin[A]>clusterNMaxAll)
00082           clusterNMaxAll = A-ParticleTable::clusterZMin[A];
00083       }
00084       std::fill(candidateConfiguration,
00085                 candidateConfiguration + ParticleTable::maxClusterMass,
00086                 static_cast<Particle*>(NULL));
00087 
00088       std::fill(runningEnergies,
00089                 runningEnergies + ParticleTable::maxClusterMass,
00090                 0.0);
00091 
00092       std::fill(runningPotentials,
00093                 runningPotentials + ParticleTable::maxClusterMass,
00094                 0.0);
00095 
00096       std::fill(runningConfiguration,
00097                 runningConfiguration + ParticleTable::maxClusterMass,
00098                 -1);
00099 
00100     }
00101 
00102     virtual ~ClusteringModelIntercomparison() {
00103       delete [] consideredPartners;
00104       delete [] isInRunningConfiguration;
00105     }
00106 
00107     virtual Cluster* getCluster(Nucleus*, Particle*);
00108     virtual G4bool clusterCanEscape(Nucleus const * const, Cluster const * const);
00109 
00110   private:
00111     void findClusterStartingFrom(const G4int oldA, const G4int oldZ);
00112     G4double getPhaseSpace(const G4int oldA, Particle const * const p);
00113 
00114     Nucleus *theNucleus;
00115 
00116     G4double runningEnergies[ParticleTable::maxClusterMass+1];
00117     ThreeVector runningMomenta[ParticleTable::maxClusterMass+1];
00118     ThreeVector runningPositions[ParticleTable::maxClusterMass+1];
00119     G4double runningPotentials[ParticleTable::maxClusterMass+1];
00120 #if defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_HashMask)
00121     Hashing::NucleonItem runningConfiguration[ParticleTable::maxClusterMass];
00122 #elif defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_Set)
00123     G4int runningConfiguration[ParticleTable::maxClusterMass];
00124 #else
00125 #error Unrecognized INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON. Allowed values are: Set, HashMask.
00126 #endif
00127 
00128     G4int selectedA, selectedZ;
00129     G4double sqtot;
00130 
00131     G4int clusterZMaxAll, clusterNMaxAll;
00132 
00133     G4double cascadingEnergyPool;
00134 
00135     static const G4double limitCosEscapeAngle;
00136 
00137     const G4double protonMass;
00138     const G4double neutronMass;
00139 
00140     G4int runningMaxClusterAlgorithmMass;
00141 
00142     G4int nConsideredMax;
00143     G4int nConsidered;
00144 
00157     Particle **consideredPartners;
00158 
00164     G4bool *isInRunningConfiguration;
00165 
00171     Particle *candidateConfiguration[ParticleTable::maxClusterMass];
00172 
00173 #if defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_HashMask)
00174     typedef std::set<Hashing::HashType> HashContainer;
00175     typedef HashContainer::iterator HashIterator;
00176 
00178     HashContainer checkedConfigurations[ParticleTable::maxClusterMass-2];
00179 #elif defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_Set)
00180 
00187     class SortedNucleonConfiguration {
00188       public:
00189         // Use Particle* as nucleon identifiers
00190         typedef G4int NucleonItem;
00191 
00193         SortedNucleonConfiguration() : theSize(0), nucleons(NULL) {}
00194 
00196         SortedNucleonConfiguration(const SortedNucleonConfiguration &rhs) :
00197           theSize(rhs.theSize),
00198           nucleons(new NucleonItem[theSize])
00199       {
00200         std::copy(rhs.nucleons, rhs.nucleons+theSize, nucleons);
00201       }
00202 
00204         ~SortedNucleonConfiguration() {
00205           delete [] nucleons;
00206         }
00207 
00209         void swap(SortedNucleonConfiguration &rhs) {
00210           std::swap(theSize, rhs.theSize);
00211           std::swap(nucleons, rhs.nucleons);
00212         }
00213 
00215         SortedNucleonConfiguration &operator=(const SortedNucleonConfiguration &rhs) {
00216           SortedNucleonConfiguration tempConfig(rhs);
00217           swap(tempConfig);
00218           return *this;
00219         }
00220 
00226         G4bool operator<(const SortedNucleonConfiguration &rhs) const {
00227 // assert(theSize==rhs.theSize);
00228           return std::lexicographical_compare(nucleons, nucleons+theSize, rhs.nucleons, rhs.nucleons+theSize);
00229         }
00230 
00232         void fill(NucleonItem *config, size_t n) {
00233           theSize = n;
00234           nucleons = new NucleonItem[theSize];
00235           std::copy(config, config+theSize, nucleons);
00236           std::sort(nucleons, nucleons+theSize);
00237         }
00238 
00239       private:
00241         size_t theSize;
00242 
00244         NucleonItem *nucleons;
00245     };
00246 
00247     typedef std::set<SortedNucleonConfiguration> SortedNucleonConfigurationContainer;
00248     typedef SortedNucleonConfigurationContainer::iterator SortedNucleonConfigurationIterator;
00249 
00251     SortedNucleonConfigurationContainer checkedConfigurations[ParticleTable::maxClusterMass-2];
00252 #else
00253 #error Unrecognized INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON. Allowed values are: Set, HashMask.
00254 #endif
00255 
00260     G4int maxMassConfigurationSkipping;
00261   };
00262 
00263 }
00264 
00265 #endif

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