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