21 #pragma GCC system_header 28 #include "TObjArray.h" 29 #include "TObjString.h" 53 cout <<
"-----> CWB_Plugin_Linear_Bilinear_Regression_Rank.C : " << ifo.Data() << endl;
60 bool SAVE_TREE =
false;
118 IMPORT(
int,RESAMPLING_INDEX)
127 if(FRLIST_WITNESS==
"") {cout <<
"Error : witness frames list not defined" << endl;gSystem->Exit(1);}
128 if(CHLIST_LINEAR==
"") {cout <<
"Error : linear witness channels list not defined" << endl;gSystem->Exit(1);}
129 if(CHLIST_WITNESS==
"") {cout <<
"Error : witness channels list not defined" << endl;gSystem->Exit(1);}
130 if(CHNAME_LINEAR==
"") {cout <<
"Error : main linear witness channel list not defined" << endl;gSystem->Exit(1);}
132 IMPORT(
double,LAYER_WIDTH)
139 IMPORT(
double,L_APPLY_THRESHOLD)
140 IMPORT(
double,L_SOLVE_THRESHOLD)
141 IMPORT(
double,L_SOLVE_NEIGEN_PER_LAYER)
142 IMPORT(
char,L_SOLVE_REGULATOR)
145 IMPORT(
double,B_APPLY_THRESHOLD)
146 IMPORT(
double,B_SOLVE_THRESHOLD)
147 IMPORT(
double,B_SOLVE_NEIGEN_PER_LAYER)
148 IMPORT(
char,B_SOLVE_REGULATOR)
150 REGRESSION_RANK.ToUpper();
151 if(REGRESSION_RANK!=
"LINEAR" && REGRESSION_RANK!=
"BILINEAR") {
152 cout <<
"Error : REGRESSION_RANK not defined [LINEAR/BILINEAR]" << endl;
158 int rank[4] = {50,30,10,1};
161 std::vector<std::string> CHN;
162 std::vector<std::string>* pCHN=&CHN;
167 for(
int n=0;
n<cfg->
nIFO;
n++)
if(ifo==cfg->
ifo[
n]) {xIFO=
n;
break;}
169 int runID = net->
nRun;
193 while (((SR % 2) == 0) && SR > 2*
CUT_LOW_FREQ) {SR /= 2;mm++;}
198 cout <<
"Set Frequency Range [0:" << SR/2 <<
"] = 0" << endl;
211 if(scratch>cfg->
segEdge+0.001) {
213 cout <<
"Regression Plugin : Error - filter scratch must be <= cwb scratch!!!" << endl;
214 cout <<
"filter scratch : " << scratch <<
" sec" << endl;
215 cout <<
"cwb scratch : " << cfg->
segEdge <<
" sec" << endl;
225 cout <<
"CWB_PLUGIN_DATA_MDC : Apply Linear Regression ..." << endl;
227 frame frl(FRLIST_WITNESS,
"",
"README",
true);
232 if(REGRESSION_RANK==
"LINEAR") {
233 cout <<
"CWB_PLUGIN_DATA_MDC : Apply Linear Regression Rank ..." << endl;
237 ifl.open(CHLIST_WITNESS.Data(),
ios::in);
238 if (!ifl.good()) {cout <<
"Error Opening File : " << CHLIST_WITNESS.Data() << endl;gSystem->Exit(1);}
244 sprintf(ofname,
"%s/linear_regression_rank_%s_%s.txt",cfg->
output_dir,ifo.Data(),flabel);
245 cout <<
"write results to " << ofname << endl;
249 if (!out.good()) {cout <<
"Error Opening File : " << ofname << endl;gSystem->Exit(1);}
255 if (!ifl.good())
break;
256 if(witness[0]==
'#')
continue;
261 size = rr.
add(wT,
"target");
262 if(size==0) {cout <<
"Regression Plugin - empty target channel" << endl;gSystem->Exit(1);}
265 size = rr.
add(wl,witness);
269 rr.
solve(L_SOLVE_THRESHOLD,L_SOLVE_NEIGEN_PER_LAYER,L_SOLVE_REGULATOR);
270 rr.
apply(L_APPLY_THRESHOLD);
272 for(
int n=0;
n<4;
n++) {
273 e[
n] = rr.
rank(rank[
n],0);
277 for(
int n=0;
n<4;
n++) {
281 CHN.push_back(witness);
282 sprintf(fstring,
"%3d %35s %10.5f %9.4f %8.3f %7.2f",
283 nCH,witness,CHC[0][nCH],CHC[1][nCH],CHC[2][nCH],CHC[3][nCH]);
284 cout << fstring << endl;
285 if(SAVE_ASCII) out << fstring << endl;out.flush();
290 if(SAVE_ASCII) out.close();
295 ifl.open(CHLIST_LINEAR.Data(),
ios::in);
296 if (!ifl.good()) {cout <<
"Error Opening File : " << CHLIST_LINEAR.Data() << endl;gSystem->Exit(1);}
301 size = rr.
add(wT,
"target");
302 if(size==0) {cout <<
"Regression Plugin - empty target channel" << endl;gSystem->Exit(1);}
307 if (!ifl.good())
break;
308 if(linear[0]==
'#')
continue;
309 cout <<
"read linear channel : \t" << linear << endl;
319 rr.
solve(L_SOLVE_THRESHOLD,L_SOLVE_NEIGEN_PER_LAYER,L_SOLVE_REGULATOR);
320 rr.
apply(L_APPLY_THRESHOLD);
328 if(REGRESSION_RANK==
"BILINEAR") {
330 cout <<
"CWB_PLUGIN_DATA_MDC : Apply Bilinear Regression Rank ..." << endl;
333 sprintf(ofname,
"%s/bilinear_regression_rank_%s_%s.txt",cfg->
output_dir,ifo.Data(),flabel);
334 cout <<
"write results to " << ofname << endl;
338 if (!out.good()) {cout <<
"Error Opening File : " << ofname << endl;gSystem->Exit(1);}
346 frame frb(FRLIST_WITNESS,
"",
"README",
true);
350 iwb.open(CHLIST_WITNESS.Data(),
ios::in);
351 if (!iwb.good()) {cout <<
"Error Opening File : " << CHLIST_WITNESS.Data() << endl;gSystem->Exit(2);}
361 if (!iwb.good())
break;
363 if(witness[0]==
'#')
continue;
369 size=rr.
add(wT,
"target");
370 if(size==0) {cout <<
"Regression Plugin - empty target channel" << endl;gSystem->Exit(1);}
380 size=rr.
add(ml,const_cast<char*>(CHNAME_LINEAR.Data()));
381 if(size==0) {cout <<
"Regression Plugin - empty main linear channel" << endl;gSystem->Exit(1);}
383 if(rr.
add(wb,witness,WFLOW,WFHIGH)) {
384 rr.
add(1,2,
"biwitness");
389 rr.
solve(B_SOLVE_THRESHOLD,B_SOLVE_NEIGEN_PER_LAYER,B_SOLVE_REGULATOR);
390 rr.
apply(B_APPLY_THRESHOLD);
392 for(
int n=0;
n<4;
n++) {
393 e[
n] = rr.
rank(rank[
n],0);
397 for(
int n=0;
n<4;
n++) {
401 CHN.push_back(witness);
403 sprintf(fstring,
"%3d %35s %10.5f %9.4f %8.3f %7.2f",
404 nCH,witness,CHC[0][nCH],CHC[1][nCH],CHC[2][nCH],CHC[3][nCH]);
405 cout << fstring << endl;
406 if(SAVE_ASCII) out << fstring << endl;out.flush();
409 if(SAVE_ASCII) out.close();
419 if(REGRESSION_RANK==
"LINEAR") {
420 sprintf(outFile,
"%s/linear_regression_rank_%s_%s.root",cfg->
output_dir,ifo.Data(),flabel);
422 sprintf(outFile,
"%s/bilinear_regression_rank_%s_%s.root",cfg->
output_dir,ifo.Data(),flabel);
424 cout <<
"write results to " << outFile << endl;
426 TFile*
ofile =
new TFile(outFile,
"RECREATE");
427 cfg->Write(
"config");
430 TTree rrtree(
"regression",
"regression");
431 double igps=x->
start();
434 char sifo[256];
sprintf(sifo,
"%s",ifo.Data());
435 rrtree.Branch(
"run",&runID,
"run/I");
436 rrtree.Branch(
"gps",&igps,
"gps/D");
437 rrtree.Branch(
"start",&start,
"start/D");
438 rrtree.Branch(
"stop",&stop,
"stop/D");
439 rrtree.Branch(
"sifo",sifo,
"sifo/C");
440 rrtree.Branch(
"ifo",&xIFO,
"ifo/I");
441 rrtree.Branch(
"nch",&nCH,
"nch/I");
442 rrtree.Branch(
"chc50",CHC[0],
"chc[nch]/D");
443 rrtree.Branch(
"chc30",CHC[1],
"chc[nch]/D");
444 rrtree.Branch(
"chc10",CHC[2],
"chc[nch]/D");
445 rrtree.Branch(
"chc01",CHC[3],
"chc[nch]/D");
446 rrtree.Branch(
"chn",&pCHN);
454 if(ifo==cfg->
ifo[xIFO]) {
455 cout <<
"remove temporary file ..." << endl;
457 jname.ReplaceAll(
":/",
"");
458 cout << jname.Data() << endl;
459 gSystem->Exec(
TString(
"rm "+jname).Data());
460 cout <<
"end job" << endl;
double L_SOLVE_NEIGEN_PER_LAYER
void setMatrix(double edge=0., double f=1.)
virtual void rate(double r)
double B_SOLVE_NEIGEN_PER_LAYER
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
size_t add(WSeries< double > &target, char *name, double fL=0., double fH=0.)
virtual void start(double s)
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
network ** net
NOISE_MDC_SIMULATION.
void setChName(TString chName)
virtual size_t size() const
wavearray< double > rank(int nbins=0, double fL=0., double fH=0.)
#define IMPORT(TYPE, VAR)
void apply(double threshold=0., char c='a')
int getLayer(wavearray< DataType_t > &w, double n)
param: n - layer number
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
void solve(double th, int nE=0, char c='s')
void setSRIndex(int srIndex)
wavearray< double > getClean()
virtual void stop(double s)
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
void unmask(int n, double flow=0., double fhigh=0.)
void mask(int n, double flow=0., double fhigh=0.)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
virtual void resize(unsigned int)
void Inverse(int n=-1)
param: n - number of steps (-1 means full reconstruction)
void putLayer(wavearray< DataType_t > &, double n)
param: n - layer number