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 8.3)


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