Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/management/src/G4ProcessManager.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/G4ProcessManager.cc (Version 11.3.0) and /processes/management/src/G4ProcessManager.cc (Version 10.6.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 // G4ProcessManager implementation                 26 // G4ProcessManager implementation
 27 //                                                 27 //
 28 // Authors:                                    <<  28 // First implementation, based on object model of
 29 // - 02.12.1995, G.Cosmo - First implementatio <<  29 // 2nd December 1995, G.Cosmo
 30 // - 06.05.1996, G.Cosmo - Revised; added vect <<  30 // --------------------------------------------------------------------
 31 // - 08.01.1997, H.Kurashige - New Physics sch <<  31 // New Physics scheme - 08.01.1997, H.Kurahige
                                                   >>  32 // Use STL vector instead of RW vector - 01.03.2000, H.Kurashige
                                                   >>  33 // Add exception to check ordering paramters - 02.10.2007, H.Kurashige
 32 // -------------------------------------------     34 // --------------------------------------------------------------------
 33                                                    35 
 34 #include <iomanip>                                 36 #include <iomanip>
 35                                                    37 
 36 #include "G4ios.hh"                                38 #include "G4ios.hh"
 37 #include "G4ProcessManager.hh"                     39 #include "G4ProcessManager.hh"
 38 #include "G4ProcessManagerMessenger.hh"            40 #include "G4ProcessManagerMessenger.hh"
 39 #include "G4ProcessAttribute.hh"                   41 #include "G4ProcessAttribute.hh"
 40 #include "G4StateManager.hh"                       42 #include "G4StateManager.hh"
 41 #include "G4ProcessTable.hh"                       43 #include "G4ProcessTable.hh"
 42                                                    44 
 43 G4ThreadLocal G4ProcessManagerMessenger*       <<  45 // ---------------------------------
 44               G4ProcessManager::fProcessManage <<  46 //  function members implementation
 45 G4ThreadLocal G4int G4ProcessManager::counterO <<  47 // ---------------------------------
                                                   >>  48 G4ThreadLocal G4ProcessManagerMessenger* G4ProcessManager::fProcessManagerMessenger = 0;
                                                   >>  49 G4ThreadLocal G4int  G4ProcessManager::counterOfObjects = 0;
 46                                                    50 
 47 // ------------------------------------------- <<  51 // ///////////////////////////////////////
 48 G4ProcessManager::G4ProcessManager(const G4Par     52 G4ProcessManager::G4ProcessManager(const G4ParticleDefinition* aParticleType)
 49   : theParticleType(aParticleType)             <<  53   : theAttrVector(nullptr),
                                                   >>  54     theParticleType(aParticleType),
                                                   >>  55     numberOfProcesses(0),
                                                   >>  56     theProcessList(nullptr),
                                                   >>  57     duringTracking(false),     
                                                   >>  58     verboseLevel(1)
 50 {                                                  59 {
 51   // create the process List                       60   // create the process List
 52   theProcessList = new G4ProcessVector();          61   theProcessList = new G4ProcessVector();
 53   if ( theProcessList == nullptr)                  62   if ( theProcessList == nullptr)
 54   {                                                63   {
 55     G4Exception( "G4ProcessManager::G4ProcessM     64     G4Exception( "G4ProcessManager::G4ProcessManager()","ProcMan012",
 56                  FatalException, "Can not crea     65                  FatalException, "Can not create G4ProcessList ");
 57   }                                                66   }
 58                                                    67 
 59   // create process vector                     <<  68   //create process vector
 60   for (G4int i=0; i<SizeOfProcVectorArray; ++i     69   for (G4int i=0; i<SizeOfProcVectorArray; ++i)
 61   {                                                70   {
 62     theProcVector[i] = new G4ProcessVector();      71     theProcVector[i] = new G4ProcessVector();
 63     if ( theProcVector[i] == nullptr)              72     if ( theProcVector[i] == nullptr)
 64     {                                              73     {
 65       G4Exception( "G4ProcessManager::G4Proces     74       G4Exception( "G4ProcessManager::G4ProcessManager()","ProcMan012",
 66                    FatalException, "Can not cr     75                    FatalException, "Can not create G4ProcessVector ");
 67     }                                              76     }
 68   }                                                77   }
 69                                                    78 
 70   // create Process Attribute vector               79   // create Process Attribute vector
 71   theAttrVector = new G4ProcessAttrVector();       80   theAttrVector = new G4ProcessAttrVector();
 72                                                    81 
 73   // create Process Manager Messenger              82   // create Process Manager Messenger
 74   if (fProcessManagerMessenger == nullptr)         83   if (fProcessManagerMessenger == nullptr)
 75   {                                                84   {
 76     fProcessManagerMessenger = new G4ProcessMa     85     fProcessManagerMessenger = new G4ProcessManagerMessenger();
 77   }                                                86   }
 78                                                    87 
 79   for (G4int i=0; i<NDoit; ++i)                    88   for (G4int i=0; i<NDoit; ++i)
 80   {                                                89   {
 81     isSetOrderingFirstInvoked[i] = false;      <<  90     isSetOrderingFirstInvoked[i]=false;
 82     isSetOrderingLastInvoked[i] = false;       <<  91     isSetOrderingLastInvoked[i]=false;
 83   }                                                92   }
 84                                                    93 
 85   // Increment counter of G4ProcessManager obj     94   // Increment counter of G4ProcessManager objects
 86   ++counterOfObjects;                          <<  95   counterOfObjects+=1; 
 87 }                                                  96 }
 88                                                    97 
 89 // ------------------------------------------- <<  98 // ///////////////////////////////////////
 90 G4ProcessManager::G4ProcessManager(G4ProcessMa     99 G4ProcessManager::G4ProcessManager(G4ProcessManager& right)
 91   : theParticleType(right.theParticleType),    << 100   : theAttrVector(nullptr),
                                                   >> 101     theParticleType(right.theParticleType),
                                                   >> 102     numberOfProcesses(0),
                                                   >> 103     theProcessList(nullptr),
                                                   >> 104     duringTracking(false),
 92     verboseLevel(right.verboseLevel)              105     verboseLevel(right.verboseLevel)
 93 {                                                 106 {
 94 #ifdef G4VERBOSE                                  107 #ifdef G4VERBOSE
 95    if (GetVerboseLevel() > 2)                     108    if (GetVerboseLevel() > 2)
 96    {                                              109    {
 97      G4cout << "G4ProcessManager::G4ProcessMan << 110      G4cout <<  "G4ProcessManageer:: copy constructor " <<G4endl; 
 98             << G4endl;                         << 
 99    }                                              111    }
100 #endif                                            112 #endif
101                                                   113 
102    // create the process List and ProcessAttr     114    // create the process List and ProcessAttr Vector
103    theProcessList = new G4ProcessVector();        115    theProcessList = new G4ProcessVector();
104    theAttrVector = new G4ProcessAttrVector();     116    theAttrVector = new G4ProcessAttrVector();
105    if ( ( theProcessList == nullptr) || (theAt    117    if ( ( theProcessList == nullptr) || (theAttrVector == nullptr) )
106    {                                              118    {
107      G4Exception( "G4ProcessManager::G4Process << 119      G4Exception( "G4ProcessManager::G4ProcessManager() [coopy constructor]",
108                   "ProcMan011",FatalException, << 120                   "ProcMan011",FatalException, "Can not create G4ProcessList ");
109    }                                              121    }
110                                                   122 
111    for (G4int idx=0; idx < right.numberOfProce    123    for (G4int idx=0; idx < right.numberOfProcesses; ++idx)
112    {                                              124    {
113      // copy contents in theProcessList           125      // copy contents in theProcessList
114      theProcessList->insert((*right.theProcess    126      theProcessList->insert((*right.theProcessList)[idx]);
115      // create a G4ProcessAttribute same as so    127      // create a G4ProcessAttribute same as source's one
116      G4ProcessAttribute* sAttr = (*right.theAt    128      G4ProcessAttribute* sAttr = (*right.theAttrVector)[idx];
117      G4ProcessAttribute* dAttr = new G4Process    129      G4ProcessAttribute* dAttr = new G4ProcessAttribute(*sAttr);
118      // adds  a G4ProcessAttribute object         130      // adds  a G4ProcessAttribute object
119      theAttrVector->push_back(dAttr);             131      theAttrVector->push_back(dAttr);
120      ++numberOfProcesses;                      << 132      numberOfProcesses +=1;
121    }                                              133    }
122                                                   134   
123    // fill up theProcVector                       135    // fill up theProcVector
124    for (G4int i=0; i<SizeOfProcVectorArray; ++    136    for (G4int i=0; i<SizeOfProcVectorArray; ++i)
125    {                                              137    {
126      // create i-th ProcessVector in theProcVe    138      // create i-th ProcessVector in theProcVector
127      theProcVector[i] = new G4ProcessVector();    139      theProcVector[i] = new G4ProcessVector();
128      if ( theProcVector[i] == nullptr )           140      if ( theProcVector[i] == nullptr )
129      {                                            141      {
130        G4Exception("G4ProcessManager::G4Proces << 142        G4Exception("G4ProcessManager::G4ProcessManager() [coopy constructor]",
131                   "ProcMan011",FatalException, << 143                    "ProcMan011",FatalException, "Can not create G4ProcessVector ");
132      }                                            144      }
133                                                   145 
134      G4ProcessTable* theProcessTable = G4Proce    146      G4ProcessTable* theProcessTable = G4ProcessTable::GetProcessTable();
135      G4ProcessVector* src = right.theProcVecto    147      G4ProcessVector* src = right.theProcVector[i];
136      for (G4int j=0; j< (G4int)src->entries()  << 148      for (std::size_t j=0; j< src->entries() ; ++j)
137      {                                            149      {
138        // copy j-th process in i-th ProcessVec    150        // copy j-th process in i-th ProcessVector 
139        theProcVector[i]->insert((*src)[j]);       151        theProcVector[i]->insert((*src)[j]);
140        //add aProcess and this ProcessManager     152        //add aProcess and this ProcessManager into ProcesssTable 
141        if (  (*src)[j] != nullptr )               153        if (  (*src)[j] != nullptr )
142        {                                          154        {
143          theProcessTable->Insert((*src)[j], th    155          theProcessTable->Insert((*src)[j], this);
144        }                                          156        }
145      }                                            157      }
146    }                                              158    }
147                                                   159 
148    for (G4int i=0; i<NDoit; ++i)                  160    for (G4int i=0; i<NDoit; ++i)
149    {                                              161    {
150      isSetOrderingFirstInvoked[i]= right.isSet    162      isSetOrderingFirstInvoked[i]= right.isSetOrderingFirstInvoked[i];
151      isSetOrderingLastInvoked[i] = right.isSet    163      isSetOrderingLastInvoked[i] = right.isSetOrderingLastInvoked[i];
152    }                                              164    }
153                                                   165 
154    // Increment counter of G4ProcessManager ob    166    // Increment counter of G4ProcessManager objects
155    ++counterOfObjects;                         << 167    counterOfObjects+=1; 
156 }                                                 168 }
157                                                   169 
158 // ------------------------------------------- << 170 // ///////////////////////////////////////
                                                   >> 171 G4ProcessManager::G4ProcessManager()
                                                   >> 172   : theAttrVector(nullptr),
                                                   >> 173     theParticleType(nullptr),
                                                   >> 174     numberOfProcesses(0),
                                                   >> 175     theProcessList(nullptr),
                                                   >> 176     duringTracking(false),
                                                   >> 177     verboseLevel(1)
                                                   >> 178 {
                                                   >> 179   // clear the process List and ProcessAttr Vector
                                                   >> 180   G4Exception("G4ProcessManager::G4ProcessManager()","ProcMan111",
                                                   >> 181               JustWarning,"Default constructor is called");
                                                   >> 182 
                                                   >> 183   //create process vector
                                                   >> 184   for (G4int i=0; i<SizeOfProcVectorArray; ++i)
                                                   >> 185   {
                                                   >> 186     theProcVector[i] = nullptr;
                                                   >> 187   }
                                                   >> 188 
                                                   >> 189   for (G4int i=0; i<NDoit; ++i)
                                                   >> 190   {
                                                   >> 191     isSetOrderingFirstInvoked[i]=false;
                                                   >> 192     isSetOrderingLastInvoked[i]=false;
                                                   >> 193   }
                                                   >> 194 }
                                                   >> 195 
                                                   >> 196 // ///////////////////////////////////////
                                                   >> 197 G4ProcessManager & G4ProcessManager::operator=(const G4ProcessManager &)
                                                   >> 198 {
                                                   >> 199   G4Exception("G4ProcessManager::operator=","ProcMan112",
                                                   >> 200               JustWarning,"Assignment operator is called");
                                                   >> 201   return *this;
                                                   >> 202 }
                                                   >> 203 
                                                   >> 204 // ///////////////////////////////////////
159 G4ProcessManager::~G4ProcessManager()             205 G4ProcessManager::~G4ProcessManager()
160 {                                                 206 {
161   for (G4int i=0; i<SizeOfProcVectorArray; ++i    207   for (G4int i=0; i<SizeOfProcVectorArray; ++i)
162   {                                               208   {
163     if (theProcVector[i])                         209     if (theProcVector[i])
164     {                                             210     {
165       theProcVector[i]->clear();                  211       theProcVector[i]->clear();
166       delete theProcVector[i];                    212       delete theProcVector[i];
167     }                                             213     }
168   }                                               214   }
169   theProcessList->clear();                        215   theProcessList->clear();
170   delete theProcessList;                          216   delete theProcessList;
171                                                   217 
172   for (auto itr = theAttrVector->cbegin(); itr << 218   for (auto itr = theAttrVector->begin(); itr!= theAttrVector->end(); ++itr)
173   {                                               219   {
174     delete (*itr);                                220     delete (*itr);
175   }                                               221   }
176   theAttrVector->clear();                         222   theAttrVector->clear();
177   delete theAttrVector;                        << 223   delete  theAttrVector;
178                                                   224 
179   --counterOfObjects;                          << 225   counterOfObjects-=1; 
180                                                   226 
181   // delete messenger if this object is last o    227   // delete messenger if this object is last one
182   if ( counterOfObjects == 0 )                    228   if ( counterOfObjects == 0 )
183   {                                               229   {
184     delete fProcessManagerMessenger;           << 230     if (fProcessManagerMessenger != nullptr)
185     fProcessManagerMessenger = nullptr;        << 
186 #ifdef G4VERBOSE                               << 
187     if (GetVerboseLevel() > 1)                 << 
188     {                                             231     {
189       G4cout << "G4ProcessManagerMessenger is  << 232       delete fProcessManagerMessenger;
190     }                                          << 233       fProcessManagerMessenger = nullptr;
                                                   >> 234 #ifdef G4VERBOSE
                                                   >> 235       if (GetVerboseLevel() > 1)
                                                   >> 236       {
                                                   >> 237         G4cout << "G4ProcessManagerMessenger is deleted" << G4endl;
                                                   >> 238       } 
191 #endif                                            239 #endif
                                                   >> 240     }
192   }                                               241   }
193 }                                                 242 }
194                                                   243 
195 // ------------------------------------------- << 244 ////////////////////////////////////////////////////////////////
196 G4int G4ProcessManager::GetProcessVectorIndex(    245 G4int G4ProcessManager::GetProcessVectorIndex(
197                            G4VProcess* aProces    246                            G4VProcess* aProcess,
198                            G4ProcessVectorDoIt    247                            G4ProcessVectorDoItIndex idx,
199                            G4ProcessVectorType    248                            G4ProcessVectorTypeIndex typ
200                            ) const                249                            ) const
201 {                                                 250 {
202   G4int idxVect = -1;                          << 251   G4int idxVect =  -1;
203   G4int idxProc = GetProcessIndex(aProcess);      252   G4int idxProc = GetProcessIndex(aProcess); 
204   G4int ivec = GetProcessVectorId(idx, typ);      253   G4int ivec = GetProcessVectorId(idx, typ);
205                                                   254 
206   if ( ( idxProc >=0) && (ivec >=0) )             255   if ( ( idxProc >=0) && (ivec >=0) )
207   {                                               256   {
208     idxVect = GetAttribute(idxProc)->idxProcVe << 257     idxVect =  GetAttribute(idxProc)->idxProcVector[ivec];
209   }                                               258   }
210   else                                            259   else
211   {                                               260   {
212 #ifdef G4VERBOSE                                  261 #ifdef G4VERBOSE
213     if (verboseLevel>0)                           262     if (verboseLevel>0)
214     {                                             263     {
215       G4cout << " G4ProcessManager::GetProcess    264       G4cout << " G4ProcessManager::GetProcessVectorIndex:";
216       G4cout << "particle[" << theParticleType    265       G4cout << "particle[" << theParticleType->GetParticleName() << "] " ;
217       G4cout <<  "process[" << aProcess->GetPr    266       G4cout <<  "process[" << aProcess->GetProcessName() << "]" ;
218       G4cout << G4endl;                           267       G4cout << G4endl;
219       if (idxProc <0)                             268       if (idxProc <0)
220       {                                           269       { 
221         G4cout << " is not registered yet ";      270         G4cout << " is not registered yet ";
222       }                                           271       }
223       if (ivec <0)                                272       if (ivec <0)
224       {                                           273       {
225         G4cout << " illegal DoIt Index [= " <<    274         G4cout << " illegal DoIt Index [= " << G4int(idx) << ","
226                                             <<    275                                             << G4int(typ) << "]";
227       }                                           276       }
228       G4cout << G4endl;                           277       G4cout << G4endl;
229     }                                             278     }
230 #endif                                            279 #endif
231   }                                               280   }
232   return idxVect;                                 281   return idxVect;
233 }                                                 282 }
234                                                   283 
235 // ------------------------------------------- << 284 /////////////////////////////////////////
236 G4ProcessAttribute* G4ProcessManager::GetAttri    285 G4ProcessAttribute* G4ProcessManager::GetAttribute(G4int index) const
237 {                                                 286 {
238   // check index range                            287   // check index range
239   if ((index<0) || (index>=numberOfProcesses))    288   if ((index<0) || (index>=numberOfProcesses))
240   {                                               289   {
241 #ifdef G4VERBOSE                                  290 #ifdef G4VERBOSE
242     if (GetVerboseLevel()>0)                      291     if (GetVerboseLevel()>0)
243     {                                             292     {
244       G4cout << "G4ProcessManager::GetAttribut    293       G4cout << "G4ProcessManager::GetAttribute():";
245       G4cout << " particle[" << theParticleTyp    294       G4cout << " particle[" << theParticleType->GetParticleName() << "]";
246       G4cout << G4endl;                           295       G4cout << G4endl;
247       G4cout << "  index out of range " << G4e    296       G4cout << "  index out of range " << G4endl;
248       G4cout << "  #processes[" << numberOfPro    297       G4cout << "  #processes[" << numberOfProcesses << "]"; 
249       G4cout << "  index [" << index << "]" <<    298       G4cout << "  index [" << index << "]" << G4endl;
250     }                                             299     }
251 #endif                                            300 #endif
252     return nullptr;                               301     return nullptr;
253   }                                               302   } 
254                                                   303 
255   // check process pointer is not null            304   // check process pointer is not null
256   G4VProcess* aProcess = (*theProcessList)[ind    305   G4VProcess* aProcess = (*theProcessList)[index];
257   if (aProcess == nullptr)                        306   if (aProcess == nullptr)
258   {                                               307   {
259     G4String aErrorMessage("Bad ProcessList: N << 308     G4String aErrorMessage("Bad ProcessList:  Null Pointer for");
260     aErrorMessage += theParticleType->GetParti    309     aErrorMessage += theParticleType->GetParticleName() ;
261     G4Exception("G4ProcessManager::GetAttribut    310     G4Exception("G4ProcessManager::GetAttribute()","ProcMan012",
262                 FatalException, aErrorMessage) << 311                 FatalException,aErrorMessage);
263     return nullptr;                               312     return nullptr;
264   }                                               313   }    
265                                                   314 
266   // find the process attribute                << 315   //find the process attribute
267   if ( ((*theAttrVector)[index])->idxProcessLi    316   if ( ((*theAttrVector)[index])->idxProcessList == index )
268   {                                               317   {
269     return  (*theAttrVector)[index];              318     return  (*theAttrVector)[index];
270   }                                               319   }
271   else                                            320   else
272   {                                               321   { 
273     // !! Error !!                                322     // !! Error !!
274     // attribute vector index is inconsistent     323     // attribute vector index is inconsistent with process List index
275 #ifdef G4VERBOSE                                  324 #ifdef G4VERBOSE
276    if (GetVerboseLevel()>0)                       325    if (GetVerboseLevel()>0)
277    {                                              326    { 
278       G4cout << "G4ProcessManager::GetAttribut    327       G4cout << "G4ProcessManager::GetAttribute():";
279       G4cout << " particle[" << theParticleTyp    328       G4cout << " particle[" << theParticleType->GetParticleName() << "]"
280              << G4endl;                           329              << G4endl;
281       G4cout << "Warning: attribute vector ind << 330       G4cout << "Warning: attribute vector index is inconsistent with process List index" 
282              << " with process List index"     << 
283              << G4endl;                           331              << G4endl; 
284    }                                              332    }
285 #endif                                            333 #endif
286    // re-ordering attribute vector                334    // re-ordering attribute vector 
287     G4ProcessAttribute* pAttr = nullptr;       << 335     G4ProcessAttribute *pAttr = nullptr;
288     for (auto itr = theAttrVector->cbegin(); i    336     for (auto itr = theAttrVector->cbegin(); itr!= theAttrVector->cend(); ++itr)
289     {                                             337     {
290       if ( (*itr)->idxProcessList == index)       338       if ( (*itr)->idxProcessList == index)
291       {                                           339       {
292         pAttr = (*itr);                           340         pAttr = (*itr);
293         break;                                    341         break;
294       }                                           342       }
295     }                                             343     }      
296     return pAttr;                                 344     return pAttr;
297   }                                               345   } 
298 }                                                 346 }
299                                                   347 
300 // ------------------------------------------- << 348 // ///////////////////////////////////////
301 G4ProcessAttribute * G4ProcessManager::GetAttr << 349 G4ProcessAttribute * G4ProcessManager::GetAttribute(G4VProcess *aProcess) const
302 {                                                 350 {
303   return GetAttribute( GetProcessIndex(aProces    351   return GetAttribute( GetProcessIndex(aProcess));
304 }                                                 352 }
305                                                   353 
306 // ------------------------------------------- << 354 // ///////////////////////////////////////
307 G4int G4ProcessManager::InsertAt(G4int ip, G4V    355 G4int G4ProcessManager::InsertAt(G4int ip, G4VProcess* process, G4int ivec)
308 {                                                 356 {
309   G4ProcessVector* pVector = theProcVector[ive    357   G4ProcessVector* pVector = theProcVector[ivec];
310   // check position                               358   // check position
311   if ( (ip<0) || (ip > G4int(pVector->entries(    359   if ( (ip<0) || (ip > G4int(pVector->entries())) ) return -1;
312                                                   360   
313   // insert in pVector                            361   // insert in pVector
314   pVector->insertAt(ip, process);                 362   pVector->insertAt(ip, process);
315                                                   363 
316   // correct index in ProcessAttributes of pro << 364   //correct index in ProcessAttributes of processes
317   for (G4int iproc=0; iproc<numberOfProcesses;    365   for (G4int iproc=0; iproc<numberOfProcesses; ++iproc)
318   {                                               366   {
319     G4ProcessAttribute* aAttr = (*theAttrVecto    367     G4ProcessAttribute* aAttr = (*theAttrVector)[iproc];
320     if (aAttr != nullptr)                         368     if (aAttr != nullptr)
321     {                                             369     {
322       if (aAttr->idxProcVector[ivec] >= ip)       370       if (aAttr->idxProcVector[ivec] >= ip)
323       {                                           371       {
324         aAttr->idxProcVector[ivec] += 1;          372         aAttr->idxProcVector[ivec] += 1;
325       }                                           373       }
326     }                                             374     }
327     else                                          375     else
328     {                                             376     {
329 #ifdef G4VERBOSE                                  377 #ifdef G4VERBOSE
330       if (GetVerboseLevel()>0)                    378       if (GetVerboseLevel()>0)
331       {                                           379       { 
332         G4cout << " G4ProcessManager::InsertAt    380         G4cout << " G4ProcessManager::InsertAt : No Process Attribute "
333                << G4endl;                         381                << G4endl;
334       }                                           382       }
335 #endif                                            383 #endif
336     }                                             384     }
337   }                                               385   }
338   return ip;                                      386   return ip;
339 }                                                 387 }
340                                                   388 
341 // ------------------------------------------- << 389 // ///////////////////////////////////////
342 G4int G4ProcessManager::RemoveAt(G4int ip, G4V << 390 G4int G4ProcessManager::RemoveAt(G4int ip, G4VProcess* , G4int ivec)
343 {                                                 391 {
344   G4ProcessVector* pVector = theProcVector[ive    392   G4ProcessVector* pVector = theProcVector[ivec];
345                                                << 
346   // check position                               393   // check position
347   if ( (ip<0) || (ip >= G4int(pVector->entries    394   if ( (ip<0) || (ip >= G4int(pVector->entries())) ) return -1;
348                                                   395 
349   // remove process                               396   // remove process
350   pVector->removeAt(ip);                          397   pVector->removeAt(ip);
351                                                   398 
352   // correct index                                399   // correct index
353   for(G4int iproc=0; iproc<numberOfProcesses;     400   for(G4int iproc=0; iproc<numberOfProcesses; ++iproc)
354   {                                               401   {
355     G4ProcessAttribute* aAttr = (*theAttrVecto    402     G4ProcessAttribute* aAttr = (*theAttrVector)[iproc];
356     if (aAttr != nullptr)                         403     if (aAttr != nullptr)
357     {                                             404     {
358       if (ip < aAttr->idxProcVector[ivec])        405       if (ip < aAttr->idxProcVector[ivec])
359       {                                           406       {
360         aAttr->idxProcVector[ivec] -=1;           407         aAttr->idxProcVector[ivec] -=1;
361       }                                           408       }
362       else if (ip ==  aAttr->idxProcVector[ive    409       else if (ip ==  aAttr->idxProcVector[ivec])
363       {                                           410       {
364         aAttr->idxProcVector[ivec] = -1;          411         aAttr->idxProcVector[ivec] = -1;
365         aAttr->ordProcVector[ivec] = ordInActi    412         aAttr->ordProcVector[ivec] = ordInActive;
366       }                                           413       }
367     }                                             414     }
368     else                                          415     else
369     {                                             416     {
370 #ifdef G4VERBOSE                                  417 #ifdef G4VERBOSE
371       if (GetVerboseLevel()>0)                    418       if (GetVerboseLevel()>0)
372       {                                           419       { 
373         G4cout << " G4ProcessManager::RemoveAt << 420         G4cout << " G4ProcessManager::RemoveAt : No Process Attribute "
374                << G4endl;                         421                << G4endl;
375       }                                           422       }
376 #endif                                            423 #endif
377     }                                             424     }
378   }                                               425   } 
379   return ip;                                      426   return ip;
380 }                                                 427 }
381                                                   428 
382 // ------------------------------------------- << 429 // ///////////////////////////////////////
383 G4int G4ProcessManager::FindInsertPosition(G4i    430 G4int G4ProcessManager::FindInsertPosition(G4int ord, G4int ivec)
384 {                                                 431 {
385   G4ProcessVector* pVector = theProcVector[ive    432   G4ProcessVector* pVector = theProcVector[ivec];
386   G4int ip = (G4int)pVector->entries();        << 433   G4int ip =  pVector->entries();
387   G4int tmp = INT_MAX;                            434   G4int tmp = INT_MAX;
388   if (ord == ordLast) return ip;                  435   if (ord == ordLast) return ip;
389                                                   436 
390   // find insert position                         437   // find insert position
391   for (G4int iproc=0; iproc<numberOfProcesses;    438   for (G4int iproc=0; iproc<numberOfProcesses; ++iproc)
392   {                                               439   {
393     G4ProcessAttribute* aAttr = (*theAttrVecto    440     G4ProcessAttribute* aAttr = (*theAttrVector)[iproc];
394     if ( (aAttr->ordProcVector[ivec] > ord )      441     if ( (aAttr->ordProcVector[ivec] > ord )
395       && (tmp > aAttr->ordProcVector[ivec]))      442       && (tmp > aAttr->ordProcVector[ivec]))
396     {                                             443     {
397       tmp = aAttr->ordProcVector[ivec] ;          444       tmp = aAttr->ordProcVector[ivec] ;
398       if (ip > aAttr->idxProcVector[ivec]) ip     445       if (ip > aAttr->idxProcVector[ivec]) ip = aAttr->idxProcVector[ivec];
399     }                                             446     }
400   }                                               447   }
401   return ip;                                      448   return ip;
402 }                                                 449 }
403                                                   450 
404 // ------------------------------------------- << 451 // ///////////////////////////////////////
405 G4int G4ProcessManager::AddProcess(               452 G4int G4ProcessManager::AddProcess(
406                  G4VProcess* aProcess,         << 453                  G4VProcess *aProcess,
407                  G4int      ordAtRestDoIt,        454                  G4int      ordAtRestDoIt,
408                  G4int      ordAlongStepDoIt,     455                  G4int      ordAlongStepDoIt,
409                  G4int      ordPostStepDoIt       456                  G4int      ordPostStepDoIt 
410                 )                                 457                 )
411 {                                              << 458 { 
412   // check the process is applicable to this p << 459    
                                                   >> 460   //check the process is applicable to this particle type
413   if (  !aProcess->IsApplicable(*theParticleTy    461   if (  !aProcess->IsApplicable(*theParticleType) )
414   {                                               462   {
415 #ifdef G4VERBOSE                                  463 #ifdef G4VERBOSE
416     if (GetVerboseLevel()>1)                      464     if (GetVerboseLevel()>1)
417     {                                             465     {
418       G4cout << "G4ProcessManager::AddProcess(    466       G4cout << "G4ProcessManager::AddProcess()" << G4endl;
419       G4cout << "This process is not applicabl    467       G4cout << "This process is not applicable to this particle" << G4endl;
420     }                                             468     }
421 #endif                                            469 #endif
422     return -1;                                    470     return -1;
423   }                                               471   }
424                                                   472 
425 #ifdef G4VERBOSE                                  473 #ifdef G4VERBOSE
426   if (GetVerboseLevel()>2)                        474   if (GetVerboseLevel()>2)
427   {                                               475   {
428     G4cout << "G4ProcessManager::AddProcess()"    476     G4cout << "G4ProcessManager::AddProcess()" << G4endl;
429   }                                               477   }
430 #endif                                            478 #endif
431                                                   479 
432   // add aProcess and this ProcessManager into << 480   //add aProcess and this ProcessManager into ProcesssTable
433   G4ProcessTable* theProcessTable = G4ProcessT    481   G4ProcessTable* theProcessTable = G4ProcessTable::GetProcessTable();
434   theProcessTable->Insert(aProcess, this);        482   theProcessTable->Insert(aProcess, this);
435                                                   483 
436   // add aProcess to process List              << 484   //add aProcess to process List
437   theProcessList->insert(aProcess);               485   theProcessList->insert(aProcess);  
438   G4int idx = G4int(theProcessList->entries()  << 486   G4int idx = (theProcessList->entries()) - 1;
439                                                   487 
440   // check size of the ProcessVector[0]           488   // check size of the ProcessVector[0]
441   if (numberOfProcesses != idx)                   489   if (numberOfProcesses != idx)
442   {                                               490   {
443     theProcessList->removeLast();                 491     theProcessList->removeLast();
444     G4String anErrorMessage("Inconsistent proc << 492     G4String anErrorMessage("Bad ProcessList: Inconsistent process List size for ");
445     anErrorMessage += "process[" + aProcess->G    493     anErrorMessage += "process[" + aProcess->GetProcessName() + "]";
446     anErrorMessage += " particle[" + thePartic    494     anErrorMessage += " particle[" + theParticleType->GetParticleName() + "]";
447     G4Exception("G4ProcessManager::AddProcess( << 495     G4Exception( "G4ProcessManager::AddProcess()","ProcMan012",
448                 FatalException, anErrorMessage << 496                  FatalException,anErrorMessage);
449     return -1;                                    497     return -1;
450   }                                               498   }
451                                                   499 
452   // create ProcessAttribute                      500   // create ProcessAttribute
453   G4ProcessAttribute* pAttr = new G4ProcessAtt    501   G4ProcessAttribute* pAttr = new G4ProcessAttribute(aProcess);
454   pAttr->idxProcessList = idx;                    502   pAttr->idxProcessList = idx;
455                                                   503 
456   // check if ordering parameter is non-zero      504   // check if ordering parameter is non-zero
457   if (ordAtRestDoIt==0)    ordAtRestDoIt    =     505   if (ordAtRestDoIt==0)    ordAtRestDoIt    = 1;
458   if (ordAlongStepDoIt==0) ordAlongStepDoIt =     506   if (ordAlongStepDoIt==0) ordAlongStepDoIt = 1;
459   if (ordPostStepDoIt==0)  ordPostStepDoIt  =     507   if (ordPostStepDoIt==0)  ordPostStepDoIt  = 1;
460                                                   508 
461   // ordering parameter                           509   // ordering parameter
462   pAttr->ordProcVector[0] = ordAtRestDoIt;        510   pAttr->ordProcVector[0] = ordAtRestDoIt;
463   pAttr->ordProcVector[1] = ordAtRestDoIt;        511   pAttr->ordProcVector[1] = ordAtRestDoIt;
464   pAttr->ordProcVector[2] = ordAlongStepDoIt;     512   pAttr->ordProcVector[2] = ordAlongStepDoIt;
465   pAttr->ordProcVector[3] = ordAlongStepDoIt;     513   pAttr->ordProcVector[3] = ordAlongStepDoIt;
466   pAttr->ordProcVector[4] = ordPostStepDoIt;      514   pAttr->ordProcVector[4] = ordPostStepDoIt;
467   pAttr->ordProcVector[5] = ordPostStepDoIt;      515   pAttr->ordProcVector[5] = ordPostStepDoIt;
468                                                   516  
469   // add aProccess in Process vectors             517   // add aProccess in Process vectors
470   for (G4int ivec=1; ivec<SizeOfProcVectorArra    518   for (G4int ivec=1; ivec<SizeOfProcVectorArray; ivec+=2)
471   {                                               519   {
472     if (pAttr->ordProcVector[ivec] < 0 )          520     if (pAttr->ordProcVector[ivec] < 0 )
473     {                                             521     {
474       // DoIt is inactive if ordering paramete    522       // DoIt is inactive if ordering parameter is negative
475       pAttr->idxProcVector[ivec] = -1;            523       pAttr->idxProcVector[ivec] = -1;
                                                   >> 524 
476     }                                             525     }
477     else                                          526     else
478     {                                             527     {
479       // add aProcess in ordering of ordProcVe << 528       //add aProcess in ordering of ordProcVector
480       // G4ProcessVector* pVector = theProcVec    529       // G4ProcessVector* pVector = theProcVector[ivec];
481       // find insert position                     530       // find insert position
482       G4int ip = FindInsertPosition(pAttr->ord    531       G4int ip = FindInsertPosition(pAttr->ordProcVector[ivec], ivec);
483       // insert                                   532       // insert 
484       InsertAt(ip, aProcess, ivec);               533       InsertAt(ip, aProcess, ivec);
485       // set index in Process Attribute           534       // set index in Process Attribute
486       pAttr->idxProcVector[ivec] = ip;            535       pAttr->idxProcVector[ivec] = ip;
487                                                   536 
488 #ifdef G4VERBOSE                                  537 #ifdef G4VERBOSE
489       if (verboseLevel>2)                         538       if (verboseLevel>2)
490       {                                           539       {
491         G4cout << "G4ProcessManager::AddProces    540         G4cout << "G4ProcessManager::AddProcess()" << G4endl;
492         G4cout << aProcess->GetProcessName() <    541         G4cout << aProcess->GetProcessName() << " is inserted at "<< ip;
493         G4cout << " in ProcessVetor[" << ivec<    542         G4cout << " in ProcessVetor[" << ivec<< "]";
494         G4cout << " with Ordering parameter =     543         G4cout << " with Ordering parameter = " ;
495         G4cout <<  pAttr->ordProcVector[ivec]     544         G4cout <<  pAttr->ordProcVector[ivec]  << G4endl;
496       }                                           545       }
497 #endif                                            546 #endif
498     }                                             547     }
499   }                                               548   }
500                                                   549 
501   // add ProcessAttribute to ProcessAttrVector << 550   //add ProcessAttribute to ProcessAttrVector
502   theAttrVector->push_back(pAttr);                551   theAttrVector->push_back(pAttr);
503                                                   552 
504   numberOfProcesses += 1;                         553   numberOfProcesses += 1;
505                                                   554 
506   // check consistencies between ordering para << 555  // check consistencies between ordering parameters and process 
507   CheckOrderingParameters(aProcess);              556   CheckOrderingParameters(aProcess);
508                                                   557 
509   CreateGPILvectors();                            558   CreateGPILvectors();
510                                                   559 
511   // inform process manager pointer to the pro    560   // inform process manager pointer to the process 
512   aProcess->SetProcessManager(this);              561   aProcess->SetProcessManager(this);
513                                                   562 
514   return idx;                                     563   return idx;
515 }                                                 564 }
516                                                   565 
517 // ------------------------------------------- << 566 
                                                   >> 567 // ///////////////////////////////////////
518 G4VProcess* G4ProcessManager::RemoveProcess(G4    568 G4VProcess* G4ProcessManager::RemoveProcess(G4int index)
519 {                                                 569 {
520   //find the process attribute                    570   //find the process attribute
521   G4ProcessAttribute* pAttr = GetAttribute(ind    571   G4ProcessAttribute* pAttr = GetAttribute(index);
522   if (pAttr == nullptr) return nullptr;           572   if (pAttr == nullptr) return nullptr;
523                                                   573 
524   // remove process                               574   // remove process
525   G4VProcess* removedProcess = (*theProcessLis    575   G4VProcess* removedProcess = (*theProcessList)[index];
526                                                   576 
527   if (!(pAttr->isActive)) { ActivateProcess(in    577   if (!(pAttr->isActive)) { ActivateProcess(index);}
528   // remove process from vectors if the proces    578   // remove process from vectors if the process is active
529   for (G4int ivec=0; ivec<SizeOfProcVectorArra    579   for (G4int ivec=0; ivec<SizeOfProcVectorArray; ++ivec)
530   {                                               580   {
531     G4ProcessVector* pVector = theProcVector[i    581     G4ProcessVector* pVector = theProcVector[ivec];
532     G4int idx = pAttr->idxProcVector[ivec];       582     G4int idx = pAttr->idxProcVector[ivec];
533     if ((idx >= 0) && (idx < G4int(pVector->en    583     if ((idx >= 0) && (idx < G4int(pVector->entries())))
534     {                                             584     {
535       // remove                                << 585       //remove
536       if (RemoveAt(idx, removedProcess, ivec)     586       if (RemoveAt(idx, removedProcess, ivec) <0)
537       {                                           587       {
538         G4String anErrorMessage("Bad index in     588         G4String anErrorMessage("Bad index in attribute");
539         anErrorMessage += "for particle["      << 589         anErrorMessage += "for particle[" + theParticleType->GetParticleName() + "] ";
540                           + theParticleType->G << 590         anErrorMessage += "process[" + removedProcess->GetProcessName() + "]  " ;
541         anErrorMessage += "process["           << 
542                           + removedProcess->Ge << 
543         G4Exception( "G4ProcessManager::Remove    591         G4Exception( "G4ProcessManager::RemoveProcess()","Fatal Error",
544                      FatalException,anErrorMes    592                      FatalException,anErrorMessage); 
545         return nullptr;                           593         return nullptr;
546       }                                           594       }    
547     }                                             595     }
548     else if (idx<0)                               596     else if (idx<0)
549     {                                             597     {
550       // corresponding DoIt is not active         598       // corresponding DoIt is not active  
551     }                                             599     } 
552     else                                          600     else
553     {                                             601     {
554       // idx is out of range                      602       // idx is out of range
555       G4String anErrorMessage("Bad ProcessList << 603       G4String anErrorMessage("Bad ProcessList : Index is out of range ");
556       anErrorMessage += "for particle[" + theP    604       anErrorMessage += "for particle[" + theParticleType->GetParticleName() + "] ";
557       anErrorMessage += "process[" + removedPr    605       anErrorMessage += "process[" + removedProcess->GetProcessName() + "]  " ;
558       G4Exception( "G4ProcessManager::RemovePr    606       G4Exception( "G4ProcessManager::RemoveProcess()","ProcMan012",
559                    FatalException,anErrorMessa    607                    FatalException,anErrorMessage); 
560       return nullptr;                             608       return nullptr;
561     }                                             609     }
562   }                                               610   }
563   pAttr->isActive = false;                        611   pAttr->isActive = false;
564   // remove from the process List and delete t    612   // remove from the process List and delete the attribute
565   theProcessList->removeAt(index);                613   theProcessList->removeAt(index);
566   for (auto itr = theAttrVector->cbegin(); itr << 614   for (auto itr = theAttrVector->begin(); itr!= theAttrVector->end(); ++itr)
567   {                                               615   {
568     if ( (*itr) == pAttr)                         616     if ( (*itr) == pAttr)
569     {                                             617     {
570       theAttrVector->erase(itr);                  618       theAttrVector->erase(itr);
571       break;                                      619       break;
572     }                                             620     }
573   }                                               621   }
574   delete pAttr;                                   622   delete pAttr;
575   --numberOfProcesses;                         << 623   numberOfProcesses -= 1;
576                                                   624   
577   // correct index                                625   // correct index
578   for(G4int i=0; i<numberOfProcesses; ++i)        626   for(G4int i=0; i<numberOfProcesses; ++i)
579   {                                               627   {
580     G4ProcessAttribute* aAttr = (*theAttrVecto    628     G4ProcessAttribute* aAttr = (*theAttrVector)[i];
581     if (index < aAttr->idxProcessList) aAttr->    629     if (index < aAttr->idxProcessList) aAttr->idxProcessList -=1;
582   }                                               630   }
583                                                   631 
584   CreateGPILvectors();                            632   CreateGPILvectors();
585                                                   633 
586   // remove aProcess from ProcesssTable           634   // remove aProcess from ProcesssTable
587   G4ProcessTable* theProcessTable = G4ProcessT    635   G4ProcessTable* theProcessTable = G4ProcessTable::GetProcessTable();
588   theProcessTable->Remove(removedProcess, this    636   theProcessTable->Remove(removedProcess, this);
589                                                   637 
590   return removedProcess;                          638   return removedProcess;
591 }                                                 639 } 
592                                                   640   
593 // ------------------------------------------- << 641 // ///////////////////////////////////////
594 G4VProcess* G4ProcessManager::RemoveProcess(G4    642 G4VProcess* G4ProcessManager::RemoveProcess(G4VProcess *aProcess)
595 {                                                 643 {
596   return RemoveProcess(GetProcessIndex(aProces    644   return RemoveProcess(GetProcessIndex(aProcess));
597 }                                                 645 } 
598                                                   646 
599 // ------------------------------------------- << 647 /////////////////////////////////////////
600 G4int G4ProcessManager::GetProcessOrdering(       648 G4int G4ProcessManager::GetProcessOrdering(
601                         G4VProcess *aProcess,     649                         G4VProcess *aProcess,
602                         G4ProcessVectorDoItInd    650                         G4ProcessVectorDoItIndex idDoIt
603                         )                         651                         )
604 {                                                 652 {
605   // get Process Vector Id                        653   // get Process Vector Id
606   G4int ivec = GetProcessVectorId(idDoIt, type    654   G4int ivec = GetProcessVectorId(idDoIt, typeDoIt);
607   if (ivec >=0 )                                  655   if (ivec >=0 )
608   {                                               656   {
609     // get attribute                              657     // get attribute
610     G4ProcessAttribute* pAttr = GetAttribute(a    658     G4ProcessAttribute* pAttr = GetAttribute(aProcess); 
611     if (pAttr != nullptr)                         659     if (pAttr != nullptr)
612     {                                             660     { 
613       return pAttr->ordProcVector[ivec];          661       return pAttr->ordProcVector[ivec];
614     }                                             662     }
615   }                                               663   }
616   return -1;                                      664   return -1;
617 }                                                 665 }
618                                                   666 
619 // ------------------------------------------- << 667 
                                                   >> 668 // ///////////////////////////////////////
620 void G4ProcessManager::SetProcessOrdering(        669 void G4ProcessManager::SetProcessOrdering(
621                         G4VProcess *aProcess,     670                         G4VProcess *aProcess,
622                         G4ProcessVectorDoItInd    671                         G4ProcessVectorDoItIndex idDoIt,
623                         G4int      ordDoIt        672                         G4int      ordDoIt
624                         )                         673                         )
625 {                                                 674 {
626   const G4String aErrorMessage("G4ProcessManag << 675   const G4String aErrorMessage(" G4ProcessManager::SetProcessOrdering");
627                                                   676 
628 #ifdef G4VERBOSE                                  677 #ifdef G4VERBOSE
629   if (GetVerboseLevel()>2)                        678   if (GetVerboseLevel()>2)
630   {                                               679   {
631     G4cout << aErrorMessage ;                     680     G4cout << aErrorMessage ;
632     G4cout << "particle[" + theParticleType->G    681     G4cout << "particle[" + theParticleType->GetParticleName() +"] " ;
633     G4cout <<"process[" + aProcess->GetProcess    682     G4cout <<"process[" + aProcess->GetProcessName() + "]"<<  G4endl;
634   }                                               683   }
635 #endif                                            684 #endif
636                                                   685 
637   // get Process Vector Id                        686   // get Process Vector Id
638   G4int ivec = GetProcessVectorId(idDoIt, type    687   G4int ivec = GetProcessVectorId(idDoIt, typeDoIt);
639   if (ivec <0 )                                   688   if (ivec <0 )
640   {                                               689   {
641 #ifdef G4VERBOSE                                  690 #ifdef G4VERBOSE
642     if (verboseLevel>0)                           691     if (verboseLevel>0)
643     {                                             692     {
644       G4cout <<  aErrorMessage << G4endl;         693       G4cout <<  aErrorMessage << G4endl;
645       G4cout << "particle[" << theParticleType    694       G4cout << "particle[" << theParticleType->GetParticleName()  << "] " ;
646       G4cout << "process[" << aProcess->GetPro    695       G4cout << "process[" << aProcess->GetProcessName() << "]"<<  G4endl;
647       G4cout << " illegal DoIt Index [= " << G    696       G4cout << " illegal DoIt Index [= " << G4int(idDoIt) << "]";
648       G4cout << G4endl;                           697       G4cout << G4endl;
649     }                                             698     }
650 #endif                                            699 #endif
651     return;                                       700     return;
652   }                                               701   }
653                                                   702  
654   if (ordDoIt>ordLast) ordDoIt = ordLast;      << 703   if (ordDoIt>ordLast) ordDoIt=ordLast;
655   // get attribute                                704   // get attribute 
656   G4ProcessAttribute* pAttr = GetAttribute(aPr    705   G4ProcessAttribute* pAttr = GetAttribute(aProcess); 
657   if (pAttr == nullptr)                           706   if (pAttr == nullptr)
658   {                                               707   {
659     // can not get process attribute              708     // can not get process attribute
660     return;                                       709     return;
661   }                                               710   }
662   else                                            711   else
663   {                                               712   {
664     G4int ip = pAttr->idxProcVector[ivec];        713     G4int ip = pAttr->idxProcVector[ivec];
665     // remove a process from the process vecto    714     // remove a process from the process vector
666     if ( ip >=0 )                                 715     if ( ip >=0 )
667     {                                             716     {
668       RemoveAt(ip, aProcess, ivec);               717       RemoveAt(ip, aProcess, ivec);
669     }                                             718     }
670                                                   719 
671     // set ordering parameter to non-zero         720     // set ordering parameter to non-zero
672     if (ordDoIt == 0) ordDoIt = 1;                721     if (ordDoIt == 0) ordDoIt = 1;
673     pAttr->ordProcVector[ivec-1] = ordDoIt;       722     pAttr->ordProcVector[ivec-1] = ordDoIt;
674     pAttr->ordProcVector[ivec] = ordDoIt;         723     pAttr->ordProcVector[ivec] = ordDoIt;
675                                                   724 
676     // insert in process vector  if ordDoIt >0    725     // insert in process vector  if ordDoIt >0
677     if (ordDoIt >0)                               726     if (ordDoIt >0)
678     {                                             727     {
679       // find insert position                     728       // find insert position
680       ip = FindInsertPosition(pAttr->ordProcVe    729       ip = FindInsertPosition(pAttr->ordProcVector[ivec], ivec);
681       // insert                                   730       // insert 
682       InsertAt(ip, aProcess, ivec);               731       InsertAt(ip, aProcess, ivec);
683       // set index in Process Attribute           732       // set index in Process Attribute
684       pAttr->idxProcVector[ivec] = ip;            733       pAttr->idxProcVector[ivec] = ip;
685 #ifdef G4VERBOSE                                  734 #ifdef G4VERBOSE
686       if (verboseLevel>2)                         735       if (verboseLevel>2)
687       {                                           736       {
688         G4cout << aErrorMessage << G4endl;     << 737         G4cout <<  aErrorMessage << G4endl;
689         G4cout << "particle[" << theParticleTy    738         G4cout << "particle[" << theParticleType->GetParticleName() << "] " ;
690         G4cout <<"process[" << aProcess->GetPr << 739         G4cout <<"process[" << aProcess->GetProcessName() << "]"<<  G4endl;
691         G4cout << aProcess->GetProcessName() <    740         G4cout << aProcess->GetProcessName() << " is inserted at "<< ip;
692         G4cout << " in ProcessVetor[" << ivec<    741         G4cout << " in ProcessVetor[" << ivec<< "]";
693         G4cout << " with Ordering parameter =  << 742         G4cout << " with Ordering parameter = " <<  ordDoIt ;
694         G4cout << G4endl;                         743         G4cout << G4endl;
695       }                                           744       }
696 #endif                                            745 #endif
697     }                                             746     }
698   }                                               747   }
699   // check consistencies between ordering para    748   // check consistencies between ordering parameters and process 
700   CheckOrderingParameters(aProcess);              749   CheckOrderingParameters(aProcess);
701                                                   750 
702   // create GPIL vectors                          751   // create GPIL vectors 
703   CreateGPILvectors();                            752   CreateGPILvectors();
704 }                                                 753 }
705                                                   754          
706 // ------------------------------------------- << 755 
                                                   >> 756 // ///////////////////////////////////////
707 void G4ProcessManager::SetProcessOrderingToFir    757 void G4ProcessManager::SetProcessOrderingToFirst(
708                                G4VProcess *aPr    758                                G4VProcess *aProcess,
709                                G4ProcessVector    759                                G4ProcessVectorDoItIndex idDoIt
710                                )                  760                                )
711 {                                                 761 { 
712   // get Process Vector Id                     << 762   // get Process Vector Id(
713   G4int ivec = GetProcessVectorId(idDoIt, type    763   G4int ivec = GetProcessVectorId(idDoIt, typeDoIt);
714   if (ivec <0 )                                   764   if (ivec <0 )
715   {                                               765   {
716 #ifdef G4VERBOSE                                  766 #ifdef G4VERBOSE
717     if (verboseLevel>0)                           767     if (verboseLevel>0)
718     {                                             768     {
719       G4cout << "G4ProcessManager::SetProcessO << 769       G4cout << "G4ProcessManager::SetProcessOrdering: ";
720       G4cout << " illegal DoIt Index [= " << G    770       G4cout << " illegal DoIt Index [= " << G4int(idDoIt) << "]";
721       G4cout << G4endl;                           771       G4cout << G4endl;
722     }                                             772     }
723 #endif                                            773 #endif
724     return;                                       774     return;
725   }                                               775   }
726                                                   776 
727     // get attribute                              777     // get attribute
728    G4ProcessAttribute* pAttr = GetAttribute(aP    778    G4ProcessAttribute* pAttr = GetAttribute(aProcess); 
729    if (pAttr == nullptr)                          779    if (pAttr == nullptr)
730    {                                              780    {
731      return;                                      781      return;
732    }                                              782    }
733    else                                           783    else
734    {                                              784    {
735      G4int ip = pAttr->idxProcVector[ivec];       785      G4int ip = pAttr->idxProcVector[ivec];
736                                                   786 
737      // remove a process from the process vect    787      // remove a process from the process vector
738      if ( ip >=0 )                                788      if ( ip >=0 )
739      {                                            789      {
740        RemoveAt(ip, aProcess, ivec);              790        RemoveAt(ip, aProcess, ivec);
741      }                                            791      }
742                                                   792 
743      // set ordering parameter to zero            793      // set ordering parameter to zero
744      pAttr->ordProcVector[ivec] = 0;              794      pAttr->ordProcVector[ivec] = 0;
745      pAttr->ordProcVector[ivec-1] = 0;            795      pAttr->ordProcVector[ivec-1] = 0;
746                                                   796 
747      // insert                                    797      // insert 
748      InsertAt(0, aProcess, ivec);                 798      InsertAt(0, aProcess, ivec);
749                                                   799 
750      // set index in Process Attribute            800      // set index in Process Attribute
751      pAttr->idxProcVector[ivec] = 0;              801      pAttr->idxProcVector[ivec] = 0;
752                                                   802 
753 #ifdef G4VERBOSE                                  803 #ifdef G4VERBOSE
754      if (verboseLevel>2)                          804      if (verboseLevel>2)
755      {                                            805      {
756        G4cout << "G4ProcessManager::SetProcess << 806        G4cout << "G4ProcessManager::SetProcessOrderingToFirst: ";
757        G4cout << aProcess->GetProcessName() <<    807        G4cout << aProcess->GetProcessName() << " is inserted at top ";
758        G4cout << " in ProcessVetor[" << ivec<<    808        G4cout << " in ProcessVetor[" << ivec<< "]";
759        G4cout << G4endl;                          809        G4cout << G4endl;
760      }                                            810      }
761 #endif                                            811 #endif
762    }                                              812    }
763                                                   813  
764    if (isSetOrderingFirstInvoked[idDoIt])         814    if (isSetOrderingFirstInvoked[idDoIt])
765    {                                              815    {
766      G4String anErrMsg = "Set Ordering First i    816      G4String anErrMsg = "Set Ordering First is invoked twice for ";
767      anErrMsg += aProcess->GetProcessName();      817      anErrMsg += aProcess->GetProcessName();
768      anErrMsg += " to ";                          818      anErrMsg += " to ";
769      anErrMsg += theParticleType->GetParticleN    819      anErrMsg += theParticleType->GetParticleName();
770      G4Exception("G4ProcessManager::SetProcess    820      G4Exception("G4ProcessManager::SetProcessOrderingToFirst()",
771                  "ProcMan113", JustWarning, an << 821                  "ProcMan113",
                                                   >> 822                  JustWarning,anErrMsg); 
772    }                                              823    }
773    isSetOrderingFirstInvoked[idDoIt] = true;      824    isSetOrderingFirstInvoked[idDoIt] = true;
774                                                   825 
775    // check consistencies between ordering par    826    // check consistencies between ordering parameters and process 
776    CheckOrderingParameters(aProcess);             827    CheckOrderingParameters(aProcess);
777                                                   828 
778    // create GPIL vectors                         829    // create GPIL vectors 
779    CreateGPILvectors();                           830    CreateGPILvectors();
780 }                                                 831 }
781                                                   832 
782 // ------------------------------------------- << 833 // ///////////////////////////////////////
783 void G4ProcessManager::SetProcessOrderingToSec    834 void G4ProcessManager::SetProcessOrderingToSecond(
784                         G4VProcess *aProcess,     835                         G4VProcess *aProcess,
785                         G4ProcessVectorDoItInd    836                         G4ProcessVectorDoItIndex idDoIt
786                         )                         837                         )
787 {                                                 838 {
788   const G4String aErrorMessage("G4ProcessManag << 839   const G4String aErrorMessage(" G4ProcessManager::SetProcessOrderingToSecond");
789                                                   840  
790 #ifdef G4VERBOSE                                  841 #ifdef G4VERBOSE
791   if (GetVerboseLevel()>2)                        842   if (GetVerboseLevel()>2)
792   {                                               843   {
793     G4cout << aErrorMessage ;                     844     G4cout << aErrorMessage ;
794     G4cout << "particle[" << theParticleType->    845     G4cout << "particle[" << theParticleType->GetParticleName()  << "] " ;
795     G4cout <<"process[" << aProcess->GetProces    846     G4cout <<"process[" << aProcess->GetProcessName() <<  "]"<<  G4endl;
796   }                                               847   }
797 #endif                                            848 #endif
798                                                   849 
799   // get Process Vector Id                        850   // get Process Vector Id
800   G4int ivec = GetProcessVectorId(idDoIt, type    851   G4int ivec = GetProcessVectorId(idDoIt, typeDoIt);
801   if (ivec <0 )                                   852   if (ivec <0 )
802   {                                               853   {
803 #ifdef G4VERBOSE                                  854 #ifdef G4VERBOSE
804     if (verboseLevel>0)                           855     if (verboseLevel>0)
805     {                                             856     {
806       G4cout <<  aErrorMessage << G4endl;         857       G4cout <<  aErrorMessage << G4endl;
807       G4cout << "particle[" << theParticleType    858       G4cout << "particle[" << theParticleType->GetParticleName() << "] " ;
808       G4cout << "process[" << aProcess->GetPro    859       G4cout << "process[" << aProcess->GetProcessName() << "]"<<  G4endl;
809       G4cout << " illegal DoIt Index [= " << G    860       G4cout << " illegal DoIt Index [= " << G4int(idDoIt) << "]";
810       G4cout << G4endl;                           861       G4cout << G4endl;
811     }                                             862     }
812 #endif                                            863 #endif
813     return;                                       864     return;
814   }                                               865   }
815                                                   866  
816   // get attribute                                867   // get attribute 
817   G4ProcessAttribute* pAttr = GetAttribute(aPr    868   G4ProcessAttribute* pAttr = GetAttribute(aProcess); 
818   if (pAttr == nullptr)                           869   if (pAttr == nullptr)
819   {                                               870   {
820     // can not get process attribute              871     // can not get process attribute
821     return;                                       872     return;
822   }                                               873   }
823   else                                            874   else
824   {                                               875   {
825     G4int ip = pAttr->idxProcVector[ivec];        876     G4int ip = pAttr->idxProcVector[ivec];
826     // remove a process from the process vecto    877     // remove a process from the process vector
827     if ( ip >=0 )                                 878     if ( ip >=0 )
828     {                                             879     {
829       RemoveAt(ip, aProcess, ivec);               880       RemoveAt(ip, aProcess, ivec);
830     }                                             881     }
831   }                                               882   }
832                                                   883 
833   // set ordering parameter                    << 884   // set ordering parameter to 1
834   pAttr->ordProcVector[ivec-1] = 0;               885   pAttr->ordProcVector[ivec-1] = 0;
835   pAttr->ordProcVector[ivec]   = 0;               886   pAttr->ordProcVector[ivec]   = 0;
836                                                   887 
837   // find insert position                         888   // find insert position
838   G4ProcessVector* pVector = theProcVector[ive    889   G4ProcessVector* pVector = theProcVector[ivec];
839   G4int ip = (G4int)pVector->entries();        << 890   G4int ip =  pVector->entries();
840   G4int tmp = INT_MAX;                            891   G4int tmp = INT_MAX;
841                                                   892 
842   // find insert position                         893   // find insert position
843   for (G4int iproc=0; iproc<numberOfProcesses;    894   for (G4int iproc=0; iproc<numberOfProcesses; ++iproc)
844   {                                               895   {
845     G4ProcessAttribute* aAttr = (*theAttrVecto    896     G4ProcessAttribute* aAttr = (*theAttrVector)[iproc];
846     if ( aAttr->idxProcVector[ivec] >= 0 )        897     if ( aAttr->idxProcVector[ivec] >= 0 )
847     {                                             898     {
848       if ( (aAttr->ordProcVector[ivec] !=0 )   << 899       if (    (aAttr->ordProcVector[ivec] !=0 )  &&
849            (tmp >= aAttr->ordProcVector[ivec]) << 900               (tmp >= aAttr->ordProcVector[ivec]) )
850       {                                           901       {
851         tmp = aAttr->ordProcVector[ivec];      << 902         tmp =  aAttr->ordProcVector[ivec];
852         if ( ip > aAttr->idxProcVector[ivec] )    903         if ( ip > aAttr->idxProcVector[ivec] )
853         {                                         904         {  
854           ip = aAttr->idxProcVector[ivec] ;       905           ip = aAttr->idxProcVector[ivec] ;
855         }                                         906         }
856       }                                           907       }
857     }                                             908     }
858   }                                               909   }
859                                                   910   
860   // insert                                       911   // insert 
861   InsertAt(ip, aProcess, ivec);                   912   InsertAt(ip, aProcess, ivec);
862                                                   913 
863   // set index in Process Attribute               914   // set index in Process Attribute
864   pAttr->idxProcVector[ivec] = ip;                915   pAttr->idxProcVector[ivec] = ip;
865 #ifdef G4VERBOSE                                  916 #ifdef G4VERBOSE
866   if (verboseLevel>2)                             917   if (verboseLevel>2)
867   {                                               918   {
868     G4cout <<  aErrorMessage << G4endl;           919     G4cout <<  aErrorMessage << G4endl;
869     G4cout << "particle[" << theParticleType->    920     G4cout << "particle[" << theParticleType->GetParticleName()  << "] " ;
870     G4cout <<"process[" << aProcess->GetProces    921     G4cout <<"process[" << aProcess->GetProcessName() << "]"<<  G4endl;
871     G4cout << aProcess->GetProcessName() << "     922     G4cout << aProcess->GetProcessName() << " is inserted at "<< ip;
872     G4cout << " in ProcessVetor[" << ivec<< "]    923     G4cout << " in ProcessVetor[" << ivec<< "]";
873     G4cout << " with Ordering parameter = 1 ";    924     G4cout << " with Ordering parameter = 1 ";
874     G4cout << G4endl;                             925     G4cout << G4endl;
875   }                                               926   }
876 #endif                                            927 #endif
877                                                   928  
878   // check consistencies between ordering para    929   // check consistencies between ordering parameters and process 
879   CheckOrderingParameters(aProcess);              930   CheckOrderingParameters(aProcess);
880                                                   931 
881   // create GPIL vectors                          932   // create GPIL vectors 
882   CreateGPILvectors();                            933   CreateGPILvectors();
883 }                                                 934 }
884                                                   935          
885 // ------------------------------------------- << 936 // ///////////////////////////////////////
886 void G4ProcessManager::SetProcessOrderingToLas    937 void G4ProcessManager::SetProcessOrderingToLast(
887                                G4VProcess *aPr    938                                G4VProcess *aProcess,
888                                G4ProcessVector    939                                G4ProcessVectorDoItIndex idDoIt
889                                )                  940                                )
890 {                                                 941 {
891   SetProcessOrdering(aProcess, idDoIt, ordLast    942   SetProcessOrdering(aProcess, idDoIt, ordLast );
892                                                   943 
893   if (isSetOrderingLastInvoked[idDoIt])           944   if (isSetOrderingLastInvoked[idDoIt])
894   {                                               945   {
895     G4String anErrMsg = "Set Ordering Last is     946     G4String anErrMsg = "Set Ordering Last is invoked twice for ";
896     anErrMsg += aProcess->GetProcessName();       947     anErrMsg += aProcess->GetProcessName();
897     anErrMsg += " to ";                           948     anErrMsg += " to ";
898     anErrMsg += theParticleType->GetParticleNa    949     anErrMsg += theParticleType->GetParticleName();
899     G4Exception( "G4ProcessManager::SetProcess    950     G4Exception( "G4ProcessManager::SetProcessOrderingToLast()","ProcMan114",
900                  JustWarning,anErrMsg);           951                  JustWarning,anErrMsg); 
901   }                                               952   }
902   isSetOrderingLastInvoked[idDoIt] = true;        953   isSetOrderingLastInvoked[idDoIt] = true;
903 }                                                 954 }
904                                                   955 
905 // ------------------------------------------- << 956 // ///////////////////////////////////////
906 G4VProcess* G4ProcessManager::InActivateProces    957 G4VProcess* G4ProcessManager::InActivateProcess(G4int index)
907 {                                                 958 {
908   G4ApplicationState currentState                 959   G4ApplicationState currentState 
909    = G4StateManager::GetStateManager()->GetCur    960    = G4StateManager::GetStateManager()->GetCurrentState();
910   if ( (currentState == G4State_PreInit) || (c    961   if ( (currentState == G4State_PreInit) || (currentState == G4State_Init) )
911   {                                               962   {
912 #ifdef G4VERBOSE                                  963 #ifdef G4VERBOSE
913     if (GetVerboseLevel()>1)                      964     if (GetVerboseLevel()>1)
914     {                                             965     {
915       G4cout << "G4ProcessManager::InActivateP    966       G4cout << "G4ProcessManager::InActivateProcess is not valid in ";
916       if (currentState == G4State_PreInit )       967       if (currentState == G4State_PreInit )
917       {                                           968       {
918         G4cout << "PreInit ";                     969         G4cout << "PreInit ";
919       }                                           970       }
920       else if  (currentState == G4State_Init )    971       else if  (currentState == G4State_Init )
921       {                                           972       {
922         G4cout << "Init ";                        973         G4cout << "Init ";
923       }                                           974       } 
924       G4cout << "state !" << G4endl;              975       G4cout << "state !" << G4endl;
925     }                                             976     }
926 #endif                                            977 #endif
927    return nullptr;                                978    return nullptr;
928   }                                               979   }
929                                                   980 
930   // find the process attribute                << 981   //find the process attribute
931   G4ProcessAttribute* pAttr = GetAttribute(ind    982   G4ProcessAttribute* pAttr = GetAttribute(index);
932   if (pAttr == nullptr) return nullptr;           983   if (pAttr == nullptr) return nullptr;
933                                                   984 
934   // remove process                               985   // remove process
935   G4VProcess* pProcess = (*theProcessList)[ind    986   G4VProcess* pProcess = (*theProcessList)[index];
936                                                   987 
937   const G4String aErrorMessage("G4ProcessManag << 988   const G4String aErrorMessage(" G4ProcessManager::InactivateProcess():");
938                                                   989 
939   if (pAttr->isActive)                            990   if (pAttr->isActive)
940   {                                               991   {
941     // remove process from vectors if the proc    992     // remove process from vectors if the process is active
942     for (G4int i=0; i<SizeOfProcVectorArray; +    993     for (G4int i=0; i<SizeOfProcVectorArray; ++i)
943     {                                             994     {
944       G4ProcessVector* pVector = theProcVector    995       G4ProcessVector* pVector = theProcVector[i];
945       G4int idx = pAttr->idxProcVector[i];        996       G4int idx = pAttr->idxProcVector[i];
946                                                   997 
947       if (idx<0)                                  998       if (idx<0)
948       {                                           999       {
949         // corresponding DoIt is not active       1000         // corresponding DoIt is not active  
950       }                                           1001       }
951       else if ((idx >= 0) && (idx < G4int(pVec    1002       else if ((idx >= 0) && (idx < G4int(pVector->entries())))
952       {                                           1003       {
953         //check pointer and set to 0              1004         //check pointer and set to 0
954         if ((*pVector)[idx]== pProcess)           1005         if ((*pVector)[idx]== pProcess)
955         {                                         1006         {
956           (*pVector)[idx]= nullptr;               1007           (*pVector)[idx]= nullptr;
957         }                                         1008         }
958         else                                      1009         else
959         {                                         1010         {
960           G4String anErrorMessage("Bad Process    1011           G4String anErrorMessage("Bad ProcessList: Bad index in attribute");
961           anErrorMessage += "for particle[" +     1012           anErrorMessage += "for particle[" + theParticleType->GetParticleName() + "] ";
962           anErrorMessage += "process[" + pProc    1013           anErrorMessage += "process[" + pProcess->GetProcessName() + "]  " ;
963           G4Exception( "G4ProcessManager::Inac << 1014           G4Exception( "G4ProcessManager::InactivateProcess():","ProcMan012",
964                        FatalException, anError << 1015                        FatalException,anErrorMessage); 
965           return nullptr;                         1016           return nullptr;
966         }                                         1017         }    
967       }                                           1018       }
968       else                                        1019       else
969       {                                           1020       {
970         // idx is out of range                    1021         // idx is out of range
971         G4String anErrorMessage("Bad ProcessLi    1022         G4String anErrorMessage("Bad ProcessList:  Index is out of range");
972         anErrorMessage += "for particle[" + th    1023         anErrorMessage += "for particle[" + theParticleType->GetParticleName() + "] ";
973         anErrorMessage += "process[" + pProces    1024         anErrorMessage += "process[" + pProcess->GetProcessName() + "]  " ;
974         G4Exception( "G4ProcessManager::Inacti << 1025         G4Exception( "G4ProcessManager::InactivateProcess():","ProcMan012",
975                      FatalException, anErrorMe << 1026                      FatalException,anErrorMessage); 
976         return nullptr;                           1027         return nullptr;
977       }                                           1028       }
978     }                                             1029     } 
979     pAttr->isActive = false;                      1030     pAttr->isActive = false;
980   }                                               1031   }
981   return pProcess;                                1032   return pProcess;
982 }                                                 1033 } 
983                                                   1034 
984 // ------------------------------------------- << 1035 // ///////////////////////////////////////
985 G4VProcess* G4ProcessManager::ActivateProcess(    1036 G4VProcess* G4ProcessManager::ActivateProcess(G4int index)
986 {                                                 1037 {
987   G4ApplicationState currentState                 1038   G4ApplicationState currentState 
988    = G4StateManager::GetStateManager()->GetCur    1039    = G4StateManager::GetStateManager()->GetCurrentState();
989   if ( (currentState == G4State_PreInit) || (c    1040   if ( (currentState == G4State_PreInit) || (currentState == G4State_Init) )
990   {                                               1041   {
991 #ifdef G4VERBOSE                                  1042 #ifdef G4VERBOSE
992     if (GetVerboseLevel()>1)                      1043     if (GetVerboseLevel()>1)
993     {                                             1044     {
994       G4cout << "G4ProcessManager::ActivatePro << 1045       G4cout << "G4ProcessManager::ActivateProcess is not valid in ";
995       if (currentState == G4State_PreInit )       1046       if (currentState == G4State_PreInit )
996       {                                           1047       {
997         G4cout << "PreInit ";                     1048         G4cout << "PreInit ";
998       }                                           1049       }
999       else  if (currentState == G4State_Init )    1050       else  if (currentState == G4State_Init )
1000       {                                          1051       {
1001         G4cout << "Init ";                       1052         G4cout << "Init ";
1002       }                                          1053       } 
1003       G4cout << "state !" << G4endl;             1054       G4cout << "state !" << G4endl;
1004     }                                            1055     }
1005 #endif                                           1056 #endif
1006    return nullptr;                               1057    return nullptr;
1007   }                                              1058   }
1008                                                  1059 
1009   //find the process attribute                   1060   //find the process attribute
1010   G4ProcessAttribute* pAttr = GetAttribute(in    1061   G4ProcessAttribute* pAttr = GetAttribute(index);
1011   if (pAttr == nullptr) return nullptr;          1062   if (pAttr == nullptr) return nullptr;
1012                                                  1063 
1013   // remove process                              1064   // remove process
1014   G4VProcess* pProcess = (*theProcessList)[in    1065   G4VProcess* pProcess = (*theProcessList)[index];
1015                                                  1066 
1016   if (!pAttr->isActive)                          1067   if (!pAttr->isActive)
1017   {                                              1068   {
1018     // remove process from vectors if the pro    1069     // remove process from vectors if the process is active
1019     for (G4int i=0; i<SizeOfProcVectorArray;     1070     for (G4int i=0; i<SizeOfProcVectorArray; ++i)
1020     {                                            1071     {
1021       G4ProcessVector* pVector = theProcVecto    1072       G4ProcessVector* pVector = theProcVector[i];
1022       G4int idx = pAttr->idxProcVector[i];       1073       G4int idx = pAttr->idxProcVector[i];
1023       if (idx<0)                                 1074       if (idx<0)
1024       {                                          1075       {
1025         // corresponding DoIt is not active      1076         // corresponding DoIt is not active  
1026       }                                          1077       }
1027       else if ((idx >= 0) && (idx < G4int(pVe    1078       else if ((idx >= 0) && (idx < G4int(pVector->entries())))
1028       {                                          1079       {
1029         // check pointer and set              << 1080         //check pointer and set
1030         if ((*pVector)[idx] == nullptr)          1081         if ((*pVector)[idx] == nullptr)
1031         {                                        1082         {
1032           (*pVector)[idx] = pProcess;            1083           (*pVector)[idx] = pProcess;
1033         }                                        1084         }
1034         else                                     1085         else
1035         {                                        1086         {
1036           G4String anErrorMessage("Bad Proces    1087           G4String anErrorMessage("Bad ProcessList: Bad index in attribute");
1037           anErrorMessage += "for particle[" +    1088           anErrorMessage += "for particle[" + theParticleType->GetParticleName() + "] ";
1038           anErrorMessage += "process[" + pPro    1089           anErrorMessage += "process[" + pProcess->GetProcessName() + "]  " ;
1039           G4Exception("G4ProcessManager::Acti << 1090           G4Exception("G4ProcessManager::ActivateProcess():","ProcMan012",
1040                       FatalException, anError << 1091                       FatalException,anErrorMessage);
1041           return nullptr;                        1092           return nullptr;
1042         }                                        1093         }    
1043       }                                          1094       }
1044       else                                       1095       else
1045       {                                          1096       {
1046         // idx is out of range                   1097         // idx is out of range
1047         G4String anErrorMessage("bad ProcessL << 1098         G4String anErrorMessage("bad ProcessList:  Index is out of range");
1048         anErrorMessage += "for particle["     << 1099         anErrorMessage += "for particle[" + theParticleType->GetParticleName() + "] ";
1049                           + theParticleType-> << 
1050         anErrorMessage += "process[" + pProce    1100         anErrorMessage += "process[" + pProcess->GetProcessName() + "]  " ;
1051         G4Exception("G4ProcessManager::Activa << 1101         G4Exception("G4ProcessManager::ActivateProcess():","ProcMan012",
1052                     FatalException, anErrorMe << 1102                     FatalException,anErrorMessage); 
1053          return nullptr;                         1103          return nullptr;
1054       }                                          1104       }
1055     }                                            1105     } 
1056     pAttr->isActive = true;                      1106     pAttr->isActive = true;
1057   }                                              1107   }
1058   return pProcess;                               1108   return pProcess;
1059 }                                                1109 } 
1060                                                  1110 
1061 // ------------------------------------------ << 1111 // ///////////////////////////////////////
1062 G4bool G4ProcessManager::operator==(const G4P    1112 G4bool G4ProcessManager::operator==(const G4ProcessManager &right) const
1063 {                                                1113 {
1064   return (this == &right);                       1114   return (this == &right);
1065 }                                                1115 }
1066                                                  1116 
1067 // ------------------------------------------ << 1117 // ///////////////////////////////////////
1068 G4bool G4ProcessManager::operator!=(const G4P    1118 G4bool G4ProcessManager::operator!=(const G4ProcessManager &right) const
1069 {                                                1119 {
1070   return (this != &right);                       1120   return (this != &right);
1071 }                                                1121 }
1072                                                  1122 
1073 // ------------------------------------------ << 1123 // ///////////////////////////////////////
1074 void G4ProcessManager::DumpInfo()                1124 void G4ProcessManager::DumpInfo()
1075 {                                                1125 { 
1076   // Dump Information                            1126   // Dump Information
1077                                                  1127 
1078   // particle type                               1128   // particle type
1079   G4cout << "G4ProcessManager: particle["     << 1129   G4cout << "G4ProcessManager:  particle[" 
1080          << theParticleType->GetParticleName(    1130          << theParticleType->GetParticleName() << "]"
1081          << G4endl;                              1131          << G4endl;
1082                                                  1132 
1083   // loop over all processes                     1133   // loop over all processes
1084   for (G4int idx=0; idx < (G4int)theProcessLi << 1134   for (std::size_t idx=0; idx < theProcessList->entries(); ++idx)
1085   {                                              1135   {
1086     // process name/type                         1136     // process name/type
1087     G4cout << "[" << idx << "]";                 1137     G4cout << "[" << idx << "]";
1088     G4cout << "=== process[" << ((*theProcess << 1138     G4cout << "=== process[" << ((*theProcessList)(idx))->GetProcessName()<< " :"; 
1089            << " :";                           << 1139     G4cout << G4VProcess::GetProcessTypeName( ((*theProcessList)(idx))->GetProcessType() )<< "]";
1090     G4cout << G4VProcess::GetProcessTypeName( << 
1091            << "]";                            << 
1092                                                  1140 
1093     // process attribute                         1141     // process attribute    
1094     G4ProcessAttribute* pAttr = (*theAttrVect    1142     G4ProcessAttribute* pAttr = (*theAttrVector)[idx];
1095     // status                                    1143     // status
1096     if ( pAttr-> isActive )                      1144     if ( pAttr-> isActive )
1097     {                                            1145     {
1098       G4cout << " Active ";                      1146       G4cout << " Active ";
1099     }                                            1147     }
1100     else                                         1148     else
1101     {                                            1149     {
1102       G4cout << " InActive ";                    1150       G4cout << " InActive ";
1103     }                                            1151     }
1104     G4cout << G4endl;                            1152     G4cout << G4endl;
1105                                                  1153 
1106 #ifdef G4VERBOSE                                 1154 #ifdef G4VERBOSE
1107     if (verboseLevel>0)                          1155     if (verboseLevel>0)
1108     {                                            1156     {
1109       // order parameter                         1157       // order parameter    
1110       G4cout << "  Ordering::     ";             1158       G4cout << "  Ordering::     ";
1111       G4cout << "        AtRest             A    1159       G4cout << "        AtRest             AlongStep          PostStep   ";
1112       G4cout << G4endl;                          1160       G4cout << G4endl;
1113       G4cout << "                 ";             1161       G4cout << "                 ";
1114       G4cout << "   GetPIL/    DoIt    GetPIL    1162       G4cout << "   GetPIL/    DoIt    GetPIL/    DoIt    GetPIL/    DoIt ";
1115       G4cout << G4endl;                          1163       G4cout << G4endl;
1116       G4cout << "  Ordering::      " << G4end    1164       G4cout << "  Ordering::      " << G4endl;
1117       G4cout << "  index           ";            1165       G4cout << "  index           ";
1118       for (G4int idx2 = 0; idx2 <6 ; ++idx2)     1166       for (G4int idx2 = 0; idx2 <6 ; ++idx2)
1119       {                                          1167       {
1120         G4cout << std::setw(8) << pAttr->idxP << 1168         G4cout << std::setw(8) << pAttr->idxProcVector[idx2] <<":";
1121       }                                          1169       }
1122       G4cout << G4endl;                          1170       G4cout << G4endl;
1123       G4cout << "  parameter       ";            1171       G4cout << "  parameter       ";
1124       for (G4int idx3 = 0; idx3 <6 ; ++idx3)     1172       for (G4int idx3 = 0; idx3 <6 ; ++idx3)
1125       {                                          1173       {
1126         G4cout << std::setw(8) << pAttr->ordP << 1174         G4cout << std::setw(8) << pAttr->ordProcVector[idx3] <<":";
1127       }                                          1175       }
1128       G4cout << G4endl;                          1176       G4cout << G4endl;
1129     }                                            1177     }
1130 #endif                                           1178 #endif 
1131   }                                              1179   }
1132 }                                                1180 }
1133                                                  1181 
1134 // ------------------------------------------ << 
1135 void G4ProcessManager::CreateGPILvectors()       1182 void G4ProcessManager::CreateGPILvectors()
1136 {                                                1183 {
1137   // Create GetPhysicalInteractionLength proc << 1184 //-- create GetPhysicalInteractionLength process vectors just as the inverse
1138   // order of DoIt() process vector           << 1185 //-- order of DoIt process vector
1139                                               << 1186   for(std::size_t k=0; k<theProcessList->entries(); ++k)
1140   for(G4int k=0; k<(G4int)theProcessList->ent << 
1141   {                                              1187   {
1142     GetAttribute((*theProcessList)[k])->idxPr    1188     GetAttribute((*theProcessList)[k])->idxProcVector[0]=-1;
1143     GetAttribute((*theProcessList)[k])->idxPr    1189     GetAttribute((*theProcessList)[k])->idxProcVector[2]=-1;
1144     GetAttribute((*theProcessList)[k])->idxPr    1190     GetAttribute((*theProcessList)[k])->idxProcVector[4]=-1;
1145   }                                              1191   }
1146                                                  1192 
1147   for(G4int i=0; i<SizeOfProcVectorArray; i +    1193   for(G4int i=0; i<SizeOfProcVectorArray; i += 2)
1148   {                                              1194   {
1149     G4ProcessVector* procGPIL = theProcVector    1195     G4ProcessVector* procGPIL = theProcVector[i];
1150     G4ProcessVector* procDoIt = theProcVector    1196     G4ProcessVector* procDoIt = theProcVector[i+1];
1151     G4int nproc = (G4int)procDoIt->entries(); << 1197     G4int nproc = procDoIt->entries();
1152     procGPIL->clear();                           1198     procGPIL->clear();
1153     for(G4int j=nproc-1;j>=0;--j)                1199     for(G4int j=nproc-1;j>=0;--j)
1154     {                                            1200     {
1155       G4VProcess* aProc = (*procDoIt)[j];        1201       G4VProcess* aProc = (*procDoIt)[j];
1156       procGPIL->insert(aProc);                   1202       procGPIL->insert(aProc);
1157       GetAttribute(aProc)->idxProcVector[i] = << 1203       GetAttribute(aProc)->idxProcVector[i] = procGPIL->entries()-1;
1158     }                                            1204     }
1159   }                                              1205   }
                                                   >> 1206 
1160 }                                                1207 }
1161                                                  1208 
1162 // ------------------------------------------ << 1209 
                                                   >> 1210 //////////////////////////////////////////
1163 void G4ProcessManager::StartTracking(G4Track*    1211 void G4ProcessManager::StartTracking(G4Track* aTrack)
1164 {                                                1212 {
1165   for (G4int idx = 0; idx<(G4int)theProcessLi << 1213   for (std::size_t idx = 0; idx<theProcessList->entries(); ++idx)
1166   {                                              1214   {
1167     if (GetAttribute(idx)->isActive)             1215     if (GetAttribute(idx)->isActive)
1168       ((*theProcessList)[idx])->StartTracking    1216       ((*theProcessList)[idx])->StartTracking(aTrack);
1169   }                                              1217   }
1170   if(aTrack) duringTracking = true;              1218   if(aTrack) duringTracking = true;
1171 }                                                1219 }
1172                                                  1220 
1173 // ------------------------------------------ << 1221 /////////////////////////////////////////////
1174 void G4ProcessManager::EndTracking()             1222 void G4ProcessManager::EndTracking()
1175 {                                                1223 {
1176   for (G4int idx = 0; idx<(G4int)theProcessLi << 1224   for (std::size_t idx = 0; idx<theProcessList->entries(); ++idx)
1177   {                                              1225   {
1178     if (GetAttribute(idx)->isActive)             1226     if (GetAttribute(idx)->isActive)
1179       ((*theProcessList)[idx])->EndTracking()    1227       ((*theProcessList)[idx])->EndTracking();
1180   }                                              1228   }
1181   duringTracking = false;                        1229   duringTracking = false;
1182 }                                                1230 }
1183                                                  1231 
1184 // ------------------------------------------ << 1232 
                                                   >> 1233 /////////////////////////////////////////////
1185 G4VProcess* G4ProcessManager::GetProcess(cons    1234 G4VProcess* G4ProcessManager::GetProcess(const G4String& processName) const
1186 {                                                1235 {
1187   for (G4int k=0; k<numberOfProcesses; ++k)      1236   for (G4int k=0; k<numberOfProcesses; ++k)
1188   {                                              1237   {
1189     G4VProcess* process = (*theProcessList)[k    1238     G4VProcess* process = (*theProcessList)[k];
1190     if (process->GetProcessName() == processN    1239     if (process->GetProcessName() == processName) return process;
1191   }                                              1240   }
1192   return nullptr;                                1241   return nullptr;
1193 }                                                1242 }
1194                                                  1243 
1195 // ------------------------------------------ << 1244 
1196 G4VProcess* G4ProcessManager::SetProcessActiv << 1245 /////////////////////////////////////////////
1197                                               << 1246  G4VProcess* G4ProcessManager::SetProcessActivation(G4VProcess *aProcess, 
                                                   >> 1247                                                     G4bool      fActive  )
1198 {                                                1248 {
1199   return SetProcessActivation(GetProcessIndex    1249   return SetProcessActivation(GetProcessIndex(aProcess), fActive);
1200 }                                                1250 } 
1201                                                  1251 
1202 // ------------------------------------------ << 1252 
1203 G4VProcess* G4ProcessManager::SetProcessActiv << 1253 /////////////////////////////////////////////
                                                   >> 1254  G4VProcess* G4ProcessManager::SetProcessActivation(G4int index, G4bool fActive)
1204 {                                                1255 {
1205   if (fActive) return ActivateProcess(index);    1256   if (fActive) return ActivateProcess(index);
1206   else         return InActivateProcess(index    1257   else         return InActivateProcess(index);
1207 }                                                1258 }
1208                                                  1259 
1209 // ------------------------------------------ << 1260 /////////////////////////////////////////////
1210  G4bool G4ProcessManager::GetProcessActivatio << 1261  G4bool G4ProcessManager::GetProcessActivation(G4VProcess *aProcess) const
1211 {                                                1262 {
1212   return GetProcessActivation(GetProcessIndex    1263   return GetProcessActivation(GetProcessIndex(aProcess));
1213 }                                                1264 } 
1214                                                  1265 
1215 // ------------------------------------------ << 1266 
1216 G4bool G4ProcessManager::GetProcessActivation << 1267 /////////////////////////////////////////////
                                                   >> 1268  G4bool G4ProcessManager::GetProcessActivation(G4int index) const
1217 {                                                1269 {
1218   if (index <0)                                  1270   if (index <0)
1219   {                                              1271   {
1220 #ifdef G4VERBOSE                                 1272 #ifdef G4VERBOSE
1221     if (GetVerboseLevel()>0)                     1273     if (GetVerboseLevel()>0)
1222     {                                            1274     {
1223       G4cout << "G4ProcessManager::GetProcess    1275       G4cout << "G4ProcessManager::GetProcessActivation  ";
1224       G4cout << " process (or its index) not     1276       G4cout << " process (or its index) not found ";
1225     }                                            1277     }
1226 #endif                                           1278 #endif
1227     return false;                                1279     return false;
1228   }                                              1280   }
1229   // process attribute                           1281   // process attribute    
1230   G4ProcessAttribute* pAttr = (*theAttrVector    1282   G4ProcessAttribute* pAttr = (*theAttrVector)[index];
1231   // status                                      1283   // status
1232   return pAttr->isActive;                     << 1284   return pAttr-> isActive;
1233 }                                                1285 }
1234                                                  1286 
1235 // ------------------------------------------ << 1287 /////////////////////////////////////////////
1236 void G4ProcessManager::CheckOrderingParameter    1288 void G4ProcessManager::CheckOrderingParameters(G4VProcess* aProcess) const
1237 {                                                1289 {
1238   if (aProcess == nullptr) return;               1290   if (aProcess == nullptr) return;
1239   G4ProcessAttribute* pAttr = GetAttribute(aP    1291   G4ProcessAttribute* pAttr = GetAttribute(aProcess);
1240   if (pAttr == nullptr)                          1292   if (pAttr == nullptr)
1241   {                                              1293   {
1242 #ifdef G4VERBOSE                                 1294 #ifdef G4VERBOSE
1243     if (GetVerboseLevel()>0)                     1295     if (GetVerboseLevel()>0)
1244     {                                            1296     {
1245       G4cout << "G4ProcessManager::CheckOrder << 1297       G4cout << "G4ProcessManager::CheckOrderingParameters ";
1246       G4cout << " process " << aProcess->GetP    1298       G4cout << " process " << aProcess->GetProcessName() 
1247              << " has no attribute" << G4endl    1299              << " has no attribute" << G4endl;
1248     }                                            1300     }
1249 #endif                                           1301 #endif
1250     return;                                      1302     return;
1251   }                                              1303   }
1252                                                  1304 
1253   // check consistencies between ordering par    1305   // check consistencies between ordering parameters and 
1254   // validity of DoIt of the Process             1306   // validity of DoIt of the Process  
1255   G4bool isOK =true;                             1307   G4bool isOK =true;
1256   if ( (pAttr->ordProcVector[0]>=0) && (!aPro    1308   if ( (pAttr->ordProcVector[0]>=0) && (!aProcess->isAtRestDoItIsEnabled()) )
1257   {                                              1309   {
1258  #ifdef G4VERBOSE                                1310  #ifdef G4VERBOSE
1259     if (GetVerboseLevel()>0)                     1311     if (GetVerboseLevel()>0)
1260     {                                            1312     {
1261       G4cerr << "G4ProcessManager::CheckOrder << 1313       G4cerr << "G4ProcessManager::CheckOrderingParameters ";
1262       G4cerr << "You cannot set ordering para    1314       G4cerr << "You cannot set ordering parameter ["
1263              << pAttr->ordProcVector[0]          1315              << pAttr->ordProcVector[0]
1264              << "] for AtRest DoIt  to the pr    1316              << "] for AtRest DoIt  to the process "
1265              << aProcess->GetProcessName() <<    1317              << aProcess->GetProcessName() << G4endl;
1266     }                                            1318     }
1267 #endif                                           1319 #endif
1268     isOK = false;                                1320     isOK = false;
1269   }                                              1321   }
1270                                                  1322 
1271   if ((pAttr->ordProcVector[2]>=0) && (!aProc    1323   if ((pAttr->ordProcVector[2]>=0) && (!aProcess->isAlongStepDoItIsEnabled()))
1272   {                                              1324   {
1273 #ifdef G4VERBOSE                                 1325 #ifdef G4VERBOSE
1274     if (GetVerboseLevel()>0)                     1326     if (GetVerboseLevel()>0)
1275     {                                            1327     {
1276       G4cerr << "G4ProcessManager::CheckOrder << 1328       G4cerr << "G4ProcessManager::CheckOrderingParameters ";
1277       G4cerr << "You cannot set ordering para    1329       G4cerr << "You cannot set ordering parameter ["
1278              <<  pAttr->ordProcVector[2]         1330              <<  pAttr->ordProcVector[2]
1279              << "] for AlongStep DoIt to the     1331              << "] for AlongStep DoIt to the process "
1280              << aProcess->GetProcessName() <<    1332              << aProcess->GetProcessName() << G4endl;
1281                                                  1333 
1282     }                                            1334     }
1283 #endif                                           1335 #endif
1284     isOK = false;                                1336     isOK = false;
1285   }                                              1337   } 
1286                                                  1338 
1287   if ((pAttr->ordProcVector[4]>=0) && (!aProc    1339   if ((pAttr->ordProcVector[4]>=0) && (!aProcess->isPostStepDoItIsEnabled()))
1288   {                                              1340   {
1289 #ifdef G4VERBOSE                                 1341 #ifdef G4VERBOSE
1290     if (GetVerboseLevel()>0)                     1342     if (GetVerboseLevel()>0)
1291     {                                            1343     {
1292       G4cerr << "G4ProcessManager::CheckOrder << 1344       G4cerr << "G4ProcessManager::CheckOrderingParameters ";
1293       G4cerr << "You cannot set ordering para    1345       G4cerr << "You cannot set ordering parameter [" 
1294              << pAttr->ordProcVector[4]          1346              << pAttr->ordProcVector[4] 
1295              << "] for PostStep DoIt to the p    1347              << "] for PostStep DoIt to the process"
1296              << aProcess->GetProcessName() <<    1348              << aProcess->GetProcessName() << G4endl;
1297     }                                            1349     }
1298 #endif                                           1350 #endif
1299     isOK = false;                                1351     isOK = false;
1300   }                                              1352   } 
1301                                                  1353 
1302   if (!isOK)                                     1354   if (!isOK)
1303   {                                              1355   {
1304     G4String msg;                                1356     G4String msg;
1305     msg = "Invalid ordering parameters are se    1357     msg = "Invalid ordering parameters are set for  ";
1306     msg +=  aProcess->GetProcessName();          1358     msg +=  aProcess->GetProcessName();
1307     G4Exception( "G4ProcessManager::CheckOrde << 1359     G4Exception( "G4ProcessManager::CheckOrderingParameters ",
1308                  "ProcMan013", FatalException << 1360                  "ProcMan013",FatalException, msg);
1309   }                                              1361   }
1310                                                  1362   
1311   return;                                        1363   return;
1312 }                                                1364 }
1313                                                  1365