From c089719032a2d4263092da594abe6dd08e83c727 Mon Sep 17 00:00:00 2001 From: vtavolar Date: Thu, 9 Jun 2016 15:10:23 +0200 Subject: [PATCH] use result of fit at mh=125 to constrain sigmas of gaussians at other masses --- Signal/src/InitialFit.cc | 113 ++++++++++++++++++++++++++++++++++----- 1 file changed, 99 insertions(+), 14 deletions(-) diff --git a/Signal/src/InitialFit.cc b/Signal/src/InitialFit.cc index 2bd3ce15..b851b547 100644 --- a/Signal/src/InitialFit.cc +++ b/Signal/src/InitialFit.cc @@ -115,7 +115,10 @@ void InitialFit::loadPriorConstraints(string filename, float constraintValue){ ifstream datfile; datfile.open(filename.c_str()); - if (datfile.fail()) return; + if (datfile.fail()){ + std::cout<<"loadPriorCostraints FAILED: no such file as "<=2 ? + fitRes125 = fitModel125->fitTo(*data125,NumCPU(ncpu),RooFit::Minimizer("Minuit","minimize"),SumW2Error(true),Save(true),PrintLevel(-1)) : + fitRes125 = fitModel125->fitTo(*data125,NumCPU(ncpu),RooFit::Minimizer("Minuit","minimize"),SumW2Error(true),Save(true),PrintLevel(-1),PrintEvalErrors(-1)); + fitResults.insert(pair(mh,fitRes125)); + mass->setBins(160); //return to default + + std::cout<<"PRINT 125 MODEL FIT RESULT"<floatParsFinal().Print(); for (unsigned int i=0; iPrint(); + RooArgSet* formulaMean = nextg->getParameters(*mass); + std::cout<<"Print formulamean:"<Print(); + for(int ng=0; ngfind(Form("dm_mh%d_g%d",mh,ng )); +// if(dm!=NULL){ +// dm->Print(); +// } + RooRealVar* sigma = (RooRealVar*)formulaMean->find(Form("sigma_mh%d_g%d",mh,ng )); + if(sigma!=NULL){ + sigma->Print(); + sigma->setVal( ((RooRealVar*)fitRes125->floatParsFinal().find( Form("sigma_mh125_g%d",ng ) ))->getVal() ); + sigma->setRange( ((RooRealVar*)fitRes125->floatParsFinal().find( Form("sigma_mh125_g%d",ng ) ))->getVal() - n_sigma_constraint*(((RooRealVar*)fitRes125->floatParsFinal().find( Form("sigma_mh125_g%d",ng ) ))->getAsymErrorLo()), ((RooRealVar*)fitRes125->floatParsFinal().find( Form("sigma_mh125_g%d",ng ) ))->getVal() + n_sigma_constraint*(((RooRealVar*)fitRes125->floatParsFinal().find( Form("sigma_mh125_g%d",ng ) ))->getAsymErrorHi()) ); + sigma->Print(); + } + else{ + std::cout<<"Constraints set on sigmas of "<getComponents(); +// TIterator* iterFormula = actualvars->createIterator(); +// RooAbsReal* nextVar = (RooAbsReal*)iterFormula->Next(); +// while(nextVar){ +// nextVar->Print(); +// nextVar = (RooAbsReal*)iterFormula->Next(); +// +// } +// nextg = (RooGaussian*)iter->Next(); +// } //RooDataSet *data = datasets[mh]; RooAbsData *data; if (binnedFit_){ - data = datasets[mh]->binnedClone(); + data = datasets[mh]->binnedClone(); } else { data = datasets[mh]; } - // help when dataset has no entries - if (data->sumEntries()<1.e-5) { - mass->setVal(mh); - data->add(RooArgSet(*mass),1.e-5); - } + // help when dataset has no entries + if (data->sumEntries()<1.e-5) { + mass->setVal(mh); + data->add(RooArgSet(*mass),1.e-5); + } //fitModel->Print(); - //data->Print(); + //data->Print(); RooFitResult *fitRes; mass->setBins(bins_); verbosity_ >=3 ? fitRes = fitModel->fitTo(*data,NumCPU(ncpu),RooFit::Minimizer("Minuit","minimize"),SumW2Error(true),Save(true)) : verbosity_ >=2 ? - fitRes = fitModel->fitTo(*data,NumCPU(ncpu),RooFit::Minimizer("Minuit","minimize"),SumW2Error(true),Save(true),PrintLevel(-1)) : - fitRes = fitModel->fitTo(*data,NumCPU(ncpu),RooFit::Minimizer("Minuit","minimize"),SumW2Error(true),Save(true),PrintLevel(-1),PrintEvalErrors(-1)); - fitResults.insert(pair(mh,fitRes)); - mass->setBins(160); //return to default + fitRes = fitModel->fitTo(*data,NumCPU(ncpu),RooFit::Minimizer("Minuit","minimize"),SumW2Error(true),Save(true),PrintLevel(-1)) : + fitRes = fitModel->fitTo(*data,NumCPU(ncpu),RooFit::Minimizer("Minuit","minimize"),SumW2Error(true),Save(true),PrintLevel(-1),PrintEvalErrors(-1)); + fitResults.insert(pair(mh,fitRes)); + mass->setBins(160); //return to default } } @@ -225,7 +309,7 @@ void InitialFit::setFitParams(std::map >& void InitialFit::plotFits(string name, string rvwv){ - + std::cout<<"Plotting InitalFit"<frame(Range(mhLow_-10,mhHigh_+10)); TPaveText *pt = new TPaveText(.65,.6,.97,.95,"NDC"); @@ -259,4 +343,5 @@ void InitialFit::plotFits(string name, string rvwv){ canv->Print(Form("%s.png",name.c_str())); mass->setBins(160); //return to default delete canv; + std::cout<<"Plotted InitalFit"<