Modifications needed by the HBT analysis (P.Skowronski)
[u/mrichter/AliRoot.git] / MUON / MUONTracker.C
CommitLineData
e50989e9 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
a501728c 18// Macro MUONTracker.C (TO BE COMPILED)
19// for testing the C++ reconstruction code
20// Output is using aliroot standard output MUON.Tracks.root
21// The output is a TClonesArray of AliMUONTracks.
e50989e9 22// Gines MARTINEZ, Subatech, sep 2003
23
d8d3b5b8 24#if !defined(__CINT__) || defined(__MAKECINT__)
a501728c 25#include <TClonesArray.h>
26
27#include "AliRun.h"
28#include "AliMUON.h"
29#include "AliMUONData.h"
30#include "AliMUONEventReconstructor.h"
31#include "AliMUONTrack.h"
32#include "AliMUONTrackHit.h"
33#include "AliMUONTrackParam.h"
d8d3b5b8 34#endif
a501728c 35
ba9436c6 36void MUONTracker (Text_t *FileName = "galice.root", Int_t FirstEvent = 0, Int_t LastEvent = 9999)
a501728c 37{
38 //
39 cout << "MUONTracker" << endl;
40 cout << "FirstEvent " << FirstEvent << endl;
41 cout << "LastEvent " << LastEvent << endl;
42 cout << "FileName ``" << FileName << "''" << endl;
43
44 // Creating Run Loader and openning file containing Hits, Digits and RecPoints
45 AliRunLoader * RunLoader = AliRunLoader::Open(FileName,"Event","UPDATE");
46 if (RunLoader ==0x0) {
47 printf(">>> Error : Error Opening %s file \n",FileName);
48 return;
49 }
50 // Loading AliRun master
51 RunLoader->LoadgAlice();
52 gAlice = RunLoader->GetAliRun();
53 RunLoader->LoadKinematics("READ");
54
55 // Loading MUON subsystem
56 AliMUON * MUON = (AliMUON *) gAlice->GetDetector("MUON");
57 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
374ebd7d 58 // MUONLoader->LoadHits("READ");
a501728c 59 MUONLoader->LoadRecPoints("READ");
276c44b7 60 MUONLoader->LoadTracks("UPDATE");
a501728c 61 AliMUONData * muondata = MUON->GetMUONData();
62 muondata->SetLoader(MUONLoader);
63
276c44b7 64 Int_t nevents;
a501728c 65 nevents = RunLoader->GetNumberOfEvents();
66
67 AliMUONEventReconstructor *Reco = new AliMUONEventReconstructor();
68
69 // The right place for changing AliMUONEventReconstructor parameters
70 // with respect to the default ones
71 // Reco->SetMaxSigma2Distance(100.0);
72 // Reco->SetPrintLevel(20);
276c44b7 73 Reco->SetPrintLevel(0);
a501728c 74 // Reco->SetBendingResolution(0.0);
75 // Reco->SetNonBendingResolution(0.0);
76 cout << "AliMUONEventReconstructor: actual parameters" << endl;
276c44b7 77// Reco->Dump();
a501728c 78 // gObjectTable->Print();
79
276c44b7 80 MUONLoader->LoadRecPoints("READ");
81
ba9436c6 82 if (LastEvent>nevents) LastEvent=nevents;
a501728c 83 // Loop over events
84 for (Int_t event = FirstEvent; event < LastEvent; event++) {
276c44b7 85 //MUONLoader->LoadHits("READ");
86 cout << "Event: " << event << endl;
87 RunLoader->GetEvent(event);
88// Test if trigger track has already been done before
89 if (MUONLoader->TreeT() == 0x0) {
90 MUONLoader->MakeTracksContainer();
91 } else {
92 if (muondata->IsTrackBranchesInTree()){ // Test if track has already been done before
93 if (event==FirstEvent) MUONLoader->UnloadTracks();
94 MUONLoader->MakeTracksContainer(); // Redoing Tracking
95 Info("TrackContainer","Recreating TrackContainer and deleting previous ones");
96 }
97 }
a501728c 98
276c44b7 99 muondata->MakeBranch("RT");
ac1fde5a 100 muondata->SetTreeAddress("RT");
276c44b7 101 Reco->EventReconstruct();
102 // Dump current event
103 // Reco->EventDump();
104
105 // Duplicating rectrack data in muondata for output
106 for(Int_t i=0; i<Reco->GetNRecTracks(); i++) {
107 AliMUONTrack * track = (AliMUONTrack*) Reco->GetRecTracksPtr()->At(i);
108 muondata->AddRecTrack(*track);
109 //printf(">>> TEST TEST event %d Number of hits in the track %d is %d \n",event,i,track->GetNTrackHits());
110 }
374ebd7d 111
1a1cdff8 112 muondata->Fill("RT");
374ebd7d 113 MUONLoader->WriteTracks("OVERWRITE");
a501728c 114 muondata->ResetRecTracks();
276c44b7 115 muondata->ResetRawClusters();
a501728c 116 } // Event loop
276c44b7 117 MUONLoader->UnloadRecPoints();
118 MUONLoader->UnloadTracks();
a501728c 119}