7 #include <lal/LALConfig.h>
16 return par[0]*TMath::PoissonI(x[0],par[1]);
25 double y = (log10(x[0])-par[0]);
27 double s = y<0 ? par[1]*exp(y*par[2]) : par[1]*exp(y*par[3]);
30 if(par[3]>1./y) {s = par[1]*par[3]*exp(1.); y = 1.;}
31 y = s>0 ?
fabs(y/s) : 100.;
32 return 1-TMath::Erfc(y)/2;
36 y = s>0 ?
fabs(y/s) : 100.;
37 return TMath::Erfc(y)/2;
49 TTree*
tree = (TTree *) gROOT->FindObject(
"mdc");
52 else tree->StartViewer();
53 }
else {cout <<
"DrawMDC : mdc tree not found !!!" << endl;
return 0;}
54 return (Int_t)tree->GetSelectedRows();
64 TTree*
tree = (TTree *) gROOT->FindObject(
"waveburst");
67 else tree->StartViewer();
68 }
else {cout <<
"DrawWAVE : waveburst tree not found !!!" << endl;
return 0;}
69 return (Int_t)tree->GetSelectedRows();
79 TTree*
tree = (TTree *) gROOT->FindObject(
"liveTime");
82 else tree->StartViewer();
83 }
else {cout <<
"DrawLIVE : liveTime tree not found !!!" << endl;
return 0;}
84 return (Int_t)tree->GetSelectedRows();
94 TTree*
tree = (TTree *) gROOT->FindObject(
"mdc");
97 else tree->StartViewer();
98 }
else {cout <<
"ScanMDC : mdc tree not found !!!" << endl;
return 0;}
99 return (Int_t)tree->GetSelectedRows();
109 TTree*
tree = (TTree *) gROOT->FindObject(
"waveburst");
112 else tree->StartViewer();
113 }
else {cout <<
"ScanWAVE : waveburst tree not found !!!" << endl;
return 0;}
114 return (Int_t)tree->GetSelectedRows();
124 TTree*
tree = (TTree *) gROOT->FindObject(
"liveTime");
127 else tree->StartViewer();
128 }
else {cout <<
"ScanLIVE : liveTime tree not found !!!" << endl;
return 0;}
129 return (Int_t)tree->GetSelectedRows();
138 TTree*
tree = (TTree *) gROOT->FindObject(
"mdc");
139 if(tree) tree->Print();
140 else {cout <<
"PrintMDC : mdc tree not found !!!" << endl;
return 0;}
141 return (Int_t)tree->GetEntries();
150 TTree*
tree = (TTree *) gROOT->FindObject(
"waveburst");
151 if(tree) tree->Print();
152 else {cout <<
"PrintWAVE : waveburst tree not found !!!" << endl;
return 0;}
153 return (Int_t)tree->GetEntries();
162 TTree*
tree = (TTree *) gROOT->FindObject(
"liveTime");
163 if(tree) tree->Print();
164 else {cout <<
"PrintLIVE : liveTime tree not found !!!" << endl;
return 0;}
165 return (Int_t)tree->GetEntries();
174 return (TTree *) gROOT->FindObject(
"mdc");
183 return (TTree *) gROOT->FindObject(
"waveburst");
192 return (TTree *) gROOT->FindObject(
"liveTime");
205 sprintf(draw,
"start[0]-left[0]:stop[0]+right[0]");
206 tree->Draw(draw,cut,
"goff");
207 if (tree->GetSelectedRows()==0) {cout <<
"GetFileLabel : No events" << endl;
exit(1);}
208 double* segstart=tree->GetV1();
209 double* segstop=tree->GetV2();
212 int stop = TMath::Nint(segstop[0])-TMath::Nint(segstart[0])-2*
segEdge;
213 sprintf(label,
"%i_%i_%s_slag%i_lag%i_%i_job%i",
214 start,stop, psfix.Data(),slag,lag,1,
run);
225 gSystem->Exec(
"date");
227 FILE *
f = fopen(Form(
"/proc/%d/statm", gSystem->GetPid()),
"r");
230 sscanf(s.Data(),
"%ld %ld", &total, &rss);
231 cout <<
str.Data() <<
" virtual : " << total * 4 / 1024
232 <<
" (mb) rss : " << rss * 4 / 1024 <<
" (mb)" << endl;
245 sprintf(cut,
"run==%i && abs(rho[%d]-%f)<0.001 && abs(time[0]-%f)<0.0001 && abs(time[1]-%f)<0.0001",
246 run,irho,rho,time0,time1);
248 sprintf(draw,
"start[%i]",nifo);
249 tree->Draw(draw,cut,
"goff");
250 if (tree->GetSelectedRows()>1) {
251 cout <<
"GetStart : Too many events @ the same time : " << tree->GetSelectedRows() << endl;
255 if (tree->GetSelectedRows()==0) {cout <<
"GetStart : No events" << endl;
exit(1);}
256 double*
start=tree->GetV1();
269 sprintf(draw,
"start[0]-left[0]:stop[0]+right[0]");
270 tree->Draw(draw,cut,
"goff");
271 double* segstart=tree->GetV1();
272 double* segstop=tree->GetV2();
274 sprintf(s,
"%i_%i_%s_%i_id%i",TMath::Nint(segstart[0])+8,
275 TMath::Nint(segstop[0])-TMath::Nint(segstart[0])-16,psfix.Data(),lag,
run);
288 TGlobal*
global = gROOT->GetGlobal(
"analysis",
true);
291 memcpy((
void*)&analysis,(
void*)global->GetAddress(),
sizeof(analysis)*
sizeof(
char));
292 }
else {cout <<
"CheckAnalysis : analysis is not defined !!!" << endl;
exit(1);}
294 if(gSystem->Getenv(
"CWB_ANALYSIS")!=NULL) {
297 cout <<
"Error : analysis=" << analysis;
298 cout <<
" is inconsistent with the environment CWB_ANALYSIS="
299 << gSystem->Getenv(
"CWB_ANALYSIS") << endl;
300 cout <<
" check analysis parameter in user_parameters.C" << endl;
301 cout <<
" check CWB_ANALYSIS env in watenv setup" << endl;
302 cout <<
" use 'cwb_setpipe [1G/1g/1,2G/2g/2]' command to switch analysis type [1G/2G]" << endl;
308 cout <<
"CWB_ANALYSIS env not defined in watenv setup" << endl;
310 cout <<
" - add in watenv setup the following statement" << endl;
312 cout <<
" setenv CWB_ANALYSIS '1G' # 1G analysis " << endl;
313 cout <<
" or" << endl;
314 cout <<
" setenv CWB_ANALYSIS '2G' # 2G analysis " << endl;
316 cout <<
" - use 'cwb_setpipe [1G/1g/1,2G/2g/2]' command to switch analysis type [1G/2G]" << endl;
334 char git_path[1024] =
"";
335 if(igit_path.BeginsWith(
"$")) {
336 igit_path.ReplaceAll(
"$",
"");
337 if(gSystem->Getenv(igit_path.Data())!=NULL) {
338 strcpy(git_path,gSystem->Getenv(igit_path.Data()));
341 strcpy(git_path,igit_path.Data());
344 if(option==
"path")
return git_path;
346 if(
TString(git_path)==
"")
return "";
350 int estat = gSystem->GetPathInfo(git_path,&
id,&size,&
flags,&mt);
351 if(estat!=0)
return "";
356 sprintf(cmd,
"git -C %s diff HEAD", git_path);
360 sprintf(cmd,
"git -C %s rev-parse HEAD", git_path);
363 if(option==
"branch") {
364 sprintf(cmd,
"git -C %s branch -l | grep '*'", git_path);
368 sprintf(cmd,
"git -C %s tag -l --points-at HEAD", git_path);
372 sprintf(cmd,
"git -C %s config --get remote.origin.url", git_path);
376 fpos_t poserr; fflush(stderr); fgetpos(stderr, &poserr);
377 int fderr = dup(fileno(stderr)); freopen(
"/dev/null",
"w", stderr);
379 fpos_t posout; fflush(stdout); fgetpos(stdout, &posout);
380 int fdout = dup(fileno(stdout)); freopen(
"/dev/null",
"w", stdout);
382 int the_err = gSystem->Exec(cmd);
385 fflush(stderr); dup2(fderr, fileno(stderr));
close(fderr);
386 clearerr(stderr); fsetpos(stderr, &poserr);
388 fflush(stdout); dup2(fdout, fileno(stdout));
close(fdout);
389 clearerr(stdout); fsetpos(stdout, &posout);
393 TString the_output = gSystem->GetFromPipe(cmd);
394 if(option==
"branch") {
395 the_output.ReplaceAll(
"*",
"");
396 the_output.ReplaceAll(
" ",
"");
397 if(the_output==
"(nobranch)") the_output=
"";
414 if(
TString(gSystem->GetBuildArch()).Contains(
"linux")) OS=
"Linux";
415 if(
TString(gSystem->GetBuildArch()).Contains(
"macos")) OS=
"Darwin";
419 const char *root_version = gROOT->GetVersion();
421 cout <<
" ****************************************************************************" << endl;
422 cout <<
" * *" << endl;
423 cout <<
" * W E L C O M E to C W B *" << endl;
424 cout <<
" * *" << endl;
427 sline=
line;sline.Resize(80);sline+=
"*";cout<<sline<<endl;
437 if(wat_diff!=
"") wat_branch=wat_branch+
"/M";
438 sprintf(line,
" * Branch %s",wat_branch.Data());
439 }
else if(wat_tag!=
"") {
440 if(wat_diff!=
"") wat_branch=wat_branch+
"/M";
441 sprintf(line,
" * Tag %s",wat_tag.Data());
443 sprintf(line,
" * %s",
"Undefined");
445 sline=
line;sline.Resize(80);sline+=
"*";cout<<sline<<endl;
450 sline=
line;sline.Resize(80);sline+=
"*";cout<<sline<<endl;
452 sline=
line;sline.Resize(80);sline+=
"*";cout<<sline<<endl;
453 cout <<
" * *" << endl;
457 sprintf(line,
" * LAL Version %s",LALVersion.Data());
458 sline=
line;sline.Resize(80);sline+=
"*";cout<<sline<<endl;
463 sprintf(line,
" * FRLIB Version %2.2f",FRAMELIB_VERSION);
464 sline=
line;sline.Resize(80);sline+=
"*";cout<<sline<<endl;
466 cout <<
" * *" << endl;
469 sprintf(line,
" * Based on ROOT %s",root_version);
470 sline=
line;sline.Resize(80);sline+=
"*";cout<<sline<<endl;
472 cout <<
" * *" << endl;
476 if(!
WAT::USE_LAL()) cout <<
" * LAL DISABLED *" << endl;
479 if(gSystem->Getenv(
"_USE_PEGASUS")!=NULL)
480 cout <<
" * PEGASUS ENABLED *" << endl;
481 if(gSystem->Getenv(
"_USE_LSF")!=NULL)
482 cout <<
" * LSF ENABLED *" << endl;
483 if(gSystem->Getenv(
"_USE_OSG")!=NULL)
484 cout <<
" * OSG ENABLED *" << endl;
485 #if (WAT_VERSION_DEVEL != 0)
486 cout <<
" * *" << endl;
488 sline=
line;sline.Resize(80);sline+=
"*";cout<<sline<<endl;
490 cout <<
" * *" << endl;
497 if(cfg_diff!=
"") cfg_branch=cfg_branch+
"/M";
498 sprintf(line,
" * CONFIG Branch %s",cfg_branch.Data());
499 }
else if(cfg_tag!=
"") {
500 if(cfg_diff!=
"") cfg_branch=cfg_branch+
"/M";
501 sprintf(line,
" * CONFIG Tag %s",cfg_tag.Data());
503 sprintf(line,
" * CONFIG %s",
"Undefined");
505 sline=
line;sline.Resize(80);sline+=
"*";cout<<sline<<endl;
509 sline=
line;sline.Resize(80);sline+=
"*";cout<<sline<<endl;
511 cout <<
" * *" << endl;
512 cout <<
" ****************************************************************************" << endl;
515 cout <<
" Compiled on " <<
watversion(
'k') <<
" "
524 inline int Draw(TChain& rf,
string par,
string cut,
string opt)
525 {
return rf.Draw(par.c_str(),cut.c_str(),opt.c_str()); }
528 inline int Draw(TTree& rf,
string par,
string cut,
string opt)
529 {
return rf.Draw(par.c_str(),cut.c_str(),opt.c_str()); }
532 inline TCanvas*
DRAW(TChain& rf,
string par,
string cut,
string opt,
int iX=600,
int iY=600){
533 TCanvas *
c1 =
new TCanvas(
"c",
"C",0,0,iX,iY);
534 c1->SetBorderMode(0);
536 c1->SetBorderSize(2);
539 c1->SetRightMargin(0.1517039);
540 c1->SetTopMargin(0.0772727);
541 c1->SetBottomMargin(0.103939);
542 rf.Draw(par.c_str(),cut.c_str(),opt.c_str());
547 inline TCanvas*
Draw(TH1F*
h,
int iX=600,
int iY=600){
549 TCanvas *
c1 =
new TCanvas(
"c",
"C",0,0,iX,iY);
550 c1->SetBorderMode(0);
552 c1->SetBorderSize(2);
555 c1->SetRightMargin(0.1517039);
556 c1->SetTopMargin(0.0772727);
557 c1->SetBottomMargin(0.103939);
564 inline TCanvas*
Draw(TH2F*
h,
char* opt,
int iX=600,
int iY=600){
566 TCanvas *
c1 =
new TCanvas(
"c",
"C",0,0,iX,iY);
567 c1->SetBorderMode(0);
569 c1->SetBorderSize(2);
573 c1->SetRightMargin(0.1517039);
574 c1->SetTopMargin(0.0772727);
575 c1->SetBottomMargin(0.103939);
582 inline TCanvas*
Draw(TH1F**
h,
int n=1,
int m=0,
int iX=600,
int iY=600){
584 TCanvas *
c1 =
new TCanvas(
"c",
"C",0,0,iX,iY);
585 c1->SetBorderMode(0);
587 c1->SetBorderSize(2);
591 c1->SetRightMargin(0.1517039);
592 c1->SetTopMargin(0.0772727);
593 c1->SetBottomMargin(0.103939);
598 for(i=1; i<
n; i++) (*(h+i))->Draw(
"same");
602 for(
int i=0; i<
n*
m; i++) { c1->cd(i+1); (*(h+
i))->Draw(); }
608 inline TCanvas*
Draw(TH2F**
h,
char* opt,
int n=1,
int m=0,
int iX=600,
int iY=600){
610 TCanvas *
c1 =
new TCanvas(
"c",
"C",0,0,iX,iY);
611 c1->SetBorderMode(0);
613 c1->SetBorderSize(2);
617 c1->SetRightMargin(0.1517039);
618 c1->SetTopMargin(0.0772727);
619 c1->SetBottomMargin(0.103939);
623 for(
int i=1;
i<
n;
i++) (*(h+
i))->Draw(
"same");
627 for(
int i=0;
i<
n*
m;
i++) { c1->cd(
i+1); (*(h+
i))->Draw(opt); }
633 inline TCanvas*
Draw(TGraphErrors**
h,
char* opt,
int n=1,
int m=0,
int iX=600,
int iY=600){
635 TCanvas *
c1 =
new TCanvas(
"c",
"C",0,0,iX,iY);
636 c1->SetBorderMode(0);
638 c1->SetBorderSize(2);
642 c1->SetRightMargin(0.1517039);
643 c1->SetTopMargin(0.0772727);
644 c1->SetBottomMargin(0.103939);
648 for(
int i=1;
i<
n;
i++) (*(h+
i))->Draw(
"P");
652 for(
int i=0;
i<
n*
m;
i++) { c1->cd(
i+1); (*(h+
i))->Draw(opt); }
658 inline TCanvas*
Draw(TGraph**
h,
char* opt,
int n=1,
int m=0,
int iX=600,
int iY=600){
660 TCanvas *
c1 =
new TCanvas(
"c",
"C",0,0,iX,iY);
661 c1->SetBorderMode(0);
663 c1->SetBorderSize(2);
667 c1->SetRightMargin(0.1517039);
668 c1->SetTopMargin(0.0772727);
669 c1->SetBottomMargin(0.103939);
673 for(
int i=1;
i<
n;
i++) (*(h+
i))->Draw(
"P");
677 for(
int i=0;
i<
n*
m;
i++) { c1->cd(
i+1); (*(h+
i))->Draw(opt); }
703 ifstream inliv(fliveName);
704 if (!inliv.good()) {cout <<
"GetLiveTime : Error Opening File : " << fliveName << endl;
exit(1);}
709 inliv.getline(line,256);
710 if (!inliv.good())
break;
714 if(Oliv.Contains(
"nonzero"))
continue;
716 if(!
TString(line).Contains(
"slag=")) {cout<<
"GetLiveTime : Bad line format : "<<line<<endl<<endl;
exit(1);}
717 if(!
TString(line).Contains(
"lag=")) {cout<<
"GetLiveTime : Bad line format : "<<line<<endl<<endl;
exit(1);}
718 if(!
TString(line).Contains(
"live=")) {cout<<
"GetLiveTime : Bad line format : "<<line<<endl<<endl;
exit(1);}
720 TObjString* tok=(TObjString*)token->At(token->GetEntries()-1);
723 TObjString* tokslag=(TObjString*)token->At(0);
726 TObjString* toklag=(TObjString*)token->At(1);
729 if((lag==LAG||LAG<0) && (slag==SLAG||SLAG<0)) {
730 livetime+=
TString(tok->GetString()).Atof();
741 char name[][128],
double fcentral[],
double fbandwidth[]) {
756 cout <<
"inj file: " << ifName << endl;
757 in.open(ifName.Data(),
ios::in);
758 if (!in.good()) {cout <<
"ReadMdcType : Error Opening File : " << ifName << endl;
exit(1);}
765 in.getline(str,1024);
766 if (!in.good() && strlen(str)!=0) {
768 cout <<
"ReadMdcType : Error Reading File : " << ifName << endl;
769 cout <<
"at line : \"" << str <<
"\"" << endl;
770 cout <<
"check if new line is defined at the end of the string" << endl;
773 if (!in.good())
break;
774 if((str[0] ==
'#')||(str[0] ==
' ')||(str[0] == 0))
continue;
775 in.seekg(fpos, ios::beg);
778 >> fcentral[
ninj] >> fbandwidth[
ninj];
781 in.seekg(fpos+1, ios::beg);
783 if (!in.good())
break;
784 cout <<
" " << set[
ninj] <<
" " << type[
ninj] <<
" " << name[
ninj]
785 <<
" " << fcentral[
ninj] <<
" " << fbandwidth[
ninj] << endl;
787 if(ninj>=ntype_max) {
788 cout <<
"ReadMdcType : Error - max allowed injection types must be < "
789 << ntype_max << endl;
816 psize = png2==
"" ? 960 : 480;
819 *out <<
"<br></td></tr></table>" << endl;
821 *out <<
"<div align=\"center\"><font color=\"red\"><h2>"<<title<<
"</h2></font></div>" << endl;
823 *out <<
"<p><table summary=\"\"><tr align=\"left\"><td valign=\"top\" width=\"50%\"> \
824 <div align=\"center\"><ul><br/>" << endl;
825 *out <<
"<a class=\"image\" title=\""<<png1<<
"\">" << endl;
826 *out <<
"<img src=\""<<png1<<
"\" onerror=\"this.style.visibility = 'hidden'\" width=\""<<psize<<
"\"> </a>" << endl;
827 *out <<
"</br></ul><br><br>" << endl;
830 *out <<
"</div>" << endl;
831 *out <<
"<p></td><td valign=\"top\" width=\"50%\"><div align=\"center\"><ul><br/>" << endl;
832 *out <<
"<a class=\"image\" title=\""<<png2<<
"\">" << endl;
833 *out <<
"<img src=\""<<png2<<
"\" onerror=\"this.style.visibility = 'hidden'\" width=\""<<psize<<
"\"> </a>" << endl;
834 *out <<
"</br></ul><br><br>" << endl;
836 *out <<
"</div>" << endl;
840 inline double GetPrecision(
int cluster_size_threshold=0,
int healpix_order=0) {
848 if(cluster_size_threshold>=65536) {
849 cout <<
"GetPrecision Error : cluster_size_threshold must be < 65536" << endl;
852 if(healpix_order<0) {
853 cout <<
"GetPrecision Error : healpix_order must be >= 0" << endl;
856 double precision = cluster_size_threshold+65536*healpix_order;
867 for(
int j=0;
j<Xfar->
size();
j++) {
869 if(rho > Xfar->
data[
j]) {Yfar->
data[
j] += 1.;}
883 if(option==
"lalVersion")
return LAL_VERSION;
884 if(option==
"lalVersionMajor") {
char s[32];
sprintf(s,
"%d",LAL_VERSION_MAJOR);
return s;}
885 if(option==
"lalVersionMinor") {
char s[32];
sprintf(s,
"%d",LAL_VERSION_MINOR);
return s;}
886 if(option==
"lalVersionMicro") {
char s[32];
sprintf(s,
"%d",LAL_VERSION_MICRO);
return s;}
887 if(option==
"lalVersionDevel") {
char s[32];
sprintf(s,
"%d",LAL_VERSION_DEVEL);
return s;}
wavearray< double > Yfar(far_rho_bin)
virtual size_t size() const
char * watversion(char c='s')
wavearray< double > Xfar(far_rho_bin)
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
#define WAT_VERSION_DEVEL
condor_log_dir ReplaceAll("X_HOME", uhome.Data())
double fabs(const Complex &x)
TString sel("slag[1]:rho[1]")
strcpy(RunLabel, RUN_LABEL)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)