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