Geant4  10.01.p01
G4EmExtraPhysics.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 // $Id: G4EmExtraPhysics.cc 66704 2013-01-10 18:20:17Z gunter $
27 //
28 //---------------------------------------------------------------------------
29 //
30 // ClassName: G4EmExtraPhysics
31 //
32 // Author: 2002 J.P. Wellisch
33 //
34 // Modified:
35 // 10.11.2005 V.Ivanchenko edit to provide a standard
36 // 19.06.2006 V.Ivanchenko add mu-nuclear process
37 // 16.10.2012 A.Ribon: renamed G4EmExtraBertiniPhysics as G4EmExtraPhysics
38 // 10.04.2014 A.Dotti: Add MT functionality for messenger
39 // 24.04.2014 A.Ribon: switched on muon-nuclear by default
40 //
41 //----------------------------------------------------------------------------
42 //
43 
44 #include "G4EmExtraPhysics.hh"
45 
46 #include "G4SystemOfUnits.hh"
48 
49 #include "G4ParticleDefinition.hh"
50 #include "G4ParticleTable.hh"
51 #include "G4Gamma.hh"
52 #include "G4Electron.hh"
53 #include "G4Positron.hh"
54 #include "G4MuonPlus.hh"
55 #include "G4MuonMinus.hh"
56 #include "G4ProcessManager.hh"
57 #include "G4BuilderType.hh"
58 #include "G4AutoDelete.hh"
59 
60 // factory
62 //
64 
72 
73 namespace {
74  //Thread-private instance of a messenger.
75  //Needed because this is a shared instance,
76  //but threads need access to UI commands.
77  G4ThreadLocal G4EmMessenger* theLocalMessenger = 0;
78 }
79 
81  G4VPhysicsConstructor("G4GammaLeptoNuclearPhys"),
82  verbose(ver)
83 {
84  theGNPhysics = 0;
85  theMessenger = new G4EmMessenger(this);
86  theLocalMessenger = theMessenger;
88  if(verbose > 1) G4cout << "### G4EmExtraPhysics" << G4endl;
89 }
90 
92  G4VPhysicsConstructor("G4GammaLeptoNuclearPhys"),
93  verbose(1)
94 {
95  theMessenger = new G4EmMessenger(this);
97  if(verbose > 1) G4cout << "### G4EmExtraPhysics" << G4endl;
98 }
99 
101 {
102  delete theMessenger;
103  delete theGNPhysics;
104 }
105 
107 {
108  if(newState == "on" || newState == "ON") {
109  synchOn = true;
110  if(wasBuilt) BuildSynch();
111  } else synchOn = false;
112 }
113 
115 {
116  if(newState == "on" || newState == "ON") {
117  gammNucOn = true;
119  } else gammNucOn = false;
120 }
121 
123 {
124  if(newState == "on" || newState == "ON") {
125  muNucOn = true;
127  } else muNucOn = false;
128 }
129 
131 {
132  G4Gamma::Gamma();
137 }
138 
140 {
141  if(wasBuilt) return;
142  wasBuilt = true;
143  if ( theLocalMessenger == 0 ) {
144  //This thread needs a private instence of the messenger
145  theLocalMessenger = new G4EmMessenger(this);
146  G4AutoDelete::Register(theLocalMessenger);
147  //This is tricky. Messenger should be safely deleted at the end of the job
148  }
149  if (synchOn) BuildSynch();
151  if (muNucOn) BuildMuonNuclear();
152 }
153 
155 {
156  if(munActivated) return;
157  munActivated = true;
158  G4ProcessManager * pManager = 0;
159 
160  G4MuonNuclearProcess* muNucProcess = new G4MuonNuclearProcess();
161  G4MuonVDNuclearModel* muNucModel = new G4MuonVDNuclearModel();
162  muNucProcess->RegisterMe(muNucModel);
163 
164  pManager = G4MuonPlus::MuonPlus()->GetProcessManager();
165  pManager->AddDiscreteProcess(muNucProcess);
166 
168  pManager->AddDiscreteProcess(muNucProcess);
169 }
170 
172 {
173  if(gnActivated) return;
174  gnActivated = true;
175 
177  theGNPhysics->Build();
178 }
179 
181 {
182  if(synActivated) return;
183  synActivated = true;
184  G4ProcessManager * pManager = 0;
185 
186  pManager = G4Electron::Electron()->GetProcessManager();
187  G4SynchrotronRadiation* theElectronSynch = new G4SynchrotronRadiation();
188  pManager->AddDiscreteProcess(theElectronSynch);
189 
190  pManager = G4Positron::Positron()->GetProcessManager();
191  G4SynchrotronRadiation* thePositronSynch = new G4SynchrotronRadiation();
192  pManager->AddDiscreteProcess(thePositronSynch);
193 }
virtual ~G4EmExtraPhysics()
static G4MuonPlus * MuonPlus()
Definition: G4MuonPlus.cc:99
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
#define G4ThreadLocal
Definition: tls.hh:89
static G4ThreadLocal G4bool synchOn
G4ProcessManager * GetProcessManager() const
int G4int
Definition: G4Types.hh:78
void RegisterMe(G4HadronicInteraction *a)
void Register(T *inst)
Definition: G4AutoDelete.hh:65
static G4ThreadLocal G4bool munActivated
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
static G4ThreadLocal G4bool muNucOn
G4EmExtraPhysics(G4int ver=1)
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
static G4ThreadLocal G4bool gnActivated
void GammaNuclear(G4String &aState)
static G4ThreadLocal G4bool synActivated
static G4Positron * Positron()
Definition: G4Positron.cc:94
static G4ThreadLocal G4bool gammNucOn
void Synch(G4String &aState)
void MuonNuclear(G4String &aState)
static G4MuonMinus * MuonMinus()
Definition: G4MuonMinus.cc:100
static G4Electron * Electron()
Definition: G4Electron.cc:94
#define G4endl
Definition: G4ios.hh:61
G4BertiniElectroNuclearBuilder * theGNPhysics
G4EmMessenger * theMessenger
static G4ThreadLocal G4bool wasBuilt
G4_DECLARE_PHYSCONSTR_FACTORY(G4EmExtraPhysics)