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.2 1999/09/29 09:24:28 fca
19 Introduction of the Copyright and cvs Log
23 ////////////////////////////////////////////////////////////////////////////////
25 // Construction of invariant mass and combinatorial background.
30 // TObjArray* photons=new TObjArray(); // Array with photon tracks for pi0 rec.
32 // // Code to create some photon tracks from pi0 decays
34 // for (Int_t i=0; i<ntracks; i++)
36 // photons->Add(new Alitrack);
42 // // Perform the invariant mass and comb. bkg. reconstruction
44 // TObjArray* allm=q.Invmass(photons,photons); // All reconstructed invariant masses
46 // TH1F* hall=new TH1F("hall","hall",200,0,2); // Histo with M_inv of all combinations
49 // if (allm) nall=allm->GetEntries();
53 // for (Int_t j=0; j<nall; j++)
55 // t=(AliTrack*)allm->At(j);
63 // TObjArray* bkgm=q.CombBkg(photons,photons); // Reconstructed comb. background
65 // TH1F* hbkg=new TH1F("hbkg","hbkg",200,0,2); // Histo with M_inv. of comb. background
68 // if (bkgm) nbkg=bkgm->GetEntries();
70 // for (Int_t j=0; j<nbkg; j++)
72 // t=(AliTrack*)bkgm->At(j);
80 // TH1F* hsig=new TH1F("sig","sig",200,0,2); // Histo with the bkg. subtracted signal
82 // hsig->Add(hall,hbkg,1,-1);
85 // Note : By default the storage of the reconstructed information is performed
86 // in separate TObjArrays for the signal and comb. background resp.
87 // In order to limit the memory usage, AliInvmass::SetStorageMode(1) may be
88 // used to activate only a single TObjArray to store the reconstructed information.
89 // Consequently, the following statements
91 // TObjArray* allm=q.Invmass(photons,photons);
92 // TObjArray* bkgm=q.CombBkg(photons,photons);
94 // will result in the fact that after he invokation of CombBkg
95 // the information of "allm" is lost due to the fact that the storage is
96 // is re-used for "bkgm" in case the "single storage" option has been selected.
97 // Usage of the, in that case invalid, pointer "allm" may cause your
100 // * Thus : In case of single storage usage, all invokations of the returned
101 // array pointer have to be completed before invoking any memberfunction
102 // of the same AliInvmass object again.
106 //--- Author: Nick van Eijndhoven 12-apr-1999 UU-SAP Utrecht
107 ////////////////////////////////////////////////////////////////////////////////
109 #include "AliInvmass.h"
111 ClassImp(AliInvmass) // Class implementation to enable ROOT I/O
113 AliInvmass::AliInvmass()
115 // Creation of an AliInvmass object and initialisation of parameters
124 ////////////////////////////////////////////////////////////////////////////////
125 AliInvmass::~AliInvmass()
127 // Destructor to delete dynamically allocated memory
142 ////////////////////////////////////////////////////////////////////////////////
143 void AliInvmass::SetStorageMode(Int_t m)
145 // Set storage mode for the result arrays for inv. mass and comb. background
149 ////////////////////////////////////////////////////////////////////////////////
150 void AliInvmass::SetThetaSwitch(Int_t i)
152 // Enable/Disable (1/0) switching of theta angle in comb. bkg. reconstruction.
153 // Default : Switching of theta is enabled.
155 if (i==0) fNewtheta=0;
157 ////////////////////////////////////////////////////////////////////////////////
158 void AliInvmass::SetPhiSwitch(Int_t i)
160 // Enable/Disable (1/0) switching of phi angle in comb. bkg. reconstruction.
161 // Default : Switching of phi is enabled.
165 ////////////////////////////////////////////////////////////////////////////////
166 Int_t AliInvmass::GetStorageMode()
168 // Provide mode of storage for the result arrays for inv. mass and comb. background
171 ////////////////////////////////////////////////////////////////////////////////
172 Int_t AliInvmass::GetThetaSwitch()
174 // Provide the theta switching flag
177 ////////////////////////////////////////////////////////////////////////////////
178 Int_t AliInvmass::GetPhiSwitch()
180 // Provide the phi switching flag
183 ////////////////////////////////////////////////////////////////////////////////
184 TObjArray* AliInvmass::Invmass(TObjArray* a1,TObjArray* a2)
186 // Perform two-particle invariant mass reconstruction
191 ////////////////////////////////////////////////////////////////////////////////
192 TObjArray* AliInvmass::CombBkg(TObjArray* a1,TObjArray* a2)
194 // Perform two-particle combinatorial background reconstruction
206 ////////////////////////////////////////////////////////////////////////////////
207 void AliInvmass::Combine(TObjArray* a1,TObjArray* a2)
209 // Perform two-particle invariant mass reconstruction
211 if ((!fBkg || fMode==1) && fMinv)
218 if (fBkg && (fMode !=1) && fMbkg)
225 Int_t isame; // Indicates whether both lists are identical
229 // Index i must loop over the shortest of a1 and a2
232 Int_t ni=a1->GetEntries();
233 Int_t nj=a2->GetEntries();
247 Double_t v2[4],vx[4];
250 Int_t jmin; // Start index for list j
251 Int_t jx; // Index for randomly picked particle for comb. bkg. reconstruction
253 for (Int_t i=0; i<ni; i++) // Select first a particle from list i
255 p1=(AliTrack*)listi->At(i);
262 for (Int_t j=jmin; j<nj; j++) // Select also a particle from list j
264 p2=(AliTrack*)listj->At(j);
265 if (p1==p2) p2=0; // Don't combine particle with itself
269 p2->GetVector(v2,"sph");
271 // Take theta and phi from randomly chosen other list j particle for bkg. reconstr.
275 if ((!isame && nj>1) || (isame && nj>2))
277 jx=int(fRndm.Uniform(0,float(nj)));
278 px=(AliTrack*)listj->At(jx);
280 while (!px || px==p2 || px==p1)
284 px=(AliTrack*)listj->At(jx);
287 px->GetVector(vx,"sph");
288 if (fNewtheta) v2[2]=vx[2]; // Replace the theta angle in the v2 vector
289 if (fNewphi) v2[3]=vx[3]; // Replace the phi angle in the v2 vector
293 if ((!fBkg && p2) || (fBkg && px))
295 // Store the data of this two-particle combination
296 ptot.SetVector(v2,"sph");
297 ptot=(Ali4Vector)(ptot+(*p1));
301 t->Set4Momentum(ptot);
303 if (!fBkg || fMode==1)
305 if (!fMinv) fMinv=new TObjArray();
310 if (!fMbkg) fMbkg=new TObjArray();
315 } // End of second particle loop
317 } // End of first particle loop
319 ////////////////////////////////////////////////////////////////////////////////