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 3 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
79 changes: 79 additions & 0 deletions source/framework/analysis/inc/TRestCalibration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*************************************************************************
* 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_TRestCalibration
#define REST_TRestCalibration

#include "TRestMetadata.h"

/// This class is meant to perform the calibration of different runs
class TRestCalibration : public TRestMetadata {
private:
// Name of the output file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave one white space between data member definitions so that is easier to read the documentation line corresponding to the metadata member.

Also I think doxygen requires to use a triple /// comment.

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; }

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

ClassDefOverride(TRestCalibration, 1);
};
#endif
70 changes: 70 additions & 0 deletions source/framework/analysis/inc/TRestOdds.h
Original file line number Diff line number Diff line change
@@ -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_TRestOdds
#define REST_TRestOdds

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

/// This class is meant to compute the log odds for different datasets
class TRestOdds : 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; }

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

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