de-comment a piece of code I forgot while testing
[u/mrichter/AliRoot.git] / MFT / AliMFTTrackerMU.cxx
CommitLineData
4cc511f4
AU
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// MFT tracker
19//
20// Class for the creation of the "global muon tracks" built from the tracks reconstructed in the
21// muon spectrometer and the clusters of the Muon Forward Tracker
22//
23// Contact author: antonio.uras@cern.ch
24//
25//====================================================================================================================================================
26
27#include "TTree.h"
28#include "AliLog.h"
29#include "AliGeomManager.h"
30#include "AliESDEvent.h"
31#include "AliESDMuonTrack.h"
026547c6 32#include "AliESDMuonGlobalTrack.h"
4cc511f4
AU
33#include "AliMFTTrackerMU.h"
34#include "TMath.h"
35#include "AliRun.h"
36#include "AliMFT.h"
37#include "AliMUONTrackExtrap.h"
38#include "AliMUONTrack.h"
39#include "AliMUONESDInterface.h"
40#include "AliMuonForwardTrack.h"
026547c6 41#include "AliMUONConstants.h"
4cc511f4
AU
42
43ClassImp(AliMFTTrackerMU)
44
45const Double_t AliMFTTrackerMU::fRadLengthSi = AliMFTConstants::fRadLengthSi;
46
47//====================================================================================================================================================
48
49AliMFTTrackerMU::AliMFTTrackerMU() :
50 AliTracker(),
51 fESD(0),
52 fMFT(0),
53 fSegmentation(0),
54 fNPlanesMFT(0),
55 fNPlanesMFTAnalyzed(0),
e21f8bf5 56 fSigmaClusterCut(2),
4cc511f4
AU
57 fScaleSigmaClusterCut(1.),
58 fNMaxMissingMFTClusters(0),
59 fGlobalTrackingDiverged(kFALSE),
60 fCandidateTracks(0),
61 fMUONTrack(0),
62 fCurrentTrack(0),
63 fFinalBestCandidate(0),
64 fVertexErrorX(0.015),
65 fVertexErrorY(0.015),
66 fVertexErrorZ(0.010),
67 fBransonCorrection(kFALSE)
68{
69
70 //--------------------------------------------------------------------
71 // This is the AliMFTTrackerMU constructor
72 //--------------------------------------------------------------------
73
74 fMFT = (AliMFT*) gAlice->GetDetector("MFT");
75 fSegmentation = fMFT->GetSegmentation();
76 SetNPlanesMFT(fSegmentation->GetNPlanes());
77 AliMUONTrackExtrap::SetField(); // set the magnetic field for track extrapolations
78
e21f8bf5 79 AliInfo(Form("fMFT = %p, fSegmentation = %p", fMFT, fSegmentation));
80
4cc511f4 81 for (Int_t iPlane=0; iPlane<fNPlanesMFT; iPlane++) {
e21f8bf5 82 fMFTClusterArray[iPlane] = new TClonesArray("AliMFTCluster");
4cc511f4
AU
83 fMFTClusterArrayFront[iPlane] = new TClonesArray("AliMFTCluster");
84 fMFTClusterArrayBack[iPlane] = new TClonesArray("AliMFTCluster");
e21f8bf5 85 fMFTClusterArray[iPlane] -> SetOwner(kTRUE);
86 fMFTClusterArrayFront[iPlane] -> SetOwner(kTRUE);
87 fMFTClusterArrayBack[iPlane] -> SetOwner(kTRUE);
88 fMinResearchRadiusAtPlane[iPlane] = 0.;
4cc511f4
AU
89 }
90
e21f8bf5 91 fCandidateTracks = new TClonesArray("AliMuonForwardTrack",50000);
92
4cc511f4
AU
93}
94
95//====================================================================================================================================================
96
97AliMFTTrackerMU::~AliMFTTrackerMU() {
98
99 // destructor
100
101 for (Int_t iPlane=0; iPlane<fNPlanesMFT; iPlane++) {
e21f8bf5 102 fMFTClusterArray[iPlane] -> Delete();
4cc511f4
AU
103 delete fMFTClusterArray[iPlane];
104 delete fMFTClusterArrayFront[iPlane];
105 delete fMFTClusterArrayBack[iPlane];
106 }
107
e21f8bf5 108 delete fCandidateTracks;
109
4cc511f4
AU
110}
111
112//====================================================================================================================================================
113
114Int_t AliMFTTrackerMU::LoadClusters(TTree *cTree) {
115
116 //--------------------------------------------------------------------
117 // This function loads the MFT clusters
118 //--------------------------------------------------------------------
119
e21f8bf5 120 for (Int_t iPlane=0; iPlane<fNPlanesMFT; iPlane++) {
121 AliDebug(1, Form("Setting Address for Branch Plane_%02d", iPlane));
122 cTree->SetBranchAddress(Form("Plane_%02d",iPlane), &fMFTClusterArray[iPlane]);
123 }
124
4cc511f4
AU
125 if (!cTree->GetEvent()) return kFALSE;
126 for (Int_t iPlane=0; iPlane<fNPlanesMFT; iPlane++) {
e21f8bf5 127 AliInfo(Form("plane %02d: nClusters = %d\n", iPlane, fMFTClusterArray[iPlane]->GetEntries()));
4cc511f4
AU
128 }
129 SeparateFrontBackClusters();
130
131 return 0;
132
133}
134
135//====================================================================================================================================================
136
137void AliMFTTrackerMU::UnloadClusters() {
138
e21f8bf5 139// //--------------------------------------------------------------------
140// // This function unloads MFT clusters
141// //--------------------------------------------------------------------
4cc511f4
AU
142
143 for (Int_t iPlane=0; iPlane<fNPlanesMFT; iPlane++) {
144 fMFTClusterArray[iPlane] -> Clear("C");
145 fMFTClusterArrayFront[iPlane] -> Clear("C");
146 fMFTClusterArrayBack[iPlane] -> Clear("C");
147 }
148
149}
150
151//====================================================================================================================================================
152
153Int_t AliMFTTrackerMU::Clusters2Tracks(AliESDEvent *event) {
154
155 //--------------------------------------------------------------------
156 // This functions reconstructs the Muon Forward Tracks
157 // The clusters must be already loaded !
158 //--------------------------------------------------------------------
159
e21f8bf5 160 // Tree of AliMuonForwardTrack objects. Created outside the ESD framework for cross-check purposes
161
162 TFile *outputFileMuonGlobalTracks = new TFile("MuonGlobalTracks.root", "update");
4cc511f4
AU
163 TTree *outputTreeMuonGlobalTracks = new TTree("AliMuonForwardTracks", "Tree of AliMuonForwardTracks");
164 TClonesArray *muonForwardTracks = new TClonesArray("AliMuonForwardTrack");
165 outputTreeMuonGlobalTracks -> Branch("tracks", &muonForwardTracks);
166
167 //--------------------------------------------------------------------
168
169 fESD = event;
170
e21f8bf5 171 // get the ITS primary vertex
172
173 Double_t vertex[3] = {0., 0., 0.};
174 const AliESDVertex* esdVert = fESD->GetVertex();
175 if (esdVert->GetNContributors() > 0 || !strcmp(esdVert->GetTitle(),"vertexer: smearMC")) {
176 esdVert->GetXYZ(vertex);
177 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
178 }
179
4cc511f4
AU
180 //----------- Read ESD MUON tracks -------------------
181
182 Int_t nTracksMUON = event->GetNumberOfMuonTracks();
183
184 AliInfo(Form("Number of ESD MUON tracks: %d\n", nTracksMUON));
185
186 Int_t iTrack=0;
187 while (iTrack<nTracksMUON) {
188
189 fNPlanesMFTAnalyzed = 0;
190
e21f8bf5 191 AliInfo("****************************************************************************************");
192 AliInfo(Form("*************************** MUON TRACK %3d/%d ***************************************", iTrack, nTracksMUON));
193 AliInfo("****************************************************************************************");
4cc511f4
AU
194
195 fCandidateTracks -> Delete();
196
197 fNPlanesMFTAnalyzed = 0;
198
199 const AliESDMuonTrack *esdTrack = event->GetMuonTrack(iTrack);
e21f8bf5 200 if (fMUONTrack) delete fMUONTrack;
201 fMUONTrack = new AliMUONTrack();
202
203 AliMUONESDInterface::ESDToMUON(*esdTrack, *fMUONTrack, kTRUE); // last arguments should be kTRUE or kFALSE??
4cc511f4
AU
204
205 // the track we are going to build, starting from fMUONTrack and adding the MFT clusters
206 AliMuonForwardTrack *track = new ((*fCandidateTracks)[0]) AliMuonForwardTrack();
207 track -> SetMUONTrack(new AliMUONTrack(*fMUONTrack));
208 track -> SetMCLabel(fMUONTrack->GetMCLabel());
209 track -> SetMatchTrigger(fMUONTrack->GetMatchTrigger());
210
026547c6 211 // track parameters linearly extrapolated from the first tracking station to the end of the absorber
212 AliMUONTrackParam trackParamEndOfAbsorber(*((AliMUONTrackParam*)(fMUONTrack->GetTrackParamAtCluster()->First())));
213 AliMUONTrackExtrap::ExtrapToZCov(&trackParamEndOfAbsorber, AliMUONConstants::AbsZEnd()); // absorber extends from -90 to -503 cm
214 Double_t xEndOfAbsorber = trackParamEndOfAbsorber.GetNonBendingCoor();
215 Double_t yEndOfAbsorber = trackParamEndOfAbsorber.GetBendingCoor();
216 Double_t rAbsorber = TMath::Sqrt(xEndOfAbsorber*xEndOfAbsorber + yEndOfAbsorber*yEndOfAbsorber);
217 track -> SetRAtAbsorberEnd(rAbsorber);
218
4cc511f4
AU
219 //------------------------- NOW THE CYCLE OVER THE MFT PLANES STARTS ---------------------------------------
220
221 for (Int_t iPlane=fNPlanesMFT-1; iPlane>=0; iPlane--) { /* *** do not reverse the order of this cycle!!!
222 *** this reflects the fact that the extrapolation is performed
223 *** starting from the last MFT plane back to the origin */
224
225 // --------- updating the array of candidates according to the clusters available in the i-th plane ---------
226
227 fNPlanesMFTAnalyzed++;
228
229 Int_t nCandidates = fCandidateTracks->GetEntriesFast();
230 for (Int_t iCandidate=0; iCandidate<nCandidates; iCandidate++) {
231 fCurrentTrack = (AliMuonForwardTrack*) fCandidateTracks->UncheckedAt(iCandidate);
e21f8bf5 232
4cc511f4
AU
233 // if the old track is compatible with the new cluster, the track is updated and inserted as new track in the array
234 // (several new tracks can be created for one old track)
235 if (FindClusterInPlane(iPlane) == kDiverged) {
236 fGlobalTrackingDiverged = kTRUE;
237 break;
238 }
239
240 if ((fNPlanesMFTAnalyzed-fCurrentTrack->GetNMFTClusters())>fNMaxMissingMFTClusters || fIsPlaneMandatory[iPlane]) {
241 fCandidateTracks->Remove(fCurrentTrack); // the old track is removed after the check;
242 }
243 }
244 if (fGlobalTrackingDiverged) {
245 if (fScaleSigmaClusterCut>0) fScaleSigmaClusterCut -= 0.1;
246 continue;
247 }
248
249 fCandidateTracks->Compress();
250
251 }
e21f8bf5 252
4cc511f4
AU
253 // -------------------------- END OF THE CYCLE OVER THE MFT PLANES --------------------------------------------
254
255 fGlobalTrackingDiverged = kFALSE;
256 fScaleSigmaClusterCut = 1.0;
257
258 AliDebug(1, "Finished cycle over planes");
259
260 iTrack++;
261
262 // If we have several final tracks, we must find the best candidate:
263
264 Int_t nFinalTracks = fCandidateTracks->GetEntriesFast();
e21f8bf5 265 AliInfo(Form("nFinalTracks = %d", nFinalTracks));
266
4cc511f4
AU
267 Int_t nGoodClustersBestCandidate = 0;
268 Int_t idBestCandidate = 0;
269 Double_t bestChi2 = -1.; // variable defining the best candidate
270
271 for (Int_t iFinalCandidate=0; iFinalCandidate<nFinalTracks; iFinalCandidate++) {
272
273 AliMuonForwardTrack *finalTrack = (AliMuonForwardTrack*) fCandidateTracks->UncheckedAt(iFinalCandidate);
274 Int_t nMFTClusters = finalTrack->GetNMFTClusters();
275
276 Double_t chi2 = 0;
277 for (Int_t iCluster=0; iCluster<nMFTClusters; iCluster++) {
278 AliMFTCluster *localCluster = finalTrack->GetMFTCluster(iCluster);
279 chi2 += localCluster->GetLocalChi2();
280 }
281 chi2 /= nMFTClusters;
282
283 // now comparing the tracks in order to find the best one
284
285 if (chi2<bestChi2 || bestChi2<0) {
286 bestChi2 = chi2;
287 idBestCandidate = iFinalCandidate;
288 }
289
290 }
291
292 if (nFinalTracks) {
293
294 AliMuonForwardTrack *newTrack = (AliMuonForwardTrack*) fCandidateTracks->UncheckedAt(idBestCandidate);
295 newTrack -> SetNWrongClustersMC(newTrack->GetNMFTClusters() - nGoodClustersBestCandidate);
296
e21f8bf5 297 new ((*muonForwardTracks)[muonForwardTracks->GetEntries()]) AliMuonForwardTrack(*newTrack);
4cc511f4 298
e21f8bf5 299 //----------------------- Save the information to the AliESDMuonGlobalTrack object
300
301 newTrack -> EvalKinem(vertex[2]); // we evaluate the kinematics at the primary vertex
302
303 AliDebug(2,"Creating a new Muon Global Track");
304 AliESDMuonGlobalTrack *myESDTrack = event->NewMuonGlobalTrack();
305 myESDTrack -> SetPxPyPz(newTrack->Px(), newTrack->Py(), newTrack->Pz());
026547c6 306
307// waiting for the commit of the new version of AliESDMuonGlobalTrack...
308
309// myESDTrack -> SetChi2OverNdf(newTrack->GetChi2OverNdf());
310// myESDTrack -> SetCharge(newTrack->GetCharge());
311// myESDTrack -> SetMatchTrigger(newTrack->GetMatchTrigger());
312// myESDTrack -> SetFirstTrackingPoint(newTrack->GetMFTCluster(0)->GetX(), newTrack->GetMFTCluster(0)->GetY(), newTrack->GetMFTCluster(0)->GetZ());
313// myESDTrack -> SetXYAtVertex(newTrack->GetOffsetX(vertex[0], vertex[2]), newTrack->GetOffsetX(vertex[1], vertex[2]));
314// myESDTrack -> SetRAtAbsorberEnd(newTrack->GetRAtAbsorberEnd());
315// myESDTrack -> SetChi2MatchTrigger(esdTrack->GetChi2MatchTrigger());
316// myESDTrack -> SetMuonClusterMap(esdTrack->GetMuonClusterMap());
317// myESDTrack -> SetHitsPatternInTrigCh(esdTrack->GetHitsPatternInTrigCh());
318// myESDTrack -> SetHitsPatternInTrigChTrk(esdTrack->GetHitsPatternInTrigChTrk());
319// myESDTrack -> Connected(esdTrack->IsConnected());
4cc511f4 320
e21f8bf5 321 //---------------------------------------------------------------------------------
4cc511f4
AU
322
323 }
324
4cc511f4
AU
325 fFinalBestCandidate = NULL;
326
327 }
328
e21f8bf5 329 outputTreeMuonGlobalTracks -> Fill();
330
4cc511f4 331 Int_t myEventID = 0;
4cc511f4
AU
332 while (outputFileMuonGlobalTracks->cd(Form("Event%d",myEventID))) myEventID++;
333 outputFileMuonGlobalTracks -> mkdir(Form("Event%d",myEventID));
334 outputFileMuonGlobalTracks -> cd(Form("Event%d",myEventID));
335 outputTreeMuonGlobalTracks -> Write();
336 outputFileMuonGlobalTracks -> Close();
337
e21f8bf5 338 muonForwardTracks -> Delete();
339 delete muonForwardTracks;
340
4cc511f4
AU
341 return 0;
342
343}
344
345//=========================================================================================================================================
346
347void AliMFTTrackerMU::SeparateFrontBackClusters() {
348
349 for (Int_t iPlane=0; iPlane<fNPlanesMFT; iPlane++) {
350 fMFTClusterArrayFront[iPlane]->Delete();
351 fMFTClusterArrayBack[iPlane] ->Delete();
352 for (Int_t iCluster=0; iCluster<fMFTClusterArray[iPlane]->GetEntries(); iCluster++) {
353 AliMFTCluster *cluster = (AliMFTCluster*) fMFTClusterArray[iPlane]->At(iCluster);
354 if (TMath::Abs(cluster->GetZ())<TMath::Abs(fSegmentation->GetPlane(iPlane)->GetZCenter())) {
355 new ((*fMFTClusterArrayFront[iPlane])[fMFTClusterArrayFront[iPlane]->GetEntries()]) AliMFTCluster(*cluster);
356 }
357 else {
358 new ((*fMFTClusterArrayBack[iPlane])[fMFTClusterArrayBack[iPlane]->GetEntries()]) AliMFTCluster(*cluster);
359 }
360 }
361 }
362
363}
364
365//==========================================================================================================================================
366
367Int_t AliMFTTrackerMU::FindClusterInPlane(Int_t planeId) {
368
4cc511f4
AU
369 // !!!!!!!!! coordinates and errors on the interaction vertex should be taken from the event itself (ITS) if available
370
371 // propagate track to plane #planeId (both to front and back active sensors)
372 // look for compatible clusters
373 // update TrackParam at found cluster (if any) using Kalman Filter
374
375 AliMUONTrackParam currentParamFront, currentParamBack, currentParamForResearchFront, currentParamForResearchBack;
376
377 if (planeId == fNPlanesMFT-1) { // last plane of the telecope
378 currentParamFront = (*((AliMUONTrackParam*)(fMUONTrack->GetTrackParamAtCluster()->First())));
379 currentParamBack = (*((AliMUONTrackParam*)(fMUONTrack->GetTrackParamAtCluster()->First())));
380 currentParamForResearchFront = currentParamFront;
381 currentParamForResearchBack = currentParamBack;
382 Double_t xExtrap = gRandom->Gaus(0,fVertexErrorX);
383 Double_t yExtrap = gRandom->Gaus(0,fVertexErrorY);
384 Double_t zExtrap = gRandom->Gaus(0,fVertexErrorZ);
385 if (fBransonCorrection) {
386 AliMUONTrackExtrap::ExtrapToVertex(&currentParamFront, xExtrap, yExtrap, zExtrap, fVertexErrorX, fVertexErrorY);
387 AliMUONTrackExtrap::ExtrapToVertex(&currentParamBack, xExtrap, yExtrap, zExtrap, fVertexErrorX, fVertexErrorY);
388 }
389 else {
390 AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(&currentParamFront, zExtrap);
391 AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(&currentParamBack, zExtrap);
392 }
393 AliMUONTrackExtrap::ExtrapToVertex(&currentParamForResearchFront, xExtrap, yExtrap, zExtrap, fVertexErrorX, fVertexErrorY);
394 AliMUONTrackExtrap::ExtrapToVertex(&currentParamForResearchBack, xExtrap, yExtrap, zExtrap, fVertexErrorX, fVertexErrorY);
395 }
396 else { // MFT planes others than the last one: mult. scattering correction because of the upstream MFT planes is performed
397 currentParamFront = (*((AliMUONTrackParam*)(fCurrentTrack->GetTrackParamAtCluster()->First())));
398 currentParamBack = (*((AliMUONTrackParam*)(fCurrentTrack->GetTrackParamAtCluster()->First())));
399 currentParamForResearchFront = currentParamFront;
400 currentParamForResearchBack = currentParamBack;
401 AliMUONTrackExtrap::AddMCSEffect(&currentParamFront, (fSegmentation->GetPlane(planeId+1)->GetEquivalentSilicon()+
402 fSegmentation->GetPlane(planeId)->GetEquivalentSiliconBeforeFront())/fRadLengthSi,-1.);
403 AliMUONTrackExtrap::AddMCSEffect(&currentParamForResearchFront,(fSegmentation->GetPlane(planeId+1)->GetEquivalentSilicon()+
404 fSegmentation->GetPlane(planeId)->GetEquivalentSiliconBeforeFront())/fRadLengthSi,-1.);
405 AliMUONTrackExtrap::AddMCSEffect(&currentParamBack, (fSegmentation->GetPlane(planeId+1)->GetEquivalentSilicon()+
406 fSegmentation->GetPlane(planeId)->GetEquivalentSiliconBeforeBack())/fRadLengthSi,-1.);
407 AliMUONTrackExtrap::AddMCSEffect(&currentParamForResearchBack, (fSegmentation->GetPlane(planeId+1)->GetEquivalentSilicon()+
408 fSegmentation->GetPlane(planeId)->GetEquivalentSiliconBeforeBack())/fRadLengthSi,-1.);
409 }
410 // for all planes: extrapolation to the Z of the plane
411 AliMUONTrackExtrap::ExtrapToZCov(&currentParamFront, -1.*fSegmentation->GetPlane(planeId)->GetZCenterActiveFront());
412 AliMUONTrackExtrap::ExtrapToZCov(&currentParamForResearchFront, -1.*fSegmentation->GetPlane(planeId)->GetZCenterActiveFront());
413 AliMUONTrackExtrap::ExtrapToZCov(&currentParamBack, -1.*fSegmentation->GetPlane(planeId)->GetZCenterActiveBack());
414 AliMUONTrackExtrap::ExtrapToZCov(&currentParamForResearchBack, -1.*fSegmentation->GetPlane(planeId)->GetZCenterActiveBack());
415
416 //---------------------------------------------------------------------------------------
417
418 TMatrixD covFront(5,5); covFront = currentParamForResearchFront.GetCovariances();
419 TMatrixD covBack(5,5); covBack = currentParamForResearchBack.GetCovariances();
420
421 Double_t squaredError_X_Front = covFront(0,0);
422 Double_t squaredError_Y_Front = covFront(2,2);
423 Double_t squaredError_X_Back = covBack(0,0);
424 Double_t squaredError_Y_Back = covBack(2,2);
425
426 Double_t corrFact = 1.0;
427
428 Double_t researchRadiusFront = TMath::Sqrt(squaredError_X_Front + squaredError_Y_Front);
429 Double_t researchRadiusBack = TMath::Sqrt(squaredError_X_Back + squaredError_Y_Back);
430 if (0.5*(researchRadiusFront+researchRadiusBack)<fMinResearchRadiusAtPlane[planeId]) {
431 corrFact = fMinResearchRadiusAtPlane[planeId]/(0.5*(researchRadiusFront+researchRadiusBack));
432 }
433
434 //---------------------------------------------------------------------------------------
435
436 Double_t chi2cut = 2.*fScaleSigmaClusterCut*fScaleSigmaClusterCut*fSigmaClusterCut*fSigmaClusterCut; // depends on the number of variables (here, 2)
437
438 // Analyizing the clusters: FRONT ACTIVE ELEMENTS
439
440 Int_t nClustersFront = fMFTClusterArrayFront[planeId]->GetEntries();
441 AliDebug(2, Form("There are %3d clusters in plane %02d FRONT\n", nClustersFront, planeId));
442
443 for (Int_t iCluster=0; iCluster<nClustersFront; iCluster++) {
444
445 Bool_t isGoodChi2 = kFALSE;
446
447 AliMFTCluster *cluster = (AliMFTCluster*) fMFTClusterArrayFront[planeId]->At(iCluster);
448 Double_t chi2 = (1./(corrFact*corrFact)) * TryOneCluster(currentParamForResearchFront, cluster); // describes the compatibility between the track and the cluster
449 if (chi2<chi2cut) isGoodChi2 = kTRUE;
450
451 if (isGoodChi2) {
452 AliDebug(3, Form("accepting cluster: chi2=%f (cut = %f)\n", chi2, chi2cut));
453 AliMuonForwardTrack *newTrack = new ((*fCandidateTracks)[fCandidateTracks->GetEntriesFast()]) AliMuonForwardTrack(*fCurrentTrack);
454 if (fCandidateTracks->GetEntriesFast() > fMaxNCandidates) return kDiverged;
455 newTrack->AddTrackParamAtMFTCluster(currentParamFront, *cluster); // creating new track param and attaching the cluster
456 AliDebug(2, Form("After plane %02d: newTrack->GetNMFTClusters() = %d (fCurrentTrack->GetNMFTClusters() = %d)",
457 planeId, newTrack->GetNMFTClusters(), fCurrentTrack->GetNMFTClusters()));
458 newTrack->SetPlaneExists(planeId);
459 }
460 else AliDebug(3, Form("discarding cluster: chi2=%f (cut = %f)\n", chi2, chi2cut));
461
462 }
463
464 // Analyizing the clusters: BACK ACTIVE ELEMENTS
465
466 Int_t nClustersBack = fMFTClusterArrayBack[planeId]->GetEntries();
467 AliDebug(2, Form("There are %3d clusters in plane %02d BACK\n", nClustersBack, planeId));
468
469 for (Int_t iCluster=0; iCluster<nClustersBack; iCluster++) {
470
471 Bool_t isGoodChi2 = kFALSE;
472
473 AliMFTCluster *cluster = (AliMFTCluster*) fMFTClusterArrayBack[planeId]->At(iCluster);
474 Double_t chi2 = (1./(corrFact*corrFact)) * TryOneCluster(currentParamForResearchBack, cluster); // describes the compatibility between the track and the cluster
475 if (chi2<chi2cut) isGoodChi2 = kTRUE;
476
477 if (isGoodChi2) {
478 AliDebug(3,Form("accepting cluster: chi2=%f (cut = %f)\n", chi2, chi2cut));
479 AliMuonForwardTrack *newTrack = new ((*fCandidateTracks)[fCandidateTracks->GetEntriesFast()]) AliMuonForwardTrack(*fCurrentTrack);
480 if (fCandidateTracks->GetEntriesFast() > fMaxNCandidates) return kDiverged;
481 newTrack->AddTrackParamAtMFTCluster(currentParamBack, *cluster); // creating new track param and attaching the cluster
482 AliDebug(2, Form("After plane %02d: newTrack->GetNMFTClusters() = %d (fCurrentTrack->GetNMFTClusters() = %d)",
483 planeId, newTrack->GetNMFTClusters(), fCurrentTrack->GetNMFTClusters()));
484 newTrack->SetPlaneExists(planeId);
485 }
486 else AliDebug(3,Form("discarding cluster: chi2=%f (cut = %f)\n", chi2, chi2cut));
487
488 }
489
490 //---------------------------------------------------------------------------------------------
491
492 return kConverged;
493
494}
495
496//==========================================================================================================================================
497
498Double_t AliMFTTrackerMU::TryOneCluster(const AliMUONTrackParam &trackParam, AliMFTCluster *cluster) {
499
500 // Test the compatibility between the track and the cluster (using trackParam's covariance matrix):
501 // return the corresponding Chi2
502 // assume the track parameters are given at the Z of the cluster
503
504 // Set differences between trackParam and cluster in the bending and non bending directions
505 Double_t dX = cluster->GetX() - trackParam.GetNonBendingCoor();
506 Double_t dY = cluster->GetY() - trackParam.GetBendingCoor();
507 AliDebug(3,Form("dX = %f, dY = %f\n", dX, dY));
508
509 // Calculate errors and covariances
510 const TMatrixD& kParamCov = trackParam.GetCovariances();
511 Double_t sigmaX2 = kParamCov(0,0) + cluster->GetErrX2();
512 Double_t sigmaY2 = kParamCov(2,2) + cluster->GetErrY2();
513 AliDebug(3, Form("dX2 = %f, dY2 = %f\n", sigmaX2, sigmaY2));
514 Double_t covXY = kParamCov(0,2);
515 Double_t det = sigmaX2 * sigmaY2 - covXY * covXY;
516
517 // Compute chi2
518 if (det==0.) return 1.e10;
519 return (dX*dX*sigmaY2 + dY*dY*sigmaX2 - 2.*dX*dY*covXY) / det;
520
521}
522
523//=========================================================================================================================================
524