Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoadWaveforms.C
Go to the documentation of this file.
1 //
2 // Load waveforms from files
3 // Author : Gabriele Vedovato
4 
5 #define WAVEFORM_GA_DIR "/home/waveburst/WAVEFORMS/GA"
6 #define WAVEFORM_SG_DIR "/home/waveburst/WAVEFORMS/SG"
7 #define WAVEFORM_WNB_DIR "/home/waveburst/WAVEFORMS/WNB"
8 #define WFRATE 16384.
9 #define N_IFO 3
10 
11 //#define READ_GA
12 #define READ_SG
13 //#define READ_WNB
14 
15 #define DRAW_WF "SG1304Q100"
16 //#define DRAW_WF "WNB_1000_1000_0d01"
17 #define PRINT_WF
18 
20 
22 
23 void LoadWaveforms() {
24 
25  TString ifo[N_IFO] = {"L1","H1","V1"};
26 
27  MDC = new CWB::mdc(N_IFO,ifo);
28 
29  MDC->SetInjLength(1.5);
30 
31  vector<TString> fileList;
32 
33 #ifdef READ_GA
34  // read GA waveform file names
35  fileList = CWB::Toolbox::getFileListFromDir(WAVEFORM_GA_DIR, ".txt", "GA");
36  for(int n=0;n<fileList.size();n++) { // loop over the root output files
37  //cout << n << " " << fileList[n].Data() << endl;
38  waveform wf = GetWaveform(fileList[n]); // read waveform
39  MDC->AddWaveform(wf); // add waveform
40  }
41 #endif
42 
43 #ifdef READ_SG
44  // read SG waveform file names
45  fileList = CWB::Toolbox::getFileListFromDir(WAVEFORM_SG_DIR, ".txt", "SG");
46  for(int n=0;n<fileList.size();n++) { // loop over the root output files
47  //cout << n << " " << fileList[n].Data() << endl;
48  waveform wf = GetWaveform(fileList[n]); // read waveform
49  MDC->AddWaveform(wf); // add waveform
50  }
51 #endif
52 
53 #ifdef READ_WNB
54  cout << "read WNB waveform file names ..." << endl;
55  fileList = CWB::Toolbox::getFileListFromDir(WAVEFORM_WNB_DIR, ".txt", "WNB");
56  for(int n=0;n<fileList.size();n++) { // loop over the root output files
57  //cout << n << " " << fileList[n].Data() << endl;
58  waveform wf = GetWaveform(fileList[n]); // read waveform
59  MDC->AddWaveform(wf); // add waveform
60  }
61  cout << "generate WNB with all possible hp,hx permutations ..." << endl;
62  for(int i=0;i<MDC->wfList.size();i++) {
63  cout << "extract all waveforms belonging to the WNB type " << MDC->wfList[i].name << " ..." << endl;
64  int N = MDC->wfList[i].list.size()+1; // number of waveforms belonging to the same WNB type
65  waveform wf,jwf,kwf;
66  vector<waveform> vWF;
67  for(int j=0;j<N;j++) {
68  for(int k=0;k<N;k++) {
69  if(j!=k) {
70  jwf = (j==0) ? MDC->wfList[i] : MDC->wfList[i].list[j-1];
71  kwf = (k==0) ? MDC->wfList[i] : MDC->wfList[i].list[k-1];
72  wf.name = jwf.name;
73  wf.type = MDC_USER;
74  wf.hpPath = jwf.hpPath;
75  wf.hxPath = kwf.hpPath;
76  wf.hp=jwf.hp;
77  wf.hx=kwf.hp;
78  wf.par.resize(3);
79  wf.par[1].name="hp"; wf.par[1].value=j;
80  wf.par[2].name="hx"; wf.par[2].value=k;
81  vWF.push_back(wf);
82  }
83  }
84  }
85  // add permutations waveform to MDC
86  for(int j=0;j<vWF.size();j++) {
87 
88  vWF[j].par[0].name="wf"; vWF[j].par[0].value=j+1; // fill par[0]
89 
90  if(j==0) MDC->wfList[i] = vWF[j]; // overwrite wf
91  if(j>0) MDC->AddWaveform(vWF[j]); // add waveform
92  }
93  }
94 #endif
95 
96  int nMDC = MDC->wfList.size(); // numer of MDC types
97 
98 #ifdef PRINT_WF
99  MDC->Print(1);
100 #endif
101 
102 #ifdef DRAW_WF
103  // Draw SG1304Q100 waveform
104  for(int i=0;i<nMDC;i++) {
105  if(MDC->wfList[i].name == DRAW_WF) {
106  cout << i << " " << MDC->wfList[i].name.Data()
107  << " " << MDC->wfList[i].list.size()+1 << endl;
108 
109  MDC->Draw(i,0,"hp",MDC_TIME);
110  MDC->Draw(i,0,"hx",MDC_TIME,"same",kRed);
111 
112  //wavearray<double> hp = MDC->wfList[i].hp;
113  //MDC->Draw(hp);
114  //MDC->Draw(hp,MDC_FFT);
115  //MDC->Draw(hp,MDC_TF);
116  }
117  }
118 #endif
119 
120 }
121 
122 waveform
124 
125  waveform wf;
127  vector<mdcpar> par(3);
128 
129  // extract MDC name
130  TString mdc_name = fName;
131  mdc_name.Remove(0,mdc_name.Last('/')+1);
132  if(mdc_name.Contains(".")) mdc_name.Remove(mdc_name.Last('.'));
133  if(mdc_name.Contains("~")) mdc_name.Remove(mdc_name.Last('~'));
134 // cout << "MDC NAME : " << mdc_name << endl;
135  // read waveform
136  MDC->ReadWaveform(x, fName, WFRATE);
137  // build waveform
138  wf.name = mdc_name;
139  wf.type = MDC_USER;
140  wf.hpPath = fName;
141  wf.hp = x;
142  wf.hxPath = "";
143  wf.hx = wf.hp;
144  wf.hx = 0;
145  wf.par=par;
146 
147  return wf;
148 }
Definition: mdc.hh:172
#define WAVEFORM_WNB_DIR
Definition: LoadWaveforms.C:7
static vector< TString > getFileListFromDir(TString dir_name, TString endString="", TString beginString="", TString containString="", bool fast=false)
Definition: Toolbox.cc:4333
watplot * Draw(TString name, int id=0, TString polarization="hp", MDC_DRAW type=MDC_TIME, TString options="ALP", Color_t color=kBlack)
Definition: mdc.cc:2288
Definition: mdc.hh:189
waveform GetWaveform(TString fName)
int n
Definition: cwb_net.C:10
TString("c")
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1)*itime+ifreq;double time=itime *dT;double freq=(ifreq >0)?ifreq *dF:dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
TString mdc[4]
void SetInjLength(double inj_length=MDC_INJ_LENGTH)
Definition: mdc.hh:272
wavearray< double > hp
Definition: mdc.hh:196
waveform wf
int j
Definition: cwb_net.C:10
i drho i
CWB::mdc * MDC
Definition: LoadWaveforms.C:21
#define N
void LoadWaveforms()
Definition: LoadWaveforms.C:23
mdcid AddWaveform(MDC_TYPE mdc_type, vector< mdcpar > par, TString uname="")
Definition: mdc.cc:445
void Print(int level=0)
Definition: mdc.cc:2707
char ifo[NIFO_MAX][8]
#define WAVEFORM_GA_DIR
Definition: LoadWaveforms.C:5
Definition: mdc.hh:138
TString name
Definition: mdc.hh:192
TString hxPath
Definition: mdc.hh:194
Definition: mdc.hh:216
vector< mdcpar > par
Definition: mdc.hh:195
#define N_IFO
Definition: LoadWaveforms.C:9
#define nMDC
int k
vector< mdcpar > par
vector< waveform > wfList
Definition: mdc.hh:355
wavearray< double > hx
Definition: mdc.hh:197
cout<< "Starting reading output directory ..."<< endl;vector< TString > fileList
void ReadWaveform(wavearray< double > &x, TString fName, double srate)
Definition: mdc.cc:1848
#define WAVEFORM_SG_DIR
Definition: LoadWaveforms.C:6
#define DRAW_WF
Definition: LoadWaveforms.C:15
#define WFRATE
Definition: LoadWaveforms.C:8
char fName[256]
MDC_TYPE type
Definition: mdc.hh:190
TString hpPath
Definition: mdc.hh:193