Geant4_10
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 
71 
73  particle(NULL),
74  isTargetSpectator(false),
75  Z(0),
76  energy(0.),
77  potentialEnergy(0.)
78  {}
79 
81  particle(p),
83  Z(particle->getZ()),
84  position(particle->getPosition()),
85  momentum(particle->getMomentum()),
86  energy(particle->getEnergy()),
87  potentialEnergy(particle->getPotentialEnergy())
88  {}
89  };
90 
93  public:
94  ClusteringModelIntercomparison(Config const * const theConfig) :
95  theNucleus(NULL),
96  selectedA(0),
97  selectedZ(0),
98  sqtot(0.),
99  cascadingEnergyPool(0.),
100  protonMass(ParticleTable::getRealMass(Proton)),
101  neutronMass(ParticleTable::getRealMass(Neutron)),
102  runningMaxClusterAlgorithmMass(theConfig->getClusterMaxMass()),
103  nConsideredMax(0),
104  nConsidered(0),
105  consideredPartners(NULL),
106  isInRunningConfiguration(NULL),
107  maxMassConfigurationSkipping(ParticleTable::maxClusterMass)
108  {
109  // Set up the maximum charge and neutron number for clusters
110  clusterZMaxAll = 0;
111  clusterNMaxAll = 0;
112  for(G4int A=0; A<=runningMaxClusterAlgorithmMass; ++A) {
113  if(clusterZMax[A]>clusterZMaxAll)
114  clusterZMaxAll = clusterZMax[A];
115  if(A-clusterZMin[A]>clusterNMaxAll)
116  clusterNMaxAll = A-clusterZMin[A];
117  }
118  std::fill(candidateConfiguration,
119  candidateConfiguration + ParticleTable::maxClusterMass,
120  static_cast<Particle*>(NULL));
121 
122  std::fill(runningEnergies,
123  runningEnergies + ParticleTable::maxClusterMass,
124  0.0);
125 
126  std::fill(runningPotentials,
127  runningPotentials + ParticleTable::maxClusterMass,
128  0.0);
129 
130  std::fill(runningConfiguration,
131  runningConfiguration + ParticleTable::maxClusterMass,
132  -1);
133 
134  }
135 
137  delete [] consideredPartners;
138  delete [] isInRunningConfiguration;
139  }
140 
141  virtual Cluster* getCluster(Nucleus*, Particle*);
142  virtual G4bool clusterCanEscape(Nucleus const * const, Cluster const * const);
143 
144  private:
145  void findClusterStartingFrom(const G4int oldA, const G4int oldZ);
146  G4double getPhaseSpace(const G4int oldA, ConsideredPartner const &p);
147 
148  Nucleus *theNucleus;
149 
150  G4double runningEnergies[ParticleTable::maxClusterMass+1];
151  ThreeVector runningMomenta[ParticleTable::maxClusterMass+1];
152  ThreeVector runningPositions[ParticleTable::maxClusterMass+1];
153  G4double runningPotentials[ParticleTable::maxClusterMass+1];
154 #if defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_HashMask)
155  Hashing::NucleonItem runningConfiguration[ParticleTable::maxClusterMass];
156 #elif defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_Set)
157  G4int runningConfiguration[ParticleTable::maxClusterMass];
158 #else
159 #error Unrecognized INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON. Allowed values are: Set, HashMask.
160 #endif
161 
162  G4int selectedA, selectedZ;
163  G4double sqtot;
164 
165  G4int clusterZMaxAll, clusterNMaxAll;
166 
167  G4double cascadingEnergyPool;
168 
170  static const G4int clusterZMin[ParticleTable::maxClusterMass+1];
172  static const G4int clusterZMax[ParticleTable::maxClusterMass+1];
173 
175  static const G4double clusterPosFact[ParticleTable::maxClusterMass+1];
176 
178  static const G4double clusterPosFact2[ParticleTable::maxClusterMass+1];
179 
181  static const G4double clusterPhaseSpaceCut[ParticleTable::maxClusterMass+1];
182 
183  static const G4double limitCosEscapeAngle;
184 
185  const G4double protonMass;
186  const G4double neutronMass;
187 
188  G4int runningMaxClusterAlgorithmMass;
189 
190  G4int nConsideredMax;
191  G4int nConsidered;
192 
206  ConsideredPartner *consideredPartners;
207 
213  G4bool *isInRunningConfiguration;
214 
220  Particle *candidateConfiguration[ParticleTable::maxClusterMass];
221 
222 #if defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_HashMask)
223  typedef std::set<Hashing::HashType> HashContainer;
224  typedef HashContainer::iterator HashIterator;
225 
227  HashContainer checkedConfigurations[ParticleTable::maxClusterMass-2];
228 #elif defined(INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON_Set)
229 
236  class SortedNucleonConfiguration {
237  public:
238  // Use Particle* as nucleon identifiers
239  typedef G4int NucleonItem;
240 
242  SortedNucleonConfiguration() : theSize(0), nucleons(NULL) {}
243 
245  SortedNucleonConfiguration(const SortedNucleonConfiguration &rhs) :
246  theSize(rhs.theSize),
247  nucleons(new NucleonItem[theSize])
248  {
249  std::copy(rhs.nucleons, rhs.nucleons+theSize, nucleons);
250  }
251 
253  ~SortedNucleonConfiguration() {
254  delete [] nucleons;
255  }
256 
258  void swap(SortedNucleonConfiguration &rhs) {
259  std::swap(theSize, rhs.theSize);
260  std::swap(nucleons, rhs.nucleons);
261  }
262 
264  SortedNucleonConfiguration &operator=(const SortedNucleonConfiguration &rhs) {
265  SortedNucleonConfiguration tempConfig(rhs);
266  swap(tempConfig);
267  return *this;
268  }
269 
275  G4bool operator<(const SortedNucleonConfiguration &rhs) const {
276 // assert(theSize==rhs.theSize);
277  return std::lexicographical_compare(nucleons, nucleons+theSize, rhs.nucleons, rhs.nucleons+theSize);
278  }
279 
281  void fill(NucleonItem *config, size_t n) {
282  theSize = n;
283  nucleons = new NucleonItem[theSize];
284  std::copy(config, config+theSize, nucleons);
285  std::sort(nucleons, nucleons+theSize);
286  }
287 
288  private:
290  size_t theSize;
291 
293  NucleonItem *nucleons;
294  };
295 
296  typedef std::set<SortedNucleonConfiguration> SortedNucleonConfigurationContainer;
297  typedef SortedNucleonConfigurationContainer::iterator SortedNucleonConfigurationIterator;
298 
300  SortedNucleonConfigurationContainer checkedConfigurations[ParticleTable::maxClusterMass-2];
301 #else
302 #error Unrecognized INCL_CACHING_CLUSTERING_MODEL_INTERCOMPARISON. Allowed values are: Set, HashMask.
303 #endif
304 
309  G4int maxMassConfigurationSkipping;
310  };
311 
312 }
313 
314 #endif
virtual G4bool clusterCanEscape(Nucleus const *const, Cluster const *const)
const char * p
Definition: xmltok.h:285
subroutine sort(A, N)
Definition: dpm25nuc7.f:4670
int G4int
Definition: G4Types.hh:78
void copy(std::vector< T > &main, const std::vector< T > &data)
Definition: DicomRun.hh:91
G4double getRealMass(const G4INCL::ParticleType t)
Get particle mass (in MeV/c^2)
Char_t n[5]
bool G4bool
Definition: G4Types.hh:79
void swap(shared_ptr< P > &, shared_ptr< P > &)
Definition: memory.h:1247
Container for the relevant information.
virtual Cluster * getCluster(Nucleus *, Particle *)
bool operator<(const CexmcAngularRange &left, const CexmcAngularRange &right)
Functions for hashing a collection of NucleonItems.
Cluster coalescence algorithm used in the IAEA intercomparison.
double G4double
Definition: G4Types.hh:76