]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/exa/deconvclusters.C
replaces AliPHOSAliEnFile: references to AliEn removed
[u/mrichter/AliRoot.git] / HLT / exa / deconvclusters.C
1 //$Id$
2
3 /* Example of how to use the AliL3ClusterFitter to fit clusters
4    to the track candidates given as a AliL3TrackArray.
5
6    The path "path" should contain the link to the digitsfile, 
7    and the directories called fitter (for the results) and hough
8    (for the track files). For NEWIO, make sure that the file 
9    TPC.Digits.root is in the path (symlink)!
10
11    Also provide the neccessary parameters in SetFitParameters.C.
12
13    RUN with ALIROOT (not ROOT), no other method is 
14    supported right now.
15 */
16
17 #ifndef __CINT__
18 #include "AliL3Logger.h"
19 #include "AliL3FileHandler.h"
20 #include "AliL3DigitData.h"
21 #include "AliL3Track.h"
22 #include "AliL3Transform.h"
23 #include "AliL3Hough.h"
24 #include "AliL3Fitter.h"
25 #include "AliL3ClusterFitter.h"
26 #include "AliL3Vertex.h"
27 #include "AliL3TrackArray.h"
28 #include <TNtuple.h>
29 #include <TRandom.h>
30 #include <TSystem.h>
31 #include <TStopwatch.h>
32 #include <stdio.h>
33 #include <iostream.h>
34 #include <time.h>
35 #endif
36
37 void deconvclusters(Char_t *path,Int_t minslice=0,Int_t maxslice=35,Int_t nevent=1)
38 {
39   
40   AliL3Transform::Init(path,kTRUE);
41   
42   Char_t filename[1024];
43   AliL3FileHandler *file = new AliL3FileHandler(kTRUE); //static index
44   UInt_t ndigits=0;
45   
46   sprintf(filename,"%s/digitfile.root",path);
47   file->SetAliInput(filename);
48   AliL3ClusterFitter *fitter = new AliL3ClusterFitter(path);
49   
50 #ifdef __CINT__
51   Char_t macroname[1024];
52   gROOT->LoadMacro("SetFitParameters.C");
53   SetFitParameters(fitter);
54 #else /*compiled version */
55   fitter->SetInnerWidthFactor(1,1);
56   fitter->SetOuterWidthFactor(1,1);
57   fitter->SetNmaxOverlaps(5);
58
59   fitter->SetChiSqMax(5,0);
60   fitter->SetChiSqMax(5,1);
61   fitter->SetChiSqMax(5,2);
62 #endif
63   
64   TStopwatch tloader;tloader.Stop();
65   TStopwatch tfinder;tfinder.Stop();
66   TStopwatch trefitter;trefitter.Stop();
67
68   Int_t patch=-1;
69   Int_t rowrange[2] = {0,AliL3Transform::GetNRows()-1};  
70   for(Int_t ev=0; ev<nevent; ev++)
71     {
72       AliL3FileHandler::LoadStaticIndex(0,ev);
73       fitter->LoadSeeds(rowrange,kFALSE,ev); //Takes input from global hough tracks
74       
75       for(Int_t slice=minslice; slice<=maxslice; slice++)
76         {
77           tloader.Start(0);
78           file->Init(slice,-1);
79           cout<<"Processing event "<<ev<<" slice "<<slice<<" patch "<<patch<<endl;
80           AliL3DigitRowData *digits = (AliL3DigitRowData*)file->AliAltroDigits2Memory(ndigits,ev);
81           fitter->Init(slice,patch);
82           fitter->SetInputData(digits);
83           tloader.Stop();
84           
85           tfinder.Start(0);
86           fitter->FindClusters();
87           fitter->WriteClusters();
88           tfinder.Stop();
89
90           tloader.Start(0);
91           file->Free();
92           tloader.Stop();
93         }
94       
95       //If you want a refit of the clusters;-------------------------
96       tloader.Start(0);
97       AliL3Vertex vertex;
98       AliL3TrackArray *tracks = fitter->GetSeeds(); //The seeds are the 
99                                                     //input tracks from circle HT
100       AliL3Fitter *ft = new AliL3Fitter(&vertex,1);
101       sprintf(filename,"%s/fitter/",path);
102       ft->LoadClusters(filename,0,kTRUE);
103       tloader.Stop();
104
105       trefitter.Start(0);
106       for(Int_t i=0; i<tracks->GetNTracks(); i++)
107         {
108           AliL3Track *track = tracks->GetCheckedTrack(i);
109           if(!track) continue;
110           if(track->GetNHits() < 40) continue;
111           ft->SortTrackClusters(track);
112           ft->FitHelix(track);
113           track->UpdateToFirstPoint();
114         }
115       trefitter.Stop();
116       //-------------------------------------------------------------
117       tloader.Start(0);
118       delete ft;
119       fitter->WriteTracks(5); //Write the final tracks
120       file->FreeDigitsTree();
121       tloader.Stop();
122     }
123   cout << " --- Timing values --- " << endl;
124   cout << "Data  Loading:        "; tloader.Print("m");
125   cout << "Cluster Deconvolution "; tfinder.Print("m");
126   cout << "Track ReFitter        "; trefitter.Print("m");
127
128   delete fitter;
129 }
130
131 void deconvlocally(Char_t *path,Int_t minslice=0,Int_t maxslice=17)
132 {
133   
134   AliL3Transform::Init(path,kTRUE);
135   
136   Char_t filename[1024];
137   AliL3FileHandler *file = new AliL3FileHandler(kTRUE);
138   UInt_t ndigits=0;
139   
140   sprintf(filename,"%s/digitfile.root",path);
141   file->SetAliInput(filename);
142   AliL3ClusterFitter *fitter = new AliL3ClusterFitter(path);
143   
144 #ifdef __CINT__
145   Char_t macroname[1024];
146   sprintf(macroname,"%s/SetFitParameters.C",path);
147   gROOT->LoadMacro(macroname);
148   SetFitParameters(fitter);
149 #else /*compiled version */
150   fitter->SetInnerWidthFactor(1,1);
151   fitter->SetOuterWidthFactor(1,1);
152   fitter->SetNmaxOverlaps(5);
153
154   fitter->SetChiSqMax(5,0);
155   fitter->SetChiSqMax(5,1);
156   fitter->SetChiSqMax(5,2);
157 #endif
158   
159   Int_t patch=-1;
160   
161   for(Int_t slice=minslice; slice<=maxslice; slice++)
162     {
163       file->Init(slice,patch);
164       cout<<"Processing slice "<<slice<<" patch "<<patch<<endl;
165       AliL3DigitRowData *digits = (AliL3DigitRowData*)file->AliAltroDigits2Memory(ndigits);
166       
167       fitter->Init(slice,patch);
168       fitter->LoadLocalSegments();
169       
170       fitter->SetInputData(digits);
171       
172       fitter->FindClusters();
173       fitter->WriteClusters();
174       
175       file->Free();
176     
177     }
178   
179   fitter->WriteTracks(5);
180   delete fitter;
181 }
182