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 **************************************************************************/
20 #include "AliInvmass.h"
22 ClassImp(AliInvmass) // Class implementation to enable ROOT I/O
24 AliInvmass::AliInvmass()
26 // Creation of an AliInvmass object and initialisation of parameters
35 ////////////////////////////////////////////////////////////////////////////////
36 AliInvmass::~AliInvmass()
38 // Destructor to delete dynamically allocated memory
53 ////////////////////////////////////////////////////////////////////////////////
54 void AliInvmass::SetStorageMode(Int_t m)
56 // Set storage mode for the result arrays for inv. mass and comb. background
60 ////////////////////////////////////////////////////////////////////////////////
61 void AliInvmass::SetThetaSwitch(Int_t i)
63 // Enable/Disable (1/0) switching of theta angle in comb. bkg. reconstruction.
64 // Default : Switching of theta is enabled.
66 if (i==0) fNewtheta=0;
68 ////////////////////////////////////////////////////////////////////////////////
69 void AliInvmass::SetPhiSwitch(Int_t i)
71 // Enable/Disable (1/0) switching of phi angle in comb. bkg. reconstruction.
72 // Default : Switching of phi is enabled.
76 ////////////////////////////////////////////////////////////////////////////////
77 Int_t AliInvmass::GetStorageMode()
79 // Provide mode of storage for the result arrays for inv. mass and comb. background
82 ////////////////////////////////////////////////////////////////////////////////
83 Int_t AliInvmass::GetThetaSwitch()
85 // Provide the theta switching flag
88 ////////////////////////////////////////////////////////////////////////////////
89 Int_t AliInvmass::GetPhiSwitch()
91 // Provide the phi switching flag
94 ////////////////////////////////////////////////////////////////////////////////
95 TObjArray* AliInvmass::Invmass(TObjArray* a1,TObjArray* a2)
97 // Perform two-particle invariant mass reconstruction
102 ////////////////////////////////////////////////////////////////////////////////
103 TObjArray* AliInvmass::CombBkg(TObjArray* a1,TObjArray* a2)
105 // Perform two-particle combinatorial background reconstruction
117 ////////////////////////////////////////////////////////////////////////////////
118 void AliInvmass::Combine(TObjArray* a1,TObjArray* a2)
120 // Perform two-particle invariant mass reconstruction
122 if ((!fBkg || fMode==1) && fMinv)
129 if (fBkg && (fMode !=1) && fMbkg)
136 Int_t isame; // Indicates whether both lists are identical
140 // Index i must loop over the shortest of a1 and a2
143 Int_t ni=a1->GetEntries();
144 Int_t nj=a2->GetEntries();
158 Double_t v2[4],vx[4];
161 Int_t jmin; // Start index for list j
162 Int_t jx; // Index for randomly picked particle for comb. bkg. reconstruction
164 for (Int_t i=0; i<ni; i++) // Select first a particle from list i
166 p1=(AliTrack*)listi->At(i);
173 for (Int_t j=jmin; j<nj; j++) // Select also a particle from list j
175 p2=(AliTrack*)listj->At(j);
176 if (p1==p2) p2=0; // Don't combine particle with itself
180 p2->GetVector(v2,"sph");
182 // Take theta and phi from randomly chosen other list j particle for bkg. reconstr.
186 if ((!isame && nj>1) || (isame && nj>2))
188 jx=int(fRndm.Uniform(0,float(nj)));
189 px=(AliTrack*)listj->At(jx);
191 while (!px || px==p2 || px==p1)
195 px=(AliTrack*)listj->At(jx);
198 px->GetVector(vx,"sph");
199 if (fNewtheta) v2[2]=vx[2]; // Replace the theta angle in the v2 vector
200 if (fNewphi) v2[3]=vx[3]; // Replace the phi angle in the v2 vector
204 if ((!fBkg && p2) || (fBkg && px))
206 // Store the data of this two-particle combination
207 ptot.SetVector(v2,"sph");
208 ptot=(Ali4Vector)(ptot+(*p1));
212 t->Set4Momentum(ptot);
214 if (!fBkg || fMode==1)
216 if (!fMinv) fMinv=new TObjArray();
221 if (!fMbkg) fMbkg=new TObjArray();
226 } // End of second particle loop
228 } // End of first particle loop
230 ////////////////////////////////////////////////////////////////////////////////