4 |
|
|
5 |
|
#include <cmath> |
6 |
|
#include <algorithm> |
7 |
+ |
#include <iostream> |
8 |
|
|
9 |
|
#include "TGraph.h" |
10 |
|
#include "TH2.h" |
41 |
|
} |
42 |
|
|
43 |
|
template<class T> |
44 |
+ |
void PlotTools<T>::Graph( TGraph*g, double(*x)(const T*), double(*y)(const T*),double ymin) |
45 |
+ |
{ |
46 |
+ |
unsigned i = g->GetN(); |
47 |
+ |
std::sort(_scan->begin(),_scan->end(),sort_by(x)); |
48 |
+ |
for (typename std::vector<T*>::const_iterator it=_scan->begin();it!=_scan->end();++it){ |
49 |
+ |
if (y(*it)>=ymin) g->SetPoint(i++, x(*it), y(*it)); |
50 |
+ |
//std::cout << i << ": x="<<x(*it)<< ", y="<<y(*it)<< std::endl; |
51 |
+ |
} |
52 |
+ |
} |
53 |
+ |
|
54 |
+ |
template<class T> |
55 |
|
std::vector<TGraph*> PlotTools<T>::GetContours(TH2*h, int ncont) |
56 |
|
{ |
57 |
|
if (!h) return std::vector<TGraph*>(); |
58 |
|
TH2 * plot = (TH2*)h->Clone(); |
59 |
|
plot->SetContour(ncont); |
48 |
– |
|
60 |
|
plot->SetFillColor(1); |
61 |
|
plot->Draw("CONT Z List"); |
62 |
|
gPad->Update(); |
63 |
|
TObjArray *contours = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours"); |
64 |
|
int ncontours = contours->GetSize(); |
54 |
– |
//std::cout << "N contours = " << ncontours << std::endl; |
65 |
|
std::vector<TGraph*> result; |
66 |
|
for (int i=0;i<ncontours;++i){ |
67 |
|
TList *list = (TList*)contours->At(i); |
73 |
|
} |
74 |
|
} |
75 |
|
delete plot; |
76 |
+ |
std::sort(result.begin(),result.end(),sort_TGraph()); |
77 |
|
return result; |
78 |
|
} |
79 |
|
|
83 |
|
return (TGraph*)GetContours(h, ncont).at(flag)->Clone(); |
84 |
|
} |
85 |
|
|
75 |
– |
/* |
86 |
|
template<class T> |
87 |
< |
TGraph * PlotTools<T>::GetContour(TH2*h, int ncont, int flag) |
88 |
< |
{ |
89 |
< |
if (!h) return 0; |
80 |
< |
TH2 * plot = (TH2*)h->Clone(); |
81 |
< |
plot->SetContour(ncont); |
82 |
< |
plot->SetFillColor(1); |
83 |
< |
plot->Draw("CONT Z List"); |
84 |
< |
gPad->Update(); |
85 |
< |
TObjArray *contours = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours"); |
86 |
< |
int ncontours = contours->GetSize(); |
87 |
< |
TList *list = 0; |
88 |
< |
TGraph *gr1 = 0; |
89 |
< |
if (flag<ncontours) list = (TList*)contours->At(flag); |
90 |
< |
if (list) gr1 = (TGraph*)list->First()->Clone(); |
91 |
< |
if (gr1) gr1->SetLineWidth(2); |
92 |
< |
if (plot) delete plot; |
93 |
< |
//don't delete contours or list: These belongs to gROOT !!! |
94 |
< |
return gr1; |
87 |
> |
bool PlotTools<T>::sort_TGraph::operator()(const TGraph*g1, const TGraph*g2) |
88 |
> |
{ |
89 |
> |
return g1->GetN() > g2->GetN(); |
90 |
|
} |
91 |
< |
*/ |
91 |
> |
|
92 |
|
|
93 |
|
template class PlotTools<SusyScan>; |
94 |
|
template class PlotTools<GeneratorMasses>; |