Logo coherent WaveBurst  
Library Reference Guide
Logo
Draw_LALSringCusp.C
Go to the documentation of this file.
1 //
2 // Show comparison between LAL Cosmic String Cusps waveformss vs High frequency cut-off
3 //
4 // Author : Gabriele Vedovato
5 //
6 
7 #define nMDC 4
8 
9 #define PLOT_TIME
10 //#define PLOT_FFT
11 //#define PLOT_TF 0
12 
13 //#define ZOOM
14 
15 #define AMPLITUDE 1.
16 
17 #define SAVE_PLOT
18 
20 
22 
23  MDC = new CWB::mdc();
24 
25  mdcid mdcID[nMDC];
26 
27  vector<mdcpar> par;
28  par.resize(2);
29  par[0].name="frequency";
30  par[1].name="amplitude"; par[1].value=AMPLITUDE;
31 
32  for(int n=0;n<nMDC;n++) {
33  if(n==3) par[0].value=50;
34  if(n==2) par[0].value=150;
35  if(n==1) par[0].value=500;
36  if(n==0) par[0].value=1500;
37  mdcID[n] = MDC->AddWaveform(MDC_SC_LAL, par);
38  cout << n << " " << mdcID[n].name << endl;
39  }
40 
41  MDC->Print();
42 
43  waveform wf[nMDC];
44  for(int n=0;n<nMDC;n++) {
45 
46  //wf[n] = MDC->GetWaveform(mdcID[n].name,0);
47  wf[n] = MDC->GetWaveform(n,0);
48 
49  if(wf[n].status==false) {
50  cout << "Error : Waveform " << mdcID[n].name << " not exist in the MDC pool !!!" << endl << endl;
51  gSystem->Exit(1);
52  }
53 
54  double dt=1./wf[n].hp.rate();
55  double hrss=0.;
56  for(int i=0;i<wf[n].hp.size();i++) hrss+=pow(wf[n].hp[i],2);
57  hrss=sqrt(hrss*dt);
58  wf[n].hx=0.;
59 
60  cout << wf[n].name << "\tfreq : " << wf[n].par[0].value << "\tsize : " << wf[n].hp.size()
61  << "\trate : " << wf[n].hp.rate() << "\tstart : " << (int)wf[n].hp.start() << "\thrss : " << hrss << endl;
62 
63  wf[n].hp.start(0); // set start to 0 (needed by draw Method)
64  wf[n].hx.start(0);
65  }
66 
67  int color[nMDC] = {kGreen, kBlue, kRed, kBlack};
68 
69  watplot* plot = NULL;
70 
71  TLegend* leg;
72  double hleg = 0.8-nMDC*0.05;
73 
74  TString gfile;
75 
76  char title[256];sprintf(title,"Cosmic String Cusps vs High frequency cut-off (amplitude=%g)",AMPLITUDE);
77 
78 #ifdef PLOT_TIME
79  for(int n=0;n<nMDC;n++) {
80  if(n==0) {
81  plot=MDC->Draw(wf[n].hp,MDC_TIME,"ALP ZOOM",color[n]);
82  plot->graph[0]->SetTitle(title);
83 #ifdef ZOOM
84  plot->graph[0]->GetHistogram()->GetXaxis()->SetRangeUser(4.49,4.51);
85  plot->graph[0]->GetHistogram()->GetYaxis()->SetRangeUser(1.5,4.5);
86  gfile = "CosmicStringCusps_TimeZoom.png";
87 #else
88  plot->graph[0]->GetHistogram()->GetXaxis()->SetRangeUser(4,5);
89  plot->graph[0]->GetHistogram()->GetYaxis()->SetRangeUser(-1,5);
90  gfile = "CosmicStringCusps_Time.png";
91 #endif
92  } else MDC->Draw(wf[n].hp,MDC_TIME,"same",color[n]);
93  plot->graph[n]->SetLineWidth(2);
94  }
95 #endif
96 
97 #ifdef PLOT_FFT
98  for(int n=0;n<nMDC;n++) {
99  if(n==0) {
100  plot = MDC->Draw(wf[n].hp,MDC_FFT,"ALP ZOOM LOGX",color[n]); // draw hp in frequency domain
101  plot->graph[0]->GetHistogram()->GetXaxis()->SetRangeUser(10,2048);
102  plot->graph[0]->GetHistogram()->GetYaxis()->SetRangeUser(1e-5,0.1);
103  plot->graph[0]->SetTitle(title);
104  } else MDC->Draw(wf[n].hp,MDC_FFT,"same LOGX",color[n]);
105  plot->graph[n]->SetLineWidth(2);
106  gfile = "CosmicStringCusps_Frequency.png";
107  }
108 #endif
109 
110  leg = new TLegend(0.6120401,hleg,0.9615385,0.8721805,NULL,"brNDC");
111  leg->SetBorderSize(1);
112  leg->SetTextAlign(22);
113  leg->SetTextFont(12);
114  leg->SetLineColor(1);
115  leg->SetLineStyle(1);
116  leg->SetLineWidth(1);
117  leg->SetFillColor(0);
118  leg->SetFillStyle(1001);
119  leg->SetTextSize(0.04);
120  leg->SetLineColor(kBlack);
121  leg->SetFillColor(kWhite);
122  for(int n=nMDC-1;n>=0;n--) {
123  char legLabel[256];
124  sprintf(legLabel,"%s",wf[n].name.Data());
125  leg->AddEntry(plot->graph[n],legLabel,"lp");
126  }
127  leg->Draw();
128 
129 #ifdef SAVE_PLOT
130  if(plot) plot->canvas->SaveAs(gfile.Data());
131 #endif
132 
133 #ifdef PLOT_TF
134  MDC->Draw(wf[PLOT_TF].hp,MDC_TF); // draw hp in frequency domain
135  CWB::STFT* stft = MDC->GetSTFT();
136  stft->GetHistogram()->GetXaxis()->SetRangeUser(4.4,4.6);
137  stft->GetHistogram()->GetYaxis()->SetRangeUser(0,200);
138  stft->GetCanvas()->SetLogy(false);
139 #endif
140 
141 }
Definition: mdc.hh:202
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:2317
Definition: mdc.hh:219
virtual void rate(double r)
Definition: wavearray.hh:141
Definition: mdc.hh:207
par [0] name
int n
Definition: cwb_net.C:28
CWB::STFT * GetSTFT()
Definition: mdc.hh:435
Definition: mdc.hh:203
TString("c")
void Draw_LALSringCusp()
TString mdc[4]
std::vector< TGraph * > graph
Definition: watplot.hh:194
wavearray< double > hp
Definition: mdc.hh:226
waveform wf
wavearray< double > hp
Definition: DrawInspiral.C:43
virtual void start(double s)
Definition: wavearray.hh:137
i drho i
mdcid AddWaveform(MDC_TYPE mdc_type, vector< mdcpar > par, TString uname="")
Definition: mdc.cc:472
void Print(int level=0)
Definition: mdc.cc:2736
Definition: mdc.hh:204
virtual size_t size() const
Definition: wavearray.hh:145
TCanvas * canvas
Definition: watplot.hh:192
#define AMPLITUDE
TString name
Definition: mdc.hh:222
x plot
double hrss
Definition: TestMDC.C:70
Definition: mdc.hh:248
i() int(T_cor *100))
vector< mdcpar > par
Definition: mdc.hh:225
TH2D * GetHistogram()
Definition: STFT.hh:71
vector< mdcpar > par
double e
CWB::mdc * MDC
double dt
wavearray< double > hx
Definition: mdc.hh:227
char title[256]
Definition: SSeriesExample.C:1
waveform GetWaveform(int ID, int id=0)
Definition: mdc.cc:2541
TCanvas * GetCanvas()
Definition: STFT.hh:70
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
TString gfile
TString name
Definition: mdc.hh:208
#define nMDC
CWB::STFT * stft
Definition: ChirpMass.C:121