]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4PhysicsConstructorSpecialCuts.cxx
Coding Rule violations corrected.
[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   : TG4VPhysicsConstructor(name) {
29 //
30 }
31
32 //_____________________________________________________________________________
33 TG4PhysicsConstructorSpecialCuts::TG4PhysicsConstructorSpecialCuts(
34                                      G4int verboseLevel,
35                                      const G4String& name)
36   : TG4VPhysicsConstructor(name, verboseLevel) {
37 //
38 }
39
40 //_____________________________________________________________________________
41 TG4PhysicsConstructorSpecialCuts::~TG4PhysicsConstructorSpecialCuts() {
42 //
43 }
44
45 // protected methods
46
47 //_____________________________________________________________________________
48 void TG4PhysicsConstructorSpecialCuts::ConstructParticle()
49 {
50 // The particles are constructed in the 
51 // TG4ModularPhysicsList.
52 // ---
53 }
54
55 //_____________________________________________________________________________
56 void TG4PhysicsConstructorSpecialCuts::ConstructProcess()
57 {
58 // Adds TG4SpecialCuts "process" that activates
59 // the kinetic energy cuts defined in 
60 // the vector of cuts (PhysicsManager::fCutVector) or in TG4Limits.
61 // ---
62
63   TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
64
65   if (g3PhysicsManager->IsSpecialCuts())
66   {
67     TG4boolVector* isCutVector = g3PhysicsManager->GetIsCutVector(); 
68
69     theParticleIterator->reset();
70     while ((*theParticleIterator)())
71     {
72       G4ParticleDefinition* particle = theParticleIterator->value();
73       TG4G3ParticleWSP particleWSP 
74         = g3PhysicsManager->GetG3ParticleWSP(particle);
75       G4String name =
76         g3PhysicsManager->GetG3ParticleWSPName(particleWSP);
77       
78       // uncomment this to see all particles "WSP"
79       //G4cout << "Iterating particle: " 
80       //       << particle->GetParticleName() << " " << particleWSP << " "
81       //       << name << G4endl;
82
83       if ((particleWSP !=kNofParticlesWSP) && 
84           ((*isCutVector)[particleWSP])) {
85         // special process is created in case
86         // cutVector (vector of kinetic energy cuts) is set
87         // or the special cut is set by TG4Limits
88   
89         // check if process already exists
90         G4String processName = "specialCutFor" + name;
91         G4VProcess* process = g3PhysicsManager->FindProcess(processName);
92         if (!process) {
93           switch (particleWSP) {
94             case kGamma:
95               process = new TG4SpecialCutsForGamma(processName);
96               break;
97             case kElectron:
98               process = new TG4SpecialCutsForElectron(processName);
99               break;
100             case kEplus:  
101               process = new TG4SpecialCutsForEplus(processName);
102               break;
103             case kChargedHadron:  
104               process = new TG4SpecialCutsForChargedHadron(processName);
105               break;
106             case kNeutralHadron:  
107               process = new TG4SpecialCutsForNeutralHadron(processName);
108               break;
109             case kMuon:  
110               process = new TG4SpecialCutsForMuon(processName);
111               break;
112             case kAny:
113               process = new TG4SpecialCutsForOther(processName);
114               break;
115           }  
116         }
117         // add process to particle
118         particle->GetProcessManager()->AddDiscreteProcess(process);
119       }
120     }
121
122     if (VerboseLevel() > 0) {
123       G4cout << "###  Special Cuts constructed. " << G4endl;
124       G4cout << "     Special cuts process is defined for: " << G4endl 
125              << "     ";
126       for (G4int i=0; i<kAny; i++) {
127         if ((*isCutVector)[i]) 
128           G4cout << g3PhysicsManager->GetG3ParticleWSPName(i) << " ";
129       }  
130       G4cout << G4endl;
131     }  
132   }
133 }
134
135