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.8 2000/12/21 16:24:06 morsch
19 Coding convention clean-up
21 Revision 1.7 2000/10/02 15:16:37 morsch
22 Correct coding rule violation for member data names of type fi -> fI.
24 Revision 1.6 2000/06/14 15:19:47 morsch
27 Revision 1.5 2000/06/09 20:35:32 morsch
28 All coding rule violations except RS3 corrected
30 Revision 1.4 2000/03/20 18:03:24 morsch
31 Change muon particle code to PDG code.
33 Revision 1.3 1999/09/29 09:24:08 fca
34 Introduction of the Copyright and cvs Log
39 Class for dimuon analysis and fast dimuon simulation.
40 It provides single and dimuon iterators, cuts, weighting, kinematic
41 It uses the AliRun particle tree.
42 Comments and suggestions to
43 andreas.morsch@cern.ch
47 #include "AliDimuCombinator.h"
51 #include <TClonesArray.h>
52 #include <TParticle.h>
56 ClassImp(AliDimuCombinator)
57 AliDimuCombinator::AliDimuCombinator()
60 fNParticle = (Int_t) (gAlice->TreeK())->GetEntries();
76 AliDimuCombinator::AliDimuCombinator(const AliDimuCombinator & combinator)
78 // Dummy copy constructor
85 TParticle* AliDimuCombinator::Particle(Int_t i)
87 return gAlice->Particle(i);
90 TParticle* AliDimuCombinator::FirstMuon()
92 // Single muon iterator: initialisation
94 fMuon1 = Particle(fImuon1);
95 while(Type(fMuon1) != kMuonPlus && Type(fMuon1) != kMuonMinus) {
97 if (fImuon1 >= fImax1) {fMuon1 = 0; break;}
98 fMuon1 = Particle(fImuon1);
103 TParticle* AliDimuCombinator::FirstMuonSelected()
105 // Single selected muon iterator: initialisation
106 TParticle* muon = FirstMuon();
107 while(muon != 0 && !Selected(muon)) {muon = NextMuon();}
112 TParticle* AliDimuCombinator::NextMuon()
114 // Single muon iterator: increment
116 if (fImuon1 >= fNParticle) {fMuon1 = 0; return fMuon1;}
118 fMuon1 = Particle(fImuon1);
119 while(Type(fMuon1) != kMuonPlus && Type(fMuon1) != kMuonMinus) {
121 if (fImuon1 >= fImax1) {fMuon1 = 0; break;}
122 fMuon1 = Particle(fImuon1);
127 TParticle* AliDimuCombinator::NextMuonSelected()
129 // Single selected muon iterator: increment
130 TParticle * muon = NextMuon();
131 while(muon !=0 && !Selected(muon)) {muon = NextMuon();}
136 void AliDimuCombinator::FirstPartner()
138 // Helper for dimuon iterator: initialisation
139 if (fImin1 == fImin2) {
144 if (fImuon2 >= fImax2) {fMuon2 = 0; return;}
145 fMuon2 = Particle(fImuon2);
146 while(Type(fMuon2) != kMuonPlus && Type(fMuon2) != kMuonMinus) {
148 if (fImuon2 >= fImax2) {fMuon2 = 0; break;}
149 fMuon2 = Particle(fImuon2);
153 void AliDimuCombinator::FirstPartnerSelected()
155 // Helper for selected dimuon iterator: initialisation
157 while(fMuon2 !=0 && !Selected(fMuon2)) {NextPartner();}
161 void AliDimuCombinator::NextPartner()
163 // Helper for dimuon iterator: increment
165 if (fImuon2 >= fImax2) {fMuon2 = 0; return;}
168 fMuon2 = Particle(fImuon2);
170 while(Type(fMuon2) != kMuonPlus && Type(fMuon2) != kMuonMinus) {
172 if (fImuon2 >= fImax2) {fMuon2 = 0; break;}
173 fMuon2 = Particle(fImuon2);
177 void AliDimuCombinator::NextPartnerSelected()
179 // Helper for selected dimuon iterator: increment
181 while(fMuon2 !=0 && !Selected(fMuon2)) {NextPartner();}
185 TParticle* AliDimuCombinator::Partner()
187 // Returns current partner for muon to form a dimuon
191 void AliDimuCombinator::FirstMuonPair(TParticle* & muon1, TParticle* & muon2)
193 // Dimuon iterator: initialisation
200 void AliDimuCombinator::NextMuonPair(TParticle* & muon1, TParticle* & muon2)
202 // Dimuon iterator: increment
211 void AliDimuCombinator::FirstMuonPairSelected(TParticle* & muon1,
214 // Selected dimuon iterator: initialisation
216 FirstPartnerSelected();
221 void AliDimuCombinator::NextMuonPairSelected(TParticle* & muon1,
224 // Selected dimuon iterator: increment
225 NextPartnerSelected();
228 FirstPartnerSelected();
234 void AliDimuCombinator::ResetRange()
236 // Reset index ranges for single muons
238 fImax1 = fImax2 = fNParticle;
241 void AliDimuCombinator::SetFirstRange(Int_t from, Int_t to)
243 // Reset index range for first muon
246 if (fImax1 > fNParticle) fImax1 = fNParticle;
249 void AliDimuCombinator::SetSecondRange(Int_t from, Int_t to)
251 // Reset index range for second muon
254 if (fImax2 > fNParticle) fImax2 = fNParticle;
260 Bool_t AliDimuCombinator::Selected(TParticle* part)
262 // Selection cut for single muon
264 if (part == 0) {return 0;}
266 if (part->Pt() > fPtMin && part->Eta() > fEtaMin && part->Eta() < fEtaMax) {
273 Bool_t AliDimuCombinator::Selected(TParticle* part1, TParticle* part2)
275 // Selection cut for dimuons
277 return Selected(part1)*Selected(part2);
282 Float_t AliDimuCombinator::Mass(TParticle* part1, TParticle* part2)
287 px = part1->Px()+part2->Px();
288 py = part1->Py()+part2->Py();
289 pz = part1->Pz()+part2->Pz();
290 e = part1->Energy()+part2->Energy();
291 Float_t p = px*px+py*py+pz*pz;
295 return TMath::Sqrt(e*e-p);
299 Float_t AliDimuCombinator::PT(TParticle* part1, TParticle* part2)
301 // Transverse momentum of dimuons
304 px = part1->Px()+part2->Px();
305 py = part1->Py()+part2->Py();
306 return TMath::Sqrt(px*px+py*py);
309 Float_t AliDimuCombinator::Pz(TParticle* part1, TParticle* part2)
311 // Pz of dimuon system
313 return part1->Pz()+part2->Pz();
316 Float_t AliDimuCombinator::Y(TParticle* part1, TParticle* part2)
318 // Rapidity of dimuon system
321 pz = part1->Pz()+part2->Pz();
322 e = part1->Energy()+part2->Energy();
323 return 0.5*TMath::Log((e+pz)/(e-pz));
327 void AliDimuCombinator::SmearGauss(Float_t width, Float_t & value)
329 // Apply gaussian smearing
331 value+=gRandom->Gaus(0, width);
336 Float_t AliDimuCombinator::DecayProbability(TParticle* part)
338 // Calculate decay probability for muons from pion and kaon decays
340 Float_t d, h, theta, cTau;
341 TParticle* parent = Parent(part);
342 Int_t ipar = Type(parent);
343 if (ipar == kPiPlus || ipar == kPiMinus) {
345 } else if (ipar == kKPlus || ipar == kKMinus) {
352 Float_t gammaBeta=(parent->P())/(parent->GetMass());
354 // this part is still very ALICE muon-arm specific
356 theta = parent->Theta();
357 h = 90*TMath::Tan(theta);
360 d=4/TMath::Sin(theta);
362 d=90/TMath::Cos(theta);
366 return 1-TMath::Exp(-d/cTau/gammaBeta);
372 Float_t AliDimuCombinator::Weight(TParticle* part1, TParticle* part2)
376 Float_t wgt = (part1->GetWeight())*(part2->GetWeight());
378 if (Correlated(part1, part2)) {
379 return wgt/(Parent(part1)->GetWeight())*fRate1;
381 return wgt*fRate1*fRate2;
386 Float_t AliDimuCombinator::Weight(TParticle* part)
388 // Single muon weight
389 return (part->GetWeight())*(Parent(part)->GetWeight())*fRate1;
392 Bool_t AliDimuCombinator::Correlated(TParticle* part1, TParticle* part2)
394 // Check if muons are correlated
396 if (Origin(part1) == Origin(part2)) {
403 TParticle* AliDimuCombinator::Parent(TParticle* part)
405 // Return pointer to parent
407 return Particle(part->GetFirstMother());
410 Int_t AliDimuCombinator::Origin(TParticle* part)
412 // Return pointer to primary particle
414 Int_t iparent= part->GetFirstMother();
415 if (iparent < 0) return iparent;
418 ip = (Particle(iparent))->GetFirstMother();
428 Int_t AliDimuCombinator::Type(TParticle *part)
430 // Return particle type for
431 return part->GetPdgCode();
434 AliDimuCombinator& AliDimuCombinator::operator=(const AliDimuCombinator& rhs)
436 // Assignment operator
441 void AliDimuCombinator::Copy(AliDimuCombinator &combi) const
444 // Copy *this onto lego -- not implemented
446 Fatal("Copy","Not implemented!\n");