Fork me on GitHub

source: git/classes/DelphesFormula.cc@ 7b461f6

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 7b461f6 was d7d2da3, checked in by pavel <pavel@…>, 12 years ago

move branches/ModularDelphes to trunk

  • Property mode set to 100644
File size: 1.8 KB
Line 
1
2#include "classes/DelphesFormula.h"
3
4#include "TString.h"
5
6#include <stdexcept>
7#include <string>
8
9using namespace std;
10
11//------------------------------------------------------------------------------
12
13DelphesFormula::DelphesFormula() :
14 TFormula()
15{
16}
17
18//------------------------------------------------------------------------------
19
20DelphesFormula::DelphesFormula(const char *name, const char *expression) :
21 TFormula()
22{
23}
24
25//------------------------------------------------------------------------------
26
27DelphesFormula::~DelphesFormula()
28{
29}
30
31//------------------------------------------------------------------------------
32
33Int_t DelphesFormula::Compile(const char *expression)
34{
35 string buffer;
36 const char *it;
37 for(it = expression; *it; ++it)
38 {
39 if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
40 buffer.push_back(*it);
41 }
42 if(TFormula::Compile(buffer.c_str()) != 0)
43 {
44 throw runtime_error("Invalid formula.");
45 }
46 return 0;
47}
48
49//------------------------------------------------------------------------------
50
51Double_t DelphesFormula::Eval(Double_t pt, Double_t eta, Double_t phi, Double_t energy)
52{
53 Double_t x[4] = {pt, eta, phi, energy};
54 return EvalPar(x);
55}
56
57//------------------------------------------------------------------------------
58
59Int_t DelphesFormula::DefinedVariable(TString &chaine, Int_t &action)
60{
61 action = kVariable;
62 if(chaine == "pt")
63 {
64 if(fNdim < 1) fNdim = 1;
65 return 0;
66 }
67 else if(chaine == "eta")
68 {
69 if(fNdim < 2) fNdim = 2;
70 return 1;
71 }
72 else if(chaine == "phi")
73 {
74 if(fNdim < 3) fNdim = 3;
75 return 2;
76 }
77 else if(chaine == "energy")
78 {
79 if(fNdim < 4) fNdim = 4;
80 return 3;
81 }
82 return -1;
83}
84
85//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.