G4INCLStore.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // INCL++ intra-nuclear cascade model
00027 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
00028 // Davide Mancusi, CEA
00029 // Alain Boudard, CEA
00030 // Sylvie Leray, CEA
00031 // Joseph Cugnon, University of Liege
00032 //
00033 #define INCLXX_IN_GEANT4_MODE 1
00034 
00035 #include "globals.hh"
00036 
00037 #ifndef G4INCLParticleStore_hh
00038 #define G4INCLParticleStore_hh 1
00039 
00040 #include <map>
00041 #include <list>
00042 #include <vector>
00043 #include <string>
00044 #include <algorithm>
00045 
00046 #include "G4INCLParticle.hh"
00047 #include "G4INCLIAvatar.hh"
00048 #include "G4INCLBook.hh"
00049 #include "G4INCLConfig.hh"
00050 
00051 #ifdef INCLXX_IN_GEANT4_MODE
00052 #define INCL_AVATAR_SEARCH_MinElement 1
00053 #endif // INCLXX_IN_GEANT4_MODE
00054 
00055 namespace G4INCL {
00056 
00062   class Store {
00063   public:
00067     Store(Config const * const config);
00068 
00072     ~Store();
00073 
00082     void add(Particle *p);
00083 
00085     void addParticleEntryAvatar(IAvatar *a);
00086 
00088     void addParticleEntryAvatars(IAvatarList const &al);
00089 
00104     void add(IAvatar *a);
00105 
00109     IAvatarList const &getAvatars() const {
00110       return avatarList;
00111     }
00112 
00118     void addIncomingParticle(Particle * const p);
00119 
00125     void removeFromIncoming(Particle * const p) { incoming.remove(p); }
00126 
00128     inline void clearIncoming() {
00129       incoming.clear();
00130     }
00131 
00133     inline void deleteIncoming() {
00134       for(ParticleIter iter = incoming.begin(); iter != incoming.end(); ++iter) {
00135         delete (*iter);
00136       }
00137       clearIncoming();
00138     }
00139 
00145     void particleHasBeenUpdated(long);
00146 
00150     IAvatar* findSmallestTime();
00151 
00156     void timeStep(G4double step);
00157     
00163     void particleHasBeenEjected(long);
00164 
00169     void addToOutgoing(Particle *p) { outgoing.push_back(p); }
00170 
00175     void addToOutgoing(ParticleList const &pl) {
00176       for(ParticleIter p=pl.begin(); p!=pl.end(); ++p)
00177         addToOutgoing(*p);
00178     }
00179 
00184     void particleHasBeenDestroyed(long);
00185 
00190     void particleHasEntered(Particle * const particle);
00191 
00196     ParticleList const & getIncomingParticles() const { return incoming; }
00197 
00202     ParticleList const & getOutgoingParticles() const { return outgoing; }
00203 
00211     ParticleList extractDynamicalSpectators() {
00212       ParticleList spectators;
00213       std::list<std::list<Particle*>::iterator> toBeErased;
00214       for(std::list<Particle*>::iterator p=outgoing.begin(); p!=outgoing.end(); ++p) {
00215         if((*p)->isProjectileSpectator()) {
00216 // assert((*p)->isNucleon());
00217           spectators.push_back(*p); // add them to the list we will return
00218           toBeErased.push_back(p); // we will remove them from outgoing later
00219         }
00220       }
00221 
00222       // Now erase them from outgoing
00223       for(std::list<std::list<Particle*>::iterator>::iterator i=toBeErased.begin();
00224           i!=toBeErased.end(); ++i) {
00225         outgoing.erase(*i);
00226       }
00227 
00228       return spectators;
00229     }
00230 
00235     ParticleList const & getParticles() const { return inside; }
00236 
00241     Book* getBook() {return theBook; };
00242 
00243     G4int countCascading() {
00244       G4int n=0;
00245       for(ParticleIter i=inside.begin(); i!=inside.end(); ++i) {
00246         if(!(*i)->isTargetSpectator())
00247           ++n;
00248       }
00249       return n;
00250     }
00251 
00255     Config const * getConfig() { return theConfig; };
00256 
00262     ParticleList getParticipants();
00263 
00269     ParticleList getSpectators();
00270 
00276     void clear();
00277 
00283     void clearOutgoing();
00284 
00288     void clearAvatars();
00289 
00295     void initialiseParticleAvatarConnections();
00296 
00301     void loadParticles(std::string filename);
00302 
00307     G4int getLoadedA() { return loadedA; };
00308 
00313     G4int getLoadedZ() { return loadedZ; };
00314 
00319     G4double getLoadedStoppingTime() { return loadedStoppingTime; };
00320 
00324     std::string printParticleConfiguration();
00325 
00329     void writeParticles(std::string filename);
00330 
00334     std::string printAvatars();
00335 
00336     G4bool containsCollisions() const;
00337 
00338 #if defined(INCL_AVATAR_SEARCH_FullSort) || defined(INCL_AVATAR_SEARCH_MinElement)
00339 
00348     static G4bool avatarComparisonPredicate(IAvatar *lhs, IAvatar *rhs) {
00349       return (lhs->getTime() < rhs->getTime());
00350     }
00351 #elif defined(INCL_AVATAR_SEARCH_INCLSort)
00352 
00365     std::list<IAvatarIter>::iterator binaryIterSearch(IAvatar const * const avatar);
00366 #endif
00367 
00368   private:
00370     Store(const Store &rhs);
00371 
00373     Store &operator=(Store const &rhs);
00374 
00378     void removeAvatarsFromParticle(long ID);
00379 
00383     G4bool avatarInConnectionMap(long);
00384 
00385 
00389     void connectParticleAndAvatar(long particleID, long avatarID);
00390 
00394     void removeAvatarFromParticle(long particleID, long avatarID);
00395     void removeAvatarByID(long ID);
00396 
00397   private:
00401     std::map<long, Particle*> particles;
00402 
00406     std::map<long, IAvatar*> avatars;
00407 
00411     std::map<long, std::vector<long>* > particleAvatarConnections;
00412 
00416     IAvatarList avatarList;
00417 
00421     ParticleList incoming;
00422 
00426     ParticleList inside;
00427 
00431     ParticleList outgoing;
00432 
00436     ParticleList geomSpectators;
00437 
00441     G4double currentTime;
00442 
00446     Book *theBook;
00447 
00451     G4int loadedA;
00452 
00456     G4int loadedZ;
00457 
00461     G4double loadedStoppingTime;
00462 
00466     Config const * theConfig;
00467 
00468 #ifdef INCL_AVATAR_SEARCH_INCLSort
00469 
00474     std::list<IAvatarIter> avatarIterList;
00475 #endif
00476 
00477   };
00478 }
00479 #endif

Generated on Mon May 27 17:48:37 2013 for Geant4 by  doxygen 1.4.7