Logo Coherent WaveBurst  
Reference Guide
Logo
 All Namespaces Files Functions Variables Macros Pages
ReadLoudestList.C
Go to the documentation of this file.
1 #define LOUDEST_MAX_SIZE 1000
2 
3 /*
4  TString run[LOUDEST_MAX_SIZE];
5  int chunk[LOUDEST_MAX_SIZE];
6  double gps[LOUDEST_MAX_SIZE];
7  TString bbh_name[LOUDEST_MAX_SIZE];
8  double ifar_sec[LOUDEST_MAX_SIZE];
9  double ifar_year[LOUDEST_MAX_SIZE];
10  int obs_time_sec[LOUDEST_MAX_SIZE];
11  double obs_time_day[LOUDEST_MAX_SIZE];
12  double expected[LOUDEST_MAX_SIZE];
13  int observed[LOUDEST_MAX_SIZE];
14  double cumul_FAP[LOUDEST_MAX_SIZE];
15  double sigma[LOUDEST_MAX_SIZE];
16 
17  int nLoudest = ReadLoudestList(ifile, run, chunk, gps, bbh_name, ifar_sec, ifar_year,
18  obs_time_sec, obs_time_day, expected, observed, cumul_FAP, sigma);
19 
20 */
21 
22 int ReadLoudestList(TString ifile, TString* run, int* chunk, double* gps, TString* bbh_name, double* ifar_sec, double* ifar_year,
23  int* obs_time_sec, double* obs_time_day, double* expected, int* observed, double* cumul_FAP, double* sigma) {
24 
25  CWB::Toolbox::checkFile(ifile);
26 
27  // Open chunk list
28  ifstream in;
29  in.open(ifile.Data(),ios::in);
30  if (!in.good()) {cout << "Error Opening File : " << ifile << endl;exit(1);}
31 
32  int isize=0;
33  char str[1024];
34  int fpos=0;
35  while(true) {
36  in.getline(str,1024);
37  if (!in.good()) break;
38  if(str[0] != '#') isize++;
39  }
40 // cout << "size " << isize << endl;
41  in.clear(ios::goodbit);
42  in.seekg(0, ios::beg);
43  if(isize==0) {cout << "Error : File " << ifile << " is empty" << endl;return 0;}
44  if(isize>LOUDEST_MAX_SIZE) {cout << "Error : File " << ifile << " > " << LOUDEST_MAX_SIZE << endl;exit(1);}
45 
46  char srun[256];
47  char sbbh[256];
48 
49  int k=0;
50  while(true) {
51  fpos=in.tellg();
52  in.getline(str,1024);
53  if (!in.good()) break;
54  if(str[0] == '#' || str[0]=='\0') continue;
55  in.seekg(fpos, ios::beg);
56  in >> srun >> chunk[k] >> gps[k] >> sbbh >> ifar_sec[k] >> ifar_year[k] >> obs_time_sec[k]
57  >> obs_time_day[k] >> expected[k] >> observed[k] >> cumul_FAP[k] >> sigma[k];
58  if(!in.good()) break;
59  run[k]=srun;
60  bbh_name[k]=sbbh;
61  //cout << "\t" << run[k] << "\t" << chunk[k] << "\t" << gps[k] << "\t" << bbh_name[k] << "\t" << ifar_sec[k] << "\t" << ifar_year[k] << "\t" << obs_time_sec[k]
62  // << "\t" << obs_time_day[k] << "\t" << expected[k] << "\t" << observed[k] << "\t" << cumul_FAP[k] << "\t" << sigma[k] << endl;
63  k++;
64  if(k>=LOUDEST_MAX_SIZE) {
65  cout << "WARNING: loudest events exceed LOUDEST_MAX_SIZE = " << LOUDEST_MAX_SIZE << endl;
66  break;
67  }
68  }
69  in.close();
70 
71  return k;
72 }
int chunk[CHUNK_MAX_SIZE]
int ReadLoudestList(TString ifile, TString *run, int *chunk, double *gps, TString *bbh_name, double *ifar_sec, double *ifar_year, int *obs_time_sec, double *obs_time_day, double *expected, int *observed, double *cumul_FAP, double *sigma)
#define LOUDEST_MAX_SIZE