ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/auterman/SusyScan/PlotScript/PrintTools.h
Revision: 1.1
Committed: Wed Jun 22 15:11:53 2011 UTC (13 years, 10 months ago) by auterman
Content type: text/plain
Branch: MAIN
CVS Tags: JHEP2010, HEAD
Log Message:
2010 RA2 paper

File Contents

# User Rev Content
1 auterman 1.1 #ifndef PRINTTOOLS_H
2     #define PRINTTOOLS_H
3    
4     #include <vector>
5     #include <cmath>
6     #include "TGraph.h"
7    
8    
9     class SusyScan;
10     class TH2;
11    
12    
13     template<class T>
14     class PrintTools {
15     public:
16    
17     class Criteria{
18     public:
19     Criteria(double(*x)(const T*), double(*y)(const T*), TGraph* g, double r=0.):x_(x),y_(y),g_(g),r2_(r*r){}
20     Criteria(double(*x)(const T*), double v, double r=0.):x_(x),v_(v),r_(r){}
21     Criteria(double v, double r=0.):v_(v),r_(r){}
22     virtual ~Criteria(){}
23     virtual bool operator()(const T*t) const = 0;
24     virtual bool operator()(double x, double y) const = 0;
25    
26     protected:
27     bool deltaR_(const T*t) const {
28     for (int j=0; j<g_->GetN(); ++j) {
29     double gx, gy;
30     g_->GetPoint(j, gx, gy);
31     if ( (x_(t)-gx)*(x_(t)-gx) + (y_(t)-gy)*(y_(t)-gy) < r2_)
32     return true;
33     }
34     return false;
35     }
36     bool equal_(const T*t) const {
37     return std::abs( x_(t)-v_) < r_;
38     }
39     bool Xbinning_(double x) const {
40     return fmod(x,v_) < r_;
41     }
42    
43     private:
44     Criteria();
45     double (*x_)(const T*), (*y_)(const T*);
46     TGraph *g_;
47     double v_,r_,r2_;
48     };
49     class deltaR: public Criteria{
50     public:
51     deltaR(double(*x)(const T*), double(*y)(const T*), TGraph* g, double r=0.) : Criteria(x,y,g,r){}
52     bool operator()(const T*t) const { return deltaR_(t); }
53     bool operator()(double x, double y) const {return false;}
54     };
55     class equal: public Criteria{
56     public:
57     equal(double(*x)(const T*), double v, double r=0.) : Criteria(x,v,r){}
58     bool operator()(const T*t) const { return equal_(t); }
59     bool operator()(double x, double y) const {return false;}
60     };
61     class Xbinning: public Criteria{
62     public:
63     Xbinning(double v, double r) : Criteria(v,r){}
64     bool operator()(double x, double y) const { return Criteria::Xbinning_(x); }
65     bool operator()(const T*t) const { return false; }
66     };
67    
68    
69     PrintTools(std::vector<T*> * scan):_scan(scan){}
70    
71     void AddMatch(const Criteria*c){ crits_.push_back(c);};
72     void AddVar( double(*x)(const T*) ){ var_ .push_back(x);};
73    
74     void Print(double(*x)(const T*));
75     void Print(const TGraph *g,const std::string& x="", const std::string& y="");
76    
77     private:
78     std::vector<T*> * _scan;
79     std::vector< const Criteria* > crits_;
80     std::vector< double(*)(const T*) > var_;
81    
82     class sort_by{
83     public:
84     sort_by(double(*x)(const T*)):_f(x){}
85     bool operator()(const T*a, const T*b){ return _f(a)<_f(b); }
86     private:
87     double(*_f)(const T*);
88     };
89    
90     class sort_TGraph{
91     public:
92     sort_TGraph(){}
93     bool operator()(const TGraph*g1, const TGraph*g2);
94     };
95    
96     };
97    
98     #endif