|
@@ -8,7 +8,7 @@
|
|
#include "TGraph.h"
|
|
#include "TGraph.h"
|
|
#include "TROOT.h"
|
|
#include "TROOT.h"
|
|
|
|
|
|
-#include "../filval/filval.hpp"
|
|
|
|
|
|
+#include "filval.hpp"
|
|
|
|
|
|
namespace fv::root::util{
|
|
namespace fv::root::util{
|
|
void _save_img(TObject* container, const std::string& fname){
|
|
void _save_img(TObject* container, const std::string& fname){
|
|
@@ -47,6 +47,10 @@ class ContainerTH1 : public Container<TH1>{
|
|
private:
|
|
private:
|
|
void _fill(){
|
|
void _fill(){
|
|
if (container == nullptr){
|
|
if (container == nullptr){
|
|
|
|
+ if (value == nullptr){
|
|
|
|
+ CRITICAL("Container: \"" << get_name() << "\" has a null Value object. "
|
|
|
|
+ << "Probably built with imcompatible type",-1);
|
|
|
|
+ }
|
|
init_TH1();
|
|
init_TH1();
|
|
}
|
|
}
|
|
_do_fill(value->get_value());
|
|
_do_fill(value->get_value());
|
|
@@ -148,68 +152,124 @@ class ContainerTH1IMany : public _ContainerTH1I<std::vector<int>>{
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
-/* template <typename T> */
|
|
|
|
-/* class ContainerTH2 : public Container<TH2>{ */
|
|
|
|
-/* private: */
|
|
|
|
-/* void _fill(){ */
|
|
|
|
-/* if (container == nullptr){ */
|
|
|
|
-/* init_TH2(); */
|
|
|
|
-/* } */
|
|
|
|
-/* std::pair<T, T> val = value->get_value(); */
|
|
|
|
-/* container->Fill(val.first, val.second); */
|
|
|
|
-/* } */
|
|
|
|
-
|
|
|
|
-/* protected: */
|
|
|
|
-/* std::string title; */
|
|
|
|
-/* int nbins_x; */
|
|
|
|
-/* int nbins_y; */
|
|
|
|
-/* T low_x; */
|
|
|
|
-/* T low_y; */
|
|
|
|
-/* T high_x; */
|
|
|
|
-/* T high_y; */
|
|
|
|
-/* Value<std::pair<T, T> > *value; */
|
|
|
|
-/* virtual void init_TH2() = 0; */
|
|
|
|
-
|
|
|
|
-/* public: */
|
|
|
|
-/* explicit ContainerTH2(const std::string& name, const std::string& title, */
|
|
|
|
-/* int nbins_x, double low_x, double high_x, */
|
|
|
|
-/* int nbins_y, double low_y, double high_y, */
|
|
|
|
-/* GenValue* value) */
|
|
|
|
-/* :Container<TH2>(name, nullptr), */
|
|
|
|
-/* nbins_x(nbins_x), low_x(low_x), high_x(high_x), */
|
|
|
|
-/* nbins_y(nbins_y), low_y(low_y), high_y(high_y), */
|
|
|
|
-/* value(dynamic_cast<Value<T>*>(value)) { } */
|
|
|
|
-
|
|
|
|
-/* void save_as(const std::string& fname, const SaveOption& option = SaveOption::PNG) { */
|
|
|
|
-/* util::_save_as(get_container(), fname, option); */
|
|
|
|
-/* } */
|
|
|
|
-
|
|
|
|
-/* void save(const SaveOption& option = SaveOption::PNG) { */
|
|
|
|
-/* save_as(this->get_name(), option); */
|
|
|
|
-/* } */
|
|
|
|
-/* }; */
|
|
|
|
-
|
|
|
|
-/* class ContainerTH2D : public ContainerTH2<double>{ */
|
|
|
|
-/* using ContainerTH2::ContainerTH2; */
|
|
|
|
-/* void init_TH2(){ */
|
|
|
|
-/* this->container = new TH2D(this->get_name().c_str(), title.c_str(), nbins_x, low_x, high_x, nbins_y, low_y, high_y); */
|
|
|
|
-/* } */
|
|
|
|
-/* }; */
|
|
|
|
-
|
|
|
|
-/* class ContainerTH2F : public ContainerTH2<float>{ */
|
|
|
|
-/* using ContainerTH2::ContainerTH2; */
|
|
|
|
-/* void init_TH2(){ */
|
|
|
|
-/* this->container = new TH2F(this->get_name().c_str(), title.c_str(), nbins_x, low_x, high_x, nbins_y, low_y, high_y); */
|
|
|
|
-/* } */
|
|
|
|
-/* }; */
|
|
|
|
-
|
|
|
|
-/* class ContainerTH2I : public ContainerTH2<int>{ */
|
|
|
|
-/* using ContainerTH2::ContainerTH2; */
|
|
|
|
-/* void init_TH2(){ */
|
|
|
|
-/* this->container = new TH2I(this->get_name().c_str(), title.c_str(), nbins_x, low_x, high_x, nbins_y, low_y, high_y); */
|
|
|
|
-/* } */
|
|
|
|
-/* }; */
|
|
|
|
|
|
+template <typename V, typename D>
|
|
|
|
+class ContainerTH2 : public Container<TH2>{
|
|
|
|
+ private:
|
|
|
|
+ void _fill(){
|
|
|
|
+ if (container == nullptr){
|
|
|
|
+ if (value == nullptr){
|
|
|
|
+ CRITICAL("Container: \"" << get_name() << "\" has a null Value object. "
|
|
|
|
+ << "Probably built with imcompatible type",-1);
|
|
|
|
+ }
|
|
|
|
+ init_TH2();
|
|
|
|
+ }
|
|
|
|
+ _do_fill(value->get_value());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected:
|
|
|
|
+ std::string title;
|
|
|
|
+ int nbins_x;
|
|
|
|
+ int nbins_y;
|
|
|
|
+ D low_x;
|
|
|
|
+ D low_y;
|
|
|
|
+ D high_x;
|
|
|
|
+ D high_y;
|
|
|
|
+ Value<std::pair<V,V>> *value;
|
|
|
|
+ virtual void init_TH2() = 0;
|
|
|
|
+ virtual void _do_fill(std::pair<V,V>& val) = 0;
|
|
|
|
+
|
|
|
|
+ public:
|
|
|
|
+ explicit ContainerTH2(const std::string& name, const std::string& title,
|
|
|
|
+ GenValue* value,
|
|
|
|
+ int nbins_x, D low_x, D high_x,
|
|
|
|
+ int nbins_y, D low_y, D high_y)
|
|
|
|
+ :Container<TH2>(name, nullptr),
|
|
|
|
+ nbins_x(nbins_x), low_x(low_x), high_x(high_x),
|
|
|
|
+ nbins_y(nbins_y), low_y(low_y), high_y(high_y),
|
|
|
|
+ value(dynamic_cast<Value<std::pair<V, V>>*>(value)) { }
|
|
|
|
+
|
|
|
|
+ void save_as(const std::string& fname, const SaveOption& option = SaveOption::PNG) {
|
|
|
|
+ util::_save_as(get_container(), fname, option);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+template <typename V>
|
|
|
|
+class _ContainerTH2D : public ContainerTH2<V, double>{
|
|
|
|
+ using ContainerTH2<V, double>::ContainerTH2;
|
|
|
|
+ void init_TH2(){
|
|
|
|
+ this->container = new TH2D(this->get_name().c_str(), this->title.c_str(),
|
|
|
|
+ this->nbins_x, this->low_x, this->high_x,
|
|
|
|
+ this->nbins_y, this->low_y, this->high_y);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+class ContainerTH2D : public _ContainerTH2D<double>{
|
|
|
|
+ using _ContainerTH2D<double>::_ContainerTH2D;
|
|
|
|
+ void _do_fill(std::pair<double,double>& val){
|
|
|
|
+ this->container->Fill(val.first, val.second);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+class ContainerTH2DMany : public _ContainerTH2D<std::vector<double>>{
|
|
|
|
+ using _ContainerTH2D<std::vector<double>>::_ContainerTH2D;
|
|
|
|
+ void _do_fill(std::pair<std::vector<double>,std::vector<double>>& val){
|
|
|
|
+ int min_size = std::min(val.first.size(), val.second.size());
|
|
|
|
+ for(int i=0; i<min_size; i++)
|
|
|
|
+ this->container->Fill(val.first[i],val.second[i]);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+template <typename V>
|
|
|
|
+class _ContainerTH2F : public ContainerTH2<V, float>{
|
|
|
|
+ using ContainerTH2<V, float>::ContainerTH2;
|
|
|
|
+ void init_TH2(){
|
|
|
|
+ this->container = new TH2F(this->get_name().c_str(), this->title.c_str(),
|
|
|
|
+ this->nbins_x, this->low_x, this->high_x,
|
|
|
|
+ this->nbins_y, this->low_y, this->high_y);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+class ContainerTH2F : public _ContainerTH2F<float>{
|
|
|
|
+ using _ContainerTH2F<float>::_ContainerTH2F;
|
|
|
|
+ void _do_fill(std::pair<float,float>& val){
|
|
|
|
+ this->container->Fill(val.first, val.second);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
|
|
|
|
+class ContainerTH2FMany : public _ContainerTH2F<std::vector<float>>{
|
|
|
|
+ using _ContainerTH2F<std::vector<float>>::_ContainerTH2F;
|
|
|
|
+ void _do_fill(std::pair<std::vector<float>,std::vector<float>>& val){
|
|
|
|
+ int min_size = std::min(val.first.size(), val.second.size());
|
|
|
|
+ for(int i=0; i<min_size; i++)
|
|
|
|
+ this->container->Fill(val.first[i],val.second[i]);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+template <typename V>
|
|
|
|
+class _ContainerTH2I : public ContainerTH2<V, int>{
|
|
|
|
+ using ContainerTH2<V, int>::ContainerTH2;
|
|
|
|
+ void init_TH2(){
|
|
|
|
+ this->container = new TH2I(this->get_name().c_str(), this->title.c_str(),
|
|
|
|
+ this->nbins_x, this->low_x, this->high_x,
|
|
|
|
+ this->nbins_y, this->low_y, this->high_y);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+class ContainerTH2I : public _ContainerTH2I<int>{
|
|
|
|
+ using _ContainerTH2I<int>::_ContainerTH2I;
|
|
|
|
+ void _do_fill(std::pair<int,int>& val){
|
|
|
|
+ this->container->Fill(val.first, val.second);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+class ContainerTH2IMany : public _ContainerTH2I<std::vector<int>>{
|
|
|
|
+ using _ContainerTH2I<std::vector<int>>::_ContainerTH2I;
|
|
|
|
+ void _do_fill(std::pair<std::vector<int>,std::vector<int>>& val){
|
|
|
|
+ int min_size = std::min(val.first.size(), val.second.size());
|
|
|
|
+ for(int i=0; i<min_size; i++)
|
|
|
|
+ this->container->Fill(val.first[i],val.second[i]);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
|
|
class ContainerTGraph : public Container<TGraph>{
|
|
class ContainerTGraph : public Container<TGraph>{
|
|
private:
|
|
private:
|
|
@@ -234,7 +294,6 @@ class ContainerTGraph : public Container<TGraph>{
|
|
delete container;
|
|
delete container;
|
|
container = new TGraph(x_data.size(), x_data.data(), y_data.data());
|
|
container = new TGraph(x_data.size(), x_data.data(), y_data.data());
|
|
container->SetName(get_name().c_str());
|
|
container->SetName(get_name().c_str());
|
|
- std::cout << "name: " << container->GetName() << std::endl;
|
|
|
|
data_modified = false;
|
|
data_modified = false;
|
|
}
|
|
}
|
|
return container;
|
|
return container;
|