5{
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 const double M_PI = 3.1415926;
23
24 TChain * trk = new TChain("trk");
25 trk->Add("hough_hist_test.root");
26
27 Int_t trk_run;
28 Int_t trk_evt;
29 Int_t trk_ntrk;
30 Int_t trk_trackId[100];
31 Int_t trk_nhop[100];
32 Int_t trk_nhot[100];
33 Double_t trk_dr[100];
34 Double_t trk_phi0[100];
35 Double_t trk_kappa[100];
36 Double_t trk_dz[100];
37 Double_t trk_tanl[100];
38 Double_t trk_Xc[100];
39 Double_t trk_Yc[100];
40 Double_t trk_R[100];
41 Double_t trk_p[100];
42 Double_t trk_pt[100];
43 Double_t trk_px[100];
44 Double_t trk_py[100];
45 Double_t trk_pz[100];
46 Int_t trk_q[100];
47 Double_t trk_truth_dr[100];
48 Double_t trk_truth_phi0[100];
49 Double_t trk_truth_kappa[100];
50 Double_t trk_truth_dz[100];
51 Double_t trk_truth_tanl[100];
52 Double_t trk_truth_Xc[100];
53 Double_t trk_truth_Yc[100];
54 Double_t trk_truth_R[100];
55 Double_t trk_truth_cosTheta[100];
56 Double_t trk_truth_p[100];
57 Double_t trk_truth_pt[100];
58 Double_t trk_truth_px[100];
59 Double_t trk_truth_py[100];
60 Double_t trk_truth_pz[100];
61 Int_t trk_truth_q[100];
62
63
64 trk->SetBranchAddress("trk_run",&trk_run);
65 trk->SetBranchAddress("trk_evt",&trk_evt);
66 trk->SetBranchAddress("trk_ntrk",&trk_ntrk);
67 trk->SetBranchAddress("trk_trackId",trk_trackId);
68 trk->SetBranchAddress("trk_nhop",trk_nhop);
69 trk->SetBranchAddress("trk_nhot",trk_nhot);
70 trk->SetBranchAddress("trk_dr",trk_dr);
71 trk->SetBranchAddress("trk_phi0",trk_phi0);
72 trk->SetBranchAddress("trk_kappa",trk_kappa);
73 trk->SetBranchAddress("trk_dz",trk_dz);
74 trk->SetBranchAddress("trk_tanl",trk_tanl);
75 trk->SetBranchAddress("trk_Xc",trk_Xc);
76 trk->SetBranchAddress("trk_Yc",trk_Yc);
77 trk->SetBranchAddress("trk_R",trk_R);
78 trk->SetBranchAddress("trk_p",trk_p);
79 trk->SetBranchAddress("trk_pt",trk_pt);
80 trk->SetBranchAddress("trk_px",trk_px);
81 trk->SetBranchAddress("trk_py",trk_py);
82 trk->SetBranchAddress("trk_pz",trk_pz);
83 trk->SetBranchAddress("trk_q",trk_q);
84 trk->SetBranchAddress("trk_truth_dr",trk_truth_dr);
85 trk->SetBranchAddress("trk_truth_phi0",trk_truth_phi0);
86 trk->SetBranchAddress("trk_truth_kappa",trk_truth_kappa);
87 trk->SetBranchAddress("trk_truth_dz",trk_truth_dz);
88 trk->SetBranchAddress("trk_truth_tanl",trk_truth_tanl);
89 trk->SetBranchAddress("trk_truth_Xc",trk_truth_Xc);
90 trk->SetBranchAddress("trk_truth_Yc",trk_truth_Yc);
91 trk->SetBranchAddress("trk_truth_R",trk_truth_R);
92 trk->SetBranchAddress("trk_truth_cosTheta",trk_truth_cosTheta);
93 trk->SetBranchAddress("trk_truth_p",trk_truth_p);
94 trk->SetBranchAddress("trk_truth_pt",trk_truth_pt);
95 trk->SetBranchAddress("trk_truth_px",trk_truth_px);
96 trk->SetBranchAddress("trk_truth_py",trk_truth_py);
97 trk->SetBranchAddress("trk_truth_pz",trk_truth_pz);
98 trk->SetBranchAddress("trk_truth_q",trk_truth_q);
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 gStyle->SetOptFit(0111);
123 TChain * hit = new TChain("hit");
124 hit->Add("hough_hist_test.root");
125
126 Int_t hit_run;
127 Int_t hit_evt;
128 Int_t hit_nhit;
129 Int_t hit_hitid[1000];
130 Int_t hit_layer[1000];
131 Int_t hit_wire[1000];
132 Double_t hit_x[1000];
133 Double_t hit_y[1000];
134 Double_t hit_z[1000];
135 Double_t hit_driftdist[1000];
136 Double_t hit_drifttime[10000];
137 Int_t hit_flag[1000];
138 Double_t hit_truth_x[1000];
139 Double_t hit_truth_y[1000];
140 Double_t hit_truth_z[1000];
141 Double_t hit_truth_drift[1000];
142 Int_t hit_truth_ambig[1000];
143
144
145 hit->SetBranchAddress("hit_run",&hit_run);
146 hit->SetBranchAddress("hit_evt",&hit_evt);
147 hit->SetBranchAddress("hit_nhit",&hit_nhit);
148 hit->SetBranchAddress("hit_hitid",hit_hitid);
149 hit->SetBranchAddress("hit_layer",hit_layer);
150 hit->SetBranchAddress("hit_wire",hit_wire);
151 hit->SetBranchAddress("hit_x",hit_x);
152 hit->SetBranchAddress("hit_y",hit_y);
153 hit->SetBranchAddress("hit_z",hit_z);
154 hit->SetBranchAddress("hit_driftdist",hit_driftdist);
155 hit->SetBranchAddress("hit_drifttime",hit_drifttime);
156 hit->SetBranchAddress("hit_flag",hit_flag);
157 hit->SetBranchAddress("hit_truth_x",hit_truth_x);
158 hit->SetBranchAddress("hit_truth_y",hit_truth_y);
159 hit->SetBranchAddress("hit_truth_z",hit_truth_z);
160 hit->SetBranchAddress("hit_truth_drift",hit_truth_drift);
161 hit->SetBranchAddress("hit_truth_ambig",hit_truth_ambig);
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185 TFile* f = TFile::Open("hough_hist_test.root");
186 TChain * hot = new TChain("hot");
187 hot->Add("hough_hist_test.root");
188
189 Int_t hot_run;
190 Int_t hot_evt;
191 Int_t hot_trk;
192 Int_t hot_nhot;
193 Int_t hot_hitid[1000];
194 Int_t hot_layer[1000];
195 Int_t hot_wire[1000];
196 Double_t hot_x[1000];
197 Double_t hot_y[1000];
198 Double_t hot_z[1000];
199 Double_t hot_drift[1000];
200 Int_t hot_flag[1000];
201 Double_t hot_deltaD[1000];
202 Double_t hot_truth_x[1000];
203 Double_t hot_truth_y[1000];
204 Double_t hot_truth_z[1000];
205 Double_t hot_truth_drift[1000];
206 Int_t hot_truth_ambig[1000];
207
208
209 hot->SetBranchAddress("hot_run",&hot_run);
210 hot->SetBranchAddress("hot_evt",&hot_evt);
211 hot->SetBranchAddress("hot_trk",&hot_trk);
212 hot->SetBranchAddress("hot_nhot",&hot_nhot);
213 hot->SetBranchAddress("hot_hitid",hot_hitid);
214 hot->SetBranchAddress("hot_layer",hot_layer);
215 hot->SetBranchAddress("hot_wire",hot_wire);
216 hot->SetBranchAddress("hot_x",hot_x);
217 hot->SetBranchAddress("hot_y",hot_y);
218 hot->SetBranchAddress("hot_z",hot_z);
219 hot->SetBranchAddress("hot_drift",hot_drift);
220 hot->SetBranchAddress("hot_flag",hot_flag);
221 hot->SetBranchAddress("hot_deltaD",hot_deltaD);
222 hot->SetBranchAddress("hot_truth_x",hot_truth_x);
223 hot->SetBranchAddress("hot_truth_y",hot_truth_y);
224 hot->SetBranchAddress("hot_truth_z",hot_truth_z);
225 hot->SetBranchAddress("hot_truth_drift",hot_truth_drift);
226 hot->SetBranchAddress("hot_truth_ambig",hot_truth_ambig);
227
228
229
230
231
232 Long64_t
nentries = trk->GetEntries();
233 Long64_t nbytes = 0;
234 int event =0 ;
235
236
237 for (Long64_t i=event; i<event+1;i++)
238 {
239 nbytes += trk->GetEntry(i);
240 cout<<trk_evt<<" "<<trk_ntrk<<endl;
241 for(int j=0;j<trk_ntrk;j++){
242 TAxis *x_axis,*y_axis;
243 stringstream ssname;
244 string sname;
245 const char * name;
246 int ibin = 0;
247 int nbin =1000 ;
248 while(nbin <= 1000){
249 int x_bin = nbin;
250 int y_bin = nbin;
252 double y_max = 0.1;
253
254
255 Long64_t
nentries = hit->GetEntries();
256 Long64_t nbytes = 0;
257 for (Long64_t ii=0; ii<
nentries;ii++)
258
259
260 {
261 nbytes += hit->GetEntry(ii);
262 if(hit_evt!=trk_evt)continue;
263 TH2D* hough = new TH2D("hough","hough",x_bin,0,x_max,y_bin,-y_max,y_max);
264 TH2D *houghhit[1000];
265 int nhit(0),ihit(0);
266
267 for(int jj=0;jj<hit_nhit;jj++){
268 if(hit_flag[jj] !=0)continue;
269 nhit++;
270
271
272
273 ssname.str("");
274 ssname <<"layer:"<<hit_layer[jj]<<" ,wire"<<hit_wire[jj];
275 sname = ssname.str();
276 name = sname.c_str();
277 houghhit[ihit] = new TH2D(name,name,x_bin,0,x_max,y_bin,-y_max,y_max);
278 fill_histogram(hit_x[jj],hit_y[jj],hit_driftdist[jj],x_bin*2,houghhit[ihit]);
279 hough->Add(houghhit[ihit]);
280 ihit++;
281 }
282
283
284
285
286
287
288
289
290 int binx,biny,binz;
291 hough->GetMaximumBin(binx,biny,binz);
292 double theta = hough->GetXaxis()->GetBinCenter(binx);
293 double rho = hough->GetYaxis()->GetBinCenter(biny);
294 double t = trk_phi0[j];
295 double r = trk_kappa[j]/333.567;
297 else r=-r;
298
299 cout<<
" rec: "<<
t<<setw(15)<<r<<endl;
300 cout<<" map: "<<theta<<setw(15)<<rho<<endl;
301 double dtheta = fabs(theta-
t);
302 double drho = fabs(rho-r);
303 double theta_bin =
M_PI/100.;
304 double rho_bin = 0.1/100.;
305 cout<<"diff: "<<dtheta<<setw(15)<<drho<<endl;
306 cout<<"nbin: "<<dtheta/theta_bin<<setw(15)<<drho/rho_bin<<endl;
307 cout<<
"rec bin: "<<
t/theta_bin<<setw(15)<<r/rho_bin<<endl;
308 cout<<"map bin: "<<theta/theta_bin<<setw(15)<<rho/rho_bin<<endl;
309 cout<<endl;
310
311
312
313 for(int ihit=0;ihit<nhit;ihit++){
314
315 delete houghhit[ihit];
316 }
317 double Xc =
cos(theta)/rho;
318 double Yc =
sin(theta)/rho;
319 double Rc = 1./fabs(rho);
320 double d0 = sqrt( Xc*Xc + Yc*Yc )-Rc;
321 double phi0 = atan2(Yc,Xc)+
M_PI/2.;
322 double omega = 1/Rc;
323 double dr = -d0;
326 while(phi0<0)phi0+=2*
M_PI;
327 double kappa = -omega*333.567;
328
329 cout<<hit_evt<<" "<<Xc<<" "<<Yc<<" "<<Rc<<endl;
330 cout<<trk_evt<<" "<<trk_Xc[j]<<" "<<trk_Yc[j]<<" "<<trk_R[j]<<endl;
331 double deltaD(0);
332 for(int jj=0;jj<hit_nhit;jj++){
333 if(hit_flag[jj] !=0)continue;
334 if(hit_layer[jj] <3){
335 double r_cgem = sqrt(hit_x[jj]*hit_x[jj]+hit_y[jj]*hit_y[jj]);
337 double phih_cluster = atan2(hit_y[jj],hit_x[jj]);
338 double dphi = phih_cluster - phi_cross;
341 deltaD = r_cgem*dphi;
342 }else{
343 double l1l2 = sqrt((hit_x[jj]-Xc)*(hit_x[jj]-Xc)+(hit_y[jj]-Yc)*(hit_y[jj]-Yc));
344 if(l1l2>Rc)deltaD = l1l2-Rc-hit_driftdist[jj];
345 else deltaD = l1l2-Rc+hit_driftdist[jj];
346 }
347 {
348 Long64_t
nentries = hot->GetEntries();
349 Long64_t nbytes = 0;
350 for (Long64_t iii=0; iii<
nentries;iii++)
351
352
353 {
354 nbytes += hot->GetEntry(iii);
355 if(hot_evt!=hit_evt)continue;
356 for(int jjj=0;jjj<hot_nhot;jjj++){
357 if(hot_flag[jjj] !=0)continue;
358 if(hot_layer[jjj]==hit_layer[jj]&&hot_wire[jjj]==hit_wire[jj]&&hot_hitid[jjj]==hit_hitid[jj]){
359 cout<<setw(5)<<hot_layer[jjj]<<setw(15)<<deltaD<<setw(15)<<hot_deltaD[jjj]<<setw(15)<<deltaD-hot_deltaD[jjj]<<endl;
360 }
361
362
363 }
364 }
365 }
366 }
367
368 delete hough;
369 }
371 if(nbin<500)
bin = 50;
372 else if(nbin<1000)
bin =100;
373 else if(nbin<2000)
bin =100;
374 else if(nbin<5000)
bin =500;
377 ibin++;
378 }
379 }
380 cout<<endl;
381 }
382}
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
double sin(const BesAngle a)
double cos(const BesAngle a)
void fill_histogram(double x, double y, double r, int nbin, TH2D *hough)
double intersect_cylinder(int charge, double x_center, double y_center, double r_cylinder)