Browse Source

Adds constructors for THParams

Caleb 6 years ago
parent
commit
18dd5c586e
1 changed files with 30 additions and 10 deletions
  1. 30 10
      root/include/root_container.hpp

+ 30 - 10
root/include/root_container.hpp

@@ -100,23 +100,43 @@ namespace fv_root {
         double low_y;
         double high_y;
 
+        THParams(int nbins_x, double low_x, double high_x, int nbins_y=0, double low_y=0, double high_y=0)
+          :nbins_x(nbins_x), low_x(low_x), high_x(high_x), nbins_y(nbins_y), low_y(low_y), high_y(high_y){}
+
+        THParams(const std::string label_x, int nbins_x, double low_x, double high_x,
+                const std::string label_y = "", int nbins_y=0, double low_y=0, double high_y=0)
+          :label_x(label_x), nbins_x(nbins_x), low_x(low_x), high_x(high_x),
+           label_y(label_y), nbins_y(nbins_y), low_y(low_y), high_y(high_y){}
+
+        THParams() {
+            label_x = "";
+            nbins_x = 20;
+            low_x = 0;
+            high_x = 1;
+            label_y = "";
+            nbins_y = 20;
+            low_y = 0;
+            high_y = 1;
+        }
+
         static THParams lookup(const std::string &&param_key) {
             auto hist_params = fv_util::the_config->get("hist-params");
             if (!hist_params[param_key]) {
                 CRITICAL("Key \"" << param_key
                                   << "\" does not exist under hist-params in supplied config file. Add it!");
-                return THParams({"", 20, 0, 1, "", 20, 0, 1});
+                std::string empty{""};
+                return {};
             } else {
                 auto params = hist_params[param_key];
-                return THParams({params["label_x"].as<std::string>(""),
-                                 params["nbins_x"].as<int>(20),
-                                 params["low_x"].as<double>(0),
-                                 params["high_x"].as<double>(1),
-                                 params["label_y"].as<std::string>(""),
-                                 params["nbins_y"].as<int>(20),
-                                 params["low_y"].as<double>(0),
-                                 params["high_y"].as<double>(1)
-                                });
+                return {params["label_x"].as<std::string>(""),
+                        params["nbins_x"].as<int>(20),
+                        params["low_x"].as<double>(0),
+                        params["high_x"].as<double>(1),
+                        params["label_y"].as<std::string>(""),
+                        params["nbins_y"].as<int>(20),
+                        params["low_y"].as<double>(0),
+                        params["high_y"].as<double>(1)
+                       };
 
             }
         }