]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONTracker.C
Compiler Warning removed
[u/mrichter/AliRoot.git] / MUON / MUONTracker.C
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
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.
22 // Gines MARTINEZ, Subatech, sep 2003
23
24 #if !defined(__CINT__) || defined(__MAKECINT__)
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"
34 #endif
35
36 void MUONTracker (Text_t *FileName = "galice.root", Int_t FirstEvent = 0, Int_t LastEvent = 9999)
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
51   // Loading AliRun master
52   RunLoader->LoadgAlice();
53   gAlice = RunLoader->GetAliRun();
54   RunLoader->LoadKinematics("READ");
55   
56   // Loading MUON subsystem
57   AliMUON * MUON = (AliMUON *) gAlice->GetDetector("MUON");
58   AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
59   AliMUONData * muondata = MUON->GetMUONData();
60
61   Int_t nevents;
62   nevents = RunLoader->GetNumberOfEvents();
63  
64   MUONLoader->LoadRecPoints("READ");
65   MUONLoader->LoadTracks("UPDATE");
66
67
68   // Testing if Tracking has already been done
69   RunLoader->GetEvent(0);
70   if (MUONLoader->TreeT()) {
71     if (muondata->IsTrackBranchesInTree()) {
72       MUONLoader->UnloadTracks();
73       MUONLoader->LoadTracks("RECREATE");
74       printf("Recreating Tracks files\n");
75     }
76   }
77   
78   AliMUONEventReconstructor *Reco = new AliMUONEventReconstructor();
79
80   // The right place for changing AliMUONEventReconstructor parameters
81   // with respect to the default ones
82   //   Reco->SetMaxSigma2Distance(100.0);
83   //   Reco->SetPrintLevel(20);
84   Reco->SetPrintLevel(0);
85   //   Reco->SetBendingResolution(0.0);
86   //   Reco->SetNonBendingResolution(0.0);
87   cout << "AliMUONEventReconstructor: actual parameters" << endl;
88 //  Reco->Dump();
89   //   gObjectTable->Print();
90
91   if  (LastEvent>nevents) LastEvent=nevents;
92   // Loop over events
93   for (Int_t event = FirstEvent; event < LastEvent; event++) {
94       cout << "Event: " << event << endl;
95       RunLoader->GetEvent(event);   
96       if (MUONLoader->TreeT() == 0x0) MUONLoader->MakeTracksContainer();
97       
98       muondata->MakeBranch("RT");
99       muondata->SetTreeAddress("RT");
100       Reco->EventReconstruct();
101       // Dump current event
102       // Reco->EventDump();
103       
104       // Duplicating rectrack data in muondata for output
105       for(Int_t i=0; i<Reco->GetNRecTracks(); i++) {
106           AliMUONTrack * track = (AliMUONTrack*) Reco->GetRecTracksPtr()->At(i);
107           muondata->AddRecTrack(*track);
108           //printf(">>> TEST TEST event %d Number of hits in the track %d is %d \n",event,i,track->GetNTrackHits());
109       }
110       
111       muondata->Fill("RT");
112       MUONLoader->WriteTracks("OVERWRITE");  
113       muondata->ResetRecTracks();
114       muondata->ResetRawClusters();
115   } // Event loop
116   MUONLoader->UnloadRecPoints();
117   MUONLoader->UnloadTracks();
118 }