41#include "TRestExperimentList.h"
92 RESTError <<
"TRestExperimentList::InitFromConfigFile. The experiments table is empty!"
101 while (comp !=
nullptr) {
102 if (
ToLower(comp->GetNature()) ==
"background")
104 else if (
ToLower(comp->GetNature()) ==
"signal")
107 RESTWarning <<
"TRestExperimentList::InitFromConfigFile. Unknown component!" <<
RESTendl;
113 Int_t nExpectedColumns = 3;
114 if (
fSignal) nExpectedColumns--;
118 if (nExpectedColumns == 0) {
119 RESTError <<
"TRestExperimentList::InitFromConfigFile. At least one free parameter required! "
120 "(Exposure/Background/Signal)"
125 if (nExpectedColumns != nTableColumns) {
126 std::string expectedColumns =
"";
130 expectedColumns +=
"signal";
134 expectedColumns +=
"background";
137 RESTError <<
"TRestExperimentList::InitFromConfigFile. Number of expected columns does not match "
138 "the number of table columns"
140 RESTError <<
"Number of table columns : " << nTableColumns <<
RESTendl;
141 RESTError <<
"Number of expected columns : " << nExpectedColumns <<
RESTendl;
142 RESTError <<
"Expected columns : " << expectedColumns <<
RESTendl;
148 Bool_t generateMockData =
false;
152 std::string rowStr =
"";
153 for (
const auto& el : experimentRow) {
157 RESTInfo <<
"TRestExperimentList. Loading experiment: " << rowStr <<
RESTendl;
162 experiment->SetExposureInSeconds(
165 generateMockData =
true;
168 std::string fname =
SearchFile(experimentRow[column]);
170 RESTWarning <<
"Loading experimental data havent been tested yet!" <<
RESTendl;
172 <<
"It might require further development. Remove these lines once it works smooth!"
175 RESTError << experimentRow[column] <<
" is not a exposure time or an experimental dataset"
183 generateMockData =
true;
188 if (GetComponent(experimentRow[column])) {
190 sgnl->SetName((TString)experimentRow[column]);
191 experiment->SetSignal(sgnl);
193 RESTError <<
"TRestExperimentList. Signal component : " << experimentRow[column]
198 experiment->SetSignal(
fSignal);
202 if (GetComponent(experimentRow[column])) {
204 experiment->SetBackground(bck);
206 RESTError <<
"TRestExperimentList. Background component : " << experimentRow[column]
213 if (generateMockData) {
214 RESTInfo <<
"TRestExperimentList. Generating mock dataset" <<
RESTendl;
215 experiment->GenerateMockDataSet();
218 if (experiment->GetSignal() && experiment->GetBackground()) {
219 experiment->SetName(experiment->GetSignal()->GetName());
230 Double_t Coefficient = 0;
232 Double_t expectedRate = 0;
234 Int_t nd = experiment->GetSignal()->FindActiveNode(node);
236 experiment->GetSignal()->SetActiveNode(nd);
237 expectedRate += experiment->GetSignal()->GetTotalRate();
241 Coefficient += 1. / node / expectedRate;
244 Double_t expectedRate = 0;
248 Int_t nd = experiment->GetSignal()->FindActiveNode(node);
250 experiment->GetSignal()->SetActiveNode(nd);
251 expectedRate += node * experiment->GetSignal()->GetTotalRate();
254 Double_t experimentTime =
fExposureTime / Coefficient / expectedRate;
255 experiment->SetExposureInSeconds(experimentTime *
units(
"s"));
258 Double_t totalExp = 0;
259 for (
const auto& experiment :
fExperiments) totalExp += experiment->GetExposureInSeconds();
262 Double_t xp = experiment->GetExposureInSeconds();
264 experiment->GenerateMockDataSet();
281 std::vector<Double_t> nodes = experiment->GetSignal()->GetParameterizationNodes();
290void TRestExperimentList::PrintParameterizationNodes() {
291 std::cout <<
"Experiment list nodes: ";
293 std::cout << std::endl;
296TRestComponent* TRestExperimentList::GetComponent(std::string compName) {
299 TFile* f = TFile::Open(c.c_str(),
"READ");
300 TObject* obj = f->Get((TString)compName);
304 if (obj->InheritsFrom(
"TRestComponent")) {
307 RESTError <<
"An object named : " << compName
308 <<
" exists inside the file, but it does not inherit from TRestComponent" <<
RESTendl;
It defines a background/signal model distribution in a given parameter space (tipically x,...
A helper metadata class to create a list of TRestExperiment instances.
std::string fExperimentsFile
A file where we define experiment components, exposureTime, and tracking data of each experiment.
std::vector< TRestExperiment * > fExperiments
A vector with a list of experiments includes the background components in this model.
std::vector< Double_t > fParameterizationNodes
The fusioned list of parameterization nodes found at each experiment signal.
std::vector< std::string > fComponentFiles
A vector with filenames containing the components.
void InitFromConfigFile() override
It customizes the retrieval of XML data values of this class.
TRestComponent * fBackground
If not null this will be the common signal used in each experiment.
void Initialize() override
It will initialize the data frame with the filelist and column names (or observables) that have been ...
std::string fExposureStrategy
In case an exposure time is given it defines how to assign time to each experiment (unique/ksvz).
void ExtractExperimentParameterizationNodes()
It scans all the experiment signals parametric nodes to build a complete list of nodes used to build ...
std::string fComponentPattern
A fullpath filename pattern helping to initialize the component files vector.
TRestExperimentList()
Default constructor.
TRestComponent * fSignal
If not null this will be the common signal used in each experiment.
std::vector< std::vector< std::string > > fExperimentsTable
A table with the experiment file information.
~TRestExperimentList()
Default destructor.
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestAxionSolarFlux.
Double_t fExposureTime
If not zero this will be the common exposure time in micro-seconds (standard REST units)
It includes a model definition and experimental data used to obtain a final experimental sensitivity.
void SetExperimentalDataSet(const std::string &filename)
Double_t StringToDouble(std::string in)
Gets a double from a string.
std::string ToLower(std::string in)
Convert string to its lower case. Alternative of TString::ToLower.
Int_t isANumber(std::string in)
Returns 1 only if a valid number is found in the string in. If not it returns 0.
std::string ReplaceMathematicalExpressions(std::string buffer, Int_t precision=0, std::string errorMessage="")
Evaluates and replaces valid mathematical expressions found in the input string buffer.