ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VUserPhysicsList.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 //
28 //
29 // ------------------------------------------------------------
30 // GEANT 4 class header file
31 //
32 // ------------------------------------------------------------
33 // History
34 // first version 09 Jan 1998 by H.Kurashige
35 // Added SetEnergyRange 18 Jun 1998 by H.Kurashige
36 // Change for short lived particles 27 Jun 1998 by H.Kurashige
37 // G4BestUnit on output 12 nov 1998 by M.Maire
38 // Added RemoveProcessManager 9 Feb 1999 by H.Kurashige
39 // Fixed RemoveProcessManager 15 Apr 1999 by H.Kurashige
40 // Removed ConstructAllParticles() 15 Apr 1999 by H.Kurashige
41 // Modified for CUTS per REGION 10 Oct 2002 by H.Kurashige
42 // Check if particle IsShortLived 18 Jun 2003 by V.Ivanchenko
43 // Modify PreparePhysicsList 18 Jan 2006 by H.Kurashige
44 // Added PhysicsListHelper 29 APr. 2011 H.Kurashige
45 // Added default impelmentation of SetCuts 10 June 2011 H.Kurashige
46 // SetCuts is not 'pure virtual' any more
47 // Transformation for G4MT 26 Mar 2013 A. Dotti
48 // PL is shared by threads. Adding a method for workers
49 // To initialize thread specific data
50 // ------------------------------------------------------------
51 
52 #include <iomanip>
53 #include <fstream>
54 
55 #include "G4PhysicsListHelper.hh"
56 #include "G4VUserPhysicsList.hh"
57 
58 //Andrea Dotti (Jan 13, 2013), transformation for G4MT
59 #include "G4VMultipleScattering.hh"
60 #include "G4VEnergyLossProcess.hh"
61 
62 
63 #include "globals.hh"
64 #include "G4SystemOfUnits.hh"
65 #include "G4ios.hh"
66 #include "G4ParticleDefinition.hh"
67 #include "G4ProcessManager.hh"
68 #include "G4ParticleTable.hh"
69 #include "G4ProductionCutsTable.hh"
70 #include "G4Material.hh"
72 #include "G4UImanager.hh"
73 #include "G4UnitsTable.hh"
74 #include "G4RegionStore.hh"
75 #include "G4Region.hh"
76 #include "G4ProductionCutsTable.hh"
77 #include "G4ProductionCuts.hh"
78 #include "G4MaterialCutsCouple.hh"
79 
80 // This static member is thread local. For each thread, it holds the array
81 // size of G4VUPLData instances.
82 //
83 #define G4MT_theMessenger ((this->subInstanceManager.offset[this->g4vuplInstanceID])._theMessenger)
84 #define G4MT_thePLHelper ((this->subInstanceManager.offset[this->g4vuplInstanceID])._thePLHelper)
85 #define fIsPhysicsTableBuilt ((this->subInstanceManager.offset[this->g4vuplInstanceID])._fIsPhysicsTableBuilt)
86 #define fDisplayThreshold ((this->subInstanceManager.offset[this->g4vuplInstanceID])._fDisplayThreshold)
87 #define theParticleIterator ((this->subInstanceManager.offset[this->g4vuplInstanceID])._theParticleIterator)
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 
153 {
155  delete G4MT_theMessenger;
156  G4MT_theMessenger = nullptr;
157 }
160 {
161  if (G4MT_theMessenger != 0) {
162  delete G4MT_theMessenger;
163  G4MT_theMessenger = 0;
164  }
166 
167  // invoke DeleteAllParticle
169 
170 }
171 
174  :verboseLevel(right.verboseLevel),
175  defaultCutValue(right.defaultCutValue),
176  isSetDefaultCutValue(right.isSetDefaultCutValue),
177  fRetrievePhysicsTable(right.fRetrievePhysicsTable),
178  fStoredInAscii(right.fStoredInAscii),
179  fIsCheckedForRetrievePhysicsTable(right.fIsCheckedForRetrievePhysicsTable),
180  fIsRestoredCutValues(right.fIsRestoredCutValues),
181  directoryPhysicsTable(right.directoryPhysicsTable),
182  //fDisplayThreshold(right.fDisplayThreshold),
183  //fIsPhysicsTableBuilt(right.fIsPhysicsTableBuilt),
184  fDisableCheckParticleList(right.fDisableCheckParticleList)
185 {
187  // pointer to the particle table
190  // pointer to the cuts table
192 
193  // UI Messenger
194  //theMessenger = new G4UserPhysicsListMessenger(this);
196 
197  // PhysicsListHelper
198  //thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
199  //thePLHelper->SetVerboseLevel(verboseLevel);
201  G4MT_thePLHelper->SetVerboseLevel(verboseLevel); //AND
202 
203  fIsPhysicsTableBuilt = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fIsPhysicsTableBuilt;
204  fDisplayThreshold = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fDisplayThreshold;
205 }
206 
207 
210 {
211  if (this != &right) {
212  verboseLevel = right.verboseLevel;
220  //fDisplayThreshold = right.fDisplayThreshold;
221  fIsPhysicsTableBuilt = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fIsPhysicsTableBuilt;
222  fDisplayThreshold = right.GetSubInstanceManager().offset[right.GetInstanceID()]._fDisplayThreshold;
223  //fIsPhysicsTableBuilt = right.fIsPhysicsTableBuilt;
225  }
226  return *this;
227 }
228 
232 {
233  if (newParticle == 0) return;
234  G4Exception("G4VUserPhysicsList::AddProcessManager",
235  "Run0252", JustWarning,
236  "This method is obsolete");
237 }
238 
239 
242 {
243  //Request lock for particle table accesses. Some changes are inside
244  //this critical region.
245 #ifdef G4MULTITHREADED
246  G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
247  G4ParticleTable::lockCount()++;
248 #endif
250 
251  // loop over all particles in G4ParticleTable
252  theParticleIterator->reset();
253  while( (*theParticleIterator)() ){
255  G4ProcessManager* pmanager = particle->GetProcessManager();
256 
257  if (pmanager==0) {
258  // create process manager if the particle does not have its own.
259  pmanager = new G4ProcessManager(particle);
260  particle->SetProcessManager(pmanager);
261  if( particle->GetMasterProcessManager() == 0 ) particle->SetMasterProcessManager(pmanager);
262 #ifdef G4VERBOSE
263  if (verboseLevel >2){
264  G4cout << "G4VUserPhysicsList::InitializeProcessManager: creating ProcessManager to "
265  << particle->GetParticleName() << G4endl;
266  }
267 #endif
268  }
269  }
270 
271  if(gion)
272  {
273  G4ProcessManager* gionPM = gion->GetProcessManager();
274  // loop over all particles once again (this time, with all general ions)
275  theParticleIterator->reset(false);
276  while( (*theParticleIterator)() ){
278  if(particle->IsGeneralIon())
279  {
280  particle->SetProcessManager(gionPM);
281 #ifdef G4VERBOSE
282  if (verboseLevel >2){
283  G4cout << "G4VUserPhysicsList::InitializeProcessManager: copying ProcessManager to "
284  << particle->GetParticleName() << G4endl;
285  }
286 #endif
287  }
288  }
289  }
290 
291  //release lock for particle table accesses.
292 #ifdef G4MULTITHREADED
293  G4MUTEXUNLOCK(&G4ParticleTable::particleTableMutex());
294 #endif
295 // G4cout << "Particle table is released by G4VUserPhysicsList::InitializeProcessManager" << G4endl;
296 
297 }
298 
301 {
302  //Request lock for particle table accesses. Some changes are inside
303  //this critical region.
304 #ifdef G4MULTITHREADED
305  G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
306  G4ParticleTable::lockCount()++;
307 #endif
308 // G4cout << "Particle table is held by G4VUserPhysicsList::InitializeProcessManager" << G4endl;
309 
310  // loop over all particles in G4ParticleTable
311  theParticleIterator->reset();
312  while( (*theParticleIterator)() ){
315  {
316  if(particle->GetParticleSubType()!="generic" || particle->GetParticleName()=="GenericIon")
317  {
318  G4ProcessManager* pmanager = particle->GetProcessManager();
319  if (pmanager!=0) delete pmanager;
320 #ifdef G4VERBOSE
321  if (verboseLevel >2){
322  G4cout << "G4VUserPhysicsList::RemoveProcessManager: ";
323  G4cout << "remove ProcessManager from ";
324  G4cout << particle->GetParticleName() << G4endl;
325  }
326 #endif
327  }
328  particle->SetProcessManager(0);
329  }
330  }
331 
332  //release lock for particle table accesses.
333 #ifdef G4MULTITHREADED
334  G4MUTEXUNLOCK(&G4ParticleTable::particleTableMutex());
335 #endif
336 // G4cout << "Particle table is released by G4VUserPhysicsList::InitializeProcessManager" << G4endl;
337 
338 }
339 
342 {
343  if ( !isSetDefaultCutValue ){
345  }
346 
347 #ifdef G4VERBOSE
348  if (verboseLevel >1){
349  G4cout << "G4VUserPhysicsList::SetCuts: " << G4endl;
350  G4cout << "Cut for gamma: " << GetCutValue("gamma")/mm
351  << "[mm]" << G4endl;
352  G4cout << "Cut for e-: " << GetCutValue("e-")/mm
353  << "[mm]" << G4endl;
354  G4cout << "Cut for e+: " << GetCutValue("e+")/mm
355  << "[mm]" << G4endl;
356  G4cout << "Cut for proton: " << GetCutValue("proton")/mm
357  << "[mm]" << G4endl;
358  }
359 #endif
360 
361  // dump Cut values if verboseLevel==3
362  if (verboseLevel>2) {
364  }
365 }
366 
367 
370 {
371  if (value<0.0) {
372 #ifdef G4VERBOSE
373  if (verboseLevel >0){
374  G4cout << "G4VUserPhysicsList::SetDefaultCutValue: negative cut values"
375  << " :" << value/mm << "[mm]" << G4endl;
376  }
377 #endif
378  return;
379  }
380 
382  isSetDefaultCutValue = true;
383 
384  // set cut values for gamma at first and for e- and e+
385  SetCutValue(defaultCutValue, "gamma");
388  SetCutValue(defaultCutValue, "proton");
389 
390 #ifdef G4VERBOSE
391  if (verboseLevel >1){
392  G4cout << "G4VUserPhysicsList::SetDefaultCutValue:"
393  << "default cut value is changed to :"
394  << defaultCutValue/mm << "[mm]" << G4endl;
395  }
396 #endif
397  }
398 
399 
402 {
403  size_t nReg = (G4RegionStore::GetInstance())->size();
404  if (nReg==0) {
405 #ifdef G4VERBOSE
406  if (verboseLevel>0){
407  G4cout << "G4VUserPhysicsList::GetCutValue "
408  <<" : No Default Region " <<G4endl;
409  }
410 #endif
411  G4Exception("G4VUserPhysicsList::GetCutValue",
412  "Run0253", FatalException,
413  "No Default Region");
414  return -1.*mm;
415  }
416  G4Region* region = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", false);
417  return region->GetProductionCuts()->GetProductionCut(name);
418 }
419 
422 {
423  SetParticleCuts( aCut ,name );
424 }
425 
428 (G4double aCut, const G4String& pname, const G4String& rname)
429 {
430  G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
431  if (region != 0){
432  //set cut value
433  SetParticleCuts( aCut ,pname, region );
434  } else {
435 #ifdef G4VERBOSE
436  if (verboseLevel>0){
437  G4cout << "G4VUserPhysicsList::SetCutValue "
438  <<" : No Region of " << rname << G4endl;
439  }
440 #endif
441  }
442 }
443 
444 
447 {
450 }
451 
454 {
455  // set cut values for gamma at first and for e- and e+
456  SetCutValue(aCut, "gamma", rname);
457  SetCutValue(aCut, "e-", rname);
458  SetCutValue(aCut, "e+", rname);
459  SetCutValue(aCut, "proton", rname);
460 }
461 
462 
463 
466 {
467  SetParticleCuts(cut, particle->GetParticleName(), region);
468 }
469 
471 void G4VUserPhysicsList::SetParticleCuts( G4double cut, const G4String& particleName, G4Region* region)
472 {
473  if (cut<0.0) {
474 #ifdef G4VERBOSE
475  if (verboseLevel >0){
476  G4cout << "G4VUserPhysicsList::SetParticleCuts: negative cut values"
477  << " :" << cut/mm << "[mm]"
478  << " for "<< particleName << G4endl;
479  }
480 #endif
481  return;
482  }
483 
484  G4Region* world_region = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", false);
485  if(!region){
486  size_t nReg = (G4RegionStore::GetInstance())->size();
487  if (nReg==0) {
488 #ifdef G4VERBOSE
489  if (verboseLevel>0){
490  G4cout << "G4VUserPhysicsList::SetParticleCuts "
491  <<" : No Default Region " <<G4endl;
492  }
493 #endif
494  G4Exception("G4VUserPhysicsList::SetParticleCuts ",
495  "Run0254", FatalException,
496  "No Default Region");
497  return;
498  }
499  region = world_region;
500  }
501 
502  if ( !isSetDefaultCutValue ){
504  }
505 
506  G4ProductionCuts* pcuts = region->GetProductionCuts();
507  if(region != world_region &&
508  pcuts==G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts())
509  { // This region had no unique cuts yet but shares the default cuts.
510  // Need to create a new object before setting the value.
511  pcuts = new G4ProductionCuts(
512  *(G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts()));
513  region->SetProductionCuts(pcuts);
514  }
515  pcuts->SetProductionCut(cut,particleName);
516 #ifdef G4VERBOSE
517  if (verboseLevel>2){
518  G4cout << "G4VUserPhysicsList::SetParticleCuts: "
519  << " :" << cut/mm << "[mm]"
520  << " for "<< particleName << G4endl;
521  }
522 #endif
523 }
524 
527 {
528  //Prepare Physics table for all particles
529  theParticleIterator->reset();
530  while( (*theParticleIterator)() ){
532  PreparePhysicsTable(particle);
533  }
534 
535  // ask processes to prepare physics table
536  if (fRetrievePhysicsTable) {
538  // check if retrieve Cut Table successfully
539  if (!fIsRestoredCutValues) {
540 #ifdef G4VERBOSE
541  if (verboseLevel>0){
542  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
543  << " Retrieve Cut Table failed !!" << G4endl;
544  }
545 #endif
546  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
547  "Run0255", RunMustBeAborted,
548  "Fail to retrieve Production Cut Table");
549  } else {
550 #ifdef G4VERBOSE
551  if (verboseLevel>2){
552  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
553  << " Retrieve Cut Table successfully " << G4endl;
554  }
555 #endif
556  }
557  } else {
558 #ifdef G4VERBOSE
559  if (verboseLevel>2){
560  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
561  << " does not retrieve Cut Table but calculate " << G4endl;
562  }
563 #endif
564  }
565 
566  // Sets a value to particle
567  // set cut values for gamma at first and for e- and e+
568  G4String particleName;
570  if(GammaP) BuildPhysicsTable(GammaP);
572  if(EMinusP) BuildPhysicsTable(EMinusP);
574  if(EPlusP) BuildPhysicsTable(EPlusP);
575  G4ParticleDefinition* ProtonP = theParticleTable->FindParticle("proton");
576  if(ProtonP) BuildPhysicsTable(ProtonP);
577 
578  theParticleIterator->reset();
579  while( (*theParticleIterator)() ){
581  if( particle!=GammaP &&
582  particle!=EMinusP &&
583  particle!=EPlusP &&
584  particle!=ProtonP ){
585  BuildPhysicsTable(particle);
586  }
587  }
588 
589  // Set flag
590  fIsPhysicsTableBuilt = true;
591 
592 }
594 //Change in order to share physics tables for two kind of process.
596 {
597  if(!(particle->GetMasterProcessManager())) {
598  G4cout << "#### G4VUserPhysicsList::BuildPhysicsTable() - BuildPhysicsTable("
599  << particle->GetParticleName() << ") skipped..." << G4endl;
600  return;
601  }
602  if (fRetrievePhysicsTable) {
603  if ( !fIsRestoredCutValues){
604  // fail to retrieve cut tables
605 #ifdef G4VERBOSE
606  if (verboseLevel>0){
607  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
608  << "Physics table can not be retrieved and will be calculated "
609  << G4endl;
610  }
611 #endif
612  fRetrievePhysicsTable = false;
613 
614  } else {
615 #ifdef G4VERBOSE
616  if (verboseLevel>2){
617  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
618  << " Retrieve Physics Table for "
619  << particle->GetParticleName() << G4endl;
620  }
621 #endif
622  // Retrieve PhysicsTable from files for proccesses
624  }
625  }
626 
627 #ifdef G4VERBOSE
628  if (verboseLevel>2){
629  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
630  << "Calculate Physics Table for "
631  << particle->GetParticleName() << G4endl;
632  }
633 #endif
634  // Rebuild the physics tables for every process for this particle type
635  // if particle is not ShortLived
636  if(!particle->IsShortLived()) {
637  G4ProcessManager* pManager = particle->GetProcessManager();
638  if (!pManager) {
639 #ifdef G4VERBOSE
640  if (verboseLevel>0){
641  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
642  <<" : No Process Manager for "
643  << particle->GetParticleName() << G4endl;
644  G4cout << particle->GetParticleName()
645  << " should be created in your PhysicsList" <<G4endl;
646  }
647 #endif
648  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
649  "Run0271", FatalException,
650  "No process manager");
651  return;
652  }
653 
654  //Get processes from master thread;
655  G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
656 
657  G4ProcessVector* pVector = pManager->GetProcessList();
658  if (!pVector) {
659 #ifdef G4VERBOSE
660  if (verboseLevel>0){
661  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
662  <<" : No Process Vector for "
663  << particle->GetParticleName() <<G4endl;
664  }
665 #endif
666  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
667  "Run0272", FatalException,
668  "No process Vector");
669  return;
670  }
671 #ifdef G4VERBOSE
672  if (verboseLevel>2){
673  G4cout << "G4VUserPhysicsList::BuildPhysicsTable %%%%%% " << particle->GetParticleName() << G4endl;
674  G4cout << " ProcessManager : " << pManager << " ProcessManagerShadow : " << pManagerShadow << G4endl;
675  for(std::size_t iv1=0;iv1<pVector->size();++iv1)
676  { G4cout << " " << iv1 << " - " << (*pVector)[iv1]->GetProcessName() << G4endl; }
677  G4cout << "--------------------------------------------------------------" << G4endl;
678  G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
679 
680  for(std::size_t iv2=0;iv2<pVectorShadow->size();++iv2)
681  { G4cout << " " << iv2 << " - " << (*pVectorShadow)[iv2]->GetProcessName() << G4endl; }
682  }
683 #endif
684  for (std::size_t j=0; j < pVector->size(); ++j) {
685  //Andrea July 16th 2013 : migration to new interface...
686  //Infer if we are in a worker thread or master thread
687  //Master thread is the one in which the process manager
688  // and process manager shadow pointers are the same
689  if ( pManagerShadow == pManager )
690  {
691  (*pVector)[j]->BuildPhysicsTable(*particle);
692  }
693  else
694  {
695  (*pVector)[j]->BuildWorkerPhysicsTable(*particle);
696  }
697 
698  } //End loop on processes vector
699  } //End if short-lived
700 }
701 
704 {
705  if(!(particle->GetMasterProcessManager())) {
708  return;
709  }
710  // Prepare the physics tables for every process for this particle type
711  // if particle is not ShortLived
712  if(!particle->IsShortLived()) {
713  G4ProcessManager* pManager = particle->GetProcessManager();
714  if (!pManager) {
715 #ifdef G4VERBOSE
716  if (verboseLevel>0) {
717  G4cout<< "G4VUserPhysicsList::PreparePhysicsTable "
718  << ": No Process Manager for "
719  << particle->GetParticleName() <<G4endl;
720  G4cout << particle->GetParticleName()
721  << " should be created in your PhysicsList" <<G4endl;
722  }
723 #endif
724  G4Exception("G4VUserPhysicsList::PreparePhysicsTable",
725  "Run0273", FatalException,
726  "No process manager");
727  return;
728  }
729 
730  //Get processes from master thread
731  G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
732  //Andrea Dotti 15 Jan 2013: Change of interface of MSC
733  //G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
734 
735  G4ProcessVector* pVector = pManager->GetProcessList();
736  if (!pVector) {
737 #ifdef G4VERBOSE
738  if (verboseLevel>0) {
739  G4cout << "G4VUserPhysicsList::PreparePhysicsTable "
740  << ": No Process Vector for "
741  << particle->GetParticleName() <<G4endl;
742  }
743 #endif
744  G4Exception("G4VUserPhysicsList::PreparePhysicsTable",
745  "Run0274", FatalException,
746  "No process Vector");
747  return;
748  }
749  for (std::size_t j=0; j < pVector->size(); ++j) {
750 
751  //Andrea July 16th 2013 : migration to new interface...
752  //Infer if we are in a worker thread or master thread
753  //Master thread is the one in which the process manager
754  // and process manager shadow pointers are the same
755  if ( pManagerShadow == pManager )
756  {
757  (*pVector)[j]->PreparePhysicsTable(*particle);
758  }
759  else
760  {
761  (*pVector)[j]->PrepareWorkerPhysicsTable(*particle);
762  }
763  } //End loop on processes vector
764  } //End if pn ShortLived
765 }
766 
767 //TODO Should we change this function?
771 {
772  //*********************************************************************
773  // temporary addition to make the integral schema of electromagnetic
774  // processes work.
775  //
776 
777  if ( (process->GetProcessName() == "Imsc") ||
778  (process->GetProcessName() == "IeIoni") ||
779  (process->GetProcessName() == "IeBrems") ||
780  (process->GetProcessName() == "Iannihil") ||
781  (process->GetProcessName() == "IhIoni") ||
782  (process->GetProcessName() == "IMuIoni") ||
783  (process->GetProcessName() == "IMuBrems") ||
784  (process->GetProcessName() == "IMuPairProd") ) {
785 #ifdef G4VERBOSE
786  if (verboseLevel>2){
787  G4cout << "G4VUserPhysicsList::BuildIntegralPhysicsTable "
788  << " BuildPhysicsTable is invoked for "
789  << process->GetProcessName()
790  << "(" << particle->GetParticleName() << ")" << G4endl;
791  }
792 #endif
793  process->BuildPhysicsTable(*particle);
794  }
795 }
796 
799 {
800  theParticleIterator->reset();
801  G4int idx = 0;
802  while( (*theParticleIterator)() ){
804  G4cout << particle->GetParticleName();
805  if ((idx++ % 4) == 3) {
806  G4cout << G4endl;
807  } else {
808  G4cout << ", ";
809  }
810  }
811  G4cout << G4endl;
812 }
813 
814 
817 {
818  fDisplayThreshold = flag;
819 }
820 
823 {
824  if(fDisplayThreshold==0) return;
826  fDisplayThreshold = 0;
827 }
828 
829 
832 {
833  G4bool ascii = fStoredInAscii;
834  G4String dir = directory;
835  if (dir.isNull()) dir = directoryPhysicsTable;
836  else directoryPhysicsTable = dir;
837 
838  // store CutsTable info
839  if (!fCutsTable->StoreCutsTable(dir, ascii)) {
840  G4Exception("G4VUserPhysicsList::StorePhysicsTable",
841  "Run0281", JustWarning,
842  "Fail to store Cut Table");
843  return false;
844  }
845 #ifdef G4VERBOSE
846  if (verboseLevel>2){
847  G4cout << "G4VUserPhysicsList::StorePhysicsTable "
848  << " Store material and cut values successfully" << G4endl;
849  }
850 #endif
851 
852  G4bool success= true;
853 
854  // loop over all particles in G4ParticleTable
855  theParticleIterator->reset();
856  while( (*theParticleIterator)() ){
858  // Store physics tables for every process for this particle type
859  G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
860  for (std::size_t j=0; j < pVector->size(); ++j) {
861  if (!(*pVector)[j]->StorePhysicsTable(particle,dir,ascii)){
862  G4String comment = "Fail to store physics table for ";
863  comment += (*pVector)[j]->GetProcessName();
864  comment += "(" + particle->GetParticleName() + ")";
865  G4Exception("G4VUserPhysicsList::StorePhysicsTable",
866  "Run0282", JustWarning,
867  comment);
868  success = false;
869  }
870  }
871  // end loop over processes
872  }
873  // end loop over particles
874  return success;
875 }
876 
877 
878 
881 {
882  fRetrievePhysicsTable = true;
883  if(!directory.isNull()) {
884  directoryPhysicsTable = directory;
885  }
887  fIsRestoredCutValues = false;
888 }
889 
892  const G4String& directory,
893  G4bool ascii)
894 {
895  G4bool success[100];
896  // Retrieve physics tables for every process for this particle type
897  G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
898  for (std::size_t j=0; j < pVector->size(); ++j) {
899  success[j] =
900  (*pVector)[j]->RetrievePhysicsTable(particle,directory,ascii);
901 
902  if (!success[j]) {
903 #ifdef G4VERBOSE
904  if (verboseLevel>2){
905  G4cout << "G4VUserPhysicsList::RetrievePhysicsTable "
906  << " Fail to retrieve Physics Table for "
907  << (*pVector)[j]->GetProcessName() << G4endl;
908  G4cout << "Calculate Physics Table for "
909  << particle->GetParticleName() << G4endl;
910  }
911 #endif
912  (*pVector)[j]->BuildPhysicsTable(*particle);
913  }
914  }
915  for (std::size_t j=0; j < pVector->size(); ++j) {
916  // temporary addition to make the integral schema
917  if (!success[j]) BuildIntegralPhysicsTable((*pVector)[j], particle);
918  }
919 }
920 
921 
924 {
925 #ifdef G4VERBOSE
926  if (verboseLevel>2){
927  G4cout << "G4VUserPhysicsList::SetApplyCuts for " << name << G4endl;
928  }
929 #endif
930  if(name=="all") {
935  } else {
937  }
938 }
939 
942 {
944 }
945 
946 
949 {
951  G4MT_thePLHelper->CheckParticleList();
952  }
953 }
954 
957 {
958  G4MT_thePLHelper->AddTransportation();
959 }
960 
963 {
964  G4MT_thePLHelper->UseCoupledTransportation(vl);
965 }
966 
970 {
971  return G4MT_thePLHelper->RegisterProcess(process, particle);
972 }
973 
976 {
977  return (subInstanceManager.offset[g4vuplInstanceID])._theParticleIterator;
978 }
979 
982 {
984  // set verboseLevel for G4ProductionCutsTable same as one for G4VUserPhysicsList:
986 
987  G4MT_thePLHelper->SetVerboseLevel(verboseLevel);
988 
989 #ifdef G4VERBOSE
990  if (verboseLevel >1){
991  G4cout << "G4VUserPhysicsList::SetVerboseLevel :"
992  << " Verbose level is set to " << verboseLevel << G4endl;
993  }
994 #endif
995 }
996 
997 
1000 
1003 {
1004 #ifdef G4VERBOSE
1005  if (verboseLevel>0){
1006  G4cout << "G4VUserPhysicsList::ResetCuts() is obsolete."
1007  << " This method gives no effect and you can remove it. "<< G4endl;
1008  }
1009 #endif
1010 }