Skip to content
Snippets Groups Projects
Commit 16438831 authored by Evgeny Kashirin's avatar Evgeny Kashirin
Browse files

Create 1D Getter builder

parent 2ce6a4f9
No related branches found
No related tags found
No related merge requests found
Pipeline #2328 failed
...@@ -47,4 +47,33 @@ float Getter::GetCentrality(float xvalue, float yvalue) const ...@@ -47,4 +47,33 @@ float Getter::GetCentrality(float xvalue, float yvalue) const
return -1.; return -1.;
} }
Getter *Getter::Create1DGetter(std::vector<double> borders) {
typedef decltype(ranges_)::value_type Floating_t;
size_t n_borders = borders.size();
assert(n_borders > 2);
Floating_t range_max = 100.f;
Floating_t range_min = 0.f;
Floating_t range_step = (range_max - range_min)/(n_borders - 1);
decltype(ranges_) ranges(n_borders);
for (int i = 0; i < n_borders; ++i) {
auto rr = range_min + range_step*i;
ranges[i] = rr;
std::cout << rr << "%: " << borders[i] << std::endl;
}
TAxis ax_borders(static_cast<Int_t>(n_borders - 1), &(borders[0]));
auto getter = new Getter;
getter->ranges_ = std::move(ranges);
getter->borders_ = ax_borders;
getter->isinitialized_ = true;
return getter;
}
} }
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#ifndef CENTRALITY_GETTER_H #ifndef CENTRALITY_GETTER_H
#define CENTRALITY_GETTER_H #define CENTRALITY_GETTER_H
#include <assert.h>
#include "vector" #include "vector"
#include "array" #include "array"
...@@ -16,53 +17,56 @@ ...@@ -16,53 +17,56 @@
#include "TRandom.h" #include "TRandom.h"
namespace Centrality { namespace Centrality {
class Getter : public TObject { class Getter : public TObject {
public: public:
Getter(){} Getter() = default;
float GetCentrality(float value) const; float GetCentrality(float value) const;
float GetCentrality(float xvalue, float yvalue) const; float GetCentrality(float xvalue, float yvalue) const;
void SetBorders(const std::vector<double> &borders) void SetBorders(const std::vector<double> &borders) {
{ borders_ = TAxis(borders.size() - 1, &(borders[0]));
borders_ = TAxis( borders.size()-1, &(borders[0]) ); isinitialized_ = true;
isinitialized_ = true; }
}
const TAxis &GetBorders() const { return borders_; };
const TAxis& GetBorders() const { return borders_; }; const std::vector<float> &GetRanges() const { return ranges_; };
const std::vector<float>& GetRanges() const { return ranges_; };
void SetRanges(const std::vector<float> &ranges) { ranges_ = ranges; }
void SetRanges(const std::vector<float> &ranges) { ranges_ = ranges; } void IsSpectator(bool is = true) { isspectator_ = is; }
void IsSpectator(bool is=true) { isspectator_ = is; }
void AddBorder2D(const std::array<float, 2> &border2D) {
void AddBorder2D( const std::array<float,2> &border2D ) borders2d_.push_back(border2D);
{ if (!isinitialized2D_) isinitialized2D_ = true;
borders2d_.push_back(border2D); }
if (!isinitialized2D_) isinitialized2D_ = true;
} const std::vector<std::array<float, 2>> &GetBorders2D() const { return borders2d_; };
const std::vector <std::array<float,2>>& GetBorders2D() const { return borders2d_; }; void SetMax(float x, float y) {
xmax_ = x;
void SetMax(float x, float y) { xmax_=x; ymax_=y; } ymax_ = y;
}
private:
static Getter *Create1DGetter(std::vector<double> borders);
TAxis borders_;
std::vector <std::array<float,2>> borders2d_{}; private:
std::vector<float> ranges_{};
TAxis borders_;
float xmax_{1.}; std::vector<std::array<float, 2>> borders2d_{};
float ymax_{1.}; std::vector<float> ranges_{};
bool isspectator_{false}; float xmax_{1.};
bool isinitialized_{false}; float ymax_{1.};
bool isinitialized2D_{false};
bool isspectator_{false};
ClassDef(Getter, 2); bool isinitialized_{false};
bool isinitialized2D_{false};
ClassDef(Getter, 2);
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment