]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TGeant4/TG4ModularPhysicsList.cxx
Bugfix in AliPoints2Memory
[u/mrichter/AliRoot.git] / TGeant4 / TG4ModularPhysicsList.cxx
index ba16f63b849623dcf2446b44509331a9977bd208..a012e42600cecc19baf812fcaeb5138eb7f3a55b 100644 (file)
@@ -1,11 +1,17 @@
 // $Id$
 // Category: physics
 //
+// Author: I. Hrivnacova
+//
+// Class TG4ModularPhysicsList
+// ---------------------------
 // See the class description in the header file.
 
 #include "TG4ModularPhysicsList.h"
+#include "TG4GeometryServices.h"
 #include "TG4G3PhysicsManager.h"
 #include "TG4G3ControlVector.h"
+#include "TG4ProcessControlMap.h"
 
 #include <G4ParticleDefinition.hh>
 #include <G4ProcessManager.hh>
 #include <G4IonConstructor.hh>
 #include <G4ShortLivedConstructor.hh>
 #include <G4ProcessTable.hh>
-#include <G4Decay.hh>
 
+const G4double TG4ModularPhysicsList::fgkDefaultCutValue = 1.0 * mm;
 
+//_____________________________________________________________________________
 TG4ModularPhysicsList::TG4ModularPhysicsList()
-  : G4VModularPhysicsList()
-{
-  G4cout << "TG4ModularPhysicsList::TG4ModularPhysicsList" << G4endl;
+  : G4VModularPhysicsList(),
+    TG4Verbose("physicsList") {
+//
+  defaultCutValue = fgkDefaultCutValue;
 
-  defaultCutValue = 1.0*mm;
+  SetVerboseLevel(VerboseLevel());
+}
 
-  SetVerboseLevel(1);
+//_____________________________________________________________________________
+TG4ModularPhysicsList::TG4ModularPhysicsList(const TG4ModularPhysicsList& right)
+  : TG4Verbose("physicsList") {
+//
+  TG4Globals::Exception("TG4ModularPhysicsList is protected from copying.");
 }
 
+//_____________________________________________________________________________
 TG4ModularPhysicsList::~TG4ModularPhysicsList() {
 //
+  //delete fExtDecayer;
+       // fExtDecayer is deleted in G4Decay destructor
+}
+
+// operators
+
+//_____________________________________________________________________________
+TG4ModularPhysicsList& 
+TG4ModularPhysicsList::operator=(const TG4ModularPhysicsList &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  TG4Globals::Exception("TG4ModularPhysicsList is protected from assigning.");
+
+  return *this;
 }
 
+// private methods
+
+//_____________________________________________________________________________
+void TG4ModularPhysicsList::SetProcessActivation(
+                                      G4ProcessManager* processManager,
+                                      G4int  processId, G4bool activation)
+{                                    
+// Sets process activation for the given process.
+// ---
+
+  G4String strActivation = "activation";
+  if (!activation) strActivation = "inactivation";
+
+  if (VerboseLevel() > 1) {
+    G4cout << "Set process " << strActivation << " for " 
+           << (*processManager->GetProcessList())[processId]->GetProcessName() 
+          << G4endl;
+  }
+  
+  processManager->SetProcessActivation(processId, activation); 
+}  
+
 // protected methods
 
+//_____________________________________________________________________________
 void TG4ModularPhysicsList::ConstructParticle()
 {
 // In this method, static member functions should be called
@@ -43,117 +96,31 @@ void TG4ModularPhysicsList::ConstructParticle()
 // created in the program. 
 // ---
 
-  G4cout << "Construct particles" << G4endl;
-
   // lock physics manager
   TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
   g3PhysicsManager->Lock();  
-  // create all particles
-  ConstructAllBosons();
-  ConstructAllLeptons();
-  ConstructAllMesons();
-  ConstructAllBaryons();
-  ConstructAllIons();
-  ConstructAllShortLiveds();
   
   // create particles for registered physics
   G4VModularPhysicsList::ConstructParticle();
 }
 
+//_____________________________________________________________________________
 void TG4ModularPhysicsList::ConstructProcess()
 {
 // Constructs all processes.
 // ---
 
-  G4cout << "Construct process" << G4endl;
-
   // create processes for registered physics
   G4VModularPhysicsList::ConstructProcess();
 
-  ConstructGeneral();
-
   // verbose
-  if (verboseLevel>1) PrintAllProcesses();
-}
-
-
-void TG4ModularPhysicsList::ConstructAllBosons()
-{
-// Construct all bosons
-// ---
-
-  G4BosonConstructor pConstructor;
-  pConstructor.ConstructParticle();
-}
-
-void TG4ModularPhysicsList::ConstructAllLeptons()
-{
-// Construct all leptons
-// ---
-
-  G4LeptonConstructor pConstructor;
-  pConstructor.ConstructParticle();
-}
-
-void TG4ModularPhysicsList::ConstructAllMesons()
-{
-// Construct all mesons
-// ---
-
-  G4MesonConstructor pConstructor;
-  pConstructor.ConstructParticle();
+  if (verboseLevel>1) DumpAllProcesses();
 }
 
-void TG4ModularPhysicsList::ConstructAllBaryons()
-{
-// Construct all barions
-// ---
-
-  G4BaryonConstructor pConstructor;
-  pConstructor.ConstructParticle();
-}
-
-void TG4ModularPhysicsList::ConstructAllIons()
-{
-// Construct light ions
-// ---
-
-  G4IonConstructor pConstructor;
-  pConstructor.ConstructParticle();  
-}
-
-void TG4ModularPhysicsList::ConstructAllShortLiveds()
-{
-// Construct  resonaces and quarks
-// ---
-
-  G4ShortLivedConstructor pConstructor;
-  pConstructor.ConstructParticle();  
-}
-
-void TG4ModularPhysicsList::ConstructGeneral()
-{
-// Constructs general processes.
-// ---
-
-  // Add Decay Process
-  G4Decay* theDecayProcess = new G4Decay();
-  theParticleIterator->reset();
-  while( (*theParticleIterator)() ){
-    G4ParticleDefinition* particle = theParticleIterator->value();
-    G4ProcessManager* pmanager = particle->GetProcessManager();
-    if (theDecayProcess->IsApplicable(*particle)) { 
-      pmanager ->AddProcess(theDecayProcess);
-      // set ordering for PostStepDoIt and AtRestDoIt
-      pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep);
-      pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest);
-    }
-  }
-}
 
 // public methods
 
+//_____________________________________________________________________________
 void TG4ModularPhysicsList::SetCuts()
 {
 // Sets the default cut value for all particle types
@@ -168,12 +135,12 @@ void TG4ModularPhysicsList::SetCuts()
 
   // default cut value
   G4double cut  = defaultCutValue;
-  G4double ecut = 10.*m; 
-  //G4double ecut = cut; 
+  //G4double ecut = 10.*m; 
+  G4double ecut = cut; 
 
 #ifdef G4VERBOSE    
-  if (verboseLevel >1){
-    G4cout << "G4VUserPhysicsList::SetCutsWithDefault:";
+  if (VerboseLevel() > 1) {
+    G4cout << "TG4ModularPhysicsList::SetCutsWithDefault:";
     G4cout << "CutLength : " << cut/mm << " (mm)" << G4endl;
   }  
 #endif
@@ -196,67 +163,78 @@ void TG4ModularPhysicsList::SetCuts()
   }
 }
 
+//_____________________________________________________________________________
 void TG4ModularPhysicsList::SetProcessActivation()
 {
 // (In)Activates built processes according
 // to the setup in TG4G3PhysicsManager::fControlVector.
 // ---
 
-  G4cout << "TG4ModularPhysicsList::SetProcessActivation() start" << G4endl;
-  
-  TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
-  TG4G3ControlVector* controlVector = g3PhysicsManager->GetControlVector();
-
-  // uncomment following lines to print
-  // the controlVector values
-  //for (G4int i=0; i<kNoG3Controls; i++)
-  //{ cout << i << " control: " << (*controlVector)[i] << G4endl; }
-
-  if (controlVector) {
-    theParticleIterator->reset();
-    while ((*theParticleIterator)())
-    {
-      G4ParticleDefinition* particle = theParticleIterator->value();
-      G4ProcessManager* processManager = particle->GetProcessManager(); 
-      G4ProcessVector* processVector = processManager->GetProcessList();
-    
-      // set processes controls
-      for (G4int i=0; i<processManager->GetProcessListLength(); i++) {
-        G4int control = controlVector->GetControl((*processVector)[i]);
-        if ((control == kInActivate) && 
-            (processManager->GetProcessActivation(i))) {
-          if (verboseLevel>1) {
-             G4cout << "Set process inactivation for " 
-                    << (*processVector)[i]->GetProcessName() << G4endl;
-          }
-          processManager->SetProcessActivation(i,false);
-        }  
-        else if (((control == kActivate) || (control == kActivate2)) &&
-                 (!processManager->GetProcessActivation(i))) {
-          if (verboseLevel>1) {
-             G4cout << "Set process activation for " 
-                    << (*processVector)[i]->GetProcessName() << G4endl;
-          }
-          processManager->SetProcessActivation(i,true);
-        } 
-      }
-    }
-  }
-  else {
+  TG4G3ControlVector* controlVector 
+    = TG4G3PhysicsManager::Instance()->GetControlVector();
+
+  G4bool specialControls 
+    = TG4GeometryServices::Instance()->IsSpecialControls();  
+
+  if (!specialControls) 
+    if (VerboseLevel() > 0) {
+      G4cout << G4endl
+             << "### No special controls in user limits are set." << G4endl;
+    }       
+
+  if (!controlVector) {
     G4String text = "TG4ModularPhysicsList::SetProcessActivation: \n";
     text = text + "    Vector of processes controls is not set.";
     TG4Globals::Warning(text);
+    return;
   }    
-  G4cout << "TG4ModularPhysicsList::SetProcessActivation() end" << G4endl;
+  
+  theParticleIterator->reset();
+  while ((*theParticleIterator)())
+  {
+    G4ProcessManager* processManager 
+      = theParticleIterator->value()->GetProcessManager(); 
+      
+    G4ProcessVector* processVector = processManager->GetProcessList();
+  
+    // set processes controls
+    for (G4int i=0; i<processVector->length(); i++) {
+
+      TG4G3ControlValue control
+        = controlVector->GetControlValue((*processVector)[i]);
+      G4bool activation = processManager->GetProcessActivation(i);
+
+      if (control != kUnset) {
+        if (!TG4Globals::Compare(activation, control)) {
+
+          // set new process activation
+          G4bool activate;
+          if (control == kInActivate) activate = false; 
+         else                        activate = true;
+         
+         SetProcessActivation(processManager, i, activate);         
+        }
+      }        
+      else  {
+        // control == kUnset
+       if ((*processVector)[i]->GetProcessName().find("specialControl")
+           != G4String::npos) { 
+
+         SetProcessActivation(processManager, i, specialControls);         
+        }  
+      }        
+    }
+  }  
 }
 
+//_____________________________________________________________________________
 void TG4ModularPhysicsList::PrintAllProcesses() const
 {
 // Prints all processes.
 // ---
 
   G4cout << "TG4ModularPhysicsList processes: " << G4endl;
-  G4cout << "========================= " << G4endl;
+  G4cout << "================================ " << G4endl;
  
   G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
   G4ProcessTable::G4ProcNameVector* processNameList 
@@ -267,3 +245,29 @@ void TG4ModularPhysicsList::PrintAllProcesses() const
   }  
 }
 
+//_____________________________________________________________________________
+void TG4ModularPhysicsList::DumpAllProcesses() const
+{
+// Dumps all particles and their processes.
+// ---
+
+  G4cout << "TG4ModularPhysicsList particles and processes: " << G4endl;
+  G4cout << "============================================== " << G4endl;
+  theParticleIterator->reset();
+  while ((*theParticleIterator)())
+  {
+    // print particle name
+    G4cout << "Particle: " 
+           << theParticleIterator->value()->GetParticleName()
+          << G4endl;
+
+    // dump particle processes
+    G4ProcessVector* processVector 
+      = theParticleIterator->value()->GetProcessManager()->GetProcessList();
+    for (G4int i=0; i<processVector->length(); i++)
+      (*processVector)[i]->DumpInfo();
+      
+    G4cout << G4endl;  
+  }  
+}