]>
Commit | Line | Data |
---|---|---|
af8e1c2d | 1 | #ifndef __CINT__ |
2 | #include "iostream.h" | |
3 | #endif | |
4 | ||
9040b789 | 5 | Bool_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 | ||
af8e1c2d | 73 | void 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 | ||
af8e1c2d | 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 | } | |
9040b789 | 84 | |
85 | cout << "Sorting TPC tracks w.r. to transverse momentum..."; | |
86 | Bool_t success_sorting = TPCSortTracks(); | |
87 | if (success_sorting) { | |
88 | cout << "DONE!" << endl; | |
89 | } | |
90 | else { | |
91 | cout << "Some error occurred..." << endl; | |
92 | return 1; | |
93 | } | |
af8e1c2d | 94 | |
95 | // Connect the Root Galice file containing Geometry, Kine and Hits | |
96 | TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename); | |
97 | if (!file) file = new TFile("galice.root","UPDATE"); | |
98 | //if (!file) file = new TFile(filename); | |
99 | ||
100 | // Get AliRun object from file or create it if not on file | |
101 | if (!gAlice) { | |
102 | gAlice = (AliRun*)file->Get("gAlice"); | |
103 | if (gAlice) printf("AliRun object found on file\n"); | |
104 | if (!gAlice) gAlice = new AliRun("gAlice","Alice test program"); | |
105 | } | |
106 | ||
107 | AliITS* IITTSS =(AliITS *)gAlice->GetDetector("ITS"); | |
108 | if (!IITTSS) return; | |
109 | ||
110 | // | |
111 | // Loop over events | |
112 | // | |
113 | Int_t Nh=0; | |
114 | Int_t Nh1=0; | |
115 | for (Int_t nev=0; nev<= evNumber2; nev++) { | |
116 | AliITSTrackerV1 *ITStracker = new AliITSTrackerV1(IITTSS,nev,flagvert); | |
117 | Int_t nparticles = gAlice->GetEvent(nev); | |
118 | cout << "nev " << nev <<endl; | |
119 | cout << "nparticles " << nparticles <<endl; | |
120 | if (nev < evNumber1) continue; | |
121 | if (nparticles <= 0) return; | |
122 | ||
123 | TTree *TR=gAlice->TreeR(); | |
124 | Int_t nent=TR->GetEntries(); | |
125 | //printf("Found %d entries in the TreeR (must be one per module per event!)\n",nent); | |
126 | ||
127 | ||
128 | TStopwatch timer; | |
129 | ||
130 | timer.Start(); | |
131 | ITStracker->DoTracking(nev,min_t,max_t,file,realmass); | |
132 | timer.Stop(); timer.Print(); | |
133 | AliITSgeom *g1 = IITTSS->GetITSgeom(); | |
134 | Int_t NumOfModules = g1->GetIndexMax(); | |
135 | ITStracker->DelMatrix(NumOfModules); | |
136 | delete ITStracker; | |
137 | } // event loop | |
138 | file->Close(); | |
139 | } | |
140 |