Rewriting and cleaning up
[u/mrichter/AliRoot.git] / HLT / hough / AliL3Hough.cxx
1 //Author:        Anders Strand Vestbo
2 //Last Modified: 28.6.01
3
4 #include <string.h>
5 #include <TCanvas.h>
6 #include <TFile.h>
7
8 #include "AliL3Histogram.h"
9 #include "AliL3Hough.h"
10 #include "AliL3HoughTransformer.h"
11 #include "AliL3HoughMaxFinder.h"
12 #include "AliL3FileHandler.h"
13 #include "AliL3DigitData.h"
14 #include "AliL3HoughEval.h"
15 #include "AliL3Transform.h"
16 #include "AliL3Defs.h"
17 #include "AliL3TrackArray.h"
18 #include "AliL3HoughTrack.h"
19
20 ClassImp(AliL3Hough)
21
22 AliL3Hough::AliL3Hough()
23 {
24
25   
26 }
27
28
29 AliL3Hough::AliL3Hough(Char_t *path,Bool_t binary,Int_t n_eta_segments)
30 {
31   fBinary = binary;
32   strcpy(fPath,path);
33   fNEtaSegments = n_eta_segments;
34   Init();
35 }
36
37
38 AliL3Hough::~AliL3Hough()
39 {
40   if(fMemHandler)
41     DeleteMemory();
42   if(fHoughTransformer)
43     DeleteTransformers();
44   if(fRootFile)
45     {
46       fRootFile->Close();
47       delete fRootFile;
48     }
49 }
50
51 void AliL3Hough::DeleteTransformers()
52 {
53   for(Int_t i=0; i<NPatches; i++)
54     {
55       if(!fHoughTransformer[i]) continue;
56       delete fHoughTransformer;
57     }
58   delete [] fHoughTransformer;
59 }
60
61 void AliL3Hough::DeleteMemory()
62 {
63   for(Int_t i=0; i<NPatches; i++)
64     {
65       if(!fMemHandler[i]) continue;
66       delete fMemHandler[i];
67     }
68   delete [] fMemHandler;
69 }
70
71 void AliL3Hough::Init()
72 {
73   fHoughTransformer = new AliL3HoughTransformer*[NPatches];
74   fMemHandler = new AliL3FileHandler*[NPatches];
75   for(Int_t i=0; i<NPatches; i++)
76     {
77       fHoughTransformer[i] = new AliL3HoughTransformer(1,i,fNEtaSegments);
78       fMemHandler[i] = new AliL3FileHandler();
79     }
80   if(!fBinary)
81     fRootFile = new TFile(fPath);
82 }
83
84 void AliL3Hough::TransformSlice(Int_t slice)
85 {
86   
87   for(Int_t i=0; i<NPatches; i++)
88     {
89       fHoughTransformer[i]->CreateHistograms(64,-0.006,0.006,64,-0.26,0.26);
90       fHoughTransformer[i]->SetThreshold(3);
91       fMemHandler[i]->Free();
92       UInt_t ndigits=0;
93       AliL3DigitRowData *digits =0;
94       Char_t name[256];
95       if(fBinary)
96         {
97           sprintf(name,"%sdigits_%d_%d.raw",fPath,slice,i);
98           fMemHandler[i]->SetBinaryInput(name);
99           digits = (AliL3DigitRowData *)fMemHandler[i]->CompBinary2Memory(ndigits);
100           fMemHandler[i]->CloseBinaryInput();
101         }
102       else //read data from root file
103         {
104           fMemHandler[i]->SetAliInput(fRootFile);
105           fMemHandler[i]->Init(slice,i,NRows[i]);
106           digits=(AliL3DigitRowData *)fMemHandler[i]->AliDigits2Memory(ndigits); 
107         }
108       fHoughTransformer[i]->SetInputData(ndigits,digits);
109       fHoughTransformer[i]->TransformCircle();
110     }
111   
112 }
113
114 AliL3Histogram *AliL3Hough::AddHistograms()
115 {
116   AliL3Histogram *hist0 = fHoughTransformer[0]->GetHistogram(0);
117   for(Int_t i=1; i<NPatches; i++)
118     {
119       AliL3Histogram *hist = fHoughTransformer[i]->GetHistogram(0);
120       hist0->Add(hist);
121     }
122   
123   return hist0;
124 }
125
126 void AliL3Hough::Evaluate(AliL3Histogram *hist)
127 {
128   
129   AliL3HoughEval **eval = new AliL3HoughEval*[NPatches];
130   for(Int_t i=0; i<NPatches; i++)
131     {
132       eval[i] = new AliL3HoughEval(fHoughTransformer[i]);
133       eval[i]->DisplayEtaSlice(0,hist);
134       delete eval[i];
135     }
136   
137   delete [] eval;
138
139 }