Introduction of the Copyright and cvs Log
[u/mrichter/AliRoot.git] / EVGEN / AliDimuCombinator.cxx
CommitLineData
4c039060 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
fe4da5cc 20//
21//
22//
23//
dafbc1c5 24#include "AliDimuCombinator.h"
fe4da5cc 25#include "AliRun.h"
26#include "TRandom.h"
27//
dafbc1c5 28ClassImp(AliDimuCombinator)
fe4da5cc 29//
30// Iterators
31//
1578254f 32 TParticle* AliDimuCombinator::FirstMuon()
fe4da5cc 33 {
34 fimuon1=fimin1;
1578254f 35 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
fe4da5cc 36 while(Type(fmuon1)!=5 && Type(fmuon1)!=6) {
37 fimuon1++;
38 if (fimuon1 >= fimax1) {fmuon1=0; break;}
1578254f 39 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
fe4da5cc 40 }
41 return fmuon1;
42 }
43
1578254f 44 TParticle* AliDimuCombinator::FirstMuonSelected()
fe4da5cc 45 {
1578254f 46 TParticle * muon=FirstMuon();
fe4da5cc 47 while(muon!=0 && !Selected(muon)) {muon=NextMuon();}
48 return muon;
49 }
50
51
1578254f 52 TParticle* AliDimuCombinator::NextMuon()
fe4da5cc 53 {
54 fimuon1++;
55 if (fimuon1>=fNParticle) {fmuon1 = 0; return fmuon1;}
56
1578254f 57 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
fe4da5cc 58 while(Type(fmuon1)!=5 && Type(fmuon1)!=6) {
59 fimuon1++;
60 if (fimuon1>=fimax1) {fmuon1 = 0; break;}
1578254f 61 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
fe4da5cc 62 }
63 return fmuon1;
64 }
65
1578254f 66TParticle* AliDimuCombinator::NextMuonSelected()
fe4da5cc 67 {
1578254f 68 TParticle * muon=NextMuon();
fe4da5cc 69 while(muon !=0 && !Selected(muon)) {muon=NextMuon();}
70 return muon;
71 }
72
73
dafbc1c5 74 void AliDimuCombinator::FirstPartner()
fe4da5cc 75 {
76 if (fimin1==fimin2) {
77 fimuon2=fimuon1+1;
78 } else {
79 fimuon2=fimin2;
80 }
81 if (fimuon2 >= fimax2) {fmuon2=0; return;}
1578254f 82 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
fe4da5cc 83 while(Type(fmuon2)!=5 && Type(fmuon2)!=6) {
84 fimuon2++;
85 if (fimuon2 >= fimax2) {fmuon2=0; break;}
1578254f 86 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
fe4da5cc 87 }
88 }
dafbc1c5 89void AliDimuCombinator::FirstPartnerSelected()
fe4da5cc 90{
91 FirstPartner();
92 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
93}
94
95
dafbc1c5 96 void AliDimuCombinator::NextPartner()
fe4da5cc 97 {
98 fimuon2++;
99 if (fimuon2>=fimax2) {fmuon2 = 0; return;}
100
101
1578254f 102 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
fe4da5cc 103
104 while(Type(fmuon2)!=5 && Type(fmuon2)!=6) {
105 fimuon2++;
106 if (fimuon2>=fimax2) {fmuon2 = 0; break;}
1578254f 107 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
fe4da5cc 108 }
109
110 }
111
dafbc1c5 112void AliDimuCombinator::NextPartnerSelected()
fe4da5cc 113{
114 NextPartner();
115 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
116}
117
118
1578254f 119 TParticle* AliDimuCombinator::Partner()
fe4da5cc 120 {
121 return fmuon2;
122 }
123
1578254f 124void AliDimuCombinator::FirstMuonPair(TParticle* & muon1, TParticle* & muon2)
fe4da5cc 125 {
126 FirstMuon();
127 FirstPartner();
128 muon1=fmuon1;
129 muon2=fmuon2;
130 }
1578254f 131void AliDimuCombinator::NextMuonPair(TParticle* & muon1, TParticle* & muon2)
fe4da5cc 132 {
133 NextPartner();
134 if (!Partner()) {
135 NextMuon();
136 FirstPartner();
137 }
138 muon1=fmuon1;
139 muon2=fmuon2;
140 }
1578254f 141void AliDimuCombinator::FirstMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
fe4da5cc 142 {
143 FirstMuonSelected();
144 FirstPartnerSelected();
145 muon1=fmuon1;
146 muon2=fmuon2;
147 }
1578254f 148void AliDimuCombinator::NextMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
fe4da5cc 149 {
150 NextPartnerSelected();
151 if (!Partner()) {
152 NextMuonSelected();
153 FirstPartnerSelected();
154 }
155 muon1=fmuon1;
156 muon2=fmuon2;
157 }
dafbc1c5 158void AliDimuCombinator::ResetRange()
fe4da5cc 159{
160 fimin1=fimin2=0;
161 fimax1=fimax2=fNParticle;
162}
163
dafbc1c5 164void AliDimuCombinator::SetFirstRange(Int_t from, Int_t to)
fe4da5cc 165{
166 fimin1=from;
167 fimax1=to;
168 if (fimax1 > fNParticle) fimax1=fNParticle;
169}
170
dafbc1c5 171void AliDimuCombinator::SetSecondRange(Int_t from, Int_t to)
fe4da5cc 172{
173 fimin2=from;
174 fimax2=to;
175 if (fimax2 > fNParticle) fimax2=fNParticle;
176}
177//
178// Selection
179//
180
1578254f 181Bool_t AliDimuCombinator::Selected(TParticle* part)
fe4da5cc 182{
183//
184//
185 if (part==0) {return 0;}
186
1578254f 187 if (part->Pt() > fPtMin && part->Eta()>fEtaMin && part->Eta()<fEtaMax) {
fe4da5cc 188 return 1;
189 } else {
190 return 0;
191 }
192
193
194}
195
1578254f 196Bool_t AliDimuCombinator::Selected(TParticle* part1, TParticle* part2)
fe4da5cc 197{
198 return Selected(part1)*Selected(part2);
199}
200//
201// Kinematics
202//
1578254f 203Float_t AliDimuCombinator::Mass(TParticle* part1, TParticle* part2)
fe4da5cc 204{
205 Float_t px,py,pz,e;
1578254f 206 px=part1->Px()+part2->Px();
207 py=part1->Py()+part2->Py();
208 pz=part1->Pz()+part2->Pz();
209 e =part1->Energy()+part2->Energy();
fe4da5cc 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
1578254f 218Float_t AliDimuCombinator::PT(TParticle* part1, TParticle* part2)
fe4da5cc 219{
220 Float_t px,py;
1578254f 221 px=part1->Px()+part2->Px();
222 py=part1->Py()+part2->Py();
fe4da5cc 223 return TMath::Sqrt(px*px+py*py);
224}
225
1578254f 226Float_t AliDimuCombinator::Pz(TParticle* part1, TParticle* part2)
fe4da5cc 227{
1578254f 228 return part1->Pz()+part2->Pz();
fe4da5cc 229}
230
1578254f 231Float_t AliDimuCombinator::Y(TParticle* part1, TParticle* part2)
fe4da5cc 232{
233 Float_t pz,e;
1578254f 234 pz=part1->Pz()+part2->Pz();
235 e =part1->Energy()+part2->Energy();
fe4da5cc 236 return 0.5*TMath::Log((e+pz)/(e-pz));
237}
238// Response
239//
dafbc1c5 240void AliDimuCombinator::SmearGauss(Float_t width, Float_t & value)
fe4da5cc 241{
242 value+=gRandom->Gaus(0, width);
243}
244// Weighting
245//
246
1578254f 247Float_t AliDimuCombinator::Decay_Prob(TParticle* part)
fe4da5cc 248{
7d566a7d 249 Float_t d, h, theta, CTau;
1578254f 250 TParticle* parent = Parent(part);
7d566a7d 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
1578254f 261 Float_t GammaBeta=(parent->P())/(parent->GetMass());
7d566a7d 262//
263// this part is still very ALICE muon-arm specific
264//
1578254f 265 theta=parent->Theta();
7d566a7d 266 h=90*TMath::Tan(theta);
267
268 if (h<4) {
269 d=4/TMath::Sin(theta);
fe4da5cc 270 } else {
7d566a7d 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;
fe4da5cc 278 }
279}
280
1578254f 281Float_t AliDimuCombinator::Weight(TParticle* part1, TParticle* part2)
7d566a7d 282{
1578254f 283 Float_t wgt=(part1->GetWeight())*(part2->GetWeight());
7d566a7d 284
285 if (Correlated(part1, part2)) {
1578254f 286 return wgt/(Parent(part1)->GetWeight())*fRate1;
7d566a7d 287 } else {
288 return wgt*fRate1*fRate2;
289 }
290}
291
292
1578254f 293Float_t AliDimuCombinator::Weight(TParticle* part)
fe4da5cc 294{
1578254f 295 return (part->GetWeight())*(Parent(part)->GetWeight())*fRate1;
7d566a7d 296}
1578254f 297Bool_t AliDimuCombinator::Correlated(TParticle* part1, TParticle* part2)
7d566a7d 298{
299 if (Origin(part1) == Origin(part2)) {
300 return kTRUE;
301 } else {
302 return kFALSE;
303 }
304}
1578254f 305
306TParticle* AliDimuCombinator::Parent(TParticle* part)
7d566a7d 307{
1578254f 308 return (TParticle*) (fPartArray->UncheckedAt(part->GetFirstMother()));
7d566a7d 309}
310
1578254f 311Int_t AliDimuCombinator::Origin(TParticle* part)
7d566a7d 312{
1578254f 313 Int_t iparent= part->GetFirstMother();
7d566a7d 314 if (iparent < 0) return iparent;
315 Int_t ip;
316 while(1) {
1578254f 317 ip=((TParticle*) fPartArray->UncheckedAt(iparent))->GetFirstMother();
7d566a7d 318 if (ip < 0) {
319 break;
320 } else {
321 iparent=ip;
322 }
323 }
324 return iparent;
fe4da5cc 325}
326