Check we get everything from OCDB even before starting, and correctly deleting calibr...
[u/mrichter/AliRoot.git] / MUON / AliMUONReconstructor.cxx
CommitLineData
cac2eb58 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 **************************************************************************/
cac2eb58 15/* $Id$ */
16
37827b29 17//-----------------------------
18// Class AliMUONReconstructor
19//-----------------------------
9265505b 20// Class for the
21// MUON track reconstruction
30178c30 22
cf464691 23#include "AliMUONReconstructor.h"
b2d7df0b 24
96fdfe9a 25#include "AliMUONConstants.h"
b2d7df0b 26#include "AliMUONCalibrationData.h"
346fb008 27#include "AliMUONClusterFinderAZ.h"
b2d7df0b 28#include "AliMUONClusterReconstructor.h"
29#include "AliMUONData.h"
30#include "AliMUONDigitCalibrator.h"
cc87ebcd 31#include "AliMUONEventRecoCombi.h"
2cf44ef3 32#include "AliMUONDigitMaker.h"
cac2eb58 33#include "AliMUONTrack.h"
34#include "AliMUONTrackParam.h"
37827b29 35#include "AliMUONTrackExtrap.h"
196471e9 36#include "AliMUONTracker.h"
2457f726 37#include "AliMUONVTrackReconstructor.h"
b2d7df0b 38#include "AliMUONTrackReconstructor.h"
2457f726 39#include "AliMUONTrackReconstructorK.h"
cac2eb58 40#include "AliMUONTriggerTrack.h"
e1a10d41 41#include "AliMUONTriggerCircuit.h"
96fdfe9a 42#include "AliMUONTriggerCrateStore.h"
6a518391 43#include "AliMUONSegFactory.h"
44#include "AliMUONSegmentation.h"
f9247068 45#include "AliMUONPreClusterFinder.h"
46#include "AliMUONClusterFinderCOG.h"
47#include "AliMUONClusterFinderSimpleFit.h"
48#include "AliMUONClusterFinderMLEM.h"
3b00d01e 49
50#include "AliESD.h"
51#include "AliESDMuonTrack.h"
52#include "AliLog.h"
cf464691 53#include "AliRawReader.h"
b2d7df0b 54#include "AliRunLoader.h"
3b00d01e 55#include "AliCDBManager.h"
56
b2d7df0b 57#include "TTask.h"
94f6fba9 58#include "TStopwatch.h"
29f1b13a 59
9265505b 60/// \cond CLASSIMP
cac2eb58 61ClassImp(AliMUONReconstructor)
9265505b 62/// \endcond
b2d7df0b 63
cac2eb58 64//_____________________________________________________________________________
65AliMUONReconstructor::AliMUONReconstructor()
aa6ecf89 66 : AliReconstructor(),
aa6ecf89 67 fDigitMaker(new AliMUONDigitMaker()),
96fdfe9a 68 fCalibrationData(0x0),
69 fCrateManager(new AliMUONTriggerCrateStore()),
e1a10d41 70 fTriggerCircuit(new TClonesArray("AliMUONTriggerCircuit", 234)),
6a518391 71 fTransformer(new AliMUONGeometryTransformer(kTRUE)),
196471e9 72 fSegmentation(0x0),
73 fMUONData(new AliMUONData(0x0,"MUON","MUON"))
8789635b 74{
d19b6003 75/// Default constructor
76
94f6fba9 77 AliDebug(1,"");
96fdfe9a 78 // Crate manager
79 fCrateManager->ReadFromFile();
80
81 // set to digit maker
82 fDigitMaker->SetCrateManager(fCrateManager);
83
9c4b1ee7 84 // transformater
85 fTransformer->ReadGeometryData("volpath.dat", "geometry.root");
6a518391 86
87 // create segmentation and pass it to EventRecoCombi
88 AliMUONSegFactory factory(fTransformer);
89 fSegmentation = factory.CreateSegmentation();
90 AliMUONEventRecoCombi::Instance(fSegmentation);
9c4b1ee7 91
96fdfe9a 92 // trigger circuit
93 for (Int_t i = 0; i < AliMUONConstants::NTriggerCircuit(); i++) {
e1a10d41 94 AliMUONTriggerCircuit* c = new AliMUONTriggerCircuit();
9c4b1ee7 95 c->SetTransformer(fTransformer);
96fdfe9a 96 c->Init(i,*fCrateManager);
97 TClonesArray& circuit = *fTriggerCircuit;
e1a10d41 98 new(circuit[circuit.GetEntriesFast()])AliMUONTriggerCircuit(*c);
96fdfe9a 99 delete c;
9c4b1ee7 100 }
101
102
8789635b 103}
94f6fba9 104
8789635b 105//_____________________________________________________________________________
106AliMUONReconstructor::~AliMUONReconstructor()
cac2eb58 107{
d19b6003 108/// Destructor
109
94f6fba9 110 AliDebug(1,"");
b2d7df0b 111 delete fCalibrationData;
aa6ecf89 112 delete fDigitMaker;
96fdfe9a 113 delete fCrateManager;
114 delete fTriggerCircuit;
9c4b1ee7 115 delete fTransformer;
6a518391 116 delete fSegmentation;
196471e9 117 delete fMUONData;
cac2eb58 118}
b2d7df0b 119
120//_____________________________________________________________________________
121TTask*
196471e9 122AliMUONReconstructor::GetCalibrationTask() const
b2d7df0b 123{
d19b6003 124/// Create the calibration task(s).
b2d7df0b 125
3b00d01e 126 //const AliRun* run = fRunLoader->GetAliRun();
127 //Int_t runNumber = run->GetRunNumber();
128 Int_t runNumber = AliCDBManager::Instance()->GetRun();
9f9729c3 129 AliInfo("Calibration will occur.");
3b00d01e 130
9f9729c3 131 fCalibrationData = new AliMUONCalibrationData(runNumber);
132 if ( !fCalibrationData->IsValid() )
b2d7df0b 133 {
134 AliError("Could not retrieve calibrations !");
135 delete fCalibrationData;
136 fCalibrationData = 0x0;
137 return 0x0;
138 }
b476b122 139 // Check that we get all the calibrations we'll need
140 if ( !fCalibrationData->Pedestals() ||
141 !fCalibrationData->Gains() ||
142 !fCalibrationData->HV() )
143 {
144 AliFatal("Could not access all required calibration data");
145 }
9f9729c3 146 TTask* calibration = new TTask("MUONCalibrator","MUON Digit calibrator");
ee103e97 147
148 TString opt(GetOption());
149 opt.ToUpper();
150 Bool_t statusMap(kTRUE);
151
152 if ( strstr(opt,"NOSTATUSMAP") )
153 {
154 AliWarning("Disconnecting status map : SHOULD BE USED FOR DEBUG ONLY. NOT FOR PRODUCTION !!!");
155 statusMap = kFALSE;
156 }
196471e9 157 calibration->Add(new AliMUONDigitCalibrator(fMUONData,fCalibrationData,statusMap));
9f9729c3 158 return calibration;
b2d7df0b 159}
160
f9247068 161//_____________________________________________________________________________
162AliMUONClusterReconstructor*
196471e9 163AliMUONReconstructor::CreateClusterReconstructor() const
f9247068 164{
06ca6d7b 165/// Create cluster reconstructor
166
f9247068 167 AliMUONVClusterFinder* clusterFinder(0x0);
168
169 TString opt(GetOption());
170 opt.ToUpper();
171
172 if ( strstr(opt,"PRECLUSTER") )
173 {
174 clusterFinder = new AliMUONPreClusterFinder;
175 }
176 else if ( strstr(opt,"COG") )
177 {
178 clusterFinder = new AliMUONClusterFinderCOG;
179 }
180 else if ( strstr(opt,"SIMPLEFIT") )
181 {
182 clusterFinder = new AliMUONClusterFinderSimpleFit;
183 }
184 else if ( strstr(opt,"MLEM:DRAW") )
185 {
186 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE);
187 }
188 else if ( strstr(opt,"MLEM") )
189 {
190 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE);
191 }
192
193 if ( clusterFinder)
194 {
195 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
196 }
197
198 AliMUONClusterReconstructor* clusterReco =
196471e9 199 new AliMUONClusterReconstructor(fMUONData,clusterFinder,fTransformer);
f9247068 200 return clusterReco;
201}
202
cac2eb58 203//_____________________________________________________________________________
204void AliMUONReconstructor::Reconstruct(AliRunLoader* runLoader) const
205{
d19b6003 206/// Reconstruct
207/// \todo add more
208
cac2eb58 209 AliLoader* loader = runLoader->GetLoader("MUONLoader");
d2f8e464 210 Int_t nEvents = runLoader->GetNumberOfEvents();
211 Int_t evtNumber = runLoader->GetEventNumber();
cac2eb58 212
196471e9 213 fMUONData->SetLoader(loader);
3bc8b580 214
215// passing loader as argument.
2457f726 216 AliMUONVTrackReconstructor* recoEvent;
196471e9 217 if (strstr(GetOption(),"Original")) recoEvent = new AliMUONTrackReconstructor(fMUONData);
218 else if (strstr(GetOption(),"Combi")) recoEvent = new AliMUONTrackReconstructorK(fMUONData,"Combi");
219 else recoEvent = new AliMUONTrackReconstructorK(fMUONData,"Kalman");
2457f726 220
96fdfe9a 221 recoEvent->SetTriggerCircuit(fTriggerCircuit);
3bc8b580 222
196471e9 223 AliMUONClusterReconstructor* recoCluster = CreateClusterReconstructor();
3bc8b580 224
7e4a628d 225 AliMUONClusterFinderVS *recModel = recoCluster->GetRecoModel();
3bc8b580 226
8e0ae46c 227 if (!strstr(GetOption(),"VS")) {
1af223d7 228 recModel = (AliMUONClusterFinderVS*) new AliMUONClusterFinderAZ();
9ffe3ef4 229 recoCluster->SetRecoModel(recModel);
9ffe3ef4 230 }
7e4a628d 231 recModel->SetGhostChi2Cut(10);
d2f8e464 232 recModel->SetEventNumber(evtNumber);
cac2eb58 233
234 loader->LoadDigits("READ");
235 loader->LoadRecPoints("RECREATE");
236 loader->LoadTracks("RECREATE");
cc87ebcd 237
196471e9 238 TTask* calibration = GetCalibrationTask();
b2d7df0b 239
2457f726 240 Int_t chBeg = (strstr(GetOption(),"Combi") ? 6 : 0);
9c4b1ee7 241
cc87ebcd 242 // Loop over events
cac2eb58 243 for(Int_t ievent = 0; ievent < nEvents; ievent++) {
94f6fba9 244
245 AliDebug(1,Form("Event %d",ievent));
246
cac2eb58 247 runLoader->GetEvent(ievent);
248
8210cb40 249 //----------------------- digit2cluster & Trigger2Trigger -------------------
cac2eb58 250 if (!loader->TreeR()) loader->MakeRecPointsContainer();
cc87ebcd 251
cac2eb58 252 // tracking branch
2457f726 253 if (!strstr(GetOption(),"Combi")) {
196471e9 254 fMUONData->MakeBranch("RC");
255 fMUONData->SetTreeAddress("D,RC");
cc87ebcd 256 } else {
196471e9 257 fMUONData->SetTreeAddress("D");
258 fMUONData->SetTreeAddress("RCC");
cc87ebcd 259 }
addbf88a 260 // Important for avoiding a memory leak when reading digits ( to be investigated more in detail)
cc87ebcd 261 // In any case the reading of GLT is needed for the Trigger2Tigger method below
196471e9 262 fMUONData->SetTreeAddress("GLT");
cc87ebcd 263
196471e9 264 fMUONData->GetDigits();
b2d7df0b 265
266 if ( calibration )
267 {
268 calibration->ExecuteTask();
269 }
270
cc87ebcd 271 recoCluster->Digits2Clusters(chBeg);
b2d7df0b 272
2457f726 273 if (strstr(GetOption(),"Combi")) {
cc87ebcd 274 // Combined cluster / track finder
196471e9 275 AliMUONEventRecoCombi::Instance()->FillEvent(fMUONData, (AliMUONClusterFinderAZ*)recModel);
cc87ebcd 276 ((AliMUONClusterFinderAZ*) recModel)->SetReco(2);
277 }
196471e9 278 else fMUONData->Fill("RC");
cac2eb58 279
280 // trigger branch
196471e9 281 fMUONData->MakeBranch("TC");
282 fMUONData->SetTreeAddress("TC");
cc87ebcd 283 recoCluster->Trigger2Trigger();
196471e9 284 fMUONData->Fill("TC");
cac2eb58 285
cc87ebcd 286 //AZ loader->WriteRecPoints("OVERWRITE");
cac2eb58 287
288 //---------------------------- Track & TriggerTrack ---------------------
289 if (!loader->TreeT()) loader->MakeTracksContainer();
290
291 // trigger branch
196471e9 292 fMUONData->MakeBranch("RL"); //trigger track
293 fMUONData->SetTreeAddress("RL");
cac2eb58 294 recoEvent->EventReconstructTrigger();
196471e9 295 fMUONData->Fill("RL");
cac2eb58 296
297 // tracking branch
196471e9 298 fMUONData->MakeBranch("RT"); //track
299 fMUONData->SetTreeAddress("RT");
cac2eb58 300 recoEvent->EventReconstruct();
196471e9 301 fMUONData->Fill("RT");
cac2eb58 302
cc87ebcd 303 loader->WriteTracks("OVERWRITE");
304
2457f726 305 if (strstr(GetOption(),"Combi")) {
cc87ebcd 306 // Combined cluster / track
307 ((AliMUONClusterFinderAZ*) recModel)->SetReco(1);
196471e9 308 fMUONData->MakeBranch("RC");
309 fMUONData->SetTreeAddress("RC");
310 AliMUONEventRecoCombi::Instance()->FillRecP(fMUONData, (AliMUONTrackReconstructorK*)recoEvent);
311 fMUONData->Fill("RC");
cc87ebcd 312 }
313 loader->WriteRecPoints("OVERWRITE");
314
cac2eb58 315 //--------------------------- Resetting branches -----------------------
196471e9 316 fMUONData->ResetDigits();
317 fMUONData->ResetRawClusters();
318 fMUONData->ResetTrigger();
319 fMUONData->ResetRecTracks();
320 fMUONData->ResetRecTriggerTracks();
29f1b13a 321
cac2eb58 322 }
323 loader->UnloadDigits();
324 loader->UnloadRecPoints();
325 loader->UnloadTracks();
326
327 delete recoCluster;
328 delete recoEvent;
b2d7df0b 329 delete calibration;
cac2eb58 330}
cf464691 331
332//_____________________________________________________________________________
f9247068 333void AliMUONReconstructor::Reconstruct(AliRunLoader* runLoader,
334 AliRawReader* rawReader) const
cf464691 335{
d19b6003 336/// Recontruct
337/// \todo add more
338
94f6fba9 339 // AliLoader
cf464691 340 AliLoader* loader = runLoader->GetLoader("MUONLoader");
d2f8e464 341 Int_t evtNumber = runLoader->GetEventNumber();
342
196471e9 343 fMUONData->SetLoader(loader);
cf464691 344
94f6fba9 345 // passing loader as argument.
196471e9 346 fDigitMaker->SetMUONData(fMUONData);
1197ff51 347
3b00d01e 348 // disable trigger rawdata reading
349 if (strstr(GetOption(),"TriggerDisable"))
350 fDigitMaker->DisableTrigger();
351
196471e9 352 AliMUONClusterReconstructor* recoCluster = CreateClusterReconstructor();
2457f726 353
f9247068 354 AliMUONClusterFinderVS *recModel = recoCluster->GetRecoModel();
355
94f6fba9 356 if (!strstr(GetOption(),"VS"))
357 {
30eabfb8 358 recModel = (AliMUONClusterFinderVS*) new AliMUONClusterFinderAZ();
f9247068 359 recoCluster->SetRecoModel(recModel);
30eabfb8 360 }
7e4a628d 361 recModel->SetGhostChi2Cut(10);
d2f8e464 362 recModel->SetEventNumber(evtNumber);
8cde4af5 363
196471e9 364 TTask* calibration = GetCalibrationTask();
b2d7df0b 365
cf464691 366 loader->LoadRecPoints("RECREATE");
64b056bc 367
196471e9 368 // Digits are not stored on disk and created on flight from rawdata.
64b056bc 369 // In order to write digits on disk the following line should be uncommented
370 // loader->LoadDigits("RECREATE");
371
cc87ebcd 372 // Loop over events
8210cb40 373 Int_t iEvent = 0;
94f6fba9 374
375 TStopwatch totalTimer;
376 TStopwatch rawTimer;
377 TStopwatch calibTimer;
378 TStopwatch clusterTimer;
94f6fba9 379
380 rawTimer.Start(kTRUE); rawTimer.Stop();
381 calibTimer.Start(kTRUE); calibTimer.Stop();
382 clusterTimer.Start(kTRUE); clusterTimer.Stop();
94f6fba9 383
384 totalTimer.Start(kTRUE);
385
386 while (rawReader->NextEvent())
387 {
388 AliDebug(1,Form("Event %d",iEvent));
389
cf464691 390 runLoader->GetEvent(iEvent++);
8cde4af5 391
ce6a659c 392 //----------------------- raw2digits & raw2trigger-------------------
196471e9 393 // if (!loader->TreeD())
394 // {
395 // AliDebug(1,Form("Making Digit Container for event %d",iEvent));
396 // loader->MakeDigitsContainer();
397 // }
398 // Digits are not stored on disk and created on flight from rawdata.
399 // In order to write digits on disk the following lines should be uncommented
400 // fMUONData->MakeBranch("D,GLT");
401 // fMUONData->SetTreeAddress("D,GLT");
402 fMUONData->SetDataContainer("D, GLT");
94f6fba9 403 rawTimer.Start(kFALSE);
aa6ecf89 404 fDigitMaker->Raw2Digits(rawReader);
94f6fba9 405 rawTimer.Stop();
406
b2d7df0b 407 if ( calibration )
408 {
94f6fba9 409 calibTimer.Start(kFALSE);
b2d7df0b 410 calibration->ExecuteTask();
94f6fba9 411 calibTimer.Stop();
b2d7df0b 412 }
64b056bc 413 // Digits are not stored on disk and created on flight from rawdata.
414 // In order to write digits on disk the following lines should be uncommented
196471e9 415 // fMUONData->Fill("D,GLT");
64b056bc 416 // loader->WriteDigits("OVERWRITE");
8210cb40 417 //----------------------- digit2cluster & Trigger2Trigger -------------------
94f6fba9 418 clusterTimer.Start(kFALSE);
419
cf464691 420 if (!loader->TreeR()) loader->MakeRecPointsContainer();
8cde4af5 421
cf464691 422 // tracking branch
196471e9 423 fMUONData->MakeBranch("RC");
424 fMUONData->SetTreeAddress("RC");
f9247068 425 recoCluster->Digits2Clusters();
196471e9 426 fMUONData->Fill("RC");
cf464691 427
428 // trigger branch
196471e9 429 fMUONData->MakeBranch("TC");
430 fMUONData->SetTreeAddress("TC");
431 fMUONData->Fill("TC");
94f6fba9 432
cf464691 433 loader->WriteRecPoints("OVERWRITE");
434
94f6fba9 435 clusterTimer.Stop();
8cde4af5 436
94f6fba9 437
cf464691 438 //--------------------------- Resetting branches -----------------------
196471e9 439 fMUONData->ResetDigits();
440 fMUONData->ResetRawClusters();
441 fMUONData->ResetTrigger();
cf464691 442 }
94f6fba9 443
444 totalTimer.Stop();
445
cf464691 446 loader->UnloadRecPoints();
ce6a659c 447 loader->UnloadDigits();
2457f726 448
f9247068 449 delete recoCluster;
b476b122 450 delete calibration;
f9247068 451
94f6fba9 452 AliInfo(Form("Execution time for converting RAW data to digits in MUON : R:%.2fs C:%.2fs",
453 rawTimer.RealTime(),rawTimer.CpuTime()));
454 AliInfo(Form("Execution time for calibrating MUON : R:%.2fs C:%.2fs",
455 calibTimer.RealTime(),calibTimer.CpuTime()));
456 AliInfo(Form("Execution time for clusterizing MUON : R:%.2fs C:%.2fs",
457 clusterTimer.RealTime(),clusterTimer.CpuTime()));
94f6fba9 458 AliInfo(Form("Total Execution time for Reconstruct(from raw) MUON : R:%.2fs C:%.2fs",
459 totalTimer.RealTime(),totalTimer.CpuTime()));
cf464691 460}
461
cac2eb58 462//_____________________________________________________________________________
463void AliMUONReconstructor::FillESD(AliRunLoader* runLoader, AliESD* esd) const
464{
d19b6003 465/// Fill ESD
466/// \todo add more
467
cac2eb58 468 TClonesArray* recTracksArray = 0;
469 TClonesArray* recTrigTracksArray = 0;
cc87ebcd 470
cac2eb58 471 AliLoader* loader = runLoader->GetLoader("MUONLoader");
472 loader->LoadTracks("READ");
196471e9 473 fMUONData->SetLoader(loader);
cac2eb58 474
cc87ebcd 475 // declaration
a2da7817 476 Int_t iEvent;// nPart;
477 Int_t nTrackHits;// nPrimary;
cac2eb58 478 Double_t fitFmin;
cac2eb58 479
480 Double_t bendingSlope, nonBendingSlope, inverseBendingMomentum;
481 Double_t xRec, yRec, zRec, chi2MatchTrigger;
482 Bool_t matchTrigger;
483
b002ac70 484 // setting pointer for tracks, triggertracks & trackparam at vertex
cac2eb58 485 AliMUONTrack* recTrack = 0;
8cde4af5 486 AliMUONTrackParam trackParam;
cac2eb58 487 AliMUONTriggerTrack* recTriggerTrack = 0;
2cf44ef3 488
cc87ebcd 489 iEvent = runLoader->GetEventNumber();
cac2eb58 490 runLoader->GetEvent(iEvent);
491
94f6fba9 492 // Get vertex
493 Double_t vertex[3] = {0};
494 const AliESDVertex *esdVert = esd->GetVertex();
43939bd8 495 if (esdVert->GetNContributors()) {
496 esdVert->GetXYZ(vertex);
196471e9 497 AliDebug(1, "find vertex\n");
43939bd8 498 }
cac2eb58 499 // setting ESD MUON class
30178c30 500 AliESDMuonTrack* theESDTrack = new AliESDMuonTrack() ;
cac2eb58 501
502 //-------------------- trigger tracks-------------
503 Long_t trigPat = 0;
196471e9 504 fMUONData->SetTreeAddress("RL");
505 fMUONData->GetRecTriggerTracks();
506 recTrigTracksArray = fMUONData->RecTriggerTracks();
cac2eb58 507
508 // ready global trigger pattern from first track
cc87ebcd 509 if (recTrigTracksArray)
cac2eb58 510 recTriggerTrack = (AliMUONTriggerTrack*) recTrigTracksArray->First();
511 if (recTriggerTrack) trigPat = recTriggerTrack->GetGTPattern();
512
513 //printf(">>> Event %d Number of Recconstructed tracks %d \n",iEvent, nrectracks);
cc87ebcd 514
cac2eb58 515 // -------------------- tracks-------------
196471e9 516 fMUONData->SetTreeAddress("RT");
517 fMUONData->GetRecTracks();
518 recTracksArray = fMUONData->RecTracks();
cc87ebcd 519
cac2eb58 520 Int_t nRecTracks = 0;
521 if (recTracksArray)
522 nRecTracks = (Int_t) recTracksArray->GetEntriesFast(); //
cc87ebcd 523
cac2eb58 524 // loop over tracks
525 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
526
527 // reading info from tracks
528 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
529
8cde4af5 530 trackParam = *((AliMUONTrackParam*) (recTrack->GetTrackParamAtHit())->First());
211c52eb 531
8cde4af5 532 // extrapolate to the vertex if required
533 // if the vertex is not available, extrapolate to (0,0,0)
534 if (!strstr(GetOption(),"NoExtrapToVtx")) {
535 if (esdVert->GetNContributors())
536 AliMUONTrackExtrap::ExtrapToVertex(&trackParam, vertex[0],vertex[1],vertex[2]);
537 else
538 AliMUONTrackExtrap::ExtrapToVertex(&trackParam, 0.,0.,0.);
539 }
540
541 bendingSlope = trackParam.GetBendingSlope();
542 nonBendingSlope = trackParam.GetNonBendingSlope();
543 inverseBendingMomentum = trackParam.GetInverseBendingMomentum();
544 xRec = trackParam.GetNonBendingCoor();
545 yRec = trackParam.GetBendingCoor();
546 zRec = trackParam.GetZ();
cac2eb58 547
548 nTrackHits = recTrack->GetNTrackHits();
549 fitFmin = recTrack->GetFitFMin();
550 matchTrigger = recTrack->GetMatchTrigger();
551 chi2MatchTrigger = recTrack->GetChi2MatchTrigger();
552
553 // setting data member of ESD MUON
30178c30 554 theESDTrack->SetInverseBendingMomentum(inverseBendingMomentum);
555 theESDTrack->SetThetaX(TMath::ATan(nonBendingSlope));
556 theESDTrack->SetThetaY(TMath::ATan(bendingSlope));
889a0215 557 theESDTrack->SetZ(zRec);
558 theESDTrack->SetBendingCoor(yRec); // calculate vertex at ESD or Tracking level ?
559 theESDTrack->SetNonBendingCoor(xRec);
30178c30 560 theESDTrack->SetChi2(fitFmin);
561 theESDTrack->SetNHit(nTrackHits);
562 theESDTrack->SetMatchTrigger(matchTrigger);
563 theESDTrack->SetChi2MatchTrigger(chi2MatchTrigger);
cac2eb58 564
cc87ebcd 565 // storing ESD MUON Track into ESD Event
566 if (nRecTracks != 0)
30178c30 567 esd->AddMuonTrack(theESDTrack);
cac2eb58 568 } // end loop tracks
569
cac2eb58 570 // reset muondata
196471e9 571 fMUONData->ResetRecTracks();
572 fMUONData->ResetRecTriggerTracks();
cac2eb58 573
cc87ebcd 574 //} // end loop on event
575 loader->UnloadTracks();
2cf44ef3 576
30178c30 577 delete theESDTrack;
196471e9 578}
579
580//_____________________________________________________________________________
a2da7817 581void AliMUONReconstructor::FillESD(AliRunLoader* runLoader, AliRawReader* /*rawReader*/, AliESD* esd) const
582{
d19b6003 583/// Fill ESD
584/// \todo add more
585
a2da7817 586 // don't need rawReader ???
587 FillESD(runLoader, esd);
cac2eb58 588}
196471e9 589
590//_____________________________________________________________________________
591AliTracker* AliMUONReconstructor::CreateTracker(AliRunLoader* runLoader) const
592{
593 /// create tracker for MUON
594 /// go into the tracking framework finally (Ch.F)
595
596 AliLoader* loader = runLoader->GetLoader("MUONLoader");
597
598 fMUONData->SetLoader(loader);
599
600 AliMUONTracker* tracker = new AliMUONTracker();
601 tracker->SetMUONData(fMUONData);
602 tracker->SetTriggerCircuit(fTriggerCircuit);
603 tracker->SetOption(GetOption());
604
605 return tracker;
606
607}