6 #define FAILMSG( stat, func, file, line, id ) \
8 if ( lalDebugLevel & LALERROR ) \
10 LALPrintError( "Error[0]: file %s, line %d, %s\n" \
11 "\tLAL_CALL: Function call `%s' failed.\n", file, line, id, func ); \
15 #define LAL_CALL( function, statusptr ) \
16 ((function),lal_errhandler(statusptr,#function,__FILE__,__LINE__,"$Id$"))
18 LALStatus blank_status;
20 typedef int ( *lal_errhandler_t )(
25 volatile const char *
id
33 volatile const char *
id
36 if ( stat->statusCode )
38 FAILMSG( stat, func, file, line,
id );
49 volatile const char *
id
52 if ( stat->statusCode )
54 FAILMSG( stat, func, file, line,
id );
57 return stat->statusCode;
61 lal_errhandler_t lal_errhandler = LAL_ERR_ABRT;
65 ProcessParamsTable **add_process_param(ProcessParamsTable **proc_param,
const ProcessTable *process,
66 const char *type,
const char *param,
const char *
value) {
67 *proc_param = XLALCreateProcessParamsTableRow(process);
68 snprintf((*proc_param)->program,
sizeof((*proc_param)->program),
"%s",
"cWB");
69 snprintf((*proc_param)->type,
sizeof((*proc_param)->type),
"%s", type);
70 snprintf((*proc_param)->param,
sizeof((*proc_param)->param),
"--%s", param);
71 snprintf((*proc_param)->value,
sizeof((*proc_param)->value),
"%s", value);
72 return &(*proc_param)->next;
75 #define ADD_PROCESS_PARAM(proc_param, process, type, param, value) \
76 do { proc_param = add_process_param(proc_param, process, type, param, value); } while(0)
216 if(pD[
n]->isBuiltin()) _pD =
new detector(pD[
n]->Name);
217 else _pD =
new detector(pD[
n]->getDetectorParams());
269 if(inj!=NULL)
delete inj;
271 if(inj_tree!=NULL)
delete inj_tree;
273 if(psp!=NULL)
delete psp;
275 if(pts!=NULL)
delete pts;
285 if(value.
net!=NULL) {
300 if(value.
inj!=NULL) {
302 if(inj!=NULL)
delete inj;
304 inj_tree = inj->setTree();
306 inj->output(inj_tree,
net,1,
false);
331 wfList.clear(); this->wfList = value.
wfList;
332 mdcList.clear(); this->mdcList = value.
mdcList;
333 mdcType.clear(); this->mdcType = value.
mdcType;
334 xmlType.clear(); this->xmlType = value.
xmlType;
335 mdcTime.clear(); this->mdcTime = value.
mdcTime;
336 mdcName.clear(); this->mdcName = value.
mdcName;
337 srcList.clear(); this->srcList = value.
srcList;
338 nameList.clear(); this->nameList = value.
nameList;
339 thList.clear(); this->thList = value.
thList;
340 phList.clear(); this->phList = value.
phList;
341 psiList.clear(); this->psiList = value.
psiList;
342 rhoList.clear(); this->rhoList = value.
rhoList;
343 iotaList.clear(); this->iotaList = value.
iotaList;
344 hrssList.clear(); this->hrssList = value.
hrssList;
345 gpsList.clear(); this->gpsList = value.
gpsList;
346 IDList.clear(); this->IDList = value.
IDList;
347 idList.clear(); this->idList = value.
idList;
382 gRandom->SetSeed(seed);
416 for(
int i=0;
i<(
int)par.size();
i++) {
417 if(par[
i].name.CompareTo(name)==0)
return par[
i].
value;
436 for(
int i=0;
i<(
int)par.size();
i++) {
437 if(par[
i].name.CompareTo(name)==0)
return par[
i].svalue;
554 if(mdc_type<0 || mdc_type>=
MDC_USER) {
555 cout <<
"CWB::mdc::AddWaveform - Error : mdc type " << mdc_type <<
" not allowed !!!" << endl;
561 mdcid waveid = {
"",0,0};
565 int decimals = (
int)GetPar(
"decimals",par,error);
566 if(error) decimals = -1;
573 double frequency = GetPar(
"frequency",par,error);
574 double tau = GetPar(
"tau",par,error);
576 if(mdc_type==
MDC_RDE) iota = 0.;
577 if(mdc_type==
MDC_RDC) iota = 0.;
578 if(mdc_type==
MDC_RD) iota = 90.;
581 cout <<
"CWB::mdc::AddWaveform - "
582 <<
"Error : num par must be at least 2 [frequency,tau]" << endl;
586 int d1 = decimals==-1 ? 0 : decimals;
587 int d2 = decimals==-1 ? 1 : decimals;
589 if(mdc_type==
MDC_RD)
sprintf(wf_name,
"RD_%.*f_%.*f",d1,frequency,d2,tau);
590 if(mdc_type==
MDC_RDC)
sprintf(wf_name,
"RDC_%.*f_%.*f",d1,frequency,d2,tau);
591 if(mdc_type==
MDC_RDE)
sprintf(wf_name,
"RDE_%.*f_%.*f",d1,frequency,d2,tau);
595 wf.
name.ReplaceAll(
".",
"d");
597 wf.
hp = GetRD(frequency,tau,iota,0);
598 wf.
hx = GetRD(frequency,tau,iota,1);
610 double frequency = GetPar(
"frequency",par,error);
611 double Q = GetPar(
"Q" ,par,error);
614 cout <<
"CWB::mdc::AddWaveform - Error : num par must be 2 [frequency,Q]" << endl;
618 int d1 = decimals==-1 ? 0 : decimals;
619 int d2 = decimals==-1 ? 1 : decimals;
621 if(mdc_type==
MDC_SG)
sprintf(wf_name,
"SG%.*fQ%.*f",d1,frequency,d2,Q);
622 if(mdc_type==
MDC_SGC)
sprintf(wf_name,
"SGC%.*fQ%.*f",d1,frequency,d2,Q);
623 if(mdc_type==
MDC_SGE)
sprintf(wf_name,
"SGE%.*fQ%.*f",d1,frequency,d2,Q);
627 wf.
name.ReplaceAll(
".",
"d");
628 if(decimals==-1) wf.
name.ReplaceAll(
"d0",
"");
630 wf.
hp = GetSGQ(frequency,Q);
637 wf.
hx = GetCGQ(frequency,Q);
650 double frequency = GetPar(
"frequency",par,error);
651 double Q = GetPar(
"Q" ,par,error);
654 cout <<
"CWB::mdc::AddWaveform - Error : num par must be 2 [frequency,Q]" << endl;
658 int d1 = decimals==-1 ? 0 : decimals;
659 int d2 = decimals==-1 ? 1 : decimals;
661 if(mdc_type==
MDC_CG)
sprintf(wf_name,
"CG%.*fQ%.*f",d1,frequency,d2,Q);
662 if(mdc_type==
MDC_CGC)
sprintf(wf_name,
"CGC%.*fQ%.*f",d1,frequency,d2,Q);
663 if(mdc_type==
MDC_CGE)
sprintf(wf_name,
"CGE%.*fQ%.*f",d1,frequency,d2,Q);
667 wf.
name.ReplaceAll(
".",
"d");
668 if(decimals==-1) wf.
name.ReplaceAll(
"d0",
"");
670 wf.
hp = GetCGQ(frequency,Q);
677 wf.
hx = GetSGQ(frequency,Q);
688 double frequency = GetPar(
"frequency",par,error);
689 double bandwidth = GetPar(
"bandwidth",par,error);
690 double duration = GetPar(
"duration" ,par,error);
693 cout <<
"CWB::mdc::AddWaveform - "
694 <<
"Error : WNB par must at least "
695 <<
"[frequency,bandwidth,duration]" << endl;
699 error=
false;
int pseed = (
int)GetPar(
"pseed",par,error);
if(error) pseed=0;
700 error=
false;
int xseed = (
int)GetPar(
"xseed",par,error);
if(error) xseed=0;
701 error=
false;
bool mode = (bool)GetPar(
"mode",par,error);
if(error) mode=0;
703 int d1 = decimals==-1 ? 0 : decimals;
704 int d2 = decimals==-1 ? 0 : decimals;
705 int d3 = decimals==-1 ? 3 : decimals;
707 sprintf(wf_name,
"WNB%.*f_%.*f_%.*f",d1,frequency,d2,bandwidth,d3,duration);
711 wf.
name.ReplaceAll(
".",
"d");
713 wf.
hp = GetWNB(frequency,bandwidth,duration,pseed,mode);
715 wf.
hx = GetWNB(frequency,bandwidth,duration,xseed,mode);
724 double duration = GetPar(
"duration" ,par,error);
727 cout <<
"CWB::mdc::AddWaveform - "
728 <<
"Error : num par must at least 1 "
729 <<
"[duration]" << endl;
733 int d1 = decimals==-1 ? 1 : decimals;
735 sprintf(wf_name,
"GA%.*f",d1,1000.*duration);
739 wf.
name.ReplaceAll(
".",
"d");
741 wf.
hp = GetGA(duration);
752 #if LAL_VERSION_MAJOR > 6 || (LAL_VERSION_MAJOR == 6 && \
753 (LAL_VERSION_MINOR > 15 || (LAL_VERSION_MINOR == 15 && \
754 LAL_VERSION_MICRO >= 0 ))) // LAL_VERSION >= 6.15.0
757 double duration = GetPar(
"duration",par,error);
760 cout <<
"CWB::mdc::AddWaveform - "
761 <<
"Error : wrong input LAL GA parameters : "
762 <<
"[duration,decimals(opt)]" << endl;
767 SimBurst *sim_burst = XLALCreateSimBurst();
768 strcpy(sim_burst->waveform,
"Gaussian");
770 mdcpar mpar={
"normalization",1};par.push_back(mpar);
772 XLALDestroySimBurst(sim_burst);
775 cout <<
"CWB::mdc::AddWaveform - "
776 <<
"Error : MDC_GA_LAL is enabled only with LAL" << endl;
780 cout <<
"CWB::mdc::AddWaveform - MDC_GA_LAL can not be used with LAL ver < 6.15.0" << endl;
789 double frequency = GetPar(
"frequency",par,error);
790 double Q = GetPar(
"Q",par,error);
793 cout <<
"CWB::mdc::AddWaveform - "
794 <<
"Error : wrong input LAL SG parameters : "
795 <<
"[frequency,Q,decimals(opt)]" << endl;
800 SimBurst *sim_burst = XLALCreateSimBurst();
801 strcpy(sim_burst->waveform,
"SineGaussian");
807 sim_burst->pol_ellipse_e=0.;
810 sim_burst->pol_ellipse_angle=0.;
811 mdcpar mpar={
"normalization",1};par.push_back(mpar);
813 XLALDestroySimBurst(sim_burst);
816 cout <<
"CWB::mdc::AddWaveform - "
817 <<
"Error : MDC_SGE_LAL is enabled only with LAL" << endl;
826 double frequency = GetPar(
"frequency",par,error);
827 double bandwidth = GetPar(
"bandwidth",par,error);
828 double duration = GetPar(
"duration" ,par,error);
830 int lseed = (
int)GetPar(
"lseed" ,par,error);
831 int hseed = (
int)GetPar(
"hseed" ,par,error);
834 cout <<
"CWB::mdc::AddWaveform - "
835 <<
"Error : wrong input LAL WNB parameters : "
836 <<
"[frequency,bandwidth,duration,lseed,hseed,decimals(opt)]" << endl;
841 SimBurst *sim_burst = XLALCreateSimBurst();
842 strcpy(sim_burst->waveform,
"BTLWNB");
845 sim_burst->bandwidth = bandwidth;
846 sim_burst->egw_over_rsquared = 1;
847 sim_burst->waveform_number = hseed*10000000000+lseed;
848 mdcpar mpar={
"normalization",1};par.push_back(mpar);
850 XLALDestroySimBurst(sim_burst);
853 cout <<
"CWB::mdc::AddWaveform - "
854 <<
"Error : MDC_WNB_LAL is enabled only with LAL" << endl;
861 #if LAL_VERSION_MAJOR > 6 || (LAL_VERSION_MAJOR == 6 && \
862 (LAL_VERSION_MINOR > 15 || (LAL_VERSION_MINOR == 15 && \
863 LAL_VERSION_MICRO >= 0 ))) // LAL_VERSION >= 6.15.0
866 double frequency = GetPar(
"frequency",par,error);
867 double amplitude = GetPar(
"amplitude",par,error);
870 cout <<
"CWB::mdc::AddWaveform - "
871 <<
"Error : wrong input LAL SC parameters : "
872 <<
"[frequency,amplitude,decimals(opt)]" << endl;
877 SimBurst *sim_burst = XLALCreateSimBurst();
878 strcpy(sim_burst->waveform,
"StringCusp");
883 sim_burst->amplitude = 1;
884 mdcpar mpar={
"normalization",1};par.push_back(mpar);
887 XLALDestroySimBurst(sim_burst);
890 cout <<
"CWB::mdc::AddWaveform - "
891 <<
"Error : MDC_SC_LAL is enabled only with LAL" << endl;
895 cout <<
"CWB::mdc::AddWaveform - MDC_SC_LAL can not be used with LAL ver < 6.15.0" << endl;
905 cout <<
"CWB::mdc::AddWaveform - "
906 <<
"Error : num par must at least 1 "
907 <<
"[file name (.lst/.root) : list of eBBH mdc]" << endl;
913 if(fName.EndsWith(
".lst")) {
918 cout <<
"CWB::mdc::AddWaveform - Error Opening File : " << fName << endl;
926 in.getline(str,1024);
927 if (!in.good())
break;
928 if(str[0] !=
'#') entries++;
930 cout <<
"entries " << entries << endl;
931 in.clear(ios::goodbit);
932 in.seekg(0, ios::beg);
939 in.getline(str,1024);
940 if(str[0] ==
'#')
continue;
941 if (!in.good())
break;
945 std::stringstream linestream(str);
946 if(!(linestream >>
id >> m1 >> m2 >> rp0 >> e0 >> dist >> redshift)) {
949 if(!(linestream >>
id >> m1 >> m2 >> rp0 >> e0 >> dist)) {
952 if(!(linestream >>
id >> m1 >> m2 >> rp0 >> e0)) {
953 cout <<
"CWB::mdc::AddWaveform - Wrong Format for File : " << fName << endl;
954 cout <<
"input line : " << endl;
956 cout <<
"must be : " << endl;
957 cout <<
"event# " <<
"id " <<
" m1 " <<
" m2 " <<
" rp0 " <<
" e0 " << endl;
958 cout <<
"or : " << endl;
959 cout <<
"event# " <<
"id " <<
" m1 " <<
" m2 " <<
" rp0 " <<
" e0 " <<
" dist " << endl;
960 cout <<
"or : " << endl;
961 cout <<
"event# " <<
"id " <<
" m1 " <<
" m2 " <<
" rp0 " <<
" e0 " <<
" dist " <<
" redshift " << endl;
981 if(fName.EndsWith(
".root")) {
983 TFile* efile =
new TFile(fName);
985 cout <<
"CWB::mdc::AddWaveform - Error opening root file : " << fName.Data() << endl;
994 TTree* etree = (TTree *) efile->Get(
"ebbh");
996 cout <<
"CWB::mdc::AddWaveform - file : " << fName.Data()
997 <<
" not contains tree ebbh" << endl;
1001 etree->SetBranchAddress(
"id",&
id);
1002 etree->SetBranchAddress(
"m1",&m1);
1003 etree->SetBranchAddress(
"m2",&m2);
1004 etree->SetBranchAddress(
"rp0",&rp0);
1005 etree->SetBranchAddress(
"e0",&e0);
1006 etree->SetBranchAddress(
"hp",&hp);
1007 etree->SetBranchAddress(
"hx",&hx);
1008 int dstatus = (etree->GetBranch(
"dist")==NULL) ? 0 : etree->SetBranchAddress(
"dist",&dist);
1009 int rstatus = (etree->GetBranch(
"redshift")==NULL) ? 0 : etree->SetBranchAddress(
"redshift",&redshift);
1012 if(par.size()==2) ecut = par[1].
name;
1013 etree->Draw(
"Entry$",ecut,
"goff");
1014 double*
entry = etree->GetV1();
1015 int esize = etree->GetSelectedRows();
1016 for(
int i=0;
i<esize;
i++) {
1017 etree->GetEntry(entry[
i]);
1019 if(rstatus)
sprintf(str,
"%d %f %f %f %f %f %f",
id,m1,m2,rp0,e0,dist,redshift);
1020 else if(dstatus)
sprintf(str,
"%d %f %f %f %f %f",
id,m1,m2,rp0,e0,dist);
1021 else sprintf(str,
"%d %f %f %f %f",
id,m1,m2,rp0,e0);
1033 wf.
par[1].value=entry[
i];
1049 std::stringstream linestream(str);
1050 if(!(linestream >>
id >> m1 >> m2 >> rp0 >> e0 >> dist >> redshift)) {
1051 linestream.str(str);
1053 if(!(linestream >>
id >> m1 >> m2 >> rp0 >> e0 >> dist)) {
1054 linestream.str(str);
1056 if(!(linestream >>
id >> m1 >> m2 >> rp0 >> e0)) {
1057 cout <<
"CWB::mdc::AddWaveform - Wrong Input Parameter Format : " << str << endl;
1058 cout <<
"input line : " << endl;
1059 cout << str << endl;
1060 cout <<
"must be : " << endl;
1061 cout <<
"event# " <<
"id " <<
" m1 " <<
" m2 " <<
" rp0 " <<
" e0 " << endl;
1062 cout <<
"or : " << endl;
1063 cout <<
"event# " <<
"id " <<
" m1 " <<
" m2 " <<
" rp0 " <<
" e0 " <<
" dist " << endl;
1064 cout <<
"or : " << endl;
1065 cout <<
"event# " <<
"id " <<
" m1 " <<
" m2 " <<
" rp0 " <<
" e0 " <<
" dist " <<
" redshift " << endl;
1082 cout <<
"CWB::mdc::AddWaveform - Error : MDC_EBBH not enabled !!!" << endl;
1089 cout <<
"CWB::mdc::AddWaveform - Warning : waveform not added !!!" << endl;
1129 if(mdc_type<0 || mdc_type>=
MDC_USER) {
1130 cout <<
"CWB::mdc::AddWaveform - Error : mdc type " << mdc_type <<
" not allowed !!!" << endl;
1133 if(sim_burst==NULL) {
1134 cout << endl <<
"CWB::mdc::AddWaveform - "
1135 <<
"Error in LAL AddWaveform : SimBurst is NULL" << endl;
1144 int decimals = (
int)GetPar(
"decimals",par,error);
1145 if(error) decimals = -1;
1147 int normalization = (
int)GetPar(
"normalization",par,error);
1148 if(error) normalization = 0;
1150 REAL8TimeSeries *
hp=NULL;
1151 REAL8TimeSeries *
hx=NULL;
1156 int ret = XLALGenerateSimBurst(&hp, &hx, sim_burst, deltaT);
1157 if( ret==XLAL_FAILURE ) {
1158 cout << endl <<
"CWB::mdc::AddWaveform - "
1159 <<
"Error in LAL AddWaveform : check sim burst parameters" << endl;
1162 if(hp->data->length!=hx->data->length) {
1163 cout <<
"CWB::mdc::AddWaveform - Error : LAL hp,hx size not equal !!!" << endl;
1182 XLALDestroyREAL8TimeSeries(hp);
1183 XLALDestroyREAL8TimeSeries(hx);
1187 int d1 = decimals==-1 ? 0 : decimals;
1188 int d2 = decimals==-1 ? 1 : decimals;
1191 wf.
par[0].name=
"frequency"; wf.
par[0].value=sim_burst->frequency;
1192 wf.
par[1].name=
"Q"; wf.
par[1].value=sim_burst->q;
1193 wf.
par[2].name=
"eccentricity"; wf.
par[2].value=sim_burst->pol_ellipse_e;
1194 wf.
par[3].name=
"phase"; wf.
par[3].value=sim_burst->pol_ellipse_angle;
1196 sprintf(wf_name,
"LAL_SGE%.*fQ%.*f",d1,wf.
par[0].value,d2,wf.
par[1].value);
1200 wf.
name.ReplaceAll(
".",
"d");
1201 if(decimals==-1) wf.
name.ReplaceAll(
"d0",
"");
1211 int d1 = decimals==-1 ? 0 : decimals;
1212 int d2 = decimals==-1 ? 0 : decimals;
1213 int d3 = decimals==-1 ? 3 : decimals;
1216 wf.
par[0].name=
"frequency"; wf.
par[0].value=sim_burst->frequency;
1217 wf.
par[1].name=
"bandwidth"; wf.
par[1].value=sim_burst->bandwidth;
1218 wf.
par[2].name=
"duration"; wf.
par[2].value=sim_burst->duration;
1220 sprintf(wf_name,
"LAL_WNB%.*f_%.*f_%.*f",d1,wf.
par[0].value,d2,wf.
par[1].value,d3,wf.
par[2].value);
1224 wf.
name.ReplaceAll(
".",
"d");
1234 int d1 = decimals==-1 ? 1 : decimals;
1237 wf.
par[0].name=
"duration"; wf.
par[0].value=sim_burst->duration;
1239 sprintf(wf_name,
"LAL_GA%.*f",d1,1000.*wf.
par[0].value);
1243 wf.
name.ReplaceAll(
".",
"d");
1252 int d1 = decimals==-1 ? 1 : decimals;
1255 wf.
par[0].name=
"frequency"; wf.
par[0].value=sim_burst->frequency;
1256 wf.
par[1].name=
"amplitude"; wf.
par[1].value=sim_burst->amplitude;
1258 sprintf(wf_name,
"LAL_SC%.*f",d1,wf.
par[0].value);
1263 wf.
name.ReplaceAll(
".",
"d");
1271 cout <<
"CWB::mdc::AddWaveform - Warning : LAL waveform not added !!!" << endl;
1272 mdcid waveid = {
"",0,0};
1313 if(hx_fName.Sizeof()>1) {
1322 cout <<
"CWB::mdc::AddWaveform - Error : hp,hx size not equal !!!" << endl;
1326 cout <<
"CWB::mdc::AddWaveform - Error : hp,hx rate not equal !!!" << endl;
1332 for(
int i=0;
i<(
int)wfList.size();
i++)
if(wfList[
i].
name.CompareTo(mdc_name)==0) {ID=
i;
break;}
1335 wfList.push_back(wf);
1337 wfList[
ID].list.push_back(wf);
1366 double srate, vector<mdcpar> par) {
1390 if(hx_fName.Sizeof()>1) {
1399 cout <<
"CWB::mdc::AddWaveform - Error : hp,hx size not equal !!!" << endl;
1403 cout <<
"CWB::mdc::AddWaveform - Error : hp,hx rate not equal !!!" << endl;
1409 double hrss_par = GetPar(
"hrss",par,error);
1410 if(error) hrss_par=0.;
1415 hrssp=sqrt(hrssp/wf.
hp.
rate());
1416 hrssc=sqrt(hrssc/wf.
hx.
rate());
1417 double hrss=sqrt(hrssp*hrssp+hrssc*hrssc);
1428 for(
int i=0;
i<(
int)wf.
hp.
size();
i++) {wf.
hp[
i]/=hrss/hrss_par;wf.
hx[
i]/=hrss/hrss_par;}
1429 hrssp /= hrss/hrss_par;
1430 hrssc /= hrss/hrss_par;
1436 vector<mdcpar> wfpar;
1437 for(
int i=0;
i<par.size();
i++) {
1438 if(par[
i].
name==
"hrss") {par[
i].value=
hrss;bhrss=
true;}
1439 wfpar.push_back(par[
i]);
1441 mdcpar upar = {
"hrss",1.,
""};
if(!bhrss) wfpar.push_back(upar);
1442 mdcpar ppar = {
"hrssp",hrssp,
""}; wfpar.push_back(ppar);
1443 mdcpar cpar = {
"hrssc",hrssc,
""}; wfpar.push_back(cpar);
1448 for(
int i=0;
i<(
int)wfList.size();
i++)
if(wfList[
i].
name.CompareTo(mdc_name)==0) {ID=
i;
break;}
1451 wfList.push_back(wf);
1453 wfList[
ID].list.push_back(wf);
1469 cout <<
"CWB::mdc::AddWaveform - Error : hp,hx size not equal !!!" << endl;
1473 cout <<
"CWB::mdc::AddWaveform - Error : hp,hx rate not equal !!!" << endl;
1479 cout <<
"CWB::mdc::AddWaveform - Error : mdc type not allowed !!!" << endl;
1485 for(
int i=0;
i<(
int)wfList.size();
i++)
if(wfList[
i].
name.CompareTo(wf.
name)==0) {ID=
i;
break;}
1488 wfList.push_back(wf);
1490 wfList[
ID].list.push_back(wf);
1495 waveid.
ID = ID==-1 ? wfList.size()-1 :
ID;
1496 waveid.
id = ID==-1 ? 0 : wfList[
ID].list.size();
1519 else listLog=GetBurst(x, ifo);
1521 listLog=GetBurst(x, ifo);
1544 cout <<
"CWB::mdc::GetBurst - Error : Dummy method : network is not initialized " << endl;
1548 cout <<
"CWB::mdc::GetBurst - Error : x.rate() != " <<
MDC_SAMPLE_RATE << endl;
1568 srcList = GetSourceList(start, stop);
1574 for(
int i=0;
i<(
int)wfList.size();
i++) {
1576 for(
int j=0;
j<(
int)mdcType.size();
j++){
1577 if(wfList[
i].
name.CompareTo(mdcType[
j])==0) {save =
false;
break;}
1580 mdcType.push_back(wfList[
i].
name.Data());
1585 for(
int k=0;
k<(
int)srcList.size();
k++) {
1587 double gps = srcList[
k].gps;
1588 double theta = srcList[
k].theta;
1589 double phi = srcList[
k].phi;
1590 double psi = srcList[
k].psi;
1591 double rho = srcList[
k].rho;
1592 double iota = srcList[
k].iota;
1593 double hrss = srcList[
k].hrss;
1600 double fPlus = GetAntennaPattern(ifo, phi, theta, psi,
"hp");
1601 double fCross = GetAntennaPattern(ifo, phi, theta, psi,
"hx");
1606 tShift = GetDelay(ifo,
"",phi,theta);
1609 tShift = GetDelay(ifo,
net->
ifoName[0],phi,theta);
1613 bool ellipticity=
false;
1621 double ePlus = ellipticity ? (1+cos(iota*deg2rad)*cos(iota*deg2rad))/2 : 1.;
1622 double eCross = ellipticity ? cos(iota*deg2rad) : 1.;
1624 if(!ellipticity) srcList[
k].iota=90;
1639 iShift = tShift<0 ? iShift : 0;
1641 w[
i+iShift] = ePlus*fPlus*wf.
hp[
i]+eCross*fCross*wf.
hx[
i];
1642 SimHpHp+=wf.
hp[
i]*wf.
hp[
i];
1643 SimHcHc+=wf.
hx[
i]*wf.
hx[
i];
1644 SimHpHc+=wf.
hp[
i]*wf.
hx[
i];
1649 double SrcHrss=sqrt(SimHpHp+SimHcHc);
1650 std::stringstream linestream;
1652 switch(srcList[
k].wf.
type) {
1655 linestream.str(wf.
par[0].name.Data());
1656 if(!(linestream >>
id >> m1 >> m2 >> rp0 >> e0 >> dist)) {
1662 srcList[
k].wf.par[0].name = pars;
1669 srcList[
k].hrss=
hrss;
1676 double eccentricity = iota>1
e-10 ? iota : 1
e-10;
1678 srcList[
k].iota = (1.-sqrt(1-eccentricity*eccentricity))/eccentricity;
1679 srcList[
k].iota = acos(srcList[k].iota)*
rad2deg;
1690 double E = eccentricity;
1691 double A = 1./sqrt(2-E*E);
1692 double B = A*sqrt(1-E*E);
1693 SimHpHp *= 1./(A*
A)/2.;
1694 SimHcHc *=
fabs(B)>1
e-5 ? 1./(B*
B)/2. : 0.;
1695 SimHpHc *=
fabs(B)>1
e-5 ? 1./(A*
B)/2. : 0.;
1696 if(SimHcHc==0) SimHcHc=SimHpHp;
1706 SimHpHp *= hrss>0 ? pow(hrss/SrcHrss,2) : pow(inj_hrss/SrcHrss,2);
1707 SimHcHc *= hrss>0 ? pow(hrss/SrcHrss,2) : pow(inj_hrss/SrcHrss,2);
1708 SimHpHc *= hrss>0 ? pow(hrss/SrcHrss,2) : pow(inj_hrss/SrcHrss,2);
1709 w *= hrss>0 ? hrss/SrcHrss : inj_hrss/SrcHrss;
1712 srcList[
k].hrss = SrcHrss;
1717 SimHpHp*=100./pow(rho,2);
1718 SimHcHc*=100./pow(rho,2);
1719 SimHpHc*=100./pow(rho,2);
1727 int sT = TMath::Nint(T*
w.
rate());
1731 int oS = (srcList[
k].gps-
start)*x.
rate()-iShift;
1736 if (j>=(
int)x.
size())
break;
1737 if (j>=0) x[
j]=
w[
i];
1741 TString log = GetBurstLog(srcList[k], start, SimHpHp, SimHcHc, SimHpHc);
1742 listLog = listLog+
log;
1745 mdcList.push_back(log.Data());
1747 mdcTime.push_back(srcList[k].gps);
1777 int estat = gSystem->GetPathInfo(fName.Data(),&
id,&fsize,&
flags,&
mt);
1779 cout <<
"CWB::mdc::ReadWaveform - File : " << fName.Data() <<
" Not Exist" << endl;
1785 in.open(fName.Data(),
ios::in);
1786 if (!in.good()) {cout <<
"CWB::mdc::ReadWaveform - Error Opening File : " << fName.Data() << endl;
exit(1);}
1789 char*
str =
new char[fsize+1];
1792 in.getline(str,fsize+1);
1793 if (!in.good())
break;
1794 if(str[0] !=
'#') size++;
1797 if(tok->GetEntries()!=2) {
1798 cout <<
"CWB::mdc::ReadWaveform - Input file with bad format : must be 2 columns " << endl;
1803 in.clear(ios::goodbit);
1804 in.seekg(0, ios::beg);
1814 int pos = in.tellg();
1815 in.getline(str,1024);
1816 if (!in.good())
break;
1820 if (!in.good())
break;
1821 if(t[cnt]<tMin) tMin=t[
cnt];
1822 if(t[cnt]>tMax) tMax=t[
cnt];
1863 int estat = gSystem->GetPathInfo(fName.Data(),&
id,&fsize,&
flags,&
mt);
1865 cout <<
"CWB::mdc::ReadWaveform - File : " << fName.Data() <<
" Not Exist" << endl;
1871 in.open(fName.Data(),
ios::in);
1872 if (!in.good()) {cout <<
"CWB::mdc::ReadWaveform - Error Opening File : " << fName.Data() << endl;
exit(1);}
1875 char*
str =
new char[fsize+1];
1878 in.getline(str,fsize+1);
1879 if (!in.good())
break;
1880 if(str[0] !=
'#') size++;
1882 if((tok->GetEntries()!=1)&&(size>1)) {
1883 cout <<
"CWB::mdc::ReadWaveform - Input file with bad format : must be 1 column " << endl;
1886 if((tok->GetEntries()>1)&&(size==1)) {
1887 x.
resize(tok->GetEntries());
1897 in.clear(ios::goodbit);
1898 in.seekg(0, ios::beg);
1906 in.getline(str,1024);
1907 if (!in.good())
break;
1932 double& iota,
double&
hrss,
int&
ID,
int&
id) {
1946 GetSourceCoordinates(theta, phi, psi, rho, iota, hrss, ID,
id);
1952 if(gps>0) phi=
sm.RA2phi(phi,gps);
1961 double& iota,
double&
hrss,
int&
ID,
int&
id) {
1980 if(thList.size()==0) {
1981 cout <<
"CWB::mdc::GetSourceCoordinates - Error : injections not defined !!!" << endl;
1985 int id = gRandom->Uniform(0,thList.size());
1991 iota = iotaList[
id];
1992 hrss = hrssList[
id];
2001 cout <<
"CWB::mdc::GetSourceCoordinates - Error : distribution not defined !!!" << endl;
2016 ID = (
int)gRandom->Uniform(0,wfList.size());
2017 id = (
int)gRandom->Uniform(0,1+wfList[ID].list.size());
2037 if((stop-start)<=2*inj_length) {
2038 cout <<
"CWB::mdc::GetSourceList - Warning : buffer too small (stop-start)<=2*inj_length !!!" << endl;
2043 gRandom->SetSeed(
int(start)+srcList_seed);
2047 double timeStep = inj_rate>0 ? 1./inj_rate : 1./
MDC_INJ_RATE;
2049 int iStart=
int(0.5+start/timeStep);
2050 int iStop=
int(stop/timeStep);
2052 if(iStart==0) iStart+=1;
2053 vector<source> src_list;
2057 if(inj_tree==NULL) {
2058 cout <<
"CWB::mdc::GetSourceList - Error : injection object is NULL" << endl;
2064 char cut[128];
sprintf(cut,
"time[0]>=%f && time[0]<%f",start+inj_length,stop-inj_length);
2065 inj_tree->Draw(
"Entry$",cut,
"goff");
2066 int entries = inj_tree->GetSelectedRows();
2073 inj_tree->SetBranchAddress(
"phi",phi);
2074 inj_tree->SetBranchAddress(
"theta",theta);
2075 inj_tree->SetBranchAddress(
"psi",psi);
2076 inj_tree->SetBranchAddress(
"time",time);
2077 inj_tree->SetBranchAddress(
"type",type);
2079 double*
entry = inj_tree->GetV1();
2080 for(
int i=0;
i<entries;
i++) {
2081 inj_tree->GetEntry(entry[
i]);
2082 src.
theta = theta[0];
2089 int TYPE = (type[0]-1)<mdcName.size() ? type[0]-1 : 0;
2090 int ID = GetWaveformID(mdcName[TYPE])!=-1 ? GetWaveformID(mdcName[TYPE]) : 0;
2091 int id = (
int)gRandom->Uniform(0,1+wfList[ID].list.size());
2093 src_list.push_back(src);
2096 for(
int i=0;
i<(
int)gpsList.size();
i++) {
2099 src.
gps = gpsList[
i];
2100 if(src.
gps<=start+inj_length)
continue;
2101 if(src.
gps>=stop-inj_length)
continue;
2103 src.
phi = phList[
i];
2104 src.
psi = psiList[
i];
2105 src.
rho = rhoList[
i];
2106 src.
iota = iotaList[
i];
2107 src.
hrss = hrssList[
i];
2111 src.
ID = GetWaveformID(nameList[
i])!=-1 ? GetWaveformID(nameList[i]) : 0;
2113 src.
ID = (src.
ID < wfList.size()) ? src.
ID : 0;
2116 src.
id = (
int)gRandom->Uniform(0,1+wfList[src.
ID].list.size());
2118 src.
id = (src.
id <= wfList[src.
ID].list.size()) ? src.
id : 0;
2121 src_list.push_back(src);
2124 for(
int i=iStart;
i<=iStop;
i++) {
2125 if(gpsList.size()>0) src.
gps=gpsList[0];
2126 else src.
gps=inj_offset+
i*timeStep+gRandom->Uniform(-inj_jitter,inj_jitter);
2129 if(src.
gps<=start+inj_length)
continue;
2130 if(src.
gps>=stop-inj_length)
continue;
2132 src.
wf = GetSourceWaveform(src.
ID, src.
id);
2136 std::stringstream linestream(src.
wf.
par[0].name.Data());
2138 if((linestream >>
id >> m1 >> m2 >> rp0 >> e0 >> dist)) src.
rho=dist;
2141 src_list.push_back(src);
2142 if(gpsList.size()>0)
break;
2163 cout <<
"CWB::mdc::GetBurstLog - Error : Dummy method : network is not initialized " << endl;
2170 char logString[10000]=
"";
2175 sprintf(GravEn_SimID,
"%s",hpPath.Data());
2179 double SimHrss = sqrt(SimHpHp+SimHcHc);
2180 double SimEgwR2 = 0.0;
2181 double GravEn_Ampl = src.
rho>0 ? 10.*hrss/src.
rho :
hrss;
2182 double Internal_x = cos(src.
iota*deg2rad);
2183 double Internal_phi = 0.0;
2184 double External_x = cos(src.
theta*deg2rad);
2188 double EarthCtrGPS = src.
gps;
2191 sprintf(logString,
"%s",GravEn_SimID);
2192 sprintf(logString,
"%s %e",logString,SimHrss);
2193 sprintf(logString,
"%s %e",logString,SimEgwR2);
2194 sprintf(logString,
"%s %e",logString,GravEn_Ampl);
2195 sprintf(logString,
"%s %e",logString,Internal_x);
2196 sprintf(logString,
"%s %e",logString,Internal_phi);
2197 sprintf(logString,
"%s %e",logString,External_x);
2198 sprintf(logString,
"%s %e",logString,External_phi);
2199 sprintf(logString,
"%s %e",logString,External_psi);
2201 sprintf(logString,
"%s %10.6f",logString,FrameGPS);
2202 sprintf(logString,
"%s %10.6f",logString,EarthCtrGPS);
2203 sprintf(logString,
"%s %s",logString,SimName);
2204 sprintf(logString,
"%s %e",logString,SimHpHp);
2205 sprintf(logString,
"%s %e",logString,SimHcHc);
2206 sprintf(logString,
"%s %e",logString,SimHpHc);
2212 double IFOctrGPS = EarthCtrGPS;
2216 IFOctrGPS += GetDelay(ifo,
"",src.
phi,src.
theta);
2219 IFOctrGPS += GetDelay(ifo,refIFO,src.
phi,src.
theta);
2221 double IFOfPlus = GetAntennaPattern(ifo, src.
phi, src.
theta, src.
psi,
"hp");
2222 double IFOfCross = GetAntennaPattern(ifo, src.
phi, src.
theta, src.
psi,
"hx");
2223 if(src.
wf.
name==
"eBBH") {
2225 std::stringstream linestream(src.
wf.
par[0].name.Data());
2226 linestream >>
id >> m1 >> m2 >> rp0 >> e0 >>
distance;
2228 double cosiota = cos(src.
iota*deg2rad);
2229 double eff_dist = distance / sqrt(pow(IFOfPlus*(1.+pow(cosiota,2)),2)/4.+pow(IFOfCross*cosiota,2));
2230 sprintf(logString,
"%s %s %10.6f %e %e %g",logString,ifo.Data(),IFOctrGPS,IFOfPlus,IFOfCross,eff_dist/1000.);
2232 sprintf(logString,
"%s %s %10.6f %e %e",logString,ifo.Data(),IFOctrGPS,IFOfPlus,IFOfCross);
2236 if(src.
wf.
name==
"eBBH") {
2238 std::stringstream linestream(src.
wf.
par[0].name.Data());
2239 linestream >>
id >> m1 >> m2 >> rp0 >> e0 >> distance >> redshift;
2240 sprintf(logString,
"%s ebbh ",logString);
2241 sprintf(logString,
"%s mass1 %g ",logString, m1);
2242 sprintf(logString,
"%s mass2 %g ",logString, m2);
2243 sprintf(logString,
"%s rp0 %g ",logString, rp0);
2244 sprintf(logString,
"%s e0 %g ",logString, e0);
2245 sprintf(logString,
"%s distance %g ",logString, distance/1000.);
2246 sprintf(logString,
"%s redshift %g ",logString, redshift);
2249 double mu = (m1*
m2)/(m1+m2);
2251 double mchirp = pow(mu,3./5)*pow(M,2./5);
2252 sprintf(logString,
"%s mchirp %g ",logString, mchirp);
2255 if(src.
rho>0)
sprintf(logString,
"%s distance %g ",logString, src.
rho/1000.);
2277 polarization.ToUpper();
2280 if(polarization.Contains(
"HP")) plot=
Draw(wf.
hp,type,options,color);
2281 if(polarization.Contains(
"HX")) plot=
Draw(wf.
hx,type,options,color);
2301 polarization.ToUpper();
2304 if(polarization.Contains(
"HP")) plot=
Draw(wf.
hp,type,options,color);
2305 if(polarization.Contains(
"HX")) plot=
Draw(wf.
hx,type,options,color);
2333 if((
int)mdcTime.size()==0) {
2334 cout <<
"CWB::mdc::Draw : Error - No events in the selected period" << endl;
2337 if(
id>=(
int)mdcTime.size())
id=(
int)mdcTime.size()-1;
2338 double tOffset = mdcTime[
id]-y.
start();
2339 double tWindow = inj_length;
2340 int iStart = (tOffset-tWindow/2)*y.
rate();
if(iStart<0) iStart=0;
2341 int iEnd = (tOffset+tWindow/2)*y.
rate();
if(iEnd>y.
size()) iEnd=y.
size();
2346 for(
int i=iStart;
i<iEnd;
i++)
x[
i-iStart]=y[
i];
2350 if(type==
MDC_TIME) plot=DrawTime(
x,options,color);
2351 if(type==
MDC_FFT) plot=DrawFFT(
x,options,color);
2372 if(type==
MDC_TIME) plot=DrawTime(x,options,color);
2373 if(type==
MDC_FFT) plot=DrawFFT(x,options,color);
2374 if(type==
MDC_TF) DrawTF(x,options);
2392 cout <<
"CWB::mdc::DrawTime : Error - rate must be >0" << endl;
2397 options.ReplaceAll(
" ",
"");
2399 if(options.Contains(
"SAME")&&(pts!=NULL)) {
2401 if(pts!=NULL)
delete pts;
2402 char name[32];
sprintf(name,
"TIME-gID:%d",
int(gRandom->Rndm(13)*1.e9));
2405 double tStart,tStop;
2406 if(options.Contains(
"ZOOM")) {
2407 options.ReplaceAll(
"ZOOM",
"");
2408 GetTimeRange(x, tStart, tStop, epzoom);
2415 if(!options.Contains(
"SAME")) {
2416 if(!options.Contains(
"A")) options=options+
" A";
2417 if(!options.Contains(
"L")) options=options+
" L";
2418 if(!options.Contains(
"P")) options=options+
" P";
2439 options.ReplaceAll(
" ",
"");
2441 if(options.Contains(
"SAME")&&(pts!=NULL)) {
2443 if(pts!=NULL)
delete pts;
2444 char name[32];
sprintf(name,
"FREQ-gID:%d",
int(gRandom->Rndm(13)*1.e9));
2450 double tStart,tStop;
2451 if(options.Contains(
"ZOOM")) {
2452 options.ReplaceAll(
"ZOOM",
"");
2453 GetTimeRange(x, tStart, tStop, epzoom);
2461 if(options.Contains(
"NOLOGX")) {logx=
false;options.ReplaceAll(
"NOLOGX",
"");}
2463 if(options.Contains(
"NOLOGY")) {logy=
false;options.ReplaceAll(
"NOLOGY",
"");}
2464 pts->plot(x,
const_cast<char*>(options.Data()), color, tStart, tStop,
true, fLow, fHigh);
2465 pts->canvas->SetLogx(logx);
2466 pts->canvas->SetLogy(logy);
2485 double fparm=nfact*6;
2487 double tStart,tStop;
2488 if(options.Contains(
"ZOOM")) {
2489 options.ReplaceAll(
"ZOOM",
"");
2490 GetTimeRange(x, tStart, tStop, epzoom);
2499 if(pts!=NULL)
delete pts;
2500 stft =
new CWB::STFT(x,nfft,noverlap,
"amplitude",
"gauss",fparm);
2504 stft->
Draw(tStart,tStop,fLow,fHigh,0,0,1);
2526 if(ID<0||ID>=(
int)wfList.size()) {
2527 cout <<
"CWB::mdc::GetWaveform - Error : ID " << ID <<
" not in the list" << endl;
2532 id = (id<0||id>(
int)wfList[ID].
list.size()) ? 0 :
id;
2533 if((
int)wfList[
ID].list.size()==0) {
2536 wf =
id==0 ? wf=wfList[
ID] : wfList[
ID].
list[
id-1];
2558 std::stringstream linestream(wf.
par[0].name.Data());
2559 if(!(linestream >>
id >> m1 >> m2 >> rp0 >> e0 >> dist >> redshift)) {
2560 linestream.str(wf.
par[0].name.Data());
2562 if(!(linestream >>
id >> m1 >> m2 >> rp0 >> e0 >> dist)) {
2563 linestream.str(wf.
par[0].name.Data());
2565 if(!(linestream >>
id >> m1 >> m2 >> rp0 >> e0)) {
2566 cout <<
"CWB::mdc::GetWaveform - Wrong eBBH parameter format : " << endl;
2567 cout <<
"input line : " << endl;
2568 cout << wf.
par[0].name.Data() << endl;
2569 cout <<
"must be : " << endl;
2570 cout <<
"event# " <<
"id " <<
" m1 " <<
" m2 " <<
" rp0 " <<
" e0 " << endl;
2571 cout <<
"or : " << endl;
2572 cout <<
"event# " <<
"id " <<
" m1 " <<
" m2 " <<
" rp0 " <<
" e0 " <<
" dist " << endl;
2573 cout <<
"or : " << endl;
2574 cout <<
"event# " <<
"id " <<
" m1 " <<
" m2 " <<
" rp0 " <<
" e0 " <<
" dist " <<
" redshift " << endl;
2580 if(wf.
par.size()==1) {
2592 wf.
hp*=distance_source_Kpc/10.;
2593 wf.
hx*=distance_source_Kpc/10.;
2596 if(wf.
par.size()==2) {
2601 TFile* efile =
new TFile(fName);
2603 cout <<
"CWB::mdc::GetWaveform - Error opening root file : " << fName.Data() << endl;
2610 TTree* etree = (TTree *) efile->Get(
"ebbh");
2612 cout <<
"CWB::mdc::GetWaveform - file : " << fName.Data()
2613 <<
" not contains tree ebbh" << endl;
2617 etree->SetBranchAddress(
"hp",&hp);
2618 etree->SetBranchAddress(
"hx",&hx);
2620 etree->GetEntry(entry);
2623 cout <<
"CWB::mdc::GetWaveform - Error : hp,hx size not equal !!!" << endl;
2627 cout <<
"CWB::mdc::GetWaveform - Error : hp,hx rate not equal !!!" << endl;
2639 cout <<
"CWB::mdc::GetWaveform - Error : wrong number of parameters not !!!" << endl;
2645 cout <<
"CWB::mdc::GetWaveform - Error : hp,hp are empty !!!" << endl;
2668 for(
int i=0;
i<(
int)wfList.size();
i++)
if(wfList[
i].name.CompareTo(name)==0) {ID=
i;
break;}
2673 id = (id<0||id>(
int)wfList[ID].
list.size()-1) ? 0 :
id;
2674 if((
int)wfList[
id].list.size()==0) {
2701 for(
int i=0;
i<(
int)wfList.size();
i++)
if(wfList[
i].name.CompareTo(name)==0) {ID=
i;
break;}
2716 for(
int i=0;
i<(
int)wfList.size();
i++) {
2717 printf(
"ID : %02i (x% 3i) \t%s\n",
i,(
int)wfList[
i].
list.size()+1,wfList[
i].name.Data());
2719 for(
int k=0;
k<(
int)wfList[
i].par.size();
k++)
2720 if(wfList[
i].par[
k].svalue!=
"") {
2721 printf(
"%s = %s ",wfList[
i].par[
k].
name.Data(),wfList[
i].par[
k].svalue.Data());
2723 printf(
"%s = %g ",wfList[
i].par[
k].
name.Data(),wfList[
i].par[
k].value);
2729 for(
int k=0;
k<(
int)wfList[
i].par.size();
k++)
2730 if(wfList[
i].
list[
j].par[
k].svalue!=
"") {
2731 printf(
"%s = %s ",wfList[
i].
list[
j].par[
k].
name.Data(),wfList[
i].list[
j].par[
k].svalue.Data());
2780 T = E>0 ?
T/E : 0.5*size/
rate;
2818 double dF=(rate/(double)size)/2.;
2819 for(
int j=0;
j<size/2;
j+=2) {
2820 a = x[
j]*x[
j]+x[
j+1]*x[
j+1];
2824 F = E>0 ?
F/E : 0.5*
rate;
2842 if(efraction<0) efraction=0;
2843 if(efraction>1) efraction=1;
2849 for(
int i=0;
i<
N;
i++) {avr+=
i*x[
i]*x[
i]; E+=x[
i]*x[
i];}
2856 double sum = ((M>=0)&&(M<N)) ? x[M]*x[M] : 0.;
2857 for(
int j=1;
j<
N;
j++) {
2858 a = ((M-
j>=0)&&(M-j<N)) ? x[M-j] : 0.;
2859 b = ((M+j>=0)&&(M+j<N)) ? x[M+j] : 0.;
2863 if(sum/E > efraction)
break;
2883 if(tShift==0)
return;
2886 int ibeg=0;
int iend=0;
2888 if(x[
i]!=0 && ibeg==0) ibeg=
i;
2891 int ilen=iend-ibeg+1;
2893 int ishift =
fabs(tShift)*x.
rate();
2894 int isize = 2*ilen+2*ishift;
2895 isize = isize + (isize%4 ? 4 - isize%4 : 0);
2897 w.rate(x.
rate()); w=0;
2899 for(
int i=0;
i<ilen;
i++) {w[
i+ishift+ilen/2]=x[ibeg+
i];x[ibeg+
i]=0;}
2905 double df = w.rate()/w.size();
2907 for (
int ii=0;ii<(
int)w.size()/2;ii++) {
2908 TComplex X(w[2*ii],w[2*ii+1]);
2909 X=X*C.Exp(TComplex(0.,-2*pi*ii*df*tShift));
2916 for(
int i=0;
i<(
int)w.size();
i++) {
2917 int j=ibeg-(ishift+ilen/2)+
i;
2918 if((j>=0)&&(j<(
int)x.
size())) x[
j]=w[
i];
2935 if(pShift==0)
return;
2938 int ibeg=0;
int iend=0;
2940 if(x[
i]!=0 && ibeg==0) ibeg=
i;
2943 int ilen=iend-ibeg+1;
2946 isize = isize + (isize%4 ? 4 - isize%4 : 0);
2948 w.rate(x.
rate()); w=0;
2950 for(
int i=0;
i<ilen;
i++) {w[
i+isize/4]=x[ibeg+
i];x[ibeg+
i]=0;}
2957 for (
int ii=0;ii<(
int)w.size()/2;ii++) {
2958 TComplex X(w[2*ii],w[2*ii+1]);
2959 X=X*C.Exp(TComplex(0.,-pShift));
2966 for(
int i=0;
i<(
int)w.size();
i++) {
2967 int j=ibeg-isize/4+
i;
2968 if((j>=0)&&(j<(
int)x.
size())) x[
j]=w[
i];
2988 x.
rate(MDC_SAMPLE_RATE);
2992 AddSGBurst(x, amplitude, frequency, duration,0);
3011 x.
rate(MDC_SAMPLE_RATE);
3015 AddCGBurst(x, amplitude, frequency, duration,0);
3020 #define GA_FORMULA_WNB "[0]*TMath::Exp(-TMath::Power((x-[2])/[1],2)/2)"
3039 gRandom->SetSeed(seed);
3043 x.
rate(MDC_SAMPLE_RATE);
3044 for (
int i=0;
i<(
int)x.
size();
i++) x[
i]=gRandom->Gaus(0,1);
3054 int bFrequency = frequency/
df;
3055 int bBandwidth = (bandwidth/2.)/
df;
3057 int bin = 2*(bFrequency+bBandwidth);
3060 for (
int i=1;
i<bBandwidth;
i++) {
3062 y[bin+2*
i+1]=x[2*
i+1];
3065 y[bin-2*
i+1]=-x[2*
i+1];
3071 int bLow = frequency/
df;
3072 int bHigh = (frequency+bandwidth)/df;
3073 for (
int i=0;
i<bLow;
i++) {x[2*
i]=0;x[2*
i+1]=0;}
3074 for (
int i=bHigh;
i<(
int)x.
size()/2;
i++) {x[2*
i]=0;x[2*
i+1]=0;}
3079 double function_range = 1.;
3080 TF1* ga_function =
new TF1(
"Gaussian",
GA_FORMULA_WNB,-function_range/2,function_range/2);
3081 ga_function->SetParameter(0,1);
3082 ga_function->SetParameter(1,duration);
3083 ga_function->SetParameter(2,function_range/2);
3084 for (
int i=0;
i<(
int)x.
size();
i++) x[
i]*=ga_function->Eval(dt*(
i+1));
3090 for (
int i=0;
i<(
int)x.
size();
i++) x[
i]*=(1./sqrt(2.))*1./hrss;
3097 #define GA_FORMULA "[0]*TMath::Exp(-TMath::Power((x-[2])/[1],2))"
3111 double function_range = 1.;
3112 TF1* ga_function =
new TF1(
"Gaussian",
GA_FORMULA,-function_range/2,function_range/2);
3113 ga_function->SetParameter(0,1);
3114 ga_function->SetParameter(1,duration);
3115 ga_function->SetParameter(2,function_range/2);
3121 x.
rate(MDC_SAMPLE_RATE);
3122 for (
int i=0;
i<(
int)x.
size();
i++) x[
i]=ga_function->Eval(dt*(
i+1));
3135 #define RD_FORMULA "(((x-1./4./[2]+TMath::Abs(x-1./4./[2]))/2./(x-1./4./[2]))*[0]*TMath::Cos(TMath::TwoPi()*[2]*x)+[1]*TMath::Sin(TMath::TwoPi()*[2]*x))*TMath::Exp(-x/[3])" // Heaviside in cos like Andrea Vicere'
3155 double c1 = (1+c2*
c2)/2.;
3157 if (c1/c2<1
e-10) c1=0;
3160 double function_range = 1.;
3161 TF1* rd_function =
new TF1(
"RingDown",rd_formula,0.,function_range);
3162 rd_function->SetParameter(2,frequency);
3163 rd_function->SetParameter(3,tau);
3165 double time_offset=0.05;
3170 x.
rate(MDC_SAMPLE_RATE);
3171 rd_function->SetParameter(0,c1);
3172 rd_function->SetParameter(1,0);
3174 double time = dt*(
i+1)-time_offset;
3175 if (time>=0) x[
i]=rd_function->Eval(time);
else x[
i]=0;
3180 y.
rate(MDC_SAMPLE_RATE);
3181 rd_function->SetParameter(0,0);
3182 rd_function->SetParameter(1,c2);
3184 double time = dt*(
i+1)-time_offset;
3185 if (time>=0) y[
i]=rd_function->Eval(time);
else y[
i]=0;
3196 return polarization==0 ? x :
y;
3214 for (
int i=0;
i <
n;
i++){
3215 td.
data[
i] += v*gRandom->Gaus(0.,1.)+u;
3237 for (i=0; i<
n; i++){
3239 for (j=0; j<
m; j++){
3240 x = gRandom->Exp(v);
3265 double r = td.
rate();
3272 if(m > n/2-1) m = n/2-2;
3274 for (
int i=0;
i <
m;
i++){
3279 a *= TMath::Sqrt(r/sum);
3281 td.
data[n/2+
int(delay*r)] += 0;
3282 for (
int i=1;
i <
m;
i++){
3307 double r = td.
rate();
3314 if(m > n/2-1) m = n/2-2;
3316 for (
int i=0;
i <
m;
i++){
3321 a *= TMath::Sqrt(r/sum);
3324 for (
int i=1;
i <
m;
i++){
3347 double r = td.
rate();
3353 if(m > n/2-1) m = n/2-2;
3357 for (
int i=0;
i <
m;
i++){
3360 gn.
data[m+
i] = g*gRandom->Gaus(0.,1.);
3361 gn.
data[m-
i-1] = g*gRandom->Gaus(0.,1.);
3364 a *= TMath::Sqrt(r/sum);
3366 for (
int i=0;
i <
m;
i++){
3381 #define MNGD_NUMERATOR "([0]*((x-[3])*(x-[3])+y*y)+([0]+3*sqrt(z*z+[1]*[1]))*pow([0]+sqrt(z*z+[1]*[1]),2))"
3382 #define MNGD_DENOMINATOR "(pow(((x-[3])*(x-[3])+y*y)+pow([0]+sqrt(z*z+[1]*[1]),2),5./2.)*pow(z*z+[1]*[1],3./2.))"
3384 #define MNGD_B 0.3 // Kpc
3385 #define MNGD_Md1 6.6e10 // Msol
3386 #define MNGD_A1 5.81 // Kpc
3387 #define MNGD_Md2 -2.9e10 // Msol
3388 #define MNGD_A2 17.43 // Kpc
3389 #define MNGD_Md3 3.3e9 // Msol
3390 #define MNGD_A3 34.86 // Kpc
3392 #define MNGD_XMAX 40
3395 #define MNGD_SOLAR_SISTEM_DISTANCE_FROM_GC 7.62 // 7.62 [+/-0.32] Kpc it.wikipedia.org/wiki/Via_Lattea
3534 gRandom->SetSeed(seed);
3536 this->sky_distribution=sky_distribution;
3537 this->sky_file=
fName;
3538 this->sky_parms=
par;
3558 int entries = GetPar(
"entries",par,error);
3559 double rho_min = GetPar(
"rho_min",par,error);
3560 if(error) rho_min=0.;
3561 double rho_max = GetPar(
"rho_max",par,error);
3562 if(error) rho_max=0.;
3565 cout <<
"CWB::mdc::SetSkyDistribution - "
3566 <<
"Error : entries must be positive" << endl;
3569 if(rho_max>0 && rho_min<=0) {
3570 cout <<
"CWB::mdc::SetSkyDistribution - " <<
"Error : rho_min must be > 0" << endl;
3573 if(rho_min>rho_max) {
3574 cout <<
"CWB::mdc::SetSkyDistribution - " <<
"Error : rho_min must be <= rho_max" << endl;
3578 cout <<
"CWB::mdc::SetSkyDistribution - All Sky random distribution" << endl;
3582 if(rho_min!=rho_max) {
3583 double rho_dist = GetPar(
"rho_dist",par,error);
3584 char rho_dist_func[256];
3585 if((!error)&&(fName==
""))
sprintf(rho_dist_func,
"pow(x,%f)",rho_dist);
3586 else if(( error)&&(fName==
""))
sprintf(rho_dist_func,
"pow(x,2)");
3587 else if(( error)&&(fName!=
""))
strcpy(rho_dist_func,fName.Data());
3588 else if((!error)&&(fName!=
"")) {
3589 cout <<
"CWB::mdc::SetSkyDistribution - "
3590 <<
"Error : ambiguous rho distribution - is defined twice "
3591 <<
" 1) as rho_dist params, 2) as formula" << endl;
3594 rd =
new TF1(
"rd",rho_dist_func,rho_min,rho_max);
3595 TF1* rdcheck = (TF1*)gROOT->GetListOfFunctions()->FindObject(
"rd");
3597 cout <<
"CWB::mdc::SetSkyDistribution - "
3598 <<
"Error : wrong formula format : " << rho_dist_func << endl;
3603 for(
int n=0;
n<entries;
n++) {
3604 thList.push_back(rad2deg*acos(gRandom->Uniform(-1,1))-90.);
3605 phList.push_back(gRandom->Uniform(-180,180));
3606 if(rd!=NULL) rhoList.push_back(rd->GetRandom());
3607 else rhoList.push_back(rho_min);
3609 error=
false;
double value=GetPar(
"psi",par,error);
3610 double psi = error ? gRandom->Uniform(0,180) :
value;
3611 psiList.push_back(psi);
3613 error=
false;
double iota = GetPar(
"iota",par,error);
3614 if(error) iotaList.push_back(0);
3615 else if(iota>=0&&iota<=180) iotaList.push_back(iota);
3616 else iotaList.push_back(rad2deg*acos(gRandom->Uniform(-1,1)));
3618 hrssList.push_back(0);
3619 IDList.push_back(-1);
3620 idList.push_back(-1);
3623 if(rd!=NULL)
delete rd;
3629 double entries = GetPar(
"entries",par,error);
3632 cout <<
"CWB::mdc::SetSkyDistribution - "
3633 <<
"Error : num par must be 1 [entries]" << endl;
3637 cout <<
"CWB::mdc::SetSkyDistribution - the Miyamoto-Nagai Galactic Disk Model" << endl;
3644 gd1->SetParameter(1,
MNGD_B);
3650 gd2->SetParameter(1,
MNGD_B);
3656 gd3->SetParameter(1,
MNGD_B);
3670 xyz.SetXYZ(xgc,ygc,
zgc);
3678 double gc_rho = sqrt(xyz.mag2());
3680 cout <<
"gc_phi : " << gc_phi <<
" gc_theta : " << gc_theta <<
" " << gc_rho << endl;
3683 for(
int n=0;
n<entries;
n++) {
3685 gd->GetRandom3(x,y,z);
3688 double ilongitude = xyz.Phi()*
rad2deg;
3692 phList.push_back(olongitude);
3693 thList.push_back(olatitude);
3694 psiList.push_back(gRandom->Uniform(0,180));
3695 rhoList.push_back(sqrt(xyz.mag2()));
3697 error=
false;
double iota = GetPar(
"iota",par,error);
3698 if(error) iotaList.push_back(0);
3699 else if(iota>=0&&iota<=180) iotaList.push_back(iota);
3700 else iotaList.push_back(rad2deg*acos(gRandom->Uniform(-1,1)));
3702 hrssList.push_back(0);
3703 IDList.push_back(-1);
3704 idList.push_back(-1);
3716 double distance_thr = GetPar(
"distance_thr",par,error);
3719 cout <<
"CWB::mdc::SetSkyDistribution - "
3720 <<
"Error : num par must be 1 [distance_thr]" << endl;
3724 cout <<
"CWB::mdc::SetSkyDistribution - Gravitational Wave Galaxy Catalog" << endl;
3725 cout <<
"CWB::mdc::SetSkyDistribution - Distance Threshold " << distance_thr <<
" Kpc" << endl;
3729 if (!in.good()) {cout <<
"CWB::mdc::SetSkyDistribution - Error Opening File : " << fName << endl;
exit(1);}
3735 in.getline(str,1024);
3736 if (!in.good())
break;
3737 if(str[0] !=
'#') entries++;
3739 cout <<
"entries " << entries << endl;
3740 in.clear(ios::goodbit);
3741 in.seekg(0, ios::beg);
3744 in.getline(iline,1024);
3747 in.getline(iline,1024);
3748 if (!in.good())
break;
3751 TObjString*
tra = (TObjString*)tok->At(2);
3752 TObjString*
tdec = (TObjString*)tok->At(3);
3753 TObjString*
tdist = (TObjString*)tok->At(14);
3757 double ra = tra->GetString().Atof();
3758 double dec = tdec->GetString().Atof();
3759 double dist = tdist->GetString().Atof();
3762 if (dist<distance_thr) {
3763 thList.push_back(dec);
3764 phList.push_back(ra*360./24.);
3765 psiList.push_back(gRandom->Uniform(0,180));
3766 rhoList.push_back(dist);
3768 error=
false;
double iota = GetPar(
"iota",par,error);
3769 if(error) iotaList.push_back(0);
3770 else if(iota>=0&&iota<=180) iotaList.push_back(iota);
3771 else iotaList.push_back(rad2deg*acos(gRandom->Uniform(-1,1)));
3773 hrssList.push_back(0);
3774 IDList.push_back(-1);
3775 idList.push_back(-1);
3782 cout <<
"CWB::mdc::SetSkyDistribution - User Custom Distribution" << endl;
3786 if (!in.good()) {cout <<
"CWB::mdc::SetSkyDistribution - Error Opening File : " << fName << endl;
exit(1);}
3792 in.getline(str,1024);
3793 if (!in.good())
break;
3794 if(str[0] !=
'#') entries++;
3796 cout <<
"entries " << entries << endl;
3797 in.clear(ios::goodbit);
3798 in.seekg(0, ios::beg);
3807 in.getline(str,1024);
3808 if(str[0] ==
'#')
continue;
3809 if (!in.good())
break;
3811 std::stringstream linestream(str);
3812 if(!(linestream >> gps >> name >> theta >> phi >> psi >> rho >> iota >> hrss >> ID >>
id)) {
3813 cout <<
"CWB::mdc::SetSkyDistribution - Wrong Format for File : " << fName << endl;
3814 cout <<
"input line : " << endl;
3815 cout << str << endl;
3816 cout <<
"must be : " << endl;
3817 cout <<
"gps " <<
"name " <<
"theta " <<
"phi " <<
"psi "
3818 <<
"rho " <<
"iota " <<
"hrss " <<
"ID " <<
"id " <<
"..." << endl;
3824 gpsList.push_back(gps);
3825 nameList.push_back(name);
3826 thList.push_back(theta);
3827 phList.push_back(phi);
3828 psiList.push_back(psi);
3829 rhoList.push_back(rho);
3830 iotaList.push_back(iota);
3831 hrssList.push_back(hrss);
3832 IDList.push_back(ID);
3833 idList.push_back(
id);
3842 cout <<
"CWB::mdc::SetSkyDistribution - User Distribution from XML" << endl;
3844 #if LAL_VERSION_MAJOR > 6 || (LAL_VERSION_MAJOR == 6 && \
3845 (LAL_VERSION_MINOR > 14 || (LAL_VERSION_MINOR == 14 && \
3846 LAL_VERSION_MICRO >= 0 ))) // LAL_VERSION >= 6.14.0
3848 cout <<
"CWB::mdc::SetSkyDistribution - LAL XML File can not be used with LAL ver < 6.14.0" << endl;
3853 int estat = gSystem->GetPathInfo(fName.Data(),&
id,&fsize,&
flags,&
mt);
3855 cout <<
"CWB::mdc::SetSkyDistribution - XML File : " << fName.Data() <<
" Not Exist" << endl;
3863 int decimals = GetPar(
"decimals",par,error);
3864 if(error) decimals=1;
3868 double hrss_factor = GetPar(
"hrss_factor",par,error);
3869 if(error) hrss_factor=1;
3873 int engine = GetPar(
"engine",par,error);
3878 int AUTO = GetPar(
"auto",par,error);
3883 double start = GetPar(
"start",par,error);
3886 double stop = GetPar(
"stop",par,error);
3887 if(error) stop=std::numeric_limits<double>::max();;
3891 for(
int n=0;
n<par.size();
n++) {
3893 vector<mdcpar> xpar(1); xpar[0]=par[
n];
3894 TString type = GetParString(
"type",xpar,error);
3897 for(
int m=0;
m<xmlType.size();
m++) {
3898 if(type==xmlType[
m]) {present=
true;
break;}
3900 if(!present) xmlType.push_back(type.Data());
3906 LIGOTimeGPS gpsStartTime = {(
int)start, 0};
3907 LIGOTimeGPS gpsStopTime = {(
int)stop, 0};
3908 SimBurst* sim_burst = XLALSimBurstTableFromLIGOLw(fName.Data(),&gpsStartTime,&gpsStopTime);
3909 if(sim_burst==NULL) {
3910 cout <<
"CWB::mdc::SetSkyDistribution - XML File : " << fName.Data() << endl;
3911 cout <<
" No Events present in the range : " << (
int)start <<
":" << (
int)stop <<endl;
3914 int sim_burst_index=0;
3915 for(; sim_burst; sim_burst = sim_burst->next) {
3921 double gps = sim_burst->time_geocent_gps.gpsSeconds;
3922 gps += 1.e-9*sim_burst->time_geocent_gps.gpsNanoSeconds;
3924 if(gps<start || gps>stop)
continue;
3929 double phi = sm.
RA2phi(rad2deg*sim_burst->ra,gps);
3930 double theta = rad2deg*(TMath::PiOver2()-sim_burst->dec);
3931 double psi = rad2deg*sim_burst->psi;
3932 double frequency = sim_burst->frequency;
3933 double Q = sim_burst->q;
3934 double duration = sim_burst->duration;
3935 double bandwidth = sim_burst->bandwidth;
3937 double phase = rad2deg*sim_burst->pol_ellipse_angle;
3938 double eccentricity = sim_burst->pol_ellipse_e;
3939 double hrss = sim_burst->hrss * hrss_factor;
3940 double amplitude = sim_burst->amplitude;
3941 double egw_over_rsquared = sim_burst->egw_over_rsquared;
3942 double waveform_number = sim_burst->waveform_number;
3953 double iota = eccentricity;
3958 vector<mdcpar> wpar;
3961 if(
TString(sim_burst->waveform)==
"Gaussian") {
3965 wpar[0].name=
"duration"; wpar[0].value=
duration;
3966 wpar[1].name=
"decimals"; wpar[1].value=decimals;
3972 if(
TString(sim_burst->waveform)==
"SineGaussian") {
3976 wpar[0].name=
"frequency"; wpar[0].value=
frequency;
3977 wpar[1].name=
"Q"; wpar[1].value=
Q;
3978 wpar[2].name=
"decimals"; wpar[2].value=decimals;
3984 if(
TString(sim_burst->waveform)==
"BTLWNB") {
3988 wpar[0].name=
"frequency"; wpar[0].value=
frequency;
3989 wpar[1].name=
"bandwidth"; wpar[1].value=bandwidth;
3990 wpar[2].name=
"duration"; wpar[2].value=
duration;
3991 wpar[3].name=
"pseed"; wpar[3].value=seed+2*sim_burst_index;
3992 wpar[4].name=
"xseed"; wpar[4].value=seed+2*sim_burst_index+1;
3993 wpar[5].name=
"mode"; wpar[5].value=0;
3994 wpar[6].name=
"decimals"; wpar[6].value=decimals;
4000 if(
TString(sim_burst->waveform)==
"StringCusp") {
4004 wpar[0].name=
"frequency"; wpar[0].value=
frequency;
4005 wpar[1].name=
"amplitude"; wpar[1].value=
amplitude;
4006 wpar[2].name=
"decimals"; wpar[2].value=decimals;
4014 for(
int i=0;
i<(
int)wfList.size();
i++) {
4016 for(
int j=0;
j<(
int)xmlType.size();
j++){
4017 if(wfList[
i].name.CompareTo(xmlType[
j])==0) {save =
false;
break;}
4020 xmlType.push_back(wfList[
i].name.Data());
4026 for(
int n=0;
n<xmlType.size();
n++) {
4027 if(waveid.
name==xmlType[
n]) {present=
true;
break;}
4030 cout <<
"CWB::mdc::SetSkyDistribution - "
4031 <<
"Error : mdc type " << waveid.
name <<
" is not in the xmlType list" << endl;
4032 cout<<endl<<
"xmlType list : "<<endl<<endl;
4033 for(
int n=0;
n<xmlType.size();
n++) {
4034 cout <<
"xmlType[" <<
n <<
"] : " << xmlType[
n] << endl;
4047 gpsList.push_back(gps);
4048 nameList.push_back(name);
4049 thList.push_back(theta);
4050 phList.push_back(phi);
4051 psiList.push_back(psi);
4052 rhoList.push_back(rho);
4053 iotaList.push_back(iota);
4054 hrssList.push_back(hrss);
4055 IDList.push_back(waveid.
ID);
4056 idList.push_back(waveid.
id);
4059 cout <<
"CWB::mdc::SetSkyDistribution - "
4060 <<
"Error : User Distribution from XML is enabled only with LAL" << endl;
4070 double theta = GetPar(
"theta",par,error);
4071 if(gerror) gerror=error;
4072 double phi = GetPar(
"phi",par,error);
4073 if(gerror) gerror=error;
4076 cout <<
"CWB::mdc::SetSkyDistribution - "
4077 <<
"Error : num par must be at least 2 [theta,phi,(psi,rho,gps)]" << endl;
4082 value=psi=rho=iota=0.;
4083 error=
false;value=GetPar(
"entries",par,error);
4084 int entries = error ? 10000 :
int(value);
4085 for(
int n=0;
n<entries;
n++) {
4086 error=
false;value=GetPar(
"psi",par,error);
4087 psi = error ? gRandom->Uniform(0,180) :
value;
4088 error=
false;value=GetPar(
"rho",par,error);
4089 rho = error ? 0. :
value;
4090 error=
false;value=GetPar(
"gps",par,error);
4091 if(!error) gpsList.push_back(value);
4093 error=
false;iota = GetPar(
"iota",par,error);
4094 if(error) iotaList.push_back(0);
4095 else if(iota>=0&&iota<=180) iotaList.push_back(iota);
4096 else iotaList.push_back(rad2deg*acos(gRandom->Uniform(-1,1)));
4098 thList.push_back(theta);
4099 phList.push_back(phi);
4100 psiList.push_back(psi);
4101 rhoList.push_back(rho);
4102 hrssList.push_back(0);
4103 IDList.push_back(-1);
4104 idList.push_back(-1);
4109 cout <<
"CWB::mdc::SetSkyDistribution - Error : Dummy method : network is not initialized " << endl;
4113 printf(
"CWB::mdc::SetSkyDistribution - injections loaded : %d\n",nInj);
4117 cout << N <<
" " << M << endl;
4123 inj_tree = inj->setTree();
4124 inj->output(inj_tree,
net,1,
false);
4127 cout <<
"inj entries : " << inj->GetEntries() << endl;
4147 if(psp!=NULL)
delete psp;
4148 psp =
new gskymap(0.4,0,180,0,360);
4149 psp->SetOptions(projection,coordinate,resolution/2);
4152 psp->SetGridxColor(kWhite);
4153 psp->SetGridyColor(kWhite);
4155 psp->SetGridxColor(kBlack);
4156 psp->SetGridyColor(kBlack);
4162 int size=360*2*resolution*180*2*resolution;
4168 if(inj_tree==NULL) {
4169 cout <<
"CWB::mdc::DrawSkyDistribution - Error : injection object is NULL" << endl;
4173 inj_tree->Draw(
"theta[0]:phi[0]:distance[0]:time[0]",
"",
"goff");
4174 entries = inj_tree->GetSelectedRows();
4177 double*
theta = inj_tree->GetV1();
4178 double*
phi = inj_tree->GetV2();
4179 double*
distance = inj_tree->GetV3();
4180 double*
gps = inj_tree->GetV4();
4181 coordinate.ToUpper();
4182 if(coordinate.CompareTo(
"CELESTIAL")==0) {
4183 for(
int n=0;
n<entries;
n++) x[
n] =
sm.phi2RA(phi[
n],gps[n]);
4185 for(
int n=0;
n<entries;
n++) x[
n] = phi[
n];
4187 for(
int n=0;
n<entries;
n++) {
4190 if(zmax<z[
n]) zmax=z[
n];
4194 entries = (
int)rhoList.
size();
4197 for(
int n=0;
n<entries;
n++) {
4201 if(zmax<z[
n]) zmax=z[
n];
4206 cout <<
"CWB::mdc::DrawSkyDistribution - Warning : no entries in sky distribution " << endl;
4213 for (
int i=0;
i<360*2*resolution;
i++) {
4214 for (
int j=0;
j<180*2*resolution;
j++) {
4215 double ph =
i/(double)(2*resolution);
4216 double th =
j/(double)(2*resolution);
4228 TMath::Sort(size,z.
data,index,
true);
4230 for (
int i=0;
i<
size;
i++) T[
i]=x[index[
i]];
4232 for (
int i=0;
i<
size;
i++) T[
i]=y[index[
i]];
4234 for (
int i=0;
i<
size;
i++) T[
i]=z[index[
i]];
4242 psp->SetZaxisTitle(
"Kpc");
4273 cout <<
"CWB::mdc::WriteFrameFile - Error : Dummy method : network is not initialized " << endl;
4282 if(chName.size()!=0 && chName.size()!=
nIFO) {
4283 cout <<
"CWB::mdc::WriteFrameFile - Error : chName list size must be equals to nIFO " << nIFO << endl;
4289 sprintf(sdir,
"%s-%s-%04d",ifoLabel,frLabel.Data(),
int(gps/100000));
4290 char cmd[128];
sprintf(cmd,
"mkdir -p %s/%s",frDir.Data(),sdir);
4291 cout << cmd << endl;
4296 cout << frFile << endl;
4297 FrFile *ofp = FrFileONew(frFile,1);
4302 simFrame->frame = 0;
4305 simFrame->GTimeS =
gps;
4306 simFrame->GTimeN = 0;
4316 if(chName[
i]!=
"")
sprintf(chNAME,
"%s",chName[
i].Data());
4324 cout <<
"Size (sec) " << x.
size()/x.
rate() << endl;
4325 FrProcData* proc = FrProcDataNew(simFrame,chNAME,x.
rate(),x.
size(),-64);
4326 if(proc == NULL) {cout <<
"CWB::mdc::WriteFrameFile - Cannot create FrProcData" << endl;
exit(-1);}
4327 proc->timeOffset = 0;
4328 proc->tRange = simFrame->dt;
4331 for (
int i=0;
i<(
int)proc->data->nData;
i++) proc->data->dataD[
i] = x[
i];
4334 int err=FrameWrite(simFrame,ofp);
4335 if (err) {cout <<
"CWB::mdc::WriteFrameFile - Error writing frame" << endl;
exit(1);}
4336 FrameFree(simFrame);
4338 if (ofp!=NULL) FrFileOEnd(ofp);
4343 for(
int i=0;
i<(
int)mdcList.size();
i++) logString = logString+mdcList[
i]+
"\n";
4348 logFile.ReplaceAll(
".gwf",
"-Log.txt");
4376 polarization.ToUpper();
4379 if(polarization.Contains(
"HP"))
Dump(fname, wf.
hp);
4380 if(polarization.Contains(
"HX"))
Dump(fname, wf.
hx);
4398 polarization.ToUpper();
4401 if(polarization.Contains(
"HP"))
Dump(fname, wf.
hp);
4402 if(polarization.Contains(
"HX"))
Dump(fname, wf.
hx);
4420 if (!out.good()) {cout <<
"CWB::mdc::WriteFrameFile - Error Opening File : " << fname.Data() << endl;
exit(1);}
4422 for(
int i=0;
i<(
int)x.
size();
i++) out << x[
i] << endl;
4441 sprintf(cmd,
"mkdir -p %s",dname.Data());
4445 for(
int i=0;
i<(
int)wfList.size();
i++) {
4447 Dump(dname+
"/"+wfList[
i].
name+
"~01.txt",
i, 0,
"hp");
4448 Dump(dname+
"/"+wfList[
i].
name+
"~02.txt",
i, 0,
"hx");
4454 Dump(dname+
"/"+wfList[
i].
name+sid+
".txt",
i,
j+1,
"hp");
4457 Dump(dname+
"/"+wfList[
i].
name+sid+
".txt",
i,
j+1,
"hx");
4487 if(ifoId<0)
delete pD;
4488 polarization.ToUpper();
4489 if(polarization.Contains(
"HP"))
return F.
real();
else return F.
imag();
4506 if(ifo1.CompareTo(ifo2)==0)
return 0.0;
4513 if(ifoId1>=0) pD1 =
net->
getifo(ifoId1);
4517 if(ifoId1<0)
delete pD1;
4518 double delay = pD1->
getTau(theta,phi);
4525 if(ifoId2>=0) pD2 =
net->
getifo(ifoId2);
4528 double delay = pD1->
getTau(theta,phi)-pD2->
getTau(theta,phi);
4530 if(ifoId1<0)
delete pD1;
4531 if(ifoId2<0)
delete pD2;
4548 if(size<=0 && inj==NULL) {
4549 cout <<
"CWB::mdc::DumpLogHeader - Error : dump needs injection object " << endl;
4557 if (!out.good()) {cout <<
"CWB::mdc::DumpLogHeader - Error Opening File : " << fName.Data() << endl;
exit(1);}
4561 out <<
"# Log File for Burst " << label.Data() << endl;
4563 out <<
"# The following detectors were simulated" << endl;
4566 out <<
"# There were " << size <<
" injections" << endl;
4568 out <<
"# There were " <<
net->
mdcList.size() <<
" injections" << endl;
4574 inj_tree->Draw(
"type",cut,
"goff");
4575 int ninj = inj_tree->GetSelectedRows();
4576 out <<
"# Burst MDC Sim type " <<
net->
mdcType[
i].data() <<
"\t occurred " << ninj <<
" times" << endl;
4580 out <<
"# GravEn_SimID SimHrss SimEgwR2 GravEn_Ampl ";
4581 out <<
"Internal_x Internal_phi ";
4582 out <<
"External_x External_phi External_psi ";
4583 out <<
"FrameGPS EarthCtrGPS SimName SimHpHp SimHcHc SimHpHc ";
4600 CWB::mdc::CreateBurstXML(
TString fName, vector<mdcpar> xml_parms) {
4610 cout <<
"CWB::mdc::CreateBurstXML : Error : This function is allowed only for Burst !!!" << endl;
4614 if(xml_filename!=
"") {
4615 cout <<
"CWB::mdc::CreateBurstXML : Error : file XML already opened !!!" << endl;
4621 double start_time = GetPar(
"start_time",xml_parms,error);
if(error) start_time = 0;
4623 double end_time = GetPar(
"end_time",xml_parms,error);
if(error) end_time = 0;
4625 xml_filename =
fName;
4626 xml_process_table_head = NULL;
4627 xml_process_params_table_head = NULL;
4628 xml_search_summary_table_head = NULL;
4629 xml_time_slide_table_head = NULL;
4630 xml_sim_burst_table_head = NULL;
4631 xml_sim_burst = &xml_sim_burst_table_head;
4635 if(ifos!=
"") ifos.Resize(ifos.Sizeof()-2);
4638 xml_process_table_head = xml_process = XLALCreateProcessTableRow();
4639 sprintf(xml_process->program,
"cWB");
4640 XLALGPSTimeNow(&xml_process->start_time);
4642 sprintf(xml_process->cvs_repository,
"https://git.ligo.org/cWB/library/");
4644 for(
int i=0;
i<gApplication->Argc();
i++)
sprintf(cmd_line,
"%s %s",cmd_line,gApplication->Argv(
i));
4645 sprintf(xml_process->comment, cmd_line);
4646 sprintf(xml_process->domain,
"cWB");
4648 UserGroup_t*
uinfo = gSystem->GetUserInfo();
4649 xml_process->unix_procid = gSystem->GetPid();
4650 sprintf(xml_process->node, gSystem->HostName());
4651 sprintf(xml_process->username, uinfo->fUser);
4652 sprintf(xml_process->ifos,ifos.Data());
4653 xml_process->process_id = 0;
4656 ProcessParamsTable **paramaddpoint = &xml_process_params_table_head;
4658 ADD_PROCESS_PARAM(paramaddpoint, xml_process,
"string",
"instrument",
net->
getifo(
n)->
Name);
4660 ADD_PROCESS_PARAM(paramaddpoint, xml_process,
"double",
"inj-hrss",
4661 TString::Format(
"%f",GetInjHrss()).Data());
4662 ADD_PROCESS_PARAM(paramaddpoint, xml_process,
"double",
"time-step",
4663 TString::Format(
"%f",1./GetInjRate()).Data());
4664 ADD_PROCESS_PARAM(paramaddpoint, xml_process,
"double",
"jitter",
4665 TString::Format(
"%f",GetInjJitter()).Data());
4666 ADD_PROCESS_PARAM(paramaddpoint, xml_process,
"enum",
"sky-distribution",
4668 ADD_PROCESS_PARAM(paramaddpoint, xml_process,
"string",
"sky-file", sky_file.Data());
4669 for(
int i=0;
i<sky_parms.size();
i++) {
4670 ADD_PROCESS_PARAM(paramaddpoint, xml_process,
"double",
4671 sky_parms[
i].
name.Data(), TString::Format(
"%f",sky_parms[
i].
value).Data());
4673 for(
int i=0;
i<xml_parms.size();
i++) {
4674 if(xml_parms[
i].svalue!=
"") {
4675 ADD_PROCESS_PARAM(paramaddpoint, xml_process,
"string",
4676 xml_parms[
i].
name.Data(), xml_parms[
i].svalue.Data());
4678 ADD_PROCESS_PARAM(paramaddpoint, xml_process,
"double",
4679 xml_parms[
i].
name.Data(), TString::Format(
"%f",xml_parms[
i].
value).Data());
4684 xml_search_summary_table_head = xml_search_summary = XLALCreateSearchSummaryTableRow(xml_process);
4685 sprintf(xml_search_summary->comment,
"");
4686 sprintf(xml_search_summary->ifos,ifos.Data());
4687 xml_search_summary->nnodes = 1;
4689 xml_search_summary->in_start_time.gpsSeconds = in_start_time.GetSec();
4690 xml_search_summary->in_start_time.gpsNanoSeconds = in_start_time.GetNSec();
4691 xml_search_summary->out_start_time.gpsSeconds = in_start_time.GetSec();
4692 xml_search_summary->out_start_time.gpsNanoSeconds = in_start_time.GetNSec();
4694 xml_search_summary->in_end_time.gpsSeconds = in_end_time.GetSec();
4695 xml_search_summary->in_end_time.gpsNanoSeconds = in_end_time.GetNSec();
4696 xml_search_summary->out_end_time.gpsSeconds = in_end_time.GetSec();
4697 xml_search_summary->out_end_time.gpsNanoSeconds = in_end_time.GetNSec();
4705 CWB::mdc::FillBurstXML(
bool verbose) {
4712 if(xml_filename==
"") {
4713 cout <<
"CWB::mdc::FillBurstXML : Error : file XML not declared !!! use CreateBurstXML" << endl;
4717 double NaN = std::numeric_limits<double>::quiet_NaN();
4721 cout <<
"gps" <<
"\t\t" <<
"wf-name" <<
"\t\t\t" <<
"theta" <<
"\t" <<
"phi" <<
"\t" <<
"psi"
4722 <<
"\t" <<
"rho" <<
"\t" <<
"iota" <<
"\t" <<
"hrss" <<
"\t" <<
"ID" <<
"\t" <<
"id" << endl;
4726 for(
int i=0;
i<(
int)srcList.size();
i++) {
4728 double hrss = srcList[
i].hrss>0 ? srcList[
i].hrss : inj_hrss;
4730 cout << std::setprecision(13) << srcList[
i].gps <<
"\t" << std::setprecision(6)
4731 << wf.
name.Data() <<
"\t" << srcList[
i].theta <<
"\t"
4732 << srcList[
i].phi <<
"\t" << srcList[
i].psi <<
"\t" << srcList[
i].rho <<
"\t"
4733 << srcList[
i].iota <<
"\t" << hrss <<
"\t" << srcList[
i].ID <<
"\t" << srcList[
i].id << endl;
4736 SimBurst *sim_burst = XLALCreateSimBurst();
4737 if(!sim_burst) {*xml_sim_burst=NULL;
return;}
4743 sim_burst->time_geocent_gps.gpsSeconds =
time.GetSec();
4744 sim_burst->time_geocent_gps.gpsNanoSeconds =
time.GetNSec();
4746 sim_burst->ra = deg2rad*
sm.phi2RA(srcList[
i].
phi,srcList[
i].
gps);
4747 sim_burst->dec = TMath::PiOver2()-deg2rad*srcList[
i].theta;
4748 sim_burst->psi = deg2rad*srcList[
i].psi;
4750 sim_burst->frequency = GetPar(
"frequency",wf.
par,error);
if(error) sim_burst->frequency=NaN;
4752 sim_burst->q = GetPar(
"Q",wf.
par,error);
if(error) sim_burst->q=NaN;
4754 sim_burst->duration = GetPar(
"duration",wf.
par,error);
if(error) sim_burst->duration=NaN;
4756 sim_burst->bandwidth = GetPar(
"bandwidth",wf.
par,error);
if(error) sim_burst->bandwidth=NaN;
4757 sim_burst->pol_ellipse_angle = 0;
4758 sim_burst->pol_ellipse_e = cos(deg2rad*srcList[
i].iota);
4759 sim_burst->hrss =
hrss;
4760 sim_burst->amplitude = 0;
4761 sim_burst->egw_over_rsquared = 0;
4762 sim_burst->waveform_number = srcList[
i].ID;
4764 *xml_sim_burst = sim_burst;
4765 xml_sim_burst = &(*xml_sim_burst)->next;
4774 CWB::mdc::CloseBurstXML() {
4781 if(xml_filename==
"") {
4782 cout <<
"CWB::mdc::CloseBurstXML : Error : file XML not declared !!! use CreateBurstXML" << endl;
4786 XLALGPSTimeNow(&xml_process->end_time);
4789 LIGOLwXMLStream *xml;
4791 xml = XLALOpenLIGOLwXMLFile(xml_filename.Data());
4794 if(XLALWriteLIGOLwXMLProcessTable(xml, xml_process_table_head)) {
4795 cout <<
"CWB::mdc::CloseBurstXML : Error in XLALWriteLIGOLwXMLProcessTable" << endl;
4799 if(XLALWriteLIGOLwXMLProcessParamsTable(xml, xml_process_params_table_head)) {
4800 cout <<
"CWB::mdc::CloseBurstXML : Error in XLALWriteLIGOLwXMLProcessParamsTable" << endl;
4804 if(XLALWriteLIGOLwXMLSearchSummaryTable(xml, xml_search_summary_table_head)) {
4805 cout <<
"CWB::mdc::CloseBurstXML : Error in XLALWriteLIGOLwXMLSearchSummaryTable" << endl;
4809 if(XLALWriteLIGOLwXMLTimeSlideTable(xml, xml_time_slide_table_head)) {
4810 cout <<
"CWB::mdc::CloseBurstXML : Error in XLALWriteLIGOLwXMLTimeSlideTable" << endl;
4814 if(XLALWriteLIGOLwXMLSimBurstTable(xml, xml_sim_burst_table_head)) {
4815 cout <<
"CWB::mdc::CloseBurstXML : Error in XLALWriteLIGOLwXMLSimBurstTable" << endl;
4819 XLALCloseLIGOLwXMLFile(xml);
4822 XLALDestroyProcessTable(xml_process_table_head);
4823 XLALDestroyProcessParamsTable(xml_process_params_table_head);
4824 XLALDestroyTimeSlideTable(xml_time_slide_table_head);
4825 XLALDestroySearchSummaryTable(xml_search_summary_table_head);
4826 XLALDestroySimBurstTable(xml_sim_burst_table_head);
4851 if(name==
"") error=
true;
4852 if((name==
"Gaussian")&&(name!=
"SineGaussian")&&(name==
"BTLWNB")) error=
true;
4854 cout <<
"CWB::mdc::GetBurstNameLAL : Error - Not valid --name option" << endl;
4855 cout <<
"available --name options are : Gaussian/SineGaussian/BTLWNB" << endl;
4862 if(sdecimals.IsDigit()) decimals = sdecimals.Atoi();
4864 if(name==
"Gaussian") {
4866 int d1 = decimals==-1 ? 1 : decimals;
4870 if(sduration.IsFloat()) {
4871 duration = sduration.Atof();
4873 cout <<
"CWB::mdc::GetBurstNameLAL : Error : --duration not defined or not a number!!! " << endl;
4877 wfname = TString::Format(
"LAL_GA%.*f",d1,1000.*duration);
4878 wfname.ReplaceAll(
".",
"d");
4881 }
else if(name==
"SineGaussian") {
4883 int d1 = decimals==-1 ? 0 : decimals;
4884 int d2 = decimals==-1 ? 1 : decimals;
4888 if(sfrequency.IsFloat()) {
4889 frequency = sfrequency.Atof();
4891 cout <<
"CWB::mdc::GetBurstNameLAL : Error : --frequency not defined or not a number!!! " << endl;
4900 cout <<
"CWB::mdc::GetBurstNameLAL : Error : --q not defined or not a number!!! " << endl;
4904 wfname = TString::Format(
"LAL_SGE%.*fQ%.*f",d1,frequency,d2,q);
4905 wfname.ReplaceAll(
".",
"d");
4906 if(decimals==-1) wfname.ReplaceAll(
"d0",
"");
4909 }
else if(name==
"BTLWNB") {
4911 int d1 = decimals==-1 ? 0 : decimals;
4912 int d2 = decimals==-1 ? 0 : decimals;
4913 int d3 = decimals==-1 ? 3 : decimals;
4917 if(sfrequency.IsFloat()) {
4918 frequency = sfrequency.Atof();
4920 cout <<
"CWB::mdc::GetBurstNameLAL : Error : --frequency not defined or not a number!!! " << endl;
4926 if(sbandwidth.IsFloat()) {
4927 bandwidth = sbandwidth.Atof();
4929 cout <<
"CWB::mdc::GetBurstNameLAL : Error : --bandwidth not defined or not a number!!! " << endl;
4935 if(sduration.IsFloat()) {
4936 duration = sduration.Atof();
4938 cout <<
"CWB::mdc::GetBurstNameLAL : Error : --duration not defined or not a number!!! " << endl;
4942 wfname = TString::Format(
"LAL_WNB%.*f_%.*f_%.*f",d1,frequency,d2,bandwidth,d3,duration);
4943 wfname.ReplaceAll(
".",
"d");
4946 }
else if(name==
"StringCusp") {
4948 int d1 = decimals==-1 ? 1 : decimals;
4952 if(sfrequency.IsFloat()) {
4953 frequency = sfrequency.Atof();
4955 cout <<
"CWB::mdc::GetBurstNameLAL : Error : --frequency not defined or not a number!!! " << endl;
4959 wfname = TString::Format(
"LAL_SC%.*f",d1,1000.*frequency);
4960 wfname.ReplaceAll(
".",
"d");
4993 cout <<
"CWB::mdc::e2cosi - Error : eccentricity must be defined in the range [0:1] " << endl;
4997 double E = e<0.9999999999 ? e : 0.9999999999;
4998 double A = 1./sqrt(2-E*E);
4999 double B = A*sqrt(1-E*E);
5000 double x1 = (A+sqrt(A*A-B*B))/(B*B);
5001 double x2 = (A-sqrt(A*A-B*B))/(B*B);
5002 double x =
fabs(x1*B)>1 ? x2 : x1;
5022 cout <<
"CWB::mdc::cosi2e - Error : cosi must be defined in the range [-1:1] " << endl;
5026 double A = (1+cosi*cosi)/2;
5029 double C = sqrt(A*A+B*B);
5032 double E = sqrt(1-(B*B)/(A*A));
5049 if(fName.Contains(
".root")) {
5052 cout <<
"CWB::mdc::DumpLog - Error : dump to root needs injection object " << endl;
5056 TFile
froot(fName,
"RECREATE");
5057 if(label.Sizeof()>1) this->
Write(label);
else this->
Write(
"WaveMDC");
5059 cout <<
"CWB::mdc::DumpLog - inj entries written : " << inj_tree->GetEntries() << endl;
5064 if(fName.Contains(
".txt")) {
5068 for(
int i=0;
i<(
int)mdcList.size();
i++) logString = logString+mdcList[
i]+
"\n";
5072 if(append) out.open(fName.Data(),ios::app);
5073 else out.open(fName.Data(),
ios::out);
5074 if (!out.good()) {cout <<
"CWB::mdc::DumpLog - Error Opening File : " << fName.Data() << endl;
exit(1);}
5076 for(
int i=0;
i<(
int)mdcList.size();
i++) out << mdcList[
i] << endl;
5080 if(fName.Contains(
".lst")) {
5084 if(append) out.open(fName.Data(),ios::app);
5085 else out.open(fName.Data(),
ios::out);
5086 if (!out.good()) {cout <<
"CWB::mdc::DumpLog - Error Opening File : " << fName.Data() << endl;
exit(1);}
5088 out <<
"#gps\t\t" <<
"name\t\t" <<
"theta\t" <<
"phi\t" <<
"psi\t"
5089 <<
"rho\t" <<
"iota\t" <<
"hrss\t" <<
"ID\t" <<
"id\t" << endl;
5090 for(
int i=0;
i<(
int)srcList.size();
i++) {
5092 double hrss = srcList[
i].hrss>0 ? srcList[
i].hrss : inj_hrss;
5093 out << srcList[
i].gps <<
"\t" << wf.
name.Data() <<
"\t" << srcList[
i].theta <<
"\t"
5094 << srcList[
i].phi <<
"\t" << srcList[
i].psi <<
"\t" << srcList[
i].rho <<
"\t"
5095 << srcList[
i].iota <<
"\t" << hrss <<
"\t" << srcList[
i].ID <<
"\t" << srcList[
i].id << endl;
5100 cout <<
"CWB::mdc::DumpLog - Error : file extention must be .root" << endl;
5125 cout <<
"CWB::mdc::GetInspiral - Error : Dummy method : network is not initialized " << endl;
5129 cout <<
"CWB::mdc::GetInspiral - Error : x.rate() != " <<
MDC_SAMPLE_RATE << endl;
5136 int gpsStartSec = x.
start();
5137 int gpsEndSec = gpsStartSec + x.
size()/x.
rate();
5140 INT4 numInjections = 0;
5141 SimInspiralTable *injections = NULL;
5142 TString injectionFile = GenInspiralXML(0., 0.,
false);
5145 lal_errhandler = LAL_ERR_EXIT;
5147 XLALSetSilentErrorHandler();
5150 numInjections = SimInspiralTableFromLIGOLw(&injections, injectionFile.Data(), gpsStartSec, gpsEndSec);
5152 if ( numInjections == 0 ) {
5153 fprintf( stderr,
"CWB::mdc::GetInspiral - Warning : No injections in specified time\n");
5156 fprintf( stdout,
"CWB::mdc::GetInspiral : Read %d injection(s) from the file '%s'\n",
5157 numInjections, injectionFile.Data() );
5165 fprintf(stdout,
"CWB::mdc::GetInspiral : Generating injection for: %s",ifo.Data());
5167 FindChirpInjectSignals(x, injections, ifo);
5172 SimInspiralTable *thisInj = NULL;
5173 for (thisInj = injections; thisInj; thisInj = thisInj->next)
5180 mdcList.push_back(log.Data());
5181 double gps = thisInj->geocent_end_time.gpsSeconds+1.e-9*thisInj->geocent_end_time.gpsNanoSeconds;
5182 mdcTime.push_back(gps);
5184 mdcType.push_back(inspName.Data());
5186 if(inspXML==
"") gSystem->Exec(
TString(
"rm ")+injectionFile);
5188 while ( injections ) {
5189 SimInspiralTable *thisInj = NULL;
5190 thisInj = injections;
5191 injections = injections->next;
5195 LALCheckMemoryLeaks();
5203 CWB::mdc::GetInspiralLog(
TString inspName,
double FrameGPS, SimInspiralTable *thisInj) {
5213 cout <<
"CWB::mdc::GetInspiralLog - Error : Dummy method : network is not initialized " << endl;
5227 if (strncmp(thisInj->waveform,
"NumRel", LIGOMETA_WAVEFORM_MAX) == 0)
5228 sprintf(output,
"%s ", thisInj->numrel_data);
5232 sprintf(output,
"%s 1 ",output);
5234 sprintf(output,
"%s 0 ",output);
5236 sprintf(output,
"%s 0 ",output);
5238 sprintf(output,
"%s %g ",output, cos(thisInj->inclination));
5240 sprintf(output,
"%s %g ",output, thisInj->coa_phase);
5242 sprintf(output,
"%s %g ",output, cos(thisInj->latitude - LAL_PI_2));
5244 gmst = fmod(XLALGreenwichMeanSiderealTime(&thisInj->geocent_end_time), LAL_TWOPI);
5245 longitude = fmod(thisInj->longitude - gmst, LAL_TWOPI);
5247 longitude += LAL_TWOPI;
5248 sprintf(output,
"%s %g ",output, longitude);
5250 sprintf(output,
"%s %g ",output, thisInj->polarization);
5252 sprintf(output,
"%s %d ",output,
int(FrameGPS));
5254 sprintf(output,
"%s %d.%09d ",output, thisInj->geocent_end_time.gpsSeconds, thisInj->geocent_end_time.gpsNanoSeconds);
5256 sprintf(output,
"%s %s ",output, inspName.Data());
5258 sprintf(output,
"%s 0 ",output);
5260 sprintf(output,
"%s 0 ",output);
5262 sprintf(output,
"%s 0 ",output);
5272 latitude=thisInj->latitude;
5273 longitude=thisInj->longitude;
5274 polarization=thisInj->polarization;
5275 theta = LAL_PI_2-latitude;
5277 longitude = fmod(longitude - gmst, LAL_TWOPI);
5278 if (longitude < 0) longitude += LAL_TWOPI;
5279 phi = longitude > 0 ? longitude : 2*
TMath::Pi()+longitude;
5283 double fp = GetAntennaPattern(ifo, phi, theta, psi,
"hp");
5284 double fc = GetAntennaPattern(ifo, phi, theta, psi,
"hx");
5293 double D_R = sqrt(D->
Rv[0]*D->
Rv[0]+D->
Rv[1]*D->
Rv[1]+D->
Rv[2]*D->
Rv[2]);
5296 dV.SetTheta(D_theta*d2r);
5297 dV.SetPhi(D_phi*d2r);
5300 sV.SetTheta(theta*d2r);
5303 double cos_dVdS =
dV.Dot(sV);
5304 double D_geocent_delay=-cos_dVdS*D_R/
speedlight;
5305 int tShift_sec =
int(
fabs(D_geocent_delay));
5306 int tShift_nsec =
int(1e9*(
fabs(D_geocent_delay)-tShift_sec));
5309 int end_time_gpsSeconds = thisInj->geocent_end_time.gpsSeconds;
5310 int end_time_gpsNanoSeconds = thisInj->geocent_end_time.gpsNanoSeconds;
5311 if(D_geocent_delay>=0) {
5312 end_time_gpsSeconds += tShift_sec;
5313 end_time_gpsNanoSeconds += tShift_nsec;
5314 if ( end_time_gpsNanoSeconds >= 1000000000 ) {
5315 end_time_gpsSeconds +=
INT_4S( end_time_gpsNanoSeconds / 1000000000 );
5316 end_time_gpsNanoSeconds = end_time_gpsNanoSeconds % 1000000000;
5319 end_time_gpsSeconds -= tShift_sec;
5320 if ( end_time_gpsNanoSeconds >= tShift_nsec ) {
5321 end_time_gpsNanoSeconds -= tShift_nsec;
5323 --end_time_gpsSeconds;
5324 end_time_gpsNanoSeconds += 1000000000 - tShift_nsec;
5329 double cosiota = cos(thisInj->inclination);
5330 double eff_dist = thisInj->distance / sqrt(pow(fp*(1.+pow(cosiota,2)),2)/4.+pow(fc*cosiota,2));
5332 sprintf(output,
"%s %s %d.%09d %e %e %g ",output, ifo.Data(), end_time_gpsSeconds,
5333 end_time_gpsNanoSeconds, fp, fc, eff_dist);
5338 f_isco = 205 * (20 / (thisInj->mass1 + thisInj->mass2));
5341 sprintf(output,
"%s insp ",output);
5342 sprintf(output,
"%s distance %g ",output, thisInj->distance);
5343 sprintf(output,
"%s mass1 %g ",output, thisInj->mass1);
5344 sprintf(output,
"%s mass2 %g ",output, thisInj->mass2);
5345 sprintf(output,
"%s mchirp %g ",output, thisInj->mchirp);
5346 sprintf(output,
"%s spin1 %g %g %g ",output, thisInj->spin1x, thisInj->spin1y, thisInj->spin1z);
5347 sprintf(output,
"%s spin2 %g %g %g ",output, thisInj->spin2x, thisInj->spin2y, thisInj->spin2z);
5348 sprintf(output,
"%s freq %g %g\n",output, thisInj->f_lower, f_isco);
5381 TString option[nOpt] = {
"--help",
"--verbose",
"--user-tag",
"--write-compress",
5382 "--ipn-gps-time",
"--t-distr",
5383 "--write-sim-ring"};
5387 if(inspName.Sizeof()<=1) {
5388 cout <<
"CWB::mdc::SetInspiral - Error : inspName not declared" << endl;
5392 for(
int i=0;
i<nOpt;
i++) {
5393 if(inspOptions.Contains(option[
i])) {
5394 cout <<
"CWB::mdc::SetInspiral - Error : option " << option[
i].Data()
5395 <<
" not allowed in CWB" << endl;
5402 inspOptions.ReplaceAll(
"--approximant",
"--waveform");
5409 for(
int i=0;i<token->GetEntries();i++) {
5410 TObjString* otoken = (TObjString*)token->At(i);
5411 TString stoken = otoken->GetString();
5412 if(stoken==
"--xml") bxml++;
5413 if(stoken==
"--waveform") bwaveform++;
5417 cout <<
"CWB::mdc::SetInspiral - Error : ";
5418 if(bwaveform>1) cout <<
"imultiple declaration of waveform option" << endl;
5419 if(!bwaveform) cout <<
"missing waveform option" << endl;
5428 cout <<
"CWB::mdc::SetInspiral - Read options ..." << endl;
5429 for(
int i=0;i<token->GetEntries();i++) {
5430 TObjString* otoken = (TObjString*)token->At(i);
5431 TString stoken = otoken->GetString();
5432 if(stoken==
"--xml") {
5433 otoken = (TObjString*)token->At(i+1);
5434 stoken = otoken->GetString();
5435 cout <<
"--xml = " << stoken.Data() << endl;
5438 this->inspXML=stoken;
5440 if(stoken==
"--dir") {
5442 otoken = (TObjString*)token->At(i+1);
5443 stoken = otoken->GetString();
5444 cout <<
"--dir = " << stoken.Data() << endl;
5447 this->inspDIR=stoken;
5449 inspOptions.ReplaceAll(
"--dir",
"");
5450 inspOptions.ReplaceAll(stoken,
"");
5452 if(stoken==
"--output") {
5453 otoken = (TObjString*)token->At(i+1);
5454 stoken = otoken->GetString();
5455 cout <<
"--output = " << stoken.Data() << endl;
5458 inspOptions.ReplaceAll(
"--output",
"");
5459 inspOptions.ReplaceAll(stoken,
"");
5461 if(stoken==
"--dump") {
5462 otoken = (TObjString*)token->At(i+1);
5463 stoken = otoken->GetString();
5464 cout <<
"--dump = " << stoken.Data() << endl;
5467 inspOptions.ReplaceAll(
"--dump",
"");
5468 inspOptions.ReplaceAll(stoken,
"");
5470 if(stoken==
"--time-step") {
5471 otoken = (TObjString*)token->At(i+1);
5472 stoken = otoken->GetString();
5473 cout <<
"--time-step = " << stoken.Data() << endl;
5474 inj_rate = 1./stoken.Atof();
5476 if(stoken==
"--time-interval") {
5477 otoken = (TObjString*)token->At(i+1);
5478 stoken = otoken->GetString();
5479 cout <<
"--time-interval = " << stoken.Data() << endl;
5480 inj_jitter = stoken.Atof();
5482 if(stoken==
"--waveform") {
5483 otoken = (TObjString*)token->At(i+1);
5484 stoken = otoken->GetString();
5485 cout <<
"--waveform = " << stoken.Data() << endl;
5486 this->waveName=stoken;
5487 if(XLALGetApproximantFromString(stoken.Data()) == XLAL_FAILURE) {
5488 cout <<
"CWB::mdc::SetInspiral - waveform : \'" << stoken.Data()
5489 <<
"\' not allowed !!!" << endl;
5497 if(this->inspDIR==
"") {
5499 cout <<
"CWB::mdc::SetInspiral - Error : temporary dir not defined !!! Use --dir option" << endl;
5501 cout <<
" if this option is called from a config plugin add the following line to the inspOptions : " << endl;
5502 cout <<
" inspOptions+= \"--dir \"+TString(cfg->tmp_dir)+\" " << endl;
5503 cout <<
" before to call : 'MDC.SetInspiral(inspOptions);'" << endl << endl;
5504 cout <<
" and these lines to the plugin : " << endl;
5505 cout <<
" // export config object to the config plugin" << endl;
5506 cout <<
" sprintf(cmd,\"CWB::config* cfg = (CWB::config*)%p;\",cfg);" << endl;
5507 cout <<
" gROOT->ProcessLine(cmd);" << endl;
5508 cout <<
" before to execute the config plugin : 'cfg->configPlugin.Exec(NULL,&error);'" << endl;
5513 this->inspName=inspName;
5518 TString injectionFile = GenInspiralXML(0, 0,
false);
5519 cout <<
"Save inspiral injection file to " << inspDump.Data() << endl;
5520 if(inspXML==
"") gSystem->Exec(
"mv "+injectionFile+
" "+inspDump);
5521 else gSystem->Exec(
"cp "+injectionFile+
" "+inspDump);
5526 if(inspOutput!=
"") {
5529 int estat = gSystem->GetPathInfo(inspOutput.Data(),&
id,&
size,&
flags,&
mt);
5531 TString injectionFile = GenInspiralXML(0, 0,
false);
5532 cout <<
"Save inspiral injection file to " << inspOutput.Data() << endl;
5533 gSystem->Exec(
"cp "+injectionFile+
" "+inspOutput);
5538 if(inspXML==
"") GenInspiralXML(900000000, 900000000,
true);
5547 CWB::mdc::GetInspiralOption(
TString inspOption) {
5554 if(inspOptions==
"")
return "";
5560 in.open(inspXML.Data(),
ios::in);
5561 if (!in.good()) {cout <<
"CWB::mdc::GetInspiralOption - Error Opening xml File : "
5562 << inspXML.Data() << endl;gSystem->Exit(1);}
5566 in.getline(str,2048);
5567 if (!in.good())
break;
5568 if(
TString(str).Contains(
"inspinj")&&
TString(str).Contains(inspOption)) {
5570 if(token->GetEntries()!=5) {cout <<
"CWB::mdc::GetInspiralOption - bad line format : "
5571 << str << endl;gSystem->Exit(1);}
5572 TObjString* otoken = (TObjString*)token->At(4);
5573 TString stoken = otoken->GetString();
5574 stoken.ReplaceAll(
"\"",
"");
5583 TObjArray* token = inspOptions.Tokenize(
TString(
" "));
5584 for(
int i=0;i<token->GetEntries();i++) {
5585 TObjString* otoken = (TObjString*)token->At(i);
5586 TString stoken = otoken->GetString();
5587 if(stoken.Contains(inspOption)) {
5588 otoken = (TObjString*)token->At(i+1);
5589 stoken = otoken->GetString();
5590 stoken.ReplaceAll(
"\"",
"");
5604 CWB::mdc::GenInspiralXML(
int gps_start_time,
int gps_end_time,
bool rmFile) {
5615 if(inspXML!=
"")
return inspXML;
5618 if(gSystem->Getenv(
"LALINSPINJ_EXEC")==NULL) {
5619 cout <<
"CWB::mdc::GenInspiralXML - Error : environment LALINSPINJ_EXEC is not defined!!!" << endl;
exit(1);
5621 lalinspinj_exec=
TString(gSystem->Getenv(
"LALINSPINJ_EXEC"));
5625 TString ofName = GetTemporaryFileName(
"inspiral",
"xml",inspDIR,
true);
5628 cmdOptions +=
" --output "+
ofName;
5629 if(gps_start_time!=0) {
5630 cmdOptions +=
" --gps-start-time ";
5631 cmdOptions += gps_start_time;
5633 if(gps_end_time!=0) {
5634 cmdOptions +=
" --gps-end-time ";
5635 cmdOptions += gps_end_time;
5639 sprintf(cmd,
"%s %s",lalinspinj_exec.Data(),cmdOptions.Data());
5640 cout << cmd << endl;
5641 int error = gSystem->Exec(cmd);
5642 if(rmFile) gSystem->Exec(
TString(
"rm ")+ofName);
5647 sprintf(help,
"%s --help",lalinspinj_exec.Data());
5648 gSystem->Exec(help);
5650 cout <<
"CWB::mdc::GenInspiralXML - Error in exececuting :" << endl << endl;
5651 cout << cmd << endl << endl;
5671 gRandom->SetSeed(0);
5672 int rnID =
int(gRandom->Rndm(13)*1.e9);
5676 UserGroup_t* uinfo = gSystem->GetUserInfo();
5680 if(mkdir) error=gSystem->Exec(
TString(
"mkdir -p ")+dir);
5683 cout <<
"CWB::mdc::GetTemporaryFileName - Error in exececuting :" << endl << endl;
5690 sprintf(fName,
"%s/%s_%d.%s",dir.Data(),tag.Data(),
rnID,ext.Data());
5718 REAL8TimeSeries *hp=NULL;
5719 REAL8TimeSeries *hx=NULL;
5731 REAL8 location[3] = {pD->
Rv[0],pD->
Rv[1],pD->
Rv[2]};
5732 if(ifoId<0)
delete pD;
5735 SimInspiralTable *thisInj = NULL;
5736 for (thisInj = injections; thisInj; thisInj = thisInj->next)
5738 REAL8 deltaT = 1./w.
rate();
5739 if(waveName!=
"")
strcpy(thisInj->waveform,waveName.Data());
5742 Approximant approximant = (Approximant)XLALSimInspiralGetApproximantFromString(thisInj->waveform);
5754 if(approximant==NR_hdf5) {
5756 #if LAL_VERSION_MAJOR > 6 || (LAL_VERSION_MAJOR == 6 && \
5757 (LAL_VERSION_MINOR > 18 || (LAL_VERSION_MINOR == 18 && \
5758 (LAL_VERSION_MICRO > 0 || (LAL_VERSION_MICRO == 0 && LAL_VERSION_DEVEL >= 1))))) // LAL_VERSION >= 6.18.0.1
5761 LALDict *LALpars=XLALCreateDict();
5762 XLALSimInspiralWaveformParamsInsertNumRelData(LALpars, thisInj->numrel_data);
5765 REAL8 f_min = XLALSimInspiralfLow2fStart(thisInj->f_lower, thisInj->amp_order, approximant);
5787 if( thisInj->amp_order!=0 ) {
5788 cout << endl <<
"CWB::mdc::FindChirpInjectSignals - "
5789 <<
"Error : amp_order must be 0 for NR waveform : "
5790 <<
"check inspiral parameters" << endl;
5795 int ret = XLALSimInspiralChooseTDWaveform(&hp, &hx, thisInj->mass1*LAL_MSUN_SI, thisInj->mass2*LAL_MSUN_SI,
5796 thisInj->spin1x, thisInj->spin1y, thisInj->spin1z,
5797 thisInj->spin2x, thisInj->spin2y, thisInj->spin2z,
5798 thisInj->distance*LAL_PC_SI*1.0e6, thisInj->inclination,
5799 thisInj->coa_phase, 0., 0., 0.,
5800 deltaT, f_min, thisInj->f_lower,
5801 LALpars, approximant);
5803 XLALDestroyDict(LALpars);
5805 if( ret==XLAL_FAILURE ) {
5806 cout << endl <<
"CWB::mdc::GetInspiral - "
5807 <<
"Error in XLALInspiralTDWaveformFromSimInspiral : "
5808 <<
"check inspiral parameters" << endl;
5812 cout << endl <<
"CWB::mdc::GetInspiral - "
5813 <<
"Error - NR_hdf5 not supported for LAL_VERSION < 6.18.0.1" << endl;
5819 #if LAL_VERSION_MAJOR > 6 || (LAL_VERSION_MAJOR == 6 && \
5820 (LAL_VERSION_MINOR > 13 || (LAL_VERSION_MINOR == 13 && \
5821 LAL_VERSION_MICRO >= 2 ))) // LAL_VERSION >= 6.13.2
5824 int ret = XLALInspiralTDWaveformFromSimInspiral(&hp, &hx, thisInj, deltaT);
5825 if( ret==XLAL_FAILURE ) {
5826 cout << endl <<
"CWB::mdc::GetInspiral - "
5827 <<
"Error in XLALInspiralTDWaveformFromSimInspiral : "
5828 <<
"check inspiral parameters" << endl;
5832 cout << endl <<
"CWB::mdc::GetInspiral - "
5833 <<
"Error - LAL_VERSION < 6.13.2 not supported " << endl;
5844 XLALGPSAddGPS(&hp->epoch, &thisInj->geocent_end_time);
5845 XLALGPSAddGPS(&hx->epoch, &thisInj->geocent_end_time);
5848 wat::Time gpsinj(hp->epoch.gpsSeconds,hp->epoch.gpsNanoSeconds);
5852 double binoff = fmod(gpsoff.
GetDouble(),deltaT);
5854 bininj+=hp->data->length;
5855 if(bininj>w.
size()) {
5856 cout <<
"CWB::mdc::FindChirpInjectSignals - Warning " << endl;
5857 cout <<
" signal length " << hp->data->length*deltaT
5858 <<
" (sec) is too high, signal is cutted to fit the buffer length" << endl;
5859 cout <<
" Decrease the injection rate and/or reduce the waveform length" << endl;
5863 gmst = fmod(XLALGreenwichMeanSiderealTime(&thisInj->geocent_end_time), LAL_TWOPI);
5865 latitude=thisInj->latitude;
5866 longitude=thisInj->longitude;
5867 polarization=thisInj->polarization;
5868 theta = LAL_PI_2-latitude;
5870 longitude = fmod(longitude - gmst, LAL_TWOPI);
5871 if (longitude < 0) longitude += LAL_TWOPI;
5872 phi = longitude > 0 ? longitude : 2*
TMath::Pi()+longitude;
5876 fp = GetAntennaPattern(ifo, phi, theta, psi,
"hp");
5877 fx = GetAntennaPattern(ifo, phi, theta, psi,
"hx");
5880 int length = hp->data->length<w.
size() ? hp->data->length : w.
size();
5882 for(
int i=bininj;i>=0;i--) {
5883 int j=length-(bininj-
i)-1;
5885 z[
i] = fp*hp->
data->data[
j]+fx*hx->data->data[
j];
5889 double tShift = XLALTimeDelayFromEarthCenter(location, thisInj->longitude, thisInj->latitude, &hp->epoch);
5893 for(
int i=0;i<(
int)w.
size();i++) w[i]+=z[i];
5895 XLALDestroyREAL8TimeSeries( hp );
5896 XLALDestroyREAL8TimeSeries( hx );
5897 hp = NULL; hx = NULL;
5906 CWB::mdc::GetInspiral(
TString pol,
int gps_start_time,
int gps_end_time) {
5921 if(pol!=
"hp" && pol!=
"hx") {
5922 fprintf( stderr,
"CWB::mdc::GetInspiral - Warning : wrong polarization (enter hp or hx)\n");
5927 int gpsStartSec = gps_start_time;
5928 int gpsEndSec = gps_end_time;
5931 INT4 numInjections = 0;
5932 SimInspiralTable *injections = NULL;
5933 TString injectionFile = GenInspiralXML(0., 0.,
false);
5936 lal_errhandler = LAL_ERR_EXIT;
5938 XLALSetSilentErrorHandler();
5941 numInjections = SimInspiralTableFromLIGOLw(&injections, injectionFile.Data(), gpsStartSec, gpsEndSec);
5943 if ( numInjections == 0 ) {
5944 fprintf( stderr,
"CWB::mdc::GetInspiral - Warning : No injections in specified time\n");
5947 fprintf( stdout,
"CWB::mdc::GetInspiral : Read %d injection(s) from the file '%s'\n",
5948 numInjections, injectionFile.Data() );
5951 REAL8TimeSeries *hp=NULL;
5952 REAL8TimeSeries *hx=NULL;
5955 SimInspiralTable *thisInj = NULL;
5956 for (thisInj = injections; thisInj; thisInj = thisInj->next)
5958 REAL8 deltaT = 1./w.
rate();
5961 Approximant approximant = (Approximant)XLALSimInspiralGetApproximantFromString(thisInj->waveform);
5973 if(approximant==NR_hdf5) {
5975 #if LAL_VERSION_MAJOR > 6 || (LAL_VERSION_MAJOR == 6 && \
5976 (LAL_VERSION_MINOR > 18 || (LAL_VERSION_MINOR == 18 && \
5977 (LAL_VERSION_MICRO > 0 || (LAL_VERSION_MICRO == 0 && LAL_VERSION_DEVEL >= 1))))) // LAL_VERSION >= 6.18.0.1
5980 LALDict *LALpars=XLALCreateDict();
5981 XLALSimInspiralWaveformParamsInsertNumRelData(LALpars, thisInj->numrel_data);
5984 REAL8 f_min = XLALSimInspiralfLow2fStart(thisInj->f_lower, thisInj->amp_order, approximant);
6006 if( thisInj->amp_order!=0 ) {
6007 cout << endl <<
"CWB::mdc::GetInspiral - "
6008 <<
"Error : amp_order must be 0 for NR waveform : "
6009 <<
"check inspiral parameters" << endl;
6014 int ret = XLALSimInspiralChooseTDWaveform(&hp, &hx, thisInj->mass1*LAL_MSUN_SI, thisInj->mass2*LAL_MSUN_SI,
6015 thisInj->spin1x, thisInj->spin1y, thisInj->spin1z,
6016 thisInj->spin2x, thisInj->spin2y, thisInj->spin2z,
6017 thisInj->distance*LAL_PC_SI*1.0e6, thisInj->inclination,
6018 thisInj->coa_phase, 0., 0., 0.,
6019 deltaT, f_min, thisInj->f_lower,
6020 LALpars, approximant);
6022 XLALDestroyDict(LALpars);
6024 if( ret==XLAL_FAILURE ) {
6025 cout << endl <<
"CWB::mdc::GetInspiral - "
6026 <<
"Error in XLALInspiralTDWaveformFromSimInspiral : "
6027 <<
"check inspiral parameters" << endl;
6031 cout << endl <<
"CWB::mdc::GetInspiral - "
6032 <<
"Error - NR_hdf5 not supported for LAL_VERSION < 6.18.0.1" << endl;
6038 #if LAL_VERSION_MAJOR > 6 || (LAL_VERSION_MAJOR == 6 && \
6039 (LAL_VERSION_MINOR > 13 || (LAL_VERSION_MINOR == 13 && \
6040 LAL_VERSION_MICRO >= 2 ))) // LAL_VERSION >= 6.13.2
6043 int ret = XLALInspiralTDWaveformFromSimInspiral(&hp, &hx, thisInj, deltaT);
6044 if( ret==XLAL_FAILURE ) {
6045 cout << endl <<
"CWB::mdc::GetInspiral - "
6046 <<
"Error in XLALInspiralTDWaveformFromSimInspiral : "
6047 <<
"check inspiral parameters" << endl;
6051 cout << endl <<
"CWB::mdc::GetInspiral - "
6052 <<
"Error - LAL_VERSION < 6.13.2 not supported " << endl;
6063 XLALGPSAddGPS(&hp->epoch, &thisInj->geocent_end_time);
6064 XLALGPSAddGPS(&hx->epoch, &thisInj->geocent_end_time);
6068 w.
resize(hp->data->length);
6069 w.
start(hp->epoch.gpsSeconds);
6070 for(
int i=0;i<(
int)w.
size();i++) w[i] = hp->
data->data[i];
6073 w.
resize(hx->data->length);
6074 w.
start(hx->epoch.gpsSeconds);
6075 for(
int i=0;i<(
int)w.
size();i++) w[i] = hx->
data->data[i];
6078 XLALDestroyREAL8TimeSeries(hp);
6079 XLALDestroyREAL8TimeSeries(hx);
6080 hp = NULL; hx = NULL;
6085 if(inspXML==
"") gSystem->Exec(
TString(
"rm ")+injectionFile);
6087 while ( injections ) {
6088 SimInspiralTable *thisInj = NULL;
6089 thisInj = injections;
6090 injections = injections->next;
6094 LALCheckMemoryLeaks();
wavearray< double > t(hp.size())
std::vector< char * > ifoName
detector * getifo(size_t n)
param: detector index
void Dump(TString fname, int ID, int id, TString polarization)
detectorParams getDetectorParams()
waveform GetSourceWaveform(int &ID, int &id)
virtual size_t size() const
static double g(double e)
watplot * Draw(TString name, int id=0, TString polarization="hp", MDC_DRAW type=MDC_TIME, TString options="ALP", Color_t color=kBlack)
size_t add(detector *)
param: detector structure return number of detectors in the network
printf("total live time: non-zero lags = %10.1f \n", liveTot)
static double GetTimeRange(wavearray< double > x, double &tMin, double &tMax, double efraction=EPZOOM)
std::vector< float > psiList
size_t readMDClog(char *, double=0., int=11, int=12)
param: MDC log file param: approximate gps time
TString Get(wavearray< double > &x, TString ifo)
fprintf(stdout,"start=%f duration=%f rate=%f\n", x.start(), x.size()/x.rate(), x.rate())
double min(double x, double y)
std::vector< std::string > mdcList
virtual void rate(double r)
wavearray< double > a(hp.size())
static double GetCentralTime(wavearray< double > x)
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
char * watversion(char c='s')
std::vector< std::string > mdcType
wavearray< double > GetSGQ(double frequency, double Q)
MDC SetSkyDistribution(MDC_CELESTIAL_FIX, par, seed)
static void PhaseShift(wavearray< double > &x, double pShift=0.)
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
unsigned int srcList_seed
void GetSourceCoordinates(double &theta, double &phi, double &psi, double &rho, double &iota, double &hrss, int &ID, int &id)
std::vector< double > gpsList
Complex Exp(double phase)
static void AddExp(wavearray< double > &td, double v, int M)
cout<<"Comparison bkg events above threshold: "<< entriesx<< endl;double *rhox=cnet.GetV1();comph=(TH1D *) gDirectory-> Get("hcomp")
wavearray< double > GetGA(double duration)
std::vector< float > phList
std::vector< std::string > mdcType
std::vector< int > IDList
void setPolarization(POLARIZATION polarization=TENSOR)
virtual void start(double s)
std::vector< size_t > mdc__ID
std::vector< detector * > ifoList
double GetDelay(TString ifo1, TString ifo2, double phi, double theta)
watplot * DrawTime(wavearray< double > &x, TString options="ALP", Color_t color=kBlack)
mdc & operator=(const mdc &)
mdcid AddWaveform(MDC_TYPE mdc_type, vector< mdcpar > par, TString uname="")
std::vector< std::string > nameList
network ** net
NOISE_MDC_SIMULATION.
void Draw(double t1=0.0, double t2=0.0, double f1=0.0, double f2=0.0, double z1=0.0, double z2=0.0, int dpaletteId=DUMMY_PALETTE_ID, Option_t *option="colfz")
void SetSkyDistribution(MDC_DISTRIBUTION sky_distribution, vector< mdcpar > par, int seed=0, bool add=false)
TString GetTemporaryFileName(TString tag="mdc", TString ext="txt", TString dir="/tmp", bool mkdir=false)
dV
Temporay patch for redshifted mass distributions, i.e. point-like in source frame and spread over mul...
double GetPar(TString name, vector< mdcpar > par, bool &error)
int GetWaveformID(TString name)
POLARIZATION getPolarization()
std::vector< std::string > xmlType
void DrawSkyDistribution(TString name="skymap", TString projection="", TString coordinate="Geographic", double resolution=2, bool background=true)
wavearray< double > GetCGQ(double frequency, double Q)
static void AddGauss(wavearray< double > &td, double v, double u=0.)
wavecomplex antenna(double, double, double=0.)
param: source theta,phi, polarization angle psi in degrees
TString WriteFrameFile(TString frDir, TString frLabel, size_t gps, size_t length=1000, bool log=false, vector< TString > chName=vector< TString >())
void DumpLogHeader(TString fName, TString label="", int size=0)
std::vector< std::string > mdcList
cout<< "Injected signals: "<< mdc.GetEntries()<< endl;cout<< "Injected signals in histogram factor_events_inj: "<< NEVTS<< endl;float myifar, ecor, m1, m2, netcc[3], neted, penalty;float rho[2];float chirp[6];float range[2];float frequency[2];float iSNR[3], sSNR[3];sim.SetBranchAddress("mass", mass);sim.SetBranchAddress("factor",&factor);sim.SetBranchAddress("range", range);sim.SetBranchAddress("chirp", chirp);sim.SetBranchAddress("rho", rho);sim.SetBranchAddress("netcc", netcc);sim.SetBranchAddress("neted",&neted);sim.SetBranchAddress("ifar",&myifar);sim.SetBranchAddress("ecor",&ecor);sim.SetBranchAddress("penalty",&penalty);sim.SetBranchAddress("time", mytime);sim.SetBranchAddress("iSNR", iSNR);sim.SetBranchAddress("sSNR", sSNR);sim.SetBranchAddress("spin", spin);sim.SetBranchAddress("frequency", frequency);float **volume=new float *[NBINS_mass1];float **volume_first_shell=new float *[NBINS_mass1];float **radius=new float *[NBINS_mass1];float **error_volume=new float *[NBINS_mass1];float **error_volume_first_shell=new float *[NBINS_mass1];float **error_radius=new float *[NBINS_mass1];for(int i=0;i< NBINS_mass1;i++){volume[i]=new float[NBINS_mass2];volume_first_shell[i]=new float[NBINS_mass2];radius[i]=new float[NBINS_mass2];error_volume[i]=new float[NBINS_mass2];error_volume_first_shell[i]=new float[NBINS_mass2];error_radius[i]=new float[NBINS_mass2];for(int j=0;j< NBINS_mass2;j++){volume[i][j]=0.;volume_first_shell[i][j]=0.;radius[i][j]=0.;error_volume[i][j]=0.;error_volume_first_shell[i][j]=0.;error_radius[i][j]=0.;}}float **spin_mtot_volume=new float *[NBINS_MTOT+1];float **spin_mtot_radius=new float *[NBINS_MTOT+1];float **error_spin_mtot_volume=new float *[NBINS_MTOT+1];float **error_spin_mtot_radius=new float *[NBINS_MTOT+1];for(int i=0;i< NBINS_MTOT+1;i++){spin_mtot_volume[i]=new float[NBINS_SPIN+1];spin_mtot_radius[i]=new float[NBINS_SPIN+1];error_spin_mtot_volume[i]=new float[NBINS_SPIN+1];error_spin_mtot_radius[i]=new float[NBINS_SPIN+1];for(int j=0;j< NBINS_SPIN+1;j++){spin_mtot_volume[i][j]=0.;error_spin_mtot_volume[i][j]=0.;spin_mtot_radius[i][j]=0.;error_spin_mtot_radius[i][j]=0.;}}char fname[1024];sprintf(fname,"%s/recovered_signals.txt", netdir);ofstream fev;fev.open(fname, std::ofstream::out);sprintf(line,"#GPS@L1 FAR[Hz] eFAR[Hz] Pval ""ePval factor rho frequency iSNR sSNR \n");fev<< line<< endl;ofstream *fev_single=new ofstream[nfactor];for(int l=1;l< nfactor+1;l++){sprintf(fname,"%s/recovered_signals_%d.txt", netdir, l);fev_single[l-1].open(fname, std::ofstream::out);fev_single[l-1]<< line<< endl;}double Vrho[RHO_NBINS], eVrho[RHO_NBINS], Rrho[RHO_NBINS], eRrho[RHO_NBINS], Trho[RHO_NBINS];for(int i=0;i< RHO_NBINS;i++){Vrho[i]=0.;eVrho[i]=0.;Rrho[i]=0.;eRrho[i]=0.;Trho[i]=RHO_MIN+i *RHO_BIN;}double dV, dV1, dV_spin_mtot, nevts, internal_volume;int nT;int countv=0;int cnt=0;int cnt2=0;int cntfreq=0;bool bcut=false;double liveTot=sim.GetMaximum("ifar");double BKG_LIVETIME_yr=liveTot/CYS;double BKG_LIVETIME_Myr=BKG_LIVETIME_yr/(1.e6);cout.precision(14);cout<< "Total live time ---> background
MDC TimeShift(MDC.wfList[14].hx, 0.001)
const char * DistributionToString(MDC_DISTRIBUTION n)
TString GetBurst(wavearray< double > &x, TString ifo)
wavearray< double > GetWNB(double frequency, double bandwidth, double duration, int seed=0, bool mode=0)
void Dump(WSeries< double > &w, double t1, double t2, const char *fname)
double RA2phi(double ph, double gps)
std::vector< int > idList
double GetCentralFrequency(wavearray< double > x)
void DrawTF(wavearray< double > &x, TString options="")
watplot * DrawFFT(wavearray< double > &x, TString options="ALP", Color_t color=kBlack)
double GetCentralTime(wavearray< double > x)
vector< waveform > wfList
static double cosi2e(double cosi)
static void AddCGBurst(wavearray< double > &td, double a, double f, double s, double d=0.)
TString GetBurstLog(source src, double FrameGPS, double SimHpHp, double SimHcHc, double SimHpHc)
double GravitationalConstant()
static void TimeShift(wavearray< double > &x, double tShift=0.)
MDC_COORDINATES mdc_coordinates
static void AddWGNoise(wavearray< double > &td, double a, double s)
std::vector< std::string > mdcName
MDC_DISTRIBUTION sky_distribution
std::vector< float > rhoList
vector< source > GetSourceList(double start, double stop)
int getEBBH(double m1, double m2, double rmin0, double e0, wavearray< double > &Hp, wavearray< double > &Hx, double t_end)
double fabs(const Complex &x)
wavearray< double > GetWaveform(int ifoId, network *NET, int lag, int id, char type, bool shift=true)
void resample(const wavearray< DataType_t > &, double, int=6)
waveform GetWaveform(int ID, int id=0)
void ReadWaveform(wavearray< double > &x, TString fName, double srate)
strcpy(RunLabel, RUN_LABEL)
static double e2cosi(double e)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
void GalacticToEquatorial(double ilongitude, double ilatitude, double &olongitude, double &olatitude)
double getTau(double, double)
param: source theta,phi angles in degrees
double distance_source_Kpc
TString GetParString(TString name, vector< mdcpar > par, bool &error)
std::vector< double > hrssList
std::vector< float > iotaList
MDC AddWaveform(MDC_SGC, par)
void DumpLog(TString fName, TString label="", bool append=false)
std::vector< source > srcList
static double GetCentralFrequency(wavearray< double > x)
#define MNGD_SOLAR_SISTEM_DISTANCE_FROM_GC
double GetAntennaPattern(TString ifo, double phi, double theta, double psi=0., TString polarization="hp")
void GeographicToCwb(double ilongitude, double ilatitude, double &olongitude, double &olatitude)
std::vector< double > mdcTime
MDC DumpLog("GHLTV-GWGC_v1-968600000-300000.root","CIAO")
wavearray< double > GetRD(double frequency, double tau, double iota, bool polarization=0)
for(int i=0;i< 101;++i) Cos2[2][i]=0
virtual void resize(unsigned int)
TString frLabel[NIFO_MAX]
static void AddSGBurst(wavearray< double > &td, double a, double f, double s, double d=0.)
std::vector< float > thList
MDC SetInspiral("inspNameTEST", inspOptions)
double SpeedOfLightInVacuo()