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 **************************************************************************/
18 Revision 1.3 1999/09/29 09:24:08 fca
19 Introduction of the Copyright and cvs Log
27 #include "AliDimuCombinator.h"
32 ClassImp(AliDimuCombinator)
36 TParticle* AliDimuCombinator::FirstMuon()
39 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
40 while(Type(fmuon1)!=kMuonPlus && Type(fmuon1)!=kMuonMinus) {
42 if (fimuon1 >= fimax1) {fmuon1=0; break;}
43 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
48 TParticle* AliDimuCombinator::FirstMuonSelected()
50 TParticle * muon=FirstMuon();
51 while(muon!=0 && !Selected(muon)) {muon=NextMuon();}
56 TParticle* AliDimuCombinator::NextMuon()
59 if (fimuon1>=fNParticle) {fmuon1 = 0; return fmuon1;}
61 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
62 while(Type(fmuon1)!=kMuonPlus && Type(fmuon1)!=kMuonMinus) {
64 if (fimuon1>=fimax1) {fmuon1 = 0; break;}
65 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
70 TParticle* AliDimuCombinator::NextMuonSelected()
72 TParticle * muon=NextMuon();
73 while(muon !=0 && !Selected(muon)) {muon=NextMuon();}
78 void AliDimuCombinator::FirstPartner()
85 if (fimuon2 >= fimax2) {fmuon2=0; return;}
86 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
87 while(Type(fmuon2)!=kMuonPlus && Type(fmuon2)!=kMuonMinus) {
89 if (fimuon2 >= fimax2) {fmuon2=0; break;}
90 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
93 void AliDimuCombinator::FirstPartnerSelected()
96 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
100 void AliDimuCombinator::NextPartner()
103 if (fimuon2>=fimax2) {fmuon2 = 0; return;}
106 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
108 while(Type(fmuon2)!=kMuonPlus && Type(fmuon2)!=kMuonMinus) {
110 if (fimuon2>=fimax2) {fmuon2 = 0; break;}
111 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
116 void AliDimuCombinator::NextPartnerSelected()
119 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
123 TParticle* AliDimuCombinator::Partner()
128 void AliDimuCombinator::FirstMuonPair(TParticle* & muon1, TParticle* & muon2)
135 void AliDimuCombinator::NextMuonPair(TParticle* & muon1, TParticle* & muon2)
145 void AliDimuCombinator::FirstMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
148 FirstPartnerSelected();
152 void AliDimuCombinator::NextMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
154 NextPartnerSelected();
157 FirstPartnerSelected();
162 void AliDimuCombinator::ResetRange()
165 fimax1=fimax2=fNParticle;
168 void AliDimuCombinator::SetFirstRange(Int_t from, Int_t to)
172 if (fimax1 > fNParticle) fimax1=fNParticle;
175 void AliDimuCombinator::SetSecondRange(Int_t from, Int_t to)
179 if (fimax2 > fNParticle) fimax2=fNParticle;
185 Bool_t AliDimuCombinator::Selected(TParticle* part)
189 if (part==0) {return 0;}
191 if (part->Pt() > fPtMin && part->Eta()>fEtaMin && part->Eta()<fEtaMax) {
200 Bool_t AliDimuCombinator::Selected(TParticle* part1, TParticle* part2)
202 return Selected(part1)*Selected(part2);
207 Float_t AliDimuCombinator::Mass(TParticle* part1, TParticle* part2)
210 px=part1->Px()+part2->Px();
211 py=part1->Py()+part2->Py();
212 pz=part1->Pz()+part2->Pz();
213 e =part1->Energy()+part2->Energy();
214 Float_t p=px*px+py*py+pz*pz;
218 return TMath::Sqrt(e*e-p);
222 Float_t AliDimuCombinator::PT(TParticle* part1, TParticle* part2)
225 px=part1->Px()+part2->Px();
226 py=part1->Py()+part2->Py();
227 return TMath::Sqrt(px*px+py*py);
230 Float_t AliDimuCombinator::Pz(TParticle* part1, TParticle* part2)
232 return part1->Pz()+part2->Pz();
235 Float_t AliDimuCombinator::Y(TParticle* part1, TParticle* part2)
238 pz=part1->Pz()+part2->Pz();
239 e =part1->Energy()+part2->Energy();
240 return 0.5*TMath::Log((e+pz)/(e-pz));
244 void AliDimuCombinator::SmearGauss(Float_t width, Float_t & value)
246 value+=gRandom->Gaus(0, width);
251 Float_t AliDimuCombinator::Decay_Prob(TParticle* part)
253 Float_t d, h, theta, CTau;
254 TParticle* parent = Parent(part);
255 Int_t ipar=Type(parent);
256 if (ipar==8 || ipar==9) {
258 } else if (ipar==11 || ipar==12) {
265 Float_t GammaBeta=(parent->P())/(parent->GetMass());
267 // this part is still very ALICE muon-arm specific
269 theta=parent->Theta();
270 h=90*TMath::Tan(theta);
273 d=4/TMath::Sin(theta);
275 d=90/TMath::Cos(theta);
279 return 1-TMath::Exp(-d/CTau/GammaBeta);
285 Float_t AliDimuCombinator::Weight(TParticle* part1, TParticle* part2)
287 Float_t wgt=(part1->GetWeight())*(part2->GetWeight());
289 if (Correlated(part1, part2)) {
290 return wgt/(Parent(part1)->GetWeight())*fRate1;
292 return wgt*fRate1*fRate2;
297 Float_t AliDimuCombinator::Weight(TParticle* part)
299 return (part->GetWeight())*(Parent(part)->GetWeight())*fRate1;
301 Bool_t AliDimuCombinator::Correlated(TParticle* part1, TParticle* part2)
303 if (Origin(part1) == Origin(part2)) {
310 TParticle* AliDimuCombinator::Parent(TParticle* part)
312 return (TParticle*) (fPartArray->UncheckedAt(part->GetFirstMother()));
315 Int_t AliDimuCombinator::Origin(TParticle* part)
317 Int_t iparent= part->GetFirstMother();
318 if (iparent < 0) return iparent;
321 ip=((TParticle*) fPartArray->UncheckedAt(iparent))->GetFirstMother();