41#include "TRestExperiment.h"
90void TRestExperiment::GenerateMockDataSet() {
92 RESTError <<
"TRestExperiment::GenerateMockData. Background component was not initialized!"
98 RESTError <<
"The experimental exposure time has not been defined" <<
RESTendl;
99 RESTError <<
"This time is required to create the mock dataset" <<
RESTendl;
104 Int_t N =
fRandom->Poisson(meanCounts);
105 RESTInfo <<
"Experiment: " << GetName() <<
" Generating mock dataset. Counts: " << N <<
RESTendl;
107 ROOT::RDF::RNode df =
fBackground->GetMonteCarloDataFrame(N);
130 RESTWarning <<
"TRestExperiment::SetExperimentalDataSet. Signal and background components must "
131 "be available before atempt to load experimental data"
138 for (
const auto& v :
fSignal->GetVariables()) {
139 if (std::find(columns.begin(), columns.end(), v) == columns.end()) {
140 RESTError <<
"TRestExperiment::SetExperimentalDataSetFile a component variable was not found in "
157 while (comp !=
nullptr) {
158 if (
ToLower(comp->GetNature()) ==
"background")
160 else if (
ToLower(comp->GetNature()) ==
"signal")
163 RESTWarning <<
"TRestExperiment::InitFromConfigFile. Unknown component!" <<
RESTendl;
170 if (ele !=
nullptr) {
171 std::string filename =
GetParameter(
"filename", ele,
"");
172 std::string component =
GetParameter(
"component", ele,
"");
174 if (filename.empty())
176 <<
"TRestExperiment. There is a problem with `filename` definition inside <addComponent."
178 if (component.empty())
180 <<
"TRestExperiment. There is a problem with `component` definition inside <addComponent."
184 TFile* file = TFile::Open(filename.c_str(),
"READ");
185 if (file !=
nullptr) {
188 if (
ToLower(comp->GetNature()) ==
"signal")
190 else if (
ToLower(comp->GetNature()) ==
"background")
193 RESTError <<
"TRestExperiment::InitFromConfigFile. Component : " << component
196 RESTError <<
"TRestExperiment::InitFromConfigFile. Component : " << component
197 <<
" not found! File : " << filename <<
RESTendl;
203 GenerateMockDataSet();
207 RESTWarning <<
"The exposure time is not zero but a experimental data filename was defined!"
209 RESTWarning <<
"The exposure time will be recovered from the dataset duration. To avoid confusion is"
211 RESTWarning <<
"better that you set exposure time to zero inside the RML definition," <<
RESTendl;
213 <<
" or do not define a dataset if you wish to generate mock data using the exposure time given"
218 RESTError <<
"TRestExperiment : " << GetName() <<
RESTendl;
219 RESTError <<
"There was a problem initiazing the signal component!" <<
RESTendl;
224 RESTError <<
"TRestExperiment : " << GetName() <<
RESTendl;
225 RESTError <<
"There was a problem initiazing the background component!" <<
RESTendl;
231 RESTError <<
"TRestExperiment : " << GetName() <<
RESTendl;
232 RESTError <<
"Background and signal components got different variable names or variable ordering!"
234 RESTError <<
"This will lead to undesired results during Likelihood calculation!" <<
RESTendl;
239 RESTError <<
"TRestExperiment : " << GetName() <<
RESTendl;
240 RESTError <<
"Background and signal components got different binning values!" <<
RESTendl;
241 RESTError <<
"This will lead to undesired results during Likelihood calculation!" <<
RESTendl;
246 std::vector<TVector2> bckRanges =
fBackground->GetRanges();
247 std::vector<TVector2> sgnlRanges =
fSignal->GetRanges();
248 for (
const TVector2& sRange : sgnlRanges) {
249 if (sRange.X() != bckRanges[cont].X() || sRange.Y() != bckRanges[cont].Y()) {
250 RESTError <<
"TRestExperiment : " << GetName() <<
RESTendl;
251 RESTError <<
"Background and signal components got different range definitions!" <<
RESTendl;
252 RESTError <<
"This will lead to undesired results during Likelihood calculation!" <<
RESTendl;
282 RESTMetadata <<
"The dataset was MC-generated" <<
RESTendl;
284 RESTMetadata <<
"The dataset was loaded from an existing dataset file" <<
RESTendl;
It defines a background/signal model distribution in a given parameter space (tipically x,...
Double_t GetTotalRate()
This method integrates the rate to all the parameter space defined in the density function....
void Import(const std::string &fileName)
This function imports metadata from a root file it import metadata info from the previous dataSet whi...
ROOT::RDF::RNode GetDataFrame() const
Gives access to the RDataFrame.
Double_t GetTotalTimeInSeconds() const
It returns the accumulated run time in seconds.
It includes a model definition and experimental data used to obtain a final experimental sensitivity.
UInt_t fSeed
Seed used in random generator.
Int_t fExperimentalCounts
It keeps track on the number of counts inside the dataset.
TRestComponent * fBackground
A pointer to the background component.
Bool_t fDataReady
Only if it is true we will be able to calculate the LogLikelihood.
TRestComponent * fSignal
A pointer to the signal component.
void InitFromConfigFile() override
It customizes the retrieval of XML data values of this class.
void Initialize() override
It will initialize the data frame with the filelist and column names (or observables) that have been ...
~TRestExperiment()
Default destructor.
TRestExperiment()
Default constructor.
TRestDataSet fExperimentalData
It contains the experimental data (should contain same columns as the components)
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestAxionSolarFlux.
TRandom3 * fRandom
Internal process random generator.
void SetExperimentalDataSet(const std::string &filename)
std::string fExperimentalDataSet
It defines the filename used to load the dataset.
Double_t fExposureTime
The exposure time. If 0 it will be extracted from the tracking dataset (In us, standard REST unit)
Bool_t fMockData
If enabled it means that the experimental data was MC-generated.
std::string ToLower(std::string in)
Convert string to its lower case. Alternative of TString::ToLower.