20 double M_PI = 3.1415926;
38 TChain * hit =
new TChain(
"hit");
39 hit->Add(
"hough_hist_test.root");
44 Int_t hit_hitid[1000];
45 Int_t hit_layer[1000];
50 Double_t hit_driftdist[1000];
51 Double_t hit_drifttime[10000];
53 Double_t hit_truth_x[1000];
54 Double_t hit_truth_y[1000];
55 Double_t hit_truth_z[1000];
56 Double_t hit_truth_drift[1000];
57 Int_t hit_truth_ambig[1000];
60 hit->SetBranchAddress(
"hit_run",&hit_run);
61 hit->SetBranchAddress(
"hit_evt",&hit_evt);
62 hit->SetBranchAddress(
"hit_nhit",&hit_nhit);
63 hit->SetBranchAddress(
"hit_hitid",hit_hitid);
64 hit->SetBranchAddress(
"hit_layer",hit_layer);
65 hit->SetBranchAddress(
"hit_wire",hit_wire);
66 hit->SetBranchAddress(
"hit_x",hit_x);
67 hit->SetBranchAddress(
"hit_y",hit_y);
68 hit->SetBranchAddress(
"hit_z",hit_z);
69 hit->SetBranchAddress(
"hit_driftdist",hit_driftdist);
70 hit->SetBranchAddress(
"hit_drifttime",hit_drifttime);
71 hit->SetBranchAddress(
"hit_flag",hit_flag);
72 hit->SetBranchAddress(
"hit_truth_x",hit_truth_x);
73 hit->SetBranchAddress(
"hit_truth_y",hit_truth_y);
74 hit->SetBranchAddress(
"hit_truth_z",hit_truth_z);
75 hit->SetBranchAddress(
"hit_truth_drift",hit_truth_drift);
76 hit->SetBranchAddress(
"hit_truth_ambig",hit_truth_ambig);
83 TAxis *x_axis,*y_axis;
87 double peak_rate_mean = 0;
88 double peak_height_rate_mean = 0;
89 double peak_rate_RMS = 0;
90 double peak_height_rate_RMS = 0;
91 TGraphErrors *gr_peak_rate_mean =
new TGraphErrors();
92 TGraphErrors *gr_peak_height_rate_mean =
new TGraphErrors();
100 TH1D *h_peak_rate =
new TH1D(
"peak_rate",
"peak_rate", 40,0,2.0);
101 TH1D *h_peak_height_rate =
new TH1D(
"peak_height_rate",
"peak_height_rate", 40,0,2.0);
102 TH1D *h_layersOnPeak =
new TH1D(
"layersOnPeak",
"layersOnPeak",50,0,50);
103 TH1D *h_layersOfEvent =
new TH1D(
"layersOfEvent",
"layersOfEvent",50,0,50);
105 Long64_t
nentries = hit->GetEntries();
112 nbytes += hit->GetEntry(i);
113 TH2D* hough =
new TH2D(
"hough",
"hough",x_bin,0,x_max,y_bin,-y_max,y_max);
115 int layersOnPeak[100];
117 for(
int j=0;j<hit_nhit;j++){
118 if(hit_flag[j] !=0)
continue;
124 ssname <<
"layer:"<<hit_layer[j]<<
" ,wire"<<hit_wire[j];
125 sname = ssname.str();
126 name = sname.c_str();
127 layersOnPeak[ihit] = hit_layer[j];
128 houghhit[ihit] =
new TH2D(name,name,x_bin,0,x_max,y_bin,-y_max,y_max);
129 fill_histogram(hit_x[j],hit_y[j],hit_driftdist[j],x_bin*2,houghhit[ihit]);
130 hough->Add(houghhit[ihit]);
132 h_layersOfEvent->Fill(hit_layer[j]);
135 hough->GetMaximumBin(binx,biny,binz);
136 int height = hough->GetBinContent(binx,biny);
143 for(
int ihit=0;ihit<nhit;ihit++){
151 if(houghhit[ihit]->GetBinContent(binx,biny)>0){
153 h_layersOnPeak->Fill(layersOnPeak[ihit]);
157 delete houghhit[ihit];
160 double peak_rate = (double)nhot/(
double)nhit;
161 double peak_height_rate = (double)height/(
double)nhit;
162 h_peak_rate->Fill(peak_rate);
163 h_peak_height_rate->Fill(peak_height_rate);
179 ssname <<x_bin<<
"bins_layersOnPeak";
180 sname = ssname.str();
181 name = sname.c_str();
182 TCanvas *c2 =
new TCanvas(name,name,700,500 );
183 h_layersOnPeak->Draw(
"same");
184 h_layersOnPeak->SetLineColor(4);
185 x_axis = h_layersOnPeak->GetXaxis();
186 y_axis = h_layersOnPeak->GetYaxis();
187 x_axis->SetTitle(
"Layer");
188 x_axis->CenterTitle();
189 y_axis->SetTitle(
"Entries");
190 y_axis->CenterTitle();
191 yMax = h_layersOnPeak->GetMaximum() > h_layersOfEvent->GetMaximum()? h_layersOnPeak->GetMaximum():h_layersOfEvent->GetMaximum();
192 h_layersOnPeak->GetYaxis()->SetRangeUser(0,yMax*1.2);
193 h_layersOfEvent->Draw(
"same");
194 h_layersOfEvent->SetLineColor(2);
195 TLegend* leg2=
new TLegend(0.12 ,0.80,0.33,0.89);
196 leg2->AddEntry(h_layersOnPeak,
"hits on peak",
"l");
197 leg2->AddEntry(h_layersOfEvent,
"hits of event",
"l");
198 leg2->SetFillColor(kWhite);
199 leg2->SetLineColor(kWhite);
202 ssname <<x_bin<<
"bins_layersOnPeak"<<
".pdf";
203 sname = ssname.str();
204 name = sname.c_str();
207 ssname <<x_bin<<
"bins_layersOnPeak"<<
".eps";
208 sname = ssname.str();
209 name = sname.c_str();
212 ssname <<x_bin<<
"bins_layersOnPeak"<<
".png";
213 sname = ssname.str();
214 name = sname.c_str();
217 peak_rate_mean = h_peak_rate->GetMean();
218 peak_height_rate_mean = h_peak_height_rate->GetMean();
219 peak_rate_RMS = h_peak_rate->GetRMS();
220 peak_height_rate_RMS = h_peak_height_rate->GetRMS();
221 cout<<x_bin<<
" "<<peak_rate_mean<<
" "<<peak_rate_RMS<<
" "<<peak_height_rate_mean<<
" "<<peak_height_rate_RMS<<endl;
222 gr_peak_rate_mean->SetPoint(ibin,x_bin,peak_rate_mean);
223 gr_peak_rate_mean->SetPointError(ibin,0,peak_rate_RMS);
224 gr_peak_height_rate_mean->SetPoint(ibin,x_bin,peak_height_rate_mean);
225 gr_peak_height_rate_mean->SetPointError(ibin,0,peak_height_rate_RMS);
227 ssname <<x_bin<<
"bins_rate";
228 sname = ssname.str();
229 name = sname.c_str();
230 TCanvas *c3 =
new TCanvas(name,name,700,500 );
232 h_peak_height_rate->Draw(
"same");
233 h_peak_rate->SetLineColor(4);
234 h_peak_height_rate->SetLineColor(2);
235 x_axis = h_peak_rate->GetXaxis();
236 y_axis = h_peak_rate->GetYaxis();
238 x_axis->SetTitle(
"Rate");
239 x_axis->CenterTitle();
243 y_axis->SetTitle(
"Entries");
244 y_axis->CenterTitle();
248 yMax = h_peak_rate->GetMaximum() > h_peak_height_rate->GetMaximum()? h_peak_rate->GetMaximum():h_peak_height_rate->GetMaximum();
249 h_peak_rate->GetYaxis()->SetRangeUser(0,yMax*1.2);
250 TLegend* leg3=
new TLegend(0.12 ,0.80,0.33,0.89);
251 leg3->AddEntry(h_peak_rate,
"hit on peak",
"l");
252 leg3->AddEntry(h_peak_height_rate,
"peak height",
"l");
253 leg3->SetFillColor(kWhite);
254 leg3->SetLineColor(kWhite);
257 ssname <<x_bin<<
"bins_rate"<<
".pdf";
258 sname = ssname.str();
259 name = sname.c_str();
262 ssname <<x_bin<<
"bins_rate"<<
".eps";
263 sname = ssname.str();
264 name = sname.c_str();
267 ssname <<x_bin<<
"bins_rate"<<
".png";
268 sname = ssname.str();
269 name = sname.c_str();
271 delete h_layersOnPeak;
273 delete h_peak_height_rate;
276 if(nbin<500)
bin = 50;
277 else if(nbin<1000)
bin =100;
278 else if(nbin<2000)
bin =200;
279 else if(nbin<5000)
bin =500;
286 TCanvas *c4 =
new TCanvas(
"peak_rate_mean",
"peak_rate_mean",700,500 );
287 gr_peak_rate_mean->Draw(
"AP");
288 x_axis = gr_peak_rate_mean->GetXaxis();
289 y_axis = gr_peak_rate_mean->GetYaxis();
291 x_axis->SetTitle(
"nbin");
292 x_axis->CenterTitle();
296 y_axis->SetTitle(
"mean rate");
297 y_axis->CenterTitle();
301 gr_peak_rate_mean->SetMinimum(0.0);
302 gr_peak_rate_mean->SetMaximum(2.0);
303 gr_peak_rate_mean->SetMarkerSize(1.0);
304 gr_peak_rate_mean->SetMarkerStyle(24);
305 gr_peak_rate_mean->SetMarkerColor(4);
306 gr_peak_height_rate_mean->Draw(
"Psame");
307 gr_peak_height_rate_mean->SetMarkerSize(1.0);
308 gr_peak_height_rate_mean->SetMarkerStyle(24);
309 gr_peak_height_rate_mean->SetMarkerColor(2);
310 TLegend* leg4=
new TLegend(0.60 ,0.75,0.85,0.85);
311 leg4->SetFillColor(kWhite);
312 leg4->SetLineColor(kWhite);
313 leg4->AddEntry(gr_peak_rate_mean,
"hit on peak",
"p");
314 leg4->AddEntry(gr_peak_height_rate_mean,
"peak height",
"p");
317 c4->SaveAs(
"peak_rate_mean.eps");
318 c4->SaveAs(
"peak_rate_mean.png");
319 c4->SaveAs(
"peak_rate_mean.pdf");
326 double M_PI = 3.1415926;
327 double U = 2*
x/(
x*
x+y*y-r*r);
328 double V = 2*y/(
x*
x+y*y-r*r);
329 double R = 2*r/(
x*
x+y*y-r*r);
330 double delta_phi = 2.*
M_PI/nbin;
331 double phi = -delta_phi/2;
332 for(
int i =0; i<nbin; i++){
334 double u = U + R*
cos(phi);
335 double v = V + R*
sin(phi);
336 double normal = (
v-V)/(u-U);
337 double k = -1./normal;
339 double x_cross = -b/(k+1/k);
340 double y_cross = b/(1+k*k);
345 double rho=sqrt(x_cross*x_cross+y_cross*y_cross);
346 double theta=atan2(y_cross,x_cross);
351 if( normal ==0 &&
x>0) {
355 if( normal ==0 &&
x<0) {
359 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)