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