Geant4  10.01.p01
G4ITTrackHolder.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 /*
27  * G4ITTrackHolder.hh
28  *
29  * Created on: 17 sept. 2014
30  * Author: kara
31  */
32 
33 #ifndef G4ITTRACKHOLDER_HH
34 #define G4ITTRACKHOLDER_HH
35 
36 #include "G4IT.hh"
37 #include "G4TrackList.hh"
38 #include "G4VITTrackHolder.hh"
39 #include <iostream>
40 
41 class PriorityList : public G4TrackList::Watcher
42 {
43 public:
44  enum Type
45  {
46  MainList = 0,
49  Undefined = -1
50  };
51 
52  PriorityList();
54  virtual ~PriorityList();
55 
56  virtual void NotifyDeletingList(G4TrackList* __list);
57 
58  void NewMainList(G4TrackList* __list, G4TrackManyList& allMainList);
59 
61 
62  void PushToMainList(G4Track* __track, G4TrackManyList& allMainList);
63 
64  void TransferToMainList(G4TrackList*& __list, G4TrackManyList& allMainList);
65 
66  void PushToListOfSecondaries(G4Track* __track,
67  G4TrackManyList& listOfAllSecondaries);
68 
69  void PushToWaitingList(G4Track* __track);
70 
72 
73  void PushToMainList(G4Track* track);
74 
75  void MergeWithMainList(G4TrackList* trackList);
76 
78  {
79  return fpMainList;
80  }
81 
83  {
84  return &fSecondaries;
85  }
86 
87  inline void SetWaitingList(G4TrackList* __list)
88  {
89  fpWaitingList = __list;
90  }
91 
92  inline G4TrackList* Get(Type type)
93  {
94  switch (type)
95  {
96  case MainList:
97  return fpMainList;
98  break;
99  case SecondariesList:
100  return &fSecondaries;
101  break;
102  case WaitingList:
103  return fpWaitingList;
104  break;
105  case Undefined:
106  return 0;
107  }
108  return 0;
109  }
110 
111  int GetNTracks();
112 
113 private:
116  // to merge with fpMainList
118  // Waiting queue of currentList
119 };
120 
122 {
123  /* UR:
124  * Push on time
125  * Push delayed
126  * Exception when going back
127  * Get all tracks
128  */
129 
132  friend class G4Scheduler;
133 
134 public:
135  //----- typedefs -----
136  typedef int Key; //TODO
137  typedef std::map<Key, PriorityList*> MapOfPriorityLists;
138  typedef std::map<double, std::map<Key, G4TrackList*> > MapOfDelayedLists;
139 
140  //----- Access singletons + constructors/destructors-----
141 
142  static G4ITTrackHolder* Instance();
144 
145  G4ITTrackHolder();
146  virtual
148 
149  //----- Time of the next set of tracks -----
150  inline double GetNextTime()
151  {
152  if (fDelayedList.empty()) return DBL_MAX;
153  return fDelayedList.begin()->first;
154  }
155 
156  //----- Add new tracks to the list -----
157  virtual void Push(G4Track*);
158  static void PushToMaster(G4Track*);
159 
160  //----- Operations between lists -----
161 
162  inline void PushToKill(G4Track* track)
163  {
164  fToBeKilledList.push_back(track);
165  }
166 
167  bool MergeNextTimeToMainList(double& time);
169  void MoveMainToWaitingList();
170 
171  // ----- To call at the end of the step -----
172  void KillTracks();
173  void Clear();
174 
175  // ----- Add a watcher to a specific track list -----
176  // comment: to stop watching, just call StopWatching from your watcher class
177  bool AddWatcher(int,
178  G4TrackList::Watcher*,
180 
181  // ----- Access track lists -----
182  inline MapOfPriorityLists& GetLists()
183  { return fLists;}
185  G4TrackList* GetMainList(Key);
187  {
188  return &fAllMainList;
189  }
190 
192  {
193  return &fAllSecondariesList;
194  }
195 
196  inline MapOfDelayedLists& GetDelayedLists()
197  {
198  return fDelayedList;
199  }
200 
201  virtual size_t GetNTracks();
202 
203  // ----- Check track lists are NOT empty -----
204  // comment: checking NOT empty faster than checking IS empty
205  inline bool MainListsNOTEmpty()
206  {
208  }
209 
211  {
213  }
214 
215  bool DelayListsNOTEmpty();
216 
217  bool CheckMapIsNOTEmpty(MapOfPriorityLists& mapOfLists,
218  PriorityList::Type type);
219 
220  inline void SetVerbose(int verbose)
221  {
222  fVerbose = verbose;
223  }
224 
225 protected:
226  void AddTrackID(G4Track* track);
227  void _PushTrack(G4Track* track);
229  void PushDelayed(G4Track* track);
230 
231 protected:
232  std::map<Key, PriorityList*> fLists;
233  MapOfDelayedLists fDelayedList;
236  int fVerbose;
238 
240  // double fPreActivityGlobalTime ;
241 
244 };
245 
246 #endif /* G4MIMOLECULARTRACKS_HH_ */
G4TrackList * Get(Type type)
G4TrackList fToBeKilledList
G4TrackManyList * GetMainList()
virtual void Push(G4Track *)
void MergeSecondariesWithMainList()
bool CheckMapIsNOTEmpty(MapOfPriorityLists &mapOfLists, PriorityList::Type type)
G4TrackManyList * GetSecondariesList()
void AddTrackID(G4Track *track)
std::map< Key, PriorityList * > fLists
double fPostActivityGlobalTime
std::map< double, std::map< Key, G4TrackList * > > MapOfDelayedLists
G4TrackList * fpWaitingList
void PushDelayed(G4Track *track)
G4ITTrackHolder is an empty interface that permits to push tracks to the IT system without actually d...
void MoveMainToWaitingList()
virtual void NotifyDeletingList(G4TrackList *__list)
G4TrackList * GetSecondariesList()
static G4ITTrackHolder * fgMasterInstance
G4TrackList * GetMainList()
void SetVerbose(int verbose)
#define G4ThreadLocal
Definition: tls.hh:89
void PushToMainList(G4Track *__track, G4TrackManyList &allMainList)
MapOfPriorityLists & GetLists()
void PushToWaitingList(G4Track *__track)
void MergeWithMainList(G4TrackList *trackList)
void _PushTrack(G4Track *track)
virtual ~PriorityList()
static G4ThreadLocal G4ITTrackHolder * fgInstance
G4ITStepManager enables to synchronize in time the step of tracks.
Definition: G4Scheduler.hh:75
void PushTo(G4Track *, PriorityList::Type)
G4TrackList fSecondaries
bool MergeNextTimeToMainList(double &time)
void SetWaitingList(G4TrackList *__list)
bool SecondaryListsNOTEmpty()
void PushToKill(G4Track *track)
G4TrackManyList fAllMainList
virtual size_t GetNTracks()
void TransferToMainList(G4TrackList *&__list, G4TrackManyList &allMainList)
static G4ITTrackHolder * MasterInstance()
void push_back(OBJECT *__track)
PriorityList * GetPriorityList(Key)
MapOfDelayedLists fDelayedList
std::map< Key, PriorityList * > MapOfPriorityLists
static void PushToMaster(G4Track *)
void PushToListOfSecondaries(G4Track *__track, G4TrackManyList &listOfAllSecondaries)
static G4ITTrackHolder * Instance()
virtual ~G4ITTrackHolder()
G4TrackList * fpMainList
MapOfDelayedLists & GetDelayedLists()
void NewMainList(G4TrackList *__list, G4TrackManyList &allMainList)
void TransferSecondariesToMainList()
G4TrackManyList fAllSecondariesList
#define DBL_MAX
Definition: templates.hh:83
bool AddWatcher(int, G4TrackList::Watcher *, PriorityList::Type=PriorityList::MainList)