Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Test11.C
Go to the documentation of this file.
1 //Test 11: Two witness channels have some common noise (or environmental signal,
2 //but anyway uncorrelated with the GW target channel) between them
3 //Witness channels: A(t) = 0.4*y(t) + w(t) + v(t)
4 // B(t) = 0.2*z(t) + 0.5*w(t) + v(t)
5 //Target channel: H(t) = x(t) + 0.8*w(t)
6 //Hopefully, the code figures out that it should subtract a linear combination of
7 //A(t) and B(t). If I've done the math right (on paper), the optimal combination is
8 //(0.9933)A(t)-(0.7726)B(t). Note that the v(t) noise mostly (but not completely)
9 //cancels out in that combination. The w(t) component amplitude in H(t) reduces
10 //from 0.8 to 0.195, although the post-regression H(t) also picks up amplitudes
11 //of 0.4*0.9933=0.3973 from the y(t) term in A(t), 0.2*0.7726=0.1545 from the z(t)
12 //term in B(t), and 0.9933-0.7726=0.2207 from the combined v(t) terms. So the
13 //expected reduction in noise amplitude is by a factor of
14 // sqrt(1+(0.195)^2+(0.3973)^2+(0.1545)^2+(0.2207)^2)/sqrt(1^2+0.8^2)
15 // = sqrt(1.268)/sqrt(1.64) = 0.88
16 //* Try this with hard, soft, and mild regulators *
17 
18 
19 {
20  //Time
21  #define LENGHT 1200
22  #define SCRATCH 32
23  #define RATE 2048
24 
25  using namespace CWB;
26 
27  //define x channel properties -> gauss 1
28  int N = RATE*(LENGHT+2*SCRATCH);
30  x.rate(RATE);
31  x.resize(N);
32  x.start(0);
33  x.stop(LENGHT+2*SCRATCH);
34 
35  //define w channel properties -> gauss 2
40 
41  // time series is filled with white noise data:
42  TRandom3 rnd(0);
43  for(int i=0; i<N; i++) x[i] = rnd.Gaus();
44  for(int i=0; i<N; i++) w[i] = rnd.Gaus();
45  for(int i=0; i<N; i++) v[i] = rnd.Gaus();
46  for(int i=0; i<N; i++) y[i] = rnd.Gaus();
47  for(int i=0; i<N; i++) z[i] = rnd.Gaus();
48 
49  //Fill target and witness
50  wavearray<double> A = w; A += v; y*= 0.4; A += y;
51  wavearray<double> w_1 = w; w_1 *= 0.5;
52  wavearray<double> B = v; z*= 0.2; B += z; B += w_1;
53  wavearray<double> H = x; w*= 0.8; H += w;
54 
55  //Make WDM transform, resolution = 1Hz
56  int lev=H.rate()/2;
57  WDM<double> wdtf(lev, 2*lev, 6, 10);
59  tfmap.Forward(H, wdtf);
60 
61  //Adding target channel
62  regression r;
63  r.add(tfmap,const_cast<char*>("hchannel"));
64 
65  //Adding witness channel
66  r.add(A,const_cast<char*>("witness"));
67  r.add(B,const_cast<char*>("witness"));
68 
69  regression r_s = r;
70  regression r_m = r;
71 
72  //Calculate prediction
73  r.setFilter(10);
74  r.setMatrix(SCRATCH);
75  r.solve(0, 20, 'h');
76  r.apply(0.2);
77 
78  wavearray<double> clean=r.getClean();
79 
80  cout << "HARD:" << endl;
81  cout << "Ratio rms: (" << clean.rms() << "/" << H.rms() << ")= " << clean.rms()/H.rms() << endl;
82 
83  cout << "x : " << x.mean() << " " << x.rms() << endl;
84  cout << "clean : " << clean.mean() << " " << clean.rms() << endl;
85  clean -= x;
86  cout << "clean-x : " << clean.mean() << " " << clean.rms() << endl;
87  cout << "-------------------" << endl;
88 
89  //Calculate prediction
90  r_s.setFilter(10);
91  r_s.setMatrix(SCRATCH);
92  r_s.solve(0, 20, 's');
93  r_s.apply(0.2);
94 
95  clean=r_s.getClean();
96 
97  cout << "SOFT:" << endl;
98  cout << "Ratio rms: (" << clean.rms() << "/" << H.rms() << ")= " << clean.rms()/H.rms() << endl;
99 
100  cout << "x : " << x.mean() << " " << x.rms() << endl;
101  cout << "clean : " << clean.mean() << " " << clean.rms() << endl;
102  clean -= x;
103  cout << "clean-x : " << clean.mean() << " " << clean.rms() << endl;
104  cout << "-------------------" << endl;
105 
106  //Calculate prediction
107  r_m.setFilter(10);
108  r_m.setMatrix(SCRATCH);
109  r_m.solve(0, 20, 'm');
110  r_m.apply(0.2);
111 
112  clean=r_m.getClean();
113 
114  cout << "MILD:" << endl;
115  cout << "Ratio rms: (" << clean.rms() << "/" << H.rms() << ")= " << clean.rms()/H.rms() << endl;
116 
117  cout << "x : " << x.mean() << " " << x.rms() << endl;
118  cout << "clean : " << clean.mean() << " " << clean.rms() << endl;
119  clean -= x;
120  cout << "clean-x : " << clean.mean() << " " << clean.rms() << endl;
121  cout << "-------------------" << endl;
122 
123  wavearray<double> eigen=r.getVEIGEN(-1);
124  eigen.rate(22);
125  watplot plot;
126  TCanvas *c1 = plot.canvas;
127  c1->SetCanvasSize(1600,800);
128  c1->Divide(1,2);
129 
130  c1->cd(1);
131  plot.plot(eigen,const_cast<char*>("alp"),1);
132  plot.graph[0]->SetTitle("Eigen-values of all layers");
133 
134  c1->cd(2);
135  TPad* P=(TPad*)c1->GetPad(2);
136  P->Divide(3,1);
137 
138  wavearray<double> freq=r.vfreq;
140  wavearray<double> rank1=r.getRank(1);
141  wavearray<double> rank2=r.getRank(2);
142  P->cd(1);
143  TMultiGraph* mg=new TMultiGraph();
144  TGraph* g=new TGraph(freq.size(),freq.data,rank.data);
145  g->SetLineColor(1);
146  mg->Add(g);
147  TGraph* g1=new TGraph(freq.size(),freq.data,rank1.data);
148  g1->SetLineColor(2);
149  mg->Add(g1);
150  TGraph* g2=new TGraph(freq.size(),freq.data,rank2.data);
151  g2->SetLineColor(3);
152  mg->Add(g2);
153  mg->Draw(const_cast<char*>("alp"));
154  mg->SetTitle("HARD: Ranking for all layers");
155 
156  wavearray<double> freq_s=r_s.vfreq;
157  wavearray<double> rank_s=r_s.getRank(0);
158  wavearray<double> rank1_s=r_s.getRank(1);
159  wavearray<double> rank2_s=r_s.getRank(2);
160  P->cd(2);
161  TMultiGraph* mg_s=new TMultiGraph();
162  TGraph* g_s=new TGraph(freq_s.size(),freq_s.data,rank_s.data);
163  g_s->SetLineColor(1);
164  mg_s->Add(g_s);
165  TGraph* g1_s=new TGraph(freq_s.size(),freq_s.data,rank1_s.data);
166  g1_s->SetLineColor(2);
167  mg_s->Add(g1_s);
168  TGraph* g2_s=new TGraph(freq_s.size(),freq_s.data,rank2_s.data);
169  g2_s->SetLineColor(3);
170  mg_s->Add(g2_s);
171  mg_s->Draw(const_cast<char*>("alp"));
172  mg_s->SetTitle("SOFT: Ranking for all layers");
173 
174  wavearray<double> freq_m=r_m.vfreq;
175  wavearray<double> rank_m=r_m.getRank(0);
176  wavearray<double> rank1_m=r_m.getRank(1);
177  wavearray<double> rank2_m=r_m.getRank(2);
178  P->cd(3);
179  TMultiGraph* mg_m=new TMultiGraph();
180  TGraph* g_m=new TGraph(freq_m.size(),freq_m.data,rank_m.data);
181  g_m->SetLineColor(1);
182  mg_m->Add(g_m);
183  TGraph* g1_m=new TGraph(freq_m.size(),freq_m.data,rank1_m.data);
184  g1_m->SetLineColor(2);
185  mg_m->Add(g1_m);
186  TGraph* g2_m=new TGraph(freq_m.size(),freq_m.data,rank2_m.data);
187  g2_m->SetLineColor(3);
188  mg_m->Add(g2_m);
189  mg_m->Draw(const_cast<char*>("alp"));
190  mg_m->SetTitle("MILD: Ranking for all layers");
191 
192  c1->SaveAs("Test11.png");
193 
194  exit(0);
195 
196 }
virtual size_t size() const
Definition: wavearray.hh:127
TF1 * g2
Definition: slag.C:248
static double g(double e)
Definition: GNGen.cc:98
void setMatrix(double edge=0., double f=1.)
Definition: regression.cc:407
Definition: ced.hh:24
virtual void rate(double r)
Definition: wavearray.hh:123
float * rank
#define B
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
std::vector< TGraph * > graph
Definition: watplot.hh:176
TRandom3 P
Definition: compare_bkg.C:296
size_t add(WSeries< double > &target, char *name, double fL=0., double fH=0.)
Definition: regression.cc:73
virtual void start(double s)
Definition: wavearray.hh:119
i drho i
void plot(wavearray< double > &, char *=NULL, int=1, double=0., double=0., bool=false, float=0., float=0., bool=false, float=0., bool=false)
Definition: watplot.cc:132
virtual double mean() const
Definition: wavearray.cc:1053
virtual double rms()
Definition: wavearray.cc:1188
TCanvas * canvas
Definition: watplot.hh:174
#define RATE
x plot
TCanvas * c1
#define LENGHT
TF1 * g1
Definition: compare_bkg.C:505
wavearray< double > v
Definition: Test11.C:37
void apply(double threshold=0., char c='a')
Definition: regression.cc:691
wavearray< double > getRank(int n)
Definition: regression.hh:134
WSeries< double > tfmap
void solve(double th, int nE=0, char c='s')
Definition: regression.cc:592
wavearray< double > y
Definition: Test11.C:38
#define SCRATCH
wavearray< double > vfreq
Definition: regression.hh:171
static double A
Definition: geodesics.cc:8
size_t setFilter(size_t)
Definition: regression.cc:258
wavearray< double > z
Definition: Test11.C:39
wavearray< double > getVEIGEN(int n=-1)
Definition: regression.cc:339
wavearray< double > getClean()
Definition: regression.hh:117
regression r
Definition: Regression_H1.C:44
WDM< double > wdtf(lev, 2 *lev, 6, 10)
virtual void stop(double s)
Definition: wavearray.hh:121
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:228
wavearray< double > w
Definition: Test11.C:36
wavearray< double > x
Definition: Test11.C:29
DataType_t * data
Definition: wavearray.hh:301
int N
Definition: Test11.C:28
int lev
Definition: Regression_H1.C:38
virtual void resize(unsigned int)
Definition: wavearray.cc:445
TMultiGraph * mg
exit(0)
TRandom3 rnd(0)