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