Skip to content
Snippets Groups Projects
Commit b2e15278 authored by Bertram Kopf's avatar Bertram Kopf
Browse files

introduced dependencies of fit parameter

parent 77d04978
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,7 @@
#include "MinFunctions/MinuitMinimizer.hh"
#include "FitParams/AbsPawianParameters.hh"
#include "FitParams/ParamDepHandler.hh"
#include "pbarpUtils/PbarpChannelEnv.hh"
#include "epemUtils/EpemChannelEnv.hh"
......@@ -384,6 +385,11 @@ std::shared_ptr<AbsPawianParameters> AppBase::streamPawianParams(){
void AppBase::fixParams(std::shared_ptr<AbsPawianParameters> upar, std::vector<std::string> fixedParams){
// Evaluate parameter dependencies and add fixes
ParamDepHandler::instance()->Fill(GlobalEnv::instance()->parser()->parameterDependencies(), upar);
std::vector<std::string> dependentParameters = ParamDepHandler::instance()->DependentParameterNames();
fixedParams.insert(fixedParams.end(), dependentParameters.begin(), dependentParameters.end());
// Always fix the primary channel's scaling parameters
// std::string fixedScaleParam = GlobalEnv::instance()->Channel()->Lh()->getChannelScaleParam() + "Other";
std::string fixedScaleParam = GlobalEnv::instance()->Channel()->Lh()->getChannelScaleParam();
......
......@@ -128,6 +128,7 @@ ParserBase::ParserBase(int argc,char **argv)
("verbose",po::value<bool>(&_verbose)->default_value(true), "Determines whether additional information should be emitted")
("enableHyp",po::value< vector<string> >(&_enabledHyps), "enable hypotheses")
("mnParFix",po::value< vector<string> >(&_mnParFixs), "minuit parameters can be fixed here")
("parameterDependency",po::value< vector<string> >(&_parameterDependencies), "parameter dependencies")
("finalStateParticle",po::value< vector<string> >(&_finalStateParticles), "name of final state particles")
("decay",po::value< vector<string> >(&_decaySystem), "decay: mother and pair of decay particles")
("addDynamics",po::value< vector<string> >(&_dynamics), "add dynamics/line shape for resonances")
......@@ -272,7 +273,11 @@ bool ParserBase::parseCommandLine(int argc, char **argv)
std::cout << "minuit parameter\t" << (*it) << "\t fixed\n";
}
std::cout << std::endl;
for (it=_parameterDependencies.begin(); it!=_parameterDependencies.end();++it){
std::cout << "parameter dependencies:\t" << (*it) << "\n";
}
std::cout << std::endl;
std::cout << "the final state particles are:" << std::endl;
// std::vector<std::string>::const_iterator it;
for (it=_finalStateParticles.begin(); it!=_finalStateParticles.end();++it){
......
......@@ -67,6 +67,7 @@ public:
const std::string startHypo() const {return _startHypo;}
const std::string mode() const {return _mode;}
const std::vector<std::string>& fixedParams() const { return _mnParFixs; }
const std::vector<std::string>& parameterDependencies() const { return _parameterDependencies; }
const int noOfThreads() const {return _noOfThreads;}
const int noOfClients() const {return _noOfClients;}
const int serverPort() const {return _serverPort;}
......@@ -125,6 +126,7 @@ protected:
std::string _clientNumberWeights;
std::vector<std::string> _enabledHyps;
std::vector<std::string> _mnParFixs;
std::vector<std::string> _parameterDependencies;
bool _verbose;
int _noOfThreads;
int _noOfClients;
......
//************************************************************************//
// //
// Copyright 2014 Bertram Kopf (bertram@ep1.rub.de) //
// Julian Pychy (julian@ep1.rub.de) //
// - Ruhr-Universität Bochum //
// //
// This file is part of Pawian. //
// //
// Pawian 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 3 of the License, or //
// (at your option) any later version. //
// //
// Pawian 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 Pawian. If not, see <http://www.gnu.org/licenses/>. //
// //
//************************************************************************//
// Copyright 2014 Julian Pychy
#include "FitParams/ParamDep.hh"
#include "FitParams/AbsPawianParameters.hh"
void ParamDep::Fill(std::string targetParameter, std::istringstream& configLine,
std::shared_ptr<AbsPawianParameters> params){
_idTarget = params->Index(targetParameter);
FillDerived(configLine, params);
}
//************************************************************************//
// //
// Copyright 2014 Bertram Kopf (bertram@ep1.rub.de) //
// Julian Pychy (julian@ep1.rub.de) //
// - Ruhr-Universität Bochum //
// //
// This file is part of Pawian. //
// //
// Pawian 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 3 of the License, or //
// (at your option) any later version. //
// //
// Pawian 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 Pawian. If not, see <http://www.gnu.org/licenses/>. //
// //
//************************************************************************//
// ParameterDependency class definition file. -*- C++ -*-
// Copyright 2014 Julian Pychy
#pragma once
#include <vector>
#include <string>
#include <sstream>
#include <memory>
class AbsPawianParameters;
class ParamDep
{
public:
void Fill(std::string targetParameter, std::istringstream& configLine, std::shared_ptr<AbsPawianParameters> params);
virtual void FillDerived(std::istringstream& configLine, std::shared_ptr<AbsPawianParameters> params) = 0;
virtual void Apply(std::vector<double>& par) = 0;
protected:
int _idTarget;
};
//************************************************************************//
// //
// Copyright 2014 Bertram Kopf (bertram@ep1.rub.de) //
// Julian Pychy (julian@ep1.rub.de) //
// - Ruhr-Universität Bochum //
// //
// This file is part of Pawian. //
// //
// Pawian 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 3 of the License, or //
// (at your option) any later version. //
// //
// Pawian 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 Pawian. If not, see <http://www.gnu.org/licenses/>. //
// //
//************************************************************************//
// Copyright 2014 Julian Pychy
#include "FitParams/ParamDepEqual.hh"
#include "FitParams/AbsPawianParameters.hh"
void ParamDepEqual::FillDerived(std::istringstream& configLine,
std::shared_ptr<AbsPawianParameters> params){
std::string parNameRef;
configLine >> parNameRef;
_idRef = params->Index(parNameRef);
}
void ParamDepEqual::Apply(std::vector<double>& par){
par.at(_idTarget) = par.at(_idRef);
}
//************************************************************************//
// //
// Copyright 2014 Bertram Kopf (bertram@ep1.rub.de) //
// Julian Pychy (julian@ep1.rub.de) //
// - Ruhr-Universität Bochum //
// //
// This file is part of Pawian. //
// //
// Pawian 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 3 of the License, or //
// (at your option) any later version. //
// //
// Pawian 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 Pawian. If not, see <http://www.gnu.org/licenses/>. //
// //
//************************************************************************//
// ParamDepEqual class definition file. -*- C++ -*-
// Copyright 2014 Julian Pychy
#include "FitParams/ParamDep.hh"
#include <vector>
#include <string>
#include <memory>
#include <sstream>
class AbsPawianParameters;
class ParamDepEqual : public ParamDep
{
public:
virtual void FillDerived(std::istringstream& configLine,
std::shared_ptr<AbsPawianParameters> params);
virtual void Apply(std::vector<double>& par);
private:
int _idRef;
};
//************************************************************************//
// //
// Copyright 2014 Bertram Kopf (bertram@ep1.rub.de) //
// Julian Pychy (julian@ep1.rub.de) //
// - Ruhr-Universität Bochum //
// //
// This file is part of Pawian. //
// //
// Pawian 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 3 of the License, or //
// (at your option) any later version. //
// //
// Pawian 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 Pawian. If not, see <http://www.gnu.org/licenses/>. //
// //
//************************************************************************//
// Copyright 2014 Julian Pychy
#include <iostream>
#include "FitParams/ParamDepGFactorToFixFullWidth.hh"
#include "FitParams/AbsPawianParameters.hh"
#include "ErrLogger/ErrLogger.hh"
#include "qft++/relativistic-quantum-mechanics/Utils.hh"
void ParamDepGFactorToFixFullWidth::FillDerived(std::istringstream& configLine,
std::shared_ptr<AbsPawianParameters> params){
configLine >> _targetFullWidth;
std::string massParamName;
configLine >> massParamName;
_targetChannelData.massParamId = params->Index(massParamName);
_targetChannelData.gParamId = _idTarget;
configLine >> _targetChannelData.m1 >> _targetChannelData.m2;
int numRefChannels;
configLine >> numRefChannels;
for(int i=1; i<=numRefChannels; i++){
ChannelData newChannelData;
configLine >> massParamName;
newChannelData.massParamId = params->Index(massParamName);
std::string gParamName;
configLine >> gParamName;
newChannelData.gParamId = params->Index(gParamName);
configLine >> newChannelData.m1 >> newChannelData.m2;
_refChannelData.push_back(newChannelData);
}
}
void ParamDepGFactorToFixFullWidth::Apply(std::vector<double>& par){
double result = 0;
double partialWidthSum = 0;
for(auto it = _refChannelData.begin(); it!= _refChannelData.end(); ++it){
// Gamma_i = g*g*rho(m,m1,m2)/m
double m = par.at((*it).massParamId);
partialWidthSum += (par.at((*it).gParamId) * par.at((*it).gParamId) * phaseSpaceFac(m, (*it).m1, (*it).m2) / m).real();
}
double targetPartialWidth = _targetFullWidth - partialWidthSum;
double mTarget = par.at(_targetChannelData.massParamId);
result = (mTarget / phaseSpaceFac(mTarget, _targetChannelData.m1, _targetChannelData.m2)).real() * targetPartialWidth;
if((targetPartialWidth < 0) || (result < 0)){
Alert << "Invalid g-Factor value! "
<< "Partial width sum = " << partialWidthSum
<< " dependent width = " << targetPartialWidth
<< " Mass = " << mTarget
<< " g^2 = " << result << endmsg;
for(auto it = _refChannelData.begin(); it!= _refChannelData.end(); ++it){
Alert << "Independent Channel: g = " << par.at((*it).gParamId) << " m = " << par.at((*it).massParamId) << endmsg;
}
exit(0);
}
par.at(_targetChannelData.gParamId) = sqrt(result);
}
//************************************************************************//
// //
// Copyright 2014 Bertram Kopf (bertram@ep1.rub.de) //
// Julian Pychy (julian@ep1.rub.de) //
// - Ruhr-Universität Bochum //
// //
// This file is part of Pawian. //
// //
// Pawian 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 3 of the License, or //
// (at your option) any later version. //
// //
// Pawian 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 Pawian. If not, see <http://www.gnu.org/licenses/>. //
// //
//************************************************************************//
// ParamDepGFactorToFixFullWidth class definition file. -*- C++ -*-
// Copyright 2014 Julian Pychy
#include "FitParams/ParamDep.hh"
#include <vector>
#include <string>
#include <memory>
#include <sstream>
class AbsPawianParameters;
struct ChannelData
{
int massParamId;
int gParamId;
double m1;
double m2;
};
class ParamDepGFactorToFixFullWidth : public ParamDep
{
public:
virtual void FillDerived(std::istringstream& configLine,
std::shared_ptr<AbsPawianParameters> params);
virtual void Apply(std::vector<double>& par);
private:
ChannelData _targetChannelData;
std::vector<ChannelData> _refChannelData;
double _targetFullWidth;
};
//************************************************************************//
// //
// Copyright 2013 Bertram Kopf (bertram@ep1.rub.de) //
// Julian Pychy (julian@ep1.rub.de) //
// - Ruhr-Universität Bochum //
// //
// This file is part of Pawian. //
// //
// Pawian 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 3 of the License, or //
// (at your option) any later version. //
// //
// Pawian 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 Pawian. If not, see <http://www.gnu.org/licenses/>. //
// //
//************************************************************************//
#include "FitParams/ParamDepHandler.hh"
#include "FitParams/ParamDepEqual.hh"
#include "FitParams/ParamDepGFactorToFixFullWidth.hh"
#include "ErrLogger/ErrLogger.hh"
ParamDepHandler* ParamDepHandler::_instance = 0;
ParamDepHandler* ParamDepHandler::instance(){
if(_instance == 0){
_instance = new ParamDepHandler();
}
return _instance;
}
void ParamDepHandler::Fill(const std::vector<std::string>& configLines,
std::shared_ptr<AbsPawianParameters> params){
for(auto it = configLines.begin(); it!=configLines.end(); ++it){
std::istringstream currentStream(*it);
std::shared_ptr<ParamDep> newDependency;
std::string targetParameter;
std::string type;
currentStream >> targetParameter >> type;
if(type == "equals"){
newDependency = std::shared_ptr<ParamDep>(new ParamDepEqual);
}
else if(type == "gFactorToFixFullWidth"){
newDependency = std::shared_ptr<ParamDep>(new ParamDepGFactorToFixFullWidth);
}
else{
Alert << "Dependency type not found: " << type << endmsg;
exit(0);
}
Info << "Adding parameter dependency for " << targetParameter << " type "
<< type << " arguments " << currentStream.str() << endmsg;
newDependency->Fill(targetParameter, currentStream, params);
_dependentParameterNames.push_back(targetParameter);
_dependencies.push_back(newDependency);
}
}
void ParamDepHandler::ApplyDependencies(std::vector<double>& par){
for(auto it = _dependencies.begin(); it!= _dependencies.end(); ++it){
(*it)->Apply(par);
}
}
//************************************************************************//
// //
// Copyright 2014 Bertram Kopf (bertram@ep1.rub.de) //
// Julian Pychy (julian@ep1.rub.de) //
// - Ruhr-Universität Bochum //
// //
// This file is part of Pawian. //
// //
// Pawian 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 3 of the License, or //
// (at your option) any later version. //
// //
// Pawian 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 Pawian. If not, see <http://www.gnu.org/licenses/>. //
// //
//************************************************************************//
// ParamDepHandler class definition file. -*- C++ -*-
// Copyright 2014 Julian Pychy
#include <vector>
#include <string>
#include <memory>
#include <sstream>
#include "FitParams/ParamDep.hh"
#include "FitParams/AbsPawianParameters.hh"
class ParamDepHandler
{
public:
static ParamDepHandler* instance();
void Fill(const std::vector<std::string>& configLines, std::shared_ptr<AbsPawianParameters> params);
void ApplyDependencies(std::vector<double>& par);
const std::vector<std::string>& DependentParameterNames() const {return _dependentParameterNames;}
protected:
ParamDepHandler(){}
private:
static ParamDepHandler* _instance;
std::vector<std::shared_ptr<ParamDep> > _dependencies;
std::vector<std::string> _dependentParameterNames;
};
......@@ -27,15 +27,12 @@
#include <boost/timer/timer.hpp>
#include "MinFunctions/PwaFcnBase.hh"
#include "Minuit2/MnUserParameters.h"
#include "FitParams/ParamDepHandler.hh"
#include "PwaUtils/AbsLh.hh"
#include "PwaUtils/GlobalEnv.hh"
#include "ErrLogger/ErrLogger.hh"
using namespace ROOT::Minuit2;
PwaFcnBase::PwaFcnBase() :
AbsFcn()
{
......@@ -49,15 +46,13 @@ PwaFcnBase::~PwaFcnBase()
double PwaFcnBase::operator()(const std::vector<double>& par) const
{
double result=0;
_currentPawianParms->SetAllValues(par);
// fitParCol theFitParmValTmp=_defaultFitValParms;
//theFitParmValTmp=_defaultFitValParms;
// GlobalEnv::instance()->fitParColBase()->getFitParamVal(par, theFitParmValTmp);
std::vector<double> modifiedParams = par;
ParamDepHandler::instance()->ApplyDependencies(modifiedParams);
// result = GlobalEnv::instance()->Channel()->Lh()->calcLogLh(theFitParmValTmp);
_currentPawianParms->SetAllValues(modifiedParams);
result = GlobalEnv::instance()->Channel()->Lh()->calcLogLh(_currentPawianParms);
Info << "current LH = " << std::setprecision(16) << result << endmsg;
_fcnCounter++;
if(_fcnCounter%20 == 0) printTimer();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment