]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONEventReconstructor.cxx
Improvement of muon reconstruction by extrapolating trackParam to real z of clusters
[u/mrichter/AliRoot.git] / MUON / AliMUONEventReconstructor.cxx
CommitLineData
a9e2aefa 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
88cb7938 16/* $Id$ */
a9e2aefa 17
3831f268 18////////////////////////////////////
a9e2aefa 19//
20// MUON event reconstructor in ALICE
21//
22// This class contains as data:
23// * the parameters for the event reconstruction
24// * a pointer to the array of hits to be reconstructed (the event)
25// * a pointer to the array of segments made with these hits inside each station
26// * a pointer to the array of reconstructed tracks
27//
28// It contains as methods, among others:
29// * MakeEventToBeReconstructed to build the array of hits to be reconstructed
30// * MakeSegments to build the segments
31// * MakeTracks to build the tracks
3831f268 32//
33////////////////////////////////////
a9e2aefa 34
ae17f568 35#include <stdlib.h>
30178c30 36#include <Riostream.h>
37#include <TDirectory.h>
38#include <TFile.h>
39#include <TMatrixD.h> //AZ
a9e2aefa 40
3831f268 41#include "AliMUONEventReconstructor.h"
30178c30 42#include "AliMUON.h"
43#include "AliMUONHit.h"
a9e2aefa 44#include "AliMUONHitForRec.h"
276c44b7 45#include "AliMUONTriggerTrack.h"
276c44b7 46#include "AliMUONTriggerCircuit.h"
a9e2aefa 47#include "AliMUONRawCluster.h"
276c44b7 48#include "AliMUONLocalTrigger.h"
52c9bc11 49#include "AliMUONGlobalTrigger.h"
3831f268 50#include "AliMUONRecoEvent.h"
51#include "AliMUONSegment.h"
a9e2aefa 52#include "AliMUONTrack.h"
a9e2aefa 53#include "AliMUONTrackHit.h"
94de3818 54#include "AliMagF.h"
3831f268 55#include "AliRun.h" // for gAlice
88cb7938 56#include "AliRunLoader.h"
57#include "AliLoader.h"
83dbc640 58#include "AliMUONTrackK.h" //AZ
5d12ce38 59#include "AliMC.h"
a9e2aefa 60
a9e2aefa 61//************* Defaults parameters for reconstruction
343146bf 62const Double_t AliMUONEventReconstructor::fgkDefaultMinBendingMomentum = 3.0;
63const Double_t AliMUONEventReconstructor::fgkDefaultMaxBendingMomentum = 500.0;
64const Double_t AliMUONEventReconstructor::fgkDefaultMaxChi2 = 100.0;
65const Double_t AliMUONEventReconstructor::fgkDefaultMaxSigma2Distance = 16.0;
66const Double_t AliMUONEventReconstructor::fgkDefaultBendingResolution = 0.01;
67const Double_t AliMUONEventReconstructor::fgkDefaultNonBendingResolution = 0.144;
68const Double_t AliMUONEventReconstructor::fgkDefaultChamberThicknessInX0 = 0.03;
a9e2aefa 69// Simple magnetic field:
70// Value taken from macro MUONtracking.C: 0.7 T, hence 7 kG
71// Length and Position from reco_muon.F, with opposite sign:
72// Length = ZMAGEND-ZCOIL
73// Position = (ZMAGEND+ZCOIL)/2
74// to be ajusted differently from real magnetic field ????
343146bf 75const Double_t AliMUONEventReconstructor::fgkDefaultSimpleBValue = 7.0;
76const Double_t AliMUONEventReconstructor::fgkDefaultSimpleBLength = 428.0;
77const Double_t AliMUONEventReconstructor::fgkDefaultSimpleBPosition = 1019.0;
78const Int_t AliMUONEventReconstructor::fgkDefaultRecGeantHits = 0;
79const Double_t AliMUONEventReconstructor::fgkDefaultEfficiency = 0.95;
a9e2aefa 80
343146bf 81const Int_t AliMUONEventReconstructor::fgkDefaultPrintLevel = -1;
a9e2aefa 82
83ClassImp(AliMUONEventReconstructor) // Class implementation in ROOT context
84
85 //__________________________________________________________________________
52c9bc11 86AliMUONEventReconstructor::AliMUONEventReconstructor(AliLoader* loader)
30178c30 87 : TObject()
a9e2aefa 88{
89 // Constructor for class AliMUONEventReconstructor
90 SetReconstructionParametersToDefaults();
83dbc640 91 fTrackMethod = 1; //AZ - tracking method (1-default, 2-Kalman)
a9e2aefa 92 // Memory allocation for the TClonesArray of hits for reconstruction
93 // Is 10000 the right size ????
94 fHitsForRecPtr = new TClonesArray("AliMUONHitForRec", 10000);
95 fNHitsForRec = 0; // really needed or GetEntriesFast sufficient ????
96 // Memory allocation for the TClonesArray's of segments in stations
97 // Is 2000 the right size ????
30178c30 98 for (Int_t st = 0; st < fgkMaxMuonTrackingStations; st++) {
a9e2aefa 99 fSegmentsPtr[st] = new TClonesArray("AliMUONSegment", 2000);
100 fNSegments[st] = 0; // really needed or GetEntriesFast sufficient ????
101 }
102 // Memory allocation for the TClonesArray of reconstructed tracks
103 // Is 10 the right size ????
104 fRecTracksPtr = new TClonesArray("AliMUONTrack", 10);
105 fNRecTracks = 0; // really needed or GetEntriesFast sufficient ????
276c44b7 106// trigger tracks
107 fRecTriggerTracksPtr = new TClonesArray("AliMUONTriggerTrack", 10);
108 fNRecTriggerTracks = 0; // really needed or GetEntriesFast sufficient ????
8429a5e4 109 // Memory allocation for the TClonesArray of hits on reconstructed tracks
110 // Is 100 the right size ????
111 fRecTrackHitsPtr = new TClonesArray("AliMUONTrack", 100);
112 fNRecTrackHits = 0; // really needed or GetEntriesFast sufficient ????
a9e2aefa 113
5b64e914 114 // Sign of fSimpleBValue according to sign of Bx value at (50,50,-950).
a6f03ddb 115 Float_t b[3], x[3];
5b64e914 116 x[0] = 50.; x[1] = 50.; x[2] = -950.;
a6f03ddb 117 gAlice->Field()->Field(x, b);
065bd0e1 118 fSimpleBValue = TMath::Sign(fSimpleBValue,(Double_t) b[0]);
5b64e914 119 fSimpleBPosition = TMath::Sign(fSimpleBPosition,(Double_t) x[2]);
a6f03ddb 120 // See how to get fSimple(BValue, BLength, BPosition)
121 // automatically calculated from the actual magnetic field ????
a9e2aefa 122
123 if (fPrintLevel >= 0) {
a6f03ddb 124 cout << "AliMUONEventReconstructor constructed with defaults" << endl; Dump();
125 cout << endl << "Magnetic field from root file:" << endl;
126 gAlice->Field()->Dump();
127 cout << endl;
128 }
c7ba256d 129
47a6b602 130 // Initializions for GEANT background events
131 fBkgGeantFile = 0;
132 fBkgGeantTK = 0;
133 fBkgGeantParticles = 0;
134 fBkgGeantTH = 0;
135 fBkgGeantHits = 0;
136 fBkgGeantEventNumber = -1;
137
c7ba256d 138 // Initialize to 0 pointers to RecoEvent, tree and tree file
139 fRecoEvent = 0;
140 fEventTree = 0;
141 fTreeFile = 0;
52c9bc11 142
143 // initialize loader's
144 fLoader = loader;
145
146 // initialize container
147 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
148
149 // Loading AliRun master
150 AliRunLoader* runloader = fLoader->GetRunLoader();
151 if (runloader->GetAliRun() == 0x0) runloader->LoadgAlice();
152 gAlice = runloader->GetAliRun();
153
a9e2aefa 154 return;
155}
52c9bc11 156 //__________________________________________________________________________
30178c30 157AliMUONEventReconstructor::AliMUONEventReconstructor (const AliMUONEventReconstructor& rhs)
158 : TObject(rhs)
9cbdf048 159{
30178c30 160// Protected copy constructor
161
162 Fatal("AliMUONEventReconstructor", "Not implemented.");
9cbdf048 163}
164
30178c30 165AliMUONEventReconstructor &
166AliMUONEventReconstructor::operator=(const AliMUONEventReconstructor& rhs)
9cbdf048 167{
30178c30 168// Protected assignement operator
169
170 if (this == &rhs) return *this;
171
172 Fatal("operator=", "Not implemented.");
173
174 return *this;
9cbdf048 175}
176
a9e2aefa 177 //__________________________________________________________________________
178AliMUONEventReconstructor::~AliMUONEventReconstructor(void)
179{
180 // Destructor for class AliMUONEventReconstructor
c7ba256d 181 if (fTreeFile) {
182 fTreeFile->Close();
183 delete fTreeFile;
184 }
185// if (fEventTree) delete fEventTree;
186 if (fRecoEvent) delete fRecoEvent;
a9e2aefa 187 delete fHitsForRecPtr; // Correct destruction of everything ???? or delete [] ????
30178c30 188 for (Int_t st = 0; st < fgkMaxMuonTrackingStations; st++)
a9e2aefa 189 delete fSegmentsPtr[st]; // Correct destruction of everything ????
190 return;
191}
192
193 //__________________________________________________________________________
194void AliMUONEventReconstructor::SetReconstructionParametersToDefaults(void)
195{
196 // Set reconstruction parameters to default values
197 // Would be much more convenient with a structure (or class) ????
343146bf 198 fMinBendingMomentum = fgkDefaultMinBendingMomentum;
199 fMaxBendingMomentum = fgkDefaultMaxBendingMomentum;
200 fMaxChi2 = fgkDefaultMaxChi2;
201 fMaxSigma2Distance = fgkDefaultMaxSigma2Distance;
a9e2aefa 202
9cbdf048 203 AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON");
a9e2aefa 204 // ******** Parameters for making HitsForRec
205 // minimum radius,
206 // like in TRACKF_STAT:
207 // 2 degrees for stations 1 and 2, or ch(0...) from 0 to 3;
208 // 30 cm for stations 3 to 5, or ch(0...) from 4 to 9
343146bf 209 for (Int_t ch = 0; ch < fgkMaxMuonTrackingChambers; ch++) {
9cbdf048 210 if (ch < 4) fRMin[ch] = TMath::Abs((&(pMUON->Chamber(ch)))->Z()) *
a9e2aefa 211 2.0 * TMath::Pi() / 180.0;
212 else fRMin[ch] = 30.0;
d0bfce8d 213 // maximum radius at 10 degrees and Z of chamber
214 fRMax[ch] = TMath::Abs((&(pMUON->Chamber(ch)))->Z()) *
215 10.0 * TMath::Pi() / 180.0;
a9e2aefa 216 }
a9e2aefa 217
218 // ******** Parameters for making segments
219 // should be parametrized ????
220 // according to interval between chambers in a station ????
221 // Maximum distance in non bending plane
222 // 5 * 0.22 just to remember the way it was made in TRACKF_STAT
223 // SIGCUT*DYMAX(IZ)
30178c30 224 for (Int_t st = 0; st < fgkMaxMuonTrackingStations; st++)
a9e2aefa 225 fSegmentMaxDistNonBending[st] = 5. * 0.22;
860cef81 226 // Maximum distance in bending plane:
227 // values from TRACKF_STAT, corresponding to (J psi 20cm),
228 // scaled to the real distance between chambers in a station
ef21c79e 229 fSegmentMaxDistBending[0] = TMath::Abs( 1.5 *
230 ((&(pMUON->Chamber(1)))->Z() - (&(pMUON->Chamber(0)))->Z()) / 20.0);
b8273575 231 fSegmentMaxDistBending[1] = TMath::Abs( 1.5 *
ef21c79e 232 ((&(pMUON->Chamber(3)))->Z() - (&(pMUON->Chamber(2)))->Z()) / 20.0);
b8273575 233 fSegmentMaxDistBending[2] = TMath::Abs( 3.0 *
ef21c79e 234 ((&(pMUON->Chamber(5)))->Z() - (&(pMUON->Chamber(4)))->Z()) / 20.0);
b8273575 235 fSegmentMaxDistBending[3] = TMath::Abs( 6.0 *
ef21c79e 236 ((&(pMUON->Chamber(7)))->Z() - (&(pMUON->Chamber(6)))->Z()) / 20.0);
b8273575 237 fSegmentMaxDistBending[4] = TMath::Abs( 6.0 *
ef21c79e 238 ((&(pMUON->Chamber(9)))->Z() - (&(pMUON->Chamber(8)))->Z()) / 20.0);
a9e2aefa 239
343146bf 240 fBendingResolution = fgkDefaultBendingResolution;
241 fNonBendingResolution = fgkDefaultNonBendingResolution;
242 fChamberThicknessInX0 = fgkDefaultChamberThicknessInX0;
243 fSimpleBValue = fgkDefaultSimpleBValue;
244 fSimpleBLength = fgkDefaultSimpleBLength;
245 fSimpleBPosition = fgkDefaultSimpleBPosition;
246 fRecGeantHits = fgkDefaultRecGeantHits;
247 fEfficiency = fgkDefaultEfficiency;
248 fPrintLevel = fgkDefaultPrintLevel;
a9e2aefa 249 return;
250}
251
252//__________________________________________________________________________
3831f268 253Double_t AliMUONEventReconstructor::GetImpactParamFromBendingMomentum(Double_t BendingMomentum) const
a9e2aefa 254{
255 // Returns impact parameter at vertex in bending plane (cm),
256 // from the signed bending momentum "BendingMomentum" in bending plane (GeV/c),
257 // using simple values for dipole magnetic field.
065bd0e1 258 // The sign of "BendingMomentum" is the sign of the charge.
a9e2aefa 259 return (-0.0003 * fSimpleBValue * fSimpleBLength * fSimpleBPosition /
260 BendingMomentum);
261}
262
263//__________________________________________________________________________
3831f268 264Double_t AliMUONEventReconstructor::GetBendingMomentumFromImpactParam(Double_t ImpactParam) const
a9e2aefa 265{
266 // Returns signed bending momentum in bending plane (GeV/c),
065bd0e1 267 // the sign being the sign of the charge for particles moving forward in Z,
a9e2aefa 268 // from the impact parameter "ImpactParam" at vertex in bending plane (cm),
269 // using simple values for dipole magnetic field.
a9e2aefa 270 return (-0.0003 * fSimpleBValue * fSimpleBLength * fSimpleBPosition /
271 ImpactParam);
272}
273
274//__________________________________________________________________________
275void AliMUONEventReconstructor::SetBkgGeantFile(Text_t *BkgGeantFileName)
276{
277 // Set background file ... for GEANT hits
278 // Must be called after having loaded the firts signal event
279 if (fPrintLevel >= 0) {
280 cout << "Enter SetBkgGeantFile with BkgGeantFileName ``"
281 << BkgGeantFileName << "''" << endl;}
282 if (strlen(BkgGeantFileName)) {
283 // BkgGeantFileName not empty: try to open the file
284 if (fPrintLevel >= 2) {cout << "Before File(Bkg)" << endl; gDirectory->Dump();}
285 fBkgGeantFile = new TFile(BkgGeantFileName);
286 if (fPrintLevel >= 2) {cout << "After File(Bkg)" << endl; gDirectory->Dump();}
287 if (fBkgGeantFile-> IsOpen()) {
288 if (fPrintLevel >= 0) {
289 cout << "Background for GEANT hits in file: ``" << BkgGeantFileName
290 << "'' successfully opened" << endl;}
291 }
292 else {
293 cout << "Background for GEANT hits in file: " << BkgGeantFileName << endl;
294 cout << "NOT FOUND: EXIT" << endl;
295 exit(0); // right instruction for exit ????
296 }
297 // Arrays for "particles" and "hits"
298 fBkgGeantParticles = new TClonesArray("TParticle", 200);
299 fBkgGeantHits = new TClonesArray("AliMUONHit", 2000);
300 // Event number to -1 for initialization
301 fBkgGeantEventNumber = -1;
302 // Back to the signal file:
303 // first signal event must have been loaded previously,
304 // otherwise, Segmentation violation at the next instruction
305 // How is it possible to do smething better ????
306 ((gAlice->TreeK())->GetCurrentFile())->cd();
307 if (fPrintLevel >= 2) {cout << "After cd(gAlice)" << endl; gDirectory->Dump();}
308 }
309 return;
310}
311
312//__________________________________________________________________________
313void AliMUONEventReconstructor::NextBkgGeantEvent(void)
314{
315 // Get next event in background file for GEANT hits
316 // Goes back to event number 0 when end of file is reached
317 char treeName[20];
318 TBranch *branch;
319 if (fPrintLevel >= 0) {
320 cout << "Enter NextBkgGeantEvent" << endl;}
321 // Clean previous event
322 if(fBkgGeantTK) delete fBkgGeantTK;
323 fBkgGeantTK = NULL;
324 if(fBkgGeantParticles) fBkgGeantParticles->Clear();
325 if(fBkgGeantTH) delete fBkgGeantTH;
326 fBkgGeantTH = NULL;
327 if(fBkgGeantHits) fBkgGeantHits->Clear();
328 // Increment event number
329 fBkgGeantEventNumber++;
330 // Get access to Particles and Hits for event from background file
331 if (fPrintLevel >= 2) {cout << "Before cd(Bkg)" << endl; gDirectory->Dump();}
332 fBkgGeantFile->cd();
333 if (fPrintLevel >= 2) {cout << "After cd(Bkg)" << endl; gDirectory->Dump();}
334 // Particles: TreeK for event and branch "Particles"
335 sprintf(treeName, "TreeK%d", fBkgGeantEventNumber);
336 fBkgGeantTK = (TTree*)gDirectory->Get(treeName);
337 if (!fBkgGeantTK) {
338 if (fPrintLevel >= 0) {
339 cout << "Cannot find Kine Tree for background event: " <<
340 fBkgGeantEventNumber << endl;
341 cout << "Goes back to event 0" << endl;
342 }
343 fBkgGeantEventNumber = 0;
344 sprintf(treeName, "TreeK%d", fBkgGeantEventNumber);
345 fBkgGeantTK = (TTree*)gDirectory->Get(treeName);
346 if (!fBkgGeantTK) {
347 cout << "ERROR: cannot find Kine Tree for background event: " <<
348 fBkgGeantEventNumber << endl;
349 exit(0);
350 }
351 }
352 if (fBkgGeantTK)
353 fBkgGeantTK->SetBranchAddress("Particles", &fBkgGeantParticles);
354 fBkgGeantTK->GetEvent(0); // why event 0 ???? necessary ????
355 // Hits: TreeH for event and branch "MUON"
356 sprintf(treeName, "TreeH%d", fBkgGeantEventNumber);
357 fBkgGeantTH = (TTree*)gDirectory->Get(treeName);
358 if (!fBkgGeantTH) {
359 cout << "ERROR: cannot find Hits Tree for background event: " <<
360 fBkgGeantEventNumber << endl;
361 exit(0);
362 }
363 if (fBkgGeantTH && fBkgGeantHits) {
364 branch = fBkgGeantTH->GetBranch("MUON");
365 if (branch) branch->SetAddress(&fBkgGeantHits);
366 }
367 fBkgGeantTH->GetEntries(); // necessary ????
368 // Back to the signal file
369 ((gAlice->TreeK())->GetCurrentFile())->cd();
370 if (fPrintLevel >= 2) {cout << "After cd(gAlice)" << endl; gDirectory->Dump();}
371 return;
372}
373
374//__________________________________________________________________________
375void AliMUONEventReconstructor::EventReconstruct(void)
376{
377 // To reconstruct one event
378 if (fPrintLevel >= 1) cout << "enter EventReconstruct" << endl;
379 MakeEventToBeReconstructed();
380 MakeSegments();
381 MakeTracks();
d837040f 382 if (fMUONData->IsTriggerTrackBranchesInTree())
383 ValidateTracksWithTrigger();
384
385 // Add tracks to MUON data container
386 for(Int_t i=0; i<GetNRecTracks(); i++) {
387 AliMUONTrack * track = (AliMUONTrack*) GetRecTracksPtr()->At(i);
388 fMUONData->AddRecTrack(*track);
389 }
390
a9e2aefa 391 return;
392}
393
276c44b7 394//__________________________________________________________________________
395void AliMUONEventReconstructor::EventReconstructTrigger(void)
396{
397 // To reconstruct one event
398 if (fPrintLevel >= 1) cout << "enter EventReconstructTrigger" << endl;
399 MakeTriggerTracks();
400 return;
401}
402
a9e2aefa 403 //__________________________________________________________________________
404void AliMUONEventReconstructor::ResetHitsForRec(void)
405{
406 // To reset the array and the number of HitsForRec,
407 // and also the number of HitsForRec
408 // and the index of the first HitForRec per chamber
409 if (fHitsForRecPtr) fHitsForRecPtr->Clear();
410 fNHitsForRec = 0;
343146bf 411 for (Int_t ch = 0; ch < fgkMaxMuonTrackingChambers; ch++)
a9e2aefa 412 fNHitsForRecPerChamber[ch] = fIndexOfFirstHitForRecPerChamber[ch] = 0;
413 return;
414}
415
416 //__________________________________________________________________________
417void AliMUONEventReconstructor::ResetSegments(void)
418{
419 // To reset the TClonesArray of segments and the number of Segments
420 // for all stations
30178c30 421 for (Int_t st = 0; st < fgkMaxMuonTrackingStations; st++) {
a9e2aefa 422 if (fSegmentsPtr[st]) fSegmentsPtr[st]->Clear();
423 fNSegments[st] = 0;
424 }
425 return;
426}
427
428 //__________________________________________________________________________
429void AliMUONEventReconstructor::ResetTracks(void)
430{
431 // To reset the TClonesArray of reconstructed tracks
8429a5e4 432 if (fRecTracksPtr) fRecTracksPtr->Delete();
433 // Delete in order that the Track destructors are called,
434 // hence the space for the TClonesArray of pointers to TrackHit's is freed
a9e2aefa 435 fNRecTracks = 0;
436 return;
437}
438
276c44b7 439 //__________________________________________________________________________
440void AliMUONEventReconstructor::ResetTriggerTracks(void)
441{
442 // To reset the TClonesArray of reconstructed trigger tracks
443 if (fRecTriggerTracksPtr) fRecTriggerTracksPtr->Delete();
444 // Delete in order that the Track destructors are called,
445 // hence the space for the TClonesArray of pointers to TrackHit's is freed
446 fNRecTriggerTracks = 0;
447 return;
448}
449
8429a5e4 450 //__________________________________________________________________________
451void AliMUONEventReconstructor::ResetTrackHits(void)
452{
453 // To reset the TClonesArray of hits on reconstructed tracks
454 if (fRecTrackHitsPtr) fRecTrackHitsPtr->Clear();
455 fNRecTrackHits = 0;
456 return;
457}
458
a9e2aefa 459 //__________________________________________________________________________
460void AliMUONEventReconstructor::MakeEventToBeReconstructed(void)
461{
462 // To make the list of hits to be reconstructed,
463 // either from the GEANT hits or from the raw clusters
464 // according to the parameter set for the reconstructor
e191bb57 465// TString evfoldname = AliConfig::GetDefaultEventFolderName();//to be interfaced properly
88cb7938 466
52c9bc11 467// AliRunLoader* rl = AliRunLoader::GetRunLoader(evfoldname);
468// if (rl == 0x0)
469// {
470// Error("MakeEventToBeReconstructed",
471// "Can not find Run Loader in Event Folder named %s.",
472// evfoldname.Data());
473// return;
474// }
475// AliLoader* gime = rl->GetLoader("MUONLoader");
476// if (gime == 0x0)
477// {
478// Error("MakeEventToBeReconstructed","Can not get MUON Loader from Run Loader.");
479// return;
480// }
88cb7938 481
a9e2aefa 482 if (fPrintLevel >= 1) cout << "enter MakeEventToBeReconstructed" << endl;
483 ResetHitsForRec();
484 if (fRecGeantHits == 1) {
485 // Reconstruction from GEANT hits
486 // Back to the signal file
52c9bc11 487 TTree* treeH = fLoader->TreeH();
88cb7938 488 if (treeH == 0x0)
489 {
52c9bc11 490 Int_t retval = fLoader->LoadHits();
88cb7938 491 if ( retval)
492 {
493 Error("MakeEventToBeReconstructed","Error occured while loading hits.");
494 return;
495 }
52c9bc11 496 treeH = fLoader->TreeH();
88cb7938 497 if (treeH == 0x0)
498 {
499 Error("MakeEventToBeReconstructed","Can not get TreeH");
500 return;
501 }
502 }
52c9bc11 503 fMUONData->SetTreeAddress("H");
504 AddHitsForRecFromGEANT(treeH);
88cb7938 505
a9e2aefa 506 // Background hits
507 AddHitsForRecFromBkgGEANT(fBkgGeantTH, fBkgGeantHits);
508 // Sort HitsForRec in increasing order with respect to chamber number
509 SortHitsForRecWithIncreasingChamber();
510 }
511 else {
512 // Reconstruction from raw clusters
513 // AliMUON *MUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ????
514 // Security on MUON ????
515 // TreeR assumed to be be "prepared" in calling function
516 // by "MUON->GetTreeR(nev)" ????
52c9bc11 517 TTree *treeR = fLoader->TreeR();
518 fMUONData->SetTreeAddress("RC");
9cbdf048 519 AddHitsForRecFromRawClusters(treeR);
a9e2aefa 520 // No sorting: it is done automatically in the previous function
521 }
522 if (fPrintLevel >= 10) {
523 cout << "end of MakeEventToBeReconstructed" << endl;
524 cout << "NHitsForRec: " << fNHitsForRec << endl;
343146bf 525 for (Int_t ch = 0; ch < fgkMaxMuonTrackingChambers; ch++) {
a9e2aefa 526 cout << "chamber(0...): " << ch
527 << " NHitsForRec: " << fNHitsForRecPerChamber[ch]
528 << " index(first HitForRec): " << fIndexOfFirstHitForRecPerChamber[ch]
529 << endl;
530 for (Int_t hit = fIndexOfFirstHitForRecPerChamber[ch];
531 hit < fIndexOfFirstHitForRecPerChamber[ch] + fNHitsForRecPerChamber[ch];
532 hit++) {
533 cout << "HitForRec index(0...): " << hit << endl;
534 ((*fHitsForRecPtr)[hit])->Dump();
535 }
536 }
537 }
538 return;
539}
540
541 //__________________________________________________________________________
542void AliMUONEventReconstructor::AddHitsForRecFromGEANT(TTree *TH)
543{
544 // To add to the list of hits for reconstruction
545 // the GEANT signal hits from a hit tree TH.
83dbc640 546 Int_t hitBits, chamBits; //AZ
a9e2aefa 547 if (fPrintLevel >= 2)
548 cout << "enter AddHitsForRecFromGEANT with TH: " << TH << endl;
549 if (TH == NULL) return;
52c9bc11 550 // AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ????
551 //AliMUONData * muondata = pMUON->GetMUONData();
a9e2aefa 552 // Security on MUON ????
553 // See whether it could be the same for signal and background ????
554 // Loop over tracks in tree
555 Int_t ntracks = (Int_t) TH->GetEntries();
556 if (fPrintLevel >= 2)
557 cout << "ntracks: " << ntracks << endl;
83dbc640 558 fMuons = 0; //AZ
a9e2aefa 559 for (Int_t track = 0; track < ntracks; track++) {
52c9bc11 560 fMUONData->ResetHits();
a9e2aefa 561 TH->GetEvent(track);
562 // Loop over hits
563 Int_t hit = 0;
83dbc640 564 hitBits = 0; // AZ
565 chamBits = 0; // AZ
566 Int_t itrack = track; //AZ
38302c61 567
568 Int_t ihit, nhits=0;
52c9bc11 569 nhits = (Int_t) fMUONData->Hits()->GetEntriesFast();
38302c61 570 AliMUONHit* mHit=0x0;
1391e633 571
38302c61 572 for(ihit=0; ihit<nhits; ihit++) {
52c9bc11 573 mHit = static_cast<AliMUONHit*>(fMUONData->Hits()->At(ihit));
38302c61 574 Int_t ipart = TMath::Abs ((Int_t) mHit->Particle()); //AZ
575 if (NewHitForRecFromGEANT(mHit,track, hit, 1) && ipart == 13
576 //if (NewHitForRecFromGEANT(mHit,itrack-1, hit, 1) && ipart == 13
1391e633 577 && itrack <= 2 && !BIT(mHit->Chamber()-1) ) chamBits |= BIT(mHit->Chamber()-1); //AZ - set bit
38302c61 578 }
1391e633 579
83dbc640 580 if (chamBits&3 && chamBits>>2&3 && chamBits>>4&3 && chamBits>>6&3 &&
581 chamBits>>8&3 && ((chamBits>>6&3)==3 || (chamBits>>8&3)==3))
582 fMuons += 1; //AZ
583 //if (chamBits&3 && chamBits>>2&3 && chamBits>>4&3 && chamBits>>6&3 &&
584 // chamBits>>8&3 && ((chamBits>>6&3)==3 || (chamBits>>8&3)==3) &&
585 // ((chamBits&3)==3 || (chamBits>>2&3)==3)) fMuons += 1;
a9e2aefa 586 } // end of track loop
587 return;
588}
589
590 //__________________________________________________________________________
591void AliMUONEventReconstructor::AddHitsForRecFromBkgGEANT(TTree *TH, TClonesArray *Hits)
592{
593 // To add to the list of hits for reconstruction
594 // the GEANT background hits from a hit tree TH and a pointer Hits to a hit list.
595 // How to have only one function "AddHitsForRecFromGEANT" ????
596 if (fPrintLevel >= 2)
597 cout << "enter AddHitsForRecFromBkgGEANT with TH: " << TH << endl;
598 if (TH == NULL) return;
599 // Loop over tracks in tree
600 Int_t ntracks = (Int_t) TH->GetEntries();
601 if (fPrintLevel >= 2)
602 cout << "ntracks: " << ntracks << endl;
603 for (Int_t track = 0; track < ntracks; track++) {
604 if (Hits) Hits->Clear();
605 TH->GetEvent(track);
606 // Loop over hits
607 for (Int_t hit = 0; hit < Hits->GetEntriesFast(); hit++) {
608 NewHitForRecFromGEANT((AliMUONHit*) (*Hits)[hit], track, hit, 0);
609 } // end of hit loop
610 } // end of track loop
611 return;
612}
613
614 //__________________________________________________________________________
615AliMUONHitForRec* AliMUONEventReconstructor::NewHitForRecFromGEANT(AliMUONHit* Hit, Int_t TrackNumber, Int_t HitNumber, Int_t Signal)
616{
617 // To make a new hit for reconstruction from a GEANT hit pointed to by "Hit",
618 // with hit number "HitNumber" in the track numbered "TrackNumber",
619 // either from signal ("Signal" = 1) or background ("Signal" = 0) event.
620 // Selects hits in tracking (not trigger) chambers.
621 // Takes into account the efficiency (fEfficiency)
622 // and the smearing from resolution (fBendingResolution and fNonBendingResolution).
623 // Adds a condition on the radius between RMin and RMax
624 // to better simulate the real chambers.
625 // Returns the pointer to the new hit for reconstruction,
626 // or NULL in case of inefficiency or non tracking chamber or bad radius.
627 // No condition on at most 20 cm from a muon from a resonance
628 // like in Fortran TRACKF_STAT.
629 AliMUONHitForRec* hitForRec;
630 Double_t bendCoor, nonBendCoor, radius;
0a5f36d9 631 Int_t chamber = Hit->Chamber() - 1; // chamber(0...)
a9e2aefa 632 // only in tracking chambers (fChamber starts at 1)
343146bf 633 if (chamber >= fgkMaxMuonTrackingChambers) return NULL;
a9e2aefa 634 // only if hit is efficient (keep track for checking ????)
635 if (gRandom->Rndm() > fEfficiency) return NULL;
636 // only if radius between RMin and RMax
94de3818 637 bendCoor = Hit->Y();
638 nonBendCoor = Hit->X();
a9e2aefa 639 radius = TMath::Sqrt((bendCoor * bendCoor) + (nonBendCoor * nonBendCoor));
d0bfce8d 640 // This cut is not needed with a realistic chamber geometry !!!!
641// if ((radius < fRMin[chamber]) || (radius > fRMax[chamber])) return NULL;
a9e2aefa 642 // new AliMUONHitForRec from GEANT hit and increment number of AliMUONHitForRec's
643 hitForRec = new ((*fHitsForRecPtr)[fNHitsForRec]) AliMUONHitForRec(Hit);
644 fNHitsForRec++;
645 // add smearing from resolution
646 hitForRec->SetBendingCoor(bendCoor + gRandom->Gaus(0., fBendingResolution));
647 hitForRec->SetNonBendingCoor(nonBendCoor
648 + gRandom->Gaus(0., fNonBendingResolution));
d0bfce8d 649// // !!!! without smearing
650// hitForRec->SetBendingCoor(bendCoor);
651// hitForRec->SetNonBendingCoor(nonBendCoor);
a9e2aefa 652 // more information into HitForRec
653 // resolution: angular effect to be added here ????
654 hitForRec->SetBendingReso2(fBendingResolution * fBendingResolution);
655 hitForRec->SetNonBendingReso2(fNonBendingResolution * fNonBendingResolution);
656 // GEANT track info
657 hitForRec->SetHitNumber(HitNumber);
658 hitForRec->SetTHTrack(TrackNumber);
659 hitForRec->SetGeantSignal(Signal);
660 if (fPrintLevel >= 10) {
661 cout << "track: " << TrackNumber << " hit: " << HitNumber << endl;
662 Hit->Dump();
663 cout << "AliMUONHitForRec number (1...): " << fNHitsForRec << endl;
664 hitForRec->Dump();}
665 return hitForRec;
666}
667
668 //__________________________________________________________________________
669void AliMUONEventReconstructor::SortHitsForRecWithIncreasingChamber()
670{
671 // Sort HitsForRec's in increasing order with respect to chamber number.
672 // Uses the function "Compare".
673 // Update the information for HitsForRec per chamber too.
674 Int_t ch, nhits, prevch;
675 fHitsForRecPtr->Sort();
343146bf 676 for (ch = 0; ch < fgkMaxMuonTrackingChambers; ch++) {
a9e2aefa 677 fNHitsForRecPerChamber[ch] = 0;
678 fIndexOfFirstHitForRecPerChamber[ch] = 0;
679 }
680 prevch = 0; // previous chamber
681 nhits = 0; // number of hits in current chamber
682 // Loop over HitsForRec
683 for (Int_t hit = 0; hit < fNHitsForRec; hit++) {
684 // chamber number (0...)
685 ch = ((AliMUONHitForRec*) ((*fHitsForRecPtr)[hit]))->GetChamberNumber();
686 // increment number of hits in current chamber
687 (fNHitsForRecPerChamber[ch])++;
688 // update index of first HitForRec in current chamber
689 // if chamber number different from previous one
690 if (ch != prevch) {
691 fIndexOfFirstHitForRecPerChamber[ch] = hit;
692 prevch = ch;
693 }
694 }
695 return;
696}
697
698// //__________________________________________________________________________
699// void AliMUONEventReconstructor::AddHitsForRecFromCathodeCorrelations(TTree* TC)
700// {
701// // OLD VERSION WHEN ONE ONE WAS USING SO CALLED CATHODE CORRELATIONS
702// // To add to the list of hits for reconstruction
703// // the (cathode correlated) raw clusters
704// // No condition added, like in Fortran TRACKF_STAT,
705// // on the radius between RMin and RMax.
706// AliMUONHitForRec *hitForRec;
707// if (fPrintLevel >= 1) cout << "enter AddHitsForRecFromCathodeCorrelations" << endl;
708// AliMUON *MUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ????
709// // Security on MUON ????
710// // Loop over tracking chambers
343146bf 711// for (Int_t ch = 0; ch < fgkMaxMuonTrackingChambers; ch++) {
a9e2aefa 712// // number of HitsForRec to 0 for the chamber
713// fNHitsForRecPerChamber[ch] = 0;
714// // index of first HitForRec for the chamber
715// if (ch == 0) fIndexOfFirstHitForRecPerChamber[ch] = 0;
716// else fIndexOfFirstHitForRecPerChamber[ch] = fNHitsForRec;
717// TClonesArray *reconst_hits = MUON->ReconstHitsAddress(ch);
718// MUON->ResetReconstHits();
719// TC->GetEvent();
720// Int_t ncor = (Int_t)reconst_hits->GetEntries();
721// // Loop over (cathode correlated) raw clusters
722// for (Int_t cor = 0; cor < ncor; cor++) {
723// AliMUONReconstHit * mCor =
724// (AliMUONReconstHit*) reconst_hits->UncheckedAt(cor);
725// // new AliMUONHitForRec from (cathode correlated) raw cluster
726// // and increment number of AliMUONHitForRec's (total and in chamber)
727// hitForRec = new ((*fHitsForRecPtr)[fNHitsForRec]) AliMUONHitForRec(mCor);
728// fNHitsForRec++;
729// (fNHitsForRecPerChamber[ch])++;
730// // more information into HitForRec
731// hitForRec->SetChamberNumber(ch);
732// hitForRec->SetHitNumber(cor);
733// // Z coordinate of the chamber (cm) with sign opposite to GEANT sign
734// // could (should) be more exact from chamber geometry ????
735// hitForRec->SetZ(-(&(MUON->Chamber(ch)))->Z());
736// if (fPrintLevel >= 10) {
737// cout << "chamber (0...): " << ch <<
738// " cathcorrel (0...): " << cor << endl;
739// mCor->Dump();
740// cout << "AliMUONHitForRec number (1...): " << fNHitsForRec << endl;
741// hitForRec->Dump();}
742// } // end of cluster loop
743// } // end of chamber loop
744// return;
745// }
746
747 //__________________________________________________________________________
748void AliMUONEventReconstructor::AddHitsForRecFromRawClusters(TTree* TR)
749{
750 // To add to the list of hits for reconstruction all the raw clusters
751 // No condition added, like in Fortran TRACKF_STAT,
752 // on the radius between RMin and RMax.
753 AliMUONHitForRec *hitForRec;
754 AliMUONRawCluster *clus;
f69d51b5 755 Int_t iclus, nclus, nTRentries;
a9e2aefa 756 TClonesArray *rawclusters;
757 if (fPrintLevel >= 1) cout << "enter AddHitsForRecFromRawClusters" << endl;
88cb7938 758
e191bb57 759// TString evfoldname = AliConfig::GetDefaultEventFolderName();//to be interfaced properly
52c9bc11 760// AliRunLoader* rl = AliRunLoader::GetRunLoader(evfoldname);
761// if (rl == 0x0)
762// {
763// Error("MakeEventToBeReconstructed",
764// "Can not find Run Loader in Event Folder named %s.",
765// evfoldname.Data());
766// return;
767// }
768// AliLoader* gime = rl->GetLoader("MUONLoader");
769// if (gime == 0x0)
770// {
771// Error("MakeEventToBeReconstructed","Can not get MUON Loader from Run Loader.");
772// return;
773// }
774// // Loading AliRun master
775// rl->LoadgAlice();
776// gAlice = rl->GetAliRun();
88cb7938 777
778 // Loading MUON subsystem
52c9bc11 779 // AliMUON * pMUON = (AliMUON *) gAlice->GetDetector("MUON");
88cb7938 780
f69d51b5 781 nTRentries = Int_t(TR->GetEntries());
782 if (nTRentries != 1) {
783 cout << "Error in AliMUONEventReconstructor::AddHitsForRecFromRawClusters"
784 << endl;
785 cout << "nTRentries = " << nTRentries << " not equal to 1" << endl;
786 exit(0);
787 }
52c9bc11 788 fLoader->TreeR()->GetEvent(0); // only one entry
789
a9e2aefa 790 // Loop over tracking chambers
343146bf 791 for (Int_t ch = 0; ch < fgkMaxMuonTrackingChambers; ch++) {
a9e2aefa 792 // number of HitsForRec to 0 for the chamber
793 fNHitsForRecPerChamber[ch] = 0;
794 // index of first HitForRec for the chamber
795 if (ch == 0) fIndexOfFirstHitForRecPerChamber[ch] = 0;
796 else fIndexOfFirstHitForRecPerChamber[ch] = fNHitsForRec;
52c9bc11 797 rawclusters =fMUONData->RawClusters(ch);
f69d51b5 798// pMUON->ResetRawClusters();
799// TR->GetEvent((Int_t) (TR->GetEntries()) - 1); // to be checked ????
a9e2aefa 800 nclus = (Int_t) (rawclusters->GetEntries());
801 // Loop over (cathode correlated) raw clusters
802 for (iclus = 0; iclus < nclus; iclus++) {
803 clus = (AliMUONRawCluster*) rawclusters->UncheckedAt(iclus);
804 // new AliMUONHitForRec from raw cluster
805 // and increment number of AliMUONHitForRec's (total and in chamber)
806 hitForRec = new ((*fHitsForRecPtr)[fNHitsForRec]) AliMUONHitForRec(clus);
807 fNHitsForRec++;
808 (fNHitsForRecPerChamber[ch])++;
809 // more information into HitForRec
810 // resolution: info should be already in raw cluster and taken from it ????
811 hitForRec->SetBendingReso2(fBendingResolution * fBendingResolution);
812 hitForRec->SetNonBendingReso2(fNonBendingResolution * fNonBendingResolution);
813 // original raw cluster
814 hitForRec->SetChamberNumber(ch);
815 hitForRec->SetHitNumber(iclus);
ba5b68db 816 // Z coordinate of the raw cluster (cm)
ba12c242 817 hitForRec->SetZ(clus->GetZ(0));
a9e2aefa 818 if (fPrintLevel >= 10) {
819 cout << "chamber (0...): " << ch <<
820 " raw cluster (0...): " << iclus << endl;
821 clus->Dump();
822 cout << "AliMUONHitForRec number (1...): " << fNHitsForRec << endl;
823 hitForRec->Dump();}
824 } // end of cluster loop
825 } // end of chamber loop
83dbc640 826 SortHitsForRecWithIncreasingChamber(); //AZ
a9e2aefa 827 return;
828}
829
830 //__________________________________________________________________________
831void AliMUONEventReconstructor::MakeSegments(void)
832{
833 // To make the list of segments in all stations,
834 // from the list of hits to be reconstructed
835 if (fPrintLevel >= 1) cout << "enter MakeSegments" << endl;
836 ResetSegments();
837 // Loop over stations
83dbc640 838 Int_t nb = (fTrackMethod == 2) ? 3 : 0; //AZ
30178c30 839 //AZ for (Int_t st = 0; st < fgkMaxMuonTrackingStations; st++)
840 for (Int_t st = nb; st < fgkMaxMuonTrackingStations; st++) //AZ
a9e2aefa 841 MakeSegmentsPerStation(st);
842 if (fPrintLevel >= 10) {
843 cout << "end of MakeSegments" << endl;
30178c30 844 for (Int_t st = 0; st < fgkMaxMuonTrackingStations; st++) {
a9e2aefa 845 cout << "station(0...): " << st
846 << " Segments: " << fNSegments[st]
847 << endl;
848 for (Int_t seg = 0;
849 seg < fNSegments[st];
850 seg++) {
851 cout << "Segment index(0...): " << seg << endl;
852 ((*fSegmentsPtr[st])[seg])->Dump();
853 }
854 }
855 }
856 return;
857}
858
859 //__________________________________________________________________________
860void AliMUONEventReconstructor::MakeSegmentsPerStation(Int_t Station)
861{
862 // To make the list of segments in station number "Station" (0...)
863 // from the list of hits to be reconstructed.
864 // Updates "fNSegments"[Station].
865 // Segments in stations 4 and 5 are sorted
866 // according to increasing absolute value of "impact parameter"
867 AliMUONHitForRec *hit1Ptr, *hit2Ptr;
868 AliMUONSegment *segment;
869 Bool_t last2st;
870 Double_t bendingSlope, distBend, distNonBend, extBendCoor, extNonBendCoor,
d0bfce8d 871 impactParam = 0., maxImpactParam = 0., minImpactParam = 0.; // =0 to avoid compilation warnings.
a9e2aefa 872 if (fPrintLevel >= 1)
873 cout << "enter MakeSegmentsPerStation (0...) " << Station << endl;
874 // first and second chambers (0...) in the station
875 Int_t ch1 = 2 * Station;
876 Int_t ch2 = ch1 + 1;
877 // variable true for stations downstream of the dipole:
878 // Station(0..4) equal to 3 or 4
879 if ((Station == 3) || (Station == 4)) {
880 last2st = kTRUE;
881 // maximum impact parameter (cm) according to fMinBendingMomentum...
882 maxImpactParam =
883 TMath::Abs(GetImpactParamFromBendingMomentum(fMinBendingMomentum));
d0bfce8d 884 // minimum impact parameter (cm) according to fMaxBendingMomentum...
885 minImpactParam =
886 TMath::Abs(GetImpactParamFromBendingMomentum(fMaxBendingMomentum));
a9e2aefa 887 }
888 else last2st = kFALSE;
889 // extrapolation factor from Z of first chamber to Z of second chamber
890 // dZ to be changed to take into account fine structure of chambers ????
b8273575 891 Double_t extrapFact;
a9e2aefa 892 // index for current segment
893 Int_t segmentIndex = 0;
894 // Loop over HitsForRec in the first chamber of the station
895 for (Int_t hit1 = fIndexOfFirstHitForRecPerChamber[ch1];
896 hit1 < fIndexOfFirstHitForRecPerChamber[ch1] + fNHitsForRecPerChamber[ch1];
897 hit1++) {
898 // pointer to the HitForRec
899 hit1Ptr = (AliMUONHitForRec*) ((*fHitsForRecPtr)[hit1]);
900 // extrapolation,
901 // on the straight line joining the HitForRec to the vertex (0,0,0),
902 // to the Z of the second chamber of the station
a9e2aefa 903 // Loop over HitsForRec in the second chamber of the station
904 for (Int_t hit2 = fIndexOfFirstHitForRecPerChamber[ch2];
905 hit2 < fIndexOfFirstHitForRecPerChamber[ch2] + fNHitsForRecPerChamber[ch2];
906 hit2++) {
907 // pointer to the HitForRec
908 hit2Ptr = (AliMUONHitForRec*) ((*fHitsForRecPtr)[hit2]);
909 // absolute values of distances, in bending and non bending planes,
910 // between the HitForRec in the second chamber
911 // and the previous extrapolation
b8273575 912 extrapFact = hit2Ptr->GetZ()/ hit1Ptr->GetZ();
913 extBendCoor = extrapFact * hit1Ptr->GetBendingCoor();
914 extNonBendCoor = extrapFact * hit1Ptr->GetNonBendingCoor();
a9e2aefa 915 distBend = TMath::Abs(hit2Ptr->GetBendingCoor() - extBendCoor);
916 distNonBend = TMath::Abs(hit2Ptr->GetNonBendingCoor() - extNonBendCoor);
917 if (last2st) {
918 // bending slope
919 bendingSlope = (hit1Ptr->GetBendingCoor() - hit2Ptr->GetBendingCoor()) /
920 (hit1Ptr->GetZ() - hit2Ptr->GetZ());
921 // absolute value of impact parameter
922 impactParam =
31817925 923 TMath::Abs(hit1Ptr->GetBendingCoor() - hit1Ptr->GetZ() * bendingSlope);
a9e2aefa 924 }
925 // check for distances not too large,
926 // and impact parameter not too big if stations downstream of the dipole.
927 // Conditions "distBend" and "impactParam" correlated for these stations ????
928 if ((distBend < fSegmentMaxDistBending[Station]) &&
929 (distNonBend < fSegmentMaxDistNonBending[Station]) &&
d0bfce8d 930 (!last2st || (impactParam < maxImpactParam)) &&
931 (!last2st || (impactParam > minImpactParam))) {
a9e2aefa 932 // make new segment
933 segment = new ((*fSegmentsPtr[Station])[segmentIndex])
934 AliMUONSegment(hit1Ptr, hit2Ptr);
935 // update "link" to this segment from the hit in the first chamber
936 if (hit1Ptr->GetNSegments() == 0)
937 hit1Ptr->SetIndexOfFirstSegment(segmentIndex);
938 hit1Ptr->SetNSegments(hit1Ptr->GetNSegments() + 1);
939 if (fPrintLevel >= 10) {
940 cout << "segmentIndex(0...): " << segmentIndex
941 << " distBend: " << distBend
942 << " distNonBend: " << distNonBend
943 << endl;
944 segment->Dump();
945 cout << "HitForRec in first chamber" << endl;
946 hit1Ptr->Dump();
947 cout << "HitForRec in second chamber" << endl;
948 hit2Ptr->Dump();
949 };
950 // increment index for current segment
951 segmentIndex++;
952 }
953 } //for (Int_t hit2
954 } // for (Int_t hit1...
955 fNSegments[Station] = segmentIndex;
956 // Sorting according to "impact parameter" if station(1..5) 4 or 5,
957 // i.e. Station(0..4) 3 or 4, using the function "Compare".
958 // After this sorting, it is impossible to use
959 // the "fNSegments" and "fIndexOfFirstSegment"
960 // of the HitForRec in the first chamber to explore all segments formed with it.
961 // Is this sorting really needed ????
962 if ((Station == 3) || (Station == 4)) (fSegmentsPtr[Station])->Sort();
963 if (fPrintLevel >= 1) cout << "Station: " << Station << " NSegments: "
964 << fNSegments[Station] << endl;
965 return;
966}
967
968 //__________________________________________________________________________
969void AliMUONEventReconstructor::MakeTracks(void)
970{
971 // To make the tracks,
972 // from the list of segments and points in all stations
973 if (fPrintLevel >= 1) cout << "enter MakeTracks" << endl;
8429a5e4 974 // The order may be important for the following Reset's
a9e2aefa 975 ResetTracks();
8429a5e4 976 ResetTrackHits();
83dbc640 977 if (fTrackMethod == 2) { //AZ - Kalman filter
978 MakeTrackCandidatesK();
979 // Follow tracks in stations(1..) 3, 2 and 1
980 FollowTracksK();
981 // Remove double tracks
982 RemoveDoubleTracksK();
983 // Propagate tracks to the vertex thru absorber
984 GoToVertex();
d837040f 985 } else {
83dbc640 986 // Look for candidates from at least 3 aligned points in stations(1..) 4 and 5
987 MakeTrackCandidates();
988 // Follow tracks in stations(1..) 3, 2 and 1
989 FollowTracks();
990 // Remove double tracks
991 RemoveDoubleTracks();
d837040f 992 UpdateTrackParamAtHit();
52c9bc11 993 }
a9e2aefa 994 return;
995}
996
276c44b7 997 //__________________________________________________________________________
d837040f 998void AliMUONEventReconstructor::ValidateTracksWithTrigger(void)
999{
7e6d7e07 1000 // Try to match track from tracking system with trigger track
d837040f 1001 AliMUONTrack *track;
24ab3324 1002 TClonesArray *recTriggerTracks;
1003
1004 fMUONData->ResetRecTriggerTracks();
1005 fMUONData->SetTreeAddress("RL");
1006 fMUONData->GetRecTriggerTracks();
1007 recTriggerTracks = fMUONData->RecTriggerTracks();
e8765288 1008
d837040f 1009 track = (AliMUONTrack*) fRecTracksPtr->First();
1010 while (track) {
1011 track->MatchTriggerTrack(recTriggerTracks);
1012 track = (AliMUONTrack*) fRecTracksPtr->After(track);
e8765288 1013 }
24ab3324 1014
d837040f 1015}
1016
1017 //__________________________________________________________________________
1018Bool_t AliMUONEventReconstructor::MakeTriggerTracks(void)
276c44b7 1019{
1020 // To make the trigger tracks from Local Trigger
1021 if (fPrintLevel >= 1) cout << "enter MakeTriggerTracks" << endl;
52c9bc11 1022 // ResetTriggerTracks();
276c44b7 1023
1024 Int_t nTRentries;
52c9bc11 1025 Long_t gloTrigPat;
276c44b7 1026 TClonesArray *localTrigger;
9131b4fe 1027 TClonesArray *globalTrigger;
276c44b7 1028 AliMUONLocalTrigger *locTrg;
9131b4fe 1029 AliMUONGlobalTrigger *gloTrg;
276c44b7 1030 AliMUONTriggerCircuit *circuit;
52c9bc11 1031 AliMUONTriggerTrack *recTriggerTrack = 0;
d837040f 1032
30178c30 1033 TTree* treeR = fLoader->TreeR();
276c44b7 1034
276c44b7 1035 // Loading MUON subsystem
1036 AliMUON * pMUON = (AliMUON *) gAlice->GetDetector("MUON");
1037
30178c30 1038 nTRentries = Int_t(treeR->GetEntries());
d837040f 1039
30178c30 1040 treeR->GetEvent(0); // only one entry
d837040f 1041
1042 if (!(fMUONData->IsTriggerBranchesInTree())) {
1043 cout << "Warning in AliMUONEventReconstructor::MakeTriggerTracks"
52c9bc11 1044 << endl;
d837040f 1045 cout << "Trigger information is not avalaible, nTRentries = " << nTRentries << " not equal to 1" << endl;
1046 return kFALSE;
276c44b7 1047 }
276c44b7 1048
ce3e25a8 1049 fMUONData->SetTreeAddress("TC");
52c9bc11 1050 fMUONData->GetTrigger();
9131b4fe 1051
52c9bc11 1052 // global trigger for trigger pattern
9131b4fe 1053 gloTrigPat = 0;
52c9bc11 1054 globalTrigger = fMUONData->GlobalTrigger();
9131b4fe 1055 gloTrg = (AliMUONGlobalTrigger*)globalTrigger->UncheckedAt(0);
8efb0686 1056 if (gloTrg) {
1057 if (gloTrg->SinglePlusLpt()) gloTrigPat|= 0x1;
1058 if (gloTrg->SinglePlusHpt()) gloTrigPat|= 0x2;
1059 if (gloTrg->SinglePlusApt()) gloTrigPat|= 0x4;
1060
1061 if (gloTrg->SingleMinusLpt()) gloTrigPat|= 0x8;
1062 if (gloTrg->SingleMinusHpt()) gloTrigPat|= 0x10;
1063 if (gloTrg->SingleMinusApt()) gloTrigPat|= 0x20;
1064
1065 if (gloTrg->SingleUndefLpt()) gloTrigPat|= 0x40;
1066 if (gloTrg->SingleUndefHpt()) gloTrigPat|= 0x80;
1067 if (gloTrg->SingleUndefApt()) gloTrigPat|= 0x100;
1068
1069 if (gloTrg->PairUnlikeLpt()) gloTrigPat|= 0x200;
1070 if (gloTrg->PairUnlikeHpt()) gloTrigPat|= 0x400;
1071 if (gloTrg->PairUnlikeApt()) gloTrigPat|= 0x800;
1072
1073 if (gloTrg->PairLikeLpt()) gloTrigPat|= 0x1000;
1074 if (gloTrg->PairLikeHpt()) gloTrigPat|= 0x2000;
1075 if (gloTrg->PairLikeApt()) gloTrigPat|= 0x4000;
1076 }
9131b4fe 1077
52c9bc11 1078
1079
1080 // local trigger for tracking
1081 localTrigger = fMUONData->LocalTrigger();
276c44b7 1082 Int_t nlocals = (Int_t) (localTrigger->GetEntries());
1083 Float_t z11 = ( &(pMUON->Chamber(10)) )->Z();
1084 Float_t z21 = ( &(pMUON->Chamber(12)) )->Z();
1085
1086 for (Int_t i=0; i<nlocals; i++) { // loop on Local Trigger
52c9bc11 1087 locTrg = (AliMUONLocalTrigger*)localTrigger->UncheckedAt(i);
1088 circuit = &(pMUON->TriggerCircuit(locTrg->LoCircuit()));
1089 Float_t y11 = circuit->GetY11Pos(locTrg->LoStripX());
aeb4f510 1090 Int_t stripX21 = locTrg->LoStripX()+locTrg->LoDev()+1;
1091 Float_t y21 = circuit->GetY21Pos(stripX21);
52c9bc11 1092 Float_t x11 = circuit->GetX11Pos(locTrg->LoStripY());
1093 Float_t thetax = TMath::ATan2( x11 , z11 );
1094 Float_t thetay = TMath::ATan2( (y21-y11) , (z21-z11) );
1095
1096 recTriggerTrack = new AliMUONTriggerTrack(x11,y11,thetax,thetay,gloTrigPat,this);
1097 // since static statement does not work, set gloTrigPat for each track
1098
1099 // fNRecTriggerTracks++;
1100 fMUONData->AddRecTriggerTrack(*recTriggerTrack);
276c44b7 1101 } // end of loop on Local Trigger
d837040f 1102 return kTRUE;
276c44b7 1103}
1104
a9e2aefa 1105 //__________________________________________________________________________
1106Int_t AliMUONEventReconstructor::MakeTrackCandidatesWithTwoSegments(AliMUONSegment *BegSegment)
1107{
1108 // To make track candidates with two segments in stations(1..) 4 and 5,
1109 // the first segment being pointed to by "BegSegment".
1110 // Returns the number of such track candidates.
1111 Int_t endStation, iEndSegment, nbCan2Seg;
b8273575 1112 AliMUONSegment *endSegment;
1113 AliMUONSegment *extrapSegment = NULL;
a9e2aefa 1114 AliMUONTrack *recTrack;
1115 Double_t mcsFactor;
1116 if (fPrintLevel >= 1) cout << "enter MakeTrackCandidatesWithTwoSegments" << endl;
1117 // Station for the end segment
1118 endStation = 7 - (BegSegment->GetHitForRec1())->GetChamberNumber() / 2;
1119 // multiple scattering factor corresponding to one chamber
1120 mcsFactor = 0.0136 /
1121 GetBendingMomentumFromImpactParam(BegSegment->GetBendingImpact());
1122 mcsFactor = fChamberThicknessInX0 * mcsFactor * mcsFactor;
1123 // linear extrapolation to end station
a9e2aefa 1124 // number of candidates with 2 segments to 0
1125 nbCan2Seg = 0;
1126 // Loop over segments in the end station
1127 for (iEndSegment = 0; iEndSegment < fNSegments[endStation]; iEndSegment++) {
1128 // pointer to segment
1129 endSegment = (AliMUONSegment*) ((*fSegmentsPtr[endStation])[iEndSegment]);
1130 // test compatibility between current segment and "extrapSegment"
04b5ea16 1131 // 4 because 4 quantities in chi2
b8273575 1132 extrapSegment =
1133 BegSegment->CreateSegmentFromLinearExtrapToStation(endSegment->GetZ(), mcsFactor);
a9e2aefa 1134 if ((endSegment->
1135 NormalizedChi2WithSegment(extrapSegment,
1136 fMaxSigma2Distance)) <= 4.0) {
1137 // both segments compatible:
1138 // make track candidate from "begSegment" and "endSegment"
1139 if (fPrintLevel >= 2)
1140 cout << "TrackCandidate with Segment " << iEndSegment <<
1141 " in Station(0..) " << endStation << endl;
1142 // flag for both segments in one track:
1143 // to be done in track constructor ????
1144 BegSegment->SetInTrack(kTRUE);
1145 endSegment->SetInTrack(kTRUE);
1146 recTrack = new ((*fRecTracksPtr)[fNRecTracks])
1147 AliMUONTrack(BegSegment, endSegment, this);
1148 fNRecTracks++;
1149 if (fPrintLevel >= 10) recTrack->RecursiveDump();
1150 // increment number of track candidates with 2 segments
1151 nbCan2Seg++;
1152 }
1153 } // for (iEndSegment = 0;...
1154 delete extrapSegment; // should not delete HitForRec's it points to !!!!
1155 return nbCan2Seg;
1156}
1157
1158 //__________________________________________________________________________
1159Int_t AliMUONEventReconstructor::MakeTrackCandidatesWithOneSegmentAndOnePoint(AliMUONSegment *BegSegment)
1160{
1161 // To make track candidates with one segment and one point
1162 // in stations(1..) 4 and 5,
1163 // the segment being pointed to by "BegSegment".
1164 Int_t ch, ch1, ch2, endStation, iHit, iHitMax, iHitMin, nbCan1Seg1Hit;
b8273575 1165 AliMUONHitForRec *extrapHitForRec= NULL;
1166 AliMUONHitForRec *hit;
a9e2aefa 1167 AliMUONTrack *recTrack;
1168 Double_t mcsFactor;
1169 if (fPrintLevel >= 1)
1170 cout << "enter MakeTrackCandidatesWithOneSegmentAndOnePoint" << endl;
1171 // station for the end point
1172 endStation = 7 - (BegSegment->GetHitForRec1())->GetChamberNumber() / 2;
1173 // multiple scattering factor corresponding to one chamber
1174 mcsFactor = 0.0136 /
1175 GetBendingMomentumFromImpactParam(BegSegment->GetBendingImpact());
1176 mcsFactor = fChamberThicknessInX0 * mcsFactor * mcsFactor;
1177 // first and second chambers(0..) in the end station
1178 ch1 = 2 * endStation;
1179 ch2 = ch1 + 1;
1180 // number of candidates to 0
1181 nbCan1Seg1Hit = 0;
1182 // Loop over chambers of the end station
1183 for (ch = ch2; ch >= ch1; ch--) {
a9e2aefa 1184 // limits for the hit index in the loop
1185 iHitMin = fIndexOfFirstHitForRecPerChamber[ch];
1186 iHitMax = iHitMin + fNHitsForRecPerChamber[ch];
1187 // Loop over HitForRec's in the chamber
1188 for (iHit = iHitMin; iHit < iHitMax; iHit++) {
1189 // pointer to HitForRec
1190 hit = (AliMUONHitForRec*) ((*fHitsForRecPtr)[iHit]);
1191 // test compatibility between current HitForRec and "extrapHitForRec"
04b5ea16 1192 // 2 because 2 quantities in chi2
b8273575 1193 // linear extrapolation to chamber
1194 extrapHitForRec =
1195 BegSegment->CreateHitForRecFromLinearExtrapToChamber( hit->GetZ(), mcsFactor);
a9e2aefa 1196 if ((hit->
1197 NormalizedChi2WithHitForRec(extrapHitForRec,
1198 fMaxSigma2Distance)) <= 2.0) {
1199 // both HitForRec's compatible:
1200 // make track candidate from begSegment and current HitForRec
1201 if (fPrintLevel >= 2)
1202 cout << "TrackCandidate with HitForRec " << iHit <<
1203 " in Chamber(0..) " << ch << endl;
1204 // flag for beginning segments in one track:
1205 // to be done in track constructor ????
1206 BegSegment->SetInTrack(kTRUE);
1207 recTrack = new ((*fRecTracksPtr)[fNRecTracks])
1208 AliMUONTrack(BegSegment, hit, this);
1209 // the right place to eliminate "double counting" ???? how ????
1210 fNRecTracks++;
1211 if (fPrintLevel >= 10) recTrack->RecursiveDump();
1212 // increment number of track candidates
1213 nbCan1Seg1Hit++;
1214 }
1215 } // for (iHit = iHitMin;...
1216 delete extrapHitForRec;
1217 } // for (ch = ch2;...
1218 return nbCan1Seg1Hit;
1219}
1220
1221 //__________________________________________________________________________
1222void AliMUONEventReconstructor::MakeTrackCandidates(void)
1223{
1224 // To make track candidates
1225 // with at least 3 aligned points in stations(1..) 4 and 5
1226 // (two Segment's or one Segment and one HitForRec)
1227 Int_t begStation, iBegSegment, nbCan1Seg1Hit, nbCan2Seg;
1228 AliMUONSegment *begSegment;
1229 if (fPrintLevel >= 1) cout << "enter MakeTrackCandidates" << endl;
1230 // Loop over stations(1..) 5 and 4 for the beginning segment
1231 for (begStation = 4; begStation > 2; begStation--) {
1232 // Loop over segments in the beginning station
1233 for (iBegSegment = 0; iBegSegment < fNSegments[begStation]; iBegSegment++) {
1234 // pointer to segment
1235 begSegment = (AliMUONSegment*) ((*fSegmentsPtr[begStation])[iBegSegment]);
1236 if (fPrintLevel >= 2)
1237 cout << "look for TrackCandidate's with Segment " << iBegSegment <<
1238 " in Station(0..) " << begStation << endl;
1239 // Look for track candidates with two segments,
1240 // "begSegment" and all compatible segments in other station.
1241 // Only for beginning station(1..) 5
1242 // because candidates with 2 segments have to looked for only once.
1243 if (begStation == 4)
1244 nbCan2Seg = MakeTrackCandidatesWithTwoSegments(begSegment);
956019b6 1245 // Look for track candidates with one segment and one point,
a9e2aefa 1246 // "begSegment" and all compatible HitForRec's in other station.
1247 // Only if "begSegment" does not belong already to a track candidate.
1248 // Is that a too strong condition ????
1249 if (!(begSegment->GetInTrack()))
1250 nbCan1Seg1Hit = MakeTrackCandidatesWithOneSegmentAndOnePoint(begSegment);
1251 } // for (iBegSegment = 0;...
1252 } // for (begStation = 4;...
1253 return;
1254}
1255
1256 //__________________________________________________________________________
1257void AliMUONEventReconstructor::FollowTracks(void)
1258{
1259 // Follow tracks in stations(1..) 3, 2 and 1
04b5ea16 1260 // too long: should be made more modular !!!!
b8273575 1261 AliMUONHitForRec *bestHit, *extrapHit, *hit;
1262 AliMUONSegment *bestSegment, *extrapSegment, *segment;
04b5ea16 1263 AliMUONTrack *track, *nextTrack;
1264 AliMUONTrackParam *trackParam1, trackParam[2], trackParamVertex;
ecfa008b 1265 // -1 to avoid compilation warnings
1266 Int_t ch = -1, chInStation, chBestHit = -1, iHit, iSegment, station, trackIndex;
04b5ea16 1267 Double_t bestChi2, chi2, dZ1, dZ2, dZ3, maxSigma2Distance, mcsFactor;
d0bfce8d 1268 Double_t bendingMomentum, chi2Norm = 0.;
9cbdf048 1269 AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ????
04b5ea16 1270 // local maxSigma2Distance, for easy increase in testing
1271 maxSigma2Distance = fMaxSigma2Distance;
a9e2aefa 1272 if (fPrintLevel >= 2)
1273 cout << "enter FollowTracks" << endl;
1274 // Loop over track candidates
04b5ea16 1275 track = (AliMUONTrack*) fRecTracksPtr->First();
1276 trackIndex = -1;
1277 while (track) {
1278 // Follow function for each track candidate ????
1279 trackIndex++;
1280 nextTrack = (AliMUONTrack*) fRecTracksPtr->After(track); // prepare next track
a9e2aefa 1281 if (fPrintLevel >= 2)
1282 cout << "FollowTracks: track candidate(0..): " << trackIndex << endl;
956019b6 1283 // Fit track candidate
1284 track->SetFitMCS(0); // without multiple Coulomb scattering
1285 track->SetFitNParam(3); // with 3 parameters (X = Y = 0)
1286 track->SetFitStart(0); // from parameters at vertex
1287 track->Fit();
a9e2aefa 1288 if (fPrintLevel >= 10) {
1289 cout << "FollowTracks: track candidate(0..): " << trackIndex
956019b6 1290 << " after fit in stations(0..) 3 and 4" << endl;
a9e2aefa 1291 track->RecursiveDump();
1292 }
1293 // Loop over stations(1..) 3, 2 and 1
04b5ea16 1294 // something SPECIAL for stations 2 and 1 for majority 3 coincidence ????
1295 // otherwise: majority coincidence 2 !!!!
a9e2aefa 1296 for (station = 2; station >= 0; station--) {
1297 // Track parameters at first track hit (smallest Z)
1298 trackParam1 = ((AliMUONTrackHit*)
1299 (track->GetTrackHitsPtr()->First()))->GetTrackParam();
1300 // extrapolation to station
1301 trackParam1->ExtrapToStation(station, trackParam);
79e1e601 1302 extrapSegment = new AliMUONSegment(); // empty segment
a9e2aefa 1303 // multiple scattering factor corresponding to one chamber
1304 // and momentum in bending plane (not total)
1305 mcsFactor = 0.0136 * trackParam1->GetInverseBendingMomentum();
1306 mcsFactor = fChamberThicknessInX0 * mcsFactor * mcsFactor;
1307 // Z difference from previous station
9cbdf048 1308 dZ1 = (&(pMUON->Chamber(2 * station)))->Z() -
1309 (&(pMUON->Chamber(2 * station + 2)))->Z();
a9e2aefa 1310 // Z difference between the two previous stations
9cbdf048 1311 dZ2 = (&(pMUON->Chamber(2 * station + 2)))->Z() -
1312 (&(pMUON->Chamber(2 * station + 4)))->Z();
04b5ea16 1313 // Z difference between the two chambers in the previous station
1314 dZ3 = (&(pMUON->Chamber(2 * station)))->Z() -
1315 (&(pMUON->Chamber(2 * station + 1)))->Z();
1316 extrapSegment->SetBendingCoorReso2(fBendingResolution * fBendingResolution);
1317 extrapSegment->
1318 SetNonBendingCoorReso2(fNonBendingResolution * fNonBendingResolution);
1319 extrapSegment->UpdateFromStationTrackParam
1320 (trackParam, mcsFactor, dZ1, dZ2, dZ3, station,
1321 trackParam1->GetInverseBendingMomentum());
a9e2aefa 1322 bestChi2 = 5.0;
1323 bestSegment = NULL;
1324 if (fPrintLevel >= 10) {
1325 cout << "FollowTracks: track candidate(0..): " << trackIndex
1326 << " Look for segment in station(0..): " << station << endl;
1327 }
1328 // Loop over segments in station
1329 for (iSegment = 0; iSegment < fNSegments[station]; iSegment++) {
1330 // Look for best compatible Segment in station
1331 // should consider all possibilities ????
1332 // multiple scattering ????
1333 // separation in 2 functions: Segment and HitForRec ????
1334 segment = (AliMUONSegment*) ((*fSegmentsPtr[station])[iSegment]);
d0bfce8d 1335 // correction of corrected segment (fBendingCoor and fNonBendingCoor)
1336 // according to real Z value of "segment" and slopes of "extrapSegment"
b8273575 1337 (&(trackParam[0]))->ExtrapToZ(segment->GetZ());
1338 (&(trackParam[1]))->ExtrapToZ(segment->GetZ());
1339 extrapSegment->SetBendingCoor((&(trackParam[0]))->GetBendingCoor());
1340 extrapSegment->SetNonBendingCoor((&(trackParam[0]))->GetNonBendingCoor());
1341 extrapSegment->SetBendingSlope((&(trackParam[0]))->GetBendingSlope());
1342 extrapSegment->SetNonBendingSlope((&(trackParam[0]))->GetNonBendingSlope());
d0bfce8d 1343 chi2 = segment->
b8273575 1344 NormalizedChi2WithSegment(extrapSegment, maxSigma2Distance);
a9e2aefa 1345 if (chi2 < bestChi2) {
1346 // update best Chi2 and Segment if better found
1347 bestSegment = segment;
1348 bestChi2 = chi2;
1349 }
1350 }
1351 if (bestSegment) {
1352 // best segment found: add it to track candidate
b8273575 1353 (&(trackParam[0]))->ExtrapToZ(bestSegment->GetZ());
1354 (&(trackParam[1]))->ExtrapToZ(bestSegment->GetZ());
a9e2aefa 1355 track->AddSegment(bestSegment);
1356 // set track parameters at these two TrakHit's
1357 track->SetTrackParamAtHit(track->GetNTrackHits() - 2, &(trackParam[0]));
1358 track->SetTrackParamAtHit(track->GetNTrackHits() - 1, &(trackParam[1]));
1359 if (fPrintLevel >= 10) {
1360 cout << "FollowTracks: track candidate(0..): " << trackIndex
1361 << " Added segment in station(0..): " << station << endl;
1362 track->RecursiveDump();
1363 }
1364 }
1365 else {
1366 // No best segment found:
1367 // Look for best compatible HitForRec in station:
1368 // should consider all possibilities ????
1369 // multiple scattering ???? do about like for extrapSegment !!!!
79e1e601 1370 extrapHit = new AliMUONHitForRec(); // empty hit
a9e2aefa 1371 bestChi2 = 3.0;
1372 bestHit = NULL;
1373 if (fPrintLevel >= 10) {
1374 cout << "FollowTracks: track candidate(0..): " << trackIndex
1375 << " Segment not found, look for hit in station(0..): " << station
1376 << endl;
1377 }
1378 // Loop over chambers of the station
d82671a0 1379 for (chInStation = 0; chInStation < 2; chInStation++) {
956019b6 1380 ch = 2 * station + chInStation;
a9e2aefa 1381 for (iHit = fIndexOfFirstHitForRecPerChamber[ch];
1382 iHit < fIndexOfFirstHitForRecPerChamber[ch] +
1383 fNHitsForRecPerChamber[ch];
1384 iHit++) {
1385 hit = (AliMUONHitForRec*) ((*fHitsForRecPtr)[iHit]);
b8273575 1386 // coordinates of extrapolated hit
1387 (&(trackParam[chInStation]))->ExtrapToZ(hit->GetZ());
1388 extrapHit->
1389 SetBendingCoor((&(trackParam[chInStation]))->GetBendingCoor());
1390 extrapHit->
1391 SetNonBendingCoor((&(trackParam[chInStation]))->GetNonBendingCoor());
1392 // resolutions from "extrapSegment"
1393 extrapHit->SetBendingReso2(extrapSegment->GetBendingCoorReso2());
1394 extrapHit->SetNonBendingReso2(extrapSegment->GetNonBendingCoorReso2());
1395 // Loop over hits in the chamber
a9e2aefa 1396 // condition for hit not already in segment ????
1397 chi2 = hit->NormalizedChi2WithHitForRec(extrapHit, maxSigma2Distance);
1398 if (chi2 < bestChi2) {
1399 // update best Chi2 and HitForRec if better found
1400 bestHit = hit;
1401 bestChi2 = chi2;
d82671a0 1402 chBestHit = chInStation;
a9e2aefa 1403 }
1404 }
1405 }
1406 if (bestHit) {
1407 // best hit found: add it to track candidate
b8273575 1408 (&(trackParam[chBestHit]))->ExtrapToZ(bestHit->GetZ());
a9e2aefa 1409 track->AddHitForRec(bestHit);
956019b6 1410 // set track parameters at this TrackHit
a9e2aefa 1411 track->SetTrackParamAtHit(track->GetNTrackHits() - 1,
1412 &(trackParam[chBestHit]));
1413 if (fPrintLevel >= 10) {
1414 cout << "FollowTracks: track candidate(0..): " << trackIndex
1415 << " Added hit in station(0..): " << station << endl;
1416 track->RecursiveDump();
1417 }
1418 }
1419 else {
8429a5e4 1420 // Remove current track candidate
1421 // and corresponding TrackHit's, ...
1422 track->Remove();
04b5ea16 1423 delete extrapSegment;
d0bfce8d 1424 delete extrapHit;
a9e2aefa 1425 break; // stop the search for this candidate:
1426 // exit from the loop over station
1427 }
d0bfce8d 1428 delete extrapHit;
a9e2aefa 1429 }
04b5ea16 1430 delete extrapSegment;
a9e2aefa 1431 // Sort track hits according to increasing Z
1432 track->GetTrackHitsPtr()->Sort();
1433 // Update track parameters at first track hit (smallest Z)
1434 trackParam1 = ((AliMUONTrackHit*)
1435 (track->GetTrackHitsPtr()->First()))->GetTrackParam();
d0bfce8d 1436 bendingMomentum = 0.;
1437 if (TMath::Abs(trackParam1->GetInverseBendingMomentum()) > 0.)
1438 bendingMomentum = TMath::Abs(1/(trackParam1->GetInverseBendingMomentum()));
1439 // Track removed if bendingMomentum not in window [min, max]
1440 if ((bendingMomentum < fMinBendingMomentum) || (bendingMomentum > fMaxBendingMomentum)) {
1441 track->Remove();
1442 break; // stop the search for this candidate:
1443 // exit from the loop over station
1444 }
956019b6 1445 // Track fit
04b5ea16 1446 // with multiple Coulomb scattering if all stations
1447 if (station == 0) track->SetFitMCS(1);
956019b6 1448 // without multiple Coulomb scattering if not all stations
04b5ea16 1449 else track->SetFitMCS(0);
956019b6 1450 track->SetFitNParam(5); // with 5 parameters (momentum and position)
1451 track->SetFitStart(1); // from parameters at first hit
1452 track->Fit();
d0bfce8d 1453 Double_t numberOfDegFree = (2.0 * track->GetNTrackHits() - 5);
1454 if (numberOfDegFree > 0) {
1455 chi2Norm = track->GetFitFMin() / numberOfDegFree;
1456 } else {
1457 chi2Norm = 1.e10;
1458 }
1459 // Track removed if normalized chi2 too high
1460 if (chi2Norm > fMaxChi2) {
1461 track->Remove();
1462 break; // stop the search for this candidate:
1463 // exit from the loop over station
1464 }
a9e2aefa 1465 if (fPrintLevel >= 10) {
1466 cout << "FollowTracks: track candidate(0..): " << trackIndex
1467 << " after fit from station(0..): " << station << " to 4" << endl;
1468 track->RecursiveDump();
1469 }
04b5ea16 1470 // Track extrapolation to the vertex through the absorber (Branson)
956019b6 1471 // after going through the first station
04b5ea16 1472 if (station == 0) {
1473 trackParamVertex = *trackParam1;
1474 (&trackParamVertex)->ExtrapToVertex();
1475 track->SetTrackParamAtVertex(&trackParamVertex);
6ae236ee 1476 if (fPrintLevel >= 1) {
1477 cout << "FollowTracks: track candidate(0..): " << trackIndex
1478 << " after extrapolation to vertex" << endl;
1479 track->RecursiveDump();
1480 }
04b5ea16 1481 }
a9e2aefa 1482 } // for (station = 2;...
04b5ea16 1483 // go really to next track
1484 track = nextTrack;
1485 } // while (track)
1486 // Compression of track array (necessary after Remove ????)
1487 fRecTracksPtr->Compress();
1488 return;
1489}
1490
1491 //__________________________________________________________________________
8429a5e4 1492void AliMUONEventReconstructor::RemoveDoubleTracks(void)
1493{
1494 // To remove double tracks.
1495 // Tracks are considered identical
1496 // if they have at least half of their hits in common.
1497 // Among two identical tracks, one keeps the track with the larger number of hits
1498 // or, if these numbers are equal, the track with the minimum Chi2.
1499 AliMUONTrack *track1, *track2, *trackToRemove;
1500 Bool_t identicalTracks;
1501 Int_t hitsInCommon, nHits1, nHits2;
1502 identicalTracks = kTRUE;
1503 while (identicalTracks) {
1504 identicalTracks = kFALSE;
1505 // Loop over first track of the pair
1506 track1 = (AliMUONTrack*) fRecTracksPtr->First();
1507 while (track1 && (!identicalTracks)) {
1508 nHits1 = track1->GetNTrackHits();
1509 // Loop over second track of the pair
1510 track2 = (AliMUONTrack*) fRecTracksPtr->After(track1);
1511 while (track2 && (!identicalTracks)) {
1512 nHits2 = track2->GetNTrackHits();
1513 // number of hits in common between two tracks
1514 hitsInCommon = track1->HitsInCommon(track2);
1515 // check for identical tracks
1516 if ((4 * hitsInCommon) >= (nHits1 + nHits2)) {
1517 identicalTracks = kTRUE;
1518 // decide which track to remove
1519 if (nHits1 > nHits2) trackToRemove = track2;
1520 else if (nHits1 < nHits2) trackToRemove = track1;
1521 else if ((track1->GetFitFMin()) < (track2->GetFitFMin()))
1522 trackToRemove = track2;
1523 else trackToRemove = track1;
1524 // remove it
1525 trackToRemove->Remove();
1526 }
1527 track2 = (AliMUONTrack*) fRecTracksPtr->After(track2);
1528 } // track2
1529 track1 = (AliMUONTrack*) fRecTracksPtr->After(track1);
1530 } // track1
1531 }
1532 return;
1533}
1534
d837040f 1535 //__________________________________________________________________________
1536void AliMUONEventReconstructor::UpdateTrackParamAtHit()
1537{
1538 // Set track parameters after track fitting. Fill fTrackParamAtHit of AliMUONTrack's
1539 AliMUONTrack *track;
1540 AliMUONTrackHit *trackHit;
1541 AliMUONTrackParam *trackParam;
1542 track = (AliMUONTrack*) fRecTracksPtr->First();
1543 while (track) {
1544 trackHit = (AliMUONTrackHit*) (track->GetTrackHitsPtr())->First();
1545 while (trackHit) {
1546 trackParam = trackHit->GetTrackParam();
1547 track->AddTrackParamAtHit(trackParam);
1548 trackHit = (AliMUONTrackHit*) (track->GetTrackHitsPtr())->After(trackHit);
1549 } // trackHit
1550 track = (AliMUONTrack*) fRecTracksPtr->After(track);
1551 } // track
1552 return;
1553}
1554
8429a5e4 1555 //__________________________________________________________________________
04b5ea16 1556void AliMUONEventReconstructor::EventDump(void)
1557{
1558 // Dump reconstructed event (track parameters at vertex and at first hit),
1559 // and the particle parameters
1560
1561 AliMUONTrack *track;
1562 AliMUONTrackParam *trackParam, *trackParam1;
04b5ea16 1563 Double_t bendingSlope, nonBendingSlope, pYZ;
1564 Double_t pX, pY, pZ, x, y, z, c;
1565 Int_t np, trackIndex, nTrackHits;
1566
1567 if (fPrintLevel >= 1) cout << "****** enter EventDump ******" << endl;
1568 if (fPrintLevel >= 1) {
1569 cout << " Number of Reconstructed tracks :" << fNRecTracks << endl;
1570 }
1571 fRecTracksPtr->Compress(); // for simple loop without "Next" since no hole
1572 // Loop over reconstructed tracks
1573 for (trackIndex = 0; trackIndex < fNRecTracks; trackIndex++) {
83dbc640 1574 if (fTrackMethod != 1) continue; //AZ - skip the rest for now
04b5ea16 1575 if (fPrintLevel >= 1)
1576 cout << " track number: " << trackIndex << endl;
1577 // function for each track for modularity ????
1578 track = (AliMUONTrack*) ((*fRecTracksPtr)[trackIndex]);
1579 nTrackHits = track->GetNTrackHits();
1580 if (fPrintLevel >= 1)
1581 cout << " number of track hits: " << nTrackHits << endl;
1582 // track parameters at Vertex
1583 trackParam = track->GetTrackParamAtVertex();
1584 x = trackParam->GetNonBendingCoor();
1585 y = trackParam->GetBendingCoor();
1586 z = trackParam->GetZ();
1587 bendingSlope = trackParam->GetBendingSlope();
1588 nonBendingSlope = trackParam->GetNonBendingSlope();
1589 pYZ = 1/TMath::Abs(trackParam->GetInverseBendingMomentum());
1590 pZ = pYZ/TMath::Sqrt(1+bendingSlope*bendingSlope);
1591 pX = pZ * nonBendingSlope;
1592 pY = pZ * bendingSlope;
1593 c = TMath::Sign(1.0, trackParam->GetInverseBendingMomentum());
1594 if (fPrintLevel >= 1)
1595 printf(" track parameters at Vertex z= %f: X= %f Y= %f pX= %f pY= %f pZ= %f c= %f\n",
1596 z, x, y, pX, pY, pZ, c);
1597
1598 // track parameters at first hit
1599 trackParam1 = ((AliMUONTrackHit*)
1600 (track->GetTrackHitsPtr()->First()))->GetTrackParam();
1601 x = trackParam1->GetNonBendingCoor();
1602 y = trackParam1->GetBendingCoor();
1603 z = trackParam1->GetZ();
1604 bendingSlope = trackParam1->GetBendingSlope();
1605 nonBendingSlope = trackParam1->GetNonBendingSlope();
1606 pYZ = 1/TMath::Abs(trackParam1->GetInverseBendingMomentum());
1607 pZ = pYZ/TMath::Sqrt(1.0 + bendingSlope * bendingSlope);
1608 pX = pZ * nonBendingSlope;
1609 pY = pZ * bendingSlope;
1610 c = TMath::Sign(1.0, trackParam1->GetInverseBendingMomentum());
1611 if (fPrintLevel >= 1)
1612 printf(" track parameters at z= %f: X= %f Y= %f pX= %f pY= %f pZ= %f c= %f\n",
1613 z, x, y, pX, pY, pZ, c);
1614 }
1615 // informations about generated particles
5d12ce38 1616 np = gAlice->GetMCApp()->GetNtrack();
04b5ea16 1617 printf(" **** number of generated particles: %d \n", np);
1618
88cb7938 1619// for (Int_t iPart = 0; iPart < np; iPart++) {
1620// p = gAlice->Particle(iPart);
1621// printf(" particle %d: type= %d px= %f py= %f pz= %f pdg= %d\n",
1622// iPart, p->GetPdgCode(), p->Px(), p->Py(), p->Pz(), p->GetPdgCode());
1623// }
a9e2aefa 1624 return;
1625}
1626
276c44b7 1627
1628//__________________________________________________________________________
1629void AliMUONEventReconstructor::EventDumpTrigger(void)
1630{
1631 // Dump reconstructed trigger event
1632 // and the particle parameters
1633
52c9bc11 1634 AliMUONTriggerTrack *triggertrack ;
1635 Int_t nTriggerTracks = fMUONData->RecTriggerTracks()->GetEntriesFast();
276c44b7 1636
276c44b7 1637 if (fPrintLevel >= 1) {
52c9bc11 1638 cout << "****** enter EventDumpTrigger ******" << endl;
1639 cout << " Number of Reconstructed tracks :" << nTriggerTracks << endl;
276c44b7 1640 }
1641 // Loop over reconstructed tracks
52c9bc11 1642 for (Int_t trackIndex = 0; trackIndex < nTriggerTracks; trackIndex++) {
1643 triggertrack = (AliMUONTriggerTrack*)fMUONData->RecTriggerTracks()->At(trackIndex);
276c44b7 1644 printf(" trigger track number %i x11=%f y11=%f thetax=%f thetay=%f \n",
1645 trackIndex,
1646 triggertrack->GetX11(),triggertrack->GetY11(),
1647 triggertrack->GetThetax(),triggertrack->GetThetay());
1648 }
1649}
1650
1651//__________________________________________________________________________
c7ba256d 1652void AliMUONEventReconstructor::FillEvent()
1653{
1654// Create a new AliMUONRecoEvent, fill its track list, then add it as a
1655// leaf in the Event branch of TreeRecoEvent tree
1656 cout << "Enter FillEvent() ...\n";
1657
1658 if (!fRecoEvent) {
1659 fRecoEvent = new AliMUONRecoEvent();
1660 } else {
1661 fRecoEvent->Clear();
1662 }
1663 //save current directory
1664 TDirectory *current = gDirectory;
1665 if (!fTreeFile) fTreeFile = new TFile("tree_reco.root", "RECREATE");
1666 if (!fEventTree) fEventTree = new TTree("TreeRecoEvent", "MUON reconstructed events");
83dbc640 1667 //AZif (fRecoEvent->MakeDumpTracks(fRecTracksPtr)) {
1668 if (fRecoEvent->MakeDumpTracks(fMuons, fRecTracksPtr, this)) { //AZ
c7ba256d 1669 if (fPrintLevel > 1) fRecoEvent->EventInfo();
1670 TBranch *branch = fEventTree->GetBranch("Event");
d0f40f23 1671 if (!branch) branch = fEventTree->Branch("Event", "AliMUONRecoEvent", &fRecoEvent, 64000);
c7ba256d 1672 branch->SetAutoDelete();
1673 fTreeFile->cd();
1674 fEventTree->Fill();
1675 fTreeFile->Write();
1676 }
1677 // restore directory
1678 current->cd();
1679}
83dbc640 1680
1681//__________________________________________________________________________
1682void AliMUONEventReconstructor::MakeTrackCandidatesK(void)
1683{
1684 // To make initial tracks for Kalman filter from the list of segments
1685 Int_t istat, iseg;
1686 AliMUONSegment *segment;
1687 AliMUONTrackK *trackK;
1688
1689 if (fPrintLevel >= 1) cout << "enter MakeTrackCandidatesK" << endl;
1690 // Reset the TClonesArray of reconstructed tracks
1691 if (fRecTracksPtr) fRecTracksPtr->Delete();
1692 // Delete in order that the Track destructors are called,
1693 // hence the space for the TClonesArray of pointers to TrackHit's is freed
1694 fNRecTracks = 0;
1695
1696 AliMUONTrackK a(this, fHitsForRecPtr); // bad idea ???
1697 // Loop over stations(1...) 5 and 4
1698 for (istat=4; istat>=3; istat--) {
1699 // Loop over segments in the station
1700 for (iseg=0; iseg<fNSegments[istat]; iseg++) {
1701 // Transform segments to tracks and evaluate covariance matrix
1702 segment = (AliMUONSegment*) ((*fSegmentsPtr[istat])[iseg]);
1703 trackK = new ((*fRecTracksPtr)[fNRecTracks]) AliMUONTrackK(segment);
1704 fNRecTracks++;
1705 } // for (iseg=0;...)
1706 } // for (istat=4;...)
1707 return;
1708}
1709
1710//__________________________________________________________________________
1711void AliMUONEventReconstructor::FollowTracksK(void)
1712{
1713 // Follow tracks using Kalman filter
30178c30 1714 Bool_t ok;
83dbc640 1715 Int_t icand, ichamBeg, ichamEnd, chamBits;
1716 Double_t zDipole1, zDipole2;
1717 AliMUONTrackK *trackK;
1718 AliMUONHitForRec *hit;
1719 AliMUONRawCluster *clus;
1720 TClonesArray *rawclusters;
1721 AliMUON *pMUON;
1722 clus = 0; rawclusters = 0;
1723
1724 zDipole1 = GetSimpleBPosition() - GetSimpleBLength()/2;
1725 zDipole2 = zDipole1 + GetSimpleBLength();
1726
1727 // Print hits
1728 pMUON = (AliMUON*) gAlice->GetModule("MUON");
1729 for (Int_t i1=0; i1<fNHitsForRec; i1++) {
1730 hit = (AliMUONHitForRec*) ((*fHitsForRecPtr)[i1]);
1731 //if (hit->GetTHTrack() > 1 || hit->GetGeantSignal() == 0) continue;
1732 /*
1733 cout << " Hit #" << hit->GetChamberNumber() << " ";
1734 cout << hit->GetBendingCoor() << " ";
1735 cout << hit->GetNonBendingCoor() << " ";
1736 cout << hit->GetZ() << " ";
1737 cout << hit->GetGeantSignal() << " ";
1738 cout << hit->GetTHTrack() << endl;
1739 */
1740 /*
1741 printf(" Hit # %d %10.4f %10.4f %10.4f",
1742 hit->GetChamberNumber(), hit->GetBendingCoor(),
1743 hit->GetNonBendingCoor(), hit->GetZ());
1744 if (fRecGeantHits) {
1745 // from GEANT hits
1746 printf(" %3d %3d \n", hit->GetGeantSignal(), hit->GetTHTrack());
1747 } else {
1748 // from raw clusters
1749 rawclusters = pMUON->RawClustAddress(hit->GetChamberNumber());
1750 clus = (AliMUONRawCluster*) rawclusters->UncheckedAt(hit->
1751 GetHitNumber());
1752 printf("%3d", clus->fTracks[1]-1);
1753 if (clus->fTracks[2] != 0) printf("%3d \n", clus->fTracks[2]-1);
1754 else printf("\n");
1755 }
1756 */
1757 }
1758
1759 icand = -1;
1760 Int_t nSeeds = fNRecTracks; // starting number of seeds
1761 // Loop over track candidates
1762 while (icand < fNRecTracks-1) {
1763 icand ++;
1764 trackK = (AliMUONTrackK*) ((*fRecTracksPtr)[icand]);
1765
1766 // Discard candidate which will produce the double track
1767 if (icand > 0) {
30178c30 1768 ok = CheckCandidateK(icand,nSeeds);
1769 if (!ok) {
83dbc640 1770 //trackK->SetRecover(-1); // mark candidate to be removed
1771 //continue;
1772 }
1773 }
1774
30178c30 1775 ok = kTRUE;
83dbc640 1776 if (trackK->GetRecover() == 0) hit = (AliMUONHitForRec*)
1777 trackK->GetHitOnTrack()->Last(); // last hit
1778 else hit = (AliMUONHitForRec*) (*trackK->GetHitOnTrack())[1]; // 2'nd hit
1779 ichamBeg = hit->GetChamberNumber();
1780 ichamEnd = 0;
1781 // Check propagation direction
1782 if (trackK->GetTrackDir() > 0) {
1783 ichamEnd = 9; // forward propagation
30178c30 1784 ok = trackK->KalmanFilter(ichamBeg,ichamEnd,kFALSE,zDipole1,zDipole2);
1785 if (ok) {
83dbc640 1786 ichamBeg = ichamEnd;
1787 ichamEnd = 6; // backward propagation
1788 // Change weight matrix and zero fChi2 for backpropagation
1789 trackK->StartBack();
30178c30 1790 ok = trackK->KalmanFilter(ichamBeg,ichamEnd,kTRUE,zDipole1,zDipole2);
83dbc640 1791 ichamBeg = ichamEnd;
1792 ichamEnd = 0;
1793 }
1794 } else {
1795 if (trackK->GetBPFlag()) {
1796 // backpropagation
1797 ichamEnd = 6; // backward propagation
1798 // Change weight matrix and zero fChi2 for backpropagation
1799 trackK->StartBack();
30178c30 1800 ok = trackK->KalmanFilter(ichamBeg,ichamEnd,kTRUE,zDipole1,zDipole2);
83dbc640 1801 ichamBeg = ichamEnd;
1802 ichamEnd = 0;
1803 }
1804 }
1805
30178c30 1806 if (ok) {
83dbc640 1807 trackK->SetTrackDir(-1);
1808 trackK->SetBPFlag(kFALSE);
30178c30 1809 ok = trackK->KalmanFilter(ichamBeg,ichamEnd,kFALSE,zDipole1,zDipole2);
83dbc640 1810 }
30178c30 1811 if (ok) trackK->SetTrackQuality(0); // compute "track quality"
83dbc640 1812 else trackK->SetRecover(-1); // mark candidate to be removed
1813
1814 // Majority 3 of 4 in first 2 stations
1815 chamBits = 0;
1816 for (Int_t i=0; i<trackK->GetNTrackHits(); i++) {
1817 hit = (AliMUONHitForRec*) (*trackK->GetHitOnTrack())[i];
1818 chamBits |= BIT(hit->GetChamberNumber()-1);
1819 }
1820 //if (!((chamBits&3)==3 || (chamBits>>2&3)==3)) trackK->SetRecover(-1);
1821 //mark candidate to be removed
1822 } // while
1823
1824 for (Int_t i=0; i<fNRecTracks; i++) {
1825 trackK = (AliMUONTrackK*) ((*fRecTracksPtr)[i]);
1826 if (trackK->GetRecover() < 0) fRecTracksPtr->RemoveAt(i);
1827 }
1828
1829 // Compress TClonesArray
1830 fRecTracksPtr->Compress();
1831 fNRecTracks = fRecTracksPtr->GetEntriesFast();
1832 return;
1833}
1834
1835//__________________________________________________________________________
30178c30 1836Bool_t AliMUONEventReconstructor::CheckCandidateK(Int_t icand, Int_t nSeeds) const
83dbc640 1837{
1838 // Discards track candidate if it will produce the double track (having
1839 // the same seed segment hits as hits of a good track found before)
1840 AliMUONTrackK *track1, *track2;
1841 AliMUONHitForRec *hit1, *hit2, *hit;
1842
1843 track1 = (AliMUONTrackK*) ((*fRecTracksPtr)[icand]);
1844 hit1 = (AliMUONHitForRec*) (*track1->GetHitOnTrack())[0]; // 1'st hit
1845 hit2 = (AliMUONHitForRec*) (*track1->GetHitOnTrack())[1]; // 2'nd hit
1846
1847 for (Int_t i=0; i<icand; i++) {
1848 track2 = (AliMUONTrackK*) ((*fRecTracksPtr)[i]);
1849 //if (track2->GetRecover() < 0) continue;
1850 if (track2->GetRecover() < 0 && icand >= nSeeds) continue;
1851
1852 if (track1->GetStartSegment() == track2->GetStartSegment()) {
1853 return kFALSE;
1854 } else {
1855 Int_t nSame = 0;
1856 for (Int_t j=0; j<track2->GetNTrackHits(); j++) {
1857 hit = (AliMUONHitForRec*) (*track2->GetHitOnTrack())[j];
1858 if (hit == hit1 || hit == hit2) {
1859 nSame++;
1860 if (nSame == 2) return kFALSE;
1861 }
1862 } // for (Int_t j=0;
1863 }
1864 } // for (Int_t i=0;
1865 return kTRUE;
1866}
1867
1868//__________________________________________________________________________
1869void AliMUONEventReconstructor::RemoveDoubleTracksK(void)
1870{
1871 // Removes double tracks (sharing more than half of their hits). Keeps
1872 // the track with higher quality
1873 AliMUONTrackK *track1, *track2, *trackToKill;
1874
1875 // Sort tracks according to their quality
1876 fRecTracksPtr->Sort();
1877
1878 // Loop over first track of the pair
1879 track1 = (AliMUONTrackK*) fRecTracksPtr->First();
1880 while (track1) {
1881 // Loop over second track of the pair
1882 track2 = (AliMUONTrackK*) fRecTracksPtr->After(track1);
1883 while (track2) {
1884 // Check whether or not to keep track2
1885 if (!track2->KeepTrack(track1)) {
1886 cout << " Killed track: " << 1/(*track2->GetTrackParameters())(4,0) <<
1887 " " << track2->GetTrackQuality() << endl;
1888 trackToKill = track2;
1889 track2 = (AliMUONTrackK*) fRecTracksPtr->After(track2);
1890 trackToKill->Kill();
1891 fRecTracksPtr->Compress();
1892 } else track2 = (AliMUONTrackK*) fRecTracksPtr->After(track2);
1893 } // track2
1894 track1 = (AliMUONTrackK*) fRecTracksPtr->After(track1);
1895 } // track1
1896
1897 fNRecTracks = fRecTracksPtr->GetEntriesFast();
1898 cout << " Number of Kalman tracks: " << fNRecTracks << endl;
1899}
1900
1901//__________________________________________________________________________
1902void AliMUONEventReconstructor::GoToVertex(void)
1903{
1904 // Propagates track to the vertex thru absorber
1905 // (using Branson correction for now)
1906
1907 Double_t zVertex;
1908 zVertex = 0;
1909 for (Int_t i=0; i<fNRecTracks; i++) {
1910 //((AliMUONTrackK*)(*fRecTracksPtr)[i])->Branson();
1911 //((AliMUONTrackK*)(*fRecTracksPtr)[i])->GoToZ(zVertex); // w/out absorber
1912 ((AliMUONTrackK*)(*fRecTracksPtr)[i])->SetTrackQuality(1); // compute Chi2
1913 ((AliMUONTrackK*)(*fRecTracksPtr)[i])->GoToVertex(); // with absorber
1914 }
1915}