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.6 2000/06/14 15:19:47 morsch
21 Revision 1.5 2000/06/09 20:35:32 morsch
22 All coding rule violations except RS3 corrected
24 Revision 1.4 2000/03/20 18:03:24 morsch
25 Change muon particle code to PDG code.
27 Revision 1.3 1999/09/29 09:24:08 fca
28 Introduction of the Copyright and cvs Log
36 #include "AliDimuCombinator.h"
39 #include <TClonesArray.h>
40 #include <TParticle.h>
43 ClassImp(AliDimuCombinator)
44 AliDimuCombinator::AliDimuCombinator(TClonesArray* Partarray)
48 fNParticle=fPartArray->GetEntriesFast();
65 AliDimuCombinator::AliDimuCombinator(const AliDimuCombinator & combinator)
74 TParticle* AliDimuCombinator::FirstMuon()
76 // Single muon iterator: initialisation
78 fMuon1 = (TParticle*) fPartArray->UncheckedAt(fImuon1);
79 while(Type(fMuon1)!=kMuonPlus && Type(fMuon1)!=kMuonMinus) {
81 if (fImuon1 >= fImax1) {fMuon1=0; break;}
82 fMuon1 = (TParticle*) fPartArray->UncheckedAt(fImuon1);
87 TParticle* AliDimuCombinator::FirstMuonSelected()
89 // Single selected muon iterator: initialisation
90 TParticle * muon=FirstMuon();
91 while(muon!=0 && !Selected(muon)) {muon=NextMuon();}
96 TParticle* AliDimuCombinator::NextMuon()
98 // Single muon iterator: increment
100 if (fImuon1>=fNParticle) {fMuon1 = 0; return fMuon1;}
102 fMuon1 = (TParticle*) fPartArray->UncheckedAt(fImuon1);
103 while(Type(fMuon1)!=kMuonPlus && Type(fMuon1)!=kMuonMinus) {
105 if (fImuon1>=fImax1) {fMuon1 = 0; break;}
106 fMuon1 = (TParticle*) fPartArray->UncheckedAt(fImuon1);
111 TParticle* AliDimuCombinator::NextMuonSelected()
113 // Single selected muon iterator: increment
114 TParticle * muon=NextMuon();
115 while(muon !=0 && !Selected(muon)) {muon=NextMuon();}
120 void AliDimuCombinator::FirstPartner()
122 // Helper for dimuon iterator: initialisation
123 if (fImin1==fImin2) {
128 if (fImuon2 >= fImax2) {fMuon2=0; return;}
129 fMuon2 = (TParticle*) fPartArray->UncheckedAt(fImuon2);
130 while(Type(fMuon2)!=kMuonPlus && Type(fMuon2)!=kMuonMinus) {
132 if (fImuon2 >= fImax2) {fMuon2=0; break;}
133 fMuon2 = (TParticle*) fPartArray->UncheckedAt(fImuon2);
137 void AliDimuCombinator::FirstPartnerSelected()
139 // Helper for selected dimuon iterator: initialisation
141 while(fMuon2 !=0 && !Selected(fMuon2)) {NextPartner();}
145 void AliDimuCombinator::NextPartner()
147 // Helper for dimuon iterator: increment
149 if (fImuon2>=fImax2) {fMuon2 = 0; return;}
152 fMuon2 = (TParticle*) fPartArray->UncheckedAt(fImuon2);
154 while(Type(fMuon2)!=kMuonPlus && Type(fMuon2)!=kMuonMinus) {
156 if (fImuon2>=fImax2) {fMuon2 = 0; break;}
157 fMuon2 = (TParticle*) fPartArray->UncheckedAt(fImuon2);
161 void AliDimuCombinator::NextPartnerSelected()
163 // Helper for selected dimuon iterator: increment
165 while(fMuon2 !=0 && !Selected(fMuon2)) {NextPartner();}
169 TParticle* AliDimuCombinator::Partner()
171 // Returns current partner for muon to form a dimuon
175 void AliDimuCombinator::FirstMuonPair(TParticle* & muon1, TParticle* & muon2)
177 // Dimuon iterator: initialisation
184 void AliDimuCombinator::NextMuonPair(TParticle* & muon1, TParticle* & muon2)
186 // Dimuon iterator: increment
195 void AliDimuCombinator::FirstMuonPairSelected(TParticle* & muon1,
198 // Selected dimuon iterator: initialisation
200 FirstPartnerSelected();
205 void AliDimuCombinator::NextMuonPairSelected(TParticle* & muon1,
208 // Selected dimuon iterator: increment
209 NextPartnerSelected();
212 FirstPartnerSelected();
218 void AliDimuCombinator::ResetRange()
220 // Reset index ranges for single muons
222 fImax1=fImax2=fNParticle;
225 void AliDimuCombinator::SetFirstRange(Int_t from, Int_t to)
227 // Reset index range for first muon
230 if (fImax1 > fNParticle) fImax1=fNParticle;
233 void AliDimuCombinator::SetSecondRange(Int_t from, Int_t to)
235 // Reset index range for second muon
238 if (fImax2 > fNParticle) fImax2=fNParticle;
244 Bool_t AliDimuCombinator::Selected(TParticle* part)
246 // Selection cut for single muon
248 if (part==0) {return 0;}
250 if (part->Pt() > fPtMin && part->Eta()>fEtaMin && part->Eta()<fEtaMax) {
257 Bool_t AliDimuCombinator::Selected(TParticle* part1, TParticle* part2)
259 // Selection cut for dimuons
261 return Selected(part1)*Selected(part2);
266 Float_t AliDimuCombinator::Mass(TParticle* part1, TParticle* part2)
271 px=part1->Px()+part2->Px();
272 py=part1->Py()+part2->Py();
273 pz=part1->Pz()+part2->Pz();
274 e =part1->Energy()+part2->Energy();
275 Float_t p=px*px+py*py+pz*pz;
279 return TMath::Sqrt(e*e-p);
283 Float_t AliDimuCombinator::PT(TParticle* part1, TParticle* part2)
285 // Transverse momentum of dimuons
288 px=part1->Px()+part2->Px();
289 py=part1->Py()+part2->Py();
290 return TMath::Sqrt(px*px+py*py);
293 Float_t AliDimuCombinator::Pz(TParticle* part1, TParticle* part2)
295 // Pz of dimuon system
297 return part1->Pz()+part2->Pz();
300 Float_t AliDimuCombinator::Y(TParticle* part1, TParticle* part2)
302 // Rapidity of dimuon system
305 pz=part1->Pz()+part2->Pz();
306 e =part1->Energy()+part2->Energy();
307 return 0.5*TMath::Log((e+pz)/(e-pz));
311 void AliDimuCombinator::SmearGauss(Float_t width, Float_t & value)
313 // Apply gaussian smearing
315 value+=gRandom->Gaus(0, width);
320 Float_t AliDimuCombinator::DecayProbability(TParticle* part)
322 // Calculate decay probability for muons from pion and kaon decays
324 Float_t d, h, theta, cTau;
325 TParticle* parent = Parent(part);
326 Int_t ipar=Type(parent);
327 if (ipar==kPiPlus || ipar==kPiMinus) {
329 } else if (ipar==kKPlus || ipar==kKMinus) {
336 Float_t gammaBeta=(parent->P())/(parent->GetMass());
338 // this part is still very ALICE muon-arm specific
340 theta=parent->Theta();
341 h=90*TMath::Tan(theta);
344 d=4/TMath::Sin(theta);
346 d=90/TMath::Cos(theta);
350 return 1-TMath::Exp(-d/cTau/gammaBeta);
356 Float_t AliDimuCombinator::Weight(TParticle* part1, TParticle* part2)
360 Float_t wgt=(part1->GetWeight())*(part2->GetWeight());
362 if (Correlated(part1, part2)) {
363 return wgt/(Parent(part1)->GetWeight())*fRate1;
365 return wgt*fRate1*fRate2;
370 Float_t AliDimuCombinator::Weight(TParticle* part)
372 // Single muon weight
373 return (part->GetWeight())*(Parent(part)->GetWeight())*fRate1;
376 Bool_t AliDimuCombinator::Correlated(TParticle* part1, TParticle* part2)
378 // Check if muons are correlated
380 if (Origin(part1) == Origin(part2)) {
387 TParticle* AliDimuCombinator::Parent(TParticle* part)
389 // Return pointer to parent
391 return (TParticle*) (fPartArray->UncheckedAt(part->GetFirstMother()));
394 Int_t AliDimuCombinator::Origin(TParticle* part)
396 // Return pointer to primary particle
398 Int_t iparent= part->GetFirstMother();
399 if (iparent < 0) return iparent;
402 ip=((TParticle*) fPartArray->UncheckedAt(iparent))->GetFirstMother();
412 Int_t AliDimuCombinator::Type(TParticle *part)
414 // Return particle type for
415 return part->GetPdgCode();
418 AliDimuCombinator& AliDimuCombinator::operator=(const AliDimuCombinator& rhs)
420 // Assignment operator