4 // See the class description in the header file.
6 #include "TG4PhysicsManager.h"
7 #include "TG4ParticlesManager.h"
8 #include "TG4G3PhysicsManager.h"
9 #include "TG4PhysicsConstructorEM.h"
10 #include "TG4PhysicsConstructorOptical.h"
11 #include "TG4PhysicsConstructorHadron.h"
12 #include "TG4PhysicsConstructorSpecialCuts.h"
13 #include "TG4PhysicsConstructorSpecialControls.h"
15 #include "TG4G3Control.h"
16 #include "AliDecayer.h"
18 #include <G4ParticleDefinition.hh>
19 #include <G4VProcess.hh>
20 #include <G4VModularPhysicsList.hh>
22 #include <TDatabasePDG.h>
24 TG4PhysicsManager* TG4PhysicsManager::fgInstance = 0;
26 TG4PhysicsManager::TG4PhysicsManager(G4VModularPhysicsList* physicsList)
27 : fPhysicsList(physicsList),
30 fSetOpticalPhysics(false),
31 fSetHadronPhysics(false),
32 fSetSpecialCutsPhysics(false),
33 fSetSpecialControlsPhysics(false)
38 TG4Globals::Exception(
39 "TG4PhysicsManager: attempt to create two instances of singleton.");
44 // create particles manager
45 fParticlesManager = new TG4ParticlesManager();
47 // create G3 physics manager
48 fG3PhysicsManager = new TG4G3PhysicsManager();
50 // fill process name map
54 TG4PhysicsManager::TG4PhysicsManager(){
57 delete fParticlesManager;
58 delete fG3PhysicsManager;
61 TG4PhysicsManager::TG4PhysicsManager(const TG4PhysicsManager& right) {
63 TG4Globals::Exception(
64 "Attempt to copy TG4PhysicsManager singleton.");
67 TG4PhysicsManager::~TG4PhysicsManager() {
74 TG4PhysicsManager::operator=(const TG4PhysicsManager& right)
76 // check assignement to self
77 if (this == &right) return *this;
79 TG4Globals::Exception(
80 "Attempt to assign TG4PhysicsManager singleton.");
87 void TG4PhysicsManager::FillProcessMap()
90 // The default G4 process names are used in the map.
93 // multiple scattering
94 fProcessMap.Add("msc", kPMultipleScattering);
95 fProcessMap.Add("Imsc", kPMultipleScattering);
97 // continuous energy loss
98 // !! including delta rays
99 fProcessMap.Add("eIoni", kPEnergyLoss);
100 fProcessMap.Add("IeIoni", kPEnergyLoss);
101 fProcessMap.Add("LowEnergyIoni", kPEnergyLoss);
102 fProcessMap.Add("hIoni", kPEnergyLoss);
103 fProcessMap.Add("IhIoni", kPEnergyLoss);
104 fProcessMap.Add("hLowEIoni", kPEnergyLoss);
105 fProcessMap.Add("MuIoni", kPEnergyLoss);
106 fProcessMap.Add("IMuIonisation", kPEnergyLoss);
107 fProcessMap.Add("ionIoni", kPEnergyLoss);
108 fProcessMap.Add("ionLowEIoni", kPEnergyLoss);
109 fProcessMap.Add("PAIonisation", kPEnergyLoss);
111 // bending in mag. field
115 fProcessMap.Add("Decay", kPDecay);
117 // photon pair production or
118 // muon direct pair production
119 fProcessMap.Add("conv", kPPair);
120 fProcessMap.Add("LowEnConversion", kPPair);
121 fProcessMap.Add("MuPairProd", kPPair);
122 fProcessMap.Add("IMuPairProduction", kPPair);
124 // Compton scattering
125 fProcessMap.Add("compt", kPCompton);
126 fProcessMap.Add("LowEnCompton", kPCompton);
127 fProcessMap.Add("polarCompt", kPCompton);
129 // photoelectric effect
130 fProcessMap.Add("phot", kPPhotoelectric);
131 fProcessMap.Add("LowEnPhotoElec", kPPhotoelectric);
134 fProcessMap.Add("eBrem", kPBrem);
135 fProcessMap.Add("IeBrem", kPBrem);
136 fProcessMap.Add("MuBrems", kPBrem);
137 fProcessMap.Add("IMuBremsstrahlung", kPBrem);
138 fProcessMap.Add("LowEnBrem", kPBrem);
140 // delta-ray production
142 // has to be distinguished from kPEnergyLoss on flight
144 // positron annihilation
145 fProcessMap.Add("annihil", kPAnnihilation);
146 fProcessMap.Add("Iannihil", kPAnnihilation);
148 // hadronic interaction
151 // nuclear evaporation
157 // nuclear absorption
158 fProcessMap.Add("PionMinusAbsorptionAtRest", kPNuclearAbsorption);
159 fProcessMap.Add("PiMinusAbsorptionAtRest", kPNuclearAbsorption);
160 fProcessMap.Add("KaonMinusAbsorption", kPNuclearAbsorption);
161 fProcessMap.Add("KaonMinusAbsorptionAtRest", kPNuclearAbsorption);
163 // antiproton annihilation
164 fProcessMap.Add("AntiProtonAnnihilationAtRest", kPPbarAnnihilation);
165 // fProcessMap.Add("AntiNeutronAnnihilationAtRest", not defined);
168 fProcessMap.Add("NeutronCaptureAtRest", kPNCapture);
169 // fProcessMap.Add("LCapture", hadron capture not defined);
171 // hadronic elastic incoherent scattering
172 fProcessMap.Add("LElastic", kPHElastic);
174 // hadronic inelastic scattering
175 fProcessMap.Add("inelastic", kPHInhelastic);
177 // muon nuclear interaction
178 fProcessMap.Add("MuNucl", kPMuonNuclear);
180 // exceeded time of flight cut
183 // nuclear photofission
186 // Rayleigh scattering
187 fProcessMap.Add("Rayleigh Scattering", kPRayleigh);
189 // no mechanism is active, usually at the entrance of a new volume
190 fProcessMap.Add("Transportation", kPNull);
192 // particle has fallen below energy threshold and tracking stops
195 // Cerenkov photon absorption
196 fProcessMap.Add("Absorption", kPLightAbsorption);
198 // Cerenkov photon reflection/refraction
199 // kPLightScattering, kPLightReflection, kPLightRefraction
200 // has to be inquired from the G4OpBoundary process
202 // synchrotron radiation
203 fProcessMap.Add("SynchrotronRadiation", kPSynchrotron);
209 void TG4PhysicsManager::BuildPhysics()
211 // Empty function - not needed in G4.
212 // (Physics is built within /run/initialize.)
216 "TG4PhysicsManager::BuildPhysics: is empty function in G4 MC.");
219 void TG4PhysicsManager::CreatePhysicsConstructors()
221 // Creates the selected physics constructors
222 // and registeres them in the modular physics list.
225 // electromagnetic physics
227 fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorEM());
230 if (fSetOpticalPhysics)
231 fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorOptical());
234 if (fSetHadronPhysics)
235 fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorHadron());
237 if (fSetSpecialCutsPhysics)
238 fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorSpecialCuts());
240 if (fSetSpecialControlsPhysics)
241 fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorSpecialControls());
243 // all created physics constructors are deleted
244 // in the G4VModularPhysicsList destructor
247 void TG4PhysicsManager::SetCut(const char* cutName, Float_t cutValue)
249 // Sets the specified cut.
252 fG3PhysicsManager->CheckLock();
253 TG4G3Cut g3Cut = fG3PhysicsManager->GetG3Cut(cutName);
254 if (g3Cut != kNoG3Cuts)
255 fG3PhysicsManager->SetCut(g3Cut, cutValue);
257 G4String text = "TG4PhysicsManager::SetCut:\n";
258 text = text + " Parameter " + cutName;
259 text = text + " is not implemented.";
260 TG4Globals::Warning(text);
264 void TG4PhysicsManager::SetProcess(const char* controlName, Int_t controlValue)
266 // Sets the specified process control.
269 fG3PhysicsManager->CheckLock();
270 TG4G3Control control = fG3PhysicsManager->GetG3Control(controlName);
271 if (control != kNoG3Controls)
272 fG3PhysicsManager->SetProcess(control, controlValue);
274 G4String text = "TG4PhysicsManager::SetProcess:\n";
275 text = text + " Parameter " + controlName;
276 text = text + " is not implemented.";
277 TG4Globals::Warning(text);
281 Float_t TG4PhysicsManager::Xsec(char* ch, Float_t p1, Int_t i1, Int_t i2)
283 // Not yet implemented -> gives exception.
286 TG4Globals::Exception(
287 "TG4PhysicsManager::Xsec: not yet implemented.");
292 Int_t TG4PhysicsManager::IdFromPDG(Int_t pdgID) const
294 // G4 does not use the integer particle identifiers
295 // Id <-> PDG is identity.
301 Int_t TG4PhysicsManager::PDGFromId(Int_t mcID) const
303 // G4 does not use integer particle identifiers
304 // Id <-> PDG is identity.
310 void TG4PhysicsManager::DefineParticles()
313 // Taken from TGeant3
315 // Use ENDF-6 mapping for ions = 10000*z+10*a+iso
317 // and numbers above 5 000 000 for special applications
320 const Int_t kion=10000000;
321 const Int_t kspe=50000000;
323 const Double_t kGeV=0.9314943228;
324 const Double_t kHslash = 1.0545726663e-27;
325 const Double_t kErgGeV = 1/1.6021773349e-3;
326 const Double_t kHshGeV = kHslash*kErgGeV;
327 const Double_t kYearsToSec = 3600*24*365.25;
329 TDatabasePDG *pdgDB = TDatabasePDG::Instance();
331 pdgDB->AddParticle("Deuteron","Deuteron",2*kGeV+8.071e-3,kTRUE,
332 0,1,"Ion",kion+10020);
334 pdgDB->AddParticle("Triton","Triton",3*kGeV+14.931e-3,kFALSE,
335 kHshGeV/(12.33*kYearsToSec),1,"Ion",kion+10030);
337 pdgDB->AddParticle("Alpha","Alpha",4*kGeV+2.424e-3,kTRUE,
338 kHshGeV/(12.33*kYearsToSec),2,"Ion",kion+20040);
340 pdgDB->AddParticle("HE3","HE3",3*kGeV+14.931e-3,kFALSE,
341 0,2,"Ion",kion+20030);
343 pdgDB->AddParticle("Cherenkov","Cherenkov",0,kFALSE,
344 0,0,"Special",kspe+50);
346 pdgDB->AddParticle("FeedbackPhoton","FeedbackPhoton",0,kFALSE,
347 0,0,"Special",kspe+51);
350 // To do: define the PDG database extension
353 // AliMC::ExtendPDGDatabase();
355 // end of "common" implementation
358 fParticlesManager->MapParticles();
362 void TG4PhysicsManager::SetProcessActivation()
364 // (In)Activates built processes according
365 // to the setup in fControlVector.
369 // temporarily excluded
370 // fPhysicsList->SetProcessActivation();
373 G4String text = "TG4PhysicsManager::SetProcessActivation:\n";
374 text = text + " There is no physics list set.";
375 TG4Globals::Exception(text);
380 AliMCProcess TG4PhysicsManager::GetMCProcess(const G4VProcess* process)
382 // Returns the AliMCProcess code of the specified G4 process.
385 if (!process) return kPNoProcess;
387 G4String name = process->GetProcessName();
388 G4int code = fProcessMap.GetSecond(name);
390 if (code == 0) return kPNoProcess;
392 return (AliMCProcess)code;