Skip to content

Commit

Permalink
Simplifying some overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroEzq committed Nov 27, 2023
1 parent ac890ce commit 69eefa9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
12 changes: 6 additions & 6 deletions source/framework/analysis/inc/TRestDataSetGainMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,20 @@ class TRestDataSetGainMap : public TRestMetadata {
std::string GetDataSetFileName() const { return fDataSetFileName; }
TVector2 GetReadoutRangeVar() const { return fReadoutRange; }

void DrawSpectrum(bool drawFits = true, int color = -1, TCanvas* c = nullptr);
void DrawSpectrum(const double x, const double y, bool drawFits = true, int color = -1,
void DrawSpectrum(const bool drawFits = true, const int color = -1, TCanvas* c = nullptr);
void DrawSpectrum(const TVector2& position, bool drawFits = true, int color = -1,
TCanvas* c = nullptr);
void DrawSpectrum(const size_t index_x, const size_t index_y, bool drawFits = true, int color = -1,
void DrawSpectrum(const int index_x, const int index_y, bool drawFits = true, int color = -1,
TCanvas* c = nullptr);
void DrawFullSpectrum();

void DrawLinearFit();
void DrawLinearFit(const double x, const double y, TCanvas* c = nullptr);
void DrawLinearFit(const size_t index_x, const size_t index_y, TCanvas* c = nullptr);
void DrawLinearFit(const TVector2& position, TCanvas* c = nullptr);
void DrawLinearFit(const int index_x, const int index_y, TCanvas* c = nullptr);

void DrawGainMap(const int peakNumber = 0);

void Refit(const double x, const double y, const double energy, const TVector2& range);
void Refit(const TVector2& position, const double energy, const TVector2& range);
void Refit(const size_t x, const size_t y, const size_t peakNumber, const TVector2& range);
void UpdateCalibrationFits(const size_t x, const size_t y);

Expand Down
31 changes: 16 additions & 15 deletions source/framework/analysis/src/TRestDataSetGainMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -823,14 +823,13 @@ void TRestDataSetGainMap::Module::GenerateGainMap() {
/////////////////////////////////////////////
/// \brief Function to fit again manually a peak for a given segment of the module.
///
/// \param x position along X-axis at the detector module (in physical units).
/// \param y position along Y-axis at the detector module (in physical units).
/// \param position position along X and Y axes at the detector module (in physical units).
/// \param energyPeak The energy of the peak to be fitted (in physical units).
/// \param range The range for the fitting of the peak (in the observables corresponding units).
///
void TRestDataSetGainMap::Module::Refit(const double x, const double y, const double energyPeak,
void TRestDataSetGainMap::Module::Refit(const TVector2& position, const double energyPeak,
const TVector2& range) {
auto [index_x, index_y] = GetIndexMatrix(x, y);
auto [index_x, index_y] = GetIndexMatrix(position.X(), position.Y());
int peakNumber = -1;
for (size_t i = 0; i < fEnergyPeaks.size(); i++)
if (fEnergyPeaks.at(i) == energyPeak) {
Expand Down Expand Up @@ -1005,19 +1004,20 @@ void TRestDataSetGainMap::Module::LoadConfigFromTiXmlElement(const TiXmlElement*
}
}

void TRestDataSetGainMap::Module::DrawSpectrum(const double x, const double y, bool drawFits, int color,
void TRestDataSetGainMap::Module::DrawSpectrum(const TVector2& position, bool drawFits, int color,
TCanvas* c) {
std::pair<size_t, size_t> index = GetIndexMatrix(x, y);
std::pair<size_t, size_t> index = GetIndexMatrix(position.X(), position.Y());
DrawSpectrum(index.first, index.second, drawFits, color, c);
}

void TRestDataSetGainMap::Module::DrawSpectrum(const size_t index_x, const size_t index_y, bool drawFits,
int color, TCanvas* c) {
void TRestDataSetGainMap::Module::DrawSpectrum(const int index_x, const int index_y, bool drawFits, int color,
TCanvas* c) {
if (fSegSpectra.size() == 0) {
RESTError << "Spectra matrix is empty." << p->RESTendl;
return;
}
if (index_x >= fSegSpectra.size() || index_y >= fSegSpectra.at(index_x).size()) {
if (index_x < 0 || index_y < 0 || index_x >= (int)fSegSpectra.size() ||
index_y >= (int)fSegSpectra.at(index_x).size()) {
RESTError << "Index out of range." << p->RESTendl;
return;
}
Expand Down Expand Up @@ -1046,7 +1046,7 @@ void TRestDataSetGainMap::Module::DrawSpectrum(const size_t index_x, const size_
auto fit = fSegSpectra[index_x][index_y]->GetFunction(("g" + std::to_string(c)).c_str());
if (!fit) RESTWarning << "Fit for energy peak" << fEnergyPeaks[c] << " not found." << p->RESTendl;
if (!fit) continue;
fit->SetLineColor(c + 2 != colorT++ ? c + 2 : c + 3); /* does not work with kRed, kBlue, etc.
fit->SetLineColor(c + 2 != colorT ? c + 2 : ++colorT); /* does not work with kRed, kBlue, etc.
as they are not defined with the same number as the first 10 basic colors. See
https://root.cern.ch/doc/master/classTColor.html#C01 and
https://root.cern.ch/doc/master/classTColor.html#C02 */
Expand All @@ -1073,7 +1073,7 @@ void TRestDataSetGainMap::Module::DrawSpectrum(const size_t index_x, const size_
/// \param c A TCanvas pointer to draw the spectra. If none (nullptr) is given,
/// a new one is created.
///
void TRestDataSetGainMap::Module::DrawSpectrum(bool drawFits, int color, TCanvas* c) {
void TRestDataSetGainMap::Module::DrawSpectrum(const bool drawFits, const int color, TCanvas* c) {
if (fSegSpectra.size() == 0) {
RESTError << "Spectra matrix is empty." << p->RESTendl;
return;
Expand Down Expand Up @@ -1121,17 +1121,18 @@ void TRestDataSetGainMap::Module::DrawFullSpectrum() {
sumHist->Draw();
}

void TRestDataSetGainMap::Module::DrawLinearFit(const double x, const double y, TCanvas* c) {
std::pair<size_t, size_t> index = GetIndexMatrix(x, y);
void TRestDataSetGainMap::Module::DrawLinearFit(const TVector2& position, TCanvas* c) {
std::pair<size_t, size_t> index = GetIndexMatrix(position.X(), position.Y());
DrawLinearFit(index.first, index.second, c);
}

void TRestDataSetGainMap::Module::DrawLinearFit(const size_t index_x, const size_t index_y, TCanvas* c) {
void TRestDataSetGainMap::Module::DrawLinearFit(const int index_x, const int index_y, TCanvas* c) {
if (fSegLinearFit.size() == 0) {
RESTError << "Spectra matrix is empty." << p->RESTendl;
return;
}
if (index_x >= fSegLinearFit.size() || index_y >= fSegLinearFit.at(index_x).size()) {
if (index_x < 0 || index_y < 0 || index_x >= (int)fSegLinearFit.size() ||
index_y >= (int)fSegLinearFit.at(index_x).size()) {
RESTError << "Index out of range." << p->RESTendl;
return;
}
Expand Down

0 comments on commit 69eefa9

Please sign in to comment.