REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestComponent.cxx
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see https://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see https://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
41#include "TRestComponent.h"
42
43#include <TKey.h>
44#include <TLatex.h>
45
46#include <numeric>
47
48ClassImp(TRestComponent);
49
54
69TRestComponent::TRestComponent(const char* cfgFileName, const std::string& name)
70 : TRestMetadata(cfgFileName) {
71 RESTDebug << "Entering TRestComponent constructor( cfgFileName, name )" << RESTendl;
72 RESTDebug << "File: " << cfgFileName << " Name: " << name << RESTendl;
73}
74
79
87 // SetSectionName(this->ClassName());
88
89 if (!fRandom) {
90 delete fRandom;
91 fRandom = nullptr;
92 }
93
94 fRandom = new TRandom3(fSeed);
95 fSeed = fRandom->TRandom::GetSeed();
96}
97
105 fNodeDensity.clear();
106
107 fSeed = seed;
109
110 FillHistograms();
111}
112
117Int_t TRestComponent::GetVariableIndex(std::string varName) {
118 int n = 0;
119 for (const auto& v : fVariables) {
120 if (v == varName) return n;
121 n++;
122 }
123
124 return -1;
125}
126
136Double_t TRestComponent::GetRate(std::vector<Double_t> point) {
137 if (!fResponse) {
138 return GetRawRate(point);
139 }
140
141 std::string responseVariable = fResponse->GetVariable();
142 Int_t respVarIndex = GetVariableIndex(responseVariable);
143
144 if (respVarIndex == -1) {
145 RESTError << "The response variable `" << responseVariable << "`, defined inside TRestResponse,"
146 << RESTendl;
147 RESTError << "could not be found inside the component." << RESTendl;
148 RESTError << "Please, check the component variable names." << RESTendl;
149 return 0;
150 }
151
152 std::vector<std::pair<Double_t, Double_t> > response = fResponse->GetResponse(point[respVarIndex]);
153
154 Double_t rate = 0;
155 for (const auto& resp : response) {
156 std::vector<Double_t> newPoint = point;
157 newPoint[respVarIndex] = resp.first;
158 rate += resp.second * GetRawRate(newPoint);
159 }
160
161 return rate;
162}
163
185Double_t TRestComponent::GetNormalizedRate(std::vector<Double_t> point) {
186 Double_t normFactor = 1;
187 for (size_t n = 0; n < GetDimensions(); n++) normFactor *= fNbins[n] / (fRanges[n].Y() - fRanges[n].X());
188
189 return normFactor * GetRate(point);
190}
191
210Double_t TRestComponent::GetRawRate(std::vector<Double_t> point) {
211 if (point.size() != GetDimensions()) {
212 RESTError << "The size of the point given is : " << point.size() << RESTendl;
213 RESTError << "The density distribution dimensions are : " << GetDimensions() << RESTendl;
214 RESTError << "Point must have the same dimension as the distribution" << RESTendl;
215 return 0;
216 }
217
218 if (!HasNodes() && !HasDensity()) {
219 RESTError << "TRestComponent::GetRawRate. The component has no nodes!" << RESTendl;
220 RESTError << "Try calling TRestComponent::Initialize" << RESTendl;
221
222 RESTInfo << "Trying to initialize" << RESTendl;
223 Initialize();
224 if (HasNodes())
225 RESTInfo << "Sucess!" << RESTendl;
226 else
227 return 0;
228 }
229
230 if (HasNodes() && fActiveNode == -1) {
231 RESTError << "TRestComponent::GetRawRate. Active node has not been defined" << RESTendl;
232 return 0;
233 }
234
235 Int_t centerBin[GetDimensions()];
236 Double_t centralDensity = GetDensity()->GetBinContent(GetDensity()->GetBin(point.data()), centerBin);
237 if (!Interpolation()) return centralDensity;
238
239 std::vector<Int_t> direction;
240 std::vector<Double_t> nDist;
241 for (size_t dim = 0; dim < GetDimensions(); dim++) {
242 Double_t x1 = GetBinCenter(dim, centerBin[dim] - 1);
243 Double_t x2 = GetBinCenter(dim, centerBin[dim] + 1);
244
245 if (centerBin[dim] == 1 || centerBin[dim] == fNbins[dim]) {
246 direction.push_back(0);
247 nDist.push_back(0);
248 } else if (x2 - point[dim] > point[dim] - x1) {
249 // we chose left bin (x1) since it is closer than right bin
250 direction.push_back(-1);
251 nDist.push_back(1 - 2 * (point[dim] - x1) / (x2 - x1));
252 } else {
253 direction.push_back(1);
254 nDist.push_back(1 - 2 * (x2 - point[dim]) / (x2 - x1));
255 }
256 }
257
258 // In 3-dimensions we got 8 points to interpolate
259 // In 4-dimensions we would get 16 points to interpolate
260 // ...
261 Int_t nPoints = (Int_t)TMath::Power(2, (Int_t)GetDimensions());
262
263 Double_t sum = 0;
264 for (int n = 0; n < nPoints; n++) {
265 std::vector<int> cell = REST_StringHelper::IntegerToBinary(n, GetDimensions());
266
267 Double_t weightDistance = 1;
268 int cont = 0;
269 for (const auto& c : cell) {
270 if (c == 0)
271 weightDistance *= (1 - nDist[cont]);
272 else
273 weightDistance *= nDist[cont];
274 cont++;
275 }
276
277 for (size_t k = 0; k < cell.size(); k++) cell[k] = cell[k] * direction[k] + centerBin[k];
278
279 Double_t density = GetDensity()->GetBinContent(cell.data());
280 sum += density * weightDistance;
281 }
282
283 return sum;
284}
285
291 THnD* dHist = GetDensityForActiveNode();
292
293 Double_t integral = 0;
294 if (dHist != nullptr) {
295 TH1D* h1 = dHist->Projection(0);
296 integral = h1->Integral();
297 delete h1;
298 }
299
300 return integral;
301}
302
308Double_t TRestComponent::GetBinCenter(Int_t nDim, const Int_t bin) {
309 return fRanges[nDim].X() + (fRanges[nDim].Y() - fRanges[nDim].X()) * ((double)bin - 0.5) / fNbins[nDim];
310}
311
312ROOT::RVecD TRestComponent::GetRandom() {
313 Double_t* tuple = new Double_t[GetDimensions()];
314
315 ROOT::RVecD result;
316 if (!GetDensity()) {
317 for (size_t n = 0; n < GetDimensions(); n++) result.push_back(0);
318 RESTWarning << "TRestComponent::GetRandom. Component might not be initialized! Use "
319 "TRestComponent::Initialize()."
320 << RESTendl;
321 return result;
322 }
323
324 GetDensity()->GetRandom(tuple);
325
326 for (size_t n = 0; n < GetDimensions(); n++) result.push_back(tuple[n]);
327 return result;
328}
329
330ROOT::RDF::RNode TRestComponent::GetMonteCarloDataFrame(Int_t N) {
331 ROOT::RDF::RNode df = ROOT::RDataFrame(N);
332
333 // Function to fill the RDataFrame using GetRandom method
334 auto fillRndm = [&]() {
335 ROOT::RVecD randomValues = GetRandom();
336 return randomValues;
337 };
338 df = df.Define("Rndm", fillRndm);
339
340 // Creating dedicated columns for each GetRandom component
341 for (size_t i = 0; i < fVariables.size(); ++i) {
342 auto varName = fVariables[i];
343 auto FillRand = [i](const ROOT::RVecD& randomValues) { return randomValues[i]; };
344 df = df.Define(varName, FillRand, {"Rndm"});
345 }
346
347 /* Excluding Rndm from df */
348 std::vector<std::string> columns = df.GetColumnNames();
349 std::vector<std::string> excludeColumns = {"Rndm"};
350 columns.erase(std::remove_if(columns.begin(), columns.end(),
351 [&excludeColumns](std::string elem) {
352 return std::find(excludeColumns.begin(), excludeColumns.end(), elem) !=
353 excludeColumns.end();
354 }),
355 columns.end());
356
357 std::string user = getenv("USER");
358 std::string fOutName = "/tmp/rest_output_" + user + ".root";
359 df.Snapshot("AnalysisTree", fOutName, columns);
360
361 df = ROOT::RDataFrame("AnalysisTree", fOutName);
362
363 return df;
364}
365
375TCanvas* TRestComponent::DrawComponent(std::vector<std::string> drawVariables,
376 std::vector<std::string> scanVariables, Int_t binScanSize,
377 TString drawOption) {
378 if (drawVariables.size() > 2 || drawVariables.size() == 0) {
379 RESTError << "TRestComponent::DrawComponent. The number of variables to be drawn must "
380 "be 1 or 2!"
381 << RESTendl;
382 return fCanvas;
383 }
384
385 if (scanVariables.size() > 2 || scanVariables.size() == 0) {
386 RESTError << "TRestComponent::DrawComponent. The number of variables to be scanned must "
387 "be 1 or 2!"
388 << RESTendl;
389 return fCanvas;
390 }
391
393 std::vector<int> scanIndexes;
394 for (const auto& x : scanVariables) scanIndexes.push_back(GetVariableIndex(x));
395
396 Int_t nPlots = 1;
397 size_t n = 0;
398 for (const auto& x : scanIndexes) {
399 if (fNbins[x] % binScanSize != 0) {
400 RESTWarning << "The variable " << scanVariables[n] << " contains " << fNbins[x]
401 << " bins and it doesnt match with a bin size " << binScanSize << RESTendl;
402 RESTWarning << "The bin size must be a multiple of the number of bins." << RESTendl;
403 RESTWarning << "Redefining bin size to 1." << RESTendl;
404 binScanSize = 1;
405 }
406 nPlots *= fNbins[x] / binScanSize;
407 n++;
408 }
409
411 Int_t nPlotsX = 0;
412 Int_t nPlotsY = 0;
413
414 if (scanIndexes.size() == 2) {
415 nPlotsX = fNbins[scanIndexes[0]] / binScanSize;
416 nPlotsY = fNbins[scanIndexes[1]] / binScanSize;
417 } else {
418 nPlotsX = TRestTools::CanvasDivisions(nPlots)[1];
419 nPlotsY = TRestTools::CanvasDivisions(nPlots)[0];
420 }
421
422 RESTInfo << "Number of plots to be generated: " << nPlots << RESTendl;
423 RESTInfo << "Canvas size : " << nPlotsX << " x " << nPlotsY << RESTendl;
424
426 if (fCanvas != nullptr) {
427 delete fCanvas;
428 fCanvas = nullptr;
429 }
430
431 fCanvas = new TCanvas(this->GetName(), this->GetName(), 0, 0, nPlotsX * 640, nPlotsY * 480);
432 fCanvas->Divide(nPlotsX, nPlotsY, 0.01, 0.01);
433
434 std::vector<int> variableIndexes;
435 for (const auto& x : drawVariables) variableIndexes.push_back(GetVariableIndex(x));
436
437 for (int n = 0; n < nPlotsX; n++)
438 for (int m = 0; m < nPlotsY; m++) {
439 TPad* pad = (TPad*)fCanvas->cd(n * nPlotsY + m + 1);
440 pad->SetFixedAspectRatio(true);
441
442 THnD* hnd = GetDensity();
443
444 int binXo = binScanSize * n + 1;
445 int binXf = binScanSize * n + binScanSize;
446 int binYo = binScanSize * m + 1;
447 int binYf = binScanSize * m + binScanSize;
448
449 if (scanVariables.size() == 2) {
450 hnd->GetAxis(scanIndexes[0])->SetRange(binXo, binXf);
451 hnd->GetAxis(scanIndexes[1])->SetRange(binYo, binYf);
452 } else if (scanVariables.size() == 1) {
453 binXo = binScanSize * nPlotsY * n + binScanSize * m + 1;
454 binXf = binScanSize * nPlotsY * n + binScanSize * m + binScanSize;
455 hnd->GetAxis(scanIndexes[0])->SetRange(binXo, binXf);
456 }
457
458 if (variableIndexes.size() == 1) {
459 TH1D* h1 = hnd->Projection(variableIndexes[0]);
460 std::string hName;
461
462 if (scanIndexes.size() == 2)
463 hName = scanVariables[0] + "(" + IntegerToString(binXo) + ", " + IntegerToString(binXf) +
464 ") " + scanVariables[1] + "(" + IntegerToString(binYo) + ", " +
465 IntegerToString(binYf) + ") ";
466
467 if (scanIndexes.size() == 1)
468 hName = scanVariables[0] + "(" + IntegerToString(binXo) + ", " + IntegerToString(binXf) +
469 ") ";
470
471 TH1D* newh = (TH1D*)h1->Clone(hName.c_str());
472 newh->SetTitle(hName.c_str());
473 newh->SetStats(false);
474 newh->GetXaxis()->SetTitle((TString)drawVariables[0]);
475 newh->SetMarkerStyle(kFullCircle);
476 newh->Draw("PLC PMC");
477
478 TString entriesStr = "Entries: " + IntegerToString(newh->GetEntries());
479 TLatex* textLatex = new TLatex(0.62, 0.825, entriesStr);
480 textLatex->SetNDC();
481 textLatex->SetTextColor(1);
482 textLatex->SetTextSize(0.05);
483 textLatex->Draw("same");
484 delete h1;
485 }
486
487 if (variableIndexes.size() == 2) {
488 TH2D* h2 = hnd->Projection(variableIndexes[0], variableIndexes[1]);
489
490 std::string hName;
491 if (scanIndexes.size() == 2)
492 hName = scanVariables[0] + "(" + IntegerToString(binXo) + ", " + IntegerToString(binXf) +
493 ") " + scanVariables[1] + "(" + IntegerToString(binYo) + ", " +
494 IntegerToString(binYf) + ") ";
495
496 if (scanIndexes.size() == 1)
497 hName = scanVariables[0] + "(" + IntegerToString(binXo) + ", " + IntegerToString(binXf) +
498 ") ";
499
500 TH2D* newh = (TH2D*)h2->Clone(hName.c_str());
501 newh->SetStats(false);
502 newh->GetXaxis()->SetTitle((TString)drawVariables[0]);
503 newh->GetYaxis()->SetTitle((TString)drawVariables[1]);
504 newh->SetTitle(hName.c_str());
505 newh->Draw(drawOption);
506
507 TString entriesStr = "Entries: " + IntegerToString(newh->GetEntries());
508 TLatex* textLatex = new TLatex(0.62, 0.825, entriesStr);
509 textLatex->SetNDC();
510 textLatex->SetTextColor(1);
511 textLatex->SetTextSize(0.05);
512 textLatex->Draw("same");
513 delete h2;
514 }
515 }
516
517 return fCanvas;
518}
519
523void TRestComponent::LoadResponse(const TRestResponse& resp) {
524 if (fResponse) {
525 delete fResponse;
526 fResponse = nullptr;
527 }
528
529 fResponse = (TRestResponse*)resp.Clone("response");
531
533}
534
540
541 RESTMetadata << "Component nature : " << fNature << RESTendl;
542 RESTMetadata << " " << RESTendl;
543
544 RESTMetadata << "Random seed : " << fSeed << RESTendl;
545 if (fSamples) RESTMetadata << "Samples : " << fSamples << RESTendl;
546 RESTMetadata << " " << RESTendl;
547
548 if (fVariables.size() != fRanges.size())
549 RESTWarning << "The number of variables does not match with the number of defined ranges!"
550 << RESTendl;
551
552 else if (fVariables.size() != fNbins.size())
553 RESTWarning << "The number of variables does not match with the number of defined bins!" << RESTendl;
554 else {
555 int n = 0;
556 RESTMetadata << " === Variables === " << RESTendl;
557 for (const auto& varName : fVariables) {
558 RESTMetadata << " - Name: " << varName << " Range: (" << fRanges[n].X() << ", " << fRanges[n].Y()
559 << ") bins: " << fNbins[n] << RESTendl;
560 n++;
561 }
562 }
563
564 if (!fParameter.empty()) {
565 RESTMetadata << " " << RESTendl;
566 RESTMetadata << " === Parameterization === " << RESTendl;
567 RESTMetadata << "- Parameter : " << fParameter << RESTendl;
568
569 RESTMetadata << " - Number of parametric nodes : " << fParameterizationNodes.size() << RESTendl;
570 RESTMetadata << " " << RESTendl;
571 RESTMetadata << " Use : PrintNodes() for additional info" << RESTendl;
572 }
573
574 if (fResponse) {
575 RESTMetadata << " " << RESTendl;
576 RESTMetadata << "A response matrix was loaded inside the component" << RESTendl;
577 RESTMetadata << "You may get more details using TRestComponent::GetResponse()->PrintMetadata()"
578 << RESTendl;
579 }
580
581 RESTMetadata << "----" << RESTendl;
582}
583
588 std::cout << " - Number of nodes : " << fParameterizationNodes.size() << std::endl;
589 for (const auto& x : fParameterizationNodes) std::cout << x << " ";
590 std::cout << std::endl;
591}
592
598
599 auto ele = GetElement("cVariable");
600 while (ele != nullptr) {
601 std::string name = GetParameter("name", ele, "");
602 TVector2 v = Get2DVectorParameterWithUnits("range", ele, TVector2(-1, -1));
603 Int_t bins = StringToInteger(GetParameter("bins", ele, "0"));
604
605 if (name.empty() || (v.X() == -1 && v.Y() == -1) || bins == 0) {
606 RESTWarning << "TRestComponentFormula::fVariable. Problem with definition." << RESTendl;
607 RESTWarning << "Name: " << name << " range: (" << v.X() << ", " << v.Y() << ") bins: " << bins
608 << RESTendl;
609 } else {
610 fVariables.push_back(name);
611 fRanges.push_back(v);
612 fNbins.push_back(bins);
613 }
614
615 ele = GetNextElement(ele);
616 }
617
618 if (fNbins.size() == 0)
619 RESTError << "TRestComponent::InitFromConfigFile. No cVariables where found!" << RESTendl;
620
621 if (fResponse) {
622 delete fResponse;
623 fResponse = nullptr;
624 }
625
628}
629
634Int_t TRestComponent::FindActiveNode(Double_t node) {
635 int n = 0;
636 for (const auto& v : fParameterizationNodes) {
637 Double_t pUp = node * (1 + fPrecision / 2);
638 Double_t pDown = node * (1 - fPrecision / 2);
639 if (v > pDown && v < pUp) {
640 fActiveNode = n;
641 return fActiveNode;
642 }
643 n++;
644 }
645
646 return -1;
647}
648
653Int_t TRestComponent::SetActiveNode(Double_t node) {
654 int n = 0;
655 for (const auto& v : fParameterizationNodes) {
656 Double_t pUp = node * (1 + fPrecision / 2);
657 Double_t pDown = node * (1 - fPrecision / 2);
658 if (v > pDown && v < pUp) {
659 fActiveNode = n;
660 return fActiveNode;
661 }
662 n++;
663 }
664
665 RESTError << "Parametric node : " << node << " was not found in component" << RESTendl;
666 RESTError << "Keeping previous node as active : " << fParameterizationNodes[fActiveNode] << RESTendl;
667 PrintNodes();
668
669 return fActiveNode;
670}
671
675THnD* TRestComponent::GetDensityForNode(Double_t node) {
676 int n = 0;
677 for (const auto& x : fParameterizationNodes) {
678 if (x == node) {
679 return fNodeDensity[n];
680 }
681 n++;
682 }
683
684 RESTError << "Parametric node : " << node << " was not found in component" << RESTendl;
685 PrintNodes();
686 return nullptr;
687}
688
692THnD* TRestComponent::GetDensityForActiveNode() {
693 if (fActiveNode >= 0) return fNodeDensity[fActiveNode];
694
695 RESTError << "The active node is invalid" << RESTendl;
696 PrintNodes();
697 return nullptr;
698}
699
704TH1D* TRestComponent::GetHistogram(Double_t node, std::string varName) {
705 SetActiveNode(node);
706 return GetHistogram(varName);
707}
708
714TH1D* TRestComponent::GetHistogram(std::string varName) {
715 if (fActiveNode < 0) return nullptr;
716
717 Int_t v1 = GetVariableIndex(varName);
718
719 if (v1 >= 0 && GetDensityForActiveNode()) return GetDensityForActiveNode()->Projection(v1);
720
721 return nullptr;
722}
723
728TH2D* TRestComponent::GetHistogram(Double_t node, std::string varName1, std::string varName2) {
729 SetActiveNode(node);
730 return GetHistogram(varName1, varName2);
731}
732
738TH2D* TRestComponent::GetHistogram(std::string varName1, std::string varName2) {
739 if (fActiveNode < 0) return nullptr;
740
741 Int_t v1 = GetVariableIndex(varName1);
742 Int_t v2 = GetVariableIndex(varName2);
743
744 if (v1 >= 0 && v2 >= 0)
745 if (GetDensityForActiveNode()) return GetDensityForActiveNode()->Projection(v1, v2);
746
747 return nullptr;
748}
749
754TH3D* TRestComponent::GetHistogram(Double_t node, std::string varName1, std::string varName2,
755 std::string varName3) {
756 SetActiveNode(node);
757 return GetHistogram(varName1, varName2, varName3);
758}
759
765TH3D* TRestComponent::GetHistogram(std::string varName1, std::string varName2, std::string varName3) {
766 if (fActiveNode < 0) return nullptr;
767
768 Int_t v1 = GetVariableIndex(varName1);
769 Int_t v2 = GetVariableIndex(varName2);
770 Int_t v3 = GetVariableIndex(varName3);
771
772 if (v1 >= 0 && v2 >= 0 && v3 >= 0)
773 if (GetDensityForActiveNode()) return GetDensityForActiveNode()->Projection(v1, v2, v3);
774
775 return nullptr;
776}
It defines a background/signal model distribution in a given parameter space (tipically x,...
UInt_t fSeed
Seed used in random generator.
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.
Int_t FindActiveNode(Double_t node)
It returns the position of the fParameterizationNodes element for the variable name given by argument...
Int_t fSamples
It introduces a fixed number of samples (if 0 it will take all available samples)
Int_t GetVariableIndex(std::string varName)
It returns the position of the fVariable element for the variable name given by argument.
Double_t GetBinCenter(Int_t nDim, const Int_t bin)
It returns the bin center of the given component dimension.
void PrintNodes()
It prints out on screen the values of the parametric node.
Double_t GetRawRate(std::vector< Double_t > point)
It returns the intensity/rate (in seconds) corresponding to the generated distribution or formula eva...
std::string fParameter
It is used to parameterize a set of distribution densities (e.g. WIMP or axion mass)
Double_t GetNormalizedRate(std::vector< Double_t > point)
It returns the intensity/rate (in seconds) corresponding to the generated distribution or formula eva...
TRestComponent()
Default constructor.
TH1D * GetHistogram(Double_t node, std::string varName)
It returns a 1-dimensional projected histogram for the variable names provided in the argument.
Float_t fPrecision
A precision used to select the node value with a given range defined as a fraction of the value.
std::vector< Int_t > fNbins
The number of bins in which we should divide each variable.
TCanvas * DrawComponent(std::vector< std::string > drawVariables, std::vector< std::string > scanVariables, Int_t binScanSize=1, TString drawOption="")
A method allowing to draw a series of plots representing the density distributions.
void Initialize() override
It initializes the random number. We avoid to define the section name here since we will never define...
TRestResponse * fResponse
A pointer to the detector response.
Double_t GetTotalRate()
This method integrates the rate to all the parameter space defined in the density function....
std::vector< TVector2 > fRanges
The range of each of the variables used to create the PDF distribution.
std::vector< Double_t > fParameterizationNodes
It defines the nodes of the parameterization (Initialized by the dataset)
Bool_t HasNodes()
It returns true if any nodes have been defined.
TCanvas * fCanvas
A canvas for drawing the active node component.
Double_t GetRate(std::vector< Double_t > point)
It returns the intensity/rate (in seconds) corresponding to the generated distribution or formula eva...
TRandom3 * fRandom
Internal process random generator.
std::vector< std::string > fVariables
A list with the branches that will be used to create the distribution space.
~TRestComponent()
Default destructor.
void RegenerateHistograms(UInt_t seed=0)
It will produce a histogram with the distribution defined using the variables and the weights for eac...
Int_t SetActiveNode(Double_t node)
It returns the position of the fParameterizationNodes element for the variable name given by argument...
std::vector< THnD * > fNodeDensity
The generated N-dimensional variable space density for a given node.
std::string fNature
It defines the component type (unknown/signal/background)
A base class for any REST metadata class.
Definition: TRestMetadata.h:70
virtual void PrintMetadata()
Implemented it in the derived metadata class to print out specific metadata information.
endl_t RESTendl
Termination flag object for TRestStringOutput.
TiXmlElement * GetElement(std::string eleDeclare, TiXmlElement *e=nullptr)
Get an xml element from a given parent element, according to its declaration.
TRestMetadata * InstantiateChildMetadata(int index, std::string pattern="")
This method will retrieve a new TRestMetadata instance of a child element of the present TRestMetadat...
virtual void InitFromConfigFile()
To make settings from rml file. This method must be implemented in the derived class.
TiXmlElement * GetNextElement(TiXmlElement *e)
Get the next sibling xml element of this element, with same eleDeclare.
std::string GetParameter(std::string parName, TiXmlElement *e, TString defaultValue=PARAMETER_NOT_FOUND_STR)
Returns the value for the parameter named parName in the given section.
A response matrix that might be applied to a given component inside a TRestComponent.
Definition: TRestResponse.h:29
void LoadResponse(Bool_t transpose=true)
It loads into the fResponseMatrix data member the response from a file.
std::vector< std::pair< Double_t, Double_t > > GetResponse(Double_t input)
This method will return a vector of std::pair, each pair will contain the output energy together with...
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestAxionSolarFlux.
static std::vector< int > CanvasDivisions(int n)
It returns a vector with 2 components {a,b}, the components satisfy that a x b = n,...
std::string IntegerToString(Int_t n, std::string format="%d")
Gets a string from an integer.
Int_t StringToInteger(std::string in)
Gets an integer from a string.
std::vector< int > IntegerToBinary(int number, size_t dimension=0)
It returns an integer vector with the binary digits decomposed.