Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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//
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 <fstream>
53#include <iomanip>
54
56#include "G4VUserPhysicsList.hh"
57
58// Andrea Dotti (Jan 13, 2013), transformation for G4MT
61
62#include "G4Material.hh"
65#include "G4ParticleTable.hh"
66#include "G4ProcessManager.hh"
67#include "G4ProductionCuts.hh"
69#include "G4Region.hh"
70#include "G4RegionStore.hh"
71#include "G4SystemOfUnits.hh"
72#include "G4UImanager.hh"
73#include "G4UnitsTable.hh"
75#include "G4ios.hh"
76#include "globals.hh"
77
78// This static member is thread local. For each thread, it holds the array
79// size of G4VUPLData instances.
80//
81#define G4MT_theMessenger \
82 ((this->subInstanceManager.offset[this->g4vuplInstanceID])._theMessenger)
83#define G4MT_thePLHelper \
84 ((this->subInstanceManager.offset[this->g4vuplInstanceID])._thePLHelper)
85#define fIsPhysicsTableBuilt \
86 ((this->subInstanceManager.offset[this->g4vuplInstanceID]) \
87 ._fIsPhysicsTableBuilt)
88#define fDisplayThreshold \
89 ((this->subInstanceManager.offset[this->g4vuplInstanceID])._fDisplayThreshold)
90#define theParticleIterator \
91 ((this->subInstanceManager.offset[this->g4vuplInstanceID]) \
92 ._theParticleIterator)
93
94// This field helps to use the class G4VUPLManager
95//
97
99{
101 _theMessenger = 0;
103 _fIsPhysicsTableBuilt = false;
105}
106
107////////////////////////////////////////////////////////
109 : verboseLevel(1)
110 , defaultCutValue(1.0 * mm)
111 , isSetDefaultCutValue(false)
112 , fRetrievePhysicsTable(false)
113 , fStoredInAscii(true)
114 , fIsCheckedForRetrievePhysicsTable(false)
115 , fIsRestoredCutValues(false)
116 , directoryPhysicsTable(".")
117 ,
118 // fDisplayThreshold(0),
119 // fIsPhysicsTableBuilt(false),
120 fDisableCheckParticleList(false)
121{
123 // default cut value (1.0mm)
124 defaultCutValue = 1.0 * mm;
125
126 // pointer to the particle table
128 // theParticleIterator = theParticleTable->GetIterator();
129
130 // pointer to the cuts table
132
133 // set energy range for SetCut calcuration
134 fCutsTable->SetEnergyRange(0.99 * keV, 100 * TeV);
135
136 // UI Messenger
137 // theMessenger = new G4UserPhysicsListMessenger(this);
139
140 // PhysicsListHelper
141 // thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
142 // thePLHelper->SetVerboseLevel(verboseLevel);
143 // G4MT_thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper(); //AND
144 G4MT_thePLHelper->SetVerboseLevel(verboseLevel); // AND
145
146 fIsPhysicsTableBuilt = false;
148}
149
151{
152 // Remember messengers are per-thread, so this needs to be done by each worker
153 // and due to the presence of "this" cannot be done in
154 // G4VUPLData::initialize()
156}
157
159{
161 delete G4MT_theMessenger;
162 G4MT_theMessenger = nullptr;
163}
164////////////////////////////////////////////////////////
166{
167 if(G4MT_theMessenger != 0)
168 {
169 delete G4MT_theMessenger;
171 }
173
174 // invoke DeleteAllParticle
176}
177
178////////////////////////////////////////////////////////
180 : verboseLevel(right.verboseLevel)
181 , defaultCutValue(right.defaultCutValue)
182 , isSetDefaultCutValue(right.isSetDefaultCutValue)
183 , fRetrievePhysicsTable(right.fRetrievePhysicsTable)
184 , fStoredInAscii(right.fStoredInAscii)
185 , fIsCheckedForRetrievePhysicsTable(right.fIsCheckedForRetrievePhysicsTable)
186 , fIsRestoredCutValues(right.fIsRestoredCutValues)
187 , directoryPhysicsTable(right.directoryPhysicsTable)
188 ,
189 // fDisplayThreshold(right.fDisplayThreshold),
190 // fIsPhysicsTableBuilt(right.fIsPhysicsTableBuilt),
191 fDisableCheckParticleList(right.fDisableCheckParticleList)
192{
194 // pointer to the particle table
197 // pointer to the cuts table
199
200 // UI Messenger
201 // theMessenger = new G4UserPhysicsListMessenger(this);
203
204 // PhysicsListHelper
205 // thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
206 // thePLHelper->SetVerboseLevel(verboseLevel);
208 G4MT_thePLHelper->SetVerboseLevel(verboseLevel); // AND
209
211 .offset[right.GetInstanceID()]
212 ._fIsPhysicsTableBuilt;
214 .offset[right.GetInstanceID()]
215 ._fDisplayThreshold;
216}
217
218////////////////////////////////////////////////////////
220 const G4VUserPhysicsList& right)
221{
222 if(this != &right)
223 {
232 // fDisplayThreshold = right.fDisplayThreshold;
234 .offset[right.GetInstanceID()]
235 ._fIsPhysicsTableBuilt;
237 .offset[right.GetInstanceID()]
238 ._fDisplayThreshold;
239 // fIsPhysicsTableBuilt = right.fIsPhysicsTableBuilt;
241 }
242 return *this;
243}
244
245////////////////////////////////////////////////////////
248{
249 if(newParticle == 0)
250 return;
251 G4Exception("G4VUserPhysicsList::AddProcessManager", "Run0252", JustWarning,
252 "This method is obsolete");
253}
254
255////////////////////////////////////////////////////////
257{
258 // Request lock for particle table accesses. Some changes are inside
259 // this critical region.
260#ifdef G4MULTITHREADED
261 G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
262 G4ParticleTable::lockCount()++;
263#endif
266
267 // loop over all particles in G4ParticleTable
268 theParticleIterator->reset();
269 while((*theParticleIterator)())
270 {
271 G4ParticleDefinition* particle = theParticleIterator->value();
272 G4ProcessManager* pmanager = particle->GetProcessManager();
273
274 if(pmanager == 0)
275 {
276 // create process manager if the particle does not have its own.
277 pmanager = new G4ProcessManager(particle);
278 particle->SetProcessManager(pmanager);
279 if(particle->GetMasterProcessManager() == 0)
280 particle->SetMasterProcessManager(pmanager);
281#ifdef G4VERBOSE
282 if(verboseLevel > 2)
283 {
284 G4cout << "G4VUserPhysicsList::InitializeProcessManager: creating "
285 "ProcessManager to "
286 << particle->GetParticleName() << G4endl;
287 }
288#endif
289 }
290 }
291
292 if(gion)
293 {
294 G4ProcessManager* gionPM = gion->GetProcessManager();
295 // loop over all particles once again (this time, with all general ions)
296 theParticleIterator->reset(false);
297 while((*theParticleIterator)())
298 {
299 G4ParticleDefinition* particle = theParticleIterator->value();
300 if(particle->IsGeneralIon())
301 {
302 particle->SetProcessManager(gionPM);
303#ifdef G4VERBOSE
304 if(verboseLevel > 2)
305 {
306 G4cout << "G4VUserPhysicsList::InitializeProcessManager: copying "
307 "ProcessManager to "
308 << particle->GetParticleName() << G4endl;
309 }
310#endif
311 }
312 }
313 }
314
315 // release lock for particle table accesses.
316#ifdef G4MULTITHREADED
317 G4MUTEXUNLOCK(&G4ParticleTable::particleTableMutex());
318#endif
319 // G4cout << "Particle table is released by
320 // G4VUserPhysicsList::InitializeProcessManager" << G4endl;
321}
322
323/////////////////////////////////////////////////////////
325{
326 // Request lock for particle table accesses. Some changes are inside
327 // this critical region.
328#ifdef G4MULTITHREADED
329 G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
330 G4ParticleTable::lockCount()++;
331#endif
332 // G4cout << "Particle table is held by
333 // G4VUserPhysicsList::InitializeProcessManager"
334 // << G4endl;
335
336 // loop over all particles in G4ParticleTable
337 theParticleIterator->reset();
338 while((*theParticleIterator)())
339 {
340 G4ParticleDefinition* particle = theParticleIterator->value();
341 if(particle->GetInstanceID() <
343 {
344 if(particle->GetParticleSubType() != "generic" ||
345 particle->GetParticleName() == "GenericIon")
346 {
347 G4ProcessManager* pmanager = particle->GetProcessManager();
348 if(pmanager != 0)
349 delete pmanager;
350#ifdef G4VERBOSE
351 if(verboseLevel > 2)
352 {
353 G4cout << "G4VUserPhysicsList::RemoveProcessManager: ";
354 G4cout << "remove ProcessManager from ";
355 G4cout << particle->GetParticleName() << G4endl;
356 }
357#endif
358 }
359 particle->SetProcessManager(0);
360 }
361 }
362
363 // release lock for particle table accesses.
364#ifdef G4MULTITHREADED
365 G4MUTEXUNLOCK(&G4ParticleTable::particleTableMutex());
366#endif
367 // G4cout << "Particle table is released by
368 // G4VUserPhysicsList::InitializeProcessManager" << G4endl;
369}
370
371////////////////////////////////////////////////////////
373{
375 {
377 }
378
379#ifdef G4VERBOSE
380 if(verboseLevel > 1)
381 {
382 G4cout << "G4VUserPhysicsList::SetCuts: " << G4endl;
383 G4cout << "Cut for gamma: " << GetCutValue("gamma") / mm << "[mm]"
384 << G4endl;
385 G4cout << "Cut for e-: " << GetCutValue("e-") / mm << "[mm]" << G4endl;
386 G4cout << "Cut for e+: " << GetCutValue("e+") / mm << "[mm]" << G4endl;
387 G4cout << "Cut for proton: " << GetCutValue("proton") / mm << "[mm]"
388 << G4endl;
389 }
390#endif
391
392 // dump Cut values if verboseLevel==3
393 if(verboseLevel > 2)
394 {
396 }
397}
398
399////////////////////////////////////////////////////////
401{
402 if(value < 0.0)
403 {
404#ifdef G4VERBOSE
405 if(verboseLevel > 0)
406 {
407 G4cout << "G4VUserPhysicsList::SetDefaultCutValue: negative cut values"
408 << " :" << value / mm << "[mm]" << G4endl;
409 }
410#endif
411 return;
412 }
413
414 defaultCutValue = value;
416
417 // set cut values for gamma at first and for e- and e+
421 SetCutValue(defaultCutValue, "proton");
422
423#ifdef G4VERBOSE
424 if(verboseLevel > 1)
425 {
426 G4cout << "G4VUserPhysicsList::SetDefaultCutValue:"
427 << "default cut value is changed to :" << defaultCutValue / mm
428 << "[mm]" << G4endl;
429 }
430#endif
431}
432
433////////////////////////////////////////////////////////
435{
436 size_t nReg = (G4RegionStore::GetInstance())->size();
437 if(nReg == 0)
438 {
439#ifdef G4VERBOSE
440 if(verboseLevel > 0)
441 {
442 G4cout << "G4VUserPhysicsList::GetCutValue "
443 << " : No Default Region " << G4endl;
444 }
445#endif
446 G4Exception("G4VUserPhysicsList::GetCutValue", "Run0253", FatalException,
447 "No Default Region");
448 return -1. * mm;
449 }
450 G4Region* region =
451 G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", false);
452 return region->GetProductionCuts()->GetProductionCut(name);
453}
454
455////////////////////////////////////////////////////////
457{
458 SetParticleCuts(aCut, name);
459}
460
461////////////////////////////////////////////////////////
463 const G4String& rname)
464{
466 if(region != 0)
467 {
468 // set cut value
469 SetParticleCuts(aCut, pname, region);
470 }
471 else
472 {
473#ifdef G4VERBOSE
474 if(verboseLevel > 0)
475 {
476 G4cout << "G4VUserPhysicsList::SetCutValue "
477 << " : No Region of " << rname << G4endl;
478 }
479#endif
480 }
481}
482
483////////////////////////////////////////////////////////
485{
488}
489
490////////////////////////////////////////////////////////
492{
493 // set cut values for gamma at first and for e- and e+
494 SetCutValue(aCut, "gamma", rname);
495 SetCutValue(aCut, "e-", rname);
496 SetCutValue(aCut, "e+", rname);
497 SetCutValue(aCut, "proton", rname);
498}
499
500////////////////////////////////////////////////////////
502 G4ParticleDefinition* particle,
503 G4Region* region)
504{
505 SetParticleCuts(cut, particle->GetParticleName(), region);
506}
507
508////////////////////////////////////////////////////////
510 const G4String& particleName,
511 G4Region* region)
512{
513 if(cut < 0.0)
514 {
515#ifdef G4VERBOSE
516 if(verboseLevel > 0)
517 {
518 G4cout << "G4VUserPhysicsList::SetParticleCuts: negative cut values"
519 << " :" << cut / mm << "[mm]"
520 << " for " << particleName << G4endl;
521 }
522#endif
523 return;
524 }
525
526 G4Region* world_region =
527 G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", false);
528 if(!region)
529 {
530 size_t nReg = (G4RegionStore::GetInstance())->size();
531 if(nReg == 0)
532 {
533#ifdef G4VERBOSE
534 if(verboseLevel > 0)
535 {
536 G4cout << "G4VUserPhysicsList::SetParticleCuts "
537 << " : No Default Region " << G4endl;
538 }
539#endif
540 G4Exception("G4VUserPhysicsList::SetParticleCuts ", "Run0254",
541 FatalException, "No Default Region");
542 return;
543 }
544 region = world_region;
545 }
546
548 {
550 }
551
552 G4ProductionCuts* pcuts = region->GetProductionCuts();
553 if(region != world_region &&
555 ->GetDefaultProductionCuts())
556 { // This region had no unique cuts yet but shares the default cuts.
557 // Need to create a new object before setting the value.
558 pcuts =
560 ->GetDefaultProductionCuts()));
561 region->SetProductionCuts(pcuts);
562 }
563 pcuts->SetProductionCut(cut, particleName);
564#ifdef G4VERBOSE
565 if(verboseLevel > 2)
566 {
567 G4cout << "G4VUserPhysicsList::SetParticleCuts: "
568 << " :" << cut / mm << "[mm]"
569 << " for " << particleName << G4endl;
570 }
571#endif
572}
573
574///////////////////////////////////////////////////////////////
576{
577 // Prepare Physics table for all particles
578 theParticleIterator->reset();
579 while((*theParticleIterator)())
580 {
581 G4ParticleDefinition* particle = theParticleIterator->value();
582 PreparePhysicsTable(particle);
583 }
584
585 // ask processes to prepare physics table
587 {
590 // check if retrieve Cut Table successfully
592 {
593#ifdef G4VERBOSE
594 if(verboseLevel > 0)
595 {
596 G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
597 << " Retrieve Cut Table failed !!" << G4endl;
598 }
599#endif
600 G4Exception("G4VUserPhysicsList::BuildPhysicsTable", "Run0255",
601 RunMustBeAborted, "Fail to retrieve Production Cut Table");
602 }
603 else
604 {
605#ifdef G4VERBOSE
606 if(verboseLevel > 2)
607 {
608 G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
609 << " Retrieve Cut Table successfully " << G4endl;
610 }
611#endif
612 }
613 }
614 else
615 {
616#ifdef G4VERBOSE
617 if(verboseLevel > 2)
618 {
619 G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
620 << " does not retrieve Cut Table but calculate " << G4endl;
621 }
622#endif
623 }
624
625 // Sets a value to particle
626 // set cut values for gamma at first and for e- and e+
627 G4String particleName;
629 if(GammaP)
630 BuildPhysicsTable(GammaP);
632 if(EMinusP)
633 BuildPhysicsTable(EMinusP);
635 if(EPlusP)
636 BuildPhysicsTable(EPlusP);
638 if(ProtonP)
639 BuildPhysicsTable(ProtonP);
640
641 theParticleIterator->reset();
642 while((*theParticleIterator)())
643 {
644 G4ParticleDefinition* particle = theParticleIterator->value();
645 if(particle != GammaP && particle != EMinusP && particle != EPlusP &&
646 particle != ProtonP)
647 {
648 BuildPhysicsTable(particle);
649 }
650 }
651
652 // Set flag
654}
655///////////////////////////////////////////////////////////////
656// Change in order to share physics tables for two kind of process.
658{
659 if(!(particle->GetMasterProcessManager()))
660 {
661 G4cout
662 << "#### G4VUserPhysicsList::BuildPhysicsTable() - BuildPhysicsTable("
663 << particle->GetParticleName() << ") skipped..." << G4endl;
664 return;
665 }
667 {
669 {
670 // fail to retrieve cut tables
671#ifdef G4VERBOSE
672 if(verboseLevel > 0)
673 {
674 G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
675 << "Physics table can not be retrieved and will be calculated "
676 << G4endl;
677 }
678#endif
679 fRetrievePhysicsTable = false;
680 }
681 else
682 {
683#ifdef G4VERBOSE
684 if(verboseLevel > 2)
685 {
686 G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
687 << " Retrieve Physics Table for " << particle->GetParticleName()
688 << G4endl;
689 }
690#endif
691 // Retrieve PhysicsTable from files for proccesses
693 }
694 }
695
696#ifdef G4VERBOSE
697 if(verboseLevel > 2)
698 {
699 G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
700 << "Calculate Physics Table for " << particle->GetParticleName()
701 << G4endl;
702 }
703#endif
704 // Rebuild the physics tables for every process for this particle type
705 // if particle is not ShortLived
706 if(!particle->IsShortLived())
707 {
708 G4ProcessManager* pManager = particle->GetProcessManager();
709 if(!pManager)
710 {
711#ifdef G4VERBOSE
712 if(verboseLevel > 0)
713 {
714 G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
715 << " : No Process Manager for " << particle->GetParticleName()
716 << G4endl;
717 G4cout << particle->GetParticleName()
718 << " should be created in your PhysicsList" << G4endl;
719 }
720#endif
721 G4Exception("G4VUserPhysicsList::BuildPhysicsTable", "Run0271",
722 FatalException, "No process manager");
723 return;
724 }
725
726 // Get processes from master thread;
727 G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
728
729 G4ProcessVector* pVector = pManager->GetProcessList();
730 if(!pVector)
731 {
732#ifdef G4VERBOSE
733 if(verboseLevel > 0)
734 {
735 G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
736 << " : No Process Vector for " << particle->GetParticleName()
737 << G4endl;
738 }
739#endif
740 G4Exception("G4VUserPhysicsList::BuildPhysicsTable", "Run0272",
741 FatalException, "No process Vector");
742 return;
743 }
744#ifdef G4VERBOSE
745 if(verboseLevel > 2)
746 {
747 G4cout << "G4VUserPhysicsList::BuildPhysicsTable %%%%%% "
748 << particle->GetParticleName() << G4endl;
749 G4cout << " ProcessManager : " << pManager
750 << " ProcessManagerShadow : " << pManagerShadow << G4endl;
751 for(std::size_t iv1 = 0; iv1 < pVector->size(); ++iv1)
752 {
753 G4cout << " " << iv1 << " - " << (*pVector)[iv1]->GetProcessName()
754 << G4endl;
755 }
756 G4cout << "--------------------------------------------------------------"
757 << G4endl;
758 G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
759
760 for(std::size_t iv2 = 0; iv2 < pVectorShadow->size(); ++iv2)
761 {
762 G4cout << " " << iv2 << " - "
763 << (*pVectorShadow)[iv2]->GetProcessName() << G4endl;
764 }
765 }
766#endif
767 for(std::size_t j = 0; j < pVector->size(); ++j)
768 {
769 // Andrea July 16th 2013 : migration to new interface...
770 // Infer if we are in a worker thread or master thread
771 // Master thread is the one in which the process manager
772 // and process manager shadow pointers are the same
773 if(pManagerShadow == pManager)
774 {
775 (*pVector)[j]->BuildPhysicsTable(*particle);
776 }
777 else
778 {
779 (*pVector)[j]->BuildWorkerPhysicsTable(*particle);
780 }
781
782 } // End loop on processes vector
783 } // End if short-lived
784}
785
786///////////////////////////////////////////////////////////////
788{
789 if(!(particle->GetMasterProcessManager()))
790 {
791 //// G4cout << "#### G4VUserPhysicsList::BuildPhysicsTable() -
792 /// BuildPhysicsTable(" / << particle->GetParticleName() << ")
793 /// skipped..." << G4endl;
794 return;
795 }
796 // Prepare the physics tables for every process for this particle type
797 // if particle is not ShortLived
798 if(!particle->IsShortLived())
799 {
800 G4ProcessManager* pManager = particle->GetProcessManager();
801 if(!pManager)
802 {
803#ifdef G4VERBOSE
804 if(verboseLevel > 0)
805 {
806 G4cout << "G4VUserPhysicsList::PreparePhysicsTable "
807 << ": No Process Manager for " << particle->GetParticleName()
808 << G4endl;
809 G4cout << particle->GetParticleName()
810 << " should be created in your PhysicsList" << G4endl;
811 }
812#endif
813 G4Exception("G4VUserPhysicsList::PreparePhysicsTable", "Run0273",
814 FatalException, "No process manager");
815 return;
816 }
817
818 // Get processes from master thread
819 G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
820 // Andrea Dotti 15 Jan 2013: Change of interface of MSC
821 // G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
822
823 G4ProcessVector* pVector = pManager->GetProcessList();
824 if(!pVector)
825 {
826#ifdef G4VERBOSE
827 if(verboseLevel > 0)
828 {
829 G4cout << "G4VUserPhysicsList::PreparePhysicsTable "
830 << ": No Process Vector for " << particle->GetParticleName()
831 << G4endl;
832 }
833#endif
834 G4Exception("G4VUserPhysicsList::PreparePhysicsTable", "Run0274",
835 FatalException, "No process Vector");
836 return;
837 }
838 for(std::size_t j = 0; j < pVector->size(); ++j)
839 {
840 // Andrea July 16th 2013 : migration to new interface...
841 // Infer if we are in a worker thread or master thread
842 // Master thread is the one in which the process manager
843 // and process manager shadow pointers are the same
844 if(pManagerShadow == pManager)
845 {
846 (*pVector)[j]->PreparePhysicsTable(*particle);
847 }
848 else
849 {
850 (*pVector)[j]->PrepareWorkerPhysicsTable(*particle);
851 }
852 } // End loop on processes vector
853 } // End if pn ShortLived
854}
855
856// TODO Should we change this function?
857///////////////////////////////////////////////////////////////
859 G4VProcess* process, G4ParticleDefinition* particle)
860{
861 //*********************************************************************
862 // temporary addition to make the integral schema of electromagnetic
863 // processes work.
864 //
865
866 if((process->GetProcessName() == "Imsc") ||
867 (process->GetProcessName() == "IeIoni") ||
868 (process->GetProcessName() == "IeBrems") ||
869 (process->GetProcessName() == "Iannihil") ||
870 (process->GetProcessName() == "IhIoni") ||
871 (process->GetProcessName() == "IMuIoni") ||
872 (process->GetProcessName() == "IMuBrems") ||
873 (process->GetProcessName() == "IMuPairProd"))
874 {
875#ifdef G4VERBOSE
876 if(verboseLevel > 2)
877 {
878 G4cout << "G4VUserPhysicsList::BuildIntegralPhysicsTable "
879 << " BuildPhysicsTable is invoked for "
880 << process->GetProcessName() << "(" << particle->GetParticleName()
881 << ")" << G4endl;
882 }
883#endif
884 process->BuildPhysicsTable(*particle);
885 }
886}
887
888///////////////////////////////////////////////////////////////
890{
891 theParticleIterator->reset();
892 G4int idx = 0;
893 while((*theParticleIterator)())
894 {
895 G4ParticleDefinition* particle = theParticleIterator->value();
896 G4cout << particle->GetParticleName();
897 if((idx++ % 4) == 3)
898 {
899 G4cout << G4endl;
900 }
901 else
902 {
903 G4cout << ", ";
904 }
905 }
906 G4cout << G4endl;
907}
908
909///////////////////////////////////////////////////////////////
911{
912 fDisplayThreshold = flag;
913}
914
915///////////////////////////////////////////////////////////////
917{
918 if(fDisplayThreshold == 0)
919 return;
922}
923
924///////////////////////////////////////////////////////////////
926{
927 G4bool ascii = fStoredInAscii;
928 G4String dir = directory;
929 if(dir.isNull())
931 else
933
934 // store CutsTable info
935 if(!fCutsTable->StoreCutsTable(dir, ascii))
936 {
937 G4Exception("G4VUserPhysicsList::StorePhysicsTable", "Run0281", JustWarning,
938 "Fail to store Cut Table");
939 return false;
940 }
941#ifdef G4VERBOSE
942 if(verboseLevel > 2)
943 {
944 G4cout << "G4VUserPhysicsList::StorePhysicsTable "
945 << " Store material and cut values successfully" << G4endl;
946 }
947#endif
948
949 G4bool success = true;
950
951 // loop over all particles in G4ParticleTable
952 theParticleIterator->reset();
953 while((*theParticleIterator)())
954 {
955 G4ParticleDefinition* particle = theParticleIterator->value();
956 // Store physics tables for every process for this particle type
957 G4ProcessVector* pVector =
958 (particle->GetProcessManager())->GetProcessList();
959 for(std::size_t j = 0; j < pVector->size(); ++j)
960 {
961 if(!(*pVector)[j]->StorePhysicsTable(particle, dir, ascii))
962 {
963 G4String comment = "Fail to store physics table for ";
964 comment += (*pVector)[j]->GetProcessName();
965 comment += "(" + particle->GetParticleName() + ")";
966 G4Exception("G4VUserPhysicsList::StorePhysicsTable", "Run0282",
967 JustWarning, comment);
968 success = false;
969 }
970 }
971 // end loop over processes
972 }
973 // end loop over particles
974 return success;
975}
976
977///////////////////////////////////////////////////////////////
979{
981 if(!directory.isNull())
982 {
983 directoryPhysicsTable = directory;
984 }
986 fIsRestoredCutValues = false;
987}
988
989///////////////////////////////////////////////////////////////
991 const G4String& directory,
992 G4bool ascii)
993{
994 G4bool success[100];
995 // Retrieve physics tables for every process for this particle type
996 G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
997 for(std::size_t j = 0; j < pVector->size(); ++j)
998 {
999 success[j] =
1000 (*pVector)[j]->RetrievePhysicsTable(particle, directory, ascii);
1001
1002 if(!success[j])
1003 {
1004#ifdef G4VERBOSE
1005 if(verboseLevel > 2)
1006 {
1007 G4cout << "G4VUserPhysicsList::RetrievePhysicsTable "
1008 << " Fail to retrieve Physics Table for "
1009 << (*pVector)[j]->GetProcessName() << G4endl;
1010 G4cout << "Calculate Physics Table for " << particle->GetParticleName()
1011 << G4endl;
1012 }
1013#endif
1014 (*pVector)[j]->BuildPhysicsTable(*particle);
1015 }
1016 }
1017 for(std::size_t j = 0; j < pVector->size(); ++j)
1018 {
1019 // temporary addition to make the integral schema
1020 if(!success[j])
1021 BuildIntegralPhysicsTable((*pVector)[j], particle);
1022 }
1023}
1024
1025///////////////////////////////////////////////////////////////
1027{
1028#ifdef G4VERBOSE
1029 if(verboseLevel > 2)
1030 {
1031 G4cout << "G4VUserPhysicsList::SetApplyCuts for " << name << G4endl;
1032 }
1033#endif
1034 if(name == "all")
1035 {
1040 }
1041 else
1042 {
1044 }
1045}
1046
1047///////////////////////////////////////////////////////////////
1049{
1051}
1052
1053////////////////////////////////////////////////////////
1055{
1057 {
1058 G4MT_thePLHelper->CheckParticleList();
1059 }
1060}
1061
1062////////////////////////////////////////////////////////
1064{
1065 G4MT_thePLHelper->AddTransportation();
1066}
1067
1068////////////////////////////////////////////////////////
1070{
1071 G4MT_thePLHelper->UseCoupledTransportation(vl);
1072}
1073
1074////////////////////////////////////////////////////////
1076 G4ParticleDefinition* particle)
1077{
1078 return G4MT_thePLHelper->RegisterProcess(process, particle);
1079}
1080
1081////////////////////////////////////////////////////////
1083 const
1084{
1085 return (subInstanceManager.offset[g4vuplInstanceID])._theParticleIterator;
1086}
1087
1088////////////////////////////////////////////////////////
1090{
1091 verboseLevel = value;
1092 // set verboseLevel for G4ProductionCutsTable same as one for
1093 // G4VUserPhysicsList:
1095
1096 G4MT_thePLHelper->SetVerboseLevel(verboseLevel);
1097
1098#ifdef G4VERBOSE
1099 if(verboseLevel > 1)
1100 {
1101 G4cout << "G4VUserPhysicsList::SetVerboseLevel :"
1102 << " Verbose level is set to " << verboseLevel << G4endl;
1103 }
1104#endif
1105}
1106
1107///////////////////////////////////////////////////////////////
1108/// obsolete methods
1109
1110///////////////////////////////////////////////////////////////
1112{
1113#ifdef G4VERBOSE
1114 if(verboseLevel > 0)
1115 {
1116 G4cout << "G4VUserPhysicsList::ResetCuts() is obsolete."
1117 << " This method gives no effect and you can remove it. " << G4endl;
1118 }
1119#endif
1120}
@ JustWarning
@ FatalException
@ RunMustBeAborted
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
#define G4MUTEXLOCK(mutex)
Definition: G4Threading.hh:251
#define G4MUTEXUNLOCK(mutex)
Definition: G4Threading.hh:254
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4MT_theMessenger
#define G4MT_thePLHelper
#define theParticleIterator
#define fIsPhysicsTableBuilt
#define fDisplayThreshold
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4PART_DLL G4int & slavetotalspace()
G4int GetInstanceID() const
G4ProcessManager * GetProcessManager() const
void SetMasterProcessManager(G4ProcessManager *aNewPM)
G4bool IsGeneralIon() const
G4ProcessManager * GetMasterProcessManager() const
G4bool GetApplyCutsFlag() const
const G4String & GetParticleName() const
void SetProcessManager(G4ProcessManager *aProcessManager)
const G4String & GetParticleSubType() const
G4PTblDicIterator * GetIterator() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
G4ParticleDefinition * GetGenericIon() const
static G4PhysicsListHelper * GetPhysicsListHelper()
G4ProcessVector * GetProcessList() const
std::size_t size() const
G4bool RetrieveCutsTable(const G4String &directory, G4bool ascii=false)
void SetVerboseLevel(G4int value)
G4bool StoreCutsTable(const G4String &directory, G4bool ascii=false)
void SetEnergyRange(G4double lowedge, G4double highedge)
static G4ProductionCutsTable * GetProductionCutsTable()
void SetProductionCut(G4double cut, G4int index=-1)
G4double GetProductionCut(G4int index) const
static G4RegionStore * GetInstance()
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
G4ProductionCuts * GetProductionCuts() const
void SetProductionCuts(G4ProductionCuts *cut)
G4bool isNull() const
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:187
const G4String & GetProcessName() const
Definition: G4VProcess.hh:382
G4bool _fIsPhysicsTableBuilt
G4ParticleTable::G4PTblDicIterator * _theParticleIterator
G4PhysicsListHelper * _thePLHelper
G4UserPhysicsListMessenger * _theMessenger
G4RUN_DLL G4ThreadLocalStatic T * offset
G4int CreateSubInstance()
G4double GetCutValue(const G4String &pname) const
void SetDefaultCutValue(G4double newCutValue)
void SetPhysicsTableRetrieved(const G4String &directory="")
G4VUserPhysicsList & operator=(const G4VUserPhysicsList &)
void PreparePhysicsTable(G4ParticleDefinition *)
virtual void TerminateWorker()
void SetCutValue(G4double aCut, const G4String &pname)
G4bool RegisterProcess(G4VProcess *process, G4ParticleDefinition *particle)
void UseCoupledTransportation(G4bool vl=true)
void SetCutsForRegion(G4double aCut, const G4String &rname)
G4ProductionCutsTable * fCutsTable
G4bool StorePhysicsTable(const G4String &directory=".")
G4ParticleTable::G4PTblDicIterator * GetParticleIterator() const
G4ParticleTable * theParticleTable
void SetVerboseLevel(G4int value)
void SetApplyCuts(G4bool value, const G4String &name)
void SetParticleCuts(G4double cut, G4ParticleDefinition *particle, G4Region *region=0)
virtual void RetrievePhysicsTable(G4ParticleDefinition *, const G4String &directory, G4bool ascii=false)
void ResetCuts()
obsolete methods
G4bool fIsCheckedForRetrievePhysicsTable
void DumpCutValuesTable(G4int flag=1)
G4bool GetApplyCuts(const G4String &name) const
static G4RUN_DLL G4VUPLManager subInstanceManager
void AddProcessManager(G4ParticleDefinition *newParticle, G4ProcessManager *newManager=0)
void BuildIntegralPhysicsTable(G4VProcess *, G4ParticleDefinition *)
G4int GetInstanceID() const
virtual void InitializeWorker()
static const G4VUPLManager & GetSubInstanceManager()