From bed9ae900a5778ea79a314b25bd3d9c0d6c17c7a Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Mon, 19 Dec 2022 09:17:31 +0100 Subject: [PATCH 01/11] First upload of prototype classes --- source/framework/CMakeLists.txt | 2 +- .../sensitivity/inc/TRestComponent.h | 70 +++++++++++++ .../sensitivity/inc/TRestExperiment.h | 49 ++++++++++ source/framework/sensitivity/inc/TRestModel.h | 54 ++++++++++ .../framework/sensitivity/inc/TRestResponse.h | 43 ++++++++ .../sensitivity/inc/TRestSensitivity.h | 44 +++++++++ .../sensitivity/src/TRestComponent.cxx | 98 +++++++++++++++++++ .../sensitivity/src/TRestExperiment.cxx | 68 +++++++++++++ .../framework/sensitivity/src/TRestModel.cxx | 92 +++++++++++++++++ .../sensitivity/src/TRestResponse.cxx | 68 +++++++++++++ .../sensitivity/src/TRestSensitivity.cxx | 68 +++++++++++++ 11 files changed, 655 insertions(+), 1 deletion(-) create mode 100644 source/framework/sensitivity/inc/TRestComponent.h create mode 100644 source/framework/sensitivity/inc/TRestExperiment.h create mode 100644 source/framework/sensitivity/inc/TRestModel.h create mode 100644 source/framework/sensitivity/inc/TRestResponse.h create mode 100644 source/framework/sensitivity/inc/TRestSensitivity.h create mode 100644 source/framework/sensitivity/src/TRestComponent.cxx create mode 100644 source/framework/sensitivity/src/TRestExperiment.cxx create mode 100644 source/framework/sensitivity/src/TRestModel.cxx create mode 100644 source/framework/sensitivity/src/TRestResponse.cxx create mode 100644 source/framework/sensitivity/src/TRestSensitivity.cxx diff --git a/source/framework/CMakeLists.txt b/source/framework/CMakeLists.txt index af736aa5b..57cf0fecd 100644 --- a/source/framework/CMakeLists.txt +++ b/source/framework/CMakeLists.txt @@ -5,7 +5,7 @@ link_libraries("-fPIC") add_subdirectory(external) -set(contents external/tinyxml tools core analysis masks) +set(contents external/tinyxml tools core analysis masks sensitivity) file(GLOB_RECURSE addon_src "tiny*cpp" diff --git a/source/framework/sensitivity/inc/TRestComponent.h b/source/framework/sensitivity/inc/TRestComponent.h new file mode 100644 index 000000000..962d4ce66 --- /dev/null +++ b/source/framework/sensitivity/inc/TRestComponent.h @@ -0,0 +1,70 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see https://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see https://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +#ifndef REST_TRestComponent +#define REST_TRestComponent + +//#include "TRestDataSet.h" +#include "TRestMetadata.h" + +/// It defines a background/signal distribution in a given parameter space (tipically x,y,en) +class TRestComponent : public TRestMetadata { + private: + /// It defines how the distribution is initialized (dataset/formula) + std::string fType = "dataset"; + + /// A list (comma separated) with the branches that will be used to create the distribution + std::string fVariables; //< + + /// A list (comma separated) with the branches that will be used to weight the binning + std::string fWeights; //< + + /// The range of each of the variables used to create the distribution + std::vector fRange; //< + + /// The number of bins in which we should divide each variable + std::vector fNbins; //< + + /// The dataset used to initialize the distribution + // TRestDataSet fDataSet; //! + + /// The function used to initialize the distribution + std::string fFunction = ""; //! + + /// The function used to initialize the distribution + TFormula fFormula; //! + + /// A pointer to the component distribution + // THnD* fDistribution = nullptr; //! + + public: + Double_t GetRate(std::vector point); + + void PrintMetadata() override; + + void Initialize() override; + TRestComponent(); + ~TRestComponent(); + + ClassDefOverride(TRestComponent, 1); +}; +#endif diff --git a/source/framework/sensitivity/inc/TRestExperiment.h b/source/framework/sensitivity/inc/TRestExperiment.h new file mode 100644 index 000000000..36fc10992 --- /dev/null +++ b/source/framework/sensitivity/inc/TRestExperiment.h @@ -0,0 +1,49 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see https://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see https://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +#ifndef REST_TRestExperiment +#define REST_TRestExperiment + +#include "TRestDataSet.h" +#include "TRestMetadata.h" +#include "TRestModel.h" + +/// It includes a model definition and experimental data used to obtain a final experimental sensitivity +class TRestExperiment : public TRestMetadata { + private: + /// It contains the model definition, including signal and background + TRestModel* fModel = nullptr; //< + + /// It contains the experimental data to be compared with the model + TRestDataSet fExperimentalData; //< + + public: + void Initialize() override; + + void PrintMetadata() override; + + TRestExperiment(); + ~TRestExperiment(); + + ClassDefOverride(TRestExperiment, 1); +}; +#endif diff --git a/source/framework/sensitivity/inc/TRestModel.h b/source/framework/sensitivity/inc/TRestModel.h new file mode 100644 index 000000000..3aebbd7b0 --- /dev/null +++ b/source/framework/sensitivity/inc/TRestModel.h @@ -0,0 +1,54 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see https://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see https://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +#ifndef REST_TRestModel +#define REST_TRestModel + +#include "TRestComponent.h" +#include "TRestMetadata.h" + +/// A combination of signal and background components that build a complete signal and background model +class TRestModel : public TRestMetadata { + private: + // TODO At some point we may want to add here a coupling for each signal component + + /// A vector that includes the signal components in this model + std::vector fSignal; //< + + /// A vector that includes the background components in this model + std::vector fBackground; + + public: + void Initialize() override; + + Double_t GetSignal(std::vector point); + + Double_t GetBackground(std::vector point); + + void PrintMetadata() override; + + TRestModel(); + ~TRestModel(); + + ClassDefOverride(TRestModel, 1); +}; +#endif diff --git a/source/framework/sensitivity/inc/TRestResponse.h b/source/framework/sensitivity/inc/TRestResponse.h new file mode 100644 index 000000000..a47d3d23c --- /dev/null +++ b/source/framework/sensitivity/inc/TRestResponse.h @@ -0,0 +1,43 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see https://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see https://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +#ifndef REST_TRestResponse +#define REST_TRestResponse + +#include "TRestMetadata.h" + +/// A response matrix that might be applied to a given signal variable inside TRestResponse +class TRestResponse : public TRestMetadata { + private: + // TODO Add here the response matrix. Probably a TH2D + + public: + void Initialize() override; + + void PrintMetadata() override; + + TRestResponse(); + ~TRestResponse(); + + ClassDefOverride(TRestResponse, 1); +}; +#endif diff --git a/source/framework/sensitivity/inc/TRestSensitivity.h b/source/framework/sensitivity/inc/TRestSensitivity.h new file mode 100644 index 000000000..c8ad6f0db --- /dev/null +++ b/source/framework/sensitivity/inc/TRestSensitivity.h @@ -0,0 +1,44 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see https://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see https://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +#ifndef REST_TRestSensitivity +#define REST_TRestSensitivity + +#include "TRestExperiment.h" + +/// It combines a number of experimental conditions allowing to calculate a combined experimental sensitivity +class TRestSensitivity : public TRestMetadata { + private: + /// A list of experimental conditions included to get a final sensitivity plot + std::vector fExperiment; //< + + public: + void Initialize() override; + + void PrintMetadata() override; + + TRestSensitivity(); + ~TRestSensitivity(); + + ClassDefOverride(TRestSensitivity, 1); +}; +#endif diff --git a/source/framework/sensitivity/src/TRestComponent.cxx b/source/framework/sensitivity/src/TRestComponent.cxx new file mode 100644 index 000000000..ec37d52ec --- /dev/null +++ b/source/framework/sensitivity/src/TRestComponent.cxx @@ -0,0 +1,98 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see https://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see https://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +///////////////////////////////////////////////////////////////////////// +/// This class allows to make a selection of ROOT data files that fulfill +/// certain metadata conditions allowing to create a group of files that +/// define a particular dataset. The files will be searched in a relative +/// or absolute path that is given together the `filePattern` parameter. +/// +/// ### Basic file selection +/// +/// We will be able to define the dates range where files will be +/// accepted, using `startTime` and `endTime` parameters. The run start +/// time and end time stored inside TRestRun will be evaluated to decide +/// if the file should be considered. +/// +/// A summary of the basic parameters follows: +/// +/// * **filePattern**: A full path glob pattern to the files that will +/// be considered. It is a first filter considering the path and the +/// filename. Usual wild cards such as * or ? will be allowed to target +/// a given range of files. +/// +/// +///---------------------------------------------------------------------- +/// +/// REST-for-Physics - Software for Rare Event Searches Toolkit +/// +/// History of developments: +/// +/// 2022-December: First implementation of TRestComponent +/// Javier Galan +/// +/// \class TRestComponent +/// \author: Javier Galan (javier.galan.lacarra@cern.ch) +/// +///
+/// +#include "TRestComponent.h" + +ClassImp(TRestComponent); + +/////////////////////////////////////////////// +/// \brief Default constructor +/// +TRestComponent::TRestComponent() { Initialize(); } + +/////////////////////////////////////////////// +/// \brief Default destructor +/// +TRestComponent::~TRestComponent() {} + +/////////////////////////////////////////////// +/// \brief It will initialize the data frame with the filelist and column names +/// (or observables) that have been defined by the user. +/// +void TRestComponent::Initialize() { SetSectionName(this->ClassName()); } + +/////////////////////////////////////////////// +/// \brief It returns the intensity/rate (in seconds) corresponding to the +/// generated distribution or formula evaluated at the position of the parameter +/// space given by point. +/// +/// The size of the point vector must have the same dimension as the dimensions +/// of the distribution. +/// +Double_t TRestComponent::GetRate(std::vector point) { + // we get the rate in seconds at the corresponding bin + return 0.0; +} + +///////////////////////////////////////////// +/// \brief Prints on screen the information about the metadata members of TRestAxionSolarFlux +/// +void TRestComponent::PrintMetadata() { + TRestMetadata::PrintMetadata(); + + RESTMetadata << "----" << RESTendl; +} diff --git a/source/framework/sensitivity/src/TRestExperiment.cxx b/source/framework/sensitivity/src/TRestExperiment.cxx new file mode 100644 index 000000000..c67c5e3ee --- /dev/null +++ b/source/framework/sensitivity/src/TRestExperiment.cxx @@ -0,0 +1,68 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see https://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see https://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +///////////////////////////////////////////////////////////////////////// +/// Documentation TOBE written +/// +/// +///---------------------------------------------------------------------- +/// +/// REST-for-Physics - Software for Rare Event Searches Toolkit +/// +/// History of developments: +/// +/// 2022-December: First implementation of TRestExperiment +/// Javier Galan +/// +/// \class TRestExperiment +/// \author: Javier Galan (javier.galan.lacarra@cern.ch) +/// +///
+/// +#include "TRestExperiment.h" + +ClassImp(TRestExperiment); + +/////////////////////////////////////////////// +/// \brief Default constructor +/// +TRestExperiment::TRestExperiment() { Initialize(); } + +/////////////////////////////////////////////// +/// \brief Default destructor +/// +TRestExperiment::~TRestExperiment() {} + +/////////////////////////////////////////////// +/// \brief It will initialize the data frame with the filelist and column names +/// (or observables) that have been defined by the user. +/// +void TRestExperiment::Initialize() { SetSectionName(this->ClassName()); } + +///////////////////////////////////////////// +/// \brief Prints on screen the information about the metadata members of TRestAxionSolarFlux +/// +void TRestExperiment::PrintMetadata() { + TRestMetadata::PrintMetadata(); + + RESTMetadata << "----" << RESTendl; +} diff --git a/source/framework/sensitivity/src/TRestModel.cxx b/source/framework/sensitivity/src/TRestModel.cxx new file mode 100644 index 000000000..5dab1d460 --- /dev/null +++ b/source/framework/sensitivity/src/TRestModel.cxx @@ -0,0 +1,92 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see https://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see https://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +///////////////////////////////////////////////////////////////////////// +/// Documentation TOBE written +/// +/// +///---------------------------------------------------------------------- +/// +/// REST-for-Physics - Software for Rare Event Searches Toolkit +/// +/// History of developments: +/// +/// 2022-December: First implementation of TRestModel +/// Javier Galan +/// +/// \class TRestModel +/// \author: Javier Galan (javier.galan.lacarra@cern.ch) +/// +///
+/// +#include "TRestModel.h" + +ClassImp(TRestModel); + +/////////////////////////////////////////////// +/// \brief Default constructor +/// +TRestModel::TRestModel() { Initialize(); } + +/////////////////////////////////////////////// +/// \brief Default destructor +/// +TRestModel::~TRestModel() {} + +/////////////////////////////////////////////// +/// \brief It will initialize the data frame with the filelist and column names +/// (or observables) that have been defined by the user. +/// +void TRestModel::Initialize() { SetSectionName(this->ClassName()); } + +/////////////////////////////////////////////// +/// \brief It returns the intensity/rate (in seconds) corresponding to the +/// combined background. +/// +/// The size of the point vector must have the same dimension as the dimensions +/// of the distribution. +/// +Double_t TRestModel::GetBackground(std::vector point) { + // we get the rate in seconds at the corresponding bin + return 0.0; +} + +/////////////////////////////////////////////// +/// \brief It returns the intensity/rate (in seconds) corresponding to the +/// combined signal. +/// +/// The size of the point vector must have the same dimension as the dimensions +/// of the distribution. +/// +Double_t TRestModel::GetSignal(std::vector point) { + // we get the rate in seconds at the corresponding bin + return 0.0; +} + +///////////////////////////////////////////// +/// \brief Prints on screen the information about the metadata members of TRestAxionSolarFlux +/// +void TRestModel::PrintMetadata() { + TRestMetadata::PrintMetadata(); + + RESTMetadata << "----" << RESTendl; +} diff --git a/source/framework/sensitivity/src/TRestResponse.cxx b/source/framework/sensitivity/src/TRestResponse.cxx new file mode 100644 index 000000000..7211db5b8 --- /dev/null +++ b/source/framework/sensitivity/src/TRestResponse.cxx @@ -0,0 +1,68 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see https://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see https://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +///////////////////////////////////////////////////////////////////////// +/// Documentation TOBE written +/// +/// +///---------------------------------------------------------------------- +/// +/// REST-for-Physics - Software for Rare Event Searches Toolkit +/// +/// History of developments: +/// +/// 2022-December: First implementation of TRestResponse +/// Javier Galan +/// +/// \class TRestResponse +/// \author: Javier Galan (javier.galan.lacarra@cern.ch) +/// +///
+/// +#include "TRestResponse.h" + +ClassImp(TRestResponse); + +/////////////////////////////////////////////// +/// \brief Default constructor +/// +TRestResponse::TRestResponse() { Initialize(); } + +/////////////////////////////////////////////// +/// \brief Default destructor +/// +TRestResponse::~TRestResponse() {} + +/////////////////////////////////////////////// +/// \brief It will initialize the data frame with the filelist and column names +/// (or observables) that have been defined by the user. +/// +void TRestResponse::Initialize() { SetSectionName(this->ClassName()); } + +///////////////////////////////////////////// +/// \brief Prints on screen the information about the metadata members of TRestAxionSolarFlux +/// +void TRestResponse::PrintMetadata() { + TRestMetadata::PrintMetadata(); + + RESTMetadata << "----" << RESTendl; +} diff --git a/source/framework/sensitivity/src/TRestSensitivity.cxx b/source/framework/sensitivity/src/TRestSensitivity.cxx new file mode 100644 index 000000000..84503f12a --- /dev/null +++ b/source/framework/sensitivity/src/TRestSensitivity.cxx @@ -0,0 +1,68 @@ +/************************************************************************* + * This file is part of the REST software framework. * + * * + * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) * + * For more information see https://gifna.unizar.es/trex * + * * + * REST is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * REST is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have a copy of the GNU General Public License along with * + * REST in $REST_PATH/LICENSE. * + * If not, see https://www.gnu.org/licenses/. * + * For the list of contributors see $REST_PATH/CREDITS. * + *************************************************************************/ + +///////////////////////////////////////////////////////////////////////// +/// Documentation TOBE written +/// +/// +///---------------------------------------------------------------------- +/// +/// REST-for-Physics - Software for Rare Event Searches Toolkit +/// +/// History of developments: +/// +/// 2022-December: First implementation of TRestSensitivity +/// Javier Galan +/// +/// \class TRestSensitivity +/// \author: Javier Galan (javier.galan.lacarra@cern.ch) +/// +///
+/// +#include "TRestSensitivity.h" + +ClassImp(TRestSensitivity); + +/////////////////////////////////////////////// +/// \brief Default constructor +/// +TRestSensitivity::TRestSensitivity() { Initialize(); } + +/////////////////////////////////////////////// +/// \brief Default destructor +/// +TRestSensitivity::~TRestSensitivity() {} + +/////////////////////////////////////////////// +/// \brief It will initialize the data frame with the filelist and column names +/// (or observables) that have been defined by the user. +/// +void TRestSensitivity::Initialize() { SetSectionName(this->ClassName()); } + +///////////////////////////////////////////// +/// \brief Prints on screen the information about the metadata members of TRestAxionSolarFlux +/// +void TRestSensitivity::PrintMetadata() { + TRestMetadata::PrintMetadata(); + + RESTMetadata << "----" << RESTendl; +} From 711458f69646416ef648b9c734bfee2fa95ae3d9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 8 Mar 2023 11:09:21 +0000 Subject: [PATCH 02/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- source/framework/sensitivity/inc/TRestComponent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/framework/sensitivity/inc/TRestComponent.h b/source/framework/sensitivity/inc/TRestComponent.h index 962d4ce66..edf3f5785 100644 --- a/source/framework/sensitivity/inc/TRestComponent.h +++ b/source/framework/sensitivity/inc/TRestComponent.h @@ -23,7 +23,7 @@ #ifndef REST_TRestComponent #define REST_TRestComponent -//#include "TRestDataSet.h" +// #include "TRestDataSet.h" #include "TRestMetadata.h" /// It defines a background/signal distribution in a given parameter space (tipically x,y,en) From 3be2b1923b370b028e2a120b53abb676d713dc17 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Sat, 11 Mar 2023 07:09:34 +0100 Subject: [PATCH 03/11] startup.cpp Adding more output --- source/framework/core/src/startup.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/framework/core/src/startup.cpp b/source/framework/core/src/startup.cpp index 259956073..55d360a53 100644 --- a/source/framework/core/src/startup.cpp +++ b/source/framework/core/src/startup.cpp @@ -288,7 +288,8 @@ vector StringToVector(string vec) { } } else { - cout << "illegal format!" << endl; + cout << "Startup. StringToVector. Illegal format!" << endl; + cout << "A vector should be defined using brackets and comma separated elements: {a,b,c,d}" << endl; return vector{}; } From e96b2ff2c01001dc07928dd9272cb737469dd4c5 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Sat, 11 Mar 2023 10:43:45 +0100 Subject: [PATCH 04/11] TRestStringHelper::RemoteDelimiters method added --- source/framework/tools/inc/TRestStringHelper.h | 1 + .../framework/tools/src/TRestStringHelper.cxx | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/framework/tools/inc/TRestStringHelper.h b/source/framework/tools/inc/TRestStringHelper.h index c49b97225..f33929793 100644 --- a/source/framework/tools/inc/TRestStringHelper.h +++ b/source/framework/tools/inc/TRestStringHelper.h @@ -45,6 +45,7 @@ std::vector Split(std::string in, std::string separator, bool allow std::vector StringToElements(std::string in, std::string separator); std::vector StringToElements(std::string in, std::string headChar, std::string separator, std::string tailChar); +std::string RemoveDelimiters(std::string in); std::string RemoveWhiteSpaces(std::string in); std::string Replace(std::string in, std::string thisString, std::string byThisString, size_t fromPosition = 0, Int_t N = 0); diff --git a/source/framework/tools/src/TRestStringHelper.cxx b/source/framework/tools/src/TRestStringHelper.cxx index 4bfeca413..bd025cc40 100644 --- a/source/framework/tools/src/TRestStringHelper.cxx +++ b/source/framework/tools/src/TRestStringHelper.cxx @@ -248,11 +248,13 @@ vector REST_StringHelper::Split(string in, string separator, bool allowB /////////////////////////////////////////////// /// \brief Convert the input string into a vector of double elements /// +/// The method will remove any delimiters found in the string (), [] or {}. +/// /// e.g. Input: "1,2,3,4", Output: {1.,2.,3.,4.} /// vector REST_StringHelper::StringToElements(string in, string separator) { vector result; - vector vec_str = REST_StringHelper::Split(in, separator); + vector vec_str = REST_StringHelper::Split(RemoveDelimiters(in), separator); for (unsigned int i = 0; i < vec_str.size(); i++) { double temp = REST_StringHelper::StringToDouble(vec_str[i]); result.push_back(temp); @@ -286,6 +288,19 @@ vector REST_StringHelper::StringToElements(string in, string headChar, s return result; } +/////////////////////////////////////////////// +/// \brief Returns the input string removing any delimiters ({[]}) +/// +string REST_StringHelper::RemoveDelimiters(string in) { + string out = in; + size_t pos = out.find_first_of("+-*/e^%"); + while ((pos = out.find_first_of("({[]})")) != string::npos) { + out.erase(pos, 1); + } + + return out; +} + /////////////////////////////////////////////// /// \brief Returns the input string removing all white spaces. /// From 56676517e773d5399a132a2dbe63e028f17635e9 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Sat, 11 Mar 2023 22:43:05 +0100 Subject: [PATCH 05/11] TRestComponent. Finalised integration of metadata members --- .../sensitivity/inc/TRestComponent.h | 46 ++++++-- .../sensitivity/src/TRestComponent.cxx | 106 ++++++++++++++---- 2 files changed, 122 insertions(+), 30 deletions(-) diff --git a/source/framework/sensitivity/inc/TRestComponent.h b/source/framework/sensitivity/inc/TRestComponent.h index edf3f5785..3625b24ce 100644 --- a/source/framework/sensitivity/inc/TRestComponent.h +++ b/source/framework/sensitivity/inc/TRestComponent.h @@ -23,45 +23,69 @@ #ifndef REST_TRestComponent #define REST_TRestComponent -// #include "TRestDataSet.h" +#include "TRestDataSet.h" #include "TRestMetadata.h" /// It defines a background/signal distribution in a given parameter space (tipically x,y,en) class TRestComponent : public TRestMetadata { private: + //// This will not be necessary the day TRestComponent is a pure abstract class. + //// We will create an instance of TRestDataSetComponent or TRestFormulaComponent /// It defines how the distribution is initialized (dataset/formula) std::string fType = "dataset"; - /// A list (comma separated) with the branches that will be used to create the distribution - std::string fVariables; //< - - /// A list (comma separated) with the branches that will be used to weight the binning - std::string fWeights; //< + /// A list with the branches that will be used to create the distribution space + std::vector fVariables; //< /// The range of each of the variables used to create the distribution - std::vector fRange; //< + std::vector fRanges; //< /// The number of bins in which we should divide each variable std::vector fNbins; //< + /// A list with the branches that will be used to construct the distribution density + std::vector fWeights; //< + + /// It does not contribute to define the density distribution but allows to parametrize a set of + /// distribution densities + std::string fParametricVariable = ""; //< + + /// It defines the nodes of the parametrization + std::vector fParametrizationNodes; + + /// It defines the binning between the parametrization nodes + Int_t fParametrizationBinning = 0; + + ////////// This should be implemented in TRestDataSetComponent + ////////// /// The dataset used to initialize the distribution - // TRestDataSet fDataSet; //! + TRestDataSet fDataSet; //! + ////////// + ////////// This should be implemented in TRestDataSetComponent + ////////// This should be implemented in TRestFormulaComponent + ////////// /// The function used to initialize the distribution - std::string fFunction = ""; //! - + /// std::string fFunction = ""; //! + /// /// The function used to initialize the distribution - TFormula fFormula; //! + /// TFormula fFormula; //! + ////////// + ////////// This should be implemented in TRestFormulaComponent /// A pointer to the component distribution // THnD* fDistribution = nullptr; //! + protected: + void InitFromConfigFile() override; + public: Double_t GetRate(std::vector point); void PrintMetadata() override; void Initialize() override; + TRestComponent(const char* cfgFileName, const std::string& name); TRestComponent(); ~TRestComponent(); diff --git a/source/framework/sensitivity/src/TRestComponent.cxx b/source/framework/sensitivity/src/TRestComponent.cxx index ec37d52ec..94d2e3d7a 100644 --- a/source/framework/sensitivity/src/TRestComponent.cxx +++ b/source/framework/sensitivity/src/TRestComponent.cxx @@ -21,24 +21,7 @@ *************************************************************************/ ///////////////////////////////////////////////////////////////////////// -/// This class allows to make a selection of ROOT data files that fulfill -/// certain metadata conditions allowing to create a group of files that -/// define a particular dataset. The files will be searched in a relative -/// or absolute path that is given together the `filePattern` parameter. -/// -/// ### Basic file selection -/// -/// We will be able to define the dates range where files will be -/// accepted, using `startTime` and `endTime` parameters. The run start -/// time and end time stored inside TRestRun will be evaluated to decide -/// if the file should be considered. -/// -/// A summary of the basic parameters follows: -/// -/// * **filePattern**: A full path glob pattern to the files that will -/// be considered. It is a first filter considering the path and the -/// filename. Usual wild cards such as * or ? will be allowed to target -/// a given range of files. +/// This class allows to ... /// /// ///---------------------------------------------------------------------- @@ -47,7 +30,7 @@ /// /// History of developments: /// -/// 2022-December: First implementation of TRestComponent +/// 2023-December: First implementation of TRestComponent /// Javier Galan /// /// \class TRestComponent @@ -64,6 +47,27 @@ ClassImp(TRestComponent); /// TRestComponent::TRestComponent() { Initialize(); } +///////////////////////////////////////////// +/// \brief Constructor loading data from a config file +/// +/// If no configuration path is defined using TRestMetadata::SetConfigFilePath +/// the path to the config file must be specified using full path, absolute or +/// relative. +/// +/// The default behaviour is that the config file must be specified with +/// full path, absolute or relative. +/// +/// \param cfgFileName A const char* giving the path to an RML file. +/// \param name The name of the specific metadata. It will be used to find the +/// corresponding TRestAxionMagneticField section inside the RML. +/// +TRestComponent::TRestComponent(const char* cfgFileName, const std::string& name) + : TRestMetadata(cfgFileName) { + LoadConfigFromFile(fConfigFileName, name); + + if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info) PrintMetadata(); +} + /////////////////////////////////////////////// /// \brief Default destructor /// @@ -94,5 +98,69 @@ Double_t TRestComponent::GetRate(std::vector point) { void TRestComponent::PrintMetadata() { TRestMetadata::PrintMetadata(); + if (fVariables.size() != fRanges.size()) + RESTWarning << "The number of variables does not match with the number of defined ranges!" + << RESTendl; + + else if (fVariables.size() != fNbins.size()) + RESTWarning << "The number of variables does not match with the number of defined bins!" << RESTendl; + else { + int n = 0; + RESTMetadata << " === Variables === " << RESTendl; + for (const auto& varName : fVariables) { + RESTMetadata << " - Name: " << varName << " Range: (" << fRanges[n].X() << ", " << fRanges[n].Y() + << ") bins: " << fNbins[n] << RESTendl; + n++; + } + } + + RESTMetadata << " " << RESTendl; + RESTMetadata << " === Weights === " << RESTendl; + for (const auto& wName : fWeights) RESTMetadata << "- " << wName << RESTendl; + + if (!fParametricVariable.empty()) { + RESTMetadata << " " << RESTendl; + RESTMetadata << " === Parametrization === " << RESTendl; + RESTMetadata << "- Parametric variable : " << fParametricVariable << RESTendl; + + RESTMetadata << " - Parametric nodes : "; + for (const auto& node : fParametrizationNodes) { + RESTMetadata << node << " "; + } + RESTMetadata << RESTendl; + } + + RESTMetadata << " - Parametrization binning : " << fParametrizationBinning << RESTendl; + RESTMetadata << "----" << RESTendl; } + +///////////////////////////////////////////// +/// \brief It customizes the retrieval of XML data values of this class +/// +void TRestComponent::InitFromConfigFile() { + TRestMetadata::InitFromConfigFile(); + + auto ele = GetElement("variable"); + while (ele != nullptr) { + std::string name = GetParameter("name", ele, ""); + TVector2 v = Get2DVectorParameterWithUnits("range", ele); + Int_t bins = StringToInteger(GetParameter("bins", ele, "100")); + + fVariables.push_back(name); + fRanges.push_back(v); + fNbins.push_back(bins); + + ele = GetNextElement(ele); + } + + ele = GetElement("parametricVariable"); + while (ele != nullptr) { + fParametricVariable = GetParameter("name", ele, ""); + std::cout << GetParameter("nodes", ele, "-1") << std::endl; + fParametrizationNodes = StringToElements(GetParameter("nodes", ele, "-1"), ","); + fParametrizationBinning = StringToInteger(GetParameter("bins", ele, "100")); + + ele = GetNextElement(ele); + } +} From d317b7863a80dc38497bcdf59259317fa27b88fc Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Sun, 12 Mar 2023 10:33:30 +0100 Subject: [PATCH 06/11] TRestComponent. Removing unwanted output --- source/framework/sensitivity/src/TRestComponent.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/source/framework/sensitivity/src/TRestComponent.cxx b/source/framework/sensitivity/src/TRestComponent.cxx index 94d2e3d7a..6dc46e504 100644 --- a/source/framework/sensitivity/src/TRestComponent.cxx +++ b/source/framework/sensitivity/src/TRestComponent.cxx @@ -157,7 +157,6 @@ void TRestComponent::InitFromConfigFile() { ele = GetElement("parametricVariable"); while (ele != nullptr) { fParametricVariable = GetParameter("name", ele, ""); - std::cout << GetParameter("nodes", ele, "-1") << std::endl; fParametrizationNodes = StringToElements(GetParameter("nodes", ele, "-1"), ","); fParametrizationBinning = StringToInteger(GetParameter("bins", ele, "100")); From cd79025116c899142d691d1f34700f9dba07b4bd Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 30 Mar 2023 11:02:20 +0200 Subject: [PATCH 07/11] TRestDataSet::GetTree(). Improving error output when fTree is null. --- source/framework/core/inc/TRestDataSet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/framework/core/inc/TRestDataSet.h b/source/framework/core/inc/TRestDataSet.h index d78fd72ce..93dc7e7ac 100644 --- a/source/framework/core/inc/TRestDataSet.h +++ b/source/framework/core/inc/TRestDataSet.h @@ -116,8 +116,8 @@ class TRestDataSet : public TRestMetadata { TTree* GetTree() const { if (fTree == nullptr) { RESTError << "Tree has not been yet initialized" << RESTendl; - RESTError << "You should invoke TRestDataSet::Initialize() before trying to access the tree" - << RESTendl; + RESTError << "You should invoke TRestDataSet::GenerateDataSet() or " << RESTendl; + RESTError << "TRestDataSet::Import( fname ) before trying to access the tree" << RESTendl; } return fTree; } From b54ae46b0332c2e54b49991dcb46550f42af23c2 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 30 Mar 2023 11:03:14 +0200 Subject: [PATCH 08/11] TRestDataSet::GenerateDataSet. Fixing typo --- source/framework/core/src/TRestDataSet.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/framework/core/src/TRestDataSet.cxx b/source/framework/core/src/TRestDataSet.cxx index 9acd42e69..d2d8aff96 100644 --- a/source/framework/core/src/TRestDataSet.cxx +++ b/source/framework/core/src/TRestDataSet.cxx @@ -273,7 +273,8 @@ void TRestDataSet::Initialize() { SetSectionName(this->ClassName()); } /// void TRestDataSet::GenerateDataSet() { if (fTree != nullptr) { - RESTWarning << "Tree has already been loaded. Skipping TRestDataSet::Initialize ... " << RESTendl; + RESTWarning << "Tree has already been loaded. Skipping TRestDataSet::GenerateDataSet ... " + << RESTendl; return; } From ab4d45630631d71f3780f31511e3f52ea556ddfe Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Tue, 23 May 2023 21:15:06 +0200 Subject: [PATCH 09/11] Updating pipelines with new analysisRange --- pipeline/trex/01_raw.rml | 2 +- pipeline/trex/02_signal.rml | 51 +++++++++++-------------------------- 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/pipeline/trex/01_raw.rml b/pipeline/trex/01_raw.rml index 0cc941894..b12051a72 100644 --- a/pipeline/trex/01_raw.rml +++ b/pipeline/trex/01_raw.rml @@ -38,7 +38,7 @@ // We define all observables except MinValue because is not yet on validation.root diff --git a/pipeline/trex/02_signal.rml b/pipeline/trex/02_signal.rml index 5cc368607..d4f369a12 100644 --- a/pipeline/trex/02_signal.rml +++ b/pipeline/trex/02_signal.rml @@ -1,38 +1,17 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + From 2ef749f7fecc6045d40eb7ff633d0e3a50bc2606 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Tue, 23 May 2023 21:16:14 +0200 Subject: [PATCH 10/11] pipeline/pandaX-III updating to analysisRange --- pipeline/pandaxiii_MC/processes_2D.rml | 77 ++++++++------------------ 1 file changed, 24 insertions(+), 53 deletions(-) diff --git a/pipeline/pandaxiii_MC/processes_2D.rml b/pipeline/pandaxiii_MC/processes_2D.rml index aa6aa3cb0..a768f658d 100644 --- a/pipeline/pandaxiii_MC/processes_2D.rml +++ b/pipeline/pandaxiii_MC/processes_2D.rml @@ -1,4 +1,4 @@ - + @@ -10,25 +10,18 @@ - - - - // fwhm - // absolute gain // parameter name="electronicsGain" - value="671744" // electrons for 4096 ADC units + // fwhm + // absolute gain // parameter name="electronicsGain" + value="671744" // electrons for 4096 ADC units - - - - // fwhm - // absolute gain // parameter name="electronicsGain" - value="671744" // electrons for 4096 ADC units + // fwhm + // absolute gain // parameter name="electronicsGain" + value="671744" // electrons for 4096 ADC units - @@ -41,18 +34,11 @@ - - - - // Number of sigmas to perform the calculation + // Number of sigmas to perform the calculation - - - // // electrons in each time bin + // // electrons in each time bin - - + @@ -62,7 +48,6 @@ - @@ -70,7 +55,6 @@ - @@ -88,8 +72,7 @@ - + @@ -112,12 +95,9 @@ - - - + + + @@ -198,14 +178,10 @@ - - - - + + + + @@ -214,8 +190,7 @@ - + @@ -227,14 +202,11 @@ - + - - + + @@ -474,7 +446,7 @@ - +