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