]>
Commit | Line | Data |
---|---|---|
594eefc8 | 1 | //#define DOTESTS /* undefine this for getting the parameters */ |
2 | ||
3 | #ifdef DOTESTS | |
4 | #define use_root | |
5 | #endif | |
6 | ||
7 | #include <stream.h> | |
8 | #include <libgen.h> | |
9 | #include <math.h> | |
10 | #include <AliL3RootTypes.h> | |
11 | #include <AliL3Defs.h> | |
12 | #include <AliL3Transform.h> | |
13 | #include <AliL3Logging.h> | |
14 | #include <AliL3Logger.h> | |
15 | #include <AliL3MemHandler.h> | |
16 | ||
17 | #ifdef use_root | |
18 | #include <TApplication.h> | |
19 | #include <TCanvas.h> | |
20 | #include <TPad.h> | |
21 | #include <TH1.h> | |
22 | #include <TMath.h> | |
23 | #endif | |
24 | ||
25 | /* | |
26 | This program extracts parameters and lookup tables needed for the | |
27 | vhdl implementation of the Hough transform. | |
28 | */ | |
29 | ||
30 | int main(int argc,char **argv) | |
31 | { | |
32 | Int_t patch=0; | |
33 | Int_t slice=0; | |
34 | Char_t path[1000]; | |
35 | //cout<<"Usage: transform [slice] [patch] [path]"<<endl; | |
36 | ||
37 | if (argc>1) { | |
38 | slice=atoi(argv[1]); | |
39 | } | |
40 | if (argc>2) { | |
41 | patch=atoi(argv[2]); | |
42 | } if (argc>3) { | |
43 | strcpy(path,argv[3]); | |
44 | } else strcpy(path,"/tmp/data/RawData/slice0"); | |
45 | ||
46 | AliL3Logger l; | |
47 | l.UseStdout(); | |
48 | //l.UseStream(); | |
49 | ||
50 | AliL3Transform::Init(path); | |
51 | //cout << "Transform version: " << AliL3Transform::GetVersion() << endl; | |
52 | ||
53 | Int_t npads=0; | |
54 | Int_t sector=0; | |
55 | Int_t sector_row=0; | |
56 | ||
57 | Float_t Xt[200]; | |
58 | Float_t Yt[200]; | |
59 | ||
60 | Float_t xbins[126]; | |
61 | for(int t=0;t<126;t++){ | |
62 | Float_t eta=exp(2.*1./125*t); | |
63 | xbins[t]=(eta-1)/(1+eta); | |
64 | //cout << eta << " " << xbins[t] << endl; | |
65 | } | |
66 | ||
67 | #ifdef DOTESTS /* do some tests in root histos */ | |
68 | #ifdef use_root | |
69 | TApplication theApp("App", &argc, argv); | |
70 | ||
71 | TCanvas *c = new TCanvas("c", "The Histogram Canvas", 800, 800); | |
72 | TPad *pad1 = new TPad("pad1","Pad for Eta",0.05,0.50,0.95,0.95,21); | |
73 | TPad *pad2 = new TPad("pad2","Pad for Tests",0.05,0.05,0.95,0.45,21); | |
74 | // TH1F *h1f = new TH1F("h1f","Eta Distribution",125,0,1.); | |
75 | TH1F *h1f = new TH1F("h1f","Test Error",100,90,110); | |
76 | TH1F *h2f = new TH1F("h2f","Test Distribution",1000,0,10); | |
77 | // TH1F *h2f = new TH1F("h2f","Test Distribution",125,xbins); | |
78 | pad1->Draw(); | |
79 | pad2->Draw(); | |
80 | pad1->cd(); | |
81 | #endif | |
82 | ||
83 | Int_t ntime=AliL3Transform::GetNTimeBins(); | |
84 | Float_t xyz[3]={0,0,0}; | |
85 | Float_t rpe[3]={0,0,0}; | |
86 | int rebinned=0; | |
87 | for(Int_t rr=NRows[patch][0];rr<=NRows[patch][1];rr++){ | |
88 | npads=AliL3Transform::GetNPads(rr); | |
89 | AliL3Transform::Slice2Sector(slice,rr,sector,sector_row); | |
90 | for(Int_t pp=0;pp<npads;pp++){ | |
91 | for (Int_t tt=0;tt<ntime;tt++){ | |
92 | AliL3Transform::Raw2Local(xyz,sector,sector_row,pp,tt); | |
93 | AliL3Transform::XYZtoRPhiEta(rpe,xyz); | |
94 | #ifdef use_root | |
95 | if(!rebinned) { | |
96 | h2f->SetBins(500,0,252.*252/xyz[0]/xyz[0]); | |
97 | rebinned=1; | |
98 | } | |
99 | //h1f->Fill(rpe[2]); | |
100 | //h2f->Fill(xyz[2]/rpe[0]); | |
101 | Float_t A2=xyz[2]*xyz[2]/(xyz[0]*xyz[0]+xyz[1]*xyz[1]); | |
102 | Float_t Sroot=1./TMath::Sqrt(1.+A2); | |
103 | Int_t bin=h2f->FindBin(A2); | |
104 | Double_t binCenter = h2f->GetBinCenter(bin); | |
105 | Double_t binCenterval = 1./TMath::Sqrt(1.+binCenter); | |
106 | Float_t err=(Sroot*100./binCenterval); | |
107 | h1f->Fill(err); | |
108 | h2f->Fill(A2); | |
109 | //printf("%.3f %.3f %.3f\n",Sroot,binCenter,err); | |
110 | #endif | |
111 | //printf("%d %d %d %f %f %f %f %f %f\n",rr,pp,tt,xyz[0],xyz[1],xyz[2],rpe[0],rpe[1],rpe[2]); | |
112 | } | |
113 | } | |
114 | } | |
115 | #else /* do the extraction of the parameters */ | |
116 | AliL3Transform::Slice2Sector(slice,NRows[patch][0],sector,sector_row); | |
117 | ||
118 | Float_t ytabval=0; | |
119 | Int_t maxrow=NRows[patch][1]-NRows[patch][0]; | |
120 | Float_t padpitch=0; | |
121 | if(sector<AliL3Transform::GetNSectorLow()) | |
122 | padpitch=AliL3Transform::GetPadPitchWidthLow(); | |
123 | else | |
124 | padpitch=AliL3Transform::GetPadPitchWidthUp(); | |
125 | ||
126 | printf("MinRow: %d\nMaxRow: %d\n",0,maxrow); | |
127 | printf("YPadWidth: %.2f\n",padpitch); | |
128 | printf("ZSign: %d\n",slice < 18 ? 1:-1); | |
129 | printf("ZWidth: %.2f\n",AliL3Transform::GetZWidth()); | |
130 | printf("TimeWidth: %.2f\n\n",AliL3Transform::GetZWidth()); | |
131 | ||
132 | //calculating lookup tables for slice and patch! | |
133 | for(Int_t rr=NRows[patch][0];rr<=NRows[patch][1];rr++){ | |
134 | npads=AliL3Transform::GetNPads(rr); | |
135 | ||
136 | //Y(row,pad)=pad*padpitch-ytabval(row); | |
137 | ytabval=0.5*(npads-1)*padpitch; | |
138 | ||
139 | Xt[rr-NRows[patch][0]]=AliL3Transform::Row2X(rr); | |
140 | Yt[rr-NRows[patch][0]]=ytabval; | |
141 | //row in patch: X(row) Y_part(row) | |
142 | printf("Row: %d X: %.2f Y: %.2f\n",rr-NRows[patch][0],AliL3Transform::Row2X(rr),ytabval); | |
143 | } | |
144 | printf("\n\nVHDL-Output for LUT:\nX_table := ("); | |
145 | for(int i=0;i<maxrow-1;i++){ | |
146 | printf("%.2f, ",Xt[i]); | |
147 | } | |
148 | printf("%.2f);\n",Xt[maxrow-1]); | |
149 | printf("Y_table := ("); | |
150 | for(int i=0;i<maxrow-1;i++){ | |
151 | printf("%.2f, ",Yt[i]); | |
152 | } | |
153 | printf("%.2f);\n",Yt[maxrow-1]); | |
154 | #endif | |
155 | ||
156 | #ifdef DOTESTS | |
157 | #ifdef use_root | |
158 | h1f->Draw(); | |
159 | pad2->cd(); | |
160 | h2f->Draw(); | |
161 | c->Update(); | |
162 | ||
163 | theApp.Run(); | |
164 | #endif | |
165 | #endif | |
166 | ||
167 | exit(0); | |
168 | } | |
169 | ||
170 | //############################################################# | |
171 | ||
172 | #if 0 | |
173 | AliL3MemHandler file; //Does all the file/data handling | |
174 | ||
175 | //Open the data file: | |
176 | if(!file.SetBinaryInput(digitfile)) | |
177 | { | |
178 | cerr<<"Error opening file "<< digitfile <<endl; | |
179 | return -1; | |
180 | } | |
181 | ||
182 | //Store the data in memory, and get the pointer to it: | |
183 | unsigned int ndigits=0; | |
184 | AliL3DigitRowData *digits=0; | |
185 | digits=(AliL3DigitRowData*)file.CompBinary2Memory(ndigits); | |
186 | file.CloseBinaryInput(); | |
187 | ||
188 | /* | |
189 | for(Int_t r=0; r<31; r++) { | |
190 | UInt_t padrow=digits->fRow; | |
191 | AliL3DigitData *dPt = (AliL3DigitData*)digits->fDigitData; | |
192 | cout<<"padrow "<<padrow<<" ndigits "<<digits->fNDigit<<endl; | |
193 | ||
194 | for(Int_t d=0; d<digits->fNDigit; d++) { | |
195 | cout<<" padrow "<<padrow<<" pad "<<(int)dPt[d]->fPad<<" time " <<(int)dPt[d]->fTime<<" charge "<<(int)dPt[d]->fCharge<<endl; | |
196 | } | |
197 | file->UpdateRowPointer(digits); | |
198 | } | |
199 | return 100; | |
200 | */ | |
201 | ||
202 | digits=(AliL3DigitRowData*)file->GetDataPointer(ndigits); | |
203 | AliL3Transform transform; //Storing all detector-spesific quantities, needed by the clusterfinder. | |
204 | AliL3ClustFinderNew cf(&transform); //The cluster finder itself. | |
205 | ||
206 | //Switch off deconvolution: | |
207 | cf.SetDeconv(false); | |
208 | cf.SetXYError(0.2); | |
209 | cf.SetZError(0.3); | |
210 | ||
211 | //Init cluster finder | |
212 | cf.InitSlice(0,0,0,20,10000); | |
213 | ||
214 | //Give the data pointer to the cluster finder | |
215 | cf.Read(ndigits,digits); | |
216 | cout << digits << endl; | |
217 | //Start processing: | |
218 | cf.ProcessDigits(); | |
219 | ||
220 | /* | |
221 | int slice=1; | |
222 | a = new AliL3Hough(digitfile,kTRUE,n_eta_segments); | |
223 | ||
224 | a->ReadData(slice); | |
225 | ||
226 | a->Transform(); | |
227 | a->AddAllHistograms(); | |
228 | ||
229 | c1 = new TCanvas("c1","",2); | |
230 | a->GetTransformer(0)->GetHistogram(0)->Draw("box"); | |
231 | ||
232 | ||
233 | a->FindTrackCandidates(); | |
234 | //a->Evaluate(2); | |
235 | */ | |
236 | /* | |
237 | //Display the track: | |
238 | dhist = new AliL3Histogram("dhist","",250,0,250,250,-125,125); | |
239 | for(int i=0; i<6; i++) | |
240 | a->GetEval(i)->DisplayEtaSlice(0,dhist); | |
241 | c2 = new TCanvas("c2","",2); | |
242 | dhist->Draw(); | |
243 | */ | |
244 | ||
245 | //a->WriteTracks();//"../compression/"); | |
246 | ||
247 | /* | |
248 | tracks = (AliL3TrackArray*)a->GetTracks(0); | |
249 | ||
250 | float xyz[3]; | |
251 | int row=0; | |
252 | cout<<"Found "<<tracks->GetNTracks()<<" tracks"<<endl; | |
253 | for(int i=0; i<tracks->GetNTracks(); i++) | |
254 | { | |
255 | AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(i); | |
256 | if(!track) continue; | |
257 | //track->GetCrossingPoint(row,xyz); | |
258 | //transform->Local2Raw(xyz,1,row); | |
259 | //cout<<"Recon. pad "<<(int)xyz[1]<<" time "<<(int)xyz[2]<<endl; | |
260 | cout<<"Pt "<<track->GetPt()<<" phi "<<track->GetPhi0()<<" charge "<<track->GetCharge()<<" weigth "<<track->GetWeight()<<endl; | |
261 | } | |
262 | */ | |
263 | ||
264 | return; | |
265 | } | |
266 | ||
267 | #endif |