Rewriting and cleaning up
[u/mrichter/AliRoot.git] / HLT / hough / AliL3Hough.cxx
CommitLineData
f80b98cb 1//Author: Anders Strand Vestbo
2//Last Modified: 28.6.01
3
f000f8a5 4#include <string.h>
f80b98cb 5#include <TCanvas.h>
6#include <TFile.h>
f000f8a5 7
f80b98cb 8#include "AliL3Histogram.h"
f000f8a5 9#include "AliL3Hough.h"
10#include "AliL3HoughTransformer.h"
11#include "AliL3HoughMaxFinder.h"
f80b98cb 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"
f000f8a5 19
20ClassImp(AliL3Hough)
21
22AliL3Hough::AliL3Hough()
23{
24
4fc9a6a4 25
f000f8a5 26}
27
28
4fc9a6a4 29AliL3Hough::AliL3Hough(Char_t *path,Bool_t binary,Int_t n_eta_segments)
f000f8a5 30{
4fc9a6a4 31 fBinary = binary;
32 strcpy(fPath,path);
f80b98cb 33 fNEtaSegments = n_eta_segments;
4fc9a6a4 34 Init();
f000f8a5 35}
36
37
38AliL3Hough::~AliL3Hough()
39{
f80b98cb 40 if(fMemHandler)
4fc9a6a4 41 DeleteMemory();
42 if(fHoughTransformer)
43 DeleteTransformers();
44 if(fRootFile)
45 {
46 fRootFile->Close();
47 delete fRootFile;
48 }
f000f8a5 49}
50
4fc9a6a4 51void AliL3Hough::DeleteTransformers()
f000f8a5 52{
4fc9a6a4 53 for(Int_t i=0; i<NPatches; i++)
f80b98cb 54 {
4fc9a6a4 55 if(!fHoughTransformer[i]) continue;
56 delete fHoughTransformer;
f80b98cb 57 }
4fc9a6a4 58 delete [] fHoughTransformer;
f000f8a5 59}
60
4fc9a6a4 61void AliL3Hough::DeleteMemory()
f000f8a5 62{
4fc9a6a4 63 for(Int_t i=0; i<NPatches; i++)
64 {
65 if(!fMemHandler[i]) continue;
66 delete fMemHandler[i];
67 }
68 delete [] fMemHandler;
f000f8a5 69}
70
4fc9a6a4 71void AliL3Hough::Init()
f000f8a5 72{
4fc9a6a4 73 fHoughTransformer = new AliL3HoughTransformer*[NPatches];
74 fMemHandler = new AliL3FileHandler*[NPatches];
75 for(Int_t i=0; i<NPatches; i++)
f80b98cb 76 {
4fc9a6a4 77 fHoughTransformer[i] = new AliL3HoughTransformer(1,i,fNEtaSegments);
78 fMemHandler[i] = new AliL3FileHandler();
f80b98cb 79 }
4fc9a6a4 80 if(!fBinary)
81 fRootFile = new TFile(fPath);
82}
f80b98cb 83
4fc9a6a4 84void AliL3Hough::TransformSlice(Int_t slice)
85{
f80b98cb 86
4fc9a6a4 87 for(Int_t i=0; i<NPatches; i++)
f80b98cb 88 {
4fc9a6a4 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();
f80b98cb 110 }
4fc9a6a4 111
112}
113
114AliL3Histogram *AliL3Hough::AddHistograms()
115{
116 AliL3Histogram *hist0 = fHoughTransformer[0]->GetHistogram(0);
117 for(Int_t i=1; i<NPatches; i++)
f80b98cb 118 {
4fc9a6a4 119 AliL3Histogram *hist = fHoughTransformer[i]->GetHistogram(0);
120 hist0->Add(hist);
f80b98cb 121 }
f80b98cb 122
4fc9a6a4 123 return hist0;
124}
125
126void AliL3Hough::Evaluate(AliL3Histogram *hist)
127{
128
129 AliL3HoughEval **eval = new AliL3HoughEval*[NPatches];
130 for(Int_t i=0; i<NPatches; i++)
f80b98cb 131 {
4fc9a6a4 132 eval[i] = new AliL3HoughEval(fHoughTransformer[i]);
133 eval[i]->DisplayEtaSlice(0,hist);
134 delete eval[i];
f80b98cb 135 }
f000f8a5 136
4fc9a6a4 137 delete [] eval;
f80b98cb 138
4fc9a6a4 139}