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 9.4.p2)


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