Logo coherent WaveBurst  
Config Reference Guide
Logo
CreateChunkFiles.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 #include "ReadChunkList.C"
20 
21 #define CHUNK_FILE_LIST "Chunk_List.txt"
22 #define CHUNK_MAX_SIZE 100
23 
24 #define EXECUTE
25 
26 void CreateChunkFiles(TString run, TString search="") {
27 
28  // get CWB_CONFIG
29  char cwb_config_env[1024] = "";
30  if(gSystem->Getenv("CWB_CONFIG")!=NULL) {
31  strcpy(cwb_config_env,TString(gSystem->Getenv("CWB_CONFIG")).Data());
32  }
33 
34  char chunk_file_list[1024];
35  sprintf(chunk_file_list,"%s/%s/CHUNKS/%s/%s",cwb_config_env,run.Data(),search.Data(),CHUNK_FILE_LIST);
36  cout << chunk_file_list << endl;
37 
38  int chunk[CHUNK_MAX_SIZE];
39  double start[CHUNK_MAX_SIZE];
40  double stop[CHUNK_MAX_SIZE];
41 
42  int nChunks = ReadChunkList(chunk_file_list, chunk, start, stop);
43 
44  char ofile[1024];
45  for(int k=0;k<nChunks;k++) {
46 // cout << "\t" << chunk[k] << "\t" << (int)start[k] << "\t" << (int)stop[k] << endl;
47 
48  sprintf(ofile,"%s/%s/CHUNKS/%s/K%02d.period",cwb_config_env,run.Data(),search.Data(),chunk[k]);
49 
50 #ifdef EXECUTE
51  ofstream out;
52  out.open(ofile,ios::out);
53  out.precision(16);
54  out << start[k] << "\t" << stop[k] << endl;
55  out.close();
56 #else
57  cout.precision(16);
58  cout << start[k] << "\t" << stop[k] << endl;
59 #endif
60 
61  cout << "output file list : " << ofile << endl;
62  }
63 
64  // create chunk99 : full period
65  sprintf(ofile,"%s/%s/CHUNKS/%s/K%02d.period",cwb_config_env,run.Data(),search.Data(),99);
66 #ifdef EXECUTE
67  ofstream out;
68  out.open(ofile,ios::out);
69  out.precision(16);
70  out << 0 << "\t" << 2147483647 << endl;
71  out.close();
72 #else
73  cout.precision(16);
74  cout << 0 << "\t" << 2147483647 << endl;
75 #endif
76  cout << "output file list : " << ofile << endl;
77 
78  exit(0);
79 
80 }
void CreateChunkFiles(TString run, TString search="")
#define CHUNK_FILE_LIST
#define CHUNK_MAX_SIZE
strcpy(analysis,"2G")
int ReadChunkList(TString ifile, int *chunk=NULL, double *start=NULL, double *stop=NULL)
Definition: ReadChunkList.C:22
string search
Definition: cWB_conf.py:63
string run
Definition: cWB_conf.py:6