Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/management/src/G4ProcessTable.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/management/src/G4ProcessTable.cc (Version 11.3.0) and /processes/management/src/G4ProcessTable.cc (Version 10.6.p1)


  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 // G4ProcessTable class implementation         << 
 27 //                                                 26 //
 28 // Author: H.Kurashige, 4 August 1998          <<  27 //
 29 // ------------------------------------------- <<  28 // 
                                                   >>  29 // ------------------------------------------------------------
                                                   >>  30 //  GEANT 4 class header file 
                                                   >>  31 //
                                                   >>  32 //  History: first implementation, based on object model of
                                                   >>  33 //  4th Aug 1998, H.Kurashige
                                                   >>  34 // ------------------------------------------------------------
                                                   >>  35 //  History:
                                                   >>  36 //   Use STL vector instead of RW vector    1. Mar 00 H.Kurashige
                                                   >>  37 //
 30                                                    38 
 31 #include "G4ProcessTableMessenger.hh"              39 #include "G4ProcessTableMessenger.hh"
 32 #include "G4ProcessTable.hh"                       40 #include "G4ProcessTable.hh"
 33 #include "G4ParticleTable.hh"                  << 
 34 #include "G4ios.hh"                            << 
 35                                                    41 
 36 // ------------------------------------------- << 
 37 // Static class variable: ptr to single instan     42 // Static class variable: ptr to single instance of class in a thread
 38 G4ThreadLocal G4ProcessTable* G4ProcessTable::     43 G4ThreadLocal G4ProcessTable* G4ProcessTable::fProcessTable = nullptr;
 39                                                    44 
 40 // ------------------------------------------- <<  45 //  constructor //////////////////////////
 41 // Default constructor                         << 
 42 //                                             << 
 43 G4ProcessTable::G4ProcessTable()                   46 G4ProcessTable::G4ProcessTable()
                                                   >>  47   :verboseLevel(1)
 44 {                                                  48 {
 45 #ifdef G4VERBOSE                                   49 #ifdef G4VERBOSE
 46   if (verboseLevel>1)                          <<  50   if (verboseLevel>1){
 47   {                                            << 
 48     G4cout << "--  G4ProcessTable constructor      51     G4cout << "--  G4ProcessTable constructor  --" << G4endl;
 49   }                                                52   }
 50 #endif                                             53 #endif
 51   fProcTblVector  = new  G4ProcTableVector();      54   fProcTblVector  = new  G4ProcTableVector();
 52   fProcNameVector = new  G4ProcNameVector();       55   fProcNameVector = new  G4ProcNameVector();
 53   tmpTblVector    = new  G4ProcTableVector();      56   tmpTblVector    = new  G4ProcTableVector();
 54   fProcTblMessenger = new G4ProcessTableMessen     57   fProcTblMessenger = new G4ProcessTableMessenger(this);
 55 }                                                  58 }
 56                                                    59 
 57 // ------------------------------------------- <<  60 // destructor //////////////////////////
 58 // Destructor                                  << 
 59 //                                             << 
 60 G4ProcessTable::~G4ProcessTable()                  61 G4ProcessTable::~G4ProcessTable()
 61 {                                                  62 {
 62   if ( tmpTblVector != nullptr )               <<  63   if ( tmpTblVector != nullptr) {
 63   {                                            << 
 64     tmpTblVector ->clear();                        64     tmpTblVector ->clear();
 65     delete tmpTblVector;                           65     delete tmpTblVector;
 66     tmpTblVector = nullptr;                        66     tmpTblVector = nullptr;
 67   }                                                67   }
 68                                                    68 
 69   if ( fProcTblVector != nullptr )             <<  69   if ( fProcTblVector != nullptr) {
 70   {                                            <<  70     G4ProcTableVector::iterator idx;
 71     for (auto elem : *fProcTblVector)          <<  71     
 72     {                                          <<  72     for (idx=fProcTblVector->begin(); idx!=fProcTblVector->end(); ++idx) {
 73       delete elem;                             <<  73       delete (*idx);
 74     }                                              74     }  
 75     fProcTblVector ->clear();                      75     fProcTblVector ->clear();
 76     delete fProcTblVector;                         76     delete fProcTblVector;
 77     fProcTblVector = nullptr;                      77     fProcTblVector = nullptr;
 78   }                                                78   }
 79                                                    79 
 80   // delete all process except transportation  <<  80   if ( fProcNameVector != nullptr) {
 81   for(auto proc : fListProcesses)              << 
 82   {                                            << 
 83     if ( proc != nullptr )                     << 
 84     {                                          << 
 85       G4ProcessType type = proc->GetProcessTyp << 
 86       if (type != fTransportation && type != f << 
 87        && type != fParameterisation)           << 
 88       {                                        << 
 89         delete proc;                           << 
 90       }                                        << 
 91     }                                          << 
 92   }                                            << 
 93                                                << 
 94   fListProcesses.clear();                      << 
 95                                                << 
 96   if ( fProcNameVector != nullptr )            << 
 97   {                                            << 
 98     fProcNameVector ->clear();                     81     fProcNameVector ->clear();
 99     delete fProcNameVector;                        82     delete fProcNameVector;
100     fProcNameVector = nullptr;                     83     fProcNameVector = nullptr;
101   }                                                84   }
102   fProcessTable = nullptr;                         85   fProcessTable = nullptr;
103   delete fProcTblMessenger;                        86   delete fProcTblMessenger;
104 }                                                  87 }
105                                                    88 
106 // ------------------------------------------- <<  89 //////////////////////////
107 //                                             << 
108 G4ProcessTable* G4ProcessTable::GetProcessTabl     90 G4ProcessTable* G4ProcessTable::GetProcessTable()
109 {                                                  91 {
110   if(fProcessTable == nullptr)                 <<  92   if(!fProcessTable) {
111   {                                            << 
112     static G4ThreadLocalSingleton<G4ProcessTab     93     static G4ThreadLocalSingleton<G4ProcessTable> inst;
113     fProcessTable = inst.Instance();               94     fProcessTable = inst.Instance();
114   }                                                95   }
115   return fProcessTable;                            96   return fProcessTable;
116 }                                                  97 }
117                                                    98 
118 // ------------------------------------------- <<  99 //////////////////////////
119 //                                             << 100 G4int   G4ProcessTable::Insert(G4VProcess* aProcess, 
120 G4int G4ProcessTable::Insert(G4VProcess* aProc << 101              G4ProcessManager* aProcMgr)
121                              G4ProcessManager* << 102 {
122 {                                              << 103   if ( (aProcess == nullptr) || ( aProcMgr == nullptr ) ){
123   if ( (aProcess == nullptr) || ( aProcMgr ==  << 104 #ifdef G4VERBOSE
124   {                                            << 105     if (verboseLevel>0){
125 #ifdef G4VERBOSE                               << 106       G4cout << "G4ProcessTable::Insert : arguments are 0 pointer "
126     if (verboseLevel>0)                        << 107        <<aProcess <<","<<  aProcMgr << G4endl;
127     {                                          << 
128       G4cout << "G4ProcessTable::Insert() - ar << 
129              << aProcess << "," << aProcMgr << << 
130     }                                             108     }
131 #endif                                            109 #endif
132     return -1;                                    110     return -1;
133   }                                               111   }
134                                                   112     
135 #ifdef G4VERBOSE                                  113 #ifdef G4VERBOSE
136   if (verboseLevel>1)                          << 114   if (verboseLevel>1){
137   {                                            << 115     G4cout << "G4ProcessTable::Insert ";
138     G4cout << "G4ProcessTable::Insert() -";    << 
139     G4cout << " Process["  << aProcess->GetPro    116     G4cout << " Process["  << aProcess->GetProcessName() << "]";
140     G4cout << " Particle["  << aProcMgr->GetPa << 117     G4cout << " Particle["  << aProcMgr->GetParticleType()->GetParticleName() << "]";
141            << "]" << G4endl;                   << 118     G4cout << G4endl;
142   }                                               119   }
143 #endif                                            120 #endif
144                                                   121 
145   G4int idxTbl = 0;                            << 122   G4int idxTbl=0;
146   G4int nidx = (G4int)fProcTblVector->size();  << 
147   G4ProcTblElement* anElement = nullptr;          123   G4ProcTblElement* anElement = nullptr;
                                                   >> 124   G4bool isFoundInTbl = false;
148   // loop over all elements                       125   // loop over all elements
149   for (; idxTbl < nidx; ++idxTbl)              << 126   for (auto itr=fProcTblVector->begin();
150   {                                            << 127             itr!=fProcTblVector->end(); ++itr, ++idxTbl) {
151     anElement = (*fProcTblVector)[idxTbl];     << 128     anElement = (*itr);
152     if(!anElement) { continue; }               << 
153     // check if this process is included          129     // check if this process is included
154     if (aProcess == anElement->GetProcess())   << 130     if (aProcess == anElement->GetProcess()) {
155     {                                          << 131       isFoundInTbl = true;
                                                   >> 132 
156       // add the process manager into the elem    133       // add the process manager into the element 
157       // unless  this process manager is inclu << 134       //  unless  this process manager is included
158       if (!anElement->Contains(aProcMgr))      << 135       if (!anElement->Contains(aProcMgr)) {
159       {                                        << 136   anElement->Insert(aProcMgr);
160         anElement->Insert(aProcMgr);           << 137 #ifdef G4VERBOSE
161 #ifdef G4VERBOSE                               << 138   if (verboseLevel>2){
162         if (verboseLevel>2)                    << 139     G4cout << " This Process Manager is registered !! " << G4endl;
163         {                                      << 140   }
164           G4cout << " This Process Manager is  << 
165         }                                      << 
166 #endif                                            141 #endif
167       }                                           142       }
168       return idxTbl;                           << 143       break;
169     }                                             144     }
170   }                                               145   }
171   // add this process into the table by creati    146   // add this process into the table by creating a new element
172   if (verboseLevel>2)                          << 147   if (!isFoundInTbl) {
173   {                                            << 148     G4ProcTblElement* newElement = new G4ProcTblElement(aProcess);
174     G4cout << " New element is created !! " << << 149     newElement->Insert(aProcMgr);
175   }                                            << 150     fProcTblVector->push_back(newElement);
176   anElement = new G4ProcTblElement(aProcess);  << 151     // add into name vector     
177   anElement->Insert(aProcMgr);                 << 152     G4bool isFound = false;
178   fProcTblVector->push_back(anElement);        << 153     for (auto ip=fProcNameVector->cbegin(); ip!=fProcNameVector->cend(); ++ip) {
179   fProcNameVector->push_back(aProcess->GetProc << 154       isFound |= (aProcess->GetProcessName() == (*ip));
180   return nidx;                                 << 155     }
                                                   >> 156     if (!isFound) {
                                                   >> 157       fProcNameVector->push_back(aProcess->GetProcessName() );
                                                   >> 158 #ifdef G4VERBOSE
                                                   >> 159       if (verboseLevel>2){
                                                   >> 160   G4cout << " This Process is registered !! " << G4endl;
                                                   >> 161       }
                                                   >> 162 #endif
                                                   >> 163     }
                                                   >> 164   }
                                                   >> 165   return idxTbl;
181 }                                                 166 }
182                                                   167 
183 // ------------------------------------------- << 168 //////////////////////////
184 //                                             << 169 G4int  G4ProcessTable::Remove( G4VProcess* aProcess, 
185 G4int G4ProcessTable::Remove( G4VProcess* aPro << 170              G4ProcessManager* aProcMgr)
186                               G4ProcessManager << 
187 {                                                 171 {
188   if ( (aProcess == nullptr) || ( aProcMgr ==  << 172   if ( (aProcess == nullptr) || ( aProcMgr == nullptr ) ){
189   {                                            << 
190 #ifdef G4VERBOSE                                  173 #ifdef G4VERBOSE
191     if (verboseLevel>0)                        << 174     if (verboseLevel>0){
192     {                                          << 175       G4cout << "G4ProcessTable::Remove : arguments are 0 pointer "<< G4endl;
193       G4cout << "G4ProcessTable::Remove() - ar << 
194              << G4endl;                        << 
195     }                                             176     }
196 #endif                                            177 #endif
197     return -1;                                    178     return -1;
198   }                                               179   }
199                                                   180     
200 #ifdef G4VERBOSE                                  181 #ifdef G4VERBOSE
201   if (verboseLevel>1)                          << 182   if (verboseLevel>1){
202   {                                            << 183     G4cout << "G4ProcessTable::Remove ";
203     G4cout << "G4ProcessTable::Remove() -";    << 
204     G4cout << " Process["  << aProcess->GetPro    184     G4cout << " Process["  << aProcess->GetProcessName() << "]";
205     G4cout << " Particle[" << aProcMgr->GetPar << 185     G4cout << " Particle[" << aProcMgr->GetParticleType()->GetParticleName() << "]" << G4endl;
206            << "]" << G4endl;                   << 
207   }                                               186   }
208 #endif                                            187 #endif
209                                                   188 
210   G4int idxTbl = 0;                            << 189   G4ProcTableVector::iterator itr; 
211   G4int nidx = (G4int)fProcTblVector->size();  << 190   G4int idxTbl=0;
212   G4ProcTblElement* anElement =nullptr;           191   G4ProcTblElement* anElement =nullptr;
                                                   >> 192   G4bool isFound = false;
213   // loop over all elements                       193   // loop over all elements
214   for (; idxTbl < nidx; ++idxTbl)              << 194   for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr, ++idxTbl) {
215   {                                            << 195     anElement = (*itr);
216     anElement = (*fProcTblVector)[idxTbl];     << 
217     if(!anElement) { continue; }               << 
218                                                   196 
219     // check if this process is included          197     // check if this process is included
220     if (aProcess == anElement->GetProcess())   << 198     if (aProcess == anElement->GetProcess()) {
221     {                                          << 199       isFound = anElement->Contains(aProcMgr);
222       if(anElement->Contains(aProcMgr))        << 200       // remove the process manager from the element
223       {                                        << 201       anElement->Remove(aProcMgr);
224         // remove the process manager from the << 
225         anElement->Remove(aProcMgr);           << 
226 #ifdef G4VERBOSE                               << 
227         if (verboseLevel>2)                    << 
228         {                                      << 
229           G4cout << " This Process Manager is  << 
230         }                                      << 
231 #endif                                         << 
232         if(anElement->Length() == 0)           << 
233         {                                      << 
234           delete anElement;                    << 
235           (*fProcTblVector)[idxTbl] = nullptr; << 
236 #ifdef G4VERBOSE                                  202 #ifdef G4VERBOSE
237           if (verboseLevel>1)                  << 203       if (verboseLevel>2){
238           {                                    << 204   G4cout << " This Process Manager is removed !! " << G4endl;
239             G4cout << " This Process is remove << 
240           }                                    << 
241 #endif                                         << 
242         }                                      << 
243         return idxTbl;                         << 
244       }                                           205       }
                                                   >> 206 #endif
                                                   >> 207       break;
245     }                                             208     }
246   }                                               209   }
                                                   >> 210   // 
                                                   >> 211   if (!isFound) {
247 #ifdef G4VERBOSE                                  212 #ifdef G4VERBOSE
248   if (verboseLevel>1)                          << 213     if (verboseLevel>0){
249   {                                            << 214       G4cout << " This Process Manager is not registered !! " << G4endl;
250     G4cout << " This Process Manager is not re << 215     }
251            << G4endl;                          << 
252   }                                            << 
253 #endif                                            216 #endif
254   return -1;                                   << 217     return -1;
255 }                                              << 
256                                                << 
257 // ------------------------------------------- << 
258 //                                             << 
259 void G4ProcessTable::RegisterProcess(G4VProces << 
260 {                                              << 
261   for(auto proc : fListProcesses)              << 
262   {                                            << 
263     if(ptr == proc) { return; }                << 
264   }                                               218   }
265   fListProcesses.push_back(ptr);               << 219   // remove the element if it has no entry
266 }                                              << 220   if (anElement->Length() == 0){
267                                                << 221     fProcTblVector->erase(itr);
268 // ------------------------------------------- << 222     delete anElement;
269 //                                             << 223     // check other prcesses with same name exist or not
270 void G4ProcessTable::DeRegisterProcess(G4VProc << 224     G4bool isSameName = false;
271 {                                              << 225     for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr) {
272   std::size_t nn = fListProcesses.size();      << 226       anElement = (*itr);
273   for(std::size_t i=0; i<nn; ++i)              << 227       if (anElement->GetProcessName() == aProcess->GetProcessName()) {
274   {                                            << 228   isSameName = true;
275     if(ptr == fListProcesses[i])               << 229   break;
276     {                                          << 230       }
277       fListProcesses[i] = nullptr;             << 
278       return;                                  << 
279     }                                             231     }
280   }                                            << 232     // remove from name vector
281 }                                              << 233     if (!isSameName ) {
282                                                << 234       for (auto i=fProcNameVector->begin(); i!=fProcNameVector->end(); ++i) {
283 // ------------------------------------------- << 235   if ( *i == aProcess->GetProcessName() ) {
284 //                                             << 236     fProcNameVector->erase(i);
285 G4VProcess* G4ProcessTable::FindProcess(const  << 237     break;
286                                         const  << 238   }
287 {                                              << 239       }
288   return FindProcess(processName,              << 
289           G4ParticleTable::GetParticleTable()- << 
290 }                                              << 
291                                                << 
292 // ------------------------------------------- << 
293 //                                             << 
294 G4VProcess* G4ProcessTable::FindProcess(const  << 
295                                         const  << 
296                                         const  << 
297 {                                              << 
298   for (auto anElement : *fProcTblVector)       << 
299   {                                            << 
300     // check name and if the processManage is  << 
301     if (anElement && anElement->GetProcessName << 
302         && anElement->Contains(processManager) << 
303     {                                          << 
304       return anElement->GetProcess();          << 
305     }                                             240     }
306   }                                            << 
307 #ifdef G4VERBOSE                                  241 #ifdef G4VERBOSE
308   if (verboseLevel > 1)                        << 242     if (verboseLevel>1){
309   {                                            << 243       G4cout << " This Process is removed !! " << G4endl;
310     G4cout << " G4ProcessTable::FindProcess()  << 
311     G4cout << " The Process[" << processName < << 
312     G4cout << " for [" << processManager->GetP << 
313            << "]" << G4endl;                   << 
314   }                                            << 
315 #endif                                         << 
316   return nullptr;                              << 
317 }                                              << 
318                                                << 
319 // ------------------------------------------- << 
320 //                                             << 
321 G4VProcess*                                    << 
322 G4ProcessTable::FindProcess(G4ProcessType proc << 
323                             const G4ParticleDe << 
324 {                                              << 
325   // find the first process of given type for  << 
326                                                << 
327   const G4ProcessManager* processManager = par << 
328   for (auto anElement : *fProcTblVector)       << 
329   {                                            << 
330     if (anElement && anElement->GetProcess()-> << 
331         && anElement->Contains(processManager) << 
332     {                                          << 
333       return anElement->GetProcess();          << 
334     }                                             244     }
335   }                                            << 
336 #ifdef G4VERBOSE                               << 
337   if (verboseLevel > 1)                        << 
338   {                                            << 
339     G4cout << " G4ProcessTable::FindProcess()  << 
340     G4cout << " The Process Type " << processT << 
341     G4cout << " for [" << particle->GetParticl << 
342   }                                            << 
343 #endif                                            245 #endif
344   return nullptr;                              << 246   }
                                                   >> 247   return idxTbl;
345 }                                                 248 }
346                                                   249 
347 // ------------------------------------------- << 250 //////////////////////////
348 //                                             << 251 G4VProcess* G4ProcessTable::FindProcess(const G4String& processName, 
349 G4VProcess*                                    << 252                       const G4ProcessManager* processManager)
350 G4ProcessTable::FindProcess(G4int procSubType, << 253                                         const
351                             const G4ParticleDe << 
352 {                                                 254 {
353   // find the first process of given type for  << 255   G4int idxTbl = 0;
354                                                << 256   G4bool isFound = false;
355   const G4ProcessManager* processManager = par << 257   G4ProcTblElement* anElement =nullptr;
356   for (auto anElement : *fProcTblVector)       << 258   for (auto itr=fProcTblVector->cbegin();
357   {                                            << 259             itr!=fProcTblVector->cend(); ++itr, ++idxTbl) {
358     if ( anElement != nullptr                  << 260     anElement = (*itr);
359       && anElement->GetProcess()->GetProcessSu << 261     // check name
360       && anElement->Contains(processManager) ) << 262     if ( anElement->GetProcessName() == processName ) {
361     {                                          << 263       // check if the processManage is included
362       return anElement->GetProcess();          << 264       if ( anElement->Contains(processManager) ) {
                                                   >> 265   isFound = true;
                                                   >> 266   break;
                                                   >> 267       }
363     }                                             268     }
364   }                                               269   }
365 #ifdef G4VERBOSE                                  270 #ifdef G4VERBOSE
366   if (verboseLevel > 1)                        << 271   if (!isFound && verboseLevel>1){
367   {                                            << 272     G4cout << " G4ProcessTable::FindProcess :" ;
368     G4cout << " G4ProcessTable::FindProcess()  << 273     G4cout << " The Process[" << processName << "] is not found  ";
369     G4cout << " The Process SubType " << procS << 274     G4cout << " for " << processManager->GetParticleType()->GetParticleName() << G4endl;
370     G4cout << " for [" << particle->GetParticl << 
371   }                                               275   }
372 #endif                                            276 #endif
373   return nullptr;                              << 277   
                                                   >> 278   if (isFound) return anElement->GetProcess();
                                                   >> 279   else         return nullptr;
374 }                                                 280 }
375                                                   281 
376 // ------------------------------------------- << 282 ///////////////
377 //                                             << 283 G4ProcessTable::G4ProcTableVector* G4ProcessTable::Find( 
378 G4ProcessTable::G4ProcTableVector*             << 284            G4ProcTableVector*,
379 G4ProcessTable::Find(const G4String& processNa << 285            const G4String& processName )
380 {                                                 286 {
381   tmpTblVector->clear();                          287   tmpTblVector->clear();
382                                                   288 
383   G4bool isFound = false;                         289   G4bool isFound = false;
384   G4ProcTblElement* anElement = nullptr;       << 290   G4ProcTblElement* anElement =nullptr;
385   for (auto itr=fProcTblVector->cbegin(); itr! << 291   for (auto itr=fProcTblVector->cbegin(); itr!=fProcTblVector->cend(); ++itr) {
386   {                                            << 
387     anElement = (*itr);                           292     anElement = (*itr);
388     // check name                                 293     // check name
389     if ( anElement != nullptr && anElement->Ge << 294     if ( anElement->GetProcessName() == processName ) {
390     {                                          << 
391       isFound = true;                             295       isFound = true;
392       tmpTblVector->push_back(anElement);         296       tmpTblVector->push_back(anElement);
393     }                                             297     }
394   }                                               298   }
395                                                   299 
396   if (!isFound && verboseLevel>0)              << 300   if (!isFound && verboseLevel>0){
397   {                                            << 
398 #ifdef G4VERBOSE                                  301 #ifdef G4VERBOSE
399     G4cout << " G4ProcessTable::Find() -" ;    << 302     G4cout << " G4ProcessTable::Find :" ;
400     G4cout << " The Process[" << processName <    303     G4cout << " The Process[" << processName << "] is not found  " << G4endl;
401 #endif                                            304 #endif
402   }                                               305   }
403                                                << 306   
404   return tmpTblVector;                            307   return tmpTblVector;
405 }                                              << 
406                                                   308 
407 // ------------------------------------------- << 309 }     
408 //                                             << 310 ///////////////
409 G4ProcessTable::G4ProcTableVector*             << 311 G4ProcessTable::G4ProcTableVector* G4ProcessTable::Find( 
410 G4ProcessTable::Find(G4ProcessType processType << 312            G4ProcTableVector*,
                                                   >> 313            G4ProcessType   processType )
411 {                                                 314 {
412   tmpTblVector->clear();                          315   tmpTblVector->clear();
413                                                   316 
414   G4bool isFound = false;                         317   G4bool isFound = false;
415   G4ProcTblElement* anElement = nullptr;       << 318   G4ProcTblElement* anElement =nullptr;
416   for (auto itr=fProcTblVector->cbegin(); itr! << 319   for (auto itr=fProcTblVector->cbegin(); itr!=fProcTblVector->cend(); ++itr) {
417   {                                            << 
418     anElement = (*itr);                           320     anElement = (*itr);
419     // check name                                 321     // check name
420     if ( anElement != nullptr && anElement->Ge << 322     if ( anElement->GetProcess()->GetProcessType() == processType ) {
421     {                                          << 
422       isFound = true;                             323       isFound = true;
423       tmpTblVector->push_back(anElement);         324       tmpTblVector->push_back(anElement);
424     }                                             325     }
425   }                                               326   }
426                                                   327 
427   if (!isFound && verboseLevel>0)              << 328   if (!isFound && verboseLevel>0){
428   {                                            << 
429 #ifdef G4VERBOSE                                  329 #ifdef G4VERBOSE
430     G4cout << " G4ProcessTable::Find() -" ;    << 330     G4cout << " G4ProcessTable::Find :" ;
431     G4cout << " The ProcessType[" << processTy << 331     G4cout << " The ProcessType[" << processType << "] is not found  " << G4endl;
432            << G4endl;                          << 
433 #endif                                            332 #endif
434   }                                               333   }
435                                                << 334   
436   return tmpTblVector;                            335   return tmpTblVector;
                                                   >> 336 
437 }                                                 337 }     
438                                                   338 
439 // ------------------------------------------- << 339 ///////////////
440 //                                             << 340 G4ProcessVector* G4ProcessTable::ExtractProcesses( G4ProcTableVector* procTblVector)
441 G4ProcessVector*                               << 
442 G4ProcessTable::ExtractProcesses(G4ProcTableVe << 
443 {                                                 341 {
444   G4ProcessVector* procList = new G4ProcessVec    342   G4ProcessVector* procList = new G4ProcessVector();
445   // loop over all elements                       343   // loop over all elements
446   for (auto itr=procTblVector->cbegin(); itr!= << 344   for (auto itr=procTblVector->cbegin(); itr!=procTblVector->cend(); ++itr) {
447   {                                            << 
448     G4ProcTblElement* anElement = (*itr);         345     G4ProcTblElement* anElement = (*itr);
449     if ( anElement != nullptr) procList->inser << 346     procList->insert( anElement->GetProcess() );
450   }                                               347   }
451   return procList;                                348   return procList;
452 }                                                 349 }
453                                                   350 
454 // ------------------------------------------- << 351 ///////////////
455 //                                             << 352 G4ProcessVector* G4ProcessTable::FindProcesses()
456 void G4ProcessTable::SetProcessActivation(cons << 
457                                           cons << 
458                                                << 
459 {                                                 353 {
460   if (particleName == "ALL" )                  << 354   return ExtractProcesses(fProcTblVector);
461   {                                            << 
462     SetProcessActivation( processName, fActive << 
463   }                                            << 
464   else                                         << 
465   {                                            << 
466     SetProcessActivation(processName,          << 
467         G4ParticleTable::GetParticleTable()->F << 
468         fActive );                             << 
469   }                                            << 
470 }                                                 355 }
471                                                   356 
472 // ------------------------------------------- << 357 ///////////////
473 //                                             << 358 G4ProcessVector* G4ProcessTable::FindProcesses( const G4ProcessManager* pManager )
474 void G4ProcessTable::SetProcessActivation(G4Pr << 
475                                           cons << 
476                                                << 
477 {                                                 359 {
478   if ((particleName == "ALL" ) || (particleNam << 360   G4ProcessVector* procList = pManager->GetProcessList();
479   {                                            << 361   return new G4ProcessVector(*procList);
480     SetProcessActivation( processType, fActive << 
481   }                                            << 
482   else                                         << 
483   {                                            << 
484     SetProcessActivation(processType,          << 
485         G4ParticleTable::GetParticleTable()->F << 
486         fActive );                             << 
487   }                                            << 
488 }                                                 362 }
489                                                   363 
490 // ------------------------------------------- << 364 ///////////////
491 //                                             << 365 G4ProcessVector* G4ProcessTable::FindProcesses( const G4String& processName )
                                                   >> 366 {
                                                   >> 367   G4ProcTableVector* pTblVector =  Find(fProcTblVector, processName);
                                                   >> 368   return ExtractProcesses(pTblVector);
                                                   >> 369 }
                                                   >> 370 
                                                   >> 371 ///////////////
                                                   >> 372 G4ProcessVector* G4ProcessTable::FindProcesses( G4ProcessType processType)
                                                   >> 373 {
                                                   >> 374   G4ProcTableVector* pTblVector =  Find(fProcTblVector, processType);
                                                   >> 375   return ExtractProcesses(pTblVector);
                                                   >> 376 }
                                                   >> 377 
                                                   >> 378 ///////////////
492 void G4ProcessTable::SetProcessActivation( con    379 void G4ProcessTable::SetProcessActivation( const G4String& processName, 
493                                            G4b << 380                          G4bool          fActive  )
494 {                                                 381 {
495 #ifdef G4VERBOSE                                  382 #ifdef G4VERBOSE
496   if (verboseLevel>1)                          << 383   if (verboseLevel>1){
497   {                                            << 384     G4cout << " G4ProcessTable::SetProcessActivation:" ;
498     G4cout << " G4ProcessTable::SetProcessActi << 
499     G4cout << " The Process[" << processName <    385     G4cout << " The Process[" << processName << "] "<< G4endl;
500   }                                               386   }
501 #endif                                            387 #endif
502                                                   388 
503   G4ProcTableVector* pTblVector =  Find(proces << 389   G4ProcTableVector* pTblVector =  Find(fProcTblVector, processName);
504   G4ProcTblElement* anElement;                    390   G4ProcTblElement* anElement;  
505    // loop over all elements                      391    // loop over all elements
506   for (auto itr=pTblVector->cbegin(); itr!=pTb << 392   for (auto itr=pTblVector->cbegin(); itr!=pTblVector->cend(); ++itr) {
507   {                                            << 
508     anElement = (*itr);                           393     anElement = (*itr);
509     if ( anElement == nullptr ) continue;      << 
510     G4VProcess* process = anElement->GetProces    394     G4VProcess* process = anElement->GetProcess();
511     for (G4int idx = 0 ; idx < anElement->Leng << 395     for (G4int idx = 0 ; idx < anElement->Length(); idx++) {
512     {                                          << 
513       G4ProcessManager* manager = anElement->G    396       G4ProcessManager* manager = anElement->GetProcessManager(idx);
514       manager->SetProcessActivation(process, f    397       manager->SetProcessActivation(process, fActive);
515 #ifdef G4VERBOSE                                  398 #ifdef G4VERBOSE
516       if (verboseLevel>1)                      << 399       if (verboseLevel>1){
517       {                                        << 
518         G4cout << "  for " << manager->GetPart    400         G4cout << "  for " << manager->GetParticleType()->GetParticleName();
519         G4cout << "  Index = " << manager->Get << 401   G4cout << "  Index = " << manager->GetProcessIndex(process); 
520         G4cout << G4endl;                         402         G4cout << G4endl;
521       }                                           403       }
522 #endif                                            404 #endif
523     }                                             405     }
524   }                                               406   }
525 }                                                 407 }
526                                                   408 
527 // ------------------------------------------- << 409 ///////////////
528 //                                             << 410 void G4ProcessTable::SetProcessActivation( 
529 void G4ProcessTable::SetProcessActivation(cons << 411          const G4String& processName, 
530                                           G4Pr << 412                G4ProcessManager* processManager, 
531                                           G4bo << 413          G4bool          fActive  )
532 {                                                 414 {
533 #ifdef G4VERBOSE                                  415 #ifdef G4VERBOSE
534   if (verboseLevel>1)                          << 416   if (verboseLevel>1){
535   {                                            << 417     G4cout << " G4ProcessTable::SetProcessActivation:" ;
536     G4cout << " G4ProcessTable::SetProcessActi << 
537     G4cout << " The Process[" << processName <    418     G4cout << " The Process[" << processName << "] "<< G4endl;
538   }                                               419   }
539 #endif                                            420 #endif
540                                                   421   
541   G4VProcess* process = FindProcess( processNa    422   G4VProcess* process = FindProcess( processName,  processManager);
542   if ( process != nullptr)                     << 423   if ( process != nullptr) {
543   {                                            << 
544     processManager->SetProcessActivation(proce    424     processManager->SetProcessActivation(process, fActive);
545 #ifdef G4VERBOSE                                  425 #ifdef G4VERBOSE
546     if (verboseLevel>1)                        << 426     if (verboseLevel>1){
547     {                                          << 427       G4cout << "  for " << processManager->GetParticleType()->GetParticleName();
548       G4cout << "  for "                       << 428       G4cout << "  Index = " << processManager->GetProcessIndex(process) << G4endl;
549              << processManager->GetParticleTyp << 
550       G4cout << "  Index = "                   << 
551              << processManager->GetProcessInde << 
552     }                                             429     }
553 #endif                                            430 #endif
554   }                                               431   } 
555 }                                                 432 }
556                                                   433 
557 // ------------------------------------------- << 434 
558 //                                             << 435 ///////////////
559 void G4ProcessTable::SetProcessActivation( G4P << 436 void G4ProcessTable::SetProcessActivation( G4ProcessType   processType, 
560                                            G4b << 437                          G4bool          fActive  )
561 {                                                 438 {
562 #ifdef G4VERBOSE                                  439 #ifdef G4VERBOSE
563   if (verboseLevel>1)                          << 440   if (verboseLevel>1){
564   {                                            << 441     G4cout << " G4ProcessTable::SetProcessActivation:" ;
565     G4cout << " G4ProcessTable::SetProcessActi << 
566     G4cout << " The ProcessType[" << G4int(pro    442     G4cout << " The ProcessType[" << G4int(processType) << "] "<< G4endl;
567   }                                               443   }
568 #endif                                            444 #endif
569                                                   445 
570   G4ProcTableVector* pTblVector = Find(process << 446   G4ProcTableVector* pTblVector =  Find(fProcTblVector, processType);
571   G4ProcTblElement* anElement;                    447   G4ProcTblElement* anElement;  
572   // loop over all elements                       448   // loop over all elements
573   for (auto itr=pTblVector->cbegin(); itr!=pTb << 449   for (auto itr=pTblVector->cbegin(); itr!=pTblVector->cend(); ++itr) {
574   {                                            << 
575     anElement = (*itr);                           450     anElement = (*itr);
576     if ( anElement == nullptr ) continue;      << 
577     G4VProcess* process = anElement->GetProces    451     G4VProcess* process = anElement->GetProcess();
578 #ifdef G4VERBOSE                                  452 #ifdef G4VERBOSE
579     if (verboseLevel>1)                        << 453     if (verboseLevel>1){
580     {                                          << 
581       G4cout << " The Process[" << process->Ge    454       G4cout << " The Process[" << process->GetProcessName()<< "] "<< G4endl;
582     }                                             455     }
583 #endif                                            456 #endif
584     for (G4int idx = 0 ; idx < anElement->Leng << 457     for (G4int idx = 0 ; idx < anElement->Length(); ++idx) {
585     {                                          << 
586       G4ProcessManager* manager = anElement->G    458       G4ProcessManager* manager = anElement->GetProcessManager(idx);
587       manager->SetProcessActivation(process, f    459       manager->SetProcessActivation(process, fActive);
588 #ifdef G4VERBOSE                                  460 #ifdef G4VERBOSE
589       if (verboseLevel>1)                      << 461       if (verboseLevel>1){
590       {                                        << 
591         G4cout << "  for " << manager->GetPart    462         G4cout << "  for " << manager->GetParticleType()->GetParticleName();
592         G4cout << "  Index = " << manager->Get << 463   G4cout << "  Index = " << manager->GetProcessIndex(process) << G4endl;
593       }                                           464       }
594 #endif                                            465 #endif
595     }                                             466     }
596   }                                               467   }
597 }                                                 468 }
598                                                   469 
599 // ------------------------------------------- << 470 ///////////////
600 //                                             << 471 void G4ProcessTable::SetProcessActivation( 
601 void G4ProcessTable::SetProcessActivation( G4P << 472          G4ProcessType   processType, 
602                                            G4P << 473                G4ProcessManager* processManager, 
603                                            G4b << 474          G4bool          fActive  )
604 {                                                 475 {
605 #ifdef G4VERBOSE                                  476 #ifdef G4VERBOSE
606   if (verboseLevel>1)                          << 477   if (verboseLevel>1){
607   {                                            << 478     G4cout << " G4ProcessTable::SetProcessActivation:" ;
608     G4cout << " G4ProcessTable::SetProcessActi << 
609     G4cout << " The ProcessType[" << G4int(pro    479     G4cout << " The ProcessType[" << G4int(processType) << "] "<< G4endl;
610   }                                               480   }
611 #endif                                            481 #endif
612                                                   482   
613   G4ProcessVector* procList =  processManager-    483   G4ProcessVector* procList =  processManager->GetProcessList();
614   for (G4int idx = 0; idx < (G4int)procList->l << 484   for (std::size_t idx = 0; idx < procList->length(); ++idx) {
615   {                                            << 
616     G4VProcess* process = (*procList)(idx);       485     G4VProcess* process = (*procList)(idx);
617     if ( process->GetProcessType() == processT << 486     if ( process->GetProcessType() == processType) {
618     {                                          << 
619       processManager->SetProcessActivation(pro    487       processManager->SetProcessActivation(process, fActive);
620 #ifdef G4VERBOSE                                  488 #ifdef G4VERBOSE
621       if (verboseLevel>1)                      << 489       if (verboseLevel>1){
622       {                                        << 
623         G4cout << " The Process[" << process->    490         G4cout << " The Process[" << process->GetProcessName()<< "] "<< G4endl;
624         G4cout << "  for "                     << 491   G4cout << "  for " << processManager->GetParticleType()->GetParticleName();
625                << processManager->GetParticleT << 492   G4cout << "  Index = " << idx << G4endl;
626         G4cout << "  Index = " << idx << G4end << 
627       }                                           493       }
628 #endif                                            494 #endif
629     }                                             495     }
630   }                                               496   }
631 }                                                 497 }
632                                                   498 
633 // ------------------------------------------- << 499 
634 //                                             << 500 /////////////
635 void G4ProcessTable::DumpInfo(G4VProcess* proc    501 void G4ProcessTable::DumpInfo(G4VProcess* process, 
636                               const G4Particle << 502             G4ParticleDefinition* particle)
637 {                                                 503 {
638   G4int idxTbl=0;                                 504   G4int idxTbl=0;
639   G4ProcTblElement* anElement = nullptr;       << 505   G4ProcTblElement* anElement =nullptr;
640   G4bool isFoundInTbl = false;                    506   G4bool isFoundInTbl = false;
641   G4ProcessManager* manager = nullptr;         << 507   G4ProcessManager* manager =nullptr;
642   G4int idx;                                      508   G4int idx;
643   // loop over all elements                       509   // loop over all elements
644   for (auto itr=fProcTblVector->cbegin();         510   for (auto itr=fProcTblVector->cbegin();
645             itr!=fProcTblVector->cend(); ++itr << 511             itr!=fProcTblVector->cend(); ++itr, ++idxTbl) {
646   {                                            << 
647     anElement = (*itr);                           512     anElement = (*itr);
648     if ( anElement == nullptr ) continue;      << 513     if (process == anElement->GetProcess() ){
649     if (process == anElement->GetProcess() )   << 514       if (particle != nullptr) {
650     {                                          << 515   for (idx=0; idx<anElement->Length(); idx++){
651       if (particle != nullptr)                 << 516     manager = anElement->GetProcessManager(idx);
652       {                                        << 517     if (particle == manager->GetParticleType()) {
653         for (idx=0; idx<anElement->Length(); + << 518       isFoundInTbl = true;
654         {                                      << 519       break;
655           manager = anElement->GetProcessManag << 520     }
656           if (particle == manager->GetParticle << 521   }
657           {                                    << 522       } else {
658             isFoundInTbl = true;               << 523   isFoundInTbl = true;
659             break;                             << 
660           }                                    << 
661         }                                      << 
662       }                                        << 
663       else                                     << 
664       {                                        << 
665         isFoundInTbl = true;                   << 
666       }                                           524       }
667       break;                                      525       break;
668     }                                             526     }
669   }                                               527   }
670   if  (!isFoundInTbl ) return;                    528   if  (!isFoundInTbl ) return;
671                                                   529   
672   G4int tmpVerbose = process->GetVerboseLevel(    530   G4int tmpVerbose = process->GetVerboseLevel();
673   process->SetVerboseLevel(verboseLevel);         531   process->SetVerboseLevel(verboseLevel);
674   process->DumpInfo();                            532   process->DumpInfo();
675   process->SetVerboseLevel(tmpVerbose);           533   process->SetVerboseLevel(tmpVerbose);
676   if (particle == nullptr)                     << 534   if (particle == nullptr) {
677   {                                            << 535     for (idx=0; idx<anElement->Length(); idx++){
678     for (idx=0; idx<anElement->Length(); ++idx << 
679     {                                          << 
680       manager = anElement->GetProcessManager(i    536       manager = anElement->GetProcessManager(idx);
681       G4cout << " for " << manager->GetParticl    537       G4cout << " for " << manager->GetParticleType()->GetParticleName();
682       G4cout << G4endl;                           538       G4cout << G4endl;
683 #ifdef G4VERBOSE                                  539 #ifdef G4VERBOSE
684       if (verboseLevel >2)                     << 540       if (verboseLevel >2){
685       {                                        << 541   tmpVerbose = manager->GetVerboseLevel();
686         tmpVerbose = manager->GetVerboseLevel( << 542   manager->SetVerboseLevel(verboseLevel);
687         manager->SetVerboseLevel(verboseLevel) << 543   manager->DumpInfo();
688         manager->DumpInfo();                   << 544   manager->SetVerboseLevel(tmpVerbose);
689         manager->SetVerboseLevel(tmpVerbose);  << 
690       }                                           545       }
691 #endif                                            546 #endif
692     }                                             547     }
693   }                                            << 548   } else {
694   else                                         << 
695   {                                            << 
696     G4cout << " for " << manager->GetParticleT    549     G4cout << " for " << manager->GetParticleType()->GetParticleName();
697     G4cout << G4endl;                             550     G4cout << G4endl;
698 #ifdef G4VERBOSE                                  551 #ifdef G4VERBOSE
699     if (verboseLevel >2)                       << 552     if (verboseLevel >2){
700     {                                          << 
701       tmpVerbose = manager->GetVerboseLevel();    553       tmpVerbose = manager->GetVerboseLevel();
702       manager->SetVerboseLevel(verboseLevel);     554       manager->SetVerboseLevel(verboseLevel);
703       manager->DumpInfo();                        555       manager->DumpInfo();
704       manager->SetVerboseLevel(tmpVerbose);       556       manager->SetVerboseLevel(tmpVerbose);
705     }                                             557     }
706 #endif                                            558 #endif
707   }                                               559   }
708 }                                                 560 }
                                                   >> 561 
                                                   >> 562 
                                                   >> 563 
                                                   >> 564 
                                                   >> 565 
                                                   >> 566 
709                                                   567