Class Reference for E1039 Core & Analysis Software
RunList.cc
Go to the documentation of this file.
1 #include <sstream>
2 #include <TSystem.h>
3 #include <TFile.h>
4 //#include <E906DataCatalog.h>
5 #include "RunList.h"
6 using namespace std;
7 
8 RunList::RunList(const std::string ds)
9  : m_env ("gpvm")
10  , m_ds (ds)
11  , m_verb(0)
12  , m_file(0)
13 {
14  /*auto dc = E906DataCatalog::instance();
15  dc->ListRun(ds, &m_list_run);
16  if (m_list_run.size() == 0) {
17  cout << "RunList finds no run for dataset '" << ds << "'. Abort." << endl;
18  exit(1);
19  }
20  dc->PreSetDataset(ds);*/
21  //dc->Verbosity(2);
22 }
23 
25 {
26  if (m_file) delete m_file;
27 }
28 
29 int RunList::OpenRunFile(const std::string dir_base, const int index, int& run_id, TFile*& file)
30 {
31  /*run_id = m_list_run[index];
32  if (Verbosity() > 0) cout << " Run " << run_id << " (" << index+1 << "/" << m_list_run.size() << ")" << endl;
33 
34  auto dc = E906DataCatalog::instance();
35  dc->PreSetRun(run_id);
36  string run6d = dc->GetRun6d(run_id);
37 
38  ostringstream oss;
39  oss << dir_base << "/" << run6d.substr(0, 2) << "/" << run6d.substr(2, 2) << "/" << run6d.substr(4, 2);
40  if (m_env == "gpvm") oss << "/out";
41  oss << "/output.root";
42 
43  string fname = oss.str();
44  if (gSystem->AccessPathName(fname.c_str()) ) { // Not found
45  if (Verbosity() > 1) cout << " No output file. Skip." << endl;
46  return 1;
47  }
48 
49  if (m_file) delete m_file;
50  m_file = file = new TFile(fname.c_str());
51  if (! m_file->IsOpen()) {
52  if (Verbosity() > 1) cout << " Cannot open '" << fname << "'. Skip." << endl;
53  return 2;
54  }*/
55  return 0;
56 }
int OpenRunFile(const std::string dir_base, const int index, int &run_id, TFile *&file)
Open the input file for the run at index under dir_base.
Definition: RunList.cc:29
RunList(const std::string ds)
Definition: RunList.cc:8
virtual ~RunList()
Definition: RunList.cc:24