Logo Coherent WaveBurst  
Reference Guide
Logo
 All Namespaces Files Functions Variables Macros Pages
Create_O1ChunkSlagRndFiles.C
Go to the documentation of this file.
1 #include <algorithm> // std::random_shuffle
2 #include <vector> // std::vector
3 #include <ctime> // std::time
4 #include <cstdlib> // std::rand, std::srand
5 
6 #define SLAGS_DIR "/home/waveburst/O1/SLAGS"
7 #define SEED 150914
8 
9 void Create_SlagRndFile(int chunkID, int slagMax);
10 void shuffle(std::vector<int>& vector, int seed=150914);
11 
13 
14  CWB::Toolbox TB;
15 
16  int nIFO = 2;
17 
18  char ifo[NIFO_MAX][8];
19  strcpy(ifo[0],"L1");
20  strcpy(ifo[1],"H1");
21 
22  vector<TString> ifos(nIFO);
23  for(int n=0;n<nIFO;n++) ifos[n]=ifo[n];
24 
25  int slagMin = 0; // if slagMax=0 -> slagMin must be < slagMax
26  int slagOff = 0;
27  size_t* slagSite = NULL; // site index starting with 0
28  char* slagFile = NULL; // slag file list
29 
30  //jobs
31  int segLen = 1200;
32  int segMLS = 600;
33  int segTHR = 0;
34  int segEdge = 10;
35 
36  // dq file list
37  // {ifo, dqcat_file, dqcat[0/1/2], shift[sec], inverse[false/true], 4columns[true/false]}
38  int nDQF=10;
39  dqfile DQF[nDQF]={
40 
41  {"L1" ,"/home/waveburst/O1/DQ/C02/ALL/L1_cat0.txt", CWB_CAT0, 0., false, false},
42  {"H1" ,"/home/waveburst/O1/DQ/C02/ALL/H1_cat0.txt", CWB_CAT0, 0., false, false},
43 
44  {"L1" ,"/home/waveburst/O1/DQ/C02/ALL/L1_cat1.txt", CWB_CAT1, 0., true, false},
45  {"H1" ,"/home/waveburst/O1/DQ/C02/ALL/H1_cat1.txt", CWB_CAT1, 0., true, false},
46 
47  {"L1" ,"/home/waveburst/O1/DQ/C02/ALL/L1_cat2.txt", CWB_CAT2, 0., true, false},
48  {"H1" ,"/home/waveburst/O1/DQ/C02/ALL/H1_cat2.txt", CWB_CAT2, 0., true, false},
49 
50  {"L1" ,"/home/waveburst/O1/DQ/C02/ALL/L1_cat4.txt", CWB_CAT1, 0., true, false},
51  {"H1" ,"/home/waveburst/O1/DQ/C02/ALL/H1_cat4.txt", CWB_CAT1, 0., true, false},
52 
53  {"L1" ," ", CWB_CAT0, 0., false, false},
54  {"H1" ," ", CWB_CAT0, 0., false, false}
55 
56  };
57 
58  for(int k=1;k<=9;k++) {
59 
60  sprintf(DQF[8].file, "/home/waveburst/O1/CHUNKS/O1_chunk%02d.lst", k);
61  sprintf(DQF[9].file, "/home/waveburst/O1/CHUNKS/O1_chunk%02d.lst", k);
62 
63  vector<waveSegment> cat1List=TB.readSegList(nDQF, DQF, CWB_CAT1);
64 
65  int slagMax=TB.getSlagJobList(cat1List, segLen).size();
66 
67  cout << k << " slagMax : " << slagMax << endl;
68 
69  Create_SlagRndFile(k, slagMax);
70  }
71 
72  exit(0);
73 }
74 
75 void Create_SlagRndFile(int chunkID, int slagMax) {
76 
77  std::vector<int> RND(2*slagMax);
78  for(int n=0; n<slagMax; n++) {
79  RND[2*n+0]=+(n+1);
80  RND[2*n+1]=-(n+1);
81  }
82 
83  shuffle(RND,SEED); // shuffle data
84 
85  // check
86  for(int n=0; n<slagMax; n++) {
87  int A = +(n+1);
88  int B = -(n+1);
89  int nA=0;
90  int nB=0;
91  for(int n=0; n<2*slagMax; n++) {
92  if(RND[n]==A) nA++;
93  if(RND[n]==B) nB++;
94  }
95  if(nA!=1 && nB!=1) {
96  cout << "ERROR !!!" << endl;
97  exit(1);
98  }
99  }
100 
101  //for(int n=0; n<2*slagMax; n++) cout << n << "\t" << RND[n] << endl;;
102 
103  char ofile[1024];
104  sprintf(ofile,"%s/slag_rnd_K%02d.lst",SLAGS_DIR,chunkID);
105 
106  ofstream out;
107  out.open(ofile);
108  out << 0 << "\t" << 0 << "\t" << 0 << endl;
109  for(int n=0; n<2*slagMax; n++) {
110  out << n+1 << "\t" << 0 << "\t" << RND[n] << endl;
111  }
112  out.close();
113 
114  return;
115 }
116 
117 void shuffle(std::vector<int>& vector, int seed) {
118 
119  TRandom3 rnd3(seed);
120 
121  size_t size = vector.size();
122 
123  if(size > 1) {
124  size_t i;
125  for(size_t i=0; i<size; i++) {
126  size_t j = int(rnd3.Uniform(0,size));
127  int t = vector[j];
128  vector[j] = vector[i];
129  vector[i] = t;
130  }
131  }
132 }
void Create_O1ChunkSlagRndFiles()
slagFile
nIFO
slagOff
void shuffle(std::vector< int > &vector, int seed=150914)
strcpy(analysis,"2G")
segEdge
#define SEED
shift breaksw case n
Definition: cwb_clchunk.csh:70
shift breaksw case B
slagMax
slagMin
#define SLAGS_DIR
segMLS
segLen
char ofile[1024]
nDQF
void Create_SlagRndFile(int chunkID, int slagMax)
shift breaksw case t
Definition: cwb_clchunk.csh:80
segTHR