41 #include "TRestExperiment.h"
90 void TRestExperiment::GenerateMockDataSet(Bool_t useAverage) {
94 RESTError <<
"TRestExperiment::GenerateMockData. Background component was not initialized!"
100 RESTError <<
"The experimental exposure time has not been defined" <<
RESTendl;
101 RESTError <<
"This time is required to create the mock dataset" <<
RESTendl;
106 Int_t N =
fRandom->Poisson(meanCounts);
108 RESTInfo <<
"Experiment: " << GetName() <<
" Generating mock dataset. Counts: " << N <<
RESTendl;
110 ROOT::RDF::RNode df =
fBackground->GetMonteCarloDataFrame(N);
133 RESTWarning <<
"TRestExperiment::SetExperimentalDataSet. Signal and background components must "
134 "be available before atempt to load experimental data"
141 for (
const auto& v :
fSignal->GetVariables()) {
142 if (std::find(columns.begin(), columns.end(), v) == columns.end()) {
143 RESTError <<
"TRestExperiment::SetExperimentalDataSetFile a component variable was not found in "
160 while (md !=
nullptr) {
161 if (md->InheritsFrom(
"TRestComponent")) {
163 if (
ToLower(comp->GetNature()) ==
"background")
165 else if (
ToLower(comp->GetNature()) ==
"signal")
168 RESTWarning <<
"TRestExperiment::InitFromConfigFile. Unknown component!" <<
RESTendl;
175 if (ele !=
nullptr) {
176 std::string filename =
GetParameter(
"filename", ele,
"");
177 std::string component =
GetParameter(
"component", ele,
"");
179 if (filename.empty())
181 <<
"TRestExperiment. There is a problem with `filename` definition inside <addComponent."
183 if (component.empty())
185 <<
"TRestExperiment. There is a problem with `component` definition inside <addComponent."
189 TFile* file = TFile::Open(filename.c_str(),
"READ");
190 if (file !=
nullptr) {
193 if (
ToLower(comp->GetNature()) ==
"signal")
195 else if (
ToLower(comp->GetNature()) ==
"background")
198 RESTError <<
"TRestExperiment::InitFromConfigFile. Component : " << component
201 RESTError <<
"TRestExperiment::InitFromConfigFile. Component : " << component
202 <<
" not found! File : " << filename <<
RESTendl;
212 RESTWarning <<
"The exposure time is not zero but a experimental data filename was defined!"
214 RESTWarning <<
"The exposure time will be recovered from the dataset duration. To avoid confusion is"
216 RESTWarning <<
"better that you set exposure time to zero inside the RML definition," <<
RESTendl;
218 <<
" or do not define a dataset if you wish to generate mock data using the exposure time given"
223 RESTError <<
"TRestExperiment : " << GetName() <<
RESTendl;
224 RESTError <<
"There was a problem initiazing the signal component!" <<
RESTendl;
229 RESTError <<
"TRestExperiment : " << GetName() <<
RESTendl;
230 RESTError <<
"There was a problem initiazing the background component!" <<
RESTendl;
236 RESTError <<
"TRestExperiment : " << GetName() <<
RESTendl;
237 RESTError <<
"Background and signal components got different variable names or variable ordering!"
239 RESTError <<
"This will lead to undesired results during Likelihood calculation!" <<
RESTendl;
244 RESTError <<
"TRestExperiment : " << GetName() <<
RESTendl;
245 RESTError <<
"Background and signal components got different binning values!" <<
RESTendl;
246 RESTError <<
"This will lead to undesired results during Likelihood calculation!" <<
RESTendl;
251 std::vector<TVector2> bckRanges =
fBackground->GetRanges();
252 std::vector<TVector2> sgnlRanges =
fSignal->GetRanges();
253 for (
const TVector2& sRange : sgnlRanges) {
254 if (sRange.X() != bckRanges[cont].X() || sRange.Y() != bckRanges[cont].Y()) {
255 RESTError <<
"TRestExperiment : " << GetName() <<
RESTendl;
256 RESTError <<
"Background and signal components got different range definitions!" <<
RESTendl;
257 RESTError <<
"This will lead to undesired results during Likelihood calculation!" <<
RESTendl;
287 RESTMetadata <<
"The dataset was MC-generated" <<
RESTendl;
290 <<
" - The number of counts in dataset was generated with the mean background counts"
294 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.
Bool_t fUseAverage
The mock dataset will be generated using the mean counts instead of a real MonteCarlo.
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.