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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/biasing/management/src/G4ProcessPlacer.cc (Version 11.3.0) and /processes/biasing/management/src/G4ProcessPlacer.cc (Version 10.0)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4ProcessPlacer                             <<  26 //
 27 // ------------------------------------------- <<  27 // $Id: G4ProcessPlacer.cc 77477 2013-11-25 09:42:24Z gcosmo $
                                                   >>  28 //
                                                   >>  29 // ----------------------------------------------------------------------
                                                   >>  30 // GEANT 4 class source file
                                                   >>  31 //
                                                   >>  32 // G4ProcessPlacer.cc
                                                   >>  33 //
                                                   >>  34 // ----------------------------------------------------------------------
 28                                                    35 
 29 #include "G4ProcessPlacer.hh"                      36 #include "G4ProcessPlacer.hh"
 30 #include "G4ProcessManager.hh"                     37 #include "G4ProcessManager.hh"
 31 #include "G4VProcess.hh"                           38 #include "G4VProcess.hh"
 32 #include "G4ParticleTable.hh"                      39 #include "G4ParticleTable.hh"
 33                                                    40 
 34 G4ProcessPlacer::G4ProcessPlacer(const G4Strin <<  41 G4ProcessPlacer::G4ProcessPlacer(const G4String &particlename)
 35   : fParticleName(particlename)                    42   : fParticleName(particlename)
 36 {                                                  43 {
 37 }                                                  44 }
 38                                                    45 
 39 G4ProcessPlacer::~G4ProcessPlacer()                46 G4ProcessPlacer::~G4ProcessPlacer()
 40 {                                                  47 {
 41 }                                                  48 }
 42                                                    49 
 43 void G4ProcessPlacer::RemoveProcess(G4VProcess <<  50 void G4ProcessPlacer::RemoveProcess(G4VProcess *process)
 44 {                                                  51 {
 45   G4cout << "=== G4ProcessPlacer::RemoveProces     52   G4cout << "=== G4ProcessPlacer::RemoveProcess: for: " <<  fParticleName 
 46          << G4endl;                                53          << G4endl;
 47   G4cout << "  ProcessName: " << process->GetP     54   G4cout << "  ProcessName: " << process->GetProcessName() 
 48          << ", will be removed!" << G4endl;        55          << ", will be removed!" << G4endl;
 49                                                    56 
 50   G4cout << "  The initial AlongStep Vectors:      57   G4cout << "  The initial AlongStep Vectors: " << G4endl;
 51   PrintAlongStepGPILVec();                         58   PrintAlongStepGPILVec();
 52   PrintAlongStepDoItVec();                         59   PrintAlongStepDoItVec();
 53                                                    60 
 54   G4cout << "  The initial PostStep Vectors: "     61   G4cout << "  The initial PostStep Vectors: " << G4endl;
 55   PrintPostStepGPILVec();                          62   PrintPostStepGPILVec();
 56   PrintPostStepDoItVec();                          63   PrintPostStepDoItVec();
 57                                                    64 
 58   GetProcessManager()->RemoveProcess(process);     65   GetProcessManager()->RemoveProcess(process);
 59                                                    66 
 60   G4cout << "  The final AlongStep Vectors: "      67   G4cout << "  The final AlongStep Vectors: " << G4endl;
 61   PrintAlongStepGPILVec();                         68   PrintAlongStepGPILVec();
 62   PrintAlongStepDoItVec();                         69   PrintAlongStepDoItVec();
 63                                                    70 
 64   G4cout << "  The final PostStep Vectors: " <     71   G4cout << "  The final PostStep Vectors: " << G4endl;
 65   PrintPostStepGPILVec();                          72   PrintPostStepGPILVec();
 66   PrintPostStepDoItVec();                          73   PrintPostStepDoItVec();
 67                                                    74 
 68   G4cout << "=================================     75   G4cout << "================================================" << G4endl;
 69                                                    76   
 70 }                                                  77 }
 71                                                    78 
 72 void G4ProcessPlacer::AddProcessAs(G4VProcess* <<  79 void G4ProcessPlacer::AddProcessAs(G4VProcess *process, SecondOrLast sol)
 73 {                                                  80 {
 74   G4cout << "  Modifying Process Order for Pro     81   G4cout << "  Modifying Process Order for ProcessName: " << process->GetProcessName() << G4endl;
 75                                                    82 
 76   G4cout << "  The initial AlongStep Vectors:      83   G4cout << "  The initial AlongStep Vectors: " << G4endl;
 77   PrintAlongStepGPILVec();                         84   PrintAlongStepGPILVec();
 78   PrintAlongStepDoItVec();                         85   PrintAlongStepDoItVec();
 79                                                    86 
 80   G4cout << "The initial PostStep Vectors: " <     87   G4cout << "The initial PostStep Vectors: " << G4endl;
 81   PrintPostStepGPILVec();                          88   PrintPostStepGPILVec();
 82   PrintPostStepDoItVec();                          89   PrintPostStepDoItVec();
 83                                                    90 
 84   if (sol == eLast)                                91   if (sol == eLast)
 85   {                                                92   {  
 86     GetProcessManager()->AddProcess(process, o     93     GetProcessManager()->AddProcess(process, ordInActive, ordInActive, ordLast);
 87   }                                                94   } 
 88   else if (sol == eSecond)                         95   else if (sol == eSecond)
 89   {                                                96   {
 90     // get transportation process                  97     // get transportation process
 91     G4VProcess *transportation =                   98     G4VProcess *transportation = 
 92      (* (GetProcessManager()->GetProcessList()     99      (* (GetProcessManager()->GetProcessList()))[0];
 93                                                   100 
 94     if (!transportation)                          101     if (!transportation)
 95     {                                             102     {
 96       G4Exception("G4ProcessPlacer::AddProcess    103       G4Exception("G4ProcessPlacer::AddProcessAs","Bias0001",RunMustBeAborted," could not get process id=0");
 97     }                                             104     }
 98     if (transportation->GetProcessName() != "T    105     if (transportation->GetProcessName() != "Transportation" && transportation->GetProcessName() != "Transportation8" && transportation->GetProcessName() != "CoupledTransportation")
 99     {                                             106     {
100       //      G4cout << " GOT HERE CoupledTran    107       //      G4cout << " GOT HERE CoupledTransportation" << G4endl;
101       G4cout << transportation->GetProcessName    108       G4cout << transportation->GetProcessName() << G4endl;
102       G4Exception("G4ProcessPlacer::AddProcess    109       G4Exception("G4ProcessPlacer::AddProcessAs","Bias0002",RunMustBeAborted," process id=0 is not Transportation");
103     }                                             110     }
104                                                   111 
105     // place the given proces as first for the    112     // place the given proces as first for the moment
106     // 31/5/11 previously set to first, then t    113     // 31/5/11 previously set to first, then transportation set ahead of it, 
107     // which is more conveniently correctly se    114     // which is more conveniently correctly set with placing it second!
108     GetProcessManager()->AddProcess(process);     115     GetProcessManager()->AddProcess(process);
109     GetProcessManager()->SetProcessOrderingToS    116     GetProcessManager()->SetProcessOrderingToSecond(process, 
110                                                   117                                                   idxAlongStep);
111     GetProcessManager()->SetProcessOrderingToS    118     GetProcessManager()->SetProcessOrderingToSecond(process, 
112                                                   119                                                   idxPostStep);
                                                   >> 120     // xx test
                                                   >> 121     //     if(process->GetProcessName() == "ImportanceProcess") 
                                                   >> 122     //bug31/10/07    GetProcessManager()->SetProcessOrdering(process, 
                                                   >> 123     //bug31/10/07             idxAlongStep, 1);
                                                   >> 124     // place transportation first again
                                                   >> 125 //     GetProcessManager()->SetProcessOrderingToFirst(transportation, 
                                                   >> 126 //                                                   idxAlongStep);
                                                   >> 127 //     GetProcessManager()->SetProcessOrderingToFirst(transportation, 
                                                   >> 128 //                                                   idxPostStep);
113   }                                               129   }
114                                                   130   
115   // for verification inly                        131   // for verification inly
116   G4cout << "  The final AlongStep Vectors: "     132   G4cout << "  The final AlongStep Vectors: " << G4endl;
117   PrintAlongStepGPILVec();                        133   PrintAlongStepGPILVec();
118   PrintAlongStepDoItVec();                        134   PrintAlongStepDoItVec();
119                                                   135 
120   G4cout << "The final PostStep Vectors: " <<     136   G4cout << "The final PostStep Vectors: " << G4endl;
121   PrintPostStepGPILVec();                         137   PrintPostStepGPILVec();
122   PrintPostStepDoItVec();                         138   PrintPostStepDoItVec();
123                                                   139   
124   G4cout << "=================================    140   G4cout << "================================================" << G4endl;
125 }                                                 141 }
126                                                   142 
127 void G4ProcessPlacer::AddProcessAsSecondDoIt(G << 143 void G4ProcessPlacer::AddProcessAsSecondDoIt(G4VProcess *process)
128 {                                                 144 {
129   G4cout << "=== G4ProcessPlacer::AddProcessAs    145   G4cout << "=== G4ProcessPlacer::AddProcessAsSecondDoIt: for: " 
130          << fParticleName << G4endl;              146          << fParticleName << G4endl;
131   AddProcessAs(process, eSecond);                 147   AddProcessAs(process, eSecond);
132 }                                                 148 }
133                                                   149 
134 void G4ProcessPlacer::AddProcessAsLastDoIt(G4V << 150 void G4ProcessPlacer::AddProcessAsLastDoIt(G4VProcess *process)
135 {                                                 151 {
136   G4cout << "=== G4ProcessPlacer::AddProcessAs    152   G4cout << "=== G4ProcessPlacer::AddProcessAsLastDoIt: for: " 
137          << fParticleName << G4endl;              153          << fParticleName << G4endl;
138   AddProcessAs(process, eLast);                   154   AddProcessAs(process, eLast);
139 }                                                 155 }
140                                                   156 
141 G4ProcessManager* G4ProcessPlacer::GetProcessM << 157 G4ProcessManager *G4ProcessPlacer::GetProcessManager()
142 {                                                 158 { 
143   // get particle iterator to add processes --    159   // get particle iterator to add processes ---------------------
144   G4ParticleTable* theParticleTable = nullptr; << 160   G4ParticleTable* theParticleTable = 0;
145   G4ParticleTable::G4PTblDicIterator* theParti << 161   G4ParticleTable::G4PTblDicIterator* theParticleIterator = 0;
146   theParticleTable = G4ParticleTable::GetParti    162   theParticleTable = G4ParticleTable::GetParticleTable();
147   theParticleIterator = theParticleTable->GetI    163   theParticleIterator = theParticleTable->GetIterator();
148   // -----------------------------------------    164   // -------------------------------------------------------
149   G4ProcessManager* processmanager = nullptr;  << 165   G4ProcessManager *processmanager = 0;
150   // find process manager --------------------    166   // find process manager ---------------------------
151   theParticleIterator->reset();                   167   theParticleIterator->reset();
152   while( (*theParticleIterator)() ) /* while c << 168   while( (*theParticleIterator)() )
153   {                                               169   {
154     G4ParticleDefinition* particle = thePartic    170     G4ParticleDefinition* particle = theParticleIterator->value();
155     if (particle->GetParticleName() == fPartic    171     if (particle->GetParticleName() == fParticleName)
156     {                                             172     {
157       processmanager =  particle->GetProcessMa    173       processmanager =  particle->GetProcessManager();
158       break;                                      174       break;
159     }                                             175     }
160   }                                               176   }
161   // -----------------------------------------    177   // ---------------------------------------------------------
162   if (!processmanager)                            178   if (!processmanager)
163   {                                               179   {
164     G4Exception("G4ProcessPlacer::GetProcessMa    180     G4Exception("G4ProcessPlacer::GetProcessManager()", "InvalidSetup",
165                 FatalException, "NULL pointer     181                 FatalException, "NULL pointer to Process Manager ! Sampler.Configure() must be after PhysicsList instantiation");
166   }                                               182   }
167   return processmanager;                          183   return processmanager;
168 }                                                 184 }
169                                                   185 
170 void G4ProcessPlacer::PrintAlongStepGPILVec()     186 void G4ProcessPlacer::PrintAlongStepGPILVec()
171 {                                                 187 {
172   G4cout << "GPIL Vector: " << G4endl;            188   G4cout << "GPIL Vector: " << G4endl;
173   G4ProcessVector* processGPILVec =               189   G4ProcessVector* processGPILVec = 
174     GetProcessManager()->GetAlongStepProcessVe    190     GetProcessManager()->GetAlongStepProcessVector(typeGPIL);
175   PrintProcVec(processGPILVec);                   191   PrintProcVec(processGPILVec);
176 }                                                 192 } 
177                                                   193 
178 void G4ProcessPlacer::PrintAlongStepDoItVec()     194 void G4ProcessPlacer::PrintAlongStepDoItVec()
179 {                                                 195 {
180   G4cout << "DoIt Vector: " << G4endl;            196   G4cout << "DoIt Vector: " << G4endl;
181   G4ProcessVector* processDoItVec =               197   G4ProcessVector* processDoItVec = 
182     GetProcessManager()->GetAlongStepProcessVe    198     GetProcessManager()->GetAlongStepProcessVector(typeDoIt); 
183   PrintProcVec(processDoItVec);                   199   PrintProcVec(processDoItVec);
184 }                                                 200 }
185                                                   201 
186                                                   202 
187 void G4ProcessPlacer::PrintPostStepGPILVec()      203 void G4ProcessPlacer::PrintPostStepGPILVec()
188 {                                                 204 {
189   G4cout << "GPIL Vector: " << G4endl;            205   G4cout << "GPIL Vector: " << G4endl;
190   G4ProcessVector* processGPILVec =               206   G4ProcessVector* processGPILVec = 
191     GetProcessManager()->GetPostStepProcessVec    207     GetProcessManager()->GetPostStepProcessVector(typeGPIL);
192   PrintProcVec(processGPILVec);                   208   PrintProcVec(processGPILVec);
193 }                                                 209 } 
194                                                   210 
195 void G4ProcessPlacer::PrintPostStepDoItVec()      211 void G4ProcessPlacer::PrintPostStepDoItVec()
196 {                                                 212 {
197   G4cout << "DoIt Vector: " << G4endl;            213   G4cout << "DoIt Vector: " << G4endl;
198   G4ProcessVector* processDoItVec =               214   G4ProcessVector* processDoItVec = 
199     GetProcessManager()->GetPostStepProcessVec    215     GetProcessManager()->GetPostStepProcessVector(typeDoIt); 
200   PrintProcVec(processDoItVec);                   216   PrintProcVec(processDoItVec);
201 }                                                 217 }
202                                                   218 
203                                                   219 
204 void G4ProcessPlacer::PrintProcVec(G4ProcessVe    220 void G4ProcessPlacer::PrintProcVec(G4ProcessVector* processVec)
205 {                                                 221 {
206   if (!processVec)                                222   if (!processVec)
207   {                                               223   {
208     G4Exception("G4ProcessPlacer::G4ProcessPla    224     G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidArgument",
209                 FatalException, "NULL pointer     225                 FatalException, "NULL pointer to process-vector !");
210   }                                               226   }
211   G4int len = (G4int)processVec->length();     << 227   size_t len = processVec->length();
212   if (len==0)                                     228   if (len==0)
213   {                                               229   {
214     G4Exception("G4ProcessPlacer::G4ProcessPla    230     G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidSetup",
215                 FatalException, "Length of pro    231                 FatalException, "Length of process-vector is zero !");
216   }                                               232   }
217   for (G4int i=0; i<len; ++i)                  << 233   for (size_t i=0; i<len; i++)
218   {                                               234   {
219     G4VProcess *p = (*processVec)[i];             235     G4VProcess *p = (*processVec)[i];
220     if (p)                                        236     if (p)
221     {                                             237     {
222       G4cout << "   " << p->GetProcessName() <    238       G4cout << "   " << p->GetProcessName() << G4endl;
223     }                                             239     } 
224     else                                          240     else
225     {                                             241     {
226       G4cout << "   " << "no process found for    242       G4cout << "   " << "no process found for position: " << i 
227              << ", in vector of length: " << l    243              << ", in vector of length: " << len << G4endl;
228     }                                             244     }
229   }                                               245   }
230 }                                                 246 }
231                                                   247