1 R__LOAD_LIBRARY(interface_main)
2 R__LOAD_LIBRARY(ana_embedding)
7 const int n_evt_file = 2000;
8 const string fn_list =
"list_run_spill.txt";
9 const string dir_in =
"scratch";
11 string dir_out = (string)
"/pnfs/e1039/scratch/users/"+gSystem->Getenv(
"USER")+
"/HitEmbedding/data_emb_nim4_merged";
12 if (! gSystem->AccessPathName(dir_out.c_str())) {
13 cout <<
"The output directory exists. Enter 'GO' to delete it." << endl;
17 cout <<
"Abort." << endl;
20 cout <<
"Deleting the directory..." << endl;
21 gSystem->Exec((
"rm -rf "+dir_out).c_str());
25 ifstream ifs(fn_list);
28 while (ifs >> run_id >> spill_id) list_run.push_back(run_id);
30 std::sort(list_run.begin(), list_run.end());
31 list_run.erase(std::unique(list_run.begin(), list_run.end()), list_run.end());
32 int n_run = list_run.size();
33 cout <<
"N of runs = " << n_run << endl;
42 for (
int i_run = 0; i_run < n_run; i_run++) {
43 run_id = list_run[i_run];
44 cout <<
"Run " << run_id <<
" | " << i_run <<
"/" << n_run << endl;
46 oss << dir_in <<
"/run_" << setfill(
'0') << setw(6) << run_id <<
"/out/embedding_data.root";
47 string fn_in = oss.str();
48 TFile* file_in =
new TFile(fn_in.c_str());
49 cout <<
" " << fn_in << endl;
50 if (! file_in->IsOpen()) {
51 cout <<
" Cannot open the input file." << endl;
55 TTree* tree_in = (TTree*)file_in->Get(
"tree");
57 cout <<
" Cannot get the input tree." << endl;
64 tree_in->SetBranchAddress(
"SQEvent" , &evt);
65 tree_in->SetBranchAddress(
"SQHitVector", &vec_hit);
66 tree_in->SetBranchAddress(
"qa_data" , &qa_data);
67 int n_ent = tree_in->GetEntries();
68 cout <<
" N of entries = " << n_ent << endl;
69 for (
int i_ent = 0; i_ent < n_ent; i_ent++) {
70 tree_in->GetEntry(i_ent);
72 cout <<
" Output file: idx = " << idx_out << endl;
74 oss << dir_out <<
"/" << setw(4) << idx_out;
75 gSystem->mkdir(oss.str().c_str(),
true);
76 oss <<
"/embedding_data.root";
77 file_out =
new TFile(oss.str().c_str(),
"RECREATE");
78 tree_out =
new TTree(
"tree",
"Created by merge_emb_file.cc.");
79 tree_out->Branch(
"SQEvent" , &evt);
80 tree_out->Branch(
"SQHitVector", &vec_hit);
82 if (qa_data->
D1 == 0 || qa_data->
D1 > 350 ||
83 qa_data->
D2 == 0 || qa_data->
D2 > 170 ||
84 qa_data->
D3p == 0 || qa_data->
D3p > 140 ||
85 qa_data->
D3m == 0 || qa_data->
D3m > 140 ) {
92 if (n_evt_now == n_evt_file) {
109 ofstream ofs(dir_out+
"/00info.txt");
110 ofs <<
"n_evt_file = " << n_evt_file <<
"\n"
111 <<
"dir_in = " << dir_in <<
"\n"
112 <<
"dir_out = " << dir_out <<
"\n"
113 <<
"n_evt_ok = " << n_evt_ok <<
"\n"
114 <<
"n_evt_ng = " << n_evt_ng <<
"\n";
An SQ interface class to hold one event header.
An SQ interface class to hold a list of SQHit objects.