Logo coherent WaveBurst  
Config Reference Guide
Logo
CreateChunkCuts.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 OFILE_CHUNK_CUTS "Chunks_Cuts.hh"
25 
26 #define EXECUTE
27 
28 void CreateChunkCuts(TString run, TString search="") {
29 
30  // get CWB_CONFIG
31  char cwb_config_env[1024] = "";
32  if(gSystem->Getenv("CWB_CONFIG")!=NULL) {
33  strcpy(cwb_config_env,TString(gSystem->Getenv("CWB_CONFIG")).Data());
34  }
35 
36  char chunk_file_list[1024];
37  sprintf(chunk_file_list,"%s/%s/CHUNKS/%s/%s",cwb_config_env,run.Data(),search.Data(),CHUNK_FILE_LIST);
38  cout << chunk_file_list << endl;
39 
40  int chunk[CHUNK_MAX_SIZE];
41  double start[CHUNK_MAX_SIZE];
42  double stop[CHUNK_MAX_SIZE];
43 
44  int nChunks = ReadChunkList(chunk_file_list,chunk,start,stop);
45 
46  char tcut[256];
47 
48  char ofile[1024];
49  sprintf(ofile,"%s/%s/CHUNKS/%s/%s",cwb_config_env,run.Data(),search.Data(),OFILE_CHUNK_CUTS);
50  cout << "output file list : " << ofile << endl;
51 #ifdef EXECUTE
52  ofstream out;
53  out.open(ofile,ios::out);
54 #endif
55  for(int k=0;k<nChunks;k++) {
56 // cout << "\t" << chunk[k] << "\t" << (int)start[k] << "\t" << (int)stop[k] << endl;
57 
58  sprintf(tcut,"TCut O2_K%02d_cut(\"O2_K%02d_cut\",\"time[0]>%d && time[0]<=%d\");",chunk[k],chunk[k],(int)start[k],(int)stop[k]);
59 
60 #ifdef EXECUTE
61  out << tcut << endl;
62 #else
63  cout << tcut << endl;
64 #endif
65 
66  }
67 
68  // create cut chunk99 : full period
69  sprintf(tcut,"TCut O2_K%02d_cut(\"O2_K%02d_cut\",\"time[0]>%d && time[0]<=%d\");",99,99,(int)start[0],(int)stop[nChunks-1]);
70 #ifdef EXECUTE
71  out << tcut << endl;
72 #else
73  cout << tcut << endl;
74 #endif
75 
76 
77 #ifdef EXECUTE
78  out.close();
79 #endif
80 
81  exit(0);
82 
83 }
#define OFILE_CHUNK_CUTS
void CreateChunkCuts(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