3 const double M_PI = 3.1415926;
14 gStyle->SetOptFit(0111);
15 TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(
"hough_hist_test.root");
17 f =
new TFile(
"hough_hist_test.root");
20 f->GetObject(
"hit",tree);
26 Int_t hit_hitid[1000];
27 Int_t hit_layer[1000];
32 Double_t hit_driftdist[10000];
33 Double_t hit_drifttime[10000];
35 Double_t hit_truth_x[1000];
36 Double_t hit_truth_y[1000];
37 Double_t hit_truth_z[1000];
38 Double_t hit_truth_drift[1000];
39 Int_t hit_truth_ambig[1000];
42 hit->SetBranchAddress(
"hit_run",&hit_run);
43 hit->SetBranchAddress(
"hit_evt",&hit_evt);
44 hit->SetBranchAddress(
"hit_nhit",&hit_nhit);
45 hit->SetBranchAddress(
"hit_hitid",hit_hitid);
46 hit->SetBranchAddress(
"hit_layer",hit_layer);
47 hit->SetBranchAddress(
"hit_wire",hit_wire);
48 hit->SetBranchAddress(
"hit_x",hit_x);
49 hit->SetBranchAddress(
"hit_y",hit_y);
50 hit->SetBranchAddress(
"hit_z",hit_z);
51 hit->SetBranchAddress(
"hit_driftdist",hit_driftdist);
52 hit->SetBranchAddress(
"hit_drifttime",hit_drifttime);
53 hit->SetBranchAddress(
"hit_flag",hit_flag);
54 hit->SetBranchAddress(
"hit_truth_x",hit_truth_x);
55 hit->SetBranchAddress(
"hit_truth_y",hit_truth_y);
56 hit->SetBranchAddress(
"hit_truth_z",hit_truth_z);
57 hit->SetBranchAddress(
"hit_truth_drift",hit_truth_drift);
58 hit->SetBranchAddress(
"hit_truth_ambig",hit_truth_ambig);
65 TAxis *x_axis,*y_axis;
79 ssname <<nbin<<
"bin, all layers";
86 Long64_t
nentries = hit->GetEntries();
90 for (Long64_t i=event; i<
event+1;i++)
92 nbytes += hit->GetEntry(i);
93 TH2D* hough =
new TH2D(
"hough",
"hough",x_bin,0,x_max,y_bin,-y_max,y_max);
97 for(
int j=0;j<hit_nhit;j++){
98 if(hit_flag[j] !=0)
continue;
104 ssname <<
"layer:"<<hit_layer[j]<<
" ,wire"<<hit_wire[j];
105 sname = ssname.str();
106 name = sname.c_str();
107 houghhit[ihit] =
new TH2D(name,name,x_bin,0,x_max,y_bin,-y_max,y_max);
108 fill_histogram(hit_x[j],hit_y[j],hit_driftdist[j],x_bin*2,houghhit[ihit]);
109 hough->Add(houghhit[ihit]);
117 TCanvas *c_map =
new TCanvas(
"houghspace",
"houghspace",1000,500 );
122 hough->Draw(
"LEGO2Z");
124 ssname <<
"hough_map.png";
125 sname = ssname.str();
126 name = sname.c_str();
129 ssname <<
"hough_map.pdf";
130 sname = ssname.str();
131 name = sname.c_str();
134 ssname <<
"hough_map.eps";
135 sname = ssname.str();
136 name = sname.c_str();
140 hough->GetMaximumBin(binx,biny,binz);
141 double theta = hough->GetXaxis()->GetBinCenter(binx);
142 double rho = hough->GetYaxis()->GetBinCenter(biny);
145 double Rc = 1./fabs(rho);
146 double Xc =
cos(theta)/rho;
147 double Yc =
sin(theta)/rho;
148 cout<<Xc<<
" "<<Yc<<endl;
149 double x1(999),y1(999),x2(-999),y2(-999);
151 for(
int j=0;j<hit_nhit;j++){
152 if(hit_flag[j] !=0)
continue;
153 x1 = hit_x[j] < x1 ? hit_x[j] : x1;
154 y1 = hit_y[j] < y1 ? hit_y[j] : y1;
155 x2 = hit_x[j] > x2 ? hit_x[j] : x2;
156 y2 = hit_y[j] > y2 ? hit_y[j] : y2;
157 double alpha =
M_PI-atan2(hit_y[j]-Yc,hit_x[j]-Xc)+atan2(Yc,Xc);
164 TEllipse *e =
new TEllipse(Xc,Yc,Rc,Rc);
167 TGraph *gr_xy =
new TGraph();
168 TGraph *gr_MC =
new TGraph();
169 TGraph *gr_O =
new TGraph();
170 TGraph *gr_C =
new TGraph();
171 gr_O->SetPoint(0,0,0);
172 gr_C->SetPoint(0,Xc,Yc);
176 for(
int j=0;j<hit_nhit;j++){
177 if(hit_flag[j] !=0)
continue;
178 gr_xy->SetPoint(point,hit_x[j],hit_y[j]);
179 gr_MC->SetPoint(point,hit_truth_x[j],hit_truth_y[j]);
191 ssname <<
"event "<<i;
192 sname = ssname.str();
193 name = sname.c_str();
194 TCanvas *c_xy =
new TCanvas(name,name,1000,1000 );
195 gr_xy->Draw(
"APsame");
196 double x_min(-81),x_max(81),y_min(-81),y_max(81);
198 double scale = (x2-x1)>(y2-y1)?(x2-x1):(y2-y1);
199 x_min = (x2+x1)/2.-scale*0.6;
200 x_max = (x2+x1)/2.+scale*0.6;
201 y_min = (y2+y1)/2.-scale*0.6;
202 y_max = (y2+y1)/2.+scale*0.6;
211 gr_xy->GetXaxis()->SetLimits(x_min,x_max);
212 gr_xy->SetMinimum(y_min);
213 gr_xy->SetMaximum(y_max);
214 gr_xy->SetMarkerStyle(5 );
215 gr_xy->SetMarkerSize(0.7);
216 gr_xy->SetMarkerColor(1);
217 gr_MC->Draw(
"Psame");
218 gr_MC->SetMarkerStyle(20);
219 gr_MC->SetMarkerSize(0.7);
220 gr_MC->SetMarkerColor(2);
222 gr_O->SetMarkerStyle(21);
223 gr_O->SetMarkerSize(1.5);
224 gr_O->SetMarkerColor(1);
226 gr_C->SetMarkerStyle(20);
227 gr_C->SetMarkerSize(1.5);
228 gr_C->SetMarkerColor(1);
232 for(
int j=0;j<hit_nhit;j++){
233 if(hit_flag[j] !=0)
continue;
234 TEllipse *exy =
new TEllipse(hit_x[j],hit_y[j],hit_driftdist[j],hit_driftdist[j]);
236 exy->SetFillStyle(0);
239 for(
int ihit=0;ihit<nhit;ihit++){
244 ssname <<
"2d_track.eps";
245 sname = ssname.str();
246 name = sname.c_str();
249 ssname <<
"2d_track.pdf";
250 sname = ssname.str();
251 name = sname.c_str();
254 ssname <<
"2d_track.png";
255 sname = ssname.str();
256 name = sname.c_str();
258 TGraph *gr_uv=
new TGraph();
260 for(
int j=0;j<hit_nhit;j++){
261 if(hit_flag[j] !=0)
continue;
262 double u= 2*hit_x[j]/(hit_x[j]*hit_x[j]+hit_y[j]*hit_y[j]-hit_driftdist[j]*hit_driftdist[j]);
263 double v= 2*hit_y[j]/(hit_x[j]*hit_x[j]+hit_y[j]*hit_y[j]-hit_driftdist[j]*hit_driftdist[j]);
264 double w= 2*hit_driftdist[j]/(hit_x[j]*hit_x[j]+hit_y[j]*hit_y[j]-hit_driftdist[j]*hit_driftdist[j]);
265 gr_uv->SetPoint(point,u,
v);
273 sname = ssname.str();
274 name = sname.c_str();
275 TCanvas *c_uv =
new TCanvas(name,name,1000,1000 );
276 gr_uv->Draw(
"APsame");
277 for(
int j=0;j<hit_nhit;j++){
278 if(hit_flag[j] !=0)
continue;
279 double u= 2*hit_x[j]/(hit_x[j]*hit_x[j]+hit_y[j]*hit_y[j]-hit_driftdist[j]*hit_driftdist[j]);
280 double v= 2*hit_y[j]/(hit_x[j]*hit_x[j]+hit_y[j]*hit_y[j]-hit_driftdist[j]*hit_driftdist[j]);
281 double w= 2*hit_driftdist[j]/(hit_x[j]*hit_x[j]+hit_y[j]*hit_y[j]-hit_driftdist[j]*hit_driftdist[j]);
283 TEllipse *euv =
new TEllipse(u,
v,w,w);
285 euv->SetFillStyle(0);
424 if(nbin<500)
bin = 50;
425 else if(nbin<1000)
bin =100;
426 else if(nbin<2000)
bin =100;
427 else if(nbin<5000)
bin =500;
479 const double M_PI = 3.1415926;
481 double phi_center = atan2(y_center,x_center);
482 double r_center = sqrt(x_center*x_center+y_center*y_center);
483 if(charge==0)
return 9999;
484 while(phi_center<0) phi_center += 2*
M_PI;
485 while(phi_center>2*
M_PI) phi_center -= 2*
M_PI;
486 if(r_center<r_cylinder/2)
return -9999;
487 double dphi = acos( r_cylinder/(2*r_center) );
488 if(charge<0) phi = phi_center + dphi;
489 else phi = phi_center - dphi;
490 while(phi<0) phi += 2*
M_PI;
497 const double M_PI = 3.1415926;
498 double U = 2*
x/(
x*
x+y*y-r*r);
499 double V = 2*y/(
x*
x+y*y-r*r);
500 double R = 2*r/(
x*
x+y*y-r*r);
501 double delta_phi = 2.*
M_PI/nbin;
502 double phi = -delta_phi/2;
503 for(
int i =0; i<nbin; i++){
505 double u = U + R*
cos(phi);
506 double v = V + R*
sin(phi);
507 double normal = (
v-V)/(u-U);
508 double k = -1./normal;
510 double x_cross = -b/(k+1/k);
511 double y_cross = b/(1+k*k);
513 double rho=sqrt(x_cross*x_cross+y_cross*y_cross);
514 double theta=atan2(y_cross,x_cross);
515 double slantOfLine = V*
cos(theta)-U*
sin(theta);
516 int chargeOfHitOnCir = (slantOfLine/fabs(slantOfLine)) * (rho/fabs(rho));
517 if( chargeOfHitOnCir == -1)
continue;
523 if( normal ==0 &&
x>0) {
527 if( normal ==0 &&
x<0) {
531 if(fabs(rho)>0.1)
continue;
532 hough->Fill(theta,rho);
*******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)
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
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)