From 0af2b05aa5560c59f721d73666194a27e9b6bc94 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 23 Apr 2018 01:54:06 +0200 Subject: [PATCH 1/2] implemented option for kfactor to be free parameter --- reactions/KFactor/include/ReactionKFactor.h | 2 ++ reactions/KFactor/src/ReactionKFactor.cc | 24 +++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/reactions/KFactor/include/ReactionKFactor.h b/reactions/KFactor/include/ReactionKFactor.h index bf5b5122e..59e1726b8 100644 --- a/reactions/KFactor/include/ReactionKFactor.h +++ b/reactions/KFactor/include/ReactionKFactor.h @@ -27,10 +27,12 @@ class ReactionKFactor : public ReactionTheory virtual string getReactionName() const { return "KFactor" ;}; int initAtStart(const string &); virtual void setDatasetParameters( int dataSetID, map<string,string> pars, map<string,double> parsDataset) override ; + virtual void initAtIteration() override; virtual int compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err); protected: virtual int parseOptions(){ return 0;}; private: map<int, std::vector<double> > _values; + map<int, std::pair<std::string, double> > _parameterNames; }; diff --git a/reactions/KFactor/src/ReactionKFactor.cc b/reactions/KFactor/src/ReactionKFactor.cc index 34266df08..2d8d5cd38 100644 --- a/reactions/KFactor/src/ReactionKFactor.cc +++ b/reactions/KFactor/src/ReactionKFactor.cc @@ -107,13 +107,33 @@ void ReactionKFactor::setDatasetParameters(int dataSetID, map<string,string> par _values[dataSetID].resize(vals->size()); _values[dataSetID].assign(std::begin(*vals), std::end(*vals)); } + // 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); + } else - hf_errlog(17102804, "F: either FileName or DataColumn must be provided for KFactor"); + 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); } + // Main function to compute results at an iteration int ReactionKFactor::compute(int dataSetID, valarray<double> &val, map<string, valarray<double> > &err) { - val = std::valarray<double>(_values[dataSetID].data(), _values[dataSetID].size()); + const auto& it = _parameterNames.find(dataSetID); + if(it != _parameterNames.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); + } + else + // kfactor is constant value read in setDatasetParameters() + val = std::valarray<double>(_values[dataSetID].data(), _values[dataSetID].size()); return 0; } -- GitLab From 553cfaae907b61884670e380d7fb98c0242af411 Mon Sep 17 00:00:00 2001 From: Oleksandr Zenaiev <oleksandr.zenaiev@cern.ch> Date: Mon, 23 Apr 2018 01:55:21 +0200 Subject: [PATCH 2/2] increased NIdMax 5 -> 6 (should usee ~1.5M more memory, needed for 3D cross sections) --- src/prep_corr.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prep_corr.f b/src/prep_corr.f index 89ccd86f5..ebd125b4c 100644 --- a/src/prep_corr.f +++ b/src/prep_corr.f @@ -13,7 +13,7 @@ integer k,i,j,b,m,n,NCorr,NIdColumns1,NIdColumns2,NIdMax,NCorrMax - parameter (NIdMax = 5) + parameter (NIdMax = 6) character *80 Name1 character *80 Name2 character *80 MatrixType -- GitLab