8fa22343eb6c4feb6b65b84ace40e631fb8a6a50
[u/mrichter/AliRoot.git] / JETAN / AliJetEventParticles.cxx
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
17 ClassImp(AliJetEventParticles)
18
19 AliJetEventParticles::AliJetEventParticles(Int_t size) :
20   fNParticles(0),
21   fParticles(new TClonesArray("AliJetParticle",size)),
22   fVertexX(0.),
23   fVertexY(0.),
24   fVertexZ(0.),
25   fTrials(0),
26   fNJets(0),
27   fNUQJets(0),
28   fXJet(-1),
29   fYJet(-1)
30 {
31   // Default Constructor
32   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
33   for (Int_t i = 0; i < 10; i++) 
34     for (Int_t j = 0; j < 4; j++) {
35       fJets[j][i]=0;    // Trigger jets
36       fUQJets[j][i]=0;  // Unquenched trigger jets
37     }
38 }
39
40 AliJetEventParticles::AliJetEventParticles(const AliJetEventParticles& source) :
41   TObject(source), 
42   fNParticles(source.fNParticles),
43   fParticles(new TClonesArray("AliJetParticle",source.fNParticles)),
44   fVertexX(source.GetVertexX()),
45   fVertexY(source.GetVertexY()),
46   fVertexZ(source.GetVertexZ()),
47   fTrials(source.Trials()),
48   fNJets(source.NTriggerJets()),
49   fNUQJets(source.NUQTriggerJets()),
50   fXJet(source.GetXJet()),
51   fYJet(source.GetXJet())
52 {
53   //copy constructor
54   for(Int_t i =0; i<fNParticles; i++)
55     {
56       const AliJetParticle *kjp=(const AliJetParticle *)source.fParticles->At(i);
57       new((*fParticles)[i]) AliJetParticle(*(kjp));
58     }
59   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
60   for (Int_t i = 0; i < 10; i++) 
61     for (Int_t j = 0; j < 4; j++) {
62       fJets[j][i]=0;    // Trigger jets
63       fUQJets[j][i]=0;  // Unquenched trigger jets
64     }
65   source.GetZQuench(fZquench);
66   for (Int_t i = 0; i < NTriggerJets(); i++){
67     source.TriggerJet(i,fJets[0][i],fJets[1][i],fJets[2][i],fJets[3][i]);
68   }
69   for (Int_t i = 0; i < NUQTriggerJets(); i++){
70     source.UQJet(i,fUQJets[0][i],fUQJets[1][i],fUQJets[2][i],fUQJets[3][i]);
71   }
72 }
73
74 AliJetEventParticles::~AliJetEventParticles()
75 {
76   //destructor   
77   Reset();
78   delete fParticles;
79 }
80
81 void  AliJetEventParticles::Reset(Int_t size)
82 {
83   //deletes all particles from the event
84   if(fParticles) fParticles->Clear();
85   if(size>=0) fParticles->Expand(size);
86   fNParticles = 0;
87
88   fVertexX=0.;
89   fVertexY=0.;
90   fVertexZ=0.;
91   fTrials=0;
92   fNJets=0;
93   fNUQJets=0;
94   fXJet=-1;
95   fYJet=-1;
96   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
97   for (Int_t i = 0; i < 10; i++) 
98     for (Int_t j = 0; j < 4; j++) {
99       fJets[j][i]=0;    // Trigger jets
100       fUQJets[j][i]=0;  // Unquenched trigger jets
101     }
102
103
104 void AliJetEventParticles::AddParticle(AliJetParticle* part)
105 {
106   //Adds new particle to the event
107   fParticles->AddAt(part,fNParticles++);
108 }
109
110 void AliJetEventParticles::AddParticle(const AliJetParticle* part)
111 {
112   //Adds new particle to the event
113   new((*fParticles)[fNParticles++]) AliJetParticle(*part);
114 }
115
116 void AliJetEventParticles::AddParticle(const TParticle* part,Int_t idx, Int_t l)
117 {
118   //Adds new particle to the event
119   new((*fParticles)[fNParticles++]) AliJetParticle(part,idx,l);
120 }
121
122 void AliJetEventParticles::AddParticle(Float_t px, Float_t py, Float_t pz, 
123                               Float_t etot, Int_t idx, Int_t l)
124 {
125   //Adds new particle to the event
126   new((*fParticles)[fNParticles++]) AliJetParticle(px,py,pz,etot,idx,l); 
127 }
128
129 void AliJetEventParticles::AddParticle(Float_t px, Float_t py, Float_t pz, Float_t etot, Int_t idx, Int_t l,
130                               Float_t pt, Float_t phi, Float_t eta)
131 {
132   //Adds new particle to the event
133   new((*fParticles)[fNParticles++]) AliJetParticle(px,py,pz,etot,idx,l,pt,phi,eta); 
134 }
135
136 const AliJetParticle* AliJetEventParticles::GetParticleSafely(Int_t n)
137 {
138   //returns nth particle with range check
139   if( (n<0) || (fNParticles<=n) ) return 0;
140   return (const AliJetParticle*)fParticles->At(n);
141 }
142
143 void AliJetEventParticles::AddJet(Float_t px, Float_t py, Float_t pz, Float_t e)
144 {
145   //
146   //  Add a jet 
147   //
148   if (fNJets < 10) {
149     fJets[0][fNJets] = px;
150     fJets[1][fNJets] = py;
151     fJets[2][fNJets] = pz;
152     fJets[3][fNJets] = e;
153     fNJets++;
154   } else {
155     printf("\nWarning: More than 10 jets triggered !!\n");
156   }
157 }
158
159 void AliJetEventParticles::AddJet(Float_t p[4])
160 {
161   //
162   //  Add a jet 
163   //
164   if (fNJets < 10) {
165     fJets[0][fNJets] = p[0];
166     fJets[1][fNJets] = p[1];
167     fJets[2][fNJets] = p[2];
168     fJets[3][fNJets] = p[3];
169     fNJets++;
170   } else {
171     printf("\nWarning: More than 10 jets triggered !!\n");
172   }
173 }
174
175 void AliJetEventParticles::AddUQJet(Float_t px, Float_t py, Float_t pz, Float_t e)
176 {
177   //
178   //  Add a jet 
179   //
180   if (fNUQJets < 10) {
181     fUQJets[0][fNUQJets] = px;
182     fUQJets[1][fNUQJets] = py;
183     fUQJets[2][fNUQJets] = pz;
184     fUQJets[3][fNUQJets] = e;
185     fNUQJets++;
186   } else {
187     printf("\nWarning: More than 10 jets triggered !!\n");
188   }
189 }
190
191 void AliJetEventParticles::AddUQJet(Float_t p[4])
192 {
193   //
194   //  Add a jet 
195   //
196   if (fNUQJets < 10) {
197     fUQJets[0][fNUQJets] = p[0];
198     fUQJets[1][fNUQJets] = p[1];
199     fUQJets[2][fNUQJets] = p[2];
200     fUQJets[3][fNUQJets] = p[3];
201     fNUQJets++;
202   } else {
203     printf("\nWarning: More than 10 jets triggered !!\n");
204   }
205 }
206
207 void AliJetEventParticles::SetZQuench(Double_t z[4])
208 {
209   //
210   // Set quenching fraction
211   //
212   for (Int_t i = 0; i < 4; i++) fZquench[i] = z[i];
213 }
214
215 void AliJetEventParticles::GetZQuench(Double_t z[4]) const
216 {
217   //
218   // Get quenching fraction
219   //
220   for (Int_t i = 0; i < 4; i++) z[i] = fZquench[i];
221 }
222
223 void AliJetEventParticles::TriggerJet(Int_t i, Float_t p[4]) const
224 {
225   //
226   // Give back jet #i
227   //
228   if (i >= fNJets) {
229     printf("\nWarning: TriggerJet, index out of Range!!\n");
230   } else {
231     p[0] = fJets[0][i];
232     p[1] = fJets[1][i];
233     p[2] = fJets[2][i];
234     p[3] = fJets[3][i];
235   }
236 }
237
238 void AliJetEventParticles::TriggerJet(Int_t i, Float_t &p1, Float_t &p2, Float_t &p3, Float_t &E) const
239 {
240   //
241   // Give back jet #i
242   //
243   if (i >= fNJets) {
244     printf("\nWarning: TriggerJet, index out of Range!!\n");
245   } else {
246     p1 = fJets[0][i];
247     p2 = fJets[1][i];
248     p3 = fJets[2][i];
249     E  = fJets[3][i];
250   }
251 }
252
253 void AliJetEventParticles::UQJet(Int_t i, Float_t p[4]) const
254 {
255   //
256   // Give back jet #i
257   //
258   if (i >= fNUQJets) {
259     printf("\nWarning: Unquenched Jets, index out of Range!!\n");
260   } else {
261     p[0] = fUQJets[0][i];
262     p[1] = fUQJets[1][i];
263     p[2] = fUQJets[2][i];
264     p[3] = fUQJets[3][i];
265   }
266 }
267
268 void AliJetEventParticles::UQJet(Int_t i, Float_t &p1, Float_t &p2, Float_t &p3, Float_t &E) const
269 {
270   //
271   // Give back jet #i
272   //
273   if (i >= fNUQJets) {
274     printf("\nWarning: Unquenched Jets, index out of Range!!\n");
275   } else {
276     p1 = fUQJets[0][i];
277     p2 = fUQJets[1][i];
278     p3 = fUQJets[2][i];
279     E = fUQJets[3][i];
280   }
281 }
282
283 void AliJetEventParticles::SetXYJet(Double_t x, Double_t y)
284 {
285   //
286   //  Add jet production point
287   //
288   fXJet = x; 
289   fYJet = y; 
290 }
291
292 void AliJetEventParticles::Print(Option_t* /*t*/) const
293 {
294   cout << "--- AliJetEventParticles ---" << endl;
295   if(fHeader.Length()) cout << fHeader.Data() << endl;
296   cout << "Particles in Event: " << fNParticles << endl;
297   if(fNUQJets){
298     cout << "Unquenched Jets: " << fNUQJets << endl;
299     for(Int_t i = 0; i<fNUQJets; i++){
300       Float_t x=fUQJets[0][i];
301       Float_t y=fUQJets[1][i];
302       Float_t z=fUQJets[2][i];
303       Float_t e=fUQJets[3][i];
304       Float_t ptj=TMath::Sqrt(x*x+y*y);
305       Float_t thj=TMath::ATan2(ptj,z);
306       Float_t etaj=-TMath::Log(TMath::Tan(thj/2));
307       Float_t phj=TMath::Pi()+TMath::ATan2(-y,-x);
308       Float_t et=e*TMath::Sin(thj);
309       cout << i << " " << et << " " << etaj << " " << phj << endl;
310     }
311   }
312   if(fNJets){
313     cout << "Triggered Jets: " << fNJets << endl;
314     for(Int_t i = 0; i<fNJets; i++){
315       Float_t x=fJets[0][i];
316       Float_t y=fJets[1][i];
317       Float_t z=fJets[2][i];
318       Float_t e=fJets[3][i];
319       Float_t ptj=TMath::Sqrt(x*x+y*y);
320       Float_t thj=TMath::ATan2(ptj,z);
321       Float_t etaj=-TMath::Log(TMath::Tan(thj/2));
322       Float_t phj=TMath::Pi()+TMath::ATan2(-y,-x);
323       Float_t et=e*TMath::Sin(thj);
324       cout << i << " " << et << " " << etaj << " " << phj << endl;
325     }
326   }
327
328 }
329