5 #include "../../MACROS/ReadChunkList.C"
9 #define CHUNK_FILE_LIST "Chunk_List.txt"
10 #define CHUNK_MAX_SIZE 100
15 void shuffle(std::vector<int>& vector,
int seed=150914);
22 char cwb_config_env[1024] =
"";
23 if(gSystem->Getenv(
"CWB_CONFIG")!=NULL) {
24 strcpy(cwb_config_env,TString(gSystem->Getenv(
"CWB_CONFIG")).Data());
28 TString o3_gps_start_cxx = TString::Format(
"O3_GPS_START_%s",
calibVer.Data());
30 if(gSystem->Getenv(o3_gps_start_cxx.Data())!=NULL) {
31 gps_start=TString(gSystem->Getenv(o3_gps_start_cxx.Data())).Atof();
33 cout <<
"Error: O3_GPS_START_CXX env not defined" << endl;
exit(1);
35 TString o3_gps_stop_cxx = TString::Format(
"O3_GPS_STOP_%s",
calibVer.Data());
37 if(gSystem->Getenv(o3_gps_stop_cxx.Data())!=NULL) {
38 gps_stop=TString(gSystem->Getenv(o3_gps_stop_cxx.Data())).Atof();
40 cout <<
"Error: O3_GPS_STOP_CXX env not defined" << endl;
exit(1);
43 char chunk_file_list[1024];
45 cout << chunk_file_list << endl;
51 int nChunks =
ReadChunkList(chunk_file_list,chunk,start,stop);
56 char ifo[NIFO_MAX][8];
65 size_t* slagSite = NULL;
76 {
"L1" ,
"", CWB_CAT0, 0.,
false,
false},
77 {
"H1" ,
"", CWB_CAT0, 0.,
false,
false},
79 {
"L1" ,
"", CWB_CAT1, 0.,
true,
false},
80 {
"H1" ,
"", CWB_CAT1, 0.,
true,
false},
82 {
"L1" ,
"", CWB_CAT2, 0.,
true,
false},
83 {
"H1" ,
"", CWB_CAT2, 0.,
true,
false},
85 {
"L1" ,
"", CWB_CAT1, 0.,
true,
false},
86 {
"H1" ,
"", CWB_CAT1, 0.,
true,
false},
88 {
"L1" ,
"", CWB_CAT0, 0.,
false,
false},
89 {
"H1" ,
"", CWB_CAT0, 0.,
false,
false}
93 sprintf(DQF[0].file,
"%s/O3/DATA/%s/DQ/%s/L1_cat0.txt",cwb_config_env,
calibVer.Data(),calibType.Data());
94 sprintf(DQF[1].file,
"%s/O3/DATA/%s/DQ/%s/H1_cat0.txt",cwb_config_env,
calibVer.Data(),calibType.Data());
96 sprintf(DQF[2].file,
"%s/O3/DATA/%s/DQ/%s/L1_cat1.txt",cwb_config_env,
calibVer.Data(),calibType.Data());
97 sprintf(DQF[3].file,
"%s/O3/DATA/%s/DQ/%s/H1_cat1.txt",cwb_config_env,
calibVer.Data(),calibType.Data());
99 sprintf(DQF[4].file,
"%s/O3/DATA/%s/DQ/%s/L1_cat2.txt",cwb_config_env,
calibVer.Data(),calibType.Data());
100 sprintf(DQF[5].file,
"%s/O3/DATA/%s/DQ/%s/H1_cat2.txt",cwb_config_env,
calibVer.Data(),calibType.Data());
102 sprintf(DQF[6].file,
"%s/O3/DATA/%s/DQ/%s/L1_cat4.txt",cwb_config_env,
calibVer.Data(),calibType.Data());
103 sprintf(DQF[7].file,
"%s/O3/DATA/%s/DQ/%s/H1_cat4.txt",cwb_config_env,
calibVer.Data(),calibType.Data());
108 sprintf(ofile,
"%s/%s/slagSizeMax.lst",slags_dir.Data(),calibType.Data());
110 sprintf(ofile,
"%s/%s/slagSizeMax.lst",slags_dir.Data(),
search.Data());
112 cout << ofile << endl;
115 if (!out.good()) {cout <<
"Error Opening File : " << ofile << endl;
exit(1);}
116 out <<
"# chunk slagSize" << endl << endl;
120 sprintf(ofile2,
"%s/%s/liveTimes.lst",slags_dir.Data(),calibType.Data());
122 sprintf(ofile2,
"%s/%s/liveTimes.lst",slags_dir.Data(),
search.Data());
124 cout << ofile2 << endl;
127 if (!out2.good()) {cout <<
"Error Opening File : " << ofile2 << endl;
exit(1);}
128 out2 <<
"# chunk liveTime_cat0\tliveTime_cat1\tliveTime_cat2" << endl << endl;
131 sprintf(sout2,
"%s %*s %*s %*s %*s %*s %*s",
132 "# chunk", 22,
"liveTime_cat0(sec)", 22,
"liveTime_cat0(days)",
133 22,
"liveTime_cat1(sec)", 22,
"liveTime_cat1(days)",
134 22,
"liveTime_cat2(sec)", 22,
"liveTime_cat2(days)");
135 out2 << sout2 << endl;
137 cout <<
"# chunk slagSize" << endl << endl;
139 for(
int k=0;k<nChunks;k++) {
141 if(stop[k]<=gps_start || start[k]>=gps_stop || stop[k]>gps_stop)
continue;
143 sprintf(DQF[8].file,
"%s/O3/CHUNKS/%s/K%02d.period",cwb_config_env,
search.Data(),chunk[k]);
144 sprintf(DQF[9].file,
"%s/O3/CHUNKS/%s/K%02d.period",cwb_config_env,
search.Data(),chunk[k]);
146 vector<waveSegment> cat0List=TB.readSegList(
nDQF, DQF, CWB_CAT0);
147 double live_time_cat0 = CWB::Toolbox::getTimeSegList(cat0List);
148 cout << endl <<
"live_time_cat0 : " << (int)live_time_cat0 <<
" (sec) - " << live_time_cat0/(24.*3600.) <<
" (days)" << endl;
150 vector<waveSegment> cat1List=TB.readSegList(
nDQF, DQF, CWB_CAT1);
151 double live_time_cat1 = CWB::Toolbox::getTimeSegList(cat1List);
152 cout << endl <<
"live_time_cat1 : " << (int)live_time_cat1 <<
" (sec) - " << live_time_cat1/(24.*3600.) <<
" (days)" << endl;
154 vector<waveSegment> cat2List=TB.readSegList(
nDQF, DQF, CWB_CAT2);
155 double live_time_cat2 = CWB::Toolbox::getTimeSegList(cat2List);
156 cout << endl <<
"live_time_cat2 : " << (int)live_time_cat2 <<
" (sec) - " << live_time_cat2/(24.*3600.) <<
" (days)" << endl << endl;
159 sprintf(sout2,
"K%02d %*d %*.2f %*d %*.2f %*d %*.2f",
160 chunk[k], 22, (
int)live_time_cat0, 22, (live_time_cat0/(24.*3600.)),
161 22, (
int)live_time_cat1, 22, (live_time_cat1/(24.*3600.)),
162 22, (
int)live_time_cat2, 22, (live_time_cat2/(24.*3600.)));
163 out2 << sout2 << endl;
168 char string[64];
sprintf(
string,
"K%02d\t%d",chunk[k],2*
slagMax+1);
169 cout <<
"slagSize = \t" <<
string << endl;
178 out <<
string << endl;
193 std::vector<int> RND(2*
slagMax);
212 cout <<
"ERROR !!!" << endl;
220 sprintf(ofile,
"%s/%s/K%02d.slags",slags_dir.Data(),
search,chunkID);
221 cout << endl << ofile << endl << endl;
226 if (!out.good()) {cout <<
"Error Opening File : " << ofile << endl;
exit(1);}
227 out << 0 <<
"\t" << 0 <<
"\t" << 0 << endl;
229 out <<
n+1 <<
"\t" << 0 <<
"\t" << RND[
n] << endl;
241 size_t size = vector.size();
245 for(
size_t i=0; i<
size; i++) {
246 size_t j = int(rnd3.Uniform(0,
size));
248 vector[j] = vector[i];
void Create_SlagRndFile(TString slags_dir, int chunkID, int slagMax, char *cwb_config_env, char *calibVer, char *search)
void shuffle(std::vector< int > &vector, int seed=150914)
void Create_O3_LH_ChunkSlagRndFiles(TString slags_dir, TString calibVer, TString calibType, TString search="")
int ReadChunkList(TString ifile, int *chunk=NULL, double *start=NULL, double *stop=NULL)
sprintf(tag,"wave_%s", data_label)