Class Reference for E1039 Core & Analysis Software
AnaBase.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <TSystem.h>
4 #include "AnaBase.h"
5 using namespace std;
6 
7 AnaBase::AnaBase(const std::string label)
8  : m_label (label)
9  , m_tree_name ("default_tree_name")
10  , m_branch_name("default_branch_name")
11 {
12  ostringstream oss;
13  oss << "result/" << m_label;
14  m_dir_out = oss.str();
15  gSystem->mkdir(oss.str().c_str(), true);
16  oss << "/log.txt";
17  m_ofs.open(oss.str().c_str());
18 }
19 
21 {
22  m_ofs.close();
23 
24  ostringstream oss;
25  oss << m_dir_out << "/log.txt";
26  string fname = oss.str();
27  ifstream ifs(fname.c_str());
28  cout << "+----------------------------------------------------------------+\n"
29  << "| Messages in '" << fname << "':\n"
30  << "+----------------------------------------------------------------+\n"
31  << string(istreambuf_iterator<char>(ifs), istreambuf_iterator<char>())
32  << "+----------------------------------------------------------------+\n"
33  << endl;
34  ifs.close();
35 }
36 
38 {
39  ;
40 }
41 
43 {
44  ;
45 }
46 
48 {
49  ;
50 }
51 
52 void AnaBase::ReadEventsFromFileList(const char* fn_list, const int n_max)
53 {
54  vector<string> list_fname;
55  ifstream ifs(fn_list);
56  string fname;
57  while (ifs >> fname) list_fname.push_back(fname);
58  ifs.close();
59  int n_fname = list_fname.size();
60 
61  m_ofs << "N of input files = " << n_fname << endl;
62  cout << "N of input files = " << n_fname << endl;
63  for (int ii = 0; ii < n_fname; ii++) {
64  if (n_max > 0 && ii == n_max) break;
65  cout << "." << flush;
66  if ((ii+1) % 50 == 0) cout << " " << (ii+1) << endl;
67  //cout << "File " << setw(3) << ii << " / " << n_fname << endl;
68  ReadEvents(list_fname[ii].c_str());
69  }
70  cout << endl;
71 }
72 
73 void AnaBase::ReadEvents(const char* fname)
74 {
75  ;
76 }
77 
79 {
80  ;
81 }
virtual void Analyze()
Definition: AnaBase.cc:42
std::string m_label
Definition: AnaBase.h:8
virtual void Init()
Definition: AnaBase.cc:37
virtual ~AnaBase()
Definition: AnaBase.cc:20
virtual void End()
Definition: AnaBase.cc:47
std::string m_dir_out
Definition: AnaBase.h:11
virtual void ReadEvents(const char *fname)
Definition: AnaBase.cc:73
std::ofstream m_ofs
Definition: AnaBase.h:12
virtual void ReadEventsFromFileList(const char *fn_list, const int n_max=0)
Definition: AnaBase.cc:52
virtual void ProcessOneEvent()
Definition: AnaBase.cc:78
AnaBase(const std::string label)
Definition: AnaBase.cc:7