// $Id$
// Category: physics
//
+// Author: I. Hrivnacova
+//
+// Class TG4G3PhysicsManager
+// -------------------------
// See the class description in the header file.
#include "TG4G3PhysicsManager.h"
#include "TG4G3CutVector.h"
#include "TG4G3ControlVector.h"
#include "TG4G3Defaults.h"
+#include "TG4G3Units.h"
#include <G4ParticleDefinition.hh>
#include <G4VProcess.hh>
TG4G3PhysicsManager::TG4G3PhysicsManager()
: fLock(false),
fCutVector(0),
- fControlVector(0)
+ fControlVector(0),
+ fIsCutVector(0),
+ fIsControlVector(0)
{
//
if (fgInstance) {
fgInstance = this;
+ // create vector of kinetic energy cut values
+ fCutVector = new TG4G3CutVector();
+
+ // create vector of control process control values
+ fControlVector = new TG4G3ControlVector();
+
// initialize fIsCutVector
- fIsCutVector = new TG4boolVector;
+ 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 fIsControlVector
fIsControlVector = new TG4boolVector;
- //for (i=0; i<kNofParticlesWSP; i++) fIsControlVector->insert(false);
for (i=0; i<kNofParticlesWSP; i++) fIsControlVector->push_back(false);
-
- // define fCutNameVector, fControlNameVector
- FillG3CutNameVector();
- FillG3ControlNameVector();
}
//_____________________________________________________________________________
//_____________________________________________________________________________
TG4G3PhysicsManager::~TG4G3PhysicsManager() {
//
- delete fIsCutVector;
+// delete fIsCutVector;
delete fIsControlVector;
}
// private methods
-//_____________________________________________________________________________
-void TG4G3PhysicsManager::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 TG4G3PhysicsManager::FillG3ControlNameVector()
-{
-// Defines fControlNameVector.
-// ---
-
- fG3ControlNameVector.insert("PAIR");
- fG3ControlNameVector.insert("COMP");
- fG3ControlNameVector.insert("PHOT");
- fG3ControlNameVector.insert("PFIS");
- fG3ControlNameVector.insert("DRAY");
- fG3ControlNameVector.insert("ANNI");
- fG3ControlNameVector.insert("BREM");
- fG3ControlNameVector.insert("HADR");
- fG3ControlNameVector.insert("MUNU");
- fG3ControlNameVector.insert("DCAY");
- fG3ControlNameVector.insert("LOSS");
- fG3ControlNameVector.insert("MULS");
-}
-
//_____________________________________________________________________________
void TG4G3PhysicsManager::SetCut(TG4G3Cut cut, G4double cutValue)
{
// Sets kinetic energy cut (in a G3-like way).
// ---
- if (!fCutVector) {
- // create vector of kinetic energy cut values
- fCutVector = new TG4G3CutVector();
- }
- fCutVector->SetG3Cut(cut, cutValue);
+ fCutVector->SetCut(cut, cutValue);
SwitchIsCutVector(cut);
}
//_____________________________________________________________________________
-void TG4G3PhysicsManager::SetProcess(TG4G3Control control, G4int controlValue)
+void TG4G3PhysicsManager::SetProcess(TG4G3Control control,
+ TG4G3ControlValue controlValue)
{
// Sets control process control (in a G3-like way).
// ---
-
- if (!fControlVector) {
- // create vector of control process control values
- fControlVector = new TG4G3ControlVector;
+
+ if (control == kDRAY || control == kLOSS) {
+ SwitchIsCutVector(kDCUTE);
+ SwitchIsCutVector(kDCUTM);
}
- fControlVector->SetG3Control(control, controlValue);
+
+ fControlVector->SetControl(control, controlValue, *fCutVector);
}
+
//_____________________________________________________________________________
void TG4G3PhysicsManager::SwitchIsCutVector(TG4G3Cut cut)
{
break;
case kCUTELE:
(*fIsCutVector)[kElectron] = true;
+ (*fIsCutVector)[kEplus] = true;
break;
case kDCUTE:
(*fIsCutVector)[kElectron] = true;
}
}
-//_____________________________________________________________________________
-TG4G3Cut TG4G3PhysicsManager::GetG3Cut(G4String cutName)
-{
-// Retrieves corresponding TG4G3Cut 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;
-}
-
-//_____________________________________________________________________________
-TG4G3Control TG4G3PhysicsManager::GetG3Control(G4String controlName)
-{
-// Retrieves corresponding TG4G3Control constant from the controlName.
-// ---
-
- if (controlName == fG3ControlNameVector[kPAIR]) return kPAIR;
- else if (controlName == fG3ControlNameVector[kCOMP]) return kCOMP;
- else if (controlName == fG3ControlNameVector[kPHOT]) return kPHOT;
- else if (controlName == fG3ControlNameVector[kPFIS]) return kPFIS;
- else if (controlName == fG3ControlNameVector[kDRAY]) return kDRAY;
- else if (controlName == fG3ControlNameVector[kANNI]) return kANNI;
- else if (controlName == fG3ControlNameVector[kBREM]) return kBREM;
- else if (controlName == fG3ControlNameVector[kHADR]) return kHADR;
- else if (controlName == fG3ControlNameVector[kMUNU]) return kMUNU;
- else if (controlName == fG3ControlNameVector[kDCAY]) return kDCAY;
- else if (controlName == fG3ControlNameVector[kLOSS]) return kLOSS;
- else if (controlName == fG3ControlNameVector[kMULS]) return kMULS;
- else return kNoG3Controls;
-}
-
// public methods
//_____________________________________________________________________________
// ---
// convert cut name -> TG4G3Cut
- cut = GetG3Cut(name);
+ cut = TG4G3CutVector::GetCut(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)) {
+ // get tolerance from TG4G3CutVector in G3 units
+ G4double tolerance = TG4G3CutVector::Tolerance()/ TG4G3Units::Energy();
+ if (abs(value - (*fCutVector)[cut]) > tolerance) {
SwitchIsCutVector(cut);
return true;
}
//_____________________________________________________________________________
G4bool TG4G3PhysicsManager::CheckControlWithTheVector(G4String name,
- G4double value, TG4G3Control& control)
+ G4double value, TG4G3Control& control,
+ TG4G3ControlValue& controlValue)
{
// Retrieves corresponding TG4G3Control from the name and
// in case the value is different from the value in controlVector
// ---
// convert control name -> TG4G3Control
- control = GetG3Control(name);
+ control = TG4G3ControlVector::GetControl(name);
+
+ // convert double value -> TG4G3ControlValue
+ controlValue = TG4G3ControlVector::GetControlValue(value, control);
// set switch vector element only if the value
// is different from the value in controlVector
if (control !=kNoG3Controls) {
- if (!(fControlVector) || (abs(value - (*fControlVector)[control]) > 0.01)) {
+ if (controlValue != (*fControlVector)[control]) {
SwitchIsControlVector(control);
return true;
}
// ---
// convert cut name -> TG4G3Cut
- cut = GetG3Cut(name);
+ cut = TG4G3CutVector::GetCut(name);
// set switch vector element only if the value
// is different from G3 default
if (cut !=kNoG3Cuts) {
- if (!TG4G3Defaults::IsDefaultCut(cut, value)) {
+ if (!fG3Defaults.IsDefaultCut(cut, value)) {
SwitchIsCutVector(cut);
return true;
}
//_____________________________________________________________________________
G4bool TG4G3PhysicsManager::CheckControlWithG3Defaults(G4String name,
- G4double value, TG4G3Control& control)
+ G4double value, TG4G3Control& control,
+ TG4G3ControlValue& controlValue)
{
// Retrieves corresponding TG4G3Control from the name and
// in case the value is different from the G3 default value
// ---
// convert control name -> TG4G3Control
- control = GetG3Control(name);
+ control = TG4G3ControlVector::GetControl(name);
+
+ // convert double value -> TG4G3ControlValue
+ controlValue = TG4G3ControlVector::GetControlValue(value, control);
// set switch vector element only if the value
// is different from G3 default
if (control !=kNoG3Controls) {
- if (!TG4G3Defaults::IsDefaultControl(control, value)) {
+ if (!fG3Defaults.IsDefaultControl(control, controlValue)) {
SwitchIsControlVector(control);
return true;
}
// ---
CheckLock();
- if (!fCutVector) {
- // create vector of kinetic energy cut values
- fCutVector = new TG4G3CutVector();
- }
fCutVector->SetG3Defaults();
}
// ---
CheckLock();
- if (!fControlVector) {
- // create vector of control process control values
- fControlVector = new TG4G3ControlVector;
- }
fControlVector->SetG3Defaults();
}
// Returns true if any special cut value is set.
// ---
+
for (G4int i=0; i<kNofParticlesWSP; i++)
{ if ((*fIsCutVector)[i]) return true; }
}
//_____________________________________________________________________________
-void TG4G3PhysicsManager::GetG3ParticleWSPName(G4int particleWSP,
- G4String& name) const
+G4String TG4G3PhysicsManager::GetG3ParticleWSPName(G4int particleWSP) const
{
-// Fills the passed name with the name/type of particle specified
-// by TG4G3ParticleWSP constant.
+// Returns the name of the particle specified by TG4G3ParticleWSP constant.
// (See TG4G3ParticleWSP.h, too.)
// ---
switch (particleWSP) {
case kGamma:
- name = "Gamma";
+ return "Gamma";
break;
case kElectron:
- name = "Electron";
+ return "Electron";
break;
case kEplus:
- name = "Eplus";
+ return "Eplus";
break;
case kNeutralHadron:
- name = "NeutralHadron";
+ return "NeutralHadron";
break;
case kChargedHadron:
- name = "ChargedHadron";
+ return "ChargedHadron";
break;
case kMuon:
- name = "Muon";
+ return "Muon";
break;
case kAny:
- name = "Any";
+ return "Any";
break;
case kNofParticlesWSP:
- name = "NoSP";
+ return "NoSP";
break;
default:
G4String text = "TG4G3PhysicsManager::GetG3ParticleWSPName:\n";
text = text + " Wrong particleWSP.";
TG4Globals::Exception(text);
- break;
+ return "";
}
}