Geant4  10.02.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 // Alain Boudard, CEA-Saclay, France
28 // Joseph Cugnon, University of Liege, Belgium
29 // Jean-Christophe David, CEA-Saclay, France
30 // Pekka Kaitaniemi, CEA-Saclay, France, and Helsinki Institute of Physics, Finland
31 // Sylvie Leray, CEA-Saclay, France
32 // Davide Mancusi, CEA-Saclay, France
33 //
34 #define INCLXX_IN_GEANT4_MODE 1
35 
36 #include "globals.hh"
37 
38 #ifndef G4INCLParticleStore_hh
39 #define G4INCLParticleStore_hh 1
40 
41 #include <map>
42 #include <set>
43 #include <list>
44 #include <string>
45 #include <algorithm>
46 
47 #include "G4INCLParticle.hh"
48 #include "G4INCLIAvatar.hh"
49 #include "G4INCLBook.hh"
50 #include "G4INCLConfig.hh"
51 
52 #ifdef INCLXX_IN_GEANT4_MODE
53 #define INCL_AVATAR_SEARCH_MinElement 1
54 #endif // INCLXX_IN_GEANT4_MODE
55 
56 #if !defined(NDEBUG) && !defined(INCLXX_IN_GEANT4_MODE)
57 // Force instantiation of all the std::multimap<Particle*,IAvatar*> methods for
58 // debugging purposes
59 namespace G4INCL {
60  class Particle;
61  class IAvatar;
62 }
63 template class std::multimap<G4INCL::Particle*, G4INCL::IAvatar*>;
64 #endif
65 
66 namespace G4INCL {
67 
73  class Store {
74  public:
78  Store(Config const * const config);
79 
83  ~Store();
84 
93  void add(Particle *p);
94 
99  void add(ParticleList const &pL);
100 
102  void addParticleEntryAvatar(IAvatar *a);
103 
105  void addParticleEntryAvatars(IAvatarList const &al);
106 
121  void add(IAvatar *a);
122 
126  IAvatarList const &getAvatars() const {
127  return avatarList;
128  }
129 
135  void addIncomingParticle(Particle * const p);
136 
142  void removeFromIncoming(Particle * const p) { incoming.remove(p); }
143 
145  inline void clearIncoming() {
146  incoming.clear();
147  }
148 
150  inline void deleteIncoming() {
151  for(ParticleIter iter=incoming.begin(), e=incoming.end(); iter!=e; ++iter) {
152  delete (*iter);
153  }
154  clearIncoming();
155  }
156 
163  void particleHasBeenUpdated(Particle * const);
164 
166  void removeScheduledAvatars();
167 
171  IAvatar* findSmallestTime();
172 
177  void timeStep(G4double step);
178 
184  void particleHasBeenEjected(Particle * const);
185 
190  void addToOutgoing(Particle *p) { outgoing.push_back(p); }
191 
196  void addToOutgoing(ParticleList const &pl) {
197  for(ParticleIter p=pl.begin(), e=pl.end(); p!=e; ++p)
198  addToOutgoing(*p);
199  }
200 
205  void particleHasBeenDestroyed(Particle * const);
206 
211  void particleHasEntered(Particle * const particle);
212 
217  ParticleList const & getIncomingParticles() const { return incoming; }
218 
223  ParticleList const & getOutgoingParticles() const { return outgoing; }
224 
233  ParticleList spectators;
234  for(ParticleIter p=outgoing.begin(), e=outgoing.end(); p!=e; ++p) {
235  if((*p)->isProjectileSpectator()) {
236 // assert((*p)->isNucleon());
237  spectators.push_back(*p); // add them to the list we will return
238  }
239  }
240 
241  // Now erase them from outgoing
242  for(ParticleIter i=spectators.begin(); i!=spectators.end(); ++i) {
243  outgoing.remove(*i);
244  }
245 
246  return spectators;
247  }
248 
253  ParticleList const & getParticles() const { return inside; }
254 
259  Book &getBook() { return theBook; };
260 
262  G4int n=0;
263  for(ParticleIter i=inside.begin(), e=inside.end(); i!=e; ++i) {
264  if(!(*i)->isTargetSpectator())
265  ++n;
266  }
267  return n;
268  }
269 
273  Config const * getConfig() { return theConfig; };
274 
280  void clear();
281 
287  void clearInside();
288 
294  void clearOutgoing();
295 
299  void clearAvatars();
300 
305  void loadParticles(std::string const &filename);
306 
311  G4int getLoadedA() { return loadedA; };
312 
317  G4int getLoadedZ() { return loadedZ; };
318 
323  G4double getLoadedStoppingTime() { return loadedStoppingTime; };
324 
328  std::string printParticleConfiguration();
329 
333  void writeParticles(std::string const &filename);
334 
338  std::string printAvatars();
339 
340  G4bool containsCollisions() const;
341 
342 #if defined(INCL_AVATAR_SEARCH_FullSort) || defined(INCL_AVATAR_SEARCH_MinElement)
343 
353  return (lhs->getTime() < rhs->getTime());
354  }
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 
395  private:
399  std::multimap<Particle*, IAvatar*> particleAvatarConnections;
400  typedef std::multimap<Particle*, IAvatar*>::value_type PAPair;
401  typedef std::multimap<Particle*, IAvatar*>::iterator PAIter;
402  typedef std::pair<PAIter, PAIter> PAIterPair;
403 
405  std::set<IAvatar*> avatarsToBeRemoved;
406  typedef std::set<IAvatar*>::const_iterator ASIter;
407 
408  private:
413 
418 
423 
428 
433 
438 
443 
448 
453 
458 
462  Config const * theConfig;
463 
464  };
465 }
466 
467 #endif
The INCL configuration object.
Definition: G4INCLConfig.hh:60
static G4bool avatarComparisonPredicate(IAvatar *lhs, IAvatar *rhs)
Comparison predicate for avatars.
Definition: G4INCLStore.hh:352
ParticleList const & getParticles() const
Return the list of "active" particles (i.e.
Definition: G4INCLStore.hh:253
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:311
ParticleList geomSpectators
List of geometrical spectators.
Definition: G4INCLStore.hh:432
Config const * getConfig()
Get the config object.
Definition: G4INCLStore.hh:273
ParticleList outgoing
List of outgoing particles.
Definition: G4INCLStore.hh:427
std::multimap< Particle *, IAvatar * >::value_type PAPair
Definition: G4INCLStore.hh:400
G4int loadedA
The target nucleus mass number that was loaded from a particle file.
Definition: G4INCLStore.hh:447
G4double a
Definition: TRTMaterials.hh:39
void deleteIncoming()
Clear the incoming list and delete the particles.
Definition: G4INCLStore.hh:150
ParticleList const & getIncomingParticles() const
Return the list of incoming particles (i.e.
Definition: G4INCLStore.hh:217
int G4int
Definition: G4Types.hh:78
IAvatarList const & getAvatars() const
Return the list of avatars.
Definition: G4INCLStore.hh:126
std::set< IAvatar * >::const_iterator ASIter
Definition: G4INCLStore.hh:406
IAvatarList avatarList
List of all avatars.
Definition: G4INCLStore.hh:412
G4double getTime() const
G4double getLoadedStoppingTime()
Get the value of the stopping time that we read from file with loadParticles.
Definition: G4INCLStore.hh:323
ParticleList const & getOutgoingParticles() const
Return the list of outgoing particles (i.e.
Definition: G4INCLStore.hh:223
Book & getBook()
Return the pointer to the Book object which keeps track of various counters.
Definition: G4INCLStore.hh:259
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:232
bool G4bool
Definition: G4Types.hh:79
const G4int n
std::pair< PAIter, PAIter > PAIterPair
Definition: G4INCLStore.hh:402
G4int getLoadedZ()
Get the value of the nucleus charge number that we read from file with loadParticles.
Definition: G4INCLStore.hh:317
G4int countCascading()
Definition: G4INCLStore.hh:261
std::multimap< Particle *, IAvatar * >::iterator PAIter
Definition: G4INCLStore.hh:401
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:196
std::multimap< Particle *, IAvatar * > particleAvatarConnections
Map particle -> [avatar].
Definition: G4INCLStore.hh:399
The purpose of the Store object is to act as a "particle manager" that keeps track ofall the particle...
Definition: G4INCLStore.hh:73
double G4double
Definition: G4Types.hh:76
G4int loadedZ
The target nucleus charge number that was loaded from a particle file.
Definition: G4INCLStore.hh:452
std::set< IAvatar * > avatarsToBeRemoved
Set of avatars to be removed.
Definition: G4INCLStore.hh:405
void addToOutgoing(Particle *p)
add the particle to the outgoing particle list.
Definition: G4INCLStore.hh:190
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
ParticleList::const_iterator ParticleIter
void removeFromIncoming(Particle *const p)
Add a particle to the incoming list.
Definition: G4INCLStore.hh:142
void clearIncoming()
Clear the incoming list.
Definition: G4INCLStore.hh:145
ParticleList inside
List of particles that are inside the nucleus.
Definition: G4INCLStore.hh:422