ea900797a36184463a4aff4c47386227a5e0f6b9
[u/mrichter/AliRoot.git] / HLT / hough / test.C
1 void 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;
10
11   fHoughTransformer = new AliL3HoughTransformer(slice,patch,fNEtaSegments);
12   fMemHandler = new AliL3FileHandler();
13   fMaxFinder = new AliL3HoughMaxFinder("KappaPhi");
14
15   fTransform = new AliL3Transform();
16
17   fHoughTransformer->CreateHistograms();
18   fHoughTransformer->SetThreshold(3);
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); 
53     }
54   fHoughTransformer->SetInputData(ndigits,digits);
55   fEval = new AliL3HoughEval(fHoughTransformer);
56   fEval->SetNumOfRowsToMiss(2);
57   //fEval->SetNumOfPadsToLook(2);
58   AliL3HoughTrack *track;
59   AliL3Histogram *histo;
60   Int_t good_count;
61   int eind=0;
62   while(1)
63     {
64       printf("Transforming\n");
65       double init = AliL3Benchmark::GetCpuTime();
66       fHoughTransformer->Transform();
67       double final = AliL3Benchmark::GetCpuTime();
68       printf("done in %f ms\n",(final-init)*1000);
69       
70       good_count=0;
71       
72       for(Int_t e=0; e<fNEtaSegments; e++)
73         {
74           histo = (AliL3Histogram*)fHoughTransformer->GetHistogram(e);
75           if(!histo) continue;
76           
77           fMaxFinder->SetHistogram(histo);
78           track = (AliL3HoughTrack*)fMaxFinder->FindPeak1();
79           peaks->Fill(track->GetKappa(),track->GetPhi0(),1);
80           
81           if(!fEval->LookInsideRoad(track,e))
82             continue;
83           for(int t=0; t<175; t++)
84             {
85               float xyz_tr[3];
86               track->GetCrossingPoint(t,xyz_tr);
87               road->Fill(xyz_tr[0],xyz_tr[1],1);
88             }
89           
90         }
91       
92       break;
93       if(good_count==0)
94         break;
95     }
96
97   image = new AliL3Histogram("image","",250,0,250,250,-125,125);
98   fEval->DisplayEtaSlice(eind,image);
99
100   c1 = new TCanvas("c1","",1000,500);
101   c1->Divide(2);
102   c1->cd(1);
103   histo = (AliL3Histogram*)fHoughTransformer->GetHistogram(eind);
104   if(!histo)
105     {printf("No histogram\n"); return;}
106   fHoughTransformer->GetHistogram(eind)->Draw("box");
107   peaks->Draw("same");
108   c1->cd(2);
109   image->Draw("colz");
110   road->Draw("same");
111 }