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 5.1.p1)


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