4 // Author: I. Hrivnacova
6 // Class TG4PhysicsManager
7 // -----------------------
8 // See the class description in the header file.
10 #include "TG4PhysicsManager.h"
11 #include "TG4ModularPhysicsList.h"
12 #include "TG4ParticlesManager.h"
13 #include "TG4G3PhysicsManager.h"
14 #include "TG4PhysicsConstructorEM.h"
15 #include "TG4PhysicsConstructorOptical.h"
16 #include "TG4PhysicsConstructorHadron.h"
17 #include "TG4PhysicsConstructorSpecialCuts.h"
18 #include "TG4PhysicsConstructorSpecialControls.h"
19 #include "TG4GeometryServices.h"
21 #include "TG4G3Control.h"
22 #include "TG4G3Units.h"
23 #include "TG4Limits.h"
24 #include "AliDecayer.h"
26 #include <G4ParticleDefinition.hh>
27 #include <G4VProcess.hh>
28 #include <G3MedTable.hh>
30 #include <TDatabasePDG.h>
32 TG4PhysicsManager* TG4PhysicsManager::fgInstance = 0;
34 //_____________________________________________________________________________
35 TG4PhysicsManager::TG4PhysicsManager(TG4ModularPhysicsList* physicsList)
36 : fPhysicsList(physicsList),
39 fSetOpticalPhysics(false),
40 fSetHadronPhysics(false),
41 fSetSpecialCutsPhysics(false),
42 fSetSpecialControlsPhysics(false)
47 TG4Globals::Exception(
48 "TG4PhysicsManager: attempt to create two instances of singleton.");
53 // create particles manager
54 fParticlesManager = new TG4ParticlesManager();
56 // create G3 physics manager
57 fG3PhysicsManager = new TG4G3PhysicsManager();
59 // fill process name map
63 //_____________________________________________________________________________
64 TG4PhysicsManager::TG4PhysicsManager(){
67 delete fParticlesManager;
68 delete fG3PhysicsManager;
71 //_____________________________________________________________________________
72 TG4PhysicsManager::TG4PhysicsManager(const TG4PhysicsManager& right) {
74 TG4Globals::Exception(
75 "Attempt to copy TG4PhysicsManager singleton.");
78 //_____________________________________________________________________________
79 TG4PhysicsManager::~TG4PhysicsManager() {
85 //_____________________________________________________________________________
87 TG4PhysicsManager::operator=(const TG4PhysicsManager& right)
89 // check assignement to self
90 if (this == &right) return *this;
92 TG4Globals::Exception(
93 "Attempt to assign TG4PhysicsManager singleton.");
100 //_____________________________________________________________________________
101 void TG4PhysicsManager::FillProcessMap()
103 // Fills fProcessMCMap.
104 // The default G4 process names are used in the map.
105 // Not used - the map is filled in physics constructors
106 // only with processes that are really built.
109 // multiple scattering
110 fProcessMCMap.Add("msc", kPMultipleScattering);
111 fProcessMCMap.Add("Imsc", kPMultipleScattering);
113 // continuous energy loss
114 // !! including delta rays
115 fProcessMCMap.Add("eIoni", kPEnergyLoss);
116 fProcessMCMap.Add("IeIoni", kPEnergyLoss);
117 fProcessMCMap.Add("LowEnergyIoni", kPEnergyLoss);
118 fProcessMCMap.Add("hIoni", kPEnergyLoss);
119 fProcessMCMap.Add("IhIoni", kPEnergyLoss);
120 fProcessMCMap.Add("hLowEIoni", kPEnergyLoss);
121 fProcessMCMap.Add("MuIoni", kPEnergyLoss);
122 fProcessMCMap.Add("IMuIonisation", kPEnergyLoss);
123 fProcessMCMap.Add("ionIoni", kPEnergyLoss);
124 fProcessMCMap.Add("ionLowEIoni", kPEnergyLoss);
125 fProcessMCMap.Add("PAIonisation", kPEnergyLoss);
127 // bending in mag. field
131 fProcessMCMap.Add("Decay", kPDecay);
133 // photon pair production or
134 // muon direct pair production
135 fProcessMCMap.Add("conv", kPPair);
136 fProcessMCMap.Add("LowEnConversion", kPPair);
137 fProcessMCMap.Add("MuPairProd", kPPair);
138 fProcessMCMap.Add("IMuPairProduction", kPPair);
140 // Compton scattering
141 fProcessMCMap.Add("compt", kPCompton);
142 fProcessMCMap.Add("LowEnCompton", kPCompton);
143 fProcessMCMap.Add("polarCompt", kPCompton);
145 // photoelectric effect
146 fProcessMCMap.Add("phot", kPPhotoelectric);
147 fProcessMCMap.Add("LowEnPhotoElec", kPPhotoelectric);
150 fProcessMCMap.Add("eBrem", kPBrem);
151 fProcessMCMap.Add("IeBrem", kPBrem);
152 fProcessMCMap.Add("MuBrems", kPBrem);
153 fProcessMCMap.Add("IMuBremsstrahlung", kPBrem);
154 fProcessMCMap.Add("LowEnBrem", kPBrem);
156 // delta-ray production
158 // has to be distinguished from kPEnergyLoss on flight
160 // positron annihilation
161 fProcessMCMap.Add("annihil", kPAnnihilation);
162 fProcessMCMap.Add("Iannihil", kPAnnihilation);
164 // hadronic interaction
167 // nuclear evaporation
173 // nuclear absorption
174 fProcessMCMap.Add("PionMinusAbsorptionAtRest", kPNuclearAbsorption);
175 fProcessMCMap.Add("PiMinusAbsorptionAtRest", kPNuclearAbsorption);
176 fProcessMCMap.Add("KaonMinusAbsorption", kPNuclearAbsorption);
177 fProcessMCMap.Add("KaonMinusAbsorptionAtRest", kPNuclearAbsorption);
179 // antiproton annihilation
180 fProcessMCMap.Add("AntiProtonAnnihilationAtRest", kPPbarAnnihilation);
181 // fProcessMCMap.Add("AntiNeutronAnnihilationAtRest", not defined);
184 fProcessMCMap.Add("NeutronCaptureAtRest", kPNCapture);
185 // fProcessMCMap.Add("LCapture", hadron capture not defined);
187 // hadronic elastic incoherent scattering
188 fProcessMCMap.Add("LElastic", kPHElastic);
190 // hadronic inelastic scattering
191 fProcessMCMap.Add("inelastic", kPHInhelastic);
193 // muon nuclear interaction
194 fProcessMCMap.Add("MuNucl", kPMuonNuclear);
196 // exceeded time of flight cut
199 // nuclear photofission
202 // Rayleigh scattering
203 fProcessMCMap.Add("Rayleigh Scattering", kPRayleigh);
205 // no mechanism is active, usually at the entrance of a new volume
206 fProcessMCMap.Add("Transportation", kPNull);
208 // particle has fallen below energy threshold and tracking stops
211 // Cerenkov photon absorption
212 fProcessMCMap.Add("Absorption", kPLightAbsorption);
214 // Cerenkov photon reflection/refraction
215 // kPLightScattering, kPLightReflection, kPLightRefraction
216 // has to be inquired from the G4OpBoundary process
218 // synchrotron radiation
219 fProcessMCMap.Add("SynchrotronRadiation", kPSynchrotron);
222 //_____________________________________________________________________________
223 void TG4PhysicsManager::GstparCut(G4int itmed, TG4G3Cut par, G4double parval)
225 // Sets special tracking medium parameter.
226 // It is applied to all logical volumes that use the specified
230 // get medium from table
231 G3MedTableEntry* medium = G3Med.get(itmed);
233 G4String text = "TG4PhysicsManager::GstparCut: \n";
234 text = text + " Medium not found.";
238 // get/create user limits
240 = TG4GeometryServices::Instance()->GetLimits(medium->GetLimits());
243 limits = new TG4Limits(*fG3PhysicsManager->GetCutVector(),
244 *fG3PhysicsManager->GetControlVector());
245 medium->SetLimits(limits);
248 G4cout << "TG4PhysicsManager::GstparCut: new TG4Limits() for medium "
249 << itmed << " has been created." << G4endl;
253 if (par == kTOFMAX) parval *= TG4G3Units::Time();
254 else parval *= TG4G3Units::Energy();
257 limits->SetG3Cut(par, parval);
261 //_____________________________________________________________________________
262 void TG4PhysicsManager::GstparControl(G4int itmed, TG4G3Control par,
263 TG4G3ControlValue parval)
265 // Sets special tracking medium parameter.
266 // It is applied to all logical volumes that use the specified
270 // get medium from table
271 G3MedTableEntry* medium = G3Med.get(itmed);
273 G4String text = "TG4PhysicsManager::GstparControl: \n";
274 text = text + " Medium not found.";
278 // get/create user limits
280 = TG4GeometryServices::Instance()->GetLimits(medium->GetLimits());
283 limits = new TG4Limits(*fG3PhysicsManager->GetCutVector(),
284 *fG3PhysicsManager->GetControlVector());
285 medium->SetLimits(limits);
288 G4cout << "TG4PhysicsManager::GstparControl: new TG4Limits() for medium"
289 << itmed << " has been created." << G4endl;
293 limits->SetG3Control(par, parval);
298 //_____________________________________________________________________________
299 void TG4PhysicsManager::Gstpar(Int_t itmed, const char *param, Float_t parval)
301 // Passes the tracking medium parameter to TG4Limits.
302 // The tracking medium parameter is set only in case
303 // its value is different from the "global" physics setup.
304 // (If: CheckCut/ControlWithG3Defaults is used checking
305 // is performed with respect to G3 default values.)
306 // When any cut/control parameter is set in limits
307 // the physics manager is locked and the physics setup
308 // cannot be changed.
309 // Applying this TG4Limits to particles and physical
310 // processes is still in development.
312 // Geant3 desription:
313 // ==================
314 // To change the value of cut or mechanism "CHPAR"
315 // to a new value PARVAL for tracking medium ITMED
316 // The data structure JTMED contains the standard tracking
317 // parameters (CUTS and flags to control the physics processes) which
318 // are used by default for all tracking media. It is possible to
319 // redefine individually with GSTPAR any of these parameters for a
320 // given tracking medium.
321 // ITMED tracking medium number
322 // CHPAR is a character string (variable name)
323 // PARVAL must be given as a floating point.
326 G4String name = TG4GeometryServices::Instance()->CutName(param);
328 if (fG3PhysicsManager->CheckCutWithTheVector(name, parval, cut)) {
329 GstparCut(itmed, cut, parval);
330 fG3PhysicsManager->Lock();
333 TG4G3Control control;
334 TG4G3ControlValue controlValue;
335 if (fG3PhysicsManager
336 ->CheckControlWithTheVector(name, parval, control, controlValue)) {
337 GstparControl(itmed, control, controlValue);
338 fG3PhysicsManager->Lock();
340 else if (cut==kNoG3Cuts && control==kNoG3Controls) {
341 G4String text = "TG4PhysicsManager::Gstpar:";
343 text = text + " parameter is not yet implemented.";
344 TG4Globals::Warning(text);
349 //_____________________________________________________________________________
350 void TG4PhysicsManager::CreatePhysicsConstructors()
352 // Creates the selected physics constructors
353 // and registeres them in the modular physics list.
356 // electromagnetic physics
358 fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorEM());
361 if (fSetOpticalPhysics)
362 fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorOptical());
365 if (fSetHadronPhysics)
366 fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorHadron());
368 if (fSetSpecialCutsPhysics)
369 fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorSpecialCuts());
371 if (fSetSpecialControlsPhysics)
372 fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorSpecialControls());
374 // all created physics constructors are deleted
375 // in the TG4ModularPhysicsList destructor
378 //_____________________________________________________________________________
379 void TG4PhysicsManager::SetCut(const char* cutName, Float_t cutValue)
381 // Sets the specified cut.
384 fG3PhysicsManager->CheckLock();
385 TG4G3Cut g3Cut = TG4G3CutVector::GetCut(cutName);
387 if (g3Cut == kNoG3Cuts) {
388 G4String text = "TG4PhysicsManager::SetCut:\n";
389 text = text + " Parameter " + cutName;
390 text = text + " is not implemented.";
391 TG4Globals::Warning(text);
396 if (g3Cut == kTOFMAX) cutValue *= TG4G3Units::Time();
397 else cutValue *= TG4G3Units::Energy();
399 fG3PhysicsManager->SetCut(g3Cut, cutValue);
402 //_____________________________________________________________________________
403 void TG4PhysicsManager::SetProcess(const char* controlName, Int_t value)
405 // Sets the specified process control.
408 fG3PhysicsManager->CheckLock();
409 TG4G3Control control = TG4G3ControlVector::GetControl(controlName);
411 if (control != kNoG3Controls) {
412 TG4G3ControlValue controlValue
413 = TG4G3ControlVector::GetControlValue(value, control);
414 fG3PhysicsManager->SetProcess(control, controlValue);
417 G4String text = "TG4PhysicsManager::SetProcess:\n";
418 text = text + " Parameter " + controlName;
419 text = text + " is not implemented.";
420 TG4Globals::Warning(text);
424 //_____________________________________________________________________________
425 Float_t TG4PhysicsManager::Xsec(char* ch, Float_t p1, Int_t i1, Int_t i2)
427 // Not yet implemented -> gives exception.
430 TG4Globals::Exception(
431 "TG4PhysicsManager::Xsec: not yet implemented.");
436 //_____________________________________________________________________________
437 Int_t TG4PhysicsManager::IdFromPDG(Int_t pdgID) const
439 // G4 does not use the integer particle identifiers
440 // Id <-> PDG is identity.
446 //_____________________________________________________________________________
447 Int_t TG4PhysicsManager::PDGFromId(Int_t mcID) const
449 // G4 does not use integer particle identifiers
450 // Id <-> PDG is identity.
456 //_____________________________________________________________________________
457 void TG4PhysicsManager::DefineParticles()
460 // Taken from TGeant3
462 // Use ENDF-6 mapping for ions = 10000*z+10*a+iso
464 // and numbers above 5 000 000 for special applications
467 const Int_t kion=10000000;
468 const Int_t kspe=50000000;
470 const Double_t kGeV=0.9314943228;
471 const Double_t kHslash = 1.0545726663e-27;
472 const Double_t kErgGeV = 1/1.6021773349e-3;
473 const Double_t kHshGeV = kHslash*kErgGeV;
474 const Double_t kYearsToSec = 3600*24*365.25;
476 TDatabasePDG *pdgDB = TDatabasePDG::Instance();
478 pdgDB->AddParticle("Deuteron","Deuteron",2*kGeV+8.071e-3,kTRUE,
479 0,1,"Ion",kion+10020);
481 pdgDB->AddParticle("Triton","Triton",3*kGeV+14.931e-3,kFALSE,
482 kHshGeV/(12.33*kYearsToSec),1,"Ion",kion+10030);
484 pdgDB->AddParticle("Alpha","Alpha",4*kGeV+2.424e-3,kTRUE,
485 kHshGeV/(12.33*kYearsToSec),2,"Ion",kion+20040);
487 pdgDB->AddParticle("HE3","HE3",3*kGeV+14.931e-3,kFALSE,
488 0,2,"Ion",kion+20030);
490 pdgDB->AddParticle("Cherenkov","Cherenkov",0,kFALSE,
491 0,0,"Special",kspe+50);
493 pdgDB->AddParticle("FeedbackPhoton","FeedbackPhoton",0,kFALSE,
494 0,0,"Special",kspe+51);
497 // To do: define the PDG database extension
500 // AliMC::ExtendPDGDatabase();
502 // end of "common" implementation
505 fParticlesManager->MapParticles();
508 //_____________________________________________________________________________
509 void TG4PhysicsManager::SetProcessActivation()
511 // (In)Activates built processes according
512 // to the setup in TG4G3PhysicsManager::fControlVector.
515 fPhysicsList->SetProcessActivation();
519 //_____________________________________________________________________________
520 AliMCProcess TG4PhysicsManager::GetMCProcess(const G4VProcess* process)
522 // Returns the AliMCProcess code of the specified G4 process.
525 if (!process) return kPNoProcess;
527 return fProcessMCMap.GetMCProcess(process);