Fork me on GitHub

source: svn/trunk/classes/DelphesTF2.cc@ 1348

Last change on this file since 1348 was 1343, checked in by Pavel Demin, 11 years ago

add DelphesTF2

File size: 2.2 KB
Line 
1#include "classes/DelphesTF2.h"
2#include "TString.h"
3#include <stdexcept>
4#include <string>
5
6using namespace std;
7
8//------------------------------------------------------------------------------
9
10DelphesTF2::DelphesTF2() :
11 TF2()
12{
13}
14
15//------------------------------------------------------------------------------
16
17DelphesTF2::DelphesTF2(const char *name, const char *expression) :
18 TF2(name,expression)
19{
20}
21
22//------------------------------------------------------------------------------
23
24DelphesTF2::~DelphesTF2()
25{
26}
27
28//------------------------------------------------------------------------------
29/*
30Int_t DelphesTF2::Compile(const char *expression)
31{
32 string buffer;
33 const char *it;
34 for(it = expression; *it; ++it)
35 {
36 if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
37 buffer.push_back(*it);
38 }
39
40 TFormula f("",buffer.c_str());
41 if(f.Compile() != 0)
42 {
43 throw runtime_error("Invalid formula.");
44 }
45 return 0;
46}
47
48//------------------------------------------------------------------------------
49
50Double_t DelphesTF2::Eval(Double_t z, Double_t t)
51{
52 Double_t x[2] = {z , t};
53 return EvalPar(x);
54}
55
56//------------------------------------------------------------------------------
57
58void DelphesTF2::ReplaceAll(std::string& subject, const std::string& search, const std::string& replace)
59{
60 size_t pos = 0;
61 while ((pos = subject.find(search, pos)) != std::string::npos)
62 {
63 subject.replace(pos, search.length(), replace);
64 pos += replace.length();
65 }
66}
67
68
69//------------------------------------------------------------------------------
70
71string DelphesTF2::ChangeVariables(const char *expression)
72{
73 DelphesTF2::Compile(expression);
74
75 string str = string(expression);
76 ReplaceAll(str,"z","x");
77 ReplaceAll(str,"t","y");
78
79 return str;
80}
81
82*/
83//------------------------------------------------------------------------------
84
85Int_t DelphesTF2::DefinedVariable(TString &chaine, Int_t &action)
86{
87 action = kVariable;
88 if(chaine == "z")
89 {
90 if(fNdim < 1) fNdim = 1;
91 return 0;
92 }
93 else if(chaine == "t")
94 {
95 if(fNdim < 2) fNdim = 2;
96 return 1;
97 }
98 return -1;
99}
100
101//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.