Geant4  10.02.p03
G4VUserPhysicsList.cc
Go to the documentation of this file.
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 102337 2017-01-23 13:20:50Z 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 
89 // This field helps to use the class G4VUPLManager
90 //
92 
94 {
96  _theMessenger = 0;
98  _fIsPhysicsTableBuilt = false;
100 }
101 
104  :verboseLevel(1),
105  defaultCutValue(1.0 * mm),
106  isSetDefaultCutValue(false),
107  fRetrievePhysicsTable(false),
108  fStoredInAscii(true),
109  fIsCheckedForRetrievePhysicsTable(false),
110  fIsRestoredCutValues(false),
111  directoryPhysicsTable("."),
112  //fDisplayThreshold(0),
113  //fIsPhysicsTableBuilt(false),
114  fDisableCheckParticleList(false)
115 {
117  // default cut value (1.0mm)
118  defaultCutValue = 1.0*mm;
119 
120  // pointer to the particle table
122  //theParticleIterator = theParticleTable->GetIterator();
123 
124  // pointer to the cuts table
126 
127  // set energy range for SetCut calcuration
128  fCutsTable->SetEnergyRange(0.99*keV, 100*TeV);
129 
130  // UI Messenger
131  //theMessenger = new G4UserPhysicsListMessenger(this);
133 
134  // PhysicsListHelper
135  //thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
136  //thePLHelper->SetVerboseLevel(verboseLevel);
137  //G4MT_thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper(); //AND
138  G4MT_thePLHelper->SetVerboseLevel(verboseLevel); //AND
139 
140  fIsPhysicsTableBuilt = false;
141  fDisplayThreshold = 0;
142 
143 }
144 
146 {
147  //Remember messengers are per-thread, so this needs to be done by each worker
148  //and due to the presence of "this" cannot be done in G4VUPLData::initialize()
150 }
151 
154 {
155  if (G4MT_theMessenger != 0) {
156  delete G4MT_theMessenger;
157  G4MT_theMessenger = 0;
158  }
160 
161  // invoke DeleteAllParticle
163 
164 }
165 
168  :verboseLevel(right.verboseLevel),
176  //fDisplayThreshold(right.fDisplayThreshold),
177  //fIsPhysicsTableBuilt(right.fIsPhysicsTableBuilt),
179 {
181  // pointer to the particle table
184  // pointer to the cuts table
186 
187  // UI Messenger
188  //theMessenger = new G4UserPhysicsListMessenger(this);
190 
191  // PhysicsListHelper
192  //thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
193  //thePLHelper->SetVerboseLevel(verboseLevel);
195  G4MT_thePLHelper->SetVerboseLevel(verboseLevel); //AND
196 
197  fIsPhysicsTableBuilt = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fIsPhysicsTableBuilt;
198  fDisplayThreshold = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fDisplayThreshold;
199 }
200 
201 
204 {
205  if (this != &right) {
206  verboseLevel = right.verboseLevel;
214  //fDisplayThreshold = right.fDisplayThreshold;
215  fIsPhysicsTableBuilt = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fIsPhysicsTableBuilt;
216  fDisplayThreshold = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fDisplayThreshold;
217  //fIsPhysicsTableBuilt = right.fIsPhysicsTableBuilt;
219  }
220  return *this;
221 }
222 
226 {
227  if (newParticle == 0) return;
228  G4Exception("G4VUserPhysicsList::AddProcessManager",
229  "Run0252", JustWarning,
230  "This method is obsolete");
231 }
232 
233 
236 {
237  //Request lock for particle table accesses. Some changes are inside
238  //this critical region.
239 #ifdef G4MULTITHREADED
240  G4MUTEXLOCK(&G4ParticleTable::particleTableMutex);
241  G4ParticleTable::lockCount++;
242 #endif
244 
245  // loop over all particles in G4ParticleTable
246  theParticleIterator->reset();
247  while( (*theParticleIterator)() ){
248  G4ParticleDefinition* particle = theParticleIterator->value();
249  G4ProcessManager* pmanager = particle->GetProcessManager();
250 
251  if (pmanager==0) {
252  // create process manager if the particle does not have its own.
253  pmanager = new G4ProcessManager(particle);
254  particle->SetProcessManager(pmanager);
255  if( particle->GetMasterProcessManager() == 0 ) particle->SetMasterProcessManager(pmanager);
256 #ifdef G4VERBOSE
257  if (verboseLevel >2){
258  G4cout << "G4VUserPhysicsList::InitializeProcessManager: creating ProcessManager to "
259  << particle->GetParticleName() << G4endl;
260  }
261 #endif
262  }
263  }
264 
265  if(gion)
266  {
267  G4ProcessManager* gionPM = gion->GetProcessManager();
268  // loop over all particles once again (this time, with all general ions)
269  theParticleIterator->reset(false);
270  while( (*theParticleIterator)() ){
271  G4ParticleDefinition* particle = theParticleIterator->value();
272  if(particle->IsGeneralIon())
273  {
274  particle->SetProcessManager(gionPM);
275 #ifdef G4VERBOSE
276  if (verboseLevel >2){
277  G4cout << "G4VUserPhysicsList::InitializeProcessManager: copying ProcessManager to "
278  << particle->GetParticleName() << G4endl;
279  }
280 #endif
281  }
282  }
283  }
284 
285  //release lock for particle table accesses.
286 #ifdef G4MULTITHREADED
287  G4MUTEXUNLOCK(&G4ParticleTable::particleTableMutex);
288 #endif
289 // G4cout << "Particle table is released by G4VUserPhysicsList::InitializeProcessManager" << G4endl;
290 
291 }
292 
295 {
296  //Request lock for particle table accesses. Some changes are inside
297  //this critical region.
298 #ifdef G4MULTITHREADED
299  G4MUTEXLOCK(&G4ParticleTable::particleTableMutex);
300  G4ParticleTable::lockCount++;
301 #endif
302 // G4cout << "Particle table is held by G4VUserPhysicsList::InitializeProcessManager" << G4endl;
303 
304  // loop over all particles in G4ParticleTable
305  theParticleIterator->reset();
306  while( (*theParticleIterator)() ){
307  G4ParticleDefinition* particle = theParticleIterator->value();
309  {
310  if(particle->GetParticleSubType()!="generic" || particle->GetParticleName()=="GenericIon")
311  {
312  G4ProcessManager* pmanager = particle->GetProcessManager();
313  if (pmanager!=0) delete pmanager;
314 #ifdef G4VERBOSE
315  if (verboseLevel >2){
316  G4cout << "G4VUserPhysicsList::RemoveProcessManager: ";
317  G4cout << "remove ProcessManager from ";
318  G4cout << particle->GetParticleName() << G4endl;
319  }
320 #endif
321  }
322  particle->SetProcessManager(0);
323  }
324  }
325 
326  //release lock for particle table accesses.
327 #ifdef G4MULTITHREADED
328  G4MUTEXUNLOCK(&G4ParticleTable::particleTableMutex);
329 #endif
330 // G4cout << "Particle table is released by G4VUserPhysicsList::InitializeProcessManager" << G4endl;
331 
332 }
333 
336 {
337  if ( !isSetDefaultCutValue ){
339  }
340 
341 #ifdef G4VERBOSE
342  if (verboseLevel >1){
343  G4cout << "G4VUserPhysicsList::SetCuts: " << G4endl;
344  G4cout << "Cut for gamma: " << GetCutValue("gamma")/mm
345  << "[mm]" << G4endl;
346  G4cout << "Cut for e-: " << GetCutValue("e-")/mm
347  << "[mm]" << G4endl;
348  G4cout << "Cut for e+: " << GetCutValue("e+")/mm
349  << "[mm]" << G4endl;
350  G4cout << "Cut for proton: " << GetCutValue("proton")/mm
351  << "[mm]" << G4endl;
352  }
353 #endif
354 
355  // dump Cut values if verboseLevel==3
356  if (verboseLevel>2) {
358  }
359 }
360 
361 
364 {
365  if (value<0.0) {
366 #ifdef G4VERBOSE
367  if (verboseLevel >0){
368  G4cout << "G4VUserPhysicsList::SetDefaultCutValue: negative cut values"
369  << " :" << value/mm << "[mm]" << G4endl;
370  }
371 #endif
372  return;
373  }
374 
375  defaultCutValue = value;
376  isSetDefaultCutValue = true;
377 
378  // set cut values for gamma at first and for e- and e+
379  SetCutValue(defaultCutValue, "gamma");
382  SetCutValue(defaultCutValue, "proton");
383 
384 #ifdef G4VERBOSE
385  if (verboseLevel >1){
386  G4cout << "G4VUserPhysicsList::SetDefaultCutValue:"
387  << "default cut value is changed to :"
388  << defaultCutValue/mm << "[mm]" << G4endl;
389  }
390 #endif
391  }
392 
393 
396 {
397  size_t nReg = (G4RegionStore::GetInstance())->size();
398  if (nReg==0) {
399 #ifdef G4VERBOSE
400  if (verboseLevel>0){
401  G4cout << "G4VUserPhysicsList::GetCutValue "
402  <<" : No Default Region " <<G4endl;
403  }
404 #endif
405  G4Exception("G4VUserPhysicsList::GetCutValue",
406  "Run0253", FatalException,
407  "No Default Region");
408  return -1.*mm;
409  }
410  G4Region* region = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", false);
411  return region->GetProductionCuts()->GetProductionCut(name);
412 }
413 
416 {
417  SetParticleCuts( aCut ,name );
418 }
419 
422 (G4double aCut, const G4String& pname, const G4String& rname)
423 {
424  G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
425  if (region != 0){
426  //set cut value
427  SetParticleCuts( aCut ,pname, region );
428  } else {
429 #ifdef G4VERBOSE
430  if (verboseLevel>0){
431  G4cout << "G4VUserPhysicsList::SetCutValue "
432  <<" : No Region of " << rname << G4endl;
433  }
434 #endif
435  }
436 }
437 
438 
441 {
444 }
445 
448 {
449  // set cut values for gamma at first and for e- and e+
450  SetCutValue(aCut, "gamma", rname);
451  SetCutValue(aCut, "e-", rname);
452  SetCutValue(aCut, "e+", rname);
453  SetCutValue(aCut, "proton", rname);
454 }
455 
456 
457 
460 {
461  SetParticleCuts(cut, particle->GetParticleName(), region);
462 }
463 
465 void G4VUserPhysicsList::SetParticleCuts( G4double cut, const G4String& particleName, G4Region* region)
466 {
467  if (cut<0.0) {
468 #ifdef G4VERBOSE
469  if (verboseLevel >0){
470  G4cout << "G4VUserPhysicsList::SetParticleCuts: negative cut values"
471  << " :" << cut/mm << "[mm]"
472  << " for "<< particleName << G4endl;
473  }
474 #endif
475  return;
476  }
477 
478  G4Region* world_region = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", false);
479  if(!region){
480  size_t nReg = (G4RegionStore::GetInstance())->size();
481  if (nReg==0) {
482 #ifdef G4VERBOSE
483  if (verboseLevel>0){
484  G4cout << "G4VUserPhysicsList::SetParticleCuts "
485  <<" : No Default Region " <<G4endl;
486  }
487 #endif
488  G4Exception("G4VUserPhysicsList::SetParticleCuts ",
489  "Run0254", FatalException,
490  "No Default Region");
491  return;
492  }
493  region = world_region;
494  }
495 
496  if ( !isSetDefaultCutValue ){
498  }
499 
500  G4ProductionCuts* pcuts = region->GetProductionCuts();
501  if(region != world_region &&
502  pcuts==G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts())
503  { // This region had no unique cuts yet but shares the default cuts.
504  // Need to create a new object before setting the value.
505  pcuts = new G4ProductionCuts(
506  *(G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts()));
507  region->SetProductionCuts(pcuts);
508  }
509  pcuts->SetProductionCut(cut,particleName);
510 #ifdef G4VERBOSE
511  if (verboseLevel>2){
512  G4cout << "G4VUserPhysicsList::SetParticleCuts: "
513  << " :" << cut/mm << "[mm]"
514  << " for "<< particleName << G4endl;
515  }
516 #endif
517 }
518 
521 {
522  //Prepare Physics table for all particles
523  theParticleIterator->reset();
524  while( (*theParticleIterator)() ){
525  G4ParticleDefinition* particle = theParticleIterator->value();
526  PreparePhysicsTable(particle);
527  }
528 
529  // ask processes to prepare physics table
530  if (fRetrievePhysicsTable) {
532  // check if retrieve Cut Table successfully
533  if (!fIsRestoredCutValues) {
534 #ifdef G4VERBOSE
535  if (verboseLevel>0){
536  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
537  << " Retrieve Cut Table failed !!" << G4endl;
538  }
539 #endif
540  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
541  "Run0255", RunMustBeAborted,
542  "Fail to retrieve Production Cut Table");
543  } else {
544 #ifdef G4VERBOSE
545  if (verboseLevel>2){
546  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
547  << " Retrieve Cut Table successfully " << G4endl;
548  }
549 #endif
550  }
551  } else {
552 #ifdef G4VERBOSE
553  if (verboseLevel>2){
554  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
555  << " does not retrieve Cut Table but calculate " << G4endl;
556  }
557 #endif
558  }
559 
560  // Sets a value to particle
561  // set cut values for gamma at first and for e- and e+
562  G4String particleName;
564  if(GammaP) BuildPhysicsTable(GammaP);
566  if(EMinusP) BuildPhysicsTable(EMinusP);
568  if(EPlusP) BuildPhysicsTable(EPlusP);
569  G4ParticleDefinition* ProtonP = theParticleTable->FindParticle("proton");
570  if(ProtonP) BuildPhysicsTable(ProtonP);
571 
572  theParticleIterator->reset();
573  while( (*theParticleIterator)() ){
574  G4ParticleDefinition* particle = theParticleIterator->value();
575  if( particle!=GammaP &&
576  particle!=EMinusP &&
577  particle!=EPlusP &&
578  particle!=ProtonP ){
579  BuildPhysicsTable(particle);
580  }
581  }
582 
583  // Set flag
584  fIsPhysicsTableBuilt = true;
585 
586 }
588 //Change in order to share physics tables for two kind of process.
590 {
591  if(!(particle->GetMasterProcessManager())) {
592  G4cout << "#### G4VUserPhysicsList::BuildPhysicsTable() - BuildPhysicsTable("
593  << particle->GetParticleName() << ") skipped..." << G4endl;
594  return;
595  }
596  if (fRetrievePhysicsTable) {
597  if ( !fIsRestoredCutValues){
598  // fail to retreive cut tables
599 #ifdef G4VERBOSE
600  if (verboseLevel>0){
601  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
602  << "Physics table can not be retreived and will be calculated "
603  << G4endl;
604  }
605 #endif
606  fRetrievePhysicsTable = false;
607 
608  } else {
609 #ifdef G4VERBOSE
610  if (verboseLevel>2){
611  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
612  << " Retrieve Physics Table for "
613  << particle->GetParticleName() << G4endl;
614  }
615 #endif
616  // Retrieve PhysicsTable from files for proccesses
618  }
619  }
620 
621 #ifdef G4VERBOSE
622  if (verboseLevel>2){
623  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
624  << "Calculate Physics Table for "
625  << particle->GetParticleName() << G4endl;
626  }
627 #endif
628  // Rebuild the physics tables for every process for this particle type
629  // if particle is not ShortLived
630  if(!particle->IsShortLived()) {
631  G4ProcessManager* pManager = particle->GetProcessManager();
632  if (!pManager) {
633 #ifdef G4VERBOSE
634  if (verboseLevel>0){
635  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
636  <<" : No Process Manager for "
637  << particle->GetParticleName() << G4endl;
638  G4cout << particle->GetParticleName()
639  << " should be created in your PhysicsList" <<G4endl;
640  }
641 #endif
642  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
643  "Run0271", FatalException,
644  "No process manager");
645  return;
646  }
647 
648  //Get processes from master thread;
649  G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
650 
651  G4ProcessVector* pVector = pManager->GetProcessList();
652  if (!pVector) {
653 #ifdef G4VERBOSE
654  if (verboseLevel>0){
655  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
656  <<" : No Process Vector for "
657  << particle->GetParticleName() <<G4endl;
658  }
659 #endif
660  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
661  "Run0272", FatalException,
662  "No process Vector");
663  return;
664  }
665 #ifdef G4VERBOSE
666  if (verboseLevel>2){
667  G4cout << "G4VUserPhysicsList::BuildPhysicsTable %%%%%% " << particle->GetParticleName() << G4endl;
668  G4cout << " ProcessManager : " << pManager << " ProcessManagerShadow : " << pManagerShadow << G4endl;
669  for(G4int iv1=0;iv1<pVector->size();iv1++)
670  { G4cout << " " << iv1 << " - " << (*pVector)[iv1]->GetProcessName() << G4endl; }
671  G4cout << "--------------------------------------------------------------" << G4endl;
672  G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
673 
674  for(G4int iv2=0;iv2<pVectorShadow->size();iv2++)
675  { G4cout << " " << iv2 << " - " << (*pVectorShadow)[iv2]->GetProcessName() << G4endl; }
676  }
677 #endif
678  for (G4int j=0; j < pVector->size(); ++j) {
679  //Andrea July 16th 2013 : migration to new interface...
680  //Infer if we are in a worker thread or master thread
681  //Master thread is the one in which the process manager
682  // and process manager shadow pointers are the same
683  if ( pManagerShadow == pManager )
684  {
685  (*pVector)[j]->BuildPhysicsTable(*particle);
686  }
687  else
688  {
689  (*pVector)[j]->BuildWorkerPhysicsTable(*particle);
690  }
691 
692  } //End loop on processes vector
693  } //End if short-lived
694 }
695 
698 {
699  if(!(particle->GetMasterProcessManager())) {
702  return;
703  }
704  // Prepare the physics tables for every process for this particle type
705  // if particle is not ShortLived
706  if(!particle->IsShortLived()) {
707  G4ProcessManager* pManager = particle->GetProcessManager();
708  if (!pManager) {
709 #ifdef G4VERBOSE
710  if (verboseLevel>0) {
711  G4cout<< "G4VUserPhysicsList::PreparePhysicsTable "
712  << ": No Process Manager for "
713  << particle->GetParticleName() <<G4endl;
714  G4cout << particle->GetParticleName()
715  << " should be created in your PhysicsList" <<G4endl;
716  }
717 #endif
718  G4Exception("G4VUserPhysicsList::PreparePhysicsTable",
719  "Run0273", FatalException,
720  "No process manager");
721  return;
722  }
723 
724  //Get processes from master thread
725  G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
726  //Andrea Dotti 15 Jan 2013: Change of interface of MSC
727  //G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
728 
729  G4ProcessVector* pVector = pManager->GetProcessList();
730  if (!pVector) {
731 #ifdef G4VERBOSE
732  if (verboseLevel>0) {
733  G4cout << "G4VUserPhysicsList::PreparePhysicsTable "
734  << ": No Process Vector for "
735  << particle->GetParticleName() <<G4endl;
736  }
737 #endif
738  G4Exception("G4VUserPhysicsList::PreparePhysicsTable",
739  "Run0274", FatalException,
740  "No process Vector");
741  return;
742  }
743  for (G4int j=0; j < pVector->size(); ++j) {
744 
745  //Andrea July 16th 2013 : migration to new interface...
746  //Infer if we are in a worker thread or master thread
747  //Master thread is the one in which the process manager
748  // and process manager shadow pointers are the same
749  if ( pManagerShadow == pManager )
750  {
751  (*pVector)[j]->PreparePhysicsTable(*particle);
752  }
753  else
754  {
755  (*pVector)[j]->PrepareWorkerPhysicsTable(*particle);
756  }
757  } //End loop on processes vector
758  } //End if pn ShortLived
759 }
760 
761 //TODO Should we change this function?
764  G4ParticleDefinition* particle)
765 {
766  //*********************************************************************
767  // temporary addition to make the integral schema of electromagnetic
768  // processes work.
769  //
770 
771  if ( (process->GetProcessName() == "Imsc") ||
772  (process->GetProcessName() == "IeIoni") ||
773  (process->GetProcessName() == "IeBrems") ||
774  (process->GetProcessName() == "Iannihil") ||
775  (process->GetProcessName() == "IhIoni") ||
776  (process->GetProcessName() == "IMuIoni") ||
777  (process->GetProcessName() == "IMuBrems") ||
778  (process->GetProcessName() == "IMuPairProd") ) {
779 #ifdef G4VERBOSE
780  if (verboseLevel>2){
781  G4cout << "G4VUserPhysicsList::BuildIntegralPhysicsTable "
782  << " BuildPhysicsTable is invoked for "
783  << process->GetProcessName()
784  << "(" << particle->GetParticleName() << ")" << G4endl;
785  }
786 #endif
787  process->BuildPhysicsTable(*particle);
788  }
789 }
790 
793 {
794  theParticleIterator->reset();
795  G4int idx = 0;
796  while( (*theParticleIterator)() ){
797  G4ParticleDefinition* particle = theParticleIterator->value();
798  G4cout << particle->GetParticleName();
799  if ((idx++ % 4) == 3) {
800  G4cout << G4endl;
801  } else {
802  G4cout << ", ";
803  }
804  }
805  G4cout << G4endl;
806 }
807 
808 
811 {
812  fDisplayThreshold = flag;
813 }
814 
817 {
818  if(fDisplayThreshold==0) return;
820  fDisplayThreshold = 0;
821 }
822 
823 
826 {
827  G4bool ascii = fStoredInAscii;
828  G4String dir = directory;
829  if (dir.isNull()) dir = directoryPhysicsTable;
830  else directoryPhysicsTable = dir;
831 
832  // store CutsTable info
833  if (!fCutsTable->StoreCutsTable(dir, ascii)) {
834  G4Exception("G4VUserPhysicsList::StorePhysicsTable",
835  "Run0281", JustWarning,
836  "Fail to store Cut Table");
837  return false;
838  }
839 #ifdef G4VERBOSE
840  if (verboseLevel>2){
841  G4cout << "G4VUserPhysicsList::StorePhysicsTable "
842  << " Store material and cut values successfully" << G4endl;
843  }
844 #endif
845 
846  G4bool success= true;
847 
848  // loop over all particles in G4ParticleTable
849  theParticleIterator->reset();
850  while( (*theParticleIterator)() ){
851  G4ParticleDefinition* particle = theParticleIterator->value();
852  // Store physics tables for every process for this particle type
853  G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
854  G4int j;
855  for ( j=0; j < pVector->size(); ++j) {
856  if (!(*pVector)[j]->StorePhysicsTable(particle,dir,ascii)){
857  G4String comment = "Fail to store physics table for ";
858  comment += (*pVector)[j]->GetProcessName();
859  comment += "(" + particle->GetParticleName() + ")";
860  G4Exception("G4VUserPhysicsList::StorePhysicsTable",
861  "Run0282", JustWarning,
862  comment);
863  success = false;
864  }
865  }
866  // end loop over processes
867  }
868  // end loop over particles
869  return success;
870 }
871 
872 
873 
876 {
877  fRetrievePhysicsTable = true;
878  if(!directory.isNull()) {
879  directoryPhysicsTable = directory;
880  }
882  fIsRestoredCutValues = false;
883 }
884 
887  const G4String& directory,
888  G4bool ascii)
889 {
890  G4int j;
891  G4bool success[100];
892  // Retrieve physics tables for every process for this particle type
893  G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
894  for ( j=0; j < pVector->size(); ++j) {
895  success[j] =
896  (*pVector)[j]->RetrievePhysicsTable(particle,directory,ascii);
897 
898  if (!success[j]) {
899 #ifdef G4VERBOSE
900  if (verboseLevel>2){
901  G4cout << "G4VUserPhysicsList::RetrievePhysicsTable "
902  << " Fail to retrieve Physics Table for "
903  << (*pVector)[j]->GetProcessName() << G4endl;
904  G4cout << "Calculate Physics Table for "
905  << particle->GetParticleName() << G4endl;
906  }
907 #endif
908  (*pVector)[j]->BuildPhysicsTable(*particle);
909  }
910  }
911  for ( j=0; j < pVector->size(); ++j) {
912  // temporary addition to make the integral schema
913  if (!success[j]) BuildIntegralPhysicsTable((*pVector)[j], particle);
914  }
915 }
916 
917 
920 {
921 #ifdef G4VERBOSE
922  if (verboseLevel>2){
923  G4cout << "G4VUserPhysicsList::SetApplyCuts for " << name << G4endl;
924  }
925 #endif
926  if(name=="all") {
931  } else {
933  }
934 }
935 
938 {
940 }
941 
942 
945 {
947  G4MT_thePLHelper->CheckParticleList();
948  }
949 }
950 
953 {
954  G4MT_thePLHelper->AddTransportation();
955 }
956 
959 {
960  G4MT_thePLHelper->UseCoupledTransportation(vl);
961 }
962 
965  G4ParticleDefinition* particle)
966 {
967  return G4MT_thePLHelper->RegisterProcess(process, particle);
968 }
969 
972 {
973  return (subInstanceManager.offset[g4vuplInstanceID])._theParticleIterator;
974 }
975 
978 {
979  verboseLevel = value;
980  // set verboseLevel for G4ProductionCutsTable same as one for G4VUserPhysicsList:
982 
983  G4MT_thePLHelper->SetVerboseLevel(verboseLevel);
984 
985 #ifdef G4VERBOSE
986  if (verboseLevel >1){
987  G4cout << "G4VUserPhysicsList::SetVerboseLevel :"
988  << " Verbose level is set to " << verboseLevel << G4endl;
989  }
990 #endif
991 }
992 
993 
996 
999 {
1000 #ifdef G4VERBOSE
1001  if (verboseLevel>0){
1002  G4cout << "G4VUserPhysicsList::ResetCuts() is obsolete."
1003  << " This method gives no effect and you can remove it. "<< G4endl;
1004  }
1005 #endif
1006 }
#define G4MUTEXUNLOCK
Definition: G4Threading.hh:180
void SetDefaultCutValue(G4double newCutValue)
void BuildIntegralPhysicsTable(G4VProcess *, G4ParticleDefinition *)
void SetApplyCuts(G4bool value, const G4String &name)
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
G4PhysicsListHelper * _thePLHelper
void SetProcessManager(G4ProcessManager *aProcessManager)
G4ProcessVector * GetProcessList() const
void SetCutValue(G4double aCut, const G4String &pname)
void SetEnergyRange(G4double lowedge, G4double highedge)
void PreparePhysicsTable(G4ParticleDefinition *)
G4bool RegisterProcess(G4VProcess *process, G4ParticleDefinition *particle)
G4ProductionCutsTable * fCutsTable
G4String name
Definition: TRTMaterials.hh:40
G4bool GetApplyCuts(const G4String &name) const
G4double GetCutValue(const G4String &pname) const
G4bool fIsCheckedForRetrievePhysicsTable
void SetProductionCut(G4double cut, G4int index=-1)
void SetCutsForRegion(G4double aCut, const G4String &rname)
G4ProcessManager * GetProcessManager() const
G4ParticleDefinition * GetGenericIon() const
G4ParticleTable * theParticleTable
TDirectory * dir
G4UserPhysicsListMessenger * _theMessenger
int G4int
Definition: G4Types.hh:78
G4RUN_DLL G4ThreadLocalStatic T * offset
G4double GetProductionCut(G4int index) const
static G4RegionStore * GetInstance()
G4bool _fIsPhysicsTableBuilt
#define fDisplayThreshold
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
void SetPhysicsTableRetrieved(const G4String &directory="")
void SetParticleCuts(G4double cut, G4ParticleDefinition *particle, G4Region *region=0)
const G4String & GetParticleName() const
void DumpCutValuesTable(G4int flag=1)
void AddProcessManager(G4ParticleDefinition *newParticle, G4ProcessManager *newManager=0)
G4GLOB_DLL std::ostream G4cout
G4int GetInstanceID() const
void SetVerboseLevel(G4int value)
G4bool RetrieveCutsTable(const G4String &directory, G4bool ascii=false)
bool G4bool
Definition: G4Types.hh:79
G4bool GetApplyCutsFlag() const
void SetVerboseLevel(G4int value)
G4ProcessManager * GetMasterProcessManager() const
G4ParticleTable::G4PTblDicIterator * _theParticleIterator
G4int size() const
#define G4MUTEXLOCK
Definition: G4Threading.hh:179
G4VUserPhysicsList & operator=(const G4VUserPhysicsList &)
G4int GetInstanceID() const
string pname
Definition: eplot.py:33
G4bool StorePhysicsTable(const G4String &directory=".")
G4bool IsGeneralIon() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4ProductionCutsTable * GetProductionCutsTable()
void UseCoupledTransportation(G4bool vl=true)
G4PART_DLL G4ThreadLocalStatic G4int slavetotalspace
static G4ParticleTable * GetParticleTable()
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:210
G4ParticleTable::G4PTblDicIterator * GetParticleIterator() const
static G4PhysicsListHelper * GetPhysicsListHelper()
G4bool StoreCutsTable(const G4String &directory, G4bool ascii=false)
static G4RUN_DLL G4VUPLManager subInstanceManager
static const G4VUPLManager & GetSubInstanceManager()
void ResetCuts()
obsolete methods
#define G4endl
Definition: G4ios.hh:61
#define G4MT_theMessenger
void SetProductionCuts(G4ProductionCuts *cut)
static const double TeV
Definition: G4SIunits.hh:215
G4int CreateSubInstance()
static const double keV
Definition: G4SIunits.hh:213
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
G4ProductionCuts * GetProductionCuts() const
#define G4MT_thePLHelper
double G4double
Definition: G4Types.hh:76
#define fIsPhysicsTableBuilt
virtual void RetrievePhysicsTable(G4ParticleDefinition *, const G4String &directory, G4bool ascii=false)
static const double mm
Definition: G4SIunits.hh:114
G4PTblDicIterator * GetIterator() const
const G4String & GetParticleSubType() const
#define theParticleIterator
void SetMasterProcessManager(G4ProcessManager *aNewPM)
G4bool isNull() const