]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MFT/AliMuonForwardTrackPair.cxx
Clear method added to several classes
[u/mrichter/AliRoot.git] / MFT / AliMuonForwardTrackPair.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 //====================================================================================================================================================
17 //
18 //      Description of an ALICE muon forward track pair, i.e. a pair of AliMuonForwardTrack objects
19 //
20 //      Contact author: antonio.uras@cern.ch
21 //
22 //====================================================================================================================================================
23
24 #include "AliLog.h"
25 #include "AliMUONTrackParam.h"
26 #include "TParticle.h"
27 #include "AliMuonForwardTrack.h"
28 #include "AliMUONTrackExtrap.h"
29 #include "TClonesArray.h"
30 #include "TDatabasePDG.h"
31 #include "TLorentzVector.h"
32 #include "TRandom.h"
33 #include "AliMuonForwardTrackPair.h"
34
35 ClassImp(AliMuonForwardTrackPair)
36
37 //====================================================================================================================================================
38
39 AliMuonForwardTrackPair::AliMuonForwardTrackPair():
40   TObject(),
41   fMuonForwardTracks(0),
42   fKinemMC(0,0,0,0),
43   fKinem(0,0,0,0),
44   fIsKinemSet(kFALSE),
45   fXPointOfClosestApproach(9999),
46   fYPointOfClosestApproach(9999),
47   fZPointOfClosestApproach(9999)
48 {
49
50   // default constructor
51
52   fMuonForwardTracks = new TClonesArray("AliMuonForwardTrack", 2);
53   fMuonForwardTracks -> SetOwner(kTRUE);
54   
55 }
56
57 //====================================================================================================================================================
58
59 AliMuonForwardTrackPair::AliMuonForwardTrackPair(AliMuonForwardTrack *track0, AliMuonForwardTrack *track1):
60   TObject(),
61   fMuonForwardTracks(0),
62   fKinemMC(0,0,0,0),
63   fKinem(0,0,0,0),
64   fIsKinemSet(kFALSE),
65   fXPointOfClosestApproach(9999),
66   fYPointOfClosestApproach(9999),
67   fZPointOfClosestApproach(9999)
68 {
69
70   fMuonForwardTracks = new TClonesArray("AliMuonForwardTrack", 2);
71   fMuonForwardTracks->SetOwner(kTRUE);
72   new ((*fMuonForwardTracks)[0]) AliMuonForwardTrack(*track0);
73   new ((*fMuonForwardTracks)[1]) AliMuonForwardTrack(*track1);
74
75   SetKinemMC();
76   SetPointOfClosestApproach();
77
78 }
79
80 //====================================================================================================================================================
81
82 AliMuonForwardTrackPair::AliMuonForwardTrackPair(const AliMuonForwardTrackPair& trackPair): 
83   TObject(trackPair),
84   fMuonForwardTracks(NULL),
85   fKinemMC(trackPair.fKinemMC),
86   fKinem(trackPair.fKinem),
87   fIsKinemSet(trackPair.fIsKinemSet),
88   fXPointOfClosestApproach(trackPair.fXPointOfClosestApproach),
89   fYPointOfClosestApproach(trackPair.fYPointOfClosestApproach),
90   fZPointOfClosestApproach(trackPair.fZPointOfClosestApproach)
91 {
92
93   // copy constructor
94   fMuonForwardTracks = new TClonesArray(*(trackPair.fMuonForwardTracks));
95   fMuonForwardTracks -> SetOwner(kTRUE);
96
97 }
98
99 //====================================================================================================================================================
100
101 AliMuonForwardTrackPair& AliMuonForwardTrackPair::operator=(const AliMuonForwardTrackPair& trackPair) {
102
103   // Asignment operator
104
105   // check assignement to self
106   if (this == &trackPair) return *this;
107
108   // base class assignement
109   AliMuonForwardTrackPair::operator=(trackPair);
110   
111   // clear memory
112   Clear("");
113   
114   fMuonForwardTracks      = new TClonesArray(*(trackPair.fMuonForwardTracks));
115   fMuonForwardTracks->SetOwner(kTRUE);
116   
117   fKinemMC = trackPair.fKinemMC;
118   fKinem = trackPair.fKinem;
119   fIsKinemSet = trackPair.fIsKinemSet;
120   fXPointOfClosestApproach = trackPair.fXPointOfClosestApproach;
121   fYPointOfClosestApproach = trackPair.fYPointOfClosestApproach;
122   fZPointOfClosestApproach = trackPair.fZPointOfClosestApproach;
123
124   return *this;
125
126 }
127
128 //====================================================================================================================================================
129
130 Double_t AliMuonForwardTrackPair::GetWeightedOffset(Double_t x, Double_t y, Double_t z) {
131
132   Double_t weightedOffset[2]={0};
133
134   weightedOffset[0] = GetTrack(0)->GetWeightedOffset(x, y, z);
135   weightedOffset[1] = GetTrack(1)->GetWeightedOffset(x, y, z);
136
137   Double_t weightedOffsetDimuon = TMath::Sqrt(0.5 * (weightedOffset[0]*weightedOffset[0] + weightedOffset[1]*weightedOffset[1]));
138
139   return weightedOffsetDimuon;
140
141 }
142
143 //====================================================================================================================================================
144
145 Double_t AliMuonForwardTrackPair::GetMassWithoutMFT(Double_t x, Double_t y, Double_t z, Int_t nClusters) {
146
147   Int_t idCluster[2] = {0};
148   if (nClusters>0) {
149     idCluster[0] = GetTrack(0)->GetNMUONClusters() - nClusters;
150     idCluster[1] = GetTrack(1)->GetNMUONClusters() - nClusters;
151   }
152   if (idCluster[0]<0) idCluster[0] = 0;
153   if (idCluster[1]<0) idCluster[1] = 0;
154
155   AliMUONTrackParam *param0 = GetTrack(0)->GetTrackParamAtMUONCluster(idCluster[0]);
156   AliMUONTrackParam *param1 = GetTrack(1)->GetTrackParamAtMUONCluster(idCluster[1]);
157
158   AliDebug(2, Form("MUON before extrap: 1st muon = (%f, %f, %f) 2nd muon = (%f, %f, %f)", 
159                    param0->Px(), param0->Py(), param0->Pz(), param1->Px(), param1->Py(), param1->Pz()));
160
161   AliDebug(2, Form("Extrapolating 1st muon from z = %f to z = %f", param0->GetZ(), z));
162   AliMUONTrackExtrap::ExtrapToVertex(param0, x, y, z, 0., 0.);   // this should reproduce what is done in AliMUONESDInterface::MUONToESD(...) 
163   AliDebug(2, Form("Extrapolating 2nd muon from z = %f to z = %f", param1->GetZ(), z));
164   AliMUONTrackExtrap::ExtrapToVertex(param1, x, y, z, 0., 0.);   // this should reproduce what is done in AliMUONESDInterface::MUONToESD(...) 
165
166   AliDebug(2, Form("MUON after extrap: 1st muon = (%f, %f, %f) 2nd muon = (%f, %f, %f)", 
167                    param0->Px(), param0->Py(), param0->Pz(), param1->Px(), param1->Py(), param1->Pz()));
168
169   Double_t momentum[2] = {0}; 
170
171   momentum[0] = param0->P();
172   momentum[1] = param1->P();
173
174   Double_t mMu = TDatabasePDG::Instance()->GetParticle("mu-")->Mass();
175
176   TLorentzVector dimu;
177
178   dimu.SetE(TMath::Sqrt(mMu*mMu + momentum[0]*momentum[0]) + TMath::Sqrt(mMu*mMu + momentum[1]*momentum[1]));
179
180   dimu.SetPx(param0->Px() + param1->Px());
181   dimu.SetPy(param0->Py() + param1->Py());
182   dimu.SetPz(param0->Pz() + param1->Pz());
183
184   return dimu.M();
185
186 }
187
188 //====================================================================================================================================================
189
190 void AliMuonForwardTrackPair::SetKinemMC() {
191
192   if ( !(GetTrack(0)->GetMCTrackRef()) || !(GetTrack(1)->GetMCTrackRef()) ) return;
193
194   AliDebug(2, Form("MC: 1st muon = (%f, %f, %f) 2nd muon = (%f, %f, %f)", 
195                    GetTrack(0)->GetMCTrackRef()->Px(), GetTrack(0)->GetMCTrackRef()->Py(), GetTrack(0)->GetMCTrackRef()->Pz(),
196                    GetTrack(1)->GetMCTrackRef()->Px(), GetTrack(1)->GetMCTrackRef()->Py(), GetTrack(1)->GetMCTrackRef()->Pz()));
197
198   fKinemMC.SetE(GetTrack(0)->GetMCTrackRef()->Energy() + GetTrack(1)->GetMCTrackRef()->Energy());
199   
200   fKinemMC.SetPx(GetTrack(0)->GetMCTrackRef()->Px() + GetTrack(1)->GetMCTrackRef()->Px());
201   fKinemMC.SetPy(GetTrack(0)->GetMCTrackRef()->Py() + GetTrack(1)->GetMCTrackRef()->Py());
202   fKinemMC.SetPz(GetTrack(0)->GetMCTrackRef()->Pz() + GetTrack(1)->GetMCTrackRef()->Pz());
203
204 }
205
206 //====================================================================================================================================================
207
208 void AliMuonForwardTrackPair::SetKinem(Double_t z, Int_t nClusters) {
209
210 //   if (!fMuonForwardTracks) return kFALSE;
211 //   if (!fMuonForwardTracks->At(0) || !fMuonForwardTracks->At(1)) return kFALSE;
212
213   Int_t idCluster[2] = {0};
214   if (nClusters>0) {
215     idCluster[0] = GetTrack(0)->GetNMFTClusters() - nClusters;
216     idCluster[1] = GetTrack(1)->GetNMFTClusters() - nClusters;
217   }
218   if (idCluster[0]<0) idCluster[0] = 0;
219   if (idCluster[1]<0) idCluster[1] = 0;
220
221   Double_t momentum[2] = {0};
222   
223   AliMUONTrackParam *param0 = GetTrack(0)->GetTrackParamAtMFTCluster(idCluster[0]);
224   AliMUONTrackParam *param1 = GetTrack(1)->GetTrackParamAtMFTCluster(idCluster[1]);
225
226   AliDebug(2, Form("MFT before extrap: 1st muon = (%f, %f, %f) 2nd muon = (%f, %f, %f)", 
227                    param0->Px(), param0->Py(), param0->Pz(), param1->Px(), param1->Py(), param1->Pz()));
228
229   if (TMath::Abs(z)<1e6) {
230     AliDebug(2, Form("Extrapolating 1st muon from z = %f to z = %f", param0->GetZ(), z));
231     AliMUONTrackExtrap::ExtrapToZCov(param0, z);
232     AliDebug(2, Form("Extrapolating 2nd muon from z = %f to z = %f", param1->GetZ(), z));
233     AliMUONTrackExtrap::ExtrapToZCov(param1, z);
234   }
235
236   AliDebug(2, Form("MFT after extrap: 1st muon = (%f, %f, %f) 2nd muon = (%f, %f, %f)", 
237                    param0->Px(), param0->Py(), param0->Pz(), param1->Px(), param1->Py(), param1->Pz()));
238
239   momentum[0] = (param0->P());
240   momentum[1] = (param1->P());
241
242   Double_t mMu = TDatabasePDG::Instance()->GetParticle("mu-")->Mass();
243
244   fKinem.SetE(TMath::Sqrt(mMu*mMu + momentum[0]*momentum[0]) + TMath::Sqrt(mMu*mMu + momentum[1]*momentum[1]));
245   fKinem.SetPx(param0->Px() + param1->Px());
246   fKinem.SetPy(param0->Py() + param1->Py());
247   fKinem.SetPz(param0->Pz() + param1->Pz());
248
249   fIsKinemSet = kTRUE;
250
251 }
252
253 //====================================================================================================================================================
254
255 void AliMuonForwardTrackPair::SetPointOfClosestApproach() {
256   
257   AliMUONTrackParam *param0 = GetTrack(0)->GetTrackParamAtMFTCluster(0);
258   AliMUONTrackParam *param1 = GetTrack(1)->GetTrackParamAtMFTCluster(0);
259   
260   Double_t step = 1.;  // in cm
261   Double_t startPoint = 0.;
262
263   Double_t r[3]={0}, z[3]={startPoint, startPoint+step, startPoint+2*step};
264   
265   for (Int_t i=0; i<3; i++) {
266     AliMUONTrackExtrap::ExtrapToZCov(param0, z[i]);
267     AliMUONTrackExtrap::ExtrapToZCov(param1, z[i]);
268     Double_t dX = param0->GetNonBendingCoor() - param1->GetNonBendingCoor();
269     Double_t dY = param0->GetBendingCoor()    - param1->GetBendingCoor();
270     r[i] = TMath::Sqrt(dX*dX + dY*dY);
271   }
272   
273   Double_t researchDirection=0.;
274   
275   if      (r[0]>r[1] && r[1]>r[2]) researchDirection = +1.;   // towards z positive
276   else if (r[0]<r[1] && r[1]<r[2]) researchDirection = -1.;   // towards z negative
277   else if (r[0]<r[1] && r[1]>r[2]) { 
278     AliError("Point of closest approach cannot be found for dimuon (no minima)");
279     return;
280   }
281   
282   while (TMath::Abs(researchDirection)>0.5) {
283     if (researchDirection>0.) {
284       z[0] = z[1];
285       z[1] = z[2];
286       z[2] = z[1]+researchDirection*step;
287     }
288     else {
289       z[2] = z[1];
290       z[1] = z[0];
291       z[0] = z[1]+researchDirection*step;
292     }
293     if (TMath::Abs(z[0])>900.) {
294       AliError("Point of closest approach cannot be found for dimuon (no minima)");
295       return;
296     }
297     for (Int_t i=0; i<3; i++) {
298       AliMUONTrackExtrap::ExtrapToZCov(param0, z[i]);
299       AliMUONTrackExtrap::ExtrapToZCov(param1, z[i]);
300       Double_t dX = param0->GetNonBendingCoor() - param1->GetNonBendingCoor();
301       Double_t dY = param0->GetBendingCoor()    - param1->GetBendingCoor();
302       r[i] = TMath::Sqrt(dX*dX + dY*dY);
303     }
304     researchDirection=0.;
305     if      (r[0]>r[1] && r[1]>r[2]) researchDirection = +1.;   // towards z positive
306     else if (r[0]<r[1] && r[1]<r[2]) researchDirection = -1.;   // towards z negative
307   }
308   
309   AliDebug(2,"Minimum region has been found");
310   
311   step *= 0.5;
312   while (step>AliMFTConstants::fPrecisionPointOfClosestApproach) {
313     z[0] = z[1]-step;
314     z[2] = z[1]+step;
315     for (Int_t i=0; i<3; i++) {
316       AliMUONTrackExtrap::ExtrapToZCov(param0, z[i]);
317       AliMUONTrackExtrap::ExtrapToZCov(param1, z[i]);
318       Double_t dX = param0->GetNonBendingCoor() - param1->GetNonBendingCoor();
319       Double_t dY = param0->GetBendingCoor()    - param1->GetBendingCoor();
320       r[i] = TMath::Sqrt(dX*dX + dY*dY);
321     }
322     if      (r[0]<r[1]) z[1] = z[0];
323     else if (r[2]<r[1]) z[1] = z[2];
324     else step *= 0.5;
325   }
326   
327   fZPointOfClosestApproach = z[1];
328   AliMUONTrackExtrap::ExtrapToZCov(param0, fZPointOfClosestApproach);
329   AliMUONTrackExtrap::ExtrapToZCov(param1, fZPointOfClosestApproach);  
330   fXPointOfClosestApproach = 0.5*(param0->GetNonBendingCoor() + param1->GetNonBendingCoor());
331   fYPointOfClosestApproach = 0.5*(param0->GetBendingCoor()    + param1->GetBendingCoor());
332   
333   AliDebug(2,Form("Point of Closest Approach: (%f, %f, %f)",fXPointOfClosestApproach,fYPointOfClosestApproach,fZPointOfClosestApproach));
334   
335 }
336
337 //====================================================================================================================================================
338
339 Bool_t AliMuonForwardTrackPair::IsResonance() {
340
341   Bool_t result = kFALSE;
342
343   Int_t labelMC[2] = {0};
344   Int_t codePDG[2] = {0};
345   
346   for (Int_t iTrack=0; iTrack<2; iTrack++) {
347     labelMC[iTrack] = GetTrack(iTrack)->GetParentMCLabel(0);
348     codePDG[iTrack] = GetTrack(iTrack)->GetParentPDGCode(0);
349   }
350
351   AliDebug(1, Form("Muons' mothers: (%d, %d)", labelMC[0], labelMC[1]));
352
353   if (labelMC[0]==labelMC[1] && codePDG[0]==codePDG[1] && (codePDG[0]==   113 ||
354                                                            codePDG[0]==   221 ||
355                                                            codePDG[0]==   223 ||
356                                                            codePDG[0]==   331 ||
357                                                            codePDG[0]==   333 ||
358                                                            codePDG[0]==   443 ||
359                                                            codePDG[0]==100443 ||
360                                                            codePDG[0]==   553 ||
361                                                            codePDG[0]==100553 ) ) result = kTRUE;
362
363   if (result) AliDebug(1, Form("Pair is a resonance %d", codePDG[0]));
364
365   return result; 
366
367 }
368
369 //====================================================================================================================================================