Added class AliMFTRecoParam.cxx/h
[u/mrichter/AliRoot.git] / MFT / AliMuonForwardTrackPair.cxx
CommitLineData
820b4d9e 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
35ClassImp(AliMuonForwardTrackPair)
36
37//====================================================================================================================================================
38
39AliMuonForwardTrackPair::AliMuonForwardTrackPair():
40 TObject(),
d4643a10 41 fMuonForwardTracks(0),
bcaf50eb 42 fKinemMC(0,0,0,0),
43 fKinem(0,0,0,0),
44 fIsKinemSet(kFALSE)
820b4d9e 45{
46
47 // default constructor
48
49 fMuonForwardTracks = new TClonesArray("AliMuonForwardTrack", 2);
50
51}
52
53//====================================================================================================================================================
54
55AliMuonForwardTrackPair::AliMuonForwardTrackPair(AliMuonForwardTrack *track0, AliMuonForwardTrack *track1):
56 TObject(),
d4643a10 57 fMuonForwardTracks(0),
bcaf50eb 58 fKinemMC(0,0,0,0),
59 fKinem(0,0,0,0),
60 fIsKinemSet(kFALSE)
820b4d9e 61{
62
63 fMuonForwardTracks = new TClonesArray("AliMuonForwardTrack", 2);
64
65 new ((*fMuonForwardTracks)[0]) AliMuonForwardTrack(*track0);
66 new ((*fMuonForwardTracks)[1]) AliMuonForwardTrack(*track1);
67
d4643a10 68 SetKinemMC();
69
820b4d9e 70}
71
72//====================================================================================================================================================
73
74AliMuonForwardTrackPair::AliMuonForwardTrackPair(const AliMuonForwardTrackPair& trackPair):
75 TObject(trackPair),
d4643a10 76 fMuonForwardTracks(trackPair.fMuonForwardTracks),
bcaf50eb 77 fKinemMC(trackPair.fKinemMC),
78 fKinem(trackPair.fKinem),
79 fIsKinemSet(trackPair.fIsKinemSet)
820b4d9e 80{
81
82 // copy constructor
83
84}
85
86//====================================================================================================================================================
87
88AliMuonForwardTrackPair& AliMuonForwardTrackPair::operator=(const AliMuonForwardTrackPair& trackPair) {
89
90 // Asignment operator
91
92 // check assignement to self
93 if (this == &trackPair) return *this;
94
95 // base class assignement
96 AliMuonForwardTrackPair::operator=(trackPair);
97
98 // clear memory
99 Clear();
100
101 fMuonForwardTracks = trackPair.fMuonForwardTracks;
bcaf50eb 102 fKinemMC = trackPair.fKinemMC;
103 fKinem = trackPair.fKinem;
104 fIsKinemSet = trackPair.fIsKinemSet;
820b4d9e 105
106 return *this;
107
108}
109
110//====================================================================================================================================================
111
112void AliMuonForwardTrackPair::SetTrack(Int_t iTrack, AliMuonForwardTrack *track) {
113
114 if (iTrack==0 || iTrack==1) {
115 new ((*fMuonForwardTracks)[iTrack]) AliMuonForwardTrack(*track);
116 }
117
118}
119
120//====================================================================================================================================================
121
122Double_t AliMuonForwardTrackPair::GetWeightedOffset(Double_t x, Double_t y, Double_t z) {
123
124 Double_t weightedOffset[2]={0};
125
126 weightedOffset[0] = ((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetWeightedOffset(x, y, z);
127 weightedOffset[1] = ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetWeightedOffset(x, y, z);
128
129 Double_t weightedOffsetDimuon = TMath::Sqrt(0.5 * (weightedOffset[0]*weightedOffset[0] + weightedOffset[1]*weightedOffset[1]));
130
131 return weightedOffsetDimuon;
132
133}
134
135//====================================================================================================================================================
136
820b4d9e 137Double_t AliMuonForwardTrackPair::GetMassWithoutMFT(Double_t x, Double_t y, Double_t z, Int_t nClusters) {
138
139 Int_t idCluster[2] = {0};
140 if (nClusters>0) {
141 idCluster[0] = ((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetNMUONClusters() - nClusters;
142 idCluster[1] = ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetNMUONClusters() - nClusters;
143 }
144 if (idCluster[0]<0) idCluster[0] = 0;
145 if (idCluster[1]<0) idCluster[1] = 0;
146
147 AliMUONTrackParam *param0 = ((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetTrackParamAtMUONCluster(idCluster[0]);
148 AliMUONTrackParam *param1 = ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetTrackParamAtMUONCluster(idCluster[1]);
149
d4643a10 150 AliDebug(2, Form("MUON before extrap: 1st muon = (%f, %f, %f) 2nd muon = (%f, %f, %f)",
151 param0->Px(), param0->Py(), param0->Pz(),
152 param1->Px(), param1->Py(), param1->Pz()));
153
154 AliDebug(2, Form("Extrapolating 1st muon from z = %f to z = %f", param0->GetZ(), z));
820b4d9e 155 AliMUONTrackExtrap::ExtrapToVertex(param0, x, y, z, 0., 0.); // this should reproduce what is done in AliMUONESDInterface::MUONToESD(...)
d4643a10 156 AliDebug(2, Form("Extrapolating 2nd muon from z = %f to z = %f", param1->GetZ(), z));
820b4d9e 157 AliMUONTrackExtrap::ExtrapToVertex(param1, x, y, z, 0., 0.); // this should reproduce what is done in AliMUONESDInterface::MUONToESD(...)
158
d4643a10 159 AliDebug(2, Form("MUON after extrap: 1st muon = (%f, %f, %f) 2nd muon = (%f, %f, %f)",
160 param0->Px(), param0->Py(), param0->Pz(),
161 param1->Px(), param1->Py(), param1->Pz()));
162
820b4d9e 163 Double_t momentum[2] = {0};
164
165 momentum[0] = param0->P();
166 momentum[1] = param1->P();
167
168 Double_t mMu = TDatabasePDG::Instance()->GetParticle("mu-")->Mass();
169
170 TLorentzVector dimu;
171
172 dimu.SetE(TMath::Sqrt(mMu*mMu + momentum[0]*momentum[0]) + TMath::Sqrt(mMu*mMu + momentum[1]*momentum[1]));
173
174 dimu.SetPx(param0->Px() + param1->Px());
175 dimu.SetPy(param0->Py() + param1->Py());
176 dimu.SetPz(param0->Pz() + param1->Pz());
177
178 return dimu.M();
179
180}
181
182//====================================================================================================================================================
183
d4643a10 184void AliMuonForwardTrackPair::SetKinemMC() {
7230691d 185
bcaf50eb 186 if ( !(((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetMCTrackRef()) ||
187 !(((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetMCTrackRef()) ) return;
188
d4643a10 189 AliDebug(2, Form("MC: 1st muon = (%f, %f, %f) 2nd muon = (%f, %f, %f)",
190 ((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetMCTrackRef()->Px(),
191 ((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetMCTrackRef()->Py(),
192 ((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetMCTrackRef()->Pz(),
193 ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetMCTrackRef()->Px(),
194 ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetMCTrackRef()->Py(),
195 ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetMCTrackRef()->Pz()));
7230691d 196
d4643a10 197 fKinemMC.SetE(((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetMCTrackRef()->Energy() +
198 ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetMCTrackRef()->Energy());
199
200 fKinemMC.SetPx(((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetMCTrackRef()->Px() +
201 ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetMCTrackRef()->Px());
202
203 fKinemMC.SetPy(((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetMCTrackRef()->Py() +
204 ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetMCTrackRef()->Py());
205
206 fKinemMC.SetPz(((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetMCTrackRef()->Pz() +
207 ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetMCTrackRef()->Pz());
820b4d9e 208
209}
210
211//====================================================================================================================================================
bcaf50eb 212
213void AliMuonForwardTrackPair::SetKinem(Double_t z, Int_t nClusters) {
214
215// if (!fMuonForwardTracks) return kFALSE;
216// if (!fMuonForwardTracks->At(0) || !fMuonForwardTracks->At(1)) return kFALSE;
217
218 Int_t idCluster[2] = {0};
219 if (nClusters>0) {
220 idCluster[0] = ((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetNMFTClusters() - nClusters;
221 idCluster[1] = ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetNMFTClusters() - nClusters;
222 }
223 if (idCluster[0]<0) idCluster[0] = 0;
224 if (idCluster[1]<0) idCluster[1] = 0;
225
226 Double_t momentum[2] = {0};
227
228 AliMUONTrackParam *param0 = ((AliMuonForwardTrack*) fMuonForwardTracks->At(0))->GetTrackParamAtMFTCluster(idCluster[0]);
229 AliMUONTrackParam *param1 = ((AliMuonForwardTrack*) fMuonForwardTracks->At(1))->GetTrackParamAtMFTCluster(idCluster[1]);
230
231 AliDebug(2, Form("MFT before extrap: 1st muon = (%f, %f, %f) 2nd muon = (%f, %f, %f)",
232 param0->Px(), param0->Py(), param0->Pz(),
233 param1->Px(), param1->Py(), param1->Pz()));
234
235 if (TMath::Abs(z)<1e6) {
236 AliDebug(2, Form("Extrapolating 1st muon from z = %f to z = %f", param0->GetZ(), z));
237 AliMUONTrackExtrap::ExtrapToZCov(param0, z);
238 AliDebug(2, Form("Extrapolating 2nd muon from z = %f to z = %f", param1->GetZ(), z));
239 AliMUONTrackExtrap::ExtrapToZCov(param1, z);
240 }
241
242 AliDebug(2, Form("MFT after extrap: 1st muon = (%f, %f, %f) 2nd muon = (%f, %f, %f)",
243 param0->Px(), param0->Py(), param0->Pz(),
244 param1->Px(), param1->Py(), param1->Pz()));
245
246 momentum[0] = (param0->P());
247 momentum[1] = (param1->P());
248
249 Double_t mMu = TDatabasePDG::Instance()->GetParticle("mu-")->Mass();
250
251 fKinem.SetE(TMath::Sqrt(mMu*mMu + momentum[0]*momentum[0]) + TMath::Sqrt(mMu*mMu + momentum[1]*momentum[1]));
252 fKinem.SetPx(param0->Px() + param1->Px());
253 fKinem.SetPy(param0->Py() + param1->Py());
254 fKinem.SetPz(param0->Pz() + param1->Pz());
255
256 fIsKinemSet = kTRUE;
257
258 // return fKinem.M();
259
260}
261
262//====================================================================================================================================================
820b4d9e 263
d4643a10 264Bool_t AliMuonForwardTrackPair::IsResonance() {
265
266 Bool_t result = kFALSE;
820b4d9e 267
d4643a10 268 Int_t labelMC[2] = {0};
269 Int_t codePDG[2] = {0};
270
271 for (Int_t iTrack=0; iTrack<2; iTrack++) {
272 labelMC[iTrack] = ((AliMuonForwardTrack*) fMuonForwardTracks->At(iTrack))->GetParentMCLabel(0);
273 codePDG[iTrack] = ((AliMuonForwardTrack*) fMuonForwardTracks->At(iTrack))->GetParentPDGCode(0);
274 }
820b4d9e 275
d4643a10 276 AliDebug(1, Form("Muons' mothers: (%d, %d)", labelMC[0], labelMC[1]));
820b4d9e 277
d4643a10 278 if (labelMC[0]==labelMC[1] && codePDG[0]==codePDG[1] && (codePDG[0]== 113 ||
7cb5b5b9 279 codePDG[0]== 221 ||
d4643a10 280 codePDG[0]== 223 ||
7cb5b5b9 281 codePDG[0]== 331 ||
d4643a10 282 codePDG[0]== 333 ||
283 codePDG[0]== 443 ||
284 codePDG[0]==100443 ||
285 codePDG[0]== 553 ||
286 codePDG[0]==100553 ) ) result = kTRUE;
820b4d9e 287
d4643a10 288 if (result) AliDebug(1, Form("Pair is a resonance %d", codePDG[0]));
820b4d9e 289
d4643a10 290 return result;
820b4d9e 291
d4643a10 292}
820b4d9e 293
d4643a10 294//====================================================================================================================================================