Geant4_10
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 
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 
308  G4double getLoadedStoppingTime() { return loadedStoppingTime; };
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 
412  IAvatarList avatarList;
413 
417  ParticleList incoming;
418 
422  ParticleList inside;
423 
427  ParticleList outgoing;
428 
432  ParticleList geomSpectators;
433 
437  G4double currentTime;
438 
442  Book theBook;
443 
447  G4int loadedA;
448 
452  G4int loadedZ;
453 
457  G4double loadedStoppingTime;
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()
Definition: G4INCLStore.cc:360
void writeParticles(std::string filename)
Definition: G4INCLStore.cc:411
void clearAvatars()
Definition: G4INCLStore.cc:252
static G4bool avatarComparisonPredicate(IAvatar *lhs, IAvatar *rhs)
Comparison predicate for avatars.
Definition: G4INCLStore.hh:337
std::string printAvatars()
Definition: G4INCLStore.cc:417
ParticleList const & getParticles() const
Definition: G4INCLStore.hh:231
G4int getLoadedA()
Definition: G4INCLStore.hh:296
tuple a
Definition: test.py:11
const char * p
Definition: xmltok.h:285
G4bool containsCollisions() const
Definition: G4INCLStore.cc:425
IAvatar * findSmallestTime()
Definition: G4INCLStore.cc:173
Config const * getConfig()
Definition: G4INCLStore.hh:251
void add(Particle *p)
Definition: G4INCLStore.cc:57
void remove(const T &t)
void deleteIncoming()
Clear the incoming list and delete the particles.
Definition: G4INCLStore.hh:132
ParticleList const & getIncomingParticles() const
Definition: G4INCLStore.hh:195
Store(Config const *const config)
Definition: G4INCLStore.cc:44
int G4int
Definition: G4Types.hh:78
IAvatarList const & getAvatars() const
Definition: G4INCLStore.hh:108
void addParticleEntryAvatars(IAvatarList const &al)
Add one ParticleEntry avatar.
Definition: G4INCLStore.cc:78
G4double getTime() const
G4double getLoadedStoppingTime()
Definition: G4INCLStore.hh:308
Char_t n[5]
tuple pl
Definition: readPY.py:5
ParticleList const & getOutgoingParticles() const
Definition: G4INCLStore.hh:201
Book & getBook()
Definition: G4INCLStore.hh:237
ParticleList extractDynamicalSpectators()
Returns a list of dynamical spectators.
Definition: G4INCLStore.hh:210
void particleHasBeenDestroyed(Particle *const)
Definition: G4INCLStore.cc:240
void initialiseParticleAvatarConnections()
Initialise the particleAvatarConnections map.
Definition: G4INCLStore.cc:267
bool G4bool
Definition: G4Types.hh:79
void particleHasBeenEjected(Particle *const)
Definition: G4INCLStore.cc:231
void clearInside()
Definition: G4INCLStore.cc:290
G4int getLoadedZ()
Definition: G4INCLStore.hh:302
void clearOutgoing()
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)
Definition: G4INCLStore.cc:144
void loadParticles(std::string filename)
Definition: G4INCLStore.cc:313
void addToOutgoing(ParticleList const &pl)
Add a list of particles to the outgoing particle list.
Definition: G4INCLStore.hh:174
void addIncomingParticle(Particle *const p)
Definition: G4INCLStore.cc:100
double G4double
Definition: G4Types.hh:76
void addToOutgoing(Particle *p)
add the particle to the outgoing particle list.
Definition: G4INCLStore.hh:168
void timeStep(G4double step)
Definition: G4INCLStore.cc:224
ParticleList::const_iterator ParticleIter
void removeFromIncoming(Particle *const p)
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