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] [ 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/G4ITModelProcessor.cc (Version 11.3.0) and /processes/electromagnetic/dna/management/src/G4ITModelProcessor.cc (Version 11.0.p3,)


** Warning: Cannot open xref database.

  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 // Author: Mathieu Karamitros (kara (AT) cenbg    
 28 //                                                
 29 // History:                                       
 30 // -----------                                    
 31 // 10 Oct 2011 M.Karamitros created               
 32 //                                                
 33 // -------------------------------------------    
 34                                                   
 35 #include "G4ITModelProcessor.hh"                  
 36 #include "G4VITTimeStepComputer.hh"               
 37 #include "G4VITReactionProcess.hh"                
 38 #include "G4ITReaction.hh"                        
 39 #include "G4ITTrackHolder.hh"                     
 40 #include "G4ITTrackingManager.hh"                 
 41 #include "G4VITStepModel.hh"                      
 42 #include "G4UserTimeStepAction.hh"                
 43 #include "G4UnitsTable.hh"                        
 44 #include "G4Scheduler.hh"                         
 45 #include "G4SystemOfUnits.hh"                     
 46 #include <vector>                                 
 47                                                   
 48 //#define DEBUG_MEM                               
 49                                                   
 50 #ifdef DEBUG_MEM                                  
 51 #include "G4MemStat.hh"                           
 52 using namespace G4MemStat;                        
 53 #endif                                            
 54                                                   
 55 G4ITModelProcessor::G4ITModelProcessor()          
 56 {                                                 
 57     fpTrack = nullptr;                            
 58     fInitialized = false;                         
 59     fUserMinTimeStep = -1.;                       
 60     fTSTimeStep = DBL_MAX;                        
 61     fpTrackingManager = nullptr;                  
 62     fReactionSet = nullptr;                       
 63     fpTrackContainer = nullptr;                   
 64     fpModelHandler = nullptr;                     
 65     fpActiveModelWithMinTimeStep = nullptr;       
 66     fComputeTimeStep = false;                     
 67     fComputeReaction = false;                     
 68 }                                                 
 69                                                   
 70 G4ITModelProcessor::~G4ITModelProcessor() = de    
 71                                                   
 72 void G4ITModelProcessor::RegisterModel(double     
 73 {                                                 
 74     fpModelHandler->RegisterModel(model, time)    
 75 }                                                 
 76                                                   
 77 void G4ITModelProcessor::Initialize()             
 78 {                                                 
 79     fpModelHandler->Initialize();                 
 80     fReactionSet = G4ITReactionSet::Instance()    
 81     fpTrackContainer = G4ITTrackHolder::Instan    
 82     fInitialized = true;                          
 83     fComputeTimeStep = false;                     
 84     fComputeReaction = false;                     
 85     if (fpModelHandler->GetTimeStepComputerFla    
 86     {                                             
 87         fComputeTimeStep = true;                  
 88     }                                             
 89     if (fpModelHandler->GetReactionProcessFlag    
 90     {                                             
 91         fComputeReaction = true;                  
 92     }                                             
 93 }                                                 
 94                                                   
 95 G4double G4ITModelProcessor::CalculateMinTimeS    
 96                                                   
 97 {                                                 
 98                                                   
 99 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_    
100     MemStat mem_first, mem_second, mem_diff;      
101     mem_first = MemoryUsage();                    
102 #endif                                            
103                                                   
104     fpActiveModelWithMinTimeStep = nullptr;       
105     fTSTimeStep = DBL_MAX;                        
106                                                   
107     InitializeStepper(currentGlobalTime, defin    
108                                                   
109 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_    
110     mem_second = MemoryUsage();                   
111     mem_diff = mem_second-mem_first;              
112     G4cout << "\t || MEM || G4Scheduler::Calcu    
113     "computing fpModelProcessor -> InitializeS    
114     << mem_diff                                   
115     << G4endl;                                    
116 #endif                                            
117                                                   
118     for (auto& pStepModel : fActiveModels)        
119     {                                             
120         fTSTimeStep =                             
121             pStepModel->GetTimeStepper()->Calc    
122                 currentGlobalTime,                
123                 definedMinTimeStep);              
124                                                   
125         fpActiveModelWithMinTimeStep = pStepMo    
126                                                   
127         if(fTSTimeStep == -1){                    
128             fpActiveModelWithMinTimeStep->GetR    
129             if(fReactionSet->Empty()) return D    
130             const auto& fReactionSetInTime = f    
131             fTSTimeStep = fReactionSetInTime.b    
132         }                                         
133     }                                             
134                                                   
135 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_    
136     mem_second = MemoryUsage();                   
137     mem_diff = mem_second-mem_first;              
138     G4cout << "\t || MEM || G4Scheduler::Calcu    
139     "After looping on tracks, diff is : " << m    
140 #endif                                            
141     return fTSTimeStep;                           
142 }                                                 
143                                                   
144 //____________________________________________    
145                                                   
146 void G4ITModelProcessor::InitializeStepper(G4d    
147                                            G4d    
148 {                                                 
149     G4VITTimeStepComputer::SetTimes(currentGlo    
150                                                   
151 #if defined (DEBUG_MEM)                           
152     MemStat mem_first, mem_second, mem_diff;      
153             mem_first = MemoryUsage();            
154 #endif                                            
155                                                   
156     fActiveModels = fpModelHandler->GetActiveM    
157                                                   
158     for (auto& pModel : fActiveModels)            
159     {                                             
160         pModel->PrepareNewTimeStep();             
161     }                                             
162                                                   
163 #if defined (DEBUG_MEM)                           
164     mem_second = MemoryUsage();                   
165             mem_diff = mem_second-mem_first;      
166             G4cout << "\t || MEM || G4ITModelP    
167 #endif                                            
168                                                   
169 }                                                 
170                                                   
171 //____________________________________________    
172                                                   
173 void G4ITModelProcessor::ComputeTrackReaction(    
174                                                   
175                                                   
176                                                   
177                                                   
178                                                   
179                                                   
180                                                   
181 #ifdef G4VERBOSE                                  
182 fVerbose                                          
183 #endif                                            
184 )                                                 
185 {                                                 
186     if (fReactionSet->Empty())                    
187     {                                             
188         return;                                   
189     }                                             
190                                                   
191     if (fITStepStatus == eCollisionBetweenTrac    
192     {                                             
193         G4VITReactionProcess* pReactionProcess    
194         fReactionInfo = pReactionProcess->Find    
195                 currentTimeStep,                  
196                 fGlobalTime,                      
197                 reachedUserTimeLimit);            
198                                                   
199         // TODO                                   
200         // A ne faire uniquement si le temps c    
201         // Sinon utiliser quelque chose comme     
202                                                   
203         for (auto& pChanges : fReactionInfo)      
204         {                                         
205             auto pTrackA = const_cast<G4Track*    
206             auto pTrackB = const_cast<G4Track*    
207                                                   
208             if (pTrackA == nullptr                
209                 || pTrackB == nullptr             
210                 || pTrackA->GetTrackStatus() =    
211                 || pTrackB->GetTrackStatus() =    
212             {                                     
213                 continue;                         
214             }                                     
215                                                   
216             G4int nbSecondaries = pChanges->Ge    
217             const std::vector<G4Track*>* produ    
218                                                   
219             if (fpUserTimeStepAction != nullpt    
220             {                                     
221                 fpUserTimeStepAction->UserReac    
222                                                   
223                                                   
224             }                                     
225                                                   
226 #ifdef G4VERBOSE                                  
227             if (fVerbose != 0)                    
228             {                                     
229                 G4cout << "At time : " << std:    
230                        << " Reaction : " << Ge    
231                        << pTrackA->GetTrackID(    
232                        << pTrackB->GetTrackID(    
233             }                                     
234 #endif                                            
235                                                   
236             if (nbSecondaries > 0)                
237             {                                     
238                 for (int i = 0; i < nbSecondar    
239                 {                                 
240 #ifdef G4VERBOSE                                  
241                     if ((fVerbose != 0) && i !    
242                     {                             
243                         G4cout << " + ";          
244                     }                             
245 #endif                                            
246                                                   
247                     G4Track* secondary = (*pro    
248 //                    fpTrackContainer->_PushT    
249                     GetIT(secondary)->SetParen    
250                                                   
251                                                   
252                     if (secondary->GetGlobalTi    
253                     {                             
254                         G4ExceptionDescription    
255                         exceptionDescription <    
256                                                   
257                                              <    
258                                                   
259                                              <    
260                                              <    
261                                              <    
262                                              <    
263                                              <    
264                                              <    
265                                              <    
266                                                   
267                         G4Exception("G4Schedul    
268                                     "ITSchedul    
269                                     FatalError    
270                                     exceptionD    
271                     }                             
272                                                   
273 #ifdef G4VERBOSE                                  
274                     if (fVerbose != 0)            
275                     {                             
276                         G4cout << GetIT(second    
277                                << secondary->G    
278                     }                             
279 #endif                                            
280                 }                                 
281             }                                     
282             else                                  
283             {                                     
284 #ifdef G4VERBOSE                                  
285                 if (fVerbose != 0)                
286                 {                                 
287                     G4cout << "No product";       
288                 }                                 
289 #endif                                            
290             }                                     
291 #ifdef G4VERBOSE                                  
292             if (fVerbose != 0)                    
293             {                                     
294                 G4cout << G4endl;                 
295             }                                     
296 #endif                                            
297             if (pTrackA->GetTrackID() == 0 ||     
298             {                                     
299                 G4Track* pTrack = nullptr;        
300                 if (pTrackA->GetTrackID() == 0    
301                 {                                 
302                     pTrack = pTrackA;             
303                 }                                 
304                 else                              
305                 {                                 
306                     pTrack = pTrackB;             
307                 }                                 
308                                                   
309                 G4ExceptionDescription excepti    
310                 exceptionDescription              
311                     << "The problem was found     
312                     << pTrackA->GetParticleDef    
313                     << pTrackA->GetTrackID() <    
314                     << pTrackB->GetParticleDef    
315                     << pTrackB->GetTrackID() <    
316                                                   
317                 if (pTrack->GetStep() == nullp    
318                 {                                 
319                     exceptionDescription << "A    
320                                          << "     
321                 }                                 
322                                                   
323                 exceptionDescription << "Paren    
324                                      << pTrack    
325                 exceptionDescription << "Paren    
326                                      << pTrack    
327                                                   
328                 exceptionDescription              
329                     << "The ID of one of the r    
330                 G4Exception("G4Scheduler::Comp    
331                             "ITScheduler011",     
332                             FatalErrorInArgume    
333                             exceptionDescripti    
334             }                                     
335                                                   
336             if (pChanges->WereParentsKilled())    
337             {                                     
338                 pTrackA->SetTrackStatus(fStopA    
339                 pTrackB->SetTrackStatus(fStopA    
340                                                   
341                 fpTrackingManager->EndTracking    
342                 fpTrackingManager->EndTracking    
343             }                                     
344                                                   
345             pChanges.reset(nullptr);              
346         }                                         
347                                                   
348         fReactionInfo.clear();                    
349     }                                             
350                                                   
351 //    fReactionSet->CleanAllReaction();           
352                                                   
353     fpTrackContainer->MergeSecondariesWithMain    
354     fpTrackContainer->KillTracks();               
355 }                                                 
356                                                   
357 void G4ITModelProcessor::SetTrack(const G4Trac    
358 {                                                 
359     fpTrack = track;                              
360 }                                                 
361                                                   
362 void G4ITModelProcessor::SetModelHandler(G4ITM    
363 {                                                 
364     if (fInitialized)                             
365     {                                             
366         G4ExceptionDescription exceptionDescri    
367         exceptionDescription                      
368             << "You are trying to set a new mo    
369         G4Exception("G4ITModelProcessor::SetMo    
370                     FatalErrorInArgument, exce    
371     }                                             
372     fpModelHandler = pModelHandler;               
373 }                                                 
374                                                   
375 void G4ITModelProcessor::CleanProcessor()         
376 {                                                 
377     fpTrack = nullptr;                            
378 }                                                 
379                                                   
380 bool G4ITModelProcessor::GetComputeTimeStep()     
381 {                                                 
382     return fComputeTimeStep;                      
383 }                                                 
384                                                   
385 const G4Track* G4ITModelProcessor::GetTrack()     
386 {                                                 
387     return fpTrack;                               
388 }                                                 
389                                                   
390 void G4ITModelProcessor::SetTrackingManager(G4    
391 {                                                 
392     fpTrackingManager = pTrackingManager;         
393 }                                                 
394                                                   
395