3 #pragma GCC system_header
10 #include "TObjArray.h"
11 #include "TObjString.h"
25 #define MDC_OTF // enable MDC On The Fly
26 #define NOISE_OTF // enable NOISE On The Fly
34 double& enINJ,
double& enREC,
double& xcorINJ_REC);
51 cout <<
"-----> CWB_Plugin_WRC.C" << endl;
52 cout <<
"ifo " << ifo.Data() << endl;
53 cout <<
"type " << type << endl;
73 if(ifo.CompareTo(
"L1")==0) seed=1000;
74 if(ifo.CompareTo(
"H1")==0) seed=2000;
75 if(ifo.CompareTo(
"V1")==0) seed=3000;
76 if(ifo.CompareTo(
"J1")==0) seed=4000;
77 if(ifo.CompareTo(
"A2")==0) seed=5000;
78 if(ifo.CompareTo(
"Y2")==0) seed=6000;
79 if(ifo.CompareTo(
"Y3")==0) seed=7000;
82 if(ifo.CompareTo(
"L1")==0) fName=
"plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
83 if(ifo.CompareTo(
"H1")==0) fName=
"plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
84 if(ifo.CompareTo(
"V1")==0) fName=
"plugins/strains/advVIRGO_sensitivity_12May09_8khz_one_side.txt";
85 if(ifo.CompareTo(
"J1")==0) fName=
"plugins/strains/LCGT_sensitivity_8khz_one_side.txt";
86 if(ifo.CompareTo(
"A2")==0) fName=
"plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
87 if(ifo.CompareTo(
"Y2")==0) fName=
"plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
88 if(ifo.CompareTo(
"Y3")==0) fName=
"plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
102 sprintf(cmd,
"network* net = (network*)%p;",NET);
103 gROOT->ProcessLine(cmd);
130 if(ifo.CompareTo(NET->
ifoName[0])==0) {
141 for(
int k=0;
k<(
int)NET->
mdcTime.size();
k++) cout <<
k <<
" mdcTime " << MDC.
mdcTime[
k] << endl;
142 for(
int k=0;
k<(
int)NET->
mdcType.size();
k++) cout <<
k <<
" mdcType " << MDC.
mdcType[
k] << endl;
149 cout <<
"CWB_Plugin_WRC.C -> CWB_PLUGIN_OLIKELIHOOD implemented only for 2G" << endl;
155 cout <<
"-----> CWB_Plugin_WRC.C -> " <<
" gIFACTOR : " << gIFACTOR << endl;
158 float* gSLAGSHIFT=NULL;
IMPORT(
float*,gSLAGSHIFT)
169 TList *
files = (TList*)gROOT->GetListOfFiles();
176 while ((file=(TSystemFile*)
next())) {
177 fname = file->GetName();
179 if(fname.Contains(
"wave_")) {
180 froot=(TFile*)file;froot->cd();
182 outDump.ReplaceAll(
".root.tmp",
".txt");
183 cout <<
"output file name : " << fname << endl;
187 cout <<
"CWB_Plugin_WRC.C : Error - output root file not found" << endl;
191 cout <<
"CWB_Plugin_WRC.C : Error - output root file not found" << endl;
196 char ciSNR[16];
sprintf(ciSNR,
"_iSNR[%1d]/F",nIFO);
197 char coSNR[16];
sprintf(coSNR,
"_oSNR[%1d]/F",nIFO);
198 char cioSNR[16];
sprintf(cioSNR,
"_ioSNR[%1d]/F",nIFO);
203 TTree*
net_tree = (TTree *) froot->Get(
"waveburst");
206 #ifdef SAVE_EVT_CLUSTER
207 net_tree->SetBranchAddress(
"netcluster",&pwc);
210 net_tree->SetBranchAddress(
"_iSNR",iSNR);
211 net_tree->SetBranchAddress(
"_oSNR",oSNR);
212 net_tree->SetBranchAddress(
"_ioSNR",ioSNR);
217 #ifdef SAVE_EVT_CLUSTER
219 net_tree->Branch(
"netcluster",
"netcluster",&pwc,32000,0);
222 net_tree->Branch(
"_iSNR",iSNR,ciSNR);
223 net_tree->Branch(
"_oSNR",oSNR,coSNR);
224 net_tree->Branch(
"_ioSNR",ioSNR,cioSNR);
229 for(
int k=0;
k<
K;
k++) {
235 int ID = size_t(
id.data[
j]+0.5);
248 double recTime = EVT->
time[0];
249 double injTh = EVT->
theta[1];
250 double injPh = EVT->
phi[1];
251 double recTh = EVT->
theta[0];
252 double recPh = EVT->
phi[0];
257 double injTime = 1.e12;
259 for(
int m=0;
m<
M;
m++) {
262 if(T<injTime && INJ.
fill_in(NET,mdcID)) {
273 int idSize = pd->
RWFID.size();
275 for(
int mm=0; mm<idSize; mm++)
if (pd->
RWFID[mm]==ID) wfIndex=mm;
282 pwfINJ[
n] = INJ.
pwf[
n];
283 if (pwfINJ[
n]==NULL) {
284 cout <<
"CWB_Plugin_WRC.C : Error : Injected waveform not saved !!! : detector "
289 cout <<
"CWB_Plugin_WRC.C : Error : Reconstructed waveform not saved !!! : ID -> "
290 << ID <<
" : detector " << NET->
ifoName[
n] << endl;
294 if (wfIndex>=0) pwfREC[
n] = pd->
RWFP[wfIndex];
302 double enINJ, enREC, xcorINJ_REC;
314 ioSNR[
n] = xcorINJ_REC;
323 if(INJ.
fill_in(NET,-(injID+1))) {
328 int idSize = pd->
RWFID.size();
330 for(
int mm=0; mm<idSize; mm++)
if (pd->
RWFID[mm]==-ID) wfIndex=mm;
336 pwfINJ[
n] = INJ.
pwf[
n];
337 if (pwfINJ[
n]==NULL) {
338 cout <<
"CWB_Plugin_WRC.C : Error : Injected waveform not saved !!! : detector "
343 cout <<
"CWB_Plugin_WRC.C : Error : Reconstructed waveform not saved !!! : ID -> "
344 << ID <<
" : detector " << NET->
ifoName[
n] << endl;
348 if (wfIndex>=0) pwfREC[
n] = pd->
RWFP[wfIndex];
362 double enINJ, enREC, xcorINJ_REC;
370 ioSNR[
n] = xcorINJ_REC;
388 if(cfg->
dump) EVT->
dopen(outDump.Data(),
const_cast<char*
>(
"a"),
false);
389 EVT->
output2G(net_tree,NET,ID,
k,ofactor);
393 #ifdef SAVE_MRA_PLOT // monster event display
402 if(iSNR)
delete []
iSNR;
403 if(oSNR)
delete []
oSNR;
404 if(ioSNR)
delete []
ioSNR;
412 double& enINJ,
double& enREC,
double& xcorINJ_REC) {
414 double bINJ = wfINJ->
start();
415 double eINJ = wfINJ->
stop();
416 double bREC = wfREC->
start();
417 double eREC = wfREC->
stop();
422 double R=wfINJ->
rate();
424 int oINJ = bINJ>bREC ? 0 :
int((bREC-bINJ)*R+0.5);
425 int oREC = bINJ<bREC ? 0 :
int((bINJ-bREC)*R+0.5);
428 double startXCOR = bINJ>bREC ? bINJ : bREC;
429 double endXCOR = eINJ<eREC ? eINJ : eREC;
430 int sizeXCOR =
int((endXCOR-startXCOR)*R+0.5);
437 if (sizeXCOR<=0)
return;
441 for (
int i=0;
i<sizeXCOR;
i++) enREC+=wfREC->
data[
i+oREC]*wfREC->
data[
i+oREC];
442 for (
int i=0;
i<sizeXCOR;
i++) xcorINJ_REC+=wfINJ->
data[
i+oINJ]*wfREC->
data[
i+oREC];
444 double erINJ_REC = enINJ+enREC-2*xcorINJ_REC;
445 cout <<
"enINJ : " << enINJ <<
" enREC : " << enREC
446 <<
" xcorINJ_REC : " << xcorINJ_REC <<
" enINJREC : " << enINJ+enREC-2*xcorINJ_REC << endl;
454 double f_low = cfg->
fLow;
455 double f_high = cfg->
fHigh;
456 cout <<
"f_low : " << f_low <<
" f_high : " << f_high << endl;
458 double Fs=((double)wf->
rate()/(double)wf->
size())/2.;
459 for (
int j=0;
j<wf->
size();
j+=2) {
461 if((f<f_low)||(f>f_high)) {wf->
data[
j]=0.;wf->
data[
j+1]=0.;}
474 sprintf(fname,
"l_tfmap_scalogram_%d.png",ID);
475 cout <<
"write " << fname << endl;
495 PTS.
graph[0]->SetLineWidth(1);
501 PTS.
graph[1]->SetLineWidth(2);
506 if(fft)
sprintf(label,
"%s",
"fft");
507 else sprintf(label,
"%s",
"time");
508 if(strain)
sprintf(label,
"%s_%s",label,
"strain");
509 else sprintf(label,
"%s_%s",label,
"white");
512 sprintf(fname,
"%s_wf_%s_inj_rec_gps_%d.root",ifo.Data(),
label,
int(tmin));
514 cout <<
"write : " << fname << endl;
527 double optRate = (pwc->
cRate[ID-1])[0];
528 double optLayer = pwc->
rate/optRate;
529 double optLevel =
int(log10(optLayer)/log10(2));
531 double bINJ = wfINJ->
start();
532 double eINJ = wfINJ->
stop();
533 double bREC = wfREC->
start();
534 double eREC = wfREC->
stop();
539 double R=wfINJ->
rate();
541 int oINJ = bINJ>bREC ? 0 :
int((bREC-bINJ)*R+0.5);
542 int oREC = bINJ<bREC ? 0 :
int((bINJ-bREC)*R+0.5);
545 double startXCOR = bINJ>bREC ? bINJ : bREC;
546 double endXCOR = eINJ<eREC ? eINJ : eREC;
547 int sizeXCOR =
int((endXCOR-startXCOR)*R+0.5);
551 if (sizeXCOR<=0)
return;
559 int xcor_length = sizeXCOR/wfINJ->
rate();
560 int wts_size = xcor_length<8 ? 16 : 16*
int(1+xcor_length/8.);
561 wts_size*=wfINJ->
rate();
565 double wts_start,wts_stop;
575 for(
int m=0;
m<sizeXCOR;
m++)
585 cout <<
"Print " << fname << endl;
588 wts_stop = sizeXCOR<wts_size/2 ? wts_start+sizeXCOR/
wINJ.
rate() : wts_start+(wts_size/2)/
wINJ.
rate();
590 WTS.
hist2D->GetYaxis()->SetRangeUser(EVT->
low[ifoID], EVT->
high[ifoID]);
603 for (
int m=0;
m<sizeXCOR;
m++)
613 cout <<
"Print " << fname << endl;
614 wts_start =
wREC.start()+(double)(wts_size/2)/
wREC.rate();
615 wts_stop = sizeXCOR<wts_size/2 ? wts_start+sizeXCOR/
wREC.rate() : wts_start+(wts_size/2)/
wREC.rate();
617 WTS.
hist2D->GetYaxis()->SetRangeUser(EVT->
low[ifoID], EVT->
high[ifoID]);
630 for (
int m=0;
m<sizeXCOR;
m++)
638 cout <<
"Print " << fname << endl;
639 if(NET->
getwdm(optLayer+1)) wDIF.Forward(wDIF,*NET->
getwdm(optLayer+1));
640 wts_start = wDIF.start()+(double)(wts_size/2)/wDIF.rate();
641 wts_stop = sizeXCOR<wts_size/2 ? wts_start+sizeXCOR/wDIF.rate() : wts_start+(wts_size/2)/wDIF.rate();
643 WTS.
hist2D->GetYaxis()->SetRangeUser(EVT->
low[ifoID], EVT->
high[ifoID]);
653 cout <<
"TF : " <<
"enINJ : " << enINJ <<
" enREC : " << enREC
654 <<
" enINJREC : " << enINJREC << endl;
665 float dt = 1./(2*
df);
673 double pixel_frequency;
678 if(
j==1) pixel_frequency = df/2;
679 if(
j==layers) pixel_frequency = (layers-1)*df;
680 if((
j!=1)&&(
j!=
layers)) pixel_frequency = df/2 + (
j-1)*df;
682 if(
j==1) EE += ER/2.;
683 if(
j==layers) EE += ER/2.;
698 cout <<
"ComputeResidualEnergy - Error : WS1 & WS2 are not compatible !!!" << endl;
703 float dt = 1./(2*
df);
711 double pixel_frequency;
716 if(
j==1) pixel_frequency = df/2;
717 if(
j==layers) pixel_frequency = (layers-1)*df;
718 if((
j!=1)&&(
j!=
layers)) pixel_frequency = df/2 + (
j-1)*df;
720 if(
j==1) EE += ER/2.;
721 if(
j==layers) EE += ER/2.;
std::vector< char * > ifoName
detector * getifo(size_t n)
param: detector index
virtual void resize(unsigned int)
virtual size_t size() const
std::vector< vector_int > cRate
Float_t * high
min frequency
std::vector< wavearray< double > > wREC[MAX_TRIALS]
void setSLags(float *slag)
TString Get(wavearray< double > &x, TString ifo)
std::vector< double > * getmdcTime()
std::vector< std::string > mdcList
virtual void rate(double r)
Float_t * low
average center_of_snr frequency
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
std::vector< std::string > mdcType
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
wavearray< double > get(char *name, size_t index=0, char atype='R', int type=1, bool=true)
param: string with parameter name param: index in the amplitude array, which define detector param: c...
std::vector< wavearray< double > * > RWFP
std::vector< TGraph * > graph
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *NET, WSeries< double > *x, TString ifo, int type)
COHERENCE.
std::vector< std::string > mdcType
std::vector< double > oSNR[NIFO_MAX]
virtual void start(double s)
std::vector< double > mdcTime
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< double > ioSNR[NIFO_MAX]
void dopen(const char *fname, char *mode, bool header=true)
WDM< double > * getwdm(size_t M)
param: number of wdm layers
void output2G(TTree *, network *, size_t, int, double)
void ComputeResidualEnergyOptTF(wavearray< double > *wfINJ, wavearray< double > *wfREC, network *NET, netevent *EVT, int lag, int ID, int ifoID)
#define IMPORT(TYPE, VAR)
Double_t * gps
average center_of_gravity time
std::vector< std::string > mdcList
TIter next(twave->GetListOfBranches())
std::vector< double > iSNR[NIFO_MAX]
void PlotWaveform(TString ifo, wavearray< double > *wfINJ, wavearray< double > *wfREC, CWB::config *cfg, bool fft=false, bool strain=false)
size_t cpf(const netcluster &, bool=false, int=0)
void ComputeResidualEnergy(wavearray< double > *wfINJ, wavearray< double > *wfREC, double &enINJ, double &enREC, double &xcorINJ_REC)
Float_t * phi
sqrt(h+*h+ + hx*hx)
netevent EVT(itree, nifo)
Float_t * theta
[0]-reconstructed, [1]-injected phi angle, [2]-RA
Double_t * time
beam pattern coefficients for hx
virtual void stop(double s)
double fabs(const Complex &x)
void ApplyFrequencyCuts(wavearray< double > *wf, CWB::config *cfg)
Meyer< double > S(1024, 2)
netcluster * getwc(size_t n)
param: delay index
void PlotMRA(netcluster *pwc, int nIFO, int ID)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
double factors[FACTORS_MAX]
DataType_t getSample(int n, double m)
wavearray< double > wINJ[NIFO_MAX]
std::vector< double > mdcTime
Bool_t fill_in(network *, int, bool=true)
size_t getmdc__ID(size_t n)
for(int i=0;i< 101;++i) Cos2[2][i]=0
wavearray< double > ** pwf
[x1,y1,z1,x2,y2,z2] components of spin vector
virtual void resize(unsigned int)
double ComputeEnergy(WSeries< double > *WS)