]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONTracker.C
readers updated (mini header -> data header)
[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 "AliRun.h"
26 #include "AliMUON.h"
27 #include "AliMUONData.h"
28 #include "AliMUONEventReconstructor.h"
29 #endif
30
31 void MUONTracker (Text_t *FileName = "galice.root", Int_t FirstEvent = 0, Int_t LastEvent = 9999)
32 {
33   //
34   cout << "MUONTracker" << endl;
35   cout << "FirstEvent " << FirstEvent << endl;
36   cout << "LastEvent " << LastEvent << endl;
37   cout << "FileName ``" << FileName << "''" << endl;
38   
39   // Creating Run Loader and openning file containing Hits, Digits and RecPoints
40   AliRunLoader * RunLoader = AliRunLoader::Open(FileName,"MUONLoader","UPDATE");
41   if (RunLoader ==0x0) {
42     printf(">>> Error : Error Opening %s file \n",FileName);
43     return;
44   }
45   // Loading AliRun master
46   if (RunLoader->GetAliRun() == 0x0) RunLoader->LoadgAlice();
47   gAlice = RunLoader->GetAliRun();
48  // RunLoader->LoadKinematics("READ");
49   
50   // Loading MUON subsystem
51   AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
52  
53   MUONLoader->LoadRecPoints("READ");
54   MUONLoader->LoadTracks("UPDATE");
55   
56   Int_t nevents;
57   nevents = RunLoader->GetNumberOfEvents();
58   
59   AliMUONEventReconstructor* Reco = new AliMUONEventReconstructor(MUONLoader);
60   AliMUONData* muondata = Reco->GetMUONData();
61
62   // Testing if Tracker has already been done
63   RunLoader->GetEvent(0);
64   if (MUONLoader->TreeT()) {
65     if (muondata->IsTrackBranchesInTree()) {
66       MUONLoader->UnloadTracks();
67       MUONLoader->LoadTracks("RECREATE");
68       printf("Recreating RecPoints files\n");
69     }
70   }
71
72   // The right place for changing AliMUONEventReconstructor parameters
73   // with respect to the default ones
74   //   Reco->SetMaxSigma2Distance(100.0);
75   //   Reco->SetPrintLevel(20);
76   Reco->SetPrintLevel(0);
77   //   Reco->SetBendingResolution(0.0);
78   //   Reco->SetNonBendingResolution(0.0);
79   //   cout << "AliMUONEventReconstructor: actual parameters" << endl;
80
81   if  (LastEvent>nevents) LastEvent=nevents;
82
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("RT");
101       Reco->EventReconstruct();
102     
103     muondata->Fill("RT");
104     MUONLoader->WriteTracks("OVERWRITE");  
105     muondata->ResetRecTracks();
106     muondata->ResetRawClusters();
107   } // Event loop
108
109   MUONLoader->UnloadRecPoints();
110   MUONLoader->UnloadTracks();
111 }