Geant4 Cross Reference |
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 // G4ProcessTable class implementation << 27 // 23 // 28 // Author: H.Kurashige, 4 August 1998 << 24 // $Id: G4ProcessTable.cc,v 1.11 2004/06/12 13:07:19 kurasige Exp $ 29 // ------------------------------------------- << 25 // GEANT4 tag $Name: geant4-07-00-cand-01 $ >> 26 // >> 27 // >> 28 // ------------------------------------------------------------ >> 29 // GEANT 4 class header file >> 30 // >> 31 // History: first implementation, based on object model of >> 32 // 4th Aug 1998, H.Kurashige >> 33 // ------------------------------------------------------------ >> 34 // History: >> 35 // Use STL vector instead of RW vector 1. Mar 00 H.Kurashige >> 36 // 30 37 31 #include "G4ProcessTableMessenger.hh" 38 #include "G4ProcessTableMessenger.hh" 32 #include "G4ProcessTable.hh" 39 #include "G4ProcessTable.hh" 33 #include "G4ParticleTable.hh" << 34 #include "G4ios.hh" << 35 << 36 // ------------------------------------------- << 37 // Static class variable: ptr to single instan << 38 G4ThreadLocal G4ProcessTable* G4ProcessTable:: << 39 40 40 // ------------------------------------------- << 41 // constructor ////////////////////////// 41 // Default constructor << 42 G4ProcessTable::G4ProcessTable():verboseLevel(1) 42 // << 43 G4ProcessTable::G4ProcessTable() << 44 { 43 { 45 #ifdef G4VERBOSE 44 #ifdef G4VERBOSE 46 if (verboseLevel>1) << 45 if (verboseLevel>1){ 47 { << 48 G4cout << "-- G4ProcessTable constructor 46 G4cout << "-- G4ProcessTable constructor --" << G4endl; 49 } 47 } 50 #endif 48 #endif 51 fProcTblVector = new G4ProcTableVector(); 49 fProcTblVector = new G4ProcTableVector(); 52 fProcNameVector = new G4ProcNameVector(); 50 fProcNameVector = new G4ProcNameVector(); 53 tmpTblVector = new G4ProcTableVector(); 51 tmpTblVector = new G4ProcTableVector(); 54 fProcTblMessenger = new G4ProcessTableMessen << 52 fProcTblMessenger = 0; 55 } 53 } 56 54 57 // ------------------------------------------- << 55 // copy constructor ////////////////////////// 58 // Destructor << 56 G4ProcessTable::G4ProcessTable(const G4ProcessTable &) 59 // << 57 { >> 58 #ifdef G4VERBOSE >> 59 if (verboseLevel>0){ >> 60 G4cout << "-- G4ProcessTable copy constructor --" << G4endl; >> 61 } >> 62 #endif >> 63 } >> 64 >> 65 // destructor ////////////////////////// 60 G4ProcessTable::~G4ProcessTable() 66 G4ProcessTable::~G4ProcessTable() 61 { 67 { 62 if ( tmpTblVector != nullptr ) << 68 #ifdef G4VERBOSE 63 { << 69 if (verboseLevel>1){ >> 70 G4cout << "-- G4ProcessTable destructor --" << G4endl; >> 71 } >> 72 >> 73 #endif >> 74 if ( tmpTblVector != 0) { 64 tmpTblVector ->clear(); 75 tmpTblVector ->clear(); 65 delete tmpTblVector; 76 delete tmpTblVector; 66 tmpTblVector = nullptr; << 67 } 77 } 68 78 69 if ( fProcTblVector != nullptr ) << 79 if ( fProcTblVector != 0) { 70 { << 80 G4ProcTableVector::iterator idx; 71 for (auto elem : *fProcTblVector) << 81 72 { << 82 // destruction of processes has moved to G4VUserPhysicsList 73 delete elem; << 83 for (idx=fProcTblVector->begin(); idx!=fProcTblVector->end(); ++idx) { >> 84 // delete all processes >> 85 // delete (*idx)->GetProcess(); >> 86 delete (*idx); 74 } 87 } 75 fProcTblVector ->clear(); 88 fProcTblVector ->clear(); 76 delete fProcTblVector; 89 delete fProcTblVector; 77 fProcTblVector = nullptr; << 78 } 90 } 79 91 80 // delete all process except transportation << 92 if ( fProcNameVector != 0) { 81 for(auto proc : fListProcesses) << 93 fProcNameVector ->clear(); 82 { << 94 delete fProcNameVector; 83 if ( proc != nullptr ) << 84 { << 85 G4ProcessType type = proc->GetProcessTyp << 86 if (type != fTransportation && type != f << 87 && type != fParameterisation) << 88 { << 89 delete proc; << 90 } << 91 } << 92 } 95 } >> 96 fProcessTable =0; >> 97 } 93 98 94 fListProcesses.clear(); << 99 ///////////////////////// >> 100 G4UImessenger* G4ProcessTable::CreateMessenger() >> 101 { >> 102 if (fProcTblMessenger == 0) { >> 103 fProcTblMessenger = new G4ProcessTableMessenger(this); >> 104 } >> 105 return fProcTblMessenger; >> 106 } 95 107 96 if ( fProcNameVector != nullptr ) << 108 ///////////////////////// 97 { << 109 void G4ProcessTable::DeleteMessenger() 98 fProcNameVector ->clear(); << 110 { 99 delete fProcNameVector; << 111 if (fProcTblMessenger != 0) { 100 fProcNameVector = nullptr; << 112 delete fProcTblMessenger; 101 } 113 } 102 fProcessTable = nullptr; << 103 delete fProcTblMessenger; << 104 } 114 } 105 115 106 // ------------------------------------------- << 116 107 // << 117 ////////////////////////// 108 G4ProcessTable* G4ProcessTable::GetProcessTabl << 118 G4ProcessTable & G4ProcessTable::operator=(const G4ProcessTable &right) 109 { 119 { 110 if(fProcessTable == nullptr) << 120 #ifdef G4VERBOSE 111 { << 121 if (verboseLevel>0){ 112 static G4ThreadLocalSingleton<G4ProcessTab << 122 G4cout << "-- G4ProcessTable assignment operator --" << G4endl; 113 fProcessTable = inst.Instance(); << 114 } 123 } 115 return fProcessTable; << 124 #endif >> 125 if (&right == this) return *this; >> 126 else return *this; 116 } 127 } 117 128 118 // ------------------------------------------- << 129 ////////////////////////// 119 // << 130 G4int G4ProcessTable::operator==(const G4ProcessTable &right) const 120 G4int G4ProcessTable::Insert(G4VProcess* aProc << 131 { 121 G4ProcessManager* << 132 return (this == &right); >> 133 } >> 134 >> 135 ////////////////////////// >> 136 G4int G4ProcessTable::operator!=(const G4ProcessTable &right) const >> 137 { >> 138 return (this != &right); >> 139 } >> 140 >> 141 // Static class variable: ptr to single instance of class >> 142 G4ProcessTable* G4ProcessTable::fProcessTable =0; >> 143 >> 144 >> 145 ////////////////////////// >> 146 G4ProcessTable* G4ProcessTable::GetProcessTable() >> 147 { >> 148 static G4ProcessTable theProcessTable; >> 149 if (!fProcessTable){ >> 150 fProcessTable = &theProcessTable; >> 151 } >> 152 return fProcessTable; >> 153 } >> 154 >> 155 ////////////////////////// >> 156 G4int G4ProcessTable::Insert(G4VProcess* aProcess, >> 157 G4ProcessManager* aProcMgr) 122 { 158 { 123 if ( (aProcess == nullptr) || ( aProcMgr == << 159 if ( (aProcess == 0) || ( aProcMgr == 0 ) ){ 124 { << 125 #ifdef G4VERBOSE 160 #ifdef G4VERBOSE 126 if (verboseLevel>0) << 161 if (verboseLevel>0){ 127 { << 162 G4cout << "G4ProcessTable::Insert : arguments are 0 pointer "<<G4endl; 128 G4cout << "G4ProcessTable::Insert() - ar << 129 << aProcess << "," << aProcMgr << << 130 } 163 } 131 #endif 164 #endif 132 return -1; 165 return -1; 133 } 166 } 134 167 135 #ifdef G4VERBOSE 168 #ifdef G4VERBOSE 136 if (verboseLevel>1) << 169 if (verboseLevel>1){ 137 { << 170 G4cout << "G4ProcessTable::Insert "; 138 G4cout << "G4ProcessTable::Insert() -"; << 139 G4cout << " Process[" << aProcess->GetPro 171 G4cout << " Process[" << aProcess->GetProcessName() << "]"; 140 G4cout << " Particle[" << aProcMgr->GetPa << 172 G4cout << " Particle[" << aProcMgr->GetParticleType()->GetParticleName() << "]"; 141 << "]" << G4endl; << 173 G4cout << G4endl; 142 } 174 } 143 #endif 175 #endif 144 176 145 G4int idxTbl = 0; << 177 G4ProcTableVector::iterator itr; 146 G4int nidx = (G4int)fProcTblVector->size(); << 178 G4int idxTbl=0; 147 G4ProcTblElement* anElement = nullptr; << 179 G4ProcTblElement* anElement; >> 180 G4bool isFoundInTbl = false; 148 // loop over all elements 181 // loop over all elements 149 for (; idxTbl < nidx; ++idxTbl) << 182 for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr, ++idxTbl) { 150 { << 183 anElement = (*itr); 151 anElement = (*fProcTblVector)[idxTbl]; << 152 if(!anElement) { continue; } << 153 // check if this process is included 184 // check if this process is included 154 if (aProcess == anElement->GetProcess()) << 185 if (aProcess == anElement->GetProcess()) { 155 { << 186 isFoundInTbl = true; >> 187 156 // add the process manager into the elem 188 // add the process manager into the element 157 // unless this process manager is inclu << 189 // unless this process manager is included 158 if (!anElement->Contains(aProcMgr)) << 190 if (!anElement->Contains(aProcMgr)) { 159 { << 191 anElement->Insert(aProcMgr); 160 anElement->Insert(aProcMgr); << 192 #ifdef G4VERBOSE 161 #ifdef G4VERBOSE << 193 if (verboseLevel>2){ 162 if (verboseLevel>2) << 194 G4cout << " This Process Manager is registered !! " << G4endl; 163 { << 195 } 164 G4cout << " This Process Manager is << 165 } << 166 #endif 196 #endif 167 } 197 } 168 return idxTbl; << 198 break; 169 } 199 } 170 } 200 } 171 // add this process into the table by creati 201 // add this process into the table by creating a new element 172 if (verboseLevel>2) << 202 if (!isFoundInTbl) { 173 { << 203 G4ProcTblElement* newElement = new G4ProcTblElement(aProcess); 174 G4cout << " New element is created !! " << << 204 newElement->Insert(aProcMgr); 175 } << 205 fProcTblVector->push_back(newElement); 176 anElement = new G4ProcTblElement(aProcess); << 206 // add into name vector 177 anElement->Insert(aProcMgr); << 207 G4ProcNameVector::iterator ip; 178 fProcTblVector->push_back(anElement); << 208 G4bool isFound = false; 179 fProcNameVector->push_back(aProcess->GetProc << 209 for (ip=fProcNameVector->begin(); ip!=fProcNameVector->end(); ++ip) { 180 return nidx; << 210 isFound |= (aProcess->GetProcessName() == (*ip)); >> 211 } >> 212 if (!isFound) { >> 213 fProcNameVector->push_back(aProcess->GetProcessName() ); >> 214 #ifdef G4VERBOSE >> 215 if (verboseLevel>2){ >> 216 G4cout << " This Process is registered !! " << G4endl; >> 217 } >> 218 #endif >> 219 } >> 220 } >> 221 return idxTbl; 181 } 222 } 182 223 183 // ------------------------------------------- << 224 ////////////////////////// 184 // << 225 G4int G4ProcessTable::Remove( G4VProcess* aProcess, 185 G4int G4ProcessTable::Remove( G4VProcess* aPro << 226 G4ProcessManager* aProcMgr) 186 G4ProcessManager << 187 { 227 { 188 if ( (aProcess == nullptr) || ( aProcMgr == << 228 if ( (aProcess == 0) || ( aProcMgr == 0 ) ){ 189 { << 190 #ifdef G4VERBOSE 229 #ifdef G4VERBOSE 191 if (verboseLevel>0) << 230 if (verboseLevel>0){ 192 { << 231 G4cout << "G4ProcessTable::Remove : arguments are 0 pointer "<< G4endl; 193 G4cout << "G4ProcessTable::Remove() - ar << 194 << G4endl; << 195 } 232 } 196 #endif 233 #endif 197 return -1; 234 return -1; 198 } 235 } 199 236 200 #ifdef G4VERBOSE 237 #ifdef G4VERBOSE 201 if (verboseLevel>1) << 238 if (verboseLevel>1){ 202 { << 239 G4cout << "G4ProcessTable::Remove "; 203 G4cout << "G4ProcessTable::Remove() -"; << 204 G4cout << " Process[" << aProcess->GetPro 240 G4cout << " Process[" << aProcess->GetProcessName() << "]"; 205 G4cout << " Particle[" << aProcMgr->GetPar << 241 G4cout << " Particle[" << aProcMgr->GetParticleType()->GetParticleName() << "]" << G4endl; 206 << "]" << G4endl; << 207 } 242 } 208 #endif 243 #endif 209 244 210 G4int idxTbl = 0; << 245 G4ProcTableVector::iterator itr; 211 G4int nidx = (G4int)fProcTblVector->size(); << 246 G4int idxTbl=0; 212 G4ProcTblElement* anElement =nullptr; << 247 G4ProcTblElement* anElement=0; >> 248 G4bool isFound = false; 213 // loop over all elements 249 // loop over all elements 214 for (; idxTbl < nidx; ++idxTbl) << 250 for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr, ++idxTbl) { 215 { << 251 anElement = (*itr); 216 anElement = (*fProcTblVector)[idxTbl]; << 217 if(!anElement) { continue; } << 218 252 219 // check if this process is included 253 // check if this process is included 220 if (aProcess == anElement->GetProcess()) << 254 if (aProcess == anElement->GetProcess()) { 221 { << 255 isFound = anElement->Contains(aProcMgr); 222 if(anElement->Contains(aProcMgr)) << 256 // remove the process manager from the element 223 { << 257 anElement->Remove(aProcMgr); 224 // remove the process manager from the << 258 #ifdef G4VERBOSE 225 anElement->Remove(aProcMgr); << 259 if (verboseLevel>2){ 226 #ifdef G4VERBOSE << 260 G4cout << " This Process Manager is removed !! " << G4endl; 227 if (verboseLevel>2) << 228 { << 229 G4cout << " This Process Manager is << 230 } << 231 #endif << 232 if(anElement->Length() == 0) << 233 { << 234 delete anElement; << 235 (*fProcTblVector)[idxTbl] = nullptr; << 236 #ifdef G4VERBOSE << 237 if (verboseLevel>1) << 238 { << 239 G4cout << " This Process is remove << 240 } << 241 #endif << 242 } << 243 return idxTbl; << 244 } 261 } >> 262 #endif >> 263 break; 245 } 264 } 246 } 265 } >> 266 // >> 267 if (!isFound) { 247 #ifdef G4VERBOSE 268 #ifdef G4VERBOSE 248 if (verboseLevel>1) << 269 if (verboseLevel>0){ 249 { << 270 G4cout << " This Process Manager is not registered !! " << G4endl; 250 G4cout << " This Process Manager is not re << 271 } 251 << G4endl; << 252 } << 253 #endif 272 #endif 254 return -1; << 273 return -1; 255 } << 256 << 257 // ------------------------------------------- << 258 // << 259 void G4ProcessTable::RegisterProcess(G4VProces << 260 { << 261 for(auto proc : fListProcesses) << 262 { << 263 if(ptr == proc) { return; } << 264 } 274 } 265 fListProcesses.push_back(ptr); << 275 // remove the element if it has no entry 266 } << 276 if (anElement->Length() == 0){ 267 << 277 fProcTblVector->erase(itr); 268 // ------------------------------------------- << 278 delete anElement; 269 // << 279 // check other prcesses with same name exist or not 270 void G4ProcessTable::DeRegisterProcess(G4VProc << 280 G4bool isSameName = false; 271 { << 281 for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr) { 272 std::size_t nn = fListProcesses.size(); << 282 anElement = (*itr); 273 for(std::size_t i=0; i<nn; ++i) << 283 if (anElement->GetProcessName() == aProcess->GetProcessName()) { 274 { << 284 isSameName = true; 275 if(ptr == fListProcesses[i]) << 285 break; 276 { << 286 } 277 fListProcesses[i] = nullptr; << 278 return; << 279 } 287 } 280 } << 288 // remove from name vector 281 } << 289 if (!isSameName ) { 282 << 290 G4ProcNameVector::iterator i; 283 // ------------------------------------------- << 291 for (i=fProcNameVector->begin(); i!=fProcNameVector->end(); ++i) { 284 // << 292 if ( *i == aProcess->GetProcessName() ) { 285 G4VProcess* G4ProcessTable::FindProcess(const << 293 fProcNameVector->erase(i); 286 const << 294 break; 287 { << 295 } 288 return FindProcess(processName, << 296 } 289 G4ParticleTable::GetParticleTable()- << 290 } << 291 << 292 // ------------------------------------------- << 293 // << 294 G4VProcess* G4ProcessTable::FindProcess(const << 295 const << 296 const << 297 { << 298 for (auto anElement : *fProcTblVector) << 299 { << 300 // check name and if the processManage is << 301 if (anElement && anElement->GetProcessName << 302 && anElement->Contains(processManager) << 303 { << 304 return anElement->GetProcess(); << 305 } 297 } 306 } << 307 #ifdef G4VERBOSE 298 #ifdef G4VERBOSE 308 if (verboseLevel > 1) << 299 if (verboseLevel>1){ 309 { << 300 G4cout << " This Process is removed !! " << G4endl; 310 G4cout << " G4ProcessTable::FindProcess() << 311 G4cout << " The Process[" << processName < << 312 G4cout << " for [" << processManager->GetP << 313 << "]" << G4endl; << 314 } << 315 #endif << 316 return nullptr; << 317 } << 318 << 319 // ------------------------------------------- << 320 // << 321 G4VProcess* << 322 G4ProcessTable::FindProcess(G4ProcessType proc << 323 const G4ParticleDe << 324 { << 325 // find the first process of given type for << 326 << 327 const G4ProcessManager* processManager = par << 328 for (auto anElement : *fProcTblVector) << 329 { << 330 if (anElement && anElement->GetProcess()-> << 331 && anElement->Contains(processManager) << 332 { << 333 return anElement->GetProcess(); << 334 } 301 } 335 } << 336 #ifdef G4VERBOSE << 337 if (verboseLevel > 1) << 338 { << 339 G4cout << " G4ProcessTable::FindProcess() << 340 G4cout << " The Process Type " << processT << 341 G4cout << " for [" << particle->GetParticl << 342 } << 343 #endif 302 #endif 344 return nullptr; << 303 } >> 304 return idxTbl; 345 } 305 } 346 306 347 // ------------------------------------------- << 307 ////////////////////////// 348 // << 308 G4VProcess* G4ProcessTable::FindProcess(const G4String& processName, 349 G4VProcess* << 309 const G4ProcessManager* processManager) 350 G4ProcessTable::FindProcess(G4int procSubType, << 310 const 351 const G4ParticleDe << 352 { 311 { 353 // find the first process of given type for << 312 G4ProcTableVector::iterator itr; 354 << 313 G4int idxTbl = 0; 355 const G4ProcessManager* processManager = par << 314 G4bool isFound = false; 356 for (auto anElement : *fProcTblVector) << 315 G4ProcTblElement* anElement=0; 357 { << 316 for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr, ++idxTbl) { 358 if ( anElement != nullptr << 317 anElement = (*itr); 359 && anElement->GetProcess()->GetProcessSu << 318 // check name 360 && anElement->Contains(processManager) ) << 319 if ( anElement->GetProcessName() == processName ) { 361 { << 320 // check if the processManage is included 362 return anElement->GetProcess(); << 321 if ( anElement->Contains(processManager) ) { >> 322 isFound = true; >> 323 break; >> 324 } 363 } 325 } 364 } 326 } 365 #ifdef G4VERBOSE 327 #ifdef G4VERBOSE 366 if (verboseLevel > 1) << 328 if (!isFound && verboseLevel>1){ 367 { << 329 G4cout << " G4ProcessTable::FindProcess :" ; 368 G4cout << " G4ProcessTable::FindProcess() << 330 G4cout << " The Process[" << processName << "] is not found "; 369 G4cout << " The Process SubType " << procS << 331 G4cout << " for " << processManager->GetParticleType()->GetParticleName() << G4endl; 370 G4cout << " for [" << particle->GetParticl << 371 } 332 } 372 #endif 333 #endif 373 return nullptr; << 334 >> 335 if (isFound) return anElement->GetProcess(); >> 336 else return 0; 374 } 337 } 375 338 376 // ------------------------------------------- << 339 /////////////// 377 // << 340 G4ProcessTable::G4ProcTableVector* G4ProcessTable::Find( 378 G4ProcessTable::G4ProcTableVector* << 341 G4ProcTableVector*, 379 G4ProcessTable::Find(const G4String& processNa << 342 const G4String& processName ) 380 { 343 { 381 tmpTblVector->clear(); 344 tmpTblVector->clear(); 382 345 >> 346 G4ProcTableVector::iterator itr; 383 G4bool isFound = false; 347 G4bool isFound = false; 384 G4ProcTblElement* anElement = nullptr; << 348 G4ProcTblElement* anElement; 385 for (auto itr=fProcTblVector->cbegin(); itr! << 349 for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr) { 386 { << 387 anElement = (*itr); 350 anElement = (*itr); 388 // check name 351 // check name 389 if ( anElement != nullptr && anElement->Ge << 352 if ( anElement->GetProcessName() == processName ) { 390 { << 391 isFound = true; 353 isFound = true; 392 tmpTblVector->push_back(anElement); 354 tmpTblVector->push_back(anElement); 393 } 355 } 394 } 356 } 395 357 396 if (!isFound && verboseLevel>0) << 397 { << 398 #ifdef G4VERBOSE 358 #ifdef G4VERBOSE 399 G4cout << " G4ProcessTable::Find() -" ; << 359 if (!isFound && verboseLevel>0){ >> 360 G4cout << " G4ProcessTable::Find :" ; 400 G4cout << " The Process[" << processName < 361 G4cout << " The Process[" << processName << "] is not found " << G4endl; 401 #endif << 402 } 362 } 403 << 363 #endif >> 364 404 return tmpTblVector; 365 return tmpTblVector; 405 } << 406 366 407 // ------------------------------------------- << 367 } 408 // << 368 /////////////// 409 G4ProcessTable::G4ProcTableVector* << 369 G4ProcessTable::G4ProcTableVector* G4ProcessTable::Find( 410 G4ProcessTable::Find(G4ProcessType processType << 370 G4ProcTableVector*, >> 371 G4ProcessType processType ) 411 { 372 { 412 tmpTblVector->clear(); 373 tmpTblVector->clear(); 413 374 >> 375 G4ProcTableVector::iterator itr; 414 G4bool isFound = false; 376 G4bool isFound = false; 415 G4ProcTblElement* anElement = nullptr; << 377 G4ProcTblElement* anElement; 416 for (auto itr=fProcTblVector->cbegin(); itr! << 378 for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr) { 417 { << 418 anElement = (*itr); 379 anElement = (*itr); 419 // check name 380 // check name 420 if ( anElement != nullptr && anElement->Ge << 381 if ( anElement->GetProcess()->GetProcessType() == processType ) { 421 { << 422 isFound = true; 382 isFound = true; 423 tmpTblVector->push_back(anElement); 383 tmpTblVector->push_back(anElement); 424 } 384 } 425 } 385 } 426 386 427 if (!isFound && verboseLevel>0) << 428 { << 429 #ifdef G4VERBOSE 387 #ifdef G4VERBOSE 430 G4cout << " G4ProcessTable::Find() -" ; << 388 if (!isFound && verboseLevel>0){ 431 G4cout << " The ProcessType[" << processTy << 389 G4cout << " G4ProcessTable::Find :" ; 432 << G4endl; << 390 G4cout << " The Process[" << anElement->GetProcessName() << "] is not found " << G4endl; 433 #endif << 434 } 391 } 435 << 392 #endif >> 393 436 return tmpTblVector; 394 return tmpTblVector; >> 395 437 } 396 } 438 397 439 // ------------------------------------------- << 398 /////////////// 440 // << 399 G4ProcessVector* G4ProcessTable::ExtractProcesses( G4ProcTableVector* procTblVector) 441 G4ProcessVector* << 442 G4ProcessTable::ExtractProcesses(G4ProcTableVe << 443 { 400 { 444 G4ProcessVector* procList = new G4ProcessVec 401 G4ProcessVector* procList = new G4ProcessVector(); >> 402 G4ProcTableVector::iterator itr; 445 // loop over all elements 403 // loop over all elements 446 for (auto itr=procTblVector->cbegin(); itr!= << 404 for (itr=procTblVector->begin(); itr!=procTblVector->end(); ++itr) { 447 { << 448 G4ProcTblElement* anElement = (*itr); 405 G4ProcTblElement* anElement = (*itr); 449 if ( anElement != nullptr) procList->inser << 406 procList->insert( anElement->GetProcess() ); 450 } 407 } 451 return procList; 408 return procList; 452 } 409 } 453 410 454 // ------------------------------------------- << 411 /////////////// 455 // << 412 G4ProcessVector* G4ProcessTable::FindProcesses() 456 void G4ProcessTable::SetProcessActivation(cons << 457 cons << 458 << 459 { 413 { 460 if (particleName == "ALL" ) << 414 return ExtractProcesses(fProcTblVector); 461 { << 462 SetProcessActivation( processName, fActive << 463 } << 464 else << 465 { << 466 SetProcessActivation(processName, << 467 G4ParticleTable::GetParticleTable()->F << 468 fActive ); << 469 } << 470 } 415 } 471 416 472 // ------------------------------------------- << 417 /////////////// 473 // << 418 G4ProcessVector* G4ProcessTable::FindProcesses( const G4ProcessManager* pManager ) 474 void G4ProcessTable::SetProcessActivation(G4Pr << 475 cons << 476 << 477 { 419 { 478 if ((particleName == "ALL" ) || (particleNam << 420 G4ProcessVector* procList = pManager->GetProcessList(); 479 { << 421 return new G4ProcessVector(*procList); 480 SetProcessActivation( processType, fActive << 481 } << 482 else << 483 { << 484 SetProcessActivation(processType, << 485 G4ParticleTable::GetParticleTable()->F << 486 fActive ); << 487 } << 488 } 422 } 489 423 490 // ------------------------------------------- << 424 /////////////// 491 // << 425 G4ProcessVector* G4ProcessTable::FindProcesses( const G4String& processName ) >> 426 { >> 427 G4ProcTableVector* pTblVector = Find(fProcTblVector, processName); >> 428 return ExtractProcesses(pTblVector); >> 429 } >> 430 >> 431 /////////////// >> 432 G4ProcessVector* G4ProcessTable::FindProcesses( G4ProcessType processType) >> 433 { >> 434 G4ProcTableVector* pTblVector = Find(fProcTblVector, processType); >> 435 return ExtractProcesses(pTblVector); >> 436 } >> 437 >> 438 /////////////// 492 void G4ProcessTable::SetProcessActivation( con 439 void G4ProcessTable::SetProcessActivation( const G4String& processName, 493 G4b << 440 G4bool fActive ) 494 { 441 { 495 #ifdef G4VERBOSE 442 #ifdef G4VERBOSE 496 if (verboseLevel>1) << 443 if (verboseLevel>1){ 497 { << 444 G4cout << " G4ProcessTable::SetProcessActivation:" ; 498 G4cout << " G4ProcessTable::SetProcessActi << 499 G4cout << " The Process[" << processName < 445 G4cout << " The Process[" << processName << "] "<< G4endl; 500 } 446 } 501 #endif 447 #endif 502 448 503 G4ProcTableVector* pTblVector = Find(proces << 449 G4ProcTableVector* pTblVector = Find(fProcTblVector, processName); >> 450 G4ProcTableVector::iterator itr; 504 G4ProcTblElement* anElement; 451 G4ProcTblElement* anElement; 505 // loop over all elements 452 // loop over all elements 506 for (auto itr=pTblVector->cbegin(); itr!=pTb << 453 for (itr=pTblVector->begin(); itr!=pTblVector->end(); ++itr) { 507 { << 508 anElement = (*itr); 454 anElement = (*itr); 509 if ( anElement == nullptr ) continue; << 510 G4VProcess* process = anElement->GetProces 455 G4VProcess* process = anElement->GetProcess(); 511 for (G4int idx = 0 ; idx < anElement->Leng << 456 for (G4int idx = 0 ; idx < anElement->Length(); idx++) { 512 { << 513 G4ProcessManager* manager = anElement->G 457 G4ProcessManager* manager = anElement->GetProcessManager(idx); 514 manager->SetProcessActivation(process, f 458 manager->SetProcessActivation(process, fActive); 515 #ifdef G4VERBOSE 459 #ifdef G4VERBOSE 516 if (verboseLevel>1) << 460 if (verboseLevel>1){ 517 { << 518 G4cout << " for " << manager->GetPart 461 G4cout << " for " << manager->GetParticleType()->GetParticleName(); 519 G4cout << " Index = " << manager->Get << 462 G4cout << " Index = " << manager->GetProcessIndex(process); 520 G4cout << G4endl; 463 G4cout << G4endl; 521 } 464 } 522 #endif 465 #endif 523 } 466 } 524 } 467 } 525 } 468 } 526 469 527 // ------------------------------------------- << 470 /////////////// 528 // << 471 void G4ProcessTable::SetProcessActivation( 529 void G4ProcessTable::SetProcessActivation(cons << 472 const G4String& processName, 530 G4Pr << 473 G4ProcessManager* processManager, 531 G4bo << 474 G4bool fActive ) 532 { 475 { 533 #ifdef G4VERBOSE 476 #ifdef G4VERBOSE 534 if (verboseLevel>1) << 477 if (verboseLevel>1){ 535 { << 478 G4cout << " G4ProcessTable::SetProcessActivation:" ; 536 G4cout << " G4ProcessTable::SetProcessActi << 537 G4cout << " The Process[" << processName < 479 G4cout << " The Process[" << processName << "] "<< G4endl; 538 } 480 } 539 #endif 481 #endif 540 482 541 G4VProcess* process = FindProcess( processNa 483 G4VProcess* process = FindProcess( processName, processManager); 542 if ( process != nullptr) << 484 if ( process != 0) { 543 { << 544 processManager->SetProcessActivation(proce 485 processManager->SetProcessActivation(process, fActive); 545 #ifdef G4VERBOSE 486 #ifdef G4VERBOSE 546 if (verboseLevel>1) << 487 if (verboseLevel>1){ 547 { << 488 G4cout << " for " << processManager->GetParticleType()->GetParticleName(); 548 G4cout << " for " << 489 G4cout << " Index = " << processManager->GetProcessIndex(process) << G4endl; 549 << processManager->GetParticleTyp << 550 G4cout << " Index = " << 551 << processManager->GetProcessInde << 552 } 490 } 553 #endif 491 #endif 554 } 492 } 555 } 493 } 556 494 557 // ------------------------------------------- << 495 558 // << 496 /////////////// 559 void G4ProcessTable::SetProcessActivation( G4P << 497 void G4ProcessTable::SetProcessActivation( G4ProcessType processType, 560 G4b << 498 G4bool fActive ) 561 { 499 { 562 #ifdef G4VERBOSE 500 #ifdef G4VERBOSE 563 if (verboseLevel>1) << 501 if (verboseLevel>1){ 564 { << 502 G4cout << " G4ProcessTable::SetProcessActivation:" ; 565 G4cout << " G4ProcessTable::SetProcessActi << 566 G4cout << " The ProcessType[" << G4int(pro 503 G4cout << " The ProcessType[" << G4int(processType) << "] "<< G4endl; 567 } 504 } 568 #endif 505 #endif 569 506 570 G4ProcTableVector* pTblVector = Find(process << 507 G4ProcTableVector* pTblVector = Find(fProcTblVector, processType); >> 508 G4ProcTableVector::iterator itr; 571 G4ProcTblElement* anElement; 509 G4ProcTblElement* anElement; 572 // loop over all elements 510 // loop over all elements 573 for (auto itr=pTblVector->cbegin(); itr!=pTb << 511 for (itr=pTblVector->begin(); itr!=pTblVector->end(); ++itr) { 574 { << 575 anElement = (*itr); 512 anElement = (*itr); 576 if ( anElement == nullptr ) continue; << 577 G4VProcess* process = anElement->GetProces 513 G4VProcess* process = anElement->GetProcess(); 578 #ifdef G4VERBOSE 514 #ifdef G4VERBOSE 579 if (verboseLevel>1) << 515 if (verboseLevel>1){ 580 { << 581 G4cout << " The Process[" << process->Ge 516 G4cout << " The Process[" << process->GetProcessName()<< "] "<< G4endl; 582 } 517 } 583 #endif 518 #endif 584 for (G4int idx = 0 ; idx < anElement->Leng << 519 for (G4int idx = 0 ; idx < anElement->Length(); idx++) { 585 { << 586 G4ProcessManager* manager = anElement->G 520 G4ProcessManager* manager = anElement->GetProcessManager(idx); 587 manager->SetProcessActivation(process, f 521 manager->SetProcessActivation(process, fActive); 588 #ifdef G4VERBOSE 522 #ifdef G4VERBOSE 589 if (verboseLevel>1) << 523 if (verboseLevel>1){ 590 { << 591 G4cout << " for " << manager->GetPart 524 G4cout << " for " << manager->GetParticleType()->GetParticleName(); 592 G4cout << " Index = " << manager->Get << 525 G4cout << " Index = " << manager->GetProcessIndex(process) << G4endl; 593 } 526 } 594 #endif 527 #endif 595 } 528 } 596 } 529 } 597 } 530 } 598 531 599 // ------------------------------------------- << 532 /////////////// 600 // << 533 void G4ProcessTable::SetProcessActivation( 601 void G4ProcessTable::SetProcessActivation( G4P << 534 G4ProcessType processType, 602 G4P << 535 G4ProcessManager* processManager, 603 G4b << 536 G4bool fActive ) 604 { 537 { 605 #ifdef G4VERBOSE 538 #ifdef G4VERBOSE 606 if (verboseLevel>1) << 539 if (verboseLevel>1){ 607 { << 540 G4cout << " G4ProcessTable::SetProcessActivation:" ; 608 G4cout << " G4ProcessTable::SetProcessActi << 609 G4cout << " The ProcessType[" << G4int(pro 541 G4cout << " The ProcessType[" << G4int(processType) << "] "<< G4endl; 610 } 542 } 611 #endif 543 #endif 612 544 613 G4ProcessVector* procList = processManager- 545 G4ProcessVector* procList = processManager->GetProcessList(); 614 for (G4int idx = 0; idx < (G4int)procList->l << 546 for (G4int idx = 0; idx < procList->length(); idx++) { 615 { << 616 G4VProcess* process = (*procList)(idx); 547 G4VProcess* process = (*procList)(idx); 617 if ( process->GetProcessType() == processT << 548 if ( process->GetProcessType() == processType) { 618 { << 619 processManager->SetProcessActivation(pro 549 processManager->SetProcessActivation(process, fActive); 620 #ifdef G4VERBOSE 550 #ifdef G4VERBOSE 621 if (verboseLevel>1) << 551 if (verboseLevel>1){ 622 { << 623 G4cout << " The Process[" << process-> 552 G4cout << " The Process[" << process->GetProcessName()<< "] "<< G4endl; 624 G4cout << " for " << 553 G4cout << " for " << processManager->GetParticleType()->GetParticleName(); 625 << processManager->GetParticleT << 554 G4cout << " Index = " << idx << G4endl; 626 G4cout << " Index = " << idx << G4end << 627 } 555 } 628 #endif 556 #endif 629 } 557 } 630 } 558 } 631 } 559 } 632 560 633 // ------------------------------------------- << 561 634 // << 562 ///////////// 635 void G4ProcessTable::DumpInfo(G4VProcess* proc 563 void G4ProcessTable::DumpInfo(G4VProcess* process, 636 const G4Particle << 564 G4ParticleDefinition* particle) 637 { 565 { >> 566 G4ProcTableVector::iterator itr; 638 G4int idxTbl=0; 567 G4int idxTbl=0; 639 G4ProcTblElement* anElement = nullptr; << 568 G4ProcTblElement* anElement=0; 640 G4bool isFoundInTbl = false; 569 G4bool isFoundInTbl = false; 641 G4ProcessManager* manager = nullptr; << 570 G4ProcessManager* manager=0; 642 G4int idx; 571 G4int idx; 643 // loop over all elements 572 // loop over all elements 644 for (auto itr=fProcTblVector->cbegin(); << 573 for (itr=fProcTblVector->begin(); itr!=fProcTblVector->end(); ++itr, ++idxTbl) { 645 itr!=fProcTblVector->cend(); ++itr << 646 { << 647 anElement = (*itr); 574 anElement = (*itr); 648 if ( anElement == nullptr ) continue; << 575 if (process == anElement->GetProcess() ){ 649 if (process == anElement->GetProcess() ) << 576 if (particle!=0) { 650 { << 577 for (idx=0; idx<anElement->Length(); idx++){ 651 if (particle != nullptr) << 578 manager = anElement->GetProcessManager(idx); 652 { << 579 if (particle == manager->GetParticleType()) { 653 for (idx=0; idx<anElement->Length(); + << 580 isFoundInTbl = true; 654 { << 581 break; 655 manager = anElement->GetProcessManag << 582 } 656 if (particle == manager->GetParticle << 583 } 657 { << 584 } else { 658 isFoundInTbl = true; << 585 isFoundInTbl = true; 659 break; << 660 } << 661 } << 662 } << 663 else << 664 { << 665 isFoundInTbl = true; << 666 } 586 } 667 break; 587 break; 668 } 588 } 669 } 589 } 670 if (!isFoundInTbl ) return; 590 if (!isFoundInTbl ) return; 671 591 672 G4int tmpVerbose = process->GetVerboseLevel( 592 G4int tmpVerbose = process->GetVerboseLevel(); 673 process->SetVerboseLevel(verboseLevel); 593 process->SetVerboseLevel(verboseLevel); 674 process->DumpInfo(); 594 process->DumpInfo(); 675 process->SetVerboseLevel(tmpVerbose); 595 process->SetVerboseLevel(tmpVerbose); 676 if (particle == nullptr) << 596 if (particle==0) { 677 { << 597 for (idx=0; idx<anElement->Length(); idx++){ 678 for (idx=0; idx<anElement->Length(); ++idx << 679 { << 680 manager = anElement->GetProcessManager(i 598 manager = anElement->GetProcessManager(idx); 681 G4cout << " for " << manager->GetParticl 599 G4cout << " for " << manager->GetParticleType()->GetParticleName(); 682 G4cout << G4endl; 600 G4cout << G4endl; 683 #ifdef G4VERBOSE << 601 if (verboseLevel >2) manager->DumpInfo(); 684 if (verboseLevel >2) << 685 { << 686 tmpVerbose = manager->GetVerboseLevel( << 687 manager->SetVerboseLevel(verboseLevel) << 688 manager->DumpInfo(); << 689 manager->SetVerboseLevel(tmpVerbose); << 690 } << 691 #endif << 692 } 602 } 693 } << 603 } else { 694 else << 695 { << 696 G4cout << " for " << manager->GetParticleT 604 G4cout << " for " << manager->GetParticleType()->GetParticleName(); 697 G4cout << G4endl; 605 G4cout << G4endl; 698 #ifdef G4VERBOSE << 606 if (verboseLevel >2) manager->DumpInfo(); 699 if (verboseLevel >2) << 700 { << 701 tmpVerbose = manager->GetVerboseLevel(); << 702 manager->SetVerboseLevel(verboseLevel); << 703 manager->DumpInfo(); << 704 manager->SetVerboseLevel(tmpVerbose); << 705 } << 706 #endif << 707 } 607 } 708 } 608 } >> 609 >> 610 >> 611 >> 612 >> 613 >> 614 709 615