File NPCalibrationManager.h
File List > core > NPCalibrationManager.h
Go to the documentation of this file
#ifndef NPCalibrationManager_h
#define NPCalibrationManager_h 1
#include <fstream>
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <vector>
namespace nptool {
class Application;
class CalibrationManager {
public: // Constructor and Destructor are protected because the class is a singleton
CalibrationManager();
~CalibrationManager();
public: // File Management
inline void AddFile(std::string Path) { m_FileList.push_back(Path); };
public: // Calibration Parameter Related
void InitCalibration();
// call like : myCalibrationManager->AddParameter( "MUST2" ,"Telescope5_Si_X38_E", "T5_Si_X38_E" )
bool AddParameter(std::string DetectorName, std::string ParameterName, std::string Token,
std::vector<double> def = std::vector<double>());
bool AddParameter(std::string Token, std::vector<double> def = std::vector<double>());
// call like : myCalibrationManager->ApplyCalibration( "MUST2/Telescope5_Si_X38_E" , RawEnergy )
// return the Calibrated value
double ApplyCalibration(const std::string& ParameterPath, const double& RawValue, double random = 0) const;
double ApplyResistivePositionCalibration(const std::string& ParameterPath, const double& RawValue) const;
// Same but with debug information outputs
double ApplyCalibrationDebug(const std::string& ParameterPath, const double& RawValue, double random = 0) const;
double ApplyResistivePositionCalibrationDebug(const std::string& ParameterPath, const double& RawValue) const;
bool ApplyThreshold(const std::string& ParameterPath, const double& RawValue) const;
double ApplySigmoid(const std::string& ParameterPath, const double& RawValue) const;
double GetPedestal(const std::string& ParameterPath) const;
double GetValue(const std::string& ParameterPath, const unsigned int& order) const;
public: // To be called after initialisation
// Loop over the file list and catch the file used for calibration
void LoadParameterFromFile();
public: // Clear calibration if we have some calibration files to read
void ClearCalibration();
public: // Get correction coefficient std::vector
std::vector<double> GetCorrection(const std::string& ParameterPath) const;
public: // Get correction coefficient std::vector
void Dump() const;
private:
// This std::map hold a std::vector of the calibration coefficient. Index is the Parameter path, like
// map token / coeff
std::map<std::string, std::vector<double>> m_CalibrationCoeff;
// Hold the path of all the registered file of coeff
std::vector<std::string> m_FileList;
};
} // namespace nptool
#endif