1 |
auterman |
1.1 |
#include "IsoMassLine.h"
|
2 |
|
|
#include "TGraph.h"
|
3 |
|
|
#include "SusyScan.h"
|
4 |
|
|
|
5 |
|
|
#include <cmath>
|
6 |
|
|
#include <algorithm>
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
class sort_by{
|
10 |
|
|
public:
|
11 |
|
|
sort_by(double(*x)(const SusyScan*)):_f(x){}
|
12 |
|
|
bool operator()(const SusyScan*a, const SusyScan*b){
|
13 |
|
|
return _f(a)<_f(b); }
|
14 |
|
|
private:
|
15 |
|
|
double(*_f)(const SusyScan*);
|
16 |
|
|
};
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
TGraph * IsoMassLine::get( double(*x)(const SusyScan*), double(*y)(const SusyScan*),
|
20 |
|
|
double(*func)(const SusyScan*), double mass, double diff )
|
21 |
|
|
{
|
22 |
|
|
TGraph * result = new TGraph(1);
|
23 |
|
|
std::sort(_scan->begin(),_scan->end(),sort_by(x));
|
24 |
|
|
int i=0;
|
25 |
|
|
for (std::vector<SusyScan*>::const_iterator it=_scan->begin();it!=_scan->end();++it){
|
26 |
|
|
if ( fabs(func( *it)-mass)<diff )
|
27 |
|
|
result->SetPoint(i++, x(*it), y(*it));
|
28 |
|
|
}
|
29 |
|
|
return result;
|
30 |
|
|
}
|