Geant4  10.00.p01
G4INCLStore.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 G4INCLParticleStore_hh
38 #define G4INCLParticleStore_hh 1
39 
40 #include <map>
41 #include <list>
42 #include <string>
43 #include <algorithm>
44 
45 #include "G4INCLParticle.hh"
46 #include "G4INCLIAvatar.hh"
47 #include "G4INCLBook.hh"
48 #include "G4INCLConfig.hh"
49 
50 #ifdef INCLXX_IN_GEANT4_MODE
51 #define INCL_AVATAR_SEARCH_MinElement 1
52 #endif // INCLXX_IN_GEANT4_MODE
53 
54 namespace G4INCL {
55 
61  class Store {
62  public:
66  Store(Config const * const config);
67 
71  ~Store();
72 
81  void add(Particle *p);
82 
85 
87  void addParticleEntryAvatars(IAvatarList const &al);
88 
103  void add(IAvatar *a);
104 
108  IAvatarList const &getAvatars() const {
109  return avatarList;
110  }
111 
117  void addIncomingParticle(Particle * const p);
118 
124  void removeFromIncoming(Particle * const p) { incoming.remove(p); }
125 
127  inline void clearIncoming() {
128  incoming.clear();
129  }
130 
132  inline void deleteIncoming() {
133  for(ParticleIter iter=incoming.begin(), e=incoming.end(); iter!=e; ++iter) {
134  delete (*iter);
135  }
136  clearIncoming();
137  }
138 
144  void particleHasBeenUpdated(Particle * const);
145 
150 
155  void timeStep(G4double step);
156 
162  void particleHasBeenEjected(Particle * const);
163 
168  void addToOutgoing(Particle *p) { outgoing.push_back(p); }
169 
174  void addToOutgoing(ParticleList const &pl) {
175  for(ParticleIter p=pl.begin(), e=pl.end(); p!=e; ++p)
176  addToOutgoing(*p);
177  }
178 
183  void particleHasBeenDestroyed(Particle * const);
184 
189  void particleHasEntered(Particle * const particle);
190 
195  ParticleList const & getIncomingParticles() const { return incoming; }
196 
201  ParticleList const & getOutgoingParticles() const { return outgoing; }
202 
211  ParticleList spectators;
212  for(ParticleIter p=outgoing.begin(), e=outgoing.end(); p!=e; ++p) {
213  if((*p)->isProjectileSpectator()) {
214 // assert((*p)->isNucleon());
215  spectators.push_back(*p); // add them to the list we will return
216  }
217  }
218 
219  // Now erase them from outgoing
220  for(ParticleIter i=spectators.begin(); i!=spectators.end(); ++i) {
221  outgoing.remove(*i);
222  }
223 
224  return spectators;
225  }
226 
231  ParticleList const & getParticles() const { return inside; }
232 
237  Book &getBook() { return theBook; };
238 
240  G4int n=0;
241  for(ParticleIter i=inside.begin(), e=inside.end(); i!=e; ++i) {
242  if(!(*i)->isTargetSpectator())
243  ++n;
244  }
245  return n;
246  }
247 
251  Config const * getConfig() { return theConfig; };
252 
258  void clear();
259 
265  void clearInside();
266 
272  void clearOutgoing();
273 
277  void clearAvatars();
278 
285 
290  void loadParticles(std::string filename);
291 
296  G4int getLoadedA() { return loadedA; };
297 
302  G4int getLoadedZ() { return loadedZ; };
303 
309 
313  std::string printParticleConfiguration();
314 
318  void writeParticles(std::string filename);
319 
323  std::string printAvatars();
324 
325  G4bool containsCollisions() const;
326 
327 #if defined(INCL_AVATAR_SEARCH_FullSort) || defined(INCL_AVATAR_SEARCH_MinElement)
328 
338  return (lhs->getTime() < rhs->getTime());
339  }
340 #elif defined(INCL_AVATAR_SEARCH_INCLSort)
341 
354  std::list<IAvatarIter>::iterator binaryIterSearch(IAvatar const * const avatar);
355 #endif
356 
357  private:
359  Store(const Store &rhs);
360 
362  Store &operator=(Store const &rhs);
363 
364 
373  void connectAvatarToParticle(IAvatar * const a, Particle * const p);
374 
384  void disconnectAvatarFromParticle(IAvatar * const a, Particle * const p);
385 
393  void removeAvatar(IAvatar * const a);
394 
401  void removeAndDeleteAvatar(IAvatar * const a);
402 
403  private:
407  std::map<Particle*, IAvatarList* > particleAvatarConnections;
408 
413 
418 
423 
428 
433 
438 
443 
448 
453 
458 
462  Config const * theConfig;
463 
464 #ifdef INCL_AVATAR_SEARCH_INCLSort
465 
470  std::list<IAvatarIter> avatarIterList;
471 #endif
472 
473  };
474 }
475 #endif
std::string printParticleConfiguration()
Print the nucleon configuration of the nucleus.
Definition: G4INCLStore.cc:360
void writeParticles(std::string filename)
Print the nucleon configuration of the nucleus.
Definition: G4INCLStore.cc:411
void clearAvatars()
Clear avatars only.
Definition: G4INCLStore.cc:252
The INCL configuration object.
Definition: G4INCLConfig.hh:67
static G4bool avatarComparisonPredicate(IAvatar *lhs, IAvatar *rhs)
Comparison predicate for avatars.
Definition: G4INCLStore.hh:337
void disconnectAvatarFromParticle(IAvatar *const a, Particle *const p)
Disconnect an avatar from a particle.
Definition: G4INCLStore.cc:116
std::string printAvatars()
Print the list of avatars.
Definition: G4INCLStore.cc:417
ParticleList const & getParticles() const
Return the list of "active" particles (i.e.
Definition: G4INCLStore.hh:231
Config const * theConfig
Pointer to the Config object.
Definition: G4INCLStore.hh:462
G4int getLoadedA()
Get the value of the nucleus mass number that we read from file with loadParticles.
Definition: G4INCLStore.hh:296
void removeAndDeleteAvatar(IAvatar *const a)
Remove an avatar from the list of avatars.
Definition: G4INCLStore.cc:139
ParticleList geomSpectators
List of geometrical spectators.
Definition: G4INCLStore.hh:432
G4bool containsCollisions() const
Definition: G4INCLStore.cc:425
IAvatar * findSmallestTime()
Find the avatar that has the smallest time.
Definition: G4INCLStore.cc:173
Config const * getConfig()
Get the config object.
Definition: G4INCLStore.hh:251
void add(Particle *p)
Add one particle to the store.
Definition: G4INCLStore.cc:57
ParticleList outgoing
List of outgoing particles.
Definition: G4INCLStore.hh:427
G4int loadedA
The target nucleus mass number that was loaded from a particle file.
Definition: G4INCLStore.hh:447
void remove(const T &t)
G4double a
Definition: TRTMaterials.hh:39
void deleteIncoming()
Clear the incoming list and delete the particles.
Definition: G4INCLStore.hh:132
ParticleList const & getIncomingParticles() const
Return the list of incoming particles (i.e.
Definition: G4INCLStore.hh:195
Store(Config const *const config)
Store constructor.
Definition: G4INCLStore.cc:44
void connectAvatarToParticle(IAvatar *const a, Particle *const p)
Connect an avatar to a particle.
Definition: G4INCLStore.cc:104
int G4int
Definition: G4Types.hh:78
void removeAvatar(IAvatar *const a)
Remove an avatar from the list of avatars.
Definition: G4INCLStore.cc:120
IAvatarList const & getAvatars() const
Return the list of avatars.
Definition: G4INCLStore.hh:108
IAvatarList avatarList
List of all avatars.
Definition: G4INCLStore.hh:412
void clear()
Clear all avatars and particles from the store.
Definition: G4INCLStore.cc:273
void addParticleEntryAvatars(IAvatarList const &al)
Add one ParticleEntry avatar.
Definition: G4INCLStore.cc:78
G4double getTime() const
G4double getLoadedStoppingTime()
Get the value of the stopping time that we read from file with loadParticles.
Definition: G4INCLStore.hh:308
ParticleList const & getOutgoingParticles() const
Return the list of outgoing particles (i.e.
Definition: G4INCLStore.hh:201
Book & getBook()
Return the pointer to the Book object which keeps track of various counters.
Definition: G4INCLStore.hh:237
G4double loadedStoppingTime
The stopping time that was loaded from a particle file.
Definition: G4INCLStore.hh:457
ParticleList extractDynamicalSpectators()
Returns a list of dynamical spectators.
Definition: G4INCLStore.hh:210
void particleHasBeenDestroyed(Particle *const)
Remove the particle from the system.
Definition: G4INCLStore.cc:240
void initialiseParticleAvatarConnections()
Initialise the particleAvatarConnections map.
Definition: G4INCLStore.cc:267
bool G4bool
Definition: G4Types.hh:79
void particleHasBeenEjected(Particle *const)
Mark the particle as ejected.
Definition: G4INCLStore.cc:231
Store & operator=(Store const &rhs)
Dummy assignment operator to shut up Coverity warnings.
const G4int n
void clearInside()
Clear all inside particles from the store.
Definition: G4INCLStore.cc:290
G4int getLoadedZ()
Get the value of the nucleus charge number that we read from file with loadParticles.
Definition: G4INCLStore.hh:302
void clearOutgoing()
Clear all outgoing particles from the store.
Definition: G4INCLStore.cc:297
G4int countCascading()
Definition: G4INCLStore.hh:239
void addParticleEntryAvatar(IAvatar *a)
Add one ParticleEntry avatar.
Definition: G4INCLStore.cc:66
void particleHasBeenUpdated(Particle *const)
Notify the Store that a particle has been updated.
Definition: G4INCLStore.cc:144
void loadParticles(std::string filename)
Load particle configuration from ASCII file (see avatarPredictionTest).
Definition: G4INCLStore.cc:313
ParticleList incoming
List of incoming particles.
Definition: G4INCLStore.hh:417
void addToOutgoing(ParticleList const &pl)
Add a list of particles to the outgoing particle list.
Definition: G4INCLStore.hh:174
void addIncomingParticle(Particle *const p)
Add a particle to the incoming list.
Definition: G4INCLStore.cc:100
std::map< Particle *, IAvatarList * > particleAvatarConnections
Map particle -> [avatar].
Definition: G4INCLStore.hh:407
The purpose of the Store object is to act as a "particle manager" that keeps track ofall the particle...
Definition: G4INCLStore.hh:61
double G4double
Definition: G4Types.hh:76
~Store()
Store destructor.
Definition: G4INCLStore.cc:52
G4int loadedZ
The target nucleus charge number that was loaded from a particle file.
Definition: G4INCLStore.hh:452
void addToOutgoing(Particle *p)
add the particle to the outgoing particle list.
Definition: G4INCLStore.hh:168
Book theBook
The Book object keeps track of global counters.
Definition: G4INCLStore.hh:442
G4double currentTime
The current time in the simulation.
Definition: G4INCLStore.hh:437
void timeStep(G4double step)
Make one time step: propagate particles and subtract the length of the step from the avatar times...
Definition: G4INCLStore.cc:224
ParticleList::const_iterator ParticleIter
void removeFromIncoming(Particle *const p)
Add a particle to the incoming list.
Definition: G4INCLStore.hh:124
void clearIncoming()
Clear the incoming list.
Definition: G4INCLStore.hh:127
void particleHasEntered(Particle *const particle)
Move a particle from incoming to inside.
Definition: G4INCLStore.cc:247
ParticleList inside
List of particles that are inside the nucleus.
Definition: G4INCLStore.hh:422