56 |
|
} |
57 |
|
|
58 |
|
template<class T> |
59 |
+ |
std::vector<TGraph*> PlotTools<T>::GetContours005(TH2*h, int ncont) |
60 |
+ |
{ |
61 |
+ |
double conts[1]; |
62 |
+ |
conts[0] = 0.05; |
63 |
+ |
if (!h) return std::vector<TGraph*>(); |
64 |
+ |
TH2 * plot = (TH2*)h->Clone(); |
65 |
+ |
plot->SetContour(1, conts); |
66 |
+ |
plot->SetFillColor(1); |
67 |
+ |
plot->Draw("CONT Z List"); |
68 |
+ |
gPad->Update(); |
69 |
+ |
TObjArray *contours = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours"); |
70 |
+ |
int ncontours = contours->GetSize(); |
71 |
+ |
std::vector<TGraph*> result; |
72 |
+ |
for (int i=0;i<ncontours;++i){ |
73 |
+ |
TList *list = (TList*)contours->At(i); |
74 |
+ |
TGraph* curv = (TGraph*)list->First(); |
75 |
+ |
if (curv) result.push_back( curv ); |
76 |
+ |
for(int j = 0; j < list->GetSize(); j++){ |
77 |
+ |
curv = (TGraph*)list->After(curv); // Get Next graph |
78 |
+ |
if (curv) result.push_back( curv ); |
79 |
+ |
} |
80 |
+ |
} |
81 |
+ |
delete plot; |
82 |
+ |
std::sort(result.begin(),result.end(),sort_TGraph()); |
83 |
+ |
return result; |
84 |
+ |
} |
85 |
+ |
|
86 |
+ |
template<class T> |
87 |
+ |
TGraph * PlotTools<T>::GetContour005(TH2*h, int ncont, int flag) |
88 |
+ |
{ |
89 |
+ |
return (TGraph*)GetContours005(h, ncont).at(flag)->Clone(); |
90 |
+ |
} |
91 |
+ |
|
92 |
+ |
template<class T> |
93 |
|
std::vector<TGraph*> PlotTools<T>::GetContours(TH2*h, int ncont) |
94 |
|
{ |
95 |
|
if (!h) return std::vector<TGraph*>(); |
134 |
|
} |
135 |
|
|
136 |
|
template<class T> |
137 |
+ |
TGraph * PlotTools<T>::GetContour005(TH2*h,double(*x)(const T*), double(*y)(const T*), |
138 |
+ |
double(*func)(const T*), int ncont, int flag, |
139 |
+ |
int color, int style){ |
140 |
+ |
TH2*hist = (TH2*)h->Clone(); |
141 |
+ |
Area(hist, x, y, func); |
142 |
+ |
TGraph * graph = GetContour005(hist, ncont, flag); |
143 |
+ |
graph->SetLineColor(color); |
144 |
+ |
graph->SetLineStyle(style); |
145 |
+ |
return graph; |
146 |
+ |
} |
147 |
+ |
|
148 |
+ |
template<class T> |
149 |
|
void PlotTools<T>::Print(double(*f)(const T*), double(*x)(const T*), double(*y)(const T*), TGraph*g, double p) |
150 |
|
{ |
151 |
|
for (typename std::vector<T*>::const_iterator it=_scan->begin();it!=_scan->end();++it){ |
242 |
|
gauss[i] /= sum; |
243 |
|
|
244 |
|
for (int i=0; i<g->GetN(); ++i){ |
245 |
< |
double av=0., x, x0, y; |
245 |
> |
double avy=0., avx=0., x, x0, y; |
246 |
|
int points=0; |
247 |
|
for (int j=i-N/2; j<=i+N/2; ++j){ |
248 |
|
if (j<0) old->GetPoint(0, x, y); |
249 |
|
else if (j>=g->GetN()) old->GetPoint(old->GetN()-1, x, y); |
250 |
|
else old->GetPoint(j, x, y); |
251 |
|
if (i==j) x0=x; |
252 |
< |
av += y * gauss[points]; |
252 |
> |
avy += y * gauss[points]; |
253 |
> |
avx += x * gauss[points]; |
254 |
|
++points; |
255 |
|
} |
256 |
< |
//g->SetPoint(i, x0, av/(double)points); |
257 |
< |
g->SetPoint(i, x0, av); |
256 |
> |
if (i-N/2<0 || i+N/2>=g->GetN()) g->SetPoint(i, x0, avy); |
257 |
> |
else g->SetPoint(i, avx, avy); |
258 |
|
} |
259 |
|
delete old; |
260 |
|
} |
261 |
|
|
262 |
|
|
263 |
+ |
void Smooth2D(TGraph * g, int N) |
264 |
+ |
{ |
265 |
+ |
//TGraph * old = (TGraph*)g->Clone(); |
266 |
+ |
TGraph * old = Close2D(g); |
267 |
+ |
//int N = (n%2==0?n+1:n); |
268 |
+ |
if (N>2*g->GetN()) N=2*g->GetN()-1; |
269 |
+ |
|
270 |
+ |
|
271 |
+ |
double gauss[N]; |
272 |
+ |
double sigma = (double)N/4.; |
273 |
+ |
double sum=0; |
274 |
+ |
double lim=(double)N/2.; |
275 |
+ |
TF1 *fb = new TF1("fb","gaus(0)",-lim,lim); |
276 |
+ |
fb->SetParameter(0, 1./(sqrt(2*3.1415)*sigma) ); |
277 |
+ |
fb->SetParameter(1, 0); |
278 |
+ |
fb->SetParameter(2, sigma); |
279 |
+ |
for (int i=0; i<N; ++i){ |
280 |
+ |
gauss[i]=fb->Integral(-lim+i,-lim+i+1); |
281 |
+ |
sum+=gauss[i]; |
282 |
+ |
} |
283 |
+ |
for (int i=0; i<N; ++i) |
284 |
+ |
gauss[i] /= sum; |
285 |
+ |
|
286 |
+ |
for (int i=0; i<g->GetN(); ++i){ |
287 |
+ |
double avy=0., avx=0, x, x0, y; |
288 |
+ |
int points=0; |
289 |
+ |
for (int j=i-N/2; j<=i+N/2; ++j){ |
290 |
+ |
//if (j<0) old->GetPoint(old->GetN()+j, x, y); |
291 |
+ |
//else if (j>=g->GetN()) old->GetPoint(j-old->GetN(), x, y); |
292 |
+ |
if (j<0) old->GetPoint(0, x, y); |
293 |
+ |
else if (j>=g->GetN()) old->GetPoint(old->GetN()-1, x, y); |
294 |
+ |
else old->GetPoint(j, x, y); |
295 |
+ |
if (i==j) x0=x; |
296 |
+ |
avy += y * gauss[points]; |
297 |
+ |
avx += x * gauss[points]; |
298 |
+ |
++points; |
299 |
+ |
} |
300 |
+ |
g->SetPoint(i, avx, avy); |
301 |
+ |
} |
302 |
+ |
delete old; |
303 |
+ |
} |
304 |
+ |
|
305 |
+ |
TGraph * Close2D(TGraph * g) |
306 |
+ |
{ |
307 |
+ |
double x, y; |
308 |
+ |
g->GetPoint(0,x,y); |
309 |
+ |
g->SetPoint(g->GetN(),x,y); |
310 |
+ |
|
311 |
+ |
int i=0; |
312 |
+ |
for (;i<g->GetN();++i){ |
313 |
+ |
g->GetPoint(i,x,y); |
314 |
+ |
if (x<450&&y<450) break; |
315 |
+ |
} |
316 |
+ |
int p=0; |
317 |
+ |
TGraph * f = new TGraph(0); |
318 |
+ |
for (int j=i+1;j!=i;++j){ |
319 |
+ |
if (j==g->GetN()) j=0; |
320 |
+ |
g->GetPoint(j,x,y); |
321 |
+ |
if (y<110+(x-120)*390/442||(x<330&&y<1000)||(x<500&&y<600)) continue; |
322 |
+ |
f->SetPoint(p++,x,y); |
323 |
+ |
} |
324 |
+ |
return f; |
325 |
+ |
} |
326 |
+ |
|
327 |
+ |
|
328 |
|
template class PlotTools<SusyScan>; |
329 |
|
template class PlotTools<GeneratorMasses>; |