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 RESTInfo <<
"Generating N-dim histogram for " << GetName() <<
RESTendl;
154 TString hName =
"formula";
156 Int_t* bins =
new Int_t[
fNbins.size()];
157 Double_t* xlow =
new Double_t[
fNbins.size()];
158 Double_t* xhigh =
new Double_t[
fNbins.size()];
160 for (
size_t n = 0; n <
fNbins.size(); n++) {
166 THnD* hNd =
new THnD(hName, hName,
fNbins.size(), bins, xlow, xhigh);
169 std::vector<double> binWidths;
170 for (
size_t i = 0; i <
fNbins.size(); ++i) {
171 double width =
static_cast<double>(xhigh[i] - xlow[i]) / bins[i];
172 binWidths.push_back(width);
176 std::vector<int> binIndices(
fNbins.size(), 0);
181 std::vector<double> binCenter;
182 for (
size_t i = 0; i <
fNbins.size(); ++i)
183 binCenter.push_back(xlow[i] + (binIndices[i] + 0.5) * binWidths[i]);
189 for (
size_t i = 0; i <
fNbins.size(); ++i) {
191 if (binIndices[i] < bins[i]) {
215 RESTMetadata <<
" == Contributions implemented inside the component ==" <<
RESTendl;
218 RESTMetadata <<
"- " << x.GetName() <<
" = " << x.GetExpFormula() <<
RESTendl;
235 while (ele !=
nullptr) {
237 std::string expression =
GetParameter(
"expression", ele,
"");
239 if (expression.empty()) {
240 RESTWarning <<
"TRestComponentFormula::InitFromConfigFile. Invalid formula" <<
RESTendl;
242 TFormula formula(name.c_str(), expression.c_str());
244 for (Int_t n = 0; n < formula.GetNpar(); n++) {
247 RESTError <<
"Variable : " << formula.GetParName(n) <<
" not found in component! "
249 RESTError <<
"TRestComponentFormula evaluation will lead to wrong results!" <<
RESTendl;
253 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