Added Thomas Kuhr changes for datachallenge/aliroot tag v4-01-00.
[u/mrichter/AliRoot.git] / HLT / programs / runhough.cxx
1 // $Id$
2
3 // Author: Constantin Loizides <loizides@ikf.uni-frankfurt.de
4 //*-- Copyright &copy ALICE HLT Group
5
6 #include <AliL3StandardIncludes.h>
7
8 #include <AliL3RootTypes.h>
9 #include <AliL3Logging.h>
10 #include <AliL3Logger.h>
11 #include <AliL3Transform.h>
12 #include <AliL3Track.h>
13 #include <AliL3TrackArray.h>
14 #include <AliL3HoughTrack.h>
15 #include <AliL3ClustFinderNew.h>
16 #include <AliL3MemHandler.h>
17 #include <AliL3SpacePointData.h>
18 #include <AliL3HoughBaseTransformer.h>
19 #include <AliL3HoughTransformer.h>
20 #include <AliL3HoughTransformerLUT.h>
21 #include <AliL3HoughTransformerVhdl.h>
22 #include <AliL3HoughMaxFinder.h>
23 #include <AliL3Hough.h>
24
25 #ifndef no_root
26 #include <TROOT.h>
27 #include <TApplication.h>
28 #include <TCanvas.h>
29 #include <TH2.h>
30 #include <TGraph.h>
31 #include <TGraphErrors.h>
32 #endif
33
34 #if GCCVERSION == 3
35 using namespace std;
36 #endif
37
38 int main(Int_t argc,Char_t **argv)
39 {
40   Int_t sl=0;
41   Int_t sh=0;
42   Int_t segs=100;
43
44   AliL3Logger l;
45   l.Set(AliL3Logger::kAll);
46   l.UseStderr();
47   //l.UseStdout();
48   //l.UseStream();
49
50   Char_t path[1024];
51   if(argc<2){
52     cout<<"Usage: runhough path [slow] [shigh] [segs]"<<endl;
53     exit(1);
54   }
55   strcpy(path,argv[1]);
56   if (argc>2) {
57     sl=atoi(argv[2]);
58   }
59   if (argc>3) {
60     sh=atoi(argv[3]);
61   }
62   if (argc>4) {
63     segs=atoi(argv[4]);
64   }
65
66   //AliL3FFloat::SetParams(10000);
67   AliL3Transform::Init(path);
68
69 #if 0
70   runhough(sl,sh,path,segs);
71 #else //do some comparison tests
72
73   AliL3HoughBaseTransformer *fh1 = new AliL3HoughTransformerVhdl(0,0,segs);
74   AliL3HoughBaseTransformer *fh2 = new AliL3HoughTransformerLUT(0,0,segs);
75
76   fh1->CreateHistograms(64,0.1,64,-30,30);
77   fh2->CreateHistograms(64,0.1,64,-30,30);
78
79   fh1->Print();
80
81 #endif
82
83   //AliL3FFloat::PrintStat();
84   exit(0);
85 }
86
87
88 //----------------------------------------------------------------------------------
89 // dont look beyond...
90 //----------------------------------------------------------------------------------
91
92 #if 0
93 void runhough(Int_t sl,Int_t sh,Char_t *path,Int_t n_eta_segments, Int_t show_seg=-1)
94 {
95
96   Bool_t binary = kTRUE;
97   Bool_t bit8 = kTRUE;
98   Int_t tv=1;
99   Int_t th=14000;
100
101   AliL3Hough *hough = new AliL3Hough();
102   hough->Init(path,binary,n_eta_segments,bit8,tv);
103   hough->GetMaxFinder()->SetThreshold(th);
104   Int_t ntracks=0;
105
106   for(Int_t slice=sl;slice<=sh;slice++){
107     hough->ReadData(slice);
108     hough->Transform();
109     hough->AddAllHistograms();
110     hough->FindTrackCandidates();
111     //hough->Evaluate(5);
112
113     AliL3TrackArray *tracks = (AliL3TrackArray*)hough->GetTracks(0);
114     ntracks=tracks->GetNTracks();
115     for(int i=0; i<ntracks; i++)
116       {
117         AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(i);
118         if(!track) continue;
119         if(sl==sh) cout<<"pt "<<track->GetPt()<<" psi "<<track->GetPsi()<<" eta "<<track->GetEta()<<" etaindex "<<track->GetEtaIndex()<<" weight "<<track->GetWeight()<<endl;
120         if(show_seg<0) show_seg=track->GetEtaIndex();
121       }
122
123     cout<<"Found total "<<tracks->GetNTracks()<<" tracks"<<endl;
124     hough->WriteTracks(slice);
125   }
126
127   //if((ntracks>0)&&(sl==sh)) display(hough,show_seg);
128 }
129 #endif
130
131 #if 0
132 void display(AliL3Hough *hough,Int_t eta_index)
133 {
134   //Display the data/tracks in eta_index
135   
136   hough->InitEvaluate();
137   AliL3Histogram *digitd = new AliL3Histogram("Digits display","",250,0,250,250,-125,125);
138   AliL3Histogram *trackd = new AliL3Histogram("Found tracks display","",250,0,250,250,-125,125);
139   for(int i=0; i<6; i++)
140     hough->GetEval(i)->DisplayEtaSlice(eta_index,digitd);
141   
142   float xyz[3];
143   tracks = (AliL3TrackArray*)hough->GetTracks(0);
144   for(int i=0; i<tracks->GetNTracks(); i++)
145     {
146       AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(i);
147       if(!track) continue;
148       if(track->GetEtaIndex() != eta_index) continue;
149
150       for(int j=0; j<176; j++)
151         {
152           track->GetCrossingPoint(j,xyz);
153           trackd->Fill(xyz[0],xyz[1],1);
154         }
155     }
156   
157   //Draw the parameter space
158   TCanvas *c1 = new TCanvas("c1","",2);
159   hough->GetTransformer(0)->GetHistogram(eta_index)->Draw("box");
160   
161   //Draw the tracks
162   TCanvas *c2 = new TCanvas("c2","",2);
163   digitd->Draw();
164   trackd->Draw("same");
165   ((TH1F*)trackd->GetRootHisto())->SetMarkerColor(2);
166 }
167 #endif
168
169 #if 0
170 struct GoodTrack
171 {
172   Int_t event;
173   Int_t label;
174   Double_t eta;
175   Int_t code;
176   Double_t px,py,pz;
177   Double_t pt;
178   Int_t nhits;
179 };
180
181 void geteff(char *fname)
182 {
183   GoodTrack gt[15000];
184   int counter=0;
185   ifstream in(fname);
186   if(!in)
187     {
188       cerr<<"Could not open "<<fname<<endl;
189       return;
190     }
191   while(in>>gt[counter].event>>gt[counter].label>>gt[counter].code
192         >>gt[counter].px>>gt[counter].py>>gt[counter].pz>>gt[counter].pt>>gt[counter].eta>>gt[counter].nhits)
193     counter++;
194   
195   char filename[100];
196   file = new AliL3MemHandler();
197 }
198 #endif