]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONTracker.C
improving IO
[u/mrichter/AliRoot.git] / MUON / MUONTracker.C
1 // Macro MUONTracker.C (TO BE COMPILED)
2 // for testing the C++ reconstruction code
3 // Output is using aliroot standard output MUON.Tracks.root
4 // The output is a TClonesArray of AliMUONTracks.
5 #include <TClonesArray.h>
6
7 #include "AliRun.h"
8 #include "AliMUON.h"
9 #include "AliMUONData.h"
10 #include "AliMUONEventReconstructor.h"
11 #include "AliMUONTrack.h"
12 #include "AliMUONTrackHit.h"
13 #include "AliMUONTrackParam.h"
14
15 void MUONTracker (Text_t *FileName = "galice.root", Int_t FirstEvent = 0, Int_t LastEvent = 9999)
16 {
17   //
18   cout << "MUONTracker" << endl;
19   cout << "FirstEvent " << FirstEvent << endl;
20   cout << "LastEvent " << LastEvent << endl;
21   cout << "FileName ``" << FileName << "''" << endl;
22   
23   // Creating Run Loader and openning file containing Hits, Digits and RecPoints
24   AliRunLoader * RunLoader = AliRunLoader::Open(FileName,"Event","UPDATE");
25   if (RunLoader ==0x0) {
26     printf(">>> Error : Error Opening %s file \n",FileName);
27     return;
28   }
29   // Loading AliRun master
30   RunLoader->LoadgAlice();
31   gAlice = RunLoader->GetAliRun();
32   RunLoader->LoadKinematics("READ");
33   
34   // Loading MUON subsystem
35   AliMUON * MUON = (AliMUON *) gAlice->GetDetector("MUON");
36   AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
37   MUONLoader->LoadHits("READ");
38   MUONLoader->LoadRecPoints("READ");
39   AliMUONData * muondata = MUON->GetMUONData();
40   muondata->SetLoader(MUONLoader);
41   
42   Int_t ievent, nevents;
43   nevents = RunLoader->GetNumberOfEvents();
44   
45   AliMUONEventReconstructor *Reco = new AliMUONEventReconstructor();
46
47   // The right place for changing AliMUONEventReconstructor parameters
48   // with respect to the default ones
49   //   Reco->SetMaxSigma2Distance(100.0);
50   //   Reco->SetPrintLevel(20);
51   Reco->SetPrintLevel(1);
52   //   Reco->SetBendingResolution(0.0);
53   //   Reco->SetNonBendingResolution(0.0);
54   cout << "AliMUONEventReconstructor: actual parameters" << endl;
55   Reco->Dump();
56   //   gObjectTable->Print();
57
58   if  (LastEvent>nevents) LastEvent=nevents;
59   // Loop over events
60   for (Int_t event = FirstEvent; event < LastEvent; event++) {
61     cout << "Event: " << event << endl;
62     RunLoader->GetEvent(event);   
63     muondata->SetTreeAddress("RC");
64     if (MUONLoader->TreeT() == 0x0) MUONLoader->MakeTree("T");
65     muondata->MakeBranch("RT");
66     muondata->SetTreeAddress("RT");
67     Reco->EventReconstruct();
68     // Dump current event
69     Reco->EventDump();
70
71     // Duplicating rectrack data in muondata for output
72     for(Int_t i=0; i<Reco->GetNRecTracks(); i++) {
73       AliMUONTrack * track = (AliMUONTrack*) Reco->GetRecTracksPtr()->At(i);
74       muondata->AddRecTrack(*track);
75     }
76
77     muondata->Fill("RT");
78     MUONLoader->WriteTracks("OVERWRITE");
79     muondata->ResetRecTracks();
80   } // Event loop
81   MUONLoader->UnloadRecPoints();
82 }