Logo coherent WaveBurst  
Library Reference Guide
Logo
WriteCalFileForPluginCE.C
Go to the documentation of this file.
1 
2 // this macro provides an example for the generation of the calibration file for CWB_Plugin_CE.C
3 
4 #define SPCAL_NPTS 10 // number of frequency points where amp and phase errors are provided
5 //#define FREQ_MIN 20
6 #define FREQ_MIN 5 // min frequency
7 #define FREQ_MAX 1024 // max frequency
8 
9 #define nIFO 3 // number of detectors used for calibration file
10 
11 #define nENTRY 1 // number of entries in the calibration file
12 
13 void WriteCalFileForPluginCE(TString clb_file="clb_file_ce.clb") {
14 
15  TString ifo[NIFO] = {"h1","l1","v1"}; // WARNING: ifo must be defined with lower-case characters
16 
17  // check input name
18  ofstream clb;
19  if(!clb_file.Contains(".clb")) {
20  cout << endl << "Error : calibration file extention must be .clb" << endl;
21  exit(1);
22  }
23 
24  // open file
25  clb.open(clb_file.Data(),ios::out);
26  if(!clb.good()) {
27  cout << endl << "Error Opening Output Calibration File : " << clb_file.Data() << endl;
28  exit(1);
29  }
30  clb.precision(14);
31 
32  // write header
33  clb << "time\t" << "spcal_active\t" << "spcal_npts\t" << "simulation_id\t";
34  for(int n=0;n<nIFO;n++) {
35  for(int i=0;i<SPCAL_NPTS;i++) {
36  clb << TString::Format("%s_spcal_freq_%d\t",ifo[n].Data(),i);
37  clb << TString::Format("%s_spcal_amp_%d\t",ifo[n].Data(),i);
38  clb << TString::Format("%s_spcal_phase_%d\t",ifo[n].Data(),i);
39  }
40  }
41  clb << endl;
42 
43  // define frequency array in log scale
44  double logFactor = (log(FREQ_MAX)-log(FREQ_MIN))/(SPCAL_NPTS-1);
45  double logFreq[SPCAL_NPTS];
46  logFreq[0] = log(FREQ_MIN);
47  for(int i=1;i<SPCAL_NPTS;i++) logFreq[i]=logFreq[i-1]+logFactor;
48  for(int i=0;i<SPCAL_NPTS;i++) cout << i << "\tFrequency: " << exp(logFreq[i]) << "\t logFrequency: " << logFreq[i] << endl;
49 
50  // init amp/phase calibration errors
51  double spcal_amp[nIFO][SPCAL_NPTS];
52  double spcal_phase[nIFO][SPCAL_NPTS];
53  for(int n=0;n<nIFO;n++) {
54  for(int i=0;i<SPCAL_NPTS;i++) {
55  if(ifo[n]=="h1") {
56  spcal_amp[n][i] = 0.2; // amplitude error in percentage
57  spcal_phase[n][i] = 90.0*TMath::Pi()/180.; // phase errors in radians
58  }
59  if(ifo[n]=="l1") {
60  spcal_amp[n][i] = 0.3;
61  spcal_phase[n][i] = 45.0*TMath::Pi()/180.;
62  }
63  if(ifo[n]=="v1") {
64  spcal_amp[n][i] = 0.0;
65  spcal_phase[n][i] = 0.0*TMath::Pi()/180.;
66  }
67  }
68  }
69 
70  // write entries
71  double time=1267963151.; // the Plugin_CE uses this GPS time to select the calibration entry
72  int spcal_active = 1; // must be 1
73  int simulation_id = 0; // not used
74  for(int k=0;k<nENTRY;k++) {
75  clb << time << " \t" << spcal_active << "\t" << SPCAL_NPTS << "\t" << simulation_id << "\t";
76  for(int n=0;n<nIFO;n++) {
77  for(int i=0;i<SPCAL_NPTS;i++) {
78  clb << exp(logFreq[i]) << "\t";
79  clb << spcal_amp[n][i] << "\t";
80  clb << spcal_phase[n][i] << "\t";
81  }
82  }
83  clb << endl;
84  }
85 
86  clb.close();
87 
88  exit(0);
89 }
#define NIFO
Definition: wat.hh:74
int n
Definition: cwb_net.C:28
TString("c")
ofstream out
Definition: cwb_merge.C:214
#define nENTRY
i drho i
char ifo[NIFO_MAX][8]
#define SPCAL_NPTS
double Pi
bool log
Definition: WaveMDC.C:41
#define FREQ_MIN
int k
void WriteCalFileForPluginCE(TString clb_file="clb_file_ce.clb")
#define FREQ_MAX
#define nIFO
exit(0)