]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONTracker.C
Modifs to account for trigger track reconstruction (Thanks to Christian)
[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   // 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");
58   //  MUONLoader->LoadHits("READ");
59   MUONLoader->LoadRecPoints("READ");
60   MUONLoader->LoadTracks("UPDATE");
61   AliMUONData * muondata = MUON->GetMUONData();
62   muondata->SetLoader(MUONLoader);
63   
64   Int_t nevents;
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);
73   Reco->SetPrintLevel(0);
74   //   Reco->SetBendingResolution(0.0);
75   //   Reco->SetNonBendingResolution(0.0);
76   cout << "AliMUONEventReconstructor: actual parameters" << endl;
77 //  Reco->Dump();
78   //   gObjectTable->Print();
79
80   MUONLoader->LoadRecPoints("READ");
81
82   if  (LastEvent>nevents) LastEvent=nevents;
83   // Loop over events
84   for (Int_t event = FirstEvent; event < LastEvent; event++) {
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       }
98
99       muondata->MakeBranch("RT");
100       muondata->SetTreeAddress("D,RT");
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       }
111     
112     muondata->Fill("RT");
113     MUONLoader->WriteTracks("OVERWRITE");  
114     muondata->ResetRecTracks();
115     muondata->ResetRawClusters();
116   } // Event loop
117     MUONLoader->UnloadRecPoints();
118     MUONLoader->UnloadTracks();
119 }