Added set method.
[u/mrichter/AliRoot.git] / JETAN / AliJetEventParticles.cxx
CommitLineData
d7c6ab14 1// $Id$
2
3//__________________________________________________________
4///////////////////////////////////////////////////////////////////
5//
6// class AliJetEventParticles
7//
8// loizides@ikf.uni-frankfurt.de
9//
10///////////////////////////////////////////////////////////////////
11
12#include <Riostream.h>
13#include <TClonesArray.h>
14#include "AliJetParticle.h"
15#include "AliJetEventParticles.h"
16
17ClassImp(AliJetEventParticles)
18
d7c6ab14 19AliJetEventParticles::AliJetEventParticles(Int_t size) :
962f5fc0 20 TObject(),
21 fHeader(),
d7c6ab14 22 fNParticles(0),
23 fParticles(new TClonesArray("AliJetParticle",size)),
24 fVertexX(0.),
25 fVertexY(0.),
04a02430 26 fVertexZ(0.),
27 fTrials(0),
28 fNJets(0),
29 fNUQJets(0),
30 fXJet(-1),
3bf434de 31 fYJet(-1),
32 fImpact(0.),
33 fNHardScatters(0),
34 fNwNwColl(0)
d7c6ab14 35{
04a02430 36 // Default Constructor
37 for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
38 for (Int_t i = 0; i < 10; i++)
39 for (Int_t j = 0; j < 4; j++) {
40 fJets[j][i]=0; // Trigger jets
41 fUQJets[j][i]=0; // Unquenched trigger jets
42 }
9e431626 43 for (Int_t i = 0; i < 5; i++){
44 fHard[i][0]=0;
45 fHard[i][1]=0;
46 }
d7c6ab14 47}
48
d7c6ab14 49AliJetEventParticles::AliJetEventParticles(const AliJetEventParticles& source) :
50 TObject(source),
962f5fc0 51 fHeader(),
d7c6ab14 52 fNParticles(source.fNParticles),
04a02430 53 fParticles(new TClonesArray("AliJetParticle",source.fNParticles)),
54 fVertexX(source.GetVertexX()),
55 fVertexY(source.GetVertexY()),
56 fVertexZ(source.GetVertexZ()),
57 fTrials(source.Trials()),
58 fNJets(source.NTriggerJets()),
59 fNUQJets(source.NUQTriggerJets()),
60 fXJet(source.GetXJet()),
3bf434de 61 fYJet(source.GetXJet()),
62 fImpact(source.GetImpact()),
63 fNHardScatters(source.GetNhard()),
64 fNwNwColl(source.GetNpart())
d7c6ab14 65{
66 //copy constructor
67 for(Int_t i =0; i<fNParticles; i++)
68 {
69 const AliJetParticle *kjp=(const AliJetParticle *)source.fParticles->At(i);
04a02430 70 new((*fParticles)[i]) AliJetParticle(*(kjp));
71 }
72 for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
73 for (Int_t i = 0; i < 10; i++)
74 for (Int_t j = 0; j < 4; j++) {
75 fJets[j][i]=0; // Trigger jets
76 fUQJets[j][i]=0; // Unquenched trigger jets
d7c6ab14 77 }
04a02430 78 source.GetZQuench(fZquench);
79 for (Int_t i = 0; i < NTriggerJets(); i++){
80 source.TriggerJet(i,fJets[0][i],fJets[1][i],fJets[2][i],fJets[3][i]);
81 }
82 for (Int_t i = 0; i < NUQTriggerJets(); i++){
83 source.UQJet(i,fUQJets[0][i],fUQJets[1][i],fUQJets[2][i],fUQJets[3][i]);
84 }
9e431626 85
86 source.Hard(0,fHard[0][0],fHard[1][0],fHard[2][0],fHard[3][0],fHard[4][0]);
87 source.Hard(1,fHard[0][1],fHard[1][1],fHard[2][1],fHard[3][1],fHard[4][1]);
d7c6ab14 88}
89
962f5fc0 90void AliJetEventParticles::Set(const AliJetEventParticles& source)
91{
92 source.Copy(*this);
93 fHeader=source.GetHeader();
94 fNParticles=source.fNParticles;
95 if(fParticles) delete fParticles;
96 fParticles=new TClonesArray("AliJetParticle",fNParticles);
97 fVertexX=source.GetVertexX();
98 fVertexY=source.GetVertexY();
99 fVertexZ=source.GetVertexZ();
100 fTrials=source.Trials();
101 fNJets=source.NTriggerJets();
102 fNUQJets=source.NUQTriggerJets();
103 fXJet=source.GetXJet();
104 fYJet=source.GetXJet();
105 fImpact=source.GetImpact();
106 fNHardScatters=source.GetNhard();
107 fNwNwColl=source.GetNpart();
108
109 for(Int_t i =0; i<fNParticles; i++)
110 {
111 const AliJetParticle *kjp=(const AliJetParticle *)source.fParticles->At(i);
112 new((*fParticles)[i]) AliJetParticle(*(kjp));
113 }
114 for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
115 for (Int_t i = 0; i < 10; i++)
116 for (Int_t j = 0; j < 4; j++) {
117 fJets[j][i]=0; // Trigger jets
118 fUQJets[j][i]=0; // Unquenched trigger jets
119 }
120 source.GetZQuench(fZquench);
121 for (Int_t i = 0; i < NTriggerJets(); i++){
122 source.TriggerJet(i,fJets[0][i],fJets[1][i],fJets[2][i],fJets[3][i]);
123 }
124 for (Int_t i = 0; i < NUQTriggerJets(); i++){
125 source.UQJet(i,fUQJets[0][i],fUQJets[1][i],fUQJets[2][i],fUQJets[3][i]);
126 }
127
128 source.Hard(0,fHard[0][0],fHard[1][0],fHard[2][0],fHard[3][0],fHard[4][0]);
129 source.Hard(1,fHard[0][1],fHard[1][1],fHard[2][1],fHard[3][1],fHard[4][1]);
130}
131
d7c6ab14 132AliJetEventParticles::~AliJetEventParticles()
133{
134 //destructor
135 Reset();
136 delete fParticles;
137}
138
d7c6ab14 139void AliJetEventParticles::Reset(Int_t size)
140{
962f5fc0 141 fHeader="";
d7c6ab14 142 //deletes all particles from the event
d7c6ab14 143 if(fParticles) fParticles->Clear();
144 if(size>=0) fParticles->Expand(size);
145 fNParticles = 0;
d7c6ab14 146
04a02430 147 fVertexX=0.;
148 fVertexY=0.;
149 fVertexZ=0.;
150 fTrials=0;
151 fNJets=0;
152 fNUQJets=0;
153 fXJet=-1;
154 fYJet=-1;
3bf434de 155 fImpact=0.;
156 fNHardScatters=0;
157 fNwNwColl=0;
04a02430 158 for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
159 for (Int_t i = 0; i < 10; i++)
160 for (Int_t j = 0; j < 4; j++) {
161 fJets[j][i]=0; // Trigger jets
162 fUQJets[j][i]=0; // Unquenched trigger jets
163 }
9e431626 164 for (Int_t i = 0; i < 5; i++){
165 fHard[i][0]=0;
166 fHard[i][1]=0;
167 }
04a02430 168}
d7c6ab14 169
301a24f1 170void AliJetEventParticles::AddSignal(const AliJetEventParticles& source)
171{ //mark signal particles and add them to TClonesArray
172 //note that fNParticles still keeps only background particles
173
174 Int_t nSignalParts=source.GetNParticles();
175 for(Int_t i=0; i<nSignalParts; i++)
176 {
177 const AliJetParticle *kjp=source.GetParticle(i);
178
179 AliJetParticle *ap=new((*fParticles)[fNParticles+i]) AliJetParticle(*(kjp));
180 ap->SetType(-123); //mark pythia particle
181 }
182 for(Int_t i=nSignalParts+fNParticles;i<fParticles->GetEntriesFast();i++)
183 fParticles->RemoveAt(i);
184 //cout << fParticles->GetEntries() << " " << fNParticles << " " << nSignalParts << endl;
185
186 /* should we transform the vertex???
187 fVertexX=source.GetVertexX();
188 fVertexY=source.GetVertexY();
189 fVertexZ=source.GetVertexZ();
190 */
191 fTrials=source.Trials();
192 fNJets=source.NTriggerJets();
193 fNUQJets=source.NUQTriggerJets();
194 fXJet=source.GetXJet();
195 fYJet=source.GetXJet();
196
301a24f1 197 for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
198 for (Int_t i = 0; i < 10; i++)
199 for (Int_t j = 0; j < 4; j++) {
200 fJets[j][i]=0; // Trigger jets
201 fUQJets[j][i]=0; // Unquenched trigger jets
202 }
203 source.GetZQuench(fZquench);
204 for (Int_t i = 0; i < NTriggerJets(); i++){
205 source.TriggerJet(i,fJets[0][i],fJets[1][i],fJets[2][i],fJets[3][i]);
206 }
207 for (Int_t i = 0; i < NUQTriggerJets(); i++){
208 source.UQJet(i,fUQJets[0][i],fUQJets[1][i],fUQJets[2][i],fUQJets[3][i]);
209 }
210 source.Hard(0,fHard[0][0],fHard[1][0],fHard[2][0],fHard[3][0],fHard[4][0]);
211 source.Hard(1,fHard[0][1],fHard[1][1],fHard[2][1],fHard[3][1],fHard[4][1]);
212}
213
d7c6ab14 214void AliJetEventParticles::AddParticle(AliJetParticle* part)
215{
216 //Adds new particle to the event
217 fParticles->AddAt(part,fNParticles++);
218}
219
d7c6ab14 220void AliJetEventParticles::AddParticle(const AliJetParticle* part)
221{
222 //Adds new particle to the event
b2760c9e 223 new((*fParticles)[fNParticles++]) AliJetParticle(*part);
d7c6ab14 224}
225
301a24f1 226void AliJetEventParticles::AddParticle(const TParticle* part,Int_t idx, Int_t l, Int_t ncl)
d7c6ab14 227{
228 //Adds new particle to the event
301a24f1 229 new((*fParticles)[fNParticles++]) AliJetParticle(part,idx,l,ncl);
d7c6ab14 230}
231
d7c6ab14 232void AliJetEventParticles::AddParticle(Float_t px, Float_t py, Float_t pz,
301a24f1 233 Float_t etot, Int_t idx, Int_t l, Int_t ncl)
d7c6ab14 234{
235 //Adds new particle to the event
301a24f1 236 new((*fParticles)[fNParticles++]) AliJetParticle(px,py,pz,etot,idx,l,ncl);
d7c6ab14 237}
238
d7c6ab14 239void AliJetEventParticles::AddParticle(Float_t px, Float_t py, Float_t pz, Float_t etot, Int_t idx, Int_t l,
301a24f1 240 Int_t ncl, Float_t pt, Float_t phi, Float_t eta)
d7c6ab14 241{
242 //Adds new particle to the event
301a24f1 243 new((*fParticles)[fNParticles++]) AliJetParticle(px,py,pz,etot,idx,l,ncl,pt,phi,eta);
d7c6ab14 244}
245
d7c6ab14 246const AliJetParticle* AliJetEventParticles::GetParticleSafely(Int_t n)
247{
248 //returns nth particle with range check
249 if( (n<0) || (fNParticles<=n) ) return 0;
250 return (const AliJetParticle*)fParticles->At(n);
251}
252
04a02430 253void AliJetEventParticles::AddJet(Float_t px, Float_t py, Float_t pz, Float_t e)
254{
255 //
256 // Add a jet
257 //
258 if (fNJets < 10) {
259 fJets[0][fNJets] = px;
260 fJets[1][fNJets] = py;
261 fJets[2][fNJets] = pz;
262 fJets[3][fNJets] = e;
263 fNJets++;
264 } else {
265 printf("\nWarning: More than 10 jets triggered !!\n");
266 }
267}
268
269void AliJetEventParticles::AddJet(Float_t p[4])
270{
271 //
272 // Add a jet
273 //
274 if (fNJets < 10) {
275 fJets[0][fNJets] = p[0];
276 fJets[1][fNJets] = p[1];
277 fJets[2][fNJets] = p[2];
278 fJets[3][fNJets] = p[3];
279 fNJets++;
280 } else {
281 printf("\nWarning: More than 10 jets triggered !!\n");
282 }
283}
284
285void AliJetEventParticles::AddUQJet(Float_t px, Float_t py, Float_t pz, Float_t e)
286{
287 //
288 // Add a jet
289 //
290 if (fNUQJets < 10) {
291 fUQJets[0][fNUQJets] = px;
292 fUQJets[1][fNUQJets] = py;
293 fUQJets[2][fNUQJets] = pz;
294 fUQJets[3][fNUQJets] = e;
295 fNUQJets++;
296 } else {
297 printf("\nWarning: More than 10 jets triggered !!\n");
298 }
299}
300
301void AliJetEventParticles::AddUQJet(Float_t p[4])
302{
303 //
304 // Add a jet
305 //
306 if (fNUQJets < 10) {
307 fUQJets[0][fNUQJets] = p[0];
308 fUQJets[1][fNUQJets] = p[1];
309 fUQJets[2][fNUQJets] = p[2];
310 fUQJets[3][fNUQJets] = p[3];
311 fNUQJets++;
312 } else {
313 printf("\nWarning: More than 10 jets triggered !!\n");
314 }
315}
316
9e431626 317void AliJetEventParticles::AddHard(Int_t i,Float_t px, Float_t py, Float_t pz, Float_t e, Float_t type)
318{
319 //
320 // Add a had parton
321 //
322 if (i < 2) {
323 fHard[0][i] = px;
324 fHard[1][i] = py;
325 fHard[2][i] = pz;
326 fHard[3][i] = e;
327 fHard[4][i] = type;
328 } else {
329 printf("\nWarning: More than 2 partons !!\n");
330 }
331}
332
04a02430 333void AliJetEventParticles::SetZQuench(Double_t z[4])
334{
335 //
336 // Set quenching fraction
337 //
338 for (Int_t i = 0; i < 4; i++) fZquench[i] = z[i];
339}
340
341void AliJetEventParticles::GetZQuench(Double_t z[4]) const
342{
343 //
344 // Get quenching fraction
345 //
346 for (Int_t i = 0; i < 4; i++) z[i] = fZquench[i];
347}
348
349void AliJetEventParticles::TriggerJet(Int_t i, Float_t p[4]) const
350{
351 //
352 // Give back jet #i
353 //
354 if (i >= fNJets) {
355 printf("\nWarning: TriggerJet, index out of Range!!\n");
356 } else {
357 p[0] = fJets[0][i];
358 p[1] = fJets[1][i];
359 p[2] = fJets[2][i];
360 p[3] = fJets[3][i];
361 }
362}
363
364void AliJetEventParticles::TriggerJet(Int_t i, Float_t &p1, Float_t &p2, Float_t &p3, Float_t &E) const
365{
366 //
367 // Give back jet #i
368 //
369 if (i >= fNJets) {
370 printf("\nWarning: TriggerJet, index out of Range!!\n");
371 } else {
9e431626 372 p1 = fJets[0][i];
373 p2 = fJets[1][i];
374 p3 = fJets[2][i];
375 E = fJets[3][i];
04a02430 376 }
377}
378
379void AliJetEventParticles::UQJet(Int_t i, Float_t p[4]) const
380{
381 //
382 // Give back jet #i
383 //
384 if (i >= fNUQJets) {
385 printf("\nWarning: Unquenched Jets, index out of Range!!\n");
386 } else {
387 p[0] = fUQJets[0][i];
388 p[1] = fUQJets[1][i];
389 p[2] = fUQJets[2][i];
390 p[3] = fUQJets[3][i];
391 }
392}
393
394void AliJetEventParticles::UQJet(Int_t i, Float_t &p1, Float_t &p2, Float_t &p3, Float_t &E) const
395{
396 //
397 // Give back jet #i
398 //
399 if (i >= fNUQJets) {
400 printf("\nWarning: Unquenched Jets, index out of Range!!\n");
401 } else {
9e431626 402 p1 = fUQJets[0][i];
403 p2 = fUQJets[1][i];
404 p3 = fUQJets[2][i];
405 E = fUQJets[3][i];
406 }
407}
408
409void AliJetEventParticles::Hard(Int_t i, Float_t &p1, Float_t &p2, Float_t &p3, Float_t &E, Float_t &type) const
410{
411 //
412 // Give back jet #i
413 //
414 if (i >= 2) {
415 printf("\nWarning: Hard partons, index out of Range!!\n");
416 } else {
417 p1 = fHard[0][i];
418 p2 = fHard[1][i];
419 p3 = fHard[2][i];
420 E = fHard[3][i];
421 type = fHard[4][i];
04a02430 422 }
423}
424
3bf434de 425void AliJetEventParticles::Hard(Int_t i, Float_t p[4], Float_t &type) const
426{
427 //
428 // Give back jet #i
429 //
430 if (i >= 2) {
431 printf("\nWarning: Hard partons, index out of Range!!\n");
432 } else {
433 p[0] = fHard[0][i];
434 p[1] = fHard[1][i];
435 p[2] = fHard[2][i];
436 p[3] = fHard[3][i];
437 type = fHard[4][i];
438 }
439}
440
04a02430 441void AliJetEventParticles::SetXYJet(Double_t x, Double_t y)
442{
443 //
444 // Add jet production point
445 //
446 fXJet = x;
447 fYJet = y;
448}
d7c6ab14 449
450void AliJetEventParticles::Print(Option_t* /*t*/) const
451{
452 cout << "--- AliJetEventParticles ---" << endl;
453 if(fHeader.Length()) cout << fHeader.Data() << endl;
04a02430 454 cout << "Particles in Event: " << fNParticles << endl;
455 if(fNUQJets){
456 cout << "Unquenched Jets: " << fNUQJets << endl;
457 for(Int_t i = 0; i<fNUQJets; i++){
458 Float_t x=fUQJets[0][i];
459 Float_t y=fUQJets[1][i];
460 Float_t z=fUQJets[2][i];
461 Float_t e=fUQJets[3][i];
462 Float_t ptj=TMath::Sqrt(x*x+y*y);
463 Float_t thj=TMath::ATan2(ptj,z);
464 Float_t etaj=-TMath::Log(TMath::Tan(thj/2));
465 Float_t phj=TMath::Pi()+TMath::ATan2(-y,-x);
466 Float_t et=e*TMath::Sin(thj);
467 cout << i << " " << et << " " << etaj << " " << phj << endl;
468 }
469 }
470 if(fNJets){
471 cout << "Triggered Jets: " << fNJets << endl;
472 for(Int_t i = 0; i<fNJets; i++){
473 Float_t x=fJets[0][i];
474 Float_t y=fJets[1][i];
475 Float_t z=fJets[2][i];
476 Float_t e=fJets[3][i];
477 Float_t ptj=TMath::Sqrt(x*x+y*y);
478 Float_t thj=TMath::ATan2(ptj,z);
479 Float_t etaj=-TMath::Log(TMath::Tan(thj/2));
480 Float_t phj=TMath::Pi()+TMath::ATan2(-y,-x);
481 Float_t et=e*TMath::Sin(thj);
482 cout << i << " " << et << " " << etaj << " " << phj << endl;
483 }
484 }
485
d7c6ab14 486}