23 #define PE_MAX_EVENTS 100 71 #define CCUT_WDM_FRES 16 // the WDM freq resolution used to decompose the signal in TF domain 72 #define CCUT_BCHIRP 1.40 // mchirp factor used to select the upper region boundary Mc=Mc.ccut_bchirp 73 #define CCUT_UCHIRP 1.60 // mchirp factor used to select the upper region boundary Mc=Mc.ccut_uchirp 74 #define CCUT_LTIME 0.5 // left time from tcoa (sec) used to select the the time region: [tcoa-left_time:tcoa-right_time] 75 #define CCUT_RTIME 0.0 // right time from tcoa (sec) used to select the the time region: [tcoa-left_time:tcoa-right_time] 108 TFile*
froot =
new TFile(ifname,
"READ");
110 cout <<
"Error : Failed to open file : " << ifname << endl;
113 TTree*
itree = (TTree*)froot->Get(
"waveburst");
115 cout <<
"Error : Failed to open tree waveburst from file : " << ifname << endl;
123 for(
int i=0;i<N_IFO;i++) sample_wREC[i] = new wavearray<double>;
126 for(
int i=0;i<N_IFO;i++) sample_wINJ[i] = new wavearray<double>;
128 double* time =
new double[2*
N_IFO];
135 string*
log =
new string;
138 for(
int k=0;
k<itree->GetEntries();
k++) {
140 for(
int i=0;
i<
N_IFO;
i++) itree->SetBranchAddress(TString::Format(
"wREC_%d",
i).Data(),&sample_wREC[
i]);
141 for(
int i=0;
i<
N_IFO;
i++) itree->SetBranchAddress(TString::Format(
"wINJ_%d",
i).Data(),&sample_wINJ[
i]);
142 itree->SetBranchAddress(
"time",time);
143 itree->SetBranchAddress(
"theta",theta);
144 itree->SetBranchAddress(
"phi",phi);
145 itree->SetBranchAddress(
"rho",rho);
146 itree->SetBranchAddress(
"likelihood",&likelihood);
147 itree->SetBranchAddress(
"wf_tcoa",&tcoa);
148 itree->SetBranchAddress(
"log",&log);
153 wREC[
gEVENTS].push_back(*sample_wREC[
i]);
154 wINJ[
gEVENTS].push_back(*sample_wINJ[i]);
161 ifar/=(24.*3600.*365.);
172 double mc = pow(m1.Atof()*m2.Atof(),3./5.)/pow(m1.Atof()+m2.Atof(),1./5.);
173 cout <<
gEVENTS <<
" m1 " << m1 <<
" m2 " << m2 <<
" mc " << mc <<
" ifar " << ifar <<
" (years) " << endl;
180 cout <<
"Error : max wf_id = " <<
gEVENTS-1 << endl;
184 cout << endl <<
"RHO " <<
wRHO[wf_id] << endl << endl;
187 int ccut_wdm_levels =
int(wREC[wf_id][ifo_id].
rate()/gOPT.ccut_wdm_fres/2);
188 cout << endl <<
"RATE " << wREC[wf_id][ifo_id].rate() <<
" WDM levels " << ccut_wdm_levels << endl << endl;
189 gWDM =
new WDM<double>(ccut_wdm_levels, ccut_wdm_levels, 6, 10);
191 vector<double> vtcoa(
N_IFO);
194 cout << n <<
"\t" <<
int(wINJ[wf_id][n].
start()) <<
"\t" << vtcoa[
n]-wINJ[wf_id][
n].start() << endl;
200 double sync_phase=0, sync_time=0, sync_xcor=0;
203 cout <<
"sync_time " << sync_time <<
" sync_phase " << sync_phase <<
" sync_xcor " << sync_xcor << endl;
223 std::vector<wavearray<double> >
vREC(N_IFO);
224 std::vector<wavearray<double> >
vINJ(N_IFO);
226 vINJ[
n] = wINJ[wf_id][ifo_id];
227 vREC[
n] = wREC[wf_id][ifo_id];
232 for(
int n=0;
n<
N_IFO;
n++) tstart[
n]-=0.25;
234 cout <<
"FF -> " << FF << endl;
236 cout <<
"RE -> " << RE << endl;
238 #ifdef APPLY_BANDPASS 247 wINJ[wf_id][ifo_id] =
GetCCut(&wINJ[wf_id][ifo_id], vtcoa[ifo_id]-wINJ[wf_id][ifo_id].
start(),
wM1[wf_id],
wM2[wf_id],
wS1[wf_id],
wS2[wf_id]);
248 cout <<
"-------> APPLY_CCUT wINJ Energy (time domain phase 00) -------> " << pow(wINJ[wf_id][ifo_id].rms(),2)*wINJ[wf_id][ifo_id].size() << endl;
253 wREC[wf_id][ifo_id] =
GetCCut(&wREC[wf_id][ifo_id], vtcoa[ifo_id]-wREC[wf_id][ifo_id].
start(),
wM1[wf_id],
wM2[wf_id],
wS1[wf_id],
wS2[wf_id]);
254 cout <<
"-------> APPLY_CCUT wREC Energy (time domain phase 00) -------> " << pow(wREC[wf_id][ifo_id].rms(),2)*wREC[wf_id][ifo_id].size() << endl;
260 cout <<
"-------> APPLY_CCUT wDIF Energy (time domain phase 00) -------> " << pow(wDIF.
rms(),2)*wDIF.
size() << endl;
265 cout <<
"END " << endl;
272 MDC->
DrawFFT(wINJ[wf_id][ifo_id],
"ALP ZOOM");
273 MDC->
DrawFFT(wREC[wf_id][ifo_id],
"SAME",kRed);
277 wINJ[wf_id][ifo_id].start(0);
278 wREC[wf_id][ifo_id].start(0);
279 MDC->
DrawTime(wINJ[wf_id][ifo_id],
"ALP ZOOM");
281 MDC->
DrawTime(wREC[wf_id][ifo_id],
"SAME",kRed);
289 vINJ[ifo_id].start(0);
290 vREC[ifo_id].start(0);
292 MDC->
DrawTime(vINJ[ifo_id],
"ALP ZOOM");
293 MDC->
DrawTime(vREC[ifo_id],
"SAME",kRed);
297 DrawCCut(&wINJ[wf_id][ifo_id], vtcoa[ifo_id]-wINJ[wf_id][ifo_id].
start(),
wM1[wf_id],
wM2[wf_id],
wS1[wf_id],
wS2[wf_id]);
300 DrawCCut(&wREC[wf_id][ifo_id], vtcoa[ifo_id]-wINJ[wf_id][ifo_id].
start(),
wM1[wf_id],
wM2[wf_id],
wS1[wf_id],
wS2[wf_id]);
314 double tdelay = MDC.
GetDelay(ifo,
"",phi,theta);
315 double ifo_tcoa = geocentric_tcoa+tdelay;
324 for(
int i=0;
i<token->GetEntries();
i++) {
325 TObjString* otoken = (TObjString*)token->At(
i);
326 TString stoken = otoken->GetString();
329 if(i<token->GetEntries()-1) {
330 if(stoken==
"spin1" || stoken==
"spin2") {
331 otoken = (TObjString*)token->At(
i+3);
332 return otoken->GetString();
334 otoken = (TObjString*)token->At(
i+1);
335 return otoken->GetString();
340 if(token)
delete token;
365 if(token->GetEntries()!=5) {
367 cout <<
"cwb_pereport - Error : ccut format - must be: wdm_fres:bchirp:uchirp:ltime:rtime" << endl;
368 cout <<
" Default setup is: 16:1.35:1.65:0.5:0.0" << endl;
369 cout <<
" To setup a default value use *" << endl;
370 cout <<
" Example: *:1.25:1.75:*:*" << endl;
374 for(
int j=0;
j<token->GetEntries();
j++) {
375 TObjString* tok = (TObjString*)token->At(
j);
376 TString stok = tok->GetString();
378 if(stok==
"*")
continue;
382 if(wdm_fres.IsDigit()) gOPT.ccut_wdm_fres=wdm_fres.Atoi();
383 else {cout<<
"cwb_pereport - Error : wdm_fres is not integer"<<endl;
exit(1);}
387 if(mc_lower_factor.IsFloat()) gOPT.ccut_bchirp=mc_lower_factor.Atof();
388 else {cout<<
"cwb_pereport - Error : mc_lower_factor is not float"<<endl;
exit(1);}
392 if(mc_upper_factor.IsFloat()) gOPT.ccut_uchirp=mc_upper_factor.Atof();
393 else {cout<<
"cwb_pereport - Error : mc_upper_factor is not float"<<endl;
exit(1);}
397 if(left_time.IsFloat()) gOPT.ccut_ltime=left_time.Atof();
398 else {cout<<
"cwb_pereport - Error : left_time is not float"<<endl;
exit(1);}
402 if(right_time.IsFloat()) gOPT.ccut_rtime=right_time.Atof();
403 else {cout<<
"cwb_pereport - Error : right_time is not float"<<endl;
exit(1);}
407 int x=gOPT.ccut_wdm_fres;
408 if(!((x != 0) && ((x & (~x + 1)) == x)) || gOPT.ccut_wdm_fres<=0) {
409 cout<<
"cwb_pereport : upTDF parameter non valid : must be power of 2 : "<<gOPT.ccut_wdm_fres<<endl;
412 if(gOPT.ccut_bchirp < 0) {
413 cout<<
"cwb_pereport - Error :.ccut_bchirp must be >= 0"<<endl;
416 if(gOPT.ccut_bchirp > gOPT.ccut_uchirp) {
417 cout<<
"cwb_pereport - Error :.ccut_bchirp must be < ccut_uchirp"<<endl;
420 if(gOPT.ccut_rtime < 0) {
421 cout<<
"cwb_pereport - Error :.ccut_rtime >=0"<<endl;
424 if(gOPT.ccut_ltime < gOPT.ccut_rtime) {
425 cout<<
"cwb_pereport - Error :.ccut_ltime must be >.ccut_rtime"<<endl;
433 const auto&
fchirp =
static_cast<double(*)(
double,
double,
double,
double,
double)
>(CWB::mdc::SimIMRSEOBNRv4ROMFrequencyOfTime);
434 const auto& tchirp =
static_cast<double(*)(
double,
double,
double,
double,
double)
>(CWB::mdc::SimIMRSEOBNRv4ROMTimeOfFrequency);
441 double fmax= ts->
rate()/2.>320 ? 320. : ts->
rate()/2.;
446 double dF = (fmax-fmin)/
nPx;
448 double F = fmin+
i*dF;
449 Fb[
i] = gOPT.ccut_bchirp*
F;
450 Fu[
i] = gOPT.ccut_uchirp*
F;
451 T[
i] = tcoa-tchirp(F,m1,m2,s1z,s2z);
453 TSpline3 tbchirp(
"tbchirp",Fb,T,nPx);
454 TSpline3 tuchirp(
"tuchirp",Fu,T,nPx);
455 TSpline3
fbchirp(
"fbchirp",T,Fb,nPx);
456 TSpline3
fuchirp(
"fuchirp",T,Fu,nPx);
459 double dt = 1./(2*
df);
464 double tl = tcoa-gOPT.ccut_ltime;
465 double tr = tcoa-gOPT.ccut_rtime;
473 double tm = time-dt/2;
474 double tM = time+dt/2;
476 if(tm<tl-dt || tM>tr+dt) {
484 double fb = fbchirp.Eval(time);
485 double fu = fuchirp.Eval(time);
487 if(TMath::IsNaN(fb)) fb = ts->
rate()/2.;
488 if(TMath::IsNaN(fu)) fu = ts->
rate()/2.;
490 double f1 = fbchirp.Eval(tm);
491 double f2 = fbchirp.Eval(tM);
492 double f3 = fuchirp.Eval(tm);
493 double f4 = fuchirp.Eval(tM);
499 double fm = freq-df/2;
500 double fM = freq+df/2;
502 if(fm<fmin || fM>fmax) {
508 double t1 = tbchirp.Eval(fm);
509 double t2 = tbchirp.Eval(fM);
510 double t3 = tuchirp.Eval(fm);
511 double t4 = tuchirp.Eval(fM);
514 bool ctime = (tM>tl && tm<tr) ?
true :
false;
517 bool cfreq = (fM>fb && fm<fu) ?
true :
false;
519 double x1=
t1,x2=t2,x3=t3,x4=t4,xm=tm,xM=tM;
520 double y1=f1,y2=
f2,y3=f3,y4=f4,ym=fm,yM=fM;
523 if(tl>tm && tl<tM) {xm=tl; f1 = fbchirp.Eval(xm); f3 = fuchirp.Eval(xm);}
524 if(tr>tm && tr<tM) {xM=tr; f2 = fbchirp.Eval(xM); f4 = fuchirp.Eval(xM);}
526 y1=f1,y2=
f2,y3=f3,y4=f4;
533 if(t1>xm && t1<xM) cline=
true;
534 if(t2>xm && t2<xM) cline=
true;
535 if(t3>xm && t3<xM) cline=
true;
536 if(t4>xm && t4<xM) cline=
true;
538 if(f1>ym && f1<yM) cline=
true;
539 if(f2>ym && f2<yM) cline=
true;
540 if(f3>ym && f3<yM) cline=
true;
541 if(f4>ym && f4<yM) cline=
true;
543 double Ap=(xM-xm)*(yM-ym);
548 if(y1<ym) y1=ym;
if(y1>yM) y1=yM;
549 if(y2<ym) y2=ym;
if(y2>yM) y2=yM;
550 if(y3<ym) y3=ym;
if(y3>yM) y3=yM;
551 if(y4<ym) y4=ym;
if(y4>yM) y4=yM;
558 if(t1<xm) {x1=xm; y1 = fbchirp.Eval(x1);}
559 if(t1>xM) {x1=xM; y1 = fbchirp.Eval(x1);}
560 if(t2<xm) {x2=xm; y2 = fbchirp.Eval(x2);}
561 if(t2>xM) {x2=xM; y2 = fbchirp.Eval(x2);}
564 if(y1<ym) y1=ym;
if(y1>yM) y1=yM;
565 if(y2<ym) y2=ym;
if(y2>yM) y2=yM;
568 if(y1 >ym && y2==yM) Ab = (x2-xm)*(yM-y1)/2;
569 if(y1 >ym && y2 <yM) Ab = (xM-xm)*(yM-y2)+(xM-xm)*(y2-y1)/2;
570 if(y1==ym && y2==yM) Ab = (x1-xm)*(yM-ym)+(x2-x1)*(yM-ym)/2;
571 if(y1==ym && y2 <yM) Ab = Ap-(xM-x1)*(y2-ym)/2;
578 if(t3<xm) {x3=xm; y3 = fuchirp.Eval(x3);}
579 if(t3>xM) {x3=xM; y3 = fuchirp.Eval(x3);}
580 if(t4<xm) {x4=xm; y4 = fuchirp.Eval(x4);}
581 if(t4>xM) {x4=xM; y4 = fuchirp.Eval(x4);}
584 if(y3<ym) y3=ym;
if(y3>yM) y3=yM;
585 if(y4<ym) y4=ym;
if(y4>yM) y4=yM;
588 if(y3 >ym && y4==yM) Au = Ap-(x4-xm)*(yM-y3)/2;
589 if(y3 >ym && y4 <yM) Au = (xM-xm)*(y3-ym)+(xM-xm)*(y4-y3)/2;
590 if(y3==ym && y4==yM) Au = (xM-x4)*(yM-ym)+(x4-x3)*(yM-ym)/2;
591 if(y3==ym && y4 <yM) Au = (xM-x3)*(y4-ym)/2;
593 if(Ab<0) Ab=0;
if(Ab>Ap) Ab=Ap;
594 if(Au<0) Au=0;
if(Au>Au) Au=Au;
595 double A = Ab+Au; A-=Ap;
597 if(A<0) {cout <<
"GetCCut Warning: pixel area < 0 " << endl; A=0;}
598 if(A>Ap) {cout <<
"GetCCut Warning: pixel area > Ap " << endl; A=Ap;}
599 double R=sqrt(A/0.5);
602 TString sR = TString::Format(
"A - GetCCut Rescaling Factor: Ap %0.3f %0.3f %0.3f %0.3f \ttime %0.3f \tfreq %0.3f \tR %0.9f \t%s",Ap,Ab,Au,A,time,freq,R,tag.Data());
609 if((ctime && cfreq) && !cline) {
611 double R = (x4<=tl || x1>=tr) ? 0 : sqrt(Ap/0.5);
616 TString sR = TString::Format(
"B - GetCCut Rescaling Factor: Ap %0.3f \ttime %0.3f \tfreq %0.3f \tR %0.3f \t%s",Ap,time,freq,R,tag.Data());
626 if((ctime && cline)||(ctime && cfreq)) {
639 Et+=(a00*a00+a90*a90)/2;
643 cout <<
"GetCCut Energy chirp cut (TF domain): " << Et << endl;
646 DrawCCut(W, tcoa, m1, m2, s1z, s2z);
661 const auto&
fchirp =
static_cast<double(*)(
double,
double,
double,
double,
double)
>(CWB::mdc::SimIMRSEOBNRv4ROMFrequencyOfTime);
662 const auto& tchirp =
static_cast<double(*)(
double,
double,
double,
double,
double)
>(CWB::mdc::SimIMRSEOBNRv4ROMTimeOfFrequency);
669 double D = G*SM/C/C/
C;
672 double tmin=tmax-0.5;
675 double fmax= W.
rate()/2.>320 ? 320. : W.
rate()/2.;
680 double dF = (fmax-fmin)/
nPx2;
682 double F = fmin+
i*dF;
683 Fb[
i] = gOPT.ccut_bchirp*
F;
684 Fu[
i] = gOPT.ccut_uchirp*
F;
685 T[
i] = tcoa-tchirp(F,m1,m2,s1z,s2z);
687 TSpline3 tbchirp(
"tbchirp",Fb,T,nPx2);
688 TSpline3 tuchirp(
"tuchirp",Fu,T,nPx2);
689 TSpline3
fbchirp(
"fbchirp",T,Fb,nPx2);
690 TSpline3
fuchirp(
"fuchirp",T,Fu,nPx2);
693 TString wplot_id=TString::Format(
"%d",
int(gRandom->Uniform(0,10000000)));
697 wplot->
hist2D->GetXaxis()->SetRangeUser(6.4,7.2);
698 wplot->
hist2D->GetYaxis()->SetRangeUser(0,600);
699 wplot->
hist2D->GetYaxis()->SetRangeUser(30,600);
702 double dxb=(tmax-tmin)/
nPX2;
706 yb[
i]=fbchirp.Eval(xb[
i]);
708 TGraph* grb =
new TGraph(nPX2,xb,yb);
709 grb->SetLineColor(kWhite);
710 grb->SetLineWidth(3);
711 grb->SetLineStyle(2);
715 double dxu=(tmax-tmin)/nPX2;
719 yu[
i]=fuchirp.Eval(xu[
i]);
721 TGraph* gru =
new TGraph(nPX2,xu,yu);
722 gru->SetLineColor(kWhite);
723 gru->SetLineWidth(3);
724 gru->SetLineStyle(2);
730 p0 = tcoa-gOPT.ccut_ltime;
731 flchirp =
new TLine(p0,0,p0,600);
738 p0 = tcoa-gOPT.ccut_rtime;
739 frchirp =
new TLine(p0,0,p0,600);
747 ftcoa =
new TLine(p0,0,p0,600);
748 ftcoa->SetLineColor(kRed);
749 ftcoa->SetLineWidth(2);
750 ftcoa->SetLineStyle(1);
std::vector< wavearray< double > > vREC
virtual void rate(double r)
void putSample(DataType_t a, int n, double m)
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<< "\ layers : "<< nLAYERS<< "\ dF(hz) : "<< dF<< "\ 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
std::vector< wavearray< double > > vINJ
void plot(wavearray< double > &, char *=NULL, int=1, double=0., double=0., bool=false, float=0., float=0., bool=false, float=0., bool=false)
std::vector< wavearray< double > > wREC[PE_MAX_EVENTS]
double GetDelay(TString ifo1, TString ifo2, double phi, double theta)
watplot * DrawTime(wavearray< double > &x, TString options="ALP", Color_t color=kBlack)
virtual size_t size() const
static double GetMatchFactor(TString match, vector< wavearray< double > > &w1, vector< wavearray< double > > &w2, vector< double > tstart=DEFAULT_VECtOR_DOUBLE, vector< double > tstop=DEFAULT_VECtOR_DOUBLE)
static wavearray< double > GetEnvelope(wavearray< double > *x)
wavearray< double > GetCCut(wavearray< double > *ts, double tcoa, double m1, double m2, double s1z, double s2z)
TString GetParameterFromInjLog(TString log, TString param)
void GetCCutParms(TString options)
double GetInjTcoa(double geocentric_tcoa, network *NET, TString ifo, double theta, double phi)
void DrawCCut(wavearray< double > *ts, double tcoa, double m1, double m2, double s1z, double s2z)
float wTHETA[PE_MAX_EVENTS]
std::vector< wavearray< double > > wINJ[PE_MAX_EVENTS]
static wavearray< double > GetBandpass(wavearray< double > x, double bF, double eF)
watplot * DrawFFT(wavearray< double > &x, TString options="ALP", Color_t color=kBlack)
double GravitationalConstant()
static wavearray< double > GetDiff(wavearray< double > *w1, wavearray< double > *w2)
wavearray< double > ts(N)
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
float wRHO[PE_MAX_EVENTS]
static double TimePhaseSync(wavearray< double > &w1, wavearray< double > &w2, double &sync_time, double &sync_phase)
DataType_t getSample(int n, double m)
double wTCOA[PE_MAX_EVENTS]
void Inverse(int n=-1)
param: n - number of steps (-1 means full reconstruction)
float wPHI[PE_MAX_EVENTS]
double SpeedOfLightInVacuo()
void DrawCCutxPE(TString ifname, int wf_id=0, int ifo_id=0, TString options="16:1.40:1.60:0.5:0.0")