Logo coherent WaveBurst  
Config Reference Guide
Logo
CreateMergedHVETO.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 #include "MergeSegments.C"
21 
22 #define CHUNK_FILE_LIST "Chunk_List.txt"
23 #define CHUNK_MAX_SIZE 100
24 
25 #define EXECUTE
26 
27 void CreateMergedHVETO(TString run, TString ifo, TString calibVer) {
28 
29  if(run!="O1" && run!="O2") {
30  cout << "CreateMergedHVETO : Error - run type not available !!!" << endl;
31  exit(1);
32  }
33  if(ifo!="L1" && ifo!="H1" && ifo!="V1") {
34  cout << "CreateMergedHVETO : Error - ifo type not available !!!" << endl;
35  exit(1);
36  }
37 
38  // get CWB_CONFIG
39  char cwb_config_env[1024] = "";
40  if(gSystem->Getenv("CWB_CONFIG")!=NULL) {
41  strcpy(cwb_config_env,TString(gSystem->Getenv("CWB_CONFIG")).Data());
42  }
43 
44  char chunk_file_list[1024];
45  sprintf(chunk_file_list,"%s/%s/CHUNKS/%s",cwb_config_env,run.Data(),CHUNK_FILE_LIST);
46  cout << chunk_file_list << endl;
47 
48  int chunk[CHUNK_MAX_SIZE];
49  double start[CHUNK_MAX_SIZE];
50  double stop[CHUNK_MAX_SIZE];
51 
52  int nChunks = ReadChunkList(chunk_file_list, chunk, start, stop);
53 
54  char vetoes_dir[1024];
55  sprintf(vetoes_dir,"%s/%s/DATA/%s/HVETO",cwb_config_env,run.Data(),calibVer.Data());
56  char vetoes_dir_tmp[1024];
57  sprintf(vetoes_dir_tmp,"%s/%s/DATA/%s/HVETO/tmp",cwb_config_env,run.Data(),calibVer.Data());
58 
59  // create temporary vetoes_dir_tmp dir
60  cout << vetoes_dir_tmp << endl << endl;
61 #ifdef EXECUTE
62  CWB::Toolbox::mkDir(vetoes_dir_tmp,true,true);
63 #endif
64 
65  // merge douplicate entries
66  char ihveto_file[1024];
67  char ohveto_file[1024];
68  for(int k=0;k<nChunks;k++) {
69  sprintf(ihveto_file,"%s/%s/HVETO_%s_ANALYSIS%d_SEGMENTS.txt",vetoes_dir,ifo.Data(),ifo.Data(),chunk[k]);
70  sprintf(ohveto_file,"%s/HVETO_%s_ANALYSIS%d_SEGMENTS_MERGED.txt",vetoes_dir_tmp,ifo.Data(),chunk[k]);
71  cout << "ihveto_file : " << ihveto_file << endl;
72  cout << "ohveto_file : " << ohveto_file << endl;
73  cout << endl;
74 #ifdef EXECUTE
75  MergeSegments(ihveto_file,ohveto_file,false);
76 #endif
77  }
78 
79  // merge hveto files
80  char cmd[1024];
81  sprintf(cmd,"rm %s/%s/HVETO_%s_ANALYSIS_SEGMENTS_MERGED.txt",vetoes_dir,ifo.Data(),ifo.Data());
82  cout << cmd << endl;
83 #ifdef EXECUTE
84  gSystem->Exec(cmd);
85 #endif
86  for(int k=0;k<nChunks;k++) {
87  if(k==0) {
88  sprintf(cmd,"cat %s/HVETO_%s_ANALYSIS%d_SEGMENTS_MERGED.txt > %s/%s/HVETO_%s_ANALYSIS_SEGMENTS_MERGED.txt",
89  vetoes_dir_tmp,ifo.Data(),chunk[k],vetoes_dir,ifo.Data(),ifo.Data());
90  } else {
91  sprintf(cmd,"cat %s/HVETO_%s_ANALYSIS%d_SEGMENTS_MERGED.txt >> %s/%s/HVETO_%s_ANALYSIS_SEGMENTS_MERGED.txt",
92  vetoes_dir_tmp,ifo.Data(),chunk[k],vetoes_dir,ifo.Data(),ifo.Data());
93  }
94  cout << cmd << endl;
95 #ifdef EXECUTE
96  gSystem->Exec(cmd);
97 #endif
98  }
99 
100  // remove temporary vetoes_dir_tmp dir
101  cout << vetoes_dir_tmp << endl << endl;
102 #ifdef EXECUTE
103  CWB::Toolbox::rmDir(vetoes_dir_tmp,false);
104 #endif
105 
106  exit(0);
107 }
void CreateMergedHVETO(TString run, TString ifo, TString calibVer)
#define CHUNK_FILE_LIST
#define CHUNK_MAX_SIZE
void MergeSegments(TString ifile, TString ofile, bool bexit=true)
Definition: MergeSegments.C:29
strcpy(analysis,"2G")
TString calibVer
int ReadChunkList(TString ifile, int *chunk=NULL, double *start=NULL, double *stop=NULL)
Definition: ReadChunkList.C:22
string run
Definition: cWB_conf.py:6