Browse Source

infers output file from source-file key if no output file specified

Caleb Fangmeier 6 years ago
parent
commit
b8c7801435
2 changed files with 10 additions and 6 deletions
  1. 6 2
      include/config.hpp
  2. 4 4
      root/include/root_dataset.hpp

+ 6 - 2
include/config.hpp

@@ -163,8 +163,12 @@ namespace fv_util {
             if (output_file) {
                 return output_file.as<std::string>();
             } else {
-                std::cout << "Must specify output-file in config file." << std::endl;
-                return "";
+                YAML::Node key = root["source-file-key"];
+                if (key) {
+                    return "../hists/" + key.as<std::string>() + ".root";
+                } else {
+                    return "../hists/output.root";
+                }
             }
         }
 

+ 4 - 4
root/include/root_dataset.hpp

@@ -64,10 +64,6 @@ namespace fv_root {
             else return nentries;
         }
 
-        int get_current_event() {
-            return next_entry - 1;
-        }
-
         fv_util::DataFileDescriptor &get_current_file() {
             TFile *file = tree_obj->fChain->GetCurrentFile();
             std::string filename = file->GetName();
@@ -134,6 +130,10 @@ namespace fv_root {
             output_file->Close();
         }
 
+        int get_current_event() {
+            return next_entry - 1;
+        }
+
         const std::string &get_current_event_category() const {
             TFile *file = tree_obj->fChain->GetCurrentFile();
             std::string filename = file->GetName();