/[PAMELA software]/PamVMC/src/PamVMCStack.cxx
ViewVC logotype

Annotation of /PamVMC/src/PamVMCStack.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Fri Jun 12 18:39:32 2009 UTC (15 years, 5 months ago) by pam-rm2
Branch: MAIN
CVS Tags: v1r0, HEAD
Changes since 1.2: +0 -0 lines
- Introduced user-defined names of output files and random seeds number.
Users can do it use options of PamVMCApplication constructor:
PamVMCApplication(const char* name,  const char *title, const char*
filename="pamtest", Int_t seed=0).
The Random object that I use is TRandom3 object which has astronomical
large period (in case of default initialization 0). All random generators
in the code use this object by calling of gRandom singleton which keeps
it.

- Corrected TOF digitization routine. No problems with TDC hits due to
hadronic interactions anymore.

- Some small changes was done to compile code under Root 5.23. +
geant4_vmc v. 2.6 without any warnings

- Some classes of PamG4RunConfiguartion was changed for geant4_vmc v.
2.6.Some obsolete classes was deleted as soon as developers implemented
regions.

- Navigation was changed from "geomRootToGeant4" to "geomRoot", because on
VMC web page written that as soon as Geant4 has no option ONLY/MANY
translation of overlapped geometry to Geant4 through VGM could be wrong.
I'd like to stay with Root navigation:
http://root.cern.ch/root/vmc/Geant4VMC.html. This should be default
option.

- New Tracker digitization routine written by Sergio was implemented

- PamVMC again became compatible with geant4_vmc v.2.5 and ROOT 5.20.
 The problem was that ROOT developers introduced in TVirtualMC class a new
method SetMagField and new base class:TVirtualMagField from which
user-defined classes shoukd be derived

1 nikolas 1.1 // $Id: PamVMCStack.cxx,v 1.0 2007/06/03
2     // Class PamVMCStack
3    
4 nikolas 1.2 #include <PamVMCParticle.h>
5 nikolas 1.1 #include <TClonesArray.h>
6     #include <TError.h>
7 nikolas 1.2 #include <TString.h>
8 nikolas 1.1 #include <Riostream.h>
9    
10     #include "PamVMCStack.h"
11    
12     ClassImp(PamVMCStack)
13    
14     PamVMCStack::PamVMCStack(Int_t size)
15     : fParticles(0),
16     fCurrentTrack(-1),
17     fNPrimary(0)
18     {
19 nikolas 1.2 fParticles = new TClonesArray("PamVMCParticle", size);
20 nikolas 1.1 }
21    
22     PamVMCStack::PamVMCStack()
23     : fParticles(0),
24     fCurrentTrack(-1),
25     fNPrimary(0)
26     {
27    
28    
29     }
30    
31     PamVMCStack::~PamVMCStack()
32     {
33    
34     if (fParticles) fParticles->Delete();
35     delete fParticles;
36     }
37    
38    
39     void PamVMCStack::PushTrack(Int_t toBeDone, Int_t parent, Int_t pdg,
40     Double_t px, Double_t py, Double_t pz, Double_t e,
41     Double_t vx, Double_t vy, Double_t vz, Double_t tof,
42     Double_t polx, Double_t poly, Double_t polz,
43 nikolas 1.2 TMCProcess mech, Int_t& ntr, Double_t weight,
44 nikolas 1.1 Int_t is)
45     {
46     // Creates a new particle with specified properties,
47     // adds it to the particles array (fParticles) and if not done to the
48     // stack (fStack).
49 nikolas 1.2 // Use PamVMCParticle::fMother[1] to store Track ID.
50 nikolas 1.1
51     const Int_t kFirstDaughter=-1;
52     const Int_t kLastDaughter=-1;
53    
54     TClonesArray& particlesRef = *fParticles;
55     Int_t trackId = GetNtrack();
56 nikolas 1.2 PamVMCParticle* particle
57 nikolas 1.1 = new(particlesRef[trackId])
58 nikolas 1.2 PamVMCParticle(pdg, is, parent, trackId, kFirstDaughter, kLastDaughter,
59 nikolas 1.1 px, py, pz, e, vx, vy, vz, tof);
60    
61     particle->SetPolarisation(polx, poly, polz);
62     particle->SetWeight(weight);
63     particle->SetUniqueID(mech);
64    
65     if (parent<0) fNPrimary++;
66    
67     if (toBeDone) fStack.push(particle);
68 nikolas 1.2 ntr=trackId-1;
69 nikolas 1.1 }
70    
71 nikolas 1.2 PamVMCParticle* PamVMCStack::PopNextTrack(Int_t& itrack)
72 nikolas 1.1 {
73     // Gets next particle for tracking from the stack.
74    
75     itrack = -1;
76     if (fStack.empty()) return 0;
77    
78 nikolas 1.2 PamVMCParticle* particle = fStack.top();
79 nikolas 1.1 fStack.pop();
80    
81     if (!particle) return 0;
82    
83     fCurrentTrack = particle->GetSecondMother();
84     itrack = fCurrentTrack;
85    
86     return particle;
87     }
88    
89 nikolas 1.2 PamVMCParticle* PamVMCStack::PopPrimaryForTracking(Int_t i)
90 nikolas 1.1 {
91     // Returns i-th particle in fParticles.
92    
93    
94     if (i < 0 || i >= fNPrimary)
95     Fatal("GetPrimaryForTracking", "Index out of range");
96    
97 nikolas 1.2 return (PamVMCParticle*)fParticles->At(i);
98 nikolas 1.1 }
99    
100     void PamVMCStack::Print(Option_t* /*option*/) const
101     {
102     // Prints info for all particles.
103    
104     cout << "PamVMCStack Info " << endl;
105     cout << "Total number of particles: " << GetNtrack() << endl;
106     cout << "Number of primary particles: " << GetNprimary() << endl;
107    
108 nikolas 1.2 for (Int_t i=0; i<GetNtrack(); i++){
109     GetParticle(i)->Print();
110    
111     }
112 nikolas 1.1 }
113    
114     void PamVMCStack::Reset()
115     {
116     // Deletes contained particles, resets particles array and stack.
117    
118     fCurrentTrack = -1;
119     fNPrimary = 0;
120 nikolas 1.2 fParticles->Clear("C");
121     fParticles->Compress();
122 nikolas 1.1 }
123    
124     void PamVMCStack::SetCurrentTrack(Int_t track)
125     {
126     // Sets the current track to a given value.
127    
128     fCurrentTrack = track;
129     }
130    
131     Int_t PamVMCStack::GetNtrack() const
132     {
133     // Returns the number of all tracks.
134    
135     return fParticles->GetEntriesFast();
136     }
137    
138     Int_t PamVMCStack::GetNprimary() const
139     {
140     // Returns the number of primary tracks.
141    
142     return fNPrimary;
143     }
144    
145 nikolas 1.2 PamVMCParticle* PamVMCStack::GetCurrentTrack() const
146 nikolas 1.1 {
147     // Returns the current track parent ID.
148    
149 nikolas 1.2 PamVMCParticle* current = GetParticle(fCurrentTrack);
150 nikolas 1.1
151     if (!current)
152     Warning("GetCurrentTrack", "Current track not found in the stack");
153    
154     return current;
155     }
156    
157     Int_t PamVMCStack::GetCurrentTrackNumber() const
158     {
159     // Returns the current track ID.
160    
161     return fCurrentTrack;
162     }
163    
164     Int_t PamVMCStack::GetCurrentParentTrackNumber() const
165     {
166     // Returns the current track parent ID.
167    
168 nikolas 1.2 PamVMCParticle* current = GetCurrentTrack();
169 nikolas 1.1
170     if (current)
171     return current->GetFirstMother();
172     else
173     return -1;
174     }
175    
176 nikolas 1.2 PamVMCParticle* PamVMCStack::GetParticle(Int_t id) const
177 nikolas 1.1 {
178     // Returns id-th particle in fParticles.
179    
180 nikolas 1.2 if (id < 0 || id >= fParticles->GetEntriesFast()){
181     TString e="Index out of range ";
182     e+=id;
183     // Fatal("GetParticle", "Index out of range");
184     Fatal("GetParticle", e.Data());
185     }
186     return (PamVMCParticle*)fParticles->At(id);
187 nikolas 1.1 }
188    
189    

  ViewVC Help
Powered by ViewVC 1.1.23