Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4VUserPhysicsList.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4VUserPhysicsList.cc 110264 2018-05-17 14:29:16Z gcosmo $
28 //
29 //
30 // ------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 // ------------------------------------------------------------
34 // History
35 // first version 09 Jan 1998 by H.Kurashige
36 // Added SetEnergyRange 18 Jun 1998 by H.Kurashige
37 // Change for short lived particles 27 Jun 1998 by H.Kurashige
38 // G4BestUnit on output 12 nov 1998 by M.Maire
39 // Added RemoveProcessManager 9 Feb 1999 by H.Kurashige
40 // Fixed RemoveProcessManager 15 Apr 1999 by H.Kurashige
41 // Removed ConstructAllParticles() 15 Apr 1999 by H.Kurashige
42 // Modified for CUTS per REGION 10 Oct 2002 by H.Kurashige
43 // Check if particle IsShortLived 18 Jun 2003 by V.Ivanchenko
44 // Modify PreparePhysicsList 18 Jan 2006 by H.Kurashige
45 // Added PhysicsListHelper 29 APr. 2011 H.Kurashige
46 // Added default impelmentation of SetCuts 10 June 2011 H.Kurashige
47 // SetCuts is not 'pure virtual' any more
48 // Transformation for G4MT 26 Mar 2013 A. Dotti
49 // PL is shared by threads. Adding a method for workers
50 // To initialize thread specific data
51 // ------------------------------------------------------------
52 
53 #include <iomanip>
54 #include <fstream>
55 
56 #include "G4PhysicsListHelper.hh"
57 #include "G4VUserPhysicsList.hh"
58 
59 //Andrea Dotti (Jan 13, 2013), transformation for G4MT
60 #include "G4VMultipleScattering.hh"
61 #include "G4VEnergyLossProcess.hh"
62 
63 
64 #include "globals.hh"
65 #include "G4SystemOfUnits.hh"
66 #include "G4ios.hh"
67 #include "G4ParticleDefinition.hh"
68 #include "G4ProcessManager.hh"
69 #include "G4ParticleTable.hh"
70 #include "G4ProductionCutsTable.hh"
71 #include "G4Material.hh"
73 #include "G4UImanager.hh"
74 #include "G4UnitsTable.hh"
75 #include "G4RegionStore.hh"
76 #include "G4Region.hh"
77 #include "G4ProductionCutsTable.hh"
78 #include "G4ProductionCuts.hh"
79 #include "G4MaterialCutsCouple.hh"
80 
81 // This static member is thread local. For each thread, it holds the array
82 // size of G4VUPLData instances.
83 //
84 #define G4MT_theMessenger ((this->subInstanceManager.offset[this->g4vuplInstanceID])._theMessenger)
85 #define G4MT_thePLHelper ((this->subInstanceManager.offset[this->g4vuplInstanceID])._thePLHelper)
86 #define fIsPhysicsTableBuilt ((this->subInstanceManager.offset[this->g4vuplInstanceID])._fIsPhysicsTableBuilt)
87 #define fDisplayThreshold ((this->subInstanceManager.offset[this->g4vuplInstanceID])._fDisplayThreshold)
88 #define theParticleIterator ((this->subInstanceManager.offset[this->g4vuplInstanceID])._theParticleIterator)
89 
90 // This field helps to use the class G4VUPLManager
91 //
93 
95 {
97  _theMessenger = 0;
99  _fIsPhysicsTableBuilt = false;
100  _fDisplayThreshold = 0;
101 }
102 
105  :verboseLevel(1),
106  defaultCutValue(1.0 * mm),
107  isSetDefaultCutValue(false),
108  fRetrievePhysicsTable(false),
109  fStoredInAscii(true),
110  fIsCheckedForRetrievePhysicsTable(false),
111  fIsRestoredCutValues(false),
112  directoryPhysicsTable("."),
113  //fDisplayThreshold(0),
114  //fIsPhysicsTableBuilt(false),
115  fDisableCheckParticleList(false)
116 {
118  // default cut value (1.0mm)
119  defaultCutValue = 1.0*mm;
120 
121  // pointer to the particle table
123  //theParticleIterator = theParticleTable->GetIterator();
124 
125  // pointer to the cuts table
127 
128  // set energy range for SetCut calcuration
129  fCutsTable->SetEnergyRange(0.99*keV, 100*TeV);
130 
131  // UI Messenger
132  //theMessenger = new G4UserPhysicsListMessenger(this);
134 
135  // PhysicsListHelper
136  //thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
137  //thePLHelper->SetVerboseLevel(verboseLevel);
138  //G4MT_thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper(); //AND
139  G4MT_thePLHelper->SetVerboseLevel(verboseLevel); //AND
140 
141  fIsPhysicsTableBuilt = false;
142  fDisplayThreshold = 0;
143 
144 }
145 
147 {
148  //Remember messengers are per-thread, so this needs to be done by each worker
149  //and due to the presence of "this" cannot be done in G4VUPLData::initialize()
151 }
152 
154 {
156  delete G4MT_theMessenger;
157  G4MT_theMessenger = nullptr;
158 }
161 {
162  if (G4MT_theMessenger != 0) {
163  delete G4MT_theMessenger;
164  G4MT_theMessenger = 0;
165  }
167 
168  // invoke DeleteAllParticle
170 
171 }
172 
175  :verboseLevel(right.verboseLevel),
176  defaultCutValue(right.defaultCutValue),
177  isSetDefaultCutValue(right.isSetDefaultCutValue),
178  fRetrievePhysicsTable(right.fRetrievePhysicsTable),
179  fStoredInAscii(right.fStoredInAscii),
180  fIsCheckedForRetrievePhysicsTable(right.fIsCheckedForRetrievePhysicsTable),
181  fIsRestoredCutValues(right.fIsRestoredCutValues),
182  directoryPhysicsTable(right.directoryPhysicsTable),
183  //fDisplayThreshold(right.fDisplayThreshold),
184  //fIsPhysicsTableBuilt(right.fIsPhysicsTableBuilt),
185  fDisableCheckParticleList(right.fDisableCheckParticleList)
186 {
188  // pointer to the particle table
191  // pointer to the cuts table
193 
194  // UI Messenger
195  //theMessenger = new G4UserPhysicsListMessenger(this);
197 
198  // PhysicsListHelper
199  //thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
200  //thePLHelper->SetVerboseLevel(verboseLevel);
202  G4MT_thePLHelper->SetVerboseLevel(verboseLevel); //AND
203 
204  fIsPhysicsTableBuilt = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fIsPhysicsTableBuilt;
205  fDisplayThreshold = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fDisplayThreshold;
206 }
207 
208 
211 {
212  if (this != &right) {
213  verboseLevel = right.verboseLevel;
221  //fDisplayThreshold = right.fDisplayThreshold;
222  fIsPhysicsTableBuilt = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fIsPhysicsTableBuilt;
223  fDisplayThreshold = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fDisplayThreshold;
224  //fIsPhysicsTableBuilt = right.fIsPhysicsTableBuilt;
226  }
227  return *this;
228 }
229 
233 {
234  if (newParticle == 0) return;
235  G4Exception("G4VUserPhysicsList::AddProcessManager",
236  "Run0252", JustWarning,
237  "This method is obsolete");
238 }
239 
240 
243 {
244  //Request lock for particle table accesses. Some changes are inside
245  //this critical region.
246 #ifdef G4MULTITHREADED
247  G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
248  G4ParticleTable::lockCount()++;
249 #endif
251 
252  // loop over all particles in G4ParticleTable
253  theParticleIterator->reset();
254  while( (*theParticleIterator)() ){
255  G4ParticleDefinition* particle = theParticleIterator->value();
256  G4ProcessManager* pmanager = particle->GetProcessManager();
257 
258  if (pmanager==0) {
259  // create process manager if the particle does not have its own.
260  pmanager = new G4ProcessManager(particle);
261  particle->SetProcessManager(pmanager);
262  if( particle->GetMasterProcessManager() == 0 ) particle->SetMasterProcessManager(pmanager);
263 #ifdef G4VERBOSE
264  if (verboseLevel >2){
265  G4cout << "G4VUserPhysicsList::InitializeProcessManager: creating ProcessManager to "
266  << particle->GetParticleName() << G4endl;
267  }
268 #endif
269  }
270  }
271 
272  if(gion)
273  {
274  G4ProcessManager* gionPM = gion->GetProcessManager();
275  // loop over all particles once again (this time, with all general ions)
276  theParticleIterator->reset(false);
277  while( (*theParticleIterator)() ){
278  G4ParticleDefinition* particle = theParticleIterator->value();
279  if(particle->IsGeneralIon())
280  {
281  particle->SetProcessManager(gionPM);
282 #ifdef G4VERBOSE
283  if (verboseLevel >2){
284  G4cout << "G4VUserPhysicsList::InitializeProcessManager: copying ProcessManager to "
285  << particle->GetParticleName() << G4endl;
286  }
287 #endif
288  }
289  }
290  }
291 
292  //release lock for particle table accesses.
293 #ifdef G4MULTITHREADED
294  G4MUTEXUNLOCK(&G4ParticleTable::particleTableMutex());
295 #endif
296 // G4cout << "Particle table is released by G4VUserPhysicsList::InitializeProcessManager" << G4endl;
297 
298 }
299 
302 {
303  //Request lock for particle table accesses. Some changes are inside
304  //this critical region.
305 #ifdef G4MULTITHREADED
306  G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
307  G4ParticleTable::lockCount()++;
308 #endif
309 // G4cout << "Particle table is held by G4VUserPhysicsList::InitializeProcessManager" << G4endl;
310 
311  // loop over all particles in G4ParticleTable
312  theParticleIterator->reset();
313  while( (*theParticleIterator)() ){
314  G4ParticleDefinition* particle = theParticleIterator->value();
316  {
317  if(particle->GetParticleSubType()!="generic" || particle->GetParticleName()=="GenericIon")
318  {
319  G4ProcessManager* pmanager = particle->GetProcessManager();
320  if (pmanager!=0) delete pmanager;
321 #ifdef G4VERBOSE
322  if (verboseLevel >2){
323  G4cout << "G4VUserPhysicsList::RemoveProcessManager: ";
324  G4cout << "remove ProcessManager from ";
325  G4cout << particle->GetParticleName() << G4endl;
326  }
327 #endif
328  }
329  particle->SetProcessManager(0);
330  }
331  }
332 
333  //release lock for particle table accesses.
334 #ifdef G4MULTITHREADED
335  G4MUTEXUNLOCK(&G4ParticleTable::particleTableMutex());
336 #endif
337 // G4cout << "Particle table is released by G4VUserPhysicsList::InitializeProcessManager" << G4endl;
338 
339 }
340 
343 {
344  if ( !isSetDefaultCutValue ){
346  }
347 
348 #ifdef G4VERBOSE
349  if (verboseLevel >1){
350  G4cout << "G4VUserPhysicsList::SetCuts: " << G4endl;
351  G4cout << "Cut for gamma: " << GetCutValue("gamma")/mm
352  << "[mm]" << G4endl;
353  G4cout << "Cut for e-: " << GetCutValue("e-")/mm
354  << "[mm]" << G4endl;
355  G4cout << "Cut for e+: " << GetCutValue("e+")/mm
356  << "[mm]" << G4endl;
357  G4cout << "Cut for proton: " << GetCutValue("proton")/mm
358  << "[mm]" << G4endl;
359  }
360 #endif
361 
362  // dump Cut values if verboseLevel==3
363  if (verboseLevel>2) {
365  }
366 }
367 
368 
371 {
372  if (value<0.0) {
373 #ifdef G4VERBOSE
374  if (verboseLevel >0){
375  G4cout << "G4VUserPhysicsList::SetDefaultCutValue: negative cut values"
376  << " :" << value/mm << "[mm]" << G4endl;
377  }
378 #endif
379  return;
380  }
381 
383  isSetDefaultCutValue = true;
384 
385  // set cut values for gamma at first and for e- and e+
386  SetCutValue(defaultCutValue, "gamma");
389  SetCutValue(defaultCutValue, "proton");
390 
391 #ifdef G4VERBOSE
392  if (verboseLevel >1){
393  G4cout << "G4VUserPhysicsList::SetDefaultCutValue:"
394  << "default cut value is changed to :"
395  << defaultCutValue/mm << "[mm]" << G4endl;
396  }
397 #endif
398  }
399 
400 
403 {
404  size_t nReg = (G4RegionStore::GetInstance())->size();
405  if (nReg==0) {
406 #ifdef G4VERBOSE
407  if (verboseLevel>0){
408  G4cout << "G4VUserPhysicsList::GetCutValue "
409  <<" : No Default Region " <<G4endl;
410  }
411 #endif
412  G4Exception("G4VUserPhysicsList::GetCutValue",
413  "Run0253", FatalException,
414  "No Default Region");
415  return -1.*mm;
416  }
417  G4Region* region = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", false);
418  return region->GetProductionCuts()->GetProductionCut(name);
419 }
420 
423 {
424  SetParticleCuts( aCut ,name );
425 }
426 
429 (G4double aCut, const G4String& pname, const G4String& rname)
430 {
431  G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
432  if (region != 0){
433  //set cut value
434  SetParticleCuts( aCut ,pname, region );
435  } else {
436 #ifdef G4VERBOSE
437  if (verboseLevel>0){
438  G4cout << "G4VUserPhysicsList::SetCutValue "
439  <<" : No Region of " << rname << G4endl;
440  }
441 #endif
442  }
443 }
444 
445 
448 {
451 }
452 
455 {
456  // set cut values for gamma at first and for e- and e+
457  SetCutValue(aCut, "gamma", rname);
458  SetCutValue(aCut, "e-", rname);
459  SetCutValue(aCut, "e+", rname);
460  SetCutValue(aCut, "proton", rname);
461 }
462 
463 
464 
467 {
468  SetParticleCuts(cut, particle->GetParticleName(), region);
469 }
470 
472 void G4VUserPhysicsList::SetParticleCuts( G4double cut, const G4String& particleName, G4Region* region)
473 {
474  if (cut<0.0) {
475 #ifdef G4VERBOSE
476  if (verboseLevel >0){
477  G4cout << "G4VUserPhysicsList::SetParticleCuts: negative cut values"
478  << " :" << cut/mm << "[mm]"
479  << " for "<< particleName << G4endl;
480  }
481 #endif
482  return;
483  }
484 
485  G4Region* world_region = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", false);
486  if(!region){
487  size_t nReg = (G4RegionStore::GetInstance())->size();
488  if (nReg==0) {
489 #ifdef G4VERBOSE
490  if (verboseLevel>0){
491  G4cout << "G4VUserPhysicsList::SetParticleCuts "
492  <<" : No Default Region " <<G4endl;
493  }
494 #endif
495  G4Exception("G4VUserPhysicsList::SetParticleCuts ",
496  "Run0254", FatalException,
497  "No Default Region");
498  return;
499  }
500  region = world_region;
501  }
502 
503  if ( !isSetDefaultCutValue ){
505  }
506 
507  G4ProductionCuts* pcuts = region->GetProductionCuts();
508  if(region != world_region &&
509  pcuts==G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts())
510  { // This region had no unique cuts yet but shares the default cuts.
511  // Need to create a new object before setting the value.
512  pcuts = new G4ProductionCuts(
513  *(G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts()));
514  region->SetProductionCuts(pcuts);
515  }
516  pcuts->SetProductionCut(cut,particleName);
517 #ifdef G4VERBOSE
518  if (verboseLevel>2){
519  G4cout << "G4VUserPhysicsList::SetParticleCuts: "
520  << " :" << cut/mm << "[mm]"
521  << " for "<< particleName << G4endl;
522  }
523 #endif
524 }
525 
528 {
529  //Prepare Physics table for all particles
530  theParticleIterator->reset();
531  while( (*theParticleIterator)() ){
532  G4ParticleDefinition* particle = theParticleIterator->value();
533  PreparePhysicsTable(particle);
534  }
535 
536  // ask processes to prepare physics table
537  if (fRetrievePhysicsTable) {
539  // check if retrieve Cut Table successfully
540  if (!fIsRestoredCutValues) {
541 #ifdef G4VERBOSE
542  if (verboseLevel>0){
543  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
544  << " Retrieve Cut Table failed !!" << G4endl;
545  }
546 #endif
547  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
548  "Run0255", RunMustBeAborted,
549  "Fail to retrieve Production Cut Table");
550  } else {
551 #ifdef G4VERBOSE
552  if (verboseLevel>2){
553  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
554  << " Retrieve Cut Table successfully " << G4endl;
555  }
556 #endif
557  }
558  } else {
559 #ifdef G4VERBOSE
560  if (verboseLevel>2){
561  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
562  << " does not retrieve Cut Table but calculate " << G4endl;
563  }
564 #endif
565  }
566 
567  // Sets a value to particle
568  // set cut values for gamma at first and for e- and e+
569  G4String particleName;
571  if(GammaP) BuildPhysicsTable(GammaP);
573  if(EMinusP) BuildPhysicsTable(EMinusP);
575  if(EPlusP) BuildPhysicsTable(EPlusP);
576  G4ParticleDefinition* ProtonP = theParticleTable->FindParticle("proton");
577  if(ProtonP) BuildPhysicsTable(ProtonP);
578 
579  theParticleIterator->reset();
580  while( (*theParticleIterator)() ){
581  G4ParticleDefinition* particle = theParticleIterator->value();
582  if( particle!=GammaP &&
583  particle!=EMinusP &&
584  particle!=EPlusP &&
585  particle!=ProtonP ){
586  BuildPhysicsTable(particle);
587  }
588  }
589 
590  // Set flag
591  fIsPhysicsTableBuilt = true;
592 
593 }
595 //Change in order to share physics tables for two kind of process.
597 {
598  if(!(particle->GetMasterProcessManager())) {
599  G4cout << "#### G4VUserPhysicsList::BuildPhysicsTable() - BuildPhysicsTable("
600  << particle->GetParticleName() << ") skipped..." << G4endl;
601  return;
602  }
603  if (fRetrievePhysicsTable) {
604  if ( !fIsRestoredCutValues){
605  // fail to retreive cut tables
606 #ifdef G4VERBOSE
607  if (verboseLevel>0){
608  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
609  << "Physics table can not be retreived and will be calculated "
610  << G4endl;
611  }
612 #endif
613  fRetrievePhysicsTable = false;
614 
615  } else {
616 #ifdef G4VERBOSE
617  if (verboseLevel>2){
618  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
619  << " Retrieve Physics Table for "
620  << particle->GetParticleName() << G4endl;
621  }
622 #endif
623  // Retrieve PhysicsTable from files for proccesses
625  }
626  }
627 
628 #ifdef G4VERBOSE
629  if (verboseLevel>2){
630  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
631  << "Calculate Physics Table for "
632  << particle->GetParticleName() << G4endl;
633  }
634 #endif
635  // Rebuild the physics tables for every process for this particle type
636  // if particle is not ShortLived
637  if(!particle->IsShortLived()) {
638  G4ProcessManager* pManager = particle->GetProcessManager();
639  if (!pManager) {
640 #ifdef G4VERBOSE
641  if (verboseLevel>0){
642  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
643  <<" : No Process Manager for "
644  << particle->GetParticleName() << G4endl;
645  G4cout << particle->GetParticleName()
646  << " should be created in your PhysicsList" <<G4endl;
647  }
648 #endif
649  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
650  "Run0271", FatalException,
651  "No process manager");
652  return;
653  }
654 
655  //Get processes from master thread;
656  G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
657 
658  G4ProcessVector* pVector = pManager->GetProcessList();
659  if (!pVector) {
660 #ifdef G4VERBOSE
661  if (verboseLevel>0){
662  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
663  <<" : No Process Vector for "
664  << particle->GetParticleName() <<G4endl;
665  }
666 #endif
667  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
668  "Run0272", FatalException,
669  "No process Vector");
670  return;
671  }
672 #ifdef G4VERBOSE
673  if (verboseLevel>2){
674  G4cout << "G4VUserPhysicsList::BuildPhysicsTable %%%%%% " << particle->GetParticleName() << G4endl;
675  G4cout << " ProcessManager : " << pManager << " ProcessManagerShadow : " << pManagerShadow << G4endl;
676  for(G4int iv1=0;iv1<pVector->size();iv1++)
677  { G4cout << " " << iv1 << " - " << (*pVector)[iv1]->GetProcessName() << G4endl; }
678  G4cout << "--------------------------------------------------------------" << G4endl;
679  G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
680 
681  for(G4int iv2=0;iv2<pVectorShadow->size();iv2++)
682  { G4cout << " " << iv2 << " - " << (*pVectorShadow)[iv2]->GetProcessName() << G4endl; }
683  }
684 #endif
685  for (G4int j=0; j < pVector->size(); ++j) {
686  //Andrea July 16th 2013 : migration to new interface...
687  //Infer if we are in a worker thread or master thread
688  //Master thread is the one in which the process manager
689  // and process manager shadow pointers are the same
690  if ( pManagerShadow == pManager )
691  {
692  (*pVector)[j]->BuildPhysicsTable(*particle);
693  }
694  else
695  {
696  (*pVector)[j]->BuildWorkerPhysicsTable(*particle);
697  }
698 
699  } //End loop on processes vector
700  } //End if short-lived
701 }
702 
705 {
706  if(!(particle->GetMasterProcessManager())) {
709  return;
710  }
711  // Prepare the physics tables for every process for this particle type
712  // if particle is not ShortLived
713  if(!particle->IsShortLived()) {
714  G4ProcessManager* pManager = particle->GetProcessManager();
715  if (!pManager) {
716 #ifdef G4VERBOSE
717  if (verboseLevel>0) {
718  G4cout<< "G4VUserPhysicsList::PreparePhysicsTable "
719  << ": No Process Manager for "
720  << particle->GetParticleName() <<G4endl;
721  G4cout << particle->GetParticleName()
722  << " should be created in your PhysicsList" <<G4endl;
723  }
724 #endif
725  G4Exception("G4VUserPhysicsList::PreparePhysicsTable",
726  "Run0273", FatalException,
727  "No process manager");
728  return;
729  }
730 
731  //Get processes from master thread
732  G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
733  //Andrea Dotti 15 Jan 2013: Change of interface of MSC
734  //G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
735 
736  G4ProcessVector* pVector = pManager->GetProcessList();
737  if (!pVector) {
738 #ifdef G4VERBOSE
739  if (verboseLevel>0) {
740  G4cout << "G4VUserPhysicsList::PreparePhysicsTable "
741  << ": No Process Vector for "
742  << particle->GetParticleName() <<G4endl;
743  }
744 #endif
745  G4Exception("G4VUserPhysicsList::PreparePhysicsTable",
746  "Run0274", FatalException,
747  "No process Vector");
748  return;
749  }
750  for (G4int j=0; j < pVector->size(); ++j) {
751 
752  //Andrea July 16th 2013 : migration to new interface...
753  //Infer if we are in a worker thread or master thread
754  //Master thread is the one in which the process manager
755  // and process manager shadow pointers are the same
756  if ( pManagerShadow == pManager )
757  {
758  (*pVector)[j]->PreparePhysicsTable(*particle);
759  }
760  else
761  {
762  (*pVector)[j]->PrepareWorkerPhysicsTable(*particle);
763  }
764  } //End loop on processes vector
765  } //End if pn ShortLived
766 }
767 
768 //TODO Should we change this function?
771  G4ParticleDefinition* particle)
772 {
773  //*********************************************************************
774  // temporary addition to make the integral schema of electromagnetic
775  // processes work.
776  //
777 
778  if ( (process->GetProcessName() == "Imsc") ||
779  (process->GetProcessName() == "IeIoni") ||
780  (process->GetProcessName() == "IeBrems") ||
781  (process->GetProcessName() == "Iannihil") ||
782  (process->GetProcessName() == "IhIoni") ||
783  (process->GetProcessName() == "IMuIoni") ||
784  (process->GetProcessName() == "IMuBrems") ||
785  (process->GetProcessName() == "IMuPairProd") ) {
786 #ifdef G4VERBOSE
787  if (verboseLevel>2){
788  G4cout << "G4VUserPhysicsList::BuildIntegralPhysicsTable "
789  << " BuildPhysicsTable is invoked for "
790  << process->GetProcessName()
791  << "(" << particle->GetParticleName() << ")" << G4endl;
792  }
793 #endif
794  process->BuildPhysicsTable(*particle);
795  }
796 }
797 
800 {
801  theParticleIterator->reset();
802  G4int idx = 0;
803  while( (*theParticleIterator)() ){
804  G4ParticleDefinition* particle = theParticleIterator->value();
805  G4cout << particle->GetParticleName();
806  if ((idx++ % 4) == 3) {
807  G4cout << G4endl;
808  } else {
809  G4cout << ", ";
810  }
811  }
812  G4cout << G4endl;
813 }
814 
815 
818 {
819  fDisplayThreshold = flag;
820 }
821 
824 {
825  if(fDisplayThreshold==0) return;
827  fDisplayThreshold = 0;
828 }
829 
830 
833 {
834  G4bool ascii = fStoredInAscii;
835  G4String dir = directory;
836  if (dir.isNull()) dir = directoryPhysicsTable;
837  else directoryPhysicsTable = dir;
838 
839  // store CutsTable info
840  if (!fCutsTable->StoreCutsTable(dir, ascii)) {
841  G4Exception("G4VUserPhysicsList::StorePhysicsTable",
842  "Run0281", JustWarning,
843  "Fail to store Cut Table");
844  return false;
845  }
846 #ifdef G4VERBOSE
847  if (verboseLevel>2){
848  G4cout << "G4VUserPhysicsList::StorePhysicsTable "
849  << " Store material and cut values successfully" << G4endl;
850  }
851 #endif
852 
853  G4bool success= true;
854 
855  // loop over all particles in G4ParticleTable
856  theParticleIterator->reset();
857  while( (*theParticleIterator)() ){
858  G4ParticleDefinition* particle = theParticleIterator->value();
859  // Store physics tables for every process for this particle type
860  G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
861  G4int j;
862  for ( j=0; j < pVector->size(); ++j) {
863  if (!(*pVector)[j]->StorePhysicsTable(particle,dir,ascii)){
864  G4String comment = "Fail to store physics table for ";
865  comment += (*pVector)[j]->GetProcessName();
866  comment += "(" + particle->GetParticleName() + ")";
867  G4Exception("G4VUserPhysicsList::StorePhysicsTable",
868  "Run0282", JustWarning,
869  comment);
870  success = false;
871  }
872  }
873  // end loop over processes
874  }
875  // end loop over particles
876  return success;
877 }
878 
879 
880 
883 {
884  fRetrievePhysicsTable = true;
885  if(!directory.isNull()) {
886  directoryPhysicsTable = directory;
887  }
889  fIsRestoredCutValues = false;
890 }
891 
894  const G4String& directory,
895  G4bool ascii)
896 {
897  G4int j;
898  G4bool success[100];
899  // Retrieve physics tables for every process for this particle type
900  G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
901  for ( j=0; j < pVector->size(); ++j) {
902  success[j] =
903  (*pVector)[j]->RetrievePhysicsTable(particle,directory,ascii);
904 
905  if (!success[j]) {
906 #ifdef G4VERBOSE
907  if (verboseLevel>2){
908  G4cout << "G4VUserPhysicsList::RetrievePhysicsTable "
909  << " Fail to retrieve Physics Table for "
910  << (*pVector)[j]->GetProcessName() << G4endl;
911  G4cout << "Calculate Physics Table for "
912  << particle->GetParticleName() << G4endl;
913  }
914 #endif
915  (*pVector)[j]->BuildPhysicsTable(*particle);
916  }
917  }
918  for ( j=0; j < pVector->size(); ++j) {
919  // temporary addition to make the integral schema
920  if (!success[j]) BuildIntegralPhysicsTable((*pVector)[j], particle);
921  }
922 }
923 
924 
927 {
928 #ifdef G4VERBOSE
929  if (verboseLevel>2){
930  G4cout << "G4VUserPhysicsList::SetApplyCuts for " << name << G4endl;
931  }
932 #endif
933  if(name=="all") {
938  } else {
940  }
941 }
942 
945 {
947 }
948 
949 
952 {
954  G4MT_thePLHelper->CheckParticleList();
955  }
956 }
957 
960 {
961  G4MT_thePLHelper->AddTransportation();
962 }
963 
966 {
967  G4MT_thePLHelper->UseCoupledTransportation(vl);
968 }
969 
972  G4ParticleDefinition* particle)
973 {
974  return G4MT_thePLHelper->RegisterProcess(process, particle);
975 }
976 
979 {
980  return (subInstanceManager.offset[g4vuplInstanceID])._theParticleIterator;
981 }
982 
985 {
987  // set verboseLevel for G4ProductionCutsTable same as one for G4VUserPhysicsList:
989 
990  G4MT_thePLHelper->SetVerboseLevel(verboseLevel);
991 
992 #ifdef G4VERBOSE
993  if (verboseLevel >1){
994  G4cout << "G4VUserPhysicsList::SetVerboseLevel :"
995  << " Verbose level is set to " << verboseLevel << G4endl;
996  }
997 #endif
998 }
999 
1000 
1003 
1006 {
1007 #ifdef G4VERBOSE
1008  if (verboseLevel>0){
1009  G4cout << "G4VUserPhysicsList::ResetCuts() is obsolete."
1010  << " This method gives no effect and you can remove it. "<< G4endl;
1011  }
1012 #endif
1013 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
#define G4MT_thePLHelper
void SetCutsForRegion(G4double aCut, const G4String &rname)
const XML_Char * name
Definition: expat.h:151
void SetProductionCut(G4double cut, G4int index=-1)
G4ProcessManager * GetMasterProcessManager() const
G4bool isNull() const
G4ParticleTable::G4PTblDicIterator * _theParticleIterator
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:210
void SetMasterProcessManager(G4ProcessManager *aNewPM)
void SetPhysicsTableRetrieved(const G4String &directory="")
static G4PART_DLL G4int & slavetotalspace()
G4bool IsGeneralIon() const
static G4ParticleTable * GetParticleTable()
void AddProcessManager(G4ParticleDefinition *newParticle, G4ProcessManager *newManager=0)
#define theParticleIterator
static constexpr double keV
Definition: G4SIunits.hh:216
static constexpr double mm
Definition: G4SIunits.hh:115
G4RUN_DLL G4ThreadLocalStatic T * offset
const G4String & GetParticleSubType() const
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
void SetEnergyRange(G4double lowedge, G4double highedge)
void SetProductionCuts(G4ProductionCuts *cut)
G4ProcessVector * GetProcessList() const
G4PTblDicIterator * GetIterator() const
static G4RUN_DLL G4VUPLManager subInstanceManager
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
G4double GetProductionCut(G4int index) const
void BuildIntegralPhysicsTable(G4VProcess *, G4ParticleDefinition *)
G4PhysicsListHelper * _thePLHelper
static constexpr double TeV
Definition: G4SIunits.hh:218
G4bool RegisterProcess(G4VProcess *process, G4ParticleDefinition *particle)
G4ParticleTable::G4PTblDicIterator * GetParticleIterator() const
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
void SetProcessManager(G4ProcessManager *aProcessManager)
void SetParticleCuts(G4double cut, G4ParticleDefinition *particle, G4Region *region=0)
const XML_Char int const XML_Char * value
Definition: expat.h:331
void ResetCuts()
obsolete methods
void PreparePhysicsTable(G4ParticleDefinition *)
G4bool GetApplyCuts(const G4String &name) const
G4int CreateSubInstance()
G4ParticleTable * theParticleTable
void UseCoupledTransportation(G4bool vl=true)
G4bool StoreCutsTable(const G4String &directory, G4bool ascii=false)
const G4String & GetProcessName() const
Definition: G4VProcess.hh:411
G4ParticleDefinition * GetGenericIon() const
G4ProductionCutsTable * fCutsTable
G4int GetInstanceID() const
G4bool fIsCheckedForRetrievePhysicsTable
G4bool RetrieveCutsTable(const G4String &directory, G4bool ascii=false)
#define G4MUTEXUNLOCK(mutex)
Definition: G4Threading.hh:234
void SetDefaultCutValue(G4double newCutValue)
G4ProductionCuts * GetProductionCuts() const
static G4ProductionCutsTable * GetProductionCutsTable()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
static G4PhysicsListHelper * GetPhysicsListHelper()
static G4RegionStore * GetInstance()
int G4int
Definition: G4Types.hh:78
static const G4VUPLManager & GetSubInstanceManager()
void SetApplyCuts(G4bool value, const G4String &name)
G4ProcessManager * GetProcessManager() const
#define fIsPhysicsTableBuilt
G4int GetInstanceID() const
virtual void RetrievePhysicsTable(G4ParticleDefinition *, const G4String &directory, G4bool ascii=false)
TDirectory * dir
#define G4MUTEXLOCK(mutex)
Definition: G4Threading.hh:233
G4bool StorePhysicsTable(const G4String &directory=".")
G4int size() const
G4GLOB_DLL std::ostream G4cout
G4bool _fIsPhysicsTableBuilt
G4double GetCutValue(const G4String &pname) const
virtual void TerminateWorker()
void SetCutValue(G4double aCut, const G4String &pname)
G4bool GetApplyCutsFlag() const
#define fDisplayThreshold
void SetVerboseLevel(G4int value)
void DumpCutValuesTable(G4int flag=1)
virtual void InitializeWorker()
#define G4MT_theMessenger
G4VUserPhysicsList & operator=(const G4VUserPhysicsList &)
void SetVerboseLevel(G4int value)
G4UserPhysicsListMessenger * _theMessenger