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