Class Reference for E1039 Core & Analysis Software
draw_qa.cc
Go to the documentation of this file.
1 R__LOAD_LIBRARY(interface_main)
2 R__LOAD_LIBRARY(ana_embedding)
3 using namespace std;
4 
5 void draw_qa()
6 {
7  const string dir_in = "scratch";
8 
9  const string fn_list = "list_run_spill.txt";
10  vector<int> list_run;
11  ifstream ifs(fn_list);
12  int run_id;
13  int spill_id;
14  while (ifs >> run_id >> spill_id) list_run.push_back(run_id);
15  ifs.close();
16  std::sort(list_run.begin(), list_run.end());
17  list_run.erase(std::unique(list_run.begin(), list_run.end()), list_run.end());
18  cout << "N of runs = " << list_run.size() << endl;
19 
20  TH1* h1_rfp00 = new TH1D("h1_rfp00", ";RF+00;", 100, 0, 1000);
21  TH1* h1_D1 = new TH1D("h1_D1" , ";D1;" , 100, 0, 800);
22  TH1* h1_D2 = new TH1D("h1_D2" , ";D2;" , 100, 0, 500);
23  TH1* h1_D3p = new TH1D("h1_D3p" , ";D3p;", 100, 0, 500);
24  TH1* h1_D3m = new TH1D("h1_D3m" , ";D3m;", 100, 0, 500);
25 
26  int n_evt_all = 0;
27  int n_evt_id_ok = 0;
28  int n_evt_rf_ok = 0;
29  int n_evt_occ_ok = 0;
30 
31  TFile* file_out = 0;
32  TTree* tree_out = 0;
33  for (auto it = list_run.begin(); it != list_run.end(); it++) {
34  run_id = *it;
35  cout << "Run " << run_id << endl;
36  ostringstream oss;
37  oss << dir_in << "/run_" << setfill('0') << setw(6) << run_id << "/out/embedding_data.root";
38  string fn_in = oss.str();
39  TFile* file_in = new TFile(fn_in.c_str());
40  if (! file_in->IsOpen()) {
41  cout << " Cannot open the input file." << endl;
42  delete file_in;
43  continue;
44  }
45  TTree* tree_in = (TTree*)file_in->Get("tree");
46  if (! tree_in) {
47  cout << " Cannot get the input tree." << endl;
48  delete file_in;
49  continue;
50  }
51  EmbQAData* qa_data = 0;
52  tree_in->SetBranchAddress("qa_data", &qa_data);
53 
54  for (int i_ent = 0; i_ent < tree_in->GetEntries(); i_ent++) {
55  tree_in->GetEntry(i_ent);
56  n_evt_all++;
57  if (qa_data->turn_id > 0 && qa_data->turn_id > 0) n_evt_id_ok++;
58  if (qa_data->rfp00 > 0) n_evt_rf_ok++;
59  if (qa_data->D1 > 0 && qa_data->D2 > 0 && qa_data->D3p > 0 && qa_data->D3m > 0) {
60  n_evt_occ_ok++;
61  h1_rfp00->Fill(qa_data->rfp00);
62  h1_D1 ->Fill(qa_data->D1);
63  h1_D2 ->Fill(qa_data->D2);
64  h1_D3p ->Fill(qa_data->D3p);
65  h1_D3m ->Fill(qa_data->D3m);
66  }
67  }
68  file_in->Close();
69  }
70 
71  gSystem->mkdir("qa", true);
72 
73  TCanvas* c1 = new TCanvas("c1", "");
74  c1->SetGrid();
75  c1->SetLogy(true);
76 
77  h1_rfp00->Draw(); c1->SaveAs("qa/h1_rfp00.png");
78  h1_D1 ->Draw(); c1->SaveAs("qa/h1_D1.png");
79  h1_D2 ->Draw(); c1->SaveAs("qa/h1_D2.png");
80  h1_D3p ->Draw(); c1->SaveAs("qa/h1_D3p.png");
81  h1_D3m ->Draw(); c1->SaveAs("qa/h1_D3m.png");
82 
83  ofstream ofs("qa/count.txt");
84  ofs << "All = " << n_evt_all << "\n"
85  << "Turn+RF ID OK = " << n_evt_id_ok << "\n"
86  << "RFp00 OK = " << n_evt_rf_ok << "\n"
87  << "Occ OK = " << n_evt_occ_ok << "\n";
88  ofs.close();
89 
90  exit(0);
91 }
void draw_qa()
Definition: draw_qa.cc:5
int D2
Definition: TreeData.h:89
int D1
Definition: TreeData.h:88
int D3m
Definition: TreeData.h:91
int D3p
Definition: TreeData.h:90
int rfp00
Definition: TreeData.h:86
int turn_id
Definition: TreeData.h:83