29fc2c86 |
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 | // Macro MUONTracker.C (TO BE COMPILED) |
17 | // for testing the C++ reconstruction code |
18 | // Output is using aliroot standard output MUON.Tracks.root |
19 | // The output is a TClonesArray of AliMUONTracks. |
20 | // Allow to make track reconstruction directly from AliTrackReference hits |
21 | // recorded in TrackRefs.root file. |
22 | |
23 | #if !defined(__CINT__) || defined(__MAKECINT__) |
24 | #include "AliRun.h" |
25 | #include "AliMUON.h" |
26 | #include "AliMUONData.h" |
29f1b13a |
27 | #include "AliMUONTrackReconstructor.h" |
29fc2c86 |
28 | #endif |
29 | |
30 | void MUONTracker (Int_t FirstEvent = 0, Int_t LastEvent = 9999, Text_t *FileName = "galice.root") |
31 | { |
32 | // |
33 | cout << "MUONTracker" << endl; |
34 | cout << "FirstEvent " << FirstEvent << endl; |
35 | cout << "LastEvent " << LastEvent << endl; |
36 | cout << "FileName ``" << FileName << "''" << endl; |
37 | |
38 | // Creating Run Loader and openning file containing Hits, Digits and RecPoints |
39 | AliRunLoader * RunLoader = AliRunLoader::Open(FileName,"MUONLoader","UPDATE"); |
40 | if (RunLoader ==0x0) { |
41 | printf(">>> Error : Error Opening %s file \n",FileName); |
42 | return; |
43 | } |
44 | // Loading AliRun master |
45 | if (RunLoader->GetAliRun() == 0x0) RunLoader->LoadgAlice(); |
46 | gAlice = RunLoader->GetAliRun(); |
47 | RunLoader->LoadTrackRefs("READ"); |
48 | |
49 | // Loading MUON subsystem |
50 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
51 | |
52 | MUONLoader->LoadTracks("UPDATE"); |
53 | |
54 | Int_t nevents; |
55 | nevents = RunLoader->GetNumberOfEvents(); |
56 | |
29f1b13a |
57 | AliMUONTrackReconstructor* Reco = new AliMUONTrackReconstructor(MUONLoader); |
29fc2c86 |
58 | AliMUONData* muondata = Reco->GetMUONData(); |
59 | |
60 | // Testing if Tracker has already been done |
61 | RunLoader->GetEvent(0); |
62 | if (MUONLoader->TreeT()) { |
63 | if (muondata->IsTrackBranchesInTree()) { |
64 | MUONLoader->UnloadTracks(); |
65 | MUONLoader->LoadTracks("RECREATE"); |
66 | printf("Recreating tracks files\n"); |
67 | } |
68 | } |
69 | |
29f1b13a |
70 | // The right place for changing AliMUONTrackReconstructor parameters |
29fc2c86 |
71 | // with respect to the default ones |
72 | // Reco->SetMaxSigma2Distance(100.0); |
73 | // Reco->SetPrintLevel(20); |
74 | Reco->SetPrintLevel(0); |
75 | // Reco->SetBendingResolution(0.0); |
76 | // Reco->SetNonBendingResolution(0.0); |
77 | Reco->SetRecTrackRefHits(1); // 1: reconst. from track ref. hits 0: from clusters |
78 | |
79 | if (Reco->GetRecTrackRefHits() == 0) |
80 | MUONLoader->LoadRecPoints("READ"); |
81 | |
82 | if (LastEvent > nevents-1) LastEvent=nevents-1; |
83 | |
84 | // Loop over events |
85 | for (Int_t event = FirstEvent; event <= LastEvent; event++) { |
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 | if (Reco->GetRecTrackRefHits() == 0) |
107 | muondata->ResetRawClusters(); |
108 | } // Event loop |
109 | |
110 | MUONLoader->UnloadRecPoints(); |
111 | MUONLoader->UnloadTracks(); |
112 | RunLoader->UnloadTrackRefs(); |
113 | } |