Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New metadata classes to perform calibration and odds analysis over a TRestDataSet #392

Merged
merged 16 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions source/framework/analysis/inc/TRestDataSetCalibration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*************************************************************************
* 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_TRestDataSetCalibration
#define REST_TRestDataSetCalibration

#include "TRestMetadata.h"

/// This class is meant to perform the calibration of different runs
class TRestDataSetCalibration : public TRestMetadata {
private:
/// Name of the output file
std::string fOutputFileName = "";

/// Name of the dataSet inside the config file
std::string fDataSetName = "";

/// Vector containing expected energy peaks in keV must be sorted
std::vector<double> fEnergyPeaks;

/// Vector containing calibrated peaks in ADCs
std::vector<double> fCalibPeaks;

/// Vector containing calibrated sigma in ADCs
std::vector<double> fCalibFWHM;

/// Name of the calibration file to be used
std::string fCalibFile = "";

/// Calibration variable to be used
std::string fCalObservable = "";

/// Range to be calibrated
TVector2 fCalibRange;

/// Number of bins used in the calibration
Int_t fNBins;

/// Slope from the calibration fit
Double_t fSlope = 0;

/// Intercept of the calibration fit
Double_t fIntercept = 0;

void Initialize() override;
void InitFromConfigFile() override;

public:
void PrintMetadata() override;

void Calibrate();

inline void SetDataSetName(const std::string& dSName) { fDataSetName = dSName; }
inline void SetOutputFileName(const std::string& outName) { fOutputFileName = outName; }
inline void SetCalibrationFile(const std::string& calibFile) { fCalibFile = calibFile; }

inline auto GetCalibPeaks() const { return fCalibPeaks; }
inline auto GetCalibFWHM() const { return fCalibFWHM; }

inline double GetSlope() const { return fSlope; }
inline double GetIntercept() const { return fIntercept; }
inline std::string GetCalObservable() const { return fCalObservable; }

TRestDataSetCalibration();
TRestDataSetCalibration(const char* configFilename, std::string name = "");
~TRestDataSetCalibration();

ClassDefOverride(TRestDataSetCalibration, 1);
};
#endif
75 changes: 75 additions & 0 deletions source/framework/analysis/inc/TRestDataSetOdds.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*************************************************************************
* 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_TRestDataSetOdds
#define REST_TRestDataSetOdds

#include "TH1F.h"
#include "TRestCut.h"
#include "TRestMetadata.h"

/// This class is meant to compute the log odds for different datasets
class TRestDataSetOdds : public TRestMetadata {
private:
/// Name of the output file
std::string fOutputFileName = "";

/// Name of the dataSet inside the config file
std::string fDataSetName = "";

/// Vector containing different obserbable names
std::vector<std::string> fObsName;

/// Vector containing different obserbable ranges
std::vector<TVector2> fObsRange;

/// Vector containing number of bins for the different observables
std::vector<int> fObsNbins;

/// Name of the odds file to be used to get the PDF
std::string fOddsFile = "";

/// Cuts over the dataset for PDF selection
TRestCut* fCut = nullptr;

/// Map containing the PDF of the different observables
std::map<std::string, TH1F*> fHistos; //!

void Initialize() override;
void InitFromConfigFile() override;

public:
void PrintMetadata() override;

void ComputeLogOdds();

inline void SetDataSetName(const std::string& dSName) { fDataSetName = dSName; }
inline void SetOutputFileName(const std::string& outName) { fOutputFileName = outName; }
inline void SetOddsFile(const std::string& oddsFile) { fOddsFile = oddsFile; }

TRestDataSetOdds();
TRestDataSetOdds(const char* configFilename, std::string name = "");
~TRestDataSetOdds();

ClassDefOverride(TRestDataSetOdds, 1);
};
#endif
Loading