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