Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/dna/management/src/G4ITTrackHolder.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/electromagnetic/dna/management/src/G4ITTrackHolder.cc (Version 11.3.0) and /processes/electromagnetic/dna/management/src/G4ITTrackHolder.cc (Version 10.1.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /*                                                 26 /*
 27  * G4MIMolecularTracks.cc                          27  * G4MIMolecularTracks.cc
 28  *                                                 28  *
 29  *  Created on: 17 sept. 2014                      29  *  Created on: 17 sept. 2014
 30  *      Author: kara                               30  *      Author: kara
 31  */                                                31  */
 32                                                    32 
 33 #include <G4Scheduler.hh>                          33 #include <G4Scheduler.hh>
 34 #include <G4VScheduler.hh>                         34 #include <G4VScheduler.hh>
 35 #include "G4ITTrackHolder.hh"                      35 #include "G4ITTrackHolder.hh"
 36 #include "G4IT.hh"                                 36 #include "G4IT.hh"
 37 #include "G4Track.hh"                              37 #include "G4Track.hh"
 38 #include "G4UnitsTable.hh"                         38 #include "G4UnitsTable.hh"
 39 #include "G4AutoLock.hh"                           39 #include "G4AutoLock.hh"
 40 #include "G4Threading.hh"                          40 #include "G4Threading.hh"
 41                                                    41 
 42 using namespace std;                               42 using namespace std;
 43                                                    43 
 44 PriorityList::PriorityList() :                     44 PriorityList::PriorityList() :
 45      fpMainList(nullptr), fpWaitingList(nullpt <<  45     G4TrackList::Watcher(), fpMainList(0), fpWaitingList(0)
 46 {                                                  46 {
 47 }                                                  47 }
 48                                                    48 
 49 PriorityList::PriorityList(G4TrackManyList& al << 
 50      fpMainList(nullptr), fpWaitingList(nullpt << 
 51 {                                              << 
 52   NewMainList(allMainList);                    << 
 53 }                                              << 
 54                                                << 
 55 PriorityList::PriorityList(const PriorityList&     49 PriorityList::PriorityList(const PriorityList& right) :
 56                                                <<  50     G4TrackList::Watcher(),
 57     fpMainList(right.fpMainList),                  51     fpMainList(right.fpMainList),
 58     fpWaitingList(right.fpWaitingList)             52     fpWaitingList(right.fpWaitingList)
 59 {                                                  53 {
 60 }                                                  54 }
 61                                                    55 
 62 PriorityList::~PriorityList()                      56 PriorityList::~PriorityList()
 63 {                                                  57 {
 64   if (fpMainList != nullptr)                   <<  58   if (fpMainList)
 65   {                                                59   {
 66     delete fpMainList;                             60     delete fpMainList;
 67     fpMainList = nullptr;                      <<  61     fpMainList = 0;
 68   }                                                62   }
 69   if (fpWaitingList != nullptr)                <<  63   if (fpWaitingList)
 70   {                                                64   {
 71     delete fpWaitingList;                          65     delete fpWaitingList;
 72     fpWaitingList = nullptr;                   <<  66     fpWaitingList = 0;
 73   }                                                67   }
 74 }                                                  68 }
 75                                                    69 
 76 void PriorityList::NotifyDeletingList(G4TrackL     70 void PriorityList::NotifyDeletingList(G4TrackList* __list)
 77 {                                                  71 {
 78   if (__list == fpMainList)                        72   if (__list == fpMainList)
 79   {                                                73   {
 80 //    StopWatching(fpMainList);                <<  74     fpMainList = 0;
 81     fpMainList = nullptr;                      <<  75     StopWatching(fpMainList);
 82   }                                                76   }
 83   else if (__list == fpWaitingList)                77   else if (__list == fpWaitingList)
 84   {                                                78   {
 85 //    StopWatching(fpWaitingList);             <<  79     fpWaitingList = 0;
 86     fpWaitingList = nullptr;                   <<  80     StopWatching(fpWaitingList);
 87   }                                                81   }
 88 }                                                  82 }
 89                                                    83 
 90 void PriorityList::NewMainList(G4TrackList* __     84 void PriorityList::NewMainList(G4TrackList* __list,
 91                                G4TrackManyList     85                                G4TrackManyList& allMainList)
 92 {                                                  86 {
 93   fpMainList = __list;                             87   fpMainList = __list;
 94   allMainList.Add(__list);                         88   allMainList.Add(__list);
 95   Watch(fpMainList);                               89   Watch(fpMainList);
 96 }                                                  90 }
 97                                                    91 
 98 G4TrackList* PriorityList::NewMainList(G4Track     92 G4TrackList* PriorityList::NewMainList(G4TrackManyList& allMainList)
 99 {                                                  93 {
100   auto  trackList = new G4TrackList();         <<  94   G4TrackList* trackList = new G4TrackList();
101   NewMainList(trackList, allMainList);             95   NewMainList(trackList, allMainList);
102   return fpMainList;                               96   return fpMainList;
103 }                                                  97 }
104                                                    98 
105 void PriorityList::PushToMainList(G4Track* __t     99 void PriorityList::PushToMainList(G4Track* __track,
106                                   G4TrackManyL    100                                   G4TrackManyList& allMainList)
107 {                                                 101 {
108   if (fpMainList == nullptr)                   << 102   if (fpMainList == 0)
109   {                                               103   {
110     NewMainList(allMainList);                     104     NewMainList(allMainList);
111   }                                               105   }
112   fpMainList->push_back(__track);                 106   fpMainList->push_back(__track);
113 }                                                 107 }
114                                                   108 
115 void PriorityList::TransferToMainList(G4TrackL    109 void PriorityList::TransferToMainList(G4TrackList*& __list,
116                                       G4TrackM    110                                       G4TrackManyList& allMainList)
117 {                                                 111 {
118   if (fpMainList != nullptr)                   << 112   if (fpMainList)
119   {                                               113   {
120     __list->transferTo(fpMainList);               114     __list->transferTo(fpMainList);
121     delete __list;                                115     delete __list;
122     __list = nullptr;                          << 116     __list = 0;
123   }                                               117   }
124   else                                            118   else
125   {                                               119   {
126     NewMainList(__list, allMainList);             120     NewMainList(__list, allMainList);
127   }                                               121   }
128 }                                                 122 }
129                                                   123 
130 void PriorityList::PushToListOfSecondaries(G4T    124 void PriorityList::PushToListOfSecondaries(G4Track* __track,
131                                            G4T    125                                            G4TrackManyList& listOfAllSecondaries)
132 {                                                 126 {
133   //      if (priorityList->fSecondaries.empty    127   //      if (priorityList->fSecondaries.empty())
134   if (fSecondaries.GetListNode() != nullptr)   << 128   if (fSecondaries.GetListNode())
135   {                                               129   {
136     listOfAllSecondaries.Add(&fSecondaries);      130     listOfAllSecondaries.Add(&fSecondaries);
137   }                                               131   }
138   fSecondaries.push_back(__track);                132   fSecondaries.push_back(__track);
139 }                                                 133 }
140                                                   134 
141 void PriorityList::PushToWaitingList(G4Track*     135 void PriorityList::PushToWaitingList(G4Track* __track)
142 {                                                 136 {
143   if (fpWaitingList == nullptr)                << 137   if (fpWaitingList == 0)
144   {                                               138   {
145     fpWaitingList = new G4TrackList();            139     fpWaitingList = new G4TrackList();
146   }                                               140   }
147   fpWaitingList->push_back(__track);              141   fpWaitingList->push_back(__track);
148 }                                                 142 }
149                                                   143 
150 void PriorityList::TransferSecondariesToMainLi    144 void PriorityList::TransferSecondariesToMainList()
151 {                                                 145 {
152   fSecondaries.transferTo(fpMainList);            146   fSecondaries.transferTo(fpMainList);
153 }                                                 147 }
154                                                   148 
155 void PriorityList::PushToMainList(G4Track* tra    149 void PriorityList::PushToMainList(G4Track* track)
156 {                                                 150 {
157   if (fpMainList == nullptr) fpMainList = new  << 151   if (fpMainList == 0) fpMainList = new G4TrackList();
158   fpMainList->push_back(track);                   152   fpMainList->push_back(track);
159 }                                                 153 }
160                                                   154 
161 void PriorityList::MergeWithMainList(G4TrackLi    155 void PriorityList::MergeWithMainList(G4TrackList* trackList)
162 {                                                 156 {
163   if (fpMainList == nullptr) fpMainList = new  << 157   if (fpMainList == 0) fpMainList = new G4TrackList();
164   trackList->transferTo(trackList);               158   trackList->transferTo(trackList);
165 }                                                 159 }
166                                                   160 
167 int PriorityList::GetNTracks()                    161 int PriorityList::GetNTracks()
168 {                                                 162 {
169   int nTracks = 0;                                163   int nTracks = 0;
170                                                   164 
171   if (fpMainList != nullptr)                   << 165   if (fpMainList)
172   {                                               166   {
173     nTracks += fpMainList->size();                167     nTracks += fpMainList->size();
174   }                                               168   }
175                                                   169 
176   if (fpWaitingList != nullptr)                << 170   if (fpWaitingList)
177   {                                               171   {
178     nTracks += fpWaitingList->size();             172     nTracks += fpWaitingList->size();
179   }                                               173   }
180                                                   174 
181   nTracks += fSecondaries.size();                 175   nTracks += fSecondaries.size();
182                                                   176 
183   return nTracks;                                 177   return nTracks;
184 }                                                 178 }
185                                                   179 
186 //============================================    180 //=============================================================================
187 // G4ITTrackHolder                                181 // G4ITTrackHolder
188 //============================================    182 //=============================================================================
189                                                   183 
190 G4ThreadLocal G4ITTrackHolder* G4ITTrackHolder << 184 G4ThreadLocal G4ITTrackHolder* G4ITTrackHolder::fgInstance(0);
191 G4ITTrackHolder* G4ITTrackHolder::fgMasterInst << 185 G4ITTrackHolder* G4ITTrackHolder::fgMasterInstance(0);
192                                                   186 
193 G4Mutex creationOfTheMasterInstance;              187 G4Mutex creationOfTheMasterInstance;
194 G4Mutex pushToTheMasterInstance;                  188 G4Mutex pushToTheMasterInstance;
195                                                   189 
196 G4ITTrackHolder* G4ITTrackHolder::Instance()      190 G4ITTrackHolder* G4ITTrackHolder::Instance()
197 {                                                 191 {
198   if (fgInstance == nullptr)                   << 192   if (fgInstance == 0)
199   {                                               193   {
200     fgInstance = new G4ITTrackHolder();           194     fgInstance = new G4ITTrackHolder();
201     if(G4Threading::IsMasterThread() ||        << 195     if(G4Threading::IsWorkerThread() == false || 
202        !G4Threading::IsMultithreadedApplicatio << 196        G4Threading::IsMultithreadedApplication() == false 
203     )                                             197     ) 
204     {                                             198     {
205       fgMasterInstance = fgInstance;              199       fgMasterInstance = fgInstance;
206     }                                             200     }
207                                                   201     
208   }                                               202   }
209   return fgInstance;                              203   return fgInstance;
210 }                                                 204 }
211                                                   205 
212 G4ITTrackHolder* G4ITTrackHolder::MasterInstan    206 G4ITTrackHolder* G4ITTrackHolder::MasterInstance()
213 {                                                 207 {
214   G4AutoLock lock(&creationOfTheMasterInstance    208   G4AutoLock lock(&creationOfTheMasterInstance);
215   if (fgMasterInstance == nullptr)             << 209   if (fgMasterInstance == 0)
216   {                                               210   {
217     fgMasterInstance = new G4ITTrackHolder();     211     fgMasterInstance = new G4ITTrackHolder();
218   }                                               212   }
219   lock.unlock();                                  213   lock.unlock();
220   return fgMasterInstance;                        214   return fgMasterInstance;
221 }                                                 215 }
222                                                   216 
223 G4ITTrackHolder::G4ITTrackHolder()             << 217 G4ITTrackHolder::G4ITTrackHolder() :
                                                   >> 218     G4VITTrackHolder()
224 {                                                 219 {
225   fNbTracks = -1;                                 220   fNbTracks = -1;
226   fMainListHaveBeenSet = false;                   221   fMainListHaveBeenSet = false;
227   fVerbose = 0;                                   222   fVerbose = 0;
228                                                   223 
229   fPostActivityGlobalTime = -1;                   224   fPostActivityGlobalTime = -1;
230 //  fPreActivityGlobalTime = -1;                  225 //  fPreActivityGlobalTime = -1;
231 }                                                 226 }
232                                                   227 
233 G4ITTrackHolder::~G4ITTrackHolder()               228 G4ITTrackHolder::~G4ITTrackHolder()
234 {                                                 229 {
235   auto end = fLists.end();                     << 230   std::map<Key, PriorityList*>::iterator end = fLists.end();
236                                                   231 
237   for (auto it = fLists.begin(); it != end;    << 232   for (std::map<Key, PriorityList*>::iterator it = fLists.begin(); it != end;
238       it++)                                       233       it++)
239   {                                               234   {
240     delete it->second;                            235     delete it->second;
241     it->second = 0;                               236     it->second = 0;
242   }                                               237   }
243                                                   238 
244   if (!fDelayedList.empty())                      239   if (!fDelayedList.empty())
245   {                                               240   {
246     auto fDelayedList_i = fDelayedList.begin() << 241     MapOfDelayedLists::iterator fDelayedList_i = fDelayedList.begin();
247     auto fDelayedList_end = fDelayedList.end() << 242     MapOfDelayedLists::iterator fDelayedList_end = fDelayedList.end();
248                                                   243 
249     for (; fDelayedList_i != fDelayedList_end;    244     for (; fDelayedList_i != fDelayedList_end; fDelayedList_i++)
250     {                                             245     {
251       auto it = fDelayedList_i->second.begin() << 246       std::map<Key, G4TrackList*>::iterator it = fDelayedList_i->second.begin();
252       auto __end =                             << 247       std::map<Key, G4TrackList*>::iterator __end =
253           fDelayedList_i->second.end();           248           fDelayedList_i->second.end();
254                                                   249 
255       for (; it != __end; it++)                   250       for (; it != __end; it++)
256       {                                           251       {
257         delete (it->second);                   << 252         if (it->second) delete (it->second);
258         it->second = 0;                           253         it->second = 0;
259       }                                           254       }
260     }                                             255     }
261     fDelayedList.clear();                         256     fDelayedList.clear();
262   }                                               257   }
263                                                   258 
264   fAllMainList.RemoveLists();                     259   fAllMainList.RemoveLists();
265   fAllSecondariesList.RemoveLists();              260   fAllSecondariesList.RemoveLists();
266   fNbTracks = -1;                                 261   fNbTracks = -1;
267 }                                                 262 }
268                                                   263 
269 /*                                                264 /*
270  void G4MIMolecularTracks::Decide()               265  void G4MIMolecularTracks::Decide()
271  {                                                266  {
272  cout << "G4MIMolecularTracks::Decide" << endl    267  cout << "G4MIMolecularTracks::Decide" << endl;
273                                                   268 
274  if (fDelayedList.empty())                        269  if (fDelayedList.empty())
275  {                                                270  {
276  cout << "fDelayedList.empty()" << endl;          271  cout << "fDelayedList.empty()" << endl;
277  return;                                          272  return;
278  }                                                273  }
279  fPostActivityGlobalTime = GetNextTime();         274  fPostActivityGlobalTime = GetNextTime();
280  //  PushActivity(workspace->GetScheduler(), t    275  //  PushActivity(workspace->GetScheduler(), this);
281  }                                                276  }
282  */                                               277  */
283                                                   278 
284 /*                                                279 /*
285  * param time = time of the merged list           280  * param time = time of the merged list
286  * returned = was there actually merged data ?    281  * returned = was there actually merged data ?
287  */                                               282  */
288 bool G4ITTrackHolder::MergeNextTimeToMainList(    283 bool G4ITTrackHolder::MergeNextTimeToMainList(double& time)
289 {                                                 284 {
290 //  G4cout << "G4ITTrackHolder::MergeNextTimeT    285 //  G4cout << "G4ITTrackHolder::MergeNextTimeToMainList" << G4endl;
291   if (fDelayedList.empty())                       286   if (fDelayedList.empty())
292   {                                               287   {
293     return false;                                 288     return false;
294   }                                               289   }
295                                                   290 
296 //  G4cout << "fDelayedList.size = " << fDelay    291 //  G4cout << "fDelayedList.size = " << fDelayedList.size() <<G4endl;
297                                                   292 
298   auto it =                                    << 293   std::map<Key, G4TrackList*>::iterator it =
299       fDelayedList.begin()->second.begin();       294       fDelayedList.begin()->second.begin();
300   auto end =                                   << 295   std::map<Key, G4TrackList*>::iterator end =
301       fDelayedList.begin()->second.end();         296       fDelayedList.begin()->second.end();
302   if (it == end) return false;                    297   if (it == end) return false;
303                                                   298 
304   bool output = false;                            299   bool output = false;
305   for (; it != end; it++)                         300   for (; it != end; it++)
306   {                                               301   {
307     PriorityList* right_listUnion(nullptr);    << 302     PriorityList* right_listUnion(0);
308                                                   303 
309     auto it_listUnion = fLists.find(           << 304     std::map<Key, PriorityList*>::iterator it_listUnion = fLists.find(
310         it->first);                               305         it->first);
311     if (it_listUnion == fLists.end())             306     if (it_listUnion == fLists.end())
312     {                                             307     {
313       right_listUnion = (fLists[it->first] = n    308       right_listUnion = (fLists[it->first] = new PriorityList());
314     }                                             309     }
315     else                                          310     else
316     {                                             311     {
317       if (it_listUnion->second == 0)              312       if (it_listUnion->second == 0)
318       {                                           313       {
319         it_listUnion->second = new PriorityLis    314         it_listUnion->second = new PriorityList();
320       }                                           315       }
321       right_listUnion = it_listUnion->second;     316       right_listUnion = it_listUnion->second;
322     }                                             317     }
323                                                   318 
324     if (it->second == 0) continue;                319     if (it->second == 0) continue;
325                                                   320 
326     /*                                            321     /*
327      if (right_listUnion->GetMainList() == 0)     322      if (right_listUnion->GetMainList() == 0)
328      {                                            323      {
329      //      right_listUnion->fpMainList = new    324      //      right_listUnion->fpMainList = new G4TrackList();
330      //      if(it->second)                       325      //      if(it->second)
331      //      {                                    326      //      {
332      right_listUnion->NewMainList(it->second,     327      right_listUnion->NewMainList(it->second, fAllMainList);
333      //      }                                    328      //      }
334      }                                            329      }
335      else                                         330      else
336      {                                            331      {
337      right_listUnion->TransferToMainList(it->s    332      right_listUnion->TransferToMainList(it->second);
338      delete it->second;                           333      delete it->second;
339      }*/                                          334      }*/
340                                                   335 
341     right_listUnion->TransferToMainList(it->se    336     right_listUnion->TransferToMainList(it->second, fAllMainList);
342                                                   337 
343     if (!output)                               << 338     if (output == false)
344     {                                             339     {
345       if (static_cast<int>(!right_listUnion->G << 340       if (right_listUnion->GetMainList()->size())
346       {                                           341       {
347         output = true;                            342         output = true;
348       }                                           343       }
349     }                                             344     }
350     it->second = 0;                               345     it->second = 0;
351   }                                               346   }
352                                                   347 
353   if (output) time = fDelayedList.begin()->fir    348   if (output) time = fDelayedList.begin()->first;
354   fDelayedList.erase(fDelayedList.begin());       349   fDelayedList.erase(fDelayedList.begin());
355   return output;                                  350   return output;
356 }                                                 351 }
357                                                   352 
358 void G4ITTrackHolder::MergeSecondariesWithMain    353 void G4ITTrackHolder::MergeSecondariesWithMainList()
359 {                                                 354 {
360   auto it = fLists.begin();                    << 355   std::map<Key, PriorityList*>::iterator it = fLists.begin();
361   auto end = fLists.end();                     << 356   std::map<Key, PriorityList*>::iterator end = fLists.end();
362                                                   357 
363   for (; it != end; it++)                         358   for (; it != end; it++)
364   {                                               359   {
365     if (it->second->GetMainList() == nullptr)  << 360     if (it->second->GetMainList() == 0)
366     {                                             361     {
367       it->second->NewMainList(fAllMainList);      362       it->second->NewMainList(fAllMainList);
368     }                                             363     }
369                                                   364 
370     it->second->TransferSecondariesToMainList(    365     it->second->TransferSecondariesToMainList();
371   }                                               366   }
372 }                                                 367 }
373                                                   368 
374 //____________________________________________    369 //_________________________________________________________________________
375                                                   370 
376 void G4ITTrackHolder::AddTrackID(G4Track* trac    371 void G4ITTrackHolder::AddTrackID(G4Track* track)
377 {                                                 372 {
378   //if(fNbTracks == 0) fNbTracks = -1;            373   //if(fNbTracks == 0) fNbTracks = -1;
379   track->SetTrackID(fNbTracks);                   374   track->SetTrackID(fNbTracks);
380   fNbTracks--;                                    375   fNbTracks--;
381 }                                                 376 }
382                                                   377 
383 //____________________________________________    378 //_________________________________________________________________________
384                                                   379 
385 void G4ITTrackHolder::Push(G4Track* track)        380 void G4ITTrackHolder::Push(G4Track* track)
386 {                                                 381 {
387 //  if (G4VScheduler::Instance()->IsRunning()) << 382   if (G4VScheduler::Instance()->IsRunning())
388 //  {                                          << 383   {
389 //    G4ExceptionDescription exceptionDescript << 384     G4ExceptionDescription exceptionDescription;
390 //    exceptionDescription                     << 385     exceptionDescription
391 //        << "G4ITTrackHolder::PushTrack : You << 386         << "G4ITTrackHolder::PushTrack : You are trying to push tracks while the "
392 //        "ITStepManager is running";          << 387         "ITStepManager is running";
393 //    G4Exception("G4ITTrackHolder::PushTrack" << 388     G4Exception("G4ITTrackHolder::PushTrack", "ITStepManager012",
394 //                FatalErrorInArgument, except << 389                 FatalErrorInArgument, exceptionDescription);
395 //  }                                          << 390   }
396   _PushTrack(track);                              391   _PushTrack(track);
397                                                   392 
398 //  G4MIConstituent::NotifyEntityAdded(track);    393 //  G4MIConstituent::NotifyEntityAdded(track);
399 }                                                 394 }
400 //____________________________________________    395 //_________________________________________________________________________
401 void G4ITTrackHolder::PushTo(G4Track* track, P    396 void G4ITTrackHolder::PushTo(G4Track* track, PriorityList::Type type)
402 {                                                 397 {
403   int moleculeID = GetIT(track)->GetITSubType(    398   int moleculeID = GetIT(track)->GetITSubType();
404   auto it = fLists.find(moleculeID);           << 399   std::map<Key, PriorityList*>::iterator it = fLists.find(moleculeID);
405                                                   400 
406   PriorityList* priorityList(nullptr);         << 401   PriorityList* priorityList(0);
407                                                   402 
408   if (it == fLists.end())                         403   if (it == fLists.end())
409   {                                               404   {
410     priorityList = new PriorityList(fAllMainLi << 405     priorityList = new PriorityList();
411     fLists[moleculeID] = priorityList;            406     fLists[moleculeID] = priorityList;
412   }                                               407   }
413   else                                            408   else
414   {                                               409   {
415     priorityList = it->second;                    410     priorityList = it->second;
416   }                                               411   }
417                                                   412 
418   switch (type)                                   413   switch (type)
419   {                                               414   {
420     case PriorityList::MainList:                  415     case PriorityList::MainList:
421     {                                             416     {
422       priorityList->PushToMainList(track, fAll    417       priorityList->PushToMainList(track, fAllMainList);
423       break;                                      418       break;
424     }                                             419     }
425     case PriorityList::SecondariesList:           420     case PriorityList::SecondariesList:
426     {                                             421     {
427       priorityList->PushToListOfSecondaries(tr    422       priorityList->PushToListOfSecondaries(track, fAllSecondariesList);
428       break;                                      423       break;
429     }                                             424     }
430     case PriorityList::WaitingList:               425     case PriorityList::WaitingList:
431     {                                             426     {
432       priorityList->PushToWaitingList(track);     427       priorityList->PushToWaitingList(track);
433       return;                                     428       return;
434       break;                                      429       break;
435     }                                             430     }
436                                                   431 
437     default:                                      432     default:
438     {                                             433     {
439       return;                                     434       return;
440       break;                                      435       break;
441     }                                             436     }
442   }                                               437   }
443 }                                                 438 }
444 //____________________________________________    439 //_________________________________________________________________________
445                                                   440 
446 void G4ITTrackHolder::_PushTrack(G4Track* trac    441 void G4ITTrackHolder::_PushTrack(G4Track* track)
447 {                                                 442 {
448   if (track == nullptr)                        << 443   if (track == 0)
449   {                                               444   {
450     G4ExceptionDescription exceptionDescriptio    445     G4ExceptionDescription exceptionDescription;
451     exceptionDescription                          446     exceptionDescription
452         << "You are trying to push a non-exist    447         << "You are trying to push a non-existing track (track pointer is null)"
453         << G4endl;                                448         << G4endl;
454                                                   449 
455     G4Exception("G4ITTrackHolder::_PushTrack",    450     G4Exception("G4ITTrackHolder::_PushTrack", "ITStepManager014",
456                 FatalErrorInArgument, exceptio    451                 FatalErrorInArgument, exceptionDescription);
457   }                                               452   }
458                                                   453 
459   G4double globalTime = track->GetGlobalTime()    454   G4double globalTime = track->GetGlobalTime();
460                                                   455 
461   if (track->GetTrackID() == 0)                   456   if (track->GetTrackID() == 0)
462   {                                               457   {
463     // Set track ID                               458     // Set track ID
464     AddTrackID(track);                            459     AddTrackID(track);
465   }                                               460   }
466                                                   461 
467   double currentGlobalTime = G4Scheduler::Inst    462   double currentGlobalTime = G4Scheduler::Instance()->GetGlobalTime();
468                                                   463 
469 #ifdef G4VERBOSE                                  464 #ifdef G4VERBOSE
470   if (fVerbose != 0)                           << 465   if (fVerbose > 5)
471   {                                               466   {
472     G4cout << G4endl;                             467     G4cout << G4endl;
473     G4cout << "\t"<< ">> Pushing a track -->      468     G4cout << "\t"<< ">> Pushing a track -->  ";
474     G4cout << GetIT(track)->GetName() << " ("     469     G4cout << GetIT(track)->GetName() << " (" << track->GetTrackID() <<")"
475     << " -- ";                                    470     << " -- ";
476     G4cout << "Global current time: " << G4Bes    471     G4cout << "Global current time: " << G4BestUnit(currentGlobalTime,"Time")
477     << "\t";                                      472     << "\t";
478     G4cout << "Track's time: " << G4BestUnit(t    473     G4cout << "Track's time: " << G4BestUnit(track->GetGlobalTime(),"Time")
479     << G4endl;                                    474     << G4endl;
480   }                                               475   }
481 #endif                                            476 #endif
482                                                   477 
483   if (!G4Scheduler::Instance()->IsRunning())   << 478   if (G4Scheduler::Instance()->IsRunning() == false)
484   {                                               479   {
485     if (globalTime < currentGlobalTime)           480     if (globalTime < currentGlobalTime)
486     {                                             481     {
487       G4ExceptionDescription exceptionDescript    482       G4ExceptionDescription exceptionDescription;
488       exceptionDescription                        483       exceptionDescription
489           << "You are trying to push a track w    484           << "You are trying to push a track with a global time"
490           << " inferior to the current simulat    485           << " inferior to the current simulation time." << G4endl<< "The time is going back : " << G4endl
491       << "The time in the step manager : "        486       << "The time in the step manager : "
492       << G4BestUnit(currentGlobalTime,"Time")     487       << G4BestUnit(currentGlobalTime,"Time")
493       << G4endl                                   488       << G4endl
494       << "The time of the track : "               489       << "The time of the track : "
495       << G4BestUnit(globalTime,"Time")            490       << G4BestUnit(globalTime,"Time")
496       << G4endl                                   491       << G4endl
497       << "(ITStepManager is not yet running)"     492       << "(ITStepManager is not yet running)"
498       << G4endl;                                  493       << G4endl;
499                                                   494 
500       G4Exception("G4ITTrackHolder::_PushTrack    495       G4Exception("G4ITTrackHolder::_PushTrack", "ITStepManager014",
501                   FatalErrorInArgument, except    496                   FatalErrorInArgument, exceptionDescription);
502     }                                             497     }
503                                                   498 
504     // Push the track to the rigth track list     499     // Push the track to the rigth track list :
505     // If the track time is the same as the ma    500     // If the track time is the same as the main track list,
506     // it will be push to the main track list     501     // it will be push to the main track list
507     // otherwise, it will be pushed to the del    502     // otherwise, it will be pushed to the delayed track list.
508     if (!fMainListHaveBeenSet)                 << 503     if (fMainListHaveBeenSet == false)
509     {                                             504     {
510       PushDelayed(track);                         505       PushDelayed(track);
511     }                                             506     }
512     else                                          507     else
513     {                                             508     {
514       if (globalTime == currentGlobalTime)        509       if (globalTime == currentGlobalTime)
515       {                                           510       {
516         #ifdef G4VERBOSE                       << 
517           if (fVerbose != 0)                   << 
518           {                                    << 
519             G4cout << G4endl;                  << 
520             G4cout << "\t"<< ">> Pushing to *m << 
521             G4cout << GetIT(track)->GetName()  << 
522             << " -- ";                         << 
523             G4cout << "Global current time: "  << 
524             << "\t";                           << 
525             G4cout << "Track's time: " << G4Be << 
526             << G4endl;                         << 
527           }                                    << 
528         #endif                                 << 
529         PushTo(track, PriorityList::MainList);    511         PushTo(track, PriorityList::MainList);
530       }                                           512       }
531       else                                        513       else
532       {                                           514       {
533         // if(currentGlobalTime > 1*CLHEP::pic << 
534         #ifdef G4VERBOSE                       << 
535           if (fVerbose != 0)                   << 
536           {                                    << 
537             G4cout << G4endl;                  << 
538             G4cout << "\t"<< ">> Pushing to *d << 
539             G4cout << GetIT(track)->GetName()  << 
540             << " -- ";                         << 
541             G4cout << "Global current time: "  << 
542             << "\t";                           << 
543             G4cout << "Track's time: " << G4Be << 
544             << G4endl;                         << 
545           }                                    << 
546         #endif                                 << 
547         PushDelayed(track);                       515         PushDelayed(track);
548       }                                           516       }
549     }                                             517     }
550   }                                               518   }
551   else // Is running                              519   else // Is running
552   {                                               520   {
553     double timeDifference = globalTime - curre    521     double timeDifference = globalTime - currentGlobalTime;
554     double timeTolerance = G4Scheduler::Instan    522     double timeTolerance = G4Scheduler::Instance()->GetTimeTolerance();
555                                                   523 
556     if (timeDifference < -1 * timeTolerance)      524     if (timeDifference < -1 * timeTolerance)
557     {                                             525     {
558       G4ExceptionDescription exceptionDescript    526       G4ExceptionDescription exceptionDescription;
559       exceptionDescription                        527       exceptionDescription
560           << "You are trying to push a track w    528           << "You are trying to push a track with a global time"
561           << " inferior to the current simulat    529           << " inferior to the current simulation time." << G4endl<< "The time is going back : "
562       << G4endl                                   530       << G4endl
563       << "The time in the step manager : "        531       << "The time in the step manager : "
564       << G4BestUnit(timeDifference,"Time")        532       << G4BestUnit(timeDifference,"Time")
565       << G4endl                                   533       << G4endl
566       << "The time of the track : " << G4BestU    534       << "The time of the track : " << G4BestUnit(globalTime,"Time")
567       << G4endl                                   535       << G4endl
568       << "(ITStepManager is running)"             536       << "(ITStepManager is running)"
569       << G4endl;                                  537       << G4endl;
570                                                   538 
571       G4Exception("G4ITTrackHolder::_PushTrack    539       G4Exception("G4ITTrackHolder::_PushTrack", "ITStepManager015",
572                   FatalErrorInArgument, except    540                   FatalErrorInArgument, exceptionDescription);
573     }                                             541     }
574                                                   542 
575     // Push the track to the rigth track list     543     // Push the track to the rigth track list :
576     // If the track time is the same as the ma    544     // If the track time is the same as the main track list,
577     // it will be push to the secondary list      545     // it will be push to the secondary list
578     // otherwise, it will be pushed to the del    546     // otherwise, it will be pushed to the delayed track list.
579     if (fabs(timeDifference) < timeTolerance)     547     if (fabs(timeDifference) < timeTolerance)
580     {                                             548     {
581 //      G4cout << "Is pushing " << GetIT(track    549 //      G4cout << "Is pushing " << GetIT(track)->GetName() << G4endl;
582                                                   550 
583       #ifdef G4VERBOSE                         << 
584         if (fVerbose != 0)                     << 
585         {                                      << 
586           G4cout << G4endl;                    << 
587           G4cout << "\t"<< ">> Pushing to *sec << 
588           G4cout << GetIT(track)->GetName() << << 
589           << " -- ";                           << 
590           G4cout << "Global current time: " << << 
591           << "\t";                             << 
592           G4cout << "Track's time: " << G4Best << 
593           << G4endl;                           << 
594         }                                      << 
595       #endif                                   << 
596       PushTo(track, PriorityList::SecondariesL    551       PushTo(track, PriorityList::SecondariesList);
597     }                                             552     }
598     else // globalTime < fGlobalTime already t    553     else // globalTime < fGlobalTime already taken into account above
599     {                                             554     {
600       G4ExceptionDescription exceptionDescript    555       G4ExceptionDescription exceptionDescription;
601       exceptionDescription                        556       exceptionDescription
602           << "While running you cannot push a     557           << "While running you cannot push a track"
603           << " with a bigger global time than     558           << " with a bigger global time than the current global time" << G4endl<< "The time in the step manager : "
604       << G4BestUnit(currentGlobalTime,"Time")     559       << G4BestUnit(currentGlobalTime,"Time")
605       << G4endl                                   560       << G4endl
606       << "The time of the track : " << G4BestU    561       << "The time of the track : " << G4BestUnit(globalTime,"Time")
607       << G4endl                                   562       << G4endl
608       << "(ITStepManager is running)"             563       << "(ITStepManager is running)"
609       << G4endl;                                  564       << G4endl;
610                                                   565 
611       G4Exception("G4ITTrackHolder::_PushTrack    566       G4Exception("G4ITTrackHolder::_PushTrack", "ITStepManager016",
612                   FatalErrorInArgument, except    567                   FatalErrorInArgument, exceptionDescription);
613       // PushDelayed(track, globalTime);          568       // PushDelayed(track, globalTime);
614     }                                             569     }
615   }                                               570   }
616 }                                                 571 }
617                                                   572 
618 //____________________________________________    573 //_________________________________________________________________________
619                                                   574 
620 void G4ITTrackHolder::PushDelayed(G4Track* tra    575 void G4ITTrackHolder::PushDelayed(G4Track* track)
621 {                                                 576 {
622 #ifdef G4VERBOSE                                  577 #ifdef G4VERBOSE
623   if (fVerbose != 0)                           << 578   if (fVerbose > 5)
624   {                                               579   {
625     G4cout << "\t" << ">> Pushing a delayed tr    580     G4cout << "\t" << ">> Pushing a delayed track" << G4endl;
626   }                                               581   }
627 #endif                                            582 #endif
628                                                   583 
629   int moleculeID = GetIT(track)->GetITSubType(    584   int moleculeID = GetIT(track)->GetITSubType();
630   //  std::map<int, PriorityList>::iterator it    585   //  std::map<int, PriorityList>::iterator it = fLists.find(moleculeID);
631                                                   586 
632   G4double globalTime = track->GetGlobalTime()    587   G4double globalTime = track->GetGlobalTime();
633                                                   588 
634   auto it_delayed =                            << 589   std::map<double, std::map<Key, G4TrackList*> >::iterator it_delayed =
635   fDelayedList.find(globalTime);                  590   fDelayedList.find(globalTime);
636                                                   591 
637   if (it_delayed == fDelayedList.end())           592   if (it_delayed == fDelayedList.end())
638   {                                               593   {
639     (fDelayedList[globalTime][moleculeID] = ne    594     (fDelayedList[globalTime][moleculeID] = new G4TrackList())->push_back(
640         track);                                   595         track);
641   }                                               596   }
642   else                                            597   else
643   {                                               598   {
644     auto it_trackList =                        << 599     std::map<Key, G4TrackList*>::iterator it_trackList =
645     it_delayed->second.find(moleculeID);          600     it_delayed->second.find(moleculeID);
646                                                   601 
647     if (it_trackList == it_delayed->second.end    602     if (it_trackList == it_delayed->second.end())
648     {                                             603     {
649       (it_delayed->second[moleculeID] = new G4    604       (it_delayed->second[moleculeID] = new G4TrackList())->push_back(track);
650     }                                             605     }
651     else                                          606     else
652     {                                             607     {
653       if (it_trackList->second != 0)              608       if (it_trackList->second != 0)
654       {                                           609       {
655         it_trackList->second->push_back(track)    610         it_trackList->second->push_back(track);
656       }                                           611       }
657     }                                             612     }
658   }                                               613   }
659                                                   614 
660   //  fDelayedList[globalTime][moleculeID]        615   //  fDelayedList[globalTime][moleculeID]
661                                                   616 
662   /*                                              617   /*
663    std::map<double,std::map<int, G4TrackList*     618    std::map<double,std::map<int, G4TrackList* > >::iterator it_delayed =
664    fDelayedList.begin();                          619    fDelayedList.begin();
665                                                   620 
666    std::map<double,std::map<int, G4TrackList*     621    std::map<double,std::map<int, G4TrackList* > >::iterator end_delayed =
667    fDelayedList.end();                            622    fDelayedList.end();
668                                                   623 
669    for(it_delayed != end_delayed ; it_delayed+    624    for(it_delayed != end_delayed ; it_delayed++)
670    {                                              625    {
671    std::map<int, G4TrackList*> & trackListMap     626    std::map<int, G4TrackList*> & trackListMap = it->second;
672                                                   627 
673                                                   628 
674    }                                              629    }
675    */                                             630    */
676   /*                                              631   /*
677    std::map<double,G4TrackList* > :: iterator     632    std::map<double,G4TrackList* > :: iterator
678    fDelayedList_i = fDelayedList.find(globalTi    633    fDelayedList_i = fDelayedList.find(globalTime) ;
679                                                   634 
680    if(fDelayedList_i == fDelayedList.end())       635    if(fDelayedList_i == fDelayedList.end())
681    {                                              636    {
682                                                   637 
683    G4TrackList* newList = new G4TrackList ;       638    G4TrackList* newList = new G4TrackList ;
684    newList -> push_back(track);                   639    newList -> push_back(track);
685    fDelayedList[globalTime] = newList ;           640    fDelayedList[globalTime] = newList ;
686    }                                              641    }
687    else                                           642    else
688    {                                              643    {
689    fDelayedList_i->second-> push_back(track);     644    fDelayedList_i->second-> push_back(track);
690    }                                              645    }
691    */                                             646    */
692 }                                                 647 }
693 //____________________________________________    648 //______________________________________________________________________________
694                                                   649 
695 void G4ITTrackHolder::KillTracks()                650 void G4ITTrackHolder::KillTracks()
696 {                                                 651 {
697   if (fToBeKilledList.empty()) return;         << 652   if (fToBeKilledList.size() == 0) return;
698 #ifdef G4VERBOSE                                  653 #ifdef G4VERBOSE
699   if (fVerbose > 1)                            << 654   if (fVerbose > 5)
700   {                                               655   {
701     G4cout << "*** G4ITTrackHolder::KillTracks    656     G4cout << "*** G4ITTrackHolder::KillTracks , step #"
702            << G4VScheduler::Instance()->GetNbS << 657 //           << G4MIWorldEngine::Instance()->GetScheduler()->GetNbSteps()
703            << " ***" << G4endl;                << 658     << G4VScheduler::Instance()->GetNbSteps() << " ***" << G4endl;
704     G4cout << "Nb of tracks to kill "<< fToBeK    659     G4cout << "Nb of tracks to kill "<< fToBeKilledList.size() << G4endl;
705     G4cout << setw(25) << left << "#Name"         660     G4cout << setw(25) << left << "#Name"
706            << setw(25) << "track ID"<< G4endl; << 661     << setw(25) << "track ID"<< G4endl;
707                                                   662 
708     G4TrackList::iterator it = fToBeKilledList    663     G4TrackList::iterator it = fToBeKilledList.begin();
709     for(; it != fToBeKilledList.end();)           664     for(; it != fToBeKilledList.end();)
710     {                                             665     {
711       G4Track* toBeErased = *it;                  666       G4Track* toBeErased = *it;
712                                                   667 
713       G4cout << setw(25) << GetIT(toBeErased)-    668       G4cout << setw(25) << GetIT(toBeErased)->GetName()
714       << setw(25) << toBeErased->GetTrackID()     669       << setw(25) << toBeErased->GetTrackID()
715       << G4endl;                                  670       << G4endl;
716                                                   671 
717       it = fToBeKilledList.erase(toBeErased);     672       it = fToBeKilledList.erase(toBeErased);
718     }                                             673     }
719   }                                               674   }
720   else                                            675   else
721 #endif                                            676 #endif
722   fToBeKilledList.erase(fToBeKilledList.begin(    677   fToBeKilledList.erase(fToBeKilledList.begin(), fToBeKilledList.end());
723 }                                                 678 }
724                                                   679 
725 void G4ITTrackHolder::Clear()                     680 void G4ITTrackHolder::Clear()
726 {                                                 681 {
727   fAllMainList.ClearLists();                      682   fAllMainList.ClearLists();
728   fAllSecondariesList.ClearLists();               683   fAllSecondariesList.ClearLists();
729 //  fAllMainList.RemoveLists();                   684 //  fAllMainList.RemoveLists();
730 //  fAllSecondariesList.RemoveLists();            685 //  fAllSecondariesList.RemoveLists();
731                                                   686 
732   auto it = fLists.begin();                    << 687   std::map<Key, PriorityList*>::iterator it = fLists.begin();
733                                                   688 
734   for (; it != fLists.end(); it++)                689   for (; it != fLists.end(); it++)
735   {                                               690   {
736     delete it->second;                         << 691     if (it->second) delete it->second;
737     it->second = 0;                               692     it->second = 0;
738   }                                               693   }
739   fLists.clear();                                 694   fLists.clear();
740                                                   695 
741   auto it1 = fDelayedList.begin();             << 696   MapOfDelayedLists::iterator it1 = fDelayedList.begin();
742                                                   697 
743   for (; it1 != fDelayedList.end(); it1++)        698   for (; it1 != fDelayedList.end(); it1++)
744   {                                               699   {
745     auto it2 = it1->second.begin();            << 700     std::map<Key, G4TrackList*>::iterator it2 = it1->second.begin();
746                                                   701 
747     for (; it2 != it1->second.end(); it2++)       702     for (; it2 != it1->second.end(); it2++)
748     {                                             703     {
749       delete it2->second;                      << 704       if (it2->second) delete it2->second;
750       it2->second = 0;                            705       it2->second = 0;
751     }                                             706     }
752   }                                               707   }
753                                                   708 
754   fDelayedList.clear();                           709   fDelayedList.clear();
755                                                   710 
756 //  fAllMainList.ClearLists();                    711 //  fAllMainList.ClearLists();
757 //  fAllSecondariesList.ClearLists();             712 //  fAllSecondariesList.ClearLists();
758   fAllMainList.RemoveLists();                     713   fAllMainList.RemoveLists();
759   fAllSecondariesList.RemoveLists();              714   fAllSecondariesList.RemoveLists();
760   KillTracks();                                   715   KillTracks();
761                                                   716 
762   fNbTracks = -1;                                 717   fNbTracks = -1;
763 }                                                 718 }
764                                                   719 
765 PriorityList* G4ITTrackHolder::GetPriorityList    720 PriorityList* G4ITTrackHolder::GetPriorityList(Key i)
766 {                                                 721 {
767   auto it = fLists.find(i);                    << 722   std::map<Key, PriorityList*>::iterator it = fLists.find(i);
768   if (it == fLists.end()) return nullptr;      << 723   if (it == fLists.end()) return 0;
769   return it->second;                              724   return it->second;
770 }                                                 725 }
771                                                   726 
772 G4TrackList* G4ITTrackHolder::GetMainList(G4in    727 G4TrackList* G4ITTrackHolder::GetMainList(G4int i)
773 {                                                 728 {
774   PriorityList* priorityList = GetPriorityList    729   PriorityList* priorityList = GetPriorityList(i);
775   if (priorityList != nullptr)                 << 730   if (priorityList)
776   {                                               731   {
777     return priorityList->GetMainList();           732     return priorityList->GetMainList();
778   }                                               733   }
779   return nullptr;                              << 734   return 0;
780 }                                                 735 }
781                                                   736 
782 bool G4ITTrackHolder::AddWatcher(Key id,          737 bool G4ITTrackHolder::AddWatcher(Key id,
783                                  G4TrackList::    738                                  G4TrackList::Watcher* watcher,
784                                  PriorityList:    739                                  PriorityList::Type type)
785 {                                                 740 {
786   auto it = fLists.find(id);                   << 741   std::map<Key, PriorityList*>::iterator it = fLists.find(id);
787   if (it == fLists.end()) return false;           742   if (it == fLists.end()) return false;
788                                                   743 
789   G4TrackList* trackList = it->second->Get(typ    744   G4TrackList* trackList = it->second->Get(type);
790   if (trackList == nullptr) return false;      << 745   if (trackList == 0) return false;
791   trackList->AddWatcher(watcher);                 746   trackList->AddWatcher(watcher);
792   return true;                                    747   return true;
793 }                                                 748 }
794                                                   749 
795 void G4ITTrackHolder::AddWatcherForMainList(G4 << 
796 {                                              << 
797   fAllMainList.AddGlobalWatcher(watcher);      << 
798 }                                              << 
799                                                << 
800 void G4ITTrackHolder::AddWatcherForKillList(G4 << 
801 {                                              << 
802   watcher->Watch(&fToBeKilledList);            << 
803 }                                              << 
804                                                << 
805 void G4ITTrackHolder::PushToMaster(G4Track* tr    750 void G4ITTrackHolder::PushToMaster(G4Track* track)
806 {                                                 751 {
807   G4ITTrackHolder* trackHolder = MasterInstanc    752   G4ITTrackHolder* trackHolder = MasterInstance();
808                                                   753 
809   G4AutoLock lock(&pushToTheMasterInstance);      754   G4AutoLock lock(&pushToTheMasterInstance);
810   trackHolder->PushDelayed(track);                755   trackHolder->PushDelayed(track);
811   lock.unlock();                                  756   lock.unlock();
812 }                                                 757 }
813                                                   758 
814 size_t G4ITTrackHolder::GetNTracks()              759 size_t G4ITTrackHolder::GetNTracks()
815 {                                                 760 {
816   size_t nTracks(0);                              761   size_t nTracks(0);
817   nTracks += fAllMainList.size();                 762   nTracks += fAllMainList.size();
818   nTracks += fAllSecondariesList.size();          763   nTracks += fAllSecondariesList.size();
819                                                   764 
820   //    G4cout << "nTracks = " << nTracks << G    765   //    G4cout << "nTracks = " << nTracks << G4endl;
821                                                   766 
822   auto delayedmap_it = fDelayedList.begin();   << 767   MapOfDelayedLists::iterator delayedmap_it = fDelayedList.begin();
823   auto delayedmap_end = fDelayedList.end();    << 768   MapOfDelayedLists::iterator delayedmap_end = fDelayedList.end();
824                                                   769 
825   for (; delayedmap_it != delayedmap_end; dela    770   for (; delayedmap_it != delayedmap_end; delayedmap_it++)
826   {                                               771   {
827     auto it = delayedmap_it->second.begin();   << 772     std::map<Key, G4TrackList*>::iterator it = delayedmap_it->second.begin();
828     auto end = delayedmap_it->second.end();    << 773     std::map<Key, G4TrackList*>::iterator end = delayedmap_it->second.end();
829                                                   774 
830     for (; it != end; it++)                       775     for (; it != end; it++)
831     {                                             776     {
832       if (it->second != nullptr) nTracks += it << 777       if (it->second) nTracks += it->second->size();
833     }                                             778     }
834   }                                               779   }
835                                                   780 
836   //    G4cout << "nTracks = " << nTracks << G    781   //    G4cout << "nTracks = " << nTracks << G4endl;
837                                                   782 
838   return nTracks;                                 783   return nTracks;
839 }                                                 784 }
840                                                   785 
841 void G4ITTrackHolder::MoveMainToWaitingList()     786 void G4ITTrackHolder::MoveMainToWaitingList()
842 {                                                 787 {
843   auto it = fLists.begin();                    << 788   MapOfPriorityLists::iterator it = fLists.begin();
844   auto end = fLists.end();                     << 789   MapOfPriorityLists::iterator end = fLists.end();
845   for (; it != end; it++)                         790   for (; it != end; it++)
846   {                                               791   {
847     if (PriorityList* lists = it->second)         792     if (PriorityList* lists = it->second)
848     {                                             793     {
849       lists->SetWaitingList(lists->GetMainList    794       lists->SetWaitingList(lists->GetMainList());
850       //TODO                                      795       //TODO
851     }                                             796     }
852   }                                               797   }
853   fAllMainList.RemoveLists();                     798   fAllMainList.RemoveLists();
854 }                                                 799 }
855                                                   800 
856 bool G4ITTrackHolder::DelayListsNOTEmpty()        801 bool G4ITTrackHolder::DelayListsNOTEmpty()
857 {                                                 802 {
858   auto __it = fDelayedList.begin();            << 803   MapOfDelayedLists::iterator __it = fDelayedList.begin();
859   auto __end = fDelayedList.end();             << 804   MapOfDelayedLists::iterator __end = fDelayedList.end();
860   for (; __it != __end; __it++)                   805   for (; __it != __end; __it++)
861   {                                               806   {
862     std::map<Key, G4TrackList*>& mapOfLists =     807     std::map<Key, G4TrackList*>& mapOfLists = __it->second;
863     if (!mapOfLists.empty())                   << 808     if (mapOfLists.empty() == false)
864     {                                             809     {
865       auto it = mapOfLists.begin();            << 810       std::map<Key, G4TrackList*>::iterator it = mapOfLists.begin();
866       auto end = mapOfLists.end();             << 811       std::map<Key, G4TrackList*>::iterator end = mapOfLists.end();
867       for (; it != end; it++)                     812       for (; it != end; it++)
868       {                                           813       {
869         if (G4TrackList* mainList = it->second    814         if (G4TrackList* mainList = it->second)
870         {                                         815         {
871           if (!(mainList->empty())) return tru    816           if (!(mainList->empty())) return true;
872         }                                         817         }
873       }                                           818       }
874     }                                             819     }
875   }                                               820   }
876   return false;                                   821   return false;
877 }                                                 822 }
878                                                   823 
879 bool G4ITTrackHolder::CheckMapIsNOTEmpty(MapOf    824 bool G4ITTrackHolder::CheckMapIsNOTEmpty(MapOfPriorityLists& mapOfLists,
880                                          Prior    825                                          PriorityList::Type type)
881 {                                                 826 {
882   auto it = mapOfLists.begin();                << 827   MapOfPriorityLists::iterator it = mapOfLists.begin();
883   auto end = mapOfLists.end();                 << 828   MapOfPriorityLists::iterator end = mapOfLists.end();
884   for (; it != end; it++)                         829   for (; it != end; it++)
885   {                                               830   {
886     if (PriorityList* lists = it->second)         831     if (PriorityList* lists = it->second)
887     {                                             832     {
888       if (G4TrackList* trackList = lists->Get(    833       if (G4TrackList* trackList = lists->Get(type))
889       {                                           834       {
890         if (!(trackList->empty())) return true    835         if (!(trackList->empty())) return true;
891       }                                           836       }
892     }                                             837     }
893   }                                               838   }
894   return false;                                   839   return false;
895 }                                                 840 }
896                                                   841