Fork me on GitHub

source: git/classes/DelphesLongFormula.cc@ 769f65b

ImprovedOutputFile Timing llp
Last change on this file since 769f65b was c749957, checked in by Michele Selvaggi <michele.selvaggi@…>, 6 years ago

new modules and classes for llp

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * Delphes: a framework for fast simulation of a generic collider experiment
3 * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19
20#include "classes/DelphesLongFormula.h"
21
22#include "TString.h"
23
24#include <stdexcept>
25
26using namespace std;
27
28//------------------------------------------------------------------------------
29
30DelphesLongFormula::DelphesLongFormula() :
31 TFormula()
32{
33}
34
35//------------------------------------------------------------------------------
36
37DelphesLongFormula::DelphesLongFormula(const char *name, const char *expression) :
38 TFormula()
39{
40}
41
42//------------------------------------------------------------------------------
43
44DelphesLongFormula::~DelphesLongFormula()
45{
46}
47
48//------------------------------------------------------------------------------
49
50Int_t DelphesLongFormula::Compile(const char *expression)
51{
52 TString buffer;
53 const char *it;
54 for(it = expression; *it; ++it)
55 {
56 if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
57 buffer.Append(*it);
58 }
59
60 buffer.ReplaceAll("pt", "[pt]");
61 buffer.ReplaceAll("eta", "[eta]");
62 buffer.ReplaceAll("phi", "[phi]");
63 buffer.ReplaceAll("energy", "[energy]");
64 buffer.ReplaceAll("d0", "[d0]");
65 buffer.ReplaceAll("dz", "[dz]");
66 buffer.ReplaceAll("ctgTheta", "[ctgTheta]");
67
68 #if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0)
69 TFormula::SetMaxima(100000,1000,1000000);
70 #endif
71
72 if(TFormula::Compile(buffer) != 0)
73 {
74 throw runtime_error("Invalid Long Formula.");
75 }
76
77 return 0;
78}
79
80//------------------------------------------------------------------------------
81
82Double_t DelphesLongFormula::Eval(Double_t pt,
83 Double_t eta,
84 Double_t phi,
85 Double_t energy,
86 Double_t d0,
87 Double_t dz,
88 Double_t ctgTheta
89 )
90{
91
92 TVarNameMap fVarNameMap;
93 TVarValMap fVarValMap;
94
95 fVarNameMap[this->GetParNumber("pt")]= "pt";
96 fVarNameMap[this->GetParNumber("eta")]= "eta";
97 fVarNameMap[this->GetParNumber("phi")]= "phi";
98 fVarNameMap[this->GetParNumber("energy")]= "energy";
99 fVarNameMap[this->GetParNumber("d0")]= "d0";
100 fVarNameMap[this->GetParNumber("dz")]= "dz";
101 fVarNameMap[this->GetParNumber("ctgTheta")]= "ctgTheta";
102
103 fVarValMap["pt"]= pt;
104 fVarValMap["eta"]= eta;
105 fVarValMap["phi"]= phi;
106 fVarValMap["energy"]= energy;
107 fVarValMap["d0"]= d0;
108 fVarValMap["dz"]= dz;
109 fVarValMap["ctgTheta"]= ctgTheta;
110
111 Double_t vals[7];
112
113 Int_t j = 0;
114 for (Int_t i=0; i != 7; i++)
115 {
116 if ( fVarNameMap.find(i) != fVarNameMap.end() )
117 {
118 TString var_name = fVarNameMap[i];
119 vals[i] = fVarValMap[var_name];
120 }
121 else
122 vals[i] = 0.;
123 }
124 return EvalPar(nullptr, vals);
125}
126
127//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.