21 #include <lal/LALSimInspiral.h> 33 if(tool==
"Posterior2XML")
Posterior2XML(spar1,
int(dpar1),spar2);
35 if(tool==
"ConvertPSD2ASD") {
37 for(
int i=0;
i<fileList.size();
i++) {
39 TString ofnameASD = fileList[
i]; ofnameASD.ReplaceAll(
"PSD",
"ASD");
55 std::map<TString, double> psample;
56 std::vector<TString> pname;
60 name=
"dummy"; psample[
name] = 0; pname.push_back(name);
62 name=
"time"; psample[
name] =
gps; pname.push_back(name);
64 name=
"costheta_jn"; psample[
name] = 0; pname.push_back(name);
65 name=
"distance"; psample[
name] = 0; pname.push_back(name);
66 name=
"ra"; psample[
name] = 0; pname.push_back(name);
67 name=
"dec"; psample[
name] = 0; pname.push_back(name);
68 name=
"m1"; psample[
name] = 0; pname.push_back(name);
69 name=
"m2"; psample[
name] = 0; pname.push_back(name);
70 name=
"a1"; psample[
name] = 0; pname.push_back(name);
71 name=
"a2"; psample[
name] = 0; pname.push_back(name);
72 name=
"costilt1"; psample[
name] = 0; pname.push_back(name);
73 name=
"costilt2"; psample[
name] = 0; pname.push_back(name);
75 if(ifname.Contains(
"GW170817")) {
76 name=
"lambda1"; psample[
name] = 0; pname.push_back(name);
77 name=
"lambda2"; psample[
name] = 0; pname.push_back(name);
80 name=
"q"; psample[
name] = 0; pname.push_back(name);
81 name=
"mc"; psample[
name] = 0; pname.push_back(name);
83 name=
"lal_pnorder"; psample[
name] = 8; pname.push_back(name);
84 name=
"lal_amporder"; psample[
name] = 0; pname.push_back(name);
85 name=
"lal_approximant"; psample[
name] = IMRPhenomPv2; pname.push_back(name);
86 name=
"flow"; psample[
name] = 20; pname.push_back(name);
87 name=
"f_ref"; psample[
name] = 20; pname.push_back(name);
89 name=
"phase"; psample[
name] = 0; pname.push_back(name);
90 name=
"psi"; psample[
name] = 0; pname.push_back(name);
91 name=
"phi12"; psample[
name] = 0; pname.push_back(name);
92 name=
"phi_jl"; psample[
name] = 0; pname.push_back(name);
97 if(!in.good()) {cout <<
"Error Opening File : " << ifname.Data() << endl;
exit(1);}
101 if(!out.good()) {cout <<
"Error Opening File : " << ofname.Data() << endl;
exit(1);}
105 for(
int i = 0;
i < pname.size();
i++) out << pname[
i] <<
"\t";
112 in >>
line;
if(!in.good())
break;
113 if(
TString(line).Contains(
"{")) {
114 in >>
line;
if(!in.good())
break;
118 psample[
"costheta_jn"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
119 psample[
"distance"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
120 psample[
"ra"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
121 psample[
"dec"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
122 psample[
"m1"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
123 psample[
"m2"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
124 if(ifname.Contains(
"GW170817")) {
125 psample[
"lambda1"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
126 psample[
"lambda2"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
128 psample[
"a1"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
129 psample[
"a2"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
130 psample[
"costilt1"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
131 psample[
"costilt2"] =
TString(line).Atof(); in >>
line;
if(!in.good())
break;
133 double m1 = psample[
"m1"];
134 double m2 = psample[
"m2"];
135 psample[
"mc"] = pow(m1*m2,3./5.)/pow(m1+m2,1./5.);
136 psample[
"q"] = m2<m1 ? m2/
m1 : m1/
m2;
139 for(
int i = 0;
i < pname.size();
i++) out << psample[pname[
i]] <<
"\t";
153 if(
TString(line).Contains(
"}")) data=
false;
158 cout << endl <<
"ConvertSamples.C - converted entries: " << entries << endl;
160 cout << endl <<
"ConvertSamples.C - created file: " << ofname << endl << endl;
183 gRandom->SetSeed(seed);
187 options +=
"--ninjections 1 ";
189 if(seed==0) options +=
"--sample maxl ";
190 else if(seed==1) options +=
"--sample map ";
191 else options += TString::Format(
"--seed %d ",seed);
193 TString file_tag = model!=
"" ? gwname+
"_PE_"+
model : gwname+
"_PE";
194 TString approximant =
model; approximant.ReplaceAll(
"C01:",
"");
196 if(model==
"") approximant =
"IMRPhenomPv2";
198 options +=
"--source "+gwname+
" ";
199 options +=
"--waveform "+approximant+
"pseudoFourPN ";
200 options +=
"--f_ref 20 ";
201 options +=
"--f_lower 20 ";
206 options +=
"--clb_file "+file_tag+
".clb ";
223 in.open(ifname.Data(),
ios::in);
224 if (!in.good()) {cout <<
"Error Opening File : " << ifname << endl;
exit(1);}
230 in.getline(str,1024);
231 if (!in.good())
break;
232 if(str[0] !=
'#') size++;
234 cout <<
"size " << size << endl;
235 in.clear(ios::goodbit);
236 in.seekg(0, ios::beg);
238 in.getline(str,1024);
241 int iH1 = header.Index(
"LIGO_Hanford_PSD");
242 int iL1 = header.Index(
"LIGO_Livingston_PSD");
243 int iV1 = header.Index(
"Virgo_PSD");
249 if(iH1>=0) {iIFO[
nIFO]=iH1;sIFO[
nIFO]=
"H1";nIFO++;}
250 if(iL1>=0) {iIFO[
nIFO]=iL1;sIFO[
nIFO]=
"L1";nIFO++;}
251 if(iV1>=0) {iIFO[
nIFO]=iV1;sIFO[
nIFO]=
"V1";nIFO++;}
253 if(nIFO==0 || nIFO>
MAX_IFOS) {cout <<
"Error: no IFOs in PSDs file or not allowed Format" << endl;
exit(1);}
260 if(nIFO==1) in >> freq[lines] >> psd[0][lines];
261 if(nIFO==2) in >> freq[lines] >> psd[0][lines] >> psd[1][lines];
262 if(nIFO==3) in >> freq[lines] >> psd[0][lines] >> psd[1][lines] >> psd[2][lines];
263 if (!in.good())
break;
270 TMath::Sort(nIFO,iIFO,idx,
false);
275 ofname.ReplaceAll(
"_PSDs.dat",
"_ASD_"+sIFO[m]+
".dat");
276 cout << ofname << endl;
279 if(!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
280 out << 0 <<
"\t" << 10*sqrt(psd[m][0]) << endl;
281 for(
int i=0;
i<
size;
i++) out << freq[
i] <<
"\t" << sqrt(psd[m][
i]) << endl;
282 out << 8192 <<
"\t" << 10*sqrt(psd[m][size-1]) << endl;
294 in.open(ifnamePSD.Data(),
ios::in);
296 {cout <<
"ConvertPSD2ASD - Error Opening File : " 297 << ifnamePSD.Data() << endl;gSystem->Exit(1);}
299 cout <<
"ConvertPSD2ASD - Read File : " << ifnamePSD.Data() << endl;
303 char sfr[1024],ssh[1024];
310 in.getline(str,1024);
311 if(str[0] ==
'#')
continue;
312 in.seekg(fpos, ios::beg);
315 if (!in.good())
break;
317 in.seekg(fpos+1, ios::beg);
321 {cout <<
"ConvertPSD2ASD - input sensitivity file : " << ifnamePSD.Data()
322 <<
" contains zero at frequency : " << fr <<
" Hz " << endl;gSystem->Exit(1);}
323 vfr.push_back(fr); vsh.push_back(sh);
329 fr = 2*vfr[vfr.size()-1] - vfr[vfr.size()-2];
330 sh = vsh[vsh.size()-1];
331 vfr.push_back(fr); vsh.push_back(sh);
332 vfr.push_back(8192.); vsh.push_back(sh);
337 cout <<
"ConvertPSD2ASD - Write File : " << ofnameASD.Data() << endl;
339 out.open(ofnameASD.Data(),
ios::out);
340 for(
int i=0;
i<vfr.size();
i++) out << vfr[
i] <<
"\t" << sqrt(vsh[
i]) << endl;
wavearray< double > psd(33)
CWB::frame fr(FRLIST_NAME)
cout<< "Starting reading output directory ..."<< endl;vector< TString > fileList