From 299f2f757389bfe2186b8a0b2da520dcbe73a1f1 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Tue, 18 Sep 2018 20:56:20 +0300 Subject: [PATCH 01/81] implemented spline and normalisation in theory expression --- common/linalg/NaturalCubicSpline.h | 139 ++++++++++++++++++++++++++++ include/TheorEval.h | 1 + src/TheorEval.cc | 144 ++++++++++++++++++++++++++++- 3 files changed, 281 insertions(+), 3 deletions(-) create mode 100644 common/linalg/NaturalCubicSpline.h diff --git a/common/linalg/NaturalCubicSpline.h b/common/linalg/NaturalCubicSpline.h new file mode 100644 index 000000000..1e2cc2e6d --- /dev/null +++ b/common/linalg/NaturalCubicSpline.h @@ -0,0 +1,139 @@ +#ifndef NATURALCUBICSPLINE_H +#define NATURALCUBICSPLINE_H + +// code mostly from https://stackoverflow.com/questions/1204553/are-there-any-good-libraries-for-solving-cubic-splines-in-c + +#include<iostream> +#include<vector> +#include<algorithm> +#include<cmath> +using namespace std; + +typedef vector<double> vec; + +class NaturalCubicSpline +{ + public: + NaturalCubicSpline(vec &x, vec &y) + { + _vectorSplineSet = Spline(x, y); + } + + double Eval(double x, const bool flagDerivative = false) + { + for(size_t i = 1; i < _vectorSplineSet.size(); i++) + { + if(_vectorSplineSet[i].x > x || i == (_vectorSplineSet.size() - 1)) + { + printf("Eval: x = %f in section %lu [%f %f]\n", x, i, _vectorSplineSet[i - 1].x, _vectorSplineSet[i].x); + if( (i == 1 && x < _vectorSplineSet[0].x) || (i == (_vectorSplineSet.size() - 1) && x > _vectorSplineSet[_vectorSplineSet.size() - 1].x) ) + printf("Warning: x = %f outside spline range [%f %f]\n", x, _vectorSplineSet[0].x, _vectorSplineSet[_vectorSplineSet.size() - 1].x); + const SplineSet& s = _vectorSplineSet[i - 1]; + double y = 0.0; + double dx = x - s.x; + if(flagDerivative) + y = 3 * s.d * dx * dx + 2 * s.c * dx + s.b; + else + y = s.d * dx * dx * dx + s.c * dx * dx + s.b * dx + s.a; + printf("y = %f\n", y); + return y; + } + } + // should not be here + throw; + } + + private: + struct SplineSet + { + double a; + double b; + double c; + double d; + double x; + }; + std::vector<SplineSet> _vectorSplineSet; + + std::vector<SplineSet> Spline(vec &x, vec &y) + { + // check input + // at least 4 points + if(x.size() < 4) + hf_errlog(18091000, "F: Natural cubic spline needs at least 4 input points"); + // x in ascending order + for(size_t s = 1; s < x.size(); s++) + if(x[s] <= x[s - 1]) + hf_errlog(18091001, "F: Natural cubic spline needs x points in accessing order"); + // x and y have same size + if(x.size() != y.size()) + hf_errlog(18091002, "F: Natural cubic spline needs same number of x and y points"); + + int n = x.size()-1; + vec a; + a.insert(a.begin(), y.begin(), y.end()); + vec b(n); + vec d(n); + vec h; + + for(int i = 0; i < n; ++i) + h.push_back(x[i+1]-x[i]); + + vec alpha; + for(int i = 0; i < n; ++i) + alpha.push_back( 3*(a[i+1]-a[i])/h[i] - 3*(a[i]-a[i-1])/h[i-1] ); + + vec c(n+1); + vec l(n+1); + vec mu(n+1); + vec z(n+1); + l[0] = 1; + mu[0] = 0; + z[0] = 0; + + for(int i = 1; i < n; ++i) + { + l[i] = 2 *(x[i+1]-x[i-1])-h[i-1]*mu[i-1]; + mu[i] = h[i]/l[i]; + z[i] = (alpha[i]-h[i-1]*z[i-1])/l[i]; + } + + l[n] = 1; + z[n] = 0; + c[n] = 0; + + for(int j = n-1; j >= 0; --j) + { + c[j] = z [j] - mu[j] * c[j+1]; + b[j] = (a[j+1]-a[j])/h[j]-h[j]*(c[j+1]+2*c[j])/3; + d[j] = (c[j+1]-c[j])/3/h[j]; + } + + vector<SplineSet> output_set(n); + for(int i = 0; i < n; ++i) + { + output_set[i].a = a[i]; + output_set[i].b = b[i]; + output_set[i].c = c[i]; + output_set[i].d = d[i]; + output_set[i].x = x[i]; + } + return output_set; + } +}; + +/*int main() +{ + vec x(11); + vec y(11); + for(int i = 0; i < x.size(); ++i) + { + x[i] = i; + y[i] = sin(i); + } + + vector<SplineSet> cs = spline(x, y); + for(int i = 0; i < cs.size(); ++i) + cout << cs[i].d << "\t" << cs[i].c << "\t" << cs[i].b << "\t" << cs[i].a << endl; +}*/ + +#endif // NATURALCUBICSPLINE_H diff --git a/include/TheorEval.h b/include/TheorEval.h index a247e93a6..bed544216 100644 --- a/include/TheorEval.h +++ b/include/TheorEval.h @@ -54,6 +54,7 @@ struct tToken { short int opr; // operator flag, includes precedence string name; // string token valarray<double> *val; // value token + int narg; }; class TheorEval{ diff --git a/src/TheorEval.cc b/src/TheorEval.cc index af1af4abc..1d6bb33cb 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -24,6 +24,8 @@ #include <yaml-cpp/yaml.h> #include "xfitter_pars.h" +#include "linalg/NaturalCubicSpline.h" + using namespace std; // extern struct ord_scales { @@ -141,7 +143,99 @@ TheorEval::assignTokens(list<tToken> &sl) sl.push_back(t); continue; } - + if ( term == string("spline") || term == string("spline_derivative") ) + { + // special case for natural cubic spline interpolation + if ( term == string("spline")) + { + t.opr = 6; + t.name = "spline"; + } + else if ( term == string("spline_derivative")) + { + t.opr = 7; + t.name = "spline"; + } + // push spline + sl.push_back(t); + int& narg_spline = sl.back().narg; + + // process arguments + t.val = new valarray<double>(0., nb); + t.narg = 0; + t.opr = 0; + // format: spline[x1,y1,x2,y2,x3,y3,x4,y4,...,x] + strexpr.get(c); + if(c != '[') + hf_errlog(18090900, "F: Theory expression syntax error: expected ["); + narg_spline = 0; + bool flagDone = false; + while(true) + { + strexpr.get(c); + int nsymbols = 0; + term.assign(1,c); + while(strexpr.get(c)) + { + if(c == ',' || c == ']') + { + if(nsymbols == 0) + hf_errlog(18090903, "F: Theory expression syntax error: error reading arguments"); + if(c == ']') + flagDone = true; + break; + } + if (!isalnum(c)) + hf_errlog(18090903, "F: Theory expression syntax error: error reading arguments"); + term.append(1,c); + nsymbols++; + } + + // have read new argument: push it + if(nsymbols > 0) + { + vector<string>::iterator found_term = find(_termNames.begin(), _termNames.end(), term); + if ( found_term == _termNames.end() ) { + cout << "Undeclared term " << term << " in expression " << _expr << endl; + return -1; + } else { + t.opr = 0; + t.name = term; + if ( _mapInitdTerms.find(term) != _mapInitdTerms.end()){ + t.val = _mapInitdTerms[term]; + } else { + t.val = new valarray<double>(0.,nb); + this->initTerm(int(found_term-_termNames.begin()), t.val); + _mapInitdTerms[term] = t.val; + } + } + sl.push_back(t); + narg_spline++; + } + else + { + if(!flagDone) + // should not be here + assert(0); + if(narg_spline % 2 == 0) + hf_errlog(18090901, "F: Theory expression syntax error: spline expected odd number of arguments"); + if(narg_spline < 9) + hf_errlog(18090902, "F: Theory expression syntax error: spline expected at least 9 arguments"); + break; + } + } + continue; + } + if ( term == string("norm") ) + { + // special case for normalised expression: norm(A)=A/sum(A) + // (A is coomputed once) + t.opr = 8; + t.name = "norm"; + t.val = new valarray<double>(0., nb); + sl.push_back(t); + continue; + } /* if ( term == string("avg") ) { // special case for avg() function t.opr = 4; @@ -179,7 +273,7 @@ TheorEval::assignTokens(list<tToken> &sl) case '*': t.opr = 3; break; case '/': t.opr = 3; break; - case '.': t.opr = 5; break; //change + case '.': t.opr = 5; break; default: cout << "Unknown operator "<< c << " in expression " << _expr << endl; } @@ -615,7 +709,51 @@ TheorEval::Evaluate(valarray<double> &vte ) } double avg = stk.top().sum()/stk.top().size(); stk.top() = avg;*/ - } else if ( it->name == string("+") ){ + } else if ( it->name == string("spline") || it->name == string("spline_derivative") ) + { + // load all arguments + int narg = it->narg; + for(int arg = 0; arg < narg; arg++) + { + //it++; + //stk.push(*(it->val)); + } + std::valarray<double> x0 = stk.top(); + stk.pop(); + int nsections = (it->narg - 1) / 2; + std::valarray<std::valarray<double> > x(nsections); + std::valarray<std::valarray<double> > y(nsections); + for(int sect = nsections - 1; sect >= 0; sect--) + { + y[sect] = stk.top(); + stk.pop(); + x[sect] = stk.top(); + stk.pop(); + } + for(int p = 0; p < x0.size(); p++) + { + std::vector<double> xSpline(nsections); + std::vector<double> ySpline(nsections); + for(int sect = 0; sect < nsections; sect++) + { + xSpline[sect] = x[sect][p]; + ySpline[sect] = y[sect][p]; + } + NaturalCubicSpline spline = NaturalCubicSpline(xSpline, ySpline); + auto result = x0; + if(it->name == string("spline")) + result[p] = spline.Eval(x0[p]); + else if(it->name == string("spline_derivative")) + result[p] = spline.Eval(x0[p], 1); + stk.push(result); + } + } + else if ( it->name == string("norm") ) + { + double sum = stk.top().sum(); + stk.top() = stk.top() / sum; + } + else if ( it->name == string("+") ){ valarray<double> a(stk.top()); stk.pop(); stk.top() += a; -- GitLab From 3e548cccf114c255092bb3a5230e3c017edd8977 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Tue, 18 Sep 2018 20:59:55 +0300 Subject: [PATCH 02/81] fixed compilation error --- src/TheorEval.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TheorEval.cc b/src/TheorEval.cc index 1d6bb33cb..372166533 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -216,7 +216,8 @@ TheorEval::assignTokens(list<tToken> &sl) { if(!flagDone) // should not be here - assert(0); + //assert(0); + hf_errlog(18090901, "F: Theory expression syntax error reading spline arguments"); if(narg_spline % 2 == 0) hf_errlog(18090901, "F: Theory expression syntax error: spline expected odd number of arguments"); if(narg_spline < 9) -- GitLab From 0e1fc0fdc7813951a0188f417d8c4a0965235341 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Tue, 18 Sep 2018 23:36:41 +0300 Subject: [PATCH 03/81] increased max theory terms 16->32 --- include/theorexpr.inc | 2 +- src/ftheor_eval.cc | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/theorexpr.inc b/include/theorexpr.inc index 99c45b673..d9e101531 100644 --- a/include/theorexpr.inc +++ b/include/theorexpr.inc @@ -1,6 +1,6 @@ C> Common block for theory expression integer NTermsMax - parameter (NTermsMax = 16) + parameter (NTermsMax = 32) double precision dynscale integer NTerms diff --git a/src/ftheor_eval.cc b/src/ftheor_eval.cc index 9a9b186b5..d9a9ea802 100644 --- a/src/ftheor_eval.cc +++ b/src/ftheor_eval.cc @@ -59,13 +59,14 @@ tDataBins gDataBins; t2Dfunctions g2Dfunctions; +#define NTERMMAX 32 extern struct thexpr_cb { double dynscale; int nterms; - char termname[16][8]; - char termtype[16][80]; - char terminfo[16][2048]; - char termsource[16][256]; + char termname[NTERMMAX][8]; + char termtype[NTERMMAX][80]; + char terminfo[NTERMMAX][2048]; + char termsource[NTERMMAX][256]; char theorexpr[1000]; int ppbar_collisions; int normalised; -- GitLab From a4cd03e632613f79f83384bc83a28a6af30b7aa9 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Wed, 19 Sep 2018 00:00:14 +0300 Subject: [PATCH 04/81] spline for multiple data points --- src/TheorEval.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TheorEval.cc b/src/TheorEval.cc index 372166533..d5e868a3b 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -731,6 +731,7 @@ TheorEval::Evaluate(valarray<double> &vte ) x[sect] = stk.top(); stk.pop(); } + auto result = x0; for(int p = 0; p < x0.size(); p++) { std::vector<double> xSpline(nsections); @@ -741,13 +742,12 @@ TheorEval::Evaluate(valarray<double> &vte ) ySpline[sect] = y[sect][p]; } NaturalCubicSpline spline = NaturalCubicSpline(xSpline, ySpline); - auto result = x0; if(it->name == string("spline")) result[p] = spline.Eval(x0[p]); else if(it->name == string("spline_derivative")) result[p] = spline.Eval(x0[p], 1); - stk.push(result); } + stk.push(result); } else if ( it->name == string("norm") ) { -- GitLab From b998ca2a37c98da61389b66ed8affc4618b5aa9f Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Wed, 19 Sep 2018 00:20:04 +0300 Subject: [PATCH 05/81] fixed spline appearing in complex theory expression --- common/linalg/NaturalCubicSpline.h | 4 ++-- src/TheorEval.cc | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/common/linalg/NaturalCubicSpline.h b/common/linalg/NaturalCubicSpline.h index 1e2cc2e6d..51a3f4880 100644 --- a/common/linalg/NaturalCubicSpline.h +++ b/common/linalg/NaturalCubicSpline.h @@ -25,7 +25,7 @@ class NaturalCubicSpline { if(_vectorSplineSet[i].x > x || i == (_vectorSplineSet.size() - 1)) { - printf("Eval: x = %f in section %lu [%f %f]\n", x, i, _vectorSplineSet[i - 1].x, _vectorSplineSet[i].x); + //printf("Eval: x = %f in section %lu [%f %f]\n", x, i, _vectorSplineSet[i - 1].x, _vectorSplineSet[i].x); if( (i == 1 && x < _vectorSplineSet[0].x) || (i == (_vectorSplineSet.size() - 1) && x > _vectorSplineSet[_vectorSplineSet.size() - 1].x) ) printf("Warning: x = %f outside spline range [%f %f]\n", x, _vectorSplineSet[0].x, _vectorSplineSet[_vectorSplineSet.size() - 1].x); const SplineSet& s = _vectorSplineSet[i - 1]; @@ -35,7 +35,7 @@ class NaturalCubicSpline y = 3 * s.d * dx * dx + 2 * s.c * dx + s.b; else y = s.d * dx * dx * dx + s.c * dx * dx + s.b * dx + s.a; - printf("y = %f\n", y); + //printf("y = %f\n", y); return y; } } diff --git a/src/TheorEval.cc b/src/TheorEval.cc index d5e868a3b..4c717c34a 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -186,7 +186,7 @@ TheorEval::assignTokens(list<tToken> &sl) break; } if (!isalnum(c)) - hf_errlog(18090903, "F: Theory expression syntax error: error reading arguments"); + hf_errlog(18090904, "F: Theory expression syntax error: error reading arguments"); term.append(1,c); nsymbols++; } @@ -211,6 +211,9 @@ TheorEval::assignTokens(list<tToken> &sl) } sl.push_back(t); narg_spline++; + // finish reading spline arguments + if(flagDone) + break; } else { -- GitLab From da34ce06da2ad85b46521a19b80cca9cdb367f25 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Wed, 19 Sep 2018 14:57:00 +0300 Subject: [PATCH 06/81] implemented dummy APPLgrid points --- reactions/APPLgrid/include/ReactionAPPLgrid.h | 1 + reactions/APPLgrid/src/ReactionAPPLgrid.cc | 96 ++++++++++++------- 2 files changed, 63 insertions(+), 34 deletions(-) diff --git a/reactions/APPLgrid/include/ReactionAPPLgrid.h b/reactions/APPLgrid/include/ReactionAPPLgrid.h index 1d53507c0..7219c754d 100644 --- a/reactions/APPLgrid/include/ReactionAPPLgrid.h +++ b/reactions/APPLgrid/include/ReactionAPPLgrid.h @@ -37,6 +37,7 @@ class ReactionAPPLgrid : public ReactionTheory enum class collision { pp, ppbar, pn}; map<int, collision> _collType; map<int, std::vector<std::shared_ptr<appl::grid> > > _grids; + map<int, std::vector<int> > _emptyPoints; map<int, int> _order; map<int, double> _muR, _muF; // !> renormalisation and factorisation scales map<int, bool> _flagNorm; // !> if true, multiply by bin width diff --git a/reactions/APPLgrid/src/ReactionAPPLgrid.cc b/reactions/APPLgrid/src/ReactionAPPLgrid.cc index 99396b514..798e4bccb 100644 --- a/reactions/APPLgrid/src/ReactionAPPLgrid.cc +++ b/reactions/APPLgrid/src/ReactionAPPLgrid.cc @@ -30,15 +30,28 @@ void ReactionAPPLgrid::setDatasetParameters(int dataSetID, map<string,string> pa while(std::getline(ss, token, ',')) { //std::cout << token << '\n'; - std::shared_ptr<appl::grid> g(new appl::grid(token)); - g->trim(); - _grids[dataSetID].push_back(g); - TFile file(token.c_str()); - _references[dataSetID].push_back((TH1D*)file.Get("grid/reference")); - if(!_references[dataSetID].back()) - hf_errlog(17033000, "W: no reference histogram grid/reference in " + token); + // dummy empty points (for bin manipulations etc.) + // GridName=DUMMYX where X is number of bins (e.g. GridName=DUMMY12) + if(std::string(token.c_str(), 5) == std::string("DUMMY")) + { + int nb = atoi(token.c_str() + 5); + _emptyPoints[dataSetID].push_back(nb); + _grids[dataSetID].push_back(NULL); + } + // normal grids else - _references[dataSetID].back()->SetDirectory(0); + { + std::shared_ptr<appl::grid> g(new appl::grid(token)); + g->trim(); + _grids[dataSetID].push_back(g); + TFile file(token.c_str()); + _references[dataSetID].push_back((TH1D*)file.Get("grid/reference")); + if(!_references[dataSetID].back()) + hf_errlog(17033000, "W: no reference histogram grid/reference in " + token); + else + _references[dataSetID].back()->SetDirectory(0); + _emptyPoints[dataSetID].push_back(-1); + } } } catch ( const std::exception& e ) { @@ -147,42 +160,57 @@ int ReactionAPPLgrid::compute(int dataSetID, valarray<double> &val, map<string, //val.resize(0); int np = 0; for(unsigned int g = 0; g < _grids[dataSetID].size(); g++) - np += _grids[dataSetID][g]->Nobs(); + { + // dummy points + if(_emptyPoints[dataSetID][g] > 0) + np += _emptyPoints[dataSetID][g]; + // grids or reference histograms + else + np += _grids[dataSetID][g]->Nobs(); + } val.resize(np); for(unsigned int g = 0; g < _grids[dataSetID].size(); g++) { - auto grid = _grids[dataSetID][g]; - std::vector<double> gridVals(grid->Nobs()); - if(!_flagUseReference[dataSetID]) + std::vector<double> gridVals; + // dummy points + if(_emptyPoints[dataSetID][g] > 0) + gridVals = std::vector<double>(_emptyPoints[dataSetID][g], 0.0); + // grids or reference histograms + else { - // Convolute the grid: - switch (_collType[dataSetID]) + auto grid = _grids[dataSetID][g]; + gridVals = std::vector<double>(grid->Nobs()); + if(!_flagUseReference[dataSetID]) { - case collision::pp : - gridVals = grid->vconvolute( getXFX(), getAlphaS(), _order[dataSetID]-1, _muR[dataSetID], _muF[dataSetID], _eScale[dataSetID][g] ); - break; - case collision::ppbar : - gridVals = grid->vconvolute( getXFX(), getXFX("pbar"), getAlphaS(), _order[dataSetID]-1, _muR[dataSetID], _muF[dataSetID], _eScale[dataSetID][g] ); - break; - case collision::pn : - gridVals = grid->vconvolute( getXFX(), getXFX("n"), getAlphaS(), _order[dataSetID]-1, _muR[dataSetID], _muF[dataSetID], _eScale[dataSetID][g] ); - break; + // Convolute the grid: + switch (_collType[dataSetID]) + { + case collision::pp : + gridVals = grid->vconvolute( getXFX(), getAlphaS(), _order[dataSetID]-1, _muR[dataSetID], _muF[dataSetID], _eScale[dataSetID][g] ); + break; + case collision::ppbar : + gridVals = grid->vconvolute( getXFX(), getXFX("pbar"), getAlphaS(), _order[dataSetID]-1, _muR[dataSetID], _muF[dataSetID], _eScale[dataSetID][g] ); + break; + case collision::pn : + gridVals = grid->vconvolute( getXFX(), getXFX("n"), getAlphaS(), _order[dataSetID]-1, _muR[dataSetID], _muF[dataSetID], _eScale[dataSetID][g] ); + break; + } } + else + { + // use reference histogram + for(std::size_t i=0; i<gridVals.size(); i++) + gridVals[i] = _references[dataSetID][g]->GetBinContent(i + 1); + } + // scale by bin width if requested + if(_flagNorm[dataSetID]) + for (std::size_t i=0; i<gridVals.size(); i++) + gridVals[i] *= grid->deltaobs(i); } - else - { - // use reference histogram - for(std::size_t i=0; i<gridVals.size(); i++) - gridVals[i] = _references[dataSetID][g]->GetBinContent(i + 1); - } - // scale by bin width if requested - if(_flagNorm[dataSetID]) - for (std::size_t i=0; i<gridVals.size(); i++) - gridVals[i] *= grid->deltaobs(i); // insert values from this grid into output array //val.resize(val.size() + grid->Nobs()); std::copy_n(gridVals.begin(), gridVals.size(), &val[pos]); - pos += grid->Nobs(); + pos += gridVals.size(); } //printf("2val.size() = %d\n", val.size()); return 0; -- GitLab From 94866e9439a59c66dfb679c436322fd5f409a0cc Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 13 Dec 2018 02:23:25 +0100 Subject: [PATCH 07/81] updated to ApplGrid 1.5.9 --- include/appl_grid/appl_grid.h | 696 --------------------------------- include/appl_grid/appl_pdf.h | 198 ---------- include/appl_grid/correction.h | 67 ---- src/fappl_grid.cxx | 36 +- tools/install-xfitter | 2 +- 5 files changed, 22 insertions(+), 977 deletions(-) delete mode 100644 include/appl_grid/appl_grid.h delete mode 100644 include/appl_grid/appl_pdf.h delete mode 100644 include/appl_grid/correction.h diff --git a/include/appl_grid/appl_grid.h b/include/appl_grid/appl_grid.h deleted file mode 100644 index bc74a2050..000000000 --- a/include/appl_grid/appl_grid.h +++ /dev/null @@ -1,696 +0,0 @@ -// emacs: this is -*- c++ -*- - -// appl_grid.h - -// grid class header - all the functions needed to create and -// fill the grid from an NLO calculation program -// -// Copyright (C) 2007 Mark Sutton (sutt@hep.ucl.ac.uk) - -// $Id: appl_grid.h, v1.00 2007/10/16 17:01:39 sutt - -// Fixme: this needs to be tidied up. eg there are too many different, -// and too many version of, accessors for x/y, Q2/tau etc there -// should be only one set, for x and Q2 *or* y and tau, but -// not both. In fact they should be for x and Q2, since y and tau -// should be purely an internal grid issue of no concern for the -// user. - -#ifndef __APPL_GRID_H -#define __APPL_GRID_H - -#include <vector> -#include <iostream> -#include <sstream> -#include <cmath> -#include <string> -#include <exception> - -#include "TH1D.h" - - -double _fy(double x); -double _fx(double y); -double _fun(double y); - - -#include "correction.h" - -namespace appl { - - -/// forward declarations - full definitions included -/// from appl_grid.cxx -class igrid; -class appl_pdf; - - -const int MAXGRIDS = 5; - - -/// externally visible grid class -class grid { - -public: - - // grid error exception - class exception : public std::exception { - public: - exception(const std::string& s) { std::cerr << what() << " " << s << std::endl; }; - //exception(std::ostream& s) { std::cerr << what() << " " << s << std::endl; }; - exception(std::ostream& s) { std::stringstream ss; ss << s.rdbuf(); std::cerr << what() << " " << ss.str() << std::endl; }; - virtual const char* what() const throw() { return "appl::grid::exception"; } - }; - - typedef enum { STANDARD=0, AMCATNLO=1, SHERPA=2, LAST_TYPE=3 } CALCULATION; - -public: - - grid(int NQ2=50, double Q2min=10000.0, double Q2max=25000000.0, int Q2order=5, - int Nx=50, double xmin=1e-5, double xmax=0.9, int xorder=5, - int Nobs=20, double obsmin=100.0, double obsmax=7000.0, - std::string genpdf="mcfm_pdf", - int leading_order=0, int nloops=1, - std::string transform="f2"); - - grid( int Nobs, const double* obsbins, - int NQ2=50, double Q2min=10000.0, double Q2max=25000000.0, int Q2order=5, - int Nx=50, double xmin=1e-5, double xmax=0.9, int xorder=5, - std::string genpdf="mcfm_pdf", - int leading_order=0, int nloops=1, - std::string transform="f2" ); - - grid( const std::vector<double>& obs, - int NQ2=50, double Q2min=10000.0, double Q2max=25000000.0, int Q2order=5, - int Nx=50, double xmin=1e-5, double xmax=0.9, int xorder=5, - std::string genpdf="mcfm_pdf", - int leading_order=0, int nloops=1, - std::string transform="f2" ); - - // build a grid but don't build the internal igrids - these can be added later - grid( const std::vector<double>& obs, - std::string genpdf="nlojet_pdf", - int leading_order=0, int nloops=1, - std::string transform="f2" ); - - // copy constructor - grid(const grid& g); - - // read from a file - grid(const std::string& filename="./grid.root", const std::string& dirname="grid"); - - // add an igrid for a given bin and a given order - void add_igrid(int bin, int order, igrid* g); - - virtual ~grid(); - - // update grid with one set of event weights - void fill(const double x1, const double x2, const double Q2, - const double obs, - const double* weight, const int iorder); - - - void fill_phasespace(const double x1, const double x2, const double Q2, - const double obs, - const double* weight, const int iorder); - - - void fill_grid(const double x1, const double x2, const double Q2, - const double obs, - const double* weight, const int iorder) { - if (isOptimised()) fill(x1, x2, Q2, obs, weight, iorder); - else fill_phasespace(x1, x2, Q2, obs, weight, iorder); - } - - - void fill_index(const int ix1, const int ix2, const int iQ2, - const int iobs, - const double* weight, const int iorder); - - - // trim/untrim the grid to reduce memory footprint - void trim(); - void untrim(); - - // formatted output - std::ostream& print(std::ostream& s=std::cout) const; - - // don't do anything anymore - // void setuppdf(void (*pdf)(const double& , const double&, double* ) ); - - // get the interpolated pdf's - // void pdfinterp(double x1, double Q2, double* f); - - - // perform the convolution to a specified number of loops - // nloops=-1 gives the nlo part only - std::vector<double> vconvolute(void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ), - int nloops, - double rscale_factor=1, - double fscale_factor=1, - double Escale=1 ); - - std::vector<double> vconvolute(void (*pdf1)(const double& , const double&, double* ), - void (*pdf2)(const double& , const double&, double* ), - double (*alphas)(const double& ), - int nloops, - double rscale_factor=1, - double fscale_factor=1, - double Escale=1 ); - - - // perform the convolution to a specified number of loops - // nloops=-1 gives the nlo part only - std::vector<double> vconvolute(double Escale, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ), - int nloops, - double rscale_factor=1, - double fscale_factor=1 ) { - return vconvolute(pdf, alphas, nloops, rscale_factor, fscale_factor, Escale); - } - - - // perform the convolution to the max number of loops in grid - std::vector<double> vconvolute(void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ) ) { - return vconvolute( pdf, alphas, m_order-1 ); - } - - - // perform the convolution to the max number of loops in grid - std::vector<double> vconvolute(double Escale, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ) ) { - return vconvolute( Escale, pdf, alphas, m_order-1 ); - } - - - // perform the convolution to a specified number of loops - // for a single sub process, nloops=-1 gives the nlo part only - std::vector<double> vconvolute_subproc(int subproc, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ), - int nloops, - double rscale_factor=1, double Escale=1 ); - - - // perform the convolution to a specified number of loops - // for a single sub process, nloops=-1 gives the nlo part only - std::vector<double> vconvolute_subproc(int subproc, - double Escale, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ), - int nloops, - double rscale_factor=1 ) { - return vconvolute_subproc(subproc, pdf, alphas, nloops, rscale_factor, Escale); - } - - - // perform the convolution to the max number of loops in grid - // for a single sub process - std::vector<double> vconvolute_subproc(int subproc, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ) ) { - return vconvolute_subproc( subproc, pdf, alphas, m_order-1 ); - } - - // perform the convolution to the max number of loops in grid - // for a single sub process - std::vector<double> vconvolute_subproc(int subproc, - double Escale, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ) ) { - return vconvolute_subproc( subproc, Escale, pdf, alphas, m_order-1 ); - } - - - double vconvolute_bin( int bin, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double&) ); - - - // perform the convolution to a specified number of loops - // nloops=-1 gives the nlo part only - TH1D* convolute(void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ), - int nloops, - double rscale_factor=1, - double fscale_factor=1, - double Escale=1 ); - - // perform the convolution to a specified number of loops - // nloops=-1 gives the nlo part only - TH1D* convolute(void (*pdf1)(const double& , const double&, double* ), - void (*pdf2)(const double& , const double&, double* ), - double (*alphas)(const double& ), - int nloops, - double rscale_factor=1, - double fscale_factor=1, - double Escale=1 ); - - - TH1D* convolute(double Escale, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ), - int nloops, - double rscale_factor=1, - double fscale_factor=1 ) { - return convolute(pdf, alphas, nloops, rscale_factor, fscale_factor, Escale); - } - - - // perform the convolution to the max number of loops in grid - TH1D* convolute(void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ) ) { - return convolute( pdf, alphas, m_order-1 ); - } - - // perform the convolution to the max number of loops in grid - TH1D* convolute(double Escale, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ) ) { - return convolute( Escale, pdf, alphas, m_order-1 ); - } - - - // perform the convolution to a specified number of loops - // for a single sub process, nloops=-1 gives the nlo part only - TH1D* convolute_subproc(int subproc, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ), - int nloops, - double rscale_factor=1, double Escale=1 ); - - TH1D* convolute_subproc(int subproc, - double Escale, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ), - int nloops, - double rscale_factor=1 ) { - return convolute_subproc( subproc, pdf, alphas, nloops, rscale_factor, Escale); - } - - // perform the convolution to the max number of loops in grid - // for a single sub process - TH1D* convolute_subproc(int subproc, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ) ) { - return convolute_subproc( subproc, pdf, alphas, m_order-1 ); - } - - TH1D* convolute_subproc(int subproc, - double Escale, - void (*pdf)(const double& , const double&, double* ), - double (*alphas)(const double& ) ) { - return convolute_subproc( subproc, Escale, pdf, alphas, m_order-1 ); - } - - - // optimise the bin limits - void optimise(bool force=false); - void optimise(int NQ2, int Nx); - void optimise(int NQ2, int Nx1, int Nx2); - - // redefine the limits by hand - void redefine(int iobs, int iorder, - int NQ2, double Q2min, double Q2max, - int Nx, double xmin, double xmax); - - bool setNormalised(bool t=true) { return m_normalised=t; } - bool getNormalised() const { return m_normalised; } - - - // set the filling to be symmetric and test status - bool symmetrise(bool t=true) { return m_symmetrise=t; } - bool isSymmetric() const { return m_symmetrise; } - - bool reweight(bool t=false); - - // access to internal grids if need be - const igrid* weightgrid(int iorder, int iobs) const { return m_grids[iorder][iobs]; } - - // save grid to specified file - void Write(const std::string& filename, const std::string& dirname="grid", const std::string& pdfname="" ); - - // accessors for the observable after possible bin combination - int Nobs() const { return m_obs_bins_combined->GetNbinsX(); } - double obs(int iobs) const { return m_obs_bins_combined->GetBinCenter(iobs+1); } - int obsbin(double obs) const { return m_obs_bins_combined->FindBin(obs)-1; } - double obslow(int iobs) const { return m_obs_bins_combined->GetBinLowEdge(iobs+1); } - double obsmin() const { return obslow(0); } - double obsmax() const { return obslow(Nobs()); } - double deltaobs(int iobs) const { return m_obs_bins_combined->GetBinWidth(iobs+1); } - - const TH1D* getReference() const { return m_obs_bins_combined; } - TH1D* getReference() { return m_obs_bins_combined; } - - - // TH1D* getXReference() { - // combineReference(); - // return m_obs_bins_combined; - // } - - - // accessors for the observable befor any bin combination - int Nobs_internal() const { return m_obs_bins->GetNbinsX(); } - double obs_internal(int iobs) const { return m_obs_bins->GetBinCenter(iobs+1); } - int obsbin_internal(double obs) const { return m_obs_bins->FindBin(obs)-1; } - double obslow_internal(int iobs) const { return m_obs_bins->GetBinLowEdge(iobs+1); } - double deltaobs_internal(int iobs) const { return m_obs_bins->GetBinWidth(iobs+1); } - double obsmin_internal() const { return obslow_internal(0); } - double obsmax_internal() const { return obslow_internal(Nobs_internal()); } - - const TH1D* getReference_internal() const { return m_obs_bins; } - TH1D* getReference_internal() { return m_obs_bins; } - - - - - // number of subprocesses - int subProcesses(int i) const; - - // general status accessors - double& run() { return m_run; } - - // accessors for the status information - bool isOptimised() const { return m_optimised; } - bool isTrimmed() const { return m_trimmed; } - - // lowest order of process - int leadingOrder() const { return m_leading_order; } - - /// maximum number of orders ( lo=1, nlo=2, nnlo=3 ) - /// but aMC@NLO uses 4 grids for the NLO, so m_order - /// will be 4, but really it is still only available - /// 1 loop, so take account of this - int nloops() const { - if ( m_type!=AMCATNLO ) return m_order-1; - else if ( m_order>0 ) return 1; - else return 0; - } - - // find out which transform and which pdf combination are being used - std::string getTransform() const { return m_transform; } - - static double transformvar(); - static double transformvar(double v); - - std::string getGenpdf() const { return m_genpdfname; } - - std::string version() const { return m_version; } - std::string appl_version() const; - - double getCMSScale() const { return m_cmsScale; } - void setCMSScale(double cmsScale) { m_cmsScale=cmsScale; } - - double getDynamicScale() const { return m_dynamicScale; } - void setDynamicScale(double dynamicScale) { m_dynamicScale=dynamicScale; } - - - // set optimise flag on all sub grids - bool setOptimised(bool t=true) { - return m_optimised=t; - // for ( int iorder=0 ; iorder<2 ; iorder++ ) { - // for ( int iobs=0 ; iobs<Nobs() ; iobs++ ) m_grids[iorder][iobs]->setOptimised(t); - // } - } - - // find the number of words used for storage - int size() const; - - // get the cross sections - double& crossSection() { return m_total; } - double& crossSectionError() { return m_totalerror; } - - // double Lambda() const { return m_Lambda2; } - - // very lovely algebraic operators - grid& operator=(const grid& g); - grid& operator*=(const double& d); - grid& operator+=(const grid& g); - - /// test if grids have the same limits etc - bool operator==(const grid& g) const; - - // shouldn't have these, the grid is too large a structure - // to be passed in a return - // grid operator*(const double& d) const { return grid(*this)*=d; } - // grid operator+(const grid& g) const { return grid(*this)+=g; } - - void setDocumentation(const std::string& s); - void addDocumentation(const std::string& s); - - std::string getDocumentation() const { return m_documentation; } - std::string& getDocumentation() { return m_documentation; } - - - /// set the range of the observable bins, with an optional - /// scaling of the observable valuesfor channging units - void setBinRange(int ilower, int iupper, double xScaleFactor=1); - void setRange(double lower, double upper, double xScaleFactor=1); - - - /// add a correction as a std::vector - void addCorrection( std::vector<double>& v, const std::string& label="", bool combine=false ); - - - /// add a correction by histogram - void addCorrection(TH1D* h, const std::string& label="", double scale=1, bool combine=false ); - - - /// access the corrections - // const std::vector<std::vector<double> >& corrections() const { - const std::vector<correction>& corrections() const { - return m_corrections; - } - - /// get the correction labels - const std::vector<std::string >& correctionLabels() const { - return m_correctionLabels; - } - - /// will the corrections be applied? - bool getApplyCorrections() const { return m_applyCorrections; } - - bool setApplyCorrections(bool b) { - std::cout << "appl::grid bin-by-bin corrections will " - << ( b ? "" : "not " ) << "be applied" << std::endl; - return m_applyCorrections=b; - } - - /// apply corrections to a std::vector - void applyCorrections(std::vector<double>& v, std::vector<bool>& applied); - - - /// will a specific correction be applied? - bool getApplyCorrection(unsigned i) const { - if ( m_applyCorrections ) return true; - else if ( i<m_applyCorrection.size() ) return m_applyCorrection.at(i); - return false; - } - - bool setApplyCorrection(unsigned i, bool b) { - if ( i>=m_corrections.size() ) return false; - std::cout << "appl::grid bin-by-bin correction will " - << ( b ? "" : "not " ) << "be applied for correction " << i; - if ( m_correctionLabels[i]!="" ) std::cout << " (" << m_correctionLabels[i] << ")"; - std::cout << std::endl; - return m_applyCorrection[i]=b; - } - - /// apply corrections to a std::vector - bool applyCorrection(unsigned i, std::vector<double>& v); - - - /// set the ckm matrix values if need be - /// takes a 3x3 matrix with the format { { Vud, Vus, Vub }, { Vcd, Vcs, Vcb }, { Vtd, Vts, Vtb } } - void setckm( const std::vector<std::vector<double> >& ckm ); - - /// takes a flat 9 element vector (or c array) with the format { Vud, Vus, Vub, Vcd, Vcs, Vcb, Vtd, Vts, Vtb } - void setckm( const std::vector<double>& ckm ); - void setckm( const double* ckm ); - - - /// set the squared ckm matrix values if need be - /// the squared terms for eihter W+ or W- production - you probably should use setckm() - void setckm2( const std::vector<std::vector<double> >& ckm2 ); - - /// set the ckm matrix and squared ckm matrix values if need be - const std::vector<std::vector<double> >& getckm() const; - const std::vector<std::vector<double> >& getckm2() const; - - - /// flag custom convolution routines - - void sherpa() { m_type = SHERPA; std::cout << "appl::grid::sherpa() using SHERPA convolution" << std::endl; } - void amcatnlo() { m_type = AMCATNLO; std::cout << "appl::grid::amcatnlo() using aMC@NLO convolution" << std::endl; } - void standard() { m_type = STANDARD; std::cout << "appl::grid::standard() using standard convolution" << std::endl; } - - CALCULATION calculation() const { return m_type; } - - static std::string _calculation(CALCULATION C) { - switch (C) { - case STANDARD: - return "standard"; - case SHERPA: - return "sherpa"; - case AMCATNLO: - return "amcatnlo"; - case LAST_TYPE: - return "last_type"; // NB: shouldn't ever be used - } - return "unknown"; - } - - /// reduce number of subprocesses if possible - void shrink(const std::string& name, int ckmcharge=0); - - /// set bins to be combined after the convolution - void combine( std::vector<int>& v) { if ( (m_combine=v).size() ) combineReference(true); } - - /// set combine the be combined after the convolution - void combineReference(bool force=false); - - void combineBins(std::vector<double>& v, int power=1 ) const; - - double fx(double x) const; - double fy(double x) const; - - const appl_pdf* genpdf(int i) const { return m_genpdf[i]; } - - std::vector<double>& userdata() { return m_userdata; } - const std::vector<double>& userdata() const { return m_userdata; } - -protected: - - // internal common construct for the different types of constructor - void construct(int Nobs, - int NQ2=50, double Q2min=10000.0, double Q2max=25000000.0, int Q2order=4, - int Nx=50, double xmin=1e-5, double xmax=0.9, int xorder=3, - int order=2, - std::string transform="f" ); - -protected: - - /// std::string manipulators to parse the pdf names - - /// return chomped std::string - static std::string chomptoken(std::string& s1, const std::string& s2) - { - std::string s3 = ""; - std::string::size_type pos = s1.find(s2); - if ( pos != std::string::npos ) { - s3 = s1.substr(0, pos); - s1.erase(0, pos+1); - } - else { - s3 = s1.substr(0, s1.size()); - s1.erase(0, s1.size()+1); - } - return s3; - } - - static std::vector<std::string> parse(std::string s, const std::string& key) { - std::vector<std::string> clauses; - while ( s.size() ) clauses.push_back( chomptoken(s, key) ); - return clauses; - } - - /// get the required pdf combinations from those registered - void findgenpdf( std::string s ); - - /// add a generic pdf to the data base of registered pdfs - void addpdf( const std::string& s, const std::vector<int>& combinations=std::vector<int>() ); - - appl_pdf* genpdf(int i) { return m_genpdf[i]; } - -public: - - int subproc() const { return m_subproc; } - -protected: - - // histograms for saving the observable - TH1D* m_obs_bins; - TH1D* m_obs_bins_combined; - - // order in alpha_s of tree level contribution - int m_leading_order; - - // how many orders in the calculation, lo, nlo, nnlo etc - int m_order; - - // the actual weight grids themselves - igrid** m_grids[MAXGRIDS]; /// up to MAXGRIDS grids LO, NLO, NNLO, Real virtual, etc - - // total cross section qand uncertainty - double m_total; - double m_totalerror; - - // state variables - double m_run; - bool m_optimised; - bool m_trimmed; - - bool m_normalised; - - bool m_symmetrise; - - // transform and pdf combination tags - std::string m_transform; - std::string m_genpdfname; - - // pdf combination class - appl_pdf* m_genpdf[MAXGRIDS]; - - static const std::string m_version; - - double m_cmsScale; - - double m_dynamicScale; - - /// bin by bin correction factors - // std::vector<std::vector<double> > m_corrections; - std::vector<correction> m_corrections; - std::vector<std::string> m_correctionLabels; - - - /// should we apply the corrections? - bool m_applyCorrections; - - /// flag vector to determine whether each individual - /// correction should be applied - std::vector<bool> m_applyCorrection; - - std::string m_documentation; - - std::vector<double> m_ckmsum; - std::vector<std::vector<double> > m_ckm2; - std::vector<std::vector<double> > m_ckm; - - CALCULATION m_type; - - bool m_read; - - std::vector<int> m_combine; - - int m_subproc; - int m_bin; - - std::vector<double> m_userdata; - -}; - - -}; - -// shouldn't have this, grid is too large a structure -// grid operator*(const double& d, const appl::grid& g) { return g*d; } - -std::ostream& operator<<(std::ostream& s, const appl::grid& mygrid); - - - -#endif // __APPL_GRID_H diff --git a/include/appl_grid/appl_pdf.h b/include/appl_grid/appl_pdf.h deleted file mode 100644 index e0e3c23b4..000000000 --- a/include/appl_grid/appl_pdf.h +++ /dev/null @@ -1,198 +0,0 @@ -// emacs: this is -*- c++ -*- -// -// appl_pdf.h -// -// pdf transform functions header -// -// Copyright (C) 2007 M.Sutton (sutt@hep.ucl.ac.uk) -// -// $Id: appl_pdf.h, v Fri Dec 21 22:19:50 GMT 2007 sutt $ - - -#ifndef __APPL_PDF_H -#define __APPL_PDF_H - -#include <iostream> -#include <fstream> -#include <sstream> - -#include <vector> -#include <map> -#include <string> - -#include <exception> - - -namespace appl { - - -class appl_pdf; - -typedef std::map<const std::string, appl_pdf*> pdfmap; - - -// this is a *maybe* nice class, a base class for pdf -// functions -// -// it has a virtual evaluate() method to be definied in -// the derived class, and a static std::map of all the names -// of instances of the derived classes -// -// when a new instance of the class is created, it -// automatically adds it's name to the std::map, so the user -// doesn't need to worry about consistency, and removes -// itself when the derived instance is deleted - -class appl_pdf { - -public: - - // pdf error exception - class exception : public std::exception { - public: - exception(const std::string& s="") { std::cerr << what() << " " << s << std::endl; }; - //exception(std::ostream& s) { std::cerr << what() << " " << s << std::endl; }; - exception(std::ostream& s) { std::stringstream ss; ss << s.rdbuf(); std::cerr << what() << " " << ss.str() << std::endl; }; - const char* what() const throw() { return "appl::appl_pdf::exception "; } - }; - -public: - - /// constructor and destructor - appl_pdf(const std::string& name); - - virtual ~appl_pdf(); - - /// retrieve an instance from the std::map - static appl_pdf* getpdf(const std::string& s, bool printout=true); - - /// print out the pdf std::map - static void printmap(std::ostream& s=std::cout) { - pdfmap::iterator itr = __pdfmap.begin(); - while ( itr!=__pdfmap.end() ) { - s << "pdfmap " << itr->first << "\t\t" << itr->second << std::endl; - itr++; - } - } - - /// initialise the factory - static bool create_map(); - - virtual void evaluate(const double* fA, const double* fB, double* H) = 0; - - virtual int decideSubProcess( const int , const int ) const; - - std::string name() const { return m_name; } - - int Nproc() const { return m_Nproc; } - int size() const { return m_Nproc; } - - - - std::string rename(const std::string& name) { - /// remove my entry from the std::map, and add me again with my new name - if ( __pdfmap.find(m_name)!=__pdfmap.end() ) { - __pdfmap.erase(__pdfmap.find(m_name)); - } - else { - std::cout << "appl_pdf::rename() " << m_name << " not in std::map" << std::endl; - } - m_name = name; - addtopdfmap(m_name, this); - return m_name; - } - - - /// code to allow optional std::vector of subprocess contribution names - - const std::vector<std::string>& subnames() const { return m_subnames; } - - void addSubnames( const std::vector<std::string>& subnames ) { m_subnames = subnames; } - - void addSubname( const std::string& subname ) { - if ( int(m_subnames.size())<m_Nproc-1 ) m_subnames.push_back(subname); - } - - - - /// is this a W+ or a W- pdf combination? or neither? - int getckmcharge() const { return m_ckmcharge; } - - /// access the ckm matrices - if no matrices are required these std::vectors have - /// zero size - - const std::vector<double>& getckmsum() const { return m_ckmsum; } - const std::vector<std::vector<double> >& getckm2() const { return m_ckm2; } - const std::vector<std::vector<double> >& getckm() const { return m_ckm; } - - /// set the ckm matrices from external values - void setckm( const std::vector<std::vector<double> >& ckm ); - void setckm2( const std::vector<std::vector<double> >& ckm2 ); - - /// code to create the ckm matrices using the hardcoded default - /// values if required - /// takes a bool input - if true creates the ckm for Wplus, - /// false for Wminus - void make_ckm( bool Wp=true ); - - void SetNProc(int Nsub){ m_Nproc=Nsub; return;}; - - /// set some useful names for the different subprocesses - void setnames( const std::vector<std::string>& names) { m_names = names; } - std::vector<std::string> getnames() const { return m_names; } - -protected: - - /// search the path for configuration files - static std::ifstream& openpdf( const std::string& filename ); - -private: - - static void addtopdfmap(const std::string& s, appl_pdf* f) { - if ( __pdfmap.find(s)==__pdfmap.end() ) { - __pdfmap.insert( pdfmap::value_type( s, f ) ); - // std::cout << "appl_pdf::addtomap() registering " << s << " in std::map addr \t" << f << std::endl; - } - else { - throw exception( std::cerr << "appl_pdf::addtopdfmap() " << s << " already in std::map\t0x" << __pdfmap.find(s)->second ); - } - } - -protected: - - int m_Nproc; - std::string m_name; - - std::vector<std::string> m_subnames; - - /// ckm matrix related information - /// W+, W- or neither? - int m_ckmcharge; - - // ckm matrices - std::vector<double> m_ckmsum; - std::vector<std::vector<double> > m_ckm2; /// squared 13x13 matrix - std::vector<std::vector<double> > m_ckm; /// simple 3x3 - - /// some strings for more useful name if required - std::vector<std::string> m_names; - - static pdfmap __pdfmap; - static std::vector<std::string> __pdfpath; -}; - - -} - - -#endif // __APPL_PDF_H - - - - - - - - - - diff --git a/include/appl_grid/correction.h b/include/appl_grid/correction.h deleted file mode 100644 index 647bbf86d..000000000 --- a/include/appl_grid/correction.h +++ /dev/null @@ -1,67 +0,0 @@ -// emacs: this is -*- c++ -*- -// -// @file correction.h -// class to store the multipliciative post processing -// corrections to be applied, only basic for the time -// but will be extended as appropriate -// -// Copyright (C) 2014 M.Sutton (sutt@cern.ch) -// -// $Id: correction.h, v0.0 Sun 23 Mar 2014 09:08:46 CET sutt $ - - -#ifndef CORRECTION_H -#define CORRECTION_H - -#include <iostream> -#include <vector> -#include <string> - - -// typedef std::vector<double> correction; - - -class correction { - -public: - - correction(const std::vector<double>& v, const std::string& s="" ) : mlabel(s), mv(v) { } - - virtual ~correction() { } - - std::string label() const { return mlabel; } - - unsigned size() const { return mv.size(); } - - double& operator[](int i) { return mv[i]; } - double operator[](int i) const { return mv[i]; } - - operator std::vector<double>&() { return mv; } - - correction operator=(const std::vector<double>& v) { mv=v; return *this; } - -private: - - std::string mlabel; - std::vector<double> mv; - -}; - - -// inline std::ostream& operator<<( std::ostream& s, const correction& /* _c */ ) { -// return s; -// } - - - -#endif // CORRECTION_H - - - - - - - - - - diff --git a/src/fappl_grid.cxx b/src/fappl_grid.cxx index d518114c2..b5b1ed8f0 100644 --- a/src/fappl_grid.cxx +++ b/src/fappl_grid.cxx @@ -100,6 +100,12 @@ extern "C" void appl_gridids_(int* ids) { } +void throw_exception( const std::string& msg, int id, const std::string& s="" ) { + std::stringstream s_; + s_ << msg << id << s; + throw appl::grid::exception( s_.str() ); +} + void appl_bookgrid_(int& id, const int& Nobs, const double* binlims) { @@ -115,7 +121,7 @@ void appl_bookgrid_(int& id, const int& Nobs, const double* binlims) "nlojet", 1, 3, "f3") ) ) ; // _grid->symmetrise(true); } - else throw appl::grid::exception( std::cerr << "grid with id " << id << " already exists" << std::endl ); + else throw_exception( "grid with id ", id, " already exists" ); } @@ -131,7 +137,7 @@ void appl_readgrid_(int& id, const char* s) { if ( gitr==_grid.end() ) { _grid.insert( std::map<int,appl::grid*>::value_type( id, new appl::grid(sstr.c_str()) ) ); } - else throw appl::grid::exception( std::cerr << "grid with id " << id << " already exists" << std::endl ); + else throw_exception("grid with id ", id, " already exists" ); } @@ -141,7 +147,7 @@ void appl_printgrid_(int& id) { if ( gitr!=_grid.end() ) { std::cout << "grid id " << id << "\n" << *gitr->second << std::endl; } - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id ); } @@ -158,7 +164,7 @@ void appl_printgriddoc_(int& id) { if ( gitr!=_grid.end() ) { std::cout << "grid id " << id << "\n" << gitr->second->getDocumentation() << std::endl; } - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id ); } @@ -168,7 +174,7 @@ void appl_releasegrid_(int& id) { delete gitr->second; _grid.erase(gitr); } - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id ); } @@ -192,7 +198,7 @@ void appl_redefine_(int& id, NQ2, Q2min, Q2max, Nx, xmin, xmax); } - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id); } @@ -201,25 +207,25 @@ void appl_redefine_(int& id, int appl_getnbins_(int& id) { std::map<int,appl::grid*>::iterator gitr = _grid.find(id); if ( gitr!=_grid.end() ) return gitr->second->Nobs(); - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id ); } int appl_getbinnumber_(int& id, double& data) { std::map<int,appl::grid*>::iterator gitr = _grid.find(id); if ( gitr!=_grid.end() ) return gitr->second->obsbin(data); - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id ); } double appl_getbinlowedge_(int& id, int& bin) { std::map<int,appl::grid*>::iterator gitr = _grid.find(id); if ( gitr!=_grid.end() ) return gitr->second->obslow(bin); - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id ); } double appl_getbinwidth_(int& id, int& bin) { std::map<int,appl::grid*>::iterator gitr = _grid.find(id); if ( gitr!=_grid.end() ) return gitr->second->deltaobs(bin); - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id ); } @@ -235,7 +241,7 @@ void appl_convoluteorder_(int& id, int& nloops, double& muR, double& muF, double vector<double> v = g->vconvolute(appl_fnpdf_, appl_fnalphas_, nloops, muR, muF); for ( unsigned i=0 ; i<v.size() ; i++ ) data[i] = v[i]; } - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id ); } void appl_convolutewrap_(int& id, double* data, @@ -247,7 +253,7 @@ void appl_convolutewrap_(int& id, double* data, vector<double> v = g->vconvolute( pdf, alphas); for ( unsigned i=0 ; i<v.size() ; i++ ) data[i] = v[i]; } - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id ); } @@ -262,7 +268,7 @@ void _appl_writegrid_(int& id, const char* s) { // g->print(); g->Write(s); } - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id ); } @@ -277,7 +283,7 @@ void appl_fillgrid_(int& id, if ( gitr!=_grid.end() ) { gitr->second->fill_index(ix1, ix2, iQ, iobs, w, iorder); } - else throw appl::grid::exception( std::cerr << "No grid with id " << id << std::endl ); + else throw_exception("No grid with id ", id ); } @@ -303,7 +309,7 @@ void appl_readfastnlogrids_( int* ids, const char* s ) { _grid.insert( std::map<int,appl::grid*>::value_type( id, grids[i] ) ); // std::cout << grids[i]->getDocumentation() << std::endl; } - else throw appl::grid::exception( std::cerr << "grid with id " << id << " already exists" << std::endl ); + else throw_exception("grid with id ", id, " already exists" ); ids[i] = id; } diff --git a/tools/install-xfitter b/tools/install-xfitter index 6e92b54ca..8d0479ca7 100755 --- a/tools/install-xfitter +++ b/tools/install-xfitter @@ -5,7 +5,7 @@ ## Programs versions lhapdfver=6.2.1 hoppetver=1.2.0 -applgridver=1.4.70 +applgridver=1.5.9 qcdnumver=17-01-14 apfelver=3.0.0 melaver=2.0.1 -- GitLab From dd2c86b8334fac08387535d49ba084aa74c5a648 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 13 Dec 2018 02:23:47 +0100 Subject: [PATCH 08/81] fixed compilation on modern gcc --- src/CheckForPDF.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CheckForPDF.cxx b/src/CheckForPDF.cxx index 8c4fbb836..b8f307083 100644 --- a/src/CheckForPDF.cxx +++ b/src/CheckForPDF.cxx @@ -1,5 +1,5 @@ #include "CheckForPDF.h" - +#include <cstring> using namespace std; -- GitLab From 3d77894acd3721bbea527f4fc2eb707b1dcaedb2 Mon Sep 17 00:00:00 2001 From: Sasha Glazov <glazov@mail.desy.de> Date: Wed, 2 Jan 2019 16:23:08 +0100 Subject: [PATCH 09/81] Remove pre-install of which --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aae3a023c..4e3b07ea8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ stages: - nightly before_script: - - yum -y install which yaml-cpp-devel libyaml-devel + - yum -y install yaml-cpp-devel libyaml-devel - . ./scripts/setup.sh - ./scripts/install-deps.sh -- GitLab From 987f13c9fccc668238d6e10f766ecf874ecbfe8b Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Wed, 16 Jan 2019 00:50:00 +0100 Subject: [PATCH 10/81] further stuff needed for MSbar mass scheme --- Makefile.am | 2 +- Reactions.txt | 1 + configure.ac | 5 ++ doxygen.cfg | 2 +- reactions/Hathor/include/ReactionHathor.h | 1 + reactions/Hathor/src/ReactionHathor.cc | 34 ++++++++++- reactions/KRunning/include/ReactionKRunning.h | 47 +++++++++++++++ reactions/KRunning/src/Makefile.am | 15 +++++ reactions/KRunning/src/ReactionKRunning.cc | 60 +++++++++++++++++++ reactions/KRunning/yaml/parameters.yaml | 0 src/TheorEval.cc | 12 ++-- 11 files changed, 169 insertions(+), 10 deletions(-) create mode 100644 reactions/KRunning/include/ReactionKRunning.h create mode 100644 reactions/KRunning/src/Makefile.am create mode 100644 reactions/KRunning/src/ReactionKRunning.cc create mode 100644 reactions/KRunning/yaml/parameters.yaml diff --git a/Makefile.am b/Makefile.am index ee288f31b..36e8fbe87 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,7 @@ SUBDIRS = minuit/src interfaces/src DY/src DIPOLE/src RT/src EW/src common commo genetic/mixmax_r004 genetic/src QEDevol/src \ include interfaces/include FastNLO/include FastNLO/include/fastnlotk DiffDIS/include \ DY/include tools/draw/include \ - pdf2yaml tools/process \ + pdf2yaml tools/process reactions/KRunning/src \ reactions/AFB/src \ reactions/KFactor/src reactions/Fractal_DISNC/src reactions/BaseDISCC/src reactions/Hathor/src reactions/BaseDISNC/src \ reactions/RT_DISNC/src reactions/FFABM_DISNC/src reactions/FFABM_DISCC/src reactions/APPLgrid/src reactions/BaseHVQMNR/src \ diff --git a/Reactions.txt b/Reactions.txt index de4193dc2..eff9d685c 100644 --- a/Reactions.txt +++ b/Reactions.txt @@ -16,3 +16,4 @@ FONLL_DISNC libfonll_disnc_xfitter.so FONLL_DISCC libfonll_discc_xfitter.so AFB libafb_xfitter.so KMatrix libkmatrix_xfitter.so +KRunning libkrunning_xfitter.so diff --git a/configure.ac b/configure.ac index 28fece7f4..ceae457f6 100644 --- a/configure.ac +++ b/configure.ac @@ -5,6 +5,10 @@ m4_esyscmd(git describe --always 2>&1 | awk '/Not a git/ {print "2.0.0\033@<:@1 [xfitter-help@desy.de],[xfitter],[http://xfitter.org]) m4_ifndef([AC_PACKAGE_URL], AC_DEFINE([PACKAGE_URL],["http://xfitter.org"])) +CFLAGS+="-O0 -g" +CPPFLAGS+="-O0 -g" +CXXFLAGS+="-O0 -g" + #Suppress verbose output when compiling (use make V=99 for verbose output) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -558,6 +562,7 @@ AC_CONFIG_FILES([include/Makefile examples/Makefile python/Makefile xfitter-config + reactions/KRunning/src/Makefile reactions/AFB/src/Makefile reactions/KFactor/src/Makefile reactions/BaseDISCC/src/Makefile diff --git a/doxygen.cfg b/doxygen.cfg index 23c24ae70..747dca5f6 100644 --- a/doxygen.cfg +++ b/doxygen.cfg @@ -574,7 +574,7 @@ INPUT = include src \ Hathor/interface Hathor/src EW/src \ NNPDF/include NNPDF/src Cascade/src \ DY/src DY/include \ - reactions/APPLgrid/include reactions/FONLL_DISCC/src reactions/FONLL_DISCC/include reactions/FONLL_DISNC/src reactions/FONLL_DISNC/include reactions/KFactor/src reactions/KFactor/include reactions/FFABM_DISCC/src reactions/FFABM_DISCC/include reactions/Fractal_DISNC/src reactions/Fractal_DISNC/include reactions/BaseDISCC/src reactions/BaseDISCC/include reactions/FFABM_DISNC/src reactions/FFABM_DISNC/include reactions/Hathor/src reactions/Hathor/include reactions/RT_DISNC/src reactions/RT_DISNC/include reactions/BaseDISNC/src reactions/BaseDISNC/include \ + reactions/APPLgrid/include reactions/KRunning/src reactions/KRunning/include reactions/FONLL_DISCC/src reactions/FONLL_DISCC/include reactions/FONLL_DISNC/src reactions/FONLL_DISNC/include reactions/KFactor/src reactions/KFactor/include reactions/FFABM_DISCC/src reactions/FFABM_DISCC/include reactions/Fractal_DISNC/src reactions/Fractal_DISNC/include reactions/BaseDISCC/src reactions/BaseDISCC/include reactions/FFABM_DISNC/src reactions/FFABM_DISNC/include reactions/Hathor/src reactions/Hathor/include reactions/RT_DISNC/src reactions/RT_DISNC/include reactions/BaseDISNC/src reactions/BaseDISNC/include \ reactions/APPLgrid/src \ reactions/fastNLO/include \ reactions/fastNLO/src \ diff --git a/reactions/Hathor/include/ReactionHathor.h b/reactions/Hathor/include/ReactionHathor.h index ec872bec8..93eed9ba2 100644 --- a/reactions/Hathor/include/ReactionHathor.h +++ b/reactions/Hathor/include/ReactionHathor.h @@ -44,6 +44,7 @@ class ReactionHathor : public ReactionTheory int* _rndStore; int _scheme; double _mtop; + std::map<int, double*> _mtopPerInstance; double _mr; double _mf; }; diff --git a/reactions/Hathor/src/ReactionHathor.cc b/reactions/Hathor/src/ReactionHathor.cc index f12eb6df7..d148178db 100644 --- a/reactions/Hathor/src/ReactionHathor.cc +++ b/reactions/Hathor/src/ReactionHathor.cc @@ -85,6 +85,12 @@ int ReactionHathor::initAtStart(const string &s) hf_errlog_(17081101, str.c_str(), strlen(str.c_str())); } _mtop = GetParam("mtp"); + + // !!!! + for(map<string, double* >::iterator it = _xfitter_pars.begin(); it != _xfitter_pars.end(); it++) + { + printf("_xfitter_pars[%s] = %f\n", it->first.c_str(), *it->second); + } // renorm. scale _mr = _mtop; @@ -176,12 +182,33 @@ void ReactionHathor::setDatasetParameters(int dataSetID, map<std::string, std::s // set centre-of-mass energy hathor->setSqrtShad(sqrtS); + // set mass, if provided as a parameter (for MSbar scheme, calculations with several mass values are needed) + // fix memory leak + it = pars.find("mtp"); + if(it != pars.end()) + //_mtopPerInstance[dataSetID] = std::shared_ptr<double>(new double(atof(it->second.c_str()))); + _mtopPerInstance[dataSetID] = new double(atof(it->second.c_str())); + else + _mtopPerInstance[dataSetID] = &_mtop; + // set scheme - hathor->setScheme(_scheme); + // for MSbar scheme, both LO and NLO calculations are needed, therefore determine perturbative order separately for each instance + auto scheme = _scheme; + it = pars.find("Order"); + if(it != pars.end()) + { + printf("Order: %s\n", it->second.c_str()); + scheme = Hathor::LO; + if(it->second == "NLO") + scheme = scheme | Hathor::NLO; + else if(it->second == "NNLO") + scheme = scheme | Hathor::NNLO; + } + hathor->setScheme(scheme); // set precision level hathor->setPrecision(precisionLevel); - + // done hathor->PrintOptions(); _hathorArray[dataSetID] = hathor; @@ -194,7 +221,8 @@ int ReactionHathor::compute(int dataSetID, valarray<double> &val, map<string, va rlxd_reset(_rndStore); Hathor* hathor = _hathorArray.at(dataSetID); - hathor->getXsection(_mtop, _mr, _mf); + //hathor->getXsection(_mtop, _mr, _mf); + hathor->getXsection(*_mtopPerInstance[dataSetID], _mr, _mf); double dum = 0.0; val[0] = 0.0; hathor->getResult(0, val[0], dum); diff --git a/reactions/KRunning/include/ReactionKRunning.h b/reactions/KRunning/include/ReactionKRunning.h new file mode 100644 index 000000000..2b751aa64 --- /dev/null +++ b/reactions/KRunning/include/ReactionKRunning.h @@ -0,0 +1,47 @@ + +#pragma once + +#include "ReactionTheory.h" + +/** + @class' ReactionKRunning + + @brief A wrapper class for KRunning reaction + + Based on the ReactionTheory class. Reads options produces 3d cross section. + + @version 0.1 + @date 2019-01-16 + */ + +class ReactionKRunning : public ReactionTheory +{ + public: + ReactionKRunning(){}; + +// ~ReactionKRunning(){}; +// ~ReactionKRunning(const ReactionKRunning &){}; +// ReactionKRunning & operator =(const ReactionKRunning &r){return *(new ReactionKRunning(r));}; + + public: + virtual string getReactionName() const { return "KRunning" ;}; + int initAtStart(const string &); + virtual void setDatasetParameters(int dataSetID, map<string,string> pars, map<string,double> dsPars) override; + virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err); + protected: + virtual int parseOptions(){ return 0;}; + + std::map<int, std::string> _type; + std::map<int, std::string> _q; + std::map<int, std::string> _q0; + + double getAlphaS(double q) { return alphaS(q); } + double getMassMSbar(const double m0, const double q, const double as, const double as0) + { + const double c0 = 4.0 / 9.0; + // m0 is m(m) + double mMsBar = m0 * pow(as / as0, c0); + return mMsBar; + } +}; + diff --git a/reactions/KRunning/src/Makefile.am b/reactions/KRunning/src/Makefile.am new file mode 100644 index 000000000..3cc25786a --- /dev/null +++ b/reactions/KRunning/src/Makefile.am @@ -0,0 +1,15 @@ + +# Created by AddReaction.py on 2019-01-16 + +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -Wall -fPIC -Wno-deprecated + +lib_LTLIBRARIES = libkrunning_xfitter.la +libkrunning_xfitter_la_SOURCES = ReactionKRunning.cc + +# libkrunning_xfitter_la_LDFLAGS = place_if_needed + +datadir = ${prefix}/yaml/reactions/KRunning +data_DATA = ../yaml/parameters.yaml + +dist_noinst_HEADERS = ../include ../yaml + \ No newline at end of file diff --git a/reactions/KRunning/src/ReactionKRunning.cc b/reactions/KRunning/src/ReactionKRunning.cc new file mode 100644 index 000000000..0ef93daf6 --- /dev/null +++ b/reactions/KRunning/src/ReactionKRunning.cc @@ -0,0 +1,60 @@ + +/* + @file ReactionKRunning.cc + @date 2019-01-16 + @author AddReaction.py + Created by AddReaction.py on 2019-01-16 +*/ + +#include "ReactionKRunning.h" + +// the class factories +extern "C" ReactionKRunning* create() { + return new ReactionKRunning(); +} + + +// Initialize at the start of the computation +int ReactionKRunning::initAtStart(const string &s) +{ + return 0; +} + +void ReactionKRunning::setDatasetParameters(int dataSetID, map<std::string, std::string> pars, map<std::string, double> dsPars) +{ + // check if dataset with provided ID already exists + if(_type.find(dataSetID) != _type.end()) + hf_errlog(19011501, "F: dataset with id " + std::to_string(dataSetID) + " already exists"); + + // read type of running + // presently only alphaS (accesses whatever running implemented in xFitter) and mass MSbar running (at NLO) is implemented + auto it = pars.find("type"); + if(it == pars.end()) + hf_errlog(19011502, "F: no type of running for dataset with id " + std::to_string(dataSetID)); + if(it->second != "as" && it->second != "massMSbarNLO") + hf_errlog(19011503, "F: unsupported running type = " + it->second); + _type[dataSetID] = it->second; + + // read scale + it = pars.find("q"); + _q[dataSetID] = it->second; + + // for type=massMSbarNLO read q0: scale at which m(m) is quoted + if(_type[dataSetID] == "massMSbarNLO") + _q0[dataSetID] = pars.find("q0")->second; +} + +// Main function to compute results at an iteration +int ReactionKRunning::compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err) +{ + double q = GetParam(_q[dataSetID]); + if(_type[dataSetID] == "as") + val = getAlphaS(q); + else if(_type[dataSetID] == "massMSbarNLO") + { + double q0 = GetParam(_q0[dataSetID]); + val = getMassMSbar(q0, q, getAlphaS(q0), getAlphaS(q)); + } + for(int i = 0; i < val.size(); i++) + printf("val[%d] = %f\n", i, val[i]); +} diff --git a/reactions/KRunning/yaml/parameters.yaml b/reactions/KRunning/yaml/parameters.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/src/TheorEval.cc b/src/TheorEval.cc index 4c717c34a..0a7f4a420 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -143,7 +143,7 @@ TheorEval::assignTokens(list<tToken> &sl) sl.push_back(t); continue; } - if ( term == string("spline") || term == string("spline_derivative") ) + if ( term == string("spline") || term == string("splinederivative") ) { // special case for natural cubic spline interpolation if ( term == string("spline")) @@ -151,10 +151,10 @@ TheorEval::assignTokens(list<tToken> &sl) t.opr = 6; t.name = "spline"; } - else if ( term == string("spline_derivative")) + else if ( term == string("splinederivative")) { t.opr = 7; - t.name = "spline"; + t.name = "splinederivative"; } // push spline sl.push_back(t); @@ -713,7 +713,7 @@ TheorEval::Evaluate(valarray<double> &vte ) } double avg = stk.top().sum()/stk.top().size(); stk.top() = avg;*/ - } else if ( it->name == string("spline") || it->name == string("spline_derivative") ) + } else if ( it->name == string("spline") || it->name == string("splinederivative") ) { // load all arguments int narg = it->narg; @@ -725,6 +725,7 @@ TheorEval::Evaluate(valarray<double> &vte ) std::valarray<double> x0 = stk.top(); stk.pop(); int nsections = (it->narg - 1) / 2; + printf("nsections = %d\n", nsections); std::valarray<std::valarray<double> > x(nsections); std::valarray<std::valarray<double> > y(nsections); for(int sect = nsections - 1; sect >= 0; sect--) @@ -743,11 +744,12 @@ TheorEval::Evaluate(valarray<double> &vte ) { xSpline[sect] = x[sect][p]; ySpline[sect] = y[sect][p]; + printf("sect = %f x,y = %f,%f\n", sect, xSpline[sect], ySpline[sect]); } NaturalCubicSpline spline = NaturalCubicSpline(xSpline, ySpline); if(it->name == string("spline")) result[p] = spline.Eval(x0[p]); - else if(it->name == string("spline_derivative")) + else if(it->name == string("splinederivative")) result[p] = spline.Eval(x0[p], 1); } stk.push(result); -- GitLab From e96a98225b8f6a10fc00fd549c946edf782d86e6 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Fri, 25 Jan 2019 22:01:51 +0100 Subject: [PATCH 11/81] updated spline interpolation, increased expression capacity --- common/linalg/NaturalCubicSpline.h | 139 ------- common/linalg/spline.h | 427 ++++++++++++++++++++++ include/theorexpr.inc | 6 +- reactions/Hathor/include/ReactionHathor.h | 7 +- reactions/Hathor/src/ReactionHathor.cc | 215 +++++------ src/TheorEval.cc | 19 +- src/ftheor_eval.cc | 6 +- 7 files changed, 544 insertions(+), 275 deletions(-) delete mode 100644 common/linalg/NaturalCubicSpline.h create mode 100644 common/linalg/spline.h diff --git a/common/linalg/NaturalCubicSpline.h b/common/linalg/NaturalCubicSpline.h deleted file mode 100644 index 51a3f4880..000000000 --- a/common/linalg/NaturalCubicSpline.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef NATURALCUBICSPLINE_H -#define NATURALCUBICSPLINE_H - -// code mostly from https://stackoverflow.com/questions/1204553/are-there-any-good-libraries-for-solving-cubic-splines-in-c - -#include<iostream> -#include<vector> -#include<algorithm> -#include<cmath> -using namespace std; - -typedef vector<double> vec; - -class NaturalCubicSpline -{ - public: - NaturalCubicSpline(vec &x, vec &y) - { - _vectorSplineSet = Spline(x, y); - } - - double Eval(double x, const bool flagDerivative = false) - { - for(size_t i = 1; i < _vectorSplineSet.size(); i++) - { - if(_vectorSplineSet[i].x > x || i == (_vectorSplineSet.size() - 1)) - { - //printf("Eval: x = %f in section %lu [%f %f]\n", x, i, _vectorSplineSet[i - 1].x, _vectorSplineSet[i].x); - if( (i == 1 && x < _vectorSplineSet[0].x) || (i == (_vectorSplineSet.size() - 1) && x > _vectorSplineSet[_vectorSplineSet.size() - 1].x) ) - printf("Warning: x = %f outside spline range [%f %f]\n", x, _vectorSplineSet[0].x, _vectorSplineSet[_vectorSplineSet.size() - 1].x); - const SplineSet& s = _vectorSplineSet[i - 1]; - double y = 0.0; - double dx = x - s.x; - if(flagDerivative) - y = 3 * s.d * dx * dx + 2 * s.c * dx + s.b; - else - y = s.d * dx * dx * dx + s.c * dx * dx + s.b * dx + s.a; - //printf("y = %f\n", y); - return y; - } - } - // should not be here - throw; - } - - private: - struct SplineSet - { - double a; - double b; - double c; - double d; - double x; - }; - std::vector<SplineSet> _vectorSplineSet; - - std::vector<SplineSet> Spline(vec &x, vec &y) - { - // check input - // at least 4 points - if(x.size() < 4) - hf_errlog(18091000, "F: Natural cubic spline needs at least 4 input points"); - // x in ascending order - for(size_t s = 1; s < x.size(); s++) - if(x[s] <= x[s - 1]) - hf_errlog(18091001, "F: Natural cubic spline needs x points in accessing order"); - // x and y have same size - if(x.size() != y.size()) - hf_errlog(18091002, "F: Natural cubic spline needs same number of x and y points"); - - int n = x.size()-1; - vec a; - a.insert(a.begin(), y.begin(), y.end()); - vec b(n); - vec d(n); - vec h; - - for(int i = 0; i < n; ++i) - h.push_back(x[i+1]-x[i]); - - vec alpha; - for(int i = 0; i < n; ++i) - alpha.push_back( 3*(a[i+1]-a[i])/h[i] - 3*(a[i]-a[i-1])/h[i-1] ); - - vec c(n+1); - vec l(n+1); - vec mu(n+1); - vec z(n+1); - l[0] = 1; - mu[0] = 0; - z[0] = 0; - - for(int i = 1; i < n; ++i) - { - l[i] = 2 *(x[i+1]-x[i-1])-h[i-1]*mu[i-1]; - mu[i] = h[i]/l[i]; - z[i] = (alpha[i]-h[i-1]*z[i-1])/l[i]; - } - - l[n] = 1; - z[n] = 0; - c[n] = 0; - - for(int j = n-1; j >= 0; --j) - { - c[j] = z [j] - mu[j] * c[j+1]; - b[j] = (a[j+1]-a[j])/h[j]-h[j]*(c[j+1]+2*c[j])/3; - d[j] = (c[j+1]-c[j])/3/h[j]; - } - - vector<SplineSet> output_set(n); - for(int i = 0; i < n; ++i) - { - output_set[i].a = a[i]; - output_set[i].b = b[i]; - output_set[i].c = c[i]; - output_set[i].d = d[i]; - output_set[i].x = x[i]; - } - return output_set; - } -}; - -/*int main() -{ - vec x(11); - vec y(11); - for(int i = 0; i < x.size(); ++i) - { - x[i] = i; - y[i] = sin(i); - } - - vector<SplineSet> cs = spline(x, y); - for(int i = 0; i < cs.size(); ++i) - cout << cs[i].d << "\t" << cs[i].c << "\t" << cs[i].b << "\t" << cs[i].a << endl; -}*/ - -#endif // NATURALCUBICSPLINE_H diff --git a/common/linalg/spline.h b/common/linalg/spline.h new file mode 100644 index 000000000..2e46efa67 --- /dev/null +++ b/common/linalg/spline.h @@ -0,0 +1,427 @@ +/* + * spline.h + * + * simple cubic spline interpolation library without external + * dependencies + * + * --------------------------------------------------------------------- + * Copyright (C) 2011, 2014 Tino Kluge (ttk448 at gmail.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * --------------------------------------------------------------------- + * + */ + +// 21.01.2019 Modified by Oleksandr Zenaiev (implemented input checks and derivative calculation) + + +#ifndef TK_SPLINE_H +#define TK_SPLINE_H + +#include <cstdio> +#include <cassert> +#include <vector> +#include <algorithm> + + +// unnamed namespace only because the implementation is in this +// header file and we don't want to export symbols to the obj files +namespace +{ + +namespace tk +{ + +// band matrix solver +class band_matrix +{ +private: + std::vector< std::vector<double> > m_upper; // upper band + std::vector< std::vector<double> > m_lower; // lower band +public: + band_matrix() {}; // constructor + band_matrix(int dim, int n_u, int n_l); // constructor + ~band_matrix() {}; // destructor + void resize(int dim, int n_u, int n_l); // init with dim,n_u,n_l + int dim() const; // matrix dimension + int num_upper() const + { + return m_upper.size()-1; + } + int num_lower() const + { + return m_lower.size()-1; + } + // access operator + double & operator () (int i, int j); // write + double operator () (int i, int j) const; // read + // we can store an additional diogonal (in m_lower) + double& saved_diag(int i); + double saved_diag(int i) const; + void lu_decompose(); + std::vector<double> r_solve(const std::vector<double>& b) const; + std::vector<double> l_solve(const std::vector<double>& b) const; + std::vector<double> lu_solve(const std::vector<double>& b, + bool is_lu_decomposed=false); + +}; + + +// spline interpolation +class spline +{ +public: + enum bd_type { + first_deriv = 1, + second_deriv = 2 + }; + +private: + std::vector<double> m_x,m_y; // x,y coordinates of points + // interpolation parameters + // f(x) = a*(x-x_i)^3 + b*(x-x_i)^2 + c*(x-x_i) + y_i + std::vector<double> m_a,m_b,m_c; // spline coefficients + double m_b0, m_c0; // for left extrapol + bd_type m_left, m_right; + double m_left_value, m_right_value; + bool m_force_linear_extrapolation; + +public: + // set default boundary condition to be zero curvature at both ends + spline(): m_left(second_deriv), m_right(second_deriv), + m_left_value(0.0), m_right_value(0.0), + m_force_linear_extrapolation(false) + { + ; + } + + // optional, but if called it has to come be before set_points() + void set_boundary(bd_type left, double left_value, + bd_type right, double right_value, + bool force_linear_extrapolation=false); + void set_points(const std::vector<double>& x, + const std::vector<double>& y, bool cubic_spline=true); + double operator() (double x, bool flagDerivative = false) const; +}; + + + +// --------------------------------------------------------------------- +// implementation part, which could be separated into a cpp file +// --------------------------------------------------------------------- + + +// band_matrix implementation +// ------------------------- + +band_matrix::band_matrix(int dim, int n_u, int n_l) +{ + resize(dim, n_u, n_l); +} +void band_matrix::resize(int dim, int n_u, int n_l) +{ + assert(dim>0); + assert(n_u>=0); + assert(n_l>=0); + m_upper.resize(n_u+1); + m_lower.resize(n_l+1); + for(size_t i=0; i<m_upper.size(); i++) { + m_upper[i].resize(dim); + } + for(size_t i=0; i<m_lower.size(); i++) { + m_lower[i].resize(dim); + } +} +int band_matrix::dim() const +{ + if(m_upper.size()>0) { + return m_upper[0].size(); + } else { + return 0; + } +} + + +// defines the new operator (), so that we can access the elements +// by A(i,j), index going from i=0,...,dim()-1 +double & band_matrix::operator () (int i, int j) +{ + int k=j-i; // what band is the entry + assert( (i>=0) && (i<dim()) && (j>=0) && (j<dim()) ); + assert( (-num_lower()<=k) && (k<=num_upper()) ); + // k=0 -> diogonal, k<0 lower left part, k>0 upper right part + if(k>=0) return m_upper[k][i]; + else return m_lower[-k][i]; +} +double band_matrix::operator () (int i, int j) const +{ + int k=j-i; // what band is the entry + assert( (i>=0) && (i<dim()) && (j>=0) && (j<dim()) ); + assert( (-num_lower()<=k) && (k<=num_upper()) ); + // k=0 -> diogonal, k<0 lower left part, k>0 upper right part + if(k>=0) return m_upper[k][i]; + else return m_lower[-k][i]; +} +// second diag (used in LU decomposition), saved in m_lower +double band_matrix::saved_diag(int i) const +{ + assert( (i>=0) && (i<dim()) ); + return m_lower[0][i]; +} +double & band_matrix::saved_diag(int i) +{ + assert( (i>=0) && (i<dim()) ); + return m_lower[0][i]; +} + +// LR-Decomposition of a band matrix +void band_matrix::lu_decompose() +{ + int i_max,j_max; + int j_min; + double x; + + // preconditioning + // normalize column i so that a_ii=1 + for(int i=0; i<this->dim(); i++) { + assert(this->operator()(i,i)!=0.0); + this->saved_diag(i)=1.0/this->operator()(i,i); + j_min=std::max(0,i-this->num_lower()); + j_max=std::min(this->dim()-1,i+this->num_upper()); + for(int j=j_min; j<=j_max; j++) { + this->operator()(i,j) *= this->saved_diag(i); + } + this->operator()(i,i)=1.0; // prevents rounding errors + } + + // Gauss LR-Decomposition + for(int k=0; k<this->dim(); k++) { + i_max=std::min(this->dim()-1,k+this->num_lower()); // num_lower not a mistake! + for(int i=k+1; i<=i_max; i++) { + assert(this->operator()(k,k)!=0.0); + x=-this->operator()(i,k)/this->operator()(k,k); + this->operator()(i,k)=-x; // assembly part of L + j_max=std::min(this->dim()-1,k+this->num_upper()); + for(int j=k+1; j<=j_max; j++) { + // assembly part of R + this->operator()(i,j)=this->operator()(i,j)+x*this->operator()(k,j); + } + } + } +} +// solves Ly=b +std::vector<double> band_matrix::l_solve(const std::vector<double>& b) const +{ + assert( this->dim()==(int)b.size() ); + std::vector<double> x(this->dim()); + int j_start; + double sum; + for(int i=0; i<this->dim(); i++) { + sum=0; + j_start=std::max(0,i-this->num_lower()); + for(int j=j_start; j<i; j++) sum += this->operator()(i,j)*x[j]; + x[i]=(b[i]*this->saved_diag(i)) - sum; + } + return x; +} +// solves Rx=y +std::vector<double> band_matrix::r_solve(const std::vector<double>& b) const +{ + assert( this->dim()==(int)b.size() ); + std::vector<double> x(this->dim()); + int j_stop; + double sum; + for(int i=this->dim()-1; i>=0; i--) { + sum=0; + j_stop=std::min(this->dim()-1,i+this->num_upper()); + for(int j=i+1; j<=j_stop; j++) sum += this->operator()(i,j)*x[j]; + x[i]=( b[i] - sum ) / this->operator()(i,i); + } + return x; +} + +std::vector<double> band_matrix::lu_solve(const std::vector<double>& b, + bool is_lu_decomposed) +{ + assert( this->dim()==(int)b.size() ); + std::vector<double> x,y; + if(is_lu_decomposed==false) { + this->lu_decompose(); + } + y=this->l_solve(b); + x=this->r_solve(y); + return x; +} + + + + +// spline implementation +// ----------------------- + +void spline::set_boundary(spline::bd_type left, double left_value, + spline::bd_type right, double right_value, + bool force_linear_extrapolation) +{ + assert(m_x.size()==0); // set_points() must not have happened yet + m_left=left; + m_right=right; + m_left_value=left_value; + m_right_value=right_value; + m_force_linear_extrapolation=force_linear_extrapolation; +} + + +void spline::set_points(const std::vector<double>& x, + const std::vector<double>& y, bool cubic_spline) +{ + // check input and provide informative error messages + // at least 4 points + if(x.size() < 4) + hf_errlog(18091000, "F: Spline needs at least 4 input points"); + // x in ascending order + for(size_t s = 1; s < x.size(); s++) + if(x[s] <= x[s - 1]) + hf_errlog(18091001, "F: Spline needs x points in accessing order"); + // x and y have same size + if(x.size() != y.size()) + hf_errlog(18091002, "F: Spline needs same number of x and y points"); + + assert(x.size()==y.size()); + assert(x.size()>2); + m_x=x; + m_y=y; + int n=x.size(); + // TODO: maybe sort x and y, rather than returning an error + for(int i=0; i<n-1; i++) { + assert(m_x[i]<m_x[i+1]); + } + + if(cubic_spline==true) { // cubic spline interpolation + // setting up the matrix and right hand side of the equation system + // for the parameters b[] + band_matrix A(n,1,1); + std::vector<double> rhs(n); + for(int i=1; i<n-1; i++) { + A(i,i-1)=1.0/3.0*(x[i]-x[i-1]); + A(i,i)=2.0/3.0*(x[i+1]-x[i-1]); + A(i,i+1)=1.0/3.0*(x[i+1]-x[i]); + rhs[i]=(y[i+1]-y[i])/(x[i+1]-x[i]) - (y[i]-y[i-1])/(x[i]-x[i-1]); + } + // boundary conditions + if(m_left == spline::second_deriv) { + // 2*b[0] = f'' + A(0,0)=2.0; + A(0,1)=0.0; + rhs[0]=m_left_value; + } else if(m_left == spline::first_deriv) { + // c[0] = f', needs to be re-expressed in terms of b: + // (2b[0]+b[1])(x[1]-x[0]) = 3 ((y[1]-y[0])/(x[1]-x[0]) - f') + A(0,0)=2.0*(x[1]-x[0]); + A(0,1)=1.0*(x[1]-x[0]); + rhs[0]=3.0*((y[1]-y[0])/(x[1]-x[0])-m_left_value); + } else { + assert(false); + } + if(m_right == spline::second_deriv) { + // 2*b[n-1] = f'' + A(n-1,n-1)=2.0; + A(n-1,n-2)=0.0; + rhs[n-1]=m_right_value; + } else if(m_right == spline::first_deriv) { + // c[n-1] = f', needs to be re-expressed in terms of b: + // (b[n-2]+2b[n-1])(x[n-1]-x[n-2]) + // = 3 (f' - (y[n-1]-y[n-2])/(x[n-1]-x[n-2])) + A(n-1,n-1)=2.0*(x[n-1]-x[n-2]); + A(n-1,n-2)=1.0*(x[n-1]-x[n-2]); + rhs[n-1]=3.0*(m_right_value-(y[n-1]-y[n-2])/(x[n-1]-x[n-2])); + } else { + assert(false); + } + + // solve the equation system to obtain the parameters b[] + m_b=A.lu_solve(rhs); + + // calculate parameters a[] and c[] based on b[] + m_a.resize(n); + m_c.resize(n); + for(int i=0; i<n-1; i++) { + m_a[i]=1.0/3.0*(m_b[i+1]-m_b[i])/(x[i+1]-x[i]); + m_c[i]=(y[i+1]-y[i])/(x[i+1]-x[i]) + - 1.0/3.0*(2.0*m_b[i]+m_b[i+1])*(x[i+1]-x[i]); + } + } else { // linear interpolation + m_a.resize(n); + m_b.resize(n); + m_c.resize(n); + for(int i=0; i<n-1; i++) { + m_a[i]=0.0; + m_b[i]=0.0; + m_c[i]=(m_y[i+1]-m_y[i])/(m_x[i+1]-m_x[i]); + } + } + + // for left extrapolation coefficients + m_b0 = (m_force_linear_extrapolation==false) ? m_b[0] : 0.0; + m_c0 = m_c[0]; + + // for the right extrapolation coefficients + // f_{n-1}(x) = b*(x-x_{n-1})^2 + c*(x-x_{n-1}) + y_{n-1} + double h=x[n-1]-x[n-2]; + // m_b[n-1] is determined by the boundary condition + m_a[n-1]=0.0; + m_c[n-1]=3.0*m_a[n-2]*h*h+2.0*m_b[n-2]*h+m_c[n-2]; // = f'_{n-2}(x_{n-1}) + if(m_force_linear_extrapolation==true) + m_b[n-1]=0.0; +} + +double spline::operator() (double x, bool flagDerivative) const +{ + size_t n=m_x.size(); + // find the closest point m_x[idx] < x, idx=0 even if x<m_x[0] + std::vector<double>::const_iterator it; + it=std::lower_bound(m_x.begin(),m_x.end(),x); + int idx=std::max( int(it-m_x.begin())-1, 0); + + double h=x-m_x[idx]; + double interpol; + if(x<m_x[0]) { + // extrapolation to the left + if(!flagDerivative) + interpol=(m_b0*h + m_c0)*h + m_y[0]; + else + interpol=2*h*m_b0 + m_c0; + } else if(x>m_x[n-1]) { + // extrapolation to the right + if(!flagDerivative) + interpol=(m_b[n-1]*h + m_c[n-1])*h + m_y[n-1]; + else + interpol=2*h*m_b[n-1] + m_c[n-1]; + } else { + // interpolation + if(!flagDerivative) + interpol=((m_a[idx]*h + m_b[idx])*h + m_c[idx])*h + m_y[idx]; + else + interpol=3*h*h*m_a[idx] + 2*h*m_b[idx] + m_c[idx]; + } + return interpol; +} + + +} // namespace tk + + +} // namespace + +#endif /* TK_SPLINE_H */ diff --git a/include/theorexpr.inc b/include/theorexpr.inc index d9e101531..a257c457e 100644 --- a/include/theorexpr.inc +++ b/include/theorexpr.inc @@ -1,12 +1,12 @@ C> Common block for theory expression integer NTermsMax - parameter (NTermsMax = 32) + parameter (NTermsMax = 128) double precision dynscale integer NTerms - character*8 TermName(NTermsMax) + character*32 TermName(NTermsMax) character*80 TermType(NTermsMax) - character*2048 TermInfo(NTermsMax) + character*4096 TermInfo(NTermsMax) character*256 TermSource(NTermsMax) character*1000 TheorExpr integer ppbar_collisions diff --git a/reactions/Hathor/include/ReactionHathor.h b/reactions/Hathor/include/ReactionHathor.h index 93eed9ba2..2495d4188 100644 --- a/reactions/Hathor/include/ReactionHathor.h +++ b/reactions/Hathor/include/ReactionHathor.h @@ -42,10 +42,9 @@ class ReactionHathor : public ReactionTheory HathorPdfxFitter* _pdf; int* _rndStore; - int _scheme; - double _mtop; + //double _mtop; std::map<int, double*> _mtopPerInstance; - double _mr; - double _mf; + std::map<int, double*> _mrPerInstance; + std::map<int, double*> _mfPerInstance; }; diff --git a/reactions/Hathor/src/ReactionHathor.cc b/reactions/Hathor/src/ReactionHathor.cc index d148178db..3c9e999a9 100644 --- a/reactions/Hathor/src/ReactionHathor.cc +++ b/reactions/Hathor/src/ReactionHathor.cc @@ -29,10 +29,9 @@ ReactionHathor::ReactionHathor() { _pdf = NULL; _rndStore = NULL; - _scheme = -1; - _mtop = -1.0; - _mr = -1.0; - _mf = -1.0; + //_mtop = -1.0; + //_mr = -1.0; + //_mf = -1.0; } ReactionHathor::~ReactionHathor() @@ -63,50 +62,20 @@ int ReactionHathor::initAtStart(const string &s) _rndStore = new int[nRnd]; rlxd_get(_rndStore); - // scheme (perturbative order and pole/MSbar mass treatment) - const string order = GetParamS("Order"); - const int pertubOrder = OrderMap(order); - _scheme = Hathor::LO; - if(pertubOrder > 1) - _scheme = _scheme | Hathor::NLO; - if(pertubOrder > 2) - _scheme = _scheme | Hathor::NNLO; - int msMass = 0; // pole mass by default - if(checkParam("MS_MASS")) - msMass = GetParamI("MS_MASS"); - if(msMass) - _scheme = _scheme | Hathor::MS_MASS; - // top quark mass - std::string mtopName = "mtp";// shouldn't we distinguish somehow between pole and running masses? - if(!checkParam(mtopName)) - { - std::string str = "F: no top quark mass (\"" + mtopName + "\" parameter) for Hathor"; - hf_errlog_(17081101, str.c_str(), strlen(str.c_str())); - } - _mtop = GetParam("mtp"); + //std::string mtopName = "mtp";// shouldn't we distinguish somehow between pole and running masses? + //if(!checkParam(mtopName)) + //{ + // std::string str = "F: no top quark mass (\"" + mtopName + "\" parameter) for Hathor"; + // hf_errlog_(17081101, str.c_str(), strlen(str.c_str())); + //} + //_mtop = GetParam("mtp"); // !!!! - for(map<string, double* >::iterator it = _xfitter_pars.begin(); it != _xfitter_pars.end(); it++) - { - printf("_xfitter_pars[%s] = %f\n", it->first.c_str(), *it->second); - } - - // renorm. scale - _mr = _mtop; - if(checkParam("muR")) - _mr *= GetParam("muR"); - - // fact. scale - _mf = _mtop; - if(checkParam("muF")) - _mf *= GetParam("muF"); - - std::cout << " Hathor will use:"; - std::cout << " mtop = " << _mtop << "[GeV] "; - std::cout << " renorm. scale = " << _mr << "[GeV] "; - std::cout << " fact. scale = " << _mf << "[GeV]"; - std::cout << std::endl; + //for(map<string, double* >::iterator it = _xfitter_pars.begin(); it != _xfitter_pars.end(); it++) + //{ + // printf("_xfitter_pars[%s] = %f\n", it->first.c_str(), *it->second); + //} return 0; } @@ -121,94 +90,96 @@ void ReactionHathor::setDatasetParameters(int dataSetID, map<std::string, std::s hf_errlog_(17080701, str, strlen(str)); } - // read centre-of-mass energy from provided dataset parameters - // (must be provided) - auto it = pars.find("SqrtS"); - if(it == pars.end()) - { - char str[256]; - sprintf(str, "F: no SqrtS for dataset with id = %d", dataSetID); - hf_errlog_(17080702, str, strlen(str)); - } - double sqrtS = atof(it->second.c_str()); - - // read precision level from provided dataset parameters - // if not specified set to default 2 -> Hathor::MEDIUM - int precisionLevel = Hathor::MEDIUM; - it = pars.find("precisionLevel"); - if(it != pars.end()) - { - precisionLevel = std::pow(10, 2 + atoi(it->second.c_str())); - // check that this setting is allowed - // see in AbstractHathor.h: - // enum ACCURACY { LOW=1000, MEDIUM=10000, HIGH=100000 }; - // and - // precisionLevel = 1 -> Hathor::LOW - // precisionLevel = 2 -> Hathor::MEDIUM - // precisionLevel = 3 -> Hathor::HIGH - if(precisionLevel != Hathor::LOW && precisionLevel != Hathor::MEDIUM && precisionLevel != Hathor::HIGH) - { - char str[256]; - sprintf(str, "F: provided precision level = %d not supported by Hathor", precisionLevel); - hf_errlog_(17081102, str, strlen(str)); - } - } - - // read ppbar from provided dataset parameters - // if not specified assume it is false (pp collisions) - int ppbar = false; - it = pars.find("ppbar"); - if(it != pars.end()) - { - ppbar = atoi(it->second.c_str()); - if(ppbar != 0 && ppbar != 1) - { - char str[256]; - sprintf(str, "F: provided ppbar = %d not recognised (must be 0 or 1)", ppbar); - hf_errlog_(17081103, str, strlen(str)); - } - } - // instantiate Hathor Hathor* hathor = new Hathor(*_pdf); //Hathor* hathor = new Hathor(); // set collision type + // read ppbar (0 for pp, 1 for ppbar) from provided dataset parameters + // if not specified assume it is 0 (pp collisions) + // here local value is preferred over global one (to allow different data sets for different collision types) + int ppbar = false; + if(pars.find("ppbar") != pars.end()) + ppbar = atoi(pars.find("ppbar")->second.c_str()); + else if(checkParam("ppbar")) + ppbar = GetParamI("ppbar"); if(ppbar) hathor->setColliderType(Hathor::PPBAR); else hathor->setColliderType(Hathor::PP); - // set centre-of-mass energy + // read centre-of-mass energy from provided dataset parameters (must be provided) + // here local value is preferred over global one (to allow different data sets with difference centre-of-mass energies) + double sqrtS = (pars.find("SqrtS") != pars.end()) ? atof(pars.find("SqrtS")->second.c_str()) : GetParam("SqrtS"); + if(sqrtS == 0.0) + hf_errlog(17080702, "F: no SqrtS for dataset with id = " + std::to_string(dataSetID)); hathor->setSqrtShad(sqrtS); - // set mass, if provided as a parameter (for MSbar scheme, calculations with several mass values are needed) - // fix memory leak - it = pars.find("mtp"); - if(it != pars.end()) - //_mtopPerInstance[dataSetID] = std::shared_ptr<double>(new double(atof(it->second.c_str()))); - _mtopPerInstance[dataSetID] = new double(atof(it->second.c_str())); - else - _mtopPerInstance[dataSetID] = &_mtop; - - // set scheme - // for MSbar scheme, both LO and NLO calculations are needed, therefore determine perturbative order separately for each instance - auto scheme = _scheme; - it = pars.find("Order"); - if(it != pars.end()) - { - printf("Order: %s\n", it->second.c_str()); - scheme = Hathor::LO; - if(it->second == "NLO") - scheme = scheme | Hathor::NLO; - else if(it->second == "NNLO") - scheme = scheme | Hathor::NNLO; - } + // set mass + // here local value is preferred over global one (to allow calculations with several mass values, e.g. for translation into MSbar mass scheme) + // the value may change further in iterations, in this case store NULL pointer (will be updated at each iteration and treated as global value) + // TODO: fix memory leak + _mtopPerInstance[dataSetID] = (pars.find("mtp") != pars.end()) ? new double(atof(pars.find("mtp")->second.c_str())) : NULL; + + // set renorm. scale + _mrPerInstance[dataSetID] = _mtopPerInstance[dataSetID]; + if(_mtopPerInstance[dataSetID] && checkParam("muR")) + *_mrPerInstance[dataSetID] *= GetParam("muR"); + + // set fact. scale + _mfPerInstance[dataSetID] = _mtopPerInstance[dataSetID]; + if(_mtopPerInstance[dataSetID] && checkParam("muF")) + *_mfPerInstance[dataSetID] *= GetParam("muF"); + + // set perturbative order + // here local value is preferred over global one (to allow LO and NLO calculations in one run, e.g. for translation into MSbar mass scheme) + std::string schemeName = (pars.find("Order") != pars.end()) ? pars.find("Order")->second : GetParamS("Order"); + int scheme = Hathor::LO; + if(schemeName == "NLO") + scheme = scheme | Hathor::NLO; + else if(schemeName == "NNLO") + scheme = scheme | Hathor::NNLO; + // set mass scheme (default is pole mass scheme) + // here local value is preferred over global one + int msMass = 0; + if(pars.find("MS_MASS") != pars.end()) + msMass = atoi(pars.find("MS_MASS")->second.c_str()); + else if(checkParam("MS_MASS")) + msMass = GetParamI("MS_MASS"); + if(msMass) + scheme = scheme | Hathor::MS_MASS; hathor->setScheme(scheme); // set precision level + // read precision level from provided dataset parameters + // if not specified set to default 2 -> Hathor::MEDIUM + int precisionLevel = 2; + if(checkParam("precisionLevel")) + precisionLevel = GetParamI("precisionLevel"); + else if(pars.find("precisionLevel") != pars.end()) + precisionLevel = atoi(pars.find("precisionLevel")->second.c_str()); + precisionLevel = std::pow(10, 2 + precisionLevel); + // check that this setting is allowed + // see in AbstractHathor.h: + // enum ACCURACY { LOW=1000, MEDIUM=10000, HIGH=100000 }; + // and + // precisionLevel = 1 -> Hathor::LOW + // precisionLevel = 2 -> Hathor::MEDIUM + // precisionLevel = 3 -> Hathor::HIGH + if(precisionLevel != Hathor::LOW && precisionLevel != Hathor::MEDIUM && precisionLevel != Hathor::HIGH) + hf_errlog(17081102, "F: provided precision level = " + std::to_string(precisionLevel) + " not supported by Hathor"); hathor->setPrecision(precisionLevel); + std::cout << " Hathor will use for this instance (" + std::to_string(dataSetID) + "):" << std::endl; + double mt = _mtopPerInstance[dataSetID] ? *_mtopPerInstance[dataSetID] : GetParam("mtp"); + std::cout << " mtop = " << mt << "[GeV] " << std::endl; + std::cout << " renorm. scale = " << (_mrPerInstance[dataSetID] ? *_mrPerInstance[dataSetID] : (mt * GetParam("muR"))) << "[GeV] " << std::endl; + std::cout << " factor. scale = " << (_mfPerInstance[dataSetID] ? *_mfPerInstance[dataSetID] : (mt * GetParam("muF"))) << "[GeV] " << std::endl; + std::cout << " SqrtS = " << sqrtS << std::endl; + std::cout << " scheme: " << scheme << std::endl; + std::cout << " precisionLevel: " << precisionLevel << std::endl; + std::cout << std::endl; + // done hathor->PrintOptions(); _hathorArray[dataSetID] = hathor; @@ -222,12 +193,16 @@ int ReactionHathor::compute(int dataSetID, valarray<double> &val, map<string, va Hathor* hathor = _hathorArray.at(dataSetID); //hathor->getXsection(_mtop, _mr, _mf); - hathor->getXsection(*_mtopPerInstance[dataSetID], _mr, _mf); + double mt = _mtopPerInstance[dataSetID] ? *_mtopPerInstance[dataSetID] : GetParam("mtp"); + double mr = _mrPerInstance[dataSetID] ? *_mrPerInstance[dataSetID] : (mt * GetParam("muR")); + double mf = _mfPerInstance[dataSetID] ? *_mfPerInstance[dataSetID] : (mt * GetParam("muF")); + hathor->getXsection(mt, mr, mf); double dum = 0.0; - val[0] = 0.0; - hathor->getResult(0, val[0], dum); + double xsec = 0.0; + hathor->getResult(0, xsec, dum); + printf("mt,mr,mf,xsec: %f %f %f %f\n", mt, mr, mf, xsec); + val = xsec; //printf("VAL ************ %f\n", val[0]); return 0; } - diff --git a/src/TheorEval.cc b/src/TheorEval.cc index 0a7f4a420..1be69ba2c 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -24,7 +24,8 @@ #include <yaml-cpp/yaml.h> #include "xfitter_pars.h" -#include "linalg/NaturalCubicSpline.h" +//#include <TSpline.h> +#include <spline.h> using namespace std; @@ -725,7 +726,6 @@ TheorEval::Evaluate(valarray<double> &vte ) std::valarray<double> x0 = stk.top(); stk.pop(); int nsections = (it->narg - 1) / 2; - printf("nsections = %d\n", nsections); std::valarray<std::valarray<double> > x(nsections); std::valarray<std::valarray<double> > y(nsections); for(int sect = nsections - 1; sect >= 0; sect--) @@ -744,13 +744,20 @@ TheorEval::Evaluate(valarray<double> &vte ) { xSpline[sect] = x[sect][p]; ySpline[sect] = y[sect][p]; - printf("sect = %f x,y = %f,%f\n", sect, xSpline[sect], ySpline[sect]); } - NaturalCubicSpline spline = NaturalCubicSpline(xSpline, ySpline); + //TSpline3 spline("", &xSpline[0], &ySpline[0], ySpline.size()); + tk::spline spline; + spline.set_points(xSpline, ySpline); if(it->name == string("spline")) - result[p] = spline.Eval(x0[p]); + { + //result[p] = spline.Eval(x0[p]); + result[p] = spline(x0[0]); + } else if(it->name == string("splinederivative")) - result[p] = spline.Eval(x0[p], 1); + { + //result[p] = spline.Derivative(x0[p]); + result[p] = spline(x0[0], 1); + } } stk.push(result); } diff --git a/src/ftheor_eval.cc b/src/ftheor_eval.cc index d9a9ea802..c8688ea6a 100644 --- a/src/ftheor_eval.cc +++ b/src/ftheor_eval.cc @@ -59,13 +59,13 @@ tDataBins gDataBins; t2Dfunctions g2Dfunctions; -#define NTERMMAX 32 +#define NTERMMAX 128 extern struct thexpr_cb { double dynscale; int nterms; - char termname[NTERMMAX][8]; + char termname[NTERMMAX][32]; char termtype[NTERMMAX][80]; - char terminfo[NTERMMAX][2048]; + char terminfo[NTERMMAX][4096]; char termsource[NTERMMAX][256]; char theorexpr[1000]; int ppbar_collisions; -- GitLab From 708d772a786358fe88be6492fb4b85f77ab276c4 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <zenaiev@naf-cms12.desy.de> Date: Sun, 27 Jan 2019 18:01:57 +0100 Subject: [PATCH 12/81] extra parameter for KFactor and KRunning to specify size of values --- reactions/KFactor/include/ReactionKFactor.h | 9 ++++++++- reactions/KFactor/src/ReactionKFactor.cc | 19 ++++++++++++------- reactions/KRunning/include/ReactionKRunning.h | 1 + reactions/KRunning/src/ReactionKRunning.cc | 17 +++++++++++++---- src/TheorEval.cc | 3 +++ 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/reactions/KFactor/include/ReactionKFactor.h b/reactions/KFactor/include/ReactionKFactor.h index 59e1726b8..2c146a98c 100644 --- a/reactions/KFactor/include/ReactionKFactor.h +++ b/reactions/KFactor/include/ReactionKFactor.h @@ -33,6 +33,13 @@ class ReactionKFactor : public ReactionTheory virtual int parseOptions(){ return 0;}; private: map<int, std::vector<double> > _values; - map<int, std::pair<std::string, double> > _parameterNames; + + struct Parameter + { + std::string Name; + double Value; + int NPoints; + }; + map<int, Parameter> _parameters; }; diff --git a/reactions/KFactor/src/ReactionKFactor.cc b/reactions/KFactor/src/ReactionKFactor.cc index 5e8b51dfe..b5c535a49 100644 --- a/reactions/KFactor/src/ReactionKFactor.cc +++ b/reactions/KFactor/src/ReactionKFactor.cc @@ -104,7 +104,7 @@ void ReactionKFactor::setDatasetParameters(int dataSetID, map<string,string> par } file.close(); } - // check if kfactors should be read from data file (soecifying column is mandatory) + // check if kfactors should be read from data file (specifying column is mandatory) else if (pars.find("DataColumn") != pars.end()) { std::string columnName = pars["DataColumn"]; @@ -118,26 +118,31 @@ void ReactionKFactor::setDatasetParameters(int dataSetID, map<string,string> par // check if kfactor is a parameter (possibly free); the value of this parameter will be used for all bins in data set else if (pars.find("Parameter") != pars.end()) { - _parameterNames[dataSetID] = std::make_pair(pars["Parameter"], 0.0); + _parameters[dataSetID].Name = pars["Parameter"]; + _parameters[dataSetID].Value = 0.0; + if (pars.find("N") != pars.end()) + _parameters[dataSetID].NPoints = atoi(pars["N"].c_str()); + else + _parameters[dataSetID].NPoints = _dsBins[dataSetID]->begin()->second.size(); } else hf_errlog(17102804, "F: FileName or DataColumn or Parameter must be provided for KFactor"); } void ReactionKFactor::initAtIteration() { - for(auto& it : _parameterNames) - it.second.second = GetParam(it.second.first); + for(auto& it : _parameters) + it.second.Value = GetParam(it.second.Name); } // Main function to compute results at an iteration int ReactionKFactor::compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err) { - const auto& it = _parameterNames.find(dataSetID); - if(it != _parameterNames.end()) + const auto& it = _parameters.find(dataSetID); + if(it != _parameters.end()) { // kfactor given as a fit parameter read in initAtIteration() int np = _dsBins[dataSetID]->begin()->second.size(); // number of data points - val = std::valarray<double>(it->second.second, np); + val = std::valarray<double>(it->second.Value, it->second.NPoints); } else // kfactor is constant value read in setDatasetParameters() diff --git a/reactions/KRunning/include/ReactionKRunning.h b/reactions/KRunning/include/ReactionKRunning.h index 2b751aa64..59ac8b951 100644 --- a/reactions/KRunning/include/ReactionKRunning.h +++ b/reactions/KRunning/include/ReactionKRunning.h @@ -34,6 +34,7 @@ class ReactionKRunning : public ReactionTheory std::map<int, std::string> _type; std::map<int, std::string> _q; std::map<int, std::string> _q0; + std::map<int, int> _NPoints; double getAlphaS(double q) { return alphaS(q); } double getMassMSbar(const double m0, const double q, const double as, const double as0) diff --git a/reactions/KRunning/src/ReactionKRunning.cc b/reactions/KRunning/src/ReactionKRunning.cc index 0ef93daf6..b1966d8e3 100644 --- a/reactions/KRunning/src/ReactionKRunning.cc +++ b/reactions/KRunning/src/ReactionKRunning.cc @@ -42,6 +42,14 @@ void ReactionKRunning::setDatasetParameters(int dataSetID, map<std::string, std: // for type=massMSbarNLO read q0: scale at which m(m) is quoted if(_type[dataSetID] == "massMSbarNLO") _q0[dataSetID] = pars.find("q0")->second; + + // read optional number of points (if not provided, use the number of data points) + it = pars.find("N"); + if(it == pars.end()) + _NPoints[dataSetID] = _dsBins[dataSetID]->begin()->second.size(); + else + _NPoints[dataSetID] = atoi(pars["N"].c_str()); + //printf("npoints: %d\n", _NPoints[dataSetID]); } // Main function to compute results at an iteration @@ -49,12 +57,13 @@ int ReactionKRunning::compute(int dataSetID, valarray<double> &val, map<string, { double q = GetParam(_q[dataSetID]); if(_type[dataSetID] == "as") - val = getAlphaS(q); + val = valarray<double>(getAlphaS(q), _NPoints[dataSetID]); else if(_type[dataSetID] == "massMSbarNLO") { double q0 = GetParam(_q0[dataSetID]); - val = getMassMSbar(q0, q, getAlphaS(q0), getAlphaS(q)); + val = valarray<double>(getMassMSbar(q0, q, getAlphaS(q0), getAlphaS(q)), _NPoints[dataSetID]); } - for(int i = 0; i < val.size(); i++) - printf("val[%d] = %f\n", i, val[i]); + //for(int i = 0; i < val.size(); i++) + // printf("val[%d] = %f\n", i, val[i]); + return 0; } diff --git a/src/TheorEval.cc b/src/TheorEval.cc index 1be69ba2c..0631fcae8 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -565,6 +565,9 @@ TheorEval::initReactionTerm(int iterm, valarray<double> *val) map<string, string> pars = SplitTermInfo(term_info); // and transfer to the module + //printf("pars\n"); + //for(map<string,string>::iterator it = pars.begin(); it != pars.end(); it++) + // printf("%s = %s\n", it->first.c_str(), it->second.c_str()); rt->setDatasetParameters(_dsId*1000+iterm, pars, _dsPars); _mapReactionToken[ std::pair<ReactionTheory*,int>(rt,iterm) ] = val; -- GitLab From 6fd1c046dd939feb211d8886165dc3b19acc79bd Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sun, 27 Jan 2019 22:53:41 +0000 Subject: [PATCH 13/81] Update install-xfitter (test) --- tools/install-xfitter | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/install-xfitter b/tools/install-xfitter index 8d0479ca7..49b13783d 100755 --- a/tools/install-xfitter +++ b/tools/install-xfitter @@ -412,7 +412,15 @@ else export PATH=$CURRENTDIR/deps/apfel/bin/:$PATH #apfelgrid - lhapdf get NNPDF30_nlo_as_0118 + if [ -d /cvmfs ] + then + lhapdf get NNPDF30_nlo_as_0118 + else + wget wget http://www.hepforge.org/archive/lhapdf/pdfsets/6.2/NNPDF30_nlo_as_0118.tar.gz + tar xvzpf NNPDF30_nlo_as_0118.tar.gz + mv NNPDF30_nlo_as_0118 `lhapdf-config --datadir` + rm NNPDF30_nlo_as_0118.tar.gz + fi echo "Installing APFELgrid $apfelgridver..." # tmp solution is to use fork @zenaiev apfelgridver=1.0.5 -- GitLab From b68ef94f5d359a55148e5358d118090dd88c50e4 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sun, 27 Jan 2019 23:12:57 +0000 Subject: [PATCH 14/81] redirecting output to the install log file and fixed typo --- tools/install-xfitter | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/install-xfitter b/tools/install-xfitter index 49b13783d..1e32e53fd 100755 --- a/tools/install-xfitter +++ b/tools/install-xfitter @@ -414,14 +414,13 @@ else #apfelgrid if [ -d /cvmfs ] then - lhapdf get NNPDF30_nlo_as_0118 + lhapdf get NNPDF30_nlo_as_0118 >> $CURRENTDIR/install.log 2>&1 else - wget wget http://www.hepforge.org/archive/lhapdf/pdfsets/6.2/NNPDF30_nlo_as_0118.tar.gz - tar xvzpf NNPDF30_nlo_as_0118.tar.gz - mv NNPDF30_nlo_as_0118 `lhapdf-config --datadir` - rm NNPDF30_nlo_as_0118.tar.gz + wget http://www.hepforge.org/archive/lhapdf/pdfsets/6.2/NNPDF30_nlo_as_0118.tar.gz >> $CURRENTDIR/install.log 2>&1 + tar xvzpf NNPDF30_nlo_as_0118.tar.gz `lhapdf-config --datadir` >> $CURRENTDIR/install.log 2>&1 + rm NNPDF30_nlo_as_0118.tar.gz >> $CURRENTDIR/install.log 2>&1 fi - echo "Installing APFELgrid $apfelgridver..." + echo "Installing APFELgrid $apfelgridver..." # tmp solution is to use fork @zenaiev apfelgridver=1.0.5 if [[ $http == "curl" ]] -- GitLab From 8f572e0a40b6fb1a8f537295571897af22eae849 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sun, 27 Jan 2019 23:24:25 +0000 Subject: [PATCH 15/81] one more fix --- tools/install-xfitter | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/install-xfitter b/tools/install-xfitter index 1e32e53fd..2f537fb52 100755 --- a/tools/install-xfitter +++ b/tools/install-xfitter @@ -417,7 +417,8 @@ else lhapdf get NNPDF30_nlo_as_0118 >> $CURRENTDIR/install.log 2>&1 else wget http://www.hepforge.org/archive/lhapdf/pdfsets/6.2/NNPDF30_nlo_as_0118.tar.gz >> $CURRENTDIR/install.log 2>&1 - tar xvzpf NNPDF30_nlo_as_0118.tar.gz `lhapdf-config --datadir` >> $CURRENTDIR/install.log 2>&1 + tar xvzpf NNPDF30_nlo_as_0118.tar.gz >> $CURRENTDIR/install.log 2>&1 + mv NNPDF30_nlo_as_0118 `lhapdf-config --datadir` >> $CURRENTDIR/install.log 2>&1 rm NNPDF30_nlo_as_0118.tar.gz >> $CURRENTDIR/install.log 2>&1 fi echo "Installing APFELgrid $apfelgridver..." -- GitLab From 6a2b2c7443e8b4de42f0e06828ba4fe475557229 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Fri, 1 Feb 2019 14:42:44 +0100 Subject: [PATCH 16/81] fixed small memory leaks --- reactions/Hathor/include/ReactionHathor.h | 6 +++--- reactions/Hathor/src/ReactionHathor.cc | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/reactions/Hathor/include/ReactionHathor.h b/reactions/Hathor/include/ReactionHathor.h index 2495d4188..7038b56cf 100644 --- a/reactions/Hathor/include/ReactionHathor.h +++ b/reactions/Hathor/include/ReactionHathor.h @@ -43,8 +43,8 @@ class ReactionHathor : public ReactionTheory HathorPdfxFitter* _pdf; int* _rndStore; //double _mtop; - std::map<int, double*> _mtopPerInstance; - std::map<int, double*> _mrPerInstance; - std::map<int, double*> _mfPerInstance; + std::map<int, std::shared_ptr<double> > _mtopPerInstance; + std::map<int, std::shared_ptr<double> > _mrPerInstance; + std::map<int, std::shared_ptr<double> > _mfPerInstance; }; diff --git a/reactions/Hathor/src/ReactionHathor.cc b/reactions/Hathor/src/ReactionHathor.cc index 3c9e999a9..af787f383 100644 --- a/reactions/Hathor/src/ReactionHathor.cc +++ b/reactions/Hathor/src/ReactionHathor.cc @@ -118,16 +118,15 @@ void ReactionHathor::setDatasetParameters(int dataSetID, map<std::string, std::s // set mass // here local value is preferred over global one (to allow calculations with several mass values, e.g. for translation into MSbar mass scheme) // the value may change further in iterations, in this case store NULL pointer (will be updated at each iteration and treated as global value) - // TODO: fix memory leak - _mtopPerInstance[dataSetID] = (pars.find("mtp") != pars.end()) ? new double(atof(pars.find("mtp")->second.c_str())) : NULL; + _mtopPerInstance[dataSetID] = (pars.find("mtp") != pars.end()) ? std::shared_ptr<double>(new double(atof(pars.find("mtp")->second.c_str()))) : NULL; // set renorm. scale - _mrPerInstance[dataSetID] = _mtopPerInstance[dataSetID]; + _mrPerInstance[dataSetID] = std::shared_ptr<double>(new double(*_mtopPerInstance[dataSetID])); if(_mtopPerInstance[dataSetID] && checkParam("muR")) *_mrPerInstance[dataSetID] *= GetParam("muR"); // set fact. scale - _mfPerInstance[dataSetID] = _mtopPerInstance[dataSetID]; + _mfPerInstance[dataSetID] = std::shared_ptr<double>(new double(*_mtopPerInstance[dataSetID])); if(_mtopPerInstance[dataSetID] && checkParam("muF")) *_mfPerInstance[dataSetID] *= GetParam("muF"); @@ -171,10 +170,10 @@ void ReactionHathor::setDatasetParameters(int dataSetID, map<std::string, std::s hathor->setPrecision(precisionLevel); std::cout << " Hathor will use for this instance (" + std::to_string(dataSetID) + "):" << std::endl; - double mt = _mtopPerInstance[dataSetID] ? *_mtopPerInstance[dataSetID] : GetParam("mtp"); + double mt = _mtopPerInstance[dataSetID] ? (*_mtopPerInstance[dataSetID]) : GetParam("mtp"); std::cout << " mtop = " << mt << "[GeV] " << std::endl; - std::cout << " renorm. scale = " << (_mrPerInstance[dataSetID] ? *_mrPerInstance[dataSetID] : (mt * GetParam("muR"))) << "[GeV] " << std::endl; - std::cout << " factor. scale = " << (_mfPerInstance[dataSetID] ? *_mfPerInstance[dataSetID] : (mt * GetParam("muF"))) << "[GeV] " << std::endl; + std::cout << " renorm. scale = " << (_mrPerInstance[dataSetID] ? (*_mrPerInstance[dataSetID]) : (mt * GetParam("muR"))) << "[GeV] " << std::endl; + std::cout << " factor. scale = " << (_mfPerInstance[dataSetID] ? (*_mfPerInstance[dataSetID]) : (mt * GetParam("muF"))) << "[GeV] " << std::endl; std::cout << " SqrtS = " << sqrtS << std::endl; std::cout << " scheme: " << scheme << std::endl; std::cout << " precisionLevel: " << precisionLevel << std::endl; @@ -193,14 +192,14 @@ int ReactionHathor::compute(int dataSetID, valarray<double> &val, map<string, va Hathor* hathor = _hathorArray.at(dataSetID); //hathor->getXsection(_mtop, _mr, _mf); - double mt = _mtopPerInstance[dataSetID] ? *_mtopPerInstance[dataSetID] : GetParam("mtp"); - double mr = _mrPerInstance[dataSetID] ? *_mrPerInstance[dataSetID] : (mt * GetParam("muR")); - double mf = _mfPerInstance[dataSetID] ? *_mfPerInstance[dataSetID] : (mt * GetParam("muF")); + double mt = _mtopPerInstance[dataSetID] ? (*_mtopPerInstance[dataSetID]) : GetParam("mtp"); + double mr = _mrPerInstance[dataSetID] ? (*_mrPerInstance[dataSetID]) : (mt * GetParam("muR")); + double mf = _mfPerInstance[dataSetID] ? (*_mfPerInstance[dataSetID]) : (mt * GetParam("muF")); hathor->getXsection(mt, mr, mf); double dum = 0.0; double xsec = 0.0; hathor->getResult(0, xsec, dum); - printf("mt,mr,mf,xsec: %f %f %f %f\n", mt, mr, mf, xsec); + //printf("mt,mr,mf,xsec: %f %f %f %f\n", mt, mr, mf, xsec); val = xsec; //printf("VAL ************ %f\n", val[0]); -- GitLab From 74bf57a094b54ac31b559190d26740d8599947d2 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Fri, 1 Feb 2019 18:22:12 +0100 Subject: [PATCH 17/81] eliminated compiler warning --- reactions/KFactor/src/ReactionKFactor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactions/KFactor/src/ReactionKFactor.cc b/reactions/KFactor/src/ReactionKFactor.cc index b5c535a49..5338dfd7a 100644 --- a/reactions/KFactor/src/ReactionKFactor.cc +++ b/reactions/KFactor/src/ReactionKFactor.cc @@ -141,7 +141,7 @@ int ReactionKFactor::compute(int dataSetID, valarray<double> &val, map<string, v if(it != _parameters.end()) { // kfactor given as a fit parameter read in initAtIteration() - int np = _dsBins[dataSetID]->begin()->second.size(); // number of data points + //int np = _dsBins[dataSetID]->begin()->second.size(); // number of data points val = std::valarray<double>(it->second.Value, it->second.NPoints); } else -- GitLab From 8cd664a9ed8cfa8fe7c124d0217d02ddaf9ae9ee Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Fri, 1 Feb 2019 18:54:59 +0100 Subject: [PATCH 18/81] fixed typo --- tools/draw/include/CommandParser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/draw/include/CommandParser.h b/tools/draw/include/CommandParser.h index c149b77a5..bead931cf 100644 --- a/tools/draw/include/CommandParser.h +++ b/tools/draw/include/CommandParser.h @@ -150,7 +150,7 @@ private: cout << "\t \t Draw PDF uncertainty bands" << endl; cout << "\t --profile" << endl; cout << "\t \t Draw Profiled PDF (only for Hessian sets)" << endl; - cout << "\t \t To set this option only for one directory, use the syntax profiled:directory[:label]" << endl; + cout << "\t \t To set this option only for one directory, use the syntax profile:directory[:label]" << endl; cout << "\t Example: xfitter-draw profile:output:\"profiled\" output:\"not-profiled\"" << endl; cout << "\t --reweight(-BAY/-GK)" << endl; cout << "\t \t Draw Reweighted PDF (only for MC replica sets)" << endl; -- GitLab From 43af95c892bb1a8967137e7df20362f0bac268bc Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sun, 3 Feb 2019 23:05:23 +0100 Subject: [PATCH 19/81] new HVQMNR reaction for custom differential cross sections --- Makefile.am | 2 +- Reactions.txt | 1 + configure.ac | 1 + doxygen.cfg | 2 +- .../BaseHVQMNR/include/ReactionBaseHVQMNR.h | 6 ++++-- reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc | 16 +++++++++------- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 36e8fbe87..c5a418325 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,7 @@ SUBDIRS = minuit/src interfaces/src DY/src DIPOLE/src RT/src EW/src common commo genetic/mixmax_r004 genetic/src QEDevol/src \ include interfaces/include FastNLO/include FastNLO/include/fastnlotk DiffDIS/include \ DY/include tools/draw/include \ - pdf2yaml tools/process reactions/KRunning/src \ + pdf2yaml tools/process reactions/cbdiff/src reactions/KRunning/src \ reactions/AFB/src \ reactions/KFactor/src reactions/Fractal_DISNC/src reactions/BaseDISCC/src reactions/Hathor/src reactions/BaseDISNC/src \ reactions/RT_DISNC/src reactions/FFABM_DISNC/src reactions/FFABM_DISCC/src reactions/APPLgrid/src reactions/BaseHVQMNR/src \ diff --git a/Reactions.txt b/Reactions.txt index eff9d685c..d791c491d 100644 --- a/Reactions.txt +++ b/Reactions.txt @@ -17,3 +17,4 @@ FONLL_DISCC libfonll_discc_xfitter.so AFB libafb_xfitter.so KMatrix libkmatrix_xfitter.so KRunning libkrunning_xfitter.so +cbdiff libcbdiff_xfitter.so diff --git a/configure.ac b/configure.ac index ceae457f6..5d4cacaf9 100644 --- a/configure.ac +++ b/configure.ac @@ -562,6 +562,7 @@ AC_CONFIG_FILES([include/Makefile examples/Makefile python/Makefile xfitter-config + reactions/cbdiff/src/Makefile reactions/KRunning/src/Makefile reactions/AFB/src/Makefile reactions/KFactor/src/Makefile diff --git a/doxygen.cfg b/doxygen.cfg index 747dca5f6..fcf432ca6 100644 --- a/doxygen.cfg +++ b/doxygen.cfg @@ -574,7 +574,7 @@ INPUT = include src \ Hathor/interface Hathor/src EW/src \ NNPDF/include NNPDF/src Cascade/src \ DY/src DY/include \ - reactions/APPLgrid/include reactions/KRunning/src reactions/KRunning/include reactions/FONLL_DISCC/src reactions/FONLL_DISCC/include reactions/FONLL_DISNC/src reactions/FONLL_DISNC/include reactions/KFactor/src reactions/KFactor/include reactions/FFABM_DISCC/src reactions/FFABM_DISCC/include reactions/Fractal_DISNC/src reactions/Fractal_DISNC/include reactions/BaseDISCC/src reactions/BaseDISCC/include reactions/FFABM_DISNC/src reactions/FFABM_DISNC/include reactions/Hathor/src reactions/Hathor/include reactions/RT_DISNC/src reactions/RT_DISNC/include reactions/BaseDISNC/src reactions/BaseDISNC/include \ + reactions/APPLgrid/include reactions/cbdiff/src reactions/cbdiff/include reactions/KRunning/src reactions/KRunning/include reactions/FONLL_DISCC/src reactions/FONLL_DISCC/include reactions/FONLL_DISNC/src reactions/FONLL_DISNC/include reactions/KFactor/src reactions/KFactor/include reactions/FFABM_DISCC/src reactions/FFABM_DISCC/include reactions/Fractal_DISNC/src reactions/Fractal_DISNC/include reactions/BaseDISCC/src reactions/BaseDISCC/include reactions/FFABM_DISNC/src reactions/FFABM_DISNC/include reactions/Hathor/src reactions/Hathor/include reactions/RT_DISNC/src reactions/RT_DISNC/include reactions/BaseDISNC/src reactions/BaseDISNC/include \ reactions/APPLgrid/src \ reactions/fastNLO/include \ reactions/fastNLO/src \ diff --git a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h index b0550a4dc..ed1a71500 100644 --- a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h +++ b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h @@ -102,6 +102,8 @@ class ReactionBaseHVQMNR : public ReactionTheory // status flags bool _isInitAtStart; //int _ifcncount_last; + // heavy-quark mass + //std::map // check if appropriate heavy-flavour scheme is used void CheckHFScheme(); @@ -110,7 +112,7 @@ class ReactionBaseHVQMNR : public ReactionTheory void UpdateParameters(); // print theory parameters - void PrintParameters() const; + void PrintParameters(Parameters const* pars = NULL) const; // initialise calculation with default parameters void DefaultInit(const Steering& steer, const double mq, MNR::MNR& mnr, MNR::Frag& frag, MNR::Grid& grid, MNR::Grid& grid_smoothed); @@ -118,7 +120,7 @@ class ReactionBaseHVQMNR : public ReactionTheory // return cross section in provided pT-y bin double FindXSecPtYBin(const TH2* histXSec, const double ymin, const double ymax, const double ptmin, const double ptmax, const bool diff_pt, const bool diff_y); - private: + //private: // check equality of float numbers with tolerance bool IsEqual(const double val1, const double val2, const double eps = 1e-6); diff --git a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc index ece984d0e..9a4e3291f 100644 --- a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc +++ b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc @@ -329,15 +329,17 @@ void ReactionBaseHVQMNR::UpdateParameters() } // print theory parameters -void ReactionBaseHVQMNR::PrintParameters() const +void ReactionBaseHVQMNR::PrintParameters(Parameters const* pars) const { + if(pars == NULL) + pars = &(this->_pars); printf("MNR scale parameters:\n"); - printf("%f %f %f\n", _pars.mf_A_c, _pars.mf_B_c, _pars.mf_C_c); - printf("%f %f %f\n", _pars.mr_A_c, _pars.mr_B_c, _pars.mr_C_c); - printf("%f %f %f\n", _pars.mf_A_b, _pars.mf_B_b, _pars.mf_C_b); - printf("%f %f %f\n", _pars.mr_A_b, _pars.mr_B_b, _pars.mr_C_b); + printf("%f %f %f\n", pars->mf_A_c, pars->mf_B_c, pars->mf_C_c); + printf("%f %f %f\n", pars->mr_A_c, pars->mr_B_c, pars->mr_C_c); + printf("%f %f %f\n", pars->mf_A_b, pars->mf_B_b, pars->mf_C_b); + printf("%f %f %f\n", pars->mr_A_b, pars->mr_B_b, pars->mr_C_b); printf("MNR masses:\n"); - printf("mc = %f mb = %f\n", _pars.mc, _pars.mb); + printf("mc = %f mb = %f\n", pars->mc, pars->mb); printf("MNR fragmentation parameters:\n"); - printf("fragpar_c = %f fragpar_b = %f\n", _pars.fragpar_c, _pars.fragpar_b); + printf("fragpar_c = %f fragpar_b = %f\n", pars->fragpar_c, pars->fragpar_b); } -- GitLab From 7ae8fa54a17b1f5bed349aeba1b61fdc3c994d74 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 4 Feb 2019 17:57:19 +0100 Subject: [PATCH 20/81] no funny median line with --therr --- tools/draw/src/DataPainter.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/draw/src/DataPainter.cc b/tools/draw/src/DataPainter.cc index 819389a2c..6512ecaa4 100644 --- a/tools/draw/src/DataPainter.cc +++ b/tools/draw/src/DataPainter.cc @@ -530,7 +530,8 @@ TCanvas * DataPainter(int dataindex, int subplotindex) for (vector<range>::iterator r = thranges.begin(); r != thranges.end(); r++) { (*it).gettherr()->SetAxisRange((*r).lowedge, (*r).upedge); - (*it).Draw((TH1F*)(*it).gettherr()->Clone(), "E3L same"); + //(*it).Draw((TH1F*)(*it).gettherr()->Clone(), "E3L same"); + (*it).Draw((TH1F*)(*it).gettherr()->Clone(), "E3 same"); } (*it).gettherr()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); } @@ -879,7 +880,8 @@ TCanvas * DataPainter(int dataindex, int subplotindex) { (*it).getrtherr()->SetAxisRange((*r).lowedge, (*r).upedge); if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory - (*it).Draw((TH1F*)(*it).getrtherr()->Clone(), "E3L same"); + //(*it).Draw((TH1F*)(*it).getrtherr()->Clone(), "E3L same"); + (*it).Draw((TH1F*)(*it).getrtherr()->Clone(), "E3 same"); } (*it).getrtherr()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); } -- GitLab From e503e09ecbfb179e02cbba239a8d1d1d1548c452 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 7 Feb 2019 18:18:20 +0100 Subject: [PATCH 21/81] const modified for CheckParam --- include/ReactionTheory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ReactionTheory.h b/include/ReactionTheory.h index 281884365..0844bf964 100644 --- a/include/ReactionTheory.h +++ b/include/ReactionTheory.h @@ -129,7 +129,7 @@ class ReactionTheory /// Generate report on the state of parameters, local for the given reaction. std::string emitReactionLocalPars() const; - bool checkParam(string name) ///< Check if a parameter is present on one of the global list + bool checkParam(string name) const ///< Check if a parameter is present on one of the global list { return (_xfitter_pars.find(name) != _xfitter_pars.end()) || (_xfitter_pars_i.find(name) != _xfitter_pars_i.end()) -- GitLab From a48640714f218460c9a2cfe4c62ed46572551b6d Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 7 Feb 2019 18:19:09 +0100 Subject: [PATCH 22/81] extended flexibility for HVQMNR --- reactions/BaseHVQMNR/include/MNR.h | 12 ++-- reactions/BaseHVQMNR/include/MNRFrag.h | 2 + .../BaseHVQMNR/include/ReactionBaseHVQMNR.h | 67 ++++++++++++++++--- reactions/BaseHVQMNR/src/MNR.cc | 9 +-- reactions/BaseHVQMNR/src/MNRFrag.cc | 23 +++++++ .../BaseHVQMNR/src/ReactionBaseHVQMNR.cc | 48 +++++++------ .../src/ReactionHVQMNR_LHCb_7TeV_beauty.cc | 7 +- .../src/ReactionHVQMNR_LHCb_7TeV_charm.cc | 7 +- 8 files changed, 135 insertions(+), 40 deletions(-) diff --git a/reactions/BaseHVQMNR/include/MNR.h b/reactions/BaseHVQMNR/include/MNR.h index d2690c4af..455e1bee3 100644 --- a/reactions/BaseHVQMNR/include/MNR.h +++ b/reactions/BaseHVQMNR/include/MNR.h @@ -85,7 +85,13 @@ namespace MNR // Contrbution flags bool bFS_Q; // particle final state bool bFS_A; // antiparticle final state - + + // PDF range + double fSF_min_x; + double fSF_max_x; + double fSF_min_mf2; + double fSF_max_mf2; + // Private fields private: // Constants @@ -109,10 +115,6 @@ namespace MNR // Variables for fast structure functions evaluation const static int fSF_npart; - const static double fSF_min_x; - const static double fSF_max_x; - const static double fSF_min_mf2; - const static double fSF_max_mf2; double fSF_log10_min_x; double fSF_log10_max_x; double fSF_min_adoptx; diff --git a/reactions/BaseHVQMNR/include/MNRFrag.h b/reactions/BaseHVQMNR/include/MNRFrag.h index 30bf20549..978f9055d 100644 --- a/reactions/BaseHVQMNR/include/MNRFrag.h +++ b/reactions/BaseHVQMNR/include/MNRFrag.h @@ -94,6 +94,8 @@ namespace MNR // on energy in parton-parton rest frame, especially if the heavy-quark mass // is released, use ff = 10 and ff = 20 with great caution! static TF1* GetFragFunction(int ff, const char* meson, double par, double* mean = 0); + + static double GetHadronMass(const char* meson); // Private methods private: diff --git a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h index ed1a71500..7f4d4ef33 100644 --- a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h +++ b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h @@ -60,19 +60,30 @@ class ReactionBaseHVQMNR : public ReactionTheory struct Parameters { // heavy-quark masses - double mc, mb; + double mc = 0.0; + double mb = 0.0; // scale parameters - double mf_A_c, mf_B_c, mf_C_c; - double mr_A_c, mr_B_c, mr_C_c; - double mf_A_b, mf_B_b, mf_C_b; - double mr_A_b, mr_B_b, mr_C_b; + double mf_A_c = 0.0; + double mf_B_c = 0.0; + double mf_C_c = 0.0; + double mr_A_c = 0.0; + double mr_B_c = 0.0; + double mr_C_c = 0.0; + double mf_A_b = 0.0; + double mf_B_b = 0.0; + double mf_C_b = 0.0; + double mr_A_b = 0.0; + double mr_B_b = 0.0; + double mr_C_b = 0.0; // fragmentation parameters - double fragpar_c, fragpar_b; + double fragpar_c = 0.0; + double fragpar_b = 0.0; }; // structure to store steering parameters struct Steering { + int nf; double ptmin; double ptmax; int npt; @@ -84,6 +95,10 @@ class ReactionBaseHVQMNR : public ReactionTheory int nx3; int nx4; int nbz; + double xmin; + double xmax; + double mf2min; + double mf2max; }; // all datasets @@ -132,9 +147,45 @@ class ReactionBaseHVQMNR : public ReactionTheory int readFromTermInfo(const std::string& str, const std::string& key, std::string& value);*/ // read parameters for perturbative scales from MINUIT extra parameters - void GetMuPar(const char mu, const char q, double& A, double& B, double& C); + void GetMuPar(const char mu, const char q, double& A, double& B, double& C, const map<string,string> pars = map<string,string>()); // read fragmentation parameter from MINUIT extra parameters - double GetFragPar(const char q); + double GetFragPar(const char q, const map<string,string> pars = map<string,string>()); + + // check parameter respecting priority: (1) supplied map (if supplied), (2) global + double checkParamInPriority(const string& name, const std::map<string,string> pars = std::map<string,string>()) const + { + if(pars.size() != 0) + return (pars.find(name) != pars.end()); + else + return checkParam(name); + } + + // get parameter respecting priority: (1) supplied map (if supplied), (2) global + double GetParamInPriority(const string& name, const std::map<string,string> pars = std::map<string,string>()) const + { + if(pars.find(name) != pars.end()) + return std::stod(pars.at(name)); + else + return GetParam(name); + } + + // get parameter respecting priority: (1) supplied map (if supplied), (2) global + double GetParamIInPriority(const string& name, const std::map<string,string> pars = std::map<string,string>()) const + { + if(pars.find(name) != pars.end()) + return std::stod(pars.at(name)); + else + return GetParamI(name); + } + + // get parameter respecting priority: (1) supplied map (if supplied), (2) global + std::string GetParamSInPriority(const string& name, const std::map<string,string> pars = std::map<string,string>()) const + { + if(pars.find(name) != pars.end()) + return pars.at(name); + else + return GetParamS(name); + } }; diff --git a/reactions/BaseHVQMNR/src/MNR.cc b/reactions/BaseHVQMNR/src/MNR.cc index 6f8fc73f8..e2dbe590b 100644 --- a/reactions/BaseHVQMNR/src/MNR.cc +++ b/reactions/BaseHVQMNR/src/MNR.cc @@ -150,6 +150,7 @@ namespace MNR void MNR::PrecalculatePDF(double mf2) { + //printf("mf2 = %f\n", mf2); if(mf2 < fSF_min_mf2 || mf2 > fSF_max_mf2) { printf("WARNING in MNR::PrecalculatePDF(): mf2 %e out of range %e .. %e\n", mf2, fSF_min_mf2, fSF_max_mf2); @@ -655,8 +656,8 @@ namespace MNR const double MNR::fC_vca = 3.0e0; const double MNR::fC_vtf = 0.5e0; const int MNR::fSF_npart = 13; - const double MNR::fSF_min_x = 1e-6; - const double MNR::fSF_max_x = 1e0; - const double MNR::fSF_min_mf2 = 1e0; - const double MNR::fSF_max_mf2 = 8e4; + //const double MNR::fSF_min_x = 1e-6; + //const double MNR::fSF_max_x = 1e0; + //const double MNR::fSF_min_mf2 = 1e0; + //const double MNR::fSF_max_mf2 = 8e4; } diff --git a/reactions/BaseHVQMNR/src/MNRFrag.cc b/reactions/BaseHVQMNR/src/MNRFrag.cc index 1ded5423b..2a0bfc547 100644 --- a/reactions/BaseHVQMNR/src/MNRFrag.cc +++ b/reactions/BaseHVQMNR/src/MNRFrag.cc @@ -557,6 +557,29 @@ namespace MNR return p[0] * TMath::Power(x[0], -1.) * TMath::Power(1. - 1./x[0] - p[1]/(1.-x[0]), -2.); } + double Frag::GetHadronMass(const char* meson) + { + if(std::string(meson) == "dzero") + return fM_dzero; + else if(std::string(meson) == "dch") + return fM_dch; + else if(std::string(meson) == "dstar") + return fM_dstar; + else if(std::string(meson) == "ds") + return fM_ds; + else if(std::string(meson) == "lambdac") + return fM_lambdac; + else if(std::string(meson) == "bzero") + return fM_bzero; + else if(std::string(meson) == "bch") + return fM_bch; + else if(std::string(meson) == "bs") + return fM_bs; + else + return -1.0; + } + + // Values from PDG const double Frag::fM_dzero = 1.865; const double Frag::fM_dch = 1.867; diff --git a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc index 9a4e3291f..ec75fcad0 100644 --- a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc +++ b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc @@ -119,13 +119,19 @@ void ReactionBaseHVQMNR::DefaultInit(const Steering& steer, const double mq, MNR // MNR (parton level cross sections) mnr.bFS_Q = true; mnr.bFS_A = true; + // number of light flavours + mnr.fC_nl = steer.nf; // x3 and x4 binning mnr.fBn_x3 = steer.nx3; mnr.fBn_x4 = steer.nx4; mnr.fSF_nb = steer.nsfnb; + // PDF range + mnr.fSF_min_x = steer.xmin; + mnr.fSF_max_x = steer.xmax; + mnr.fSF_min_mf2 = steer.mf2min; + mnr.fSF_max_mf2 = steer.mf2max; + // precalculation (memory allocation etc.) mnr.CalcBinning(); - // Number of flavours - mnr.fC_nl = 3; // Parton level pT-y grids grid.SetL(steer.npt, steer.ptmin, steer.ptmax, mq); grid.SetY(steer.ny, steer.ymin, steer.ymax); @@ -191,7 +197,7 @@ void ReactionBaseHVQMNR::CheckHFScheme() } // read parameters for perturbative scales from MINUIT extra parameters -void ReactionBaseHVQMNR::GetMuPar(const char mu, const char q, double& A, double& B, double& C) +void ReactionBaseHVQMNR::GetMuPar(const char mu, const char q, double& A, double& B, double& C, const map<std::string, std::string> pars) { // *********************************************************************************************** // Scales for charm and beauty production are parametrised as: @@ -226,39 +232,39 @@ void ReactionBaseHVQMNR::GetMuPar(const char mu, const char q, double& A, double std::string baseParameterName = "MNRm" + std::string(1, mu); // A and B parameters - if(checkParam(baseParameterName + "_AB")) - A = B = GetParam(baseParameterName + "_AB"); + if(GetParamInPriority(baseParameterName + "_AB", pars)) + A = B = GetParamInPriority(baseParameterName + "_AB", pars); else { - if(checkParam(baseParameterName + "_A") && checkParam(baseParameterName + "_B")) + if(checkParamInPriority(baseParameterName + "_A", pars) && checkParamInPriority(baseParameterName + "_B", pars)) { - A = GetParam(baseParameterName + "_A"); - B = GetParam(baseParameterName + "_B"); + A = GetParamInPriority(baseParameterName + "_A", pars); + B = GetParamInPriority(baseParameterName + "_B", pars); } else { - if(checkParam(baseParameterName + "_AB_" + std::string(1, q))) - A = B = GetParam(baseParameterName + "_AB_" + std::string(1, q)); + if(checkParamInPriority(baseParameterName + "_AB_" + std::string(1, q), pars)) + A = B = GetParamInPriority(baseParameterName + "_AB_" + std::string(1, q), pars); else { - if(checkParam(baseParameterName + "_A_" + std::string(1, q))) - A = GetParam(baseParameterName + "_A_" + std::string(1, q)); + if(checkParamInPriority(baseParameterName + "_A_" + std::string(1, q), pars)) + A = GetParamInPriority(baseParameterName + "_A_" + std::string(1, q), pars); else A = defA; - if(checkParam(baseParameterName + "_B_" + std::string(1, q))) - B = GetParam(baseParameterName + "_B_" + std::string(1, q)); + if(checkParamInPriority(baseParameterName + "_B_" + std::string(1, q), pars)) + B = GetParamInPriority(baseParameterName + "_B_" + std::string(1, q), pars); else B = defB; } } } // C parameter - if(checkParam(baseParameterName + "_C")) - C = GetParam(baseParameterName + "_C"); + if(checkParamInPriority(baseParameterName + "_C", pars)) + C = GetParamInPriority(baseParameterName + "_C", pars); else { - if(checkParam(baseParameterName + "_C_" + std::string(1, q))) - C = GetParam(baseParameterName + "_C_" + std::string(1, q)); + if(checkParamInPriority(baseParameterName + "_C_" + std::string(1, q), pars)) + C = GetParamInPriority(baseParameterName + "_C_" + std::string(1, q), pars); else C = defC; } @@ -266,7 +272,7 @@ void ReactionBaseHVQMNR::GetMuPar(const char mu, const char q, double& A, double // read fragmentation parameter from MINUIT extra parameters -double ReactionBaseHVQMNR::GetFragPar(const char q) +double ReactionBaseHVQMNR::GetFragPar(const char q, const map<string,string> pars) { // ********************************************************************* // Parameters for non-perturbative fragmentation can be provided @@ -282,7 +288,7 @@ double ReactionBaseHVQMNR::GetFragPar(const char q) double parvalue = NAN; char parname[16]; sprintf(parname, "MNRfrag_%c", q); - if(!checkParam(parname)) + if(!checkParamInPriority(parname, pars)) { // parameter not in ExtraParamMinuit -> using default value if(q == 'c') @@ -293,7 +299,7 @@ double ReactionBaseHVQMNR::GetFragPar(const char q) hf_errlog(17102103, "F: no default value for q = " + std::string(1, q) + " in ReactionBaseHVQMNR::GetFragPar()"); } else - parvalue = GetParam(parname); + parvalue = GetParamInPriority(parname, pars); // TODO check below whether it is still relevant /* ! parameter in ExtraParamMinuit, but not in MINUIT: this happens, if we are not in 'Fit' mode -> using default value diff --git a/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc b/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc index 9c2bfaad8..e7434526b 100644 --- a/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc +++ b/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc @@ -46,6 +46,7 @@ int ReactionHVQMNR_LHCb_7TeV_beauty::initAtStart(const string &s) // stereing parameters for this calculation (modify only if you understand what you are doing) Steering steer; + steer.nf = 3; steer.ptmin = 0.001; steer.ptmax = 70.0; steer.npt = 35; @@ -57,7 +58,11 @@ int ReactionHVQMNR_LHCb_7TeV_beauty::initAtStart(const string &s) steer.nx3 = 125; steer.nx4 = 125; steer.nbz = 100; - + steer.xmin = 1e-6; + steer.xmax = 1e0; + steer.mf2min = 1e0; + steer.mf2max = 8e4; + DefaultInit(steer, _pars.mb, _mnr, _frag, _grid, _gridSmoothed); //if(_debug) printf("ReactionHVQMNR_LHCb_7TeV_beauty::initAtStart(): at initialisation mb = %f\n", _pars.mb); diff --git a/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc b/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc index 88288808d..766e42f4a 100644 --- a/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc +++ b/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc @@ -46,6 +46,7 @@ int ReactionHVQMNR_LHCb_7TeV_charm::initAtStart(const string &s) // stereing parameters for this calculation (modify only if you understand what you are doing) Steering steer; + steer.nf = 3; steer.ptmin = 0.001; steer.ptmax = 20.0; steer.npt = 25; @@ -57,7 +58,11 @@ int ReactionHVQMNR_LHCb_7TeV_charm::initAtStart(const string &s) steer.nx3 = 25; steer.nx4 = 125; steer.nbz = 50; - + steer.xmin = 1e-6; + steer.xmax = 1e0; + steer.mf2min = 1e0; + steer.mf2max = 8e4; + DefaultInit(steer, _pars.mc, _mnr, _frag, _grid, _gridSmoothed); //if(_debug) printf("ReactionHVQMNR_LHCb_7TeV_charm::initAtStart(): at initialisation mc = %f\n", _pars.mc); -- GitLab From 5b7e166c8bed38ae6b65973dc05929a938fd2268 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 7 Feb 2019 18:19:43 +0100 Subject: [PATCH 23/81] better treatment of different scale and mt for Hathor --- reactions/Hathor/src/ReactionHathor.cc | 31 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/reactions/Hathor/src/ReactionHathor.cc b/reactions/Hathor/src/ReactionHathor.cc index af787f383..fd1688ffc 100644 --- a/reactions/Hathor/src/ReactionHathor.cc +++ b/reactions/Hathor/src/ReactionHathor.cc @@ -117,18 +117,27 @@ void ReactionHathor::setDatasetParameters(int dataSetID, map<std::string, std::s // set mass // here local value is preferred over global one (to allow calculations with several mass values, e.g. for translation into MSbar mass scheme) - // the value may change further in iterations, in this case store NULL pointer (will be updated at each iteration and treated as global value) - _mtopPerInstance[dataSetID] = (pars.find("mtp") != pars.end()) ? std::shared_ptr<double>(new double(atof(pars.find("mtp")->second.c_str()))) : NULL; + _mtopPerInstance[dataSetID] = std::shared_ptr<double>(new double(pars.find("mtp") == pars.end() ? GetParam("mtp") : atof(pars.find("mtp")->second.c_str()))); // set renorm. scale _mrPerInstance[dataSetID] = std::shared_ptr<double>(new double(*_mtopPerInstance[dataSetID])); - if(_mtopPerInstance[dataSetID] && checkParam("muR")) - *_mrPerInstance[dataSetID] *= GetParam("muR"); + if(checkParam("muR") || pars.find("muR") != pars.end()) + { + if(pars.find("muR") != pars.end()) + *_mrPerInstance[dataSetID] *= stod(pars["muR"]); + else + *_mrPerInstance[dataSetID] *= GetParam("muR"); + } // set fact. scale _mfPerInstance[dataSetID] = std::shared_ptr<double>(new double(*_mtopPerInstance[dataSetID])); - if(_mtopPerInstance[dataSetID] && checkParam("muF")) - *_mfPerInstance[dataSetID] *= GetParam("muF"); + if(checkParam("muF") || pars.find("muF") != pars.end()) + { + if(pars.find("muF") != pars.end()) + *_mfPerInstance[dataSetID] *= stod(pars["muF"]); + else + *_mfPerInstance[dataSetID] *= GetParam("muF"); + } // set perturbative order // here local value is preferred over global one (to allow LO and NLO calculations in one run, e.g. for translation into MSbar mass scheme) @@ -170,10 +179,10 @@ void ReactionHathor::setDatasetParameters(int dataSetID, map<std::string, std::s hathor->setPrecision(precisionLevel); std::cout << " Hathor will use for this instance (" + std::to_string(dataSetID) + "):" << std::endl; - double mt = _mtopPerInstance[dataSetID] ? (*_mtopPerInstance[dataSetID]) : GetParam("mtp"); + double mt = *_mtopPerInstance[dataSetID]; std::cout << " mtop = " << mt << "[GeV] " << std::endl; - std::cout << " renorm. scale = " << (_mrPerInstance[dataSetID] ? (*_mrPerInstance[dataSetID]) : (mt * GetParam("muR"))) << "[GeV] " << std::endl; - std::cout << " factor. scale = " << (_mfPerInstance[dataSetID] ? (*_mfPerInstance[dataSetID]) : (mt * GetParam("muF"))) << "[GeV] " << std::endl; + std::cout << " renorm. scale = " << *_mrPerInstance[dataSetID] << "[GeV] " << std::endl; + std::cout << " factor. scale = " << *_mfPerInstance[dataSetID] << "[GeV] " << std::endl; std::cout << " SqrtS = " << sqrtS << std::endl; std::cout << " scheme: " << scheme << std::endl; std::cout << " precisionLevel: " << precisionLevel << std::endl; @@ -193,8 +202,8 @@ int ReactionHathor::compute(int dataSetID, valarray<double> &val, map<string, va Hathor* hathor = _hathorArray.at(dataSetID); //hathor->getXsection(_mtop, _mr, _mf); double mt = _mtopPerInstance[dataSetID] ? (*_mtopPerInstance[dataSetID]) : GetParam("mtp"); - double mr = _mrPerInstance[dataSetID] ? (*_mrPerInstance[dataSetID]) : (mt * GetParam("muR")); - double mf = _mfPerInstance[dataSetID] ? (*_mfPerInstance[dataSetID]) : (mt * GetParam("muF")); + double mr = *_mrPerInstance[dataSetID]; + double mf = *_mfPerInstance[dataSetID]; hathor->getXsection(mt, mr, mf); double dum = 0.0; double xsec = 0.0; -- GitLab From 62026c3e374ffef3ea41f12824731f0a716edc95 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Wed, 20 Feb 2019 01:02:08 +0100 Subject: [PATCH 24/81] separated quarks and antiquarks for MNR, minot changes for KRunning --- reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h | 2 ++ reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc | 10 +++++----- .../src/ReactionHVQMNR_LHCb_7TeV_beauty.cc | 2 ++ .../src/ReactionHVQMNR_LHCb_7TeV_charm.cc | 2 ++ reactions/KRunning/include/ReactionKRunning.h | 1 + reactions/KRunning/src/ReactionKRunning.cc | 7 +++++-- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h index 7f4d4ef33..48abf48b3 100644 --- a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h +++ b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h @@ -99,6 +99,8 @@ class ReactionBaseHVQMNR : public ReactionTheory double xmax; double mf2min; double mf2max; + bool q; + bool a; }; // all datasets diff --git a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc index ec75fcad0..58f9ab170 100644 --- a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc +++ b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc @@ -87,8 +87,8 @@ void ReactionBaseHVQMNR::setDatasetParameters(int dataSetID, map<string,string> ds.BinsYMax = GetBinValues(dataSetID, "ymax"); ds.BinsPtMin = GetBinValues(dataSetID, "pTmin"); ds.BinsPtMax = GetBinValues(dataSetID, "pTmax"); - if (ds.BinsYMin == NULL || ds.BinsYMax == NULL || ds.BinsPtMin == NULL || ds.BinsPtMax == NULL ) - hf_errlog(16123004, "F: No bins ymin or ymax or ptmin or ptmax"); + //if (ds.BinsYMin == NULL || ds.BinsYMax == NULL || ds.BinsPtMin == NULL || ds.BinsPtMax == NULL ) + // hf_errlog(16123004, "F: No bins ymin or ymax or ptmin or ptmax"); // set reference y bins if needed if(ds.NormY == 1) { @@ -116,9 +116,9 @@ bool ReactionBaseHVQMNR::IsEqual(const double val1, const double val2, const dou // initialise calculation with default parameters void ReactionBaseHVQMNR::DefaultInit(const Steering& steer, const double mq, MNR::MNR& mnr, MNR::Frag& frag, MNR::Grid& grid, MNR::Grid& grid_smoothed) { - // MNR (parton level cross sections) - mnr.bFS_Q = true; - mnr.bFS_A = true; + // MNR parton level cross sections, quark-antiquark contributions + mnr.bFS_Q = steer.q; + mnr.bFS_A = steer.a; // number of light flavours mnr.fC_nl = steer.nf; // x3 and x4 binning diff --git a/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc b/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc index e7434526b..fc4b68c82 100644 --- a/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc +++ b/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc @@ -46,6 +46,8 @@ int ReactionHVQMNR_LHCb_7TeV_beauty::initAtStart(const string &s) // stereing parameters for this calculation (modify only if you understand what you are doing) Steering steer; + steer.q = true; + steer.a = true; steer.nf = 3; steer.ptmin = 0.001; steer.ptmax = 70.0; diff --git a/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc b/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc index 766e42f4a..3e25d134e 100644 --- a/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc +++ b/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc @@ -46,6 +46,8 @@ int ReactionHVQMNR_LHCb_7TeV_charm::initAtStart(const string &s) // stereing parameters for this calculation (modify only if you understand what you are doing) Steering steer; + steer.q = true; + steer.a = true; steer.nf = 3; steer.ptmin = 0.001; steer.ptmax = 20.0; diff --git a/reactions/KRunning/include/ReactionKRunning.h b/reactions/KRunning/include/ReactionKRunning.h index 59ac8b951..5dce38b9e 100644 --- a/reactions/KRunning/include/ReactionKRunning.h +++ b/reactions/KRunning/include/ReactionKRunning.h @@ -33,6 +33,7 @@ class ReactionKRunning : public ReactionTheory std::map<int, std::string> _type; std::map<int, std::string> _q; + std::map<int, double> _qValue; std::map<int, std::string> _q0; std::map<int, int> _NPoints; diff --git a/reactions/KRunning/src/ReactionKRunning.cc b/reactions/KRunning/src/ReactionKRunning.cc index b1966d8e3..36701f857 100644 --- a/reactions/KRunning/src/ReactionKRunning.cc +++ b/reactions/KRunning/src/ReactionKRunning.cc @@ -37,7 +37,10 @@ void ReactionKRunning::setDatasetParameters(int dataSetID, map<std::string, std: // read scale it = pars.find("q"); - _q[dataSetID] = it->second; + if(!checkParam(it->second)) // value provided + _qValue[dataSetID] = stod(it->second); + else // parameter name is provided + _q[dataSetID] = it->second; // for type=massMSbarNLO read q0: scale at which m(m) is quoted if(_type[dataSetID] == "massMSbarNLO") @@ -55,7 +58,7 @@ void ReactionKRunning::setDatasetParameters(int dataSetID, map<std::string, std: // Main function to compute results at an iteration int ReactionKRunning::compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err) { - double q = GetParam(_q[dataSetID]); + double q = (_qValue.find(dataSetID) != _qValue.end()) ? _qValue[dataSetID] : GetParam(_q[dataSetID]); if(_type[dataSetID] == "as") val = valarray<double>(getAlphaS(q), _NPoints[dataSetID]); else if(_type[dataSetID] == "massMSbarNLO") -- GitLab From 72b98c231ab6444b6b9b240e40bdff8390ea0d08 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Wed, 20 Feb 2019 01:02:48 +0100 Subject: [PATCH 25/81] more flexible implementation of MNR --- reactions/cbdiff/include/Reactioncbdiff.h | 45 +++++ reactions/cbdiff/src/Makefile.am | 20 +++ reactions/cbdiff/src/Reactioncbdiff.cc | 198 ++++++++++++++++++++++ reactions/cbdiff/yaml/parameters.yaml | 0 4 files changed, 263 insertions(+) create mode 100644 reactions/cbdiff/include/Reactioncbdiff.h create mode 100644 reactions/cbdiff/src/Makefile.am create mode 100644 reactions/cbdiff/src/Reactioncbdiff.cc create mode 100644 reactions/cbdiff/yaml/parameters.yaml diff --git a/reactions/cbdiff/include/Reactioncbdiff.h b/reactions/cbdiff/include/Reactioncbdiff.h new file mode 100644 index 000000000..5eed25068 --- /dev/null +++ b/reactions/cbdiff/include/Reactioncbdiff.h @@ -0,0 +1,45 @@ + +#pragma once + +#include "ReactionBaseHVQMNR.h" +//#include "ReactionTheory.h" + +/** + @class' Reactioncbdiff + + @brief A wrapper class for cbdiff reaction + + Based on the ReactionTheory class. Reads options produces 3d cross section. + + @version 0.1 + @date 2019-02-01 + */ + +class Reactioncbdiff : public ReactionBaseHVQMNR +//class Reactioncbdiff : public ReactionTheory +{ + public: + Reactioncbdiff(){}; + +// ~Reactioncbdiff(){}; +// ~Reactioncbdiff(const Reactioncbdiff &){}; +// Reactioncbdiff & operator =(const Reactioncbdiff &r){return *(new Reactioncbdiff(r));}; + + public: + virtual string getReactionName() const { return "cbdiff" ;}; + virtual int initAtStart(const string &); + virtual void initAtIteration(); + virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err); + virtual void setDatasetParameters(int dataSetID, map<string,string> pars, map<string,double> dsPars) override; + protected: + virtual int parseOptions(){ return 0;}; + + std::map<int, std::shared_ptr<MNR::MNR> > _mapMNR; + std::map<int, std::shared_ptr<MNR::Grid> > _mapGrid; + std::map<int, std::shared_ptr<MNR::Grid> > _mapGridSm; + std::map<int, std::shared_ptr<MNR::Frag> > _mapFrag; + std::map<int, std::shared_ptr<Parameters> > _mapPar; + std::map<int, std::vector<TH2D*> > _mapXSec; + std::map<int, double> _mapFF; +}; + diff --git a/reactions/cbdiff/src/Makefile.am b/reactions/cbdiff/src/Makefile.am new file mode 100644 index 000000000..16647bbe2 --- /dev/null +++ b/reactions/cbdiff/src/Makefile.am @@ -0,0 +1,20 @@ + +# Created by AddReaction.py on 2019-02-01 + +if HAVE_ROOT + +AM_CXXFLAGS = $(ROOT_CFLAGS) -I$(srcdir)/../../../reactions/BaseHVQMNR/include -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -Wall -fPIC -Wno-deprecated + +lib_LTLIBRARIES = libcbdiff_xfitter.la +libcbdiff_xfitter_la_SOURCES = Reactioncbdiff.cc + +# libcbdiff_xfitter_la_LDFLAGS = place_if_needed +libcbdiff_xfitter_la_LDFLAGS = -lbasehvqmnr_xfitter -L$(srcdir)/../../../reactions/BaseHVQMNR/src/.libs + +datadir = ${prefix}/yaml/reactions/cbdiff +data_DATA = ../yaml/parameters.yaml + +endif + +dist_noinst_HEADERS = ../include ../yaml + diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc new file mode 100644 index 000000000..c565787b9 --- /dev/null +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -0,0 +1,198 @@ + +/* + @file Reactioncbdiff.cc + @date 2019-02-01 + @author AddReaction.py + Created by AddReaction.py on 2019-02-01 +*/ + +#include "Reactioncbdiff.h" +#include <TMath.h> +#include <TF1.h> + +// the class factories +extern "C" Reactioncbdiff* create() { + return new Reactioncbdiff(); +} + +void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars, map<string,double> dsPars) +{ + ReactionBaseHVQMNR::setDatasetParameters(dataSetID, pars, dsPars); + //_debug = 1; + Steering steer; + if(checkParam("steer_q") || pars.find("steer_q") != pars.end()) + steer.q = GetParamIInPriority("steer_q", pars); + else + steer.q = true; + if(checkParam("steer_a") || pars.find("steer_a") != pars.end()) + steer.a = GetParamIInPriority("steer_a", pars); + else + steer.a = true; + steer.nf = GetParamIInPriority("steer_nf", pars); + steer.ptmin = GetParamInPriority("steer_ptmin", pars); + steer.ptmax = GetParamInPriority("steer_ptmax", pars); + steer.npt = GetParamIInPriority("steer_npt", pars); + steer.nptsm = GetParamIInPriority("steer_nptsm", pars); + steer.ymin = GetParamInPriority("steer_ymin", pars); + steer.ymax = GetParamInPriority("steer_ymax", pars); + steer.ny = GetParamIInPriority("steer_ny", pars); + steer.nsfnb = GetParamIInPriority("steer_nsfnb", pars); + steer.nx3 = GetParamIInPriority("steer_nx3", pars); + steer.nx4 = GetParamIInPriority("steer_nx4", pars); + steer.nbz = GetParamIInPriority("steer_nbz", pars); + steer.xmin = GetParamIInPriority("steer_xmin", pars); + steer.xmax = GetParamIInPriority("steer_xmax", pars); + steer.mf2min = GetParamIInPriority("steer_mf2min", pars); + steer.mf2max = GetParamIInPriority("steer_mf2max", pars); + + std::shared_ptr<Parameters>& par = _mapPar[dataSetID]; + par = std::shared_ptr<Parameters>(new Parameters); + // Order + std::string order = GetParamSInPriority("Order", pars); + MNR::MNRContribution contr = 11111; // NLO + if(order == "LO") + contr = 10111; + else if(order != "NLO") + hf_errlog(19020301, "F: order " + order + " not supported"); + const int ncontr = 1; + MNR::MNRContribution** ptrContr = new MNR::MNRContribution*[ncontr]; + ptrContr[0] = new MNR::MNRContribution(contr); + // HQ masses + par->mc = GetParamInPriority("mq", pars); + // scale parameters + //GetMuPar('f', 'q', par->mf_A_c, par->mf_B_c, par->mf_C_c, pars); + //GetMuPar('r', 'q', par->mr_A_c, par->mr_B_c, par->mr_C_c, pars); + par->mf_A_c = GetParamInPriority("mf_A", pars); + par->mf_B_c = GetParamInPriority("mf_B", pars); + par->mr_A_c = GetParamInPriority("mr_A", pars); + par->mr_B_c = GetParamInPriority("mr_B", pars); + // fragmentation parameters + par->fragpar_c = GetParamInPriority("FragPar", pars); + PrintParameters(par.get()); + + std::shared_ptr<MNR::MNR>& mnr = _mapMNR[dataSetID]; + mnr = std::shared_ptr<MNR::MNR>(new MNR::MNR(this)); + mnr->SetScaleCoef(par->mf_A_c, par->mf_B_c, par->mf_C_c, par->mr_A_c, par->mr_B_c, par->mr_C_c); + + std::shared_ptr<MNR::Grid>& grid = _mapGrid[dataSetID]; + grid = std::shared_ptr<MNR::Grid>(new MNR::Grid(ncontr, ptrContr)); + std::shared_ptr<MNR::Grid>& gridSm = _mapGridSm[dataSetID]; + gridSm = std::shared_ptr<MNR::Grid>(new MNR::Grid(ncontr, ptrContr)); + std::shared_ptr<MNR::Frag>& frag = _mapFrag[dataSetID]; + frag = std::shared_ptr<MNR::Frag>(new MNR::Frag); + std::vector<TH2D*>& xsec = _mapXSec[dataSetID]; + + mnr->SetDebug(_debug); + DefaultInit(steer, par->mc, *mnr.get(), *frag.get(), *grid.get(), *gridSm.get()); + mnr->fC_sh = TMath::Power(stod(pars["energy"]), 2.0); // centre-of-mass energy squared + mnr->CalcConstants(); + mnr->SetDebug(_debug); + std::string finalState = pars["FinalState"]; + if(finalState == "parton") + { + frag->AddOut(NULL, par->mc); + } + else + { + frag->AddOut(MNR::Frag::GetFragFunction(0, finalState.c_str(), par->fragpar_c), MNR::Frag::GetHadronMass(finalState.c_str())); + frag->GetFF(0)->SetParameter(1, par->fragpar_c); + } + _mapFF[dataSetID] = stod(pars["FragFrac"]); + + xsec.resize(1); + for(size_t i = 0; i < xsec.size(); i++) + { + xsec[i] = new TH2D; + // pT binning + std::vector<double> binsPt; + if(pars.find("pTn") != pars.end() && pars.find("pTmin") != pars.end() && pars.find("pTmax") != pars.end()) + { + int nb = stoi(pars["pTn"]); + binsPt.resize(nb + 1); + double w = (stod(pars["pTmax"]) - stod(pars["pTmin"])) / nb; + for(int b = 0; b < nb + 1; b++) + binsPt[b] = stod(pars["pTmin"]) + w * b; + } + else if(pars.find("pT") != pars.end()) + { + std::istringstream ss(pars["pT"]); + std::string token; + while(std::getline(ss, token, ',')) + binsPt.push_back(stod(token)); + } + else + hf_errlog(19021900, "F: no pT binning provided"); + // y binning + std::vector<double> binsY; + if(pars.find("yn") != pars.end() && pars.find("ymin") != pars.end() && pars.find("ymax") != pars.end()) + { + int nb = stoi(pars["yn"]); + binsY.resize(nb + 1); + double w = (stod(pars["ymax"]) - stod(pars["ymin"])) / nb; + for(int b = 0; b < nb + 1; b++) + binsY[b] = stod(pars["ymin"]) + w * b; + } + else if(pars.find("y") != pars.end()) + { + std::istringstream ss(pars["y"]); + std::string token; + while(std::getline(ss, token, ',')) + binsY.push_back(stod(token)); + } + else + hf_errlog(19021901, "F: no y binning provided"); + xsec[i]->SetBins(binsPt.size() - 1, &binsPt[0], binsY.size() - 1, &binsY[0]); + } + + // test + //mnr.get()->CalcXS(grid.get(), par->mc); + //MNR::Grid::InterpolateGrid(gridSm.get(), gridSm.get(), par->mc); + //frag->CalcCS(gridSm.get(), par->mc, xsec); + //xsec[0]->Print("all"); +} + +// Initialize at the start of the computation +int Reactioncbdiff::initAtStart(const string &s) +{ + return 0; +} + +void Reactioncbdiff::initAtIteration() +{ + ; +} + +// Main function to compute results at an iteration +int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err) +{ + //printf("COMPUTE\n"); + std::shared_ptr<MNR::MNR> mnr(_mapMNR[dataSetID]); + std::shared_ptr<Parameters> par(_mapPar[dataSetID]); + std::shared_ptr<MNR::Grid> grid(_mapGrid[dataSetID]); + std::shared_ptr<MNR::Grid> gridSm(_mapGridSm[dataSetID]); + std::shared_ptr<MNR::Frag> frag(_mapFrag[dataSetID]); + std::vector<TH2D*> xsec(_mapXSec[dataSetID]); + + mnr->CalcXS(grid.get(), par->mc); + MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); + frag->CalcCS(gridSm.get(), par->mc, xsec); + //xsec[0]->Print("all"); + + DataSet& ds = _dataSets[dataSetID]; + if (ds.BinsYMin == NULL || ds.BinsYMax == NULL || ds.BinsPtMin == NULL || ds.BinsPtMax == NULL ) + { + // fill results array with cross sections bin by bin + int nbx = xsec[0]->GetNbinsX(); + for(size_t i = 0; i < val.size(); i++) + val[i] = xsec[0]->GetBinContent((i % nbx) + 1, (i / nbx) + 1) * _mapFF[dataSetID]; + } + else + { + // fill results array with cross sections by matching bins + for(unsigned int i = 0; i < ds.BinsYMin->size(); i++) + val[i] = FindXSecPtYBin(xsec[0], (*ds.BinsYMin)[i], (*ds.BinsYMax)[i], (*ds.BinsPtMin)[i], (*ds.BinsPtMax)[i], false, false) * _mapFF[dataSetID]; + } + + return 0; +} + diff --git a/reactions/cbdiff/yaml/parameters.yaml b/reactions/cbdiff/yaml/parameters.yaml new file mode 100644 index 000000000..e69de29bb -- GitLab From 94c802de70919f89a228fd8dae23e9c891d2031a Mon Sep 17 00:00:00 2001 From: Alexander Glazov <alexander.glazov@desy.de> Date: Wed, 20 Feb 2019 09:41:47 +0000 Subject: [PATCH 26/81] Improve toys --- src/mc_errors.f | 103 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 89 insertions(+), 14 deletions(-) diff --git a/src/mc_errors.f b/src/mc_errors.f index 0f7708344..7c1d19d99 100644 --- a/src/mc_errors.f +++ b/src/mc_errors.f @@ -24,7 +24,8 @@ C To be used as a seed: double precision s,voica,dummy_st,sorig C Single precision here: - real rndsh,ranflat + real rndsh(3) ! additive, poisson, linear + $ ,ranflat C double precision rand_shift(NSYS) double precision r_sh_fl(NSYS) @@ -41,11 +42,11 @@ C For log normal random shifts: double precision estat_in, ecor_in, euncor_in, etot_in !> Input uncertainites double precision estat_out,euncor_out ! recalculated stat. error - double precision alpha_rel ! original relative alpha (uncertainty) - + double precision scaleF + integer scaling_type C functions: real logshift - double precision alnorm + double precision alnorm C------------------------------------------------------------ @@ -64,7 +65,7 @@ C call rnorml(rndsh,1) ! gauss random number call ranlux(ranflat,1) ! uniform random number - rand_shift(isys) = rndsh + rand_shift(isys) = rndsh(1) r_sh_fl(isys) = (ranflat-0.5)*f_un print '(''random numbers: sys, gauss, flat '',2i6,2F8.2)', @@ -76,12 +77,9 @@ C C Loop over the data: C do n0=1,npoints - call rnorml(rndsh,1) + call rnorml(rndsh,3) call ranlux(ranflat,1) -C Store relative alpha: - alpha_rel = alpha(n0)/DATEN(n0) - if (lrandData) then s = DATEN(n0) else @@ -128,9 +126,13 @@ CV now choose sta (advised gauss OR poisson) if (statype.eq.1) then ! gauss - alpha(n0) = sorig * alpha_rel ! adjust alpha0, important for theory-like data. - s = s + rndsh * alpha(n0) - +C do separate fluctuations for stat-const, stat-poisson and stat-linear pieces + s = s + $ + sqrt( e_uncor_const(n0)**2 + e_stat_const(n0)**2) + $ * daten(n0)*rndsh(1) + $ + sqrt( e_uncor_poisson(n0)**2 + e_stat_poisson(n0)**2) + $ * sqrt(abs(daten(n0)*sorig))*rndsh(2) + $ + e_uncor_mult(n0)*sorig*rndsh(3) c if (alpha(n0).eq.0) then c s = 0.1 c alpha(n0) = 1.e6 @@ -185,7 +187,7 @@ C New absolute uncor: euncor_out = euncor_in / data_in * s ! rescale to new value if (statype.eq.14) then - s = s + rndsh*euncor_in + s = s + rndsh(1)*euncor_in else if (statype.eq.34) then lsig = euncor_in lmu=1. @@ -217,12 +219,85 @@ C Store uncor in %: print $ '(''Original, systematics and stat. shifted data:'',i4,5E12.4)' $ , n0,sorig, voica,s,alpha(n0),e_unc(n0)/100.*s + + + if (s.eq.0) then + call hf_errlog(1302201902, + $ 'S: ToyMC cross section with exact ZERO value, stopOB') + endif + +C Re-scale relative error sources, depending on scaling rule define in chi2 or data files. +C For : +C - addivie ("NoRescale") errors keep absolute errors unmodified +C - multiplicaiive ("Linear") errors keep relative errors unmodified +C - poisson ("Poisson") keep error * sqrt(old/newVal) unmodified + + scaleF = DATEN(n0)/s + + if (s .lt. 0) then + call hf_errlog(1302201901, + $ 'W: ToyMC cross section with negative value, ' // + $ 'reset error scaling to NoRescale') + e_uncor_const(n0) = sqrt(e_uncor_const(n0)**2 + $ + e_uncor_poisson(n0)**2 + $ + e_uncor_mult(n0)**2 ) + e_stat_const(n0) = sqrt(e_stat_const(n0)**2+ + $ e_stat_poisson(n0)**2) + + e_stat_poisson(n0) = 0. + e_uncor_poisson(n0) = 0. + e_uncor_mult(n0) = 0. + else + e_stat_poisson(n0) = e_stat_poisson(n0) * sqrt(scaleF) + e_uncor_poisson(n0) = e_uncor_poisson(n0) * sqrt(scaleF) + e_uncor_mult(n0) = e_uncor_mult(n0) ! NO scale, keep relative + endif + e_uncor_const(n0) = e_uncor_const(n0) * scaleF + e_stat_const(n0) = e_stat_const(n0) * scaleF +C XXXXX +C The following scaling of e_tot assumes constant (no) scaling. +C This is not intuitive, since e_tot is a sum in quadrature of +C different error sources, with different scaling laws. +C However, currently, e_tot is the total uncertainty as given +C by experiment. It is used only for printing in fittedresults.txt +c and used in xfitter-draw which shows data points with total +c experimental uncertainties as given in the experimental publications. +c We should introduce a function which computes properly scaled etot, +C in addition to the constant etot. + e_tot(n0) = e_tot(n0) * scaleF + +C Also correlated systematicss: + do isys=1,nsys + + scaling_type = SysScalingType(isys) + + if ( + $ (scaling_type .eq. isNoRescale) + $ .or. (LForceAdditiveData(n0) ) + $ ) then ! additive, keep absolute + beta(isys,n0) = beta(isys,n0) * scaleF + omega(isys,n0) = omega(isys,n0) * scaleF + elseif (scaling_type.eq. isLinear) then ! mult, do nothing + beta(isys,n0) = beta(isys,n0) + omega(isys,n0) = omega(isys,n0) + elseif (scaling_type.eq. isPoisson) then + beta(isys,n0) = beta(isys,n0) * sqrt(scaleF) + omega(isys,n0) = omega(isys,n0) * sqrt(scaleF) + endif + enddo + DATEN(n0) = s +C update alpha: + alpha(n0) = sqrt(e_uncor_mult(n0)**2 + $ +e_stat_poisson(n0)**2 + $ +e_uncor_const(n0)**2 + $ +e_stat_const(n0)**2 + $ +e_uncor_poisson(n0)**2) + $ *daten(n0) enddo C call HF_stop - C------------------------------------------------------------ end -- GitLab From e049bf254350a801eafeea852ad5ee196ddb1699 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sun, 24 Feb 2019 00:24:00 +0100 Subject: [PATCH 27/81] built-in implementation of scheme transformation for dynamic scale, need cleanup --- reactions/BaseHVQMNR/include/MNR.h | 15 ++- reactions/BaseHVQMNR/include/MNRGrid.h | 9 ++ .../BaseHVQMNR/include/ReactionBaseHVQMNR.h | 9 +- reactions/BaseHVQMNR/src/MNR.cc | 2 + reactions/BaseHVQMNR/src/MNRGrid.cc | 124 ++++++++++++++++++ .../BaseHVQMNR/src/ReactionBaseHVQMNR.cc | 21 ++- reactions/cbdiff/include/Reactioncbdiff.h | 6 + reactions/cbdiff/src/Reactioncbdiff.cc | 91 +++++++++++-- 8 files changed, 255 insertions(+), 22 deletions(-) diff --git a/reactions/BaseHVQMNR/include/MNR.h b/reactions/BaseHVQMNR/include/MNR.h index 455e1bee3..2d65ebca5 100644 --- a/reactions/BaseHVQMNR/include/MNR.h +++ b/reactions/BaseHVQMNR/include/MNR.h @@ -92,6 +92,14 @@ namespace MNR double fSF_min_mf2; double fSF_max_mf2; + // Perturbative scale coefficients + double fMf_A; + double fMf_B; + double fMf_C; + double fMr_A; + double fMr_B; + double fMr_C; + // Private fields private: // Constants @@ -105,13 +113,6 @@ namespace MNR double fC_sqrt_sh; // Normalisation factor double fC_xnorm; - // Perturbative scale coefficients - double fMf_A; - double fMf_B; - double fMf_C; - double fMr_A; - double fMr_B; - double fMr_C; // Variables for fast structure functions evaluation const static int fSF_npart; diff --git a/reactions/BaseHVQMNR/include/MNRGrid.h b/reactions/BaseHVQMNR/include/MNRGrid.h index 45f498d7e..6d2db43b1 100644 --- a/reactions/BaseHVQMNR/include/MNRGrid.h +++ b/reactions/BaseHVQMNR/include/MNRGrid.h @@ -70,6 +70,9 @@ namespace MNR // Get cross section (by reference) in specified bin inline double& CS(int contr, int bl, int by, int bw=0) { return fCS[contr][bl][by][bw]; }; + // Get alpha_s (by reference) in specified bin + inline double& AlphaS(int bl) { return fAs[bl]; }; + // Get number of pT (L) bins inline int NL() { return fNL; }; @@ -115,6 +118,10 @@ namespace MNR // Transformation from original grid (gridorig) to new one (gridtrg) // (using cubic spline interpolation) static void InterpolateGrid(Grid* gridorig, Grid* gridtrg, double mq); + static void InterpolateGrid(Grid* gridorig, Grid* gridtrg, double mq, Grid* gridorig_LO_massUp, double mq_masUp, Grid* gridorig_LO_massDown, double mq_masDown); + + // Transformation from pole mass scaheme into MSbar mass scheme + static void TransformGridToMSbarMassScheme(Grid* grid, Grid* gridLOMassUp, Grid* gridLOMassDown, double mq, double mqDiff); // Private fields private: @@ -138,5 +145,7 @@ namespace MNR int fNContr; // Contributions MNRContribution** fContr; + // alpha_s in pT (L) bins + double* fAs; }; } diff --git a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h index 48abf48b3..827782f3e 100644 --- a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h +++ b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h @@ -133,7 +133,10 @@ class ReactionBaseHVQMNR : public ReactionTheory // initialise calculation with default parameters void DefaultInit(const Steering& steer, const double mq, MNR::MNR& mnr, MNR::Frag& frag, MNR::Grid& grid, MNR::Grid& grid_smoothed); - + void DefaultInitMNR(const Steering& steer, const double mq, MNR::MNR& mnr); + void DefaultInitGrid(const Steering& steer, const double mq, const int npt, MNR::Grid& grid); + void DefaultInitFrag(const Steering& steer, MNR::Frag& frag); + // return cross section in provided pT-y bin double FindXSecPtYBin(const TH2* histXSec, const double ymin, const double ymax, const double ptmin, const double ptmax, const bool diff_pt, const bool diff_y); @@ -155,7 +158,7 @@ class ReactionBaseHVQMNR : public ReactionTheory double GetFragPar(const char q, const map<string,string> pars = map<string,string>()); // check parameter respecting priority: (1) supplied map (if supplied), (2) global - double checkParamInPriority(const string& name, const std::map<string,string> pars = std::map<string,string>()) const + bool checkParamInPriority(const string& name, const std::map<string,string> pars = std::map<string,string>()) const { if(pars.size() != 0) return (pars.find(name) != pars.end()); @@ -173,7 +176,7 @@ class ReactionBaseHVQMNR : public ReactionTheory } // get parameter respecting priority: (1) supplied map (if supplied), (2) global - double GetParamIInPriority(const string& name, const std::map<string,string> pars = std::map<string,string>()) const + int GetParamIInPriority(const string& name, const std::map<string,string> pars = std::map<string,string>()) const { if(pars.find(name) != pars.end()) return std::stod(pars.at(name)); diff --git a/reactions/BaseHVQMNR/src/MNR.cc b/reactions/BaseHVQMNR/src/MNR.cc index e2dbe590b..24c2f05f4 100644 --- a/reactions/BaseHVQMNR/src/MNR.cc +++ b/reactions/BaseHVQMNR/src/MNR.cc @@ -507,6 +507,8 @@ namespace MNR double as = GetAs(mr2); double as2 = as * as; double as3 = as2 * as; + // store alpha_s in grid + grid->AlphaS(c_l) = as; // Ratios of scales double xmf = TMath::Log(mf2 / xm2); double xmr = 4 * fC_pi * fC_b0 * TMath::Log(mr2 / mf2); diff --git a/reactions/BaseHVQMNR/src/MNRGrid.cc b/reactions/BaseHVQMNR/src/MNRGrid.cc index e377b3df7..bb0a9069e 100644 --- a/reactions/BaseHVQMNR/src/MNRGrid.cc +++ b/reactions/BaseHVQMNR/src/MNRGrid.cc @@ -11,6 +11,7 @@ namespace MNR fNY = 0; fNW = 0; fL = NULL; + fAs = NULL; fY = NULL; fW = NULL; fBW = NULL; @@ -28,6 +29,7 @@ namespace MNR fNY = 0; fNW = 0; fL = NULL; + fAs = NULL; fY = NULL; fW = NULL; fBW = NULL; @@ -43,6 +45,7 @@ namespace MNR { //printf("OZ Grid::~Grid()\n"); if(fL) delete fL; + if(fAs) delete fAs; if(fY) delete fY; if(fW) delete fW; if(fBW) delete fBW; @@ -108,6 +111,9 @@ namespace MNR double pt = TMath::Power(minpower + i * steppower, 1.0 / power); fL[i] = xm2 / (xm2 + pt * pt); } + // array for alpha_s values + if(fAs) delete fAs; + fAs = new double[fNL]; } void Grid::FillPt(double* ptall, double xm) @@ -255,5 +261,123 @@ namespace MNR TSpline3 spline("", spline_x, spline_y, nlorig); for(int l = 0; l < nltrg; l++) gridtrg->CS(c,l,y,w) = spline.Eval(ltrg[l]); } + // interpolate as + double spline_y_as[nlorig]; + for(int l = 0; l < nlorig; l++) + spline_y_as[nlorig-1-l] = gridorig->AlphaS(l); + TSpline3 spline_as("", spline_x, spline_y_as, nlorig); + for(int l = 0; l < nltrg; l++) + gridtrg->AlphaS(l) = spline_as.Eval(ltrg[l]); + } + + void Grid::InterpolateGrid(Grid *gridorig, Grid *gridtrg, double mq, Grid *gridorig_LO_massUp, double mq_masUp, Grid *gridorig_LO_massDown, double mq_masDown) + { + double mqDiff = mq_masUp - mq_masDown; + // Get pT array of target grid + double pt[gridtrg->fNL]; + gridtrg->FillPt(pt, mq); + // Transform this pT array into array of L = m^2 / (m^2 + pT^2) + double mq2 = mq * mq; + double mq_masUp2 = mq_masUp * mq_masUp; + double mq_masDown2 = mq_masDown * mq_masDown; + int nltrg = gridtrg->NL(); + double* ltrg = gridtrg->LPtr(); + for(int i = 0; i < nltrg; i++) ltrg[i] = mq2 / (mq2 + pt[i] * pt[i]); + // For spline: prepare L array of original grid in reversed order + int nlorig = gridorig->NL(); + double* lorig = gridorig->LPtr(); + double* lorig_LO_massUp = gridorig_LO_massUp->LPtr(); + double* lorig_LO_massDown = gridorig_LO_massDown->LPtr(); + double spline_x[3][nlorig], spline_y[4][nlorig]; + for(int i = 0; i < nlorig; i++) + { + //spline_x[0][nlorig-1-i] = mq2 / lorig[i] - mq2; + //spline_x[1][nlorig-1-i] = mq_masUp2 / lorig_LO_massUp[i] - mq_masUp2; + //spline_x[2][nlorig-1-i] = mq_masDown2 / lorig_LO_massDown[i] - mq_masDown2; + spline_x[0][i] = mq2 / lorig[i] - mq2; + spline_x[1][i] = mq_masUp2 / lorig_LO_massUp[i] - mq_masUp2; + spline_x[2][i] = mq_masDown2 / lorig_LO_massDown[i] - mq_masDown2; + } + // Loop over contributions + for(int c = 0; c < gridorig->GetNContr(); c++) + // Loop over y bins + for(int y = 0; y < gridorig->NY(); y++) + // Loop over W bins + for(int w = 0; w < gridorig->NW(); w++) + { + // For spline: prepare X-section array of original grid in reversed order + for(int l = 0; l < nlorig; l++) + { + //spline_y[0][nlorig-1-l] = gridorig->CS(c,l,y,w); + //spline_y[1][nlorig-1-l] = gridorig_LO_massUp->CS(c,l,y,w); + //spline_y[2][nlorig-1-l] = gridorig_LO_massDown->CS(c,l,y,w); + //spline_y[3][nlorig-1-l] = gridorig->AlphaS(l); + spline_y[0][l] = gridorig->CS(c,l,y,w); + spline_y[1][l] = gridorig_LO_massUp->CS(c,l,y,w); + spline_y[2][l] = gridorig_LO_massDown->CS(c,l,y,w); + spline_y[3][l] = gridorig->AlphaS(l); + } + // Spline interpolation + TSpline3 spline("", spline_x[0], spline_y[0], nlorig); + TSpline3 spline_LO_massUp("", spline_x[1], spline_y[1], nlorig); + TSpline3 spline_LO_massDown("", spline_x[2], spline_y[2], nlorig); + //TSpline3 spline_LO_massUp("", spline_x[0], spline_y[1], nlorig); + //TSpline3 spline_LO_massDown("", spline_x[0], spline_y[2], nlorig); + TSpline3 spline_as("", spline_x[0], spline_y[3], nlorig); + for(int l = 0; l < nltrg; l++) + { + //double pt2 = mq2 / ltrg[l] - mq2; + double pt2 = pt[l] * pt[l]; + //double xsecOld = spline.Eval(ltrg[l]); + //double xsecOld_LO_massUp = spline_LO_massUp.Eval(ltrg[l]); + //double xsecOld_LO_massDown = spline_LO_massDown.Eval(ltrg[l]); + //double as = spline_as.Eval(ltrg[l]); + double xsecOld = spline.Eval(pt2); + double xsecOld_LO_massUp = spline_LO_massUp.Eval(pt2); + double xsecOld_LO_massDown = spline_LO_massDown.Eval(pt2); + double as = spline_as.Eval(pt2); + //printf("as = %f\n", as); + double d1 = 4.0 / 3.0; + double xsecNew = xsecOld + as / TMath::Pi() * d1 * mq * (xsecOld_LO_massUp - xsecOld_LO_massDown) / mqDiff; + gridtrg->CS(c,l,y,w) = xsecNew; + //gridtrg->CS(c,l,y,w) = xsecOld; + //if(y == 20) + // printf("c,y,w,l,g,u,d: %d %d %d %d %f[%f] %f %f --> %f [%.2f]\n", c, y, w, l, xsecOld, pt2, xsecOld_LO_massUp, xsecOld_LO_massDown, xsecNew, xsecNew / xsecOld * 100); + } + } + // interpolate as + /*double spline_y_as[nlorig]; + for(int l = 0; l < nlorig; l++) + spline_y_as[nlorig-1-l] = gridorig->AlphaS(l); + TSpline3 spline_as("", spline_x[0], spline_y_as, nlorig); + for(int l = 0; l < nltrg; l++) + gridtrg->AlphaS(l) = spline_as.Eval(ltrg[l]);*/ + } + + void Grid::TransformGridToMSbarMassScheme(Grid *grid, Grid *gridLOMassUp, Grid *gridLOMassDown, double mq, double mqDiff) + { + // Loop over contributions + for(int c = 0; c < grid->GetNContr(); c++) + { + // Loop over y bins + for(int y = 0; y < grid->NY(); y++) + { + // Loop over W bins + for(int w = 0; w < grid->NW(); w++) + { + // Loop over pT (L) bins + for(int l = 0; l < grid->NL(); l++) + { + double as = grid->AlphaS(l); + //printf("as = %f\n", as); + double d1 = 4.0 / 3.0; + double xsecNew = grid->CS(c,l,y,w) + as / TMath::Pi() * d1 * mq * (gridLOMassUp->CS(c,l,y,w) - gridLOMassDown->CS(c,l,y,w)) / (2 * mqDiff); + if(y == 20) + printf("c,y,w,l,g,u,d: %d %d %d %d %f[%f] %f[%f] %f[%f] --> %f [%.2f]\n", c, y, w, l, grid->CS(c,l,y,w), grid->LPtr()[l], gridLOMassUp->CS(c,l,y,w), gridLOMassUp->LPtr()[l], gridLOMassDown->CS(c,l,y,w), gridLOMassDown->LPtr()[l], xsecNew, xsecNew / grid->CS(c,l,y,w) * 100); + grid->CS(c,l,y,w) = xsecNew; + } + } + } + } } } diff --git a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc index 58f9ab170..17dd02dd8 100644 --- a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc +++ b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc @@ -115,6 +115,14 @@ bool ReactionBaseHVQMNR::IsEqual(const double val1, const double val2, const dou // initialise calculation with default parameters void ReactionBaseHVQMNR::DefaultInit(const Steering& steer, const double mq, MNR::MNR& mnr, MNR::Frag& frag, MNR::Grid& grid, MNR::Grid& grid_smoothed) +{ + DefaultInitMNR(steer, mq, mnr); + DefaultInitGrid(steer, mq, steer.npt, grid); + DefaultInitGrid(steer, mq, steer.nptsm, grid_smoothed); + DefaultInitFrag(steer, frag); +} + +void ReactionBaseHVQMNR::DefaultInitMNR(const ReactionBaseHVQMNR::Steering &steer, const double mq, MNR::MNR &mnr) { // MNR parton level cross sections, quark-antiquark contributions mnr.bFS_Q = steer.q; @@ -132,13 +140,18 @@ void ReactionBaseHVQMNR::DefaultInit(const Steering& steer, const double mq, MNR mnr.fSF_max_mf2 = steer.mf2max; // precalculation (memory allocation etc.) mnr.CalcBinning(); +} + +void ReactionBaseHVQMNR::DefaultInitGrid(const ReactionBaseHVQMNR::Steering &steer, const double mq, const int npt, MNR::Grid &grid) +{ // Parton level pT-y grids - grid.SetL(steer.npt, steer.ptmin, steer.ptmax, mq); + grid.SetL(npt, steer.ptmin, steer.ptmax, mq); grid.SetY(steer.ny, steer.ymin, steer.ymax); grid.SetW(1); - grid_smoothed.SetL(steer.nptsm, steer.ptmin, steer.ptmax, mq); - grid_smoothed.SetY(steer.ny, steer.ymin, steer.ymax); - grid_smoothed.SetW(1); +} + +void ReactionBaseHVQMNR::DefaultInitFrag(const ReactionBaseHVQMNR::Steering &steer, MNR::Frag &frag) +{ // Fragmentation frag.SetNz(steer.nbz); } diff --git a/reactions/cbdiff/include/Reactioncbdiff.h b/reactions/cbdiff/include/Reactioncbdiff.h index 5eed25068..765a86204 100644 --- a/reactions/cbdiff/include/Reactioncbdiff.h +++ b/reactions/cbdiff/include/Reactioncbdiff.h @@ -36,6 +36,12 @@ class Reactioncbdiff : public ReactionBaseHVQMNR std::map<int, std::shared_ptr<MNR::MNR> > _mapMNR; std::map<int, std::shared_ptr<MNR::Grid> > _mapGrid; + std::map<int, bool> _mapMSbarMass; + std::map<int, double> _mapMassDiff; + std::map<int, std::shared_ptr<MNR::Grid> > _mapGridLOMassUp; + std::map<int, std::shared_ptr<MNR::Grid> > _mapGridLOMassDown; + std::map<int, std::shared_ptr<MNR::Grid> > _mapGridSmLOMassUp; + std::map<int, std::shared_ptr<MNR::Grid> > _mapGridSmLOMassDown; std::map<int, std::shared_ptr<MNR::Grid> > _mapGridSm; std::map<int, std::shared_ptr<MNR::Frag> > _mapFrag; std::map<int, std::shared_ptr<Parameters> > _mapPar; diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index c565787b9..1c1f8dcba 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -40,25 +40,31 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars steer.nx3 = GetParamIInPriority("steer_nx3", pars); steer.nx4 = GetParamIInPriority("steer_nx4", pars); steer.nbz = GetParamIInPriority("steer_nbz", pars); - steer.xmin = GetParamIInPriority("steer_xmin", pars); - steer.xmax = GetParamIInPriority("steer_xmax", pars); - steer.mf2min = GetParamIInPriority("steer_mf2min", pars); - steer.mf2max = GetParamIInPriority("steer_mf2max", pars); + steer.xmin = GetParamInPriority("steer_xmin", pars); + steer.xmax = GetParamInPriority("steer_xmax", pars); + steer.mf2min = GetParamInPriority("steer_mf2min", pars); + steer.mf2max = GetParamInPriority("steer_mf2max", pars); std::shared_ptr<Parameters>& par = _mapPar[dataSetID]; par = std::shared_ptr<Parameters>(new Parameters); // Order std::string order = GetParamSInPriority("Order", pars); - MNR::MNRContribution contr = 11111; // NLO + MNR::MNRContribution contrNLO = 11111; // NLO + MNR::MNRContribution contrLO = 10111; // NLO + MNR::MNRContribution contr = contrNLO; if(order == "LO") - contr = 10111; + contr = contrLO; else if(order != "NLO") hf_errlog(19020301, "F: order " + order + " not supported"); const int ncontr = 1; MNR::MNRContribution** ptrContr = new MNR::MNRContribution*[ncontr]; ptrContr[0] = new MNR::MNRContribution(contr); + MNR::MNRContribution** ptrContrLO = new MNR::MNRContribution*[ncontr]; + ptrContrLO[0] = new MNR::MNRContribution(contrLO); // HQ masses par->mc = GetParamInPriority("mq", pars); + _mapMassDiff[dataSetID] = 0.001; // for MSbar mass transformation; 1 MeV should work for c, b and t + //_mapMassDiff[dataSetID] = 0.150; // for MSbar mass transformation; 1 MeV should work for c, b and t // scale parameters //GetMuPar('f', 'q', par->mf_A_c, par->mf_B_c, par->mf_C_c, pars); //GetMuPar('r', 'q', par->mr_A_c, par->mr_B_c, par->mr_C_c, pars); @@ -69,21 +75,47 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars // fragmentation parameters par->fragpar_c = GetParamInPriority("FragPar", pars); PrintParameters(par.get()); + // pole or MSbar mass + _mapMSbarMass[dataSetID] = 0; + if(checkParamInPriority("MS_MASS", pars)) + _mapMSbarMass[dataSetID] = GetParamInPriority("MS_MASS", pars); std::shared_ptr<MNR::MNR>& mnr = _mapMNR[dataSetID]; mnr = std::shared_ptr<MNR::MNR>(new MNR::MNR(this)); mnr->SetScaleCoef(par->mf_A_c, par->mf_B_c, par->mf_C_c, par->mr_A_c, par->mr_B_c, par->mr_C_c); + // main grid (LO or NLO) std::shared_ptr<MNR::Grid>& grid = _mapGrid[dataSetID]; grid = std::shared_ptr<MNR::Grid>(new MNR::Grid(ncontr, ptrContr)); + // LO mass up grid (for MSbar mass) + std::shared_ptr<MNR::Grid>& gridLOMassUp = _mapGridLOMassUp[dataSetID]; + gridLOMassUp = std::shared_ptr<MNR::Grid>(new MNR::Grid(ncontr, ptrContrLO)); + std::shared_ptr<MNR::Grid>& gridSmLOMassUp = _mapGridSmLOMassUp[dataSetID]; + gridSmLOMassUp = std::shared_ptr<MNR::Grid>(new MNR::Grid(ncontr, ptrContrLO)); + // LO mass down grid (for MSbar mass) + std::shared_ptr<MNR::Grid>& gridLOMassDown = _mapGridLOMassDown[dataSetID]; + gridLOMassDown = std::shared_ptr<MNR::Grid>(new MNR::Grid(ncontr, ptrContrLO)); + std::shared_ptr<MNR::Grid>& gridSmLOMassDown = _mapGridSmLOMassDown[dataSetID]; + gridSmLOMassDown = std::shared_ptr<MNR::Grid>(new MNR::Grid(ncontr, ptrContrLO)); + // final smoothed grid std::shared_ptr<MNR::Grid>& gridSm = _mapGridSm[dataSetID]; gridSm = std::shared_ptr<MNR::Grid>(new MNR::Grid(ncontr, ptrContr)); + std::shared_ptr<MNR::Frag>& frag = _mapFrag[dataSetID]; frag = std::shared_ptr<MNR::Frag>(new MNR::Frag); std::vector<TH2D*>& xsec = _mapXSec[dataSetID]; mnr->SetDebug(_debug); - DefaultInit(steer, par->mc, *mnr.get(), *frag.get(), *grid.get(), *gridSm.get()); + DefaultInitMNR(steer, par->mc, *mnr.get()); + DefaultInitGrid(steer, par->mc, steer.npt, *grid.get()); + DefaultInitGrid(steer, par->mc, steer.npt, *gridLOMassUp.get()); + DefaultInitGrid(steer, par->mc, steer.npt, *gridLOMassDown.get()); + //DefaultInitGrid(steer, par->mc + _mapMassDiff[dataSetID], steer.npt, *gridLOMassUp.get()); + //DefaultInitGrid(steer, par->mc - _mapMassDiff[dataSetID], steer.npt, *gridLOMassDown.get()); + DefaultInitGrid(steer, par->mc, steer.nptsm, *gridSm.get()); + DefaultInitGrid(steer, par->mc, steer.nptsm, *gridSmLOMassUp.get()); + DefaultInitGrid(steer, par->mc, steer.nptsm, *gridSmLOMassDown.get()); + DefaultInitFrag(steer, *frag.get()); mnr->fC_sh = TMath::Power(stod(pars["energy"]), 2.0); // centre-of-mass energy squared mnr->CalcConstants(); mnr->SetDebug(_debug); @@ -174,7 +206,50 @@ int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, va std::vector<TH2D*> xsec(_mapXSec[dataSetID]); mnr->CalcXS(grid.get(), par->mc); - MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); + //MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); + + // tarnsformation to MSbar mass scheme + if(_mapMSbarMass[dataSetID]) + { + // store original scale B parameters which need to be modify for changed mass + const double mfB = mnr->fMf_B; + const double mrB = mnr->fMr_B; + + // LO mass up variation + double massU = par->mc + _mapMassDiff[dataSetID]; + mnr->fMf_B = mfB * pow(par->mc / massU, 2.0); + mnr->fMr_B = mrB * pow(par->mc / massU, 2.0); + std::shared_ptr<MNR::Grid> gridLOMassU(_mapGridLOMassUp[dataSetID]); + mnr->CalcXS(gridLOMassU.get(), massU); + //std::shared_ptr<MNR::Grid> gridSmLOMassU(_mapGridSmLOMassUp[dataSetID]); + //MNR::Grid::InterpolateGrid(gridLOMassU.get(), gridSmLOMassU.get(), massU); + //MNR::Grid::InterpolateGrid(gridLOMassU.get(), gridSmLOMassU.get(), par->mc); + + // LO mass down variation + double massD = par->mc - _mapMassDiff[dataSetID]; + mnr->fMf_B = mfB * pow(par->mc / massD, 2.0); + mnr->fMr_B = mrB * pow(par->mc / massD, 2.0); + std::shared_ptr<MNR::Grid> gridLOMassD(_mapGridLOMassDown[dataSetID]); + mnr->CalcXS(gridLOMassD.get(), massD); + //std::shared_ptr<MNR::Grid> gridSmLOMassD(_mapGridSmLOMassDown[dataSetID]); + //MNR::Grid::InterpolateGrid(gridLOMassD.get(), gridSmLOMassD.get(), massD); + //MNR::Grid::InterpolateGrid(gridLOMassD.get(), gridSmLOMassD.get(), par->mc); + + // scheme transformation + //MNR::Grid::TransformGridToMSbarMassScheme(grid.get(), gridLOMassU.get(), gridLOMassD.get(), par->mc, _mapMassDiff[dataSetID]); + //MNR::Grid::TransformGridToMSbarMassScheme(gridSm.get(), gridSmLOMassU.get(), gridSmLOMassD.get(), par->mc, _mapMassDiff[dataSetID]); + + // restore original scales + mnr->fMf_B = mfB; + mnr->fMr_B = mrB; + + MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc, gridLOMassU.get(), massU, gridLOMassD.get(), massD); + //MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); + } + else + MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); + + //MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); frag->CalcCS(gridSm.get(), par->mc, xsec); //xsec[0]->Print("all"); -- GitLab From 5db79cd92756a88f638196c138ab9bde56f0e319 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sun, 24 Feb 2019 21:16:37 +0100 Subject: [PATCH 28/81] implemented ln dependence in d1 --- reactions/BaseHVQMNR/include/MNRGrid.h | 7 ++++++- reactions/BaseHVQMNR/src/MNR.cc | 3 +++ reactions/BaseHVQMNR/src/MNRGrid.cc | 28 ++++++++++++++++++++++---- reactions/cbdiff/src/Reactioncbdiff.cc | 3 ++- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/reactions/BaseHVQMNR/include/MNRGrid.h b/reactions/BaseHVQMNR/include/MNRGrid.h index 6d2db43b1..5b5bbc301 100644 --- a/reactions/BaseHVQMNR/include/MNRGrid.h +++ b/reactions/BaseHVQMNR/include/MNRGrid.h @@ -73,6 +73,9 @@ namespace MNR // Get alpha_s (by reference) in specified bin inline double& AlphaS(int bl) { return fAs[bl]; }; + // Get mu_r (by reference) in specified bin + inline double& MuR(int bl) { return fMr[bl]; }; + // Get number of pT (L) bins inline int NL() { return fNL; }; @@ -118,7 +121,7 @@ namespace MNR // Transformation from original grid (gridorig) to new one (gridtrg) // (using cubic spline interpolation) static void InterpolateGrid(Grid* gridorig, Grid* gridtrg, double mq); - static void InterpolateGrid(Grid* gridorig, Grid* gridtrg, double mq, Grid* gridorig_LO_massUp, double mq_masUp, Grid* gridorig_LO_massDown, double mq_masDown); + static void InterpolateGrid(Grid* gridorig, Grid* gridtrg, double mq, Grid* gridorig_LO_massUp, double mq_masUp, Grid* gridorig_LO_massDown, double mq_masDown, int flag = 0); // Transformation from pole mass scaheme into MSbar mass scheme static void TransformGridToMSbarMassScheme(Grid* grid, Grid* gridLOMassUp, Grid* gridLOMassDown, double mq, double mqDiff); @@ -147,5 +150,7 @@ namespace MNR MNRContribution** fContr; // alpha_s in pT (L) bins double* fAs; + // mu_r in pT (L) bins + double* fMr; }; } diff --git a/reactions/BaseHVQMNR/src/MNR.cc b/reactions/BaseHVQMNR/src/MNR.cc index 24c2f05f4..68ab2db80 100644 --- a/reactions/BaseHVQMNR/src/MNR.cc +++ b/reactions/BaseHVQMNR/src/MNR.cc @@ -498,6 +498,7 @@ namespace MNR this->PrecalculatePDF(mf2); // Renormalisation scale double mr2 = this->GetMr2(xm2, pt2); + double mr = TMath::Sqrt(mr2); if(mr2 <= 0.0) { grid->NonPhys(c_l); @@ -509,6 +510,8 @@ namespace MNR double as3 = as2 * as; // store alpha_s in grid grid->AlphaS(c_l) = as; + // store mu_r in grid + grid->MuR(c_l) = mr; // Ratios of scales double xmf = TMath::Log(mf2 / xm2); double xmr = 4 * fC_pi * fC_b0 * TMath::Log(mr2 / mf2); diff --git a/reactions/BaseHVQMNR/src/MNRGrid.cc b/reactions/BaseHVQMNR/src/MNRGrid.cc index bb0a9069e..c751865a2 100644 --- a/reactions/BaseHVQMNR/src/MNRGrid.cc +++ b/reactions/BaseHVQMNR/src/MNRGrid.cc @@ -12,6 +12,7 @@ namespace MNR fNW = 0; fL = NULL; fAs = NULL; + fMr = NULL; fY = NULL; fW = NULL; fBW = NULL; @@ -30,6 +31,7 @@ namespace MNR fNW = 0; fL = NULL; fAs = NULL; + fMr = NULL; fY = NULL; fW = NULL; fBW = NULL; @@ -46,6 +48,7 @@ namespace MNR //printf("OZ Grid::~Grid()\n"); if(fL) delete fL; if(fAs) delete fAs; + if(fMr) delete fMr; if(fY) delete fY; if(fW) delete fW; if(fBW) delete fBW; @@ -114,6 +117,9 @@ namespace MNR // array for alpha_s values if(fAs) delete fAs; fAs = new double[fNL]; + // array for mu_r values + if(fMr) delete fMr; + fMr = new double[fNL]; } void Grid::FillPt(double* ptall, double xm) @@ -261,16 +267,23 @@ namespace MNR TSpline3 spline("", spline_x, spline_y, nlorig); for(int l = 0; l < nltrg; l++) gridtrg->CS(c,l,y,w) = spline.Eval(ltrg[l]); } - // interpolate as - double spline_y_as[nlorig]; + // interpolate as and mu_r + double spline_y_as[nlorig], spline_y_mr[nlorig]; for(int l = 0; l < nlorig; l++) + { spline_y_as[nlorig-1-l] = gridorig->AlphaS(l); + spline_y_mr[nlorig-1-l] = gridorig->MuR(l); + } TSpline3 spline_as("", spline_x, spline_y_as, nlorig); + TSpline3 spline_mr("", spline_x, spline_y_mr, nlorig); for(int l = 0; l < nltrg; l++) + { gridtrg->AlphaS(l) = spline_as.Eval(ltrg[l]); + gridtrg->MuR(l) = spline_mr.Eval(ltrg[l]); + } } - void Grid::InterpolateGrid(Grid *gridorig, Grid *gridtrg, double mq, Grid *gridorig_LO_massUp, double mq_masUp, Grid *gridorig_LO_massDown, double mq_masDown) + void Grid::InterpolateGrid(Grid *gridorig, Grid *gridtrg, double mq, Grid *gridorig_LO_massUp, double mq_masUp, Grid *gridorig_LO_massDown, double mq_masDown, int flag) { double mqDiff = mq_masUp - mq_masDown; // Get pT array of target grid @@ -288,7 +301,7 @@ namespace MNR double* lorig = gridorig->LPtr(); double* lorig_LO_massUp = gridorig_LO_massUp->LPtr(); double* lorig_LO_massDown = gridorig_LO_massDown->LPtr(); - double spline_x[3][nlorig], spline_y[4][nlorig]; + double spline_x[3][nlorig], spline_y[5][nlorig]; for(int i = 0; i < nlorig; i++) { //spline_x[0][nlorig-1-i] = mq2 / lorig[i] - mq2; @@ -316,6 +329,7 @@ namespace MNR spline_y[1][l] = gridorig_LO_massUp->CS(c,l,y,w); spline_y[2][l] = gridorig_LO_massDown->CS(c,l,y,w); spline_y[3][l] = gridorig->AlphaS(l); + spline_y[4][l] = gridorig->MuR(l); } // Spline interpolation TSpline3 spline("", spline_x[0], spline_y[0], nlorig); @@ -324,6 +338,7 @@ namespace MNR //TSpline3 spline_LO_massUp("", spline_x[0], spline_y[1], nlorig); //TSpline3 spline_LO_massDown("", spline_x[0], spline_y[2], nlorig); TSpline3 spline_as("", spline_x[0], spline_y[3], nlorig); + TSpline3 spline_mr("", spline_x[0], spline_y[4], nlorig); for(int l = 0; l < nltrg; l++) { //double pt2 = mq2 / ltrg[l] - mq2; @@ -337,7 +352,12 @@ namespace MNR double xsecOld_LO_massDown = spline_LO_massDown.Eval(pt2); double as = spline_as.Eval(pt2); //printf("as = %f\n", as); + //double d1 = 4.0 / 3.0; + double mr = spline_mr.Eval(pt2); double d1 = 4.0 / 3.0; + if(flag == 1) + d1 += 2.0 * TMath::Log(mr / mq); + // TODO: check different options for transformation double xsecNew = xsecOld + as / TMath::Pi() * d1 * mq * (xsecOld_LO_massUp - xsecOld_LO_massDown) / mqDiff; gridtrg->CS(c,l,y,w) = xsecNew; //gridtrg->CS(c,l,y,w) = xsecOld; diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index 1c1f8dcba..8903c94e0 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -243,7 +243,8 @@ int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, va mnr->fMf_B = mfB; mnr->fMr_B = mrB; - MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc, gridLOMassU.get(), massU, gridLOMassD.get(), massD); + int flagMSbarTransformation = 0; // d1=4/3 (no ln) + MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc, gridLOMassU.get(), massU, gridLOMassD.get(), massD, flagMSbarTransformation); //MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); } else -- GitLab From fb2a0b9cdad222f9232251053fa720278b6b4ded Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 25 Feb 2019 18:14:54 +0100 Subject: [PATCH 29/81] implemented s!=sbar, stored sbar in PDF files, and extra PDF plotting for sbar sbar/s dv+uv and dv+uv+2Sea (backward compatible) --- Makefile.am | 2 +- Reactions.txt | 1 + configure.ac | 1 + doxygen.cfg | 2 +- .../UvDvUbarDbarSSbarPdfDecomposition.h | 46 +++++++++ .../src/Makefile.am | 13 +++ .../src/UvDvUbarDbarSSbarPdfDecomposition.cc | 98 +++++++++++++++++++ .../yaml/parameters.yaml | 0 src/store_output.f | 14 +-- tools/draw/include/PdfData.h | 3 +- tools/draw/src/PdfData.cc | 55 ++++++++++- 11 files changed, 221 insertions(+), 14 deletions(-) create mode 100644 pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h create mode 100644 pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile.am create mode 100644 pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc create mode 100644 pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/yaml/parameters.yaml diff --git a/Makefile.am b/Makefile.am index f7cc0b761..2c68784ff 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,7 +28,7 @@ SUBDIRS = minuit/src interfaces/src DY/src DIPOLE/src RT/src EW/src common commo pdfparams/BasePdfParam/src \ pdfparams/HERAPDF_PdfParam/src \ pdfparams/PolySqrtPdfParam/src \ - pdfdecompositions/BasePdfDecomposition/src pdfparams/NegativeGluonPdfParam/src \ + pdfdecompositions/BasePdfDecomposition/src pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src pdfparams/NegativeGluonPdfParam/src \ pdfdecompositions/LHAPDFDecomposition/src \ pdfdecompositions/UvDvUbarDbarS/src \ pdfdecompositions/SU3_PionPdfDecomposition/src \ diff --git a/Reactions.txt b/Reactions.txt index 979e5742c..866ef6502 100644 --- a/Reactions.txt +++ b/Reactions.txt @@ -27,3 +27,4 @@ NegativeGluon libNegativeGluonPdfParam_xfitter.so PolySqrt libPolySqrtPdfParam_xfitter.so AFB libafb_xfitter.so KMatrix libkmatrix_xfitter.so +UvDvUbarDbarSSbar libuvdvubardbarssbarpdfdecomposition_xfitter.so diff --git a/configure.ac b/configure.ac index 62957adaa..58c454a6c 100644 --- a/configure.ac +++ b/configure.ac @@ -599,6 +599,7 @@ AC_CONFIG_FILES([include/Makefile examples/Makefile python/Makefile xfitter-config + pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile pdfparams/NegativeGluonPdfParam/src/Makefile evolutions/LHAPDF/src/Makefile minimizers/CERESMinimizer/src/Makefile diff --git a/doxygen.cfg b/doxygen.cfg index 6fdb1376a..18a2206fb 100644 --- a/doxygen.cfg +++ b/doxygen.cfg @@ -585,7 +585,7 @@ INPUT = include src \ pdfparams/BasePdfParam/include pdfparams/NegativeGluonPdf/include \ pdfparams/HERAPDF_PdfParam/include \ pdfparams/PolySqrtPdfParam/include \ - pdfdecompositions/BasePdfDecomposition/include \ + pdfdecompositions/BasePdfDecomposition/include pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include \ pdfdecompositions/LHAPDFDecomposition/include \ pdfdecompositions/UvDvUbarDbarS/include \ pdfdecompositions/GRV_PionPdfDecomposition/include \ diff --git a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h new file mode 100644 index 000000000..9399aebdb --- /dev/null +++ b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h @@ -0,0 +1,46 @@ + +#pragma once + +#include "BasePdfDecomposition.h" + +/** + @class UvDvUbarDbarSSbarPdfDecomposition + + @brief A class for UvDvUbarDbarSSbar pdf decomposition + + @version 0.1 + @date 2019-02-25 + */ + +namespace xfitter { + +class UvDvUbarDbarSSbarPdfDecomposition : public BasePdfDecomposition +{ + public: + /// Default constructor. + UvDvUbarDbarSSbarPdfDecomposition (); + + /// Default constructor. Name is the PDF name + UvDvUbarDbarSSbarPdfDecomposition (const char *inName); + + virtual const char*getClassName()const override final; + + /// Optional initialization at the first call + virtual void atStart() override final; + + /// Compute sum-rules + virtual void atIteration() override final; + + /// Compute PDF in a physical base in LHAPDF format for given x and Q + virtual std::function<std::map<int,double>(const double& x)> f0() const override final; + +private: + BasePdfParam*par_xuv{nullptr}, + *par_xdv{nullptr}, + *par_xubar{nullptr}, + *par_xdbar{nullptr}, + *par_xs{nullptr}, + *par_xsbar{nullptr}, + *par_xg{nullptr}; +}; +} diff --git a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile.am b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile.am new file mode 100644 index 000000000..0091a38cc --- /dev/null +++ b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile.am @@ -0,0 +1,13 @@ + +# Created by AddPdfDecomposition.py on 2019-02-25 + +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../pdfparams/BasePdfParam/include/ -I$(srcdir)/../../BasePdfDecomposition/include -Wall -fPIC -Wno-deprecated + +#lib_LTLIBRARIES = libUvDvUbarDbarSSbarPdfDecomposition_xfitter.la +lib_LTLIBRARIES = libuvdvubardbarssbarpdfdecomposition_xfitter.la +libuvdvubardbarssbarpdfdecomposition_xfitter_la_SOURCES = UvDvUbarDbarSSbarPdfDecomposition.cc + +datadir = ${prefix}/yaml/pdfdecompositions/UvDvUbarDbarSSbar +data_DATA = ../yaml/parameters.yaml + +dist_noinst_HEADERS = ../include ../yaml diff --git a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc new file mode 100644 index 000000000..0b255ffeb --- /dev/null +++ b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc @@ -0,0 +1,98 @@ + +/* + @file UvDvUbarDbarSSbarPdfDecomposition.cc + @date 2019-02-25 + @author AddPdfDecomposition.py + Created by AddPdfDecomposition.py on 2019-02-25 +*/ + +#include "UvDvUbarDbarSSbarPdfDecomposition.h" +#include "xfitter_pars.h" +#include "xfitter_steer.h" +#include <iostream> +#include <iomanip> +#include <cmath> + +namespace xfitter { + +/// the class factories, for dynamic loading +extern "C" UvDvUbarDbarSSbarPdfDecomposition* create(const char*name) { + return new UvDvUbarDbarSSbarPdfDecomposition(name); +} + + +// Constructor + UvDvUbarDbarSSbarPdfDecomposition::UvDvUbarDbarSSbarPdfDecomposition() : BasePdfDecomposition("UvDvUbarDbarSSbar") { +} + +// Constructor +UvDvUbarDbarSSbarPdfDecomposition::UvDvUbarDbarSSbarPdfDecomposition(const char* inName) : BasePdfDecomposition(inName) { +} + +const char*UvDvUbarDbarSSbarPdfDecomposition::getClassName()const{return"UvDvUbarDbarS";} + +// Init at start: +void UvDvUbarDbarSSbarPdfDecomposition::atStart() { + const YAML::Node node=XFITTER_PARS::getDecompositionNode(_name); + //TODO: handle errors + par_xuv =getParameterisation(node["xuv"].as<string>()); + par_xdv =getParameterisation(node["xdv"].as<string>()); + par_xubar=getParameterisation(node["xubar"].as<string>()); + par_xdbar=getParameterisation(node["xdbar"].as<string>()); + par_xs =getParameterisation(node["xs"].as<string>()); + par_xsbar =getParameterisation(node["xsbar"].as<string>()); + par_xg =getParameterisation(node["xg"].as<string>()); +} + +void UvDvUbarDbarSSbarPdfDecomposition::atIteration() { + //Enforce sum rules + // counting sum-rules for uv and dv + par_xuv->setMoment(-1,2.0); + par_xdv->setMoment(-1,1.0); + // momentum sum-rule + // quark part + double xsumq=0; + xsumq+= par_xuv ->moment(0); + xsumq+= par_xdv ->moment(0); + xsumq+=2*par_xubar->moment(0); + xsumq+=2*par_xdbar->moment(0); + xsumq+=par_xs ->moment(0); + xsumq+=par_xsbar ->moment(0); + // gluon part + par_xg->setMoment(0,1-xsumq); + + printParams(); +} + +// Returns a LHAPDF-style function, that returns PDFs in a physical basis for given x +std::function<std::map<int,double>(const double& x)> UvDvUbarDbarSSbarPdfDecomposition::f0() const +{ + // lambda function + return [=] (double const& x)->std::map<int, double> { + double ubar=(*par_xubar)(x); + double dbar=(*par_xdbar)(x); + double u=(*par_xuv)(x)+ubar; + double d=(*par_xdv)(x)+dbar; + double s=(*par_xs)(x); + double sbar=(*par_xsbar)(x); + double g=(*par_xg)(x); + std::map<int, double> res = { + {-6,0}, + {-5,0}, + {-4,0}, + {-3,sbar}, + {-2,ubar}, + {-1,dbar}, + { 1,d}, + { 2,u}, + { 3,s}, + { 4,0}, + { 5,0}, + { 6,0}, + {21,g} + }; + return res; + }; +} + +} diff --git a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/yaml/parameters.yaml b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/yaml/parameters.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/src/store_output.f b/src/store_output.f index c4035277d..b8aca23af 100644 --- a/src/store_output.f +++ b/src/store_output.f @@ -16,7 +16,7 @@ C-------------------------------------------------------------- double precision q2,x,gval,sing,umin,dmin *new jf double precision QPDFXQ,cplus,splus,bplus,uplus,dplus,U,D,sea,DbmUb - double precision d_Ubar,d_Dbar,u_sea,d_sea,str,chm,bot, photon + double precision d_Ubar,d_Dbar,u_sea,d_sea,str,strbar,chm,bot,photon double precision totstr,totDbar,totcha,totUbar,afs,afc,xbelow,delx double precision totusea,totdsea,afs_ud @@ -66,7 +66,7 @@ C-------------------------------------------------------------- ! Store how many PDFs are written out: integer NPdfs - parameter (NPdfs = 14) + parameter (NPdfs = 15) C--------------------------------------------------------------- @@ -93,10 +93,11 @@ c open(82,file=h1name) write (81,*) q2val(iq2),outnx, NPdfs, outxrange(1), outxrange(2) ! Write the names of PDFs - write (81,'(15(2x,A12))') + write (81,'(16(2x,A12))') $ ' x ',' g ',' U ',' D ',' Ubar ', ' Dbar ', $ ' u_val ', ' d_val ', ' sea ' ,' u_sea ', - $ ' d_sea ', ' str ',' chm ',' bot ', ' ph ' + $ ' d_sea ', ' str ',' chm ',' bot ', ' ph ', + $ 'strbar' totstr= 0.d0 totDbar= 0.d0 @@ -158,6 +159,7 @@ c open(82,file=h1name) u_sea=pdf(-2) d_sea=pdf(-1) str = (pdf(-3)+pdf(3))/2.d0 + strbar = pdf(-3) chm = 0.0d0 @@ -182,8 +184,8 @@ c open(82,file=h1name) write(81,810) + x,gval,U,D,d_Ubar,d_Dbar,umin,dmin,sea,u_sea,d_sea,str, - $ chm,bot,photon - 810 format(15(2x,G12.6)) + $ chm,bot,photon,strbar + 810 format(16(2x,G12.6)) 811 format(I3,2x,23(2x,G12.6)) diff --git a/tools/draw/include/PdfData.h b/tools/draw/include/PdfData.h index 5df80031e..468f3e01b 100644 --- a/tools/draw/include/PdfData.h +++ b/tools/draw/include/PdfData.h @@ -10,7 +10,8 @@ using namespace std; enum pdferr {None, AsymHess, SymHess, MC}; -enum pdftype{uv=0, dv, g, Sea, ubar, dbar, s, Rs, c, b, dbarminubar, uvmindv, U, D, Ubar, Dbar, goversea, doveru, dbaroverubar, dvoveruv, rs, photon, SeaOverGlue, photonOverGlue}; +//enum pdftype{uv=0, dv, g, Sea, ubar, dbar, s, Rs, c, b, dbarminubar, uvmindv, U, D, Ubar, Dbar, goversea, doveru, dbaroverubar, dvoveruv, rs, photon, SeaOverGlue, photonOverGlue}; +enum pdftype{uv=0, dv, g, Sea, ubar, dbar, s, sbar, Rs, soversbar, c, b, dbarminubar, uvmindv, U, D, Ubar, Dbar, goversea, doveru, dbaroverubar, dvoveruv, rs, photon, SeaOverGlue, photonOverGlue, uvplusdv, uvplusdvplusSea}; extern vector <pdftype> pdfs; extern vector <string> pdflabels; diff --git a/tools/draw/src/PdfData.cc b/tools/draw/src/PdfData.cc index 034a3ebe5..4749ef239 100644 --- a/tools/draw/src/PdfData.cc +++ b/tools/draw/src/PdfData.cc @@ -20,12 +20,17 @@ #include "FileOpener.h" //pdf type -pdftype pdfts[] = {uv, dv, g, Sea, ubar, dbar, s, Rs, c, b, dbarminubar, uvmindv, U, D, Ubar, Dbar, goversea, doveru, dbaroverubar, dvoveruv,rs,photon,SeaOverGlue, photonOverGlue }; +//pdftype pdfts[] = {uv, dv, g, Sea, ubar, dbar, s, Rs, c, b, dbarminubar, uvmindv, U, D, Ubar, Dbar, goversea, doveru, dbaroverubar, dvoveruv,rs,photon,SeaOverGlue, photonOverGlue }; +pdftype pdfts[] = {uv, dv, g, Sea, ubar, dbar, s, sbar, Rs, soversbar, c, b, dbarminubar, uvmindv, U, D, Ubar, Dbar, goversea, doveru, dbaroverubar, dvoveruv,rs,photon,SeaOverGlue, photonOverGlue, uvplusdv, uvplusdvplusSea }; //pdf labels -string pdflab[] = {"u_{V}", "d_{V}", "g", "#Sigma", "#bar{u}", "#bar{d}", "s", "(s+#bar{s})/(#bar{u}+#bar{d})", "c", "b", "#bar{d}-#bar{u}", "d_{V}-u_{V}", "U", "D", "#bar{U}", "#bar{D}", "g/#Sigma", - "d/u", "#bar{d}/#bar{u}", "d_{V}/u_{V}","rs","#gamma","#Sigma/g","#gamma/g"}; +//string pdflab[] = {"u_{V}", "d_{V}", "g", "#Sigma", "#bar{u}", "#bar{d}", "s", "(s+#bar{s})/(#bar{u}+#bar{d})", "c", "b", "#bar{d}-#bar{u}", "d_{V}-u_{V}", "U", "D", "#bar{U}", "#bar{D}", "g/#Sigma", +// "d/u", "#bar{d}/#bar{u}", "d_{V}/u_{V}","rs","#gamma","#Sigma/g","#gamma/g"}; +string pdflab[] = {"u_{V}", "d_{V}", "g", "#Sigma", "#bar{u}", "#bar{d}", "(s+#bar{s})/2", "#bar{s}", "(s+#bar{s})/(#bar{u}+#bar{d})", "s/#bar{s}", "c", "b", "#bar{d}-#bar{u}", "d_{V}-u_{V}", "U", "D", "#bar{U}", "#bar{D}", "g/#Sigma", + "d/u", "#bar{d}/#bar{u}", "d_{V}/u_{V}","rs","#gamma","#Sigma/g","#gamma/g","u_{V}+d_{V}", "u_{V}+d_{V}+2#Sigma"}; //pdf filenames -string pdffil[] = {"uv", "dv", "g", "Sea", "ubar", "dbar", "s", "Rs", "c", "b", "dbar-ubar", "uv-dv", "U", "D", "UBar", "DBar", "goversea", "doveru", "dbaroverubar", "dvoveruv","rs","ph","sg","gg" +//string pdffil[] = {"uv", "dv", "g", "Sea", "ubar", "dbar", "s", "Rs", "c", "b", "dbar-ubar", "uv-dv", "U", "D", "UBar", "DBar", "goversea", "doveru", "dbaroverubar", "dvoveruv","rs","ph","sg","gg" +// }; +string pdffil[] = {"uv", "dv", "g", "Sea", "ubar", "dbar", "s", "sbar", "Rs", "soversbar", "c", "b", "dbar-ubar", "uv-dv", "U", "D", "UBar", "DBar", "goversea", "doveru", "dbaroverubar", "dvoveruv","rs","ph","sg","gg","uv+dv","uv+dv+2Sea" }; vector <pdftype> pdfs(pdfts, pdfts + sizeof(pdfts) / sizeof(pdftype)); @@ -60,6 +65,7 @@ Pdf::Pdf(string filename) : Q2value(0), NxValues(0), NPdfs(0), Xmin(0), Xmax(0) else if (var == "u_sea") ipdf = ubar; else if (var == "d_sea") ipdf = dbar; else if (var == "str") ipdf = s; + else if (var == "strbar") ipdf = sbar; else if (var == "chm") ipdf = c; else if (var == "bot") ipdf = b; else if (var == "ph") ipdf = photon; @@ -70,7 +76,7 @@ Pdf::Pdf(string filename) : Q2value(0), NxValues(0), NPdfs(0), Xmin(0), Xmax(0) } PdfTypes.push_back(ipdf); } - + // Read the table double val; for (int ix = 0; ix < NxValues; ix++) @@ -85,11 +91,29 @@ Pdf::Pdf(string filename) : Q2value(0), NxValues(0), NPdfs(0), Xmin(0), Xmax(0) } } + // for backward compatibility: if no strbar, set strbar=-999 + if(std::find(PdfTypes.begin(), PdfTypes.end(), sbar) == PdfTypes.end()) + { + PdfTypes.push_back(sbar); + for (int ix = 0; ix < NxValues; ix++) + { + tablemap[sbar].push_back(-999); + } + } + + //custom pdf types PdfTypes.push_back(dbarminubar); NPdfs++; for (int ix = 0; ix < NxValues; ix++) tablemap[dbarminubar].push_back(tablemap[dbar][ix] - tablemap[ubar][ix]); + PdfTypes.push_back(soversbar); NPdfs++; + for (int ix = 0; ix < NxValues; ix++) + if (tablemap[sbar][ix] != -999) + tablemap[soversbar].push_back(2*tablemap[s][ix]/tablemap[sbar][ix]-1); + else + tablemap[soversbar].push_back(-999); + PdfTypes.push_back(Rs); NPdfs++; for (int ix = 0; ix < NxValues; ix++) if (tablemap[dbar][ix] != 0) @@ -154,6 +178,27 @@ Pdf::Pdf(string filename) : Q2value(0), NxValues(0), NPdfs(0), Xmin(0), Xmax(0) else tablemap[photonOverGlue].push_back(0); + PdfTypes.push_back(uvplusdv); NPdfs++; + for (int ix = 0; ix < NxValues; ix++) + if (tablemap[g][ix] != 0) + tablemap[uvplusdv].push_back(tablemap[dv][ix]+tablemap[uv][ix]); + else + tablemap[uvplusdv].push_back(0); + + PdfTypes.push_back(uvplusdvplusSea); NPdfs++; + for (int ix = 0; ix < NxValues; ix++) + if (tablemap[g][ix] != 0) + tablemap[uvplusdvplusSea].push_back(tablemap[dv][ix]+tablemap[uv][ix]+2.0*tablemap[Sea][ix]); + else + tablemap[uvplusdvplusSea].push_back(0); + + /*PdfTypes.push_back(uvplusdvminSea); NPdfs++; + for (int ix = 0; ix < NxValues; ix++) + if (tablemap[g][ix] != 0) + tablemap[uvplusdvminSea].push_back(tablemap[dv][ix]+tablemap[uv][ix]-2.0*tablemap[Sea][ix]); + else + tablemap[uvplusdvminSea].push_back(0);*/ + } -- GitLab From 2d8ef7c11953198d734eb345d70cb40d70542ed3 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 25 Feb 2019 19:26:10 +0100 Subject: [PATCH 30/81] implemented ABMP parametrisation --- Makefile.am | 2 +- Reactions.txt | 1 + configure.ac | 1 + doxygen.cfg | 2 +- input_steering/parameters.yaml.abmp16 | 196 ++++++++++++++++++ parameters.yaml | 105 ++++++++-- pdfparams/ABMPPdfParam/include/ABMPPdfParam.h | 29 +++ pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc | 25 +++ pdfparams/ABMPPdfParam/src/Makefile.am | 13 ++ 9 files changed, 352 insertions(+), 22 deletions(-) create mode 100644 input_steering/parameters.yaml.abmp16 create mode 100644 pdfparams/ABMPPdfParam/include/ABMPPdfParam.h create mode 100644 pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc create mode 100644 pdfparams/ABMPPdfParam/src/Makefile.am diff --git a/Makefile.am b/Makefile.am index 2c68784ff..53fe5c0f7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,7 +28,7 @@ SUBDIRS = minuit/src interfaces/src DY/src DIPOLE/src RT/src EW/src common commo pdfparams/BasePdfParam/src \ pdfparams/HERAPDF_PdfParam/src \ pdfparams/PolySqrtPdfParam/src \ - pdfdecompositions/BasePdfDecomposition/src pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src pdfparams/NegativeGluonPdfParam/src \ + pdfdecompositions/BasePdfDecomposition/src pdfparams/ABMPPdfParam/src pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src pdfparams/NegativeGluonPdfParam/src \ pdfdecompositions/LHAPDFDecomposition/src \ pdfdecompositions/UvDvUbarDbarS/src \ pdfdecompositions/SU3_PionPdfDecomposition/src \ diff --git a/Reactions.txt b/Reactions.txt index 866ef6502..ec3a20d72 100644 --- a/Reactions.txt +++ b/Reactions.txt @@ -28,3 +28,4 @@ PolySqrt libPolySqrtPdfParam_xfitter.so AFB libafb_xfitter.so KMatrix libkmatrix_xfitter.so UvDvUbarDbarSSbar libuvdvubardbarssbarpdfdecomposition_xfitter.so +ABMPPdfParam libABMPPdfParam_xfitter.so diff --git a/configure.ac b/configure.ac index 58c454a6c..f0bf74a7c 100644 --- a/configure.ac +++ b/configure.ac @@ -599,6 +599,7 @@ AC_CONFIG_FILES([include/Makefile examples/Makefile python/Makefile xfitter-config + pdfparams/ABMPPdfParam/src/Makefile pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile pdfparams/NegativeGluonPdfParam/src/Makefile evolutions/LHAPDF/src/Makefile diff --git a/doxygen.cfg b/doxygen.cfg index 18a2206fb..86959e022 100644 --- a/doxygen.cfg +++ b/doxygen.cfg @@ -582,7 +582,7 @@ INPUT = include src \ reactions/BaseHVQMNR/src reactions/HVQMNR_LHCb_7TeV_beauty/include \ reactions/HVQMNR_LHCb_7TeV_beauty/src \ - pdfparams/BasePdfParam/include pdfparams/NegativeGluonPdf/include \ + pdfparams/BasePdfParam/include pdfparams/ABMPPdfParam/include pdfparams/NegativeGluonPdf/include \ pdfparams/HERAPDF_PdfParam/include \ pdfparams/PolySqrtPdfParam/include \ pdfdecompositions/BasePdfDecomposition/include pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include \ diff --git a/input_steering/parameters.yaml.abmp16 b/input_steering/parameters.yaml.abmp16 new file mode 100644 index 000000000..123b20387 --- /dev/null +++ b/input_steering/parameters.yaml.abmp16 @@ -0,0 +1,196 @@ +Minimizer: MINUIT # CERES +MINUIT: + Commands: | + call fcn 3 +# doErrors : Hesse # None + +Parameters: + Ag : DEPENDENT + Bg : [ -0.061953] + Cg : [ 5.562367 , 0.55] + Agp : [ 0.07311 ] # negative gluon .... + Bgp : [ -0.383100 ] + Cgp : [ 25.0, 0.] # fix C of negative gluon + Auv : DEPENDENT + Buv : [ 0.810476 ] + Cuv : [ 4.823512 ] + Duv : [ 0 ] + Euv : [ 9.921366 ] + Adv : DEPENDENT + Bdv : [ 1.029995 ] + Cdv : [ 4.846279 ] + Aubar: [ 0.1613 ] + Bubar: [ -0.1273 ] + Cubar: [ 7.059694] + Dubar: [ 1.548098] + Adbar: [ 0.1613 ] + Bdbar: [ -0.1273 ] + Cdbar: + value: 9.586246 + step: 1.2345 + #min + #max + #pr_mean + #pr_sigma + As : [ 0.1075 ] + Bs : [ -0.1273 ] + Cs : [ 9.586246 ] + Asbar : [ 0.1075 ] + Bsbar : [ -0.1473 ] + Csbar : [ 8.586246 ] + ZERO : [ 0. ] # zero + + ABMP_uv_A : DEPENDENT + ABMP_uv_a : [ 0.623, 0.033 ] + ABMP_uv_b : [ 3.443, 0.064 ] + ABMP_uv_g1 : [ -0.22, 0.33 ] + ABMP_uv_g2 : [ -2.88, 0.46 ] + ABMP_uv_g3 : [ 2.67, 0.80 ] + + ABMP_dv_A : DEPENDENT + ABMP_dv_a : [ 0.372, 0.068 ] + ABMP_dv_b : [ 4.47, 0.55 ] + ABMP_dv_g1 : [ -3.20, 0.77 ] + ABMP_dv_g2 : [ -0.61, 1.96 ] + ABMP_dv_g3 : [ 0.0, 0.001 ] + + ABMP_us_A : [ 0.0703, 0.0081] + ABMP_us_a : [ -0.415, 0.031 ] + ABMP_us_b : [ 7.75, 0.39 ] + ABMP_us_gm1 : [ 0.0373, 0.0032] + ABMP_us_g1 : [ 4.44, 0.95 ] + + ABMP_ds_A : [ 0.1408, 0.0076] + ABMP_ds_a : [ -0.17, 0.011 ] + ABMP_ds_b : [ 8.41, 0.34 ] + ABMP_ds_g1 : [ 13.3, 1.7 ] + + ABMP_ss_A : [ 0.0594, 0.0042] + ABMP_ss_a : [ -0.344, 0.019 ] + ABMP_ss_b : [ 6.52, 0.27 ] + + #ABMP_ssbar_A: [ 0.0594, 0.0042] + #ABMP_ssbar_a: [ -0.344, 0.019 ] + #ABMP_ss_bbar: [ 6.52, 0.27 ] + + ABMP_g_A : DEPENDENT + ABMP_g_a : [-0.1534, 0.0094] + ABMP_g_b : [ 6.42, 0.83 ] + ABMP_g_g1 : [ -11.8, 3.7 ] + +Parameterisations: + par_uv: + #class: HERAPDF + #parameters: [Auv,Buv,Cuv,Duv,Euv] + class: ABMPPdfParam + parameters: [ABMP_uv_A,ABMP_uv_a,ABMP_uv_b,ZERO,ABMP_uv_g1,ABMP_uv_g2,ABMP_uv_g3] + par_dv: + #class: HERAPDF + #parameters: [Adv,Bdv,Cdv] + class: ABMPPdfParam + parameters: [ABMP_dv_A,ABMP_dv_a,ABMP_dv_b,ZERO,ABMP_dv_g1,ABMP_dv_g2,ABMP_dv_g3] + par_ubar: + #class: HERAPDF + #parameters: [Aubar,Bubar,Cubar,Dubar] + class: ABMPPdfParam + parameters: [ABMP_us_A,ABMP_us_a,ABMP_us_b,ABMP_us_gm1,ABMP_us_g1,ZERO,ZERO] + par_dbar: + #class: HERAPDF + #parameters: [Adbar,Bdbar,Cdbar] + class: ABMPPdfParam + parameters: [ABMP_ds_A,ABMP_ds_a,ABMP_ds_b,ZERO,ABMP_ds_g1,ZERO,ZERO] + par_s: + #class: HERAPDF + #parameters: [As,Bs,Cs] + class: ABMPPdfParam + parameters: [ABMP_ss_A,ABMP_ss_a,ABMP_ss_b,ZERO,ZERO,ZERO,ZERO] + par_sbar: + #class: HERAPDF + #parameters: [Asbar,Bsbar,Csbar] + class: ABMPPdfParam + parameters: [ABMP_ss_A,ABMP_ss_a,ABMP_ss_b,ZERO,ZERO,ZERO,ZERO] + #class: ABMPPdfParam + #parameters: [ABMP_ssbar_A,ABMP_ssbar_a,ABMP_ssbar_b,ZERO,ZERO,ZERO,ZERO] + par_g: + #class: NegativeGluon + #parameters: [Ag,Bg,Cg,ZERO,ZERO,Agp,Bgp,Cgp] + class: ABMPPdfParam + parameters: [ABMP_g_A,ABMP_g_a,ABMP_g_b,ZERO,ABMP_g_g1,ZERO,ZERO] + +DefaultDecomposition: proton +Decompositions: + proton: + class: UvDvUbarDbarSSbar + xuv: par_uv + xdv: par_dv + xubar: par_ubar + xdbar: par_dbar + xs: par_s + xsbar: par_sbar + xg: par_g + +#DefaultEvolution: proton-QCDNUM +DefaultEvolution: proton-LHAPDF +Evolutions: + proton-QCDNUM: + ? !include yaml/evolutions/QCDNUM/parameters.yaml + decomposition: proton #this could be omitted, as the default decomposition is set + proton-LHAPDF: + class: LHAPDF + set: "CT10" + member: 0 +# proton-APFEL: +# ? !include yaml/evolutions/APFELxx/parameters.yaml +# decomposition: proton + +#Q0 : 1.378404875209 # Initial scale =sqrt(1.9) +Q0 : 3.0 # ABMP16 + +? !include constants.yaml + +# just for test of ABMP16 parametrisation (in QCDNUM charm quark mass should be above starting scale) +mch : 3.1 + +# AlphaS, incuding options to fit it: +alphas : 0.118 +# value: 0.118 +# step: 0.01 +# prior: 0.118 +# priorUnc: 0.1 +# min: 0.1 +# max: 0.3 + +# Strange and charm fractions: +fs: 0.4 +fcharm: 0. + +# RT DIS scheme settings: +? !include yaml/reactions/RT_DISNC/parameters.yaml +# FONLL scheme settings: +? !include yaml/reactions/FONLL_DISNC/parameters.yaml +? !include yaml/reactions/FONLL_DISCC/parameters.yaml +# FF ABM scheme settings: +? !include yaml/reactions/FFABM_DISNC/parameters.yaml +? !include yaml/reactions/FFABM_DISCC/parameters.yaml +# AFB settings: +? !include yaml/reactions/AFB/parameters.yaml +# APPLgrid settings: +? !include yaml/reactions/APPLgrid/parameters.yaml +# (optional) Fractal module settings: +# ? !include yaml/reactions/Fractal_DISNC/parameters.yaml + +# Specify HF scheme used for DIS NC processes: +hf_scheme_DISNC : + defaultValue : 'RT_DISNC' # global specification +# defaultValue : 'BaseDISNC' # global specification +# defaultValue : 'FONLL_DISNC' # global specification +# defaultValue : 'FFABM_DISNC' +# 'HERA1+2 NCep 920' : 'BaseDISNC' # datafile specific (based on name) +# 1 : BaseDISNC +# 'HERA1+2 NCep 920' : 'Fractal_DISNC' # Fractal model. Add parameters file if you want to try it (see above) + +# Specify HF scheme used for DIS CC processes: +hf_scheme_DISCC : + defaultValue : 'BaseDISCC' # global specification +# defaultValue : 'FONLL_DISCC' # global specification +# defaultValue : 'FFABM_DISCC' # global specification diff --git a/parameters.yaml b/parameters.yaml index 73d782161..123b20387 100644 --- a/parameters.yaml +++ b/parameters.yaml @@ -1,7 +1,6 @@ Minimizer: MINUIT # CERES MINUIT: Commands: | - fix 6 7 9 11 12 13 14 15 16 17 18 19 20 22 call fcn 3 # doErrors : Hesse # None @@ -36,40 +35,102 @@ Parameters: As : [ 0.1075 ] Bs : [ -0.1273 ] Cs : [ 9.586246 ] + Asbar : [ 0.1075 ] + Bsbar : [ -0.1473 ] + Csbar : [ 8.586246 ] ZERO : [ 0. ] # zero + + ABMP_uv_A : DEPENDENT + ABMP_uv_a : [ 0.623, 0.033 ] + ABMP_uv_b : [ 3.443, 0.064 ] + ABMP_uv_g1 : [ -0.22, 0.33 ] + ABMP_uv_g2 : [ -2.88, 0.46 ] + ABMP_uv_g3 : [ 2.67, 0.80 ] + + ABMP_dv_A : DEPENDENT + ABMP_dv_a : [ 0.372, 0.068 ] + ABMP_dv_b : [ 4.47, 0.55 ] + ABMP_dv_g1 : [ -3.20, 0.77 ] + ABMP_dv_g2 : [ -0.61, 1.96 ] + ABMP_dv_g3 : [ 0.0, 0.001 ] + + ABMP_us_A : [ 0.0703, 0.0081] + ABMP_us_a : [ -0.415, 0.031 ] + ABMP_us_b : [ 7.75, 0.39 ] + ABMP_us_gm1 : [ 0.0373, 0.0032] + ABMP_us_g1 : [ 4.44, 0.95 ] + + ABMP_ds_A : [ 0.1408, 0.0076] + ABMP_ds_a : [ -0.17, 0.011 ] + ABMP_ds_b : [ 8.41, 0.34 ] + ABMP_ds_g1 : [ 13.3, 1.7 ] + + ABMP_ss_A : [ 0.0594, 0.0042] + ABMP_ss_a : [ -0.344, 0.019 ] + ABMP_ss_b : [ 6.52, 0.27 ] + + #ABMP_ssbar_A: [ 0.0594, 0.0042] + #ABMP_ssbar_a: [ -0.344, 0.019 ] + #ABMP_ss_bbar: [ 6.52, 0.27 ] + + ABMP_g_A : DEPENDENT + ABMP_g_a : [-0.1534, 0.0094] + ABMP_g_b : [ 6.42, 0.83 ] + ABMP_g_g1 : [ -11.8, 3.7 ] Parameterisations: par_uv: - class: HERAPDF - parameters: [Auv,Buv,Cuv,Duv,Euv] + #class: HERAPDF + #parameters: [Auv,Buv,Cuv,Duv,Euv] + class: ABMPPdfParam + parameters: [ABMP_uv_A,ABMP_uv_a,ABMP_uv_b,ZERO,ABMP_uv_g1,ABMP_uv_g2,ABMP_uv_g3] par_dv: - class: HERAPDF - parameters: [Adv,Bdv,Cdv] + #class: HERAPDF + #parameters: [Adv,Bdv,Cdv] + class: ABMPPdfParam + parameters: [ABMP_dv_A,ABMP_dv_a,ABMP_dv_b,ZERO,ABMP_dv_g1,ABMP_dv_g2,ABMP_dv_g3] par_ubar: - class: HERAPDF - parameters: [Aubar,Bubar,Cubar,Dubar] + #class: HERAPDF + #parameters: [Aubar,Bubar,Cubar,Dubar] + class: ABMPPdfParam + parameters: [ABMP_us_A,ABMP_us_a,ABMP_us_b,ABMP_us_gm1,ABMP_us_g1,ZERO,ZERO] par_dbar: - class: HERAPDF - parameters: [Adbar,Bdbar,Cdbar] + #class: HERAPDF + #parameters: [Adbar,Bdbar,Cdbar] + class: ABMPPdfParam + parameters: [ABMP_ds_A,ABMP_ds_a,ABMP_ds_b,ZERO,ABMP_ds_g1,ZERO,ZERO] par_s: - class: HERAPDF - parameters: [As,Bs,Cs] + #class: HERAPDF + #parameters: [As,Bs,Cs] + class: ABMPPdfParam + parameters: [ABMP_ss_A,ABMP_ss_a,ABMP_ss_b,ZERO,ZERO,ZERO,ZERO] + par_sbar: + #class: HERAPDF + #parameters: [Asbar,Bsbar,Csbar] + class: ABMPPdfParam + parameters: [ABMP_ss_A,ABMP_ss_a,ABMP_ss_b,ZERO,ZERO,ZERO,ZERO] + #class: ABMPPdfParam + #parameters: [ABMP_ssbar_A,ABMP_ssbar_a,ABMP_ssbar_b,ZERO,ZERO,ZERO,ZERO] par_g: - class: NegativeGluon - parameters: [Ag,Bg,Cg,ZERO,ZERO,Agp,Bgp,Cgp] + #class: NegativeGluon + #parameters: [Ag,Bg,Cg,ZERO,ZERO,Agp,Bgp,Cgp] + class: ABMPPdfParam + parameters: [ABMP_g_A,ABMP_g_a,ABMP_g_b,ZERO,ABMP_g_g1,ZERO,ZERO] DefaultDecomposition: proton Decompositions: proton: - class: UvDvubardbars - xuv: par_uv - xdv: par_dv + class: UvDvUbarDbarSSbar + xuv: par_uv + xdv: par_dv xubar: par_ubar xdbar: par_dbar - xs: par_s - xg: par_g + xs: par_s + xsbar: par_sbar + xg: par_g -DefaultEvolution: proton-QCDNUM +#DefaultEvolution: proton-QCDNUM +DefaultEvolution: proton-LHAPDF Evolutions: proton-QCDNUM: ? !include yaml/evolutions/QCDNUM/parameters.yaml @@ -82,10 +143,14 @@ Evolutions: # ? !include yaml/evolutions/APFELxx/parameters.yaml # decomposition: proton -Q0 : 1.378404875209 # Initial scale =sqrt(1.9) +#Q0 : 1.378404875209 # Initial scale =sqrt(1.9) +Q0 : 3.0 # ABMP16 ? !include constants.yaml +# just for test of ABMP16 parametrisation (in QCDNUM charm quark mass should be above starting scale) +mch : 3.1 + # AlphaS, incuding options to fit it: alphas : 0.118 # value: 0.118 diff --git a/pdfparams/ABMPPdfParam/include/ABMPPdfParam.h b/pdfparams/ABMPPdfParam/include/ABMPPdfParam.h new file mode 100644 index 000000000..73f2c8636 --- /dev/null +++ b/pdfparams/ABMPPdfParam/include/ABMPPdfParam.h @@ -0,0 +1,29 @@ + +#pragma once + +#include "BasePdfParam.h" + +/** + @class ABMPPdfParam + + @brief A class for ABMP pdf parameterisation + + @version 0.1 + @date 2019-02-25 + */ + +namespace xfitter{ +class ABMPPdfParam:public BasePdfParam{ + public: + ABMPPdfParam(const std::string&inName):BasePdfParam(inName){} + //Evaluate xf(x) at given x with current parameters + virtual double operator()(double x)const override final; + // (Optional) compute moments: + // virtual double moment(int nMoment=-1)const override final; + // (Optional) set moments: + // virtual void setMoment(int nMoment,double value)override final; + // (Optional) + //Initialize from a yaml node. Uses node[getName] as the basis + // virtual void initFromYaml(YAML::Node value)override final; +}; +} diff --git a/pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc b/pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc new file mode 100644 index 000000000..99d51ca38 --- /dev/null +++ b/pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc @@ -0,0 +1,25 @@ + +/* + @file ABMPPdfParam.cc + @date 2019-02-25 + @author AddPdfParam.py + Created by AddPdfParam.py on 2019-02-25 +*/ + +#include "ABMPPdfParam.h" +namespace xfitter{ + //for dynamic loading + extern"C" ABMPPdfParam*create(const char*name){ + return new ABMPPdfParam(name); + } + // Main function to compute PDF + double ABMPPdfParam::operator()(double x)const{ + const int npar = getNPar(); + if (npar<7) { + return NAN; + } + double power = (1 + *pars[3]) * (1 + *pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); + double val = *pars[0] * pow(x, *pars[1]) * pow(1 - x, *pars[2]) * pow(x, power); + return val; +} +} diff --git a/pdfparams/ABMPPdfParam/src/Makefile.am b/pdfparams/ABMPPdfParam/src/Makefile.am new file mode 100644 index 000000000..da705eba9 --- /dev/null +++ b/pdfparams/ABMPPdfParam/src/Makefile.am @@ -0,0 +1,13 @@ + +# Created by AddPdfParam.py on 2019-02-25 + +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated + +lib_LTLIBRARIES = libABMPPdfParam_xfitter.la +libABMPPdfParam_xfitter_la_SOURCES = ABMPPdfParam.cc + +datadir = ${prefix}/yaml/pdfparams/ABMP +data_DATA = ../yaml/parameters.yaml + +dist_noinst_HEADERS = ../include ../yaml +libABMPPdfParam_xfitter_la_LDFLAGS=-lBasePdfParam_xfitter -L$(libdir) -- GitLab From 034ac8c493afeb589854013be12f91601a1a7d13 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 25 Feb 2019 19:46:38 +0100 Subject: [PATCH 31/81] restored parameters.yaml --- steering.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/steering.txt b/steering.txt index 580cc1d21..1775a68ab 100644 --- a/steering.txt +++ b/steering.txt @@ -68,7 +68,8 @@ &OutDir ! Name of the directory where output will be stored (max 255 characters) - OutDirName = 'output' + !OutDirName = 'output' + OutDirName = 'output-ABMP16' &End * * (Optional) Modify renormalisation/factorisation scales, dataset @@ -171,7 +172,8 @@ ! 'DDIS' -- use Diffractive DIS ! 'BiLog' -- bi-lognormal parametrisation - PDFStyle = 'HERAPDF' + !PDFStyle = 'HERAPDF' + PDFStyle = 'LHAPDFNATIVE' ! XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ! @@ -217,8 +219,8 @@ DoBandsSym = False ! symmetric bands ( HESSE ) ! -- Q2 values at which the pdfs & errors are done (up to 20) - Q2VAL = 1.9, 3.0, 4.0, 5., 10., 100., 6464, 8317 ! Q2VAL = 1.9, 4., 10., 100., 6464, 8317 + Q2VAL = 9.0 ! How many x points to write (standard = 101) OUTNX = 101 -- GitLab From dc273c4e457023be21641ee0142a8796ab848424 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 25 Feb 2019 21:11:35 +0100 Subject: [PATCH 32/81] fixed PDF expression --- pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc b/pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc index 99d51ca38..7ecf56b64 100644 --- a/pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc +++ b/pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc @@ -18,7 +18,7 @@ namespace xfitter{ if (npar<7) { return NAN; } - double power = (1 + *pars[3]) * (1 + *pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); + double power = *pars[1] * (1 + *pars[3] * log(x)) * (1 + *pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); double val = *pars[0] * pow(x, *pars[1]) * pow(1 - x, *pars[2]) * pow(x, power); return val; } -- GitLab From a185d5dda78ca75d620eeb9d459b8dbc07825721 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 25 Feb 2019 21:25:32 +0100 Subject: [PATCH 33/81] fixed AddPdfParam.py --- tools/AddPdfParam.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tools/AddPdfParam.py b/tools/AddPdfParam.py index a6f4239b3..1fc0a321d 100644 --- a/tools/AddPdfParam.py +++ b/tools/AddPdfParam.py @@ -16,6 +16,18 @@ name = sys.argv[1] # First check if the name is already used +with open("Reactions.txt","r+") as f: + for l in f: + a = l.split() + if a[0] == name: + print "Interface for reaction "+name+" already exists, exit" + exit(0) + +# Not present, add new line to the Reactions.txt file + +with open("Reactions.txt","a") as f: + f.write(name+" "+"lib"+name+"PdfParam"+"_xfitter.so\n") + print "Creating directories in pdfparams/"+name os.system("mkdir -p pdfparams/"+name+"PdfParam/include") @@ -43,6 +55,7 @@ with open(hFile,"w+") as f: @date {date:s} */ +namespace xfitter{{ class {name:s}PdfParam:public BasePdfParam{{ public: {name:s}PdfParam(const std::string&inName):BasePdfParam(inName){{}} @@ -56,6 +69,7 @@ class {name:s}PdfParam:public BasePdfParam{{ //Initialize from a yaml node. Uses node[getName] as the basis // virtual void initFromYaml(YAML::Node value)override final; }}; +}} '''.format(name=name,date=datetime.date.today().isoformat()) ) @@ -75,8 +89,16 @@ with open(sFile,"w+") as f: #include "{name:s}PdfParam.h" -double {name:s}PdfParam::operator()(double x){{ +namespace xfitter{{ +//for dynamic loading +extern"C" {name:s}PdfParam*create(const char*name){{ + return new {name:s}PdfParam(name); +}} +// Main function to compute PDF +double {name:s}PdfParam::operator()(double x)const{{ //Your code here + return NAN; +}} }} '''.format(name=name,date=datetime.date.today().isoformat()) ) @@ -99,7 +121,8 @@ datadir = ${{prefix}}/yaml/pdfparams/{:s} data_DATA = ../yaml/parameters.yaml dist_noinst_HEADERS = ../include ../yaml -'''.format(datetime.date.today().isoformat(),name,name,name,name)) +lib{:s}PdfParam_xfitter_la_LDFLAGS=-lBasePdfParam_xfitter -L$(libdir) +'''.format(datetime.date.today().isoformat(),name,name,name,name,name)) print "Update configure.ac file" -- GitLab From 83d5e930684a0727c81361f07c650f42809fadb5 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 25 Feb 2019 21:40:58 +0100 Subject: [PATCH 34/81] fixed AddPdfDecomp.py --- tools/AddPdfDecomp.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/AddPdfDecomp.py b/tools/AddPdfDecomp.py index 516d12a2b..20247584e 100644 --- a/tools/AddPdfDecomp.py +++ b/tools/AddPdfDecomp.py @@ -25,8 +25,9 @@ with open("Reactions.txt","r+") as f: # Not present, add new line to the Reactions.txt file +print "Update Reactions.txt file" with open("Reactions.txt","a") as f: - f.write(name+" "+"lib"+name.lower()+"_xfitter.so\n") + f.write(name+" "+"lib"+name+"PdfDecomposition"+"_xfitter.so\n") print "Creating directories in pdfdecompositions/"+name+"PdfDecomposition" @@ -66,10 +67,12 @@ class {:s}PdfDecomposition : public BasePdfDecomposition {:s}PdfDecomposition (); /// Default constructor. Name is the PDF name - {:s}PdfDecomposition (const std::string& inName); + {:s}PdfDecomposition (const char* inName); + + virtual const char*getClassName()const override final; /// Optional initialization at the first call - virtual void initAtStart(const std::string & pars) override final; + virtual void atStart() override final; /// Compute PDF in a physical base in LHAPDF format for given x and Q virtual std::function<std::map<int,double>(const double& x)> f0() const override final; @@ -98,8 +101,8 @@ with open(sFile,"w+") as f: namespace xfitter {{ /// the class factories, for dynamic loading -extern "C" {:s}PdfDecomposition* create() {{ - return new {:s}PdfDecomposition(); +extern "C" {:s}PdfDecomposition* create(const char*name) {{ + return new {:s}PdfDecomposition(name); }} @@ -108,11 +111,13 @@ extern "C" {:s}PdfDecomposition* create() {{ }} // Constructor -{:s}PdfDecomposition::{:s}PdfDecomposition(const std::string& inName) : BasePdfDecomposition(inName) {{ +{:s}PdfDecomposition::{:s}PdfDecomposition(const char* inName) : BasePdfDecomposition(inName) {{ }} +const char*{:s}PdfDecomposition::getClassName()const{{return"{:s}";}} + // Init at start: -void {:s}PdfDecomposition::initAtStart(const std::string & pars) {{ +void {:s}PdfDecomposition::atStart() {{ return; }} @@ -142,7 +147,7 @@ std::function<std::map<int,double>(const double& x)> {:s}PdfDecomposition::f0() }} '''.format(name,datetime.date.today().isoformat(),datetime.date.today().isoformat() - ,name,name,name,name,name,name,name,name,name,name) + ,name,name,name,name,name,name,name,name,name,name,name,name) ) -- GitLab From 6702410e42bc206c7e51bfc9639c02ed39bb92c5 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 25 Feb 2019 21:54:33 +0100 Subject: [PATCH 35/81] polished scripts --- tools/AddPdfDecomp.py | 12 +++++++----- tools/AddPdfParam.py | 6 +++++- tools/AddReaction.py | 6 +++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/AddPdfDecomp.py b/tools/AddPdfDecomp.py index 20247584e..2b3d7a5f5 100644 --- a/tools/AddPdfDecomp.py +++ b/tools/AddPdfDecomp.py @@ -25,7 +25,7 @@ with open("Reactions.txt","r+") as f: # Not present, add new line to the Reactions.txt file -print "Update Reactions.txt file" +print "Updating Reactions.txt file" with open("Reactions.txt","a") as f: f.write(name+" "+"lib"+name+"PdfDecomposition"+"_xfitter.so\n") @@ -35,7 +35,6 @@ print "Creating directories in pdfdecompositions/"+name+"PdfDecomposition" os.system("mkdir -p pdfdecompositions/"+name+"PdfDecomposition/include") os.system("mkdir -p pdfdecompositions/"+name+"PdfDecomposition/src") os.system("mkdir -p pdfdecompositions/"+name+"PdfDecomposition/yaml") -os.system("touch pdfdecompositions/"+name+"PdfDecomposition/yaml/parameters.yaml") hFile = "pdfdecompositions/{:s}PdfDecomposition/include/{:s}PdfDecomposition.h".format(name,name) @@ -172,16 +171,19 @@ dist_noinst_HEADERS = ../include ../yaml '''.format(datetime.date.today().isoformat(),name,name,name,name)) +pFile="pdfdecompositions/"+name+"PdfDecomposition/yaml/parameters.yaml" +print "Creating (empty) parameter file "+pFile +os.system("touch "+pFile) -print "Update configure.ac file" +print "Updating configure.ac file" os.system("sed 's|xfitter-config|xfitter-config\\n pdfdecompositions/{:s}PdfDecomposition/src/Makefile|' configure.ac >/tmp/configure.ac".format(name)) os.system("cp /tmp/configure.ac configure.ac") -print "Update Makefile.am" +print "Updating Makefile.am" os.system("sed 's|pdfdecompositions/BasePdfDecomposition/src|pdfdecompositions/BasePdfDecomposition/src pdfdecompositions/{:s}PdfDecomposition/src|' Makefile.am > /tmp/Makefile.am".format(name)) os.system("cp /tmp/Makefile.am Makefile.am") -print "Update doxygen.cfg" +print "Updating doxygen.cfg" os.system("sed 's|pdfdecompositions/BasePdfDecomposition/include|pdfdecompositions/BasePdfDecomposition/include pdfdecompositions/{:s}PdfDecomposition/include|' doxygen.cfg > /tmp/doxygen.cfg".format(name)) os.system("cp /tmp/doxygen.cfg doxygen.cfg") diff --git a/tools/AddPdfParam.py b/tools/AddPdfParam.py index 1fc0a321d..35e4a12ec 100644 --- a/tools/AddPdfParam.py +++ b/tools/AddPdfParam.py @@ -25,6 +25,7 @@ with open("Reactions.txt","r+") as f: # Not present, add new line to the Reactions.txt file +print "Update Reactions.txt file" with open("Reactions.txt","a") as f: f.write(name+" "+"lib"+name+"PdfParam"+"_xfitter.so\n") @@ -33,7 +34,6 @@ print "Creating directories in pdfparams/"+name os.system("mkdir -p pdfparams/"+name+"PdfParam/include") os.system("mkdir -p pdfparams/"+name+"PdfParam/src") os.system("mkdir -p pdfparams/"+name+"PdfParam/yaml") -os.system("touch pdfparams/"+name+"PdfParam/yaml/parameters.yaml") hFile = "pdfparams/{:s}PdfParam/include/{:s}PdfParam.h".format(name,name) @@ -125,6 +125,10 @@ lib{:s}PdfParam_xfitter_la_LDFLAGS=-lBasePdfParam_xfitter -L$(libdir) '''.format(datetime.date.today().isoformat(),name,name,name,name,name)) +pFile="pdfparams/"+name+"PdfParam/yaml/parameters.yaml" +print "Creating (empty) parameter file "+pFile +os.system("touch "+pFile) + print "Update configure.ac file" os.system("sed 's|xfitter-config|xfitter-config\\n pdfparams/{:s}PdfParam/src/Makefile|' configure.ac >/tmp/configure.ac".format(name)) os.system("cp /tmp/configure.ac configure.ac") diff --git a/tools/AddReaction.py b/tools/AddReaction.py index 77480f1a9..35d56f751 100644 --- a/tools/AddReaction.py +++ b/tools/AddReaction.py @@ -25,6 +25,7 @@ with open("Reactions.txt","r+") as f: # Not present, add new line to the Reactions.txt file +print "Update Reactions.txt file" with open("Reactions.txt","a") as f: f.write(name+" "+"lib"+name.lower()+"_xfitter.so\n") @@ -35,7 +36,6 @@ print "Creating directories in reactions/"+name os.system("mkdir -p reactions/"+name+"/include") os.system("mkdir -p reactions/"+name+"/src") os.system("mkdir -p reactions/"+name+"/yaml") -os.system("touch reactions/"+name+"/yaml/parameters.yaml") print "Creating header file reactions/"+name+"/include/Reaction"+name+".h" @@ -129,6 +129,10 @@ dist_noinst_HEADERS = ../include ../yaml ''') +pFile="reactions/"+name+"/yaml/parameters.yaml" +print "Creating (empty) parameter file "+pFile +os.system("touch "+pFile) + print "Update configure.ac file" os.system("sed 's|xfitter-config|xfitter-config\\n reactions/" +name +"/src/Makefile|' configure.ac >/tmp/configure.ac") os.system("cp /tmp/configure.ac configure.ac") -- GitLab From 7a6fae1eaabecce1bcddf09d84e0278c8dbed69d Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 25 Feb 2019 23:33:01 +0100 Subject: [PATCH 36/81] improved ABMP parametrisation --- Makefile.am | 2 +- Reactions.txt | 4 ++- configure.ac | 4 ++- doxygen.cfg | 2 +- pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc | 25 ---------------- pdfparams/ABMPPdfParam/src/Makefile.am | 13 --------- .../include/ABMPgluonPdfParam.h | 29 +++++++++++++++++++ .../src/ABMPgluonPdfParam.cc | 27 +++++++++++++++++ .../include/ABMPseaPdfParam.h} | 8 ++--- .../ABMPseaPdfParam/src/ABMPseaPdfParam.cc | 26 +++++++++++++++++ .../include/ABMPvalencePdfParam.h | 29 +++++++++++++++++++ .../src/ABMPvalencePdfParam.cc | 26 +++++++++++++++++ 12 files changed, 149 insertions(+), 46 deletions(-) delete mode 100644 pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc delete mode 100644 pdfparams/ABMPPdfParam/src/Makefile.am create mode 100644 pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h create mode 100644 pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc rename pdfparams/{ABMPPdfParam/include/ABMPPdfParam.h => ABMPseaPdfParam/include/ABMPseaPdfParam.h} (75%) create mode 100644 pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc create mode 100644 pdfparams/ABMPvalencePdfParam/include/ABMPvalencePdfParam.h create mode 100644 pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc diff --git a/Makefile.am b/Makefile.am index 53fe5c0f7..617065d3b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,7 +28,7 @@ SUBDIRS = minuit/src interfaces/src DY/src DIPOLE/src RT/src EW/src common commo pdfparams/BasePdfParam/src \ pdfparams/HERAPDF_PdfParam/src \ pdfparams/PolySqrtPdfParam/src \ - pdfdecompositions/BasePdfDecomposition/src pdfparams/ABMPPdfParam/src pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src pdfparams/NegativeGluonPdfParam/src \ + pdfdecompositions/BasePdfDecomposition/src pdfparams/ABMPgluonPdfParam/src pdfparams/ABMPseaPdfParam/src pdfparams/ABMPvalencePdfParam/src pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src pdfparams/NegativeGluonPdfParam/src \ pdfdecompositions/LHAPDFDecomposition/src \ pdfdecompositions/UvDvUbarDbarS/src \ pdfdecompositions/SU3_PionPdfDecomposition/src \ diff --git a/Reactions.txt b/Reactions.txt index ec3a20d72..61e9b56fe 100644 --- a/Reactions.txt +++ b/Reactions.txt @@ -28,4 +28,6 @@ PolySqrt libPolySqrtPdfParam_xfitter.so AFB libafb_xfitter.so KMatrix libkmatrix_xfitter.so UvDvUbarDbarSSbar libuvdvubardbarssbarpdfdecomposition_xfitter.so -ABMPPdfParam libABMPPdfParam_xfitter.so +ABMPvalence libABMPvalencePdfParam_xfitter.so +ABMPsea libABMPseaPdfParam_xfitter.so +ABMPgluon libABMPgluonPdfParam_xfitter.so diff --git a/configure.ac b/configure.ac index f0bf74a7c..bff940fe8 100644 --- a/configure.ac +++ b/configure.ac @@ -599,7 +599,9 @@ AC_CONFIG_FILES([include/Makefile examples/Makefile python/Makefile xfitter-config - pdfparams/ABMPPdfParam/src/Makefile + pdfparams/ABMPgluonPdfParam/src/Makefile + pdfparams/ABMPseaPdfParam/src/Makefile + pdfparams/ABMPvalencePdfParam/src/Makefile pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile pdfparams/NegativeGluonPdfParam/src/Makefile evolutions/LHAPDF/src/Makefile diff --git a/doxygen.cfg b/doxygen.cfg index 86959e022..52c690b76 100644 --- a/doxygen.cfg +++ b/doxygen.cfg @@ -582,7 +582,7 @@ INPUT = include src \ reactions/BaseHVQMNR/src reactions/HVQMNR_LHCb_7TeV_beauty/include \ reactions/HVQMNR_LHCb_7TeV_beauty/src \ - pdfparams/BasePdfParam/include pdfparams/ABMPPdfParam/include pdfparams/NegativeGluonPdf/include \ + pdfparams/BasePdfParam/include pdfparams/ABMPgluonPdfParam/include pdfparams/ABMPseaPdfParam/include pdfparams/ABMPvalencePdfParam/include pdfparams/NegativeGluonPdf/include \ pdfparams/HERAPDF_PdfParam/include \ pdfparams/PolySqrtPdfParam/include \ pdfdecompositions/BasePdfDecomposition/include pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include \ diff --git a/pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc b/pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc deleted file mode 100644 index 7ecf56b64..000000000 --- a/pdfparams/ABMPPdfParam/src/ABMPPdfParam.cc +++ /dev/null @@ -1,25 +0,0 @@ - -/* - @file ABMPPdfParam.cc - @date 2019-02-25 - @author AddPdfParam.py - Created by AddPdfParam.py on 2019-02-25 -*/ - -#include "ABMPPdfParam.h" -namespace xfitter{ - //for dynamic loading - extern"C" ABMPPdfParam*create(const char*name){ - return new ABMPPdfParam(name); - } - // Main function to compute PDF - double ABMPPdfParam::operator()(double x)const{ - const int npar = getNPar(); - if (npar<7) { - return NAN; - } - double power = *pars[1] * (1 + *pars[3] * log(x)) * (1 + *pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); - double val = *pars[0] * pow(x, *pars[1]) * pow(1 - x, *pars[2]) * pow(x, power); - return val; -} -} diff --git a/pdfparams/ABMPPdfParam/src/Makefile.am b/pdfparams/ABMPPdfParam/src/Makefile.am deleted file mode 100644 index da705eba9..000000000 --- a/pdfparams/ABMPPdfParam/src/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ - -# Created by AddPdfParam.py on 2019-02-25 - -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated - -lib_LTLIBRARIES = libABMPPdfParam_xfitter.la -libABMPPdfParam_xfitter_la_SOURCES = ABMPPdfParam.cc - -datadir = ${prefix}/yaml/pdfparams/ABMP -data_DATA = ../yaml/parameters.yaml - -dist_noinst_HEADERS = ../include ../yaml -libABMPPdfParam_xfitter_la_LDFLAGS=-lBasePdfParam_xfitter -L$(libdir) diff --git a/pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h b/pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h new file mode 100644 index 000000000..1619e21f7 --- /dev/null +++ b/pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h @@ -0,0 +1,29 @@ + +#pragma once + +#include "BasePdfParam.h" + +/** + @class ABMPgluonPdfParam + + @brief A class for ABMPgluon pdf parameterisation + + @version 0.1 + @date 2019-02-25 + */ + +namespace xfitter{ +class ABMPgluonPdfParam:public BasePdfParam{ + public: + ABMPgluonPdfParam(const std::string&inName):BasePdfParam(inName){} + //Evaluate xf(x) at given x with current parameters + virtual double operator()(double x)const override final; + // (Optional) compute moments: + // virtual double moment(int nMoment=-1)const override final; + // (Optional) set moments: + // virtual void setMoment(int nMoment,double value)override final; + // (Optional) + //Initialize from a yaml node. Uses node[getName] as the basis + // virtual void initFromYaml(YAML::Node value)override final; +}; +} diff --git a/pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc b/pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc new file mode 100644 index 000000000..e5b22edef --- /dev/null +++ b/pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc @@ -0,0 +1,27 @@ + +/* + @file ABMPgluonPdfParam.cc + @date 2019-02-25 + @author AddPdfParam.py + Created by AddPdfParam.py on 2019-02-25 +*/ + +#include "ABMPgluonPdfParam.h" + +namespace xfitter{ +//for dynamic loading +extern"C" ABMPgluonPdfParam*create(const char*name){ + return new ABMPgluonPdfParam(name); +} +// Main function to compute PDF +double ABMPgluonPdfParam::operator()(double x)const{ + const int npar = getNPar(); + if (npar<7) { + return NAN; + } + //double power = *pars[1] * (1 + *pars[3] * log(x)) * (1 + *pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); + double power = *pars[1] * (1 + *pars[3] * log(x)) * (*pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); + double val = *pars[0] * pow(x, *pars[1]) * pow(1 - x, *pars[2]) * pow(x, power); + return val; +} +} diff --git a/pdfparams/ABMPPdfParam/include/ABMPPdfParam.h b/pdfparams/ABMPseaPdfParam/include/ABMPseaPdfParam.h similarity index 75% rename from pdfparams/ABMPPdfParam/include/ABMPPdfParam.h rename to pdfparams/ABMPseaPdfParam/include/ABMPseaPdfParam.h index 73f2c8636..41f278b56 100644 --- a/pdfparams/ABMPPdfParam/include/ABMPPdfParam.h +++ b/pdfparams/ABMPseaPdfParam/include/ABMPseaPdfParam.h @@ -4,18 +4,18 @@ #include "BasePdfParam.h" /** - @class ABMPPdfParam + @class ABMPseaPdfParam - @brief A class for ABMP pdf parameterisation + @brief A class for ABMPsea pdf parameterisation @version 0.1 @date 2019-02-25 */ namespace xfitter{ -class ABMPPdfParam:public BasePdfParam{ +class ABMPseaPdfParam:public BasePdfParam{ public: - ABMPPdfParam(const std::string&inName):BasePdfParam(inName){} + ABMPseaPdfParam(const std::string&inName):BasePdfParam(inName){} //Evaluate xf(x) at given x with current parameters virtual double operator()(double x)const override final; // (Optional) compute moments: diff --git a/pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc b/pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc new file mode 100644 index 000000000..aa2c863f9 --- /dev/null +++ b/pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc @@ -0,0 +1,26 @@ + +/* + @file ABMPseaPdfParam.cc + @date 2019-02-25 + @author AddPdfParam.py + Created by AddPdfParam.py on 2019-02-25 +*/ + +#include "ABMPseaPdfParam.h" + +namespace xfitter{ +//for dynamic loading +extern"C" ABMPseaPdfParam*create(const char*name){ + return new ABMPseaPdfParam(name); +} +// Main function to compute PDF +double ABMPseaPdfParam::operator()(double x)const{ + const int npar = getNPar(); + if (npar<7) { + return NAN; + } + double power = *pars[1] * (1 + *pars[3] * log(x)) * (1 + *pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); + double val = *pars[0] * pow(1 - x, *pars[2]) * pow(x, power); + return val; +} +} diff --git a/pdfparams/ABMPvalencePdfParam/include/ABMPvalencePdfParam.h b/pdfparams/ABMPvalencePdfParam/include/ABMPvalencePdfParam.h new file mode 100644 index 000000000..f406776d8 --- /dev/null +++ b/pdfparams/ABMPvalencePdfParam/include/ABMPvalencePdfParam.h @@ -0,0 +1,29 @@ + +#pragma once + +#include "BasePdfParam.h" + +/** + @class ABMPvalencePdfParam + + @brief A class for ABMPvalence pdf parameterisation + + @version 0.1 + @date 2019-02-25 + */ + +namespace xfitter{ +class ABMPvalencePdfParam:public BasePdfParam{ + public: + ABMPvalencePdfParam(const std::string&inName):BasePdfParam(inName){} + //Evaluate xf(x) at given x with current parameters + virtual double operator()(double x)const override final; + // (Optional) compute moments: + // virtual double moment(int nMoment=-1)const override final; + // (Optional) set moments: + // virtual void setMoment(int nMoment,double value)override final; + // (Optional) + //Initialize from a yaml node. Uses node[getName] as the basis + // virtual void initFromYaml(YAML::Node value)override final; +}; +} diff --git a/pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc b/pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc new file mode 100644 index 000000000..7c307c4b3 --- /dev/null +++ b/pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc @@ -0,0 +1,26 @@ + +/* + @file ABMPvalencePdfParam.cc + @date 2019-02-25 + @author AddPdfParam.py + Created by AddPdfParam.py on 2019-02-25 +*/ + +#include "ABMPvalencePdfParam.h" + +namespace xfitter{ +//for dynamic loading +extern"C" ABMPvalencePdfParam*create(const char*name){ + return new ABMPvalencePdfParam(name); +} +// Main function to compute PDF +double ABMPvalencePdfParam::operator()(double x)const{ + const int npar = getNPar(); + if (npar<7) { + return NAN; + } + double power = (1 + *pars[3] * log(x)) * (*pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); + double val = *pars[0] * pow(x, *pars[1]) * pow(1 - x, *pars[2]) * pow(x, power); + return val; +} +} -- GitLab From fce84f63f6b4d43a6613725757a2077cc4c20627 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 25 Feb 2019 23:37:58 +0100 Subject: [PATCH 37/81] restored parameters.yaml, copied new one to input_steering/ --- input_steering/parameters.yaml.abmp16 | 34 ++++----- parameters.yaml | 105 +++++--------------------- 2 files changed, 37 insertions(+), 102 deletions(-) diff --git a/input_steering/parameters.yaml.abmp16 b/input_steering/parameters.yaml.abmp16 index 123b20387..93b98a07d 100644 --- a/input_steering/parameters.yaml.abmp16 +++ b/input_steering/parameters.yaml.abmp16 @@ -82,40 +82,40 @@ Parameterisations: par_uv: #class: HERAPDF #parameters: [Auv,Buv,Cuv,Duv,Euv] - class: ABMPPdfParam - parameters: [ABMP_uv_A,ABMP_uv_a,ABMP_uv_b,ZERO,ABMP_uv_g1,ABMP_uv_g2,ABMP_uv_g3] + class: ABMPvalence + parameters: [ABMP_uv_A, ABMP_uv_a, ABMP_uv_b, ZERO, ABMP_uv_g1, ABMP_uv_g2, ABMP_uv_g3] par_dv: #class: HERAPDF #parameters: [Adv,Bdv,Cdv] - class: ABMPPdfParam - parameters: [ABMP_dv_A,ABMP_dv_a,ABMP_dv_b,ZERO,ABMP_dv_g1,ABMP_dv_g2,ABMP_dv_g3] + class: ABMPvalence + parameters: [ABMP_dv_A, ABMP_dv_a, ABMP_dv_b, ZERO, ABMP_dv_g1, ABMP_dv_g2, ABMP_dv_g3] par_ubar: #class: HERAPDF #parameters: [Aubar,Bubar,Cubar,Dubar] - class: ABMPPdfParam - parameters: [ABMP_us_A,ABMP_us_a,ABMP_us_b,ABMP_us_gm1,ABMP_us_g1,ZERO,ZERO] + class: ABMPsea + parameters: [ABMP_us_A, ABMP_us_a, ABMP_us_b, ABMP_us_gm1, ABMP_us_g1, ZERO, ZERO] par_dbar: #class: HERAPDF #parameters: [Adbar,Bdbar,Cdbar] - class: ABMPPdfParam - parameters: [ABMP_ds_A,ABMP_ds_a,ABMP_ds_b,ZERO,ABMP_ds_g1,ZERO,ZERO] + class: ABMPsea + parameters: [ABMP_ds_A, ABMP_ds_a, ABMP_ds_b, ZERO, ABMP_ds_g1, ZERO, ZERO] par_s: #class: HERAPDF #parameters: [As,Bs,Cs] - class: ABMPPdfParam - parameters: [ABMP_ss_A,ABMP_ss_a,ABMP_ss_b,ZERO,ZERO,ZERO,ZERO] + class: ABMPsea + parameters: [ABMP_ss_A, ABMP_ss_a, ABMP_ss_b, ZERO, ZERO, ZERO, ZERO] par_sbar: #class: HERAPDF #parameters: [Asbar,Bsbar,Csbar] - class: ABMPPdfParam - parameters: [ABMP_ss_A,ABMP_ss_a,ABMP_ss_b,ZERO,ZERO,ZERO,ZERO] + class: ABMPsea + parameters: [ABMP_ss_A, ABMP_ss_a, ABMP_ss_b, ZERO, ZERO, ZERO, ZERO] #class: ABMPPdfParam - #parameters: [ABMP_ssbar_A,ABMP_ssbar_a,ABMP_ssbar_b,ZERO,ZERO,ZERO,ZERO] + #parameters: [ABMP_ssbar_A, ABMP_ssbar_a, ABMP_ssbar_b, ZERO, ZERO, ZERO, ZERO] par_g: #class: NegativeGluon #parameters: [Ag,Bg,Cg,ZERO,ZERO,Agp,Bgp,Cgp] - class: ABMPPdfParam - parameters: [ABMP_g_A,ABMP_g_a,ABMP_g_b,ZERO,ABMP_g_g1,ZERO,ZERO] + class: ABMPgluon + parameters: [ABMP_g_A, ABMP_g_a, ABMP_g_b, ZERO, ABMP_g_g1, ZERO, ZERO] DefaultDecomposition: proton Decompositions: @@ -129,8 +129,8 @@ Decompositions: xsbar: par_sbar xg: par_g -#DefaultEvolution: proton-QCDNUM -DefaultEvolution: proton-LHAPDF +DefaultEvolution: proton-QCDNUM +#DefaultEvolution: proton-LHAPDF Evolutions: proton-QCDNUM: ? !include yaml/evolutions/QCDNUM/parameters.yaml diff --git a/parameters.yaml b/parameters.yaml index 123b20387..73d782161 100644 --- a/parameters.yaml +++ b/parameters.yaml @@ -1,6 +1,7 @@ Minimizer: MINUIT # CERES MINUIT: Commands: | + fix 6 7 9 11 12 13 14 15 16 17 18 19 20 22 call fcn 3 # doErrors : Hesse # None @@ -35,102 +36,40 @@ Parameters: As : [ 0.1075 ] Bs : [ -0.1273 ] Cs : [ 9.586246 ] - Asbar : [ 0.1075 ] - Bsbar : [ -0.1473 ] - Csbar : [ 8.586246 ] ZERO : [ 0. ] # zero - - ABMP_uv_A : DEPENDENT - ABMP_uv_a : [ 0.623, 0.033 ] - ABMP_uv_b : [ 3.443, 0.064 ] - ABMP_uv_g1 : [ -0.22, 0.33 ] - ABMP_uv_g2 : [ -2.88, 0.46 ] - ABMP_uv_g3 : [ 2.67, 0.80 ] - - ABMP_dv_A : DEPENDENT - ABMP_dv_a : [ 0.372, 0.068 ] - ABMP_dv_b : [ 4.47, 0.55 ] - ABMP_dv_g1 : [ -3.20, 0.77 ] - ABMP_dv_g2 : [ -0.61, 1.96 ] - ABMP_dv_g3 : [ 0.0, 0.001 ] - - ABMP_us_A : [ 0.0703, 0.0081] - ABMP_us_a : [ -0.415, 0.031 ] - ABMP_us_b : [ 7.75, 0.39 ] - ABMP_us_gm1 : [ 0.0373, 0.0032] - ABMP_us_g1 : [ 4.44, 0.95 ] - - ABMP_ds_A : [ 0.1408, 0.0076] - ABMP_ds_a : [ -0.17, 0.011 ] - ABMP_ds_b : [ 8.41, 0.34 ] - ABMP_ds_g1 : [ 13.3, 1.7 ] - - ABMP_ss_A : [ 0.0594, 0.0042] - ABMP_ss_a : [ -0.344, 0.019 ] - ABMP_ss_b : [ 6.52, 0.27 ] - - #ABMP_ssbar_A: [ 0.0594, 0.0042] - #ABMP_ssbar_a: [ -0.344, 0.019 ] - #ABMP_ss_bbar: [ 6.52, 0.27 ] - - ABMP_g_A : DEPENDENT - ABMP_g_a : [-0.1534, 0.0094] - ABMP_g_b : [ 6.42, 0.83 ] - ABMP_g_g1 : [ -11.8, 3.7 ] Parameterisations: par_uv: - #class: HERAPDF - #parameters: [Auv,Buv,Cuv,Duv,Euv] - class: ABMPPdfParam - parameters: [ABMP_uv_A,ABMP_uv_a,ABMP_uv_b,ZERO,ABMP_uv_g1,ABMP_uv_g2,ABMP_uv_g3] + class: HERAPDF + parameters: [Auv,Buv,Cuv,Duv,Euv] par_dv: - #class: HERAPDF - #parameters: [Adv,Bdv,Cdv] - class: ABMPPdfParam - parameters: [ABMP_dv_A,ABMP_dv_a,ABMP_dv_b,ZERO,ABMP_dv_g1,ABMP_dv_g2,ABMP_dv_g3] + class: HERAPDF + parameters: [Adv,Bdv,Cdv] par_ubar: - #class: HERAPDF - #parameters: [Aubar,Bubar,Cubar,Dubar] - class: ABMPPdfParam - parameters: [ABMP_us_A,ABMP_us_a,ABMP_us_b,ABMP_us_gm1,ABMP_us_g1,ZERO,ZERO] + class: HERAPDF + parameters: [Aubar,Bubar,Cubar,Dubar] par_dbar: - #class: HERAPDF - #parameters: [Adbar,Bdbar,Cdbar] - class: ABMPPdfParam - parameters: [ABMP_ds_A,ABMP_ds_a,ABMP_ds_b,ZERO,ABMP_ds_g1,ZERO,ZERO] + class: HERAPDF + parameters: [Adbar,Bdbar,Cdbar] par_s: - #class: HERAPDF - #parameters: [As,Bs,Cs] - class: ABMPPdfParam - parameters: [ABMP_ss_A,ABMP_ss_a,ABMP_ss_b,ZERO,ZERO,ZERO,ZERO] - par_sbar: - #class: HERAPDF - #parameters: [Asbar,Bsbar,Csbar] - class: ABMPPdfParam - parameters: [ABMP_ss_A,ABMP_ss_a,ABMP_ss_b,ZERO,ZERO,ZERO,ZERO] - #class: ABMPPdfParam - #parameters: [ABMP_ssbar_A,ABMP_ssbar_a,ABMP_ssbar_b,ZERO,ZERO,ZERO,ZERO] + class: HERAPDF + parameters: [As,Bs,Cs] par_g: - #class: NegativeGluon - #parameters: [Ag,Bg,Cg,ZERO,ZERO,Agp,Bgp,Cgp] - class: ABMPPdfParam - parameters: [ABMP_g_A,ABMP_g_a,ABMP_g_b,ZERO,ABMP_g_g1,ZERO,ZERO] + class: NegativeGluon + parameters: [Ag,Bg,Cg,ZERO,ZERO,Agp,Bgp,Cgp] DefaultDecomposition: proton Decompositions: proton: - class: UvDvUbarDbarSSbar - xuv: par_uv - xdv: par_dv + class: UvDvubardbars + xuv: par_uv + xdv: par_dv xubar: par_ubar xdbar: par_dbar - xs: par_s - xsbar: par_sbar - xg: par_g + xs: par_s + xg: par_g -#DefaultEvolution: proton-QCDNUM -DefaultEvolution: proton-LHAPDF +DefaultEvolution: proton-QCDNUM Evolutions: proton-QCDNUM: ? !include yaml/evolutions/QCDNUM/parameters.yaml @@ -143,14 +82,10 @@ Evolutions: # ? !include yaml/evolutions/APFELxx/parameters.yaml # decomposition: proton -#Q0 : 1.378404875209 # Initial scale =sqrt(1.9) -Q0 : 3.0 # ABMP16 +Q0 : 1.378404875209 # Initial scale =sqrt(1.9) ? !include constants.yaml -# just for test of ABMP16 parametrisation (in QCDNUM charm quark mass should be above starting scale) -mch : 3.1 - # AlphaS, incuding options to fit it: alphas : 0.118 # value: 0.118 -- GitLab From bf49ab0119414fc2c5fddfdffcfe51209f3de6c2 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Tue, 26 Feb 2019 14:02:15 +0100 Subject: [PATCH 38/81] restored steering --- steering.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/steering.txt b/steering.txt index 1775a68ab..580cc1d21 100644 --- a/steering.txt +++ b/steering.txt @@ -68,8 +68,7 @@ &OutDir ! Name of the directory where output will be stored (max 255 characters) - !OutDirName = 'output' - OutDirName = 'output-ABMP16' + OutDirName = 'output' &End * * (Optional) Modify renormalisation/factorisation scales, dataset @@ -172,8 +171,7 @@ ! 'DDIS' -- use Diffractive DIS ! 'BiLog' -- bi-lognormal parametrisation - !PDFStyle = 'HERAPDF' - PDFStyle = 'LHAPDFNATIVE' + PDFStyle = 'HERAPDF' ! XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ! @@ -219,8 +217,8 @@ DoBandsSym = False ! symmetric bands ( HESSE ) ! -- Q2 values at which the pdfs & errors are done (up to 20) + Q2VAL = 1.9, 3.0, 4.0, 5., 10., 100., 6464, 8317 ! Q2VAL = 1.9, 4., 10., 100., 6464, 8317 - Q2VAL = 9.0 ! How many x points to write (standard = 101) OUTNX = 101 -- GitLab From ab31b08f359788ea71feb7865da5fe79bf903b34 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Tue, 26 Feb 2019 14:20:00 +0100 Subject: [PATCH 39/81] addressed PR comments, fixed ABMP expressions: final version --- input_steering/parameters.yaml.abmp16 | 19 +-- .../UvDvUbarDbarSSbarPdfDecomposition.h | 31 ++-- .../src/UvDvUbarDbarSSbarPdfDecomposition.cc | 139 +++++++++--------- .../include/ABMPgluonPdfParam.h | 10 +- .../src/ABMPgluonPdfParam.cc | 23 ++- .../ABMPseaPdfParam/include/ABMPseaPdfParam.h | 9 +- .../ABMPseaPdfParam/src/ABMPseaPdfParam.cc | 22 +-- .../include/ABMPvalencePdfParam.h | 10 +- .../src/ABMPvalencePdfParam.cc | 22 +-- tools/AddPdfDecomp.py | 8 - 10 files changed, 137 insertions(+), 156 deletions(-) diff --git a/input_steering/parameters.yaml.abmp16 b/input_steering/parameters.yaml.abmp16 index 93b98a07d..a15f0f3f9 100644 --- a/input_steering/parameters.yaml.abmp16 +++ b/input_steering/parameters.yaml.abmp16 @@ -41,7 +41,7 @@ Parameters: ZERO : [ 0. ] # zero ABMP_uv_A : DEPENDENT - ABMP_uv_a : [ 0.623, 0.033 ] + ABMP_uv_a : [ 0.613, 0.033 ] ABMP_uv_b : [ 3.443, 0.064 ] ABMP_uv_g1 : [ -0.22, 0.33 ] ABMP_uv_g2 : [ -2.88, 0.46 ] @@ -55,22 +55,22 @@ Parameters: ABMP_dv_g3 : [ 0.0, 0.001 ] ABMP_us_A : [ 0.0703, 0.0081] - ABMP_us_a : [ -0.415, 0.031 ] + ABMP_us_a : [-0.4155, 0.031 ] ABMP_us_b : [ 7.75, 0.39 ] ABMP_us_gm1 : [ 0.0373, 0.0032] ABMP_us_g1 : [ 4.44, 0.95 ] ABMP_ds_A : [ 0.1408, 0.0076] - ABMP_ds_a : [ -0.17, 0.011 ] + ABMP_ds_a : [-0.1731, 0.011 ] ABMP_ds_b : [ 8.41, 0.34 ] ABMP_ds_g1 : [ 13.3, 1.7 ] ABMP_ss_A : [ 0.0594, 0.0042] - ABMP_ss_a : [ -0.344, 0.019 ] + ABMP_ss_a : [-0.3445, 0.019 ] ABMP_ss_b : [ 6.52, 0.27 ] #ABMP_ssbar_A: [ 0.0594, 0.0042] - #ABMP_ssbar_a: [ -0.344, 0.019 ] + #ABMP_ssbar_a: [-0.3445, 0.019 ] #ABMP_ss_bbar: [ 6.52, 0.27 ] ABMP_g_A : DEPENDENT @@ -120,14 +120,7 @@ Parameterisations: DefaultDecomposition: proton Decompositions: proton: - class: UvDvUbarDbarSSbar - xuv: par_uv - xdv: par_dv - xubar: par_ubar - xdbar: par_dbar - xs: par_s - xsbar: par_sbar - xg: par_g + class: TestD DefaultEvolution: proton-QCDNUM #DefaultEvolution: proton-LHAPDF diff --git a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h index 9399aebdb..160917459 100644 --- a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h +++ b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h @@ -4,7 +4,7 @@ #include "BasePdfDecomposition.h" /** - @class UvDvUbarDbarSSbarPdfDecomposition + @class UvDvUbarDbarSSbarPdfDecomposition @brief A class for UvDvUbarDbarSSbar pdf decomposition @@ -14,13 +14,10 @@ namespace xfitter { -class UvDvUbarDbarSSbarPdfDecomposition : public BasePdfDecomposition -{ + class UvDvUbarDbarSSbarPdfDecomposition : public BasePdfDecomposition + { public: - /// Default constructor. - UvDvUbarDbarSSbarPdfDecomposition (); - - /// Default constructor. Name is the PDF name + /// Default constructor. Name is the PDF name UvDvUbarDbarSSbarPdfDecomposition (const char *inName); virtual const char*getClassName()const override final; @@ -32,15 +29,15 @@ class UvDvUbarDbarSSbarPdfDecomposition : public BasePdfDecomposition virtual void atIteration() override final; /// Compute PDF in a physical base in LHAPDF format for given x and Q - virtual std::function<std::map<int,double>(const double& x)> f0() const override final; + virtual std::function<std::map<int,double>(const double& x)> f0() const override final; -private: - BasePdfParam*par_xuv{nullptr}, - *par_xdv{nullptr}, - *par_xubar{nullptr}, - *par_xdbar{nullptr}, - *par_xs{nullptr}, - *par_xsbar{nullptr}, - *par_xg{nullptr}; -}; + private: + BasePdfParam*par_xuv{nullptr}, + *par_xdv{nullptr}, + *par_xubar{nullptr}, + *par_xdbar{nullptr}, + *par_xs{nullptr}, + *par_xsbar{nullptr}, + *par_xg{nullptr}; + }; } diff --git a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc index 0b255ffeb..5f858b7a5 100644 --- a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc +++ b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc @@ -1,4 +1,4 @@ - + /* @file UvDvUbarDbarSSbarPdfDecomposition.cc @date 2019-02-25 @@ -15,84 +15,79 @@ namespace xfitter { -/// the class factories, for dynamic loading -extern "C" UvDvUbarDbarSSbarPdfDecomposition* create(const char*name) { + /// the class factories, for dynamic loading + extern "C" UvDvUbarDbarSSbarPdfDecomposition* create(const char*name) { return new UvDvUbarDbarSSbarPdfDecomposition(name); -} + } + // Constructor + UvDvUbarDbarSSbarPdfDecomposition::UvDvUbarDbarSSbarPdfDecomposition(const char* inName) : BasePdfDecomposition(inName) { + } -// Constructor - UvDvUbarDbarSSbarPdfDecomposition::UvDvUbarDbarSSbarPdfDecomposition() : BasePdfDecomposition("UvDvUbarDbarSSbar") { -} + const char*UvDvUbarDbarSSbarPdfDecomposition::getClassName()const{return"UvDvUbarDbarS";} -// Constructor -UvDvUbarDbarSSbarPdfDecomposition::UvDvUbarDbarSSbarPdfDecomposition(const char* inName) : BasePdfDecomposition(inName) { -} + // Init at start: + void UvDvUbarDbarSSbarPdfDecomposition::atStart() { + const YAML::Node node=XFITTER_PARS::getDecompositionNode(_name); + //TODO: handle errors + par_xuv =getParameterisation(node["xuv"].as<string>()); + par_xdv =getParameterisation(node["xdv"].as<string>()); + par_xubar=getParameterisation(node["xubar"].as<string>()); + par_xdbar=getParameterisation(node["xdbar"].as<string>()); + par_xs =getParameterisation(node["xs"].as<string>()); + par_xsbar =getParameterisation(node["xsbar"].as<string>()); + par_xg =getParameterisation(node["xg"].as<string>()); + } -const char*UvDvUbarDbarSSbarPdfDecomposition::getClassName()const{return"UvDvUbarDbarS";} + void UvDvUbarDbarSSbarPdfDecomposition::atIteration() { + //Enforce sum rules + // counting sum-rules for uv and dv + par_xuv->setMoment(-1,2.0); + par_xdv->setMoment(-1,1.0); + // momentum sum-rule + // quark part + double xsumq=0; + xsumq+= par_xuv ->moment(0); + xsumq+= par_xdv ->moment(0); + xsumq+=2*par_xubar->moment(0); + xsumq+=2*par_xdbar->moment(0); + xsumq+=par_xs ->moment(0); + xsumq+=par_xsbar ->moment(0); + // gluon part + par_xg->setMoment(0,1-xsumq); -// Init at start: -void UvDvUbarDbarSSbarPdfDecomposition::atStart() { - const YAML::Node node=XFITTER_PARS::getDecompositionNode(_name); - //TODO: handle errors - par_xuv =getParameterisation(node["xuv"].as<string>()); - par_xdv =getParameterisation(node["xdv"].as<string>()); - par_xubar=getParameterisation(node["xubar"].as<string>()); - par_xdbar=getParameterisation(node["xdbar"].as<string>()); - par_xs =getParameterisation(node["xs"].as<string>()); - par_xsbar =getParameterisation(node["xsbar"].as<string>()); - par_xg =getParameterisation(node["xg"].as<string>()); -} + printParams(); + } -void UvDvUbarDbarSSbarPdfDecomposition::atIteration() { - //Enforce sum rules - // counting sum-rules for uv and dv - par_xuv->setMoment(-1,2.0); - par_xdv->setMoment(-1,1.0); - // momentum sum-rule - // quark part - double xsumq=0; - xsumq+= par_xuv ->moment(0); - xsumq+= par_xdv ->moment(0); - xsumq+=2*par_xubar->moment(0); - xsumq+=2*par_xdbar->moment(0); - xsumq+=par_xs ->moment(0); - xsumq+=par_xsbar ->moment(0); - // gluon part - par_xg->setMoment(0,1-xsumq); - - printParams(); -} - -// Returns a LHAPDF-style function, that returns PDFs in a physical basis for given x -std::function<std::map<int,double>(const double& x)> UvDvUbarDbarSSbarPdfDecomposition::f0() const -{ - // lambda function - return [=] (double const& x)->std::map<int, double> { - double ubar=(*par_xubar)(x); - double dbar=(*par_xdbar)(x); - double u=(*par_xuv)(x)+ubar; - double d=(*par_xdv)(x)+dbar; - double s=(*par_xs)(x); - double sbar=(*par_xsbar)(x); - double g=(*par_xg)(x); - std::map<int, double> res = { - {-6,0}, - {-5,0}, - {-4,0}, - {-3,sbar}, - {-2,ubar}, - {-1,dbar}, - { 1,d}, - { 2,u}, - { 3,s}, - { 4,0}, - { 5,0}, - { 6,0}, - {21,g} + // Returns a LHAPDF-style function, that returns PDFs in a physical basis for given x + std::function<std::map<int,double>(const double& x)> UvDvUbarDbarSSbarPdfDecomposition::f0() const + { + // lambda function + return [=] (double const& x)->std::map<int, double> { + double ubar=(*par_xubar)(x); + double dbar=(*par_xdbar)(x); + double u=(*par_xuv)(x)+ubar; + double d=(*par_xdv)(x)+dbar; + double s=(*par_xs)(x); + double sbar=(*par_xsbar)(x); + double g=(*par_xg)(x); + std::map<int, double> res = { + {-6,0}, + {-5,0}, + {-4,0}, + {-3,sbar}, + {-2,ubar}, + {-1,dbar}, + { 1,d}, + { 2,u}, + { 3,s}, + { 4,0}, + { 5,0}, + { 6,0}, + {21,g} + }; + return res; }; - return res; - }; -} + } } diff --git a/pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h b/pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h index 1619e21f7..4be9b46bf 100644 --- a/pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h +++ b/pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h @@ -4,16 +4,18 @@ #include "BasePdfParam.h" /** - @class ABMPgluonPdfParam + @class ABMPgluonPdfParam - @brief A class for ABMPgluon pdf parameterisation + @brief A class for ABMPgluon pdf parameterisation according to Eqs. 19-22 from Phys.Rev. D96 (2017) no.1, 014011 + xg(x) = A * (1 - x)^b * x^[a * (1 + gam_m1 * ln(x)) * (1 + gam_1 * x + gam_2 * x^2 + gam_3 * x^3)] + (Note that gam_m1 is zero for gluon in the ABMP16 fitm so it appears for generality with other PDFs.) @version 0.1 @date 2019-02-25 */ namespace xfitter{ -class ABMPgluonPdfParam:public BasePdfParam{ + class ABMPgluonPdfParam:public BasePdfParam{ public: ABMPgluonPdfParam(const std::string&inName):BasePdfParam(inName){} //Evaluate xf(x) at given x with current parameters @@ -25,5 +27,5 @@ class ABMPgluonPdfParam:public BasePdfParam{ // (Optional) //Initialize from a yaml node. Uses node[getName] as the basis // virtual void initFromYaml(YAML::Node value)override final; -}; + }; } diff --git a/pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc b/pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc index e5b22edef..4d1e3bc78 100644 --- a/pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc +++ b/pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc @@ -1,4 +1,4 @@ - + /* @file ABMPgluonPdfParam.cc @date 2019-02-25 @@ -9,19 +9,18 @@ #include "ABMPgluonPdfParam.h" namespace xfitter{ -//for dynamic loading -extern"C" ABMPgluonPdfParam*create(const char*name){ - return new ABMPgluonPdfParam(name); -} -// Main function to compute PDF -double ABMPgluonPdfParam::operator()(double x)const{ + //for dynamic loading + extern"C" ABMPgluonPdfParam*create(const char*name){ + return new ABMPgluonPdfParam(name); + } + // Main function to compute PDF + double ABMPgluonPdfParam::operator()(double x)const{ const int npar = getNPar(); if (npar<7) { return NAN; } - //double power = *pars[1] * (1 + *pars[3] * log(x)) * (1 + *pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); - double power = *pars[1] * (1 + *pars[3] * log(x)) * (*pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); - double val = *pars[0] * pow(x, *pars[1]) * pow(1 - x, *pars[2]) * pow(x, power); - return val; -} + double power = *pars[1] * (1 + *pars[3] * log(x)) * (1 + *pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); + double val = *pars[0] * pow(1 - x, *pars[2]) * pow(x, power); + return val; + } } diff --git a/pdfparams/ABMPseaPdfParam/include/ABMPseaPdfParam.h b/pdfparams/ABMPseaPdfParam/include/ABMPseaPdfParam.h index 41f278b56..847278e85 100644 --- a/pdfparams/ABMPseaPdfParam/include/ABMPseaPdfParam.h +++ b/pdfparams/ABMPseaPdfParam/include/ABMPseaPdfParam.h @@ -4,16 +4,17 @@ #include "BasePdfParam.h" /** - @class ABMPseaPdfParam + @class ABMPseaPdfParam - @brief A class for ABMPsea pdf parameterisation + @brief A class for ABMPsea pdf parameterisation according to Eqs. 19-22 from Phys.Rev. D96 (2017) no.1, 014011 + xv(x) = A * (1 - x)^b * x^[a * (1 + gam_m1 * ln(x)) * (1 + gam_1 * x + gam_2 * x^2 + gam_3 * x^3)] @version 0.1 @date 2019-02-25 */ namespace xfitter{ -class ABMPseaPdfParam:public BasePdfParam{ + class ABMPseaPdfParam:public BasePdfParam{ public: ABMPseaPdfParam(const std::string&inName):BasePdfParam(inName){} //Evaluate xf(x) at given x with current parameters @@ -25,5 +26,5 @@ class ABMPseaPdfParam:public BasePdfParam{ // (Optional) //Initialize from a yaml node. Uses node[getName] as the basis // virtual void initFromYaml(YAML::Node value)override final; -}; + }; } diff --git a/pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc b/pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc index aa2c863f9..e37a1810b 100644 --- a/pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc +++ b/pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc @@ -1,4 +1,4 @@ - + /* @file ABMPseaPdfParam.cc @date 2019-02-25 @@ -9,18 +9,18 @@ #include "ABMPseaPdfParam.h" namespace xfitter{ -//for dynamic loading -extern"C" ABMPseaPdfParam*create(const char*name){ - return new ABMPseaPdfParam(name); -} -// Main function to compute PDF -double ABMPseaPdfParam::operator()(double x)const{ + //for dynamic loading + extern"C" ABMPseaPdfParam*create(const char*name){ + return new ABMPseaPdfParam(name); + } + // Main function to compute PDF + double ABMPseaPdfParam::operator()(double x)const{ const int npar = getNPar(); if (npar<7) { return NAN; } - double power = *pars[1] * (1 + *pars[3] * log(x)) * (1 + *pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); - double val = *pars[0] * pow(1 - x, *pars[2]) * pow(x, power); - return val; -} + double power = *pars[1] * (1 + *pars[3] * log(x)) * (1 + *pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); + double val = *pars[0] * pow(1 - x, *pars[2]) * pow(x, power); + return val; + } } diff --git a/pdfparams/ABMPvalencePdfParam/include/ABMPvalencePdfParam.h b/pdfparams/ABMPvalencePdfParam/include/ABMPvalencePdfParam.h index f406776d8..c28e42574 100644 --- a/pdfparams/ABMPvalencePdfParam/include/ABMPvalencePdfParam.h +++ b/pdfparams/ABMPvalencePdfParam/include/ABMPvalencePdfParam.h @@ -4,16 +4,18 @@ #include "BasePdfParam.h" /** - @class ABMPvalencePdfParam + @class ABMPvalencePdfParam - @brief A class for ABMPvalence pdf parameterisation + @brief A class for ABMPvalence pdf parameterisation according to Eqs. 19-22 from Phys.Rev. D96 (2017) no.1, 014011 + xv(x) = A * (1 - x)^b * x^[(1 + gam_m1 * ln(x)) * (a + gam_1 * x + gam_2 * x^2 + gam_3 * x^3)] + (Note that gam_m1 is zero for both u- and d-valence in the ABMP16 fit.) @version 0.1 @date 2019-02-25 */ namespace xfitter{ -class ABMPvalencePdfParam:public BasePdfParam{ + class ABMPvalencePdfParam:public BasePdfParam{ public: ABMPvalencePdfParam(const std::string&inName):BasePdfParam(inName){} //Evaluate xf(x) at given x with current parameters @@ -25,5 +27,5 @@ class ABMPvalencePdfParam:public BasePdfParam{ // (Optional) //Initialize from a yaml node. Uses node[getName] as the basis // virtual void initFromYaml(YAML::Node value)override final; -}; + }; } diff --git a/pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc b/pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc index 7c307c4b3..2f95158a7 100644 --- a/pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc +++ b/pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc @@ -1,4 +1,4 @@ - + /* @file ABMPvalencePdfParam.cc @date 2019-02-25 @@ -9,18 +9,18 @@ #include "ABMPvalencePdfParam.h" namespace xfitter{ -//for dynamic loading -extern"C" ABMPvalencePdfParam*create(const char*name){ - return new ABMPvalencePdfParam(name); -} -// Main function to compute PDF -double ABMPvalencePdfParam::operator()(double x)const{ + //for dynamic loading + extern"C" ABMPvalencePdfParam*create(const char*name){ + return new ABMPvalencePdfParam(name); + } + // Main function to compute PDF + double ABMPvalencePdfParam::operator()(double x)const{ const int npar = getNPar(); if (npar<7) { return NAN; } - double power = (1 + *pars[3] * log(x)) * (*pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x); - double val = *pars[0] * pow(x, *pars[1]) * pow(1 - x, *pars[2]) * pow(x, power); - return val; -} + double power = (*pars[1] + *pars[4] * x + *pars[5] * x * x + *pars[6] * x * x * x) * (1 + *pars[3] * log(x)); + double val = *pars[0] * pow(1 - x, *pars[2]) * pow(x, power); + return val; + } } diff --git a/tools/AddPdfDecomp.py b/tools/AddPdfDecomp.py index 2b3d7a5f5..7f8c3c6cd 100644 --- a/tools/AddPdfDecomp.py +++ b/tools/AddPdfDecomp.py @@ -62,9 +62,6 @@ namespace xfitter {{ class {:s}PdfDecomposition : public BasePdfDecomposition {{ public: - /// Default constructor. - {:s}PdfDecomposition (); - /// Default constructor. Name is the PDF name {:s}PdfDecomposition (const char* inName); @@ -104,11 +101,6 @@ extern "C" {:s}PdfDecomposition* create(const char*name) {{ return new {:s}PdfDecomposition(name); }} - -// Constructor - {:s}PdfDecomposition::{:s}PdfDecomposition() : BasePdfDecomposition("{:s}") {{ -}} - // Constructor {:s}PdfDecomposition::{:s}PdfDecomposition(const char* inName) : BasePdfDecomposition(inName) {{ }} -- GitLab From 5bf2e0bffa5dfba03f4db6dad5e69d8a8064ae13 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Tue, 26 Feb 2019 15:39:07 +0100 Subject: [PATCH 40/81] fixed class name --- .../src/UvDvUbarDbarSSbarPdfDecomposition.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc index 5f858b7a5..b359cc147 100644 --- a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc +++ b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc @@ -24,7 +24,7 @@ namespace xfitter { UvDvUbarDbarSSbarPdfDecomposition::UvDvUbarDbarSSbarPdfDecomposition(const char* inName) : BasePdfDecomposition(inName) { } - const char*UvDvUbarDbarSSbarPdfDecomposition::getClassName()const{return"UvDvUbarDbarS";} + const char*UvDvUbarDbarSSbarPdfDecomposition::getClassName()const{return"UvDvUbarDbarSSbar";} // Init at start: void UvDvUbarDbarSSbarPdfDecomposition::atStart() { -- GitLab From ef5cd5de2438618f1f617956fa0597f5748f936a Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Wed, 27 Feb 2019 15:35:08 +0100 Subject: [PATCH 41/81] added missing makefiles --- pdfparams/ABMPgluonPdfParam/src/Makefile.am | 13 +++++++++++++ pdfparams/ABMPseaPdfParam/src/Makefile.am | 13 +++++++++++++ pdfparams/ABMPvalencePdfParam/src/Makefile.am | 13 +++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 pdfparams/ABMPgluonPdfParam/src/Makefile.am create mode 100644 pdfparams/ABMPseaPdfParam/src/Makefile.am create mode 100644 pdfparams/ABMPvalencePdfParam/src/Makefile.am diff --git a/pdfparams/ABMPgluonPdfParam/src/Makefile.am b/pdfparams/ABMPgluonPdfParam/src/Makefile.am new file mode 100644 index 000000000..5ec16aa2b --- /dev/null +++ b/pdfparams/ABMPgluonPdfParam/src/Makefile.am @@ -0,0 +1,13 @@ + +# Created by AddPdfParam.py on 2019-02-25 + +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated + +lib_LTLIBRARIES = libABMPgluonPdfParam_xfitter.la +libABMPgluonPdfParam_xfitter_la_SOURCES = ABMPgluonPdfParam.cc + +datadir = ${prefix}/yaml/pdfparams/ABMPgluon +data_DATA = ../yaml/parameters.yaml + +dist_noinst_HEADERS = ../include ../yaml +libABMPgluonPdfParam_xfitter_la_LDFLAGS=-lBasePdfParam_xfitter -L$(libdir) diff --git a/pdfparams/ABMPseaPdfParam/src/Makefile.am b/pdfparams/ABMPseaPdfParam/src/Makefile.am new file mode 100644 index 000000000..c961c1bff --- /dev/null +++ b/pdfparams/ABMPseaPdfParam/src/Makefile.am @@ -0,0 +1,13 @@ + +# Created by AddPdfParam.py on 2019-02-25 + +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated + +lib_LTLIBRARIES = libABMPseaPdfParam_xfitter.la +libABMPseaPdfParam_xfitter_la_SOURCES = ABMPseaPdfParam.cc + +datadir = ${prefix}/yaml/pdfparams/ABMPsea +data_DATA = ../yaml/parameters.yaml + +dist_noinst_HEADERS = ../include ../yaml +libABMPseaPdfParam_xfitter_la_LDFLAGS=-lBasePdfParam_xfitter -L$(libdir) diff --git a/pdfparams/ABMPvalencePdfParam/src/Makefile.am b/pdfparams/ABMPvalencePdfParam/src/Makefile.am new file mode 100644 index 000000000..25a884507 --- /dev/null +++ b/pdfparams/ABMPvalencePdfParam/src/Makefile.am @@ -0,0 +1,13 @@ + +# Created by AddPdfParam.py on 2019-02-25 + +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated + +lib_LTLIBRARIES = libABMPvalencePdfParam_xfitter.la +libABMPvalencePdfParam_xfitter_la_SOURCES = ABMPvalencePdfParam.cc + +datadir = ${prefix}/yaml/pdfparams/ABMPvalence +data_DATA = ../yaml/parameters.yaml + +dist_noinst_HEADERS = ../include ../yaml +libABMPvalencePdfParam_xfitter_la_LDFLAGS=-lBasePdfParam_xfitter -L$(libdir) -- GitLab From 57f670406a41355594ffeddbbd93ca8ac03c88ed Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Wed, 27 Feb 2019 15:47:59 +0100 Subject: [PATCH 42/81] added !empty! parameter files --- pdfparams/ABMPgluonPdfParam/yaml/parameters.yaml | 0 pdfparams/ABMPseaPdfParam/yaml/parameters.yaml | 0 pdfparams/ABMPvalencePdfParam/yaml/parameters.yaml | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 pdfparams/ABMPgluonPdfParam/yaml/parameters.yaml create mode 100644 pdfparams/ABMPseaPdfParam/yaml/parameters.yaml create mode 100644 pdfparams/ABMPvalencePdfParam/yaml/parameters.yaml diff --git a/pdfparams/ABMPgluonPdfParam/yaml/parameters.yaml b/pdfparams/ABMPgluonPdfParam/yaml/parameters.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/pdfparams/ABMPseaPdfParam/yaml/parameters.yaml b/pdfparams/ABMPseaPdfParam/yaml/parameters.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/pdfparams/ABMPvalencePdfParam/yaml/parameters.yaml b/pdfparams/ABMPvalencePdfParam/yaml/parameters.yaml new file mode 100644 index 000000000..e69de29bb -- GitLab From 1288eb5dc0b4511ed8d5bd4ce2fd795609be530e Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Wed, 27 Feb 2019 18:06:13 +0100 Subject: [PATCH 43/81] restored parametery.yaml with abmp16 settings (spoiled while doing tests) --- input_steering/parameters.yaml.abmp16 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/input_steering/parameters.yaml.abmp16 b/input_steering/parameters.yaml.abmp16 index a15f0f3f9..7b4bdd3d9 100644 --- a/input_steering/parameters.yaml.abmp16 +++ b/input_steering/parameters.yaml.abmp16 @@ -120,7 +120,15 @@ Parameterisations: DefaultDecomposition: proton Decompositions: proton: - class: TestD + #class: UvDvubardbars + class: UvDvUbarDbarSSbar + xuv: par_uv + xdv: par_dv + xubar: par_ubar + xdbar: par_dbar + xs: par_s + xsbar: par_sbar + xg: par_g DefaultEvolution: proton-QCDNUM #DefaultEvolution: proton-LHAPDF -- GitLab From 6fbf57f66a8e550173deeb8b43210e14ed63afd0 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 28 Feb 2019 17:06:21 +0100 Subject: [PATCH 44/81] fixed compilation errors (added cmath headers) --- pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc | 1 + pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc | 1 + pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc | 1 + 3 files changed, 3 insertions(+) diff --git a/pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc b/pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc index 4d1e3bc78..6715da106 100644 --- a/pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc +++ b/pdfparams/ABMPgluonPdfParam/src/ABMPgluonPdfParam.cc @@ -7,6 +7,7 @@ */ #include "ABMPgluonPdfParam.h" +#include <cmath> namespace xfitter{ //for dynamic loading diff --git a/pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc b/pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc index e37a1810b..574c0439d 100644 --- a/pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc +++ b/pdfparams/ABMPseaPdfParam/src/ABMPseaPdfParam.cc @@ -7,6 +7,7 @@ */ #include "ABMPseaPdfParam.h" +#include <cmath> namespace xfitter{ //for dynamic loading diff --git a/pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc b/pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc index 2f95158a7..10094d4ba 100644 --- a/pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc +++ b/pdfparams/ABMPvalencePdfParam/src/ABMPvalencePdfParam.cc @@ -7,6 +7,7 @@ */ #include "ABMPvalencePdfParam.h" +#include <cmath> namespace xfitter{ //for dynamic loading -- GitLab From 1a5ba94cf5d5c7191fd63981ef7ee1bbc0ee2837 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 14 Mar 2019 00:04:02 +0100 Subject: [PATCH 45/81] update to cbdiff reaction --- Makefile.am | 4 +- configure.ac | 2 +- .../BaseHVQMNR/include/ReactionBaseHVQMNR.h | 9 + reactions/Hathor/src/HathorPdfxFitter.cc | 8 + reactions/KMatrix/src/ReactionKMatrix.cc | 173 +++++++++--------- reactions/cbdiff/include/Reactioncbdiff.h | 1 + reactions/cbdiff/src/Reactioncbdiff.cc | 99 ++++++---- 7 files changed, 179 insertions(+), 117 deletions(-) diff --git a/Makefile.am b/Makefile.am index c5a418325..1ad1a75ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,11 +6,11 @@ SUBDIRS = minuit/src interfaces/src DY/src DIPOLE/src RT/src EW/src common commo genetic/mixmax_r004 genetic/src QEDevol/src \ include interfaces/include FastNLO/include FastNLO/include/fastnlotk DiffDIS/include \ DY/include tools/draw/include \ - pdf2yaml tools/process reactions/cbdiff/src reactions/KRunning/src \ + pdf2yaml tools/process reactions/KRunning/src \ reactions/AFB/src \ reactions/KFactor/src reactions/Fractal_DISNC/src reactions/BaseDISCC/src reactions/Hathor/src reactions/BaseDISNC/src \ reactions/RT_DISNC/src reactions/FFABM_DISNC/src reactions/FFABM_DISCC/src reactions/APPLgrid/src reactions/BaseHVQMNR/src \ - reactions/HVQMNR_LHCb_7TeV_beauty/src reactions/HVQMNR_LHCb_7TeV_charm/src reactions/testZMVFNS/src reactions/fastNLO/src/ \ + reactions/HVQMNR_LHCb_7TeV_beauty/src reactions/HVQMNR_LHCb_7TeV_charm/src reactions/cbdiff/src reactions/testZMVFNS/src reactions/fastNLO/src/ \ reactions/FONLL_DISCC/src reactions/FONLL_DISNC/src reactions/KMatrix/src DIST_SUBDIRS = $(SUBDIRS) Hathor/src HVQMNR/src doc/tex/manual ACOT SACOT datafiles QEDevol/include \ diff --git a/configure.ac b/configure.ac index 5d4cacaf9..3758920d5 100644 --- a/configure.ac +++ b/configure.ac @@ -562,7 +562,6 @@ AC_CONFIG_FILES([include/Makefile examples/Makefile python/Makefile xfitter-config - reactions/cbdiff/src/Makefile reactions/KRunning/src/Makefile reactions/AFB/src/Makefile reactions/KFactor/src/Makefile @@ -577,6 +576,7 @@ AC_CONFIG_FILES([include/Makefile reactions/BaseHVQMNR/src/Makefile reactions/HVQMNR_LHCb_7TeV_beauty/src/Makefile reactions/HVQMNR_LHCb_7TeV_charm/src/Makefile + reactions/cbdiff/src/Makefile reactions/testZMVFNS/src/Makefile reactions/fastNLO/src/Makefile reactions/FONLL_DISCC/src/Makefile diff --git a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h index 827782f3e..5004b359e 100644 --- a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h +++ b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h @@ -62,6 +62,10 @@ class ReactionBaseHVQMNR : public ReactionTheory // heavy-quark masses double mc = 0.0; double mb = 0.0; + // flavour (used by cbdiff reaction) + char flav; + // flag that mass is taken from global parameters and should be updated at each iteration + bool flagMassIsGlobal = false; // scale parameters double mf_A_c = 0.0; double mf_B_c = 0.0; @@ -78,6 +82,10 @@ class ReactionBaseHVQMNR : public ReactionTheory // fragmentation parameters double fragpar_c = 0.0; double fragpar_b = 0.0; + // divide by bin width + bool flagDivideBinWidth = false; + // verbose output for debugging + bool debug = false; }; // structure to store steering parameters @@ -101,6 +109,7 @@ class ReactionBaseHVQMNR : public ReactionTheory double mf2max; bool q; bool a; + char flav; // c, b or t }; // all datasets diff --git a/reactions/Hathor/src/HathorPdfxFitter.cc b/reactions/Hathor/src/HathorPdfxFitter.cc index 58b83c252..13ff51fb5 100644 --- a/reactions/Hathor/src/HathorPdfxFitter.cc +++ b/reactions/Hathor/src/HathorPdfxFitter.cc @@ -15,6 +15,14 @@ HathorPdfxFitter::HathorPdfxFitter(ReactionHathor *ptrReactionTheory) void HathorPdfxFitter::GetPdf(double x, double muf, double h[13]) { + /*static double xmin = 1.0; + static double xmax = 0.0; + if(x < xmin) + xmin = x; + if(x > xmax) + xmax = x; + printf("HATHORGetPdf x = %f [%12.8f%12.8f]\n", x, xmin, xmax);*/ + if(!IsValid) return; diff --git a/reactions/KMatrix/src/ReactionKMatrix.cc b/reactions/KMatrix/src/ReactionKMatrix.cc index 35eb3bac4..55fd8dcbc 100644 --- a/reactions/KMatrix/src/ReactionKMatrix.cc +++ b/reactions/KMatrix/src/ReactionKMatrix.cc @@ -1,4 +1,4 @@ - + /* @file ReactionKMatrix.cc @date 2018-08-03 @@ -26,97 +26,104 @@ int ReactionKMatrix::initAtStart(const string &s) // Initialisze for a given dataset: void ReactionKMatrix::setDatasetParameters(int dataSetID, map<string,string> pars, map<string, double> parsDataset){ - std::vector<double> temp; - double var; - // check if KMatrixs should be read from separate file - if (pars.find("FileName") != pars.end()) + std::vector<double> temp; + double var; + // check if KMatrixs should be read from separate file + if (pars.find("FileName") != pars.end()) + { + // file name to read KMatrixs + std::string fileName = pars["FileName"]; + + // TODO: how to get number of data points? + // not very elegant way below + int np = _dsBins[dataSetID]->begin()->second.size(); + + // requested starting column from file (by default 1st) + int column_start = 1; + if(pars.find("FileColumnStart") != pars.end()){ + column_start = atoi(pars["FileColumnStart"].c_str()); + } + // requested finishing column from file (by default 1st) + int column_finish = np; + if(pars.find("FileColumnFinish") != pars.end()){ + column_finish = atoi(pars["FileColumnFinish"].c_str()); + } + + // check that the column is reasonable + if(column_start < 1){ + hf_errlog(18080700, "F: wrong starting column = " + std::to_string(column_start)); + } + if(column_start > column_finish){ + hf_errlog(18080701, "F: starting column greater than finishing column "); + } + + // requested starting line from file (by default 1st) and last line (by default last line) + int lineStart = 1; + if(pars.find("FileLineStart") != pars.end()) + lineStart = atoi(pars["FileLineStart"].c_str()); + int lineFinish = -1; + if(pars.find("FileLineFinish") != pars.end()) + lineFinish = atoi(pars["FileLineFinish"].c_str()); + + // open file + std::ifstream file(fileName.c_str()); + string line; + if (!file.is_open()){ + hf_errlog(18080702, "F: error opening KMatrix file = " + fileName); + } + + // skip lineStart lines + int readLines = 0; + for(int l = 1; l < lineStart; l++){ + readLines++; + getline(file, line); + } + + while(getline(file,line)) { - // file name to read KMatrixs - std::string fileName = pars["FileName"]; - - // TODO: how to get number of data points? - // not very elegant way below - int np = _dsBins[dataSetID]->begin()->second.size(); - - // requested starting column from file (by default 1st) - int column_start = 1; - if(pars.find("FileColumnStart") != pars.end()){ - column_start = atoi(pars["FileColumnStart"].c_str()); - } - // requested finishing column from file (by default 1st) - int column_finish = np; - if(pars.find("FileColumnFinish") != pars.end()){ - column_finish = atoi(pars["FileColumnFinish"].c_str()); + readLines++; + if(lineFinish != -1 && readLines > lineFinish) + break; + if(line.at(0) == '#') continue; //ignore comments + line.erase(line.find_last_not_of(" \n\r\t")+1); // trim trailing whitespaces + + std::stringstream sline(line); + + int current_col = 1; + while(sline.good()){ + sline >> var; + if(current_col >= column_start && current_col <= column_finish){ //Only using range between spezified columns + temp.push_back(var); + } + current_col++; } - - // check that the column is reasonable - if(column_start < 1){ - hf_errlog(18080700, "F: wrong starting column = " + std::to_string(column_start)); - } - if(column_start > column_finish){ - hf_errlog(18080701, "F: starting column greater than finishing column "); - } - - // requested starting line from file (by default 1st) - int lineStart = 1; - if(pars.find("FileLine") != pars.end()){ - lineStart = atoi(pars["FileLine"].c_str()); + _values2D[dataSetID].push_back(temp); + temp.clear(); + sline.clear(); + + } + file.close(); + + //mapping 2d matrix (m x n) to 1d vector (m*n): list of column vectors, mapping with vec(i*n + j) = mat(j,i) + int m = _values2D[dataSetID].size(); + int n = _values2D[dataSetID].at(0).size(); + _values[dataSetID].resize(n*m); + for(int i = 0; i < m; i++){ + for(int j = 0; j < n; j++){ + _values[dataSetID].at(i*n+j)=_values2D[dataSetID].at(i).at(j); } - - // open file - std::ifstream file(fileName.c_str()); - string line; - if (!file.is_open()){ - hf_errlog(18080702, "F: error opening KMatrix file = " + fileName); - } - - // skip lineStart lines - for(int l = 1; l < lineStart; l++){ - getline(file, line); - } - - while(getline(file,line)) - { - if(line.at(0) == '#') continue; //ignore comments - line.erase(line.find_last_not_of(" \n\r\t")+1); // trim trailing whitespaces - - std::stringstream sline(line); - - int current_col = 1; - while(sline.good()){ - sline >> var; - if(current_col >= column_start && current_col <= column_finish){ //Only using range between spezified columns - temp.push_back(var); - } - current_col++; - } - _values2D[dataSetID].push_back(temp); - temp.clear(); - sline.clear(); - - } - file.close(); - - //mapping 2d matrix (m x n) to 1d vector (m*n): list of column vectors, mapping with vec(i*n + j) = mat(j,i) - int m = _values2D[dataSetID].size(); - int n = _values2D[dataSetID].at(0).size(); - _values[dataSetID].resize(n*m); - for(int i = 0; i < m; i++){ - for(int j = 0; j < n; j++){ - _values[dataSetID].at(i*n+j)=_values2D[dataSetID].at(i).at(j); - } - } - }else{ - hf_errlog(18080703, "F: FileName must be provided for KMatrix"); + } + }else{ + hf_errlog(18080703, "F: FileName must be provided for KMatrix"); } } // Main function to compute results at an iteration int ReactionKMatrix::compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err) { - // kmatrix is constant value read in setDatasetParameters() - val = std::valarray<double>(_values[dataSetID].data(), _values[dataSetID].size()); + // kmatrix is constant value read in setDatasetParameters() + val = std::valarray<double>(_values[dataSetID].data(), _values[dataSetID].size()); - return 0; + return 0; } diff --git a/reactions/cbdiff/include/Reactioncbdiff.h b/reactions/cbdiff/include/Reactioncbdiff.h index 765a86204..8bab374bf 100644 --- a/reactions/cbdiff/include/Reactioncbdiff.h +++ b/reactions/cbdiff/include/Reactioncbdiff.h @@ -47,5 +47,6 @@ class Reactioncbdiff : public ReactionBaseHVQMNR std::map<int, std::shared_ptr<Parameters> > _mapPar; std::map<int, std::vector<TH2D*> > _mapXSec; std::map<int, double> _mapFF; + std::map<int, int> _mapN; }; diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index 8903c94e0..ac1d3b652 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -47,6 +47,11 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars std::shared_ptr<Parameters>& par = _mapPar[dataSetID]; par = std::shared_ptr<Parameters>(new Parameters); + // Flavour + if(checkParam("flav") || pars.find("flav") != pars.end()) + par->flav = GetParamSInPriority("flav", pars).c_str()[0]; + else + par->flav = 'c'; // Order std::string order = GetParamSInPriority("Order", pars); MNR::MNRContribution contrNLO = 11111; // NLO @@ -62,9 +67,20 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars MNR::MNRContribution** ptrContrLO = new MNR::MNRContribution*[ncontr]; ptrContrLO[0] = new MNR::MNRContribution(contrLO); // HQ masses - par->mc = GetParamInPriority("mq", pars); + if(checkParam("mq") || pars.find("mq") != pars.end()) + par->mc = GetParamInPriority("mq", pars); + else + { + par->flagMassIsGlobal = true; + if(par->flav == 'c') + par->mc = GetParam("mch"); + else if(par->flav == 'b') + par->mc = GetParam("mbt"); + else if(par->flav == 't') + par->mc = GetParam("mtp"); + } _mapMassDiff[dataSetID] = 0.001; // for MSbar mass transformation; 1 MeV should work for c, b and t - //_mapMassDiff[dataSetID] = 0.150; // for MSbar mass transformation; 1 MeV should work for c, b and t + //_mapMassDiff[dataSetID] = 0.150; // scale parameters //GetMuPar('f', 'q', par->mf_A_c, par->mf_B_c, par->mf_C_c, pars); //GetMuPar('r', 'q', par->mr_A_c, par->mr_B_c, par->mr_C_c, pars); @@ -79,6 +95,12 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars _mapMSbarMass[dataSetID] = 0; if(checkParamInPriority("MS_MASS", pars)) _mapMSbarMass[dataSetID] = GetParamInPriority("MS_MASS", pars); + // divide or not by bin width + if(checkParam("dividebw") || pars.find("dividebw") != pars.end()) + par->flagDivideBinWidth = GetParamIInPriority("dividebw", pars); + // debug mode + if(checkParam("debug") || pars.find("debug") != pars.end()) + par->debug = GetParamIInPriority("debug", pars); std::shared_ptr<MNR::MNR>& mnr = _mapMNR[dataSetID]; mnr = std::shared_ptr<MNR::MNR>(new MNR::MNR(this)); @@ -110,8 +132,6 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars DefaultInitGrid(steer, par->mc, steer.npt, *grid.get()); DefaultInitGrid(steer, par->mc, steer.npt, *gridLOMassUp.get()); DefaultInitGrid(steer, par->mc, steer.npt, *gridLOMassDown.get()); - //DefaultInitGrid(steer, par->mc + _mapMassDiff[dataSetID], steer.npt, *gridLOMassUp.get()); - //DefaultInitGrid(steer, par->mc - _mapMassDiff[dataSetID], steer.npt, *gridLOMassDown.get()); DefaultInitGrid(steer, par->mc, steer.nptsm, *gridSm.get()); DefaultInitGrid(steer, par->mc, steer.nptsm, *gridSmLOMassUp.get()); DefaultInitGrid(steer, par->mc, steer.nptsm, *gridSmLOMassDown.get()); @@ -126,7 +146,8 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars } else { - frag->AddOut(MNR::Frag::GetFragFunction(0, finalState.c_str(), par->fragpar_c), MNR::Frag::GetHadronMass(finalState.c_str())); + int fragType = 0; // Kartvelishvili + frag->AddOut(MNR::Frag::GetFragFunction(fragType, finalState.c_str(), par->fragpar_c), MNR::Frag::GetHadronMass(finalState.c_str())); frag->GetFF(0)->SetParameter(1, par->fragpar_c); } _mapFF[dataSetID] = stod(pars["FragFrac"]); @@ -175,12 +196,9 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars hf_errlog(19021901, "F: no y binning provided"); xsec[i]->SetBins(binsPt.size() - 1, &binsPt[0], binsY.size() - 1, &binsY[0]); } - - // test - //mnr.get()->CalcXS(grid.get(), par->mc); - //MNR::Grid::InterpolateGrid(gridSm.get(), gridSm.get(), par->mc); - //frag->CalcCS(gridSm.get(), par->mc, xsec); - //xsec[0]->Print("all"); + _mapN[dataSetID] = 1; + if(pars.find("N") != pars.end()) + _mapN[dataSetID] = stod(pars["N"]); } // Initialize at the start of the computation @@ -205,13 +223,23 @@ int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, va std::shared_ptr<MNR::Frag> frag(_mapFrag[dataSetID]); std::vector<TH2D*> xsec(_mapXSec[dataSetID]); + // update mass which may be fitted (scales or frag. par. cannot be fitted with this implementation) + if(par->flagMassIsGlobal) + { + if(par->flav == 'c') + par->mc = GetParam("mch"); + else if(par->flav == 'b') + par->mc = GetParam("mbt"); + else if(par->flav == 't') + par->mc = GetParam("mtp"); + } + mnr->CalcXS(grid.get(), par->mc); - //MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); // tarnsformation to MSbar mass scheme if(_mapMSbarMass[dataSetID]) { - // store original scale B parameters which need to be modify for changed mass + // store original scale B parameters which need to be modified for changed mass const double mfB = mnr->fMf_B; const double mrB = mnr->fMr_B; @@ -221,9 +249,6 @@ int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, va mnr->fMr_B = mrB * pow(par->mc / massU, 2.0); std::shared_ptr<MNR::Grid> gridLOMassU(_mapGridLOMassUp[dataSetID]); mnr->CalcXS(gridLOMassU.get(), massU); - //std::shared_ptr<MNR::Grid> gridSmLOMassU(_mapGridSmLOMassUp[dataSetID]); - //MNR::Grid::InterpolateGrid(gridLOMassU.get(), gridSmLOMassU.get(), massU); - //MNR::Grid::InterpolateGrid(gridLOMassU.get(), gridSmLOMassU.get(), par->mc); // LO mass down variation double massD = par->mc - _mapMassDiff[dataSetID]; @@ -231,13 +256,6 @@ int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, va mnr->fMr_B = mrB * pow(par->mc / massD, 2.0); std::shared_ptr<MNR::Grid> gridLOMassD(_mapGridLOMassDown[dataSetID]); mnr->CalcXS(gridLOMassD.get(), massD); - //std::shared_ptr<MNR::Grid> gridSmLOMassD(_mapGridSmLOMassDown[dataSetID]); - //MNR::Grid::InterpolateGrid(gridLOMassD.get(), gridSmLOMassD.get(), massD); - //MNR::Grid::InterpolateGrid(gridLOMassD.get(), gridSmLOMassD.get(), par->mc); - - // scheme transformation - //MNR::Grid::TransformGridToMSbarMassScheme(grid.get(), gridLOMassU.get(), gridLOMassD.get(), par->mc, _mapMassDiff[dataSetID]); - //MNR::Grid::TransformGridToMSbarMassScheme(gridSm.get(), gridSmLOMassU.get(), gridSmLOMassD.get(), par->mc, _mapMassDiff[dataSetID]); // restore original scales mnr->fMf_B = mfB; @@ -245,28 +263,47 @@ int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, va int flagMSbarTransformation = 0; // d1=4/3 (no ln) MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc, gridLOMassU.get(), massU, gridLOMassD.get(), massD, flagMSbarTransformation); - //MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); } else MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); - //MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); frag->CalcCS(gridSm.get(), par->mc, xsec); - //xsec[0]->Print("all"); + if(par->debug) + xsec[0]->Print("all"); DataSet& ds = _dataSets[dataSetID]; + val.resize(xsec[0]->GetNbinsX() * xsec[0]->GetNbinsY() * _mapN[dataSetID]); if (ds.BinsYMin == NULL || ds.BinsYMax == NULL || ds.BinsPtMin == NULL || ds.BinsPtMax == NULL ) { - // fill results array with cross sections bin by bin - int nbx = xsec[0]->GetNbinsX(); - for(size_t i = 0; i < val.size(); i++) - val[i] = xsec[0]->GetBinContent((i % nbx) + 1, (i / nbx) + 1) * _mapFF[dataSetID]; + // fill results array with cross sections bin by bin, optionally repeat N times + for(int in = 0; in < _mapN[dataSetID]; in++) + { + for(int ix = 1; ix <= xsec[0]->GetNbinsX(); ix++) + for(int iy = 1; iy <= xsec[0]->GetNbinsY(); iy++) + { + int ival = (ix - 1) * xsec[0]->GetNbinsY() + iy - 1 + in * xsec[0]->GetNbinsX() * xsec[0]->GetNbinsY(); + val[ival] = xsec[0]->GetBinContent(ix, iy) * _mapFF[dataSetID]; + if(par->flagDivideBinWidth) + { + val[ival] /= xsec[0]->GetXaxis()->GetBinWidth(ix); + val[ival] /= xsec[0]->GetYaxis()->GetBinWidth(iy); + } + } + } } else { // fill results array with cross sections by matching bins + // make sure number of bins is consistent + if(ds.BinsYMin->size() > (size_t)(xsec[0]->GetNbinsX() * xsec[0]->GetNbinsY())) + hf_errlog(19021900, "F: inconsistent number of bins"); for(unsigned int i = 0; i < ds.BinsYMin->size(); i++) - val[i] = FindXSecPtYBin(xsec[0], (*ds.BinsYMin)[i], (*ds.BinsYMax)[i], (*ds.BinsPtMin)[i], (*ds.BinsPtMax)[i], false, false) * _mapFF[dataSetID]; + val[i] = FindXSecPtYBin(xsec[0], (*ds.BinsYMin)[i], (*ds.BinsYMax)[i], (*ds.BinsPtMin)[i], (*ds.BinsPtMax)[i], par->flagDivideBinWidth, par->flagDivideBinWidth) * _mapFF[dataSetID]; + } + if(par->debug) + { + for(size_t i = 0; i < val.size(); i++) + printf("val[%lu] = %f\n", i, val[i]); } return 0; -- GitLab From 33a2eefb286d2ea1de0b32e946a60d30ff8ad90c Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 14 Mar 2019 00:04:27 +0100 Subject: [PATCH 46/81] increased expression capacity --- include/theorexpr.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/theorexpr.inc b/include/theorexpr.inc index a257c457e..96d8f769d 100644 --- a/include/theorexpr.inc +++ b/include/theorexpr.inc @@ -8,7 +8,7 @@ C> Common block for theory expression character*80 TermType(NTermsMax) character*4096 TermInfo(NTermsMax) character*256 TermSource(NTermsMax) - character*1000 TheorExpr + character*10000 TheorExpr integer ppbar_collisions integer normalised integer murdef -- GitLab From 2ecb68066f711347bcb490140cf0e8ada90700c3 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 14 Mar 2019 00:04:50 +0100 Subject: [PATCH 47/81] increased expression capacity --- src/ftheor_eval.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ftheor_eval.cc b/src/ftheor_eval.cc index c8688ea6a..32f97079f 100644 --- a/src/ftheor_eval.cc +++ b/src/ftheor_eval.cc @@ -67,7 +67,7 @@ extern struct thexpr_cb { char termtype[NTERMMAX][80]; char terminfo[NTERMMAX][4096]; char termsource[NTERMMAX][256]; - char theorexpr[1000]; + char theorexpr[10000]; int ppbar_collisions; int normalised; int murdef; -- GitLab From a9f11d64c16fae26ae494761fb6494834373108a Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 14 Mar 2019 00:05:50 +0100 Subject: [PATCH 48/81] support for plotting up to 12 output directories --- tools/draw/include/CommandParser.h | 12 ++++++++---- tools/draw/src/CommandParser.cc | 28 +++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/tools/draw/include/CommandParser.h b/tools/draw/include/CommandParser.h index bead931cf..a0b66059d 100644 --- a/tools/draw/include/CommandParser.h +++ b/tools/draw/include/CommandParser.h @@ -67,10 +67,14 @@ class CommandParser map <string, int> styles; map <string, int> lstyles; map <string, int> markers; - int col[6]; - int styl[6]; - int lstyl[6]; - int mark[6]; + //int col[6]; + //int styl[6]; + //int lstyl[6]; + //int mark[6]; + int col[12]; + int styl[12]; + int lstyl[12]; + int mark[12]; float lwidth; float resolution, pagewidth; bool nodata; diff --git a/tools/draw/src/CommandParser.cc b/tools/draw/src/CommandParser.cc index 1380ea838..80c09ee25 100644 --- a/tools/draw/src/CommandParser.cc +++ b/tools/draw/src/CommandParser.cc @@ -78,12 +78,29 @@ CommandParser::CommandParser(int argc, char **argv): outdir("") { //initialise colors and styles - col[0] = kRed + 2; + /*col[0] = kRed + 2; col[1] = kBlue + 2; col[2] = kGreen + 3; col[3] = kOrange + 7; col[4] = kAzure + 1; - col[5] = kMagenta + 1; + col[5] = kMagenta + 1;*/ + + //static int cols[NCOLSXYZ] = {kBlack, kBlue, kRed, kMagenta, kGreen + 2, kYellow + 1, kAzure + 4, kSpring + 4, kOrange + 2, kRed - 7, kBlue - 9, kRed + 3, kViolet - 7}; + col[0] = kRed + 2; + col[1] = kBlue + 2; + //col[0] = kBlack; + //col[1] = kBlue; + //col[2] = kRed; + col[2] = kMagenta; + col[3] = kGreen + 2; + col[4] = kYellow + 1; + col[5] = kAzure + 4; + col[6] = kOrange + 2; + col[7] = kRed - 7; + col[8] = kBlue - 9; + col[9] = kRed + 3; + col[10] = kViolet - 7; + col[11] = kBlue - 2; styl[0] = 3354; styl[1] = 3345; @@ -98,6 +115,8 @@ CommandParser::CommandParser(int argc, char **argv): mark[3] = 32; mark[4] = 31; mark[5] = 27; + //for(int i = 6; i < 12; i++) + // mark[i] = 27; lstyl[0] = 1; lstyl[1] = 2; @@ -105,6 +124,8 @@ CommandParser::CommandParser(int argc, char **argv): lstyl[3] = 4; lstyl[4] = 5; lstyl[5] = 6; + //for(int i = 6; i < 12; i++) + // lstyl[i] = 6; // tight MC replica selection by default: looseRepSelection = false; @@ -473,7 +494,8 @@ CommandParser::CommandParser(int argc, char **argv): exit(-1); } - if (dirs.size() > 6) + //if (dirs.size() > 6) + if (dirs.size() > 12) { cout << endl; cout << "Maximum number of directories is 6" << endl; -- GitLab From 93eab3eeb0d8518259afe3c2befa9e01799fe138 Mon Sep 17 00:00:00 2001 From: Daniel Britzger <daniel.britzger@cern.ch> Date: Thu, 14 Mar 2019 13:53:45 +0000 Subject: [PATCH 49/81] remove not needed typedef, which causes naming ambiguity with ROOT TError.h (Info) --- tools/process/rootplot.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/process/rootplot.cc b/tools/process/rootplot.cc index 5cc590b94..8d6720207 100644 --- a/tools/process/rootplot.cc +++ b/tools/process/rootplot.cc @@ -1,7 +1,9 @@ #include <TH1F.h> #include <TCanvas.h> #include <stdlib.h> +#define Info xfitter_Info #include "utils.h" +#undef Info #include <string.h> #include <libgen.h> #include <iostream> -- GitLab From a1a0d54974937da985d94bebc3aceefe3781e653 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 14 Mar 2019 15:44:22 +0100 Subject: [PATCH 50/81] fixed bin order --- reactions/cbdiff/src/Reactioncbdiff.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index ac1d3b652..465ca8425 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -279,9 +279,11 @@ int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, va for(int in = 0; in < _mapN[dataSetID]; in++) { for(int ix = 1; ix <= xsec[0]->GetNbinsX(); ix++) + { for(int iy = 1; iy <= xsec[0]->GetNbinsY(); iy++) { - int ival = (ix - 1) * xsec[0]->GetNbinsY() + iy - 1 + in * xsec[0]->GetNbinsX() * xsec[0]->GetNbinsY(); + //int ival = (ix - 1) * xsec[0]->GetNbinsY() + iy - 1 + in * xsec[0]->GetNbinsX() * xsec[0]->GetNbinsY(); + int ival = (iy - 1) * xsec[0]->GetNbinsX() + ix - 1 + in * xsec[0]->GetNbinsX() * xsec[0]->GetNbinsY(); val[ival] = xsec[0]->GetBinContent(ix, iy) * _mapFF[dataSetID]; if(par->flagDivideBinWidth) { @@ -289,6 +291,7 @@ int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, va val[ival] /= xsec[0]->GetYaxis()->GetBinWidth(iy); } } + } } } else -- GitLab From 4e0ca3a25c10ee113588f8888e84066eafebf383 Mon Sep 17 00:00:00 2001 From: Igor Pelevanyuk <igor.pelevanyuk@cern.ch> Date: Tue, 19 Mar 2019 12:00:42 +0300 Subject: [PATCH 51/81] DevOps: Try to fix CI integration (rpmdb checksum mismatch error) --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4e3b07ea8..03cd55224 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,8 @@ stages: - nightly before_script: - - yum -y install yaml-cpp-devel libyaml-devel + - yum -y install yum-plugin-ovl + - yum -y install yaml-cpp-devel libyaml-devel - . ./scripts/setup.sh - ./scripts/install-deps.sh -- GitLab From bb22a7d39c698d8068d8dc422da874888ac910cb Mon Sep 17 00:00:00 2001 From: Sasha Glazov <glazov@mail.desy.de> Date: Tue, 19 Mar 2019 13:46:10 +0100 Subject: [PATCH 52/81] Add which back --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 03cd55224..91b5ab88a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ stages: before_script: - yum -y install yum-plugin-ovl - - yum -y install yaml-cpp-devel libyaml-devel + - yum -y install which yaml-cpp-devel libyaml-devel - . ./scripts/setup.sh - ./scripts/install-deps.sh -- GitLab From d9800f6b38d5362ec8f2bf1ef5866fa22081572a Mon Sep 17 00:00:00 2001 From: Sasha Glazov <glazov@mail.desy.de> Date: Tue, 19 Mar 2019 14:20:20 +0100 Subject: [PATCH 53/81] add gsl-devel again --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 91b5ab88a..c360eb4d5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ stages: before_script: - yum -y install yum-plugin-ovl - - yum -y install which yaml-cpp-devel libyaml-devel + - yum -y install which yaml-cpp-devel libyaml-devel gsl-devel - . ./scripts/setup.sh - ./scripts/install-deps.sh -- GitLab From ed00f71df07ced5d2775db618742f8d88c91f798 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Wed, 20 Mar 2019 17:02:12 +0300 Subject: [PATCH 54/81] attempt to fix compilation error --- src/CheckForPDF.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CheckForPDF.cxx b/src/CheckForPDF.cxx index 475ba6069..d76a97e4c 100644 --- a/src/CheckForPDF.cxx +++ b/src/CheckForPDF.cxx @@ -2,6 +2,7 @@ #include "LHAPDF/Paths.h" #include <iostream> #include <algorithm> +#include <cstring> -- GitLab From 71c81890184f684c185e130d8ea988ddb0662b2b Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Tue, 26 Mar 2019 17:14:50 +0100 Subject: [PATCH 55/81] implemented variable precision --- reactions/cbdiff/include/Reactioncbdiff.h | 1 + reactions/cbdiff/src/Reactioncbdiff.cc | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/reactions/cbdiff/include/Reactioncbdiff.h b/reactions/cbdiff/include/Reactioncbdiff.h index 8bab374bf..302aa34fe 100644 --- a/reactions/cbdiff/include/Reactioncbdiff.h +++ b/reactions/cbdiff/include/Reactioncbdiff.h @@ -48,5 +48,6 @@ class Reactioncbdiff : public ReactionBaseHVQMNR std::map<int, std::vector<TH2D*> > _mapXSec; std::map<int, double> _mapFF; std::map<int, int> _mapN; + std::map<int, double> _mapPrecision; }; diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index 465ca8425..0cce05a14 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -45,6 +45,26 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars steer.mf2min = GetParamInPriority("steer_mf2min", pars); steer.mf2max = GetParamInPriority("steer_mf2max", pars); + // precision: 1.0 is default + _mapPrecision[dataSetID] = 1.0; + printf("precision: %f\n", GetParamInPriority("precision", pars)); + if(pars.find("precision") != pars.end() || checkParam("precision")) + { + printf("in if\n"); + _mapPrecision[dataSetID] = GetParamInPriority("precision", pars); + if(_mapPrecision[dataSetID] != 1.0) + { + printf("Using precision factor %f\n", _mapPrecision[dataSetID]); + steer.npt *= _mapPrecision[dataSetID]; + steer.nptsm *= _mapPrecision[dataSetID]; + steer.ny *= _mapPrecision[dataSetID]; + steer.nsfnb *= _mapPrecision[dataSetID]; + steer.nx3 *= _mapPrecision[dataSetID]; + steer.nx4 *= _mapPrecision[dataSetID]; + steer.nbz *= _mapPrecision[dataSetID]; + } + } + std::shared_ptr<Parameters>& par = _mapPar[dataSetID]; par = std::shared_ptr<Parameters>(new Parameters); // Flavour -- GitLab From 13e5f2ca449a5aa2d2fc1ee76369a0eac92242fe Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Tue, 26 Mar 2019 19:53:42 +0100 Subject: [PATCH 56/81] implemented hadron mass parameter --- reactions/cbdiff/include/Reactioncbdiff.h | 1 + reactions/cbdiff/src/Reactioncbdiff.cc | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/reactions/cbdiff/include/Reactioncbdiff.h b/reactions/cbdiff/include/Reactioncbdiff.h index 302aa34fe..0e2805e94 100644 --- a/reactions/cbdiff/include/Reactioncbdiff.h +++ b/reactions/cbdiff/include/Reactioncbdiff.h @@ -49,5 +49,6 @@ class Reactioncbdiff : public ReactionBaseHVQMNR std::map<int, double> _mapFF; std::map<int, int> _mapN; std::map<int, double> _mapPrecision; + std::map<int, double> _mapHadronMass; }; diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index 0cce05a14..9e39fa3ca 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -47,10 +47,8 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars // precision: 1.0 is default _mapPrecision[dataSetID] = 1.0; - printf("precision: %f\n", GetParamInPriority("precision", pars)); if(pars.find("precision") != pars.end() || checkParam("precision")) { - printf("in if\n"); _mapPrecision[dataSetID] = GetParamInPriority("precision", pars); if(_mapPrecision[dataSetID] != 1.0) { @@ -163,11 +161,20 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars if(finalState == "parton") { frag->AddOut(NULL, par->mc); + _mapHadronMass[dataSetID] = 0.0; // hadron mass is irrelevant } else { int fragType = 0; // Kartvelishvili - frag->AddOut(MNR::Frag::GetFragFunction(fragType, finalState.c_str(), par->fragpar_c), MNR::Frag::GetHadronMass(finalState.c_str())); + // read hadron mass (if <0 then PDG values are used) + _mapHadronMass[dataSetID] = -1.0; + if(pars.find("hadronMass") != pars.end() || checkParam("hadronMass")) + _mapHadronMass[dataSetID] = GetParamInPriority("hadronMass", pars); + if(_mapHadronMass[dataSetID] < 0.0) + _mapHadronMass[dataSetID] = MNR::Frag::GetHadronMass(finalState.c_str()); + //frag->AddOut(MNR::Frag::GetFragFunction(fragType, finalState.c_str(), par->fragpar_c), MNR::Frag::GetHadronMass(finalState.c_str())); + printf("MNRFrag: using Kartvelishvili function with par = %.1f and hadronMass = %.3f\n", par->fragpar_c, _mapHadronMass[dataSetID]); + frag->AddOut(MNR::Frag::GetFragFunction(fragType, finalState.c_str(), par->fragpar_c), _mapHadronMass[dataSetID]); frag->GetFF(0)->SetParameter(1, par->fragpar_c); } _mapFF[dataSetID] = stod(pars["FragFrac"]); -- GitLab From 1f52a35b34fe746835913a6a7e6fe88cfedc0950 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 28 Mar 2019 14:37:31 +0100 Subject: [PATCH 57/81] protection againsta nan masses --- reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc | 6 ++++++ reactions/cbdiff/src/Reactioncbdiff.cc | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc index 17dd02dd8..eb6d49246 100644 --- a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc +++ b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc @@ -345,6 +345,12 @@ void ReactionBaseHVQMNR::UpdateParameters() // fragmentation parameters _pars.fragpar_c = GetFragPar('c'); _pars.fragpar_b = GetFragPar('b'); + + // protection against nan + if(_pars.mc != _pars.mc) + _pars.mc = 1000.0; + if(_pars.mb != _pars.mb) + _pars.mb = 1000.0; } // print theory parameters diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index 9e39fa3ca..dfae579b6 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -261,6 +261,10 @@ int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, va par->mc = GetParam("mtp"); } + // protection against nan + if(par->mc != par->mc) + par->mc = 1000.0; // probably there are no heavy quarks for which mass of 1000 GeV would be reasonable + mnr->CalcXS(grid.get(), par->mc); // tarnsformation to MSbar mass scheme -- GitLab From 5b6ef80b346833027236deaae3245dbe298e7430 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Thu, 28 Mar 2019 14:43:39 +0100 Subject: [PATCH 58/81] protection against not positive masses --- reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc | 6 +++--- reactions/cbdiff/src/Reactioncbdiff.cc | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc index eb6d49246..3a31a37f6 100644 --- a/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc +++ b/reactions/BaseHVQMNR/src/ReactionBaseHVQMNR.cc @@ -346,10 +346,10 @@ void ReactionBaseHVQMNR::UpdateParameters() _pars.fragpar_c = GetFragPar('c'); _pars.fragpar_b = GetFragPar('b'); - // protection against nan - if(_pars.mc != _pars.mc) + // protection against not positive or nan masses + if(_pars.mc <= 0.0 || _pars.mc != _pars.mc) _pars.mc = 1000.0; - if(_pars.mb != _pars.mb) + if(_pars.mb <= 0.0 || _pars.mb != _pars.mb) _pars.mb = 1000.0; } diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index dfae579b6..d9c653352 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -261,8 +261,8 @@ int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, va par->mc = GetParam("mtp"); } - // protection against nan - if(par->mc != par->mc) + // protection against not positive or nan mass + if(par->mc < 0.0 || par->mc != par->mc) par->mc = 1000.0; // probably there are no heavy quarks for which mass of 1000 GeV would be reasonable mnr->CalcXS(grid.get(), par->mc); -- GitLab From a0928215a1036e8fa34783c8c0f4ca7c132e0a2f Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Fri, 29 Mar 2019 23:11:20 +0100 Subject: [PATCH 59/81] finished merging cbdiff into test_ceres + improvements for FF ABM (no usage of static lib) + FFNS in QCDNUM --- ABM/src/Makefile.am | 11 +- ABM/src/cq.f | 229 ------------------ ABM/src/sf_abkm_wrap.f | 7 + evolutions/QCDNUM/src/EvolutionQCDNUM.cc | 19 +- reactions/APPLgrid/include/ReactionAPPLgrid.h | 18 +- reactions/APPLgrid/src/ReactionAPPLgrid.cc | 16 +- reactions/BaseHVQMNR/src/Makefile.am | 1 + reactions/FFABM_DISCC/src/Makefile.am | 2 +- .../FFABM_DISCC/src/ReactionFFABM_DISCC.cc | 4 +- reactions/FFABM_DISNC/src/Makefile.am | 2 +- .../FFABM_DISNC/src/ReactionFFABM_DISNC.cc | 4 +- reactions/KRunning/include/ReactionKRunning.h | 2 +- reactions/KRunning/src/ReactionKRunning.cc | 2 +- reactions/cbdiff/include/Reactioncbdiff.h | 2 +- reactions/cbdiff/src/Reactioncbdiff.cc | 2 +- 15 files changed, 49 insertions(+), 272 deletions(-) delete mode 100644 ABM/src/cq.f diff --git a/ABM/src/Makefile.am b/ABM/src/Makefile.am index 762210d6a..6b42757c3 100644 --- a/ABM/src/Makefile.am +++ b/ABM/src/Makefile.am @@ -1,12 +1,5 @@ AUTOMAKE_OPTIONS = foreign -dist_noinst_HEADERS = APSCOM6. CONSTCOM. PDFCOM. PRECCOM. -# Force recompilation if include files are modified: -*.o: APSCOM6. CONSTCOM. PDFCOM. PRECCOM. +lib_LTLIBRARIES = libmyabm.la -noinst_LIBRARIES = libmyabm.a - -libmyabm_a_SOURCES = sf_abkm_wrap.f alphasvfn.f asympcoef.f cq.f dishq.f dislt.f disqpm.f f2ccbmsn.f gauss.f hqcoef.f hqnnlocoef.f lpcoef.f ome.f spline.f grid.F initgridconst.F asy-hpcc.f hplog.f split.f s2nlo.f -AM_FFLAGS = -I$(srcdir)/../../include $(NOAUTOFCFLAG) - -#AM_FFLAGS = -I$(srcdir)/../../include -fno-automatic -finit-local-zero -ffixed-line-length-132 +libmyabm_la_SOURCES = sf_abkm_wrap.f alphasvfn.f asympcoef.f dishq.f dislt.f disqpm.f f2ccbmsn.f gauss.f hqcoef.f hqnnlocoef.f lpcoef.f ome.f spline.f grid.F initgridconst.F asy-hpcc.f hplog.f split.f s2nlo.f diff --git a/ABM/src/cq.f b/ABM/src/cq.f deleted file mode 100644 index 93584192b..000000000 --- a/ABM/src/cq.f +++ /dev/null @@ -1,229 +0,0 @@ -c------------- - subroutine fillvfngrid - IMPLICIT DOUBLE PRECISION (A-H,O-Z) - - INCLUDE 'APSCOM6.' - INCLUDE 'CONSTCOM.' - INCLUDE 'PDFCOM.' - - common /forqgspl/ xb0,q2,xlog,an,an2,an3,kn,iqn,ixn,isn,ihqn - -! Set up the boundary conditions for the strong coupling evolution -! using the 3-flavour strong coupling at the scale of 4-flavour matching -! stored in the grid - alphas0=xqg(0,0.1d0,vfnth(4)**2,0) - q20alphas=vfnth(4)**2 - - do is=-nsmgrid,nspgrid -! Take the 3-flavour PDFs as an input for the matching conditions - isch0=0 -! filling the LO 4-flavour PDFs - isch1=-2 - Q2=0.04*exp(exp(sgrid(is,isch1))*log(q2ini(isch1)/0.04)) - AN=ALPHAS_ffn4(q2)/4./PI - an2=an**2 - call fillvfx(is,8,0,isch0,isch1) -! filling the NLO 4-flavour PDFs - if (kordhq.ge.1) then - isch1=-3 - call fillvfx(is,8,1,isch0,isch1) - end if -! Take the LO 4-flavour PDFs as an input for the matching conditions - isch0=-2 -! filling the LO 5-flavour PDFs - isch1=-4 - Q2=0.04*exp(exp(sgrid(is,isch1))*log(q2ini(isch1)/0.04)) - AN=ALPHAS_ffn5(q2)/4./PI - an2=an**2 - call fillvfx(is,10,0,isch0,isch1) - if (kordhq.ge.1) then -! Take the NLO 4-flavour PDFs as an input for the matching conditions - isch0=-3 -! filling the NLO 5-flavour PDFs - isch1=-5 - call fillvfx(is,10,1,isch0,isch1) - end if - end do - - return - end -c------------- - subroutine fillvfx(is,nhq,kome,isch0,isch1) - IMPLICIT DOUBLE PRECISION (A-H,O-Z) - - INCLUDE 'APSCOM6.' - INCLUDE 'CONSTCOM.' - INCLUDE 'PDFCOM.' - - common /forqgspl/ xb0,q2,xlog,an,an2,an3,kn,iqn,ixn,isn,ihqn - - real*8 fsp(nxtot),bs(nxtot),cs(nxtot),ds(nxtot),xx(nxtot) - - an2=an**2 - ischem=isch1 - - do ix=-nxmgrid,nxpgrid - xx(ix+nxmgrid+1)=xgrid(ix) - end do - - do IX=-nxmgrid,nxpgrid-1 -! FOPT matching - Y(ischem,0,IX,is)=an*4*pi - do iq=1,nhq - Y(ischem,iq,IX,is)=hqpdf(XGRID(IX),is,iq,nhq,kome,isch0) - end do - Y(ischem,nhq+1,IX,is)=Y(ischem,nhq,IX,is) - end do - Y(ischem,0,nxpgrid,is)=Y(ischem,0,nxpgrid-1,is) - - do iq=1,nhq+1 - Y(ischem,iq,nxpgrid,is)=0D0 - do ix=-nxmgrid,nxpgrid - fsp(ix+nxmgrid+1)=y(ischem,iq,ix,is) - end do - call spline (nxmgrid+nxpgrid+1,xx,fsp,bs,cs,ds) - do ix=-nxmgrid,nxpgrid - bcoeff(ischem,iq,ix,is)=bs(ix+nxmgrid+1) - ccoeff(ischem,iq,ix,is)=cs(ix+nxmgrid+1) - dcoeff(ischem,iq,ix,is)=ds(ix+nxmgrid+1) - end do - end do - - return - end -C------------------ - real*8 function hqpdf(xb,is,iq,ihq,kome,isch0) - IMPLICIT DOUBLE PRECISION (A-H,O-Z) - - INCLUDE 'APSCOM6.' - include 'CONSTCOM.' - include 'PRECCOM.' - - COMMON /FORQGSPL/ XB0,Q2,XLOG,AN,AN2,an3,kn,iqn,ixn,isn,ihqn - common /forhqpdf/ r,kome0 - real*8 q(nflim) - - external hqpdfi1,hqpdfi2 - - xb0=xb - iqn=iq - isn=is - ihqn=ihq - kn=isch0 - - kome0=kome - r=q2/rmass(ihq)**2 - - hqpdf=0. - -c Local terms for the gluon and quark pieces - - if (iq.eq.1) then - hqpdf=1 + an*ome_gg_1_local(xb,r) - if (kome.ge.1) hqpdf=hqpdf + an2*ome_gg_2_local(xb,r) - hqpdf=hqpdf*XQGX1(kn,1,XB,IS) - end if - - if (iq.ge.2.and.iq.le.ihq-1) then - hqpdf=1 - if (kome.ge.1) hqpdf=hqpdf + an2*ome_qqns_2_local(xb,r) - hqpdf=hqpdf*XQGX1(kn,iq,XB,IS) - end if - -c integration of the total regular term - - if (xb.ge.0.1) then - CALL GAUSS1(hqpdfi1 - , ,log(1d-8),log(1.-xb),nmthq,res,EPS) - else - CALL GAUSS1(hqpdfi1 - , ,log(1d-8),log(0.9d0),nmthq,df1,EPS1) - CALL GAUSS1(hqpdfi2,log(xb) - , ,log(0.1d0),nmthq,df2,EPS2) - res=df1+df2 - eps=sqrt(eps1**2+eps2**2) - end if - - hqpdf=hqpdf+res - - return - end -C------------------ - real*8 function hqpdfi1(t) - IMPLICIT DOUBLE PRECISION (A-H,O-Z) - - y=1.-exp(t) - - hqpdfi1=hqpdfi(y)*(1-y) - - return - end -C------------------ - real*8 function hqpdfi2(t) - IMPLICIT DOUBLE PRECISION (A-H,O-Z) - - y=exp(t) - - hqpdfi2=hqpdfi(y)*y - - return - end -C------------------ - real*8 function hqpdfi(z) - IMPLICIT DOUBLE PRECISION (A-H,O-Z) - - include 'CONSTCOM.' - real*8 q(13) - - common /forqgspl/ xb0,q2,xlog,an,an2,an3,kn,iqn,ixn,isn,ihqn - common /forhqpdf/ r,kome0 - - y=xb0/z - hqpdfi=0. - -c gluon distribution - - if (iqn.eq.1) then - if (kome0.ge.1) then - glu0=xqgx1(kn,1,xb0,isn) - glu=xqgx1(kn,1,y,isn) - hqpdfi=hqpdfi+ome_gg_2_singular(z,r)*(glu-glu0) - hqpdfi=hqpdfi+ome_gg_2(z,r)*glu - qps=0. - do k=2,ihqn-1 - qps=qps+xqgx1(kn,k,y,isn) - end do - hqpdfi=hqpdfi+ome_gq_2(z,r)*qps - hqpdfi=hqpdfi*an2 - end if - end if - -c light quark disributions - - if (iqn.ge.2.and.iqn.le.ihqn-1) then - if (kome0.ge.1) then - pdf0=xqgx1(kn,iqn,xb0,isn) - pdfc=xqgx1(kn,iqn,y,isn) - hqpdfi=hqpdfi+ome_qqns_2_singular(z,r)*(pdfc-pdf0) - hqpdfi=hqpdfi+ome_qqns_2(z,r)*pdfc - hqpdfi=hqpdfi*an2 - end if - end if - -c heavy quark distributions - - if (iqn.ge.ihqn) then - glu=xqgx1(kn,1,y,isn) - hqpdfi=hqpdfi+ome_g_1(z,r)*an*glu - if (kome0.ge.1) then - qps=0. - do k=2,ihqn-1 - qps=qps+xqgx1(kn,k,y,isn) - end do - hqpdfi=hqpdfi + an2*(ome_g_2(z,r)*glu + ome_q_2(z,r)*qps) - end if - hqpdfi=hqpdfi/2. - end if - - return - end diff --git a/ABM/src/sf_abkm_wrap.f b/ABM/src/sf_abkm_wrap.f index 06f38a0c1..f658a1505 100644 --- a/ABM/src/sf_abkm_wrap.f +++ b/ABM/src/sf_abkm_wrap.f @@ -25,6 +25,13 @@ C New user routines for PDFs and alpha_S have to be provided in this version RETURN END + + DOUBLE PRECISION FUNCTION DiLog(X) + double precision x + double precision ddilog + dilog = ddilog(x) + return + end subroutine sf_abkm_wrap(x,q2,f2abkm,flabkm,f3abkm,f2cabkm, diff --git a/evolutions/QCDNUM/src/EvolutionQCDNUM.cc b/evolutions/QCDNUM/src/EvolutionQCDNUM.cc index 3855a334d..1922dbeee 100644 --- a/evolutions/QCDNUM/src/EvolutionQCDNUM.cc +++ b/evolutions/QCDNUM/src/EvolutionQCDNUM.cc @@ -118,6 +118,7 @@ namespace xfitter QCDNUM::setord(PtOrder); std::cout << "Set evolution order "<<PtOrder <<"\n"; + std::cout << "xGrid[0]: " << xGrid[0] << std::endl; QCDNUM::gxmake(xGrid.data(),xGridW.data(),xGrid.size(),nxgrid,nxout,_splineOrder); // x-grid std::cout << "Requested (actual) number of x grid points: "<<nxgrid << "(" << nxout << ")\n"; @@ -164,8 +165,22 @@ namespace xfitter int iqb = QCDNUM::iqfrmq( (*mbt)*(*mbt) + 1.e-6 ); int iqt = 0; // top off for now - // For now VFNS only - QCDNUM::setcbt(0,iqc,iqb,iqt); + // For now VFNS only and NFlavour = 3 only + int nflavour = XFITTER_PARS::gParametersI.at("NFlavour"); + if(nflavour == 3) + { + std::cout << "Fixed Flavour Number Scheme set with nf=3" << std::endl; + QCDNUM::setcbt(3,iqc,iqb,iqt); + } + else if(nflavour == 5) + { + std::cout << "Variable Flavour Number Scheme set with nf=5" << std::endl; + QCDNUM::setcbt(0,iqc,iqb,iqt); + } + else + { + hf_errlog(280320191, "F: Unsupported NFlavour = " + std::to_string(nflavour)); + } // Init SF int id1=0; int id2=0; int nw=0; int ierr=1; diff --git a/reactions/APPLgrid/include/ReactionAPPLgrid.h b/reactions/APPLgrid/include/ReactionAPPLgrid.h index 05b63fed9..3de2f8be0 100644 --- a/reactions/APPLgrid/include/ReactionAPPLgrid.h +++ b/reactions/APPLgrid/include/ReactionAPPLgrid.h @@ -22,7 +22,8 @@ struct DatasetData{ double muR,muF; // !> renormalisation and factorisation scales bool flagNorm; // !> if true, multiply by bin width bool flagUseReference; // !> if true, prediction will be calculated from reference histogram (for tests and grids validation) - std::vector<TH1D*> references; + std::vector<TH1D*> references; // !> reference predictions + std::vector<int> emptyPoints; // !> optional numbers of empty points for manipulation with bins std::vector<double> eScale; // !> CMS energy double*scaleParameter=nullptr; // !> pointer to a minimization parameter which by which the predicted cross-section will be additionally multiplied. If this pointer is nullptr, no additional scaling is used. xfitter::BaseEvolution*evolutions[2]; @@ -36,21 +37,6 @@ class ReactionAPPLgrid : public ReactionTheory int atStart(const string &); virtual void setDatasetParameters( int dataSetID, map<string,string> pars, map<string,double> parsDataset) override ; virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err); - protected: - virtual int parseOptions(){ return 0;}; - - private: - enum class collision { pp, ppbar, pn}; - map<int, collision> _collType; - map<int, std::vector<std::shared_ptr<appl::grid> > > _grids; - map<int, std::vector<int> > _emptyPoints; - map<int, int> _order; - map<int, double> _muR, _muF; // !> renormalisation and factorisation scales - map<int, bool> _flagNorm; // !> if true, multiply by bin width - map<int, bool> _flagUseReference; // !> if true, prediction will be calculated from reference histogram (for tests and grids validation) - map<int, std::vector<TH1D*> > _references; - map<int, std::vector<double> > _eScale; // !> CMS energy - protected: virtual int parseOptions(){ return 0;}; private: diff --git a/reactions/APPLgrid/src/ReactionAPPLgrid.cc b/reactions/APPLgrid/src/ReactionAPPLgrid.cc index 65c758e18..dc7aba5c9 100644 --- a/reactions/APPLgrid/src/ReactionAPPLgrid.cc +++ b/reactions/APPLgrid/src/ReactionAPPLgrid.cc @@ -46,7 +46,7 @@ void ReactionAPPLgrid::setDatasetParameters(int dataSetID, map<string,string> pa if(std::string(token.c_str(), 5) == std::string("DUMMY")) { int nb = atoi(token.c_str() + 5); - _emptyPoints[dataSetID].push_back(nb); + data.emptyPoints.push_back(nb); data.grids.push_back(NULL); } else @@ -60,7 +60,7 @@ void ReactionAPPLgrid::setDatasetParameters(int dataSetID, map<string,string> pa hf_errlog(17033000, "W: no reference histogram grid/reference in " + token); else references.back()->SetDirectory(0); - _emptyPoints[dataSetID].push_back(-1); + data.emptyPoints.push_back(-1); } } } @@ -190,19 +190,19 @@ int ReactionAPPLgrid::compute(int dataSetID, valarray<double> &val, map<string, for(unsigned int g = 0; g < data.grids.size(); g++) { // dummy points - if(_emptyPoints[dataSetID][g] > 0) - np += _emptyPoints[dataSetID][g]; + if(data.emptyPoints[g] > 0) + np += data.emptyPoints[g]; // grids or reference histograms else - np += _grids[dataSetID][g]->Nobs(); + np += data.grids[g]->Nobs(); } val.resize(np); - for(unsigned int g = 0; g < _grids[dataSetID].size(); g++) + for(unsigned int g = 0; g < data.grids.size(); g++) { std::vector<double> gridVals; // dummy points - if(_emptyPoints[dataSetID][g] > 0) - gridVals = std::vector<double>(_emptyPoints[dataSetID][g], 0.0); + if(data.emptyPoints[g] > 0) + gridVals = std::vector<double>(data.emptyPoints[g], 0.0); // grids or reference histograms else { diff --git a/reactions/BaseHVQMNR/src/Makefile.am b/reactions/BaseHVQMNR/src/Makefile.am index 00b751efc..d34e8e621 100644 --- a/reactions/BaseHVQMNR/src/Makefile.am +++ b/reactions/BaseHVQMNR/src/Makefile.am @@ -9,6 +9,7 @@ lib_LTLIBRARIES = libbasehvqmnr_xfitter.la libbasehvqmnr_xfitter_la_SOURCES = ReactionBaseHVQMNR.cc MNR.cc MNRFrag.cc MNRGrid.cc hvqcrsx.f # libbasehvqmnr_xfitter_la_LDFLAGS = place_if_needed +libbasehvqmnr_xfitter_la_LDFLAGS = $(ROOT_LIBS) endif diff --git a/reactions/FFABM_DISCC/src/Makefile.am b/reactions/FFABM_DISCC/src/Makefile.am index 59a2e9cad..f536e8518 100644 --- a/reactions/FFABM_DISCC/src/Makefile.am +++ b/reactions/FFABM_DISCC/src/Makefile.am @@ -6,7 +6,7 @@ AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/ lib_LTLIBRARIES = libffabm_discc_xfitter.la libffabm_discc_xfitter_la_SOURCES = ReactionFFABM_DISCC.cc -libffabm_discc_xfitter_la_LDFLAGS = -lbasediscc_xfitter -L$(top_srcdir)/reactions/BaseDISCC/src/.libs +libffabm_discc_xfitter_la_LDFLAGS = -lmyabm -lbasediscc_xfitter -L$(top_srcdir)/reactions/BaseDISCC/src/.libs -lmyabm -L$(top_srcdir)/ABM/src/.libs datadir = ${prefix}/yaml/reactions/FFABM_DISCC data_DATA = ../yaml/parameters.yaml diff --git a/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc b/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc index 7fbfc7055..7a9017957 100644 --- a/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc +++ b/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc @@ -39,7 +39,7 @@ extern "C" { struct COMMON_masses { double rmass[150]; - double rmassp[150]; + double rmassp[50]; double rcharge[150]; }; extern COMMON_masses masses_; @@ -77,9 +77,11 @@ int ReactionFFABM_DISCC::atStart(const string &s) // heavy quark masses double rmass8in = GetParam("mch"); masses_.rmass[7] = rmass8in; + masses_.rcharge[7] = 0.6666666; _mc = rmass8in; double rmass10in = GetParam("mbt"); masses_.rmass[9] = rmass10in; + masses_.rcharge[9] = 0.3333333; _mb = rmass10in; printf("---------------------------------------------\n"); diff --git a/reactions/FFABM_DISNC/src/Makefile.am b/reactions/FFABM_DISNC/src/Makefile.am index f38b30a02..eace5562b 100644 --- a/reactions/FFABM_DISNC/src/Makefile.am +++ b/reactions/FFABM_DISNC/src/Makefile.am @@ -6,7 +6,7 @@ AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/ lib_LTLIBRARIES = libffabm_disnc_xfitter.la libffabm_disnc_xfitter_la_SOURCES = ReactionFFABM_DISNC.cc -libffabm_disnc_xfitter_la_LDFLAGS = -lbasedisnc_xfitter -L$(top_srcdir)/reactions/BaseDISNC/src/.libs +libffabm_disnc_xfitter_la_LDFLAGS = -lbasedisnc_xfitter -L$(top_srcdir)/reactions/BaseDISNC/src/.libs -l:libmyabm.a -L$(top_srcdir)/ABM/src/.libs datadir = ${prefix}/yaml/reactions/FFABM_DISNC data_DATA = ../yaml/parameters.yaml diff --git a/reactions/FFABM_DISNC/src/ReactionFFABM_DISNC.cc b/reactions/FFABM_DISNC/src/ReactionFFABM_DISNC.cc index f4c6f722b..46202eb42 100644 --- a/reactions/FFABM_DISNC/src/ReactionFFABM_DISNC.cc +++ b/reactions/FFABM_DISNC/src/ReactionFFABM_DISNC.cc @@ -35,7 +35,7 @@ extern "C" { struct COMMON_masses { double rmass[150]; - double rmassp[150]; + double rmassp[50]; double rcharge[150]; }; extern COMMON_masses masses_; @@ -74,9 +74,11 @@ int ReactionFFABM_DISNC::atStart(const string &s) // heavy quark masses double rmass8in = GetParam("mch"); masses_.rmass[7] = rmass8in; + masses_.rcharge[7] = 0.6666666; _mc = rmass8in; double rmass10in = GetParam("mbt"); masses_.rmass[9] = rmass10in; + masses_.rcharge[9] = 0.3333333; _mb = rmass10in; printf("---------------------------------------------\n"); diff --git a/reactions/KRunning/include/ReactionKRunning.h b/reactions/KRunning/include/ReactionKRunning.h index 5dce38b9e..e0c7cb9a5 100644 --- a/reactions/KRunning/include/ReactionKRunning.h +++ b/reactions/KRunning/include/ReactionKRunning.h @@ -25,7 +25,7 @@ class ReactionKRunning : public ReactionTheory public: virtual string getReactionName() const { return "KRunning" ;}; - int initAtStart(const string &); + int atStart(const string &); virtual void setDatasetParameters(int dataSetID, map<string,string> pars, map<string,double> dsPars) override; virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err); protected: diff --git a/reactions/KRunning/src/ReactionKRunning.cc b/reactions/KRunning/src/ReactionKRunning.cc index 36701f857..15910a5d9 100644 --- a/reactions/KRunning/src/ReactionKRunning.cc +++ b/reactions/KRunning/src/ReactionKRunning.cc @@ -15,7 +15,7 @@ extern "C" ReactionKRunning* create() { // Initialize at the start of the computation -int ReactionKRunning::initAtStart(const string &s) +int ReactionKRunning::atStart(const string &s) { return 0; } diff --git a/reactions/cbdiff/include/Reactioncbdiff.h b/reactions/cbdiff/include/Reactioncbdiff.h index 0e2805e94..a8a3210e8 100644 --- a/reactions/cbdiff/include/Reactioncbdiff.h +++ b/reactions/cbdiff/include/Reactioncbdiff.h @@ -27,7 +27,7 @@ class Reactioncbdiff : public ReactionBaseHVQMNR public: virtual string getReactionName() const { return "cbdiff" ;}; - virtual int initAtStart(const string &); + virtual int atStart(const string &); virtual void initAtIteration(); virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err); virtual void setDatasetParameters(int dataSetID, map<string,string> pars, map<string,double> dsPars) override; diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index d9c653352..57f94fb79 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -229,7 +229,7 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars } // Initialize at the start of the computation -int Reactioncbdiff::initAtStart(const string &s) +int Reactioncbdiff::atStart(const string &s) { return 0; } -- GitLab From ad523b8ec9b9df762fe8a8b549f6be329cfe9626 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@desy.de> Date: Sat, 30 Mar 2019 23:51:27 +0100 Subject: [PATCH 60/81] fixed reading value of MS_MASS parameter --- reactions/cbdiff/src/Reactioncbdiff.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index 57f94fb79..b38fabe9a 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -111,8 +111,9 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars PrintParameters(par.get()); // pole or MSbar mass _mapMSbarMass[dataSetID] = 0; - if(checkParamInPriority("MS_MASS", pars)) - _mapMSbarMass[dataSetID] = GetParamInPriority("MS_MASS", pars); + if(pars.find("MS_MASS") != pars.end() || checkParam("MS_MASS")) + _mapMSbarMass[dataSetID] = GetParamIInPriority("MS_MASS", pars); + printf("MNR: order = %s MS_MASS = %d\n", order.c_str(), _mapMSbarMass[dataSetID]); // divide or not by bin width if(checkParam("dividebw") || pars.find("dividebw") != pars.end()) par->flagDivideBinWidth = GetParamIInPriority("dividebw", pars); -- GitLab From 0fce714a76bf39af57cf8f72611e4dc4b3e333f6 Mon Sep 17 00:00:00 2001 From: Ivan Novikov <novivanya@yandex.ru> Date: Sun, 31 Mar 2019 20:58:32 +0200 Subject: [PATCH 61/81] Fix duplicate option entries when including a YAML file Issue XFITTER-87 This was caused by some nonintuitive behavior of yaml-cpp, which led to duplicate keys in YAML maps. Now locally-defined options override options included from a file, issuing a warning. However, because it is in general difficult to check if two YAML nodes are equal, we currently only handle cases when the map key is a scalar. -- GitLab From 7eaff3def1ff5360f941126acb15ae8ef3df0238 Mon Sep 17 00:00:00 2001 From: Ivan Novikov <novivanya@yandex.ru> Date: Sun, 31 Mar 2019 20:58:32 +0200 Subject: [PATCH 62/81] Fix duplicate option entries when including a YAML file Issue XFITTER-87 This was caused by some nonintuitive behavior of yaml-cpp, which led to duplicate keys in YAML maps. Now locally-defined options override options included from a file, issuing a warning. However, because it is in general difficult to check if two YAML nodes are equal, we currently only handle cases when the map key is a scalar. -- GitLab From 5e247c02ade34800746d3ad8fd769999762409aa Mon Sep 17 00:00:00 2001 From: Ivan Novikov <novivanya@yandex.ru> Date: Sun, 31 Mar 2019 20:58:32 +0200 Subject: [PATCH 63/81] Fix duplicate option entries when including a YAML file Issue XFITTER-87 This was caused by some nonintuitive behavior of yaml-cpp, which led to duplicate keys in YAML maps. Now locally-defined options override options included from a file, issuing a warning. However, because it is in general difficult to check if two YAML nodes are equal, we currently only handle cases when the map key is a scalar. -- GitLab From 6f14a1de3651dfb8026a000c64a65013f8c904df Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 1 Apr 2019 21:47:44 +0200 Subject: [PATCH 64/81] fixed compiler flags (turned off debug) --- configure.ac | 3 --- 1 file changed, 3 deletions(-) diff --git a/configure.ac b/configure.ac index fb7305de6..48d872b49 100644 --- a/configure.ac +++ b/configure.ac @@ -5,9 +5,6 @@ m4_esyscmd(git describe --always 2>&1 | awk '/Not a git/ {print "2.0.0\033@<:@1 [xfitter-help@desy.de],[xfitter],[http://xfitter.org]) m4_ifndef([AC_PACKAGE_URL], AC_DEFINE([PACKAGE_URL],["http://xfitter.org"])) -CFLAGS+="-O0 -g" -CPPFLAGS+="-O0 -g" -CXXFLAGS+="-O0 -g" #Suppress verbose output when compiling (use make V=99 for verbose output) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -- GitLab From 4af7dbff6ca01a538af93b724e1ec81236cfc327 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 1 Apr 2019 21:51:17 +0200 Subject: [PATCH 65/81] fixed spaces --- configure.ac | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index 48d872b49..21e5277a8 100644 --- a/configure.ac +++ b/configure.ac @@ -436,28 +436,28 @@ AM_CONDITIONAL(ENABLE_HVQMNR, [test x$enable_hvqmnr == xyes]) AC_ARG_ENABLE([root],[AS_HELP_STRING([--enable-root],[use ROOT libraries])]): ${enable_root=yes} AS_IF([test "$enable_root" = "yes"], [ - AC_MSG_CHECKING([for ROOT installation]) - root_config=`which root-config` - if test x$root_config == x; then - AC_MSG_ERROR([Unable to find root-config, install ROOT or configure with --disable-root]) - else - AC_MSG_RESULT([Using $root_config]) - root_ok=1 - ROOT_CFLAGS=`root-config --cflags` - ROOT_LDFLAGS=`root-config --ldflags` - ROOT_LIBS=`root-config --libs` - AC_SUBST(ROOT_CFLAGS) - AC_SUBST(ROOT_LDFLAGS) - AC_SUBST(ROOT_LIBS) - AC_DEFINE([ROOT_ENABLED],[1],[Define if ROOT is enabled]) - fi - ], - [ - AC_MSG_WARN([ROOT libraries are disabled, xfitter-draw not available]) - if test x$enable_applgrid == xyes; then - AC_MSG_ERROR([Root is required for APPLGRID]) - fi - ]) + AC_MSG_CHECKING([for ROOT installation]) + root_config=`which root-config` + if test x$root_config == x; then + AC_MSG_ERROR([Unable to find root-config, install ROOT or configure with --disable-root]) + else + AC_MSG_RESULT([Using $root_config]) + root_ok=1 + ROOT_CFLAGS=`root-config --cflags` + ROOT_LDFLAGS=`root-config --ldflags` + ROOT_LIBS=`root-config --libs` + AC_SUBST(ROOT_CFLAGS) + AC_SUBST(ROOT_LDFLAGS) + AC_SUBST(ROOT_LIBS) + AC_DEFINE([ROOT_ENABLED],[1],[Define if ROOT is enabled]) + fi + ], + [ + AC_MSG_WARN([ROOT libraries are disabled, xfitter-draw not available]) + if test x$enable_applgrid == xyes; then + AC_MSG_ERROR([Root is required for APPLGRID]) + fi + ]) AM_CONDITIONAL([HAVE_ROOT],test $root_ok) -- GitLab From 782bfb9b77970c8201eaf97fb86b59f9cc0cb963 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 1 Apr 2019 21:52:51 +0200 Subject: [PATCH 66/81] fixed spaces 2 --- configure.ac | 80 ++++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/configure.ac b/configure.ac index 21e5277a8..d1999da23 100644 --- a/configure.ac +++ b/configure.ac @@ -579,7 +579,7 @@ AC_CONFIG_FILES([include/Makefile SACOT/src/Makefile SACOT/Makefile ABM/src/Makefile - FONLL/src/Makefile + FONLL/src/Makefile FONLL/Makefile Cascade/src/Makefile genetic/mixmax_r004/Makefile @@ -599,48 +599,48 @@ AC_CONFIG_FILES([include/Makefile doc/logo/Makefile examples/Makefile python/Makefile - xfitter-config - pdfparams/ABMPgluonPdfParam/src/Makefile - pdfparams/ABMPseaPdfParam/src/Makefile - pdfparams/ABMPvalencePdfParam/src/Makefile - pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile - pdfparams/NegativeGluonPdfParam/src/Makefile - evolutions/LHAPDF/src/Makefile - minimizers/CERESMinimizer/src/Makefile - minimizers/MINUITMinimizer/src/Makefile - evolutions/QCDNUM/src/Makefile - pdfparams/BasePdfParam/src/Makefile + xfitter-config + pdfparams/ABMPgluonPdfParam/src/Makefile + pdfparams/ABMPseaPdfParam/src/Makefile + pdfparams/ABMPvalencePdfParam/src/Makefile + pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile + pdfparams/NegativeGluonPdfParam/src/Makefile + evolutions/LHAPDF/src/Makefile + minimizers/CERESMinimizer/src/Makefile + minimizers/MINUITMinimizer/src/Makefile + evolutions/QCDNUM/src/Makefile + pdfparams/BasePdfParam/src/Makefile pdfparams/Expression/src/Makefile - pdfparams/HERAPDF_PdfParam/src/Makefile - pdfparams/PolySqrtPdfParam/src/Makefile - pdfdecompositions/LHAPDFDecomposition/src/Makefile - pdfdecompositions/UvDvUbarDbarS/src/Makefile - pdfdecompositions/SU3_PionPdfDecomposition/src/Makefile - pdfdecompositions/BasePdfDecomposition/src/Makefile - reactions/KRunning/src/Makefile - reactions/AFB/src/Makefile - reactions/KFactor/src/Makefile - reactions/BaseDISCC/src/Makefile - reactions/FFABM_DISCC/src/Makefile - reactions/BaseDISNC/src/Makefile - reactions/FFABM_DISNC/src/Makefile - reactions/Hathor/src/Makefile - reactions/Fractal_DISNC/src/Makefile - reactions/RT_DISNC/src/Makefile - reactions/APPLgrid/src/Makefile - reactions/BaseHVQMNR/src/Makefile - reactions/HVQMNR_LHCb_7TeV_beauty/src/Makefile - reactions/HVQMNR_LHCb_7TeV_charm/src/Makefile - reactions/cbdiff/src/Makefile - reactions/testZMVFNS/src/Makefile - reactions/fastNLO/src/Makefile - reactions/FONLL_DISCC/src/Makefile - reactions/FONLL_DISNC/src/Makefile - evolutions/BaseEvolution/src/Makefile + pdfparams/HERAPDF_PdfParam/src/Makefile + pdfparams/PolySqrtPdfParam/src/Makefile + pdfdecompositions/LHAPDFDecomposition/src/Makefile + pdfdecompositions/UvDvUbarDbarS/src/Makefile + pdfdecompositions/SU3_PionPdfDecomposition/src/Makefile + pdfdecompositions/BasePdfDecomposition/src/Makefile + reactions/KRunning/src/Makefile + reactions/AFB/src/Makefile + reactions/KFactor/src/Makefile + reactions/BaseDISCC/src/Makefile + reactions/FFABM_DISCC/src/Makefile + reactions/BaseDISNC/src/Makefile + reactions/FFABM_DISNC/src/Makefile + reactions/Hathor/src/Makefile + reactions/Fractal_DISNC/src/Makefile + reactions/RT_DISNC/src/Makefile + reactions/APPLgrid/src/Makefile + reactions/BaseHVQMNR/src/Makefile + reactions/HVQMNR_LHCb_7TeV_beauty/src/Makefile + reactions/HVQMNR_LHCb_7TeV_charm/src/Makefile + reactions/cbdiff/src/Makefile + reactions/testZMVFNS/src/Makefile + reactions/fastNLO/src/Makefile + reactions/FONLL_DISCC/src/Makefile + reactions/FONLL_DISNC/src/Makefile + evolutions/BaseEvolution/src/Makefile evolutions/FlipUD/src/Makefile evolutions/FlipCharge/src/Makefile - evolutions/APFELxx/src/Makefile - minimizers/BaseMinimizer/src/Makefile + evolutions/APFELxx/src/Makefile + minimizers/BaseMinimizer/src/Makefile reactions/KMatrix/src/Makefile Makefile]) -- GitLab From 0af813ad4d78c620fd3b8e895630c21d4c2e6982 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 1 Apr 2019 21:54:46 +0200 Subject: [PATCH 67/81] fixed spaces 3 --- doxygen.cfg | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/doxygen.cfg b/doxygen.cfg index 9b2c0ecc1..23c592ad9 100644 --- a/doxygen.cfg +++ b/doxygen.cfg @@ -570,9 +570,9 @@ WARN_LOGFILE = INPUT = include src \ RT/src ACOT/src ABM/src DIPOLE/src \ - DiffDIS/include DiffDIS/src \ - Hathor/interface Hathor/src EW/src \ - NNPDF/include NNPDF/src Cascade/src \ + DiffDIS/include DiffDIS/src \ + Hathor/interface Hathor/src EW/src \ + NNPDF/include NNPDF/src Cascade/src \ DY/src DY/include \ evolutions/LHAPDF/src\ evolutions/LHAPDF/include\ @@ -619,16 +619,15 @@ INPUT = include src \ pdfparams/ABMPgluonPdfParam/include \ pdfparams/ABMPseaPdfParam/include \ pdfparams/ABMPvalencePdfParam/include \ ->>>>>>> origin/test_ceres - pdfparams/HERAPDF_PdfParam/include \ - pdfparams/PolySqrtPdfParam/include \ - pdfdecompositions/BasePdfDecomposition/include pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include \ - pdfdecompositions/LHAPDFDecomposition/include \ - pdfdecompositions/UvDvUbarDbarS/include \ - pdfdecompositions/GRV_PionPdfDecomposition/include \ - minimizers/BaseMinimizer/include \ - minimizers/CERESMinimizer/include \ - minimizers/MINUITMinimizer/include \ + pdfparams/HERAPDF_PdfParam/include \ + pdfparams/PolySqrtPdfParam/include \ + pdfdecompositions/BasePdfDecomposition/include pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include \ + pdfdecompositions/LHAPDFDecomposition/include \ + pdfdecompositions/UvDvUbarDbarS/include \ + pdfdecompositions/GRV_PionPdfDecomposition/include \ + minimizers/BaseMinimizer/include \ + minimizers/CERESMinimizer/include \ + minimizers/MINUITMinimizer/include \ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built -- GitLab From 28d9f949cf6633b97d01275a89aa4690189c3708 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 1 Apr 2019 22:37:05 +0200 Subject: [PATCH 68/81] cosmetics --- reactions/APPLgrid/src/ReactionAPPLgrid.cc | 4 ++-- src/CheckForPDF.cxx | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/reactions/APPLgrid/src/ReactionAPPLgrid.cc b/reactions/APPLgrid/src/ReactionAPPLgrid.cc index dc7aba5c9..d12506dcb 100644 --- a/reactions/APPLgrid/src/ReactionAPPLgrid.cc +++ b/reactions/APPLgrid/src/ReactionAPPLgrid.cc @@ -96,7 +96,7 @@ void ReactionAPPLgrid::setDatasetParameters(int dataSetID, map<string,string> pa data.muR=pars.find("muR") == pars.end() ? GetParam("muR") : stod(pars["muR"]); data.muF=pars.find("muF") == pars.end() ? GetParam("muF") : stod(pars["muF"]); - if(data.muR==0)data.muR=1.0; + if(data.muR==0)data.muR=1.0; if(data.muF==0)data.muF=1.0; // bin width normalisation (by default no rescaling) data.flagNorm=false; @@ -217,7 +217,7 @@ int ReactionAPPLgrid::compute(int dataSetID, valarray<double> &val, map<string, gridVals=grid->vconvolute(xfxWrapper0,getAlphaS(),order-1,muR,muF,eScale); }else{ active_xfxQ_functions[1]=evolutions[1]->xfxQArray(); - gridVals=grid->vconvolute(xfxWrapper0,xfxWrapper1,getAlphaS(),order-1,muR,muF,eScale); + gridVals=grid->vconvolute(xfxWrapper0,xfxWrapper1,getAlphaS(),order-1,muR,muF,eScale); } } else diff --git a/src/CheckForPDF.cxx b/src/CheckForPDF.cxx index 010f27047..da3589760 100644 --- a/src/CheckForPDF.cxx +++ b/src/CheckForPDF.cxx @@ -3,7 +3,6 @@ #include <iostream> #include <algorithm> #include <cstring> -#include <cstring> using namespace std; -- GitLab From e5030f3b4a63416402b31ae5b5feef73e2333222 Mon Sep 17 00:00:00 2001 From: Ivan Novikov <novivanya@yandex.ru> Date: Thu, 4 Apr 2019 12:31:28 +0200 Subject: [PATCH 69/81] Autoremove trailing whitespace --- .gitlab-ci.yml | 2 +- ABM/src/sf_abkm_wrap.f | 62 ++++---- Makefile.am | 4 +- configure.ac | 30 ++-- doxygen.cfg | 6 +- evolutions/QCDNUM/src/EvolutionQCDNUM.cc | 32 ++-- include/ReactionTheory.h | 60 ++++---- include/TheorEval.h | 12 +- include/theorexpr.inc | 4 +- input_steering/parameters.yaml.abmp16 | 2 +- .../UvDvUbarDbarSSbarPdfDecomposition.h | 2 +- .../src/Makefile.am | 2 +- .../src/UvDvUbarDbarSSbarPdfDecomposition.cc | 2 +- pdfparams/ABMPgluonPdfParam/src/Makefile.am | 2 +- pdfparams/ABMPseaPdfParam/src/Makefile.am | 2 +- pdfparams/ABMPvalencePdfParam/src/Makefile.am | 2 +- reactions/APPLgrid/include/ReactionAPPLgrid.h | 2 +- reactions/APPLgrid/src/ReactionAPPLgrid.cc | 4 +- reactions/BaseHVQMNR/include/MNR.h | 18 +-- reactions/BaseHVQMNR/include/MNRFrag.h | 32 ++-- reactions/BaseHVQMNR/include/MNRGrid.h | 28 ++-- .../BaseHVQMNR/include/ReactionBaseHVQMNR.h | 16 +- reactions/BaseHVQMNR/src/MNR.cc | 90 +++++------ reactions/BaseHVQMNR/src/MNRFrag.cc | 144 +++++++++--------- reactions/BaseHVQMNR/src/MNRGrid.cc | 50 +++--- reactions/BaseHVQMNR/src/Makefile.am | 6 +- reactions/FFABM_DISCC/src/Makefile.am | 2 +- reactions/FFABM_DISNC/src/Makefile.am | 2 +- .../src/ReactionHVQMNR_LHCb_7TeV_beauty.cc | 18 +-- .../src/ReactionHVQMNR_LHCb_7TeV_charm.cc | 20 +-- reactions/Hathor/include/ReactionHathor.h | 2 +- reactions/Hathor/src/ReactionHathor.cc | 4 +- reactions/KRunning/include/ReactionKRunning.h | 8 +- reactions/KRunning/src/Makefile.am | 5 +- reactions/KRunning/src/ReactionKRunning.cc | 4 +- reactions/cbdiff/include/Reactioncbdiff.h | 2 +- reactions/cbdiff/src/Makefile.am | 6 +- reactions/cbdiff/src/Reactioncbdiff.cc | 2 +- src/TheorEval.cc | 56 +++---- src/mc_errors.f | 108 ++++++------- src/store_output.f | 100 ++++++------ src/xfitter_pars.cc | 28 ++-- tools/AddPdfDecomp.py | 28 ++-- tools/AddPdfParam.py | 10 +- tools/AddReaction.py | 14 +- tools/draw/include/CommandParser.h | 12 +- tools/draw/include/PdfData.h | 4 +- tools/draw/src/CommandParser.cc | 6 +- tools/draw/src/DataPainter.cc | 56 +++---- tools/draw/src/PdfData.cc | 68 ++++----- tools/install-xfitter | 22 +-- 51 files changed, 601 insertions(+), 602 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c360eb4d5..2fad6e219 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ image: "gitlab-registry.cern.ch/fitters/xfitter" cache: - paths: + paths: - deps stages: diff --git a/ABM/src/sf_abkm_wrap.f b/ABM/src/sf_abkm_wrap.f index f658a1505..5a1bf2e58 100644 --- a/ABM/src/sf_abkm_wrap.f +++ b/ABM/src/sf_abkm_wrap.f @@ -32,8 +32,8 @@ C New user routines for PDFs and alpha_S have to be provided in this version dilog = ddilog(x) return end - - + + subroutine sf_abkm_wrap(x,q2,f2abkm,flabkm,f3abkm,f2cabkm, $ flcabkm,f3cabkm,f2babkm,flbabkm,f3babkm,ncflag,charge, $ polar,sin2thw,cos2thw,MZ) @@ -65,11 +65,11 @@ c f2qcd(nb,nt,ni,xb,q2) nt = 1 -c --------------- Neutral Currents ! ---------------- +c --------------- Neutral Currents ! ---------------- if(ncflag.eq.1) then -c new rewriten version of ABM, now with Z cont available need to calculate full SFs -c we also take polarisation into account +c new rewriten version of ABM, now with Z cont available need to calculate full SFs +c we also take polarisation into account c------- Z-ELECTRON COUPLINGS: eleVec= -0.5d0 + 2.0d0 * sin2thw @@ -93,13 +93,13 @@ C Propagator factor PZ PZ = 4.d0 * sin2thw * cos2thw * (1.+Mz**2/q2) PZ = 1./Pz - f2abkm = f2qcd(3,nt,22,x,q2) + facgz*PZ*f2qcd(3,nt,25,x,q2) + f2abkm = f2qcd(3,nt,22,x,q2) + facgz*PZ*f2qcd(3,nt,25,x,q2) $ + faczz*PZ*PZ*f2qcd(3,nt,23,x,q2) - flabkm = flqcd(3,nt,22,x,q2) + facgz*PZ*flqcd(3,nt,25,x,q2) + flabkm = flqcd(3,nt,22,x,q2) + facgz*PZ*flqcd(3,nt,25,x,q2) $ + faczz*PZ*PZ*flqcd(3,nt,23,x,q2) f3abkm = facgzf3*PZ*f3qcd(3,nt,25,x,q2) + faczzf3*PZ*PZ $ *f3qcd(3,nt,23,x,q2) -c add the negative sign in front of Y_xF3 for neg charge +c add the negative sign in front of Y_xF3 for neg charge if(charge.gt.0) then f3abkm = -1*f3abkm endif @@ -116,15 +116,15 @@ c b quark f3babkm = 0.0d0 -c --------------- Charged Currents ! ---------------- +c --------------- Charged Currents ! ---------------- elseif(ncflag.eq.0) then ni = 24 if(charge.gt.0) then -c W+ +c W+ nb = 6 else -c W- +c W- nb = 7 endif @@ -132,7 +132,7 @@ c divide all SFs by 2 to get e+/- f2abkm = f2qcd(nb,nt,ni,x,q2)/2 flabkm = flqcd(nb,nt,ni,x,q2)/2 f3abkm = f3qcd(nb,nt,ni,x,q2)/2 - + c c quark f2cabkm = f2nucharm(nb,nt,ni,x,q2,8)/2 flcabkm = f2nucharm(nb,nt,ni,x,q2,8)/2 @@ -148,7 +148,7 @@ c b quark end Subroutine ABKM_Set_Input(kschemepdfin,kordpdfin,rmass8in, - $ rmass10in,msbarmin,hqscale1in,hqscale2in,flagthinterface) + $ rmass10in,msbarmin,hqscale1in,hqscale2in,flagthinterface) C--------------------------------------------------------------------------- C Wraper for INPUT common, set parameters C--------------------------------------------------------------------------- @@ -158,7 +158,7 @@ C Input variables: integer kschemepdfin,kordpdfin logical msbarmin double precision hqscale1in,hqscale2in - + C Common variables: integer npdftot,kordpdf,kschemepdf,kpdfset,kordkernel c common /forpdfset/ kschemepdf,kordpdf @@ -171,10 +171,10 @@ c common /forpdfset/ kschemepdf,kordpdf double precision alpsc,alpsb,alpst,tscale,rscale,fscale,hqscale1 double precision hqscale2 integer nfeff,kordalps,kfeff,kordhq,kordf2,kordfl,kordf3 - logical alsmz - + logical alsmz + C OZ 17.10.17 Flags to check that this routine is called only once. -C In the future it should be removed, now it is needed to avoid +C In the future it should be removed, now it is needed to avoid C interference with legacy call from init_theory.f integer flagthinterface integer flaginit @@ -191,7 +191,7 @@ C interference with legacy call from init_theory.f double precision ddnnlohq common /forschemedef/ ddnnlohq,msbarm,hqnons , ,bmsnfopt,bmsnnlo,vloop -C------------------------------- +C------------------------------- C OZ 17.10.17 TODO avoid this in the future C (or stop execution if called not from theory interface) @@ -208,51 +208,51 @@ C (or stop execution if called not from theory interface) rmass(8) = rmass8in rmass(10) = rmass10in kschemepdf= kschemepdfin -c set same order for pdf, light, heavy quarks +c set same order for pdf, light, heavy quarks print*,'kordpdfin, rmass8in,rmass10in ', kordpdfin, rmass8in,rmass10in kordpdf = kordpdfin kordhq = kordpdfin kordf2 = kordpdfin -c follow recommendation of Sergey Alekhin for FL +c follow recommendation of Sergey Alekhin for FL kordfl = kordpdfin+1 kordf3 = kordpdfin kordalps = kordpdfin c run in running m scheme - msbarm = msbarmin + msbarm = msbarmin hqscale1 = hqscale1in hqscale2 = hqscale2in - + c 10.10.2017 Discussion with Sergey Alekhin: -c The parameter HQNONS drives the nonsinglet contribution to the charm production. -c It is infrared unsafe in the NNLO therefore there are pro and contra for including it and it is up to user. +c The parameter HQNONS drives the nonsinglet contribution to the charm production. +c It is infrared unsafe in the NNLO therefore there are pro and contra for including it and it is up to user. c In ABMP16 fit it was set to .false. c (makes small difference which reaches few % only at highest Q2 of the charm HERA data and is negligible for practical purposes) hqnons = .false. - + C-------------------------------------------------------------------------- end - + Subroutine ABKM_Set_Input_OrderFl(flordin) C OZ 1.10.2017 set O(alpha_S) for F_L C--------------------------------------------------------------------------- implicit none C Input variables: integer flordin - + C Common variables: double precision q20,q2rep,q2s,q20alphas,alphas0,alpsz,alpss double precision alpsc,alpsb,alpst,tscale,rscale,fscale,hqscale1 double precision hqscale2 integer nfeff,kordalps,kfeff,kordhq,kordf2,kordfl,kordf3 - logical alsmz + logical alsmz common /FORALPSRENORM/ q20,q2rep,q2s,q20alphas,alphas0,alpsz,alpss , ,alpsc,alpsb,alpst,tscale,rscale,fscale,hqscale1,hqscale2 , ,nfeff,kordalps,kfeff , ,kordhq,kordf2,kordfl,kordf3 , ,alsmz - -C------------------------------- + +C------------------------------- kordfl = kordf2+flordin -C------------------------------- +C------------------------------- end diff --git a/Makefile.am b/Makefile.am index ccebfa6f7..b7f0e85dd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,7 +66,7 @@ if BUILD_DOCS DOCS=doc/tex/manual doc/tex/paper endif #$(info ${DOCS}) -SUBDIRS+= src xfitter $(DOCS) +SUBDIRS+= src xfitter $(DOCS) include $(top_srcdir)/aminclude.am @@ -75,7 +75,7 @@ reaction_DATA = Reactions.txt # Tell which program should run the .sh scripts. #SH_LOG_COMPILER = $(SHELL) -ex -#TESTS_ENVIRONMENT = $(SHELL) +#TESTS_ENVIRONMENT = $(SHELL) #TESTS= ./tools/check.sh EXTRA_DIST= README INSTALLATION LICENCE REFERENCES \ diff --git a/configure.ac b/configure.ac index d1999da23..cc98f519f 100644 --- a/configure.ac +++ b/configure.ac @@ -64,7 +64,7 @@ else echo "Disabling mcmodel=medium option" FCFLAGS="$FCFLAGS -fPIC -cpp" FFLAGS="$FFLAGS -fPIC -cpp" -fi +fi # fortran detection: @@ -120,7 +120,7 @@ AC_LANG_POP(C++) AC_ARG_ENABLE([process], [AS_HELP_STRING([--enable-process],[enable xfitter-process tool])]) -: ${enable_process=yes} +: ${enable_process=yes} AS_IF([test "$enable_process" = "yes"], [ AC_MSG_CHECKING([for libyaml]) @@ -142,7 +142,7 @@ AS_IF([test "$enable_process" = "yes"], [ AC_ARG_ENABLE([openmp], [AS_HELP_STRING([--enable-openmp],[enable openmp support])]) -: ${enable_openmp=no} +: ${enable_openmp=no} AS_IF([test "$enable_openmp" = "yes"], [ AX_OPENMP([AM_CONDITIONAL(ENABLE_OPENMP,true)], @@ -206,7 +206,7 @@ AC_MSG_CHECKING([for QCDNUM installation]) qcdnum_config=`which qcdnum-config` if test x$qcdnum_config == x; then AC_MSG_ERROR([Unable to find qcdnum-config.]) -else +else QCDNUMVERS=`qcdnum-config --version` QCDNUMLIBS=`qcdnum-config --ldflags` QCDNUM_CPPFLAGS=`qcdnum-config --cppflags` @@ -224,7 +224,7 @@ if test $enable_lhapdf; then lhapdf_config=`which lhapdf-config` if test x$lhapdf_config == x; then AC_MSG_ERROR([Unable to find lhapdf-config.]) - else + else LHAPDFVERS=`lhapdf-config --version` LHAPDF_CPPFLAGS=`lhapdf-config --cppflags` LHAPDF_LDFLAGS=`lhapdf-config --ldflags` @@ -235,7 +235,7 @@ if test $enable_lhapdf; then AC_DEFINE([LHAPDF_ENABLED],[1],[Define if LHAPDF is enabled]) lhapdf_family=`lhapdf-config --version | sed 's/\..*$//'` - if test "x$lhapdf_family" != "x5"; then + if test "x$lhapdf_family" != "x5"; then AC_DEFINE([LHAPDF_FAMILY],[6],[Define value of LHAPDF family]) fi fi @@ -250,7 +250,7 @@ if test $enable_apfel; then apfel_config=`which apfel-config` if test x$apfel_config == x; then AC_MSG_ERROR([Unable to find apfel-config.]) - else + else APFELVERS=`apfel-config --version` APFEL_CPPFLAGS=`apfel-config --cppflags` APFEL_LDFLAGS=`apfel-config --ldflags` @@ -297,7 +297,7 @@ if test $enable_ceres; then CERES_LDFLAGS="-L${CERES_DIR}/lib -lceres -lglog -lgflags -lpthread -lspqr -lcholmod -lccolamd -lcamd -lcolamd -lamd -llapack -lblas -lsuitesparseconfig -lrt -lcxsparse -lrt -lcxsparse -lgomp" AC_SUBST(CERES_CPPFLAGS) AC_SUBST(CERES_LDFLAGS) - AC_DEFINE([CERES_ENABLED],[1],[Define if APFEL++ is enabled]) + AC_DEFINE([CERES_ENABLED],[1],[Define if APFEL++ is enabled]) fi fi AM_CONDITIONAL(ENABLE_CERES, [test $enable_ceres]) @@ -310,7 +310,7 @@ if test $enable_mela; then mela_config=`which mela-config` if test x$mela_config == x; then AC_MSG_ERROR([Unable to find mela-config.]) - else + else MELAVERS=`mela-config --version` MELA_LDFLAGS=`mela-config --ldflags` AC_MSG_RESULT([Using $mela_config version $MELAVERS]) @@ -329,7 +329,7 @@ if test x$enable_applgrid == xyes; then applgrid_config=`which applgrid-config` if test x$applgrid_config == x; then AC_MSG_ERROR([Unable to find applgrid-config.]) - else + else APPLGRIDVERS=`applgrid-config --version` APPLGRID_CPPFLAGS=`applgrid-config --cxxflags` APPLGRID_LDFLAGS=`applgrid-config --ldcflags` @@ -407,7 +407,7 @@ if test x$enable_hathor == xyes; then AC_MSG_CHECKING([for hathor installation]) if test "x$HATHOR_ROOT" = "x"; then AC_MSG_ERROR([HATHOR_ROOT environment variable is not set!.]) - else + else AC_MSG_RESULT([Using $HATHOR_ROOT]) AC_CHECK_FILE([$HATHOR_ROOT/libHathor.a],,[AC_MSG_ERROR([HATHOR_ROOT must contain libHathor.a])]) # check which hathor libraries are available: @@ -471,7 +471,7 @@ AM_CONDITIONAL([HAVE_ROOT],test $root_ok) # if test x$enable_nnpdfWeight == xyes; then # AC_MSG_ERROR([Root is required for NNPDF]) # fi -#else +#else # AC_MSG_RESULT([Using $root_config]) # root_ok=1 # ROOT_CFLAGS=`root-config --cflags` @@ -527,7 +527,7 @@ if test x$enable_doc = xyes; then if test -z "$PDFLATEX"; then AC_MSG_ERROR([Pdflatex is required to create the user manual.]) fi - + # Check for presence of pdfLaTeX AC_CHECK_PROG(BIBTEX, bibtex, bibtex) if test -z "$BIBTEX"; then @@ -550,7 +550,7 @@ DX_PS_FEATURE(OFF) DX_INIT_DOXYGEN([$PACKAGE_NAME],[doxygen.cfg]) # Output -AC_CONFIG_FILES([include/Makefile +AC_CONFIG_FILES([include/Makefile src/Makefile xfitter/Makefile common/Makefile @@ -577,7 +577,7 @@ AC_CONFIG_FILES([include/Makefile ACOT/src/Makefile ACOT/Makefile SACOT/src/Makefile - SACOT/Makefile + SACOT/Makefile ABM/src/Makefile FONLL/src/Makefile FONLL/Makefile diff --git a/doxygen.cfg b/doxygen.cfg index 23c592ad9..a8adaea16 100644 --- a/doxygen.cfg +++ b/doxygen.cfg @@ -216,7 +216,7 @@ OPTIMIZE_OUTPUT_VHDL = NO # .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), # use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. -EXTENSION_MAPPING = +EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should @@ -607,7 +607,7 @@ INPUT = include src \ reactions/fastNLO/include \ reactions/fastNLO/src \ reactions/BaseHVQMNR/include \ - reactions/BaseHVQMNR/src + reactions/BaseHVQMNR/src reactions/HVQMNR_LHCb_7TeV_beauty/include \ reactions/HVQMNR_LHCb_7TeV_beauty/src \ reactions/APPLgrid/include \ @@ -643,7 +643,7 @@ INPUT_ENCODING = UTF-8 # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 -FILE_PATTERNS = +FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. diff --git a/evolutions/QCDNUM/src/EvolutionQCDNUM.cc b/evolutions/QCDNUM/src/EvolutionQCDNUM.cc index 1922dbeee..06dce820c 100644 --- a/evolutions/QCDNUM/src/EvolutionQCDNUM.cc +++ b/evolutions/QCDNUM/src/EvolutionQCDNUM.cc @@ -1,4 +1,4 @@ - + /* @file EvolutionQCDNUM.cc @date 2018-08-14 @@ -13,7 +13,7 @@ #include <algorithm> // Global var to hold current pdfDecomposition -std::function<std::map<int,double>(double const& x)> gPdfDecomp; +std::function<std::map<int,double>(double const& x)> gPdfDecomp; // Wrapper for QCDNUM double funcPDF(int *ipdf, double *x) { @@ -45,12 +45,12 @@ double static qcdnumDef[] = { 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., // d 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., // u 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., // s - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., // - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., // - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., // - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., // - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., // - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. // + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., // + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., // + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., // + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., // + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., // + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. // }; @@ -101,7 +101,7 @@ namespace xfitter const double* mbt = XFITTER_PARS::gParameters.at("mbt"); // const double* mtp = XFITTER_PARS::gParameters.at("mtp"); // no top PDF treatment yet XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - + YAML::Node yQCDNUM=XFITTER_PARS::getEvolutionNode(_name); _icheck = yQCDNUM["ICheck"].as<int>(); _splineOrder = yQCDNUM["SplineOrder"].as<int>(); @@ -115,7 +115,7 @@ namespace xfitter int nxgrid = yQCDNUM["NXbins"].as<int>(); int nxout = 0; - + QCDNUM::setord(PtOrder); std::cout << "Set evolution order "<<PtOrder <<"\n"; std::cout << "xGrid[0]: " << xGrid[0] << std::endl; @@ -149,14 +149,14 @@ namespace xfitter Q2Grid[i] = tmp[i].first; Q2GridW[i] = tmp[i].second; } - + //for (size_t i = 0; i<Q2Grid.size(); i++) { // std::cout << " Q2= " << Q2Grid[i] << " weight = " << Q2GridW[i] << "\n"; //} int nq2grid = yQCDNUM["NQ2bins"].as<int>(); int nq2out = 0; - + QCDNUM::gqmake(Q2Grid.data(), Q2GridW.data(), Q2Grid.size(), nq2grid, nq2out); std::cout << "Requested (actual) number of Q2 grid points: "<<nq2grid << "(" << nq2out << ")\n"; @@ -181,7 +181,7 @@ namespace xfitter { hf_errlog(280320191, "F: Unsupported NFlavour = " + std::to_string(nflavour)); } - + // Init SF int id1=0; int id2=0; int nw=0; int ierr=1; if (_readTables>0 ) { @@ -192,7 +192,7 @@ namespace xfitter QCDNUM::fillwt(0,id1,id2,nw); QCDNUM::dmpwgt(1,22,"unpolarised.wgt"); } - + //Evolution gets its decomposition from YAML gPdfDecomp=XFITTER_PARS::getInputFunctionFromYaml(yQCDNUM); atConfigurationChange(); @@ -204,7 +204,7 @@ namespace xfitter const double* Mz = XFITTER_PARS::gParameters.at("Mz"); const double* alphas = XFITTER_PARS::gParameters.at("alphas"); - + QCDNUM::setalf(*alphas,(*Mz)*(*Mz)); } void EvolutionQCDNUM::atIteration(){ @@ -215,7 +215,7 @@ namespace xfitter } std::function<std::map<int,double>(double const& x, double const& Q)> EvolutionQCDNUM::xfxQMap() { - + const auto _f0 = [=] (double const& x, double const& Q) -> std::map<int, double> { std::map<int, double> res; for (int ipdf =-6; ipdf<7; ipdf++) { diff --git a/include/ReactionTheory.h b/include/ReactionTheory.h index 5970a5ebd..03d240e4d 100644 --- a/include/ReactionTheory.h +++ b/include/ReactionTheory.h @@ -21,7 +21,7 @@ using std::valarray; typedef double (*pZeroParFunc)(); typedef double (*pOneParFunc)(const double&); typedef double (*pTwoParFunc)(const double&, const double& ); -typedef void (*pThreeParSub)(const double& , const double&, const double&); +typedef void (*pThreeParSub)(const double& , const double&, const double&); // Function to emulate LHAPDF xfx behavior: typedef void (*pXFXlike)(const double&x,const double&Q,double*results); @@ -53,7 +53,7 @@ typedef void (*pXFXlike)(const double&x,const double&Q,double*results); //class Evolution; //why is this not in namespace xfitter? --Ivan -class ReactionTheory +class ReactionTheory { public: ReactionTheory() {}; @@ -78,20 +78,20 @@ class ReactionTheory virtual void setxFitterparametersYaml(map<string,YAML::Node> &xfitter_pars) {_xfitter_pars_node = xfitter_pars; }; ///< Set map for complex parameters virtual void setxFitterparametersVec(map<string,vector<double> > &xfitter_pars) {_xfitter_pars_vec = xfitter_pars; }; ///< Set map for vector parameters - virtual void resetParameters(const YAML::Node& node); ///< Reset reaction-specific parameters + virtual void resetParameters(const YAML::Node& node); ///< Reset reaction-specific parameters - virtual void setEvolFunctions(double (*palpha_S)(const double& ), map<string, pTwoParFunc> *func2D ) { _alpha_S = palpha_S; PDFs = func2D; }; + virtual void setEvolFunctions(double (*palpha_S)(const double& ), map<string, pTwoParFunc> *func2D ) { _alpha_S = palpha_S; PDFs = func2D; }; ///< Set alpha_S and PDF maps virtual void setExtraFunctions(map<string, pZeroParFunc>, map<string, pOneParFunc>, map<string, pTwoParFunc>) { }; //! Set XFX function for different hadrons (proton: p, neutron: n, anti-proton: pbar) virtual void setXFX(pXFXlike xfx, string type="p" ){ _xfx[type] = xfx; };//DEPRECATED - + virtual void setBinning(int dataSetID, map<string,valarray<double> > *dsBins){ _dsIDs.push_back(dataSetID); _dsBins[dataSetID] = dsBins; } ; - /// Perform optional re-initialization for a given iteration. Interface for old-style pdf functions + /// Perform optional re-initialization for a given iteration. Interface for old-style pdf functions //A better name would be atIteration - virtual void initAtIteration(); + virtual void initAtIteration(); //! Perform optional action when minuit fcn 3 is called (normally after fit) virtual void actionAtFCN3() {}; @@ -102,21 +102,21 @@ class ReactionTheory //! Set dataset @param dataSetID parameters which can be term- and dataset-specific virtual void setDatasetParameters( int dataSetID, map<string,string> parsReaction, map<string,double> parsDataset) {} ; - //! Main function to compute predictions for @param dataSetID - virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err) = 0; - + //! Main function to compute predictions for @param dataSetID + virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err) = 0; + //! Provide additional optional information about the reaction virtual void printInfo(){}; //! Helper function to emmulate LHAPDF6 calls to get PDFs void xfx(const double& x, const double& q, double* results) const;//Currently accesses default evolution, to be replaced later --Ivan - + //! Helper function to emmulate LHAPDF6 calls to get PDFs double xfx(double x, double q, int iPDF) const { double pdfs[13]; xfx(x,q,pdfs); return pdfs[iPDF+6];}; - + //! Helper function to emmulate LHAPDF6 calls to get PDFs std::vector<double> xfx(double x, double q) const { vector<double> pdfs(13); xfx(x,q,&pdfs[0]); return pdfs;}; - + //! strong coupling at scale q [GeV] double alphaS(double q) const { return _alpha_S(q); } @@ -128,19 +128,19 @@ class ReactionTheory //! Default helper to determine if bin is masked or not virtual bool notMasked(int DSID, int Bin); - - //! Helper function to report not implemented functionality + + //! Helper function to report not implemented functionality void NOT_IMPLEMENTED(const string& functionName) { string message = "F: Function "+functionName+" is not implemented for module" + getReactionName(); hf_errlog_(17040701,message.c_str(),message.size()); - } + } /// Set evolution name void setEvolution(std::string& evolution) { _evolution = evolution; } /// Retrieve evolution name //A better name would be "getEvolutionName" -- Ivan - const std::string getEvolution() const { return _evolution; } - + const std::string getEvolution() const { return _evolution; } + protected: map<string, pTwoParFunc> *PDFs; @@ -151,18 +151,18 @@ class ReactionTheory bool checkParam(string name) const ///< Check if a parameter is present on one of the global list { - return (_xfitter_pars.find(name) != _xfitter_pars.end()) - || (_xfitter_pars_i.find(name) != _xfitter_pars_i.end()) - || (_xfitter_pars_s.find(name) != _xfitter_pars_s.end()) - || (_xfitter_pars_vec.find(name) != _xfitter_pars_vec.end()) - || (_xfitter_pars_node.find(name) != _xfitter_pars_node.end()) + return (_xfitter_pars.find(name) != _xfitter_pars.end()) + || (_xfitter_pars_i.find(name) != _xfitter_pars_i.end()) + || (_xfitter_pars_s.find(name) != _xfitter_pars_s.end()) + || (_xfitter_pars_vec.find(name) != _xfitter_pars_vec.end()) + || (_xfitter_pars_node.find(name) != _xfitter_pars_node.end()) ; } // Helper function to get a parameter (double) double GetParam(const string& name) const - { - if (_xfitter_pars.find(name) != _xfitter_pars.end() ) + { + if (_xfitter_pars.find(name) != _xfitter_pars.end() ) return *_xfitter_pars.at(name); else return 0; @@ -183,7 +183,7 @@ class ReactionTheory return _xfitter_pars_s.at(name); } else { - return GetParamY(name, dsID); // + return GetParamY(name, dsID); // } } @@ -192,12 +192,12 @@ class ReactionTheory // Helper function to get bin values for a given data set, bin name. Returns null if not found virtual valarray<double> *GetBinValues(int idDS, const string& binName) - { + { map<string, valarray<double> >* mapBins = _dsBins[idDS]; if (mapBins == nullptr ) { return nullptr; } - else { + else { map<string, valarray<double> >::iterator binPair = mapBins->find(binName); if ( binPair == mapBins->end() ) { return nullptr; @@ -228,14 +228,14 @@ class ReactionTheory /// Global vector of double parameters: map< string, vector<double> > _xfitter_pars_vec; - + /// Global YAML node parameters, for complex cases. map< string, YAML::Node > _xfitter_pars_node; private: /// Default evolution: string _evolution; - + /// list of xfx-like PDFs (using pointer function) map<string,pXFXlike> _xfx; /// list of alphaS (using pointer function) diff --git a/include/TheorEval.h b/include/TheorEval.h index ef15401ff..ddc00122b 100644 --- a/include/TheorEval.h +++ b/include/TheorEval.h @@ -1,7 +1,7 @@ /** @class TheorEval - @brief Theory expression evaluation + @brief Theory expression evaluation This class performs evaluation of expression that describes theoretical prediction for a given dataset. The expression may contain APPLgrid terms, @@ -46,7 +46,7 @@ using std::list; -1, -2 -- brackets (, ) 1 -- operators +, - 3 -- operators *, / - 4 -- functions sum, avg + 4 -- functions sum, avg 5 -- Matrix . Vector / vector . Matrix */ struct tToken { @@ -63,7 +63,7 @@ class TheorEval{ public: ~TheorEval(); //! Proper constructor for TheorEval class - /*! + /*! \param dsID dataset ID for which the expression is evaluated \param nTerms the number of terms in the expression \param stn array of strings with term names @@ -76,7 +76,7 @@ class TheorEval{ */ TheorEval(const int dsID, const int nTerms, const std::vector<string> stn, const std::vector<string> stt, const std::vector<string> sti, const std::vector<string> sts, const string& ste); - + //! Evaluates array of predictions for requested expression /*! \param iorder order for grids evaluation @@ -141,7 +141,7 @@ class TheorEval{ int initReactionTerm(int iterm, valarray<double> *val); //! Update the reaction values into the tokens int getReactionValues(); - //! + //! map<string, string> SplitTermInfo(const string& term_info); private: @@ -178,7 +178,7 @@ class TheorEval{ /// bin-by-bin dynamic scale float _dynamicscale; - /// also keep DS pars, which are valid for all terms + /// also keep DS pars, which are valid for all terms map <string, double> _dsPars; /// Name ! diff --git a/include/theorexpr.inc b/include/theorexpr.inc index 96d8f769d..6b126ba61 100644 --- a/include/theorexpr.inc +++ b/include/theorexpr.inc @@ -25,7 +25,7 @@ C Also store dataset info here C And some basic vars: - common/theorexpr/ dynscale, NTerms, TermName, TermType, TermInfo, - & TermSource, TheorExpr, ppbar_collisions, normalised, + common/theorexpr/ dynscale, NTerms, TermName, TermType, TermInfo, + & TermSource, TheorExpr, ppbar_collisions, normalised, $ murdef, mufdef, $ ninfo, datainfo, CInfo, dsname, ds_index diff --git a/input_steering/parameters.yaml.abmp16 b/input_steering/parameters.yaml.abmp16 index 7b4bdd3d9..4535f8ede 100644 --- a/input_steering/parameters.yaml.abmp16 +++ b/input_steering/parameters.yaml.abmp16 @@ -39,7 +39,7 @@ Parameters: Bsbar : [ -0.1473 ] Csbar : [ 8.586246 ] ZERO : [ 0. ] # zero - + ABMP_uv_A : DEPENDENT ABMP_uv_a : [ 0.613, 0.033 ] ABMP_uv_b : [ 3.443, 0.064 ] diff --git a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h index 160917459..65ea8542c 100644 --- a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h +++ b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include/UvDvUbarDbarSSbarPdfDecomposition.h @@ -30,7 +30,7 @@ namespace xfitter { /// Compute PDF in a physical base in LHAPDF format for given x and Q virtual std::function<std::map<int,double>(const double& x)> f0() const override final; - + private: BasePdfParam*par_xuv{nullptr}, *par_xdv{nullptr}, diff --git a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile.am b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile.am index 0091a38cc..110a22006 100644 --- a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile.am +++ b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/Makefile.am @@ -1,7 +1,7 @@ # Created by AddPdfDecomposition.py on 2019-02-25 -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../pdfparams/BasePdfParam/include/ -I$(srcdir)/../../BasePdfDecomposition/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../pdfparams/BasePdfParam/include/ -I$(srcdir)/../../BasePdfDecomposition/include -Wall -fPIC -Wno-deprecated #lib_LTLIBRARIES = libUvDvUbarDbarSSbarPdfDecomposition_xfitter.la lib_LTLIBRARIES = libuvdvubardbarssbarpdfdecomposition_xfitter.la diff --git a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc index b359cc147..de890f65a 100644 --- a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc +++ b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc @@ -14,7 +14,7 @@ #include <cmath> namespace xfitter { - + /// the class factories, for dynamic loading extern "C" UvDvUbarDbarSSbarPdfDecomposition* create(const char*name) { return new UvDvUbarDbarSSbarPdfDecomposition(name); diff --git a/pdfparams/ABMPgluonPdfParam/src/Makefile.am b/pdfparams/ABMPgluonPdfParam/src/Makefile.am index 5ec16aa2b..33c8aeb4f 100644 --- a/pdfparams/ABMPgluonPdfParam/src/Makefile.am +++ b/pdfparams/ABMPgluonPdfParam/src/Makefile.am @@ -1,7 +1,7 @@ # Created by AddPdfParam.py on 2019-02-25 -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated lib_LTLIBRARIES = libABMPgluonPdfParam_xfitter.la libABMPgluonPdfParam_xfitter_la_SOURCES = ABMPgluonPdfParam.cc diff --git a/pdfparams/ABMPseaPdfParam/src/Makefile.am b/pdfparams/ABMPseaPdfParam/src/Makefile.am index c961c1bff..d48c7c857 100644 --- a/pdfparams/ABMPseaPdfParam/src/Makefile.am +++ b/pdfparams/ABMPseaPdfParam/src/Makefile.am @@ -1,7 +1,7 @@ # Created by AddPdfParam.py on 2019-02-25 -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated lib_LTLIBRARIES = libABMPseaPdfParam_xfitter.la libABMPseaPdfParam_xfitter_la_SOURCES = ABMPseaPdfParam.cc diff --git a/pdfparams/ABMPvalencePdfParam/src/Makefile.am b/pdfparams/ABMPvalencePdfParam/src/Makefile.am index 25a884507..d98d0a19d 100644 --- a/pdfparams/ABMPvalencePdfParam/src/Makefile.am +++ b/pdfparams/ABMPvalencePdfParam/src/Makefile.am @@ -1,7 +1,7 @@ # Created by AddPdfParam.py on 2019-02-25 -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated lib_LTLIBRARIES = libABMPvalencePdfParam_xfitter.la libABMPvalencePdfParam_xfitter_la_SOURCES = ABMPvalencePdfParam.cc diff --git a/reactions/APPLgrid/include/ReactionAPPLgrid.h b/reactions/APPLgrid/include/ReactionAPPLgrid.h index 3de2f8be0..4d4c12da5 100644 --- a/reactions/APPLgrid/include/ReactionAPPLgrid.h +++ b/reactions/APPLgrid/include/ReactionAPPLgrid.h @@ -9,7 +9,7 @@ /** @class' ReactionAPPLgrid - @brief A wrapper class for APPLgrid reaction + @brief A wrapper class for APPLgrid reaction Based on the ReactionTheory class. Reads options produces 3d cross section. diff --git a/reactions/APPLgrid/src/ReactionAPPLgrid.cc b/reactions/APPLgrid/src/ReactionAPPLgrid.cc index d12506dcb..6fafdf516 100644 --- a/reactions/APPLgrid/src/ReactionAPPLgrid.cc +++ b/reactions/APPLgrid/src/ReactionAPPLgrid.cc @@ -40,7 +40,7 @@ void ReactionAPPLgrid::setDatasetParameters(int dataSetID, map<string,string> pa // dummy empty points (for bin manipulations etc.) // GridName=DUMMYX where X is number of bins (e.g. GridName=DUMMY12) // ********** - // SZ 27.03.2019 trying to merge the developments in master and test_ceres: + // SZ 27.03.2019 trying to merge the developments in master and test_ceres: // probably not yet fully consistent (should emptyPoints be in DatasetData?) // ********** if(std::string(token.c_str(), 5) == std::string("DUMMY")) @@ -92,7 +92,7 @@ void ReactionAPPLgrid::setDatasetParameters(int dataSetID, map<string,string> pa order = localOrder>order ? order : localOrder; } data.order=order; -// Determine MuR and MuF. Use default +// Determine MuR and MuF. Use default data.muR=pars.find("muR") == pars.end() ? GetParam("muR") : stod(pars["muR"]); data.muF=pars.find("muF") == pars.end() ? GetParam("muF") : stod(pars["muF"]); diff --git a/reactions/BaseHVQMNR/include/MNR.h b/reactions/BaseHVQMNR/include/MNR.h index 2d65ebca5..61e65be16 100644 --- a/reactions/BaseHVQMNR/include/MNR.h +++ b/reactions/BaseHVQMNR/include/MNR.h @@ -19,10 +19,10 @@ namespace MNR public: // Constructor MNR(ReactionBaseHVQMNR* ptrReactionTheory); - + // Destructor ~MNR(); - + // Set perturbative scale coefficients // // Scales are parametrised as: @@ -31,20 +31,20 @@ namespace MNR // where mu_f, mu_r are factorisation and renormalisation, respectively, // pT is transverse momentum and xm is the heavy-quark mass. void SetScaleCoef(double mf_a, double mf_b, double mf_c, double mr_a, double mr_b, double mr_c); - + // Set debug flag void SetDebug(int debug) { bDebug = debug; }; // Calculate constants void CalcConstants(); - + // Calculate binning void CalcBinning(); // Calculate cross sections for provided grid and heavy-quark mass xm void CalcXS(Grid* grid, double xm); - + // Private members private: // Get factorisation scale @@ -68,7 +68,7 @@ namespace MNR // Public fields public: // Centre-of-mass energy squared - double fC_sh; + double fC_sh; // Number of light flavours int fC_nl; @@ -110,7 +110,7 @@ namespace MNR const static double fC_vtf; double fC_b0; // Centre-of-mass energy - double fC_sqrt_sh; + double fC_sqrt_sh; // Normalisation factor double fC_xnorm; @@ -130,7 +130,7 @@ namespace MNR // t3 bins (3 body variable) double* fBc_x4; double* fBw_x4; - + // Precalcuated grid variables int fNRecalc; // Pointer to all allocated memory @@ -189,7 +189,7 @@ namespace MNR // Flags bool bFirst; // first run bool bDebug; // verbose output - + // pointer to instance inherited from ReactionTheory (allow access to alphas and PDF routines) ReactionBaseHVQMNR* _reactionTheory; }; diff --git a/reactions/BaseHVQMNR/include/MNRFrag.h b/reactions/BaseHVQMNR/include/MNRFrag.h index 978f9055d..a17d53f6f 100644 --- a/reactions/BaseHVQMNR/include/MNRFrag.h +++ b/reactions/BaseHVQMNR/include/MNRFrag.h @@ -14,7 +14,7 @@ namespace MNR // // Class for non-perturbative heavy quark to hadron fragmentation. // Kartvelishvili, Peterson and BCFY fragmentation functions are provided. - // Specific ground state mesons can be treated separately + // Specific ground state mesons can be treated separately // (e.g. for contribution to D^0 from D*+ decays). class Frag { // Public methods @@ -24,20 +24,20 @@ namespace MNR // Destructor ~Frag(); - + // Set number of z (rescaling variable) bins void SetNz(int nz); - + // Add final state with fragmentation function ffrag and mass M. // If M < 0, heavy-quark mass is used instead. void AddOut(TF1* ffrag, double M); - + // Get fragmentation function for specified final state TF1* GetFF(int f) { return fFFrag[f]; }; - + // Calculate cross sections for provided grid and heavy-quark mass xm and fill histograms hcs void CalcCS(Grid* grid, double xm, std::vector<TH2D*> hcs); - + // Set debug flag void SetDebug(bool debug) { bDebug=debug; }; @@ -63,7 +63,7 @@ namespace MNR static double kar_dch(double* x, double* p); // Peterson function [Phys.Rev. D27 (1983) 105] static double pet(double* x, double* p); - // Kartvelishvili with two parameters ("Misha-style" parametrisation, + // Kartvelishvili with two parameters ("Misha-style" parametrisation, // see DESY-THESIS-2011-033, Section 2.2 for description) static double karw(double* x, double* p); // Kartvelishvili with two parameters (rescaled) @@ -90,13 +90,13 @@ namespace MNR // ff = 20: Kartvelishvili with three W bins // If mean pointer is provided, for 1D function it is set to mean value. // - // WARNING: it is known feature that the fit might not converge if fragmentation depends - // on energy in parton-parton rest frame, especially if the heavy-quark mass + // WARNING: it is known feature that the fit might not converge if fragmentation depends + // on energy in parton-parton rest frame, especially if the heavy-quark mass // is released, use ff = 10 and ff = 20 with great caution! static TF1* GetFragFunction(int ff, const char* meson, double par, double* mean = 0); static double GetHadronMass(const char* meson); - + // Private methods private: // Precalculate variables for provided grid and heavy-quark mass xm @@ -104,10 +104,10 @@ namespace MNR // Clear z binning void ClearZ(); - + // Clear precalculated variables void ClearPrecalc(); - + // Public fields public: // Charm and beauty hadron masses @@ -119,20 +119,20 @@ namespace MNR static const double fM_bzero; static const double fM_bch; static const double fM_bs; - + // Private fields private: // Final states int fNout; // number of final states std::vector<TF1*> fFFrag; // fragmentation functions std::vector<double> fMh2; // hadron masses squared - + // Precalculated variables int fBnz; double* fZc; double* fZw; - std::vector<double*> fWz; - + std::vector<double*> fWz; + // Flags bool bFirst; // first run bool bDebug; // verbose output diff --git a/reactions/BaseHVQMNR/include/MNRGrid.h b/reactions/BaseHVQMNR/include/MNRGrid.h index 5b5bbc301..6e5b33863 100644 --- a/reactions/BaseHVQMNR/include/MNRGrid.h +++ b/reactions/BaseHVQMNR/include/MNRGrid.h @@ -42,31 +42,31 @@ namespace MNR public: // Default constructor (one full contrbution: LO+NLO gg+q+qg) Grid(); - + // Construct with specified array of contributions Grid(int ncontr, MNRContribution** contr); - + // Destructor ~Grid(); - + // Set pT binning (n bins from minpt to maxpt, xm is heavy-quark mass) // (internally binning in L = xm^2 / (xm^2 + pT^2)) void SetL(int n, double minpt, double maxpt, double xm); - + // Set y binning (n bins from min to max) void SetY(int n, double min, double max); - + // Set W (squared energy in parton-parton rest frame), default binning - // WARNING: it is known feature that the fit might not converge if n != 1 (i.e. if fragmentation depends - // on energy in parton-parton rest frame), especially if the heavy-quark mass is released, + // WARNING: it is known feature that the fit might not converge if n != 1 (i.e. if fragmentation depends + // on energy in parton-parton rest frame), especially if the heavy-quark mass is released, // use this with great caution! void SetW(int n = 1, double min = 0.0, double max = 500.0); // Set W (squared energy in parton-parton rest frame) three bins, separated by b1 and b2 values // (corresponds to the fragmentation set-up used for charm in arXiv:1211.1182) - // WARNING: it is known feature that the fit might not converge if this option is used, + // WARNING: it is known feature that the fit might not converge if this option is used, // especially if the heavy-quark mass is released, use this with great caution! void SetW(double b1, double b2); - + // Get cross section (by reference) in specified bin inline double& CS(int contr, int bl, int by, int bw=0) { return fCS[contr][bl][by][bw]; }; @@ -84,7 +84,7 @@ namespace MNR // Get number of W bins inline int NW() { return fNW; }; - + // Get L binning inline double* LPtr() { return fL; }; @@ -93,13 +93,13 @@ namespace MNR // Get W binning inline double* WPtr() { return fW; }; - + // Fill array with pT values for the specified heavy-quark mass xm void FillPt(double* ptall, double xm); // Get number of contributions inline int GetNContr() { return fNContr; }; - + // Get specified contribution inline MNRContribution* GetContr(int c) { return fContr[c]; }; @@ -108,13 +108,13 @@ namespace MNR // Set cross sections in specified pT bin to non-physical values void NonPhys(int bpt); - + // Set all cross sections to zero void Zero(); // Print grid (to console) for the specified heavy-quark mass void Print(double xm); - + // Find W bin that matches the specified value w int FindWBin(double w); diff --git a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h index 54bfd4ea3..c816e2f41 100644 --- a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h +++ b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h @@ -10,11 +10,11 @@ /** @class' ReactionBaseHVQMNR - @brief A wrapper class for BaseHVQMNR reaction + @brief A wrapper class for BaseHVQMNR reaction Based on the ReactionTheory class. Reads options produces 3d cross section. - This is abstract class from which implementations of HVQMNR + This is abstract class from which implementations of HVQMNR calculations for particular datasets should be derived. @version 0.1 @@ -38,8 +38,8 @@ class ReactionBaseHVQMNR : public ReactionTheory virtual void setDatasetParameters(int dataSetID, map<string,string> pars, map<string,double> dsPars) override; protected: virtual int parseOptions(){ return 0;}; - -// ********** common stuff for MNR calculation ********** + +// ********** common stuff for MNR calculation ********** protected: // structure for particular dataset struct DataSet @@ -55,7 +55,7 @@ class ReactionBaseHVQMNR : public ReactionTheory std::valarray<double>* BinsYMinRef; std::valarray<double>* BinsYMaxRef; }; - + // structure to store theory parameters struct Parameters { @@ -111,7 +111,7 @@ class ReactionBaseHVQMNR : public ReactionTheory bool a; char flav; // c, b or t }; - + // all datasets std::map<int, DataSet> _dataSets; // theory parameters @@ -136,7 +136,7 @@ class ReactionBaseHVQMNR : public ReactionTheory // read and update theory parameters void UpdateParameters(); - + // print theory parameters void PrintParameters(Parameters const* pars = NULL) const; @@ -152,7 +152,7 @@ class ReactionBaseHVQMNR : public ReactionTheory //private: // check equality of float numbers with tolerance bool IsEqual(const double val1, const double val2, const double eps = 1e-6); - + // TODO this old commented out code to be removed one day /*// read values from terminfo in format key1=value1:key2=value2:... int readFromTermInfo(const std::string& str, const std::string& key, int& value); diff --git a/reactions/BaseHVQMNR/src/MNR.cc b/reactions/BaseHVQMNR/src/MNR.cc index 730a383e6..f3da82793 100644 --- a/reactions/BaseHVQMNR/src/MNR.cc +++ b/reactions/BaseHVQMNR/src/MNR.cc @@ -62,7 +62,7 @@ namespace MNR fNRecalc = 0; } - MNR::~MNR() + MNR::~MNR() { //printf("OZ MNR::~MNR()\n"); if(fSF_pdf) delete fSF_pdf; @@ -73,14 +73,14 @@ namespace MNR if(fBw_x4) delete fBw_x4; } - void MNR::CalcConstants() + void MNR::CalcConstants() { fC_sqrt_sh = TMath::Sqrt(fC_sh); fC_xnorm = fC_hc2 * fC_pi / fC_sh; fC_b0 = (11 * fC_vca - 4 * fC_vtf * fC_nl) / (12 * fC_pi); } - void MNR::CalcBinning() + void MNR::CalcBinning() { // PDFs in x for certain factorisation scale fSF_pdf = new double[fSF_nb * fSF_npart]; @@ -97,7 +97,7 @@ namespace MNR double minx3 = -6.0; double maxx3 = 6.0; double stepx3 = (maxx3 - minx3) / fBn_x3; - for(int b = 0; b < fBn_x3 + 1; b++) + for(int b = 0; b < fBn_x3 + 1; b++) { bb_x3[b] = minx3 + stepx3 * b; if(b == 0) continue; @@ -112,7 +112,7 @@ namespace MNR double bb_x4[fBn_x4+1]; fBc_x4 = new double[fBn_x4]; fBw_x4 = new double[fBn_x4]; - for(int b = 0; b < fBn_x4 + 1; b++) + for(int b = 0; b < fBn_x4 + 1; b++) { bb_x4[b] = 1. * b / fBn_x4; if(bb_x4[b] <= fbx4_12) bb_x4[b] = fbx4_1.Eval(bb_x4[b]); @@ -123,9 +123,9 @@ namespace MNR } } - void MNR::SetScaleCoef(double mf_a, double mf_b, double mf_c, double mr_a, double mr_b, double mr_c) + void MNR::SetScaleCoef(double mf_a, double mf_b, double mf_c, double mr_a, double mr_b, double mr_c) { - // Check for possible nan + // Check for possible nan // (it happens if corresponding parameters were not provided in steering.txt via ExtraMinimisationParameters) if(mf_a != mf_a || mf_b != mf_b || mf_c != mf_c || mr_a != mr_a || mr_b != mr_b || mr_c != mr_c) { @@ -140,39 +140,39 @@ namespace MNR fMr_C = mr_c; } - double MNR::GetMf2(double xm2, double pt2) + double MNR::GetMf2(double xm2, double pt2) { return fMf_A * pt2 + fMf_B * xm2 + fMf_C; } - double MNR::GetMr2(double xm2, double pt2) + double MNR::GetMr2(double xm2, double pt2) { return fMr_A * pt2 + fMr_B * xm2 + fMr_C; } - void MNR::PrecalculatePDF(double mf2) + void MNR::PrecalculatePDF(double mf2) { //printf("mf2 = %f\n", mf2); - if(mf2 < fSF_min_mf2 || mf2 > fSF_max_mf2) + if(mf2 < fSF_min_mf2 || mf2 > fSF_max_mf2) { printf("WARNING in MNR::PrecalculatePDF(): mf2 %e out of range %e .. %e\n", mf2, fSF_min_mf2, fSF_max_mf2); printf("PDFs are set to 0\n"); - for(int b = 0; b < fSF_nb; b++) + for(int b = 0; b < fSF_nb; b++) for(int nf = -fC_nl; nf <= fC_nl; nf++) fSF_pdf[b*fSF_npart+nf] = 0.0; return; } - for(int b = 0; b < fSF_nb; b++) + for(int b = 0; b < fSF_nb; b++) { double log10x = fSF_log10_min_x + b * fSF_step_log10_x; this->GetPDF(mf2, TMath::Power(10., log10x), fSF_pdf + fSF_npart * b); } } - int MNR::GetSF(double& pdf_gg, double& pdf_qq, double& pdf_qq_a, double& pdf_qg, double& pdf_qg_a, - double& pdf_qg_r, double& pdf_qg_a_r, double adoptx1, double adoptx2, double mf2/* = -1.0*/) + int MNR::GetSF(double& pdf_gg, double& pdf_qq, double& pdf_qq_a, double& pdf_qg, double& pdf_qg_a, + double& pdf_qg_r, double& pdf_qg_a_r, double adoptx1, double adoptx2, double mf2/* = -1.0*/) { pdf_gg = pdf_qq = pdf_qq_a = pdf_qg = pdf_qg_a = pdf_qg_r = pdf_qg_a_r = 0.0; - if(mf2 > 0.0 && (mf2 < fSF_min_mf2 || mf2 > fSF_max_mf2)) + if(mf2 > 0.0 && (mf2 < fSF_min_mf2 || mf2 > fSF_max_mf2)) { printf("WARNING in MNR::GetSF(): mf2 %e out of range %e .. %e\n", mf2, fSF_min_mf2, fSF_max_mf2); return 1; @@ -181,7 +181,7 @@ namespace MNR if(adoptx1<fSF_min_adoptx) adoptx1 = fSF_min_adoptx; if(adoptx2<fSF_min_adoptx) adoptx2 = fSF_min_adoptx; double pdf1[fSF_npart], pdf2[fSF_npart]; - if(mf2 < 0.0) + if(mf2 < 0.0) { double part1, part2; double delta1 = modf(adoptx1, &part1); @@ -192,14 +192,14 @@ namespace MNR int offset2 = int(part2) * fSF_npart + 6; int one_p_offset1 = offset1 + fSF_npart; int one_p_offset2 = offset2 + fSF_npart; - for(int nf = -fC_nl; nf <= fC_nl; nf++) + for(int nf = -fC_nl; nf <= fC_nl; nf++) { int six_p_nf = 6 + nf; pdf1[six_p_nf] = fSF_pdf[offset1+nf] * one_m_delta1 + fSF_pdf[one_p_offset1+nf] * delta1; pdf2[six_p_nf] = fSF_pdf[offset2+nf] * one_m_delta2 + fSF_pdf[one_p_offset2+nf] * delta2; } } - else + else { double x1 = TMath::Power(10.0, fSF_step_log10_x * adoptx1 + fSF_log10_min_x); double x2 = TMath::Power(10.0, fSF_step_log10_x * adoptx2 + fSF_log10_min_x); @@ -209,7 +209,7 @@ namespace MNR // Calculate gg pdf_gg = pdf1[6] * pdf2[6]; // ... and the rest - for(int nf = 1; nf <= fC_nl; nf++) + for(int nf = 1; nf <= fC_nl; nf++) { int six_p_nf = 6 + nf; int six_m_nf = 6 - nf; @@ -241,7 +241,7 @@ namespace MNR pdf[i] = pdfV[i]; } - double MNR::GetAs(double mr2) + double MNR::GetAs(double mr2) { //return hf_get_alphas_(&mr2); //return _reactionTheory->alpha_S(&mr2); @@ -249,7 +249,7 @@ namespace MNR return _reactionTheory->alphaS(q); } - void MNR::Precalc(Grid* grid) + void MNR::Precalc(Grid* grid) { fNRecalc++; printf("MNR::Precalc(): recalculation NO %d\n", fNRecalc); @@ -262,7 +262,7 @@ namespace MNR double mb = sizeof(double) * ndouble / (1024. * 1024.); printf("MNR::Precalc(): required %.0f MB\n", mb); - // Allocate memory in one place, because + // Allocate memory in one place, because // (1) one call to new is faster than multiple calls // (2) it is faster to access memory allocated in one place fC_mem = new double[ndouble]; @@ -359,7 +359,7 @@ namespace MNR mem_offset += fBn_x3; // Calculate x3 (binning in parton CMS rapidity) variables - for(int c_x3 = 0; c_x3 < fBn_x3; c_x3++) + for(int c_x3 = 0; c_x3 < fBn_x3; c_x3++) { double yprim = fBc_x3[c_x3]; fCk_t1t[c_x3] = 0.5 * (1 - TMath::TanH(yprim)); @@ -370,7 +370,7 @@ namespace MNR fCk_sum_lntx_o_tx = 0.0; // Calculate x4 (t3, 3 body variable) variables - for(int c_x4 = 0; c_x4 < fBn_x4; c_x4++) + for(int c_x4 = 0; c_x4 < fBn_x4; c_x4++) { double t3 = fBc_x4[c_x4]; double t32 = t3 * t3; @@ -388,12 +388,12 @@ namespace MNR } // Loop over L = xm^2 / (xm^2 + pT^2) bins - for(int c_l = 0; c_l < n_l; c_l++) + for(int c_l = 0; c_l < n_l; c_l++) { if(bDebug) if(c_l % 10 == 0) printf("MNR::Precalc(): 1st dimension: %3d from %3d\n", c_l, n_l); double l2 = p_l[c_l]; // Loop over x3 bins - for(int c_x3 = 0; c_x3 < fBn_x3; c_x3++) + for(int c_x3 = 0; c_x3 < fBn_x3; c_x3++) { double yprim = fBc_x3[c_x3]; double t1t = 0.5 * (1 - TMath::TanH(yprim)); @@ -424,7 +424,7 @@ namespace MNR fCh3c_hqhlqa[n2] = hqhlqa_(&tz, &t1t, &rot); fCh3c_a_ashpqa[n2] = ashpqa_(&tz, &t1t, &rot); // Loop over x4 bins - for(int c_x4 = 0; c_x4 < fBn_x4; c_x4++) + for(int c_x4 = 0; c_x4 < fBn_x4; c_x4++) { double t3 = fBc_x4[c_x4]; double t32 = t3 * t3; @@ -459,7 +459,7 @@ namespace MNR } } - void MNR::CalcXS(Grid* grid, double xm) + void MNR::CalcXS(Grid* grid, double xm) { // First call: precalculate variables if(bFirst) { @@ -467,13 +467,13 @@ namespace MNR bFirst = false; } grid->Zero(); - + // Check heavy-quark mass for nan if(xm != xm) { grid->NonPhys(); return; } - + int ncontr = grid->GetNContr(); double xm2 = xm * xm; int n_l = grid->NL(); @@ -482,7 +482,7 @@ namespace MNR double* p_y = grid->YPtr(); int nbw = grid->NW(); // Loop over pT (internally L) - for(int c_l = 0; c_l < n_l; c_l++) + for(int c_l = 0; c_l < n_l; c_l++) { if(bDebug) if( c_l % 10 == 0) printf("MNR::CalcXS(): 1st dimension: %3d from %3d\n", c_l, n_l); double l2 = p_l[c_l]; @@ -491,7 +491,7 @@ namespace MNR double pt = TMath::Sqrt(pt2); // Factorisation scale double mf2 = this->GetMf2(xm2, pt2); - if(mf2 < fSF_min_mf2 || mf2 > fSF_max_mf2) + if(mf2 < fSF_min_mf2 || mf2 > fSF_max_mf2) { grid->NonPhys(c_l); continue; @@ -501,7 +501,7 @@ namespace MNR // Renormalisation scale double mr2 = this->GetMr2(xm2, pt2); double mr = TMath::Sqrt(mr2); - if(mr2 <= 0.0) + if(mr2 <= 0.0) { grid->NonPhys(c_l); continue; @@ -518,11 +518,11 @@ namespace MNR double xmf = TMath::Log(mf2 / xm2); double xmr = 4 * fC_pi * fC_b0 * TMath::Log(mr2 / mf2); // Loop over rapidity - for(int c_y = 0; c_y < n_y; c_y++) + for(int c_y = 0; c_y < n_y; c_y++) { double y = p_y[c_y]; // Loop over rapidity in parton CMS - for(int c_x3 = 0; c_x3 < fBn_x3; c_x3++) + for(int c_x3 = 0; c_x3 < fBn_x3; c_x3++) { double yprim = fBc_x3[c_x3]; double chyprim2 = fCk_chyprim2[c_x3]; @@ -549,18 +549,18 @@ namespace MNR double w_lo_qq = N * fCh0_hqh0qa[n2] * pdf_qq_t; // X-section int bw_t = 0; - if(nbw != 1) + if(nbw != 1) { double what_t = taut * fC_sh - 4 * xm2; bw_t = grid->FindWBin(what_t); } // Add all LO contributions - for(int c = 0; c < ncontr; c++) + for(int c = 0; c < ncontr; c++) { double& cs = grid->CS(c, c_l, c_y, bw_t); MNRContribution* contr = grid->GetContr(c); if(contr->fActive == 0) continue; - if(contr->fLO) + if(contr->fLO) { if(contr->fgg) cs += w_lo_gg; if(contr->fqq) cs += w_lo_qq; @@ -580,7 +580,7 @@ namespace MNR if(bFS_A&&!bFS_Q) pdf_qq_a_t *= -1; double w_nlo_qq_c = NN * ((me_qq_h2 - me_qq_h3c) * pdf_qq_t + (me_qq_h2_a - me_qq_h3c_a) * pdf_qq_a_t); // X-section - for(int c = 0; c < ncontr; c++) + for(int c = 0; c < ncontr; c++) { double& cs_c = grid->CS(c, c_l, c_y, bw_t); MNRContribution* contr = grid->GetContr(c); @@ -591,7 +591,7 @@ namespace MNR } } // Loop over t3 (3 body variable) - for(int c_x4 = fBn_x4 - 1; c_x4 >= 0; c_x4--) + for(int c_x4 = fBn_x4 - 1; c_x4 >= 0; c_x4--) { double px1 = px1t - fCk_pxtcor[c_x4]; double px2 = px2t - fCk_pxtcor[c_x4]; @@ -615,7 +615,7 @@ namespace MNR double me_qg_h3_r = kinok ? 0.0 : (fCh3_r_hqhpqg[n3] + xmf * fCh3_r_hqbpqg[n3]) / tx + fCh3_r_hqhlqg[n3] * lntx_o_tx; double me_qg_h3_a = (kinok || (bFS_Q && bFS_A)) ? 0.0 : fCh3_a_ashpqg[n3] / tx; double me_qg_h3_a_r = (kinok || (bFS_Q && bFS_A)) ? 0.0 : fCh3_a_r_ashpqg[n3] / tx; - if(bFS_A && !bFS_Q) + if(bFS_A && !bFS_Q) { pdf_qg_a *= -1; pdf_qg_a_r *= -1; @@ -624,14 +624,14 @@ namespace MNR // X-section int bw = 0; // Determine W bins, if cross section in mupltiple W bins is needed - if(nbw != 1) + if(nbw != 1) { double tau = taut / t32; double what = tau * fC_sh - 4 * xm2; bw = grid->FindWBin(what); } // Add all NLO contributions - for(int c = 0; c < ncontr; c++) + for(int c = 0; c < ncontr; c++) { double& cs = grid->CS(c, c_l, c_y, bw); MNRContribution* contr = grid->GetContr(c); @@ -655,7 +655,7 @@ namespace MNR for(int bw = 0; bw < n_w; bw++) grid->CS(c, bl, by, bw) *= 2; } - + // Constants const double MNR::fC_pi = 3.14159265359e0; const double MNR::fC_2pi = 6.28318530718e0; diff --git a/reactions/BaseHVQMNR/src/MNRFrag.cc b/reactions/BaseHVQMNR/src/MNRFrag.cc index 2a0bfc547..94093e0a5 100644 --- a/reactions/BaseHVQMNR/src/MNRFrag.cc +++ b/reactions/BaseHVQMNR/src/MNRFrag.cc @@ -32,7 +32,7 @@ namespace MNR fNRecalc = 0; } - Frag::~Frag() + Frag::~Frag() { //printf("OZ Frag::~Frag()\n"); this->ClearZ(); @@ -40,15 +40,15 @@ namespace MNR for(unsigned int f = 0; f < fFFrag.size(); f++) if(fFFrag[f]) delete fFFrag[f]; } - void Frag::ClearZ() + void Frag::ClearZ() { - if(fBnz) + if(fBnz) { delete fZc; fZc = NULL; delete fZw; fZw = NULL; - for(int f = 0; f < fNout; f++) + for(int f = 0; f < fNout; f++) { delete fWz[f]; fWz[f] = NULL; @@ -57,9 +57,9 @@ namespace MNR fBnz = 0; } - void Frag::ClearPrecalc() + void Frag::ClearPrecalc() { - if(fCGnpt && fCGny) + if(fCGnpt && fCGny) { delete fCGpt; fCGpt = NULL; @@ -71,7 +71,7 @@ namespace MNR fCGptf[bpt] = NULL; for(int by = 0; by < fCGny; by++) { - for(int bz = 0; bz < fBnz; bz++) + for(int bz = 0; bz < fBnz; bz++) { delete fCGyf[bpt][by][bz]; fCGyf[bpt][by][bz] = NULL; @@ -90,9 +90,9 @@ namespace MNR fCGnpt = fCGny = 0; } - void Frag::SetNz(int nz) + void Frag::SetNz(int nz) { - if(nz < 1) + if(nz < 1) { char str[256]; sprintf(str, "F: ERROR in Frag::SetNz(): nz %d < 1\n", nz); @@ -104,7 +104,7 @@ namespace MNR fZw = new double[fBnz]; double zprev, znext; zprev = 0.0; - for(int bz = 0; bz < fBnz+1; bz++) + for(int bz = 0; bz < fBnz+1; bz++) { znext = 1. * bz / fBnz; znext = TMath::Power(znext, 0.75); @@ -115,9 +115,9 @@ namespace MNR } } - void Frag::AddOut(TF1* ffrag, double M) + void Frag::AddOut(TF1* ffrag, double M) { - if(!fBnz) + if(!fBnz) { std::string str = "F: ERROR in Frag::AddOut(): first call Frag::SetNz()\n"; hf_errlog_(16123010, str.c_str(), str.length()); @@ -130,7 +130,7 @@ namespace MNR fNout++; } - void Frag::Precalc(Grid* grid, double xm) + void Frag::Precalc(Grid* grid, double xm) { fNRecalc++; // Fast variables @@ -145,19 +145,19 @@ namespace MNR fCGyf = new double***[fCGnpt]; double xm2 = xm * xm; double M2[fNout]; - for(int f = 0; f < fNout; f++) + for(int f = 0; f < fNout; f++) { M2[f] = fMh2[f]; if(fMh2[f] < 0.0) M2[f]=xm2; } double shy[fCGny]; - for(int by = 0; by < fCGny; by++) + for(int by = 0; by < fCGny; by++) { fCGy[by] = p_y[by]; shy[by] = TMath::SinH(fCGy[by]); } // Loop over pT (internally L) - for(int bpt = 0; bpt < fCGnpt; bpt++) + for(int bpt = 0; bpt < fCGnpt; bpt++) { double l2 = p_l[bpt]; double mt2 = xm2 / l2; @@ -168,18 +168,18 @@ namespace MNR fCGptf[bpt] = new double[fBnz]; fCGyf[bpt] = new double**[fCGny]; // Loop over y - for(int by = 0; by < fCGny; by++) + for(int by = 0; by < fCGny; by++) { double pl = mt * shy[by]; fCGyf[bpt][by] = new double*[fBnz]; // Loop over z - for(int bz = 0; bz < fBnz; bz++) + for(int bz = 0; bz < fBnz; bz++) { if(by == 0) fCGptf[bpt][bz] = fCGpt[bpt] * fZc[bz]; fCGyf[bpt][by][bz] = new double[fNout]; double plf = pl * fZc[bz]; // Loop over final states - for(int f = 0; f < fNout; f++) + for(int f = 0; f < fNout; f++) { double Mt = TMath::Sqrt(M2[f] + fCGptf[bpt][bz] * fCGptf[bpt][bz]); fCGyf[bpt][by][bz][f] = TMath::ASinH(plf / Mt); @@ -189,16 +189,16 @@ namespace MNR } } - void Frag::CalcCS(Grid* grid, double xm, std::vector<TH2D*> hcs) + void Frag::CalcCS(Grid* grid, double xm, std::vector<TH2D*> hcs) { // If it is first run or heavy-quark mass changed, recalculation is needed - if(bFirst || fLastxm != xm) + if(bFirst || fLastxm != xm) { this->Precalc(grid, xm); fLastxm = xm; } if(bFirst) bFirst=0; - + // Prepare output histograms and fast variables int ncontr = grid->GetNContr(); MNRContribution* contr[ncontr]; @@ -206,10 +206,10 @@ namespace MNR double* p_w = grid->WPtr(); double wgrid[ncontr][fCGnpt][fCGny][nw]; double* harray[ncontr][fNout]; - for(int c = 0; c < ncontr; c++) + for(int c = 0; c < ncontr; c++) { contr[c] = grid->GetContr(c); - for(int f = 0; f < fNout; f++) + for(int f = 0; f < fNout; f++) { TH2D* h = hcs[f * ncontr + c]; h->Reset(); @@ -220,19 +220,19 @@ namespace MNR for(int bw = 0; bw < nw; bw++) wgrid[c][bpt][by][bw] = grid->CS(c, bpt, by, bw); } - + // Check heavy-quark mass for nan if(xm != xm) return; double wfz[fNout][fBnz][nw]; - for(int f = 0; f < fNout; f++) + for(int f = 0; f < fNout; f++) { // Parton level if(fFFrag[f] == 0) continue; // 1D fragmentation function - if(fFFrag[f]->ClassName() == TString("TF1")) + if(fFFrag[f]->ClassName() == TString("TF1")) { double norm = 0.0; - for(int bz = 0; bz < fBnz; bz++) + for(int bz = 0; bz < fBnz; bz++) { double z = fZc[bz]; double wz = fZw[bz] * fFFrag[f]->Eval(z); @@ -244,13 +244,13 @@ namespace MNR wfz[f][bz][bw] /= norm; } // 2D fragmentation function - else if(fFFrag[f]->ClassName() == TString("TF2")) + else if(fFFrag[f]->ClassName() == TString("TF2")) { - for(int bw = 0; bw < nw; bw++) + for(int bw = 0; bw < nw; bw++) { double w = p_w[bw]; double norm = 0.0; - for(int bz = 0; bz < fBnz; bz++) + for(int bz = 0; bz < fBnz; bz++) { double z = fZc[bz]; double zw = fZw[bz]; @@ -260,7 +260,7 @@ namespace MNR for(int bz = 0; bz < fBnz; bz++) wfz[f][bz][bw] /= norm; } } - else + else { char str[256]; sprintf(str, "F: ERROR in Frag::CalcCS(): ff[%d] does not belong to TF1 or TF2\n", f); @@ -278,7 +278,7 @@ namespace MNR double pt2 = fCGpt[bptn]; double pt_w = pt2 - pt1; // Loop over y - for(int by = 0; by < fCGny - 1; by++) + for(int by = 0; by < fCGny - 1; by++) { int byn = by + 1; double y1 = fCGy[by]; @@ -286,13 +286,13 @@ namespace MNR double y_w = y2 - y1; double pty_w = pt_w * y_w; // Loop over z - for(int bz = 0; bz < fBnz; bz++) + for(int bz = 0; bz < fBnz; bz++) { // Loop over final states - for(int f = 0; f < fNout; f++) + for(int f = 0; f < fNout; f++) { double wf, pth1, pth2, yh11, yh12, yh21, yh22; - if(!fFFrag[f]) + if(!fFFrag[f]) { // parton level: no rescaling if(bz != 0) continue; wf = 1.0; @@ -301,7 +301,7 @@ namespace MNR yh11 = yh21 = y1; yh12 = yh22 = y2; } - else + else { wf = 0.0; pth1 = fCGptf[bpt][bz]; @@ -312,7 +312,7 @@ namespace MNR yh22 = fCGyf[bptn][byn][bz][f]; } // Loop over contributions - for(int c = 0; c < ncontr; c++) + for(int c = 0; c < ncontr; c++) { if(contr[c]->fActive == 0) continue; int offset = f * ncontr + c; @@ -326,7 +326,7 @@ namespace MNR int baynb = ay->GetNbins(); double xw = pth2 - pth1; // Loop over hadron pT bins - for(int bax = bax1; bax <= bax2; bax++) + for(int bax = bax1; bax <= bax2; bax++) { double xl = pth1; double xh = pth2; @@ -345,7 +345,7 @@ namespace MNR int bay2 = ay->FindBin(yh2); if(bay2 == 0 || bay1 == baynb + 1) continue; // Loop over hadron y bins - for(int bay = bay1; bay <= bay2; bay++) + for(int bay = bay1; bay <= bay2; bay++) { double yl = yh1; double yh = yh2; @@ -357,13 +357,13 @@ namespace MNR double dyr = (yh2 - yc) * ywcoef; int binxy = h->GetBin(bax, bay); // Loop over W - for(int bw = 0; bw < nw; bw++) + for(int bw = 0; bw < nw; bw++) { if(fFFrag[f]) wf = wfz[f][bz][bw]; // not parton level // Smooth final contrbution as linear 2D function - double w_parton = pty_w * (wgrid[c][bpt][by][bw] * dxr * dyr + - wgrid[c][bpt][byn][bw] * dxr * dy + - wgrid[c][bptn][by][bw] * dx * dyr + + double w_parton = pty_w * (wgrid[c][bpt][by][bw] * dxr * dyr + + wgrid[c][bpt][byn][bw] * dxr * dy + + wgrid[c][bptn][by][bw] * dx * dyr + wgrid[c][bptn][byn][bw] * dx * dy); harray[c][f][binxy] += w_parton * wf; } // W @@ -383,7 +383,7 @@ namespace MNR int f2 = f % 10; if(f1 == 0) { - if(f2 == 0) + if(f2 == 0) { // Kartvelishvili if(TString(meson) == TString("dzero")) f_meson = new TF1("f_kar_dzero", Frag::kar_dzero, 0., 1., 2); else if(TString(meson) == TString("dch")) f_meson = new TF1("f_kar_dch", Frag::kar_dch, 0., 1., 2); @@ -395,30 +395,30 @@ namespace MNR else if(TString(meson)==TString("dch")) f_meson = new TF1("f_bcfy_dch", Frag::bcfy_dch, 0., 1., 2); else f_meson = new TF1("f_bcfy", Frag::bcfy_v, 0., 1., 2); } - else if(f2==2) + else if(f2==2) { // Peterson f_meson = new TF1("f_pet", Frag::pet, 0., 1., 2); } } - else if(f1 == 1) + else if(f1 == 1) { - if(f2 == 0) + if(f2 == 0) { // Kartvelishvili "Misha-style" if(TString(meson) == TString("dzero")) f_meson = new TF2("f_karw_dzero", Frag::karw_dzero, 0., 1., 0., 10000., 3); else if(TString(meson) == TString("dch")) f_meson = new TF2("f_karw_dch", Frag::karw_dch, 0., 1., 0., 10000., 3); else f_meson = new TF2("f_karw", Frag::karw, 0., 1., 0., 10000., 3); } } - else if(f1 == 2) + else if(f1 == 2) { - if(f2 == 0) + if(f2 == 0) { // Kartvelishvili step if(TString(meson) == TString("dzero")) f_meson = new TF2("f_karstep_dzero", Frag::karstep_dzero, 0., 1., 0., 10000., 3); else if(TString(meson) == TString("dch")) f_meson = new TF2("f_karstep_dch", Frag::karstep_dch, 0., 1., 0., 10000., 3); else f_meson = new TF2("f_karstep", Frag::karstep, 0., 1., 0., 10000., 3); } } - if(!f_meson) + if(!f_meson) { char str[256]; sprintf(str, "F: ERROR in Frag::GetFragFunction(): unknown f %d\n", f); @@ -435,56 +435,56 @@ namespace MNR } return f_meson; } - - double Frag::bcfy_v(double* x, double* p) + + double Frag::bcfy_v(double* x, double* p) { - return 3.0 * p[0] * (p[1] * x[0] * TMath::Power((1. - x[0]), 2.) * TMath::Power((1. - (1. - p[1]) * x[0]), -6.) * - (2. - 2. * (3. - 2 * p[1]) * x[0] + 3. * (3. - 2. * p[1] + 4. * p[1] * p[1]) * x[0] * x[0] - 2. * (1. - p[1]) * - (4. - p[1] + 2 * p[1] * p[1]) * x[0] * x[0] * x[0] + (1. - p[1]) * (1. - p[1]) * (3. - 2. * p[1] + + return 3.0 * p[0] * (p[1] * x[0] * TMath::Power((1. - x[0]), 2.) * TMath::Power((1. - (1. - p[1]) * x[0]), -6.) * + (2. - 2. * (3. - 2 * p[1]) * x[0] + 3. * (3. - 2. * p[1] + 4. * p[1] * p[1]) * x[0] * x[0] - 2. * (1. - p[1]) * + (4. - p[1] + 2 * p[1] * p[1]) * x[0] * x[0] * x[0] + (1. - p[1]) * (1. - p[1]) * (3. - 2. * p[1] + 2. * p[1] * p[1]) * x[0] * x[0] * x[0] * x[0])); } - double Frag::bcfy_v_prim(double* x, double* p) + double Frag::bcfy_v_prim(double* x, double* p) { if(x[0] > (fM_dzero / fM_dstar)) return 0.; double newx = fM_dstar /fM_dzero * x[0]; return (fM_dstar / fM_dzero) * bcfy_v(&newx, p); } - double Frag::bcfy_p(double* x, double* p) + double Frag::bcfy_p(double* x, double* p) { - return p[0] * (p[1] *x[0] * TMath::Power((1. - x[0]), 2.) * TMath::Power((1. - (1. - p[1]) * x[0]), -6.) * - (6. - 18. * (1. - 2 * p[1]) * x[0] + (21. - 74. * p[1] + 68. * p[1] * p[1]) * x[0] * x[0] - 2. * - (1. - p[1]) * (6. - 19. * p[1] + 18. * p[1] *p[1]) * x[0] * x[0] * x[0] + 3. * (1. - p[1]) * (1. - p[1]) * + return p[0] * (p[1] *x[0] * TMath::Power((1. - x[0]), 2.) * TMath::Power((1. - (1. - p[1]) * x[0]), -6.) * + (6. - 18. * (1. - 2 * p[1]) * x[0] + (21. - 74. * p[1] + 68. * p[1] * p[1]) * x[0] * x[0] - 2. * + (1. - p[1]) * (6. - 19. * p[1] + 18. * p[1] *p[1]) * x[0] * x[0] * x[0] + 3. * (1. - p[1]) * (1. - p[1]) * (1. - 2. * p[1] + 2. * p[1] * p[1]) * x[0] * x[0] * x[0] * x[0])); } - double Frag::bcfy_dzero(double* x, double* p) + double Frag::bcfy_dzero(double* x, double* p) { return p[0] * (0.168 * bcfy_p(x, p) + 0.390 * bcfy_v_prim(x, p)); } - double Frag::kar_dzero(double* x, double* p) + double Frag::kar_dzero(double* x, double* p) { return p[0] * (0.168 * kar(x, p) + 0.390 * kar_prim(x, p)); } - double Frag::karw_dzero(double* x, double* p) + double Frag::karw_dzero(double* x, double* p) { return p[0] * (0.168 * karw(x, p) + 0.390 * karw_prim(x, p)); } - double Frag::karstep_dzero(double* x, double* p) + double Frag::karstep_dzero(double* x, double* p) { return p[0] * (0.168 * karstep(x, p) + 0.390 * karstep_prim(x, p)); } - double Frag::bcfy_dch(double* x, double* p) + double Frag::bcfy_dch(double* x, double* p) { return p[0] * (0.162 * bcfy_p(x, p) + 0.07153 * bcfy_v_prim(x, p)); } - double Frag::kar_dch(double* x, double* p) + double Frag::kar_dch(double* x, double* p) { return p[0] * (0.162 * kar(x, p) + 0.07153 * kar_prim(x, p)); } @@ -494,24 +494,24 @@ namespace MNR return p[0] * (0.162 * karw(x, p) + 0.07153 * karw_prim(x,p)); } - double Frag::karstep_dch(double* x, double* p) + double Frag::karstep_dch(double* x, double* p) { return p[0] * (0.162 * karstep(x, p) + 0.07153 * karstep_prim(x, p)); } - double Frag::kar(double* x, double* p) + double Frag::kar(double* x, double* p) { return p[0] * TMath::Power(x[0], p[1]) * (1 - x[0]); } - double Frag::kar_prim(double* x, double* p) + double Frag::kar_prim(double* x, double* p) { if(x[0] > (fM_dzero / fM_dstar)) return 0.; double newx = fM_dstar / fM_dzero * x[0]; return (fM_dstar / fM_dzero) * kar(&newx, p); } - double Frag::karw(double* x, double* p) + double Frag::karw(double* x, double* p) { double alpha = p[1] + p[2] / x[1]; // prevent very hard form (may lead to numerical problems) @@ -522,7 +522,7 @@ namespace MNR return kar(x, newp); } - double Frag::karw_prim(double* x, double* p) + double Frag::karw_prim(double* x, double* p) { if(x[0] > (fM_dzero / fM_dstar)) return 0.; double newx[2] = { fM_dstar / fM_dzero * x[0], x[1] }; diff --git a/reactions/BaseHVQMNR/src/MNRGrid.cc b/reactions/BaseHVQMNR/src/MNRGrid.cc index c751865a2..ac2fbcc4e 100644 --- a/reactions/BaseHVQMNR/src/MNRGrid.cc +++ b/reactions/BaseHVQMNR/src/MNRGrid.cc @@ -5,7 +5,7 @@ namespace MNR { - Grid::Grid() + Grid::Grid() { fNL = 0; fNY = 0; @@ -24,7 +24,7 @@ namespace MNR for(int i = 0; i < fNContr; i++) fCS[i] = NULL; } - Grid::Grid(int ncontr, MNRContribution** contr) + Grid::Grid(int ncontr, MNRContribution** contr) { fNL = 0; fNY = 0; @@ -43,7 +43,7 @@ namespace MNR for(int i = 0; i < fNContr; i++) fCS[i] = NULL; } - Grid::~Grid() + Grid::~Grid() { //printf("OZ Grid::~Grid()\n"); if(fL) delete fL; @@ -53,11 +53,11 @@ namespace MNR if(fW) delete fW; if(fBW) delete fBW; if(fCS) { - for(int c = 0; c < fNContr; c++) + for(int c = 0; c < fNContr; c++) { - for(int i = 0; i < fNL; i++) + for(int i = 0; i < fNL; i++) { - for(int j = 0; j < fNY; j++) + for(int j = 0; j < fNY; j++) { delete fCS[c][i][j]; } @@ -67,7 +67,7 @@ namespace MNR } delete fCS; } - if(fContr) + if(fContr) { for(int i = 0; i < fNContr; i++) { @@ -82,7 +82,7 @@ namespace MNR for(int i = 0; i < fNL; i++) this->NonPhys(i); } - void Grid::NonPhys(int bpt) + void Grid::NonPhys(int bpt) { for(int i = 0; i < fNY; i++) for(int j = 0; j < fNW; j++) @@ -90,7 +90,7 @@ namespace MNR this->CS(k, bpt, i, j) = -1.0; // negative non-physical value } - void Grid::Zero() + void Grid::Zero() { for(int bpt = 0; bpt < fNL; bpt++) for(int i = 0; i < fNY; i++) @@ -99,7 +99,7 @@ namespace MNR this->CS(k, bpt, i, j) = 0; } - void Grid::SetL(int n, double minpt, double maxpt, double xm) + void Grid::SetL(int n, double minpt, double maxpt, double xm) { double power = 0.25; fNL = n; @@ -109,7 +109,7 @@ namespace MNR double minpower = TMath::Power(minpt,power); double maxpower = TMath::Power(maxpt,power); double steppower = (maxpower - minpower) / fNL; - for(int i = 0; i < fNL; i++) + for(int i = 0; i < fNL; i++) { double pt = TMath::Power(minpower + i * steppower, 1.0 / power); fL[i] = xm2 / (xm2 + pt * pt); @@ -122,7 +122,7 @@ namespace MNR fMr = new double[fNL]; } - void Grid::FillPt(double* ptall, double xm) + void Grid::FillPt(double* ptall, double xm) { double xm2 = xm * xm; for(int i = 0; i < fNL; i++) ptall[i] = TMath::Sqrt(xm2 / fL[i] - xm2); @@ -144,14 +144,14 @@ namespace MNR fY = new double[fNY]; double step = (max - min) / (n - 1); for(int i = 0; i < n; i++) fY[i] = min + step * i; - for(int c = 0; c < fNContr; c++) + for(int c = 0; c < fNContr; c++) { if(fCS[c]) { for(int i = 0; i < fNL; i++) if(fCS[c][i]) delete fCS[c][i]; delete fCS[c]; } fCS[c] = new double**[fNL]; - for(int i = 0; i < fNL; i++) + for(int i = 0; i < fNL; i++) { fCS[c][i] = new double*[fNY]; for(int j = 0; j < fNY; j++) fCS[c][i][j] = NULL; @@ -159,9 +159,9 @@ namespace MNR } } - void Grid::SetW(int n, double min/* = 0.0*/, double max/* = 500.0*/) + void Grid::SetW(int n, double min/* = 0.0*/, double max/* = 500.0*/) { - if(!fNY || !fY) + if(!fNY || !fY) { std::string str = "F: ERROR in Grid::SetW(): first call Grid::SetY(), then Grid::SetW()\n"; hf_errlog_(16123010, str.c_str(), str.length()); @@ -187,7 +187,7 @@ namespace MNR } } - void Grid::SetW(double b1, double b2) + void Grid::SetW(double b1, double b2) { if(!fNY || !fY) { @@ -214,18 +214,18 @@ namespace MNR fCS[c][i][j] = new double[fNW]; } } - + int Grid::FindWBin(double w) { - for(int i = 0; i < fNW; i++) + for(int i = 0; i < fNW; i++) if(w < fBW[i+1] && w > fBW[i]) return i; return fNW - 1; } - void Grid::Print(double xm) + void Grid::Print(double xm) { double xm2 = xm * xm; - for(int c = 0; c < fNContr; c++) + for(int c = 0; c < fNContr; c++) { for(int bpt = 0; bpt < fNL; bpt++) { @@ -252,14 +252,14 @@ namespace MNR int nlorig = gridorig->NL(); double* lorig = gridorig->LPtr(); double spline_x[nlorig], spline_y[nlorig]; - for(int i = 0; i < nlorig; i++) + for(int i = 0; i < nlorig; i++) spline_x[nlorig-1-i] = lorig[i]; // Loop over contributions - for(int c = 0; c < gridorig->GetNContr(); c++) + for(int c = 0; c < gridorig->GetNContr(); c++) // Loop over y bins - for(int y = 0; y < gridorig->NY(); y++) + for(int y = 0; y < gridorig->NY(); y++) // Loop over W bins - for(int w = 0; w < gridorig->NW(); w++) + for(int w = 0; w < gridorig->NW(); w++) { // For spline: prepare X-section array of original grid in reversed order for(int l = 0; l < nlorig; l++) spline_y[nlorig-1-l] = gridorig->CS(c,l,y,w); diff --git a/reactions/BaseHVQMNR/src/Makefile.am b/reactions/BaseHVQMNR/src/Makefile.am index d34e8e621..2755e4861 100644 --- a/reactions/BaseHVQMNR/src/Makefile.am +++ b/reactions/BaseHVQMNR/src/Makefile.am @@ -3,14 +3,14 @@ if HAVE_ROOT -AM_CXXFLAGS = $(ROOT_CFLAGS) -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = $(ROOT_CFLAGS) -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -Wall -fPIC -Wno-deprecated lib_LTLIBRARIES = libbasehvqmnr_xfitter.la libbasehvqmnr_xfitter_la_SOURCES = ReactionBaseHVQMNR.cc MNR.cc MNRFrag.cc MNRGrid.cc hvqcrsx.f -# libbasehvqmnr_xfitter_la_LDFLAGS = place_if_needed +# libbasehvqmnr_xfitter_la_LDFLAGS = place_if_needed libbasehvqmnr_xfitter_la_LDFLAGS = $(ROOT_LIBS) -endif +endif dist_noinst_HEADERS = ../include ../yaml diff --git a/reactions/FFABM_DISCC/src/Makefile.am b/reactions/FFABM_DISCC/src/Makefile.am index f536e8518..8c5274b0c 100644 --- a/reactions/FFABM_DISCC/src/Makefile.am +++ b/reactions/FFABM_DISCC/src/Makefile.am @@ -1,7 +1,7 @@ # Created by AddReaction.py on 2017-10-09 -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -I$(srcdir)/../../../reactions/BaseDISCC/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -I$(srcdir)/../../../reactions/BaseDISCC/include -Wall -fPIC -Wno-deprecated lib_LTLIBRARIES = libffabm_discc_xfitter.la libffabm_discc_xfitter_la_SOURCES = ReactionFFABM_DISCC.cc diff --git a/reactions/FFABM_DISNC/src/Makefile.am b/reactions/FFABM_DISNC/src/Makefile.am index eace5562b..6fe39d7cf 100644 --- a/reactions/FFABM_DISNC/src/Makefile.am +++ b/reactions/FFABM_DISNC/src/Makefile.am @@ -1,7 +1,7 @@ # Created by AddReaction.py on 2017-09-29 -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -I$(srcdir)/../../../reactions/BaseDISNC/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -I$(srcdir)/../../../reactions/BaseDISNC/include -Wall -fPIC -Wno-deprecated lib_LTLIBRARIES = libffabm_disnc_xfitter.la libffabm_disnc_xfitter_la_SOURCES = ReactionFFABM_DISNC.cc diff --git a/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc b/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc index f5b2bf257..604a32457 100644 --- a/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc +++ b/reactions/HVQMNR_LHCb_7TeV_beauty/src/ReactionHVQMNR_LHCb_7TeV_beauty.cc @@ -1,4 +1,4 @@ - + /* @file ReactionHVQMNR_LHCb_7TeV_beauty.cc @date 2017-01-02 @@ -6,7 +6,7 @@ Created by AddReaction.py on 2017-01-02 Derived from ReactionBaseHVQMNR where basic stuff for HVQMNR calculation is implemented. - This class implements calculation for LHCb beauty measurement at 7 TeV + This class implements calculation for LHCb beauty measurement at 7 TeV [JHEP 1308 (2013) 117] [arXiv:1306.3663] */ @@ -25,9 +25,9 @@ extern "C" ReactionHVQMNR_LHCb_7TeV_beauty* create() { // initialize at the start of the computation int ReactionHVQMNR_LHCb_7TeV_beauty::atStart(const string &s) { - // ignore provided terminfo (s): all needed information has been set already + // ignore provided terminfo (s): all needed information has been set already // via setDatasetParameters(int dataSetID, map<string,string> pars) - + // ****************************************************************** // perform initialisation and pre-calculation // ****************************************************************** @@ -39,7 +39,7 @@ int ReactionHVQMNR_LHCb_7TeV_beauty::atStart(const string &s) // check HF scheme CheckHFScheme(); - + // read needed theory parameters UpdateParameters(); PrintParameters(); @@ -97,13 +97,13 @@ int ReactionHVQMNR_LHCb_7TeV_beauty::atStart(const string &s) int nbin_pt_bs = 15; double bin_pt_bs[16] = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,13.0,15.0,19.0,40.0}; _hCalculatedXSec[2]->SetBins(nbin_pt_bs, bin_pt_bs, nbin_y, bin_y); - + return 0; } // perform calculation (this is done once per iteration) -void ReactionHVQMNR_LHCb_7TeV_beauty::initAtIteration() +void ReactionHVQMNR_LHCb_7TeV_beauty::initAtIteration() { // protection against overdoing // TODO: remove this trick @@ -134,7 +134,7 @@ int ReactionHVQMNR_LHCb_7TeV_beauty::compute(int dataSetID, valarray<double> &va // TODO move to core xFitter //initAtIteration(); //printf("ReactionHVQMNR_LHCb_7TeV_beauty::compute() %d\n", dataSetID); - + // get histogramm with cross sections for needed dataset DataSet& ds = _dataSets[dataSetID]; TH2D* histXSec = NULL; @@ -160,6 +160,6 @@ int ReactionHVQMNR_LHCb_7TeV_beauty::compute(int dataSetID, valarray<double> &va else val[i] = val[i] * ds.FragFraction; } - + return 0; } diff --git a/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc b/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc index 661e9bd58..cd94eeb07 100644 --- a/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc +++ b/reactions/HVQMNR_LHCb_7TeV_charm/src/ReactionHVQMNR_LHCb_7TeV_charm.cc @@ -1,4 +1,4 @@ - + /* @file ReactionHVQMNR_LHCb_7TeV_charm.cc @date 2017-01-02 @@ -6,7 +6,7 @@ Created by AddReaction.py on 2017-01-02 Derived from ReactionBaseHVQMNR where basic stuff for HVQMNR calculation is implemented - This class implements calculation for LHCb charm measurement at 7 TeV + This class implements calculation for LHCb charm measurement at 7 TeV [Nucl. Phys. B 871 (2013), 1] [arXiv:1302.2864] */ @@ -25,9 +25,9 @@ extern "C" ReactionHVQMNR_LHCb_7TeV_charm* create() { // initialize at the start of the computation int ReactionHVQMNR_LHCb_7TeV_charm::atStart(const string &s) { - // ignore provided terminfo (s): all needed information has been set already + // ignore provided terminfo (s): all needed information has been set already // via setDatasetParameters(int dataSetID, map<string,string> pars) - + // ****************************************************************** // perform initialisation and pre-calculation // ****************************************************************** @@ -39,7 +39,7 @@ int ReactionHVQMNR_LHCb_7TeV_charm::atStart(const string &s) // check HF scheme CheckHFScheme(); - + // read needed theory parameters UpdateParameters(); PrintParameters(); @@ -91,7 +91,7 @@ int ReactionHVQMNR_LHCb_7TeV_charm::atStart(const string &s) double bin_y[6] = { 2.0, 2.5, 3.0, 3.5, 4.0, 4.5 }; int nbin_pt = 8; double bin_pt[9] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; - for(int f = 0; f < 4; f++) + for(int f = 0; f < 4; f++) _hCalculatedXSec[f]->SetBins(nbin_pt, bin_pt, nbin_y, bin_y); // Lambda_c rapidity differenential (for normalised cross section) int nbin_pt_lambdac = 1; @@ -101,13 +101,13 @@ int ReactionHVQMNR_LHCb_7TeV_charm::atStart(const string &s) int nbin_y_lambdac = 1; double bin_y_lambdac[2] = { 2.0, 4.5 }; _hCalculatedXSec[5]->SetBins(nbin_pt, bin_pt, nbin_y_lambdac, bin_y_lambdac); - + return 0; } // perform calculation (this is done once per iteration) -void ReactionHVQMNR_LHCb_7TeV_charm::initAtIteration() +void ReactionHVQMNR_LHCb_7TeV_charm::initAtIteration() { // protection against overdoing // TODO: remove this trick @@ -138,7 +138,7 @@ int ReactionHVQMNR_LHCb_7TeV_charm::compute(int dataSetID, valarray<double> &val // TODO move to core xFitter //initAtIteration(); //printf("ReactionHVQMNR_LHCb_7TeV_charm::compute() %d\n", dataSetID); - + // get histogramm with cross sections for needed dataset DataSet& ds = _dataSets[dataSetID]; TH2D* histXSec = NULL; @@ -170,6 +170,6 @@ int ReactionHVQMNR_LHCb_7TeV_charm::compute(int dataSetID, valarray<double> &val else val[i] = val[i] * ds.FragFraction; } - + return 0; } diff --git a/reactions/Hathor/include/ReactionHathor.h b/reactions/Hathor/include/ReactionHathor.h index 222709b9f..bf50bb79c 100644 --- a/reactions/Hathor/include/ReactionHathor.h +++ b/reactions/Hathor/include/ReactionHathor.h @@ -6,7 +6,7 @@ /** @class' ReactionHathor - @brief A wrapper class for Hathor reaction + @brief A wrapper class for Hathor reaction Based on the ReactionTheory class. Reads options produces 3d cross section. diff --git a/reactions/Hathor/src/ReactionHathor.cc b/reactions/Hathor/src/ReactionHathor.cc index 6bf7f8073..e51d83d14 100644 --- a/reactions/Hathor/src/ReactionHathor.cc +++ b/reactions/Hathor/src/ReactionHathor.cc @@ -70,7 +70,7 @@ int ReactionHathor::atStart(const string &s) // hf_errlog_(17081101, str.c_str(), strlen(str.c_str())); //} //_mtop = GetParam("mtp"); - + // !!!! //for(map<string, double* >::iterator it = _xfitter_pars.begin(); it != _xfitter_pars.end(); it++) //{ @@ -177,7 +177,7 @@ void ReactionHathor::setDatasetParameters(int dataSetID, map<std::string, std::s if(precisionLevel != Hathor::LOW && precisionLevel != Hathor::MEDIUM && precisionLevel != Hathor::HIGH) hf_errlog(17081102, "F: provided precision level = " + std::to_string(precisionLevel) + " not supported by Hathor"); hathor->setPrecision(precisionLevel); - + std::cout << " Hathor will use for this instance (" + std::to_string(dataSetID) + "):" << std::endl; double mt = *_mtopPerInstance[dataSetID]; std::cout << " mtop = " << mt << "[GeV] " << std::endl; diff --git a/reactions/KRunning/include/ReactionKRunning.h b/reactions/KRunning/include/ReactionKRunning.h index e0c7cb9a5..ce5b625f9 100644 --- a/reactions/KRunning/include/ReactionKRunning.h +++ b/reactions/KRunning/include/ReactionKRunning.h @@ -6,7 +6,7 @@ /** @class' ReactionKRunning - @brief A wrapper class for KRunning reaction + @brief A wrapper class for KRunning reaction Based on the ReactionTheory class. Reads options produces 3d cross section. @@ -30,15 +30,15 @@ class ReactionKRunning : public ReactionTheory virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err); protected: virtual int parseOptions(){ return 0;}; - + std::map<int, std::string> _type; std::map<int, std::string> _q; std::map<int, double> _qValue; std::map<int, std::string> _q0; std::map<int, int> _NPoints; - + double getAlphaS(double q) { return alphaS(q); } - double getMassMSbar(const double m0, const double q, const double as, const double as0) + double getMassMSbar(const double m0, const double q, const double as, const double as0) { const double c0 = 4.0 / 9.0; // m0 is m(m) diff --git a/reactions/KRunning/src/Makefile.am b/reactions/KRunning/src/Makefile.am index 3cc25786a..b3f7529d6 100644 --- a/reactions/KRunning/src/Makefile.am +++ b/reactions/KRunning/src/Makefile.am @@ -1,15 +1,14 @@ # Created by AddReaction.py on 2019-01-16 -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -Wall -fPIC -Wno-deprecated lib_LTLIBRARIES = libkrunning_xfitter.la libkrunning_xfitter_la_SOURCES = ReactionKRunning.cc -# libkrunning_xfitter_la_LDFLAGS = place_if_needed +# libkrunning_xfitter_la_LDFLAGS = place_if_needed datadir = ${prefix}/yaml/reactions/KRunning data_DATA = ../yaml/parameters.yaml dist_noinst_HEADERS = ../include ../yaml - \ No newline at end of file diff --git a/reactions/KRunning/src/ReactionKRunning.cc b/reactions/KRunning/src/ReactionKRunning.cc index 15910a5d9..26c35a8a5 100644 --- a/reactions/KRunning/src/ReactionKRunning.cc +++ b/reactions/KRunning/src/ReactionKRunning.cc @@ -1,4 +1,4 @@ - + /* @file ReactionKRunning.cc @date 2019-01-16 @@ -34,7 +34,7 @@ void ReactionKRunning::setDatasetParameters(int dataSetID, map<std::string, std: if(it->second != "as" && it->second != "massMSbarNLO") hf_errlog(19011503, "F: unsupported running type = " + it->second); _type[dataSetID] = it->second; - + // read scale it = pars.find("q"); if(!checkParam(it->second)) // value provided diff --git a/reactions/cbdiff/include/Reactioncbdiff.h b/reactions/cbdiff/include/Reactioncbdiff.h index a8a3210e8..9b9c97004 100644 --- a/reactions/cbdiff/include/Reactioncbdiff.h +++ b/reactions/cbdiff/include/Reactioncbdiff.h @@ -7,7 +7,7 @@ /** @class' Reactioncbdiff - @brief A wrapper class for cbdiff reaction + @brief A wrapper class for cbdiff reaction Based on the ReactionTheory class. Reads options produces 3d cross section. diff --git a/reactions/cbdiff/src/Makefile.am b/reactions/cbdiff/src/Makefile.am index 16647bbe2..1abd1707f 100644 --- a/reactions/cbdiff/src/Makefile.am +++ b/reactions/cbdiff/src/Makefile.am @@ -3,12 +3,12 @@ if HAVE_ROOT -AM_CXXFLAGS = $(ROOT_CFLAGS) -I$(srcdir)/../../../reactions/BaseHVQMNR/include -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = $(ROOT_CFLAGS) -I$(srcdir)/../../../reactions/BaseHVQMNR/include -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -Wall -fPIC -Wno-deprecated lib_LTLIBRARIES = libcbdiff_xfitter.la libcbdiff_xfitter_la_SOURCES = Reactioncbdiff.cc -# libcbdiff_xfitter_la_LDFLAGS = place_if_needed +# libcbdiff_xfitter_la_LDFLAGS = place_if_needed libcbdiff_xfitter_la_LDFLAGS = -lbasehvqmnr_xfitter -L$(srcdir)/../../../reactions/BaseHVQMNR/src/.libs datadir = ${prefix}/yaml/reactions/cbdiff @@ -17,4 +17,4 @@ data_DATA = ../yaml/parameters.yaml endif dist_noinst_HEADERS = ../include ../yaml - + diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index b38fabe9a..d57743e8d 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -1,4 +1,4 @@ - + /* @file Reactioncbdiff.cc @date 2019-02-01 diff --git a/src/TheorEval.cc b/src/TheorEval.cc index df2c46679..d31c7aaf6 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -18,7 +18,7 @@ #include "ReactionTheory.h" #include "xfitter_cpp.h" #include "get_pdfs.h" -#include <string.h> +#include <string.h> #include <yaml-cpp/yaml.h> #include "xfitter_pars.h" @@ -34,19 +34,19 @@ using namespace std; std::function<double(double const& Q)> gAlphaS; double alphaS(double const& Q) { - return gAlphaS(Q); + return gAlphaS(Q); } // also fortran interface extern "C" { double alphasdef_(double const& Q) { - return gAlphaS(Q); + return gAlphaS(Q); } } -TheorEval::TheorEval(const int dsId, const int nTerms, const std::vector<string> stn, const std::vector<string> stt, +TheorEval::TheorEval(const int dsId, const int nTerms, const std::vector<string> stn, const std::vector<string> stt, const std::vector<string> sti, const std::vector<string> sts, const string& expr) : _dsId(dsId), _nTerms(nTerms) { for (int it= 0 ; it<nTerms; it++ ){ @@ -87,7 +87,7 @@ TheorEval::initTheory() this->convertToRPN(sl); } -int +int TheorEval::assignTokens(list<tToken> &sl) { stringstream strexpr(_expr); @@ -99,7 +99,7 @@ TheorEval::assignTokens(list<tToken> &sl) while (1){ strexpr.get(c); if ( strexpr.eof() ) break; - if ( isspace(c) ) continue; // skip whitespaces. + if ( isspace(c) ) continue; // skip whitespaces. // Oh noes! doesn't work after fortran reading expression with spaces :(. if ( isdigit(c) ) { // process numbers term.assign(1,c); @@ -134,7 +134,7 @@ TheorEval::assignTokens(list<tToken> &sl) term.assign(1,c); while (strexpr.get(c) ) { if ( isalnum(c) ) term.append(1,c); - else { + else { strexpr.putback(c); break; } @@ -252,9 +252,9 @@ TheorEval::assignTokens(list<tToken> &sl) continue; } */ - + vector<string>::iterator found_term = find(_termNames.begin(), _termNames.end(), term); - if ( found_term == _termNames.end() ) { + if ( found_term == _termNames.end() ) { cout << "Undeclared term " << term << " in expression " << _expr << endl; return -1; } else { @@ -329,8 +329,8 @@ TheorEval::convertToRPN(list<tToken> &sl) _exprRPN.push_back(tknstk.top()); tknstk.pop(); } - - + + /* vector<tToken>::iterator it= _exprRPN.begin(); for (;it!=_exprRPN.end(); it++){ @@ -338,13 +338,13 @@ TheorEval::convertToRPN(list<tToken> &sl) } cout << endl; */ - + } int TheorEval::initTerm(int iterm, valarray<double> *val) { - + string term_type = _termTypes.at(iterm); if ( term_type == string("reaction")) { this->initReactionTerm(iterm, val); @@ -408,15 +408,15 @@ TheorEval::initReactionTerm(int iterm, valarray<double> *val) if ( gNameReaction.find(term_source) == gNameReaction.end()) { string path_to_lib=PREFIX+string("/lib/")+libname; void *theory_handler = dlopen(path_to_lib.c_str(), RTLD_NOW); - if (theory_handler == NULL) { + if (theory_handler == NULL) { std::cerr<<"Failed to open shared library "<<path_to_lib<<" for "<<term_source<<"; error:\n" <<dlerror()<<"\n Check that the correct library is given in Reactions.txt"<<std::endl; hf_errlog(16120502,"F: Failed to open reaction shared library, see stderr for details"); } - + // reset errors dlerror(); - + create_t *dispatch_theory = (create_t*) dlsym(theory_handler, "create"); rt = dispatch_theory(); gNameReaction[term_source] = rt; @@ -441,7 +441,7 @@ TheorEval::initReactionTerm(int iterm, valarray<double> *val) rt->setxFitterParametersS(XFITTER_PARS::gParametersS); rt->setxFitterparametersVec(XFITTER_PARS::gParametersV); rt->setxFitterparametersYaml(XFITTER_PARS::gParametersY); - + // Override some global pars for reaction specific: if ( XFITTER_PARS::gParametersY[term_source] ) { rt->resetParameters(XFITTER_PARS::gParametersY[term_source]); @@ -453,7 +453,7 @@ TheorEval::initReactionTerm(int iterm, valarray<double> *val) //Retrieve evolution - xfitter::BaseEvolution* evo = xfitter::get_evolution(evoName); + xfitter::BaseEvolution* evo = xfitter::get_evolution(evoName); // rt->setEvolFunctions( &HF_GET_ALPHASQ_WRAP, &g2Dfunctions); //This is not how we should pass PDFs and alphas //pending TermData rewrite @@ -474,7 +474,7 @@ TheorEval::initReactionTerm(int iterm, valarray<double> *val) string text = "F:Failed to init reaction " +term_source ; hf_errlog_(16120803,text.c_str(),text.size()); }; - + } else { rt = gNameReaction[term_source]; } @@ -484,7 +484,7 @@ TheorEval::initReactionTerm(int iterm, valarray<double> *val) // Set bins rt->setBinning(_dsId*1000+iterm, &gDataBins[_dsId]); - + // split term_info into map<string, string> according to key1=value1:key2=value2:key=value3... map<string, string> pars = SplitTermInfo(term_info); LoadParametersFromYAML(pars,rt->getReactionName()); @@ -506,10 +506,10 @@ TheorEval::setBins(int nBinDim, int nPoints, int *binFlags, double *allBins) _binFlags.push_back(binFlags[ip]); } - for(int ibd = 0; ibd < nBinDim; ibd++){ - vector<double> bins; - bins.clear(); - for(int ip = 0; ip<nPoints; ip++){ + for(int ibd = 0; ibd < nBinDim; ibd++){ + vector<double> bins; + bins.clear(); + for(int ip = 0; ip<nPoints; ip++){ bins.push_back(allBins[ip*10 + ibd]); } _dsBins.push_back(bins); @@ -694,15 +694,15 @@ TheorEval::getReactionValues() ReactionTheory* rt = (itm->first).first; int idTerm = (itm->first).second; map<string, valarray<double> > errors; - + int result = rt->compute(_dsId*1000+idTerm, *(itm->second), errors); - + if (result != 0) { string text = "F:(from TheorEval::getReactionValues) Failed to compute theory"; hf_errlog_(16081202,text.c_str(),text.size()); } } - + return 1; } @@ -812,7 +812,7 @@ const std::string GetParamDS(const std::string& ParName, const std::string& DSna } else { string text = "F: missing value field for parameter " + ParName; - hf_errlog_(17041101,text.c_str(),text.size()); + hf_errlog_(17041101,text.c_str(),text.size()); return ""; } } diff --git a/src/mc_errors.f b/src/mc_errors.f index 4f8921991..bd25cc73a 100644 --- a/src/mc_errors.f +++ b/src/mc_errors.f @@ -1,6 +1,6 @@ C------------------------------------------------------------ C -!> MC method for propagating of the data uncertainties. +!> MC method for propagating of the data uncertainties. !> Creat a replica of the data, which fluctuates accoding to their uncertainteis. C C------------------------------------------------------------ @@ -26,17 +26,17 @@ C To be used as a seed: C Single precision here: real rndsh(3) ! additive, poisson, linear $ ,ranflat -C +C double precision rand_shift(NSYS) double precision r_sh_fl(NSYS) double precision f_un - parameter (f_un = 2.0) ! translate 0.:-1 to -1.:1. - + parameter (f_un = 2.0) ! translate 0.:-1 to -1.:1. + real amu integer npoi, ierr C For log normal random shifts: real lsig, lmu,lrunif - + double precision epsilon ! estimated acceptance/lumi correction double precision data_in double precision estat_in, ecor_in, euncor_in, etot_in !> Input uncertainites @@ -44,14 +44,14 @@ C For log normal random shifts: double precision scaleF integer scaling_type - + C functions: real logshift double precision alnorm - + C------------------------------------------------------------ - + cv initialise the random shifts do isys=1,nsys @@ -62,7 +62,7 @@ cv initialise the random shifts C C Loop over systematic sources: -C +C do isys=1,nsys call rnorml(rndsh,1) ! gauss random number call ranlux(ranflat,1) ! uniform random number @@ -79,7 +79,7 @@ C C Loop over the data: C do n0=1,npoints - call rnorml(rndsh,3) + call rnorml(rndsh,3) call ranlux(ranflat,1) if (lrandData) then @@ -92,7 +92,7 @@ C do isys=1,nsys cv test different distributions -cv first for systematic uncert, then for stat. +cv first for systematic uncert, then for stat. if (systype.eq.1) then ! gauss syst C ! Introduce asymmetric errors, for Gaussian case only: @@ -105,37 +105,37 @@ C ! Introduce asymmetric errors, for Gaussian case only: s = s*(1.+ BetaAsym(isys,2,n0) * rand_shift(isys)) endif endif - + elseif (systype.eq.2) then ! uniform s = s*(1. + beta(isys,n0) * r_sh_fl(isys)) - + elseif (systype.eq.3) then ! lognormal if (beta(isys,n0).ne.0) then - lsig=beta(isys,n0) + lsig=beta(isys,n0) lmu=1. lrunif=r_sh_fl(isys)/f_un + 0.5 ! Expect random number between 0 and 1. s=s*logshift(lmu,lsig,lrunif) c print*,'log...', n0,isys, -c $ lrunif, beta(isys,n0), +c $ lrunif, beta(isys,n0), c $ s,logshift(lmu,lsig,lrunif) endif endif ! endif (sys for systematic shifts) enddo ! end loop over the systematic shifts - + voica=s ! save cross section before the stat shift -CV now choose sta (advised gauss OR poisson) - +CV now choose sta (advised gauss OR poisson) + if (statype.eq.1) then ! gauss C do separate fluctuations for stat-const, stat-poisson and stat-linear pieces - s = s + s = s $ + sqrt( e_uncor_const(n0)**2 + e_stat_const(n0)**2) - $ * daten(n0)*rndsh(1) + $ * daten(n0)*rndsh(1) $ + sqrt( e_uncor_poisson(n0)**2 + e_stat_poisson(n0)**2) $ * sqrt(abs(daten(n0)*sorig))*rndsh(2) $ + e_uncor_mult(n0)*sorig*rndsh(3) - + c if (alpha(n0).eq.0) then c s = 0.1 c alpha(n0) = 1.e6 @@ -177,7 +177,7 @@ C Reset uncor: C Get acceptance/lumi correction, called "epsilon" epsilon = data_in/estat_in**2 - + C Expected number of events: amu = epsilon*theo(n0) call RNPSSN(amu, Npoi, Ierr) @@ -185,9 +185,9 @@ C Expected number of events: s = (s/THEO(n0)) * Npoi/epsilon C Also apply fluctuations due to uncorrelated systematics: - + C New absolute uncor: - euncor_out = euncor_in / data_in * s ! rescale to new value + euncor_out = euncor_in / data_in * s ! rescale to new value if (statype.eq.14) then s = s + rndsh(1)*euncor_in @@ -217,9 +217,9 @@ C Store uncor in %: e_tot(n0) = sqrt(euncor_out**2+estat_out**2+ecor_in**2) $ /s*100.0 endif - - - print + + + print $ '(''Original, systematics and stat. shifted data:'',i4,5E12.4)' $ , n0,sorig, voica,s,alpha(n0),e_unc(n0)/100.*s @@ -254,27 +254,27 @@ C - poisson ("Poisson") keep error * sqrt(old/newVal) unmodified e_uncor_const(n0) = e_uncor_const(n0) * scaleF e_stat_const(n0) = e_stat_const(n0) * scaleF e_tot(n0) = e_tot(n0) * scaleF - + C Also correlated systematicss: do isys=1,nsys - scaling_type = SysScalingType(isys) - + scaling_type = SysScalingType(isys) + if ( $ (scaling_type .eq. isNoRescale) $ .or. (LForceAdditiveData(n0) ) - $ ) then ! additive, keep absolute + $ ) then ! additive, keep absolute beta(isys,n0) = beta(isys,n0) * scaleF omega(isys,n0) = omega(isys,n0) * scaleF elseif (scaling_type.eq. isLinear) then ! mult, do nothing - beta(isys,n0) = beta(isys,n0) - omega(isys,n0) = omega(isys,n0) - elseif (scaling_type.eq. isPoisson) then + beta(isys,n0) = beta(isys,n0) + omega(isys,n0) = omega(isys,n0) + elseif (scaling_type.eq. isPoisson) then beta(isys,n0) = beta(isys,n0) * sqrt(scaleF) - omega(isys,n0) = omega(isys,n0) * sqrt(scaleF) + omega(isys,n0) = omega(isys,n0) * sqrt(scaleF) endif enddo - + DATEN(n0) = s C update alpha: @@ -284,12 +284,12 @@ C update alpha: $ +e_stat_const(n0)**2 $ +e_uncor_poisson(n0)**2) $ *daten(n0) - - enddo + + enddo C call HF_stop - - + + C------------------------------------------------------------ end @@ -307,7 +307,7 @@ C !> @param[in] am mean value !> @param[in] as RMS C -C Input: am -- mean value +C Input: am -- mean value C as -- RMS C---------------------------------------------------- function alnorm(am,as) @@ -323,29 +323,29 @@ C---------------------------------------------------- COMMON/SLATE/IS(40) cv am=1 cv as=1 - + C SG: Comment out initialization of the seed, already done in read_data ! Csg call datime(ndate,ntime) Csg ntime = ntime*100+is(6) Csg isrnd = ntime - + Csg call rmarin(isrnd,0,0) cv call rnorml(normrnd1,1) cv call rnorml(normrnd2,1) call ranmar(normrnd1,1) - call ranmar(normrnd2,1) + call ranmar(normrnd2,1) cv r1 = rand() cv r2 = rand() r1 = normrnd1 r2 = normrnd2 - + rr = sqrt(-2*log(r1))*sin(2*pi*r2) stdlog = sqrt(log(1+(as/am)**2 ) ) amlog = log(am) - 0.5 * log(1+(as/am)**2) - + cv stdlog=0.548662 cv amlog =-0.150515 @@ -353,16 +353,16 @@ cv amlog =-0.150515 alnorm = dble(exp(rr)) - + cv print*,'voica gets the lognorml distribution....',alnorm end -c real function logshift(mu,sig,runif) +c real function logshift(mu,sig,runif) C----------------------------------------------------------------------- C- -C- Purpose and Methods: +C- Purpose and Methods: C- C- Inputs : C- Outputs : @@ -372,12 +372,12 @@ C- Created 12-JUN-2008 Voica Radescu C- C----------------------------------------------------------------------- * ------------------------------------------- - real function logshift(mmu,ssig,rrunif) + real function logshift(mmu,ssig,rrunif) * ------------------------------------------- IMPLICIT NONE - + real zeroth, ANS,ex2,runif real mu, sig,x2, mu2, sig2,z1,z2 external zeroth @@ -401,7 +401,7 @@ C----------------------------------------------------------------------- C----------------------------------------------------------------------- C- -C- Purpose and Methods: +C- Purpose and Methods: C- C- Inputs : C- Outputs : @@ -426,7 +426,7 @@ C---------------------------------------------------------------------- COMMON/PARAM/mu,sig,runif -cv transform the formula from mean, std of x to log(x) +cv transform the formula from mean, std of x to log(x) stdlog = sqrt(log(1+(sig/mu)**2 ) ) amlog = log(mu) - 0.5 * log(1+(sig/mu)**2) @@ -458,7 +458,7 @@ C Common from CERNLIB datime: C------------------------------------------- if (iseedmc.ne.0) then C Seed from the steering: - icount = iseedmc + icount = iseedmc else C Seed from current time call datime(ndate,ntime) diff --git a/src/store_output.f b/src/store_output.f index 2e060f276..a4d3c62b9 100644 --- a/src/store_output.f +++ b/src/store_output.f @@ -30,7 +30,7 @@ C-------------------------------------------------------------- + rt_flc,rt_f1c,rt_f2b, + rt_flb,rt_f1b - double precision xnu, xrho, Qsimple + double precision xnu, xrho, Qsimple double precision F123(3) character*48 name @@ -64,7 +64,7 @@ C-------------------------------------------------------------- integer iq,jx,j ! Store how many PDFs are written out: - integer NPdfs + integer NPdfs parameter (NPdfs = 15) C--------------------------------------------------------------- @@ -78,7 +78,7 @@ C--------------------------------------------------------------- nf = 5. if (q2.lt.qb) nf=4. if (q2.lt.qc) nf=3. - + if (idx.gt.0) then name =base(1:idx)//tag(iq2)//'.txt' h1name = base(1:idx)//tag(iq2)//'.txt' @@ -136,7 +136,7 @@ c open(82,file=h1name) else D=pdf(1)+pdf(-3) endif - + umin=pdf(2)-pdf(-2) dmin=pdf(1)-pdf(-1) @@ -145,7 +145,7 @@ c open(82,file=h1name) else d_Ubar=pdf(-2) endif - + if (q2.gt.qb) then d_Dbar=pdf(-1)+pdf(-3)+pdf(-5) else @@ -165,7 +165,7 @@ c open(82,file=h1name) if (q2.gt.qc) then chm=pdf(-4) endif - + bot = 0.d0 if (q2.gt.qb) then bot=pdf(-5) @@ -191,7 +191,7 @@ c open(82,file=h1name) enddo close(81) - + 999 continue @@ -199,13 +199,13 @@ c open(82,file=h1name) cv store for LHAPDF cv HERAPDF in LHAPDF5 format -cv PDFs are Glue Uval Dval Ubar Dbar Str Chrm Bot +cv PDFs are Glue Uval Dval Ubar Dbar Str Chrm Bot DO Iq=0,160 Q2=10**(8.30103/160D0*Iq ) q2valpdf(iq) = q2 alphas(iq)=hf_get_alphas(q2) enddo - + DO jx=0,160 IF(Jx.LE.80)THEN @@ -215,22 +215,22 @@ cv PDFs are Glue Uval Dval Ubar Dbar Str Chrm Bot ENDIF xvalpdf(jx) = x enddo - + C Prepare LHAPDF output do iq2=1,23 write (76,'(7E12.4)') (q2valpdf((iq2-1)*7+j),j=0,6) enddo - + do jx=1,23 write (76,'(7E12.4)') (xvalpdf((jx-1)*7+j),j=0,6) enddo - + do iq2=1,23 write (76,'(7E12.4)') (alphas((iq2-1)*7+j),j=0,6) enddo - + DO Iq=0,160 Q2=10**(8.30103/160D0*Iq ) @@ -247,7 +247,7 @@ c v grid(1+jx)=x write(76,666) PDFl(0), PDFl(2)-PDFl(-2), PDFl(1)-PDFl(-1), $ PDFl(-2), PDFl(-1), $ PDFl(3), PDFl(4), PDFl(5) - + enddo ENDDO @@ -266,22 +266,22 @@ c v grid(1+jx)=x C-------------------------------------------------- C> \brief Write results of fit -C> \details Write to a text file binning, +C> \details Write to a text file binning, C> data points with uncorrelated and total uncertainties, -C> fitted points and pulls. +C> fitted points and pulls. C-------------------------------------------------- subroutine WriteFittedPoints implicit none - + #include "steering.inc" #include "ntot.inc" #include "datasets.inc" #include "indata.inc" #include "systematics.inc" #include "theo.inc" - + integer i,j,index,PlotVarColIdx,PreviousPlots double precision PlotVar,PullVar @@ -295,7 +295,7 @@ C-------------------------------------------------- do i=1,ndatasets write(90,*)DATASETNUMBER(i) write(90,*) DATASETLABEL(i) - + do j=1,GNPlots(i) PreviousPlots = PreviousPlots + 1 write(90,16) 'Plot',j,'@',TRIM(GPlotOptions(PreviousPlots)) @@ -319,14 +319,14 @@ c & ' +-toterr theory pull dataset ' if(PlotVarColIdx.eq.0.and.GNPlots(i).eq.0) then if(Gplotvarcol(i).eq.'undefined') then call HF_Errlog(13021000, - $ 'W: Plotting options not set for data set: ' + $ 'W: Plotting options not set for data set: ' $ //DATASETLABEL(i)) else call HF_Errlog(13012901, $ 'W: Plotting: Can not find one of the columns') endif PlotVar = 0. - else + else if ( PlotVarColIdx.eq.0) then PlotVar = 0 else @@ -334,14 +334,14 @@ c & ' +-toterr theory pull dataset ' endif endif -c set pull to zero if no unc error +c set pull to zero if no unc error if(ALPHA_MOD(index).gt.0d0) then PullVar = (DATEN(index)-THEO_MOD(index))/ALPHA_MOD(index) - else + else PullVar = 0d0 endif - write(90,'(1X,11(e11.5,1X),i4,i4,A1,E11.5)') + write(90,'(1X,11(e11.5,1X),i4,i4,A1,E11.5)') $ AbstractBins(1,index), $ AbstractBins(2,index),AbstractBins(3,index), & DATEN(index),ALPHA_MOD(index), @@ -357,8 +357,8 @@ cv write(34,*), index,i,DATASETNUMBER(i) enddo 111 format(1X, F10.3, 2X, F12.6, 2X, 3(F12.6,2X)) close(90) - - + + RETURN END @@ -390,7 +390,7 @@ C------------------------------------------------------------- character*300 fname double precision, allocatable :: errIterate(:,:) - + C------------------------------------------------------------- if (ifcn3.lt.10) then @@ -475,7 +475,7 @@ C------------------------------------------------------------------- print *,' ' print *,' ' print *,'======================================================' - print '('' Use NNPDF overfitting method. + print '('' Use NNPDF overfitting method. $ Prepare output PDF files '')' print '('' Best FCN3 call='',i4,'' out of '',i4,'' calls'')', $ iminCont,nfcn3 @@ -495,10 +495,10 @@ C call Evolution !I'm commenting this out because it conflicts with C the new evolution interface, but I do not know why it was here C --Ivan -C ! Ready to store: +C ! Ready to store: cv open (76,file='output/lhapdf.block.txt',status='unknown') cv call store_pdfs('output/pdfs_q2val_') -C store the optimal values +C store the optimal values open (76,file=TRIM(OutDirName)//'/opt_lhapdf.block.txt', & status='unknown') @@ -546,7 +546,7 @@ C---------------------------------------------------- #include "theo.inc" integer i,j,index,k,reacindx - + double precision currEcharge open(90,file='./'//TRIM(OutDirName)//'/heraverager.dat') @@ -556,7 +556,7 @@ C write(90,*)ndatasets write(90,*) '!* ' - write(90,*) + write(90,*) $ '!* Swimming set from XFITTER for the HERAverager' write(90,*) '&Data' write(90,*) ' Name = ''Swimming'' ' @@ -596,8 +596,8 @@ C write(90,*)ndatasets endif do j=1,NDATAPOINTS(i) index = DATASETIDX(i,j) - - write(90,'(1X,i5,1X,4(e11.5,1X),i4)') + + write(90,'(1X,i5,1X,4(e11.5,1X),i4)') $ reacindx, $ AbstractBins(1,index), $ AbstractBins(2,index), @@ -617,7 +617,7 @@ C---------------------------------------------------------------- C> \brief Write theory prediction in format of input data tables. C> \param NNuisance number of error sets C> \param Theo_cent central value of theory predction -C> \param SymmetricPDFErr use symmetric or assymmetric errros (beta vs betaasym) +C> \param SymmetricPDFErr use symmetric or assymmetric errros (beta vs betaasym) C---------------------------------------------------------------- Subroutine WriteTheoryFiles(NNuisance,Theo_cent,SymmetricPDFErr) implicit none @@ -631,7 +631,7 @@ C---------------------------------------------------------------- double precision Theo_cent(Ntot) logical SymmetricPDFErr integer iset, ipoint, j, i - + character*2 c C--------------------------------------------------------- @@ -648,8 +648,8 @@ C--------------------------------------------------------- $ ,file=Trim(OutDirName)//'/theo_'//c//'.dat' $ ,status='unknown') - ! Write a header - write (51,'(''* Theory file for '',A)') + ! Write a header + write (51,'(''* Theory file for '',A)') $ Trim(DATASETLABEL(iset)) write (51,'(''&Data '')') @@ -658,7 +658,7 @@ C--------------------------------------------------------- write (51,'('' NData = '',I5)') NDATAPOINTS(iset) if (SymmetricPDFErr) then - write (51,'('' NColumn = '',I5)') NNuisance+1 + write (51,'('' NColumn = '',I5)') NNuisance+1 $ + DATASETBinningDimension(iset) write (51, @@ -670,11 +670,11 @@ C--------------------------------------------------------- $ ( trim(DATASETBinNames(i,iset)), $ i=1,DATASETBinningDimension(iset) ), 'theory', $ ( trim(System(nsys+i)),i=1,NNuisance-1) - write (51,'(A,''"'')') + write (51,'(A,''"'')') $ ( trim(System(nsys+i)),i=NNuisance,NNuisance) write (51,'('' Percent = '',I3,''*True'')') NNuisance else - write (51,'('' NColumn = '',I5)') NNuisance*2+1 + write (51,'('' NColumn = '',I5)') NNuisance*2+1 $ + DATASETBinningDimension(iset) write (51, $'('' ColumnType = '',I1,''*"Bin","Theory",'',i3,''*"Error"'')') @@ -683,12 +683,12 @@ C--------------------------------------------------------- $ ,advance='no' ) $ ( trim(DATASETBinNames(i,iset)), $ i=1,DATASETBinningDimension(iset) ), 'theory', - $ ( trim(System(nsys+i))//'+', + $ ( trim(System(nsys+i))//'+', $ trim(System(nsys+i))//'-',i=1,NNuisance-1) - write (51,'(A,''",'',''"'',A,''"'')') - $ ( trim(System(nsys+i))//'+', + write (51,'(A,''",'',''"'',A,''"'')') + $ ( trim(System(nsys+i))//'+', $ trim(System(nsys+i))//'-',i=NNuisance,NNuisance) - write (51,'('' Percent = '',I3,''*True'')') NNuisance*2 + write (51,'('' Percent = '',I3,''*True'')') NNuisance*2 endif write (51,'(''&End '')') @@ -696,19 +696,19 @@ C--------------------------------------------------------- do i = 1, NDATAPOINTS(iset) ipoint = Datasetidx(iset,i) if (SymmetricPDFErr) then - write (51,'(200E12.4)') + write (51,'(200E12.4)') $ ( AbstractBins(j,ipoint),j=1,DATASETBinningDimension(iset)), $ theo_cent(ipoint), $ ( -Beta(j,ipoint)*100.0, ! negative sign, since it is inverted in lhapdferrors.cc $ j=NSys+1 - $ ,NSys+NNuisance) + $ ,NSys+NNuisance) else - write (51,'(200E14.6)') + write (51,'(200E14.6)') $ ( AbstractBins(j,ipoint),j=1,DATASETBinningDimension(iset)), $ theo_cent(ipoint), - $ ( -BetaAsym(j,1,ipoint)*100.0, -BetaAsym(j,2,ipoint)*100., + $ ( -BetaAsym(j,1,ipoint)*100.0, -BetaAsym(j,2,ipoint)*100., $ j=NSys+1 - $ ,NSys+NNuisance) + $ ,NSys+NNuisance) endif enddo close (51) diff --git a/src/xfitter_pars.cc b/src/xfitter_pars.cc index a19c538d3..01dc305c0 100644 --- a/src/xfitter_pars.cc +++ b/src/xfitter_pars.cc @@ -3,7 +3,7 @@ @date Sun 16 April 2017 @author SG - Contains functions to read parameters.yaml, + Contains functions to read parameters.yaml, global maps to store parameters, and fortran interface functions. */ @@ -23,18 +23,18 @@ extern "C" { void parse_params_(); //!< Fortran callable parsing /// Interface to minuit parameters - void addexternalparam_(const char name[], const double &val, + void addexternalparam_(const char name[], const double &val, const double &step, - const double &min, const double &max, + const double &min, const double &max, const double &prior, const double &priorUnc, - const int &add, + const int &add, map<std::string,double*> *map, int len); void add_to_param_map_(map<std::string,double*>* map,double &value, int& global, char *name, int len); // Get parameters in fortran, for backward compatibility: double getparamd_(const char* name, int len); // Update of EWK/QCD parameters, can be fitted at each iteration. - void update_pars_fortran_(); + void update_pars_fortran_(); } @@ -48,7 +48,7 @@ namespace XFITTER_PARS { map <string, string> gParametersS; map <string, vector<double> > gParametersV; ///< Vectors of double parameters map <string, YAML::Node > gParametersY; ///< Store complete nodes for complex cases - + map<string,std::function<void(double const& x, double const& Q, double* pdfs)> > gXfxQArrays; // Also keep list of loaded evolutions here: @@ -66,7 +66,7 @@ namespace XFITTER_PARS { name=node.as<string>(); }catch(YAML::TypedBadConversion<string>ex){ ostringstream s;s<<"W: YAML exception: "<<ex.what()<<"; while trying to extract decomposition name from node: "<<node<<"; using default decomposition name"; - hf_errlog(18082930,s.str()); + hf_errlog(18082930,s.str()); name=getDefaultDecompositionName(); } return xfitter::get_pdfDecomposition(name)->f0(); @@ -123,7 +123,7 @@ namespace XFITTER_PARS { return search->second; } else { - hf_errlog(18071301,"W: string parameter "+name+" not found"); + hf_errlog(18071301,"W: string parameter "+name+" not found"); return ""; // not found } } @@ -163,7 +163,7 @@ namespace XFITTER_PARS { string text = "F: Problems reading yaml-parameters file: " + name + " : "+e.what(); hf_errlog_(17032503,text.c_str(),text.size()); } - + return; } */ @@ -196,7 +196,7 @@ void expandIncludes(YAML::Node&node,unsigned int recursionLimit=256){ expandIncludes(val,recursionLimit-1); } } - //Load and merge + //Load and merge for(vector<YAML::Node>::const_iterator kit=include_keys.begin();kit!=include_keys.end();++kit){ node.remove(*kit); string filename=(*kit).as<string>(""); @@ -280,9 +280,9 @@ void expandIncludes(YAML::Node&node,unsigned int recursionLimit=256){ void ParsToFortran(){ // helper macros -#define FortAssignD(NameV,Struc) if (gParameters.find(#NameV) != gParameters.end()) Struc.NameV = *gParameters[#NameV]; +#define FortAssignD(NameV,Struc) if (gParameters.find(#NameV) != gParameters.end()) Struc.NameV = *gParameters[#NameV]; #define FortAssignS(NameV,Struc) if (gParametersS.find(#NameV) != gParametersS.end()) strcpy(Struc.NameV,gParametersS[#NameV].c_str()); -#define FortAssignI(NameV,Struc) if (gParametersI.find(#NameV) != gParametersI.end()) Struc.NameV = gParametersI[#NameV]; +#define FortAssignI(NameV,Struc) if (gParametersI.find(#NameV) != gParametersI.end()) Struc.NameV = gParametersI[#NameV]; // CKM: FortAssignD(Vud,ckm_matrix_) @@ -317,7 +317,7 @@ void expandIncludes(YAML::Node&node,unsigned int recursionLimit=256){ // OZ 26.04.18 some lines above do not do what expected because it is gf, convFac and alphaem in parameters.yaml, not Gf, ConvFac and Alphaem // as a result CC DIS cross section and integrated NC and CC cross sections are always zero with old interface - // temporary fix: set these parameters manually + // temporary fix: set these parameters manually // (maybe some other parameters are not assigned as well) if(gParameters.find("alphaem") != gParameters.end()) ew_couplings_.Alphaem = *gParameters["alphaem"]; @@ -508,7 +508,7 @@ double getparamd_(const char* name,int len){ char buff[128]; memcpy( buff, &name[0], len); buff[len] = '\0'; - std::string key(buff); + std::string key(buff); if (XFITTER_PARS::gParameters.find(key) != XFITTER_PARS::gParameters.end()) { return *XFITTER_PARS::gParameters[key]; } diff --git a/tools/AddPdfDecomp.py b/tools/AddPdfDecomp.py index 516d12a2b..78fdd7604 100644 --- a/tools/AddPdfDecomp.py +++ b/tools/AddPdfDecomp.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python ''' Script to generate templates for new PDF decomposition ''' @@ -7,7 +7,7 @@ import os import datetime if len(sys.argv)<2: - print ''' + print ''' Usage: AddPdfDecomp.py NAME ''' exit(0) @@ -49,7 +49,7 @@ with open(hFile,"w+") as f: #include "BasePdfDecomposition.h" /** - @class {:s}PdfDecomposition + @class {:s}PdfDecomposition @brief A class for {:s} pdf decomposition @@ -62,7 +62,7 @@ namespace xfitter {{ class {:s}PdfDecomposition : public BasePdfDecomposition {{ public: - /// Default constructor. + /// Default constructor. {:s}PdfDecomposition (); /// Default constructor. Name is the PDF name @@ -72,8 +72,8 @@ class {:s}PdfDecomposition : public BasePdfDecomposition virtual void initAtStart(const std::string & pars) override final; /// Compute PDF in a physical base in LHAPDF format for given x and Q - virtual std::function<std::map<int,double>(const double& x)> f0() const override final; - + virtual std::function<std::map<int,double>(const double& x)> f0() const override final; + }}; }} '''.format( name, name, datetime.date.today().isoformat(),name,name,name) @@ -85,7 +85,7 @@ sFile = "pdfdecompositions/{:s}PdfDecomposition/src/{:s}PdfDecomposition.cc".for print "Creating source file "+sFile with open(sFile,"w+") as f: - f.write(''' + f.write(''' /* @file {:s}PdfDecomposition.cc @date {:s} @@ -96,7 +96,7 @@ with open(sFile,"w+") as f: #include "{:s}PdfDecomposition.h" namespace xfitter {{ - + /// the class factories, for dynamic loading extern "C" {:s}PdfDecomposition* create() {{ return new {:s}PdfDecomposition(); @@ -104,11 +104,11 @@ extern "C" {:s}PdfDecomposition* create() {{ // Constructor - {:s}PdfDecomposition::{:s}PdfDecomposition() : BasePdfDecomposition("{:s}") {{ + {:s}PdfDecomposition::{:s}PdfDecomposition() : BasePdfDecomposition("{:s}") {{ }} // Constructor -{:s}PdfDecomposition::{:s}PdfDecomposition(const std::string& inName) : BasePdfDecomposition(inName) {{ +{:s}PdfDecomposition::{:s}PdfDecomposition(const std::string& inName) : BasePdfDecomposition(inName) {{ }} // Init at start: @@ -121,7 +121,7 @@ std::function<std::map<int,double>(const double& x)> {:s}PdfDecomposition::f0() {{ const auto f_ = [=](double const& x)->std::map<int, double> {{ std::map<int, double> res_ = {{ - {{-6,0}}, + {{-6,0}}, {{-5,0}}, {{-4,0}}, {{-3,0}}, @@ -145,7 +145,7 @@ std::function<std::map<int,double>(const double& x)> {:s}PdfDecomposition::f0() ,name,name,name,name,name,name,name,name,name,name) ) - + aFile = "pdfdecompositions/{:s}PdfDecomposition/src/Makefile.am".format(name) print "Creating autoconf file " + aFile @@ -155,7 +155,7 @@ with open(aFile,"w+") as f: f.write(''' # Created by AddPdfDecomposition.py on {:s} -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../pdfparams/BasePdfParam/include/ -I$(srcdir)/../../BasePdfDecomposition/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../pdfparams/BasePdfParam/include/ -I$(srcdir)/../../BasePdfDecomposition/include -Wall -fPIC -Wno-deprecated lib_LTLIBRARIES = lib{:s}PdfDecomposition_xfitter.la lib{:s}PdfDecomposition_xfitter_la_SOURCES = {:s}PdfDecomposition.cc @@ -167,7 +167,7 @@ dist_noinst_HEADERS = ../include ../yaml '''.format(datetime.date.today().isoformat(),name,name,name,name)) - + print "Update configure.ac file" os.system("sed 's|xfitter-config|xfitter-config\\n pdfdecompositions/{:s}PdfDecomposition/src/Makefile|' configure.ac >/tmp/configure.ac".format(name)) os.system("cp /tmp/configure.ac configure.ac") diff --git a/tools/AddPdfParam.py b/tools/AddPdfParam.py index a6f4239b3..6b995f5b9 100644 --- a/tools/AddPdfParam.py +++ b/tools/AddPdfParam.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python ''' Script to generate templates for new PDF parameterisation ''' @@ -7,7 +7,7 @@ import os import datetime if len(sys.argv)<2: - print ''' + print ''' Usage: AddPdfParam.py NAME ''' exit(0) @@ -35,7 +35,7 @@ with open(hFile,"w+") as f: #include "BasePdfParam.h" /** - @class {name:s}PdfParam + @class {name:s}PdfParam @brief A class for {name:s} pdf parameterisation @@ -65,7 +65,7 @@ sFile = "pdfparams/{:s}PdfParam/src/{:s}PdfParam.cc".format(name,name) print "Creating source file "+sFile with open(sFile,"w+") as f: - f.write(''' + f.write(''' /* @file {name:s}PdfParam.cc @date {date:s} @@ -90,7 +90,7 @@ with open(aFile,"w+") as f: f.write(''' # Created by AddPdfParam.py on {:s} -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated lib_LTLIBRARIES = lib{:s}PdfParam_xfitter.la lib{:s}PdfParam_xfitter_la_SOURCES = {:s}PdfParam.cc diff --git a/tools/AddReaction.py b/tools/AddReaction.py index 35d56f751..1e4a34cec 100644 --- a/tools/AddReaction.py +++ b/tools/AddReaction.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python ''' Script to generate templates for a new theory module ''' @@ -7,7 +7,7 @@ import os import datetime if len(sys.argv)<2: - print ''' + print ''' Usage: AddReaction.py NAME ''' exit(0) @@ -50,7 +50,7 @@ with open("reactions/"+name+"/include/Reaction"+name+".h","w+") as f: /** @class' Reaction'''+name+''' - @brief A wrapper class for '''+name+''' reaction + @brief A wrapper class for '''+name+''' reaction Based on the ReactionTheory class. Reads options produces 3d cross section. @@ -69,7 +69,7 @@ class Reaction'''+name+''' : public ReactionTheory public: virtual string getReactionName() const { return "'''+name+ '''" ;}; - int initAtStart(const string &); + int initAtStart(const string &); virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err); protected: virtual int parseOptions(){ return 0;}; @@ -79,7 +79,7 @@ class Reaction'''+name+''' : public ReactionTheory print "Creating source file reactions/"+name+"/src/Reaction"+name+".cc" with open("reactions/"+name+"/src/Reaction"+name+".cc","w+") as f: - f.write(''' + f.write(''' /* @file Reaction'''+name+'''.cc @date ''' + datetime.date.today().isoformat() + ''' @@ -115,12 +115,12 @@ with open("reactions/"+name+"/src/Makefile.am","w+") as f: f.write(''' # Created by AddReaction.py on ''' + datetime.date.today().isoformat() + ''' -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -Wall -fPIC -Wno-deprecated +AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../interfaces/include -Wall -fPIC -Wno-deprecated lib_LTLIBRARIES = lib'''+ name.lower() + '''_xfitter.la lib'''+ name.lower()+'''_xfitter_la_SOURCES = Reaction'''+name+'''.cc -# lib'''+ name.lower()+'''_xfitter_la_LDFLAGS = place_if_needed +# lib'''+ name.lower()+'''_xfitter_la_LDFLAGS = place_if_needed datadir = ${prefix}/yaml/reactions/'''+name+''' data_DATA = ../yaml/parameters.yaml diff --git a/tools/draw/include/CommandParser.h b/tools/draw/include/CommandParser.h index a0b66059d..abbe7de70 100644 --- a/tools/draw/include/CommandParser.h +++ b/tools/draw/include/CommandParser.h @@ -46,7 +46,7 @@ class CommandParser bool diff; bool noupband; int errbandcol; - + //shifts options int spp, shgth; bool adjshift; @@ -88,7 +88,7 @@ class CommandParser bool profile, reweight, BAYweight, GKweight; bool bw; bool looseRepSelection; - + private: vector <string> allargs; void help(void) @@ -145,7 +145,7 @@ private: cout << "\t \t Number of rows and columns of PDF and data plots per page, default value is 2" << endl; cout << "\t --loose-mc-replica-selection" <<endl; cout << "\t \t Do not check for fit convergence for MC replica " <<endl; - + cout << "options for pdf plots:" << endl; cout << "\t --no-pdfs" << endl; @@ -268,14 +268,14 @@ private: cout << "\t PlotDefColumn = 'y2' ! Variable used to divide the data in SubPlots" << endl; cout << "\t PlotDefValue = 0., 5.! Ranges of PlotDefColumn used to divide the data in SubPlots" << endl; cout << "\t PlotVarColumn = 'x'! Variable providing bin center information (use only if bin edges are missing)" << endl; - cout << "\t PlotOptions(1) = 'Experiment:ATLAS@Title: pp #rightarrow Z@XTitle: y_{Z} @YTitle: d#sigma/dy_{Z} [pb] @ExtraLabel:#int L = 100 fb^{-1}@Xmin:0.0@Xmax:2.5@Xlog@Ylog@YminR:0.91@YmaxR:1.09'" + cout << "\t PlotOptions(1) = 'Experiment:ATLAS@Title: pp #rightarrow Z@XTitle: y_{Z} @YTitle: d#sigma/dy_{Z} [pb] @ExtraLabel:#int L = 100 fb^{-1}@Xmin:0.0@Xmax:2.5@Xlog@Ylog@YminR:0.91@YmaxR:1.09'" << endl; cout << "\t &End" << endl; cout << endl; cout << "Option for 3-band PDF uncertainty bands (HERAPDF style) in PDF plots." << endl; cout << "\t --bands 3bands:<dir-full-uncert>" << endl; cout << "\t \t draw PDFs with three uncertainty bands: experimental (red), model (yellow) parametrisation (green)." << endl; - cout << "\t The model uncertainty originates from variation of model parameters (e.g. masses of heavy quarks, Q^2 cuts on data, etc.)," << endl; + cout << "\t The model uncertainty originates from variation of model parameters (e.g. masses of heavy quarks, Q^2 cuts on data, etc.)," << endl; cout << "\t parametrisation - from variations of the parameters in the fit and variation of the starting scale Q_0^2."<< endl; cout << " \t Directory <dir-full-uncert> should have fit results for experimental, model and parametrisation variations. " << endl; cout << " \t The file names for experimental variations should follow convention as follows: " << endl; @@ -288,7 +288,7 @@ private: cout << " \t Finally, p14s stands for parametrisation uncertainty and the number should start from N+K+1 (here assuming that K=3 for model errors)." << endl; cout << " \t NOTE: if command '--bands <dir-full-uncert>' is used, the total uncertainty in red is drawn." << endl; cout << endl; - }; + }; }; extern CommandParser opts; diff --git a/tools/draw/include/PdfData.h b/tools/draw/include/PdfData.h index 468f3e01b..289da36a5 100644 --- a/tools/draw/include/PdfData.h +++ b/tools/draw/include/PdfData.h @@ -71,7 +71,7 @@ class Pdf vector <double> xpoints; }; -struct pdfshift +struct pdfshift { double val; double err; @@ -89,7 +89,7 @@ class PdfData //PdfData(const PdfData &Prior, string dirname, string label); void profile(string dirname, string label); //profile PDF uncertainty bands void pdfRotate(string dirname, string label); //rotate PDF - void pdfSet(string dirname, string label); // get single set + void pdfSet(string dirname, string label); // get single set pdferr err; //Type of PDF uncertainties bool model; //Model PDF uncertainties bool par; //Parametrisation PDF uncertainties diff --git a/tools/draw/src/CommandParser.cc b/tools/draw/src/CommandParser.cc index d17ec10b7..3c7d58f9f 100644 --- a/tools/draw/src/CommandParser.cc +++ b/tools/draw/src/CommandParser.cc @@ -129,7 +129,7 @@ CommandParser::CommandParser(int argc, char **argv): // tight MC replica selection by default: looseRepSelection = false; - + //Set Hatches style gStyle->SetHatchesSpacing(2); gStyle->SetHatchesLineWidth(lwidth); @@ -486,7 +486,7 @@ CommandParser::CommandParser(int argc, char **argv): allargs.erase(it); it = allargs.begin(); } - + for (vector<string>::iterator it = allargs.begin() + 1; it != allargs.end(); it++) dirs.push_back(*it); @@ -539,6 +539,6 @@ vector<string> Round(double value, double error, bool sign) result.push_back(Numb); sprintf (Numb, ((string)"%." + D + "f").c_str(), error); result.push_back(Numb); - + return result; } diff --git a/tools/draw/src/DataPainter.cc b/tools/draw/src/DataPainter.cc index 98b61331b..ed63dfeb5 100644 --- a/tools/draw/src/DataPainter.cc +++ b/tools/draw/src/DataPainter.cc @@ -22,7 +22,7 @@ double hmin(TH1F *h) for (int b = h->GetXaxis()->GetFirst(); b <= h->GetXaxis()->GetLast(); b++) if (h->GetBinContent(b) != 0) min0 = min(min0, h->GetBinContent(b)); - return min0; + return min0; } struct range @@ -54,7 +54,7 @@ void Subplot::Draw(TH1F* histo, string opt) if (bins1.size() == 1) if (opt.find("E3") != string::npos) opt.replace(opt.find("E3"), opt.find("E3")+2, "E2"); - + if (maketgraph) { TGraphAsymmErrors * graph = new TGraphAsymmErrors(histo); @@ -138,7 +138,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) return 0; } } - + TCanvas * cnv; if (opts.twopanels || opts.threepanels) cnv = new TCanvas(cnvname.c_str(), "", 0, 0, 2 * opts.resolution, opts.resolution); @@ -164,7 +164,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) dy = (1.-bmarg-tmarg)/3.; else //1 panel dy = (1.-bmarg-tmarg)/4.; - + TPad* Main; TPad* Ratio; @@ -209,7 +209,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) mb = marg0/my; } - + //Ratio pad geometry if (opts.twopanels || opts.threepanels) { @@ -413,7 +413,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) TLatex l; l.SetNDC(); l.SetTextFont(42); - + float vertdist; float txtsz; vertdist = 0.13; @@ -421,7 +421,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) l.SetTextSize(txtsz*0.04/my); l.DrawLatex(lmarg+0.05, (1-tmarg/my) - vertdist/my, datahistos[0].getlumilabel().c_str()); } - + //Main legend TPaveText* leg1; if (opts.onlytheory) @@ -528,7 +528,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) (*it).getth()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); if (opts.therr && !opts.noupband) - { + { (*it).gettherr()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); if (opts.bw) (*it).gettherr()->SetLineStyle(opts.lstyles[labels[it-datahistos.begin()]]); @@ -573,7 +573,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) //Set Y error float errup, errdown; if (opts.therr && !opts.noupband) - { + { errup = (*it).gettherrup()->GetBinContent(b + 1) - (*it).getth()->GetBinContent(b + 1); errdown = (*it).getth()->GetBinContent(b + 1) - (*it).gettherrdown()->GetBinContent(b + 1); } @@ -868,7 +868,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) } (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); } - + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) //plot as continous line with dashed error bands { for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) @@ -923,7 +923,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) //Set Y error float errup, errdown; if (opts.therr) - { + { errup = (*it).getrtherrup()->GetBinContent(b + 1) - (*it).getrth()->GetBinContent(b + 1); errdown = (*it).getrth()->GetBinContent(b + 1) - (*it).getrtherrdown()->GetBinContent(b + 1); } @@ -952,7 +952,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) leg2->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "p"); } } - + //draw theory error borders if (opts.therr) for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) @@ -1057,7 +1057,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) } (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); } - + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) //plot as continous line with dashed error bands { for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) @@ -1111,7 +1111,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) //Set Y error float errup, errdown; if (opts.therr) - { + { errup = (*it).getrtherrup()->GetBinContent(b + 1) - (*it).getrth()->GetBinContent(b + 1); errdown = (*it).getrth()->GetBinContent(b + 1) - (*it).getrtherrdown()->GetBinContent(b + 1); } @@ -1128,7 +1128,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) } if (it - datahistos.begin() == 1) { - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) if (opts.therr && (*it).HasTherr()) legr->AddEntry((*it).getrtherr(), (labels[it-datahistos.begin()]).c_str(), "lf"); else @@ -1140,7 +1140,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) leg2->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "p"); } } - + //draw theory error borders if (opts.therr) for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) @@ -1149,7 +1149,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) (*it).getrtherrdown()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); (*it).getrtherrup()->SetLineWidth(opts.lwidth); (*it).getrtherrdown()->SetLineWidth(opts.lwidth); - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) { vector <range> rthranges = historanges((*it).getth()); for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) @@ -1264,7 +1264,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "hist ][ same"); } (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } + } //plot data if (!opts.onlytheory) datahistos[0].Draw(r_data, "PE1 same"); @@ -1332,14 +1332,14 @@ TCanvas * DataPainter(int dataindex, int subplotindex) if (!opts.onlytheory) if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory if (!opts.nothshifts) - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "LX same"); else (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "hist ][ same"); } (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); } - + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) //plot as continous line with dashed error bands { for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) @@ -1393,7 +1393,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) //Set Y error float errup, errdown; if (opts.therr) - { + { errup = (*it).getrtherrup()->GetBinContent(b + 1) - (*it).getrth()->GetBinContent(b + 1); errdown = (*it).getrth()->GetBinContent(b + 1) - (*it).getrtherrdown()->GetBinContent(b + 1); } @@ -1410,7 +1410,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) } if (it - datahistos.begin() == nth-1) { - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) if (opts.therr && (*it).HasTherr()) legr->AddEntry((*it).getrtherr(), (labels[it-datahistos.begin()]).c_str(), "lf"); else @@ -1421,8 +1421,8 @@ TCanvas * DataPainter(int dataindex, int subplotindex) else leg2->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "p"); } - } - + } + //draw theory error borders if (opts.therr) for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) @@ -1431,7 +1431,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) (*it).getrtherrdown()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); (*it).getrtherrup()->SetLineWidth(opts.lwidth); (*it).getrtherrdown()->SetLineWidth(opts.lwidth); - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) { vector <range> rthranges = historanges((*it).getth()); for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) @@ -1507,7 +1507,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) (*it).getpull()->SetLineWidth(opts.lwidth); (*it).getpull()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); datahistos[0].Draw((TH1F*)(*it).getpull()->Clone(), "same ]["); - } + } } //Labels @@ -1516,7 +1516,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) cnv->cd(1); DrawLabels(); if (opts.drawlogo) - DrawLogo()->Draw(); + DrawLogo()->Draw(); cnv->cd(2); DrawLabels(); } @@ -1525,7 +1525,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) cnv->cd(); DrawLabels(); if (opts.drawlogo) - DrawLogo()->Draw(); + DrawLogo()->Draw(); } return cnv; diff --git a/tools/draw/src/PdfData.cc b/tools/draw/src/PdfData.cc index 4749ef239..78b9a0816 100644 --- a/tools/draw/src/PdfData.cc +++ b/tools/draw/src/PdfData.cc @@ -23,9 +23,9 @@ //pdftype pdfts[] = {uv, dv, g, Sea, ubar, dbar, s, Rs, c, b, dbarminubar, uvmindv, U, D, Ubar, Dbar, goversea, doveru, dbaroverubar, dvoveruv,rs,photon,SeaOverGlue, photonOverGlue }; pdftype pdfts[] = {uv, dv, g, Sea, ubar, dbar, s, sbar, Rs, soversbar, c, b, dbarminubar, uvmindv, U, D, Ubar, Dbar, goversea, doveru, dbaroverubar, dvoveruv,rs,photon,SeaOverGlue, photonOverGlue, uvplusdv, uvplusdvplusSea }; //pdf labels -//string pdflab[] = {"u_{V}", "d_{V}", "g", "#Sigma", "#bar{u}", "#bar{d}", "s", "(s+#bar{s})/(#bar{u}+#bar{d})", "c", "b", "#bar{d}-#bar{u}", "d_{V}-u_{V}", "U", "D", "#bar{U}", "#bar{D}", "g/#Sigma", +//string pdflab[] = {"u_{V}", "d_{V}", "g", "#Sigma", "#bar{u}", "#bar{d}", "s", "(s+#bar{s})/(#bar{u}+#bar{d})", "c", "b", "#bar{d}-#bar{u}", "d_{V}-u_{V}", "U", "D", "#bar{U}", "#bar{D}", "g/#Sigma", // "d/u", "#bar{d}/#bar{u}", "d_{V}/u_{V}","rs","#gamma","#Sigma/g","#gamma/g"}; -string pdflab[] = {"u_{V}", "d_{V}", "g", "#Sigma", "#bar{u}", "#bar{d}", "(s+#bar{s})/2", "#bar{s}", "(s+#bar{s})/(#bar{u}+#bar{d})", "s/#bar{s}", "c", "b", "#bar{d}-#bar{u}", "d_{V}-u_{V}", "U", "D", "#bar{U}", "#bar{D}", "g/#Sigma", +string pdflab[] = {"u_{V}", "d_{V}", "g", "#Sigma", "#bar{u}", "#bar{d}", "(s+#bar{s})/2", "#bar{s}", "(s+#bar{s})/(#bar{u}+#bar{d})", "s/#bar{s}", "c", "b", "#bar{d}-#bar{u}", "d_{V}-u_{V}", "U", "D", "#bar{U}", "#bar{D}", "g/#Sigma", "d/u", "#bar{d}/#bar{u}", "d_{V}/u_{V}","rs","#gamma","#Sigma/g","#gamma/g","u_{V}+d_{V}", "u_{V}+d_{V}+2#Sigma"}; //pdf filenames //string pdffil[] = {"uv", "dv", "g", "Sea", "ubar", "dbar", "s", "Rs", "c", "b", "dbar-ubar", "uv-dv", "U", "D", "UBar", "DBar", "goversea", "doveru", "dbaroverubar", "dvoveruv","rs","ph","sg","gg" @@ -76,7 +76,7 @@ Pdf::Pdf(string filename) : Q2value(0), NxValues(0), NPdfs(0), Xmin(0), Xmax(0) } PdfTypes.push_back(ipdf); } - + // Read the table double val; for (int ix = 0; ix < NxValues; ix++) @@ -316,7 +316,7 @@ PdfData::PdfData(string dirname, string label) : model(false), par(false) //Get Pdf errors if requested if (!opts.dobands && !outdirs[label].IsProfiled() && !outdirs[label].IsRotated() && !outdirs[label].IsReweighted() && !outdirs[label].IsSingleSet()) continue; - + //Load PDF error sets int iband = 1; if (err == MC) @@ -431,7 +431,7 @@ PdfData::PdfData(string dirname, string label) : model(false), par(false) getline (mcwfile,line); getline (mcwfile, line); getline (mcwfile, line); - line.erase(line.begin(),line.begin()+8); + line.erase(line.begin(),line.begin()+8); ndata=atoi( line.c_str() ); getline (mcwfile, line); while (mcwfile >> n >> chi2 >> w) { @@ -566,7 +566,7 @@ PdfData::PdfData(string dirname, string label) : model(false), par(false) for (vector <Pdf>::iterator eit = ModelErrors[q2].begin(); eit != ModelErrors[q2].end(); eit++) xi.push_back((*eit).GetTable(*pit)[ix]); - + double modeplus, modeminus; if (!outdirs[label].IsAsym()) //symmetrise errors modeplus = modeminus = ahessdelta(xi); @@ -613,7 +613,7 @@ PdfData::PdfData(string dirname, string label) : model(false), par(false) profile(dirname, label); if (outdirs[label].IsRotated() ) pdfRotate(dirname, label); - + if (outdirs[label].IsSingleSet() ) pdfSet(dirname,label); @@ -621,7 +621,7 @@ PdfData::PdfData(string dirname, string label) : model(false), par(false) void PdfData::pdfRotate(string dirname, string label) -{ +{ // Extra rotations from rot.dat file string fname = dirname + "/pdf_rotation.dat"; ifstream f(fname.c_str()); @@ -639,7 +639,7 @@ void PdfData::pdfRotate(string dirname, string label) int N; iss >> N; int idx1 = 0; - while ( getline (f,line) ) + while ( getline (f,line) ) { vector <double> aline; istringstream iss(line); @@ -662,7 +662,7 @@ void PdfData::pdfRotate(string dirname, string label) for ( map<float, Pdf>::iterator pdfit = Central.begin(); pdfit != Central.end(); pdfit++) { float q2 = pdfit->first; Pdf Cent = pdfit->second; - + // loop over pdf types for (vector <pdftype>::iterator pit = pdfs.begin(); pit != pdfs.end(); pit++) { @@ -672,8 +672,8 @@ void PdfData::pdfRotate(string dirname, string label) double val = Cent.GetTable(*pit)[ix]; double corsum = 0; double eminus = 0; // also errors - double eplus = 0; - + double eplus = 0; + // For now CT10 only: for ( int id=0; id<N; id++) { Pdf Up = Errors[q2].at(2*(id)); @@ -686,11 +686,11 @@ void PdfData::pdfRotate(string dirname, string label) // corsum += 0.5*(plus-minus)*rotation[iRotation][id]; } - + Cent.SetPoint(*pit, ix, val+corsum); Cent.SetErrUp(*pit, ix, eplus); Cent.SetErrDn(*pit, ix, eminus); - + Up[q2].SetPoint(*pit, ix, val+corsum+eplus); Down[q2].SetPoint(*pit, ix, val+corsum-eminus); @@ -698,11 +698,11 @@ void PdfData::pdfRotate(string dirname, string label) } pdfit->second = Cent; } - + } void PdfData::pdfSet(string dirname, string label) -{ +{ int id = outdirs[label].pdfSet()-1; @@ -710,9 +710,9 @@ void PdfData::pdfSet(string dirname, string label) float q2 = pdfit->first; Pdf Cent = pdfit->second; Pdf Pset = Errors[q2].at(id); - + double eminus = 0; // also errors - double eplus = 0; + double eplus = 0; // loop over pdf types for (vector <pdftype>::iterator pit = pdfs.begin(); pit != pdfs.end(); pit++) { @@ -720,10 +720,10 @@ void PdfData::pdfSet(string dirname, string label) for (int ix = 0; ix < Cent.GetNx(); ix++) { double val = Pset.GetTable(*pit)[ix]; - + Cent.SetPoint(*pit, ix, val); Cent.SetErrUp(*pit, ix, eplus); - Cent.SetErrDn(*pit, ix, eminus); + Cent.SetErrDn(*pit, ix, eminus); Up[q2].SetPoint(*pit, ix, val+eplus); Down[q2].SetPoint(*pit, ix, val-eminus); @@ -731,7 +731,7 @@ void PdfData::pdfSet(string dirname, string label) } pdfit->second = Cent; } - + } void PdfData::profile(string dirname, string label) @@ -746,7 +746,7 @@ void PdfData::profile(string dirname, string label) // cout << "File " << fname << " is empty (or io error)" << endl; // return; // } - + InFileOpener_t fo; fo.Add(dirname + "/Results.txt"); fo.Add(dirname + "/Results_0.txt"); @@ -760,7 +760,7 @@ void PdfData::profile(string dirname, string label) { getline(f, line); istringstream iss(line); - iss >> buffer; + iss >> buffer; } string systlabel, dummy; float systindex, value, error; @@ -768,7 +768,7 @@ void PdfData::profile(string dirname, string label) while (getline(f, line)) { istringstream iss(line); - iss >> systindex >> systlabel >> value >> dummy >> error; + iss >> systindex >> systlabel >> value >> dummy >> error; if ( systlabel.find("PDF_nuisance_param") == 0 ) { ++counter; pdfshift shift; @@ -792,7 +792,7 @@ void PdfData::profile(string dirname, string label) int N; iss >> N; int idx1 = 0; - while ( getline (ff,line) ) + while ( getline (ff,line) ) { vector <double> aline; istringstream iss(line); @@ -811,7 +811,7 @@ void PdfData::profile(string dirname, string label) for ( map<float, Pdf>::iterator pdfit = Central.begin(); pdfit != Central.end(); pdfit++) { float q2 = pdfit->first; Pdf Cent = pdfit->second; - + // loop over pdf types for (vector <pdftype>::iterator pit = pdfs.begin(); pit != pdfs.end(); pit++) { @@ -823,11 +823,11 @@ void PdfData::profile(string dirname, string label) double t2 = Down[q2].GetTable(*pit)[ix]; double corsum = 0; double eminus = 0; // also errors - double eplus = 0; + double eplus = 0; vector <double> xi; xi.push_back(val); - for ( vector<pdfshift>::iterator shift = pdfshifts.begin(); shift != pdfshifts.end(); shift++) { + for ( vector<pdfshift>::iterator shift = pdfshifts.begin(); shift != pdfshifts.end(); shift++) { int id = shift->id; double valShift = shift->val; @@ -840,10 +840,10 @@ void PdfData::profile(string dirname, string label) double plus = Up.GetTable(*pit)[ix] - val; double minus = Dn.GetTable(*pit)[ix] - val; - + double cor = 0.5*(plus - minus)*valShift + 0.5*(plus+minus)*valShift*valShift; - + xi.push_back(plus*errShift+val); xi.push_back(minus*errShift+val); @@ -852,11 +852,11 @@ void PdfData::profile(string dirname, string label) else if (err == SymHess) { Pdf Up = Errors[q2].at(id-1); double plus = Up.GetTable(*pit)[ix] - val; - double cor = plus*valShift; + double cor = plus*valShift; xi.push_back(plus*errShift+val); corsum += cor; - } + } } if ( err == AsymHess ) { @@ -864,12 +864,12 @@ void PdfData::profile(string dirname, string label) if (!outdirs[label].IsAsym()) //symmetrise errors eplus = eminus = ahessdelta(xi, cor_matrix); else //asymmetric errors - ahessdeltaasym(xi, eplus, eminus, cor_matrix); + ahessdeltaasym(xi, eplus, eminus, cor_matrix); } else if (err == SymHess) { eplus = eminus = shessdelta(xi, cor_matrix ); - } + } if (outdirs[label].Scale68()) { eplus = eplus/1.645; diff --git a/tools/install-xfitter b/tools/install-xfitter index 2f537fb52..953f5714d 100755 --- a/tools/install-xfitter +++ b/tools/install-xfitter @@ -98,7 +98,7 @@ if [[ $version != "master" ]] done vers=`git ls-remote --tags https://gitlab.cern.ch/fitters/xfitter.git | sed 's|/| |g; s|\^| |' | awk '{print $4}' | uniq` - + for ver in $vers do if [[ $version == $ver ]] @@ -261,7 +261,7 @@ else exit fi fi - + #directory: CURRENTDIR=`pwd` @@ -278,7 +278,7 @@ installDeps=1 if [[ $installDeps == 0 ]] then echo "Skip installation of dependences" -else +else #Make all dependencies rm -rf deps >& /dev/null mkdir deps @@ -302,7 +302,7 @@ else wget https://lhapdf.hepforge.org/downloads/${lhapdf}-${lhapdfver}.tar.gz >> $CURRENTDIR/install.log 2>&1 fi tar xfz ${lhapdf}-${lhapdfver}.tar.gz >> $CURRENTDIR/install.log 2>&1 - cd ${lhapdf}-${lhapdfver} + cd ${lhapdf}-${lhapdfver} ./configure --prefix=$CURRENTDIR/deps/lhapdf >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then @@ -461,7 +461,7 @@ else then echo "Error, check install.log for details" exit - fi + fi make -j 9 install >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then @@ -486,12 +486,12 @@ else ./configure --prefix=$CURRENTDIR/deps/qcdnum >> $CURRENTDIR/install.log 2>&1 export PATH=$CURRENTDIR/deps/qcdnum/bin/:$PATH - + if [[ $? != 0 ]] then echo "Error, check install.log for details" exit - fi + fi make -j 9 install >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then @@ -508,10 +508,10 @@ if [[ $mode != "deps" ]] then echo "Installing xFitter $version..." - + if [[ $version == "master" ]] then - git clone https://gitlab.cern.ch/fitters/xfitter.git >> $CURRENTDIR/install.log 2>&1 + git clone https://gitlab.cern.ch/fitters/xfitter.git >> $CURRENTDIR/install.log 2>&1 mv xfitter xfitter-master else if [[ $http == "curl" ]] @@ -526,7 +526,7 @@ then wget https://xfitter.hepforge.org/downloads/tar_files/xfitter-$version.tar.gz >> $CURRENTDIR/install.log 2>&1 fi # unpack nicely: - rm -fr xfitter-${version} + rm -fr xfitter-${version} mkdir xfitter-${version} ; tar xfz xfitter-${version}.tar.gz -C xfitter-${version} --strip-components 1 fi else @@ -648,7 +648,7 @@ then echo "-----------------------------------------------------------" cat quickstart-readme.txt echo "-----------------------------------------------------------" - echo + echo echo "To read again these instructions, see quickstart-readme.txt" echo "Have fun!" fi -- GitLab From 4e3aa885cf68b9135ed5050572c6089330f6f5b1 Mon Sep 17 00:00:00 2001 From: Ivan Novikov <novivanya@yandex.ru> Date: Thu, 4 Apr 2019 12:35:15 +0200 Subject: [PATCH 70/81] Replace tabs with spaces for indentation --- src/TheorEval.cc | 92 +++++++++++++++++++++++----------------------- src/ftheor_eval.cc | 6 +-- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/TheorEval.cc b/src/TheorEval.cc index d31c7aaf6..3beae9641 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -106,22 +106,22 @@ TheorEval::assignTokens(list<tToken> &sl) do { strexpr.get(c); if ( strexpr.eof() ) break; - if ( isdigit(c) || c=='.' ) { + if ( isdigit(c) || c=='.' ) { term.append(1,c); - } else if ( c=='E' || c=='e' ) { // read mantissa including sign in scientific notation - term.append(1,c); - strexpr.get(c); + } else if ( c=='E' || c=='e' ) { // read mantissa including sign in scientific notation + term.append(1,c); + strexpr.get(c); if ( strexpr.eof() ) break; - if ( isdigit(c) || c == '-' ){ - term.append(1,c); - } else { - cout << "Theory expression syntax error: " << _expr << endl; - return -1; - } - } else { - strexpr.putback(c); - break; - } + if ( isdigit(c) || c == '-' ){ + term.append(1,c); + } else { + cout << "Theory expression syntax error: " << _expr << endl; + return -1; + } + } else { + strexpr.putback(c); + break; + } } while (1); double dterm = atof(term.c_str()); @@ -134,17 +134,17 @@ TheorEval::assignTokens(list<tToken> &sl) term.assign(1,c); while (strexpr.get(c) ) { if ( isalnum(c) ) term.append(1,c); - else { - strexpr.putback(c); - break; - } + else { + strexpr.putback(c); + break; + } } if ( term == string("sum") ) { // special case for sum() function t.opr = 4; t.name = "sum"; - t.val = new valarray<double>(0., nb); - sl.push_back(t); - continue; + t.val = new valarray<double>(0., nb); + sl.push_back(t); + continue; } if ( term == string("spline") || term == string("splinederivative") ) { @@ -247,27 +247,27 @@ TheorEval::assignTokens(list<tToken> &sl) if ( term == string("avg") ) { // special case for avg() function t.opr = 4; t.name = "avg"; - t.val = new valarray<double>(0., nb); - sl.push_back(t); - continue; + t.val = new valarray<double>(0., nb); + sl.push_back(t); + continue; } */ vector<string>::iterator found_term = find(_termNames.begin(), _termNames.end(), term); if ( found_term == _termNames.end() ) { cout << "Undeclared term " << term << " in expression " << _expr << endl; - return -1; + return -1; } else { t.opr = 0; t.name = term; - if ( _mapInitdTerms.find(term) != _mapInitdTerms.end()){ - t.val = _mapInitdTerms[term]; - } else { - t.val = new valarray<double>(0.,nb); - this->initTerm(int(found_term-_termNames.begin()), t.val); - _mapInitdTerms[term] = t.val; - } - sl.push_back(t); + if ( _mapInitdTerms.find(term) != _mapInitdTerms.end()){ + t.val = _mapInitdTerms[term]; + } else { + t.val = new valarray<double>(0.,nb); + this->initTerm(int(found_term-_termNames.begin()), t.val); + _mapInitdTerms[term] = t.val; + } + sl.push_back(t); } term.clear(); continue; @@ -308,7 +308,7 @@ TheorEval::convertToRPN(list<tToken> &sl) if ( t.opr >0 ) { while ( tknstk.size() > 0 && t.opr <= tknstk.top().opr ) { _exprRPN.push_back(tknstk.top()); - tknstk.pop(); + tknstk.pop(); } tknstk.push(t); @@ -316,7 +316,7 @@ TheorEval::convertToRPN(list<tToken> &sl) if ( t.opr == -1 ){ tknstk.push(t); delete t.val;} // left parenthesis if ( t.opr == -2 ){ // right parenthesis while ( tknstk.top().opr != -1 ) { - if ( tknstk.size() == 0 ) cout << "ERROR: Wrong syntax in theoretical expression: "<< _expr << endl; + if ( tknstk.size() == 0 ) cout << "ERROR: Wrong syntax in theoretical expression: "<< _expr << endl; _exprRPN.push_back(tknstk.top()); tknstk.pop(); } @@ -644,8 +644,8 @@ TheorEval::Evaluate(valarray<double> &vte ) } stk.top() = result; }else{ - char error[] = "ERROR: Dimensions do not match "; - cout<<error<<endl;} + char error[] = "ERROR: Dimensions do not match "; + cout<<error<<endl;} /*if(it + 1 ->name == string("kmatrix")){//possible matrix matrix multiplication int nb1 = ?;//TODO find dimensions of matrices for check and multiplication int mb1 = ?; @@ -673,13 +673,13 @@ TheorEval::Evaluate(valarray<double> &vte ) //Normalised cross section if (_normalised) { - double integral = 0; - for (int bin = 0; bin < _binFlags.size(); bin++) - if (!(vte[bin] != vte[bin])) //protection against nan - integral += (_dsBins.at(1).at(bin) - _dsBins.at(0).at(bin)) * vte[bin]; - if (integral != 0) - for (int bin = 0; bin < _binFlags.size(); bin++) - vte[bin] /= integral; + double integral = 0; + for (int bin = 0; bin < _binFlags.size(); bin++) + if (!(vte[bin] != vte[bin])) //protection against nan + integral += (_dsBins.at(1).at(bin) - _dsBins.at(0).at(bin)) * vte[bin]; + if (integral != 0) + for (int bin = 0; bin < _binFlags.size(); bin++) + vte[bin] /= integral; } //vte /= _units; } @@ -802,10 +802,10 @@ const std::string GetParamDS(const std::string& ParName, const std::string& DSna std::string Val = Node["defaultValue"].as<string>(); if (Node[DSname]) { - Val = Node[DSname].as<string>(); + Val = Node[DSname].as<string>(); } if (Node[DSindex]) { - Val = Node[DSindex].as<string>(); + Val = Node[DSindex].as<string>(); } return Val; diff --git a/src/ftheor_eval.cc b/src/ftheor_eval.cc index ea708b9b0..353fc09d9 100644 --- a/src/ftheor_eval.cc +++ b/src/ftheor_eval.cc @@ -43,7 +43,7 @@ extern "C" { int set_theor_eval_(int *dsId);//, int *nTerms, char **TermName, char **TermType, // char **TermSource, char *TermExpr); int set_theor_bins_(int *dsId, int *nBinDimension, int *nPoints, int *binFlags, - double *allBins, char binNames[10][80]); + double *allBins, char binNames[10][80]); // int set_theor_units_(int *dsId, double *units); int init_theor_eval_(int *dsId); int update_theor_ckm_(); @@ -159,7 +159,7 @@ int set_theor_eval_(int *dsId)//, int *nTerms, char **TermName, char **TermType, write details on argumets */ int set_theor_bins_(int *dsId, int *nBinDimension, int *nPoints, int *binFlags, - double *allBins, char binNames[10][80]) + double *allBins, char binNames[10][80]) { tTEmap::iterator it = gTEmap.find(*dsId); if (it == gTEmap.end() ) { @@ -282,7 +282,7 @@ int read_reactions_() frt >> rname >> lib; if (frt.eof()) break; if (gReactionLibs.find(rname) == gReactionLibs.end() ) { - // possible check + // possible check } gReactionLibs[rname] = lib; } -- GitLab From 5fe325312608886763c9f0c3b9d15d4738e08ab8 Mon Sep 17 00:00:00 2001 From: Ivan Novikov <novivanya@yandex.ru> Date: Thu, 4 Apr 2019 13:54:11 +0200 Subject: [PATCH 71/81] Revert AddPdfDecomp.py AddPdfParam.py to their latest version --- src/mc_errors.f | 31 +- tools/AddPdfDecomp.py | 262 +++--- tools/AddPdfParam.py | 181 ++-- tools/draw/src/CommandParser.cc | 668 +++++++-------- tools/draw/src/DataPainter.cc | 1396 +++++++++++++++---------------- tools/draw/src/PdfData.cc | 146 ++-- tools/install-xfitter | 312 +++---- 7 files changed, 1475 insertions(+), 1521 deletions(-) mode change 100644 => 100755 tools/AddPdfDecomp.py mode change 100644 => 100755 tools/AddPdfParam.py diff --git a/src/mc_errors.f b/src/mc_errors.f index bd25cc73a..7a8147802 100644 --- a/src/mc_errors.f +++ b/src/mc_errors.f @@ -26,7 +26,7 @@ C To be used as a seed: C Single precision here: real rndsh(3) ! additive, poisson, linear $ ,ranflat -C + double precision rand_shift(NSYS) double precision r_sh_fl(NSYS) double precision f_un @@ -48,7 +48,6 @@ C For log normal random shifts: C functions: real logshift double precision alnorm - C------------------------------------------------------------ @@ -127,7 +126,6 @@ c $ s,logshift(lmu,lsig,lrunif) CV now choose sta (advised gauss OR poisson) if (statype.eq.1) then ! gauss - C do separate fluctuations for stat-const, stat-poisson and stat-linear pieces s = s $ + sqrt( e_uncor_const(n0)**2 + e_stat_const(n0)**2) @@ -135,11 +133,6 @@ C do separate fluctuations for stat-const, stat-poisson and stat-linear pieces $ + sqrt( e_uncor_poisson(n0)**2 + e_stat_poisson(n0)**2) $ * sqrt(abs(daten(n0)*sorig))*rndsh(2) $ + e_uncor_mult(n0)*sorig*rndsh(3) - -c if (alpha(n0).eq.0) then -c s = 0.1 -c alpha(n0) = 1.e6 -c endif elseif (statype.eq.3.) then ! lognormal lsig = alpha(n0) lmu=1. @@ -229,13 +222,13 @@ C Store uncor in %: $ 'S: ToyMC cross section with exact ZERO value, stopOB') endif -C Re-scale relative error sources, depending on scaling rule define in chi2 or data files. +C Scale relative error sources, depending on scaling rule defined in chi2-related section of steering or in data files C For : -C - addivie ("NoRescale") errors keep absolute errors unmodified -C - multiplicaiive ("Linear") errors keep relative errors unmodified -C - poisson ("Poisson") keep error * sqrt(old/newVal) unmodified +C - additive ("NoRescale") keep absolute errors unmodified +C - multiplicaitive ("Linear") keep relative errors unmodified +C - poisson ("Poisson") keep (relative error)*sqrt(value) unmodified - scaleF = DATEN(n0)/s + scaleF = DATEN(n0)/s !=oldValue/newValue if (s .lt. 0) then call hf_errlog(1302201901, @@ -276,7 +269,6 @@ C Also correlated systematicss: enddo DATEN(n0) = s - C update alpha: alpha(n0) = sqrt(e_uncor_mult(n0)**2 $ +e_stat_poisson(n0)**2 @@ -286,18 +278,7 @@ C update alpha: $ *daten(n0) enddo - -C call HF_stop - - -C------------------------------------------------------------ end - - - -* --------------------------------------------- - -cv Program voica C--------------------------------------------------- C Created by SG, 23 Apr 2008 following C diff --git a/tools/AddPdfDecomp.py b/tools/AddPdfDecomp.py old mode 100644 new mode 100755 index 78fdd7604..6e0168543 --- a/tools/AddPdfDecomp.py +++ b/tools/AddPdfDecomp.py @@ -7,176 +7,140 @@ import os import datetime if len(sys.argv)<2: - print ''' - Usage: AddPdfDecomp.py NAME - ''' - exit(0) - -name = sys.argv[1] - + print "Usage: "+__file__+" NAME\n Expects working directory to be xFitter root directory" + exit(1) +# Are we in the correct directory? +if not os.path.isdir("pdfdecompositions"): + print "pdfdecompositions directory not found" + exit(2) +name=sys.argv[1] +prefix="pdfdecompositions/"+name # First check if the name is already used - -with open("Reactions.txt","r+") as f: - for l in f: - a = l.split() - if a[0] == name: - print "Interface for reaction "+name+" already exists, exit" - exit(0) - -# Not present, add new line to the Reactions.txt file - -with open("Reactions.txt","a") as f: - f.write(name+" "+"lib"+name.lower()+"_xfitter.so\n") - - -print "Creating directories in pdfdecompositions/"+name+"PdfDecomposition" - -os.system("mkdir -p pdfdecompositions/"+name+"PdfDecomposition/include") -os.system("mkdir -p pdfdecompositions/"+name+"PdfDecomposition/src") -os.system("mkdir -p pdfdecompositions/"+name+"PdfDecomposition/yaml") -os.system("touch pdfdecompositions/"+name+"PdfDecomposition/yaml/parameters.yaml") - -hFile = "pdfdecompositions/{:s}PdfDecomposition/include/{:s}PdfDecomposition.h".format(name,name) - -print "Creating header file "+hFile - - -with open(hFile,"w+") as f: - f.write( - ''' +if os.path.isdir(prefix): + print prefix+" already exists" + exit(3) +classname=None +if name[-1].isupper(): + classname=name+"_PdfDecomp" +else: + classname=name+"PdfDecomp" + +print "Creating directories in "+prefix +os.makedirs(prefix+"/include") +os.makedirs(prefix+"/src") +#here this script used to create an empty prefix+"/yaml/parameters.yaml", but I do not see why --Ivan + +formatDict={"name":name,"classname":classname,"date":datetime.date.today().isoformat(),"scriptname":__file__} + +hFile=prefix+"/include/"+classname+".h" +print "Creating header file "+hFile + +with open(hFile,"w") as f: + f.write('''//Automatically generated by {scriptname} on {date} #pragma once +#include"BasePdfDecomposition.h" +//you probably want to include this +//#include"BasePdfParam.h" -#include "BasePdfDecomposition.h" - +namespace xfitter{{ /** - @class {:s}PdfDecomposition - - @brief A class for {:s} pdf decomposition + @class {classname} - @version 0.1 - @date {:s} - */ + @brief A class for {name} pdf decomposition -namespace xfitter {{ + ADD DESCRIPTION HERE -class {:s}PdfDecomposition : public BasePdfDecomposition -{{ +*/ +class {classname}:public BasePdfDecomposition{{ public: - /// Default constructor. - {:s}PdfDecomposition (); - - /// Default constructor. Name is the PDF name - {:s}PdfDecomposition (const std::string& inName); - - /// Optional initialization at the first call - virtual void initAtStart(const std::string & pars) override final; - - /// Compute PDF in a physical base in LHAPDF format for given x and Q - virtual std::function<std::map<int,double>(const double& x)> f0() const override final; - + {classname}(const char*name):BasePdfDecomposition(name){{}}; + //virtual ~BasePdfDecomposition() + virtual const char*getClassName()const override final{{return"{name}";}}; + virtual std::function<std::map<int,double>(const double&x)>f0()const override final; + virtual void atStart(); //use this to get parameterisations + virtual void atIteration(); //use this to enforce sum rules + //virtual void atConfigurationChange(); }}; }} -'''.format( name, name, datetime.date.today().isoformat(),name,name,name) +'''.format(**formatDict) ) - -sFile = "pdfdecompositions/{:s}PdfDecomposition/src/{:s}PdfDecomposition.cc".format(name,name) - +sFile=prefix+"/src/"+classname+".cc" print "Creating source file "+sFile -with open(sFile,"w+") as f: - f.write(''' -/* - @file {:s}PdfDecomposition.cc - @date {:s} - @author AddPdfDecomposition.py - Created by AddPdfDecomposition.py on {:s} -*/ - -#include "{:s}PdfDecomposition.h" - -namespace xfitter {{ - -/// the class factories, for dynamic loading -extern "C" {:s}PdfDecomposition* create() {{ - return new {:s}PdfDecomposition(); -}} - - -// Constructor - {:s}PdfDecomposition::{:s}PdfDecomposition() : BasePdfDecomposition("{:s}") {{ +with open(sFile,"w") as f: + f.write('''//Automatically generated by {scriptname} on {date} +#include"{classname}.h" +//These might be useful +#include "xfitter_pars.h" +//#include"xfitter_cpp_base.h" //for hf_errlog +//#include<cmath> +//#include<iostream> +namespace xfitter{{ +//for dynamic loading +extern"C" {classname}*create(const char*name){{return new {classname}(name);}} + +void {classname}::atStart(){{ + //YOUR CODE HERE; THE FOLLOWING IS A SUGGESTION + const YAML::Node node=XFITTER_PARS::getDecompositionNode(_name); + //???=getParameterisation(node["???"].as<string>()); + //... }} -// Constructor -{:s}PdfDecomposition::{:s}PdfDecomposition(const std::string& inName) : BasePdfDecomposition(inName) {{ +void {classname}::atIteration(){{ + //YOUR CODE HERE + //Enforce sum rules }} -// Init at start: -void {:s}PdfDecomposition::initAtStart(const std::string & pars) {{ - return; -}} - -// Returns a LHAPDF-style function, that returns PDFs in a physical basis for given x -std::function<std::map<int,double>(const double& x)> {:s}PdfDecomposition::f0() const -{{ - const auto f_ = [=](double const& x)->std::map<int, double> {{ - std::map<int, double> res_ = {{ - {{-6,0}}, - {{-5,0}}, - {{-4,0}}, - {{-3,0}}, - {{-2,0}}, - {{-1,0}}, - {{ 1,0}}, - {{ 2,0}}, - {{ 3,0}}, - {{ 4,0}}, - {{ 5,0}}, - {{ 6,0}}, - {{22,0}} - }}; - return res_; +std::function<std::map<int,double>(const double&x)>{classname}::f0()const{{ + return[=](double const&x)->std::map<int,double>{{ + //YOUR CODE HERE + //retrieve and rotate pdf here + return std::map<int, double>{{ + //change zeros to something meaningful + {{-6,0}}, + {{-5,0}}, + {{-4,0}}, + {{-3,0}},//sbar + {{-2,0}},//dbar + {{-1,0}},//ubar + {{ 1,0}},//d + {{ 2,0}},//u + {{ 3,0}},//s + {{ 4,0}}, + {{ 5,0}}, + {{ 6,0}}, + {{21,0}}//gluon + }}; }}; - return f_; }} }} -'''.format(name,datetime.date.today().isoformat(),datetime.date.today().isoformat() - ,name,name,name,name,name,name,name,name,name,name) +'''.format(**formatDict) ) - -aFile = "pdfdecompositions/{:s}PdfDecomposition/src/Makefile.am".format(name) - -print "Creating autoconf file " + aFile - - -with open(aFile,"w+") as f: - f.write(''' -# Created by AddPdfDecomposition.py on {:s} - -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../pdfparams/BasePdfParam/include/ -I$(srcdir)/../../BasePdfDecomposition/include -Wall -fPIC -Wno-deprecated - -lib_LTLIBRARIES = lib{:s}PdfDecomposition_xfitter.la -lib{:s}PdfDecomposition_xfitter_la_SOURCES = {:s}PdfDecomposition.cc - -datadir = ${{prefix}}/yaml/pdfdecompositions/{:s} -data_DATA = ../yaml/parameters.yaml - -dist_noinst_HEADERS = ../include ../yaml -'''.format(datetime.date.today().isoformat(),name,name,name,name)) - - - -print "Update configure.ac file" -os.system("sed 's|xfitter-config|xfitter-config\\n pdfdecompositions/{:s}PdfDecomposition/src/Makefile|' configure.ac >/tmp/configure.ac".format(name)) -os.system("cp /tmp/configure.ac configure.ac") - -print "Update Makefile.am" -os.system("sed 's|pdfdecompositions/BasePdfDecomposition/src|pdfdecompositions/BasePdfDecomposition/src pdfdecompositions/{:s}PdfDecomposition/src|' Makefile.am > /tmp/Makefile.am".format(name)) -os.system("cp /tmp/Makefile.am Makefile.am") - -print "Update doxygen.cfg" -os.system("sed 's|pdfdecompositions/BasePdfDecomposition/include|pdfdecompositions/BasePdfDecomposition/include pdfdecompositions/{:s}PdfDecomposition/include|' doxygen.cfg > /tmp/doxygen.cfg".format(name)) -os.system("cp /tmp/doxygen.cfg doxygen.cfg") - +aFile=prefix+"/src/Makefile.am" +print "Creating automake file "+aFile + +with open(aFile,"w") as f: + f.write('''#Automatically generated by {scriptname} on {date} +AM_CXXFLAGS=-I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../../pdfparams/BasePdfParam/include/ -I$(srcdir)/../../BasePdfDecomposition/include -Wall -fPIC -Wno-deprecated + +lib_LTLIBRARIES=lib{classname}_xfitter.la +lib{classname}_xfitter_la_SOURCES={classname}.cc +dist_noinst_HEADERS=../include +'''.format(**formatDict)) + +def insertLine(filename,after,line): + after=after.replace('/',r'\/') + if line[0]==' ':line='\\'+line + s="sed -i '/{}/a{}' {}".format(after,line,filename) + os.system(s) +print "Updating configure.ac" +insertLine("configure.ac","pdfdecompositions/BasePdfDecomposition/src/Makefile"," {}/src/Makefile".format(prefix)) +print "Updating Makefile.am" +insertLine("Makefile.am","pdfdecompositions/BasePdfDecomposition/src"," {}/src\\\\".format(prefix)) +print "Updating doxygen.cfg" +insertLine("doxygen.cfg","pdfdecompositions/BasePdfDecomposition/include"," {}/include\\\\".format(prefix)) +print "Updating Reactions.txt" +insertLine("Reactions.txt","UvDvubardbars",name+" lib"+classname+"_xfitter.so") diff --git a/tools/AddPdfParam.py b/tools/AddPdfParam.py old mode 100644 new mode 100755 index 6b995f5b9..4cd5e5233 --- a/tools/AddPdfParam.py +++ b/tools/AddPdfParam.py @@ -7,111 +7,120 @@ import os import datetime if len(sys.argv)<2: - print ''' - Usage: AddPdfParam.py NAME - ''' - exit(0) - -name = sys.argv[1] - + print "Usage: "+__file__+" NAME\n Expects working directory to be xFitter root directory" + exit(1) +# Are we in the correct directory? +if not os.path.isdir("pdfparams"): + print "pdfparams directory not found" + exit(2) # First check if the name is already used - -print "Creating directories in pdfparams/"+name - -os.system("mkdir -p pdfparams/"+name+"PdfParam/include") -os.system("mkdir -p pdfparams/"+name+"PdfParam/src") -os.system("mkdir -p pdfparams/"+name+"PdfParam/yaml") -os.system("touch pdfparams/"+name+"PdfParam/yaml/parameters.yaml") - -hFile = "pdfparams/{:s}PdfParam/include/{:s}PdfParam.h".format(name,name) - -print "Creating header file "+hFile - -with open(hFile,"w+") as f: - f.write( - ''' +name=sys.argv[1] +prefix="pdfparams/"+name +if os.path.isdir(prefix): + print prefix+" already exists" + exit(3) +classname=None +if name[-1].isupper(): + classname=name+"_PdfParam" +else: + classname=name+"PdfParam" + +print "Creating directories in "+prefix +os.makedirs(prefix+"/include") +os.makedirs(prefix+"/src") +#here this script used to create an empty prefix+"/yaml/parameters.yaml", but I do not see why --Ivan + +formatDict={"name":name,"classname":classname,"date":datetime.date.today().isoformat(),"scriptname":__file__} + +hFile=prefix+"/include/"+classname+".h" +print "Creating header file "+hFile + +with open(hFile,"w") as f: + f.write('''//Automatically generated by {scriptname} on {date} #pragma once - -#include "BasePdfParam.h" +#include"BasePdfParam.h" /** - @class {name:s}PdfParam + @class {classname} - @brief A class for {name:s} pdf parameterisation + @brief A class for {name} pdf parameterisation - @version 0.1 - @date {date:s} - */ + ADD DESCRIPTION HERE -class {name:s}PdfParam:public BasePdfParam{{ +*/ + +namespace xfitter{{ +class {classname}:public BasePdfParam{{ public: - {name:s}PdfParam(const std::string&inName):BasePdfParam(inName){{}} - //Evaluate xf(x) at given x with current parameters + {classname}(const std::string&name):BasePdfParam(name){{}} virtual double operator()(double x)const override final; - // (Optional) compute moments: // virtual double moment(int nMoment=-1)const override final; - // (Optional) set moments: // virtual void setMoment(int nMoment,double value)override final; - // (Optional) - //Initialize from a yaml node. Uses node[getName] as the basis - // virtual void initFromYaml(YAML::Node value)override final; + // virtual void atStart()override final; }}; -'''.format(name=name,date=datetime.date.today().isoformat()) +}} +'''.format(**formatDict) ) - -sFile = "pdfparams/{:s}PdfParam/src/{:s}PdfParam.cc".format(name,name) - +sFile=prefix+"/src/"+classname+".cc" print "Creating source file "+sFile -with open(sFile,"w+") as f: - f.write(''' -/* - @file {name:s}PdfParam.cc - @date {date:s} - @author AddPdfParam.py - Created by AddPdfParam.py on {date:s} -*/ +with open(sFile,"w") as f: + f.write('''//Automatically generated by {scriptname} on {date} + +#include"{classname}.h" +//These might be useful +//#include"xfitter_cpp_base.h" //for hf_errlog +//#include<cmath> +//#include<iostream> -#include "{name:s}PdfParam.h" +namespace xfitter{{ +//for dynamic loading +extern"C" {classname}*create(const char*s){{return new {classname}(s);}} -double {name:s}PdfParam::operator()(double x){{ +double {classname}::operator()(double x)const{{ //Your code here }} -'''.format(name=name,date=datetime.date.today().isoformat()) -) - -aFile = "pdfparams/{:s}PdfParam/src/Makefile.am".format(name) - -print "Creating autoconf file " + aFile - - -with open(aFile,"w+") as f: - f.write(''' -# Created by AddPdfParam.py on {:s} - -AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated - -lib_LTLIBRARIES = lib{:s}PdfParam_xfitter.la -lib{:s}PdfParam_xfitter_la_SOURCES = {:s}PdfParam.cc -datadir = ${{prefix}}/yaml/pdfparams/{:s} -data_DATA = ../yaml/parameters.yaml - -dist_noinst_HEADERS = ../include ../yaml -'''.format(datetime.date.today().isoformat(),name,name,name,name)) - - -print "Update configure.ac file" -os.system("sed 's|xfitter-config|xfitter-config\\n pdfparams/{:s}PdfParam/src/Makefile|' configure.ac >/tmp/configure.ac".format(name)) -os.system("cp /tmp/configure.ac configure.ac") - -print "Update Makefile.am" -os.system("sed 's|pdfdecompositions/BasePdfDecomposition/src|pdfdecompositions/BasePdfDecomposition/src pdfparams/{:s}PdfParam/src|' Makefile.am > /tmp/Makefile.am".format(name)) -os.system("cp /tmp/Makefile.am Makefile.am") - -print "Update doxygen.cfg" -os.system("sed 's|pdfparams/BasePdfParam/include|pdfparams/BasePdfParam/include pdfparams/{:s}PdfParam/include|' doxygen.cfg > /tmp/doxygen.cfg".format(name)) -os.system("cp /tmp/doxygen.cfg doxygen.cfg") +//OPTIONAL + +//void {classname}::atStart(){{ +// Your code here +// Check that number of parameters is sane +//}} +//double {classname}::moment(int n)const{{ +// Your code here +//}} +//void {classname}::setMoment(int n,double val){{ +// Your code here +//}} +}} +'''.format(**formatDict) +) -exit(0) +aFile=prefix+"/src/Makefile.am" +print "Creating automake file "+aFile + +with open(aFile,"w") as f: + f.write('''#Automatically generated by {scriptname} on {date} +AM_CXXFLAGS=-I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/../../BasePdfParam/include -Wall -fPIC -Wno-deprecated + +lib_LTLIBRARIES=lib{classname}_xfitter.la +lib{classname}_xfitter_la_SOURCES={classname}.cc +dist_noinst_HEADERS=../include +lib{classname}_xfitter_la_LDFLAGS=-lBasePdfParam_xfitter -L$(libdir) +'''.format(**formatDict)) + +def insertLine(filename,after,line): + after=after.replace('/',r'\/') + if line[0]==' ':line='\\'+line + s="sed -i '/{}/a{}' {}".format(after,line,filename) + os.system(s) +print "Updating configure.ac" +insertLine("configure.ac","pdfparams/BasePdfParam/src/Makefile"," {}/src/Makefile".format(prefix)) +print "Updating Makefile.am" +insertLine("Makefile.am","pdfparams/BasePdfParam/src"," {}/src\\\\".format(prefix)) +print "Updating doxygen.cfg" +insertLine("doxygen.cfg","pdfparams/BasePdfParam/include"," {}/include\\\\".format(prefix)) +print "Updating Reactions.txt" +insertLine("Reactions.txt","HERAPDF",name+" lib"+classname+"_xfitter.so") diff --git a/tools/draw/src/CommandParser.cc b/tools/draw/src/CommandParser.cc index 3c7d58f9f..c5f74f3c4 100644 --- a/tools/draw/src/CommandParser.cc +++ b/tools/draw/src/CommandParser.cc @@ -142,213 +142,213 @@ CommandParser::CommandParser(int argc, char **argv): for (vector<string>::iterator it = allargs.begin() + 1; it != allargs.end(); it++) if ((*it).find("--") == 0) { - if (*it == "--help") - { - help(); - exit(0); - } - else if (*it == "--thicklines") - lwidth = 3; - else if (*it == "--largetext") - { - txtsize = 0.05; - lmarg = 0.18; - bmarg = 0.13; - offset = 1.6; - } - else if (*it == "--bw") - bw = true; - else if (*it == "--lowres") - { - resolution = 400; - // pagewidth = 10; - } - else if (*it == "--highres") - { - resolution = 2400; - // pagewidth = 60; - } - else if (*it == "--no-version") - version = false; - else if (*it == "--no-logo") - drawlogo = false; - else if (*it == "--no-data") - nodata = true; - else if (*it == "--no-pdfs") - nopdfs = true; - else if (*it == "--no-shifts") - noshifts = true; - else if (*it == "--no-tables") - notables = true; - else if (*it == "--chi2-nopdf-uncertainties") - chi2nopdf = true; - else if (*it == "--partial-log-penalty") - logpenalty = true; - else if (*it == "--helvet-fonts") - font = "helvet"; - else if (*it == "--cmbright-fonts") - font = "modernbright"; - else if (*it == "--shifts-per-page") - { - adjshift = false; - spp = atoi((*(it+1)).c_str()); - spp = max(1, spp); - spp = min(40, spp); - allargs.erase(it+1); - } - else if (*it == "--shifts-heigth") - { - adjshift = false; - shgth = atoi((*(it+1)).c_str()); - shgth = max(20, shgth); - shgth = min(200, shgth); - allargs.erase(it+1); - } - else if (*it == "--cms") - { - cms = true; - drawlogo = false; - } - else if (*it == "--cms-preliminary") - { - cmspreliminary = true; - drawlogo = false; - } - else if (*it == "--atlas") - { - atlas = true; - drawlogo = false; - } - else if (*it == "--atlas-internal") - { - atlasinternal = true; - drawlogo = false; - } - else if (*it == "--atlas-preliminary") - { - atlaspreliminary = true; - drawlogo = false; - } - else if (*it == "--cdfii-preliminary") - { - cdfiipreliminary = true; - drawlogo = false; - } - else if (*it == "--hidden") - { - cout << endl; - cout << "Hidden options" << endl; - cout << "Please use this options only if you are authorised from your collaboration to do so" << endl; - cout << "--cms" << endl; - cout << "--cms-preliminary" << endl; - cout << "--atlas" << endl; - cout << "--atlas-internal" << endl; - cout << "--atlas-preliminary" << endl; - cout << "--cdfii-preliminary" << endl; - cout << "--no-logo" << endl; - cout << endl; - exit(-1); - } - else if (*it == "--bands") - dobands = true; - else if (*it == "--scale68") - scale68 = true; - else if (*it == "--profile") { - dobands = true; - profile = true; - } - else if (*it == "--reweight-BAY") { - dobands = true; - reweight = true; - BAYweight = true; - } - else if (*it == "--reweight-GK") { - dobands = true; - reweight = true; - GKweight = true; - } - else if (*it == "--asym") - { - dobands = true; - asym = true; - } - else if (*it == "--median") - median = true; - else if (*it == "--68cl") - { - if (cl90 == true) - { - cout << "Options --68cl and --90cl are mutually exclusive, cannot use both" << endl; - exit(1); - } - cl68 = true; - median = true; - } - else if (*it == "--90cl") - { - if (cl68 == true) - { - cout << "Options --68cl and --90cl are mutually exclusive, cannot use both" << endl; - exit(1); - } - cl90 = true; - median = true; - } - else if (*it == "--absolute-errors") - { - dobands = true; - abserror = true; - } - else if (*it == "--relative-errors") - { - dobands = true; - relerror = true; - } - else if (*it == "--no-logx") - logx = false; - else if (*it == "--q2all") - q2all = true; - else if (*it == "--plots-per-page") - { - plotsperpage = atoi((*(it+1)).c_str()); - allargs.erase(it+1); - } - else if (*it == "--loose-mc-replica-selection") - looseRepSelection = true; - else if (*it == "--outdir") - { - outdir = *(it+1); - allargs.erase(it+1); - } - else if (*it == "--eps") - format = "eps"; - else if (*it == "--root") - root = true; - else if (*it == "--splitplots-eps") - { - splitplots = true; - ext = "eps"; - } - else if (*it == "--splitplots-pdf") - { - splitplots = true; - ext = "pdf"; - } - else if (*it == "--splitplots-png") - { - splitplots = true; - ext = "png"; - } - else if (*it == "--filledbands") - filledbands = true; - else if (*it == "--ratiorange") - { - rmin = atof((*(it+1)).substr(0, (*(it+1)).find(":")).c_str()); - rmax = atof((*(it+1)).substr((*(it+1)).find(":") + 1, (*(it+1)).size() - (*(it+1)).find(":") - 1).c_str()); - allargs.erase(it+1); - } - else if (*it == "--xrange") - { + if (*it == "--help") + { + help(); + exit(0); + } + else if (*it == "--thicklines") + lwidth = 3; + else if (*it == "--largetext") + { + txtsize = 0.05; + lmarg = 0.18; + bmarg = 0.13; + offset = 1.6; + } + else if (*it == "--bw") + bw = true; + else if (*it == "--lowres") + { + resolution = 400; + // pagewidth = 10; + } + else if (*it == "--highres") + { + resolution = 2400; + // pagewidth = 60; + } + else if (*it == "--no-version") + version = false; + else if (*it == "--no-logo") + drawlogo = false; + else if (*it == "--no-data") + nodata = true; + else if (*it == "--no-pdfs") + nopdfs = true; + else if (*it == "--no-shifts") + noshifts = true; + else if (*it == "--no-tables") + notables = true; + else if (*it == "--chi2-nopdf-uncertainties") + chi2nopdf = true; + else if (*it == "--partial-log-penalty") + logpenalty = true; + else if (*it == "--helvet-fonts") + font = "helvet"; + else if (*it == "--cmbright-fonts") + font = "modernbright"; + else if (*it == "--shifts-per-page") + { + adjshift = false; + spp = atoi((*(it+1)).c_str()); + spp = max(1, spp); + spp = min(40, spp); + allargs.erase(it+1); + } + else if (*it == "--shifts-heigth") + { + adjshift = false; + shgth = atoi((*(it+1)).c_str()); + shgth = max(20, shgth); + shgth = min(200, shgth); + allargs.erase(it+1); + } + else if (*it == "--cms") + { + cms = true; + drawlogo = false; + } + else if (*it == "--cms-preliminary") + { + cmspreliminary = true; + drawlogo = false; + } + else if (*it == "--atlas") + { + atlas = true; + drawlogo = false; + } + else if (*it == "--atlas-internal") + { + atlasinternal = true; + drawlogo = false; + } + else if (*it == "--atlas-preliminary") + { + atlaspreliminary = true; + drawlogo = false; + } + else if (*it == "--cdfii-preliminary") + { + cdfiipreliminary = true; + drawlogo = false; + } + else if (*it == "--hidden") + { + cout << endl; + cout << "Hidden options" << endl; + cout << "Please use this options only if you are authorised from your collaboration to do so" << endl; + cout << "--cms" << endl; + cout << "--cms-preliminary" << endl; + cout << "--atlas" << endl; + cout << "--atlas-internal" << endl; + cout << "--atlas-preliminary" << endl; + cout << "--cdfii-preliminary" << endl; + cout << "--no-logo" << endl; + cout << endl; + exit(-1); + } + else if (*it == "--bands") + dobands = true; + else if (*it == "--scale68") + scale68 = true; + else if (*it == "--profile") { + dobands = true; + profile = true; + } + else if (*it == "--reweight-BAY") { + dobands = true; + reweight = true; + BAYweight = true; + } + else if (*it == "--reweight-GK") { + dobands = true; + reweight = true; + GKweight = true; + } + else if (*it == "--asym") + { + dobands = true; + asym = true; + } + else if (*it == "--median") + median = true; + else if (*it == "--68cl") + { + if (cl90 == true) + { + cout << "Options --68cl and --90cl are mutually exclusive, cannot use both" << endl; + exit(1); + } + cl68 = true; + median = true; + } + else if (*it == "--90cl") + { + if (cl68 == true) + { + cout << "Options --68cl and --90cl are mutually exclusive, cannot use both" << endl; + exit(1); + } + cl90 = true; + median = true; + } + else if (*it == "--absolute-errors") + { + dobands = true; + abserror = true; + } + else if (*it == "--relative-errors") + { + dobands = true; + relerror = true; + } + else if (*it == "--no-logx") + logx = false; + else if (*it == "--q2all") + q2all = true; + else if (*it == "--plots-per-page") + { + plotsperpage = atoi((*(it+1)).c_str()); + allargs.erase(it+1); + } + else if (*it == "--loose-mc-replica-selection") + looseRepSelection = true; + else if (*it == "--outdir") + { + outdir = *(it+1); + allargs.erase(it+1); + } + else if (*it == "--eps") + format = "eps"; + else if (*it == "--root") + root = true; + else if (*it == "--splitplots-eps") + { + splitplots = true; + ext = "eps"; + } + else if (*it == "--splitplots-pdf") + { + splitplots = true; + ext = "pdf"; + } + else if (*it == "--splitplots-png") + { + splitplots = true; + ext = "png"; + } + else if (*it == "--filledbands") + filledbands = true; + else if (*it == "--ratiorange") + { + rmin = atof((*(it+1)).substr(0, (*(it+1)).find(":")).c_str()); + rmax = atof((*(it+1)).substr((*(it+1)).find(":") + 1, (*(it+1)).size() - (*(it+1)).find(":") - 1).c_str()); + allargs.erase(it+1); + } + else if (*it == "--xrange") + { string&s=*(it+1); size_t p=s.find(':'); s[p]=0; @@ -356,135 +356,135 @@ CommandParser::CommandParser(int argc, char **argv): xmin=max(1e-15,xmin); xmax=atof(s.c_str()+p+1); xmax=min(1.,xmax); - allargs.erase(it+1); - } - else if (*it == "--colorpattern") - { - int pattern = atoi((*(it+1)).c_str()); - if (pattern == 1) - { - col[0] = kBlue + 2; - col[1] = kOrange; - col[2] = kGreen - 3; - col[3] = kRed + 1; - col[5] = kOrange + 7; - col[5] = kCyan + 1; - } - else if (pattern == 2) - { - col[0] = kBlue + 2; - col[1] = kRed + 1; - col[2] = kYellow - 7; - col[3] = kOrange + 7; - col[4] = kMagenta + 1; - col[5] = kCyan + 1; - } - else if (pattern == 3) - { - col[0] = kBlue + 2; - col[1] = kMagenta + 1; - col[2] = kCyan + 1; - col[3] = kRed + 1; - col[4] = kGreen + 2; - col[5] = kYellow + 1; - } - else if (pattern == 4) - { - col[0] = kBlue + 1; - col[1] = kAzure - 9; - col[2] = kAzure + 3; - col[3] = kAzure + 4; - col[4] = kAzure + 5; - col[5] = kAzure + 6; - } - else if (pattern == 5) - { - col[0] = kOrange + 7; - col[1] = kYellow; - col[2] = kRed - 1; - col[3] = kOrange + 4; - col[4] = kOrange + 2; - col[5] = kOrange -1; - } - else if (pattern == 6) - { - col[0] = kGreen + 2; - col[1] = kSpring - 9; - col[2] = kGreen + 1; - col[3] = kSpring + 4; - col[4] = kSpring + 2; - col[5] = kSpring + 7; - } - else if (pattern == 7) - { - col[0] = kRed - 2; - col[1] = kAzure - 9; - col[2] = kSpring - 9; - col[3] = kOrange + 7; - col[4] = kSpring + 2; - col[5] = kSpring + 7; - } - else if (pattern == 8) - { - col[0] = kRed - 2; - col[1] = kBlue + 1; - col[2] = kGreen + 1; - col[3] = kOrange + 7; - col[4] = kSpring + 2; - col[5] = kSpring + 7; - } + allargs.erase(it+1); + } + else if (*it == "--colorpattern") + { + int pattern = atoi((*(it+1)).c_str()); + if (pattern == 1) + { + col[0] = kBlue + 2; + col[1] = kOrange; + col[2] = kGreen - 3; + col[3] = kRed + 1; + col[5] = kOrange + 7; + col[5] = kCyan + 1; + } + else if (pattern == 2) + { + col[0] = kBlue + 2; + col[1] = kRed + 1; + col[2] = kYellow - 7; + col[3] = kOrange + 7; + col[4] = kMagenta + 1; + col[5] = kCyan + 1; + } + else if (pattern == 3) + { + col[0] = kBlue + 2; + col[1] = kMagenta + 1; + col[2] = kCyan + 1; + col[3] = kRed + 1; + col[4] = kGreen + 2; + col[5] = kYellow + 1; + } + else if (pattern == 4) + { + col[0] = kBlue + 1; + col[1] = kAzure - 9; + col[2] = kAzure + 3; + col[3] = kAzure + 4; + col[4] = kAzure + 5; + col[5] = kAzure + 6; + } + else if (pattern == 5) + { + col[0] = kOrange + 7; + col[1] = kYellow; + col[2] = kRed - 1; + col[3] = kOrange + 4; + col[4] = kOrange + 2; + col[5] = kOrange -1; + } + else if (pattern == 6) + { + col[0] = kGreen + 2; + col[1] = kSpring - 9; + col[2] = kGreen + 1; + col[3] = kSpring + 4; + col[4] = kSpring + 2; + col[5] = kSpring + 7; + } + else if (pattern == 7) + { + col[0] = kRed - 2; + col[1] = kAzure - 9; + col[2] = kSpring - 9; + col[3] = kOrange + 7; + col[4] = kSpring + 2; + col[5] = kSpring + 7; + } + else if (pattern == 8) + { + col[0] = kRed - 2; + col[1] = kBlue + 1; + col[2] = kGreen + 1; + col[3] = kOrange + 7; + col[4] = kSpring + 2; + col[5] = kSpring + 7; + } - allargs.erase(it+1); - } - else if (*it == "--therr") - therr = true; - else if (*it == "--noupband") - noupband = true; - else if (*it == "--greenband") - errbandcol = kGreen - 3; - else if (*it == "--blueband") - errbandcol = kAzure - 9; - else if (*it == "--points") - points = true; - else if (*it == "--theory") - { - theorylabel = *(it+1); - allargs.erase(it+1); - } - else if (*it == "--only-theory") - { - onlytheory = true; - ratiototheory = true; - } - else if (*it == "--theory-rel-errors") - { - onlytheory = true; - ratiototheory = true; - threlerr = true; - } - else if (*it == "--ratio-to-theory") - ratiototheory = true; - else if (*it == "--diff") - diff = true; - else if (*it == "--2panels") - twopanels = true; - else if (*it == "--3panels") - threepanels = true; - else if (*it == "--multitheory") - multitheory = true; - else if (*it == "--nothshifts") - nothshifts = true; - else - { - cout << endl; - cout << "Invalid option " << *it << endl; - cout << allargs[0] << " --help for help " << endl; - cout << endl; - exit(-1); - } - allargs.erase(it); - it = allargs.begin(); + allargs.erase(it+1); + } + else if (*it == "--therr") + therr = true; + else if (*it == "--noupband") + noupband = true; + else if (*it == "--greenband") + errbandcol = kGreen - 3; + else if (*it == "--blueband") + errbandcol = kAzure - 9; + else if (*it == "--points") + points = true; + else if (*it == "--theory") + { + theorylabel = *(it+1); + allargs.erase(it+1); + } + else if (*it == "--only-theory") + { + onlytheory = true; + ratiototheory = true; + } + else if (*it == "--theory-rel-errors") + { + onlytheory = true; + ratiototheory = true; + threlerr = true; + } + else if (*it == "--ratio-to-theory") + ratiototheory = true; + else if (*it == "--diff") + diff = true; + else if (*it == "--2panels") + twopanels = true; + else if (*it == "--3panels") + threepanels = true; + else if (*it == "--multitheory") + multitheory = true; + else if (*it == "--nothshifts") + nothshifts = true; + else + { + cout << endl; + cout << "Invalid option " << *it << endl; + cout << allargs[0] << " --help for help " << endl; + cout << endl; + exit(-1); + } + allargs.erase(it); + it = allargs.begin(); } for (vector<string>::iterator it = allargs.begin() + 1; it != allargs.end(); it++) diff --git a/tools/draw/src/DataPainter.cc b/tools/draw/src/DataPainter.cc index ed63dfeb5..d2d0340a2 100644 --- a/tools/draw/src/DataPainter.cc +++ b/tools/draw/src/DataPainter.cc @@ -40,9 +40,9 @@ vector <range> historanges(TH1F *h) for (; b <= h->GetXaxis()->GetLast(); b++) if (h->GetBinContent(b) == 0) { - temp.upedge = h->GetXaxis()->GetBinLowEdge(b - 1); - ranges.push_back(temp); - temp.lowedge = h->GetXaxis()->GetBinUpEdge(b); + temp.upedge = h->GetXaxis()->GetBinLowEdge(b - 1); + ranges.push_back(temp); + temp.lowedge = h->GetXaxis()->GetBinUpEdge(b); } temp.upedge = h->GetXaxis()->GetBinUpEdge(b - 2); ranges.push_back(temp); @@ -62,32 +62,32 @@ void Subplot::Draw(TH1F* histo, string opt) //Set correct x point vector <double> valy; for (int i = 0; i < graph->GetN(); i++) - valy.push_back(graph->GetY()[i]); + valy.push_back(graph->GetY()[i]); for (int i = 0; i < graph->GetN(); i++) - { - graph->SetPoint(i, valx[i], valy[i]); - graph->SetPointEXhigh(i, 0); - graph->SetPointEXlow(i, 0); - } + { + graph->SetPoint(i, valx[i], valy[i]); + graph->SetPointEXhigh(i, 0); + graph->SetPointEXlow(i, 0); + } graph->Sort(); if (opt.find("same") == string::npos) - opt.insert(0, "A"); + opt.insert(0, "A"); if (opt.find("E1") != string::npos) - opt.erase(opt.find("E1")+1); + opt.erase(opt.find("E1")+1); if (opt.find("][") != string::npos) //this is a pull histo, force drawing as histogram - { - vector <double> valy; - for (int i = 0; i < graph->GetN(); i++) - valy.push_back(graph->GetY()[i]); - for (int i = 0; i < graph->GetN(); i++) - histo->SetBinContent(i+1, valy[i]); - histo->Draw(opt.c_str()); - } + { + vector <double> valy; + for (int i = 0; i < graph->GetN(); i++) + valy.push_back(graph->GetY()[i]); + for (int i = 0; i < graph->GetN(); i++) + histo->SetBinContent(i+1, valy[i]); + histo->Draw(opt.c_str()); + } else - graph->Draw(opt.c_str()); + graph->Draw(opt.c_str()); } else histo->Draw(opt.c_str()); } @@ -108,7 +108,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) if(!subplot.IsValid())continue; datahistos.push_back(subplot); labels.push_back(label); - } + } if (datahistos.size() < 1) return 0; //Empty dataset vector @@ -123,20 +123,20 @@ TCanvas * DataPainter(int dataindex, int subplotindex) if (opts.multitheory) { if (datahistos.size() == 2) - { - opts.twopanels = true; - opts.threepanels = false; - } + { + opts.twopanels = true; + opts.threepanels = false; + } if (datahistos.size() == 3) - { - opts.twopanels = false; - opts.threepanels = true; - } + { + opts.twopanels = false; + opts.threepanels = true; + } if (datahistos.size() > 3) - { - cout << "Cannot plot in multitheory mode more than 3 directories" << endl; - return 0; - } + { + cout << "Cannot plot in multitheory mode more than 3 directories" << endl; + return 0; + } } TCanvas * cnv; @@ -245,9 +245,9 @@ TCanvas * DataPainter(int dataindex, int subplotindex) { int pullpad; if (opts.twopanels) - pullpad = 2; + pullpad = 2; if (opts.threepanels) - pullpad = 3; + pullpad = 3; Pulls = (TPad*)cnv->GetPad(2)->GetPad(pullpad); Pulls->SetPad(0, 0, 1, bmarg+dy); @@ -304,7 +304,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) { up_templ->GetXaxis()->SetNoExponent(); if (axmax/axmin < 90) - up_templ->GetXaxis()->SetMoreLogLabels(); + up_templ->GetXaxis()->SetMoreLogLabels(); } //Evaluate maximum and minimum @@ -317,11 +317,11 @@ TCanvas * DataPainter(int dataindex, int subplotindex) for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) { if (opts.therr && !opts.noupband) - mx = max(mx, (float)((*it).gettherrup()->GetMaximum())); + mx = max(mx, (float)((*it).gettherrup()->GetMaximum())); else - mx = max(mx, (float)((*it).getth()->GetMaximum())); + mx = max(mx, (float)((*it).getth()->GetMaximum())); if (!opts.onlytheory) - mx = max(mx, (float)((*it).getthshift()->GetMaximum())); + mx = max(mx, (float)((*it).getthshift()->GetMaximum())); } float mn = mx; @@ -332,17 +332,17 @@ TCanvas * DataPainter(int dataindex, int subplotindex) for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) { if (opts.therr && !opts.noupband) - mn = min(mn, (float)(hmin((*it).gettherrdown()))); + mn = min(mn, (float)(hmin((*it).gettherrdown()))); else - mn= min(mn, (float)(hmin((*it).getth()))); + mn= min(mn, (float)(hmin((*it).getth()))); if (!opts.onlytheory) - mn = min(mn, (float)(hmin((*it).getthshift()))); + mn = min(mn, (float)(hmin((*it).getthshift()))); } if (datahistos[0].getlogy()) { if (mn < 0) - mn = 0.000001; + mn = 0.000001; float ratio = mx / mn; mx = mx * pow(10, log10(ratio) * 0.45/my); mn = mn / pow(10, log10(ratio) * 0.7/my); @@ -375,7 +375,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) { datatot->SetAxisRange((*r).lowedge, (*r).upedge); if (!opts.onlytheory) - datahistos[0].Draw((TH1F*)datatot->Clone(), "PE3 same"); + datahistos[0].Draw((TH1F*)datatot->Clone(), "PE3 same"); } if (!opts.onlytheory) datahistos[0].Draw(data, "PE1 same"); @@ -392,17 +392,17 @@ TCanvas * DataPainter(int dataindex, int subplotindex) float txtsz; string infolabel; if (opts.atlasinternal || opts.atlaspreliminary || opts.atlas) - { - vertdist = 0.10; - txtsz = 1.; - infolabel = datahistos[0].getextralabel() + "; " + datahistos[0].getlumilabel(); - } + { + vertdist = 0.10; + txtsz = 1.; + infolabel = datahistos[0].getextralabel() + "; " + datahistos[0].getlumilabel(); + } else - { - vertdist = 0.05; - txtsz = 1.; - infolabel = datahistos[0].getextralabel(); - } + { + vertdist = 0.05; + txtsz = 1.; + infolabel = datahistos[0].getextralabel(); + } l.SetTextSize(txtsz*0.04/my); l.DrawLatex(lmarg+0.05, (1-tmarg/my) - vertdist/my, infolabel.c_str()); } @@ -410,16 +410,16 @@ TCanvas * DataPainter(int dataindex, int subplotindex) if (datahistos[0].getlumilabel() != "") if (!(opts.atlasinternal || opts.atlaspreliminary || opts.atlas)) { - TLatex l; - l.SetNDC(); - l.SetTextFont(42); - - float vertdist; - float txtsz; - vertdist = 0.13; - txtsz = 1.; - l.SetTextSize(txtsz*0.04/my); - l.DrawLatex(lmarg+0.05, (1-tmarg/my) - vertdist/my, datahistos[0].getlumilabel().c_str()); + TLatex l; + l.SetNDC(); + l.SetTextFont(42); + + float vertdist; + float txtsz; + vertdist = 0.13; + txtsz = 1.; + l.SetTextSize(txtsz*0.04/my); + l.DrawLatex(lmarg+0.05, (1-tmarg/my) - vertdist/my, datahistos[0].getlumilabel().c_str()); } //Main legend @@ -433,18 +433,18 @@ TCanvas * DataPainter(int dataindex, int subplotindex) { TLegend * leg; if (opts.nothshifts) - leg = new TLegend(lmarg+0.04, mb+0.03, lmarg+0.04+0.30, mb+0.03+0.12/my); + leg = new TLegend(lmarg+0.04, mb+0.03, lmarg+0.04+0.30, mb+0.03+0.12/my); else - leg = new TLegend(lmarg+0.04, mb+0.03, lmarg+0.04+0.30, mb+0.03+0.2/my); + leg = new TLegend(lmarg+0.04, mb+0.03, lmarg+0.04+0.30, mb+0.03+0.2/my); string datalab = (string) "Data " + datahistos[0].gettitle(); if (datahistos[0].getexperiment() != "") - datalab = datahistos[0].getexperiment() + " " + datalab; + datalab = datahistos[0].getexperiment() + " " + datalab; if (!opts.onlytheory) - { - leg->AddEntry(data, datalab.c_str(), "pl"); - leg->AddEntry(data, "#delta uncorrelated", "pe"); - leg->AddEntry(datatot, "#delta total", "f"); - } + { + leg->AddEntry(data, datalab.c_str(), "pl"); + leg->AddEntry(data, "#delta uncorrelated", "pe"); + leg->AddEntry(datatot, "#delta total", "f"); + } TH1 *mark = (TH1F*)datahistos[0].getth()->Clone(); mark->SetMarkerStyle(opts.markers[labels[0]]); mark->SetMarkerSize(2 * opts.resolution / 1200); @@ -456,23 +456,23 @@ TCanvas * DataPainter(int dataindex, int subplotindex) dash->SetLineStyle(2); dash->SetLineWidth(opts.lwidth); if (datahistos.size() == 1) - { - cont->SetLineColor(opts.colors[labels[0]]); - dash->SetLineColor(opts.colors[labels[0]]); - mark->SetMarkerColor(opts.colors[labels[0]]); - } + { + cont->SetLineColor(opts.colors[labels[0]]); + dash->SetLineColor(opts.colors[labels[0]]); + mark->SetMarkerColor(opts.colors[labels[0]]); + } if (opts.onlytheory) - leg->AddEntry((TObject*)0, opts.theorylabel.c_str(), ""); + leg->AddEntry((TObject*)0, opts.theorylabel.c_str(), ""); else - { - if (opts.nothshifts) - if ((opts.points && !datahistos[0].bincenter()) || datahistos[0].nbins() == 1) - leg->AddEntry(mark, opts.theorylabel.c_str(), "p"); - else - leg->AddEntry(cont, opts.theorylabel.c_str(), "l"); - if (!opts.nothshifts) - leg->AddEntry(dash, (opts.theorylabel + " + shifts").c_str(), "l"); - } + { + if (opts.nothshifts) + if ((opts.points && !datahistos[0].bincenter()) || datahistos[0].nbins() == 1) + leg->AddEntry(mark, opts.theorylabel.c_str(), "p"); + else + leg->AddEntry(cont, opts.theorylabel.c_str(), "l"); + if (!opts.nothshifts) + leg->AddEntry(dash, (opts.theorylabel + " + shifts").c_str(), "l"); + } leg1 = (TPaveText*)leg; } leg1->SetFillColor(0); @@ -502,134 +502,134 @@ TCanvas * DataPainter(int dataindex, int subplotindex) vector <range> thranges = historanges((*it).getthshift()); for (vector<range>::iterator r = thranges.begin(); r != thranges.end(); r++) - { - (*it).getthshift()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.onlytheory) - if (!opts.nothshifts) - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) //plot as continous line - (*it).Draw((TH1F*)(*it).getthshift()->Clone(), "LX same"); - else - (*it).Draw((TH1F*)(*it).getthshift()->Clone(), "hist ][ same"); //plot as histogram in points mode - } + { + (*it).getthshift()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.onlytheory) + if (!opts.nothshifts) + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) //plot as continous line + (*it).Draw((TH1F*)(*it).getthshift()->Clone(), "LX same"); + else + (*it).Draw((TH1F*)(*it).getthshift()->Clone(), "hist ][ same"); //plot as histogram in points mode + } (*it).getthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); (*it).getth()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); (*it).getth()->SetLineWidth(opts.lwidth); if (opts.bw) - (*it).getth()->SetLineStyle(opts.lstyles[labels[it-datahistos.begin()]]); + (*it).getth()->SetLineStyle(opts.lstyles[labels[it-datahistos.begin()]]); if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) //plot as continous line with dashed error bands - { - for (vector<range>::iterator r = thranges.begin(); r != thranges.end(); r++) - { - (*it).getth()->SetAxisRange((*r).lowedge, (*r).upedge); - (*it).Draw((TH1F*)(*it).getth()->Clone(), "LX same"); - } - (*it).getth()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - - if (opts.therr && !opts.noupband) - { - (*it).gettherr()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - if (opts.bw) - (*it).gettherr()->SetLineStyle(opts.lstyles[labels[it-datahistos.begin()]]); - (*it).gettherr()->SetMarkerSize(0); - (*it).gettherr()->SetFillColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).gettherr()->SetFillStyle(opts.styles[labels[it-datahistos.begin()]]); - float toterr = 0; - for (int b = 1; b <= (*it).gettherr()->GetNbinsX(); b++) - toterr += (*it).gettherr()->GetBinError(b); - if (toterr > 0) - { - for (vector<range>::iterator r = thranges.begin(); r != thranges.end(); r++) - { - (*it).gettherr()->SetAxisRange((*r).lowedge, (*r).upedge); - //(*it).Draw((TH1F*)(*it).gettherr()->Clone(), "E3L same"); - (*it).Draw((TH1F*)(*it).gettherr()->Clone(), "E3 same"); - } - (*it).gettherr()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } - } - } + { + for (vector<range>::iterator r = thranges.begin(); r != thranges.end(); r++) + { + (*it).getth()->SetAxisRange((*r).lowedge, (*r).upedge); + (*it).Draw((TH1F*)(*it).getth()->Clone(), "LX same"); + } + (*it).getth()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + + if (opts.therr && !opts.noupband) + { + (*it).gettherr()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + if (opts.bw) + (*it).gettherr()->SetLineStyle(opts.lstyles[labels[it-datahistos.begin()]]); + (*it).gettherr()->SetMarkerSize(0); + (*it).gettherr()->SetFillColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).gettherr()->SetFillStyle(opts.styles[labels[it-datahistos.begin()]]); + float toterr = 0; + for (int b = 1; b <= (*it).gettherr()->GetNbinsX(); b++) + toterr += (*it).gettherr()->GetBinError(b); + if (toterr > 0) + { + for (vector<range>::iterator r = thranges.begin(); r != thranges.end(); r++) + { + (*it).gettherr()->SetAxisRange((*r).lowedge, (*r).upedge); + //(*it).Draw((TH1F*)(*it).gettherr()->Clone(), "E3L same"); + (*it).Draw((TH1F*)(*it).gettherr()->Clone(), "E3 same"); + } + (*it).gettherr()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } + } + } else //plot as displaced points with vertical error line - { - gtherr->SetMarkerStyle(opts.markers[labels[it-datahistos.begin()]]); - gtherr->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - gtherr->SetMarkerSize(2 * opts.resolution / 1200); - gtherr->SetMarkerColor(opts.colors[labels[it-datahistos.begin()]]); - for (int b = 0; b < gtherr->GetN(); b++) - { - //Set X error to 0 - gtherr->SetPointEXlow(b, 0); - gtherr->SetPointEXhigh(b, 0); - - //displace horizontally - double x, y; - gtherr->GetPoint(b, x, y); - float width = (*it).getth()->GetBinWidth(b + 1); - float lowedge = (*it).getth()->GetBinLowEdge(b + 1); - x = lowedge + (it - datahistos.begin() + 1) * width/(datahistos.size() + 1); - gtherr->SetPoint(b, x, y); - - //Set Y error - float errup, errdown; - if (opts.therr && !opts.noupband) - { - errup = (*it).gettherrup()->GetBinContent(b + 1) - (*it).getth()->GetBinContent(b + 1); - errdown = (*it).getth()->GetBinContent(b + 1) - (*it).gettherrdown()->GetBinContent(b + 1); - } - else - { - errup = 0; - errdown = 0; - } - gtherr->SetPointEYhigh(b, errup); - gtherr->SetPointEYlow(b, errdown); - } - gtherr->Draw("P same"); - } + { + gtherr->SetMarkerStyle(opts.markers[labels[it-datahistos.begin()]]); + gtherr->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + gtherr->SetMarkerSize(2 * opts.resolution / 1200); + gtherr->SetMarkerColor(opts.colors[labels[it-datahistos.begin()]]); + for (int b = 0; b < gtherr->GetN(); b++) + { + //Set X error to 0 + gtherr->SetPointEXlow(b, 0); + gtherr->SetPointEXhigh(b, 0); + + //displace horizontally + double x, y; + gtherr->GetPoint(b, x, y); + float width = (*it).getth()->GetBinWidth(b + 1); + float lowedge = (*it).getth()->GetBinLowEdge(b + 1); + x = lowedge + (it - datahistos.begin() + 1) * width/(datahistos.size() + 1); + gtherr->SetPoint(b, x, y); + + //Set Y error + float errup, errdown; + if (opts.therr && !opts.noupband) + { + errup = (*it).gettherrup()->GetBinContent(b + 1) - (*it).getth()->GetBinContent(b + 1); + errdown = (*it).getth()->GetBinContent(b + 1) - (*it).gettherrdown()->GetBinContent(b + 1); + } + else + { + errup = 0; + errdown = 0; + } + gtherr->SetPointEYhigh(b, errup); + gtherr->SetPointEYlow(b, errdown); + } + gtherr->Draw("P same"); + } if (datahistos.size() == 1) - { - leg2->AddEntry((TObject*)0, (labels[it-datahistos.begin()]).c_str(), ""); - if (opts.therr && !opts.noupband && (*it).HasTherr()) - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - leg2->AddEntry((*it).gettherr(), "Theory uncertainty", "lf"); - else - leg2->AddEntry((*it).gettherr(), "Theory uncertainty", "pe"); - } + { + leg2->AddEntry((TObject*)0, (labels[it-datahistos.begin()]).c_str(), ""); + if (opts.therr && !opts.noupband && (*it).HasTherr()) + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + leg2->AddEntry((*it).gettherr(), "Theory uncertainty", "lf"); + else + leg2->AddEntry((*it).gettherr(), "Theory uncertainty", "pe"); + } else - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - if (opts.therr && !opts.noupband && (*it).HasTherr()) - leg2->AddEntry((*it).gettherr(), (labels[it-datahistos.begin()]).c_str(), "lf"); - else - leg2->AddEntry((*it).getth(), (labels[it-datahistos.begin()]).c_str(), "l"); - else - if (opts.therr && !opts.noupband && (*it).HasTherr()) - leg2->AddEntry(gtherr, (labels[it-datahistos.begin()]).c_str(), "pe"); - else - leg2->AddEntry(gtherr, (labels[it-datahistos.begin()]).c_str(), "p"); + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + if (opts.therr && !opts.noupband && (*it).HasTherr()) + leg2->AddEntry((*it).gettherr(), (labels[it-datahistos.begin()]).c_str(), "lf"); + else + leg2->AddEntry((*it).getth(), (labels[it-datahistos.begin()]).c_str(), "l"); + else + if (opts.therr && !opts.noupband && (*it).HasTherr()) + leg2->AddEntry(gtherr, (labels[it-datahistos.begin()]).c_str(), "pe"); + else + leg2->AddEntry(gtherr, (labels[it-datahistos.begin()]).c_str(), "p"); } //draw theory error borders if (opts.therr && !opts.noupband) for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) { - (*it).gettherrup()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).gettherrdown()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).gettherrup()->SetLineWidth(opts.lwidth); - (*it).gettherrdown()->SetLineWidth(opts.lwidth); - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - { - vector <range> thranges = historanges((*it).getth()); - for (vector<range>::iterator r = thranges.begin(); r != thranges.end(); r++) - { - (*it).gettherrup()->SetAxisRange((*r).lowedge, (*r).upedge); - (*it).Draw((TH1F*)(*it).gettherrup()->Clone(), "LX same"); - (*it).gettherrdown()->SetAxisRange((*r).lowedge, (*r).upedge); - (*it).Draw((TH1F*)(*it).gettherrdown()->Clone(), "LX same"); - } - (*it).gettherrup()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - (*it).gettherrdown()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } + (*it).gettherrup()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).gettherrdown()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).gettherrup()->SetLineWidth(opts.lwidth); + (*it).gettherrdown()->SetLineWidth(opts.lwidth); + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + { + vector <range> thranges = historanges((*it).getth()); + for (vector<range>::iterator r = thranges.begin(); r != thranges.end(); r++) + { + (*it).gettherrup()->SetAxisRange((*r).lowedge, (*r).upedge); + (*it).Draw((TH1F*)(*it).gettherrup()->Clone(), "LX same"); + (*it).gettherrdown()->SetAxisRange((*r).lowedge, (*r).upedge); + (*it).Draw((TH1F*)(*it).gettherrdown()->Clone(), "LX same"); + } + (*it).gettherrup()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + (*it).gettherrdown()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } } data->SetStats(0); @@ -669,43 +669,43 @@ TCanvas * DataPainter(int dataindex, int subplotindex) for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) { if (opts.diff) - { - (*it).getrth()->Add(refdata, -1); - (*it).getrthshift()->Add(refdata, -1); - (*it).getrtherr()->Add(refdata, -1); - (*it).getrtherrup()->Add(refdata, -1); - (*it).getrtherrdown()->Add(refdata, -1); - } + { + (*it).getrth()->Add(refdata, -1); + (*it).getrthshift()->Add(refdata, -1); + (*it).getrtherr()->Add(refdata, -1); + (*it).getrtherrup()->Add(refdata, -1); + (*it).getrtherrdown()->Add(refdata, -1); + } else - { - if (opts.onlytheory && opts.threlerr) - { - (*it).getrth()->Divide((*it).getth()); - (*it).getrthshift()->Divide((*it).getth()); - (*it).getrtherr()->Divide((*it).getth()); - (*it).getrtherrup()->Divide((*it).getth()); - (*it).getrtherrdown()->Divide((*it).getth()); - } - else - { - (*it).getrth()->Divide(refdata); - (*it).getrthshift()->Divide(refdata); - (*it).getrtherr()->Divide(refdata); - (*it).getrtherrup()->Divide(refdata); - (*it).getrtherrdown()->Divide(refdata); - } - } + { + if (opts.onlytheory && opts.threlerr) + { + (*it).getrth()->Divide((*it).getth()); + (*it).getrthshift()->Divide((*it).getth()); + (*it).getrtherr()->Divide((*it).getth()); + (*it).getrtherrup()->Divide((*it).getth()); + (*it).getrtherrdown()->Divide((*it).getth()); + } + else + { + (*it).getrth()->Divide(refdata); + (*it).getrthshift()->Divide(refdata); + (*it).getrtherr()->Divide(refdata); + (*it).getrtherrup()->Divide(refdata); + (*it).getrtherrdown()->Divide(refdata); + } + } for (int b = 1; b <= (*it).getrth()->GetNbinsX(); b++) - (*it).getrth()->SetBinError(b, 0); + (*it).getrth()->SetBinError(b, 0); for (int b = 1; b <= (*it).getrthshift()->GetNbinsX(); b++) - (*it).getrthshift()->SetBinError(b, 0); + (*it).getrthshift()->SetBinError(b, 0); for (int b = 1; b <= (*it).getrtherr()->GetNbinsX(); b++) - (*it).getrtherr()->SetBinError(b, ((*it).getrtherrup()->GetBinContent(b) - (*it).getrtherrdown()->GetBinContent(b)) / 2 ); + (*it).getrtherr()->SetBinError(b, ((*it).getrtherrup()->GetBinContent(b) - (*it).getrtherrdown()->GetBinContent(b)) / 2 ); for (int b = 1; b <= (*it).getrtherrup()->GetNbinsX(); b++) - (*it).getrtherrup()->SetBinError(b, 0); + (*it).getrtherrup()->SetBinError(b, 0); for (int b = 1; b <= (*it).getrtherrdown()->GetNbinsX(); b++) - (*it).getrtherrdown()->SetBinError(b, 0); + (*it).getrtherrdown()->SetBinError(b, 0); } //create template histogram for axis @@ -721,7 +721,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) { r_templ->GetXaxis()->SetNoExponent(); if (axmax/axmin < 90) - r_templ->GetXaxis()->SetMoreLogLabels(); + r_templ->GetXaxis()->SetMoreLogLabels(); } r_templ->GetYaxis()->SetLabelSize(txtsize/ry); @@ -731,20 +731,20 @@ TCanvas * DataPainter(int dataindex, int subplotindex) if (opts.diff) { if (opts.onlytheory) - ytitle = "Difference"; + ytitle = "Difference"; else if (opts.ratiototheory) - ytitle = (string) "Data-" + opts.theorylabel; + ytitle = (string) "Data-" + opts.theorylabel; else - ytitle = "Theory-Data"; + ytitle = "Theory-Data"; } else { if (opts.onlytheory) - ytitle = "Ratio"; + ytitle = "Ratio"; else if (opts.ratiototheory) - ytitle = (string) "Data/" + opts.theorylabel; + ytitle = (string) "Data/" + opts.theorylabel; else - ytitle = "Theory/Data"; + ytitle = "Theory/Data"; } r_templ->SetYTitle(ytitle.c_str()); @@ -770,15 +770,15 @@ TCanvas * DataPainter(int dataindex, int subplotindex) for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) { if (opts.therr) - { - mx = max(mx, (float)((*it).getrtherrup()->GetMaximum())); - mx = max(mx, (float)((*it).getrtherrdown()->GetMaximum())); - } + { + mx = max(mx, (float)((*it).getrtherrup()->GetMaximum())); + mx = max(mx, (float)((*it).getrtherrdown()->GetMaximum())); + } else - mx = max(mx, (float)((*it).getrth()->GetMaximum())); + mx = max(mx, (float)((*it).getrth()->GetMaximum())); if (!opts.threepanels) - if (!opts.onlytheory) - mx = max(mx, (float)((*it).getrthshift()->GetMaximum())); + if (!opts.onlytheory) + mx = max(mx, (float)((*it).getrthshift()->GetMaximum())); } mn = mx; @@ -789,15 +789,15 @@ TCanvas * DataPainter(int dataindex, int subplotindex) for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) { if (opts.therr) - { - mn = min(mn, (float)(hmin((*it).getrtherrdown()))); - mn = min(mn, (float)(hmin((*it).getrtherrup()))); - } + { + mn = min(mn, (float)(hmin((*it).getrtherrdown()))); + mn = min(mn, (float)(hmin((*it).getrtherrup()))); + } else - mn = min(mn, (float)(hmin((*it).getrth()))); + mn = min(mn, (float)(hmin((*it).getrth()))); if (!opts.threepanels) - if (!opts.onlytheory) - mn = min(mn, (float)(hmin((*it).getrthshift()))); + if (!opts.onlytheory) + mn = min(mn, (float)(hmin((*it).getrthshift()))); } float delta = mx - mn; if (datahistos[0].getymaxr() != 0) @@ -821,7 +821,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) { r_datatot->SetAxisRange((*r).lowedge, (*r).upedge); if (!opts.onlytheory) - datahistos[0].Draw((TH1F*)r_datatot->Clone(), "E3 same"); + datahistos[0].Draw((TH1F*)r_datatot->Clone(), "E3 same"); } r_datatot->GetXaxis()->SetRange(datahistos[0].getlowrange(), datahistos[0].getuprange()); @@ -849,133 +849,133 @@ TCanvas * DataPainter(int dataindex, int subplotindex) (*it).getrth()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); (*it).getrth()->SetLineWidth(opts.lwidth); if (opts.bw) - (*it).getrth()->SetLineStyle(opts.lstyles[labels[it-datahistos.begin()]]); + (*it).getrth()->SetLineStyle(opts.lstyles[labels[it-datahistos.begin()]]); vector <range> rthranges = historanges((*it).getrthshift()); if (!opts.threepanels) - { - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrthshift()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.onlytheory) - if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory - if (!opts.nothshifts) - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "LX same"); - else - (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "hist ][ same"); - - } - (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } + { + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrthshift()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.onlytheory) + if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory + if (!opts.nothshifts) + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "LX same"); + else + (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "hist ][ same"); + + } + (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) //plot as continous line with dashed error bands - { - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrth()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory - (*it).Draw((TH1F*)(*it).getrth()->Clone(), "LX same"); - } - (*it).getrth()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - if (opts.therr) - { - (*it).getrtherr()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherr()->SetMarkerSize(0); - (*it).getrtherr()->SetFillColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherr()->SetFillStyle(opts.styles[labels[it-datahistos.begin()]]); - float toterr = 0; - for (int b = 1; b <= (*it).gettherr()->GetNbinsX(); b++) - toterr += (*it).gettherr()->GetBinError(b); - if (toterr > 0) - { - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrtherr()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory - //(*it).Draw((TH1F*)(*it).getrtherr()->Clone(), "E3L same"); - (*it).Draw((TH1F*)(*it).getrtherr()->Clone(), "E3 same"); - } - (*it).getrtherr()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } - } - } + { + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrth()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory + (*it).Draw((TH1F*)(*it).getrth()->Clone(), "LX same"); + } + (*it).getrth()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + if (opts.therr) + { + (*it).getrtherr()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherr()->SetMarkerSize(0); + (*it).getrtherr()->SetFillColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherr()->SetFillStyle(opts.styles[labels[it-datahistos.begin()]]); + float toterr = 0; + for (int b = 1; b <= (*it).gettherr()->GetNbinsX(); b++) + toterr += (*it).gettherr()->GetBinError(b); + if (toterr > 0) + { + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrtherr()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory + //(*it).Draw((TH1F*)(*it).getrtherr()->Clone(), "E3L same"); + (*it).Draw((TH1F*)(*it).getrtherr()->Clone(), "E3 same"); + } + (*it).getrtherr()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } + } + } else //plot as displaced TGraphs - { - TGraphAsymmErrors * r_gtherr = new TGraphAsymmErrors((*it).getrth()); - r_gtherr->SetMarkerStyle(opts.markers[labels[it-datahistos.begin()]]); - r_gtherr->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - r_gtherr->SetMarkerSize(2 * opts.resolution / 1200); - r_gtherr->SetMarkerColor(opts.colors[labels[it-datahistos.begin()]]); - for (int b = 0; b < r_gtherr->GetN(); b++) - { - //Set X error to 0 - r_gtherr->SetPointEXlow(b, 0); - r_gtherr->SetPointEXhigh(b, 0); - - //displace horizontally - double x, y; - r_gtherr->GetPoint(b, x, y); - float width = (*it).getrth()->GetBinWidth(b + 1); - float lowedge = (*it).getrth()->GetBinLowEdge(b + 1); - x = lowedge + (it - datahistos.begin() + 1) * width/(datahistos.size() + 1); - r_gtherr->SetPoint(b, x, y); - //Set Y error - float errup, errdown; - if (opts.therr) - { - errup = (*it).getrtherrup()->GetBinContent(b + 1) - (*it).getrth()->GetBinContent(b + 1); - errdown = (*it).getrth()->GetBinContent(b + 1) - (*it).getrtherrdown()->GetBinContent(b + 1); - } - else - { - errup = 0; - errdown = 0; - } - r_gtherr->SetPointEYhigh(b, errup); - r_gtherr->SetPointEYlow(b, errdown); - } - if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory - r_gtherr->Draw("P same"); - } + { + TGraphAsymmErrors * r_gtherr = new TGraphAsymmErrors((*it).getrth()); + r_gtherr->SetMarkerStyle(opts.markers[labels[it-datahistos.begin()]]); + r_gtherr->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + r_gtherr->SetMarkerSize(2 * opts.resolution / 1200); + r_gtherr->SetMarkerColor(opts.colors[labels[it-datahistos.begin()]]); + for (int b = 0; b < r_gtherr->GetN(); b++) + { + //Set X error to 0 + r_gtherr->SetPointEXlow(b, 0); + r_gtherr->SetPointEXhigh(b, 0); + + //displace horizontally + double x, y; + r_gtherr->GetPoint(b, x, y); + float width = (*it).getrth()->GetBinWidth(b + 1); + float lowedge = (*it).getrth()->GetBinLowEdge(b + 1); + x = lowedge + (it - datahistos.begin() + 1) * width/(datahistos.size() + 1); + r_gtherr->SetPoint(b, x, y); + //Set Y error + float errup, errdown; + if (opts.therr) + { + errup = (*it).getrtherrup()->GetBinContent(b + 1) - (*it).getrth()->GetBinContent(b + 1); + errdown = (*it).getrth()->GetBinContent(b + 1) - (*it).getrtherrdown()->GetBinContent(b + 1); + } + else + { + errup = 0; + errdown = 0; + } + r_gtherr->SetPointEYhigh(b, errup); + r_gtherr->SetPointEYlow(b, errdown); + } + if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory + r_gtherr->Draw("P same"); + } if (opts.multitheory && (it - datahistos.begin() == 0)) - { - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - if (opts.therr && (*it).HasTherr()) - legr->AddEntry((*it).getrtherr(), (labels[it-datahistos.begin()]).c_str(), "lf"); - else - legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "l"); - else - if (opts.therr && (*it).HasTherr()) - legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "pe"); - else - leg2->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "p"); - } + { + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + if (opts.therr && (*it).HasTherr()) + legr->AddEntry((*it).getrtherr(), (labels[it-datahistos.begin()]).c_str(), "lf"); + else + legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "l"); + else + if (opts.therr && (*it).HasTherr()) + legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "pe"); + else + leg2->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "p"); + } } //draw theory error borders if (opts.therr) for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) { - (*it).getrtherrup()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherrdown()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherrup()->SetLineWidth(opts.lwidth); - (*it).getrtherrdown()->SetLineWidth(opts.lwidth); - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - { - vector <range> rthranges = historanges((*it).getth()); - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrtherrup()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory - (*it).Draw((TH1F*)(*it).getrtherrup()->Clone(), "LX same"); - (*it).getrtherrdown()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory - (*it).Draw((TH1F*)(*it).getrtherrdown()->Clone(), "LX same"); - } - (*it).getrtherrup()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - (*it).getrtherrdown()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } + (*it).getrtherrup()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherrdown()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherrup()->SetLineWidth(opts.lwidth); + (*it).getrtherrdown()->SetLineWidth(opts.lwidth); + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + { + vector <range> rthranges = historanges((*it).getth()); + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrtherrup()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory + (*it).Draw((TH1F*)(*it).getrtherrup()->Clone(), "LX same"); + (*it).getrtherrdown()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == 0)) //if in multitheory mode, plot only the first theory + (*it).Draw((TH1F*)(*it).getrtherrdown()->Clone(), "LX same"); + } + (*it).getrtherrup()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + (*it).getrtherrdown()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } } //Draw data points @@ -997,7 +997,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) { Shifts->cd(); if (datahistos[0].getlogx()) - Shifts->SetLogx(); + Shifts->SetLogx(); //Set up template histogram for axis r_templ->GetYaxis()->SetLabelSize(txtsize/sy); @@ -1010,19 +1010,19 @@ TCanvas * DataPainter(int dataindex, int subplotindex) //draw data vector <range> rdtranges = historanges(r_datatot); for (vector<range>::iterator r = rdtranges.begin(); r != rdtranges.end(); r++) - { - r_datatot->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.onlytheory) - datahistos[0].Draw((TH1F*)r_datatot->Clone(), "E3 same"); - } + { + r_datatot->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.onlytheory) + datahistos[0].Draw((TH1F*)r_datatot->Clone(), "E3 same"); + } r_datatot->GetXaxis()->SetRange(datahistos[0].getlowrange(), datahistos[0].getuprange()); //plot lines at 1 (or 0 for diff plots) TLine *r_ref; if (opts.diff) - r_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 0, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 0); + r_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 0, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 0); else - r_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 1, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 1); + r_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 1, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 1); r_ref->SetLineStyle(2); r_ref->SetLineStyle(1); r_ref->Draw(); @@ -1031,144 +1031,144 @@ TCanvas * DataPainter(int dataindex, int subplotindex) //Draw ratios for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) - { - (*it).getrthshift()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrthshift()->SetLineStyle(2); - (*it).getrthshift()->SetLineWidth(opts.lwidth); - - (*it).getrth()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrth()->SetLineWidth(opts.lwidth); - if (opts.bw) - (*it).getrth()->SetLineStyle(opts.lstyles[labels[it-datahistos.begin()]]); - - vector <range> rthranges = historanges((*it).getrthshift()); - if (!opts.threepanels) - { - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrthshift()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.onlytheory) - if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory - if (!opts.nothshifts) - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "LX same"); - else - (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "hist ][ same"); - } - (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } - - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) //plot as continous line with dashed error bands - { - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrth()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory - (*it).Draw((TH1F*)(*it).getrth()->Clone(), "LX same"); - } - (*it).getrth()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - if (opts.therr) - { - (*it).getrtherr()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherr()->SetMarkerSize(0); - (*it).getrtherr()->SetFillColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherr()->SetFillStyle(opts.styles[labels[it-datahistos.begin()]]); - float toterr = 0; - for (int b = 1; b <= (*it).gettherr()->GetNbinsX(); b++) - toterr += (*it).gettherr()->GetBinError(b); - if (toterr > 0) - { - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrtherr()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory - (*it).Draw((TH1F*)(*it).getrtherr()->Clone(), "E3L same"); - } - (*it).getrtherr()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } - } - } - else //plot as displaced TGraphs - { - TGraphAsymmErrors * r_gtherr = new TGraphAsymmErrors((*it).getrth()); - r_gtherr->SetMarkerStyle(opts.markers[labels[it-datahistos.begin()]]); - r_gtherr->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - r_gtherr->SetMarkerSize(2 * opts.resolution / 1200); - r_gtherr->SetMarkerColor(opts.colors[labels[it-datahistos.begin()]]); - for (int b = 0; b < r_gtherr->GetN(); b++) - { - //Set X error to 0 - r_gtherr->SetPointEXlow(b, 0); - r_gtherr->SetPointEXhigh(b, 0); - - //displace horizontally - double x, y; - r_gtherr->GetPoint(b, x, y); - float width = (*it).getrth()->GetBinWidth(b + 1); - float lowedge = (*it).getrth()->GetBinLowEdge(b + 1); - x = lowedge + (it - datahistos.begin() + 1) * width/(datahistos.size() + 1); - r_gtherr->SetPoint(b, x, y); - //Set Y error - float errup, errdown; - if (opts.therr) - { - errup = (*it).getrtherrup()->GetBinContent(b + 1) - (*it).getrth()->GetBinContent(b + 1); - errdown = (*it).getrth()->GetBinContent(b + 1) - (*it).getrtherrdown()->GetBinContent(b + 1); - } - else - { - errup = 0; - errdown = 0; - } - r_gtherr->SetPointEYhigh(b, errup); - r_gtherr->SetPointEYlow(b, errdown); - } - if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory - r_gtherr->Draw("P same"); - } - if (it - datahistos.begin() == 1) - { - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - if (opts.therr && (*it).HasTherr()) - legr->AddEntry((*it).getrtherr(), (labels[it-datahistos.begin()]).c_str(), "lf"); - else - legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "l"); - else - if (opts.therr && (*it).HasTherr()) - legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "pe"); - else - leg2->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "p"); - } - } + { + (*it).getrthshift()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrthshift()->SetLineStyle(2); + (*it).getrthshift()->SetLineWidth(opts.lwidth); + + (*it).getrth()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrth()->SetLineWidth(opts.lwidth); + if (opts.bw) + (*it).getrth()->SetLineStyle(opts.lstyles[labels[it-datahistos.begin()]]); + + vector <range> rthranges = historanges((*it).getrthshift()); + if (!opts.threepanels) + { + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrthshift()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.onlytheory) + if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory + if (!opts.nothshifts) + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "LX same"); + else + (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "hist ][ same"); + } + (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } + + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) //plot as continous line with dashed error bands + { + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrth()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory + (*it).Draw((TH1F*)(*it).getrth()->Clone(), "LX same"); + } + (*it).getrth()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + if (opts.therr) + { + (*it).getrtherr()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherr()->SetMarkerSize(0); + (*it).getrtherr()->SetFillColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherr()->SetFillStyle(opts.styles[labels[it-datahistos.begin()]]); + float toterr = 0; + for (int b = 1; b <= (*it).gettherr()->GetNbinsX(); b++) + toterr += (*it).gettherr()->GetBinError(b); + if (toterr > 0) + { + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrtherr()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory + (*it).Draw((TH1F*)(*it).getrtherr()->Clone(), "E3L same"); + } + (*it).getrtherr()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } + } + } + else //plot as displaced TGraphs + { + TGraphAsymmErrors * r_gtherr = new TGraphAsymmErrors((*it).getrth()); + r_gtherr->SetMarkerStyle(opts.markers[labels[it-datahistos.begin()]]); + r_gtherr->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + r_gtherr->SetMarkerSize(2 * opts.resolution / 1200); + r_gtherr->SetMarkerColor(opts.colors[labels[it-datahistos.begin()]]); + for (int b = 0; b < r_gtherr->GetN(); b++) + { + //Set X error to 0 + r_gtherr->SetPointEXlow(b, 0); + r_gtherr->SetPointEXhigh(b, 0); + + //displace horizontally + double x, y; + r_gtherr->GetPoint(b, x, y); + float width = (*it).getrth()->GetBinWidth(b + 1); + float lowedge = (*it).getrth()->GetBinLowEdge(b + 1); + x = lowedge + (it - datahistos.begin() + 1) * width/(datahistos.size() + 1); + r_gtherr->SetPoint(b, x, y); + //Set Y error + float errup, errdown; + if (opts.therr) + { + errup = (*it).getrtherrup()->GetBinContent(b + 1) - (*it).getrth()->GetBinContent(b + 1); + errdown = (*it).getrth()->GetBinContent(b + 1) - (*it).getrtherrdown()->GetBinContent(b + 1); + } + else + { + errup = 0; + errdown = 0; + } + r_gtherr->SetPointEYhigh(b, errup); + r_gtherr->SetPointEYlow(b, errdown); + } + if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory + r_gtherr->Draw("P same"); + } + if (it - datahistos.begin() == 1) + { + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + if (opts.therr && (*it).HasTherr()) + legr->AddEntry((*it).getrtherr(), (labels[it-datahistos.begin()]).c_str(), "lf"); + else + legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "l"); + else + if (opts.therr && (*it).HasTherr()) + legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "pe"); + else + leg2->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "p"); + } + } //draw theory error borders if (opts.therr) - for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) - { - (*it).getrtherrup()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherrdown()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherrup()->SetLineWidth(opts.lwidth); - (*it).getrtherrdown()->SetLineWidth(opts.lwidth); - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - { - vector <range> rthranges = historanges((*it).getth()); - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrtherrup()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory - (*it).Draw((TH1F*)(*it).getrtherrup()->Clone(), "LX same"); - (*it).getrtherrdown()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory - (*it).Draw((TH1F*)(*it).getrtherrdown()->Clone(), "LX same"); - } - (*it).getrtherrup()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - (*it).getrtherrdown()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } - } + for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) + { + (*it).getrtherrup()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherrdown()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherrup()->SetLineWidth(opts.lwidth); + (*it).getrtherrdown()->SetLineWidth(opts.lwidth); + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + { + vector <range> rthranges = historanges((*it).getth()); + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrtherrup()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory + (*it).Draw((TH1F*)(*it).getrtherrup()->Clone(), "LX same"); + (*it).getrtherrdown()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == 1)) //if in multitheory mode, plot only the second theory + (*it).Draw((TH1F*)(*it).getrtherrdown()->Clone(), "LX same"); + } + (*it).getrtherrup()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + (*it).getrtherrdown()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } + } //Draw data points if (!opts.onlytheory) - datahistos[0].Draw(r_data, "PE1 same"); + datahistos[0].Draw(r_data, "PE1 same"); legr->SetFillColor(0); legr->SetBorderSize(0); @@ -1181,7 +1181,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) { Shifts->cd(); if (datahistos[0].getlogx()) - Shifts->SetLogx(); + Shifts->SetLogx(); //Set up template histogram for axis r_templ->GetYaxis()->SetLabelSize(txtsize/sy); @@ -1189,19 +1189,19 @@ TCanvas * DataPainter(int dataindex, int subplotindex) r_templ->GetYaxis()->SetTitleOffset((offset+0.3) * sy); string ytitle = ""; if (opts.diff) - { - if (opts.ratiototheory) - ytitle = (string) "Data-" + opts.theorylabel; - else - ytitle = "Theory-Data"; - } + { + if (opts.ratiototheory) + ytitle = (string) "Data-" + opts.theorylabel; + else + ytitle = "Theory-Data"; + } else - { - if (opts.ratiototheory) - ytitle = (string) "Ratio to " + opts.theorylabel; - else - ytitle = "#frac{Theory+shifts}{Data}"; - } + { + if (opts.ratiototheory) + ytitle = (string) "Ratio to " + opts.theorylabel; + else + ytitle = "#frac{Theory+shifts}{Data}"; + } r_templ->SetYTitle(ytitle.c_str()); @@ -1209,26 +1209,26 @@ TCanvas * DataPainter(int dataindex, int subplotindex) mx = 0; TH1F * r_dataerr = (TH1F*) r_data->Clone(); for (int b = 1; b <= r_data->GetNbinsX(); b++) - r_dataerr->SetBinContent(b, r_data->GetBinContent(b) + r_data->GetBinError(b)); + r_dataerr->SetBinContent(b, r_data->GetBinContent(b) + r_data->GetBinError(b)); if (!opts.onlytheory) - mx = r_dataerr->GetBinContent(r_dataerr->GetMaximumBin()); + mx = r_dataerr->GetBinContent(r_dataerr->GetMaximumBin()); for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) - mx = max(mx, (float)((*it).getrthshift()->GetMaximum())); + mx = max(mx, (float)((*it).getrthshift()->GetMaximum())); mn = mx; for (int b = 1; b <= r_dataerr->GetNbinsX(); b++) - r_dataerr->SetBinContent(b, r_data->GetBinContent(b) - r_data->GetBinError(b)); + r_dataerr->SetBinContent(b, r_data->GetBinContent(b) - r_data->GetBinError(b)); if (!opts.onlytheory) - mn = hmin(r_dataerr); + mn = hmin(r_dataerr); for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) - mn = min(mn, (float)(hmin((*it).getrthshift()))); + mn = min(mn, (float)(hmin((*it).getrthshift()))); float delta = mx - mn; if (datahistos[0].getymaxr() != 0) - { - mx = datahistos[0].getymaxr(); - mn = datahistos[0].getyminr(); - delta = 0; - } + { + mx = datahistos[0].getymaxr(); + mn = datahistos[0].getyminr(); + delta = 0; + } r_templ->SetMaximum(mx + delta * 0.2); r_templ->SetMinimum(mn - delta * 0.2); @@ -1237,37 +1237,37 @@ TCanvas * DataPainter(int dataindex, int subplotindex) /* //plot data if (!opts.onlytheory) - datahistos[0].Draw(r_data, "PE1 same"); + datahistos[0].Draw(r_data, "PE1 same"); */ //plot lines at 1 (or 0 for diff plots) TLine *rs_ref; if (opts.diff) - rs_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 0, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 0); + rs_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 0, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 0); else - rs_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 1, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 1); + rs_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 1, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 1); rs_ref->SetLineStyle(2); rs_ref->SetLineStyle(1); rs_ref->Draw(); //Draw ratios for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) - { - vector <range> rthranges = historanges((*it).getrthshift()); - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrthshift()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.nothshifts) - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "LX same"); - else - (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "hist ][ same"); - } - (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } + { + vector <range> rthranges = historanges((*it).getrthshift()); + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrthshift()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.nothshifts) + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "LX same"); + else + (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "hist ][ same"); + } + (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } //plot data if (!opts.onlytheory) - datahistos[0].Draw(r_data, "PE1 same"); + datahistos[0].Draw(r_data, "PE1 same"); } //Theory-Data pulls pad @@ -1276,7 +1276,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) int nth = datahistos.size(); Pulls->cd(); if (datahistos[0].getlogx()) - Pulls->SetLogx(); + Pulls->SetLogx(); //Set up template histogram for axis r_templ->GetXaxis()->SetLabelSize(txtsize/py); @@ -1292,19 +1292,19 @@ TCanvas * DataPainter(int dataindex, int subplotindex) //draw data vector <range> rdtranges = historanges(r_datatot); for (vector<range>::iterator r = rdtranges.begin(); r != rdtranges.end(); r++) - { - r_datatot->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.onlytheory) - datahistos[0].Draw((TH1F*)r_datatot->Clone(), "E3 same"); - } + { + r_datatot->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.onlytheory) + datahistos[0].Draw((TH1F*)r_datatot->Clone(), "E3 same"); + } r_datatot->GetXaxis()->SetRange(datahistos[0].getlowrange(), datahistos[0].getuprange()); //plot lines at 1 (or 0 for diff plots) TLine *r_ref; if (opts.diff) - r_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 0, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 0); + r_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 0, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 0); else - r_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 1, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 1); + r_ref = new TLine(r_templ->GetBinLowEdge(r_templ->GetXaxis()->GetFirst()), 1, r_templ->GetXaxis()->GetBinUpEdge(r_templ->GetXaxis()->GetLast()), 1); r_ref->SetLineStyle(2); r_ref->SetLineStyle(1); r_ref->Draw(); @@ -1313,144 +1313,144 @@ TCanvas * DataPainter(int dataindex, int subplotindex) //Draw ratios for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) - { - (*it).getrthshift()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrthshift()->SetLineStyle(2); - (*it).getrthshift()->SetLineWidth(opts.lwidth); - - (*it).getrth()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrth()->SetLineWidth(opts.lwidth); - if (opts.bw) - (*it).getrth()->SetLineStyle(opts.lstyles[labels[it-datahistos.begin()]]); - - vector <range> rthranges = historanges((*it).getrthshift()); - if (!opts.threepanels) - { - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrthshift()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.onlytheory) - if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory - if (!opts.nothshifts) - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "LX same"); - else - (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "hist ][ same"); - } - (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } - - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) //plot as continous line with dashed error bands - { - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrth()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory - (*it).Draw((TH1F*)(*it).getrth()->Clone(), "LX same"); - } - (*it).getrth()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - if (opts.therr) - { - (*it).getrtherr()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherr()->SetMarkerSize(0); - (*it).getrtherr()->SetFillColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherr()->SetFillStyle(opts.styles[labels[it-datahistos.begin()]]); - float toterr = 0; - for (int b = 1; b <= (*it).gettherr()->GetNbinsX(); b++) - toterr += (*it).gettherr()->GetBinError(b); - if (toterr > 0) - { - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrtherr()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory - (*it).Draw((TH1F*)(*it).getrtherr()->Clone(), "E3L same"); - } - (*it).getrtherr()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } - } - } - else //plot as displaced TGraphs - { - TGraphAsymmErrors * r_gtherr = new TGraphAsymmErrors((*it).getrth()); - r_gtherr->SetMarkerStyle(opts.markers[labels[it-datahistos.begin()]]); - r_gtherr->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - r_gtherr->SetMarkerSize(2 * opts.resolution / 1200); - r_gtherr->SetMarkerColor(opts.colors[labels[it-datahistos.begin()]]); - for (int b = 0; b < r_gtherr->GetN(); b++) - { - //Set X error to 0 - r_gtherr->SetPointEXlow(b, 0); - r_gtherr->SetPointEXhigh(b, 0); - - //displace horizontally - double x, y; - r_gtherr->GetPoint(b, x, y); - float width = (*it).getrth()->GetBinWidth(b + 1); - float lowedge = (*it).getrth()->GetBinLowEdge(b + 1); - x = lowedge + (it - datahistos.begin() + 1) * width/(datahistos.size() + 1); - r_gtherr->SetPoint(b, x, y); - //Set Y error - float errup, errdown; - if (opts.therr) - { - errup = (*it).getrtherrup()->GetBinContent(b + 1) - (*it).getrth()->GetBinContent(b + 1); - errdown = (*it).getrth()->GetBinContent(b + 1) - (*it).getrtherrdown()->GetBinContent(b + 1); - } - else - { - errup = 0; - errdown = 0; - } - r_gtherr->SetPointEYhigh(b, errup); - r_gtherr->SetPointEYlow(b, errdown); - } - if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory - r_gtherr->Draw("P same"); - } - if (it - datahistos.begin() == nth-1) - { - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - if (opts.therr && (*it).HasTherr()) - legr->AddEntry((*it).getrtherr(), (labels[it-datahistos.begin()]).c_str(), "lf"); - else - legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "l"); - else - if (opts.therr && (*it).HasTherr()) - legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "pe"); - else - leg2->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "p"); - } - } + { + (*it).getrthshift()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrthshift()->SetLineStyle(2); + (*it).getrthshift()->SetLineWidth(opts.lwidth); + + (*it).getrth()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrth()->SetLineWidth(opts.lwidth); + if (opts.bw) + (*it).getrth()->SetLineStyle(opts.lstyles[labels[it-datahistos.begin()]]); + + vector <range> rthranges = historanges((*it).getrthshift()); + if (!opts.threepanels) + { + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrthshift()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.onlytheory) + if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory + if (!opts.nothshifts) + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "LX same"); + else + (*it).Draw((TH1F*)(*it).getrthshift()->Clone(), "hist ][ same"); + } + (*it).getrthshift()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } + + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) //plot as continous line with dashed error bands + { + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrth()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory + (*it).Draw((TH1F*)(*it).getrth()->Clone(), "LX same"); + } + (*it).getrth()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + if (opts.therr) + { + (*it).getrtherr()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherr()->SetMarkerSize(0); + (*it).getrtherr()->SetFillColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherr()->SetFillStyle(opts.styles[labels[it-datahistos.begin()]]); + float toterr = 0; + for (int b = 1; b <= (*it).gettherr()->GetNbinsX(); b++) + toterr += (*it).gettherr()->GetBinError(b); + if (toterr > 0) + { + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrtherr()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory + (*it).Draw((TH1F*)(*it).getrtherr()->Clone(), "E3L same"); + } + (*it).getrtherr()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } + } + } + else //plot as displaced TGraphs + { + TGraphAsymmErrors * r_gtherr = new TGraphAsymmErrors((*it).getrth()); + r_gtherr->SetMarkerStyle(opts.markers[labels[it-datahistos.begin()]]); + r_gtherr->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + r_gtherr->SetMarkerSize(2 * opts.resolution / 1200); + r_gtherr->SetMarkerColor(opts.colors[labels[it-datahistos.begin()]]); + for (int b = 0; b < r_gtherr->GetN(); b++) + { + //Set X error to 0 + r_gtherr->SetPointEXlow(b, 0); + r_gtherr->SetPointEXhigh(b, 0); + + //displace horizontally + double x, y; + r_gtherr->GetPoint(b, x, y); + float width = (*it).getrth()->GetBinWidth(b + 1); + float lowedge = (*it).getrth()->GetBinLowEdge(b + 1); + x = lowedge + (it - datahistos.begin() + 1) * width/(datahistos.size() + 1); + r_gtherr->SetPoint(b, x, y); + //Set Y error + float errup, errdown; + if (opts.therr) + { + errup = (*it).getrtherrup()->GetBinContent(b + 1) - (*it).getrth()->GetBinContent(b + 1); + errdown = (*it).getrth()->GetBinContent(b + 1) - (*it).getrtherrdown()->GetBinContent(b + 1); + } + else + { + errup = 0; + errdown = 0; + } + r_gtherr->SetPointEYhigh(b, errup); + r_gtherr->SetPointEYlow(b, errdown); + } + if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory + r_gtherr->Draw("P same"); + } + if (it - datahistos.begin() == nth-1) + { + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + if (opts.therr && (*it).HasTherr()) + legr->AddEntry((*it).getrtherr(), (labels[it-datahistos.begin()]).c_str(), "lf"); + else + legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "l"); + else + if (opts.therr && (*it).HasTherr()) + legr->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "pe"); + else + leg2->AddEntry((*it).getrth(), (labels[it-datahistos.begin()]).c_str(), "p"); + } + } //draw theory error borders if (opts.therr) - for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) - { - (*it).getrtherrup()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherrdown()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getrtherrup()->SetLineWidth(opts.lwidth); - (*it).getrtherrdown()->SetLineWidth(opts.lwidth); - if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) - { - vector <range> rthranges = historanges((*it).getth()); - for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) - { - (*it).getrtherrup()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory - (*it).Draw((TH1F*)(*it).getrtherrup()->Clone(), "LX same"); - (*it).getrtherrdown()->SetAxisRange((*r).lowedge, (*r).upedge); - if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory - (*it).Draw((TH1F*)(*it).getrtherrdown()->Clone(), "LX same"); - } - (*it).getrtherrup()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - (*it).getrtherrdown()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); - } - } + for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) + { + (*it).getrtherrup()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherrdown()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getrtherrup()->SetLineWidth(opts.lwidth); + (*it).getrtherrdown()->SetLineWidth(opts.lwidth); + if ((!opts.points || (*it).bincenter()) && (*it).nbins() > 1) + { + vector <range> rthranges = historanges((*it).getth()); + for (vector<range>::iterator r = rthranges.begin(); r != rthranges.end(); r++) + { + (*it).getrtherrup()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory + (*it).Draw((TH1F*)(*it).getrtherrup()->Clone(), "LX same"); + (*it).getrtherrdown()->SetAxisRange((*r).lowedge, (*r).upedge); + if (!opts.multitheory || (it - datahistos.begin() == nth-1)) //if in multitheory mode, plot only the second theory + (*it).Draw((TH1F*)(*it).getrtherrdown()->Clone(), "LX same"); + } + (*it).getrtherrup()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + (*it).getrtherrdown()->GetXaxis()->SetRange((*it).getlowrange(), (*it).getuprange()); + } + } //Draw data points if (!opts.onlytheory) - datahistos[0].Draw(r_data, "PE1 same"); + datahistos[0].Draw(r_data, "PE1 same"); legr->SetFillColor(0); legr->SetBorderSize(0); @@ -1463,7 +1463,7 @@ TCanvas * DataPainter(int dataindex, int subplotindex) { Pulls->cd(); if (datahistos[0].getlogx()) - Pulls->SetLogx(); + Pulls->SetLogx(); TH1F * pull = datahistos[0].getpull(); @@ -1497,17 +1497,17 @@ TCanvas * DataPainter(int dataindex, int subplotindex) //plot pulls for (vector <Subplot>::iterator it = datahistos.begin(); it != datahistos.end(); it++) - { - if (datahistos.size() == 1) - { - (*it).getpull()->SetFillColor(opts.colors[labels[it-datahistos.begin()]]); - (*it).getpull()->SetFillStyle(1001); - } - (*it).getpull()->SetLineStyle(1); - (*it).getpull()->SetLineWidth(opts.lwidth); - (*it).getpull()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); - datahistos[0].Draw((TH1F*)(*it).getpull()->Clone(), "same ]["); - } + { + if (datahistos.size() == 1) + { + (*it).getpull()->SetFillColor(opts.colors[labels[it-datahistos.begin()]]); + (*it).getpull()->SetFillStyle(1001); + } + (*it).getpull()->SetLineStyle(1); + (*it).getpull()->SetLineWidth(opts.lwidth); + (*it).getpull()->SetLineColor(opts.colors[labels[it-datahistos.begin()]]); + datahistos[0].Draw((TH1F*)(*it).getpull()->Clone(), "same ]["); + } } //Labels diff --git a/tools/draw/src/PdfData.cc b/tools/draw/src/PdfData.cc index 78b9a0816..6592866d7 100644 --- a/tools/draw/src/PdfData.cc +++ b/tools/draw/src/PdfData.cc @@ -29,9 +29,9 @@ string pdflab[] = {"u_{V}", "d_{V}", "g", "#Sigma", "#bar{u}", "#bar{d}", "(s+#b "d/u", "#bar{d}/#bar{u}", "d_{V}/u_{V}","rs","#gamma","#Sigma/g","#gamma/g","u_{V}+d_{V}", "u_{V}+d_{V}+2#Sigma"}; //pdf filenames //string pdffil[] = {"uv", "dv", "g", "Sea", "ubar", "dbar", "s", "Rs", "c", "b", "dbar-ubar", "uv-dv", "U", "D", "UBar", "DBar", "goversea", "doveru", "dbaroverubar", "dvoveruv","rs","ph","sg","gg" -// }; +// }; string pdffil[] = {"uv", "dv", "g", "Sea", "ubar", "dbar", "s", "sbar", "Rs", "soversbar", "c", "b", "dbar-ubar", "uv-dv", "U", "D", "UBar", "DBar", "goversea", "doveru", "dbaroverubar", "dvoveruv","rs","ph","sg","gg","uv+dv","uv+dv+2Sea" - }; + }; vector <pdftype> pdfs(pdfts, pdfts + sizeof(pdfts) / sizeof(pdftype)); vector <string> pdflabels(pdflab, pdflab + sizeof(pdflab) / sizeof(string)); @@ -313,9 +313,9 @@ PdfData::PdfData(string dirname, string label) : model(false), par(false) Central[temppdf.GetQ2()] = temppdf; - //Get Pdf errors if requested - if (!opts.dobands && !outdirs[label].IsProfiled() && !outdirs[label].IsRotated() && !outdirs[label].IsReweighted() && !outdirs[label].IsSingleSet()) - continue; + //Get Pdf errors if requested + if (!opts.dobands && !outdirs[label].IsProfiled() && !outdirs[label].IsRotated() && !outdirs[label].IsReweighted() && !outdirs[label].IsSingleSet()) + continue; //Load PDF error sets int iband = 1; @@ -435,8 +435,8 @@ PdfData::PdfData(string dirname, string label) : model(false), par(false) ndata=atoi( line.c_str() ); getline (mcwfile, line); while (mcwfile >> n >> chi2 >> w) { - mcchi2.push_back(chi2); - mcw.push_back(w); + mcchi2.push_back(chi2); + mcw.push_back(w); } } //Remake central PDF @@ -449,11 +449,11 @@ PdfData::PdfData(string dirname, string label) : model(false), par(false) { vector <double> xi; for (vector <Pdf>::iterator eit = Errors[q2].begin(); eit != Errors[q2].end(); eit++) - xi.push_back((*eit).GetTable(*pit)[ix]); + xi.push_back((*eit).GetTable(*pit)[ix]); double val; - if (outdirs[label].IsReweighted()) + if (outdirs[label].IsReweighted()) val = mean(xi, mcw); - else if (outdirs[label].IsMedian()) + else if (outdirs[label].IsMedian()) val = median(xi); else val = mean(xi); @@ -494,14 +494,14 @@ PdfData::PdfData(string dirname, string label) : model(false), par(false) for (vector <Pdf>::iterator eit = Errors[q2].begin(); eit != Errors[q2].end(); eit++) xi.push_back((*eit).GetTable(*pit)[ix]); - if (outdirs[label].IsReweighted()) + if (outdirs[label].IsReweighted()) val = mean(xi, mcw); else if (outdirs[label].IsMedian()) val = median(xi); else val = mean(xi); - if (outdirs[label].IsReweighted()) + if (outdirs[label].IsReweighted()) eminus = eplus = rms(xi, mcw); else if (outdirs[label].Is68cl()) { @@ -527,30 +527,30 @@ PdfData::PdfData(string dirname, string label) : model(false), par(false) for (vector <Pdf>::iterator eit = Errors[q2].begin(); eit != Errors[q2].end(); eit++) xi.push_back((*eit).GetTable(*pit)[ix]); - if (!outdirs[label].IsAsym()) //symmetrise errors - eplus = eminus = ahessdelta(xi); - else //asymmetric errors - ahessdeltaasym(xi, eplus, eminus); - if (outdirs[label].Scale68()) - { - eplus = eplus/1.645; - eminus = eminus/1.645; - } - } + if (!outdirs[label].IsAsym()) //symmetrise errors + eplus = eminus = ahessdelta(xi); + else //asymmetric errors + ahessdeltaasym(xi, eplus, eminus); + if (outdirs[label].Scale68()) + { + eplus = eplus/1.645; + eminus = eminus/1.645; + } + } else if (err == SymHess) { vector <double> xi; xi.push_back(val); for (vector <Pdf>::iterator eit = Errors[q2].begin(); eit != Errors[q2].end(); eit++) - xi.push_back((*eit).GetTable(*pit)[ix]); + xi.push_back((*eit).GetTable(*pit)[ix]); - eplus = eminus = shessdelta(xi); - if (outdirs[label].Scale68()) - { - eplus = eplus/1.645; - eminus = eminus/1.645; - } - } + eplus = eminus = shessdelta(xi); + if (outdirs[label].Scale68()) + { + eplus = eplus/1.645; + eminus = eminus/1.645; + } + } UpExp[q2].SetPoint(*pit, ix, val+eplus); DownExp[q2].SetPoint(*pit, ix, val-eminus); @@ -641,16 +641,16 @@ void PdfData::pdfRotate(string dirname, string label) int idx1 = 0; while ( getline (f,line) ) { - vector <double> aline; - istringstream iss(line); - int idx2; - iss >> idx2; - for ( int i = 0; i<N; i++) { - double val; - iss >> val; - aline.push_back(val); - } - rotation.push_back(aline); + vector <double> aline; + istringstream iss(line); + int idx2; + iss >> idx2; + for ( int i = 0; i<N; i++) { + double val; + iss >> val; + aline.push_back(val); + } + rotation.push_back(aline); } f.close(); @@ -668,33 +668,33 @@ void PdfData::pdfRotate(string dirname, string label) for (vector <pdftype>::iterator pit = pdfs.begin(); pit != pdfs.end(); pit++) { //Loop on x points for (int ix = 0; ix < Cent.GetNx(); ix++) - { - double val = Cent.GetTable(*pit)[ix]; - double corsum = 0; - double eminus = 0; // also errors - double eplus = 0; + { + double val = Cent.GetTable(*pit)[ix]; + double corsum = 0; + double eminus = 0; // also errors + double eplus = 0; - // For now CT10 only: - for ( int id=0; id<N; id++) { - Pdf Up = Errors[q2].at(2*(id)); - Pdf Dn = Errors[q2].at(2*(id)+1); - double plus = Up.GetTable(*pit)[ix] - val; - double minus = Dn.GetTable(*pit)[ix] - val; + // For now CT10 only: + for ( int id=0; id<N; id++) { + Pdf Up = Errors[q2].at(2*(id)); + Pdf Dn = Errors[q2].at(2*(id)+1); + double plus = Up.GetTable(*pit)[ix] - val; + double minus = Dn.GetTable(*pit)[ix] - val; - corsum += 0.5*(plus-minus)*rotation[iRotation][id]; + corsum += 0.5*(plus-minus)*rotation[iRotation][id]; - // corsum += 0.5*(plus-minus)*rotation[iRotation][id]; - } + // corsum += 0.5*(plus-minus)*rotation[iRotation][id]; + } - Cent.SetPoint(*pit, ix, val+corsum); - Cent.SetErrUp(*pit, ix, eplus); - Cent.SetErrDn(*pit, ix, eminus); + Cent.SetPoint(*pit, ix, val+corsum); + Cent.SetErrUp(*pit, ix, eplus); + Cent.SetErrDn(*pit, ix, eminus); - Up[q2].SetPoint(*pit, ix, val+corsum+eplus); - Down[q2].SetPoint(*pit, ix, val+corsum-eminus); - } + Up[q2].SetPoint(*pit, ix, val+corsum+eplus); + Down[q2].SetPoint(*pit, ix, val+corsum-eminus); + } } pdfit->second = Cent; } @@ -718,16 +718,16 @@ void PdfData::pdfSet(string dirname, string label) for (vector <pdftype>::iterator pit = pdfs.begin(); pit != pdfs.end(); pit++) { //Loop on x points for (int ix = 0; ix < Cent.GetNx(); ix++) - { - double val = Pset.GetTable(*pit)[ix]; + { + double val = Pset.GetTable(*pit)[ix]; - Cent.SetPoint(*pit, ix, val); - Cent.SetErrUp(*pit, ix, eplus); - Cent.SetErrDn(*pit, ix, eminus); + Cent.SetPoint(*pit, ix, val); + Cent.SetErrUp(*pit, ix, eplus); + Cent.SetErrDn(*pit, ix, eminus); - Up[q2].SetPoint(*pit, ix, val+eplus); - Down[q2].SetPoint(*pit, ix, val-eminus); - } + Up[q2].SetPoint(*pit, ix, val+eplus); + Down[q2].SetPoint(*pit, ix, val-eminus); + } } pdfit->second = Cent; } @@ -870,11 +870,11 @@ void PdfData::profile(string dirname, string label) else if (err == SymHess) { eplus = eminus = shessdelta(xi, cor_matrix ); } - if (outdirs[label].Scale68()) - { - eplus = eplus/1.645; - eminus = eminus/1.645; - } + if (outdirs[label].Scale68()) + { + eplus = eplus/1.645; + eminus = eminus/1.645; + } Cent.SetPoint(*pit, ix, val+corsum); Cent.SetErrUp(*pit, ix, eplus); Cent.SetErrDn(*pit, ix, eminus); diff --git a/tools/install-xfitter b/tools/install-xfitter index 953f5714d..8571e26ef 100755 --- a/tools/install-xfitter +++ b/tools/install-xfitter @@ -66,14 +66,14 @@ if [[ $mode != "deps" ]] version=$mode else if [[ ! -e version ]] - then - echo - echo "could not find file \"version\"" - echo "cannot determine current version" - echo "run first:" - echo "$0 <version>" - echo - exit + then + echo + echo "could not find file \"version\"" + echo "cannot determine current version" + echo "run first:" + echo "$0 <version>" + echo + exit fi version=`cat version` echo "reinstalling dependencies for xFitter version $version" @@ -91,31 +91,31 @@ if [[ $version != "master" ]] exist=0 for ver in `` do - if [[ $version == $ver ]] - then - exist=1 - fi + if [[ $version == $ver ]] + then + exist=1 + fi done vers=`git ls-remote --tags https://gitlab.cern.ch/fitters/xfitter.git | sed 's|/| |g; s|\^| |' | awk '{print $4}' | uniq` for ver in $vers do - if [[ $version == $ver ]] - then - exist=1 - fi + if [[ $version == $ver ]] + then + exist=1 + fi done if [[ $exist == 0 ]] then - echo - echo "version $version not found, available versions:" - echo "" - echo "$vers" - echo "master" - echo - exit + echo + echo "version $version not found, available versions:" + echo "" + echo "$vers" + echo "master" + echo + exit fi fi @@ -143,22 +143,22 @@ then which sw_vers >& /dev/null if [[ $? == 0 ]] then - echo "Detected Mac OS X system" - MODE=local + echo "Detected Mac OS X system" + MODE=local else - SYS=$(echo `lsb_release -i |cut -d: -f2`) - ver=$(echo `lsb_release -r |cut -d: -f2`) - if [[ $SYS == Scientific* && $ver == 6.* ]] - then - echo "Detected SL6 Linux distribution" - MODE=cern - gccv=4.9 - echo "Using gcc version = ${gccv}" - os=slc6 - arch=x86_64 - rootversion=5.34.36 - boostver=1.53.0 - pyth=2.7 + SYS=$(echo `lsb_release -i |cut -d: -f2`) + ver=$(echo `lsb_release -r |cut -d: -f2`) + if [[ $SYS == Scientific* && $ver == 6.* ]] + then + echo "Detected SL6 Linux distribution" + MODE=cern + gccv=4.9 + echo "Using gcc version = ${gccv}" + os=slc6 + arch=x86_64 + rootversion=5.34.36 + boostver=1.53.0 + pyth=2.7 elif [[ $SYS == CentOS* && $ver == 7.* ]] then echo "Detected CentOS7 Linux distribution" @@ -169,46 +169,46 @@ then rootversion=6.06.08 boostver=1.53.0 pyth=2.7 - elif [[ $SYS == Scientific* && $ver == 5.* ]] - then - echo "Detected SL5 Linux distribution" - MODE=cern - gccv=4.3 - os=slc5 - arch=x86_64 - rootversion=5.34.00 - boostver=1.48.0 - python=2.6.5 - pyth=2.6 - elif [[ $SYS == "Ubuntu" ]] - then - echo "Detected Ubuntu distribution" - MODE=local - else - echo "Sorry, I don't recognize your system:" - echo "$SYS $ver" - echo "I will assume you have root installed in your system," + elif [[ $SYS == Scientific* && $ver == 5.* ]] + then + echo "Detected SL5 Linux distribution" + MODE=cern + gccv=4.3 + os=slc5 + arch=x86_64 + rootversion=5.34.00 + boostver=1.48.0 + python=2.6.5 + pyth=2.6 + elif [[ $SYS == "Ubuntu" ]] + then + echo "Detected Ubuntu distribution" + MODE=local + else + echo "Sorry, I don't recognize your system:" + echo "$SYS $ver" + echo "I will assume you have root installed in your system," echo "gcc version >= 4.3, python, boost libraries, and wget" - echo "If this doesn't work, and you have /cvmfs/sft.cern.ch mounted" - echo "edit me (I am $0) and try to setup appropriate settings" - echo "in the section: manual configuration" - echo - MODE="local" - fi + echo "If this doesn't work, and you have /cvmfs/sft.cern.ch mounted" + echo "edit me (I am $0) and try to setup appropriate settings" + echo "in the section: manual configuration" + echo + MODE="local" + fi fi fi if [[ $MODE == "cern" ]] then # if [[ ! -e /afs/cern.ch ]] if [[ ! -e /cvmfs/sft.cern.ch ]] - then - echo - echo "/cvmfs/sft.cern.ch not mounted, forcing local MODE" - echo "Fasten you seat belt" - echo "I hope you have root, gcc >= 4.8, python and boost libraries" - echo "all installed in your system" - echo - MODE="local" + then + echo + echo "/cvmfs/sft.cern.ch not mounted, forcing local MODE" + echo "Fasten you seat belt" + echo "I hope you have root, gcc >= 4.8, python and boost libraries" + echo "all installed in your system" + echo + MODE="local" fi fi @@ -222,13 +222,13 @@ then if [[ $os == slc5 ]] then echo "LEGACY SL5 ! using afs" - PYTHONBIN=/afs/cern.ch/sw/lcg/external/Python/${python}/${arch}-${os}-${compiler}-opt/bin - PATH=$PYTHONBIN:$PATH - export BOOST=--with-boost=/afs/cern.ch/sw/lcg/external/Boost/${boostver}_python${pyth}/${arch}-${os}-${compiler}-opt + PYTHONBIN=/afs/cern.ch/sw/lcg/external/Python/${python}/${arch}-${os}-${compiler}-opt/bin + PATH=$PYTHONBIN:$PATH + export BOOST=--with-boost=/afs/cern.ch/sw/lcg/external/Boost/${boostver}_python${pyth}/${arch}-${os}-${compiler}-opt fi if [[ $os == slc6 ]] then - export BOOST=--with-boost=/cvmfs/sft.cern.ch/lcg/external/Boost/${boostver}_python${pyth}/${arch}-${os}-${compiler}-opt + export BOOST=--with-boost=/cvmfs/sft.cern.ch/lcg/external/Boost/${boostver}_python${pyth}/${arch}-${os}-${compiler}-opt fi fi @@ -255,10 +255,10 @@ else which curl >& /dev/null if [[ $? == 0 ]] then - http=curl + http=curl else - echo "Error, wget or curl not found" - exit + echo "Error, wget or curl not found" + exit fi fi @@ -287,33 +287,33 @@ else echo "Installing LHAPDF $lhapdfver..." if (( `echo $lhapdfver |cut -d. -f1` >= 6 )) then - lhapdf="LHAPDF" - withboost=$BOOST + lhapdf="LHAPDF" + withboost=$BOOST else - lhapdf="lhapdf" + lhapdf="lhapdf" fi if [[ $http == "curl" ]] then -# curl https://www.hepforge.org/archive/lhapdf/${lhapdf}-${lhapdfver}.tar.gz > ${lhapdf}-${lhapdfver}.tar.gz 2>> $CURRENTDIR/install.log - curl https://lhapdf.hepforge.org/downloads/${lhapdf}-${lhapdfver}.tar.gz > ${lhapdf}-${lhapdfver}.tar.gz 2>> $CURRENTDIR/install.log +# curl https://www.hepforge.org/archive/lhapdf/${lhapdf}-${lhapdfver}.tar.gz > ${lhapdf}-${lhapdfver}.tar.gz 2>> $CURRENTDIR/install.log + curl https://lhapdf.hepforge.org/downloads/${lhapdf}-${lhapdfver}.tar.gz > ${lhapdf}-${lhapdfver}.tar.gz 2>> $CURRENTDIR/install.log else -# wget https://www.hepforge.org/archive/lhapdf/${lhapdf}-${lhapdfver}.tar.gz >> $CURRENTDIR/install.log 2>&1 - wget https://lhapdf.hepforge.org/downloads/${lhapdf}-${lhapdfver}.tar.gz >> $CURRENTDIR/install.log 2>&1 +# wget https://www.hepforge.org/archive/lhapdf/${lhapdf}-${lhapdfver}.tar.gz >> $CURRENTDIR/install.log 2>&1 + wget https://lhapdf.hepforge.org/downloads/${lhapdf}-${lhapdfver}.tar.gz >> $CURRENTDIR/install.log 2>&1 fi tar xfz ${lhapdf}-${lhapdfver}.tar.gz >> $CURRENTDIR/install.log 2>&1 cd ${lhapdf}-${lhapdfver} ./configure --prefix=$CURRENTDIR/deps/lhapdf >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi make -j 9 install >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi cd - >& /dev/null @@ -321,23 +321,23 @@ else echo "Installing HOPPET $hoppetver..." if [[ $http == "curl" ]] then - curl http://hoppet.hepforge.org/downloads/hoppet-${hoppetver}.tgz > hoppet-${hoppetver}.tgz 2>> $CURRENTDIR/install.log + curl http://hoppet.hepforge.org/downloads/hoppet-${hoppetver}.tgz > hoppet-${hoppetver}.tgz 2>> $CURRENTDIR/install.log else - wget http://hoppet.hepforge.org/downloads/hoppet-${hoppetver}.tgz >> $CURRENTDIR/install.log 2>&1 + wget http://hoppet.hepforge.org/downloads/hoppet-${hoppetver}.tgz >> $CURRENTDIR/install.log 2>&1 fi tar xfz hoppet-${hoppetver}.tgz >> $CURRENTDIR/install.log 2>&1 cd hoppet-${hoppetver} ./configure --prefix=$CURRENTDIR/deps/hoppet >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi make -j 9 install >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then - echo "Error, check install.log for details" -# exit + echo "Error, check install.log for details" +# exit fi cd - >& /dev/null @@ -353,31 +353,31 @@ else echo "Installing APPLGRID $applgridver..." if [[ $http == "curl" ]] then -# curl https://www.hepforge.org/archive/applgrid/applgrid-$applgridver.tgz > applgrid-$applgridver.tgz 2>> $CURRENTDIR/install.log - curl https://applgrid.hepforge.org/downloads/applgrid-$applgridver.tgz > applgrid-$applgridver.tgz 2>> $CURRENTDIR/install.log +# curl https://www.hepforge.org/archive/applgrid/applgrid-$applgridver.tgz > applgrid-$applgridver.tgz 2>> $CURRENTDIR/install.log + curl https://applgrid.hepforge.org/downloads/applgrid-$applgridver.tgz > applgrid-$applgridver.tgz 2>> $CURRENTDIR/install.log else -# wget https://www.hepforge.org/archive/applgrid/applgrid-$applgridver.tgz >> $CURRENTDIR/install.log 2>&1 - wget https://applgrid.hepforge.org/downloads/applgrid-$applgridver.tgz >> $CURRENTDIR/install.log 2>&1 +# wget https://www.hepforge.org/archive/applgrid/applgrid-$applgridver.tgz >> $CURRENTDIR/install.log 2>&1 + wget https://applgrid.hepforge.org/downloads/applgrid-$applgridver.tgz >> $CURRENTDIR/install.log 2>&1 fi tar xfz applgrid-$applgridver.tgz >> $CURRENTDIR/install.log 2>&1 cd applgrid-$applgridver ./configure --prefix=$CURRENTDIR/deps/applgrid >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi make >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi make -j 9 install >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi cd - >& /dev/null @@ -387,9 +387,9 @@ else echo "Installing APFEL $apfelver..." if [[ $http == "curl" ]] then - curl https://github.com/scarrazza/apfel/archive/${apfelver}.tar.gz > ${apfelver}.tar.gz 2 >> $CURRENTDIR/install.log + curl https://github.com/scarrazza/apfel/archive/${apfelver}.tar.gz > ${apfelver}.tar.gz 2 >> $CURRENTDIR/install.log else - wget https://github.com/scarrazza/apfel/archive/${apfelver}.tar.gz >> $CURRENTDIR/install.log 2>&1 + wget https://github.com/scarrazza/apfel/archive/${apfelver}.tar.gz >> $CURRENTDIR/install.log 2>&1 fi mv ${apfelver}.tar.gz apfel-${apfelver}.tar.gz tar xfvz apfel-${apfelver}.tar.gz >> $CURRENTDIR/install.log 2>&1 @@ -398,14 +398,14 @@ else if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi make -j 9 install >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi cd - >& /dev/null # setup paths for apfel: @@ -414,23 +414,23 @@ else #apfelgrid if [ -d /cvmfs ] then - lhapdf get NNPDF30_nlo_as_0118 >> $CURRENTDIR/install.log 2>&1 - else - wget http://www.hepforge.org/archive/lhapdf/pdfsets/6.2/NNPDF30_nlo_as_0118.tar.gz >> $CURRENTDIR/install.log 2>&1 - tar xvzpf NNPDF30_nlo_as_0118.tar.gz >> $CURRENTDIR/install.log 2>&1 - mv NNPDF30_nlo_as_0118 `lhapdf-config --datadir` >> $CURRENTDIR/install.log 2>&1 - rm NNPDF30_nlo_as_0118.tar.gz >> $CURRENTDIR/install.log 2>&1 - fi - echo "Installing APFELgrid $apfelgridver..." + lhapdf get NNPDF30_nlo_as_0118 >> $CURRENTDIR/install.log 2>&1 + else + wget http://www.hepforge.org/archive/lhapdf/pdfsets/6.2/NNPDF30_nlo_as_0118.tar.gz >> $CURRENTDIR/install.log 2>&1 + tar xvzpf NNPDF30_nlo_as_0118.tar.gz >> $CURRENTDIR/install.log 2>&1 + mv NNPDF30_nlo_as_0118 `lhapdf-config --datadir` >> $CURRENTDIR/install.log 2>&1 + rm NNPDF30_nlo_as_0118.tar.gz >> $CURRENTDIR/install.log 2>&1 + fi + echo "Installing APFELgrid $apfelgridver..." # tmp solution is to use fork @zenaiev apfelgridver=1.0.5 if [[ $http == "curl" ]] then -# curl https://github.com/nhartland/APFELgrid/archive/v${apfelgridver}.tar.gz > v${apfelgridver}.tar.gz 2 >> $CURRENTDIR/install.log - curl https://github.com/zenaiev/APFELgrid/archive/v${apfelgridver}.tar.gz > v${apfelgridver}.tar.gz 2 >> $CURRENTDIR/install.log +# curl https://github.com/nhartland/APFELgrid/archive/v${apfelgridver}.tar.gz > v${apfelgridver}.tar.gz 2 >> $CURRENTDIR/install.log + curl https://github.com/zenaiev/APFELgrid/archive/v${apfelgridver}.tar.gz > v${apfelgridver}.tar.gz 2 >> $CURRENTDIR/install.log else -# wget https://github.com/nhartland/APFELgrid/archive/v${apfelgridver}.tar.gz >> $CURRENTDIR/install.log 2>&1 - wget https://github.com/zenaiev/APFELgrid/archive/v${apfelgridver}.tar.gz >> $CURRENTDIR/install.log 2>&1 +# wget https://github.com/nhartland/APFELgrid/archive/v${apfelgridver}.tar.gz >> $CURRENTDIR/install.log 2>&1 + wget https://github.com/zenaiev/APFELgrid/archive/v${apfelgridver}.tar.gz >> $CURRENTDIR/install.log 2>&1 fi mv v${apfelgridver}.tar.gz APFELgrid-${apfelgridver}.tar.gz tar xfvz APFELgrid-${apfelgridver}.tar.gz >> $CURRENTDIR/install.log 2>&1 @@ -438,8 +438,8 @@ else ./setup.sh >> $CURRENTDIR/install.log 2>&1 if [[ $? != 1 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi cd - >& /dev/null @@ -448,9 +448,9 @@ else if [[ $http == "curl" ]] then - curl https://github.com/vbertone/MELA/archive/${melaver}.tar.gz > ${melaver}.tar.gz 2 >> $CURRENTDIR/install.log + curl https://github.com/vbertone/MELA/archive/${melaver}.tar.gz > ${melaver}.tar.gz 2 >> $CURRENTDIR/install.log else - wget https://github.com/vbertone/MELA/archive/${melaver}.tar.gz >> $CURRENTDIR/install.log 2>&1 + wget https://github.com/vbertone/MELA/archive/${melaver}.tar.gz >> $CURRENTDIR/install.log 2>&1 fi mv ${melaver}.tar.gz MELA-${melaver}.tar.gz tar xfvz MELA-${melaver}.tar.gz >> $CURRENTDIR/install.log 2>&1 @@ -459,14 +459,14 @@ else if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi make -j 9 install >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi cd - >& /dev/null # setup paths for mela: @@ -477,9 +477,9 @@ else qcdnumstripver=`echo $qcdnumver |sed "s/-//g"` if [[ $http == "curl" ]] then - curl http://www.nikhef.nl/user/h24/qcdnum-files/download/qcdnum${qcdnumstripver}.tar.gz > qcdnum${qcdnumstripver}.tar.gz 2>> $CURRENTDIR/install.log + curl http://www.nikhef.nl/user/h24/qcdnum-files/download/qcdnum${qcdnumstripver}.tar.gz > qcdnum${qcdnumstripver}.tar.gz 2>> $CURRENTDIR/install.log else - wget http://www.nikhef.nl/user/h24/qcdnum-files/download/qcdnum${qcdnumstripver}.tar.gz >> $CURRENTDIR/install.log 2>&1 + wget http://www.nikhef.nl/user/h24/qcdnum-files/download/qcdnum${qcdnumstripver}.tar.gz >> $CURRENTDIR/install.log 2>&1 fi tar xfz qcdnum${qcdnumstripver}.tar.gz >> $CURRENTDIR/install.log 2>&1 cd qcdnum-${qcdnumver} @@ -489,14 +489,14 @@ else if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi make -j 9 install >> $CURRENTDIR/install.log 2>&1 if [[ $? != 0 ]] then - echo "Error, check install.log for details" - exit + echo "Error, check install.log for details" + exit fi cd - >& /dev/null fi @@ -511,23 +511,23 @@ then if [[ $version == "master" ]] then - git clone https://gitlab.cern.ch/fitters/xfitter.git >> $CURRENTDIR/install.log 2>&1 - mv xfitter xfitter-master + git clone https://gitlab.cern.ch/fitters/xfitter.git >> $CURRENTDIR/install.log 2>&1 + mv xfitter xfitter-master else - if [[ $http == "curl" ]] - then -# curl https://gitlab.cern.ch/fitters/xfitter/repository/archive.tar.gz\?ref=$version > xfitter-$version.tar.gz -# curl https://www.hepforge.org/archive/xfitter/tar_files/xfitter-$version.tar.gz > xfitter-$version.tar.gz - curl https://xfitter.hepforge.org/downloads/tar_files/xfitter-$version.tar.gz > xfitter-$version.tar.gz - else -# wget https://gitlab.cern.ch/fitters/xfitter/repository/archive.tar.gz\?ref=$version >> $CURRENTDIR/install.log 2>&1 -# mv archive.tar.gz\?ref=$version xfitter-$version.tar.gz -# wget https://www.hepforge.org/archive/xfitter/tar_files/xfitter-$version.tar.gz >> $CURRENTDIR/install.log 2>&1 - wget https://xfitter.hepforge.org/downloads/tar_files/xfitter-$version.tar.gz >> $CURRENTDIR/install.log 2>&1 - fi + if [[ $http == "curl" ]] + then +# curl https://gitlab.cern.ch/fitters/xfitter/repository/archive.tar.gz\?ref=$version > xfitter-$version.tar.gz +# curl https://www.hepforge.org/archive/xfitter/tar_files/xfitter-$version.tar.gz > xfitter-$version.tar.gz + curl https://xfitter.hepforge.org/downloads/tar_files/xfitter-$version.tar.gz > xfitter-$version.tar.gz + else +# wget https://gitlab.cern.ch/fitters/xfitter/repository/archive.tar.gz\?ref=$version >> $CURRENTDIR/install.log 2>&1 +# mv archive.tar.gz\?ref=$version xfitter-$version.tar.gz +# wget https://www.hepforge.org/archive/xfitter/tar_files/xfitter-$version.tar.gz >> $CURRENTDIR/install.log 2>&1 + wget https://xfitter.hepforge.org/downloads/tar_files/xfitter-$version.tar.gz >> $CURRENTDIR/install.log 2>&1 + fi # unpack nicely: - rm -fr xfitter-${version} - mkdir xfitter-${version} ; tar xfz xfitter-${version}.tar.gz -C xfitter-${version} --strip-components 1 + rm -fr xfitter-${version} + mkdir xfitter-${version} ; tar xfz xfitter-${version}.tar.gz -C xfitter-${version} --strip-components 1 fi else make -C xfitter-${version} clean >> $CURRENTDIR/install.log 2>&1 @@ -618,10 +618,10 @@ if [[ ! -e run ]] then mkdir -p run cp xfitter-${version}/steering.txt \ - xfitter-${version}/minuit.in.txt \ - xfitter-${version}/ewparam.txt \ - xfitter-${version}/parameters.yaml \ - run + xfitter-${version}/minuit.in.txt \ + xfitter-${version}/ewparam.txt \ + xfitter-${version}/parameters.yaml \ + run rsync -a --exclude=".*" xfitter-${version}/datafiles run/ rsync -a --exclude=".*" xfitter-${version}/theoryfiles run/ else -- GitLab From 099a638d0d11fa0d402841cb615d9c23b7ed7e24 Mon Sep 17 00:00:00 2001 From: Ivan Novikov <novivanya@yandex.ru> Date: Tue, 9 Apr 2019 15:59:44 +0200 Subject: [PATCH 72/81] Make small cosmetic changes --- Makefile.am | 7 +- configure.ac | 1 - doxygen.cfg | 5 +- .../src/UvDvUbarDbarSSbarPdfDecomposition.cc | 6 +- .../include/ABMPgluonPdfParam.h | 2 +- reactions/APPLgrid/src/ReactionAPPLgrid.cc | 20 ++-- reactions/FFABM_DISCC/src/Makefile.am | 2 +- src/TheorEval.cc | 97 +++++++++---------- 8 files changed, 70 insertions(+), 70 deletions(-) diff --git a/Makefile.am b/Makefile.am index b7f0e85dd..f28ece38e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,11 +31,12 @@ SUBDIRS = minuit/src DY/src DIPOLE/src RT/src EW/src common common/linalg \ pdfparams/Expression/src\ pdfparams/HERAPDF_PdfParam/src \ pdfparams/PolySqrtPdfParam/src \ - pdfdecompositions/BasePdfDecomposition/src \ - pdfparams/ABMPgluonPdfParam/src pdfparams/ABMPseaPdfParam/src \ + pdfparams/NegativeGluonPdfParam/src\ + pdfparams/ABMPgluonPdfParam/src\ + pdfparams/ABMPseaPdfParam/src \ pdfparams/ABMPvalencePdfParam/src \ + pdfdecompositions/BasePdfDecomposition/src\ pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src \ - pdfparams/NegativeGluonPdfParam/src \ pdfdecompositions/LHAPDFDecomposition/src \ pdfdecompositions/UvDvUbarDbarS/src \ pdfdecompositions/SU3_PionPdfDecomposition/src \ diff --git a/configure.ac b/configure.ac index cc98f519f..c53697ceb 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,6 @@ m4_esyscmd(git describe --always 2>&1 | awk '/Not a git/ {print "2.0.0\033@<:@1 [xfitter-help@desy.de],[xfitter],[http://xfitter.org]) m4_ifndef([AC_PACKAGE_URL], AC_DEFINE([PACKAGE_URL],["http://xfitter.org"])) - #Suppress verbose output when compiling (use make V=99 for verbose output) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff --git a/doxygen.cfg b/doxygen.cfg index a8adaea16..b4c05ac75 100644 --- a/doxygen.cfg +++ b/doxygen.cfg @@ -607,7 +607,7 @@ INPUT = include src \ reactions/fastNLO/include \ reactions/fastNLO/src \ reactions/BaseHVQMNR/include \ - reactions/BaseHVQMNR/src + reactions/BaseHVQMNR/src\ reactions/HVQMNR_LHCb_7TeV_beauty/include \ reactions/HVQMNR_LHCb_7TeV_beauty/src \ reactions/APPLgrid/include \ @@ -621,7 +621,8 @@ INPUT = include src \ pdfparams/ABMPvalencePdfParam/include \ pdfparams/HERAPDF_PdfParam/include \ pdfparams/PolySqrtPdfParam/include \ - pdfdecompositions/BasePdfDecomposition/include pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include \ + pdfdecompositions/BasePdfDecomposition/include \ + pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/include \ pdfdecompositions/LHAPDFDecomposition/include \ pdfdecompositions/UvDvUbarDbarS/include \ pdfdecompositions/GRV_PionPdfDecomposition/include \ diff --git a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc index de890f65a..2c69e4e3f 100644 --- a/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc +++ b/pdfdecompositions/UvDvUbarDbarSSbarPdfDecomposition/src/UvDvUbarDbarSSbarPdfDecomposition.cc @@ -35,7 +35,7 @@ namespace xfitter { par_xubar=getParameterisation(node["xubar"].as<string>()); par_xdbar=getParameterisation(node["xdbar"].as<string>()); par_xs =getParameterisation(node["xs"].as<string>()); - par_xsbar =getParameterisation(node["xsbar"].as<string>()); + par_xsbar=getParameterisation(node["xsbar"].as<string>()); par_xg =getParameterisation(node["xg"].as<string>()); } @@ -51,8 +51,8 @@ namespace xfitter { xsumq+= par_xdv ->moment(0); xsumq+=2*par_xubar->moment(0); xsumq+=2*par_xdbar->moment(0); - xsumq+=par_xs ->moment(0); - xsumq+=par_xsbar ->moment(0); + xsumq+= par_xs ->moment(0); + xsumq+= par_xsbar->moment(0); // gluon part par_xg->setMoment(0,1-xsumq); diff --git a/pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h b/pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h index 4be9b46bf..8294a5475 100644 --- a/pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h +++ b/pdfparams/ABMPgluonPdfParam/include/ABMPgluonPdfParam.h @@ -8,7 +8,7 @@ @brief A class for ABMPgluon pdf parameterisation according to Eqs. 19-22 from Phys.Rev. D96 (2017) no.1, 014011 xg(x) = A * (1 - x)^b * x^[a * (1 + gam_m1 * ln(x)) * (1 + gam_1 * x + gam_2 * x^2 + gam_3 * x^3)] - (Note that gam_m1 is zero for gluon in the ABMP16 fitm so it appears for generality with other PDFs.) + (Note that gam_m1 is zero for gluon in the ABMP16 fit so it appears for generality with other PDFs.) @version 0.1 @date 2019-02-25 diff --git a/reactions/APPLgrid/src/ReactionAPPLgrid.cc b/reactions/APPLgrid/src/ReactionAPPLgrid.cc index 6fafdf516..cfb73e63f 100644 --- a/reactions/APPLgrid/src/ReactionAPPLgrid.cc +++ b/reactions/APPLgrid/src/ReactionAPPLgrid.cc @@ -51,16 +51,16 @@ void ReactionAPPLgrid::setDatasetParameters(int dataSetID, map<string,string> pa } else { - std::shared_ptr<appl::grid> g(new appl::grid(token)); - g->trim(); - data.grids.push_back(g); - TFile file(token.c_str()); - references.push_back((TH1D*)file.Get("grid/reference")); - if(!references.back()) - hf_errlog(17033000, "W: no reference histogram grid/reference in " + token); - else - references.back()->SetDirectory(0); - data.emptyPoints.push_back(-1); + std::shared_ptr<appl::grid> g(new appl::grid(token)); + g->trim(); + data.grids.push_back(g); + TFile file(token.c_str()); + references.push_back((TH1D*)file.Get("grid/reference")); + if(!references.back()) + hf_errlog(17033000, "W: no reference histogram grid/reference in " + token); + else + references.back()->SetDirectory(0); + data.emptyPoints.push_back(-1); } } } diff --git a/reactions/FFABM_DISCC/src/Makefile.am b/reactions/FFABM_DISCC/src/Makefile.am index 8c5274b0c..558892749 100644 --- a/reactions/FFABM_DISCC/src/Makefile.am +++ b/reactions/FFABM_DISCC/src/Makefile.am @@ -6,7 +6,7 @@ AM_CXXFLAGS = -I$(srcdir)/../include -I$(srcdir)/../../../include -I$(srcdir)/ lib_LTLIBRARIES = libffabm_discc_xfitter.la libffabm_discc_xfitter_la_SOURCES = ReactionFFABM_DISCC.cc -libffabm_discc_xfitter_la_LDFLAGS = -lmyabm -lbasediscc_xfitter -L$(top_srcdir)/reactions/BaseDISCC/src/.libs -lmyabm -L$(top_srcdir)/ABM/src/.libs +libffabm_discc_xfitter_la_LDFLAGS = -lmyabm -lbasediscc_xfitter -L$(top_srcdir)/reactions/BaseDISCC/src/.libs -L$(top_srcdir)/ABM/src/.libs datadir = ${prefix}/yaml/reactions/FFABM_DISCC data_DATA = ../yaml/parameters.yaml diff --git a/src/TheorEval.cc b/src/TheorEval.cc index 3beae9641..a2100a29b 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -422,7 +422,7 @@ TheorEval::initReactionTerm(int iterm, valarray<double> *val) gNameReaction[term_source] = rt; - // First make sure the name matches: + // First make sure the name matches: if ( rt->getReactionName() == term_source) { string msg = "I: Use reaction "+ rt->getReactionName(); hf_errlog_(17041610+_dsId,msg.c_str(),msg.size()); @@ -595,8 +595,7 @@ TheorEval::Evaluate(valarray<double> &vte ) { double sum = stk.top().sum(); stk.top() = stk.top() / sum; - } - else if ( it->name == string("+") ){ + } else if ( it->name == string("+") ){ valarray<double> a(stk.top()); stk.pop(); stk.top() += a; @@ -614,53 +613,53 @@ TheorEval::Evaluate(valarray<double> &vte ) stk.top() /= a; } else if ( it->name == string(".") ){ - valarray<double> temp; - valarray<double> result; - - valarray<double> a(stk.top()); - int size_a = a.size(); - stk.pop(); - valarray<double> b(stk.top()); - int size_b = b.size(); - - if(size_a % size_b == 0){ // Matrix * Vector - int size_return = size_a / size_b; - result.resize(size_return); - for ( int n = 0; n < size_b; n++){ - temp.resize(size_return); - temp = a[std::slice(n*size_return, size_return, 1)]; //creating nth colum vector - temp *= b[n]; - result += temp; - } - stk.top() = result; - }else if(size_b % size_a == 0){ // Transposed(Vector)*Matrix -> Transposed(Matrix) vector - int size_return = size_b / size_a; - result.resize(size_return); - for ( int n = 0; n < size_a; n++){ - temp.resize(size_return); - temp = b[std::slice(n, size_return, size_a)]; // creating nth row vector -> nth colum vector - temp *= a[n]; - result += temp; - } - stk.top() = result; - }else{ - char error[] = "ERROR: Dimensions do not match "; - cout<<error<<endl;} - /*if(it + 1 ->name == string("kmatrix")){//possible matrix matrix multiplication - int nb1 = ?;//TODO find dimensions of matrices for check and multiplication - int mb1 = ?; - int nb2 = ?; - int mb2 = ?; - result.resize(mb1*nb2); - for(int m = 0; m < mb1; m++){ - for(int n = 0; n < nb2; n++){ - temp.resize(nb1); - temp = M.slize(m*nb1,1, nb); - temp *= M2.slize(n, mb2, nb2); - result[m*nb1 + n] = temp.sum(); - } + valarray<double> temp; + valarray<double> result; + + valarray<double> a(stk.top()); + int size_a = a.size(); + stk.pop(); + valarray<double> b(stk.top()); + int size_b = b.size(); + + if(size_a % size_b == 0){ // Matrix * Vector + int size_return = size_a / size_b; + result.resize(size_return); + for ( int n = 0; n < size_b; n++){ + temp.resize(size_return); + temp = a[std::slice(n*size_return, size_return, 1)]; //creating nth colum vector + temp *= b[n]; + result += temp; + } + stk.top() = result; + }else if(size_b % size_a == 0){ // Transposed(Vector)*Matrix -> Transposed(Matrix) vector + int size_return = size_b / size_a; + result.resize(size_return); + for ( int n = 0; n < size_a; n++){ + temp.resize(size_return); + temp = b[std::slice(n, size_return, size_a)]; // creating nth row vector -> nth colum vector + temp *= a[n]; + result += temp; + } + stk.top() = result; + }else{ + char error[] = "ERROR: Dimensions do not match "; + cout<<error<<endl;} + /*if(it + 1 ->name == string("kmatrix")){//possible matrix matrix multiplication + int nb1 = ?;//TODO find dimensions of matrices for check and multiplication + int mb1 = ?; + int nb2 = ?; + int mb2 = ?; + result.resize(mb1*nb2); + for(int m = 0; m < mb1; m++){ + for(int n = 0; n < nb2; n++){ + temp.resize(nb1); + temp = M.slize(m*nb1,1, nb); + temp *= M2.slize(n, mb2, nb2); + result[m*nb1 + n] = temp.sum(); } - }*/ + } + }*/ } it++; } -- GitLab From add945281e17675dc0f8714c148f8a3a5504c95f Mon Sep 17 00:00:00 2001 From: Ivan Novikov <novivanya@yandex.ru> Date: Fri, 12 Apr 2019 15:01:12 +0200 Subject: [PATCH 73/81] Fix that APFEL++ would get APFEL cppflags instead of its own Issue XFITTER-95 --- evolutions/APFELxx/src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evolutions/APFELxx/src/Makefile.am b/evolutions/APFELxx/src/Makefile.am index 35a3381d6..3355f204c 100644 --- a/evolutions/APFELxx/src/Makefile.am +++ b/evolutions/APFELxx/src/Makefile.am @@ -1,5 +1,5 @@ if ENABLE_APFELXX - AM_CXXFLAGS = $(APFEL_CPPFLAGS) \ + AM_CPPFLAGS=$(APFELXX_CPPFLAGS)\ -I$(srcdir)/../include \ -I$(srcdir)/../../BaseEvolution/include \ -I$(srcdir)/../../../pdfdecompositions/BasePdfDecomposition/include \ -- GitLab From 8a6ac7e97ce4eda26fc974966a3fc0654de2a844 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sat, 4 May 2019 21:54:23 +0200 Subject: [PATCH 74/81] resolve merge conflict --- reactions/APPLgrid/src/ReactionAPPLgrid.cc | 6 +----- reactions/cbdiff/src/Reactioncbdiff.cc | 1 - src/TheorEval.cc | 1 + 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/reactions/APPLgrid/src/ReactionAPPLgrid.cc b/reactions/APPLgrid/src/ReactionAPPLgrid.cc index cfb73e63f..162eb17f6 100644 --- a/reactions/APPLgrid/src/ReactionAPPLgrid.cc +++ b/reactions/APPLgrid/src/ReactionAPPLgrid.cc @@ -38,11 +38,7 @@ void ReactionAPPLgrid::setDatasetParameters(int dataSetID, map<string,string> pa while(std::getline(ss, token, ',')){ //std::cout << token << '\n'; // dummy empty points (for bin manipulations etc.) - // GridName=DUMMYX where X is number of bins (e.g. GridName=DUMMY12) - // ********** - // SZ 27.03.2019 trying to merge the developments in master and test_ceres: - // probably not yet fully consistent (should emptyPoints be in DatasetData?) - // ********** + // GridName=DUMMYX where X is number of bins (e.g. GridName=DUMMY12 for 12 empty bins) if(std::string(token.c_str(), 5) == std::string("DUMMY")) { int nb = atoi(token.c_str() + 5); diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index d57743e8d..30631222c 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -157,7 +157,6 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars DefaultInitFrag(steer, *frag.get()); mnr->fC_sh = TMath::Power(stod(pars["energy"]), 2.0); // centre-of-mass energy squared mnr->CalcConstants(); - mnr->SetDebug(_debug); std::string finalState = pars["FinalState"]; if(finalState == "parton") { diff --git a/src/TheorEval.cc b/src/TheorEval.cc index a2100a29b..1501b5262 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -25,6 +25,7 @@ #include "xfitter_steer.h" #include "BaseEvolution.h" +// ROOT spline can be uncommented (here and below in the code) and used e.g. for cross checks (obviously requires ROOT) //#include <TSpline.h> #include <spline.h> -- GitLab From 4b7f50a1a3f5b8a090e60646de799c29a1bc30a3 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sat, 4 May 2019 21:54:23 +0200 Subject: [PATCH 75/81] some minor code cosmetics -- GitLab From 8952e38136a916420055572585adb64019c2264a Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sat, 4 May 2019 22:00:15 +0200 Subject: [PATCH 76/81] removed empty loop --- .../FFABM_DISCC/src/ReactionFFABM_DISCC.cc | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc b/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc index 7a9017957..e6d0f2b41 100644 --- a/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc +++ b/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc @@ -36,13 +36,28 @@ extern "C" { void initgridconst_(); void pdffillgrid_(); - struct COMMON_masses + extern struct COMMON_masses { double rmass[150]; double rmassp[50]; double rcharge[150]; - }; - extern COMMON_masses masses_; + } masses_; + + extern struct COMMON_constants_abkm + { + double pi; + double alpha; + double alphady; + double rmpr; + double gfer2; + double sintc; + double sintw2; + double rmw; + double rmz; + double rgz; + double ckm[3][3]; + double ckm2[3][3]; + } constants_abkm_; } @@ -69,6 +84,7 @@ int ReactionFFABM_DISCC::atStart(const string &s) if(checkParam("ordfl")) ordfl = GetParamI("ordfl"); + printf("ckm[1][2] = %f\n", constants_abkm_.ckm[1][2]); initgridconst_(); // Take the 3-flavour scheme as a default @@ -77,13 +93,17 @@ int ReactionFFABM_DISCC::atStart(const string &s) // heavy quark masses double rmass8in = GetParam("mch"); masses_.rmass[7] = rmass8in; - masses_.rcharge[7] = 0.6666666; + //masses_.rcharge[7] = 0.6666666; _mc = rmass8in; double rmass10in = GetParam("mbt"); masses_.rmass[9] = rmass10in; - masses_.rcharge[9] = 0.3333333; + //masses_.rcharge[9] = 0.3333333; _mb = rmass10in; + //constants_abkm_.pi = 0.1; + printf("ckm[1][2] = %f\n", constants_abkm_.ckm[1][2]); + printf("masses_.rcharge[9] = %f\n", masses_.rcharge[9]); + printf("---------------------------------------------\n"); printf("INFO from ABKM_init:\n"); printf("FF ABM running mass def? T(rue), (F)alse: %c\n", msbarmin ? 'T' : 'F'); -- GitLab From 29dcc2e4eb51026a18ca068a393858f97eecf724 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sat, 4 May 2019 22:50:56 +0200 Subject: [PATCH 77/81] resolved conflict --- reactions/BaseHVQMNR/include/MNR.h | 19 ++-- reactions/BaseHVQMNR/include/MNRGrid.h | 2 +- reactions/BaseHVQMNR/src/MNRGrid.cc | 107 ++++++++++------------ reactions/cbdiff/include/Reactioncbdiff.h | 2 +- reactions/cbdiff/src/Reactioncbdiff.cc | 15 ++- 5 files changed, 73 insertions(+), 72 deletions(-) diff --git a/reactions/BaseHVQMNR/include/MNR.h b/reactions/BaseHVQMNR/include/MNR.h index 61e65be16..28ad8af26 100644 --- a/reactions/BaseHVQMNR/include/MNR.h +++ b/reactions/BaseHVQMNR/include/MNR.h @@ -19,10 +19,10 @@ namespace MNR public: // Constructor MNR(ReactionBaseHVQMNR* ptrReactionTheory); - + // Destructor ~MNR(); - + // Set perturbative scale coefficients // // Scales are parametrised as: @@ -31,20 +31,23 @@ namespace MNR // where mu_f, mu_r are factorisation and renormalisation, respectively, // pT is transverse momentum and xm is the heavy-quark mass. void SetScaleCoef(double mf_a, double mf_b, double mf_c, double mr_a, double mr_b, double mr_c); - + // Set debug flag void SetDebug(int debug) { bDebug = debug; }; // Calculate constants void CalcConstants(); - + // Calculate binning void CalcBinning(); // Calculate cross sections for provided grid and heavy-quark mass xm void CalcXS(Grid* grid, double xm); + // Get number of light flavours + int GetNl() { return fC_nl; } + // Private members private: // Get factorisation scale @@ -68,7 +71,7 @@ namespace MNR // Public fields public: // Centre-of-mass energy squared - double fC_sh; + double fC_sh; // Number of light flavours int fC_nl; @@ -110,7 +113,7 @@ namespace MNR const static double fC_vtf; double fC_b0; // Centre-of-mass energy - double fC_sqrt_sh; + double fC_sqrt_sh; // Normalisation factor double fC_xnorm; @@ -130,7 +133,7 @@ namespace MNR // t3 bins (3 body variable) double* fBc_x4; double* fBw_x4; - + // Precalcuated grid variables int fNRecalc; // Pointer to all allocated memory @@ -189,7 +192,7 @@ namespace MNR // Flags bool bFirst; // first run bool bDebug; // verbose output - + // pointer to instance inherited from ReactionTheory (allow access to alphas and PDF routines) ReactionBaseHVQMNR* _reactionTheory; }; diff --git a/reactions/BaseHVQMNR/include/MNRGrid.h b/reactions/BaseHVQMNR/include/MNRGrid.h index 6e5b33863..014157024 100644 --- a/reactions/BaseHVQMNR/include/MNRGrid.h +++ b/reactions/BaseHVQMNR/include/MNRGrid.h @@ -121,7 +121,7 @@ namespace MNR // Transformation from original grid (gridorig) to new one (gridtrg) // (using cubic spline interpolation) static void InterpolateGrid(Grid* gridorig, Grid* gridtrg, double mq); - static void InterpolateGrid(Grid* gridorig, Grid* gridtrg, double mq, Grid* gridorig_LO_massUp, double mq_masUp, Grid* gridorig_LO_massDown, double mq_masDown, int flag = 0); + static void InterpolateGrid(Grid* gridorig, Grid* gridtrg, double mq, Grid* gridorig_LO_massUp, double mq_masUp, Grid* gridorig_LO_massDown, double mq_masDown, int flag = 0, double* R = 0, int* nf = 0); // Transformation from pole mass scaheme into MSbar mass scheme static void TransformGridToMSbarMassScheme(Grid* grid, Grid* gridLOMassUp, Grid* gridLOMassDown, double mq, double mqDiff); diff --git a/reactions/BaseHVQMNR/src/MNRGrid.cc b/reactions/BaseHVQMNR/src/MNRGrid.cc index ac2fbcc4e..5b86e20cc 100644 --- a/reactions/BaseHVQMNR/src/MNRGrid.cc +++ b/reactions/BaseHVQMNR/src/MNRGrid.cc @@ -5,7 +5,7 @@ namespace MNR { - Grid::Grid() + Grid::Grid() { fNL = 0; fNY = 0; @@ -24,7 +24,7 @@ namespace MNR for(int i = 0; i < fNContr; i++) fCS[i] = NULL; } - Grid::Grid(int ncontr, MNRContribution** contr) + Grid::Grid(int ncontr, MNRContribution** contr) { fNL = 0; fNY = 0; @@ -43,7 +43,7 @@ namespace MNR for(int i = 0; i < fNContr; i++) fCS[i] = NULL; } - Grid::~Grid() + Grid::~Grid() { //printf("OZ Grid::~Grid()\n"); if(fL) delete fL; @@ -53,11 +53,11 @@ namespace MNR if(fW) delete fW; if(fBW) delete fBW; if(fCS) { - for(int c = 0; c < fNContr; c++) + for(int c = 0; c < fNContr; c++) { - for(int i = 0; i < fNL; i++) + for(int i = 0; i < fNL; i++) { - for(int j = 0; j < fNY; j++) + for(int j = 0; j < fNY; j++) { delete fCS[c][i][j]; } @@ -67,7 +67,7 @@ namespace MNR } delete fCS; } - if(fContr) + if(fContr) { for(int i = 0; i < fNContr; i++) { @@ -82,7 +82,7 @@ namespace MNR for(int i = 0; i < fNL; i++) this->NonPhys(i); } - void Grid::NonPhys(int bpt) + void Grid::NonPhys(int bpt) { for(int i = 0; i < fNY; i++) for(int j = 0; j < fNW; j++) @@ -90,7 +90,7 @@ namespace MNR this->CS(k, bpt, i, j) = -1.0; // negative non-physical value } - void Grid::Zero() + void Grid::Zero() { for(int bpt = 0; bpt < fNL; bpt++) for(int i = 0; i < fNY; i++) @@ -99,7 +99,7 @@ namespace MNR this->CS(k, bpt, i, j) = 0; } - void Grid::SetL(int n, double minpt, double maxpt, double xm) + void Grid::SetL(int n, double minpt, double maxpt, double xm) { double power = 0.25; fNL = n; @@ -109,7 +109,7 @@ namespace MNR double minpower = TMath::Power(minpt,power); double maxpower = TMath::Power(maxpt,power); double steppower = (maxpower - minpower) / fNL; - for(int i = 0; i < fNL; i++) + for(int i = 0; i < fNL; i++) { double pt = TMath::Power(minpower + i * steppower, 1.0 / power); fL[i] = xm2 / (xm2 + pt * pt); @@ -122,7 +122,7 @@ namespace MNR fMr = new double[fNL]; } - void Grid::FillPt(double* ptall, double xm) + void Grid::FillPt(double* ptall, double xm) { double xm2 = xm * xm; for(int i = 0; i < fNL; i++) ptall[i] = TMath::Sqrt(xm2 / fL[i] - xm2); @@ -144,14 +144,14 @@ namespace MNR fY = new double[fNY]; double step = (max - min) / (n - 1); for(int i = 0; i < n; i++) fY[i] = min + step * i; - for(int c = 0; c < fNContr; c++) + for(int c = 0; c < fNContr; c++) { if(fCS[c]) { for(int i = 0; i < fNL; i++) if(fCS[c][i]) delete fCS[c][i]; delete fCS[c]; } fCS[c] = new double**[fNL]; - for(int i = 0; i < fNL; i++) + for(int i = 0; i < fNL; i++) { fCS[c][i] = new double*[fNY]; for(int j = 0; j < fNY; j++) fCS[c][i][j] = NULL; @@ -159,9 +159,9 @@ namespace MNR } } - void Grid::SetW(int n, double min/* = 0.0*/, double max/* = 500.0*/) + void Grid::SetW(int n, double min/* = 0.0*/, double max/* = 500.0*/) { - if(!fNY || !fY) + if(!fNY || !fY) { std::string str = "F: ERROR in Grid::SetW(): first call Grid::SetY(), then Grid::SetW()\n"; hf_errlog_(16123010, str.c_str(), str.length()); @@ -187,7 +187,7 @@ namespace MNR } } - void Grid::SetW(double b1, double b2) + void Grid::SetW(double b1, double b2) { if(!fNY || !fY) { @@ -214,18 +214,18 @@ namespace MNR fCS[c][i][j] = new double[fNW]; } } - + int Grid::FindWBin(double w) { - for(int i = 0; i < fNW; i++) + for(int i = 0; i < fNW; i++) if(w < fBW[i+1] && w > fBW[i]) return i; return fNW - 1; } - void Grid::Print(double xm) + void Grid::Print(double xm) { double xm2 = xm * xm; - for(int c = 0; c < fNContr; c++) + for(int c = 0; c < fNContr; c++) { for(int bpt = 0; bpt < fNL; bpt++) { @@ -252,14 +252,14 @@ namespace MNR int nlorig = gridorig->NL(); double* lorig = gridorig->LPtr(); double spline_x[nlorig], spline_y[nlorig]; - for(int i = 0; i < nlorig; i++) + for(int i = 0; i < nlorig; i++) spline_x[nlorig-1-i] = lorig[i]; // Loop over contributions - for(int c = 0; c < gridorig->GetNContr(); c++) + for(int c = 0; c < gridorig->GetNContr(); c++) // Loop over y bins - for(int y = 0; y < gridorig->NY(); y++) + for(int y = 0; y < gridorig->NY(); y++) // Loop over W bins - for(int w = 0; w < gridorig->NW(); w++) + for(int w = 0; w < gridorig->NW(); w++) { // For spline: prepare X-section array of original grid in reversed order for(int l = 0; l < nlorig; l++) spline_y[nlorig-1-l] = gridorig->CS(c,l,y,w); @@ -283,7 +283,11 @@ namespace MNR } } - void Grid::InterpolateGrid(Grid *gridorig, Grid *gridtrg, double mq, Grid *gridorig_LO_massUp, double mq_masUp, Grid *gridorig_LO_massDown, double mq_masDown, int flag) + // Different mass schemes: + // flag = 0: MSbar mass scheme with mu = mu_R + // flag = 1: MSbar mass scheme with mu = mu_R and l != 0 + // flag = 2: MSR mass scheme with R provided (nf should be provided - number of flavours) + void Grid::InterpolateGrid(Grid *gridorig, Grid *gridtrg, double mq, Grid *gridorig_LO_massUp, double mq_masUp, Grid *gridorig_LO_massDown, double mq_masDown, int flag, double* R, int* nf) { double mqDiff = mq_masUp - mq_masDown; // Get pT array of target grid @@ -304,9 +308,6 @@ namespace MNR double spline_x[3][nlorig], spline_y[5][nlorig]; for(int i = 0; i < nlorig; i++) { - //spline_x[0][nlorig-1-i] = mq2 / lorig[i] - mq2; - //spline_x[1][nlorig-1-i] = mq_masUp2 / lorig_LO_massUp[i] - mq_masUp2; - //spline_x[2][nlorig-1-i] = mq_masDown2 / lorig_LO_massDown[i] - mq_masDown2; spline_x[0][i] = mq2 / lorig[i] - mq2; spline_x[1][i] = mq_masUp2 / lorig_LO_massUp[i] - mq_masUp2; spline_x[2][i] = mq_masDown2 / lorig_LO_massDown[i] - mq_masDown2; @@ -321,10 +322,6 @@ namespace MNR // For spline: prepare X-section array of original grid in reversed order for(int l = 0; l < nlorig; l++) { - //spline_y[0][nlorig-1-l] = gridorig->CS(c,l,y,w); - //spline_y[1][nlorig-1-l] = gridorig_LO_massUp->CS(c,l,y,w); - //spline_y[2][nlorig-1-l] = gridorig_LO_massDown->CS(c,l,y,w); - //spline_y[3][nlorig-1-l] = gridorig->AlphaS(l); spline_y[0][l] = gridorig->CS(c,l,y,w); spline_y[1][l] = gridorig_LO_massUp->CS(c,l,y,w); spline_y[2][l] = gridorig_LO_massDown->CS(c,l,y,w); @@ -335,43 +332,35 @@ namespace MNR TSpline3 spline("", spline_x[0], spline_y[0], nlorig); TSpline3 spline_LO_massUp("", spline_x[1], spline_y[1], nlorig); TSpline3 spline_LO_massDown("", spline_x[2], spline_y[2], nlorig); - //TSpline3 spline_LO_massUp("", spline_x[0], spline_y[1], nlorig); - //TSpline3 spline_LO_massDown("", spline_x[0], spline_y[2], nlorig); TSpline3 spline_as("", spline_x[0], spline_y[3], nlorig); TSpline3 spline_mr("", spline_x[0], spline_y[4], nlorig); for(int l = 0; l < nltrg; l++) { - //double pt2 = mq2 / ltrg[l] - mq2; double pt2 = pt[l] * pt[l]; - //double xsecOld = spline.Eval(ltrg[l]); - //double xsecOld_LO_massUp = spline_LO_massUp.Eval(ltrg[l]); - //double xsecOld_LO_massDown = spline_LO_massDown.Eval(ltrg[l]); - //double as = spline_as.Eval(ltrg[l]); double xsecOld = spline.Eval(pt2); double xsecOld_LO_massUp = spline_LO_massUp.Eval(pt2); double xsecOld_LO_massDown = spline_LO_massDown.Eval(pt2); - double as = spline_as.Eval(pt2); - //printf("as = %f\n", as); - //double d1 = 4.0 / 3.0; - double mr = spline_mr.Eval(pt2); - double d1 = 4.0 / 3.0; - if(flag == 1) - d1 += 2.0 * TMath::Log(mr / mq); - // TODO: check different options for transformation - double xsecNew = xsecOld + as / TMath::Pi() * d1 * mq * (xsecOld_LO_massUp - xsecOld_LO_massDown) / mqDiff; + double delta = 0.0; + if(flag == 0 || flag == 1) + { + double as = spline_as.Eval(pt2); + double mr = spline_mr.Eval(pt2); + double d1 = 4.0 / 3.0; + if(flag == 1) + d1 += 2.0 * TMath::Log(mr / mq); + delta = as / TMath::Pi() * d1 * mq * (xsecOld_LO_massUp - xsecOld_LO_massDown) / mqDiff; + } + else if(flag == 2) + { + double as = spline_as.Eval(*R); + double b0 = 11.0 - 2.0 / 3.0 * (*nf); + double a1 = 2 * b0 * 0.348; + delta = (*R) * a1 * as / (4.0 * TMath::Pi()); + } + double xsecNew = xsecOld + delta; gridtrg->CS(c,l,y,w) = xsecNew; - //gridtrg->CS(c,l,y,w) = xsecOld; - //if(y == 20) - // printf("c,y,w,l,g,u,d: %d %d %d %d %f[%f] %f %f --> %f [%.2f]\n", c, y, w, l, xsecOld, pt2, xsecOld_LO_massUp, xsecOld_LO_massDown, xsecNew, xsecNew / xsecOld * 100); } } - // interpolate as - /*double spline_y_as[nlorig]; - for(int l = 0; l < nlorig; l++) - spline_y_as[nlorig-1-l] = gridorig->AlphaS(l); - TSpline3 spline_as("", spline_x[0], spline_y_as, nlorig); - for(int l = 0; l < nltrg; l++) - gridtrg->AlphaS(l) = spline_as.Eval(ltrg[l]);*/ } void Grid::TransformGridToMSbarMassScheme(Grid *grid, Grid *gridLOMassUp, Grid *gridLOMassDown, double mq, double mqDiff) diff --git a/reactions/cbdiff/include/Reactioncbdiff.h b/reactions/cbdiff/include/Reactioncbdiff.h index 9b9c97004..215a8fbc7 100644 --- a/reactions/cbdiff/include/Reactioncbdiff.h +++ b/reactions/cbdiff/include/Reactioncbdiff.h @@ -36,7 +36,7 @@ class Reactioncbdiff : public ReactionBaseHVQMNR std::map<int, std::shared_ptr<MNR::MNR> > _mapMNR; std::map<int, std::shared_ptr<MNR::Grid> > _mapGrid; - std::map<int, bool> _mapMSbarMass; + std::map<int, int> _mapMSbarMass; std::map<int, double> _mapMassDiff; std::map<int, std::shared_ptr<MNR::Grid> > _mapGridLOMassUp; std::map<int, std::shared_ptr<MNR::Grid> > _mapGridLOMassDown; diff --git a/reactions/cbdiff/src/Reactioncbdiff.cc b/reactions/cbdiff/src/Reactioncbdiff.cc index 30631222c..f5cc69c5f 100644 --- a/reactions/cbdiff/src/Reactioncbdiff.cc +++ b/reactions/cbdiff/src/Reactioncbdiff.cc @@ -109,7 +109,7 @@ void Reactioncbdiff::setDatasetParameters(int dataSetID, map<string,string> pars // fragmentation parameters par->fragpar_c = GetParamInPriority("FragPar", pars); PrintParameters(par.get()); - // pole or MSbar mass + // pole, MSbar or MSR mass (0 pole, 1 MSbar, 2 MSR) _mapMSbarMass[dataSetID] = 0; if(pars.find("MS_MASS") != pars.end() || checkParam("MS_MASS")) _mapMSbarMass[dataSetID] = GetParamIInPriority("MS_MASS", pars); @@ -292,8 +292,17 @@ int Reactioncbdiff::compute(int dataSetID, valarray<double> &val, map<string, va mnr->fMf_B = mfB; mnr->fMr_B = mrB; - int flagMSbarTransformation = 0; // d1=4/3 (no ln) - MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc, gridLOMassU.get(), massU, gridLOMassD.get(), massD, flagMSbarTransformation); + if(_mapMSbarMass[dataSetID] == 1) + { + int flagMSbarTransformation = 0; // d1=4/3 (no ln) + MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc, gridLOMassU.get(), massU, gridLOMassD.get(), massD, flagMSbarTransformation); + } + else if(_mapMSbarMass[dataSetID] == 2) + { + double R = 3.0; + int nl = mnr->GetNl(); + MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc, gridLOMassU.get(), massU, gridLOMassD.get(), massD, 2, &R, &nl); + } } else MNR::Grid::InterpolateGrid(grid.get(), gridSm.get(), par->mc); -- GitLab From a600781bb1d2f6a7425e8c5f561a4975ddc45263 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sat, 4 May 2019 22:58:42 +0200 Subject: [PATCH 78/81] removed trailing spaces --- reactions/BaseHVQMNR/include/MNR.h | 18 +++---- .../BaseHVQMNR/include/ReactionBaseHVQMNR.h | 18 +++---- reactions/BaseHVQMNR/src/MNRGrid.cc | 50 +++++++++---------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/reactions/BaseHVQMNR/include/MNR.h b/reactions/BaseHVQMNR/include/MNR.h index 28ad8af26..69dd1e361 100644 --- a/reactions/BaseHVQMNR/include/MNR.h +++ b/reactions/BaseHVQMNR/include/MNR.h @@ -19,10 +19,10 @@ namespace MNR public: // Constructor MNR(ReactionBaseHVQMNR* ptrReactionTheory); - + // Destructor ~MNR(); - + // Set perturbative scale coefficients // // Scales are parametrised as: @@ -31,13 +31,13 @@ namespace MNR // where mu_f, mu_r are factorisation and renormalisation, respectively, // pT is transverse momentum and xm is the heavy-quark mass. void SetScaleCoef(double mf_a, double mf_b, double mf_c, double mr_a, double mr_b, double mr_c); - + // Set debug flag void SetDebug(int debug) { bDebug = debug; }; // Calculate constants void CalcConstants(); - + // Calculate binning void CalcBinning(); @@ -47,7 +47,7 @@ namespace MNR // Get number of light flavours int GetNl() { return fC_nl; } - + // Private members private: // Get factorisation scale @@ -71,7 +71,7 @@ namespace MNR // Public fields public: // Centre-of-mass energy squared - double fC_sh; + double fC_sh; // Number of light flavours int fC_nl; @@ -113,7 +113,7 @@ namespace MNR const static double fC_vtf; double fC_b0; // Centre-of-mass energy - double fC_sqrt_sh; + double fC_sqrt_sh; // Normalisation factor double fC_xnorm; @@ -133,7 +133,7 @@ namespace MNR // t3 bins (3 body variable) double* fBc_x4; double* fBw_x4; - + // Precalcuated grid variables int fNRecalc; // Pointer to all allocated memory @@ -192,7 +192,7 @@ namespace MNR // Flags bool bFirst; // first run bool bDebug; // verbose output - + // pointer to instance inherited from ReactionTheory (allow access to alphas and PDF routines) ReactionBaseHVQMNR* _reactionTheory; }; diff --git a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h index c816e2f41..5004b359e 100644 --- a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h +++ b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h @@ -10,11 +10,11 @@ /** @class' ReactionBaseHVQMNR - @brief A wrapper class for BaseHVQMNR reaction + @brief A wrapper class for BaseHVQMNR reaction Based on the ReactionTheory class. Reads options produces 3d cross section. - This is abstract class from which implementations of HVQMNR + This is abstract class from which implementations of HVQMNR calculations for particular datasets should be derived. @version 0.1 @@ -32,14 +32,14 @@ class ReactionBaseHVQMNR : public ReactionTheory public: virtual string getReactionName() const { return "BaseHVQMNR" ;}; - virtual int atStart(const string &) = 0; + virtual int initAtStart(const string &) = 0; virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err) = 0; virtual void initAtIteration() = 0; virtual void setDatasetParameters(int dataSetID, map<string,string> pars, map<string,double> dsPars) override; protected: virtual int parseOptions(){ return 0;}; - -// ********** common stuff for MNR calculation ********** + +// ********** common stuff for MNR calculation ********** protected: // structure for particular dataset struct DataSet @@ -55,7 +55,7 @@ class ReactionBaseHVQMNR : public ReactionTheory std::valarray<double>* BinsYMinRef; std::valarray<double>* BinsYMaxRef; }; - + // structure to store theory parameters struct Parameters { @@ -111,7 +111,7 @@ class ReactionBaseHVQMNR : public ReactionTheory bool a; char flav; // c, b or t }; - + // all datasets std::map<int, DataSet> _dataSets; // theory parameters @@ -136,7 +136,7 @@ class ReactionBaseHVQMNR : public ReactionTheory // read and update theory parameters void UpdateParameters(); - + // print theory parameters void PrintParameters(Parameters const* pars = NULL) const; @@ -152,7 +152,7 @@ class ReactionBaseHVQMNR : public ReactionTheory //private: // check equality of float numbers with tolerance bool IsEqual(const double val1, const double val2, const double eps = 1e-6); - + // TODO this old commented out code to be removed one day /*// read values from terminfo in format key1=value1:key2=value2:... int readFromTermInfo(const std::string& str, const std::string& key, int& value); diff --git a/reactions/BaseHVQMNR/src/MNRGrid.cc b/reactions/BaseHVQMNR/src/MNRGrid.cc index 5b86e20cc..c4d8c8b7d 100644 --- a/reactions/BaseHVQMNR/src/MNRGrid.cc +++ b/reactions/BaseHVQMNR/src/MNRGrid.cc @@ -5,7 +5,7 @@ namespace MNR { - Grid::Grid() + Grid::Grid() { fNL = 0; fNY = 0; @@ -24,7 +24,7 @@ namespace MNR for(int i = 0; i < fNContr; i++) fCS[i] = NULL; } - Grid::Grid(int ncontr, MNRContribution** contr) + Grid::Grid(int ncontr, MNRContribution** contr) { fNL = 0; fNY = 0; @@ -43,7 +43,7 @@ namespace MNR for(int i = 0; i < fNContr; i++) fCS[i] = NULL; } - Grid::~Grid() + Grid::~Grid() { //printf("OZ Grid::~Grid()\n"); if(fL) delete fL; @@ -53,11 +53,11 @@ namespace MNR if(fW) delete fW; if(fBW) delete fBW; if(fCS) { - for(int c = 0; c < fNContr; c++) + for(int c = 0; c < fNContr; c++) { - for(int i = 0; i < fNL; i++) + for(int i = 0; i < fNL; i++) { - for(int j = 0; j < fNY; j++) + for(int j = 0; j < fNY; j++) { delete fCS[c][i][j]; } @@ -67,7 +67,7 @@ namespace MNR } delete fCS; } - if(fContr) + if(fContr) { for(int i = 0; i < fNContr; i++) { @@ -82,7 +82,7 @@ namespace MNR for(int i = 0; i < fNL; i++) this->NonPhys(i); } - void Grid::NonPhys(int bpt) + void Grid::NonPhys(int bpt) { for(int i = 0; i < fNY; i++) for(int j = 0; j < fNW; j++) @@ -90,7 +90,7 @@ namespace MNR this->CS(k, bpt, i, j) = -1.0; // negative non-physical value } - void Grid::Zero() + void Grid::Zero() { for(int bpt = 0; bpt < fNL; bpt++) for(int i = 0; i < fNY; i++) @@ -99,7 +99,7 @@ namespace MNR this->CS(k, bpt, i, j) = 0; } - void Grid::SetL(int n, double minpt, double maxpt, double xm) + void Grid::SetL(int n, double minpt, double maxpt, double xm) { double power = 0.25; fNL = n; @@ -109,7 +109,7 @@ namespace MNR double minpower = TMath::Power(minpt,power); double maxpower = TMath::Power(maxpt,power); double steppower = (maxpower - minpower) / fNL; - for(int i = 0; i < fNL; i++) + for(int i = 0; i < fNL; i++) { double pt = TMath::Power(minpower + i * steppower, 1.0 / power); fL[i] = xm2 / (xm2 + pt * pt); @@ -122,7 +122,7 @@ namespace MNR fMr = new double[fNL]; } - void Grid::FillPt(double* ptall, double xm) + void Grid::FillPt(double* ptall, double xm) { double xm2 = xm * xm; for(int i = 0; i < fNL; i++) ptall[i] = TMath::Sqrt(xm2 / fL[i] - xm2); @@ -144,14 +144,14 @@ namespace MNR fY = new double[fNY]; double step = (max - min) / (n - 1); for(int i = 0; i < n; i++) fY[i] = min + step * i; - for(int c = 0; c < fNContr; c++) + for(int c = 0; c < fNContr; c++) { if(fCS[c]) { for(int i = 0; i < fNL; i++) if(fCS[c][i]) delete fCS[c][i]; delete fCS[c]; } fCS[c] = new double**[fNL]; - for(int i = 0; i < fNL; i++) + for(int i = 0; i < fNL; i++) { fCS[c][i] = new double*[fNY]; for(int j = 0; j < fNY; j++) fCS[c][i][j] = NULL; @@ -159,9 +159,9 @@ namespace MNR } } - void Grid::SetW(int n, double min/* = 0.0*/, double max/* = 500.0*/) + void Grid::SetW(int n, double min/* = 0.0*/, double max/* = 500.0*/) { - if(!fNY || !fY) + if(!fNY || !fY) { std::string str = "F: ERROR in Grid::SetW(): first call Grid::SetY(), then Grid::SetW()\n"; hf_errlog_(16123010, str.c_str(), str.length()); @@ -187,7 +187,7 @@ namespace MNR } } - void Grid::SetW(double b1, double b2) + void Grid::SetW(double b1, double b2) { if(!fNY || !fY) { @@ -214,18 +214,18 @@ namespace MNR fCS[c][i][j] = new double[fNW]; } } - + int Grid::FindWBin(double w) { - for(int i = 0; i < fNW; i++) + for(int i = 0; i < fNW; i++) if(w < fBW[i+1] && w > fBW[i]) return i; return fNW - 1; } - void Grid::Print(double xm) + void Grid::Print(double xm) { double xm2 = xm * xm; - for(int c = 0; c < fNContr; c++) + for(int c = 0; c < fNContr; c++) { for(int bpt = 0; bpt < fNL; bpt++) { @@ -252,14 +252,14 @@ namespace MNR int nlorig = gridorig->NL(); double* lorig = gridorig->LPtr(); double spline_x[nlorig], spline_y[nlorig]; - for(int i = 0; i < nlorig; i++) + for(int i = 0; i < nlorig; i++) spline_x[nlorig-1-i] = lorig[i]; // Loop over contributions - for(int c = 0; c < gridorig->GetNContr(); c++) + for(int c = 0; c < gridorig->GetNContr(); c++) // Loop over y bins - for(int y = 0; y < gridorig->NY(); y++) + for(int y = 0; y < gridorig->NY(); y++) // Loop over W bins - for(int w = 0; w < gridorig->NW(); w++) + for(int w = 0; w < gridorig->NW(); w++) { // For spline: prepare X-section array of original grid in reversed order for(int l = 0; l < nlorig; l++) spline_y[nlorig-1-l] = gridorig->CS(c,l,y,w); -- GitLab From 508116dd8485ca6f1bd7d06ea2abf64c63492292 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sun, 5 May 2019 14:59:55 +0200 Subject: [PATCH 79/81] restored FFABMDISCC --- .../FFABM_DISCC/src/ReactionFFABM_DISCC.cc | 32 +++---------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc b/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc index e6d0f2b41..39615448c 100644 --- a/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc +++ b/reactions/FFABM_DISCC/src/ReactionFFABM_DISCC.cc @@ -1,4 +1,4 @@ - + /* @file ReactionFFABM_DISCC.cc @date 2017-10-09 @@ -36,28 +36,13 @@ extern "C" { void initgridconst_(); void pdffillgrid_(); - extern struct COMMON_masses + struct COMMON_masses { double rmass[150]; - double rmassp[50]; + double rmassp[150]; double rcharge[150]; - } masses_; - - extern struct COMMON_constants_abkm - { - double pi; - double alpha; - double alphady; - double rmpr; - double gfer2; - double sintc; - double sintw2; - double rmw; - double rmz; - double rgz; - double ckm[3][3]; - double ckm2[3][3]; - } constants_abkm_; + }; + extern COMMON_masses masses_; } @@ -84,7 +69,6 @@ int ReactionFFABM_DISCC::atStart(const string &s) if(checkParam("ordfl")) ordfl = GetParamI("ordfl"); - printf("ckm[1][2] = %f\n", constants_abkm_.ckm[1][2]); initgridconst_(); // Take the 3-flavour scheme as a default @@ -93,17 +77,11 @@ int ReactionFFABM_DISCC::atStart(const string &s) // heavy quark masses double rmass8in = GetParam("mch"); masses_.rmass[7] = rmass8in; - //masses_.rcharge[7] = 0.6666666; _mc = rmass8in; double rmass10in = GetParam("mbt"); masses_.rmass[9] = rmass10in; - //masses_.rcharge[9] = 0.3333333; _mb = rmass10in; - //constants_abkm_.pi = 0.1; - printf("ckm[1][2] = %f\n", constants_abkm_.ckm[1][2]); - printf("masses_.rcharge[9] = %f\n", masses_.rcharge[9]); - printf("---------------------------------------------\n"); printf("INFO from ABKM_init:\n"); printf("FF ABM running mass def? T(rue), (F)alse: %c\n", msbarmin ? 'T' : 'F'); -- GitLab From 8167f6b24bb0fa9d4b7f59afd73812669c897220 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sun, 5 May 2019 15:12:28 +0200 Subject: [PATCH 80/81] fixed HVQMBR header --- .../BaseHVQMNR/include/ReactionBaseHVQMNR.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h index 5004b359e..c816e2f41 100644 --- a/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h +++ b/reactions/BaseHVQMNR/include/ReactionBaseHVQMNR.h @@ -10,11 +10,11 @@ /** @class' ReactionBaseHVQMNR - @brief A wrapper class for BaseHVQMNR reaction + @brief A wrapper class for BaseHVQMNR reaction Based on the ReactionTheory class. Reads options produces 3d cross section. - This is abstract class from which implementations of HVQMNR + This is abstract class from which implementations of HVQMNR calculations for particular datasets should be derived. @version 0.1 @@ -32,14 +32,14 @@ class ReactionBaseHVQMNR : public ReactionTheory public: virtual string getReactionName() const { return "BaseHVQMNR" ;}; - virtual int initAtStart(const string &) = 0; + virtual int atStart(const string &) = 0; virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err) = 0; virtual void initAtIteration() = 0; virtual void setDatasetParameters(int dataSetID, map<string,string> pars, map<string,double> dsPars) override; protected: virtual int parseOptions(){ return 0;}; - -// ********** common stuff for MNR calculation ********** + +// ********** common stuff for MNR calculation ********** protected: // structure for particular dataset struct DataSet @@ -55,7 +55,7 @@ class ReactionBaseHVQMNR : public ReactionTheory std::valarray<double>* BinsYMinRef; std::valarray<double>* BinsYMaxRef; }; - + // structure to store theory parameters struct Parameters { @@ -111,7 +111,7 @@ class ReactionBaseHVQMNR : public ReactionTheory bool a; char flav; // c, b or t }; - + // all datasets std::map<int, DataSet> _dataSets; // theory parameters @@ -136,7 +136,7 @@ class ReactionBaseHVQMNR : public ReactionTheory // read and update theory parameters void UpdateParameters(); - + // print theory parameters void PrintParameters(Parameters const* pars = NULL) const; @@ -152,7 +152,7 @@ class ReactionBaseHVQMNR : public ReactionTheory //private: // check equality of float numbers with tolerance bool IsEqual(const double val1, const double val2, const double eps = 1e-6); - + // TODO this old commented out code to be removed one day /*// read values from terminfo in format key1=value1:key2=value2:... int readFromTermInfo(const std::string& str, const std::string& key, int& value); -- GitLab From a23661571f86bd52b4b6201993af66af334d6cd0 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Sun, 5 May 2019 15:12:52 +0200 Subject: [PATCH 81/81] really removed empty loop --- src/TheorEval.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/TheorEval.cc b/src/TheorEval.cc index 1501b5262..a358a5e01 100644 --- a/src/TheorEval.cc +++ b/src/TheorEval.cc @@ -549,11 +549,6 @@ TheorEval::Evaluate(valarray<double> &vte ) { // load all arguments int narg = it->narg; - for(int arg = 0; arg < narg; arg++) - { - //it++; - //stk.push(*(it->val)); - } std::valarray<double> x0 = stk.top(); stk.pop(); int nsections = (it->narg - 1) / 2; -- GitLab