044c7172b7b84bbb171c4a07b0ea55013a26506f
[u/mrichter/AliRoot.git] / HLT / exa / runhough.C
1 // $Id$
2
3 /**
4    Shows how to use the hough code. Stores tracks parameters
5    in files.
6 */
7
8 void runhough(Int_t slice,Char_t *path,Int_t n_eta_segments,Int_t vseg=-1)
9 {
10   Bool_t binary = kFALSE;
11   Bool_t bit8 = kFALSE;
12   
13   hough = new AliL3Hough();
14
15   hough->Init(path,binary,n_eta_segments,bit8);
16   hough->SetTransformerParams(64,64,0.1,30);
17   hough->GetMaxFinder()->SetThreshold(14000);
18   
19   hough->ReadData(slice);
20   hough->Transform();
21   hough->AddAllHistograms();
22   hough->FindTrackCandidates();
23   
24   //hough->Evaluate();
25   tracks = (AliL3TrackArray*)hough->GetTracks(0);
26   
27   for(int i=0; i<tracks->GetNTracks(); i++)
28     {
29       track = (AliL3HoughTrack*)tracks->GetCheckedTrack(i);
30       if(!track) continue;
31       //cout<<"pt "<<track->GetPt()<<" psi "<<track->GetPsi()<<" eta "<<track->GetEta()<<" etaindex "<<track->GetEtaIndex()<<" weight "<<track->GetWeight()<<" nhits "<<track->GetNHits()<<endl;
32       if(vseg==-1) vseg=track->GetEtaIndex();
33     }
34   
35   cout<<"Found in slice " << slice << " total "<<tracks->GetNTracks()<<" tracks"<<endl;
36
37   hough->WriteTracks(slice);
38   display(hough,vseg);
39   
40 }
41
42 void display(AliL3Hough *hough,Int_t eta_index)
43 {
44   //Display the data/tracks in eta_index
45   
46   hough->InitEvaluate();
47   digitd = new AliL3Histogram("Digits display","",250,0,250,250,-125,125);
48   trackd = new AliL3Histogram("Found tracks display","",250,0,250,250,-125,125);
49   for(int i=0; i<6; i++)
50     hough->GetEval(i)->DisplayEtaSlice(eta_index,digitd);
51   
52   tracks = (AliL3TrackArray*)hough->GetTracks(0);
53   float xyz[3];
54   for(int i=0; i<tracks->GetNTracks(); i++)
55     {
56       AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(i);
57       if(!track) continue;
58       if(track->GetEtaIndex() != eta_index) continue;
59
60       for(int j=0; j<176; j++)
61         {
62           track->GetCrossingPoint(j,xyz);
63           trackd->Fill(xyz[0],xyz[1],1);
64         }
65     }
66   
67   //Draw the parameter space
68   c1 = new TCanvas("c1","",2);
69   hough->GetTransformer(0)->GetHistogram(eta_index)->Draw("box");
70   
71   //Draw the tracks
72   c2 = new TCanvas("c2","",2);
73   digitd->Draw();
74   trackd->Draw("same");
75   ((TH1F*)trackd->GetRootHisto())->SetMarkerColor(2);
76 }
77
78 struct GoodTrack
79 {
80   Int_t event;
81   Int_t label;
82   Double_t eta;
83   Int_t code;
84   Double_t px,py,pz;
85   Double_t pt;
86   Int_t nhits;
87 };
88
89 void geteff(char *fname)
90 {
91   GoodTrack gt[15000];
92   int counter=0;
93   ifstream in(fname);
94   if(!in)
95     {
96       cerr<<"Could not open "<<fname<<endl;
97       return;
98     }
99   while(in>>gt[counter].event>>gt[counter].label>>gt[counter].code
100         >>gt[counter].px>>gt[counter].py>>gt[counter].pz>>gt[counter].pt>>gt[counter].eta>>gt[counter].nhits)
101     counter++;
102   
103   char filename[100];
104   file = new AliL3MemHandler();
105   
106   
107 }