1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
24 #include "AliDimuCombinator.h"
28 ClassImp(AliDimuCombinator)
32 TParticle* AliDimuCombinator::FirstMuon()
35 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
36 while(Type(fmuon1)!=5 && Type(fmuon1)!=6) {
38 if (fimuon1 >= fimax1) {fmuon1=0; break;}
39 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
44 TParticle* AliDimuCombinator::FirstMuonSelected()
46 TParticle * muon=FirstMuon();
47 while(muon!=0 && !Selected(muon)) {muon=NextMuon();}
52 TParticle* AliDimuCombinator::NextMuon()
55 if (fimuon1>=fNParticle) {fmuon1 = 0; return fmuon1;}
57 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
58 while(Type(fmuon1)!=5 && Type(fmuon1)!=6) {
60 if (fimuon1>=fimax1) {fmuon1 = 0; break;}
61 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
66 TParticle* AliDimuCombinator::NextMuonSelected()
68 TParticle * muon=NextMuon();
69 while(muon !=0 && !Selected(muon)) {muon=NextMuon();}
74 void AliDimuCombinator::FirstPartner()
81 if (fimuon2 >= fimax2) {fmuon2=0; return;}
82 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
83 while(Type(fmuon2)!=5 && Type(fmuon2)!=6) {
85 if (fimuon2 >= fimax2) {fmuon2=0; break;}
86 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
89 void AliDimuCombinator::FirstPartnerSelected()
92 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
96 void AliDimuCombinator::NextPartner()
99 if (fimuon2>=fimax2) {fmuon2 = 0; return;}
102 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
104 while(Type(fmuon2)!=5 && Type(fmuon2)!=6) {
106 if (fimuon2>=fimax2) {fmuon2 = 0; break;}
107 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
112 void AliDimuCombinator::NextPartnerSelected()
115 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
119 TParticle* AliDimuCombinator::Partner()
124 void AliDimuCombinator::FirstMuonPair(TParticle* & muon1, TParticle* & muon2)
131 void AliDimuCombinator::NextMuonPair(TParticle* & muon1, TParticle* & muon2)
141 void AliDimuCombinator::FirstMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
144 FirstPartnerSelected();
148 void AliDimuCombinator::NextMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
150 NextPartnerSelected();
153 FirstPartnerSelected();
158 void AliDimuCombinator::ResetRange()
161 fimax1=fimax2=fNParticle;
164 void AliDimuCombinator::SetFirstRange(Int_t from, Int_t to)
168 if (fimax1 > fNParticle) fimax1=fNParticle;
171 void AliDimuCombinator::SetSecondRange(Int_t from, Int_t to)
175 if (fimax2 > fNParticle) fimax2=fNParticle;
181 Bool_t AliDimuCombinator::Selected(TParticle* part)
185 if (part==0) {return 0;}
187 if (part->Pt() > fPtMin && part->Eta()>fEtaMin && part->Eta()<fEtaMax) {
196 Bool_t AliDimuCombinator::Selected(TParticle* part1, TParticle* part2)
198 return Selected(part1)*Selected(part2);
203 Float_t AliDimuCombinator::Mass(TParticle* part1, TParticle* part2)
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;
214 return TMath::Sqrt(e*e-p);
218 Float_t AliDimuCombinator::PT(TParticle* part1, TParticle* part2)
221 px=part1->Px()+part2->Px();
222 py=part1->Py()+part2->Py();
223 return TMath::Sqrt(px*px+py*py);
226 Float_t AliDimuCombinator::Pz(TParticle* part1, TParticle* part2)
228 return part1->Pz()+part2->Pz();
231 Float_t AliDimuCombinator::Y(TParticle* part1, TParticle* part2)
234 pz=part1->Pz()+part2->Pz();
235 e =part1->Energy()+part2->Energy();
236 return 0.5*TMath::Log((e+pz)/(e-pz));
240 void AliDimuCombinator::SmearGauss(Float_t width, Float_t & value)
242 value+=gRandom->Gaus(0, width);
247 Float_t AliDimuCombinator::Decay_Prob(TParticle* part)
249 Float_t d, h, theta, CTau;
250 TParticle* parent = Parent(part);
251 Int_t ipar=Type(parent);
252 if (ipar==8 || ipar==9) {
254 } else if (ipar==11 || ipar==12) {
261 Float_t GammaBeta=(parent->P())/(parent->GetMass());
263 // this part is still very ALICE muon-arm specific
265 theta=parent->Theta();
266 h=90*TMath::Tan(theta);
269 d=4/TMath::Sin(theta);
271 d=90/TMath::Cos(theta);
275 return 1-TMath::Exp(-d/CTau/GammaBeta);
281 Float_t AliDimuCombinator::Weight(TParticle* part1, TParticle* part2)
283 Float_t wgt=(part1->GetWeight())*(part2->GetWeight());
285 if (Correlated(part1, part2)) {
286 return wgt/(Parent(part1)->GetWeight())*fRate1;
288 return wgt*fRate1*fRate2;
293 Float_t AliDimuCombinator::Weight(TParticle* part)
295 return (part->GetWeight())*(Parent(part)->GetWeight())*fRate1;
297 Bool_t AliDimuCombinator::Correlated(TParticle* part1, TParticle* part2)
299 if (Origin(part1) == Origin(part2)) {
306 TParticle* AliDimuCombinator::Parent(TParticle* part)
308 return (TParticle*) (fPartArray->UncheckedAt(part->GetFirstMother()));
311 Int_t AliDimuCombinator::Origin(TParticle* part)
313 Int_t iparent= part->GetFirstMother();
314 if (iparent < 0) return iparent;
317 ip=((TParticle*) fPartArray->UncheckedAt(iparent))->GetFirstMother();