22 #include "Math/Polar3D.h" 25 #define EXIT(ERR) gSystem->Exit(ERR) // better exit handling for ROOT stuff 42 this->lagBuffer.Set(0);
70 this->lagBuffer.Set(0);
72 if(fName.EndsWith(
".root")) {
73 TFile*
ifile =
new TFile(fName);
74 if(!ifile->IsOpen()) {
75 cout <<
"cwb::cwb - Error opening root file : " << fName.Data() << endl;
79 if(ifile->Get(
"config")!=NULL) {
86 cout <<
"cwb::cwb - Error : cwb is not contained in root file " << fName.Data() << endl;
90 this->runID = CWB->
runID;
94 this->istage = CWB->
jstage;
96 cout <<
"cwb::cwb - Error : the stage(job file) " << GetStageString(istage).Data() <<
" >= " 97 <<
" input stage " << GetStageString(jstage).Data() << endl;
EXIT(1);
108 lagBuffer.Set(lagBuffer.GetSize()+1);
109 lagBuffer[lagBuffer.GetSize()-1]=0;
116 if(gSystem->Getenv(
"HOME_WAT_FILTERS")==NULL) {
117 cout <<
"cwb::cwb - Error : environment HOME_WAT_FILTERS is not defined!!!" << endl;
EXIT(1);
134 cout <<
"cwb::cwb - Error : aux simulation " <<
cfg.
simulation 137 cout <<
"cwb::cwb - Error : aux nfactor " <<
cfg.
nfactor 138 <<
" != in cfg nfactor " << icfg.
nfactor << endl;
EXIT(1);
141 cout <<
"cwb::cwb - Error : aux factors["<<
i<<
"]="<<
cfg.
factors[
i]
142 <<
" != in cfg factors["<<
i<<
"]=="<<icfg.
factors[
i]<<endl;
EXIT(1);}
145 cout <<
"cwb::cwb - Error : aux l_low " <<
cfg.
l_low 146 <<
" != in cfg l_low " << icfg.
l_low << endl;
EXIT(1);}
148 cout <<
"cwb::cwb - Error : aux l_high " <<
cfg.
l_high 149 <<
" != in cfg l_high " << icfg.
l_high << endl;
EXIT(1);}
151 cout <<
"cwb::cwb - Error : aux fLow " <<
cfg.
fLow 152 <<
" != in cfg fLow " << icfg.
fLow << endl;
EXIT(1);}
154 cout <<
"cwb::cwb - Error : aux fHigh " <<
cfg.
fHigh 155 <<
" != in cfg fHigh " << icfg.
fHigh << endl;
EXIT(1);}
157 cout <<
"cwb::cwb - Error : aux healpix " <<
cfg.
healpix 158 <<
" != in cfg healpix " << icfg.
healpix << endl;
EXIT(1);}
161 cout <<
"cwb::cwb - Error : config is not contained in root file " << fName.Data() << endl;
166 }
else if(fName.EndsWith(
".C")) {
167 if(gSystem->Getenv(
"CWB_PARAMETERS_FILE")==NULL) {
168 cout <<
"cwb::cwb - Error : environment CWB_PARAMETERS_FILE is not defined!!!" << endl;
176 }
else if(fName==
"") {
177 if(gSystem->Getenv(
"CWB_PARAMETERS_FILE")==NULL) {
178 cout <<
"cwb::cwb - Error : environment CWB_PARAMETERS_FILE is not defined!!!" << endl;
186 cout <<
"cwb::cwb - Error : bad input file extension [.C, .root] " << fName.Data() << endl;
209 this->lagBuffer.Set(0);
241 if(gROOT->GetVersionInt()>53204 && gROOT->GetVersionInt()<53400) {
242 cout <<
"cwb::Init - Error : cWB analysis don't works with ROOT version > 5.32.04 && version < 5.34.00" << endl;
243 cout <<
"You are running version : ROOT " << gROOT->GetVersion() << endl << endl;
249 cout <<
"cwb::Init - Error : stage STRAIN not implemented with simulation=4" << endl;
254 cout<<
"cwb::Init - Error : jobfOptions=CWB_JOBF_SAVE_TRGFILE is allowed only with CWB_STAGE_FULL!!!"<<endl;
266 cout <<
"cwb::Init - Error : data rate : " <<
rateANA 267 <<
" is not a multiple of 2^l_high : " << (1<<
cfg.
l_high) << endl;
312 unsigned int Pid = gSystem->GetPid();
314 double DATA_RATE = 0.;
328 if(
cfg.
nIFO==0) {cout <<
"cwb::cwb - Error : no detector is presents in the configuration" << endl;
EXIT(1);}
341 this->runID = srunID.Atoi();
348 cout<<
"job ID : "<<this->runID<<endl;
352 cout<<
"Pid : "<<Pid<<endl;
376 iname==
"" ? InitNetwork() : InitNetwork(iname);
390 double mdcShift = iname==
"" ? InitJob() : InitJob(iname);
394 cout<<
"temporary job file : " <<
jname<<endl;
403 DATA_RATE = ReadData(mdcShift,0);
428 cout<<endl<<
"---> Start processing factor["<<
ifactor<<
"]="<<factor<<endl<< endl;
432 if(factor==0)
sprintf(sfactor,
"z%g",factor);
433 if(factor>0)
sprintf(sfactor,
"p%g",factor);
434 }
else sprintf(sfactor,
"%g",factor);
446 if(!gSystem->GetPathInfo(endFile,fstemp)) {
447 printf(
"The file %s already exists - skip\n",endFile);
450 if(!rf.IsZombie())
continue;
454 char prod_label[512];
455 sprintf(prod_label,
"%d_%d_%s_slag%d_lag%lu_%lu_job%d",
470 if (!gSystem->GetPathInfo(out_CED,&
id,&size,&
flags,&mt)) {
471 cout <<
"cwb::run - Warning !!! - Dir \"" << out_CED <<
"\" already exist" << endl;
474 if (!gSystem->GetPathInfo(end_CED,&
id,&size,&
flags,&mt)) {
475 cout <<
"cwb::run - Warning !!! - Dir \"" << end_CED <<
"\" already exist" << endl;
481 Long_t xid,xsize,xflags,xmt;
482 int xestat = gSystem->GetPathInfo(outDump,&xid,&xsize,&xflags,&xmt);
484 sprintf(command,
"/bin/rm %s",outDump);
485 ecommand=gSystem->Exec(command);
486 if(ecommand) {cout <<
"cwb::cwb - Warning -> " << command << endl;}
489 cout<<
"output file on the node : "<<outFile<<endl;
490 cout<<
"final output file name : "<<endFile<<endl;
491 cout<<
"temporary output file : "<<tmpFile<<endl;
498 DATA_RATE = ReadData(mdcShift,
ifactor);
515 froot =
new TFile(tmpFile,
"RECREATE");
516 if(
froot==NULL) {cout <<
"cwb::cwb - Error opening root file : " << tmpFile << endl;
EXIT(1);}
518 TTree* live_tree=
live.setTree();
519 TTree* mdc_tree=NULL;
520 TTree* var_tree=NULL;
521 TTree* noise_tree=NULL;
524 mdc_tree =
mdc->setTree();
526 var_tree = wavevar.setTree();
527 noise_tree = noiserms.setTree();
540 for(
size_t mlag=mlagOff;mlag<mlagSize;mlag+=
mlagStep) {
548 std::vector<double> livTime;
554 cout<<
"number of time lags: "<<lags<<endl;
579 ceddir=Likelihood(
ifactor, out_CED, netburst, net_tree, outDump);
580 cout<<
"\nSearch done\n";
599 if(
cfg.
dump) netburst->dopen(outDump,const_cast<char*>(
"w"));
600 netburst->output(net_tree,&
NET,ofactor);
601 if(
cfg.
dump) netburst->dclose();
603 mdc->output(mdc_tree,&
NET,ofactor);
606 if(
cfg.
dump) netburst->dopen(outDump,const_cast<char*>(
"w"));
607 netburst->output(net_tree,&
NET);
608 if(
cfg.
dump) netburst->dclose();
614 noiserms.output(noise_tree,&
pD[i]->nRMS,i+1,DATA_RATE/2);
620 history->
AddLog( const_cast<char*>(
"FULL"), const_cast<char*>(
"STOP JOB"));
635 sprintf(command,
"/bin/rm %s", tmpFile);
636 ecommand=gSystem->Exec(command);
637 if(ecommand) {cout <<
"cwb::cwb - Warning -> " << command << endl;}
640 sprintf(command,
"/bin/mv %s %s", tmpFile, outFile);
643 else sprintf(command,
"/bin/mv %s %s",outFile,endFile);
646 else sprintf(command,
"/bin/mv %s %s",outDump,endDump);
649 if(!gSystem->GetPathInfo(outDump,&xid,&xsize,&xflags,&xmt))
Exec(command);
651 xestat = gSystem->GetPathInfo(end_CED,&xid,&xsize,&xflags,&xmt);
653 sprintf(command,
"/bin/mv %s/* %s/.",out_CED,end_CED);
655 sprintf(command,
"/bin/mv %s %s",out_CED,end_CED);
674 NET. nSensitivity=0;
NET. nAlignment=0;
NET. nCorrelation=0;
675 NET. nLikelihood=0;
NET. nNullEnergy=0;
NET. nPenalty=0;
676 NET. nCorrEnergy=0;
NET. nNetIndex=0;
NET. nDisbalance=0;
677 NET. nSkyStat=0;
NET. nEllipticity=0;
NET. nPolarisation=0;
683 {cout <<
"cwb::cwb - Error opening root file : " <<
jname << endl;
EXIT(1);}
689 TObjString* objn =
cfg.
configPlugin.GetLineWith(
"//#?CONFIG_PLUGIN_NAME ");
690 TString origName = objn ? objn->GetString() :
"";
691 cfg.
configPlugin.SetName(origName.ReplaceAll(
"//#?CONFIG_PLUGIN_NAME ",
""));
693 TObjString* objt =
cfg.
configPlugin.GetLineWith(
"//#?CONFIG_PLUGIN_TITLE ");
694 TString origTitle = objt ? objt->GetString() :
"";
695 cfg.
configPlugin.SetTitle(origTitle.ReplaceAll(
"//#?CONFIG_PLUGIN_TITLE ",
""));
712 TString cwb_jnet_name = gSystem->ExpandPathName(
"$CWB_MACROS/cwb_jnet.C");
715 cwb_jnet.Write(
"cwb_jnet");
718 history->
AddLog( const_cast<char*>(
"FULL"), const_cast<char*>(
"STOP JOB"));
737 TFile *
f = TFile::Open(
jname,
"UPDATE");
742 if(pwc==NULL)
continue;
744 char trName[64];
sprintf(trName,
"clusters-cycle:%d;2",cycle);
745 d = (TDirectory*)f->Get(
"coherence;1");
746 if(d!=NULL)
if(d->Get(trName)!=NULL) d->Delete(trName);
747 d = (TDirectory*)f->Get(
"supercluster;1");
748 if(d!=NULL)
if(d->Get(trName)!=NULL) d->Delete(trName);
749 d = (TDirectory*)f->Get(
"likelihood;1");
750 if(d!=NULL)
if(d->Get(trName)!=NULL) d->Delete(trName);
757 char wlabel[512];
sprintf(wlabel,
"wave_%s",jlabel);
779 if(ojname.BeginsWith(
"/")) {
780 sprintf(command,
"/bin/ln -sf %s %s",ojname.Data(),olname.Data());
782 sprintf(command,
"/bin/ln -sf ../%s %s",ojname.Data(),olname.Data());
784 cout << command << endl;
785 ecommand=gSystem->Exec(command);
786 if(ecommand) {cout <<
"cwb::cwb - Warning -> " << command << endl;}
789 sprintf(endFile,
"%s",ojname.Data());
793 ecommand=gSystem->Exec(command);
794 if(ecommand) {cout <<
"cwb::cwb - Warning -> " << command << endl;}
800 ecommand=gSystem->Exec(command);
801 if(ecommand) {cout <<
"cwb::cwb - Warning -> " << command << endl;}
812 cout << endl << endl;
815 double job_speed_factor = double(job_data_size_sec)/double(watchJob.RealTime());
817 printf(
"Job Speed Factor - %2.2fX\n",job_speed_factor);
820 watchJob.Stop();watchJob.Reset();
825 gSystem->Exec(command);
842 TFile*
ifile =
new TFile(fName);
843 if(ifile==NULL) {cout <<
"cwb::InitNetwork - Error opening root file : " << fName.Data() << endl;
EXIT(1);}
850 cout <<
"cwb::InitNetwork - Error : net is not contained in root file " << fName.Data() << endl;
903 gSystem->Exec(
"/bin/date");
904 gSystem->Exec(
"/bin/hostname");
942 cout <<
"cwb::InitNetwork - Error : user detector name at position " 943 <<
i <<
" is not defined (detParms)" << endl;
996 gSystem->Exec(
"/bin/date");
997 gSystem->Exec(
"/bin/hostname");
1037 TB.
checkFile(gSystem->Getenv(
"CWB_ROOTLOGON_FILE"));
1040 const char* STAGE_NAMES[7] = {
"FULL",
"INIT",
"STRAIN",
"CSTRAIN",
"COHERENCE",
"SUPERCLUSTER",
"LIKELIHOOD"};
1042 const char* TYPE_NAMES[22] = {
"CWB_ENV",
"WATVERSION",
"XIFO",
"GITVERSION",
"GITBRANCH",
"WORKDIR",
1043 "FRLIBVERSION",
"ROOTVERSION",
"LALVERSION",
1044 "DATALABEL",
"CMDLINE",
"ROOTLOGON",
"PARAMETERS",
1045 "CWB_ENV_MD5",
"ROOTLOGON_MD5",
"PARAMETERS_MD5",
1046 "CWB_CONFIG_URL",
"CWB_CONFIG_PATH",
"CWB_CONFIG_BRANCH",
"CWB_CONFIG_TAG",
"CWB_CONFIG_HASH",
"CWB_CONFIG_DIFF"};
1048 history =
new CWB::History(const_cast<char**>(STAGE_NAMES), 7, const_cast<char**>(TYPE_NAMES), 22);
1053 TFile*
ifile =
new TFile(iname);
1054 if(ifile==NULL) {cout <<
"cwb::InitHistory - Error opening root file : " << iname.Data() << endl;
EXIT(1);}
1056 if(ifile->Get(
"history")!=NULL) {
1061 for(
int i=0;
i<stageList->GetSize();
i++) {
1062 TObjString* stageString = (TObjString*)stageList->At(
i);
1063 for(
int j=0;
j<typeList->GetSize();
j++) {
1064 TObjString* typeString = (TObjString*)typeList->At(
j);
1065 char* histData = hst->
GetHistory(const_cast<char*>(stageString->GetString().Data()),
1066 const_cast<char*>(typeString->GetString().Data()));
1067 if(histData!=NULL) {
1069 const_cast<char*>(typeString->GetString().Data()),histData);
1077 int log_size = hst->
GetLogSize(const_cast<char*>(
"FULL"));
1078 for(
int i=0;
i<log_size;
i++) {
1081 char stg_label[16];
sprintf(stg_label,
"STG:%d",jstage);
1082 if(log.Contains(
"STG:8")) log.ReplaceAll(
"STG:8",stg_label);
1084 history->
AddLog(const_cast<char*>(
"FULL"), const_cast<char*>(log.Data()));
1088 cout <<
"cwb::InitHistory - Error : history is not contained in root file " << iname.Data() << endl;
1095 TString jStageString = GetStageString(jstage).ReplaceAll(
"CWB_STAGE_",
"");
1096 char jStage[256];
sprintf(jStage,jStageString.Data());
1100 if(cwbBuffer!=NULL) {
1102 TMD5 md5;md5.Update((UChar_t*)cwbBuffer,strlen(cwbBuffer));md5.Final();
1103 history->
AddHistory(jStage, const_cast<char*>(
"CWB_ENV_MD5"), const_cast<char*>(md5.AsString()));
1104 delete [] cwbBuffer;
1109 char framelib_version[32];
sprintf(framelib_version,
"%f",FRAMELIB_VERSION);
1114 history->
AddHistory(jStage, const_cast<char*>(
"FRLIBVERSION"), framelib_version);
1115 history->
AddHistory(jStage, const_cast<char*>(
"ROOTVERSION"), const_cast<char*>(gROOT->GetVersion()));
1125 for(
int i=0;
i<gApplication->Argc();
i++) cmd_line_len+=strlen(gApplication->Argv(
i));
1126 if(cmd_line_len>2047)
1127 {cout <<
"cwb::InitHistory - command line too long : " << cmd_line_len << endl;
EXIT(1);}
1128 for(
int i=0;
i<gApplication->Argc();
i++)
sprintf(cmd_line,
"%s %s",cmd_line,gApplication->Argv(
i));
1133 if(rootlogonBuffer!=NULL) {
1135 TMD5 md5;md5.Update((UChar_t*)rootlogonBuffer,strlen(rootlogonBuffer));md5.Final();
1136 history->
AddHistory(jStage, const_cast<char*>(
"ROOTLOGON_MD5"), const_cast<char*>(md5.AsString()));
1146 history->
AddHistory(jStage, const_cast<char*>(
"CWB_CONFIG_DIFF"), const_cast<char*>(
GetGitInfos(
"diff",
"$CWB_CONFIG")!=
"" ?
"M" :
""));
1150 unsigned int Pid = gSystem->GetPid();
1152 if(mkstemp(tmpFile)==-1) {
1153 cout <<
"cwb::InitHistory - mkstemp error in creating tmp file : " << tmpFile << endl;
1160 TObjString* objt =
cfg.
configPlugin.GetLineWith(
"//#?CONFIG_PLUGIN_TITLE ");
1161 TString origTitle = objt ? objt->GetString() :
"";
1162 cfg.
configPlugin.SetTitle(origTitle.ReplaceAll(
"//#?CONFIG_PLUGIN_TITLE ",
""));
1166 char* parametersBuffer =
TB.
readFile(tmpFile);
1168 if(parametersBuffer!=NULL) {
1170 TMD5 md5;md5.Update((UChar_t*)parametersBuffer,strlen(parametersBuffer));md5.Final();
1171 history->
AddHistory(jStage, const_cast<char*>(
"PARAMETERS_MD5"), const_cast<char*>(md5.AsString()));
1172 delete [] parametersBuffer;
1176 history->
AddLog(const_cast<char*>(
"FULL"), const_cast<char*>(
"START JOB"));
1193 TFile*
ifile =
new TFile(fName);
1194 if(ifile==NULL||!ifile->IsOpen())
1195 {cout <<
"cwb::InitJob - Error opening root file : " << fName.Data() << endl;
EXIT(1);}
1199 cout <<
"cwb::InitJob - Error : cwb is not contained in root file " << fName.Data() << endl;
1211 netburst->setSLags(slagShift);
1233 cout<<
"cwb::InitJob : when simulation=4 factors[0] is the offset and must be integer>=0"<<endl;
1237 cout<<
"cwb::InitJob : when simulation=4 factors[0] is the offset and must be integer>=0"<<endl;
1281 cout <<
"Error : slagSize<=1 & lagSize==1 in simulation mode !!!" << endl;
EXIT(1);
1298 cout << endl <<
"START SLAG Init ..." << endl << endl;
1318 if(SLAG.
jobId!=runID) {cout <<
"jobID " << runID <<
" not found in the slag list !!!" << endl;
EXIT(1);}
1322 cout <<
"SuperLag=" <<
slagID <<
" jobID=" <<
jobID;
1323 for(
int n=0;
n<nIFO;
n++) cout <<
" segID[" <<
ifo[
n] <<
"]=" <<
segID[
n];cout << endl;
1337 cout << endl <<
"Segment type = SLAG" << endl;
1339 cout << endl <<
"END SLAG Init ..." << endl << endl;
1355 cout <<
"Segment type = LAG" << endl;
1357 cout <<
"segLen = " <<
cfg.
segLen <<
" sec" << endl;
1358 cout <<
"segMLS = " <<
cfg.
segMLS <<
" sec" << endl;
1359 cout <<
"segOverlap = " <<
cfg.
segOverlap <<
" sec" << endl;
1365 netburst->setSLags(slagShift);
1385 cout <<
"detSegs_dq1[" <<
ifo[
i] <<
"] GPS range : " 1389 if(
detSegs.size()==0) {cout <<
"no segments found for this job, job terminated !!!" << endl;
EXIT(1);}
1401 cout <<
"cwb::InitJob - Error : noise frame files list name is not defined" << endl;
1423 for(
int n=nIFO;
n<2*
nIFO;
n++) {
1431 cout <<
"cwb::InitJob - Error : MDC frame files list name is not defined" << endl;
1442 cout <<
"MDC " <<
" -> nfrFiles : " <<
nfrFiles[
n] << endl;
1446 cout <<
"mdc_range : " << mdc_range.
start <<
" " << mdc_range.
stop << endl;
1451 cout <<
"mdcShift : " << mdcShift << endl;
1463 cout<<
"cwb::InitJob : when simulation=4 factors[0] is the offset and must be integer>=0"<<endl;
1467 cout<<
"cwb::InitJob : when simulation=4 factors[0] is the offset and must be integer>=0"<<endl;
1487 detSegs_dq2.push_back(
detSegs[0]);
1489 for(
int i=0;
i<(
int)detSegs_dq2.size();
i++) {
1490 cout <<
"detSegs_dq2[" <<
i <<
"] GPS range : " 1491 << detSegs_dq2[
i].start <<
"-" << detSegs_dq2[
i].stop << endl;
1495 cout <<
"live time after cat 2 : " << detSegs_ctime <<
" sec" << endl;
1497 cout <<
"cwb::InitJob : job segment live time after cat2 < segTHR=" 1498 <<
cfg.
segTHR <<
" sec, job terminated !!!" << endl;
1499 cout << endl <<
"To remove this check set segTHR=0 in the parameter file" << endl << endl;
1512 printf(
"GPS: %16.6f saved, injections: %d\n",
double(
long(Tb)),i);
1517 vector<waveSegment> mdcSegs(
NET.
mdcTime.size());
1522 vector<waveSegment> mdcSegs_dq2 =
TB.
mergeSegLists(detSegs_dq2,mdcSegs);
1524 cout <<
"live time in zero lag after cat2+inj : " << mdcSegs_ctime << endl;
1525 if(mdcSegs_ctime==0) {
1526 cout <<
"cwb::InitJob : job segment with zero cat2+inj " 1527 <<
"live time in zero lag, job terminated !!!" << endl;
1528 cout <<
"Warning : MDC data frames could be zero !!!" << endl;
1544 cout <<
"cwb::InitJob : Error Opening File : " <<
cfg.
lagFile << endl;
1548 in.seekg (0, in.end);
1549 int len = in.tellg();
1550 in.seekg (0, in.beg);
1552 in.read(lagBuffer.GetArray(),len);
1555 cout <<
"cwb::InitJob : Error Reading File : " <<
cfg.
lagFile << endl;
1560 lagBuffer.Set(lagBuffer.GetSize()+1);
1561 lagBuffer[lagBuffer.GetSize()-1]=0;
1593 {cout <<
"cwb::ReadData - Error opening root file : " <<
jname << endl;
EXIT(1);}
1594 TDirectory* cdstrain = (TDirectory*)
jfile->Get(
"strain");
1595 if(cdstrain==NULL) cdstrain =
jfile->mkdir(
"strain");
1599 TFile*
ifile =
new TFile(fName);
1600 if(ifile==NULL) {cout <<
"cwb::ReadData - Error opening root file : " << fName << endl;
EXIT(1);}
1608 {cout <<
"cwb::ReadData - Error : data not present in file : " << fName << endl;
EXIT(1);}
1611 cdstrain->cd();pws->Write(
ifo[
i]);
1617 {cout <<
"cwb::ReadData - Error : mdc not present in file : " << fName << endl;
EXIT(1);}
1619 TDirectory* cdmdc = (TDirectory*)
jfile->Get(
"mdc");
1620 if(cdmdc==NULL) cdmdc =
jfile->mkdir(
"mdc");
1621 cdmdc->cd();pws->Write(
ifo[i]);
1641 char cdcstrain_name[32];
sprintf(cdcstrain_name,
"cstrain-f%d",ifactor);
1645 TDirectory* jcdcstrain = NULL;
1649 {cout <<
"cwb::DataConditioning - Error opening root file : " <<
jname << endl;
EXIT(1);}
1650 jcdcstrain=
jfile->mkdir(cdcstrain_name);
1655 TFile*
ifile =
new TFile(fName);
1657 {cout <<
"cwb::DataConditioning - Error opening root file : " << fName << endl;
EXIT(1);}
1665 {cout <<
"cwb::DataConditioning - Error : data not present, job terminated!!!" << endl;
EXIT(1);}
1667 if(
jfile!=NULL) {
jfile->cd();jcdcstrain->cd();pws->Write(
ifo[
i]);}
1733 if(stageInfos) PrintStageInfo(
CWB_STAGE_INIT,
"cwb::PrintAnalysis");
1735 cout <<
" jobID : " << runID << endl;
1738 cout <<
" stage : ";
1750 cout <<
"\n detectors : ";
1754 cout <<
" search : ";
1762 cout <<
"(" <<
cfg.
search <<
")" << endl;
1764 char _search = std::tolower(
cfg.
search);
1765 if(_search==
'r') cout<<
"un-modeled";
1766 if(_search==
'i') cout<<
"iota-wave";
1767 if(_search==
'p') cout<<
"psi-wave";
1768 if(_search==
'l' || _search==
's') cout<<
"linear polarisation";
1769 if(_search==
'c' || _search==
'g') cout<<
"circular polarisation";
1770 if(_search==
'e' || _search==
'b') cout<<
"elliptical polarisation";
1779 cout<<
"\n unavailable analysis type !!!"<<endl;
EXIT(1);
1785 cout<<
"maximum time delay between detectors : "<<
mTau<<endl;
1786 cout<<
" maximum time delay difference : "<<dTau<<endl;
1788 cout<<
" HEALPix order : "<<
cfg.
healpix<<endl;
1790 cout<<
" skymap angular resolution : "<<
cfg.
angle<<endl;
1792 cout<<
" skymap size in azimuthal angle : "<<
cfg.
Phi1<<
", "<<
cfg.
Phi2<<endl;
1805 if(pattern== 0) cout<<
"('*' single pixel standard)"<<endl;
1806 if(pattern== 1) cout<<
"('3|' packet)"<<endl;
1807 if(pattern== 2) cout<<
"('3-' packet)"<<endl;
1808 if(pattern== 3) cout<<
"('3/' packet - chirp)"<<endl;
1809 if(pattern== 4) cout<<
"('3\\' packet - ringdown)"<<endl;
1810 if(pattern== 5) cout<<
"('5/' packet - chirp)"<<endl;
1811 if(pattern== 6) cout<<
"('5\\' packet - ringdown)"<<endl;
1812 if(pattern== 7) cout<<
"('3+' packet)"<<endl;
1813 if(pattern== 8) cout<<
"('3x' cross packet)"<<endl;
1814 if(pattern== 9) cout<<
"('9p' 9-pixel square packet)"<<endl;
1815 if(pattern > 9) cout<<
"('*' single pixel packet)"<<endl;
1822 int csize = precision%65536;
1823 int order = (precision-csize)/65536;
1824 cout<<
" precision csize, order : "<<csize<<
", "<<order<<endl;
1828 cout<<
" mask ; "<<
cfg.
mask<<endl;
1861 gSystem->GetProcInfo(&info);
1863 cout <<
"Memory - virtual : " << info.fMemVirtual / 1024
1864 <<
" (mb) rss : " << info.fMemResident / 1024 <<
" (mb)" << endl;
1865 return mvirtual ? info.fMemVirtual/1024 : info.fMemResident/1024;
1881 if(
TString(plugin.GetName())==
"")
return;
1883 unsigned int Pid = gSystem->GetPid();
1885 TString pluginPath = plugin.GetTitle();
1890 if(
TString(configPlugin.GetName())!=
"") {
1892 configPlugin.AddLine(TString::Format(
"//#?CONFIG_PLUGIN_NAME %s",configPlugin.GetName()));
1893 configPlugin.AddLine(TString::Format(
"//#?CONFIG_PLUGIN_TITLE %s",configPlugin.GetTitle()));
1898 char configPluginName[1024];
1899 if((gROOT->GetVersionInt()>=53400)&&(gROOT->GetVersionInt()<=53407)) {
1902 sprintf(configPluginName,
"CWB_Plugin_Config_%s_%d_job%d.XXXXXX",
1906 sprintf(configPluginName,
"%s/CWB_Plugin_Config_%s_%d_job%d.XXXXXX",
1909 if(mkstemp(configPluginName)==-1) {
1910 cout <<
"cwb::LoadPlugin - Error : mkstemp error in creating tmp file : " << configPluginName << endl;
1913 configPlugin.SetName(
"CWB_PluginConfig");
1914 configPlugin.SetTitle(configPluginName);
1919 if(pluginPath.EndsWith(
".so")) {
1923 int estat = gSystem->GetPathInfo(pluginPath.Data(),fStatus);
1925 wat::Time plugin_comp_date(
double(fStatus.fMtime));
1929 TString pluginSrc = pluginPath;
1930 pluginSrc.ReplaceAll(
"_C.so",
".C");
1932 cout <<
"cwb::LoadPlugin : The plugin compilation date is not up to date !!! " << endl;
1933 cout <<
" plugin compilation date : " << plugin_comp_date.
GetDateString() << endl;
1934 cout <<
" wat compilation date : " << wat_comp_date.
GetDateString() << endl;
1936 cout <<
"Recompile the plugin : " << endl;
1937 cout <<
"cwb_compile " << pluginSrc << endl << endl;
1941 cout << endl <<
"cwb::LoadPlugin - Load pre-compiled plugin ..." << endl << endl;
1942 check = gROOT->LoadMacro(pluginPath.Data(),&
error);
1944 cout <<
"cwb::LoadPlugin : Load pre-compiled Plugin Failed !!! " << endl;
1945 cout <<
"cwb::LoadPlugin : The plugin is compiled 'On-The-Fly'!!! " << endl;
1951 if(!(pluginPath.EndsWith(
".so"))||(check!=0)) {
1952 cout << endl <<
"cwb::LoadPlugin - compile and load plugin ..." << endl << endl;
1954 char tmpFile[1024]=
"";
1956 if(mkstemp(tmpFile)==-1) {
1957 cout <<
"cwb::LoadPlugin - mkstemp error in creating tmp file : " << tmpFile << endl;
1960 char pluginSrc[1024]=
"";
1961 sprintf(pluginSrc,
"%s.C",tmpFile);
1966 int success = gSystem->CompileMacro(
TString(pluginSrc).Data(),
"f");
1967 gSystem->Exec(
TString(
"/bin/rm ")+tmpFile);
1969 cout <<
"cwb::LoadPlugin : Plugin Compilation Failed !!! " << endl;
1974 TString pluginShr = pluginSrc;
1975 pluginShr.ReplaceAll(
".C",
"_C.so");
1976 check = gROOT->LoadMacro(pluginShr.Data(),&
error,
true);
1978 cout <<
"cwb::LoadPlugin : Plugin Compilation Failed !!! " << endl;
1983 TString pluginTmp = pluginSrc;
1986 sprintf(tmpStr,
"/bin/rm -f %s", pluginTmp.Data());
1988 pluginTmp.ReplaceAll(
".C",
"_C.so");
1989 sprintf(tmpStr,
"/bin/rm -f %s", pluginTmp.Data());
1991 pluginTmp.ReplaceAll(
"_C.so",
"_C.d");
1992 sprintf(tmpStr,
"/bin/rm -f %s", pluginTmp.Data());
2011 int job_elapsed_sec =
int(job_elapsed_time-3600*job_elapsed_hour-60*job_elapsed_min);
2031 TString info = GetStageInfo(stage,comment,fname);
2033 if(out) cout << info.Data() << endl;
2087 std::stringstream buffer;
2088 std::streambuf * old = std::cout.rdbuf(buffer.rdbuf());
2092 cout <<
"--------------------------------------------------------------------" << endl;
2093 cout << comment.Data();
2095 cout <<
" - factor[" << FCT <<
"]=" <<
cfg.
factors[FCT] << endl;
2097 cout <<
"--------------------------------------------------------------------" << endl;
2098 cout <<
"UTC - "; cout.flush();
2101 JET = watchJob.RealTime();
2103 watchJob.Continue();
2105 SET = watchStage.RealTime();
2110 Long_t xid,xsize,xflags,xmt;
2112 int xestat = gSystem->GetPathInfo(xname.Data(),&xid,&xsize,&xflags,&xmt);
2113 if(xestat==0) JFS=xsize;
else JFS=0;
2114 cout <<
"Job File Size - " << JFS <<
" (bytes) : " 2115 <<
int(JFS/1024.) <<
" (kb) : " <<
int(JFS/1024./1024) <<
" (mb)" << endl;
2116 cout <<
"--------------------------------------------------------------------" << endl;
2117 cout <<
"GPS:" << GPS <<
"-JOB:" << JOB <<
"-STG:" << STG <<
"-FCT:" << FCT
2118 <<
"-JET:" << JET <<
"-SET:" << SET <<
"-MEM:" << MEM <<
"-JFS:" << JFS << endl;
2119 cout <<
"--------------------------------------------------------------------" << endl;
2123 std::cout.rdbuf(old);
2125 return buffer.str();
2140 TString ainfo = GetAnalysisInfo(stage,comment,info);
2142 if(out) cout << ainfo.Data() << endl;
2180 TGlobal*
global = gROOT->GetGlobal(
"gIFACTOR",
true);
2181 if(global!=NULL) FCT = *(
int*)global->GetAddress();
else FCT=-1;
2184 std::stringstream buffer;
2185 std::streambuf * old = std::cout.rdbuf(buffer.rdbuf());
2189 cout <<
"--------------------------------------------------------------------" << endl;
2190 cout << comment.Data();
2192 cout <<
" - factor[" << FCT <<
"]=" <<
cfg.
factors[FCT] << endl;
2194 cout <<
"--------------------------------------------------------------------" << endl;
2195 cout <<
"GPS:" << GPS <<
"-JOB:" << JOB <<
"-STG:" << STG <<
"-FCT:" << FCT << info << endl;
2196 cout <<
"--------------------------------------------------------------------" << endl;
2200 std::cout.rdbuf(old);
2202 return buffer.str();
2215 return(
"CWB_STAGE_FULL");
2218 return(
"CWB_STAGE_INIT");
2221 return(
"CWB_STAGE_STRAIN");
2224 return(
"CWB_STAGE_CSTRAIN");
2227 return(
"CWB_STAGE_COHERENCE");
2230 return(
"CWB_STAGE_SUPERCLUSTER");
2233 return(
"CWB_STAGE_LIKELIHOOD");
2321 while(ecommand&&(ntry<maxtry)) {
2322 ecommand=gSystem->Exec(command);
2323 if(ecommand) gSystem->Sleep(
int(gRandom->Uniform(10000,30000)));
2327 cout << command << endl;
2328 cout <<
"cwb::Exec - NTRY " << ntry << endl;
2333 if(ecommand) {cout <<
"cwb::Exec - Error -> " << command << endl;
EXIT(1);}
2353 bool replace =
false;
2356 ofName.ReplaceAll(
".root",
"_tmp.root");
2360 if(delObjList.size()==0) {
2363 sprintf(command,
"/bin/mv %s %s",ofName.Data(),ifName.Data());
2364 gSystem->Exec(command);
2368 if(gROOT->GetVersionInt()<53405) {
2370 TFile* kfile =
new TFile(ifName,
"UPDATE");
2371 for(
int i=0;
i<delObjList.size();
i++) kfile->Delete(delObjList[
i]+
";1");
2375 gErrorIgnoreLevel=kBreak;
2376 TFileMerger
M(
false);
2377 M.AddFile(ifName,
false);
2378 M.OutputFile(ofName);
2379 if(gROOT->GetVersionInt()<53400) {
2382 cout <<
"cwb::FileGarbageCollector : Error - Merge failed !!!" << endl;
EXIT(1);
2385 if(gROOT->GetVersionInt()>=53400 && gROOT->GetVersionInt()<53405) {
2388 if(!M.PartialMerge(TFileMerger::kAllIncremental | TFileMerger::kRegular)) {
2389 cout <<
"cwb::FileGarbageCollector : Error - Merge failed !!!" << endl;
EXIT(1);
2392 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,34,5) 2393 if(gROOT->GetVersionInt()>=53405) {
2395 for(
int i=0;
i<delObjList.size();
i++) M.AddObjectNames(delObjList[
i]);
2397 Int_t default_mode = TFileMerger::kAll | TFileMerger::kIncremental;
2398 Int_t
mode = default_mode | TFileMerger::kSkipListed;
2399 if(!M.PartialMerge(mode)) {
2400 cout <<
"cwb::FileGarbageCollector : Error - Merge failed !!!" << endl;
EXIT(1);
2405 gErrorIgnoreLevel=kUnset;
2409 sprintf(command,
"/bin/mv %s %s",ofName.Data(),ifName.Data());
2410 gSystem->Exec(command);
2430 int L = SkyMask.
size();
2433 if(
fabs(theta)>90 || (phi<0 || phi>360) || radius<=0 || L<=0) {
2434 cout <<
"cwb::MakeSkyMask : wrong input parameters !!! " << endl;
2435 if(
fabs(theta)>90) cout << theta <<
" theta must be in the range [-90,90]" << endl;
2436 if(phi<0 || phi>360) cout << phi <<
" phi must be in the range [0,360]" << endl;
2437 if(radius<=0) cout << radius <<
" radius must be > 0" << endl;
2438 if(L<=0) cout << L <<
" SkyMask size must be > 0" << endl;
2442 if (!gROOT->GetClass(
"Polar3DVector")) gSystem->Load(
"libMathCore");
2449 double skyres = sphere_solid_angle/
npix;
2450 if(radius < sqrt(skyres)) radius = sqrt(skyres);
2452 if(radius < SkyMask.
sms) radius = SkyMask.
sms;
2461 for (
int l=0;
l<
L;
l++) {
2462 double phi = SkyMask.
getPhi(
l);
2466 double Dot = ov1.Dot(ov2);
2467 double dOmega = 180.*TMath::ACos(Dot)/
TMath::Pi();
2470 if(dOmega<=radius) {SkyMask.
set(
l,1);nset++;}
else SkyMask.
set(
l,0);
2474 cout <<
"cwb::MakeSkyMask : no sky positions setted !!! " << endl;
2475 cout <<
"check input mask parameters : theta = " 2476 << theta <<
" phi = " << phi <<
" radius : " << radius << endl << endl;
2512 if(skycoord!=
'e' && skycoord!=
'c') {
2513 cout <<
"cwb::SetSkyMask - Error : wrong input sky coordinates " 2514 <<
" must be 'e'/'c' earth/celestial" << endl;;
2518 if(strlen(options)>0) {
2519 if(!
TString(options).Contains(
"--")) {
2520 if(skyres>=0)
return 1;
2524 cout <<
"cwb::SetSkyMask - Error : skyMask file" 2525 <<
" not exist or it has a wrong format" << endl;
2527 cout <<
" format : two columns ascii file -> [sky_index value]" << endl;
2528 cout <<
" sky_index : is the sky grid index" << endl;
2529 cout <<
" value : if !=0 the index sky location is used for the analysis" << endl;
2539 if(THETA.IsFloat()) theta=THETA.Atof();
2542 if(PHI.IsFloat()) phi=PHI.Atof();
2543 double radius=-1000;
2545 if(RADIUS.IsFloat()) radius=RADIUS.Atof();
2547 if(theta==-1000 || phi==-1000 || radius==-1000) {
2548 cout << endl <<
"cwb::SetSkyMask - Error : wrong input skyMask params" << endl << endl;
2549 cout <<
"wrong input options : " << options << endl;
2551 cout<<
"options must be : --theta THETA --phi PHI --radius RADIUS"<<endl<<endl;
2553 cout<<
"options must be : --theta DEC --phi AR --radius RADIUS"<<endl<<endl;
2554 if(
fabs(theta)>90) cout << theta <<
" theta must be in the range [-90,90]" << endl;
2555 if(phi<0 || phi>360) cout << phi <<
" phi must be in the range [0,360]" << endl;
2556 if(radius<=0) cout << radius <<
" radius must be > 0" << endl;
2564 MakeSkyMask(*SkyMask, theta, phi, radius);
2567 if(SkyMask!=NULL)
delete SkyMask;
2584 if((ifoID==-1)||(
i==ifoID)||(
i==(ifoID+nIFO))) frlist.push_back(
FRF[
i]);
2599 for(
int n=0;
n<
nIFO;
n++)
if(ifo.CompareTo(this->ifo[
n])==0) {ifoID=
n;
break;}
2602 cout <<
"cwb::GetFrList - Error : requested ifo " << ifo
2603 <<
" not present !!!" << endl;;
2607 return GetFrList(ifoID);
std::vector< char * > ifoName
CWB_JOBF_OPTIONS jobfOptions
detector * getifo(size_t n)
param: detector index
int jobID
category 2 data quality list
virtual void resize(unsigned int)
CWB::frame fr[2 *NIFO_MAX]
void PrintElapsedTime(int job_elapsed_time, TString info)
TString GetAnalysisInfo(CWB_STAGE stage, TString comment, TString info)
cwb(CWB_STAGE jstage=CWB_STAGE_FULL)
static size_t GetProcInfo(bool mvirtual=true)
WSeries< double > pixeLHood
void Export(TString fname="")
void cwb_jnet(TString jName="", TString uName="")
void FileGarbageCollector(TString ifName, TString ofName="", vector< TString > delObjList=vector< TString >())
void Print(Option_t *option="")
size_t add(detector *)
param: detector structure return number of detectors in the network
bool singleDetector
used for the stage stuff
size_t readMDClog(char *, double=0., int=11, int=12)
param: MDC log file param: approximate gps time
void setAntenna(detector *)
param: detector (use theta, phi index array)
int nfrFiles[2 *NIFO_MAX]
virtual void rate(double r)
CWB SetSkyMask(net, cfg, cfg->skyMaskCCFile, 'c')
void CWB_Plugin(TFile *jfile, CWB::config *, network *, WSeries< double > *, TString, int)
COHERENCE.
vector< frfile > GetFrList(int ifoID=-1)
char * watversion(char c='s')
size_t setIndexMode(size_t=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<< "\ 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 > * > RWFP
CWB::frame fr(FRLIST_NAME)
size_t setSkyMask(double f, char *fname)
CWB_JOBF_OPTIONS jobfOptions
TString GetStageInfo(CWB_STAGE stage, TString comment, TString fname="")
virtual double ReadData(double mdcShift, int ifactor)
double getTheta(size_t i)
virtual void start(double s)
vector< waveSegment > detSegs_dq2
std::vector< double > mdcTime
void Import(TString umacro="")
void setRunID(size_t n)
param: run
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
network ** net
NOISE_MDC_SIMULATION.
void constraint(double d=1., double g=0.0001)
param: constraint parameter, p=0 - no constraint
vector< waveSegment > detSegs
time delay difference
void setTimeRange(int xstart=0, int xstop=0)
detectorParams detParms[NIFO_MAX]
std::vector< double > livTime
static TString GetStageString(CWB_STAGE jstage)
void PrintAnalysisInfo(CWB_STAGE stage, TString comment, TString info, bool out=true, bool log=true)
void SetupStage(CWB_STAGE jstage)
CWB_OUTF_OPTIONS outfOptions
#define IMPORT(TYPE, VAR)
char * GetLog(char *Stage, int index)
int GetLogSize(char *Stage)
virtual void run(int runID=0)
std::vector< std::string > mdcList
double getDelay(const char *c="")
WSeries< double > pTF[nRES]
printf("total live time: non-zero lags = %10.1f \, liveTot)
double dataShift[NIFO_MAX]
void setVerbose(bool verbose=true)
void PrintStageInfo(CWB_STAGE stage, TString comment, bool out=true, bool log=true, TString fname="")
void Exec(char *command, int maxtry=3, bool verbose=true)
std::vector< waveSegment > segList
virtual void DataConditioning(int ifactor)
std::vector< wavearray< double > * > IWFP
void PrintElapsedTime(int job_elapsed_time, double cpu_time, TString info)
vector< waveSegment > cat1List
void setSRIndex(int srIndex)
void setDelay(const char *="L1")
cout<< endl;cout<< "Unfinished Jobs : "<< cnt<< "/"<< jobList.size()<< endl;cout<< endl;sprintf(dagfile,"%s/%s.dag.recovery.%d", condor_dir, data_label, iversion);cout<< "To submit condor recovered jobs, type :"<< endl;cout<< "cwb_condor submit "<< dagfile<< endl;} cout<< endl;if(gSystem->Getenv("_USE_LSF")!=NULL) { TString cwb_stage_label="supercluster_";if(cwb_stage_input=="FULL") cwb_stage_label="wave_";if(cwb_stage_input=="INIT") cwb_stage_label="init_";if(cwb_stage_input=="STRAIN") cwb_stage_label="strain_";if(cwb_stage_input=="CSTRAIN") cwb_stage_label="cstrain_";if(cwb_stage_input=="COHERENCE") cwb_stage_label="coherence_";if(cwb_stage_input=="SUPERCLUSTER") cwb_stage_label="supercluster_";if(cwb_stage_input=="LIKELIHOOD") cwb_stage_label="wave_";int jobID=1;TString exec_cmd=TString::Format("export file_n_st=""$(ls %s*_job%i.root)""", cwb_stage_label.Data(), jobID);gSystem-> Exec(exec_cmd)
vector< waveSegment > detSegs
#define EXPORT(TYPE, VAR, CMD)
void PrintAnalysis(bool stageInfos=true)
WSeries< double > * getTFmap()
param: no parameters
static void MakeSkyMask(skymap &SkyMask, double theta, double phi, double radius)
virtual void InitHistory()
double fabs(const Complex &x)
int SetSkyMask(network *net, CWB::config *cfg, char *options, char skycoord, double skyres=-1)
void AddLog(char *Stage, char *Log, TDatime *Time=NULL)
void LoadPlugin(TMacro &plugin, TMacro &configPlugin)
strcpy(RunLabel, RUN_LABEL)
cout<< "total cat1 livetime : "<< int(cat1_time)<< " sec "<< cat1_time/3600.<< " h "<< cat1_time/86400.<< " day"<< endl;cout<< endl;vector< waveSegment > cat2List
netcluster * getwc(size_t n)
param: delay index
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
frfile getFrList(int istart, int istop, int segEdge)
void set(size_t i, double a)
param: sky index param: value to set
SortOrderType SetSortOrder(SortOrderType SortOrder)
double factors[FACTORS_MAX]
WaveDWT< DataType_t > * pWavelet
void GeographicToCwb(double ilongitude, double ilatitude, double &olongitude, double &olatitude)
char * GetHistory(char *StageName, char *Type)
void setRetryTime(int frRetryTime=60)
cout<< fr.getNfiles()<< endl;std::vector< frfile > frlist
virtual void SuperCluster(int ifactor)
void open(TString ioFile, TString chName="", Option_t *option="", bool onDisk=false, TString label=".gwf", unsigned int mode=0)
virtual void Coherence(int ifactor)
virtual void resize(unsigned int)
int setTimeShifts(size_t=1, double=1., size_t=0, size_t=0, const char *=NULL, const char *="w", size_t *=NULL)
param number of time lags param time shift step in seconds param first lag ID param maximum lag ID pa...
void AddHistory(char *Stage, char *Type, char *History, TDatime *Time=NULL)
char frFiles[2 *NIFO_MAX][1024]
virtual void InitNetwork()
void SetSingleDetectorMode()
void setSkyMaps(double, double=0., double=180., double=0., double=360.)
param: sky map granularity step, degrees param: theta begin, degrees param: theta end...