Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4INCLProjectileRemnant.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 
44 #ifndef G4INCLPROJECTILEREMNANT_HH_
45 #define G4INCLPROJECTILEREMNANT_HH_
46 
47 #include "G4INCLCluster.hh"
48 #include "G4INCLRandom.hh"
49 #include <vector>
50 #include <map>
51 #include <numeric>
52 #include <functional>
53 
54 namespace G4INCL {
55 
58 
59  class ProjectileRemnant : public Cluster {
60  // typedefs for the calculation of the projectile excitation energy
61  typedef std::vector<G4double> EnergyLevels;
62  typedef std::map<long, G4double> EnergyLevelMap;
63 
64  public:
65  ProjectileRemnant(ParticleSpecies const species, const G4double kineticEnergy)
66  : Cluster(species.theZ, species.theA) {
67 
68  // Use the table mass
69  setTableMass();
70 
71  // Set the kinematics
72  const G4double projectileMass = getMass();
73  const G4double energy = kineticEnergy + projectileMass;
74  const G4double momentumZ = std::sqrt(energy*energy - projectileMass*projectileMass);
75 
76  // Initialise the particles
80 
81  // Store the energy levels of the ProjectileRemnant (used to compute its
82  // excitation energy)
84 
85  // Boost the whole thing
86  const ThreeVector aBoostVector = ThreeVector(0.0, 0.0, momentumZ / energy);
87  boost(-aBoostVector);
88 
89  // Freeze the internal motion of the particles
91 
92  // Set as projectile spectator
94  }
95 
99  }
100 
102  void reset();
103 
109  void removeParticle(Particle * const p, const G4double theProjectileCorrection);
110 
120 
131 
134  for(std::map<long,Particle*>::const_iterator p=storedComponents.begin(); p!=storedComponents.end(); ++p)
135  delete p->second;
137  }
138 
141  storedComponents.clear();
142  }
143 
146  theInitialEnergyLevels.clear();
147  theGroundStateEnergies.clear();
148  }
149 
159  G4double computeExcitationEnergy(const long exceptID) const;
160 
161  EnergyLevels getPresentEnergyLevels(const long exceptID) const {
162  EnergyLevels theEnergyLevels;
163  for(ParticleIter p=particles.begin(); p!=particles.end(); ++p) {
164  if((*p)->getID()!=exceptID) {
165  EnergyLevelMap::const_iterator i = theInitialEnergyLevels.find((*p)->getID());
166 // assert(i!=theInitialEnergyLevels.end());
167  theEnergyLevels.push_back(i->second);
168  }
169  }
170 // assert(theEnergyLevels.size()==particles.size()-1);
171  return theEnergyLevels;
172  }
173 
176  for(ParticleIter p=particles.begin(); p!=particles.end(); ++p) {
177  // Store the particles (needed for forced CN)
178  storedComponents[(*p)->getID()]=new Particle(**p);
179  }
180  }
181 
184  return storedComponents.size();
185  }
186 
189  EnergyLevels energies;
190 
191  for(ParticleIter p=particles.begin(); p!=particles.end(); ++p) {
192  const G4double theCMEnergy = (*p)->getEnergy();
193  // Store the CM energy in the EnergyLevels map
194  theInitialEnergyLevels[(*p)->getID()] = theCMEnergy;
195  energies.push_back(theCMEnergy);
196  }
197 
198  std::sort(energies.begin(), energies.end());
199 // assert(energies.size()==(unsigned int)theA);
200  theGroundStateEnergies.resize(energies.size());
201  // Compute the partial sums of the CM energies -- they are our reference
202  // ground-state energies for any number of nucleons
203  std::partial_sum(energies.begin(), energies.end(), theGroundStateEnergies.begin());
204  }
205 
206  private:
207 
209  ParticleList shuffleStoredComponents() {
210  ParticleList pL = getStoredComponents();
211  std::vector<Particle *> theVector(pL.begin(),pL.end());
212  std::random_shuffle(theVector.begin(), theVector.end(), shuffleComponentsHelper);
213  return ParticleList(theVector.begin(),theVector.end());
214  }
215 
216  ParticleList getStoredComponents() const {
217  ParticleList pL;
218  for(std::map<long,Particle*>::const_iterator p=storedComponents.begin(); p!=storedComponents.end(); ++p)
219  pL.push_back(p->second);
220  return pL;
221  }
222 
224  ThreeVector const &getStoredMomentum(Particle const * const p) const {
225  std::map<long,Particle*>::const_iterator i = storedComponents.find(p->getID());
226  if(i==storedComponents.end()) {
227  ERROR("Couldn't find particle " << p->getID() << " in the list of projectile components" << std::endl);
228  return p->getMomentum();
229  } else {
230  return i->second->getMomentum();
231  }
232  }
233 
240  G4bool addDynamicalSpectator(Particle * const p);
241 
243  /* G4double getStoredEnergy(Particle const * const p) {
244  std::map<long,Particle*>::const_iterator i = initialProjectileComponents.find(p->getID());
245  if(i==initialProjectileComponents.end()) {
246  ERROR("Couldn't find particle " << p->getID() << " in the list of projectile components" << std::endl);
247  return 0.;
248  } else {
249  return i->second->getEnergy();
250  }
251  }*/
252 
254  std::map<long, Particle*> storedComponents;
255 
257  EnergyLevelMap theInitialEnergyLevels;
258 
260  EnergyLevels theGroundStateEnergies;
261 
262  };
263 }
264 
265 #endif // G4INCLPROJECTILEREMNANT_HH_
266