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

make use of the ErrLogger

parent 7a04ebec
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,7 @@ TARGET_LINK_LIBRARIES (${EXECUTABLENAME}
${Minuit2_LIBRARIES}
${ROOT_LIBRARIES}
qft++
ErrLogger
)
INSTALL ( TARGETS ${EXECUTABLENAME} DESTINATION bin/${EXECUTABLENAME})
......
......@@ -5,7 +5,7 @@
#include "Examples/qft++/EtacToa1320pi0Fcn.hh"
#include "Examples/qft++/EtacToa1320pi0Data.hh"
#include "Examples/qft++/EtacToa1320pi0fit.hh"
#include "ErrLogger/ErrLineLog.hh"
#include <cassert>
using namespace ROOT::Minuit2;
......@@ -13,10 +13,8 @@ using namespace ROOT::Minuit2;
EtacToa1320pi0Fcn::EtacToa1320pi0Fcn(EtacToa1320pi0fit* etacToa1320pi0fit) :
_etacToa1320pi0fit(etacToa1320pi0fit)
{
if (0==_etacToa1320pi0fit){
std::cout << "EtacToa1320pi0fit pointer is 0 !!!!";
assert(0);
}
if (0==_etacToa1320pi0fit) ErrMsg(fatal) << "EtacToa1320pi0fit pointer is 0 !!!!" << endmsg;
}
EtacToa1320pi0Fcn::~EtacToa1320pi0Fcn()
......@@ -30,12 +28,12 @@ double EtacToa1320pi0Fcn::operator()(const std::vector<double>& par) const
double result=_etacToa1320pi0fit->calcLogLh(theFitParmValTmp);
std::cout << "InterMassFit= " << theFitParmValTmp.a1320Mass
<< " InterWidthFit= " << theFitParmValTmp.a1320Width
<< " spin0= " << theFitParmValTmp.cont0spin
<< " spin1= " << theFitParmValTmp.cont1spin
<< " spin2= " << theFitParmValTmp.cont2spin
<< " logLH= " << result << std::endl;
ErrMsg(debugging) << "InterMassFit= " << theFitParmValTmp.a1320Mass
<< " InterWidthFit= " << theFitParmValTmp.a1320Width
<< " spin0= " << theFitParmValTmp.cont0spin
<< " spin1= " << theFitParmValTmp.cont1spin
<< " spin2= " << theFitParmValTmp.cont2spin
<< " logLH= " << result << endmsg;
return result;
}
......
......@@ -3,6 +3,7 @@
#include <string>
#include "Examples/qft++/EtacToa1320pi0fit.hh"
#include "ErrLogger/ErrLineLog.hh"
#include "TFile.h"
#include "TH1F.h"
#include "TH2F.h"
......@@ -30,10 +31,9 @@ EtacToa1320pi0fit::EtacToa1320pi0fit(int kindOfData) :
if (kindOfData==0) _dataPath=theSourcePath+std::string("/Examples/qft++/data/dataEtacToA0Pi_100Mgev.dat");
else if (kindOfData==2) _dataPath=theSourcePath+std::string("/Examples/qft++/data/dataSpin2100MgevNew.dat");
else{
std::cout <<"this kind of data: " << kindOfData << " is not supported!!!!\n"
ErrMsg(fatal) <<"this kind of data: " << kindOfData << " is not supported!!!!\n"
<<"initialze EtacToa1320pi0fit either with 0 or with 2 !!!!"
<< std::endl;
assert(0);
<< endmsg;
}
initRootStuff();
......@@ -93,7 +93,7 @@ void EtacToa1320pi0fit::initRootStuff()
void EtacToa1320pi0fit::read4Vecs(std::string& path, int nEvts, std::vector<evt4Vec>& the4Vecs)
{
std::cout << "calculate 4Vecs and amplitudes for " << path << std::endl;
ErrMsg(routine) << "calculate 4Vecs and amplitudes for " << path << endmsg;
std::ifstream inputStream(path.c_str(), std::ios::in);
if (!inputStream.good())
......@@ -105,7 +105,7 @@ void EtacToa1320pi0fit::read4Vecs(std::string& path, int nEvts, std::vector<evt
int counter=0;
while (!inputStream.eof() && counter<nEvts )
{
if ( counter%1000 == 0 ) std::cout << "event " << counter << std::endl;
if ( counter%1000 == 0 ) ErrMsg(routine) << "event " << counter << endmsg;
Vector4<double> pi14V,pi24V,eta4V; // 4-momenta
get4Vecs(inputStream, pi14V);
get4Vecs(inputStream, pi24V);
......@@ -274,7 +274,7 @@ double EtacToa1320pi0fit::calcLogLh(const fitParamVal& theParamVal)
if (intensity>0.) logLH_data+=log10(intensity);
}
std::cout << "logLH_data= " << logLH_data << std::endl;
ErrMsg(debugging) << "logLH_data= " << logLH_data << endmsg;
double LH_mc=0.;
......@@ -283,7 +283,7 @@ double EtacToa1320pi0fit::calcLogLh(const fitParamVal& theParamVal)
double intensity=calcIntensityCache(_mc4Vecs[it], theParamVal);
LH_mc+=intensity;
}
std::cout << "LH_mc= " << LH_mc << std::endl;
ErrMsg(debugging) << "LH_mc= " << LH_mc << endmsg;
double logLH_mc_Norm=0.;
if (LH_mc>0.) logLH_mc_Norm=log10(LH_mc/_mc4Vecs.size());
......@@ -334,9 +334,9 @@ bool EtacToa1320pi0fit::fillFitHists(const fitParamVal& fitParamVal)
{
if(_fitHistsFilled)
{
std::cout <<"Not possible to fill the histos with fit results!!!!\n"
<<"They are already filled!!!!"
<<std::endl;
ErrMsg(warning) <<"Not possible to fill the histos with fit results!!!!\n"
<<"They are already filled!!!!"
<<endmsg;
return false;
}
......@@ -350,9 +350,11 @@ bool EtacToa1320pi0fit::fillFitHists(const fitParamVal& fitParamVal)
//normalize fitted histos
double integralData=_invpipiDataHist->Integral();
std::cout << "integralData= " << integralData << std::endl;
ErrMsg(debugging) << "integralData= " << integralData << endmsg;
double integralFittedMc=_invpipiFittedHist->Integral();
std::cout << "integralFittedMc= " << integralFittedMc << std::endl;
ErrMsg(debugging) << "integralFittedMc= " << integralFittedMc << endmsg;
_invpipiFittedHist->Scale(integralData/integralFittedMc);
_invpietaFittedHist->Scale(integralData/integralFittedMc);
_dalitzFittedHist->Scale(integralData/integralFittedMc);
......
......@@ -6,6 +6,7 @@
#include "Examples/qft++/EtacToa1320pi0Data.hh"
#include "Examples/qft++/EtacToa1320pi0fit.hh"
#include "Examples/qft++/EtacToa1320pi0Fcn.hh"
#include "ErrLogger/ErrLineLog.hh"
#include "Minuit2/MnUserParameters.h"
#include "Minuit2/MnMigrad.h"
#include "Minuit2/FunctionMinimum.h"
......@@ -27,12 +28,16 @@ int main(int __argc,char *__argv[]){
<< "In addition the mass and width of the intermediate resonance will be fitted with a simple Breit-Wigner\n"
<< "To start the application with data containing an intermediate resonance with Spin=0 and mass 0.98 GeV, type: ./EtacToa1320pi0fitApp -d 0\n"
<< "To start the application with data containing an intermediate resonance with Spin=2 and mass 1.32 GeV, type: ./EtacToa1320pi0fitApp -d 2\n"
<< "with the flag -msg <errorLogMode> you can choose the mode for the error logger\n"
<< "i.e. with './EtacToa1320pi0fitApp -d 2 -msg debugging' you start the fit with Spin=2 in the debugging mode for the error logger\n"
<< std::endl;
return 0;
}
int optind=1;
std::string dataSpinStr="";
std::string msgModeStr="default";
// decode arguments
while ((optind < __argc) && (__argv[optind][0]=='-')) {
......@@ -41,37 +46,55 @@ int main(int __argc,char *__argv[]){
optind++;
dataSpinStr = __argv[optind];
}
if (sw=="-msg"){
optind++;
msgModeStr = __argv[optind];
}
else{
cout << "Unknown switch: "
<< __argv[optind] << endl;
ErrMsg(warning) << "Unknown switch: "
<< __argv[optind] << endmsg;
optind++;
}
}
ErrLineLog* myLogger=0;
if(msgModeStr == "debugging") myLogger= new ErrLineLog(ErrLog::debugging);
else if(msgModeStr == "trace") myLogger= new ErrLineLog(ErrLog::trace);
else if(msgModeStr == "routine") myLogger= new ErrLineLog(ErrLog::routine);
else if(msgModeStr == "warning") myLogger= new ErrLineLog(ErrLog::warning);
else if(msgModeStr == "error") myLogger= new ErrLineLog(ErrLog::error);
else {
myLogger= new ErrLineLog(ErrLog::debugging);
ErrMsg(warning) << "ErrorLogger not (properly) set -> Use mode 'ErrLog::debugging' " << endmsg;
}
std::stringstream dataSpinStrStr(dataSpinStr);
int dataSpin=2;
dataSpinStrStr >> dataSpin ;
std::cout << "dataSpin: " << dataSpin << std::endl;
ErrMsg(routine) << "dataSpin: " << dataSpin << endmsg;
EtacToa1320pi0fit* etacToa1320pi0fit=new EtacToa1320pi0fit(dataSpin);
EtacToa1320pi0Fcn fcn(etacToa1320pi0fit);
MnUserParameters upar;
if (! etacToa1320pi0fit->initFitParameters(upar)) assert(0);
if (! etacToa1320pi0fit->initFitParameters(upar)){
ErrMsg(fatal) << "initialization of the MnUserParameters failed in etacToa1320pi0fit->initFitParameters(upar)" << endmsg;
}
MnMigrad migrad(fcn, upar);
std::cout<<"start migrad "<<std::endl;
ErrMsg(routine) <<"start migrad "<< endmsg;
FunctionMinimum min = migrad();
if(!min.IsValid()) {
//try with higher strategy
std::cout<<"FM is invalid, try with strategy = 2."<<std::endl;
ErrMsg(routine) <<"FM is invalid, try with strategy = 2."<< endmsg;
MnMigrad migrad2(fcn, min.UserState(), MnStrategy(2));
min = migrad2();
}
// std::cout << "minimum: " << min << std::endl;
std::cout << "migrad.Fval(): " << min.Fval() << std::endl;
ErrMsg(routine) << "migrad.Fval(): " << min.Fval() << endmsg;
// std::cout<<"start Minos"<<std::endl;
// MnMinos Minos(fcn, min);
......@@ -95,7 +118,7 @@ int main(int __argc,char *__argv[]){
theFitResult.cont2spin=min.UserState().Value("spin2");
etacToa1320pi0fit->fillFitHists(theFitResult);
delete etacToa1320pi0fit;
if (0!=myLogger) delete myLogger;
return 0;
}
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