]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TGeant4/TG4PhysicsManager.cxx
Bugfix in AliPoints2Memory
[u/mrichter/AliRoot.git] / TGeant4 / TG4PhysicsManager.cxx
index 462935615c563285c5ecb564bdbcd667573afdd7..3f2dab1b9b54225a140364ba8b1669e4c1d07cd7 100644 (file)
 #include "TG4ModularPhysicsList.h"
 #include "TG4ParticlesManager.h"
 #include "TG4G3PhysicsManager.h"
+#include "TG4PhysicsConstructorGeneral.h"
 #include "TG4PhysicsConstructorEM.h"
-#include "TG4PhysicsConstructorOptical.h"
+#include "TG4PhysicsConstructorMuon.h"
 #include "TG4PhysicsConstructorHadron.h"
+#include "TG4PhysicsConstructorIon.h"
+#include "TG4PhysicsConstructorOptical.h"
 #include "TG4PhysicsConstructorSpecialCuts.h"
 #include "TG4PhysicsConstructorSpecialControls.h"
 #include "TG4GeometryServices.h"
@@ -24,6 +27,7 @@
 #include "AliDecayer.h"
 
 #include <G4ParticleDefinition.hh>
+#include <G4OpBoundaryProcess.hh>
 #include <G4VProcess.hh>
 #include <G3MedTable.hh>
 
@@ -33,11 +37,14 @@ TG4PhysicsManager* TG4PhysicsManager::fgInstance = 0;
 
 //_____________________________________________________________________________
 TG4PhysicsManager::TG4PhysicsManager(TG4ModularPhysicsList* physicsList)
-  : fPhysicsList(physicsList),
+  : TG4Verbose("physicsManager"),
+    fMessenger(this),
+    fPhysicsList(physicsList),
     fDecayer(0),
     fSetEMPhysics(true),
-    fSetOpticalPhysics(false),
+    fSetMuonPhysics(true),
     fSetHadronPhysics(false),
+    fSetOpticalPhysics(false),
     fSetSpecialCutsPhysics(false),
     fSetSpecialControlsPhysics(false)
 
@@ -61,15 +68,16 @@ TG4PhysicsManager::TG4PhysicsManager(TG4ModularPhysicsList* physicsList)
 }
 
 //_____________________________________________________________________________
-TG4PhysicsManager::TG4PhysicsManager(){
+TG4PhysicsManager::TG4PhysicsManager()
+  : TG4Verbose("physicsManager"),
+    fMessenger(this) {
 //
-  delete fDecayer;
-  delete fParticlesManager;
-  delete fG3PhysicsManager;
 }
 
 //_____________________________________________________________________________
-TG4PhysicsManager::TG4PhysicsManager(const TG4PhysicsManager& right) {
+TG4PhysicsManager::TG4PhysicsManager(const TG4PhysicsManager& right) 
+  : TG4Verbose("physicsManager"),
+    fMessenger(this) {
 // 
   TG4Globals::Exception(
     "Attempt to copy TG4PhysicsManager singleton.");
@@ -78,6 +86,9 @@ TG4PhysicsManager::TG4PhysicsManager(const TG4PhysicsManager& right) {
 //_____________________________________________________________________________
 TG4PhysicsManager::~TG4PhysicsManager() {
 //
+  delete fDecayer;
+  delete fParticlesManager;
+  delete fG3PhysicsManager;
 }
 
 // operators
@@ -244,9 +255,10 @@ void TG4PhysicsManager::GstparCut(G4int itmed, TG4G3Cut par, G4double parval)
                            *fG3PhysicsManager->GetControlVector());
     medium->SetLimits(limits);
 
-    // add verbose 
-    G4cout << "TG4PhysicsManager::GstparCut: new TG4Limits() for medium " 
-           << itmed << " has been created." << G4endl;  
+    if (VerboseLevel() > 1) {
+      G4cout << "TG4PhysicsManager::GstparCut: new TG4Limits() for medium " 
+             << itmed << " has been created." << G4endl;  
+    }       
   }       
 
   // add units
@@ -284,9 +296,10 @@ void TG4PhysicsManager::GstparControl(G4int itmed, TG4G3Control par,
                            *fG3PhysicsManager->GetControlVector());
     medium->SetLimits(limits);
 
-    // add verbose 
-    G4cout << "TG4PhysicsManager::GstparControl: new TG4Limits() for medium" 
-           << itmed << " has been created." << G4endl;  
+    if (VerboseLevel() > 1) {
+      G4cout << "TG4PhysicsManager::GstparControl: new TG4Limits() for medium" 
+             << itmed << " has been created." << G4endl;  
+    }       
   }       
   
   // set parameter
@@ -353,23 +366,51 @@ void TG4PhysicsManager::CreatePhysicsConstructors()
 // and registeres them in the modular physics list.
 // ---
 
+  // general physics
+  fPhysicsList->RegisterPhysics(
+                    new TG4PhysicsConstructorGeneral(VerboseLevel()));
+
   // electromagnetic physics
   if (fSetEMPhysics) 
-    fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorEM());
+    fPhysicsList->RegisterPhysics(
+                    new TG4PhysicsConstructorEM(VerboseLevel()));
 
-  // optical physics
-  if (fSetOpticalPhysics) 
-    fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorOptical());
+  // muon physics
+  if (fSetMuonPhysics && fSetEMPhysics)      
+    fPhysicsList->RegisterPhysics(
+                    new TG4PhysicsConstructorMuon(VerboseLevel()));
 
   // hadron physics
-  if (fSetHadronPhysics) 
-    fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorHadron());
+  if (fSetEMPhysics || fSetHadronPhysics) { 
+    fPhysicsList->RegisterPhysics(
+                    new TG4PhysicsConstructorIon(
+                          VerboseLevel(), fSetEMPhysics, fSetHadronPhysics));
+    fPhysicsList->RegisterPhysics(
+                    new TG4PhysicsConstructorHadron(
+                          VerboseLevel(), fSetEMPhysics, fSetHadronPhysics));
+  }  
+
+  // optical physics
+  if (fSetOpticalPhysics) 
+    fPhysicsList->RegisterPhysics(
+                    new TG4PhysicsConstructorOptical(VerboseLevel()));
 
+  // special processes
   if (fSetSpecialCutsPhysics) 
-    fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorSpecialCuts());
+    fPhysicsList->RegisterPhysics(
+                    new TG4PhysicsConstructorSpecialCuts(VerboseLevel()));
 
   if (fSetSpecialControlsPhysics) 
-    fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorSpecialControls());
+    fPhysicsList->RegisterPhysics(
+                    new TG4PhysicsConstructorSpecialControls(VerboseLevel()));
+
+  // warn about not allowed combinations
+  if (fSetMuonPhysics && !fSetEMPhysics) {
+    G4String text = "TG4PhysicsManager::CreatePhysicsConstructors:\n";
+    text = text + "    Muon physics cannot be constructed without EM physics.\n";
+    text = text + "    SetMuon control was ignored.";
+    TG4Globals::Warning(text);     
+  }
 
          // all created physics constructors are deleted
         // in the TG4ModularPhysicsList destructor
@@ -527,3 +568,54 @@ AliMCProcess TG4PhysicsManager::GetMCProcess(const G4VProcess* process)
   return fProcessMCMap.GetMCProcess(process);
 }
 
+//_____________________________________________________________________________
+AliMCProcess TG4PhysicsManager::GetOpBoundaryStatus(const G4VProcess* process)
+{
+// Returns the AliMCProcess code according to the OpBoundary process
+// status.
+// ---
+  if (!process) return kPNoProcess;
+
+#ifdef TGEANT4_DEBUG
+  G4OpBoundaryProcess* opBoundary
+    = dynamic_cast<G4OpBoundaryProcess*>(process);
+    
+  if (!opBoundary) 
+    TG4Globals::Exception(
+      "TG4PhysicsManager::GetOpBoundaryStatus: Wrong process type.");
+    return kPNoProcess;
+  }
+  
+  return opBoundary;  
+#else
+  G4OpBoundaryProcess* opBoundary = (G4OpBoundaryProcess*)process;
+#endif  
+
+  switch (opBoundary->GetStatus()) {
+    // reflection
+    case FresnelReflection: 
+    case TotalInternalReflection:
+    case LambertianReflection: 
+    case LobeReflection:
+    case SpikeReflection: 
+    case BackScattering:
+       return kPLightReflection;
+       ;;
+
+    // refraction
+    case FresnelRefraction: 
+       return kPLightRefraction;
+       ;;
+
+    // absorption
+    case Absorption:
+    case Detection: 
+       return kPLightAbsorption;
+       ;;
+  }
+  
+  // should not happen
+  return kPNoProcess;
+}
+