33 #define INCLXX_IN_GEANT4_MODE 1
47 loadedStoppingTime(0.),
71 for(
ParticleIter i=pList.begin(), e=pList.end(); i!=e; ++i) {
88 for(
ParticleIter i=pList.begin(), e=pList.end(); i!=e; ++i) {
108 iter->second->push_back(a);
111 avatars->push_back(a);
123 for(
ParticleIter particleIter = particlesRelatedToAvatar.begin(), e = particlesRelatedToAvatar.end();
124 particleIter != e; ++particleIter) {
128 #ifdef INCL_AVATAR_SEARCH_INCLSort
130 std::list<IAvatarIter>::iterator it=binaryIterSearch(avatar);
131 if(it != avatarIterList.end())
132 avatarIterList.erase(it);
151 #ifdef INCL_AVATAR_SEARCH_INCLSort
152 std::list<IAvatarIter>::iterator Store::binaryIterSearch(
IAvatar const *
const avatar) {
153 std::list<IAvatarIter>::iterator it;
154 std::iterator_traits<std::list<IAvatarIter>::iterator>::difference_type count, step;
155 std::list<IAvatarIter>::iterator first = avatarIterList.begin();
156 std::list<IAvatarIter>::iterator last = avatarIterList.end();
158 count = distance(first,last);
161 it = first; step=count/2; advance(it,step);
162 if ((**it)->getTime()>avatarTime)
163 { first=++it; count-=step+1; }
166 if(first!=last && (**first)->getID()==avatar->
getID())
176 #ifdef INCL_AVATAR_SEARCH_FullSort
185 #elif defined(INCL_AVATAR_SEARCH_INCLSort)
195 if(avatarIterList.empty())
198 best = avatarIterList.back();
199 G4double bestTime = (*best)->getTime();
203 if((*a)->getTime() < bestTime) {
205 bestTime = (*best)->getTime();
206 avatarIterList.push_back(best);
210 #elif defined(INCL_AVATAR_SEARCH_MinElement)
217 #error Unrecognized INCL_AVATAR_SEARCH. Allowed values are: FullSort, INCLSort, MinElement.
226 particleIter != particleEnd; ++particleIter) {
227 (*particleIter)->propagate(step);
236 delete mapItem->second;
280 INCL_WARN(
"Incoming list is not empty when Store::clear() is called" << std::endl);
284 #ifdef INCL_AVATAR_SEARCH_INCLSort
285 avatarIterList.clear();
299 if((*iter)->isCluster()) {
302 #ifdef INCLXX_IN_GEANT4_MODE
315 G4int projectileA, projectileZ,
A, Z;
317 G4int ID, type, isParticipant;
321 std::ifstream in(filename.c_str());
322 in >> projectileA >> projectileZ >> A >> Z >> stoppingTime >> cutNN;
330 in >> ID >> type >> isParticipant >> x >> y >> z >> px >> py >> pz >> E >> v;
331 if(!in.good())
break;
338 else if(type == -1) {
343 INCL_FATAL(
"Unrecognized particle type while loading particles; type=" << type << std::endl);
350 if(isParticipant == 1) {
361 std::stringstream ss;
364 if((*i)->getType() ==
Proton) {
368 if((*i)->getType() ==
Neutron) {
374 ss <<
"0 0 " << A <<
" " << Z <<
" "
376 <<
"0.0" << std::endl;
379 G4int ID = (*i)->getID();
381 if((*i)->getType() ==
Proton) {
384 if((*i)->getType() ==
Neutron) {
388 G4int isParticipant = 0;
389 if((*i)->isParticipant()) {
393 G4double x = (*i)->getPosition().getX();
394 G4double y = (*i)->getPosition().getY();
397 G4double px = (*i)->getMomentum().getX();
398 G4double py = (*i)->getMomentum().getY();
399 G4double pz = (*i)->getMomentum().getZ();
400 G4double V = (*i)->getPotentialEnergy();
402 ss << ID <<
" " << type <<
" " << isParticipant <<
" "
403 << x <<
" " << y <<
" " << z <<
" "
404 << px <<
" " << py <<
" " << pz <<
" "
405 << E <<
" " << V << std::endl;
412 std::ofstream out(filename.c_str());
418 std::stringstream ss;
420 ss << (*i)->toString() << std::endl;
std::string printParticleConfiguration()
Print the nucleon configuration of the nucleus.
void writeParticles(std::string filename)
Print the nucleon configuration of the nucleus.
void clearAvatars()
Clear avatars only.
The INCL configuration object.
static G4bool avatarComparisonPredicate(IAvatar *lhs, IAvatar *rhs)
Comparison predicate for avatars.
void disconnectAvatarFromParticle(IAvatar *const a, Particle *const p)
Disconnect an avatar from a particle.
std::string printAvatars()
Print the list of avatars.
void removeAndDeleteAvatar(IAvatar *const a)
Remove an avatar from the list of avatars.
G4bool containsCollisions() const
UnorderedVector< IAvatar * >::const_iterator IAvatarIter
IAvatar * findSmallestTime()
Find the avatar that has the smallest time.
void add(Particle *p)
Add one particle to the store.
ParticleList outgoing
List of outgoing particles.
G4int loadedA
The target nucleus mass number that was loaded from a particle file.
Store(Config const *const config)
Store constructor.
Cluster is a particle (inherits from the Particle class) that is actually a collection of elementary ...
void connectAvatarToParticle(IAvatar *const a, Particle *const p)
Connect an avatar to a particle.
void removeAvatar(IAvatar *const a)
Remove an avatar from the list of avatars.
IAvatarList avatarList
List of all avatars.
void clear()
Clear all avatars and particles from the store.
void addParticleEntryAvatars(IAvatarList const &al)
Add one ParticleEntry avatar.
G4double loadedStoppingTime
The stopping time that was loaded from a particle file.
void particleHasBeenDestroyed(Particle *const)
Remove the particle from the system.
void initialiseParticleAvatarConnections()
Initialise the particleAvatarConnections map.
void particleHasBeenEjected(Particle *const)
Mark the particle as ejected.
virtual ParticleList getParticles() const =0
void setPotentialEnergy(G4double v)
Set the particle potential energy.
UnorderedVector< IAvatar * > IAvatarList
void clearInside()
Clear all inside particles from the store.
static const G4double A[nN]
void clearOutgoing()
Clear all outgoing particles from the store.
void incrementCascading()
void addParticleEntryAvatar(IAvatar *a)
Add one ParticleEntry avatar.
void particleHasBeenUpdated(Particle *const)
Notify the Store that a particle has been updated.
void loadParticles(std::string filename)
Load particle configuration from ASCII file (see avatarPredictionTest).
ParticleList incoming
List of incoming particles.
void addIncomingParticle(Particle *const p)
Add a particle to the incoming list.
std::map< Particle *, IAvatarList * > particleAvatarConnections
Map particle -> [avatar].
virtual void makeParticipant()
~Store()
Store destructor.
G4int loadedZ
The target nucleus charge number that was loaded from a particle file.
Book theBook
The Book object keeps track of global counters.
void timeStep(G4double step)
Make one time step: propagate particles and subtract the length of the step from the avatar times...
ParticleList::const_iterator ParticleIter
void removeFromIncoming(Particle *const p)
Add a particle to the incoming list.
void particleHasEntered(Particle *const particle)
Move a particle from incoming to inside.
ParticleList inside
List of particles that are inside the nucleus.