Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
UEvent.cxx
1
19#include <iostream>
20using namespace std;
21
22#include "TClonesArray.h"
23#include "TObject.h"
24#include "TString.h"
25
26#include "UEvent.h"
27#include "UParticle.h"
28
29
30//____________________________________________________________________
31//
32// UEvent
33//
34// Class for event description. Contains the particle array
35//
36
37
38//--------------------------------------------------------------------
39UEvent::UEvent() {
40 // Default constructor
41 fEventNr = 0;
42 fB = fPhi = 0.;
43 fNes = 1;
44 fStepNr = 0;
45 fStepT = 0.;
46 fNpa = 0;
47 fComment = "";
48 fParticles = new TClonesArray("UParticle", 100);
49}
50//--------------------------------------------------------------------
51
52
53//--------------------------------------------------------------------
54UEvent::UEvent(const UEvent& right) {
55 // Copy constructor
56 fEventNr = right.fEventNr;
57 fB = right.fB;
58 fPhi = right.fPhi;
59 fNes = right.fNes;
60 fStepNr = right.fStepNr;
61 fStepT = right.fStepT;
62 fComment = right.fComment;
63 fNpa = right.fNpa;
64 fParticles = new TClonesArray("UParticle", 100);
65 UParticle* p;
66 for (Int_t i = 0; i < fNpa; i++) {
67 p = (UParticle*) right.fParticles->At(i);
68 new ((*fParticles)[i]) UParticle(*p);
69 }
70}
71//--------------------------------------------------------------------
72
73//--------------------------------------------------------------------
74
75UEvent& UEvent::operator=(const UEvent& right) {
76 if (this != &right) {
77 fEventNr = right.fEventNr;
78 fB = right.fB;
79 fPhi = right.fPhi;
80 fNes = right.fNes;
81 fStepNr = right.fStepNr;
82 fStepT = right.fStepT;
83 fNpa = right.fNpa;
84 fComment = right.fComment;
85 fParticles->Clear();
86 UParticle* p;
87 for (Int_t i = 0; i < fNpa; i++) {
88 p = (UParticle*) right.fParticles->At(i);
89 new ((*fParticles)[i]) UParticle(*p);
90 }
91 }
92 return *this;
93}
94
95//--------------------------------------------------------------------
96
97//--------------------------------------------------------------------
98UEvent::~UEvent() {
99 // Destructor
100 Clear();
101 delete fParticles;
102}
103//--------------------------------------------------------------------
104
105
106//--------------------------------------------------------------------
107void UEvent::Print(Option_t* option) {
108 // Print data members to the standard output
109 cout << "---------------------------------------------" << endl
110 << "-I- Event -I-" << endl
111 << "Event number : " << fEventNr << endl
112 << "Impact parameter (fm) : " << fB << endl
113 << "Reaction plane angle (rad) : " << fPhi << endl
114 << "Number of time steps : " << fNes << endl
115 << "Time step number : " << fStepNr << endl
116 << "Time of the time step (fm) : " << fStepT << endl
117 << "Number of particles : " << fNpa << endl
118 << "Comment :\n"
119 << fComment << endl;
120 TString opt = option;
121 if (opt.Contains("all")) {
122 UParticle* particle;
123 for (Int_t iPa = 0; iPa < fNpa; iPa++) {
124 particle = (UParticle*) fParticles->At(iPa);
125 particle->Print(option);
126 }
127 }
128 cout << "---------------------------------------------" << endl;
129}
130//--------------------------------------------------------------------
131
132
133//--------------------------------------------------------------------
134UParticle* UEvent::GetParticle(Int_t index) const {
135 // Get pointer to the particle.
136 // index - index of the particle
137 if (index < 0) { return NULL; }
138 if (index >= fNpa) { return NULL; }
139 return ((UParticle*) fParticles->At(index));
140}
141//--------------------------------------------------------------------
142
143
144//--------------------------------------------------------------------
145void UEvent::AddParticle(Int_t index,
146 Int_t pdg,
147 Int_t status,
148 Int_t parent,
149 Int_t parentDecay,
150 Int_t mate,
151 Int_t decay,
152 Int_t child[2],
153 Double_t px,
154 Double_t py,
155 Double_t pz,
156 Double_t e,
157 Double_t x,
158 Double_t y,
159 Double_t z,
160 Double_t t,
161 Double_t weight) {
162 // Add particle to the array
163 new ((*fParticles)[fNpa])
164 UParticle(index, pdg, status, parent, parentDecay, mate, decay, child, px, py, pz, e, x, y, z, t, weight);
165 fNpa += 1;
166}
167//--------------------------------------------------------------------
168
169
170//--------------------------------------------------------------------
171void UEvent::AddParticle(Int_t index,
172 Int_t pdg,
173 Int_t status,
174 Int_t parent,
175 Int_t parentDecay,
176 Int_t mate,
177 Int_t decay,
178 Int_t child[2],
179 TLorentzVector mom,
180 TLorentzVector pos,
181 Double_t weight) {
182 // Add particle to the array
183 new ((*fParticles)[fNpa]) UParticle(index, pdg, status, parent, parentDecay, mate, decay, child, mom, pos, weight);
184 fNpa += 1;
185}
186//--------------------------------------------------------------------
187
188
189//--------------------------------------------------------------------
190void UEvent::AddParticle(const UParticle& particle) {
191 // Add particle to the array
192 new ((*fParticles)[fNpa]) UParticle(particle);
193 fNpa += 1;
194}
195//--------------------------------------------------------------------
196
197
198//--------------------------------------------------------------------
199void UEvent::SetParameters(Int_t eventNr,
200 Double_t b,
201 Double_t phi,
202 Int_t nes,
203 Int_t stepNr,
204 Double_t stepT,
205 const char* comment) {
206 // Set the event parameters
207 fEventNr = eventNr;
208 fB = b;
209 fPhi = phi;
210 fNes = nes;
211 fStepNr = stepNr;
212 fStepT = stepT;
213 fComment = comment;
214}
215//--------------------------------------------------------------------
216
217
218//--------------------------------------------------------------------
219void UEvent::Clear() {
220 // Remove the particles from the array and reset counter
221 fParticles->Clear();
222 fNpa = 0;
223}
224//--------------------------------------------------------------------
225
226
227//--------------------------------------------------------------------
228void UEvent::RemoveAt(Int_t i) {
229 // Remove one particle from the array.
230 // i - index of the particle.
231 // Array is automaticaly compressed afterwards, mind the indexing
232 fParticles->RemoveAt(i);
233 fParticles->Compress();
234 fNpa -= 1;
235}
236//--------------------------------------------------------------------