]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/oldmacros/AliITSTrackingV1.C
Fix for the case of non-existent calibration files
[u/mrichter/AliRoot.git] / ITS / oldmacros / AliITSTrackingV1.C
CommitLineData
b3d9d240 1#ifndef __CINT__
2#include "iostream.h"
3#endif
4
5Bool_t TPCSortTracks(Int_t event = 0)
6{
7 TFile *fileTracks = TFile::Open("AliTPCtracks.root");
8 TFile *fileClusters = TFile::Open("AliTPCclusters.root");
9 TFile *fileEvent = TFile::Open("galice.root");
10
11 // get TPC parameterization
12 AliTPCParam *param=(AliTPCParam *)fileEvent->Get("75x40_100x60_150x60");
13 if (!param) {
14 cerr << "(TPCSortTracks) ERROR: TPC parameters have not been found!" << endl;
15 return kFALSE;
16 }
17
18 // read and sort tracks
19 Int_t i;
20 TSortedList tracks_list;
21 AliTPCtrack *iotrack = 0;
22 TTree *tracktree = (TTree*)fileTracks->Get(Form("TreeT_TPC_%d", event));
23 Int_t nentr = (Int_t)tracktree->GetEntries();
24 for (i = 0; i < nentr; i++) {
25 iotrack = new AliTPCtrack;
26 tracktree->SetBranchAddress("tracks", &iotrack);
27 tracktree->GetEvent(i);
28 tracks_list.Add(iotrack);
29 }
30 delete tracktree;
31
32 // assign to each track its GEANT label
33 fileClusters->cd();
34 AliTPCtracker *tracker = new AliTPCtracker(param, event);
35 tracker->LoadInnerSectors();
36 tracker->LoadOuterSectors();
37 TListIter iter(&tracks_list);
38 for (i = 0; i < nentr; i++) {
39 iotrack = (AliTPCtrack*)iter.Next();
40 if (!iotrack) {
41 cerr << "(TPCSortTracks) WARNING: Track no. " << i << " is NULL!!!" << endl;
42 continue;
43 }
44 tracker->CookLabel(iotrack, 0.1);
45 }
46 delete tracker;
47
48 // create the new TTree of TPC tracks sorted w.r. to Pt
49 tracktree = new TTree(Form("TreeT_TPC_%d", event),"Tree with TPC tracks sorted w.r to pt");
50 tracktree->Branch("tracks", "AliTPCtrack", &iotrack, 32000, 0);
51 iter.Reset();
52 for (i = 0; i < nentr; i++) {
53 iotrack = (AliTPCtrack*)iter.Next();
54 if (!iotrack) {
55 cerr << "(TPCSortTracks) WARNING: Track no. " << i << " is NULL!!!" << endl;
56 continue;
57 }
58 tracktree->Fill();
59 }
60
61 // save the new tree into new file
62 TFile *fileOutput = TFile::Open("AliTPCtracksSorted.root","recreate");
63 tracktree->Write();
64 fileOutput->Close();
65 fileEvent->Close();
66 fileClusters->Close();
67 fileTracks->Close();
68
69 return kTRUE;
70}
71
72
73void AliITSTrackingV1(Int_t evNumber1=0,Int_t evNumber2=0, Int_t min_t=-1, Int_t max_t=0,Bool_t flagvert=1, Bool_t realmass=0, const char *filename="galice.root") {
74
75 ///////////////// Dynamically link some shared libs ////////////////////////////////
76
77 if (gClassTable->GetID("AliRun") < 0) {
78 gROOT->LoadMacro("loadlibs.C");
79 loadlibs();
80 } else {
81 delete gAlice;
82 gAlice=0;
83 }
84
85 // Connect the Root Galice file containing Geometry, Kine and Hits
86 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename);
87 if (!file) file = new TFile("galice.root","UPDATE");
88 //if (!file) file = new TFile(filename);
89
90// Get AliRun object from file or create it if not on file
91 if (!gAlice) {
92 gAlice = (AliRun*)file->Get("gAlice");
93 if (gAlice) printf("AliRun object found on file\n");
94 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
95 }
96
97 AliKalmanTrack::SetMagneticField(gAlice->Field()->SolenoidField() / 10.0);
98
99
100 cout << "Sorting TPC tracks w.r. to transverse momentum...";
101 Bool_t success_sorting = TPCSortTracks();
102 if (success_sorting) {
103 cout << "DONE!" << endl;
104 }
105 else {
106 cout << "Some error occurred..." << endl;
107 return 1;
108 }
109
110 AliITS* IITTSS =(AliITS *)gAlice->GetDetector("ITS");
111 if (!IITTSS) return;
112
113//
114// Loop over events
115//
116 Int_t Nh=0;
117 Int_t Nh1=0;
118 for (Int_t nev=0; nev<= evNumber2; nev++) {
119 AliITSTrackerV1 *ITStracker = new AliITSTrackerV1(IITTSS,nev,flagvert);
120 Int_t nparticles = gAlice->GetEvent(nev);
121 cout << "nev " << nev <<endl;
122 cout << "nparticles " << nparticles <<endl;
123 if (nev < evNumber1) continue;
124 if (nparticles <= 0) return;
125
126 TTree *TR=gAlice->TreeR();
127 Int_t nent=TR->GetEntries();
128 //printf("Found %d entries in the TreeR (must be one per module per event!)\n",nent);
129
130
131 TStopwatch timer;
132
133 timer.Start();
134 ITStracker->DoTracking(nev,min_t,max_t,file,realmass);
135 timer.Stop(); timer.Print();
136 AliITSgeom *g1 = IITTSS->GetITSgeom();
137 Int_t NumOfModules = g1->GetIndexMax();
138 ITStracker->DelMatrix(NumOfModules);
139 delete ITStracker;
140 } // event loop
141 file->Close();
142}
143