Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4INCLClusteringModelIntercomparison.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // INCL++ intra-nuclear cascade model
27 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
28 // Davide Mancusi, CEA
29 // Alain Boudard, CEA
30 // Sylvie Leray, CEA
31 // Joseph Cugnon, University of Liege
32 //
33 #define INCLXX_IN_GEANT4_MODE 1
34 
35 #include "globals.hh"
36 
37 #ifndef G4INCLClusteringModelIntercomparison_hh
38 #define G4INCLClusteringModelIntercomparison_hh 1
39 
40 #ifdef INCLXX_IN_GEANT4_MODE
41 #define INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_Set 1
42 #endif // INCLXX_IN_GEANT4_MODE
43 
45 #include "G4INCLParticle.hh"
46 #include "G4INCLParticleTable.hh"
47 #include "G4INCLCluster.hh"
48 #include "G4INCLNucleus.hh"
49 #include "G4INCLKinematicsUtils.hh"
50 #include "G4INCLHashing.hh"
51 
52 #include <set>
53 #include <algorithm>
54 
55 namespace G4INCL {
56 
59  public:
60  ClusteringModelIntercomparison(Config const * const theConfig) :
61  theNucleus(NULL),
62  selectedA(0),
63  selectedZ(0),
64  sqtot(0.),
65  cascadingEnergyPool(0.),
66  protonMass(ParticleTable::getRealMass(Proton)),
67  neutronMass(ParticleTable::getRealMass(Neutron)),
68  runningMaxClusterAlgorithmMass(theConfig->getClusterMaxMass()),
69  nConsideredMax(0),
70  nConsidered(0),
71  consideredPartners(NULL),
72  isInRunningConfiguration(NULL),
73  maxMassConfigurationSkipping(ParticleTable::maxClusterMass)
74  {
75  // Set up the maximum charge and neutron number for clusters
76  clusterZMaxAll = 0;
77  clusterNMaxAll = 0;
78  for(G4int A=0; A<=runningMaxClusterAlgorithmMass; ++A) {
79  if(ParticleTable::clusterZMax[A]>clusterZMaxAll)
80  clusterZMaxAll = ParticleTable::clusterZMax[A];
81  if(A-ParticleTable::clusterZMin[A]>clusterNMaxAll)
82  clusterNMaxAll = A-ParticleTable::clusterZMin[A];
83  }
84  std::fill(candidateConfiguration,
85  candidateConfiguration + ParticleTable::maxClusterMass,
86  static_cast<Particle*>(NULL));
87 
88  std::fill(runningEnergies,
89  runningEnergies + ParticleTable::maxClusterMass,
90  0.0);
91 
92  std::fill(runningPotentials,
93  runningPotentials + ParticleTable::maxClusterMass,
94  0.0);
95 
96  std::fill(runningConfiguration,
97  runningConfiguration + ParticleTable::maxClusterMass,
98  -1);
99 
100  }
101 
103  delete [] consideredPartners;
104  delete [] isInRunningConfiguration;
105  }
106 
107  virtual Cluster* getCluster(Nucleus*, Particle*);
108  virtual G4bool clusterCanEscape(Nucleus const * const, Cluster const * const);
109 
110  private:
111  void findClusterStartingFrom(const G4int oldA, const G4int oldZ);
112  G4double getPhaseSpace(const G4int oldA, Particle const * const p);
113 
114  Nucleus *theNucleus;
115 
116  G4double runningEnergies[ParticleTable::maxClusterMass+1];
117  ThreeVector runningMomenta[ParticleTable::maxClusterMass+1];
118  ThreeVector runningPositions[ParticleTable::maxClusterMass+1];
119  G4double runningPotentials[ParticleTable::maxClusterMass+1];
120 #if defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_HashMask)
121  Hashing::NucleonItem runningConfiguration[ParticleTable::maxClusterMass];
122 #elif defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_Set)
123  G4int runningConfiguration[ParticleTable::maxClusterMass];
124 #else
125 #error Unrecognized INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON. Allowed values are: Set, HashMask.
126 #endif
127 
128  G4int selectedA, selectedZ;
129  G4double sqtot;
130 
131  G4int clusterZMaxAll, clusterNMaxAll;
132 
133  G4double cascadingEnergyPool;
134 
135  static const G4double limitCosEscapeAngle;
136 
137  const G4double protonMass;
138  const G4double neutronMass;
139 
140  G4int runningMaxClusterAlgorithmMass;
141 
142  G4int nConsideredMax;
143  G4int nConsidered;
144 
157  Particle **consideredPartners;
158 
164  G4bool *isInRunningConfiguration;
165 
171  Particle *candidateConfiguration[ParticleTable::maxClusterMass];
172 
173 #if defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_HashMask)
174  typedef std::set<Hashing::HashType> HashContainer;
175  typedef HashContainer::iterator HashIterator;
176 
178  HashContainer checkedConfigurations[ParticleTable::maxClusterMass-2];
179 #elif defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_Set)
180 
187  class SortedNucleonConfiguration {
188  public:
189  // Use Particle* as nucleon identifiers
190  typedef G4int NucleonItem;
191 
193  SortedNucleonConfiguration() : theSize(0), nucleons(NULL) {}
194 
196  SortedNucleonConfiguration(const SortedNucleonConfiguration &rhs) :
197  theSize(rhs.theSize),
198  nucleons(new NucleonItem[theSize])
199  {
200  std::copy(rhs.nucleons, rhs.nucleons+theSize, nucleons);
201  }
202 
204  ~SortedNucleonConfiguration() {
205  delete [] nucleons;
206  }
207 
209  void swap(SortedNucleonConfiguration &rhs) {
210  std::swap(theSize, rhs.theSize);
211  std::swap(nucleons, rhs.nucleons);
212  }
213 
215  SortedNucleonConfiguration &operator=(const SortedNucleonConfiguration &rhs) {
216  SortedNucleonConfiguration tempConfig(rhs);
217  swap(tempConfig);
218  return *this;
219  }
220 
226  G4bool operator<(const SortedNucleonConfiguration &rhs) const {
227 // assert(theSize==rhs.theSize);
228  return std::lexicographical_compare(nucleons, nucleons+theSize, rhs.nucleons, rhs.nucleons+theSize);
229  }
230 
232  void fill(NucleonItem *config, size_t n) {
233  theSize = n;
234  nucleons = new NucleonItem[theSize];
235  std::copy(config, config+theSize, nucleons);
236  std::sort(nucleons, nucleons+theSize);
237  }
238 
239  private:
241  size_t theSize;
242 
244  NucleonItem *nucleons;
245  };
246 
247  typedef std::set<SortedNucleonConfiguration> SortedNucleonConfigurationContainer;
248  typedef SortedNucleonConfigurationContainer::iterator SortedNucleonConfigurationIterator;
249 
251  SortedNucleonConfigurationContainer checkedConfigurations[ParticleTable::maxClusterMass-2];
252 #else
253 #error Unrecognized INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON. Allowed values are: Set, HashMask.
254 #endif
255 
260  G4int maxMassConfigurationSkipping;
261  };
262 
263 }
264 
265 #endif