Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <vector>
43 #include <string>
44 #include <algorithm>
45 
46 #include "G4INCLParticle.hh"
47 #include "G4INCLIAvatar.hh"
48 #include "G4INCLBook.hh"
49 #include "G4INCLConfig.hh"
50 
51 #ifdef INCLXX_IN_GEANT4_MODE
52 #define INCL_AVATAR_SEARCH_MinElement 1
53 #endif // INCLXX_IN_GEANT4_MODE
54 
55 namespace G4INCL {
56 
62  class Store {
63  public:
67  Store(Config const * const config);
68 
72  ~Store();
73 
82  void add(Particle *p);
83 
86 
88  void addParticleEntryAvatars(IAvatarList const &al);
89 
104  void add(IAvatar *a);
105 
109  IAvatarList const &getAvatars() const {
110  return avatarList;
111  }
112 
118  void addIncomingParticle(Particle * const p);
119 
125  void removeFromIncoming(Particle * const p) { incoming.remove(p); }
126 
128  inline void clearIncoming() {
129  incoming.clear();
130  }
131 
133  inline void deleteIncoming() {
134  for(ParticleIter iter = incoming.begin(); iter != incoming.end(); ++iter) {
135  delete (*iter);
136  }
137  clearIncoming();
138  }
139 
145  void particleHasBeenUpdated(long);
146 
151 
156  void timeStep(G4double step);
157 
163  void particleHasBeenEjected(long);
164 
169  void addToOutgoing(Particle *p) { outgoing.push_back(p); }
170 
176  for(ParticleIter p=pl.begin(); p!=pl.end(); ++p)
177  addToOutgoing(*p);
178  }
179 
184  void particleHasBeenDestroyed(long);
185 
190  void particleHasEntered(Particle * const particle);
191 
196  ParticleList const & getIncomingParticles() const { return incoming; }
197 
202  ParticleList const & getOutgoingParticles() const { return outgoing; }
203 
212  ParticleList spectators;
213  std::list<std::list<Particle*>::iterator> toBeErased;
214  for(std::list<Particle*>::iterator p=outgoing.begin(); p!=outgoing.end(); ++p) {
215  if((*p)->isProjectileSpectator()) {
216 // assert((*p)->isNucleon());
217  spectators.push_back(*p); // add them to the list we will return
218  toBeErased.push_back(p); // we will remove them from outgoing later
219  }
220  }
221 
222  // Now erase them from outgoing
223  for(std::list<std::list<Particle*>::iterator>::iterator i=toBeErased.begin();
224  i!=toBeErased.end(); ++i) {
225  outgoing.erase(*i);
226  }
227 
228  return spectators;
229  }
230 
235  ParticleList const & getParticles() const { return inside; }
236 
241  Book* getBook() {return theBook; };
242 
244  G4int n=0;
245  for(ParticleIter i=inside.begin(); i!=inside.end(); ++i) {
246  if(!(*i)->isTargetSpectator())
247  ++n;
248  }
249  return n;
250  }
251 
255  Config const * getConfig() { return theConfig; };
256 
263 
270 
276  void clear();
277 
283  void clearOutgoing();
284 
288  void clearAvatars();
289 
296 
301  void loadParticles(std::string filename);
302 
307  G4int getLoadedA() { return loadedA; };
308 
313  G4int getLoadedZ() { return loadedZ; };
314 
319  G4double getLoadedStoppingTime() { return loadedStoppingTime; };
320 
324  std::string printParticleConfiguration();
325 
329  void writeParticles(std::string filename);
330 
334  std::string printAvatars();
335 
336  G4bool containsCollisions() const;
337 
338 #if defined(INCL_AVATAR_SEARCH_FullSort) || defined(INCL_AVATAR_SEARCH_MinElement)
339 
349  return (lhs->getTime() < rhs->getTime());
350  }
351 #elif defined(INCL_AVATAR_SEARCH_INCLSort)
352 
365  std::list<IAvatarIter>::iterator binaryIterSearch(IAvatar const * const avatar);
366 #endif
367 
368  private:
370  Store(const Store &rhs);
371 
373  Store &operator=(Store const &rhs);
374 
378  void removeAvatarsFromParticle(long ID);
379 
383  G4bool avatarInConnectionMap(long);
384 
385 
389  void connectParticleAndAvatar(long particleID, long avatarID);
390 
394  void removeAvatarFromParticle(long particleID, long avatarID);
395  void removeAvatarByID(long ID);
396 
397  private:
401  std::map<long, Particle*> particles;
402 
406  std::map<long, IAvatar*> avatars;
407 
411  std::map<long, std::vector<long>* > particleAvatarConnections;
412 
416  IAvatarList avatarList;
417 
421  ParticleList incoming;
422 
426  ParticleList inside;
427 
431  ParticleList outgoing;
432 
436  ParticleList geomSpectators;
437 
441  G4double currentTime;
442 
446  Book *theBook;
447 
451  G4int loadedA;
452 
456  G4int loadedZ;
457 
461  G4double loadedStoppingTime;
462 
466  Config const * theConfig;
467 
468 #ifdef INCL_AVATAR_SEARCH_INCLSort
469 
474  std::list<IAvatarIter> avatarIterList;
475 #endif
476 
477  };
478 }
479 #endif