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