Logo Coherent WaveBurst  
Reference Guide
Logo
 All Namespaces Files Functions Variables Macros Pages
CreateChunkFiles.C
Go to the documentation of this file.
1 #define CHUNK_FILE_LIST "Chunk_List.txt"
2 #define MACRO_READ_CHUNK "ReadChunkList.C"
3 #define CHUNK_MAX_SIZE 100
4 
5 #define EXECUTE
6 
7 void CreateChunkFiles(TString run) {
8 
9  // get CWB_CONFIG
10  char cwb_config_env[1024] = "";
11  if(gSystem->Getenv("CWB_CONFIG")!=NULL) {
12  strcpy(cwb_config_env,TString(gSystem->Getenv("CWB_CONFIG")).Data());
13  }
14 
15  char chunk_file_list[1024];
16  sprintf(chunk_file_list,"%s/%s/CHUNKS/%s",cwb_config_env,run.Data(),CHUNK_FILE_LIST);
17  cout << chunk_file_list << endl;
18 
19  char macro_read_chunk_path[1024];
20  sprintf(macro_read_chunk_path,"%s/MACROS/%s",cwb_config_env,MACRO_READ_CHUNK);
21 
22  CWB::Toolbox::checkFile(macro_read_chunk_path);
23 
24  // load macro
25  gROOT->LoadMacro(gSystem->ExpandPathName(macro_read_chunk_path));
26 
27  int chunk[CHUNK_MAX_SIZE];
28  double start[CHUNK_MAX_SIZE];
29  double stop[CHUNK_MAX_SIZE];
30 
31  int nChunks = ReadChunkList(chunk_file_list, chunk, start, stop);
32 
33  char ofile[1024];
34  for(int k=0;k<nChunks;k++) {
35 // cout << "\t" << chunk[k] << "\t" << (int)start[k] << "\t" << (int)stop[k] << endl;
36 
37  sprintf(ofile,"%s/%s/CHUNKS/K%02d.period",cwb_config_env,run.Data(),chunk[k]);
38 
39 #ifdef EXECUTE
40  ofstream out;
41  out.open(ofile,ios::out);
42  out.precision(16);
43  out << start[k] << "\t" << stop[k] << endl;
44  out.close();
45 #else
46  cout.precision(16);
47  cout << start[k] << "\t" << stop[k] << endl;
48 #endif
49 
50  cout << "output file list : " << ofile << endl;
51  }
52 
53  // create chunk99 : full period
54  sprintf(ofile,"%s/%s/CHUNKS/K%02d.period",cwb_config_env,run.Data(),99);
55 #ifdef EXECUTE
56  ofstream out;
57  out.open(ofile,ios::out);
58  out.precision(16);
59  out << 0 << "\t" << 2147483647 << endl;
60  out.close();
61 #else
62  cout.precision(16);
63  cout << 0 << "\t" << 2147483647 << endl;
64 #endif
65  cout << "output file list : " << ofile << endl;
66 
67  exit(0);
68 
69 }
strcpy(analysis,"2G")
exit(0)
int nChunks
#define CHUNK_MAX_SIZE
int ReadChunkList(TString ifile, int *chunk=NULL, double *start=NULL, double *stop=NULL)
Definition: ReadChunkList.C:4
#define CHUNK_FILE_LIST
double stop[CHUNK_MAX_SIZE]
int chunk[CHUNK_MAX_SIZE]
double start[CHUNK_MAX_SIZE]
char ofile[1024]
void CreateChunkFiles(TString run)
#define MACRO_READ_CHUNK