83#define NaN std::numeric_limits<double>::quiet_NaN()
92template <
typename Test,
template <
typename...>
class Ref>
96template <
template <
typename...>
class Ref,
typename... Args>
107template <
class MatrixT>
108inline size_t size(
const MatrixT &matrix);
118template <
class MatrixT>
121 if (!stream.good()) {
124 for (
size_t i = 0; i <
size(matrix); ++i) {
125 for (
size_t j = 0; j <
size(matrix); ++j) {
127 stream << std::setprecision(RooFit::SuperFloatPrecision::digits10) << matrix(i, j) <<
"\t";
129 stream << matrix(i, j) <<
"\t";
139template <
class MatrixT>
142 std::ofstream of(fname);
144 cerr <<
"unable to read file '" << fname <<
"'!" << std::endl;
153#pragma GCC diagnostic push
154#pragma GCC diagnostic ignored "-Wshadow"
155#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
156#include <boost/numeric/ublas/io.hpp>
157#include <boost/numeric/ublas/lu.hpp>
158#include <boost/numeric/ublas/matrix.hpp>
159#include <boost/numeric/ublas/matrix_expression.hpp>
160#include <boost/numeric/ublas/symmetric.hpp>
161#include <boost/numeric/ublas/triangular.hpp>
162#include <boost/operators.hpp>
164#pragma GCC diagnostic pop
166typedef boost::numeric::ublas::matrix<RooFit::SuperFloat>
Matrix;
173 for (
size_t i = 0; i < mat.size1(); ++i) {
174 for (
size_t j = 0; j < mat.size2(); ++j) {
175 std::cout << std::setprecision(RooFit::SuperFloatPrecision::digits10) << mat(i, j) <<
" ,\t";
177 std::cout << std::endl;
185inline size_t size<Matrix>(
const Matrix &matrix)
187 return matrix.size1();
195 return boost::numeric::ublas::identity_matrix<RooFit::SuperFloat>(
n);
205 for (
size_t i = 0; i <
n; ++i) {
206 for (
size_t j = 0; j <
n; ++j) {
207 mat(i, j) =
double(in(i, j));
220 for (
size_t i = 0; i <
n; ++i) {
221 for (
size_t j = 0; j <
n; ++j) {
222 mat(i, j) =
double(in(i, j));
234 return prod(
m, otherM);
242 boost::numeric::ublas::permutation_matrix<size_t> pm(
size(matrix));
246 int res = lu_factorize(lu, pm);
248 std::stringstream ss;
253 lu_substitute(lu, pm, inverse);
254 }
catch (boost::numeric::ublas::internal_logic &error) {
308 bool status = lu.
Invert(inverse);
311 std::cerr <<
" matrix is not invertible!" << std::endl;
314 const size_t n =
size(inverse);
316 for (
size_t i = 0; i <
n; ++i)
317 for (
size_t j = 0; j <
n; ++j)
318 if (
fabs(inverse(i, j)) < 1
e-9)
335typedef std::vector<std::vector<bool>> FeynmanDiagram;
336typedef std::vector<std::vector<int>> MorphFuncPattern;
337typedef std::map<int, std::unique_ptr<RooAbsReal>> FormulaList;
345 retval.ReplaceAll(
"/",
"_");
346 retval.ReplaceAll(
"^",
"");
347 retval.ReplaceAll(
"*",
"X");
348 retval.ReplaceAll(
"[",
"");
349 retval.ReplaceAll(
"]",
"");
357std::string concatNames(
const List &
c,
const char *
sep)
359 std::stringstream ss;
364 ss << itr->GetName();
374template <
class A,
class B>
375inline void assignElement(
A &
a,
const B &
b)
377 a =
static_cast<A>(
b);
382template <
class MatrixT>
383inline MatrixT readMatrixFromStreamT(std::istream &stream)
385 std::vector<std::vector<RooFit::SuperFloat>> matrix;
386 std::vector<RooFit::SuperFloat>
line;
387 while (!stream.eof()) {
388 if (stream.peek() ==
'\n') {
396 while (stream.peek() ==
' ' || stream.peek() ==
'\t') {
399 if (stream.peek() ==
'\n') {
400 matrix.push_back(
line);
404 MatrixT retval(matrix.size(), matrix.size());
405 for (
size_t i = 0; i < matrix.size(); ++i) {
406 if (matrix[i].
size() != matrix.size()) {
407 std::cerr <<
"matrix read from stream doesn't seem to be square!" << std::endl;
409 for (
size_t j = 0; j < matrix[i].size(); ++j) {
410 assignElement(retval(i, j), matrix[i][j]);
419template <
class MatrixT>
420inline MatrixT readMatrixFromFileT(
const char *fname)
422 std::ifstream in(fname);
424 std::cerr <<
"unable to read file '" << fname <<
"'!" << std::endl;
426 MatrixT mat = readMatrixFromStreamT<MatrixT>(in);
435void readValues(std::map<const std::string, T> &myMap,
TH1 *h_pc)
439 for (
int ibx = 1; ibx <= h_pc->
GetNbinsX(); ++ibx) {
444 if (!s_coup.empty()) {
445 myMap[s_coup] =
T(coup_val);
454void setOwnerRecursive(
TFolder *theFolder)
459 for (
auto *subdir : *subdirs) {
460 auto thisfolder =
dynamic_cast<TFolder *
>(subdir);
463 setOwnerRecursive(thisfolder);
476std::unique_ptr<TFolder> readOwningFolderFromFile(
TDirectory *inFile,
const std::string &folderName)
478 std::unique_ptr<TFolder> theFolder(inFile->
Get<
TFolder>(folderName.c_str()));
480 std::cerr <<
"Error: unable to access data from folder '" << folderName <<
"' from file '" << inFile->
GetName()
481 <<
"'!" << std::endl;
484 setOwnerRecursive(theFolder.get());
497template <
class AObjType>
498AObjType *loadFromFileResidentFolder(
TDirectory *inFile,
const std::string &folderName,
const std::string &objName,
499 bool notFoundError =
true)
501 auto folder = readOwningFolderFromFile(inFile, folderName);
505 AObjType *loadedObject =
dynamic_cast<AObjType *
>(folder->FindObject(objName.c_str()));
508 std::stringstream errstr;
509 errstr <<
"Error: unable to retrieve object '" << objName <<
"' from folder '" << folderName
510 <<
"'. contents are:";
511 TIter next(folder->GetListOfFolders()->begin());
514 errstr <<
" " <<
f->GetName();
516 std::cerr << errstr.str() << std::endl;
521 return static_cast<AObjType *
>(
522 loadedObject->Clone());
529void readValues(std::map<const std::string, T> &myMap,
TDirectory *
file,
const std::string &
name,
530 const std::string &key =
"param_card",
bool notFoundError =
true)
532 TH1F *h_pc = loadFromFileResidentFolder<TH1F>(
file,
name, key, notFoundError);
533 readValues(myMap, h_pc);
542void readValues(std::map<
const std::string, std::map<const std::string, T>> &inputParameters,
TDirectory *
f,
543 const std::vector<std::string> &names,
const std::string &key =
"param_card",
bool notFoundError =
true)
545 inputParameters.clear();
548 for (
size_t i = 0; i < names.size(); i++) {
549 const std::string
name(names[i]);
551 readValues(inputParameters[
name],
f,
name, key, notFoundError);
569 std::cerr <<
"could not open file '" <<
filename <<
"'!" << std::endl;
591inline void extractServers(
const RooAbsArg &coupling,
T2 &operators)
594 for (
const auto server : coupling.
servers()) {
595 extractServers(*server, operators);
599 operators.add(coupling);
607inline void extractOperators(
const T1 &couplings,
T2 &operators)
611 for (
auto itr : couplings) {
612 extractServers(*itr, operators);
620inline void extractOperators(
const T1 &
vec,
T2 &operators)
622 for (
const auto &
v :
vec) {
623 extractOperators(
v, operators);
630template <
class T1,
class T2>
631inline void extractCouplings(
const T1 &inCouplings,
T2 &outCouplings)
633 for (
auto itr : inCouplings) {
634 if (!outCouplings.find(itr->GetName())) {
637 outCouplings.add(*itr);
646inline RooAbsArg &get(
T &operators,
const char *
name,
double defaultval = 0)
653 operators.add(*newKappa);
661inline RooAbsArg &get(
T &operators,
const std::string &
name,
double defaultval = 0)
663 return get(operators,
name.c_str(), defaultval);
672 if (!set.find(
name)) {
674 c->setAttribute(
"NewPhysics", isNP);
683inline bool setParam(
RooRealVar *
p,
double val,
bool force)
686 if (val >
p->getMax()) {
690 std::cerr <<
": parameter " <<
p->
GetName() <<
" out of bounds: " << val <<
" > " <<
p->getMax() << std::endl;
693 }
else if (val < p->getMin()) {
697 std::cerr <<
": parameter " <<
p->
GetName() <<
" out of bounds: " << val <<
" < " <<
p->getMin() << std::endl;
710template <
class T1,
class T2>
711inline bool setParams(
const T2 &args,
T1 val)
713 for (
auto itr : args) {
717 setParam(param, val,
true);
726template <
class T1,
class T2>
728setParams(
const std::map<const std::string, T1> &point,
const T2 &args,
bool force =
false,
T1 defaultVal = 0)
731 for (
auto itr : args) {
735 ok = setParam(param, defaultVal, force) && ok;
738 for (
auto paramit : point) {
740 const std::string param(paramit.first);
746 ok = setParam(
p, paramit.second, force) && ok;
756inline bool setParams(
TH1 *hist,
const T &args,
bool force =
false)
760 for (
auto itr : args) {
764 ok = setParam(param, 0., force) && ok;
769 for (
int i = 1; i <= ax->
GetNbins(); ++i) {
787 for (
auto itr : parameters) {
804 bool binningOK =
false;
805 for (
auto sampleit : inputParameters) {
806 const std::string sample(sampleit.first);
807 TH1 *hist = loadFromFileResidentFolder<TH1>(
file, sample, varname,
true);
811 auto it = list_hf.find(sample);
812 if (it != list_hf.end()) {
824 std::vector<double> bins;
825 for (
int i = 1; i <
n + 1; ++i) {
833 TString histname = makeValidName(
Form(
"dh_%s_%s", sample.c_str(),
name));
834 TString funcname = makeValidName(
Form(
"phys_%s_%s", sample.c_str(),
name));
842 list_hf[sample] = idx;
854void collectRooAbsReal(
const char * ,
TDirectory *
file, std::map<std::string, int> &list_hf,
855 RooArgList &physics,
const std::string &varname,
858 for (
auto sampleit : inputParameters) {
859 const std::string sample(sampleit.first);
860 RooAbsReal *obj = loadFromFileResidentFolder<RooAbsReal>(
file, sample, varname,
true);
863 auto it = list_hf.find(sample);
864 if (it == list_hf.end()) {
866 list_hf[sample] = idx;
868 assert(obj == physics.
at(idx));
881 for (
auto sampleit : inputParameters) {
882 const std::string sample(sampleit.first);
883 TObject *obj = loadFromFileResidentFolder<TObject>(
file, sample, varname,
false);
896 std::stringstream errstr;
897 errstr <<
"Error: unable to retrieve cross section '" << varname <<
"' from folder '" << sample;
901 auto it = list_xs.find(sample.c_str());
903 if (it != list_xs.end()) {
907 std::string objname =
Form(
"phys_%s_%s",
name, sample.c_str());
911 list_xs[sample] = idx;
913 assert(physics.
at(idx) == xs);
924void collectCrosssectionsTPair(
const char *
name,
TDirectory *
file, std::map<std::string, int> &list_xs,
925 RooArgList &physics,
const std::string &varname,
const std::string &basefolder,
928 TPair *pair = loadFromFileResidentFolder<TPair>(
file, basefolder, varname,
false);
933 collectCrosssections<double>(
name,
file, list_xs, physics, varname, inputParameters);
937 collectCrosssections<float>(
name,
file, list_xs, physics, varname, inputParameters);
939 std::cerr <<
"cannot morph objects of class 'TPair' if parameter is not "
954void collectPolynomialsHelper(
const FeynmanDiagram &diagram, MorphFuncPattern &morphfunc, std::vector<int> &term,
955 int vertexid,
bool first)
958 for (
size_t i = 0; i < diagram[vertexid - 1].size(); ++i) {
959 if (!diagram[vertexid - 1][i])
961 std::vector<int> newterm(term);
964 ::collectPolynomialsHelper(diagram, morphfunc, newterm, vertexid,
false);
966 ::collectPolynomialsHelper(diagram, morphfunc, newterm, vertexid - 1,
true);
971 for (
size_t i = 0; i < morphfunc.size(); ++i) {
972 bool thisfound =
true;
973 for (
size_t j = 0; j < morphfunc[i].size(); ++j) {
974 if (morphfunc[i][j] != term[j]) {
985 morphfunc.push_back(term);
993void collectPolynomials(MorphFuncPattern &morphfunc,
const FeynmanDiagram &diagram)
995 int nvtx(diagram.size());
996 std::vector<int> term(diagram[0].
size(), 0);
998 ::collectPolynomialsHelper(diagram, morphfunc, term, nvtx,
true);
1004template <
class List>
1005inline void fillFeynmanDiagram(FeynmanDiagram &diagram,
const std::vector<List *> &vertices,
RooArgList &couplings)
1007 const int ncouplings = couplings.
getSize();
1009 for (
auto const &
vertex : vertices) {
1010 std::vector<bool> vertexCouplings(ncouplings,
false);
1013 for (
auto citr : couplings) {
1017 std::cerr <<
"encountered invalid list of couplings in vertex!" << std::endl;
1021 vertexCouplings[idx] =
true;
1024 diagram.push_back(vertexCouplings);
1031template <
class MatrixT,
class T1,
class T2>
1035 const size_t dim = inputParameters.size();
1036 MatrixT matrix(dim, dim);
1038 for (
auto sampleit : inputParameters) {
1039 const std::string sample(sampleit.first);
1041 if (!setParams<double>(sampleit.second, args,
true, 0)) {
1042 std::cout <<
"unable to set parameters for sample " << sample <<
"!" << std::endl;
1044 auto flagit = flagValues.find(sample);
1045 if (flagit != flagValues.end() && !setParams<int>(flagit->second, flags,
true, 1)) {
1046 std::cout <<
"unable to set parameters for sample " << sample <<
"!" << std::endl;
1050 for (
auto const &formula : formulas) {
1051 if (!formula.second) {
1052 std::cerr <<
"Error: invalid formula encountered!" << std::endl;
1054 matrix(row, col) = formula.second->getVal();
1067 if (inputParameters.size() != formulas.size()) {
1068 std::stringstream ss;
1069 ss <<
"matrix is not square, consistency check failed: " << inputParameters.size() <<
" samples, "
1070 << formulas.size() <<
" expressions:" << std::endl;
1071 ss <<
"formulas: " << std::endl;
1072 for (
auto const &formula : formulas) {
1073 ss << formula.second->GetTitle() << std::endl;
1075 ss <<
"samples: " << std::endl;
1076 for (
auto sample : inputParameters) {
1077 ss << sample.first << std::endl;
1079 std::cerr << ss.str() << std::endl;
1086inline void inverseSanity(
const Matrix &matrix,
const Matrix &inverse,
double &unityDeviation,
double &largestWeight)
1088 Matrix unity(inverse * matrix);
1090 unityDeviation = 0.;
1092 const size_t dim =
size(unity);
1093 for (
size_t i = 0; i < dim; ++i) {
1094 for (
size_t j = 0; j < dim; ++j) {
1095 if (inverse(i, j) > largestWeight) {
1096 largestWeight = (
double)inverse(i, j);
1098 if (
fabs(unity(i, j) -
static_cast<int>(i == j)) > unityDeviation) {
1099 unityDeviation =
fabs((
double)unity(i, j)) -
static_cast<int>(i == j);
1107template <
class List>
1110 for (
auto sampleit : inputParameters) {
1111 const std::string sample(sampleit.first);
1112 RooAbsArg *arg = args.find(sample.c_str());
1114 std::cerr <<
"detected name conflict: cannot use sample '" << sample
1115 <<
"' - a parameter with the same name of type '" << arg->
ClassName() <<
"' is present in set '"
1116 << args.GetName() <<
"'!" << std::endl;
1128 const std::vector<RooArgList *> &nonInterfering)
1137 const int ncouplings = couplings.
getSize();
1138 std::vector<bool> couplingsZero(ncouplings,
true);
1139 std::map<TString, bool> flagsZero;
1142 extractOperators(couplings, operators);
1143 size_t nOps = operators.
getSize();
1145 for (
auto sampleit : inputParameters) {
1146 const std::string sample(sampleit.first);
1147 if (!setParams(sampleit.second, operators,
true)) {
1148 std::cerr <<
"unable to set parameters for sample '" << sample <<
"'!" << std::endl;
1151 if ((
int)nOps != (operators.
getSize())) {
1152 std::cerr <<
"internal error, number of operators inconsistent!" << std::endl;
1158 for (
auto itr1 : couplings) {
1160 if (obj0->
getVal() != 0) {
1161 couplingsZero[idx] =
false;
1167 for (
auto itr2 : flags) {
1168 auto obj1 =
dynamic_cast<RooAbsReal *
>(itr2);
1171 for (
auto sampleit : inputFlags) {
1172 const auto &flag = sampleit.second.find(obj1->GetName());
1173 if (flag != sampleit.second.end()) {
1174 if (flag->second == 0.)
1180 if (nZero > 0 && nNonZero == 0)
1181 flagsZero[obj1->GetName()] =
true;
1183 flagsZero[obj1->GetName()] =
false;
1186 FormulaList formulas;
1187 for (
size_t i = 0; i < morphfunc.size(); ++i) {
1189 bool isZero =
false;
1192 for (
const auto &
group : nonInterfering) {
1193 int nInterferingOperators = 0;
1194 for (
size_t j = 0; j < morphfunc[i].size(); ++j) {
1195 if (morphfunc[i][j] % 2 == 0)
1197 if (
group->find(couplings.at(j)->GetName())) {
1199 nInterferingOperators++;
1202 if (nInterferingOperators > 1) {
1204 reason =
"blacklisted interference term!";
1210 for (
size_t j = 0; j < morphfunc[i].size(); ++j) {
1211 const int exponent = morphfunc[i][j];
1215 for (
int k = 0; k < exponent; ++k) {
1224 reason =
"coupling " +
cname +
" was listed as leading-order-only";
1227 if (!isZero && couplingsZero[j]) {
1229 reason =
"coupling " +
cname +
" is zero!";
1234 bool removedByFlag =
false;
1236 for (
auto itr : flags) {
1240 TString sval(obj->getStringAttribute(
"NewPhysics"));
1241 int val = atoi(sval);
1243 if (flagsZero.find(obj->
GetName()) != flagsZero.end() && flagsZero.at(obj->
GetName())) {
1244 removedByFlag =
true;
1252 if (!isZero && !removedByFlag) {
1254 const auto name = std::string(mfname) +
"_pol" + std::to_string(i);
1255 formulas[i] = std::make_unique<RooProduct>(
name.c_str(), ::concatNames(ss,
" * ").c_str(), ss);
1266 const std::vector<std::vector<RooArgList *>> &diagrams,
RooArgList &couplings,
1267 const RooArgList &flags,
const std::vector<RooArgList *> &nonInterfering)
1269 MorphFuncPattern morphfuncpattern;
1271 for (
const auto &vertices : diagrams) {
1273 ::fillFeynmanDiagram(
d, vertices, couplings);
1274 ::collectPolynomials(morphfuncpattern,
d);
1276 FormulaList retval = buildFormulas(
name, inputs, inputFlags, morphfuncpattern, couplings, flags, nonInterfering);
1277 if (retval.empty()) {
1278 std::stringstream errorMsgStream;
1280 <<
"no formulas are non-zero, check if any if your couplings is floating and missing from your param_cards!"
1282 const auto errorMsg = errorMsgStream.str();
1283 throw std::runtime_error(errorMsg);
1285 checkMatrix(inputs, retval);
1294 FormulaList &formulas,
const Matrix &inverse)
1298 for (
auto sampleit : inputParameters) {
1299 const std::string sample(sampleit.first);
1300 std::stringstream title;
1301 TString name_full(makeValidName(sample.c_str()));
1303 name_full.Append(
"_");
1304 name_full.Append(fname);
1305 name_full.Prepend(
"w_");
1311 for (
auto const &formulait : formulas) {
1313 sampleformula->
add(val, formulait.second.get());
1316 weights.add(*sampleformula);
1321inline std::map<std::string, std::string>
1326 std::map<std::string, std::string> weights;
1327 for (
auto sampleit : inputParameters) {
1328 const std::string sample(sampleit.first);
1329 std::stringstream str;
1332 for (
auto const &formulait : formulas) {
1333 double val(inverse(formulaidx, sampleidx));
1335 if (formulaidx > 0 && val > 0)
1337 str << val <<
"*(" << formulait.second->GetTitle() <<
")";
1341 weights[sample] = str.str();
1376 args.
add(*(it.second));
1391 const std::vector<std::vector<RooListProxy *>> &diagramProxyList,
1392 const std::vector<RooArgList *> &nonInterfering,
const RooArgList &flags)
1395 std::vector<std::vector<RooArgList *>> diagrams;
1396 for (
const auto &diagram : diagramProxyList) {
1397 diagrams.emplace_back();
1400 diagrams.back().emplace_back(
vertex);
1405 ::createFormulas(funcname, inputParameters, inputFlags, diagrams,
_couplings, flags, nonInterfering);
1410 template <
class List>
1416 Matrix matrix(buildMatrixT<Matrix>(inputParameters,
_formulas, operators, inputFlags, flags));
1417 if (
size(matrix) < 1) {
1418 std::cerr <<
"input matrix is empty, please provide suitable input samples!" << std::endl;
1423 double unityDeviation, largestWeight;
1424 inverseSanity(matrix, inverse, unityDeviation, largestWeight);
1430 oocxcoutW((
TObject *)0,
Eval) <<
"Warning: The matrix inversion seems to be unstable. This can "
1431 "be a result to input samples that are not sufficiently "
1432 "different to provide any morphing power."
1434 }
else if (weightwarning) {
1436 "result to input samples that are not sufficiently different to "
1437 "provide any morphing power."
1441 "encoded in your samples to cross-check:"
1443 for (
auto sampleit : inputParameters) {
1444 const std::string sample(sampleit.first);
1447 setParams(sampleit.second, operators,
true);
1474 const std::map<std::string, int> &storage,
const RooArgList &physics,
1478 std::cerr <<
"invalid bin width given!" << std::endl;
1482 std::cerr <<
"invalid observable given!" << std::endl;
1496 for (
auto sampleit : inputParameters) {
1498 TString prodname(makeValidName(sampleit.first.c_str()));
1503 std::cerr <<
"unable to access physics object for " << prodname << std::endl;
1510 std::cerr <<
"unable to access weight object for " << prodname << std::endl;
1517 allowNegativeYields =
true;
1518 auto prod = std::make_unique<RooProduct>(prodname, prodname, prodElems);
1519 if (!allowNegativeYields) {
1520 auto maxname = std::string(prodname) +
"_max0";
1523 auto max = std::make_unique<RooFormulaVar>(maxname.c_str(),
"max(0," + prodname +
")", prodset);
1524 max->addOwnedComponents(std::move(prod));
1525 sumElements.
addOwned(std::move(max));
1527 sumElements.
addOwned(std::move(prod));
1529 scaleElements.
add(*(binWidth));
1534 _sumFunc = make_unique<RooRealSumFunc>(
Form(
"%s_morphfunc",
name),
name, sumElements, scaleElements);
1537 std::cerr <<
"unable to access observable" << std::endl;
1538 _sumFunc.get()->addServer(*observable);
1540 std::cerr <<
"unable to access bin width" << std::endl;
1541 _sumFunc.get()->addServer(*binWidth);
1543 std::cerr <<
"no operators listed" << std::endl;
1544 _sumFunc.get()->addServerList(operators);
1546 std::cerr <<
"unable to access weight objects" << std::endl;
1548 _sumFunc.get()->addOwnedComponents(std::move(sumElements));
1549 _sumFunc.get()->addServerList(sumElements);
1550 _sumFunc.get()->addServerList(scaleElements);
1553 std::cout.precision(std::numeric_limits<double>::digits);
1567 {func->_nonInterfering.begin(), func->_nonInterfering.end()}, func->
_flags);
1570 if (obsName.empty()) {
1571 std::cerr <<
"Matrix inversion succeeded, but no observable was "
1572 "supplied. quitting..."
1580 setParams(func->
_flags, 1);
1584 setParams(func->
_flags, 1);
1599 {func->_nonInterfering.begin(), func->_nonInterfering.end()}, func->
_flags);
1607 setParams(func->
_flags, 1);
1611 setParams(func->
_flags, 1);
1641 return readMatrixFromFileT<TMatrixD>(fname);
1649 return readMatrixFromStreamT<TMatrixD>(stream);
1659 bool obsExists(
false);
1680 TH1 *hist = (
TH1 *)(inputExample);
1684 obs =
new RooRealVar(obsname, obsname, 0, 1);
1689 if (strcmp(obsname, obs->
GetName()) != 0) {
1691 <<
" does not match expected name " << obsname << std::endl;
1718 const size_t n(
size(cache->_inverse));
1720 const std::string sample(sampleit.first);
1723 if (!sampleformula) {
1728 for (
size_t formulaidx = 0; formulaidx <
n; ++formulaidx) {
1733 if (std::isnan(val)) {
1738 << val << std::endl;
1769 << obsName <<
"'" << std::endl;
1771 TObject *obj = loadFromFileResidentFolder<TObject>(
file, folderNames.front(), obsName,
true);
1773 std::cerr <<
"unable to locate object '" << obsName <<
"' in folder '" << folderNames.front() <<
"'!"
1777 std::string classname = obj->
ClassName();
1781 if (classname.find(
"TH1") != std::string::npos) {
1784 }
else if (classname.find(
"RooHistFunc") != std::string::npos ||
1785 classname.find(
"RooParamHistFunc") != std::string::npos ||
1786 classname.find(
"PiecewiseInterpolation") != std::string::npos) {
1788 }
else if (classname.find(
"TParameter<double>") != std::string::npos) {
1791 }
else if (classname.find(
"TParameter<float>") != std::string::npos) {
1794 }
else if (classname.find(
"TPair") != std::string::npos) {
1798 std::cerr <<
"cannot morph objects of class '" <<
mode->GetName() <<
"'!" << std::endl;
1807 for (
auto const &folder : folders) {
1809 const std::string sample(var ? var->
getVal() : folder->GetName());
1818 while ((obj = (
TObject *)next())) {
1819 auto f = readOwningFolderFromFile(
file, obj->
GetName());
1822 std::string
name(
f->GetName());
1837 std::cout << param.first <<
" = " << param.second;
1839 std::cout <<
" (const)";
1840 std::cout << std::endl;
1852 std::cout << folder << std::endl;
1874 _operators(
"operators",
"set of operators", this),
_observables(
"observables",
"morphing observables", this),
1886 const char *observableName,
const RooArgSet &couplings,
1888 :
RooAbsReal(
name, title), _cacheMgr(this, 10, true, true), _physics(
"physics",
"physics", this),
1889 _operators(
"operators",
"set of operators", this), _observables(
"observables",
"morphing observables", this),
1890 _binWidths(
"binWidths",
"set of binWidth objects", this), _flags(
"flags",
"flags", this)
1911 if (diagrams.size() > 0) {
1916 for (
auto const &
v : diagrams) {
1918 extractOperators(*t, operators);
1928 for (
size_t j = 0; j < diagrams.size(); ++j) {
1929 std::vector<RooListProxy *> diagram;
1930 for (
size_t i = 0; i < diagrams[j].size(); ++i) {
1931 std::stringstream
name;
1932 name <<
"!vertex" << i;
1933 std::stringstream title;
1934 title <<
"set of couplings in the vertex " << i;
1935 diagram.push_back(
new RooListProxy(
name.str().c_str(), title.str().c_str(),
this,
true,
false));
1937 diagram[i]->addOwned(*diagrams[j][i]);
1939 diagram[i]->add(*diagrams[j][i]);
1948 std::vector<RooListProxy *> vertices;
1950 vertices.push_back(
new RooListProxy(
"!couplings",
"set of couplings in the vertex",
this,
true,
false));
1962 std::vector<RooListProxy *> vertices;
1968 new RooListProxy(
"!production",
"set of couplings in the production vertex",
this,
true,
false));
1969 vertices.push_back(
new RooListProxy(
"!decay",
"set of couplings in the decay vertex",
this,
true,
false));
2028 :
RooAbsReal(other,
name), _cacheMgr(other._cacheMgr, this), _scale(other._scale), _sampleMap(other._sampleMap),
2029 _physics(other._physics.GetName(), this, other._physics),
2030 _operators(other._operators.GetName(), this, other._operators),
2031 _observables(other._observables.GetName(), this, other._observables),
2032 _binWidths(other._binWidths.GetName(), this, other._binWidths), _flags{other._flags.GetName(), this, other._flags},
2033 _config(other._config)
2035 for (
size_t j = 0; j < other.
_diagrams.size(); ++j) {
2036 std::vector<RooListProxy *> diagram;
2037 for (
size_t i = 0; i < other.
_diagrams[j].size(); ++i) {
2039 diagram.push_back(list);
2066 : _cacheMgr(this, 10, true, true), _operators(
"operators",
"set of operators", this, true, false),
2067 _observables(
"observable",
"morphing observable", this, true, false),
2068 _binWidths(
"binWidths",
"set of bin width objects", this, true, false)
2070 static int counter(0);
2102 FeynmanDiagram diagram;
2103 std::vector<bool> prod;
2104 std::vector<bool> dec;
2105 for (
int i = 0; i < nboth; ++i) {
2106 prod.push_back(
true);
2107 dec.push_back(
true);
2109 for (
int i = 0; i < nprod; ++i) {
2110 prod.push_back(
true);
2111 dec.push_back(
false);
2113 for (
int i = 0; i < ndec; ++i) {
2114 prod.push_back(
false);
2115 dec.push_back(
true);
2117 diagram.push_back(prod);
2118 diagram.push_back(dec);
2119 MorphFuncPattern morphfuncpattern;
2120 ::collectPolynomials(morphfuncpattern, diagram);
2121 return morphfuncpattern.size();
2133 for (
auto vertex : vertices) {
2134 extractOperators(*
vertex, operators);
2135 extractCouplings(*
vertex, couplings);
2137 FeynmanDiagram diagram;
2138 ::fillFeynmanDiagram(diagram, vertices, couplings);
2139 MorphFuncPattern morphfuncpattern;
2140 ::collectPolynomials(morphfuncpattern, diagram);
2141 return morphfuncpattern.size();
2156std::map<std::string, std::string>
2158 const std::vector<std::vector<std::string>> &vertices_str)
2160 std::stack<RooArgList> ownedVertices;
2161 std::vector<RooArgList *> vertices;
2163 for (
const auto &vtx : vertices_str) {
2164 ownedVertices.emplace();
2165 auto &
vertex = ownedVertices.top();
2166 for (
const auto &
c : vtx) {
2169 coupling =
new RooRealVar(
c.c_str(),
c.c_str(), 1., 0., 10.);
2170 couplings.
add(*coupling);
2174 vertices.push_back(&
vertex);
2183std::map<std::string, std::string>
2185 const std::vector<RooArgList *> &vertices,
RooArgList &couplings)
2193std::map<std::string, std::string>
2195 const std::vector<RooArgList *> &vertices,
RooArgList &couplings,
2197 const std::vector<RooArgList *> &nonInterfering)
2199 FormulaList formulas = ::createFormulas(
"", inputs, flagValues, {vertices}, couplings, flags, nonInterfering);
2201 extractOperators(couplings, operators);
2202 Matrix matrix(::buildMatrixT<Matrix>(inputs, formulas, operators, flagValues, flags));
2203 if (
size(matrix) < 1) {
2204 std::cerr <<
"input matrix is empty, please provide suitable input samples!" << std::endl;
2208 auto retval = buildSampleWeightStrings(inputs, formulas, inverse);
2216 const std::vector<RooArgList *> &vertices,
RooArgList &couplings,
2219 const std::vector<RooArgList *> &nonInterfering)
2221 FormulaList formulas = ::createFormulas(
"", inputs, flagValues, {vertices}, couplings, flags, nonInterfering);
2223 extractOperators(couplings, operators);
2224 Matrix matrix(::buildMatrixT<Matrix>(inputs, formulas, operators, flagValues, flags));
2225 if (
size(matrix) < 1) {
2226 std::cerr <<
"input matrix is empty, please provide suitable input samples!" << std::endl;
2231 ::buildSampleWeights(retval, (
const char *)
nullptr , inputs, formulas, inverse);
2239 const std::vector<RooArgList *> &vertices,
RooArgList &couplings)
2241 std::vector<RooArgList *> nonInterfering;
2255 coutE(
Eval) <<
"unable to retrieve morphing function" << std::endl;
2263 for (
auto itr : *args) {
2288 auto wname = std::string(
"w_") +
name +
"_" + this->
GetName();
2289 return dynamic_cast<RooAbsReal *
>(cache->_weights.find(wname.c_str()));
2307 auto weightName = std::string(
"w_") + sample.first +
"_" + this->
GetName();
2308 auto weight =
static_cast<RooAbsReal *
>(cache->_weights.find(weightName.c_str()));
2325 double val = obj->
getVal();
2328 double variation =
r.Gaus(1, z);
2329 obj->
setVal(val * variation);
2370 cache->_inverse =
m;
2388 coutE(
Caching) <<
"unable to create cache!" << std::endl;
2406 coutE(
Caching) <<
"unable to create cache!" << std::endl;
2430 cxcoutP(
Caching) <<
"creating cache from getCache function for " <<
this << std::endl;
2436 coutE(
Caching) <<
"unable to create cache!" << std::endl;
2460 if (value < param->getMin())
2584 TH1 *paramhist = loadFromFileResidentFolder<TH1>(
file, foldername,
"param_card");
2595 const std::string
name(foldername);
2605 for (
auto itr : *list) {
2652 auto mf = std::make_unique<RooRealSumFunc>(*(this->
getFunc()));
2655 const int nbins = observable->
getBins();
2660 for (
int i = 0; i < nbins; ++i) {
2665 for (
auto itr : *args) {
2677 double weight = formula->
getVal();
2680 val += dhist.
weight() * weight;
2694 auto mf = std::make_unique<RooRealSumFunc>(*(this->
getFunc()));
2698 for (
auto itr : *args) {
2700 if (prod->
getVal() != 0) {
2714 std::string pname(paramname);
2716 bool isUsed =
false;
2718 double thisval = sample.second.at(pname);
2719 if (thisval != val) {
2735 std::string
cname(couplname);
2742 bool isUsed =
false;
2745 double thisval = coupling->
getVal();
2746 if (thisval != val) {
2771 return cache->_formulas.size();
2779 auto mf = std::make_unique<RooRealSumFunc>(*(this->
getFunc()));
2781 std::cerr <<
"Error: unable to retrieve morphing function" << std::endl;
2785 for (
auto itr : *args) {
2790 name.Prepend(
"phys_");
2794 double val = formula->
getVal();
2796 std::cout << formula->
GetName() <<
": " << val <<
" = " << formula->
GetTitle() << std::endl;
2816 return &(cache->_couplings);
2830 double val = var->
getVal();
2831 couplings[
name] = val;
2858 auto func = std::make_unique<RooRealSumFunc>(*(cache->_sumFunc));
2861 return std::make_unique<RooWrapperPdf>(
Form(
"pdf_%s", func->GetName()),
Form(
"pdf of %s", func->GetTitle()), *func);
2870 return cache->_sumFunc.get();
2887 return this->
createPdf()->expectedEvents(nset);
2897 return this->
createPdf()->expectedEvents(set);
2906 return createPdf()->expectedEvents(&nset);
2919 auto weightName = std::string(
"w_") + sample.first +
"_" + this->
GetName();
2920 auto weight =
static_cast<RooAbsReal *
>(cache->_weights.find(weightName.c_str()));
2937 double w = weight->getVal();
2938 unc2 += newunc2 *
w *
w;
2965 for (
auto flag :
_flags) {
2979 for (
auto c : couplings) {
2980 std::cout <<
c.first <<
": " <<
c.second << std::endl;
3021 std::cerr <<
"unable to acquire in-built function!" << std::endl;
3053 const char *rangeName)
const
3097 coutE(
Caching) <<
"unable to retrieve cache!" << std::endl;
3108 coutE(
Caching) <<
"unable to retrieve cache!" << std::endl;
3121 coutE(
Caching) <<
"unable to retrieve cache!" << std::endl;
3122 return cache->_condition;
3128std::unique_ptr<RooRatio>
3132 for (
auto it : nr) {
3135 for (
auto it : dr) {
3139 return make_unique<RooRatio>(
name, title, num, denom);
RooCollectionProxy< RooArgList > RooListProxy
size_t size< TMatrixD >(const TMatrixD &mat)
void writeMatrixToStreamT(const MatrixT &matrix, std::ostream &stream)
write a matrix to a stream
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
static constexpr double morphUnityDeviation
Matrix makeSuperMatrix(const TMatrixD &in)
convert a TMatrixD into a Matrix
static constexpr double morphLargestWeight
void writeMatrixToFileT(const MatrixT &matrix, const char *fname)
write a matrix to a text file
double invertMatrix(const Matrix &matrix, Matrix &inverse)
TMatrixD makeRootMatrix(const Matrix &in)
convert a matrix into a TMatrixD
Matrix diagMatrix(size_t n)
create a new diagonal matrix of size n
void printMatrix(const TMatrixD &mat)
write a matrix
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
TMatrixT< Double_t > TMatrixD
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
std::string & operator+=(std::string &left, const TString &right)
TTime operator*(const TTime &t1, const TTime &t2)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
bool isConstant() const
Check if the "Constant" attribute is set.
void Print(Option_t *options=0) const override
Print the object to the defaultPrintStream().
const RefCountList_t & servers() const
List of all servers of this object.
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
virtual double * array() const =0
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
RooAbsArg * first() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual double getMax(const char *name=0) const
Get maximum of currently defined range.
void setConstant(bool value=true)
void setBin(Int_t ibin, const char *rangeName=0) override
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
virtual double getMin(const char *name=0) const
Get minimum of currently defined range.
Int_t numBins(const char *rangeName=0) const override
virtual Int_t getBins(const char *name=0) const
Get number of bins of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual double getValV(const RooArgSet *normalisationSet=nullptr) const
Return value of object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Class RooBinning is an implements RooAbsBinning in terms of an array of boundary values,...
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
Getter function without integration set.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
Setter function without integration set.
bool addOwned(RooAbsArg &var, bool silent=false) override
Overloaded RooCollection_t::addOwned() method insert object into owning set and registers object as s...
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
The RooDataHist is a container class to hold N-dimensional binned data.
double weight(std::size_t i) const
Return weight of i-th bin.
double weightSquared(std::size_t i) const
Return squared weight sum of i-th bin.
const RooArgSet * get() const override
Get bin centre of current bin.
RooHistFunc implements a real-valued function sampled from a multidimensional histogram.
RooArgSet const & getHistObsList() const
RooDataHist & dataHist()
Return RooDataHist that is represented.
static RooLagrangianMorphFunc::CacheElem * createCache(const RooLagrangianMorphFunc *func)
create all the temporary objects required by the class
void buildMatrix(const RooLagrangianMorphFunc::ParamMap &inputParameters, const RooLagrangianMorphFunc::FlagMap &inputFlags, const List &flags)
build and invert the morphing matrix
static RooLagrangianMorphFunc::CacheElem * createCache(const RooLagrangianMorphFunc *func, const Matrix &inverse)
create all the temporary objects required by the class function variant with precomputed inverse matr...
std::unique_ptr< RooRealSumFunc > _sumFunc
RooArgList containedArgs(Action) override
retrieve the list of contained args
void operModeHook(RooAbsArg::OperMode) override
Interface for changes of operation mode.
void createComponents(const RooLagrangianMorphFunc::ParamMap &inputParameters, const RooLagrangianMorphFunc::FlagMap &inputFlags, const char *funcname, const std::vector< std::vector< RooListProxy * > > &diagramProxyList, const std::vector< RooArgList * > &nonInterfering, const RooArgList &flags)
create the basic objects required for the morphing
void buildMorphingFunction(const char *name, const RooLagrangianMorphFunc::ParamMap &inputParameters, const std::map< std::string, int > &storage, const RooArgList &physics, bool allowNegativeYields, RooRealVar *observable, RooRealVar *binWidth)
build the final morphing function
Class RooLagrangianMorphing is a implementation of the method of Effective Lagrangian Morphing,...
bool isParameterConstant(const char *paramname) const
return true if the parameter with the given name is set constant, false otherwise
TPair * makeCrosssectionContainer(double xs, double unc)
create TPair containers of the type expected by the RooLagrangianMorph
bool isBinnedDistribution(const RooArgSet &obs) const override
check if this PDF is a binned distribution in the given observable
int nPolynomials() const
return the number of samples in this morphing function
void setParameter(const char *name, double value)
set one parameter to a specific value
ParamSet getMorphParameters() const
retrieve the parameter set
double evaluate() const override
call getVal on the internal function
RooProduct * getSumElement(const char *name) const
return the RooProduct that is the element of the RooRealSumPdfi corresponding to the given sample nam...
RooRealVar * getBinWidth() const
retrieve the histogram observable
void writeMatrixToFile(const TMatrixD &matrix, const char *fname)
write a matrix to a file
RooRealVar * getParameter(const char *name) const
retrieve the RooRealVar object incorporating the parameter with the given name
bool useCoefficients(const TMatrixD &inverse)
setup the morphing function with a predefined inverse matrix call this function before any other afte...
const RooArgSet * getParameterSet() const
get the set of parameters
TMatrixD readMatrixFromStream(std::istream &stream)
read a matrix from a stream
const RooArgSet * _curNormSet
std::vector< std::string > getSamples() const
return the vector of sample names, used to build the morph func
int countSamples(std::vector< RooArgList * > &vertices)
calculate the number of samples needed to morph a certain physics process usage: countSamples ( { Roo...
void setCacheAndTrackHints(RooArgSet &) override
Retrieve the matrix of coefficients.
ParamSet getCouplings() const
retrieve a set of couplings (-?-)
void printSampleWeights() const
print the current sample weights
std::map< const std::string, double > ParamSet
RooArgSet createWeights(const ParamMap &inputs, const std::vector< RooArgList * > &vertices, RooArgList &couplings, const FlagMap &inputFlags, const RooArgList &flags, const std::vector< RooArgList * > &nonInterfering)
create only the weight formulas. static function for external usage.
void writeMatrixToStream(const TMatrixD &matrix, std::ostream &stream)
write a matrix to a stream
void addFolders(const RooArgList &folders)
The cache manager.
std::map< const std::string, ParamSet > ParamMap
bool updateCoefficients()
retrive the new physics objects and update the weights in the morphing function
RooRealVar * getObservable() const
retrieve the histogram observable
int countContributingFormulas() const
count the number of formulas that correspond to the current parameter set
std::list< double > * plotSamplingHint(RooAbsRealLValue &, double, double) const override
retrieve the sample Hint
RooRealVar * getFlag(const char *name) const
retrieve the RooRealVar object incorporating the flag with the given name
void randomizeParameters(double z)
randomize the parameters a bit useful to test and debug fitting
bool isCouplingUsed(const char *couplname)
check if there is any morphing power provided for the given coupling morphing power is provided as so...
void readParameters(TDirectory *f)
read the parameters from the input file
double getScale()
get energy scale of the EFT expansion
double getCondition() const
Retrieve the condition of the coefficient matrix.
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const override
Retrieve the matrix of coefficients.
TMatrixD getMatrix() const
Retrieve the matrix of coefficients.
void printWeights() const
print the current sample weights
void printCouplings() const
print a set of couplings
TMatrixD readMatrixFromFile(const char *fname)
read a matrix from a text file
~RooLagrangianMorphFunc() override
default destructor
void printParameters() const
print the parameters and their current values
void printPhysics() const
print the current physics values
static std::unique_ptr< RooRatio > makeRatio(const char *name, const char *title, RooArgList &nr, RooArgList &dr)
Return the RooRatio form of products and denominators of morphing functions.
void setFlag(const char *name, double value)
set one flag to a specific value
TH1 * createTH1(const std::string &name)
retrieve a histogram output of the current morphing settings
double expectedUncertainty() const
return the expected uncertainty for the current parameter set
int nParameters() const
return the number of parameters in this morphing function
RooLagrangianMorphFunc::CacheElem * getCache(const RooArgSet *nset) const
retrieve the cache object
bool hasParameter(const char *paramname) const
check if a parameter of the given name is contained in the list of known parameters
bool checkObservables(const RooArgSet *nset) const override
check if observable exists in the RooArgSet (-?-)
bool hasCache() const
return true if a cache object is present, false otherwise
void printFlags() const
print the flags and their current values
void setScale(double val)
set energy scale of the EFT expansion
TMatrixD getInvertedMatrix() const
Retrieve the matrix of coefficients after inversion.
RooAbsArg::CacheMode canNodeBeCached() const override
Retrieve the matrix of coefficients.
void updateSampleWeights()
update sample weight (-?-)
void setParameters(const char *foldername)
set the morphing parameters to those supplied in the sample with the given name
RooObjCacheManager _cacheMgr
bool isParameterUsed(const char *paramname) const
check if there is any morphing power provided for the given parameter morphing power is provided as s...
RooListProxy _observables
RooAbsPdf::ExtendMode extendMode() const
return extended mored capabilities
std::map< const std::string, FlagSet > FlagMap
bool forceAnalyticalInt(const RooAbsArg &arg) const override
Force analytical integration for the given observable.
void setParameterConstant(const char *paramname, bool constant) const
call setConstant with the boolean argument provided on the parameter with the given name
void printSamples() const
print all the known samples to the console
double getParameterValue(const char *name) const
set one parameter to a specific value
double getValV(const RooArgSet *set=0) const override
call getVal on the internal function
void setup(bool ownParams=true)
setup this instance with the given set of operators and vertices if own=true, the class will own the ...
void printMetaArgs(std::ostream &os) const override
Retrieve the matrix of coefficients.
std::unique_ptr< RooWrapperPdf > createPdf() const
(currently similar to cloning the Pdf
RooAbsReal * getSampleWeight(const char *name)
retrieve the weight (prefactor) of a sample with the given name
std::map< std::string, std::string > createWeightStrings(const ParamMap &inputs, const std::vector< std::vector< std::string > > &vertices)
create only the weight formulas. static function for external usage.
std::vector< std::vector< RooListProxy * > > _diagrams
double expectedEvents() const
return the number of expected events for the current parameter set
std::map< std::string, int > _sampleMap
TObject * clone(const char *newname) const override
cloning method
RooRealVar * setupObservable(const char *obsname, TClass *mode, TObject *inputExample)
setup observable, recycle existing observable if defined
const RooArgList * getCouplingSet() const
get the set of couplings
RooRealSumFunc * getFunc() const
get the func
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
retrieve the list of bin boundaries
void printEvaluation() const
print the contributing samples and their respective weights
bool writeCoefficients(const char *filename)
write the inverse matrix to a file
void collectInputs(TDirectory *f)
retrieve the physics inputs
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=0) const override
Retrieve the mat.
RooLinearCombination is a class that helps perform linear combination of floating point numbers and p...
void add(RooFit::SuperFloat c, RooAbsReal *t)
void setCoefficient(size_t idx, RooFit::SuperFloat c)
RooFit::SuperFloat getCoefficient(size_t idx)
A histogram function that assigns scale parameters to every bin.
const RooArgList & paramList() const
A RooProduct represents the product of a given set of RooAbsReal objects.
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Retrieve bin boundaries if this distribution is binned in obs.
void printMetaArgs(std::ostream &os) const override
Customized printing of arguments of a RooRealSumFunc to more intuitively reflect the contents of the ...
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Variant of getAnalyticalIntegral that is also passed the normalization set that should be applied to ...
CacheMode canNodeBeCached() const override
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
bool isBinnedDistribution(const RooArgSet &obs) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
bool checkObservables(const RooArgSet *nset) const override
Overloadable function in which derived classes can implement consistency checks of the variables.
void setCacheAndTrackHints(RooArgSet &) override
std::list< double > * plotSamplingHint(RooAbsRealLValue &, double, double) const override
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
bool forceAnalyticalInt(const RooAbsArg &arg) const override
RooRealVar represents a variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
void setError(double value)
void setBins(Int_t nBins, const char *name=0)
Create a uniform binning under name 'name' for this variable.
void setMin(const char *name, double value)
Set minimum of name range to given value.
const RooAbsBinning & getBinning(const char *name=0, bool verbose=true, bool createOnTheFly=false) const override
Return binning definition with name.
void setMax(const char *name, double value)
Set maximum of name range to given value.
void setBinning(const RooAbsBinning &binning, const char *name=0)
Add given binning under name 'name' with this variable.
RooStringVar is a RooAbsArg implementing string values.
const char * getVal() const
Class to manage histogram axis.
const char * GetBinLabel(Int_t bin) const
Return label for bin.
TClass instances represent classes, structs and namespaces in the ROOT type system.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Double_t GetCondition() const
Bool_t Invert(TMatrixD &inv)
For a matrix A(m,m), its inverse A_inv is defined as A * A_inv = A_inv * A = unit (m x m) Ainv is ret...
Describe directory structure in memory.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
A TFolder object is a collection of objects and folders.
TCollection * GetListOfFolders() const
virtual void SetOwner(Bool_t owner=kTRUE)
Set ownership.
1-D histogram with a float per channel (see TH1 documentation)}
TH1 is the base class of all histogram classes in ROOT.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
virtual Int_t GetNbinsX() const
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual Double_t GetBinLowEdge(Int_t bin) const
Return bin lower edge for 1D histogram.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width for 1D histogram.
virtual TMatrixTBase< Element > & UnitMatrix()
Make a unit matrix (matrix need not be a square one).
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1) override
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Class used by TMap to store (key,value) pairs.
Named parameter, streamable and storable.
const AParamType & GetVal() const
Random number generator class based on M.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
const char * Data() const
TString & Append(const char *cs)
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
std::string observableName
std::vector< std::string > folderNames