TTTT Analysis  0.1
dataset.hpp
1 #ifndef dataset_hpp
2 #define dataset_hpp
3 #include <iostream>
4 #include "value.hpp"
5 #include "container.hpp"
6 #include "log.hpp"
7 
8 namespace fv{
9 class DataSet{
10  private:
11  void summary(){
12  INFO(GenValue::summary());
13  INFO(GenFunction::summary());
14  }
15 
16  protected:
17  ContainerSet containers;
18  virtual bool load_next() = 0;
19  virtual int get_events() = 0;
20  virtual int get_current_event() = 0;
21 
22  public:
23  void process(bool silent=false){
24  int events, current_event;
25  summary();
26  events = get_events();
27  if (!silent) std::cout << std::endl;
28  while( load_next() ){
29  current_event = get_current_event();
30  if (!silent) std::cout << "\rprocessing event: " << current_event+1 << "/" << events << std::flush;
31  GenValue::reset();
32  for(auto con : containers){
33  con.second->fill();
34  }
35  }
36  if (!silent) std::cout << " Finished!" << std::endl;
37  }
38 
39  virtual void save_all(){
40  for(auto container : containers)
41  container.second->save();
42  }
43 
44  void register_container(GenContainer *container){
45  if (containers[container->get_name()] != nullptr){
46  CRITICAL("Container with name \""+container->get_name()+"\" already exists.", -1);
47  }
48  containers[container->get_name()] = container;
49  }
50 
51  GenContainer* get_container(std::string container_name){
52  GenContainer* c = containers[container_name];
53  if (c == nullptr){
54  CRITICAL("Request for container \"" << container_name << "\" failed. Doesn't exist.", -1);
55  }
56  return c;
57  }
58 };
59 }
60 #endif // dataset_hpp
Definition: dataset.hpp:9
The namespace containing all filval classes and functions.
Definition: container.hpp:15