]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MFT/AliMFTSupport.cxx
Support and analysis code modified
[u/mrichter/AliRoot.git] / MFT / AliMFTSupport.cxx
CommitLineData
d30a0b7b 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// Support class for various common operation on MFT objects
19//
20// Contact author: antonio.uras@cern.ch
21//
22//====================================================================================================================================================
23
24#include "AliMUONTrackParam.h"
25#include "AliMUONTrackExtrap.h"
26#include "AliAODTrack.h"
27#include "AliAODDimuon.h"
28#include "TLorentzVector.h"
29#include "AliMFTConstants.h"
30#include "TDatabasePDG.h"
31#include "TMath.h"
32#include "AliLog.h"
33
34#include "AliMFTSupport.h"
35
36ClassImp(AliMFTSupport)
37
38//====================================================================================================================================================
39
40Bool_t AliMFTSupport::ExtrapAODMuonToZ(AliAODTrack *muon, Double_t z, Double_t xy[2]) {
41
42 if (!(muon->Pz()!=0)) return kFALSE;
43
44 AliMUONTrackParam *param = new AliMUONTrackParam();
45
46 param -> SetNonBendingCoor(muon->XAtDCA());
47 param -> SetBendingCoor(muon->YAtDCA());
9aa4fd6b 48 param -> SetZ(AliMFTConstants::fZEvalKinem);
d30a0b7b 49 param -> SetNonBendingSlope(muon->Px()/muon->Pz());
50 param -> SetBendingSlope(muon->Py()/muon->Pz());
51 param -> SetInverseBendingMomentum( muon->Charge() * (1./muon->Pz()) / (TMath::Sqrt(1+TMath::Power(muon->Py()/muon->Pz(),2))) );
52
53 AliMUONTrackExtrap::ExtrapToZ(param, z);
54 xy[0] = param->GetNonBendingCoor();
55 xy[1] = param->GetBendingCoor();
56
57 return kTRUE;
58
59}
60
61//====================================================================================================================================================
62
63Bool_t AliMFTSupport::RefitAODDimuonWithCommonVertex(AliAODDimuon *dimuon, Double_t *vertex, TLorentzVector &kinem) {
64
65 Double_t fXPointOfClosestApproach=0, fYPointOfClosestApproach=0, fZPointOfClosestApproach=0;
66
67 AliAODTrack *muon0 = dimuon->GetMu(0);
68 AliAODTrack *muon1 = dimuon->GetMu(1);
69
70 if (!(muon0->Pz()!=0 && muon1->Pz()!=0)) return kFALSE;
71
72 AliMUONTrackParam *param0 = new AliMUONTrackParam();
73 AliMUONTrackParam *param1 = new AliMUONTrackParam();
74
75 param0 -> SetNonBendingCoor(muon0->XAtDCA());
76 param1 -> SetNonBendingCoor(muon1->XAtDCA());
77
78 param0 -> SetBendingCoor(muon0->YAtDCA());
79 param1 -> SetBendingCoor(muon1->YAtDCA());
80
9aa4fd6b 81 param0 -> SetZ(AliMFTConstants::fZEvalKinem);
82 param1 -> SetZ(AliMFTConstants::fZEvalKinem);
d30a0b7b 83
84 param0 -> SetNonBendingSlope(muon0->Px()/muon0->Pz());
85 param1 -> SetNonBendingSlope(muon1->Px()/muon1->Pz());
86
87 param0 -> SetBendingSlope(muon0->Py()/muon0->Pz());
88 param1 -> SetBendingSlope(muon1->Py()/muon1->Pz());
89
90 param0 -> SetInverseBendingMomentum( muon0->Charge() * (1./muon0->Pz()) / (TMath::Sqrt(1+TMath::Power(muon0->Py()/muon0->Pz(),2))) );
91 param1 -> SetInverseBendingMomentum( muon1->Charge() * (1./muon1->Pz()) / (TMath::Sqrt(1+TMath::Power(muon1->Py()/muon1->Pz(),2))) );
92
9aa4fd6b 93 // here we understand in which direction we have to search the minimum...
94
d30a0b7b 95 Double_t step = 1.; // in cm
96 Double_t startPoint = 0.;
97
98 Double_t r[3]={0}, z[3]={startPoint, startPoint+step, startPoint+2*step};
99
100 for (Int_t i=0; i<3; i++) {
101 AliMUONTrackExtrap::ExtrapToZ(param0, z[i]);
102 AliMUONTrackExtrap::ExtrapToZ(param1, z[i]);
103 Double_t dX = param0->GetNonBendingCoor() - param1->GetNonBendingCoor();
104 Double_t dY = param0->GetBendingCoor() - param1->GetBendingCoor();
105 r[i] = TMath::Sqrt(dX*dX + dY*dY);
106 }
107
108 Double_t researchDirection=0.;
109
110 if (r[0]>r[1] && r[1]>r[2]) researchDirection = +1.; // towards z positive
111 else if (r[0]<r[1] && r[1]<r[2]) researchDirection = -1.; // towards z negative
112 else if (r[0]<r[1] && r[1]>r[2]) {
113 printf("E-AliMFTSupport::RefitAODDimuonWithCommonVertex: Point of closest approach cannot be found for dimuon (no minima)\n");
114 return kFALSE;
115 }
116
117 while (TMath::Abs(researchDirection)>0.5) {
118 if (researchDirection>0.) {
119 z[0] = z[1];
120 z[1] = z[2];
121 z[2] = z[1]+researchDirection*step;
122 }
123 else {
124 z[2] = z[1];
125 z[1] = z[0];
126 z[0] = z[1]+researchDirection*step;
127 }
128 if (TMath::Abs(z[0])>900.) {
129 printf("E-AliMFTSupport::RefitAODDimuonWithCommonVertex: Point of closest approach cannot be found for dimuon (no minima)\n");
130 return kFALSE;
131 }
132 for (Int_t i=0; i<3; i++) {
133 AliMUONTrackExtrap::ExtrapToZ(param0, z[i]);
134 AliMUONTrackExtrap::ExtrapToZ(param1, z[i]);
135 Double_t dX = param0->GetNonBendingCoor() - param1->GetNonBendingCoor();
136 Double_t dY = param0->GetBendingCoor() - param1->GetBendingCoor();
137 r[i] = TMath::Sqrt(dX*dX + dY*dY);
138 }
139 researchDirection=0.;
140 if (r[0]>r[1] && r[1]>r[2]) researchDirection = +1.; // towards z positive
141 else if (r[0]<r[1] && r[1]<r[2]) researchDirection = -1.; // towards z negative
142 }
9aa4fd6b 143
144 // now we now that the minimum is between z[0] and z[2] and we search it
d30a0b7b 145
146 step *= 0.5;
147 while (step>AliMFTConstants::fPrecisionPointOfClosestApproach) {
148 z[0] = z[1]-step;
149 z[2] = z[1]+step;
150 for (Int_t i=0; i<3; i++) {
151 AliMUONTrackExtrap::ExtrapToZ(param0, z[i]);
152 AliMUONTrackExtrap::ExtrapToZ(param1, z[i]);
153 Double_t dX = param0->GetNonBendingCoor() - param1->GetNonBendingCoor();
154 Double_t dY = param0->GetBendingCoor() - param1->GetBendingCoor();
155 r[i] = TMath::Sqrt(dX*dX + dY*dY);
156 }
157 if (r[0]<r[1]) z[1] = z[0];
158 else if (r[2]<r[1]) z[1] = z[2];
159 else step *= 0.5;
160 }
161
162 fZPointOfClosestApproach = z[1];
163 AliMUONTrackExtrap::ExtrapToZ(param0, fZPointOfClosestApproach);
164 AliMUONTrackExtrap::ExtrapToZ(param1, fZPointOfClosestApproach);
165 fXPointOfClosestApproach = 0.5*(param0->GetNonBendingCoor() + param1->GetNonBendingCoor());
166 fYPointOfClosestApproach = 0.5*(param0->GetBendingCoor() + param1->GetBendingCoor());
167
168 //-------------------------------------------------------------------------------------------------------------------------------------------------
169
170 vertex[0] = fXPointOfClosestApproach;
171 vertex[1] = fYPointOfClosestApproach;
172 vertex[2] = fZPointOfClosestApproach;
173
174 Double_t pTot[3] = {0};
175 pTot[0] = param0->Px() + param1->Px();
176 pTot[1] = param0->Py() + param1->Py();
177 pTot[2] = param0->Pz() + param1->Pz();
178
179 Double_t massMu = TDatabasePDG::Instance()->GetParticle("mu-")->Mass();
180
ad597c71 181 Double_t energy0 = TMath::Sqrt(massMu*massMu + param0->Px()*param0->Px() + param0->Py()*param0->Py() + param0->Pz()*param0->Pz());
182 Double_t energy1 = TMath::Sqrt(massMu*massMu + param1->Px()*param1->Px() + param1->Py()*param1->Py() + param1->Pz()*param1->Pz());
d30a0b7b 183
ad597c71 184 kinem.SetPxPyPzE(pTot[0], pTot[1], pTot[2], energy0+energy1);
d30a0b7b 185
186 return kTRUE;
187
188}
189
190//====================================================================================================================================================