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.4 2000/03/20 18:03:24 morsch
19 Change muon particle code to PDG code.
21 Revision 1.3 1999/09/29 09:24:08 fca
22 Introduction of the Copyright and cvs Log
30 #include "AliDimuCombinator.h"
33 #include <TClonesArray.h>
34 #include <TParticle.h>
36 ClassImp(AliDimuCombinator)
37 AliDimuCombinator::AliDimuCombinator(TClonesArray* Partarray)
41 fNParticle=fPartArray->GetEntriesFast();
58 AliDimuCombinator::AliDimuCombinator(const AliDimuCombinator & combinator)
67 TParticle* AliDimuCombinator::FirstMuon()
69 // Single muon iterator: initialisation
71 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
72 while(Type(fmuon1)!=kMuonPlus && Type(fmuon1)!=kMuonMinus) {
74 if (fimuon1 >= fimax1) {fmuon1=0; break;}
75 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
80 TParticle* AliDimuCombinator::FirstMuonSelected()
82 // Single selected muon iterator: initialisation
83 TParticle * muon=FirstMuon();
84 while(muon!=0 && !Selected(muon)) {muon=NextMuon();}
89 TParticle* AliDimuCombinator::NextMuon()
91 // Single muon iterator: increment
93 if (fimuon1>=fNParticle) {fmuon1 = 0; return fmuon1;}
95 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
96 while(Type(fmuon1)!=kMuonPlus && Type(fmuon1)!=kMuonMinus) {
98 if (fimuon1>=fimax1) {fmuon1 = 0; break;}
99 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
104 TParticle* AliDimuCombinator::NextMuonSelected()
106 // Single selected muon iterator: increment
107 TParticle * muon=NextMuon();
108 while(muon !=0 && !Selected(muon)) {muon=NextMuon();}
113 void AliDimuCombinator::FirstPartner()
115 // Helper for dimuon iterator: initialisation
116 if (fimin1==fimin2) {
121 if (fimuon2 >= fimax2) {fmuon2=0; return;}
122 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
123 while(Type(fmuon2)!=kMuonPlus && Type(fmuon2)!=kMuonMinus) {
125 if (fimuon2 >= fimax2) {fmuon2=0; break;}
126 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
130 void AliDimuCombinator::FirstPartnerSelected()
132 // Helper for selected dimuon iterator: initialisation
134 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
138 void AliDimuCombinator::NextPartner()
140 // Helper for dimuon iterator: increment
142 if (fimuon2>=fimax2) {fmuon2 = 0; return;}
145 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
147 while(Type(fmuon2)!=kMuonPlus && Type(fmuon2)!=kMuonMinus) {
149 if (fimuon2>=fimax2) {fmuon2 = 0; break;}
150 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
154 void AliDimuCombinator::NextPartnerSelected()
156 // Helper for selected dimuon iterator: increment
158 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
162 TParticle* AliDimuCombinator::Partner()
164 // Returns current partner for muon to form a dimuon
168 void AliDimuCombinator::FirstMuonPair(TParticle* & muon1, TParticle* & muon2)
170 // Dimuon iterator: initialisation
177 void AliDimuCombinator::NextMuonPair(TParticle* & muon1, TParticle* & muon2)
179 // Dimuon iterator: increment
188 void AliDimuCombinator::FirstMuonPairSelected(TParticle* & muon1,
191 // Selected dimuon iterator: initialisation
193 FirstPartnerSelected();
198 void AliDimuCombinator::NextMuonPairSelected(TParticle* & muon1,
201 // Selected dimuon iterator: increment
202 NextPartnerSelected();
205 FirstPartnerSelected();
211 void AliDimuCombinator::ResetRange()
213 // Reset index ranges for single muons
215 fimax1=fimax2=fNParticle;
218 void AliDimuCombinator::SetFirstRange(Int_t from, Int_t to)
220 // Reset index range for first muon
223 if (fimax1 > fNParticle) fimax1=fNParticle;
226 void AliDimuCombinator::SetSecondRange(Int_t from, Int_t to)
228 // Reset index range for second muon
231 if (fimax2 > fNParticle) fimax2=fNParticle;
237 Bool_t AliDimuCombinator::Selected(TParticle* part)
239 // Selection cut for single muon
241 if (part==0) {return 0;}
243 if (part->Pt() > fPtMin && part->Eta()>fEtaMin && part->Eta()<fEtaMax) {
250 Bool_t AliDimuCombinator::Selected(TParticle* part1, TParticle* part2)
252 // Selection cut for dimuons
254 return Selected(part1)*Selected(part2);
259 Float_t AliDimuCombinator::Mass(TParticle* part1, TParticle* part2)
264 px=part1->Px()+part2->Px();
265 py=part1->Py()+part2->Py();
266 pz=part1->Pz()+part2->Pz();
267 e =part1->Energy()+part2->Energy();
268 Float_t p=px*px+py*py+pz*pz;
272 return TMath::Sqrt(e*e-p);
276 Float_t AliDimuCombinator::PT(TParticle* part1, TParticle* part2)
278 // Transverse momentum of dimuons
281 px=part1->Px()+part2->Px();
282 py=part1->Py()+part2->Py();
283 return TMath::Sqrt(px*px+py*py);
286 Float_t AliDimuCombinator::Pz(TParticle* part1, TParticle* part2)
288 // Pz of dimuon system
290 return part1->Pz()+part2->Pz();
293 Float_t AliDimuCombinator::Y(TParticle* part1, TParticle* part2)
295 // Rapidity of dimuon system
298 pz=part1->Pz()+part2->Pz();
299 e =part1->Energy()+part2->Energy();
300 return 0.5*TMath::Log((e+pz)/(e-pz));
304 void AliDimuCombinator::SmearGauss(Float_t width, Float_t & value)
306 // Apply gaussian smearing
308 value+=gRandom->Gaus(0, width);
313 Float_t AliDimuCombinator::DecayProbability(TParticle* part)
315 // Calculate decay probability for muons from pion and kaon decays
317 Float_t d, h, theta, cTau;
318 TParticle* parent = Parent(part);
319 Int_t ipar=Type(parent);
320 if (ipar==kPiPlus || ipar==kPiMinus) {
322 } else if (ipar==kKPlus || ipar==kKMinus) {
329 Float_t gammaBeta=(parent->P())/(parent->GetMass());
331 // this part is still very ALICE muon-arm specific
333 theta=parent->Theta();
334 h=90*TMath::Tan(theta);
337 d=4/TMath::Sin(theta);
339 d=90/TMath::Cos(theta);
343 return 1-TMath::Exp(-d/cTau/gammaBeta);
349 Float_t AliDimuCombinator::Weight(TParticle* part1, TParticle* part2)
353 Float_t wgt=(part1->GetWeight())*(part2->GetWeight());
355 if (Correlated(part1, part2)) {
356 return wgt/(Parent(part1)->GetWeight())*fRate1;
358 return wgt*fRate1*fRate2;
363 Float_t AliDimuCombinator::Weight(TParticle* part)
365 // Single muon weight
366 return (part->GetWeight())*(Parent(part)->GetWeight())*fRate1;
369 Bool_t AliDimuCombinator::Correlated(TParticle* part1, TParticle* part2)
371 // Check if muons are correlated
373 if (Origin(part1) == Origin(part2)) {
380 TParticle* AliDimuCombinator::Parent(TParticle* part)
382 // Return pointer to parent
384 return (TParticle*) (fPartArray->UncheckedAt(part->GetFirstMother()));
387 Int_t AliDimuCombinator::Origin(TParticle* part)
389 // Return pointer to primary particle
391 Int_t iparent= part->GetFirstMother();
392 if (iparent < 0) return iparent;
395 ip=((TParticle*) fPartArray->UncheckedAt(iparent))->GetFirstMother();
405 AliDimuCombinator& AliDimuCombinator::operator=(const AliDimuCombinator& rhs)
407 // Assignment operator