Geant4  10.01.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 87128 2014-11-25 09:00:59Z 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()))[0];
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  if(!region){
483  size_t nReg = (G4RegionStore::GetInstance())->size();
484  if (nReg==0) {
485 #ifdef G4VERBOSE
486  if (verboseLevel>0){
487  G4cout << "G4VUserPhysicsList::SetParticleCuts "
488  <<" : No Default Region " <<G4endl;
489  }
490 #endif
491  G4Exception("G4VUserPhysicsList::SetParticleCuts ",
492  "Run0254", FatalException,
493  "No Default Region");
494  return;
495  }
496  region = (*(G4RegionStore::GetInstance()))[0];
497  }
498 
499  if ( !isSetDefaultCutValue ){
501  }
502 
503  G4ProductionCuts* pcuts = region->GetProductionCuts();
504  if(region!=(*(G4RegionStore::GetInstance()))[0] &&
505  pcuts==G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts())
506  { // This region had no unique cuts yet but shares the default cuts.
507  // Need to create a new object before setting the value.
508  pcuts = new G4ProductionCuts(
509  *(G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts()));
510  region->SetProductionCuts(pcuts);
511  }
512  pcuts->SetProductionCut(cut,particleName);
513 #ifdef G4VERBOSE
514  if (verboseLevel>2){
515  G4cout << "G4VUserPhysicsList::SetParticleCuts: "
516  << " :" << cut/mm << "[mm]"
517  << " for "<< particleName << G4endl;
518  }
519 #endif
520 }
521 
524 {
525  //Prepare Physics table for all particles
526  theParticleIterator->reset();
527  while( (*theParticleIterator)() ){
528  G4ParticleDefinition* particle = theParticleIterator->value();
529  PreparePhysicsTable(particle);
530  }
531 
532  // ask processes to prepare physics table
533  if (fRetrievePhysicsTable) {
535  // check if retrieve Cut Table successfully
536  if (!fIsRestoredCutValues) {
537 #ifdef G4VERBOSE
538  if (verboseLevel>0){
539  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
540  << " Retrieve Cut Table failed !!" << G4endl;
541  }
542 #endif
543  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
544  "Run0255", RunMustBeAborted,
545  "Fail to retrieve Production Cut Table");
546  } else {
547 #ifdef G4VERBOSE
548  if (verboseLevel>2){
549  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
550  << " Retrieve Cut Table successfully " << G4endl;
551  }
552 #endif
553  }
554  } else {
555 #ifdef G4VERBOSE
556  if (verboseLevel>2){
557  G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
558  << " does not retrieve Cut Table but calculate " << G4endl;
559  }
560 #endif
561  }
562 
563  // Sets a value to particle
564  // set cut values for gamma at first and for e- and e+
565  G4String particleName;
567  if(GammaP) BuildPhysicsTable(GammaP);
569  if(EMinusP) BuildPhysicsTable(EMinusP);
571  if(EPlusP) BuildPhysicsTable(EPlusP);
572  G4ParticleDefinition* ProtonP = theParticleTable->FindParticle("proton");
573  if(ProtonP) BuildPhysicsTable(ProtonP);
574 
575  theParticleIterator->reset();
576  while( (*theParticleIterator)() ){
577  G4ParticleDefinition* particle = theParticleIterator->value();
578  if( particle!=GammaP &&
579  particle!=EMinusP &&
580  particle!=EPlusP &&
581  particle!=ProtonP ){
582  BuildPhysicsTable(particle);
583  }
584  }
585 
586  // Set flag
587  fIsPhysicsTableBuilt = true;
588 
589 }
591 //Change in order to share physics tables for two kind of process.
593 {
594  if(!(particle->GetMasterProcessManager())) {
595  G4cout << "#### G4VUserPhysicsList::BuildPhysicsTable() - BuildPhysicsTable("
596  << particle->GetParticleName() << ") skipped..." << G4endl;
597  return;
598  }
599  if (fRetrievePhysicsTable) {
600  if ( !fIsRestoredCutValues){
601  // fail to retreive cut tables
602 #ifdef G4VERBOSE
603  if (verboseLevel>0){
604  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
605  << "Physics table can not be retreived and will be calculated "
606  << G4endl;
607  }
608 #endif
609  fRetrievePhysicsTable = false;
610 
611  } else {
612 #ifdef G4VERBOSE
613  if (verboseLevel>2){
614  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
615  << " Retrieve Physics Table for "
616  << particle->GetParticleName() << G4endl;
617  }
618 #endif
619  // Retrieve PhysicsTable from files for proccesses
621  }
622  }
623 
624 #ifdef G4VERBOSE
625  if (verboseLevel>2){
626  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
627  << "Calculate Physics Table for "
628  << particle->GetParticleName() << G4endl;
629  }
630 #endif
631  // Rebuild the physics tables for every process for this particle type
632  // if particle is not ShortLived
633  if(!particle->IsShortLived()) {
634  G4ProcessManager* pManager = particle->GetProcessManager();
635  if (!pManager) {
636 #ifdef G4VERBOSE
637  if (verboseLevel>0){
638  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
639  <<" : No Process Manager for "
640  << particle->GetParticleName() << G4endl;
641  G4cout << particle->GetParticleName()
642  << " should be created in your PhysicsList" <<G4endl;
643  }
644 #endif
645  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
646  "Run0271", FatalException,
647  "No process manager");
648  return;
649  }
650 
651  //Get processes from master thread;
652  G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
653 
654  G4ProcessVector* pVector = pManager->GetProcessList();
655  if (!pVector) {
656 #ifdef G4VERBOSE
657  if (verboseLevel>0){
658  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
659  <<" : No Process Vector for "
660  << particle->GetParticleName() <<G4endl;
661  }
662 #endif
663  G4Exception("G4VUserPhysicsList::BuildPhysicsTable",
664  "Run0272", FatalException,
665  "No process Vector");
666  return;
667  }
668 #ifdef G4VERBOSE
669  if (verboseLevel>2){
670  G4cout << "G4VUserPhysicsList::BuildPhysicsTable %%%%%% " << particle->GetParticleName() << G4endl;
671  G4cout << " ProcessManager : " << pManager << " ProcessManagerShadow : " << pManagerShadow << G4endl;
672  for(G4int iv1=0;iv1<pVector->size();iv1++)
673  { G4cout << " " << iv1 << " - " << (*pVector)[iv1]->GetProcessName() << G4endl; }
674  G4cout << "--------------------------------------------------------------" << G4endl;
675  G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
676 
677  for(G4int iv2=0;iv2<pVectorShadow->size();iv2++)
678  { G4cout << " " << iv2 << " - " << (*pVectorShadow)[iv2]->GetProcessName() << G4endl; }
679  }
680 #endif
681  for (G4int j=0; j < pVector->size(); ++j) {
682  //Andrea July 16th 2013 : migration to new interface...
683  //Infer if we are in a worker thread or master thread
684  //Master thread is the one in which the process manager
685  // and process manager shadow pointers are the same
686  if ( pManagerShadow == pManager )
687  {
688  (*pVector)[j]->BuildPhysicsTable(*particle);
689  }
690  else
691  {
692  (*pVector)[j]->BuildWorkerPhysicsTable(*particle);
693  }
694 
695  } //End loop on processes vector
696  } //End if short-lived
697 }
698 
701 {
702  if(!(particle->GetMasterProcessManager())) {
705  return;
706  }
707  // Prepare the physics tables for every process for this particle type
708  // if particle is not ShortLived
709  if(!particle->IsShortLived()) {
710  G4ProcessManager* pManager = particle->GetProcessManager();
711  if (!pManager) {
712 #ifdef G4VERBOSE
713  if (verboseLevel>0) {
714  G4cout<< "G4VUserPhysicsList::PreparePhysicsTable "
715  << ": No Process Manager for "
716  << particle->GetParticleName() <<G4endl;
717  G4cout << particle->GetParticleName()
718  << " should be created in your PhysicsList" <<G4endl;
719  }
720 #endif
721  G4Exception("G4VUserPhysicsList::PreparePhysicsTable",
722  "Run0273", FatalException,
723  "No process manager");
724  return;
725  }
726 
727  //Get processes from master thread
728  G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
729  //Andrea Dotti 15 Jan 2013: Change of interface of MSC
730  //G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
731 
732  G4ProcessVector* pVector = pManager->GetProcessList();
733  if (!pVector) {
734 #ifdef G4VERBOSE
735  if (verboseLevel>0) {
736  G4cout << "G4VUserPhysicsList::PreparePhysicsTable "
737  << ": No Process Vector for "
738  << particle->GetParticleName() <<G4endl;
739  }
740 #endif
741  G4Exception("G4VUserPhysicsList::PreparePhysicsTable",
742  "Run0274", FatalException,
743  "No process Vector");
744  return;
745  }
746  for (G4int j=0; j < pVector->size(); ++j) {
747 
748  //Andrea July 16th 2013 : migration to new interface...
749  //Infer if we are in a worker thread or master thread
750  //Master thread is the one in which the process manager
751  // and process manager shadow pointers are the same
752  if ( pManagerShadow == pManager )
753  {
754  (*pVector)[j]->PreparePhysicsTable(*particle);
755  }
756  else
757  {
758  (*pVector)[j]->PrepareWorkerPhysicsTable(*particle);
759  }
760  } //End loop on processes vector
761  } //End if pn ShortLived
762 }
763 
764 //TODO Should we change this function?
767  G4ParticleDefinition* particle)
768 {
769  //*********************************************************************
770  // temporary addition to make the integral schema of electromagnetic
771  // processes work.
772  //
773 
774  if ( (process->GetProcessName() == "Imsc") ||
775  (process->GetProcessName() == "IeIoni") ||
776  (process->GetProcessName() == "IeBrems") ||
777  (process->GetProcessName() == "Iannihil") ||
778  (process->GetProcessName() == "IhIoni") ||
779  (process->GetProcessName() == "IMuIoni") ||
780  (process->GetProcessName() == "IMuBrems") ||
781  (process->GetProcessName() == "IMuPairProd") ) {
782 #ifdef G4VERBOSE
783  if (verboseLevel>2){
784  G4cout << "G4VUserPhysicsList::BuildIntegralPhysicsTable "
785  << " BuildPhysicsTable is invoked for "
786  << process->GetProcessName()
787  << "(" << particle->GetParticleName() << ")" << G4endl;
788  }
789 #endif
790  process->BuildPhysicsTable(*particle);
791  }
792 }
793 
796 {
797  theParticleIterator->reset();
798  G4int idx = 0;
799  while( (*theParticleIterator)() ){
800  G4ParticleDefinition* particle = theParticleIterator->value();
801  G4cout << particle->GetParticleName();
802  if ((idx++ % 4) == 3) {
803  G4cout << G4endl;
804  } else {
805  G4cout << ", ";
806  }
807  }
808  G4cout << G4endl;
809 }
810 
811 
814 {
815  fDisplayThreshold = flag;
816 }
817 
820 {
821  if(fDisplayThreshold==0) return;
823  fDisplayThreshold = 0;
824 }
825 
826 
829 {
830  G4bool ascii = fStoredInAscii;
831  G4String dir = directory;
832  if (dir.isNull()) dir = directoryPhysicsTable;
833  else directoryPhysicsTable = dir;
834 
835  // store CutsTable info
836  if (!fCutsTable->StoreCutsTable(dir, ascii)) {
837  G4Exception("G4VUserPhysicsList::StorePhysicsTable",
838  "Run0281", JustWarning,
839  "Fail to store Cut Table");
840  return false;
841  }
842 #ifdef G4VERBOSE
843  if (verboseLevel>2){
844  G4cout << "G4VUserPhysicsList::StorePhysicsTable "
845  << " Store material and cut values successfully" << G4endl;
846  }
847 #endif
848 
849  G4bool success= true;
850 
851  // loop over all particles in G4ParticleTable
852  theParticleIterator->reset();
853  while( (*theParticleIterator)() ){
854  G4ParticleDefinition* particle = theParticleIterator->value();
855  // Store physics tables for every process for this particle type
856  G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
857  G4int j;
858  for ( j=0; j < pVector->size(); ++j) {
859  if (!(*pVector)[j]->StorePhysicsTable(particle,dir,ascii)){
860  G4String comment = "Fail to store physics table for ";
861  comment += (*pVector)[j]->GetProcessName();
862  comment += "(" + particle->GetParticleName() + ")";
863  G4Exception("G4VUserPhysicsList::StorePhysicsTable",
864  "Run0282", JustWarning,
865  comment);
866  success = false;
867  }
868  }
869  // end loop over processes
870  }
871  // end loop over particles
872  return success;
873 }
874 
875 
876 
879 {
880  fRetrievePhysicsTable = true;
881  if(!directory.isNull()) {
882  directoryPhysicsTable = directory;
883  }
885  fIsRestoredCutValues = false;
886 }
887 
890  const G4String& directory,
891  G4bool ascii)
892 {
893  G4int j;
894  G4bool success[100];
895  // Retrieve physics tables for every process for this particle type
896  G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
897  for ( j=0; j < pVector->size(); ++j) {
898  success[j] =
899  (*pVector)[j]->RetrievePhysicsTable(particle,directory,ascii);
900 
901  if (!success[j]) {
902 #ifdef G4VERBOSE
903  if (verboseLevel>2){
904  G4cout << "G4VUserPhysicsList::RetrievePhysicsTable "
905  << " Fail to retrieve Physics Table for "
906  << (*pVector)[j]->GetProcessName() << G4endl;
907  G4cout << "Calculate Physics Table for "
908  << particle->GetParticleName() << G4endl;
909  }
910 #endif
911  (*pVector)[j]->BuildPhysicsTable(*particle);
912  }
913  }
914  for ( j=0; j < pVector->size(); ++j) {
915  // temporary addition to make the integral schema
916  if (!success[j]) BuildIntegralPhysicsTable((*pVector)[j], particle);
917  }
918 }
919 
920 
923 {
924 #ifdef G4VERBOSE
925  if (verboseLevel>2){
926  G4cout << "G4VUserPhysicsList::SetApplyCuts for " << name << G4endl;
927  }
928 #endif
929  if(name=="all") {
934  } else {
936  }
937 }
938 
941 {
943 }
944 
945 
948 {
950  G4MT_thePLHelper->CheckParticleList();
951  }
952 }
953 
956 {
957  G4MT_thePLHelper->AddTransportation();
958 }
959 
962 {
963  G4MT_thePLHelper->UseCoupledTransportation(vl);
964 }
965 
968  G4ParticleDefinition* particle)
969 {
970  return G4MT_thePLHelper->RegisterProcess(process, particle);
971 }
972 
975 {
976  verboseLevel = value;
977  // set verboseLevel for G4ProductionCutsTable same as one for G4VUserPhysicsList:
979 
980  G4MT_thePLHelper->SetVerboseLevel(verboseLevel);
981 
982 #ifdef G4VERBOSE
983  if (verboseLevel >1){
984  G4cout << "G4VUserPhysicsList::SetVerboseLevel :"
985  << " Verbose level is set to " << verboseLevel << G4endl;
986  }
987 #endif
988 }
989 
990 
993 
996 {
997 #ifdef G4VERBOSE
998  if (verboseLevel>0){
999  G4cout << "G4VUserPhysicsList::ResetCuts() is obsolete."
1000  << " This method gives no effect and you can remove it. "<< G4endl;
1001  }
1002 #endif
1003 }
#define G4MUTEXUNLOCK
Definition: G4Threading.hh:176
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:175
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:197
G4int CreateSubInstance()
static const double keV
Definition: G4SIunits.hh:195
double G4double
Definition: G4Types.hh:76
virtual void RetrievePhysicsTable(G4ParticleDefinition *, const G4String &directory, G4bool ascii=false)
static const double mm
Definition: G4SIunits.hh:102
G4PTblDicIterator * GetIterator() const
G4bool isNull() const
#define theParticleIterator
void SetMasterProcessManager(G4ProcessManager *aNewPM)
G4ProcessVector * GetProcessList() const