results of cleanup
[u/mrichter/AliRoot.git] / HLT / hough / test.C
CommitLineData
46e4136e 1void test(char *file="/prog/alice/data/Rawdata/6_patch/hg_42105_s1-3/",bool bin=true)
2{
3
4 Int_t fNEtaSegments = 1 ;
5
6 Char_t histname[50];
7 Int_t i;
8
9 int slice=1,patch=0;
1b737078 10
46e4136e 11 fHoughTransformer = new AliL3HoughTransformer(slice,patch,fNEtaSegments);
12 fMemHandler = new AliL3FileHandler();
13 fMaxFinder = new AliL3HoughMaxFinder("KappaPhi");
1b737078 14
46e4136e 15 fTransform = new AliL3Transform();
1b737078 16
17 fHoughTransformer->CreateHistograms();//64,0,3.1415,128,-120,120);
18 fHoughTransformer->SetThreshold(10);
46e4136e 19 fTracks = new AliL3TrackArray("AliL3HoughTrack");
20
21
22 TH2F *road = new TH2F("road","",250,0,250,250,-125,125);
23 TH2F *peaks = new TH2F("peaks","",64,-0.006,0.006,64,-0.26,0.26);
24 peaks->SetMarkerStyle(3);
25 peaks->SetMarkerColor(2);
26 road->SetMarkerStyle(6);
27 road->SetMarkerColor(2);
28
29 Char_t name[256];
30
31 UInt_t ndigits=0;
32 AliL3DigitRowData *digits =0;
33
34 if(bin) //read data from binary files
35 {
36 Char_t fPath[256];
37 strcpy(fPath,file);
38 fMemHandler->Free();
39 sprintf(name,"%sdigits_%d_%d.raw",fPath,slice,patch);
40 fMemHandler->SetBinaryInput(name);
41 digits = (AliL3DigitRowData *)fMemHandler->CompBinary2Memory(ndigits);
42 fMemHandler->CloseBinaryInput();
43 }
44 else //read data from root file
45 {
46 const Int_t NRows[6][2] = {{0,31},{32,63},{64,91},{92,119},{120,143},{144,175}};
47 fMemHandler->Free();
48 TFile *rootfile = new TFile(file);
49 fMemHandler->SetAliInput(rootfile);
50 fMemHandler->Init(slice,patch,NRows[patch]);
51 fMemHandler->Init(fTransform);
52 digits=(AliL3DigitRowData *)fMemHandler->AliDigits2Memory(ndigits);
1b737078 53 rootfile->Close();
54 delete rootfile;
46e4136e 55 }
56 fHoughTransformer->SetInputData(ndigits,digits);
57 fEval = new AliL3HoughEval(fHoughTransformer);
58 fEval->SetNumOfRowsToMiss(2);
59 //fEval->SetNumOfPadsToLook(2);
60 AliL3HoughTrack *track;
61 AliL3Histogram *histo;
62 Int_t good_count;
63 int eind=0;
64 while(1)
65 {
66 printf("Transforming\n");
67 double init = AliL3Benchmark::GetCpuTime();
1b737078 68 fHoughTransformer->TransformCircle();
46e4136e 69 double final = AliL3Benchmark::GetCpuTime();
70 printf("done in %f ms\n",(final-init)*1000);
71
72 good_count=0;
1b737078 73 /*
46e4136e 74 for(Int_t e=0; e<fNEtaSegments; e++)
75 {
76 histo = (AliL3Histogram*)fHoughTransformer->GetHistogram(e);
77 if(!histo) continue;
78
79 fMaxFinder->SetHistogram(histo);
1b737078 80 Int_t n=10;
81 Float_t x[10];
82 Float_t y[10];
83 fMaxFinder->FindPeak1(x,y,n);
84 track = new AliL3HoughTrack();
85 track->SetTrackParameters(x[0],y[0],1);
46e4136e 86
1b737078 87 //if(!fEval->LookInsideRoad(track,e))
88 //continue;
89 for(int t=0; t<176; t++)
46e4136e 90 {
91 float xyz_tr[3];
92 track->GetCrossingPoint(t,xyz_tr);
93 road->Fill(xyz_tr[0],xyz_tr[1],1);
94 }
95
96 }
1b737078 97 */
46e4136e 98 break;
99 if(good_count==0)
100 break;
101 }
1b737078 102
46e4136e 103 image = new AliL3Histogram("image","",250,0,250,250,-125,125);
104 fEval->DisplayEtaSlice(eind,image);
1b737078 105
46e4136e 106 c1 = new TCanvas("c1","",1000,500);
107 c1->Divide(2);
108 c1->cd(1);
109 histo = (AliL3Histogram*)fHoughTransformer->GetHistogram(eind);
110 if(!histo)
111 {printf("No histogram\n"); return;}
112 fHoughTransformer->GetHistogram(eind)->Draw("box");
1b737078 113 // peaks->Draw("same");
114 c1->cd(2);
115 image->Draw("");
116 //road->Draw("same");
117}
118
119void process(char *path="/prog/alice/data/Rawdata/6_patch/hg_42105_s1-3/",bool bin=true)
120{
121 double torad = 3.1415/180;
122 a = new AliL3Hough(path,bin,1);
123 a->TransformSlice(1);
124
125 hist = (AliL3Histogram*)a->AddHistograms();
126
127 //hist->SetThreshold(10000);
128
129 b = new AliL3HoughMaxFinder("KappaPhi");
130 b->SetHistogram(hist);
131
132 Int_t xbin,ybin;
133
134 Int_t n=10;
135 Float_t x[10];
136 Float_t y[10];
137 b->FindPeak1(x,y,n);
138 printf("peak at pt %f phi0 %f\n",0.2*0.003/x[0],y[0]/torad);
139
140 track = new AliL3HoughTrack();
141 track->SetTrackParameters(x[0],y[0],1);
142
143 image = new AliL3Histogram("image","",250,0,250,250,-125,125);
144 a->Evaluate(image);
145 TH2F *road = new TH2F("road","",250,0,250,250,-125,125);
146 road->SetMarkerStyle(5);
147 road->SetMarkerColor(2);
148
149 float xyz[3];
150 for(int i=0; i<176; i++)
151 {
152 if(i%10) continue;
153 track->GetCrossingPoint(i,xyz);
154 road->Fill(xyz[0],xyz[1],1);
155 }
156 c1 = new TCanvas("c1","",1000,500);
157 c1->Divide(2);
158 c1->cd(1);
159 hist->Draw("box");
46e4136e 160 c1->cd(2);
1b737078 161 image->Draw();
46e4136e 162 road->Draw("same");
163}