REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
 All Data Structures Namespaces Functions Variables Enumerations Enumerator Friends Pages
TRestComponentDataSet.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 
83 #include "TRestComponentDataSet.h"
84 
85 #include <numeric>
86 
87 #include <TKey.h>
88 #include <TLatex.h>
89 
90 ClassImp(TRestComponentDataSet);
91 
96 
101 
116 TRestComponentDataSet::TRestComponentDataSet(const char* cfgFileName, const std::string& name)
117  : TRestComponent(cfgFileName) {
118  Initialize();
119 
121 
123 }
124 
131 
132  SetSectionName(this->ClassName());
133 }
134 
150 Double_t TRestComponentDataSet::GetRate(std::vector<Double_t> point) {
151  if (!HasNodes()) {
152  RESTError << "TRestComponentDataSet::GetRate. The component has no nodes!" << RESTendl;
153  RESTError << "Try calling TRestComponentDataSet::LoadDataSets" << RESTendl;
154 
155  RESTInfo << "Trying to load datasets" << RESTendl;
156  LoadDataSets();
157  if (IsDataSetLoaded())
158  RESTInfo << "Sucess!" << RESTendl;
159  else
160  return 0;
161  }
162 
163  if (HasNodes() && fActiveNode == -1) {
164  RESTError << "TRestComponentDataSet::GetRate. Active node has not been defined" << RESTendl;
165  return 0;
166  }
167 
168  Double_t density =
169  GetDensityForActiveNode()->GetBinContent(GetDensityForActiveNode()->GetBin(point.data()));
170 
171  Double_t norm = 1;
172 
173  // Perhaps this value could be stored internally
174  // for (size_t n = 0; n < fNbins.size(); n++) norm = norm * (fRanges[n].Y() - fRanges[n].X()) / fNbins[n];
175 
176  return norm * density;
177 }
178 
184  THnD* dHist = GetDensityForActiveNode();
185 
186  Double_t integral = 0;
187  if (dHist != nullptr) integral = dHist->ComputeIntegral();
188 
189  // Perhaps this value could be stored internally
190  for (size_t n = 0; n < fNbins.size(); n++)
191  integral = integral * (fRanges[n].Y() - fRanges[n].X()) / fNbins[n];
192 
193  return integral;
194 }
195 
199 TCanvas* TRestComponentDataSet::DrawComponent(std::vector<std::string> drawVariables,
200  std::vector<std::string> scanVariables, Int_t binScanSize,
201  TString drawOption) {
202  if (drawVariables.size() > 2 || drawVariables.size() == 0) {
203  RESTError << "TRestComponentDataSet::DrawComponent. The number of variables to be drawn must "
204  "be 1 or 2!" << RESTendl;
205  return fCanvas;
206  }
207 
208  if (scanVariables.size() > 2 || scanVariables.size() == 0) {
209  RESTError << "TRestComponentDataSet::DrawComponent. The number of variables to be scanned must "
210  "be 1 or 2!" << RESTendl;
211  return fCanvas;
212  }
213 
215  std::vector<int> scanIndexes;
216  for (const auto& x : scanVariables) scanIndexes.push_back(GetVariableIndex(x));
217 
218  Int_t nPlots = 1;
219  size_t n = 0;
220  for (const auto& x : scanIndexes) {
221  if (fNbins[x] % binScanSize != 0) {
222  RESTWarning << "The variable " << scanVariables[n] << " contains " << fNbins[x]
223  << " bins and it doesnt match with a bin size " << binScanSize << RESTendl;
224  RESTWarning << "The bin size must be a multiple of the number of bins." << RESTendl;
225  RESTWarning << "Redefining bin size to 1." << RESTendl;
226  binScanSize = 1;
227  }
228  nPlots *= fNbins[x] / binScanSize;
229  n++;
230  }
231 
233  Int_t nPlotsX = 0;
234  Int_t nPlotsY = 0;
235 
236  if (scanIndexes.size() == 2) {
237  nPlotsX = fNbins[scanIndexes[0]] / binScanSize;
238  nPlotsY = fNbins[scanIndexes[1]] / binScanSize;
239  } else {
240  nPlotsX = TRestTools::CanvasDivisions(nPlots)[1];
241  nPlotsY = TRestTools::CanvasDivisions(nPlots)[0];
242  }
243 
244  RESTInfo << "Number of plots to be generated: " << nPlots << RESTendl;
245  RESTInfo << "Canvas size : " << nPlotsX << " x " << nPlotsY << RESTendl;
246 
248  if (fCanvas != nullptr) {
249  delete fCanvas;
250  fCanvas = nullptr;
251  }
252 
253  fCanvas = new TCanvas(this->GetName(), this->GetName(), 0, 0, nPlotsX * 640, nPlotsY * 480);
254  fCanvas->Divide(nPlotsX, nPlotsY, 0.01, 0.01);
255 
256  std::vector<int> variableIndexes;
257  for (const auto& x : drawVariables) variableIndexes.push_back(GetVariableIndex(x));
258 
259  for (int n = 0; n < nPlotsX; n++)
260  for (int m = 0; m < nPlotsY; m++) {
261  fCanvas->cd(n * nPlotsY + m + 1);
262 
263  THnD* hnd = GetDensity();
264 
265  int binXo = binScanSize * n + 1;
266  int binXf = binScanSize * n + binScanSize;
267  int binYo = binScanSize * m + 1;
268  int binYf = binScanSize * m + binScanSize;
269 
270  if (scanVariables.size() == 2) {
271  hnd->GetAxis(scanIndexes[0])->SetRange(binXo, binXf);
272  hnd->GetAxis(scanIndexes[1])->SetRange(binYo, binYf);
273  } else if (scanVariables.size() == 1) {
274  binXo = binScanSize * nPlotsY * n + binScanSize * m + 1;
275  binXf = binScanSize * nPlotsY * n + binScanSize * m + binScanSize;
276  hnd->GetAxis(scanIndexes[0])->SetRange(binXo, binXf);
277  }
278 
279  if (variableIndexes.size() == 1) {
280  TH1D* h1 = hnd->Projection(variableIndexes[0]);
281  std::string hName;
282 
283  if (scanIndexes.size() == 2)
284  hName = scanVariables[0] + "(" + IntegerToString(binXo) + ", " + IntegerToString(binXf) +
285  ") " + scanVariables[1] + "(" + IntegerToString(binYo) + ", " +
286  IntegerToString(binYf) + ") ";
287 
288  if (scanIndexes.size() == 1)
289  hName = scanVariables[0] + "(" + IntegerToString(binXo) + ", " + IntegerToString(binXf) +
290  ") ";
291 
292  TH1D* newh = (TH1D*)h1->Clone(hName.c_str());
293  newh->SetTitle(hName.c_str());
294  newh->SetStats(false);
295  newh->GetXaxis()->SetTitle((TString)drawVariables[0]);
296  newh->SetMarkerStyle(kFullCircle);
297  newh->Draw("PLC PMC");
298 
299  TString entriesStr = "Entries: " + IntegerToString(newh->GetEntries());
300  TLatex* textLatex = new TLatex(0.62, 0.825, entriesStr);
301  textLatex->SetNDC();
302  textLatex->SetTextColor(1);
303  textLatex->SetTextSize(0.05);
304  textLatex->Draw("same");
305  delete h1;
306  }
307 
308  if (variableIndexes.size() == 2) {
309  TH2D* h2 = hnd->Projection(variableIndexes[0], variableIndexes[1]);
310 
311  std::string hName;
312  if (scanIndexes.size() == 2)
313  hName = scanVariables[0] + "(" + IntegerToString(binXo) + ", " + IntegerToString(binXf) +
314  ") " + scanVariables[1] + "(" + IntegerToString(binYo) + ", " +
315  IntegerToString(binYf) + ") ";
316 
317  if (scanIndexes.size() == 1)
318  hName = scanVariables[0] + "(" + IntegerToString(binXo) + ", " + IntegerToString(binXf) +
319  ") ";
320 
321  TH2D* newh = (TH2D*)h2->Clone(hName.c_str());
322  newh->SetStats(false);
323  newh->GetXaxis()->SetTitle((TString)drawVariables[0]);
324  newh->GetYaxis()->SetTitle((TString)drawVariables[1]);
325  newh->SetTitle(hName.c_str());
326  newh->Draw(drawOption);
327 
328  TString entriesStr = "Entries: " + IntegerToString(newh->GetEntries());
329  TLatex* textLatex = new TLatex(0.62, 0.825, entriesStr);
330  textLatex->SetNDC();
331  textLatex->SetTextColor(1);
332  textLatex->SetTextSize(0.05);
333  textLatex->Draw("same");
334  delete h2;
335  }
336  }
337 
338  return fCanvas;
339 }
340 
346 
347  if (!fDataSetFileNames.empty()) {
348  RESTMetadata << " " << RESTendl;
349  RESTMetadata << " == Dataset filenames ==" << RESTendl;
350 
351  for (const auto& x : fDataSetFileNames) RESTMetadata << "- " << x << RESTendl;
352 
353  RESTMetadata << " " << RESTendl;
354  }
355 
356  if (!fParameter.empty() && fParameterizationNodes.empty()) {
357  RESTMetadata << "This component has no nodes!" << RESTendl;
358  RESTMetadata << " Use: LoadDataSets() to initialize the nodes" << RESTendl;
359  }
360 
361  if (!fWeights.empty()) {
362  RESTMetadata << " " << RESTendl;
363  RESTMetadata << " == Weights ==" << RESTendl;
364 
365  for (const auto& x : fWeights) RESTMetadata << "- " << x << RESTendl;
366 
367  RESTMetadata << " " << RESTendl;
368  }
369 
370  RESTMetadata << " Use : PrintStatistics() to check node statistics" << RESTendl;
371  RESTMetadata << "----" << RESTendl;
372 }
373 
379 
380  if (!HasNodes() && !IsDataSetLoaded()) {
381  RESTWarning << "TRestComponentDataSet::PrintStatistics. Empty nodes and no dataset loaded!"
382  << RESTendl;
383  RESTWarning << "Invoking TRestComponentDataSet::LoadDataSets might solve the problem" << RESTendl;
384  return;
385  }
386 
387  auto result = std::accumulate(fNSimPerNode.begin(), fNSimPerNode.end(), 0);
388  std::cout << "Total counts : " << result << std::endl;
389  std::cout << std::endl;
390 
391  std::cout << " Parameter node statistics (" << fParameter << ")" << std::endl;
392  int n = 0;
393  for (const auto& p : fParameterizationNodes) {
394  std::cout << " - Value : " << p << " Counts: " << fNSimPerNode[n] << std::endl;
395  n++;
396  }
397 }
398 
404 
405  auto ele = GetElement("dataset");
406  while (ele != nullptr) {
407  fDataSetFileNames.push_back(GetParameter("filename", ele, ""));
408  ele = GetNextElement(ele);
409  }
410 }
411 
418 
419  if (!IsDataSetLoaded()) {
420  RESTError << "TRestComponentDataSet::FillHistograms. Dataset has not been initialized!" << RESTendl;
421  return;
422  }
423 
424  if (fParameterizationNodes.empty()) {
425  RESTWarning << "Nodes have not been defined" << RESTendl;
426  RESTWarning << "The full dataset will be used to generate the density distribution" << RESTendl;
427  fParameterizationNodes.push_back(-137);
428  }
429 
430  RESTInfo << "Generating N-dim histograms" << RESTendl;
431  int nIndex = 0;
432  for (const auto& node : fParameterizationNodes) {
433  ROOT::RDF::RNode df = ROOT::RDataFrame(0);
436  if (fParameterizationNodes.size() == 1 && node == -137) {
437  RESTInfo << "Creating component with no parameters (full dataset used)" << RESTendl;
438  df = fDataSet.GetDataFrame();
439  fParameterizationNodes.clear();
440  } else {
441  RESTInfo << "Creating THnD for parameter " << fParameter << ": " << DoubleToString(node)
442  << RESTendl;
443  std::string filter = fParameter + " == " + DoubleToString(node);
444  df = fDataSet.GetDataFrame().Filter(filter);
445  }
446 
447  Int_t* bins = new Int_t[fNbins.size()];
448  Double_t* xmin = new Double_t[fNbins.size()];
449  Double_t* xmax = new Double_t[fNbins.size()];
450 
451  for (size_t n = 0; n < fNbins.size(); n++) {
452  bins[n] = fNbins[n];
453  xmin[n] = fRanges[n].X();
454  xmax[n] = fRanges[n].Y();
455  }
456 
457  TString hName = fParameter + "_" + DoubleToString(node);
458  if (fParameterizationNodes.empty()) hName = "full";
459 
460  std::vector<std::string> varsAndWeight = fVariables;
461 
462  if (!fWeights.empty()) {
463  std::string weightsStr = "";
464  for (size_t n = 0; n < fWeights.size(); n++) {
465  if (n > 0) weightsStr += "*";
466 
467  weightsStr += fWeights[n];
468  }
469  df = df.Define("componentWeight", weightsStr);
470  varsAndWeight.push_back("componentWeight");
471  }
472 
473  auto hn = df.HistoND({hName, hName, (int)fNbins.size(), bins, xmin, xmax}, varsAndWeight);
474  THnD* hNd = new THnD(*hn);
475  hNd->Scale(1. / fNSimPerNode[nIndex]);
476 
477  fNodeDensity.push_back(hNd);
478  fActiveNode = nIndex;
479  nIndex++;
480  }
481 }
482 
486 THnD* TRestComponentDataSet::GetDensityForNode(Double_t node) {
487  int n = 0;
488  for (const auto& x : fParameterizationNodes) {
489  if (x == node) {
490  return fNodeDensity[n];
491  }
492  n++;
493  }
494 
495  RESTError << "Parametric node : " << node << " was not found in component" << RESTendl;
496  PrintNodes();
497  return nullptr;
498 }
499 
503 THnD* TRestComponentDataSet::GetDensityForActiveNode() {
504  if (fActiveNode >= 0) return fNodeDensity[fActiveNode];
505 
506  RESTError << "The active node is invalid" << RESTendl;
507  PrintNodes();
508  return nullptr;
509 }
510 
515 TH1D* TRestComponentDataSet::GetHistogram(Double_t node, std::string varName) {
516  SetActiveNode(node);
517  return GetHistogram(varName);
518 }
519 
525 TH1D* TRestComponentDataSet::GetHistogram(std::string varName) {
526  if (fActiveNode < 0) return nullptr;
527 
528  Int_t v1 = GetVariableIndex(varName);
529 
530  if (v1 >= 0 && GetDensityForActiveNode()) return GetDensityForActiveNode()->Projection(v1);
531 
532  return nullptr;
533 }
534 
539 TH2D* TRestComponentDataSet::GetHistogram(Double_t node, std::string varName1, std::string varName2) {
540  SetActiveNode(node);
541  return GetHistogram(varName1, varName2);
542 }
543 
549 TH2D* TRestComponentDataSet::GetHistogram(std::string varName1, std::string varName2) {
550  if (fActiveNode < 0) return nullptr;
551 
552  Int_t v1 = GetVariableIndex(varName1);
553  Int_t v2 = GetVariableIndex(varName2);
554 
555  if (v1 >= 0 && v2 >= 0)
556  if (GetDensityForActiveNode()) return GetDensityForActiveNode()->Projection(v1, v2);
557 
558  return nullptr;
559 }
560 
565 TH3D* TRestComponentDataSet::GetHistogram(Double_t node, std::string varName1, std::string varName2,
566  std::string varName3) {
567  SetActiveNode(node);
568  return GetHistogram(varName1, varName2, varName3);
569 }
570 
576 TH3D* TRestComponentDataSet::GetHistogram(std::string varName1, std::string varName2, std::string varName3) {
577  if (fActiveNode < 0) return nullptr;
578 
579  Int_t v1 = GetVariableIndex(varName1);
580  Int_t v2 = GetVariableIndex(varName2);
581  Int_t v3 = GetVariableIndex(varName3);
582 
583  if (v1 >= 0 && v2 >= 0 && v3 >= 0)
584  if (GetDensityForActiveNode()) return GetDensityForActiveNode()->Projection(v1, v2, v3);
585 
586  return nullptr;
587 }
588 
597  if (!fParameterizationNodes.empty()) return fParameterizationNodes;
598 
599  RESTInfo << "Extracting parameterization nodes" << RESTendl;
600 
601  std::vector<double> vs;
602  if (!IsDataSetLoaded()) {
603  RESTError << "TRestComponentDataSet::ExtractParameterizationNodes. Dataset has not been initialized!"
604  << RESTendl;
605  return vs;
606  }
607 
608  auto parValues = fDataSet.GetDataFrame().Take<double>(fParameter);
609  for (const auto v : parValues) vs.push_back(v);
610 
611  std::vector<double>::iterator ip;
612  ip = std::unique(vs.begin(), vs.begin() + vs.size());
613  vs.resize(std::distance(vs.begin(), ip));
614  std::sort(vs.begin(), vs.end());
615  ip = std::unique(vs.begin(), vs.end());
616  vs.resize(std::distance(vs.begin(), ip));
617 
618  return vs;
619 }
620 
629  if (!fNSimPerNode.empty()) return fNSimPerNode;
630 
631  std::vector<Int_t> stats;
632  if (!IsDataSetLoaded()) {
633  RESTError << "TRestComponentDataSet::ExtractNodeStatistics. Dataset has not been initialized!"
634  << RESTendl;
635  return stats;
636  }
637 
638  RESTInfo << "Counting statistics for each node ..." << RESTendl;
639  RESTInfo << "Number of nodes : " << fParameterizationNodes.size() << RESTendl;
640  for (const auto& p : fParameterizationNodes) {
641  std::string filter = fParameter + " == " + DoubleToString(p);
642  auto nEv = fDataSet.GetDataFrame().Filter(filter).Count();
643  stats.push_back(*nEv);
644  }
645  return stats;
646 }
647 
654  if (fDataSetFileNames.empty()) {
655  RESTWarning << "Dataset filename was not defined. You may still use "
656  "TRestComponentDataSet::LoadDataSet( filename );" << RESTendl;
657  fDataSetLoaded = false;
658  return fDataSetLoaded;
659  }
660 
661  RESTInfo << "Loading datasets" << RESTendl;
662 
663  std::vector<std::string> fullFileNames;
664  for (const auto& name : fDataSetFileNames) {
665  // TODO we get here a list of files. However, we will need to weight each dataset with a factor
666  // to consider the contribution of each background component.
667  // Of course, we could previously take a factor into account already in the dataset, through the
668  // definition of a new column. But being this way would allow us to play around with the
669  // background model without having to regenerate the dataset.
670  std::string fileName = SearchFile(name);
671  if (fileName.empty()) {
672  RESTError << "TRestComponentDataSet::LoadDataSet. Error loading file : " << name << RESTendl;
673  RESTError << "Does the file exist?" << RESTendl;
674  RESTError << "You may use `<globals> <searchPath ...` to indicate the path location" << RESTendl;
675  return false;
676  }
677  fullFileNames.push_back(fileName);
678  }
679 
680  fDataSet.Import(fullFileNames);
681  fDataSetLoaded = true;
682 
683  if (fDataSet.GetTree() == nullptr) {
684  RESTError << "Problem loading dataset from file list :" << RESTendl;
685  for (const auto& f : fDataSetFileNames) RESTError << " - " << f << RESTendl;
686  return false;
687  }
688 
690 
691  if (VariablesOk() && WeightsOk()) {
692  fParameterizationNodes = ExtractParameterizationNodes();
693  FillHistograms();
694  return fDataSetLoaded;
695  }
696 
697  return fDataSetLoaded;
698 }
699 
704  Bool_t ok = true;
705  std::vector cNames = fDataSet.GetDataFrame().GetColumnNames();
706 
707  for (const auto var : fVariables)
708  if (std::count(cNames.begin(), cNames.end(), var) == 0) {
709  RESTError << "Variable ---> " << var << " <--- NOT found on dataset" << RESTendl;
710  ok = false;
711  }
712  return ok;
713 }
714 
719  Bool_t ok = true;
720  std::vector cNames = fDataSet.GetDataFrame().GetColumnNames();
721 
722  for (const auto var : fWeights)
723  if (std::count(cNames.begin(), cNames.end(), var) == 0) {
724  RESTError << "Weight ---> " << var << " <--- NOT found on dataset" << RESTendl;
725  ok = false;
726  }
727  return ok;
728 }
729 
735  if (!IsDataSetLoaded()) {
736  RESTWarning << "TRestComponentDataSet::ValidDataSet. Dataset has not been loaded" << RESTendl;
737  RESTWarning << "Try calling TRestComponentDataSet::LoadDataSets" << RESTendl;
738 
739  RESTInfo << "Trying to load datasets" << RESTendl;
740  LoadDataSets();
741  if (IsDataSetLoaded()) {
742  RESTInfo << "Sucess!" << RESTendl;
743  } else {
744  RESTError << "Failed loading datasets" << RESTendl;
745  return false;
746  }
747  }
748 
749  if (HasNodes() && fActiveNode == -1) {
750  RESTError << "TRestComponentDataSet::ValidDataSet. Active node has not been defined" << RESTendl;
751  return false;
752  }
753  return true;
754 }
It defines a background/signal model distribution in a given parameter space (tipically x...
std::vector< Double_t > fParameterizationNodes
It defines the nodes of the parameterization (Initialized by the dataset)
void Initialize() override
It will initialize the data frame with the filelist and column names (or observables) that have been ...
std::string IntegerToString(Int_t n, std::string format="%d")
Gets a string from an integer.
std::vector< TVector2 > fRanges
The range of each of the variables used to create the PDF distribution.
std::vector< THnD * > fNodeDensity
The generated N-dimensional variable space density for a given node.
Bool_t IsDataSetLoaded()
This method should go to TRestComponentDataSet.
void SetSectionName(std::string sName)
set the section name, clear the section content
Bool_t ValidDataSet()
Takes care of initializing datasets if have not been initialized. On sucess it returns true...
~TRestComponentDataSet()
Default destructor.
TRestDataSet fDataSet
The dataset used to initialize the distribution.
std::string fParameter
It is used to parameterize a set of distribution densities (e.g. WIMP or axion mass) ...
void Import(const std::string &fileName)
This function imports metadata from a root file it import metadata info from the previous dataSet whi...
TCanvas * fCanvas
A canvas for drawing the active node component.
Double_t GetTotalRate() override
This method integrates the rate to all the parameter space defined in the density function...
TiXmlElement * GetElement(std::string eleDeclare, TiXmlElement *e=nullptr)
Get an xml element from a given parent element, according to its declaration.
std::vector< Int_t > fNbins
The number of bins in which we should divide each variable.
Bool_t LoadDataSets()
A method responsible to import a list of TRestDataSet into fDataSet and check that the variables and ...
std::vector< Int_t > ExtractNodeStatistics()
It returns a vector with the number of entries found for each parameterization node.
void PrintStatistics()
It prints out the statistics available for each parametric node.
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestAxionSolarFlux.
Bool_t HasNodes()
It returns true if any nodes have been defined.
Int_t fActiveNode
It is used to define the node that will be accessed for rate retrieval.
void FillHistograms()
It will produce a histogram with the distribution defined using the variables and the weights for eac...
ROOT::RDF::RNode GetDataFrame() const
Gives access to the RDataFrame.
Definition: TRestDataSet.h:124
Double_t GetRate(std::vector< Double_t > point) override
It returns the intensity/rate (in seconds) corresponding to the generated distribution or formula eva...
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestAxionSolarFlux.
std::string DoubleToString(Double_t d, std::string format="%8.6e")
Gets a string from a double.
std::string fConfigFileName
Full name of the rml file.
void InitFromConfigFile() override
It customizes the retrieval of XML data values of this class.
+show most of the information for each steps
Int_t SetActiveNode(Double_t node)
It returns the position of the fParameterizationNodes element for the variable name given by argument...
Bool_t VariablesOk()
It returns true if all variables have been found inside TRestDataSet.
Bool_t WeightsOk()
It returns true if all weights have been found inside TRestDataSet.
std::vector< std::string > fVariables
A list with the branches that will be used to create the distribution space.
void InitFromConfigFile() override
It customizes the retrieval of XML data values of this class.
TCanvas * DrawComponent(std::vector< std::string > drawVariables, std::vector< std::string > scanVariables, Int_t binScanSize=1, TString drawOption="")
TRestStringOutput::REST_Verbose_Level GetVerboseLevel()
returns the verboselevel in type of REST_Verbose_Level enumerator
std::vector< Int_t > fNSimPerNode
It defines the number of entries for each parameterization node (Initialized by the dataset) ...
std::vector< std::string > fWeights
A list with the dataset columns used to weight the distribution density and define rate...
TiXmlElement * GetNextElement(TiXmlElement *e)
Get the next sibling xml element of this element, with same eleDeclare.
Bool_t fDataSetLoaded
It is true of the dataset was loaded without issues.
std::vector< Double_t > ExtractParameterizationNodes()
It returns a vector with all the different values found on the dataset column for the user given para...
void PrintNodes()
It prints out on screen the values of the parametric node.
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestDataSet.
std::string SearchFile(std::string filename)
Search files in current directory and directories specified in &quot;searchPath&quot; section.
static std::vector< int > CanvasDivisions(int n)
It returns a vector with 2 components {a,b}, the components satisfy that a x b = n, being the ratio a/b as close to 1 as possible.
Int_t LoadConfigFromFile(const std::string &configFilename, const std::string &sectionName="")
Give the file name, find out the corresponding section. Then call the main starter.
It defines a background/signal model distribution in a given parameter space (tipically x...
TH1D * GetHistogram(Double_t node, std::string varName)
It returns a 1-dimensional projected histogram for the variable names provided in the argument...
std::vector< std::string > fDataSetFileNames
The filename of the dataset used.
TTree * GetTree() const
Gives access to the tree.
Definition: TRestDataSet.h:134
void Initialize() override
It will initialize the data frame with the filelist and column names (or observables) that have been ...
Int_t GetVariableIndex(std::string varName)
It returns the position of the fVariable element for the variable name given by argument.
endl_t RESTendl
Termination flag object for TRestStringOutput.
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.
TRestComponentDataSet()
Default constructor.