55#include "TRestComponentFormula.h"
118 RESTError <<
"Point should have same dimensions as number of variables!" <<
RESTendl;
124 for (
size_t n = 0; n <
fVariables.size(); n++) formula.SetParameter(
fVariables[n].c_str(), point[n]);
126 result += formula.EvalPar(
nullptr);
129 Double_t normFactor = 1;
130 for (
size_t n = 0; n < GetDimensions(); n++) {
152 if (GetDimensions() == 0) {
153 RESTError <<
"TRestComponentFormula::FillHistograms. No variables defined!" <<
RESTendl;
154 RESTError <<
"Did you add a <cVariable entry?" <<
RESTendl;
158 RESTInfo <<
"Generating N-dim histogram for " << GetName() <<
RESTendl;
160 TString hName =
"formula";
162 Int_t* bins =
new Int_t[
fNbins.size()];
163 Double_t* xlow =
new Double_t[
fNbins.size()];
164 Double_t* xhigh =
new Double_t[
fNbins.size()];
166 for (
size_t n = 0; n <
fNbins.size(); n++) {
172 THnD* hNd =
new THnD(hName, hName,
fNbins.size(), bins, xlow, xhigh);
175 std::vector<double> binWidths;
176 for (
size_t i = 0; i <
fNbins.size(); ++i) {
177 double width =
static_cast<double>(xhigh[i] - xlow[i]) / bins[i];
178 binWidths.push_back(width);
182 std::vector<int> binIndices(
fNbins.size(), 0);
187 std::vector<double> binCenter;
188 for (
size_t i = 0; i <
fNbins.size(); ++i)
189 binCenter.push_back(xlow[i] + (binIndices[i] + 0.5) * binWidths[i]);
195 for (
size_t i = 0; i <
fNbins.size(); ++i) {
197 if (binIndices[i] < bins[i]) {
221 RESTMetadata <<
" == Contributions implemented inside the component ==" <<
RESTendl;
224 RESTMetadata <<
"- " << x.GetName() <<
" = " << x.GetExpFormula() <<
RESTendl;
244 while (ele !=
nullptr) {
246 std::string expression =
GetParameter(
"expression", ele,
"");
248 if (expression.empty()) {
249 RESTWarning <<
"TRestComponentFormula::InitFromConfigFile. Invalid formula" <<
RESTendl;
251 TFormula formula(name.c_str(), expression.c_str());
253 for (Int_t n = 0; n < formula.GetNpar(); n++) {
256 RESTError <<
"Variable : " << formula.GetParName(n) <<
" not found in component! "
258 RESTError <<
"TRestComponentFormula evaluation will lead to wrong results!" <<
RESTendl;
262 for (
const auto& varName :
fVariables) formula.SetParameter(varName.c_str(), 0.0);
It defines a background/signal model distribution in a given parameter space (tipically x,...
void InitFromConfigFile() override
It customizes the retrieval of XML data values of this class.
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestAxionSolarFlux.
Int_t fActiveNode
It is used to define the node that will be accessed for rate retrieval.
std::vector< Int_t > fNbins
The number of bins in which we should divide each variable.
void Initialize() override
It initializes the random number. We avoid to define the section name here since we will never define...
std::vector< TVector2 > fRanges
The range of each of the variables used to create the PDF distribution.
std::vector< std::string > fVariables
A list with the branches that will be used to create the distribution space.
std::vector< THnD * > fNodeDensity
The generated N-dimensional variable space density for a given node.
@ REST_Info
+show most of the information for each steps