]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
major upgrade: separated TG4ParticlesManager, TG4G3PhysicsManager (now aggregated)
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 13 Feb 2001 14:37:55 +0000 (14:37 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 13 Feb 2001 14:37:55 +0000 (14:37 +0000)
TGeant4/TG4PhysicsManager.cxx
TGeant4/TG4PhysicsManager.h

index 0acdd7c44954712347da15e86ef86f731dc5014b..4cb69f2efdcc866b6c73526fa4bede1d96045016 100644 (file)
@@ -4,23 +4,32 @@
 // See the class description in the header file.
 
 #include "TG4PhysicsManager.h"
-#include "TG4PhysicsList.h"
-#include "TG4CutVector.h"
-#include "TG4FlagVector.h"
-#include "TG4G3Defaults.h"
+#include "TG4ParticlesManager.h"
+#include "TG4G3PhysicsManager.h"
+#include "TG4PhysicsConstructorEM.h"
+#include "TG4PhysicsConstructorOptical.h"
+#include "TG4PhysicsConstructorHadron.h"
+#include "TG4PhysicsConstructorSpecialCuts.h"
+#include "TG4PhysicsConstructorSpecialControls.h"
+#include "TG4G3Cut.h"
+#include "TG4G3Control.h"
 
 #include <G4ParticleDefinition.hh>
 #include <G4VProcess.hh>
+#include <G4VModularPhysicsList.hh>
 
 #include <TDatabasePDG.h>
 
 TG4PhysicsManager* TG4PhysicsManager::fgInstance = 0;
 
-TG4PhysicsManager::TG4PhysicsManager()
-  : fLock(false),
-    fPhysicsList(0),
-    fCutVector(0),
-    fFlagVector(0) 
+TG4PhysicsManager::TG4PhysicsManager(G4VModularPhysicsList* physicsList)
+  : fPhysicsList(physicsList),
+    fSetEMPhysics(true),
+    fSetOpticalPhysics(false),
+    fSetHadronPhysics(false),
+    fSetSpecialCutsPhysics(false),
+    fSetSpecialControlsPhysics(false)
+
 { 
 //
   if (fgInstance) {
@@ -29,26 +38,23 @@ TG4PhysicsManager::TG4PhysicsManager()
   }
       
   fgInstance = this;  
+  
+  // create particles manager
+  fParticlesManager = new TG4ParticlesManager();
       
-  // initialize fIsCutVector 
-  fIsCutVector = new TG4boolVector;
-  G4int i;
-  //for (i=0; i<kNofParticlesWSP; i++) fIsCutVector->insert(false);  
-  for (i=0; i<kNofParticlesWSP; i++) fIsCutVector->push_back(false);
-
-  // initialize fIsFlagVector 
-  fIsFlagVector = new TG4boolVector;
-  //for (i=0; i<kNofParticlesWSP; i++) fIsFlagVector->insert(false);
-  for (i=0; i<kNofParticlesWSP; i++) fIsFlagVector->push_back(false);
-
-  // define fCutNameVector, fFlagNameVector
-  FillG3CutNameVector();
-  FillG3FlagNameVector();
+  // create G3 physics manager
+  fG3PhysicsManager = new TG4G3PhysicsManager();
 
   // fill process name map
   FillProcessMap();
 }
 
+TG4PhysicsManager::TG4PhysicsManager(){
+//
+  delete fParticlesManager;
+  delete fG3PhysicsManager;
+}
+
 TG4PhysicsManager::TG4PhysicsManager(const TG4PhysicsManager& right) {
 // 
   TG4Globals::Exception(
@@ -57,8 +63,6 @@ TG4PhysicsManager::TG4PhysicsManager(const TG4PhysicsManager& right) {
 
 TG4PhysicsManager::~TG4PhysicsManager() {
 //
-  delete fIsCutVector;
-  delete fIsFlagVector;
 }
 
 // operators
@@ -77,54 +81,6 @@ TG4PhysicsManager::operator=(const TG4PhysicsManager& right)
           
 // private methods
 
-void TG4PhysicsManager::LockException() const
-{
-// Gives exception in case of attempt to modified physics
-// setup after physics manager was locked.
-// ---
-
-  G4String text = "TG4PhysicsManager: \n";
-  text = text + "    It is too late to change physics setup. \n";
-  text = text + "    PhysicsManager has been already locked.";
-  TG4Globals::Exception(text);
-}
-
-void TG4PhysicsManager::FillG3CutNameVector()
-{
-// Defines fCutNameVector.
-// ---
-
-  fG3CutNameVector.insert("CUTGAM");
-  fG3CutNameVector.insert("CUTELE");
-  fG3CutNameVector.insert("CUTNEU");
-  fG3CutNameVector.insert("CUTHAD");
-  fG3CutNameVector.insert("CUTMUO");
-  fG3CutNameVector.insert("BCUTE");
-  fG3CutNameVector.insert("BCUTM"); 
-  fG3CutNameVector.insert("DCUTE");
-  fG3CutNameVector.insert("DCUTM");
-  fG3CutNameVector.insert("PPCUTM");
-}
-
-void TG4PhysicsManager::FillG3FlagNameVector() 
-{
-// Defines fFlagNameVector.
-// ---
-
-  fG3FlagNameVector.insert("PAIR");
-  fG3FlagNameVector.insert("COMP");
-  fG3FlagNameVector.insert("PHOT");
-  fG3FlagNameVector.insert("PFIS");
-  fG3FlagNameVector.insert("DRAY");
-  fG3FlagNameVector.insert("ANNI");
-  fG3FlagNameVector.insert("BREM");
-  fG3FlagNameVector.insert("HADR");
-  fG3FlagNameVector.insert("MUNU");
-  fG3FlagNameVector.insert("DCAY");
-  fG3FlagNameVector.insert("LOSS");
-  fG3FlagNameVector.insert("MULS");
-}
-
 void TG4PhysicsManager::FillProcessMap()
 {
 // Fills fProcessMap.
@@ -245,105 +201,79 @@ void TG4PhysicsManager::FillProcessMap()
 }  
 
 
-G4int TG4PhysicsManager::GetPDGEncoding(G4ParticleDefinition* particle)
+// public methods
+
+void TG4PhysicsManager::BuildPhysics()
 {
-// Returns the PDG code of particle;
-// if standard PDG code is not defined the TDatabasePDG
-// is used.
+// Empty function - not needed in G4.
+// (Physics is built within /run/initialize.)
 // ---
 
-  // get PDG encoding from G4 particle definition
-  G4int pdgEncoding = particle->GetPDGEncoding();
+  TG4Globals::Warning(
+    "TG4PhysicsManager::BuildPhysics: is empty function in G4 MC.");
+}    
 
-  if (pdgEncoding == 0) {
-    // get PDG encoding from TDatabasePDG
-  
-    // get particle name from the name map
-    G4String g4name = particle->GetParticleName();
-    G4String tname = fParticleNameMap.GetSecond(g4name);
-    if (tname == "Undefined") {
-      G4String text = "TG4PhysicsManager::GetPDGEncoding: \n";
-      text = text + "    Particle " + g4name;
-      text = text + " was not found in the name map.";
-      TG4Globals::Exception(text);
-    }  
-  
-    // get particle from TDatabasePDG
-    TDatabasePDG* pdgDB = TDatabasePDG::Instance();
-    TParticlePDG* particle = pdgDB->GetParticle(tname);
-    if (!particle) {
-      G4String text = "TG4PhysicsManager::GetPDGEncoding: \n";
-      text = text + "    Particle " + tname;
-      text = text + " was not found in TDatabasePDG.";
-      TG4Globals::Exception(text);
-    }  
-    
-    // get PDG encoding
-    pdgEncoding = particle->PdgCode();
-  }
-    
-  return pdgEncoding;  
-}  
-     
-AliMCProcess TG4PhysicsManager::GetMCProcess(const G4VProcess* process)
+void TG4PhysicsManager::CreatePhysicsConstructors()
 {
-// Returns the AliMCProcess code of the specified G4 process.
+// Creates the selected physics constructors
+// and registeres them in the modular physics list.
 // ---
-  if (!process) return kPNoProcess;
 
-  G4String name = process->GetProcessName();
-  G4int code = fProcessMap.GetSecond(name);
-  
-  if (code == 0) return kPNoProcess;
-  
-  return (AliMCProcess)code; 
-}
+  // electromagnetic physics
+  if (fSetEMPhysics) 
+    fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorEM());
 
-G4int TG4PhysicsManager::GetPDGEncoding(G4String particleName)
-{
-// Returns the PDG code of particle specified by name.
-// ---
+  // optical physics
+  if (fSetOpticalPhysics) 
+    fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorOptical());
 
-  G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
+  // hadron physics
+  if (fSetHadronPhysics) 
+    fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorHadron());
 
-  G4ParticleDefinition* particle = 0;  
-  particle = particleTable->FindParticle(particleName);
-  if (!particle) {    
-    G4String text = "TG4PhysicsManager::GetPDGEncoding:\n";
-    text = text + "   G4ParticleTable::FindParticle() " + particleName;
-    text = text + " failed.";
-    TG4Globals::Exception(text);
-  }    
+  if (fSetSpecialCutsPhysics) 
+    fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorSpecialCuts());
 
-  return GetPDGEncoding(particle);
-}  
-  
-void TG4PhysicsManager::SetCut(TG3Cut cut, G4double cutValue)
-{  
-// Sets kinetic energy cut (in a G3-like way).
+  if (fSetSpecialControlsPhysics) 
+    fPhysicsList->RegisterPhysics(new TG4PhysicsConstructorSpecialControls());
+
+         // all created physics constructors are deleted
+        // in the G4VModularPhysicsList destructor
+}    
+
+void TG4PhysicsManager::SetCut(const char* cutName, Float_t cutValue)
+{
+// Sets the specified cut.
 // ---
 
-  if (!fCutVector) {
-    // create vector of kinetic energy cut values  
-    fCutVector = new TG4CutVector();
+  fG3PhysicsManager->CheckLock();
+  TG4G3Cut g3Cut = fG3PhysicsManager->GetG3Cut(cutName);
+  if (g3Cut != kNoG3Cuts)
+    fG3PhysicsManager->SetCut(g3Cut, cutValue);
+  else {   
+    G4String text = "TG4PhysicsManager::SetCut:\n";
+    text = text + "    Parameter " + cutName;
+    text = text + " is not implemented.";
+    TG4Globals::Warning(text);
   }  
-  fCutVector->SetG3Cut(cut, cutValue);
-  SwitchIsCutVector(cut);
 }  
-
-void TG4PhysicsManager::SetProcess(TG3Flag flag, G4int flagValue)
+  
+void TG4PhysicsManager::SetProcess(const char* controlName, Int_t controlValue)
 {
-// Sets control process flag (in a G3-like way).
+// Sets the specified process control.
 // ---
 
-  if (!fFlagVector) {
-    // create vector of control process flag values
-    fFlagVector = new TG4FlagVector;
+  fG3PhysicsManager->CheckLock();
+  TG4G3Control control = fG3PhysicsManager->GetG3Control(controlName);
+  if (control != kNoG3Controls)
+    fG3PhysicsManager->SetProcess(control, controlValue);
+  else {   
+    G4String text = "TG4PhysicsManager::SetProcess:\n";
+    text = text + "    Parameter " + controlName;
+    text = text + " is not implemented.";
+    TG4Globals::Warning(text);
   }  
-  fFlagVector->SetG3Flag(flag, flagValue);
-} 
-
+}  
 
 Float_t TG4PhysicsManager::Xsec(char* ch, Float_t p1, Int_t i1, Int_t i2)
 {
@@ -422,228 +352,14 @@ void  TG4PhysicsManager::DefineParticles()
   // end of "common" implementation
   // ======
 
-  // map G4 particle names to TDatabasePDG names
-  // (the map is built only for particles that have not
-  //  defined standard PDG encoding)
-  
-  fParticleNameMap.Add("deuteron","Deuteron");
-  fParticleNameMap.Add("triton",  "Triton");
-  fParticleNameMap.Add("alpha",   "Alpha");
-  fParticleNameMap.Add("He3",     "HE3");
-  fParticleNameMap.Add("opticalphoton","Cherenkov");
-  // fParticleNameMap.Add("???","FeedbackPhoton");
-  fParticleNameMap.Add("geantino", "Rootino");
-  
-  // map G4 particle names to TDatabasePDG encodings
-  fParticlePDGMap.Add("deuteron", GetPDGEncoding("deuteron"));
-  fParticlePDGMap.Add("triton", GetPDGEncoding("triton"));
-  fParticlePDGMap.Add("alpha", GetPDGEncoding("alpha"));
-  fParticlePDGMap.Add("He3", GetPDGEncoding("He3") );
-  fParticlePDGMap.Add("opticalphoton", GetPDGEncoding("opticalphoton"));
-  // fParticlePDGMap.Add("???","FeedbackPhoton");
-  fParticleNameMap.Add("geantino", GetPDGEncoding("geantino"));
-
-  // add verbose
-  G4cout << "Particle maps have been filled." << G4endl;
-  //fParticleNameMap.PrintAll();
-  //fParticlePDGMap.PrintAll();
-}    
-
-void TG4PhysicsManager::SwitchIsCutVector(TG3Cut cut)
-{
-// Updates the vector of booleans (fIsCutVector) for the specified cut.
-// ---
-
-  switch (cut) {
-    case kCUTGAM: 
-           (*fIsCutVector)[kGamma] = true; 
-           break;
-    case kBCUTE:
-           (*fIsCutVector)[kGamma] = true; 
-           break;
-    case kBCUTM:
-           (*fIsCutVector)[kGamma] = true; 
-           break;
-    case kCUTELE:
-           (*fIsCutVector)[kElectron] = true; 
-           break;
-    case kDCUTE:
-           (*fIsCutVector)[kElectron] = true; 
-           break;
-    case kDCUTM:
-           (*fIsCutVector)[kElectron] = true; 
-           break;
-    case kCUTNEU:
-           (*fIsCutVector)[kNeutralHadron] = true; 
-           break;
-    case kCUTHAD:
-           (*fIsCutVector)[kChargedHadron] = true; 
-           break;
-    case kCUTMUO:
-           (*fIsCutVector)[kMuon] = true; 
-           break;
-    default:
-           break;
-  }
-}
-
-void TG4PhysicsManager::SwitchIsFlagVector(TG3Flag flag)
-{
-// Updates the vector of booleans (fIsFlagVector) for the specified flag.
-// ---
-
-  switch (flag) {
-    case kPAIR: 
-           // gamma
-           (*fIsFlagVector)[kGamma] = true; 
-           break;
-    case kCOMP:
-           // gamma
-           (*fIsFlagVector)[kGamma] = true; 
-          break;
-    case kPHOT:
-           // gamma
-           (*fIsFlagVector)[kGamma] = true; 
-          break;
-    case kPFIS:
-           // gamma
-           (*fIsFlagVector)[kGamma] = true; 
-          break;
-    case kDRAY:        
-           // all charged particles
-           (*fIsFlagVector)[kElectron] = true; 
-           (*fIsFlagVector)[kEplus] = true; 
-           (*fIsFlagVector)[kChargedHadron] = true; 
-           (*fIsFlagVector)[kMuon] = true; 
-          break;
-    case kANNI:
-          // e+ only
-           (*fIsFlagVector)[kEplus] = true; 
-          break;
-    case kBREM:
-          // e-/e+, muons
-           (*fIsFlagVector)[kElectron] = true; 
-           (*fIsFlagVector)[kEplus] = true; 
-           (*fIsFlagVector)[kMuon] = true; 
-          break;
-    case kHADR:
-          // hadrons
-           (*fIsFlagVector)[kNeutralHadron] = true; 
-           (*fIsFlagVector)[kChargedHadron] = true; 
-          break;
-    case kMUNU:
-           // muons
-           (*fIsFlagVector)[kMuon] = true; 
-          break;
-    case kDCAY:
-           // any
-           (*fIsFlagVector)[kAny] = true; 
-          break;
-    case kLOSS:
-           // all charged particles
-           (*fIsFlagVector)[kElectron] = true; 
-           (*fIsFlagVector)[kEplus] = true; 
-           (*fIsFlagVector)[kChargedHadron] = true; 
-           (*fIsFlagVector)[kMuon] = true; 
-          break;
-    case kMULS:
-           // all charged particles
-           (*fIsFlagVector)[kElectron] = true; 
-           (*fIsFlagVector)[kEplus] = true; 
-           (*fIsFlagVector)[kChargedHadron] = true; 
-           (*fIsFlagVector)[kMuon] = true; 
-          break;
-    default:
-          break;
-  }
-}
-
-TG3Cut TG4PhysicsManager::GetG3Cut(G4String cutName)
-{
-// Retrieves corresponding TG3Cut constant from the cutName.
-// ---
-
-  if      (cutName == fG3CutNameVector[kCUTGAM]) return kCUTGAM; 
-  else if (cutName == fG3CutNameVector[kBCUTE])  return kBCUTE; 
-  else if (cutName == fG3CutNameVector[kBCUTM])  return kBCUTM; 
-  else if (cutName == fG3CutNameVector[kCUTELE]) return kCUTELE;
-  else if (cutName == fG3CutNameVector[kDCUTE])  return kDCUTE;
-  else if (cutName == fG3CutNameVector[kDCUTM])  return kDCUTM;
-  else if (cutName == fG3CutNameVector[kCUTNEU]) return kCUTNEU;
-  else if (cutName == fG3CutNameVector[kCUTHAD]) return kCUTHAD;
-  else if (cutName == fG3CutNameVector[kCUTMUO]) return kCUTMUO;
-  else return kNoG3Cuts;
-}
-
-TG3Flag TG4PhysicsManager::GetG3Flag(G4String flagName)
-{
-// Retrieves corresponding TG3Flag constant from the flagName.
-// ---
-
-  if      (flagName == fG3FlagNameVector[kPAIR]) return kPAIR;
-  else if (flagName == fG3FlagNameVector[kCOMP]) return kCOMP;
-  else if (flagName == fG3FlagNameVector[kPHOT]) return kPHOT;
-  else if (flagName == fG3FlagNameVector[kPFIS]) return kPFIS;
-  else if (flagName == fG3FlagNameVector[kDRAY]) return kDRAY;
-  else if (flagName == fG3FlagNameVector[kANNI]) return kANNI;
-  else if (flagName == fG3FlagNameVector[kBREM]) return kBREM;
-  else if (flagName == fG3FlagNameVector[kHADR]) return kHADR;
-  else if (flagName == fG3FlagNameVector[kMUNU]) return kMUNU;
-  else if (flagName == fG3FlagNameVector[kDCAY]) return kDCAY;
-  else if (flagName == fG3FlagNameVector[kLOSS]) return kLOSS;
-  else if (flagName == fG3FlagNameVector[kMULS]) return kMULS;
-  else return kNoG3Flags;
-}
-
-// public methods
-
-void TG4PhysicsManager::BuildPhysics()
-{
-// Empty function - not needed in G4.
-// (Physics is built within /run/initialize.)
-
-  TG4Globals::Warning(
-    "TG4PhysicsManager::BuildPhysics: is empty function in G4 MC.");
+  fParticlesManager->MapParticles();
 }    
 
-void TG4PhysicsManager::SetCut(const char* cutName, Float_t cutValue)
-{
-// Sets the specified cut.
-// ---
-
-  if (fLock) LockException();
-  TG3Cut g3Cut = GetG3Cut(cutName);
-  if (g3Cut != kNoG3Cuts)
-    SetCut(g3Cut, cutValue);
-  else {   
-    G4String text = "TG4PhysicsManager::SetCut:\n";
-    text = text + "    Parameter " + cutName;
-    text = text + " is not implemented.";
-    TG4Globals::Warning(text);
-  }  
-}  
-  
-void TG4PhysicsManager::SetProcess(const char* flagName, Int_t flagValue)
-{
-// Sets the specified process control.
-// ---
-
-  if (fLock) LockException();
-  TG3Flag g3Flag = GetG3Flag(flagName);
-  if (g3Flag != kNoG3Flags)
-    SetProcess(g3Flag, flagValue);
-  else {   
-    G4String text = "TG4PhysicsManager::SetProcess:\n";
-    text = text + "    Parameter " + flagName;
-    text = text + " is not implemented.";
-    TG4Globals::Warning(text);
-  }  
-}  
 
 void TG4PhysicsManager::SetProcessActivation()
 {
 // (In)Activates built processes according
-// to the setup in fFlagVector.
+// to the setup in fControlVector.
 // ---
 
   if (fPhysicsList) {
@@ -657,247 +373,19 @@ void TG4PhysicsManager::SetProcessActivation()
   }
 }       
 
-G4int TG4PhysicsManager::GetPDGEncodingFast(G4ParticleDefinition* particle)
-{
-// Returns the PDG code of particle;
-// if standard PDG code is not defined the preregistred
-// fParticlePDGMap is used.
-// ---
-
-  // get PDG encoding from G4 particle definition
-  G4int pdgEncoding = particle->GetPDGEncoding();
-
-  if (pdgEncoding == 0) {
-    // use FParticlePDGMap if standard PDG code is not defined
-    G4String name = particle->GetParticleName();
-    pdgEncoding = fParticlePDGMap.GetSecond(name);
-  }
-    
-  return pdgEncoding;  
-}  
-     
-G4bool TG4PhysicsManager::CheckCutWithCutVector(G4String name, 
-                             G4double value, TG3Cut& cut)
-{
-// Retrieves corresponding TG3Cut from the name and 
-// in case the value is different from the value in cutVector
-// sets true the value of the fIsCutVector element 
-// corresponding to this cut and returns true; 
-// returns false otherwise.
-// ---
-
-  // convert cut name -> TG3Cut
-  cut = GetG3Cut(name);
-
-  // set switch vector element only if the value
-  // is different from the value in cutVector
-  if (cut !=kNoG3Cuts) {
-    // get tolerance from TG4G3Defaults in GeV
-    G4double tolerance = TG4G3Defaults::CutTolerance()/GeV;
-    if (!(fCutVector) || (abs(value - (*fCutVector)[cut]) > tolerance)) {
-      SwitchIsCutVector(cut);      
-      return true;
-    }  
-    else return false;  
-  }                     
-  return false;
-}
-
-G4bool TG4PhysicsManager::CheckFlagWithFlagVector(G4String name, 
-                              G4double value, TG3Flag& flag)
-{
-// Retrieves corresponding TG3Flag from the name and 
-// in case the value is different from the value in flagVector
-// sets true the value of the fIsFlagVector element 
-// corresponding to this flag and returns true; 
-// returns false otherwise.
-// ---
-
-  // convert flag name -> TG3Flag
-  flag = GetG3Flag(name);
-
-  // set switch vector element only if the value
-  // is different from the value in flagVector
-  if (flag !=kNoG3Flags) {
-    if (!(fFlagVector) || (abs(value - (*fFlagVector)[flag]) > 0.01)) {
-      SwitchIsFlagVector(flag);      
-      return true;
-    }  
-    else return false;  
-  }                     
-  return false;
-}
-
-G4bool TG4PhysicsManager::CheckCutWithG3Defaults(G4String name, 
-                              G4double value, TG3Cut& cut)
-{
-// Retrieves corresponding TG3Cut from the name and 
-// in case the value is different from the G3 default value
-// sets true the value of the SwitchCutVector element 
-// corresponding to this cut and returns true; 
-// returns false otherwise.
-// ---
-
-  // convert cut name -> TG3Cut
-  cut = GetG3Cut(name);
-
-  // set switch vector element only if the value
-  // is different from G3 default
-  if (cut !=kNoG3Cuts) {
-    if (!TG4G3Defaults::IsDefaultCut(cut, value)) {
-      SwitchIsCutVector(cut);      
-      return true;
-    }  
-    else return false;  
-  }                     
-  return false;
-}
-
-G4bool TG4PhysicsManager::CheckFlagWithG3Defaults(G4String name, 
-                              G4double value, TG3Flag& flag)
-{
-// Retrieves corresponding TG3Flag from the name and 
-// in case the value is different from the G3 default value
-// sets true the value of the SwitchFlagVector element 
-// corresponding to this flag and returns true; 
-// returns false otherwise.
-// ---
-
-  // convert flag name -> TG3Flag
-  flag = GetG3Flag(name);
-
-  // set switch vector element only if the value
-  // is different from G3 default
-  if (flag !=kNoG3Flags) {
-    if (!TG4G3Defaults::IsDefaultFlag(flag, value)) {
-      SwitchIsFlagVector(flag);      
-      return true;
-    }  
-    else return false;  
-  }                     
-  return false;
-}
-
-void TG4PhysicsManager::SetG3DefaultCuts() 
-{
-// Sets G3 default values of kinetic energy cuts.
-// ---
-
-  if (fLock) LockException();
-  if (!fCutVector) {
-    // create vector of kinetic energy cut values  
-    fCutVector = new TG4CutVector();
-  }  
-  fCutVector->SetG3Defaults();
-}
-
-void TG4PhysicsManager::SetG3DefaultProcesses()
-{
-// Sets G3 default values of control process flags.
-// ---
-
-  if (fLock) LockException();
-  if (!fFlagVector) {
-    // create vector of control process flag values
-    fFlagVector = new TG4FlagVector;
-  }  
-  fFlagVector->SetG3Defaults();
-}  
-
-G4bool TG4PhysicsManager::IsSpecialCuts() const
-{
-// Returns true if any special cut value is set.
-// ---
 
-  for (G4int i=0; i<kNofParticlesWSP; i++)
-  {  if ((*fIsCutVector)[i]) return true; }
-
-  return false;
-}
-
-G4bool TG4PhysicsManager::IsSpecialFlags() const
+AliMCProcess TG4PhysicsManager::GetMCProcess(const G4VProcess* process)
 {
-// Returns true if any special flag value is set.
+// Returns the AliMCProcess code of the specified G4 process.
 // ---
+  if (!process) return kPNoProcess;
 
-  for (G4int i=0; i<kNofParticlesWSP; i++)
-  {  if ((*fIsFlagVector)[i]) return true; }
-
-  return false;
+  G4String name = process->GetProcessName();
+  G4int code = fProcessMap.GetSecond(name);
+  
+  if (code == 0) return kPNoProcess;
+  
+  return (AliMCProcess)code; 
 }
 
-TG3ParticleWSP TG4PhysicsManager::GetG3ParticleWSP(
-                                  G4ParticleDefinition* particle) const 
-{
-// Returns TG3ParticleWSP constant for the specified particle.
-// (See TG3ParticleWSP.h, too.)
-// ---
-
-  G4String name = particle->GetParticleName();     
-  G4String pType = particle->GetParticleType();
-    
-  if (name == "gamma") {
-    return kGamma;
-  }  
-  else if (name == "e-") {    
-    return kElectron;
-  }  
-  else if (name == "e+") {   
-    return kEplus;
-  }  
-  else if (( pType == "baryon" || pType == "meson" || pType == "nucleus" )) {
-    if (particle->GetPDGCharge() == 0) { 
-      return kNeutralHadron;
-    }
-    else  
-      return kChargedHadron;
-  }    
-  else if ( name == "mu-" || name == "mu+" ) {
-    return kMuon;
-  }  
-  else {
-    return kNofParticlesWSP;
-  }    
-}  
-
-void TG4PhysicsManager::GetG3ParticleWSPName(G4int particleWSP,
-                                             G4String& name) const 
-{
-// Fills the passed name with the name/type of particle specified
-// by TG3ParticleWSP constant.
-// (See TG3ParticleWSP.h, too.)
-// ---
-
-  switch (particleWSP) {
-    case kGamma:
-      name = "Gamma";
-      break;
-    case kElectron:
-      name = "Electron";
-      break;
-    case kEplus:
-      name = "Eplus";
-      break;
-    case kNeutralHadron:
-      name = "NeutralHadron";
-      break;
-    case kChargedHadron:
-      name = "ChargedHadron";
-      break;
-    case kMuon:
-      name = "Muon";
-      break;
-    case kAny:
-      name = "Any";
-      break;
-    case kNofParticlesWSP:
-      name = "NoSP";
-      break;
-    default:
-      G4String text = "TG4PhysicsList::GetG3ParticleWSPName:\n";
-      text = text + "   Wrong particleWSP."; 
-      TG4Globals::Exception(text);
-      break;      
-  }
-}  
-
index 18949a81a93a60cd034f0b836b5540f9ef2c4a44..0554d4c03a4c124f36eb30f72c533b5f41f07b27 100644 (file)
 #include "TG4Globals.h"
 #include "TG4NameMap.h"
 #include "TG4IntMap.h"
-#include "TG3Cut.h"
-#include "TG3Flag.h"
-#include "TG3ParticleWSP.h"
 
 #include <Rtypes.h>
 #include "AliMCProcess.h"
 
 #include <globals.hh>
 
-
-class TG4CutVector;
-class TG4FlagVector;
-class TG4PhysicsList;
+class AliDecayer;
+class TG4ParticlesManager;
+class TG4G3PhysicsManager;
 
 class G4ParticleDefinition;
 class G4VProcess;
+class G4VModularPhysicsList;
 
 class TG4PhysicsManager
 {
   public:
-    TG4PhysicsManager();
+    TG4PhysicsManager(G4VModularPhysicsList* physicsList);
     // --> protected
+    // TG4PhysicsManager();
     // TG4PhysicsManager(const TG4PhysicsManager& right);
     virtual ~TG4PhysicsManager();
 
@@ -43,9 +41,13 @@ class TG4PhysicsManager
 
     // set methods
     void SetCut(const char* cutName, Float_t cutValue);
-    void SetProcess(const char* flagName, Int_t flagValue);
+    void SetProcess(const char* controlName, Int_t controlValue);
     Float_t Xsec(char* reac, Float_t energy, Int_t part, Int_t mate);
+    void SetExternalDecayer(AliDecayer* decayer);
+     
+    // get methods
+    AliDecayer* Decayer() const;
+
         // particle table usage         
     Int_t IdFromPDG(Int_t pdgID) const;
     Int_t PDGFromId(Int_t mcID) const;
@@ -55,36 +57,23 @@ class TG4PhysicsManager
     // methods for Geant4 only 
     //
 
-    void Lock();     
+    void CreatePhysicsConstructors();
     void SetProcessActivation();  
-    G4int GetPDGEncodingFast(G4ParticleDefinition* particle);
     AliMCProcess GetMCProcess(const G4VProcess* process);
-    G4bool CheckCutWithCutVector(
-             G4String name, G4double value, TG3Cut& cut);   
-    G4bool CheckFlagWithFlagVector(
-             G4String name, G4double value, TG3Flag& flag); 
-    G4bool CheckCutWithG3Defaults(
-             G4String name, G4double value, TG3Cut& cut); 
-    G4bool CheckFlagWithG3Defaults(
-             G4String name, G4double value, TG3Flag& flag); 
 
     // set methods
-    void SetPhysicsList(TG4PhysicsList* physicsList);
-    void SetG3DefaultCuts();                    
-    void SetG3DefaultProcesses();               
+    void SetPhysicsList(G4VModularPhysicsList* physicsList);
+    void SetEMPhysics(G4bool value);
+    void SetOpticalPhysics(G4bool value);
+    void SetHadronPhysics(G4bool value);
+    void SetSpecialCutsPhysics(G4bool value);
+    void SetSpecialControlsPhysics(G4bool value);
     
     // get methods
-    G4bool IsLock() const;   
-    G4bool IsSpecialCuts() const;
-    G4bool IsSpecialFlags() const;
-    TG4CutVector*  GetCutVector() const;    
-    TG4FlagVector* GetFlagVector() const;   
-    TG4boolVector* GetIsCutVector() const;
-    TG4boolVector* GetIsFlagVector() const;
-    TG3ParticleWSP GetG3ParticleWSP(G4ParticleDefinition* particle) const;
-    void GetG3ParticleWSPName(G4int particleWSP, G4String& name) const;
-    
+    G4VModularPhysicsList* GetPhysicsList() const; 
+   
   protected:
+    TG4PhysicsManager();
     TG4PhysicsManager(const TG4PhysicsManager& right);
 
     // operators
@@ -92,42 +81,25 @@ class TG4PhysicsManager
 
   private:
     // methods
-    void LockException() const;
-    void FillG3CutNameVector();
-    void FillG3FlagNameVector();
     void FillProcessMap();
-    G4int GetPDGEncoding(G4ParticleDefinition* particle);
-    G4int GetPDGEncoding(G4String particleName);
-
-    // set methods
-    void SetCut(TG3Cut cut, G4double cutValue);
-    void SetProcess(TG3Flag flag, G4int flagValue);
-    void SwitchIsCutVector(TG3Cut cut);
-    void SwitchIsFlagVector(TG3Flag flag);
-
-    // get methods
-    TG3Cut  GetG3Cut(G4String cutName);
-    TG3Flag GetG3Flag(G4String flagName);
 
     // static data members
     static TG4PhysicsManager*  fgInstance; //this instance
     
     // data members
-    G4bool           fLock;         //if true: cut/flag vectors cannot be modified
-    TG4PhysicsList*  fPhysicsList;  //physics list
-    TG4CutVector*    fCutVector;    //TG4CutVector  
-    TG4FlagVector*   fFlagVector;   //TG4FlagVector
-    TG4boolVector*   fIsCutVector;  //vector of booleans which cuts are set
-    TG4boolVector*   fIsFlagVector; //vector of booleans which flags are set
-    TG4StringVector  fG3CutNameVector;  //vector of cut parameters names     
-    TG4StringVector  fG3FlagNameVector; //vector of process control parameters
-                                        //names   
-    TG4NameMap       fParticleNameMap;  //the mapping between G4 particle names
-                                        //and TDatabasePDG names 
-    TG4IntMap        fParticlePDGMap;   //the mapping between G4 particle names
-                                        //and TDatabasePDG codes
-    TG4IntMap        fProcessMap;       //the mapping between G4 process names
-                                        //and AliMCProcess codes
+    TG4ParticlesManager*   fParticlesManager; //particles manager
+    TG4G3PhysicsManager*   fG3PhysicsManager; //G3 physics manager
+    G4VModularPhysicsList* fPhysicsList; //physics list
+    AliDecayer*            fDecayer;     //external decayer
+    TG4IntMap              fProcessMap;  //the mapping between G4 process names
+                                         //and AliMCProcess codes
+    G4bool  fSetEMPhysics;          //electromagnetic physics control
+    G4bool  fSetOpticalPhysics;     //optical physics control
+    G4bool  fSetHadronPhysics;      //hadron physics control
+    G4bool  fSetSpecialCutsPhysics; //special cuts process control 
+                                    //(under development)                  
+    G4bool  fSetSpecialControlsPhysics;//special controls process control
+                                    //(under development)
 };
 
 // inline methods
@@ -135,26 +107,26 @@ class TG4PhysicsManager
 inline TG4PhysicsManager* TG4PhysicsManager::Instance() 
 { return fgInstance; }
 
-inline void TG4PhysicsManager::Lock() 
-{ fLock = true; }
-
-inline void TG4PhysicsManager::SetPhysicsList(TG4PhysicsList* physicsList)
+inline void TG4PhysicsManager::SetPhysicsList(G4VModularPhysicsList* physicsList)
 { fPhysicsList = physicsList; }
 
-inline G4bool TG4PhysicsManager::IsLock() const
-{ return fLock; }
+inline void TG4PhysicsManager::SetEMPhysics(G4bool value)
+{ fSetEMPhysics = value; }
+
+inline void TG4PhysicsManager::SetOpticalPhysics(G4bool value)
+{ fSetOpticalPhysics = value; }
 
-inline TG4CutVector* TG4PhysicsManager::GetCutVector() const
-{ return fCutVector; }
+inline void TG4PhysicsManager::SetHadronPhysics(G4bool value)
+{ fSetHadronPhysics = value; }
 
-inline TG4FlagVector* TG4PhysicsManager::GetFlagVector() const
-{ return fFlagVector; }
+inline void TG4PhysicsManager::SetSpecialCutsPhysics(G4bool value)
+{ fSetSpecialCutsPhysics = value; }
 
-inline TG4boolVector* TG4PhysicsManager::GetIsCutVector() const
-{ return fIsCutVector; }
+inline void TG4PhysicsManager::SetSpecialControlsPhysics(G4bool value)
+{ fSetSpecialControlsPhysics = value; }
 
-inline TG4boolVector* TG4PhysicsManager::GetIsFlagVector() const
-{ return fIsFlagVector; }
+inline G4VModularPhysicsList* TG4PhysicsManager::GetPhysicsList() const
+{ return fPhysicsList; }
 
 #endif //TG4_PHYSICS_MANAGER_H