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