Logo coherent WaveBurst  
Library Reference Guide
Logo
Make_SN_O1.C
Go to the documentation of this file.
1 //
2 // Make BRST LF [32:1024] Hz Set for O1 (proposal)
3 // How to use it :
4 // root -b Make_SN_O1.C
5 //
6 // 1) TIME & FFT plots are generated for each waveform and saved under the ODIR/plots directory
7 // 2) A texi file html_index.texi is created under ODIR
8 // 3) texi file is converted into ODIR/html_index/index.html
9 //
10 // Author : Gabriele Vedovato
11 //
12 
13 // ------------------------------------------------------------------------------
14 // Scheidegger2010 : R4E1FC
15 // https://wiki.ligo.org/viewauth/Bursts/O1Waveforms
16 // https://svn.ligo.caltech.edu/svn/snsearch/Raw_Waveforms/Scheidegger2010/
17 // ------------------------------------------------------------------------------
18 /*
19 #define SNNAME "R4E1FC_L"
20 #define SNDIR "/home/waveburst/WAVEFORMS/SN/Scheidegger2010/WaveformFiles"
21 #define ODIR "sn_o1/R4E1FC_L" // output plot directory
22 #define NTH 14
23 #define NPH 23
24 */
25 
26 // ------------------------------------------------------------------------------
27 // Ott2013 : s27fheat1p05
28 // https://wiki.ligo.org/viewauth/Bursts/O1Waveforms
29 // https://svn.ligo.caltech.edu/svn/snsearch/Raw_Waveforms/Ott2013/WaveformFiles/
30 // ------------------------------------------------------------------------------
31 
32 #define SNNAME "s27fheat1p05"
33 #define SNDIR "/home/waveburst/WAVEFORMS/SN/Ott2013/WaveformFiles"
34 #define ODIR "sn_o1/s27fheat1p05" // output plot directory
35 #define NTH 18
36 #define NPH 27
37 
38 
39 #define HEADER // add cwb header to html
40 
42 
43 void Plot_SN_O1(vector<waveform> wfList, int ID, int id);
44 void WriteHtml_SN_O1(ofstream& out, vector<waveform> wfList, int ID, int id, int index);
45 
46 void Make_SN_O1() {
47 
48  gROOT->SetBatch(true);
49 
50  MDC = new CWB::mdc();
51 
52  // read SN waveform file list
53  vector<TString> snList = CWB::Toolbox::getFileListFromDir(SNDIR, "plus.txt",SNNAME,"",true);
54  if(snList.size()==0) {
55  cout << "No SN files are present on the directory : " << SNDIR << endl;
56  return;
57  }
58  for(int j=0;j<snList.size();j++) {
59  //cout << j << " " << snList[j] << endl;
60  TString sn_name = SNNAME;
61  TString hp_name = snList[j];
62  TString hc_name = snList[j]; hc_name.ReplaceAll("plus.txt","cross.txt");
63  TString name = gSystem->BaseName(hp_name.Data()); name.ReplaceAll("-plus.txt","");
64  TString sth = name; sth.Remove(0,NTH);sth.Remove(5,sth.Sizeof());
65  TString sph = name; sph.Remove(0,NPH);sph.Remove(5,sph.Sizeof());
66  vector<mdcpar> sn_par(4);
67  sn_par[0].name="name"; sn_par[0].svalue=name;
68  sn_par[1].name="theta"; sn_par[1].value=sth.Atof();
69  sn_par[2].name="phi"; sn_par[2].value=sph.Atof();
70  sn_par[3].name="hrss"; sn_par[3].value=-1; // do not normalize hrss
71  MDC->AddWaveform(sn_name,hp_name,hc_name,16384,sn_par);
72  }
73 
74  MDC->Print(1);
75 
76  vector<waveform> wfList = MDC->GetWaveformList();
77 
78  gSystem->mkdir(TString::Format("%s/plots",ODIR),true);
79 
80  // loop over the waveform list
81  for(int n=0;n<wfList.size();n++) {
82  Plot_SN_O1(wfList,n,0);
83  for(int j=0;j<(int)wfList[n].list.size();j++) {
84  Plot_SN_O1(wfList,n,j);
85  }
86  }
87 
88  TString texiName=TString::Format("%s/html_index.texi",ODIR);
89  bool overwrite=CWB::Toolbox::checkFile(texiName,true);
90  if(!overwrite) gSystem->Exit(0);
91  int index=1;
92  ofstream out;
93  out.open(texiName,ios::out);
94  out << "@c include texi macros" << endl;
95  out << "@include macros.texi" << endl;
96  out << "@include mathjax.texi" << endl << endl;
97  for(int n=0;n<wfList.size();n++) {
98  WriteHtml_SN_O1(out,wfList,n,0,index++);
99  for(int j=0;j<(int)wfList[n].list.size();j++) {
100  WriteHtml_SN_O1(out,wfList,n,j,index++);
101  }
102  }
103  out.close();
104 
105  // convert texi into html
106  TString cwb_scripts = TString(gSystem->Getenv("CWB_SCRIPTS"));
107  //TString exec_cmd = TString::Format("%s/cwb_mkhtml.csh %s wheader;rm %s",
108  // cwb_scripts.Data(),texiName.Data(),texiName.Data());
109 #ifdef HEADER
110  TString exec_cmd = TString::Format("%s/cwb_mkhtml.csh %s wheader",
111  cwb_scripts.Data(),texiName.Data());
112 #else
113  TString exec_cmd = TString::Format("%s/cwb_mkhtml.csh %s",
114  cwb_scripts.Data(),texiName.Data());
115 #endif
116  int ret=gSystem->Exec(exec_cmd);
117  if(ret) {
118  cout << "Make_SN_O1.C : Error while executing cwb_mkhtml html_index.texi !!!" << endl;
119  gSystem->Exit(1);
120  }
121  cout << endl << "New html file created : " << ODIR << "/html_index/index.html" << endl << endl;
122 
123  gSystem->Exit(0);
124 }
125 
126 void Plot_SN_O1(vector<waveform> wfList, int ID, int id) {
127 
128  waveform wf = MDC->GetWaveform(wfList[ID].name,id);
129  if(wf.status==false) {
130  cout << "Error : Waveform " << wf.name << " not exist in the MDC pool !!!" << endl << endl;
131  gSystem->Exit(1);
132  }
133 
134  cout << ID << " " << wf.name << " size : " << wf.hp.size() << " rate : " << wf.hp.rate()
135  << " start : " << (int)wf.hp.start() << endl;
136 
137  wf.hp.start(0); // set start to 0 (needed by draw Method)
138  wf.hx.start(0);
139 
140  watplot* plot = NULL;
141  TString name = wf.par[0].svalue;
142 
143  plot=MDC->Draw(wf.hp,MDC_TIME,"ALP");
144  MDC->Draw(wf.hx,MDC_TIME,"same",kRed);
145  if(plot) plot->graph[0]->SetTitle(TString::Format("%s : h+(black), hx(red))",name.Data()));
146  if(plot) plot->canvas->SaveAs(TString::Format("%s/plots/%s_TIME.png",ODIR,name.Data()));
147 
148  plot = MDC->Draw(wf.hp,MDC_FFT,"ALP"); // draw hp in frequency domain
149  MDC->Draw(wf.hx,MDC_FFT,"same",kRed);
150  plot->graph[0]->GetHistogram()->GetXaxis()->SetRangeUser(0,8*1024);
151  if(plot) plot->graph[0]->SetTitle(TString::Format("%s : h+(black), hx(red))",name.Data()));
152  if(plot) plot->canvas->SaveAs(TString::Format("%s/plots/%s_FFT.png",ODIR,name.Data()));
153 
154 }
155 
156 void WriteHtml_SN_O1(ofstream& out, vector<waveform> wfList, int ID, int id, int index) {
157 
158  waveform wf = MDC->GetWaveform(wfList[ID].name,id);
159  TString parms = TString::Format("hrss @@ 10kpc : %s = %0.3g - %s = %0.3g",
160  wf.par[4].name.Data(),wf.par[4].value,
161  wf.par[5].name.Data(),wf.par[5].value);
162  TString name = wf.par[0].svalue;
163  out << "@center @txtfont{"<<TString::Format("%d - %s",index,name.Data()).Data() <<", red, h1}" << endl;
164  out << "@center @txtfont{"<<parms<<", blue, h2}" << endl;
165  out << "@multitable @columnfractions .5 .5" << endl;
166  out << "@item @center @displayimage{../plots,"
167  <<TString::Format("%s_TIME",name.Data())<<",480}"<<endl;
168  out << "@tab @center @displayimage{../plots,"
169  <<TString::Format("%s_FFT",name.Data())<<",480}"<<endl;
170  out << "@end multitable" << endl;
171 }
#define SNDIR
Definition: Make_SN_O1.C:33
TString cwb_scripts
Definition: mdc.hh:202
static vector< TString > getFileListFromDir(TString dir_name, TString endString="", TString beginString="", TString containString="", bool fast=false)
Definition: Toolbox.cc:5108
#define ODIR
Definition: Make_SN_O1.C:34
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
bool status
Definition: mdc.hh:221
virtual void rate(double r)
Definition: wavearray.hh:141
void Plot_SN_O1(vector< waveform > wfList, int ID, int id)
Definition: Make_SN_O1.C:126
par [0] name
int n
Definition: cwb_net.C:28
Definition: mdc.hh:203
TString("c")
int ID
Definition: TestMDC.C:70
ofstream out
Definition: cwb_merge.C:214
void Make_SN_O1()
Definition: Make_SN_O1.C:46
TString mdc[4]
std::vector< TGraph * > graph
Definition: watplot.hh:194
wavearray< double > hp
Definition: mdc.hh:226
waveform wf
vector< waveform > GetWaveformList()
Definition: mdc.hh:385
virtual void start(double s)
Definition: wavearray.hh:137
int j
Definition: cwb_net.C:28
TList * list
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
mdcid AddWaveform(MDC_TYPE mdc_type, vector< mdcpar > par, TString uname="")
Definition: mdc.cc:472
void Print(int level=0)
Definition: mdc.cc:2736
virtual size_t size() const
Definition: wavearray.hh:145
TCanvas * canvas
Definition: watplot.hh:192
#define NTH
Definition: Make_SN_O1.C:35
TString name
Definition: mdc.hh:222
x plot
Definition: mdc.hh:248
i() int(T_cor *100))
vector< mdcpar > par
Definition: mdc.hh:225
#define SNNAME
Definition: Make_SN_O1.C:32
void WriteHtml_SN_O1(ofstream &out, vector< waveform > wfList, int ID, int id, int index)
Definition: Make_SN_O1.C:156
#define NPH
Definition: Make_SN_O1.C:36
wavearray< double > hx
Definition: mdc.hh:227
wavearray< int > index
waveform GetWaveform(int ID, int id=0)
Definition: mdc.cc:2541
bool overwrite
Definition: cwb_dump_inj.C:100
CWB::mdc * MDC
Definition: Make_SN_O1.C:41