]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4PhysicsConstructorSpecialCuts.cxx
added Gsbool() method
[u/mrichter/AliRoot.git] / TGeant4 / TG4PhysicsConstructorSpecialCuts.cxx
1 // $Id$
2 // Category: physics
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class TG4PhysicsConstructorSpecialCuts
7 // --------------------------------------
8 // See the class description in the header file.
9
10 #include "TG4PhysicsConstructorSpecialCuts.h"
11 #include "TG4G3PhysicsManager.h"
12 #include "TG4SpecialCutsForGamma.h"
13 #include "TG4SpecialCutsForElectron.h"
14 #include "TG4SpecialCutsForEplus.h"
15 #include "TG4SpecialCutsForChargedHadron.h"
16 #include "TG4SpecialCutsForNeutralHadron.h"
17 #include "TG4SpecialCutsForMuon.h"
18 #include "TG4SpecialCutsForOther.h"
19
20 #include <G4ParticleDefinition.hh>
21 #include <G4ProcessManager.hh>
22 #include <G4VProcess.hh>
23
24
25 //_____________________________________________________________________________
26 TG4PhysicsConstructorSpecialCuts::TG4PhysicsConstructorSpecialCuts(
27                                      const G4String& name)
28   : G4VPhysicsConstructor(name)
29 {
30 //
31   SetVerboseLevel(1);
32 }
33
34 //_____________________________________________________________________________
35 TG4PhysicsConstructorSpecialCuts::~TG4PhysicsConstructorSpecialCuts() {
36 //
37 }
38
39 // protected methods
40
41 //_____________________________________________________________________________
42 void TG4PhysicsConstructorSpecialCuts::ConstructParticle()
43 {
44 // The particles are constructed in the 
45 // TG4ModularPhysicsList.
46 // ---
47 }
48
49 //_____________________________________________________________________________
50 void TG4PhysicsConstructorSpecialCuts::ConstructProcess()
51 {
52 // Adds TG4SpecialCuts "process" that activates
53 // the kinetic energy cuts defined in 
54 // the vector of cuts (PhysicsManager::fCutVector) or in TG4Limits.
55 // ---
56
57   TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
58
59   if (g3PhysicsManager->IsSpecialCuts())
60   {
61     TG4boolVector* isCutVector = g3PhysicsManager->GetIsCutVector(); 
62
63     theParticleIterator->reset();
64     while ((*theParticleIterator)())
65     {
66       G4ParticleDefinition* particle = theParticleIterator->value();
67       TG4G3ParticleWSP particleWSP 
68         = g3PhysicsManager->GetG3ParticleWSP(particle);
69       G4String name =
70         g3PhysicsManager->GetG3ParticleWSPName(particleWSP);
71       
72       // uncomment this to see all particles "WSP"
73       //G4cout << "Iterating particle: " 
74       //       << particle->GetParticleName() << " " << particleWSP << " "
75       //       << name << G4endl;
76
77       if ((particleWSP !=kNofParticlesWSP) && 
78           ((*isCutVector)[particleWSP])) {
79         // special process is created in case
80         // cutVector (vector of kinetic energy cuts) is set
81         // or the special cut is set by TG4Limits
82   
83         // check if process already exists
84         G4String processName = "specialCutFor" + name;
85         G4VProcess* process = g3PhysicsManager->FindProcess(processName);
86         if (!process) {
87           switch (particleWSP) {
88             case kGamma:
89               process = new TG4SpecialCutsForGamma(processName);
90               break;
91             case kElectron:
92               process = new TG4SpecialCutsForElectron(processName);
93               break;
94             case kEplus:  
95               process = new TG4SpecialCutsForEplus(processName);
96               break;
97             case kChargedHadron:  
98               process = new TG4SpecialCutsForChargedHadron(processName);
99               break;
100             case kNeutralHadron:  
101               process = new TG4SpecialCutsForNeutralHadron(processName);
102               break;
103             case kMuon:  
104               process = new TG4SpecialCutsForMuon(processName);
105               break;
106             case kAny:
107               process = new TG4SpecialCutsForOther(processName);
108               break;
109           }  
110         }
111         // add process to particle
112         particle->GetProcessManager()->AddDiscreteProcess(process);
113       }
114     }
115
116     if (verboseLevel>0) {
117       G4cout << "###  Special Cuts constructed. " << G4endl;
118       G4cout << "     Special cuts process is defined for: " << G4endl 
119              << "     ";
120       for (G4int i=0; i<kAny; i++) {
121         if ((*isCutVector)[i]) 
122           G4cout << g3PhysicsManager->GetG3ParticleWSPName(i) << " ";
123       }  
124       G4cout << G4endl;
125     }  
126   }
127 }
128
129