]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - EVGEN/AliDimuCombinator.cxx
Wrong comments removed from file
[u/mrichter/AliRoot.git] / EVGEN / AliDimuCombinator.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17$Log$
18*/
19
20//
21//
22//
23//
24#include "AliDimuCombinator.h"
25#include "AliRun.h"
26#include "TRandom.h"
27//
28ClassImp(AliDimuCombinator)
29//
30// Iterators
31//
32 TParticle* AliDimuCombinator::FirstMuon()
33 {
34 fimuon1=fimin1;
35 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
36 while(Type(fmuon1)!=5 && Type(fmuon1)!=6) {
37 fimuon1++;
38 if (fimuon1 >= fimax1) {fmuon1=0; break;}
39 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
40 }
41 return fmuon1;
42 }
43
44 TParticle* AliDimuCombinator::FirstMuonSelected()
45 {
46 TParticle * muon=FirstMuon();
47 while(muon!=0 && !Selected(muon)) {muon=NextMuon();}
48 return muon;
49 }
50
51
52 TParticle* AliDimuCombinator::NextMuon()
53 {
54 fimuon1++;
55 if (fimuon1>=fNParticle) {fmuon1 = 0; return fmuon1;}
56
57 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
58 while(Type(fmuon1)!=5 && Type(fmuon1)!=6) {
59 fimuon1++;
60 if (fimuon1>=fimax1) {fmuon1 = 0; break;}
61 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
62 }
63 return fmuon1;
64 }
65
66TParticle* AliDimuCombinator::NextMuonSelected()
67 {
68 TParticle * muon=NextMuon();
69 while(muon !=0 && !Selected(muon)) {muon=NextMuon();}
70 return muon;
71 }
72
73
74 void AliDimuCombinator::FirstPartner()
75 {
76 if (fimin1==fimin2) {
77 fimuon2=fimuon1+1;
78 } else {
79 fimuon2=fimin2;
80 }
81 if (fimuon2 >= fimax2) {fmuon2=0; return;}
82 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
83 while(Type(fmuon2)!=5 && Type(fmuon2)!=6) {
84 fimuon2++;
85 if (fimuon2 >= fimax2) {fmuon2=0; break;}
86 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
87 }
88 }
89void AliDimuCombinator::FirstPartnerSelected()
90{
91 FirstPartner();
92 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
93}
94
95
96 void AliDimuCombinator::NextPartner()
97 {
98 fimuon2++;
99 if (fimuon2>=fimax2) {fmuon2 = 0; return;}
100
101
102 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
103
104 while(Type(fmuon2)!=5 && Type(fmuon2)!=6) {
105 fimuon2++;
106 if (fimuon2>=fimax2) {fmuon2 = 0; break;}
107 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
108 }
109
110 }
111
112void AliDimuCombinator::NextPartnerSelected()
113{
114 NextPartner();
115 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
116}
117
118
119 TParticle* AliDimuCombinator::Partner()
120 {
121 return fmuon2;
122 }
123
124void AliDimuCombinator::FirstMuonPair(TParticle* & muon1, TParticle* & muon2)
125 {
126 FirstMuon();
127 FirstPartner();
128 muon1=fmuon1;
129 muon2=fmuon2;
130 }
131void AliDimuCombinator::NextMuonPair(TParticle* & muon1, TParticle* & muon2)
132 {
133 NextPartner();
134 if (!Partner()) {
135 NextMuon();
136 FirstPartner();
137 }
138 muon1=fmuon1;
139 muon2=fmuon2;
140 }
141void AliDimuCombinator::FirstMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
142 {
143 FirstMuonSelected();
144 FirstPartnerSelected();
145 muon1=fmuon1;
146 muon2=fmuon2;
147 }
148void AliDimuCombinator::NextMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
149 {
150 NextPartnerSelected();
151 if (!Partner()) {
152 NextMuonSelected();
153 FirstPartnerSelected();
154 }
155 muon1=fmuon1;
156 muon2=fmuon2;
157 }
158void AliDimuCombinator::ResetRange()
159{
160 fimin1=fimin2=0;
161 fimax1=fimax2=fNParticle;
162}
163
164void AliDimuCombinator::SetFirstRange(Int_t from, Int_t to)
165{
166 fimin1=from;
167 fimax1=to;
168 if (fimax1 > fNParticle) fimax1=fNParticle;
169}
170
171void AliDimuCombinator::SetSecondRange(Int_t from, Int_t to)
172{
173 fimin2=from;
174 fimax2=to;
175 if (fimax2 > fNParticle) fimax2=fNParticle;
176}
177//
178// Selection
179//
180
181Bool_t AliDimuCombinator::Selected(TParticle* part)
182{
183//
184//
185 if (part==0) {return 0;}
186
187 if (part->Pt() > fPtMin && part->Eta()>fEtaMin && part->Eta()<fEtaMax) {
188 return 1;
189 } else {
190 return 0;
191 }
192
193
194}
195
196Bool_t AliDimuCombinator::Selected(TParticle* part1, TParticle* part2)
197{
198 return Selected(part1)*Selected(part2);
199}
200//
201// Kinematics
202//
203Float_t AliDimuCombinator::Mass(TParticle* part1, TParticle* part2)
204{
205 Float_t px,py,pz,e;
206 px=part1->Px()+part2->Px();
207 py=part1->Py()+part2->Py();
208 pz=part1->Pz()+part2->Pz();
209 e =part1->Energy()+part2->Energy();
210 Float_t p=px*px+py*py+pz*pz;
211 if (e*e < p) {
212 return -1;
213 } else {
214 return TMath::Sqrt(e*e-p);
215 }
216}
217
218Float_t AliDimuCombinator::PT(TParticle* part1, TParticle* part2)
219{
220 Float_t px,py;
221 px=part1->Px()+part2->Px();
222 py=part1->Py()+part2->Py();
223 return TMath::Sqrt(px*px+py*py);
224}
225
226Float_t AliDimuCombinator::Pz(TParticle* part1, TParticle* part2)
227{
228 return part1->Pz()+part2->Pz();
229}
230
231Float_t AliDimuCombinator::Y(TParticle* part1, TParticle* part2)
232{
233 Float_t pz,e;
234 pz=part1->Pz()+part2->Pz();
235 e =part1->Energy()+part2->Energy();
236 return 0.5*TMath::Log((e+pz)/(e-pz));
237}
238// Response
239//
240void AliDimuCombinator::SmearGauss(Float_t width, Float_t & value)
241{
242 value+=gRandom->Gaus(0, width);
243}
244// Weighting
245//
246
247Float_t AliDimuCombinator::Decay_Prob(TParticle* part)
248{
249 Float_t d, h, theta, CTau;
250 TParticle* parent = Parent(part);
251 Int_t ipar=Type(parent);
252 if (ipar==8 || ipar==9) {
253 CTau=780.4;
254 } else if (ipar==11 || ipar==12) {
255 CTau=370.9;
256 } else {
257 CTau=0;
258 }
259
260
261 Float_t GammaBeta=(parent->P())/(parent->GetMass());
262//
263// this part is still very ALICE muon-arm specific
264//
265 theta=parent->Theta();
266 h=90*TMath::Tan(theta);
267
268 if (h<4) {
269 d=4/TMath::Sin(theta);
270 } else {
271 d=90/TMath::Cos(theta);
272 }
273
274 if (CTau > 0) {
275 return 1-TMath::Exp(-d/CTau/GammaBeta);
276 } else {
277 return 1;
278 }
279}
280
281Float_t AliDimuCombinator::Weight(TParticle* part1, TParticle* part2)
282{
283 Float_t wgt=(part1->GetWeight())*(part2->GetWeight());
284
285 if (Correlated(part1, part2)) {
286 return wgt/(Parent(part1)->GetWeight())*fRate1;
287 } else {
288 return wgt*fRate1*fRate2;
289 }
290}
291
292
293Float_t AliDimuCombinator::Weight(TParticle* part)
294{
295 return (part->GetWeight())*(Parent(part)->GetWeight())*fRate1;
296}
297Bool_t AliDimuCombinator::Correlated(TParticle* part1, TParticle* part2)
298{
299 if (Origin(part1) == Origin(part2)) {
300 return kTRUE;
301 } else {
302 return kFALSE;
303 }
304}
305
306TParticle* AliDimuCombinator::Parent(TParticle* part)
307{
308 return (TParticle*) (fPartArray->UncheckedAt(part->GetFirstMother()));
309}
310
311Int_t AliDimuCombinator::Origin(TParticle* part)
312{
313 Int_t iparent= part->GetFirstMother();
314 if (iparent < 0) return iparent;
315 Int_t ip;
316 while(1) {
317 ip=((TParticle*) fPartArray->UncheckedAt(iparent))->GetFirstMother();
318 if (ip < 0) {
319 break;
320 } else {
321 iparent=ip;
322 }
323 }
324 return iparent;
325}
326