Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_frdisplay.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 {
21 
22  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
23  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
24  TB.checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
25 
26  int cwb_jobid=0;
27  if(gSystem->Getenv("CWB_JOBID")==NULL) {
28  cout << "Error : environment CWB_JOBID is not defined!!!" << endl;exit(1);
29  } else {
30  if(TString(gSystem->Getenv("CWB_JOBID")).IsDigit()) {
31  cwb_jobid=TString(gSystem->Getenv("CWB_JOBID")).Atoi();
32  } else {
33  cout << "Error : environment CWB_JOBID is not defined!!!" << endl;exit(1);
34  }
35  }
36  cout << "cwb_jobid : " << cwb_jobid << endl;
37 
39  if(gSystem->Getenv("CWB_IFO")==NULL) {
40  cout << "Error : environment CWB_IFO is not defined!!!" << endl;exit(1);
41  } else {
42  cwb_ifo=TString(gSystem->Getenv("CWB_IFO"));
43  }
44  cout << "cwb_ifo : " << cwb_ifo.Data() << endl;
45 
46  TString home_frdisplay="";
47  if(gSystem->Getenv("HOME_FRDISPLAY")==NULL) {
48  cout << "Error : environment HOME_FRDISPLAY is not defined!!!" << endl;exit(1);
49  } else {
50  home_frdisplay=TString(gSystem->Getenv("HOME_FRDISPLAY"));
51  }
52  cout << "home_frdisplay : " << home_frdisplay.Data() << endl;
53 
54  // check if ifo is declared in user_parameters.C
55  bool icheck=false;
56  for(int i=0;i<nIFO;i++) {
57  if(cwb_ifo.CompareTo(ifo[i])==0) icheck=true;
58  }
59  if(!icheck) {
60  cout << "Error - ifo : " << cwb_ifo.Data() << " is not declared in "
61  << gSystem->Getenv("CWB_UPARAMETERS_FILE") << endl;
62  cout << endl << "List of allowed ifos " << endl << endl;
63  for(int i=0;i<nIFO;i++) cout << ifo[i] << endl;
64  cout << endl;
65  exit(1);
66  }
67 
68  int ifoID=0;
69  for(int i=0;i<nIFO;i++) if(cwb_ifo.CompareTo(ifo[i])==0) ifoID=i;
70  cout << "ifoID : " << ifoID << endl;
71 
72  vector<waveSegment> cat1List=TB.readSegList(nDQF, DQF, CWB_CAT1);
73  vector<waveSegment> jobList;
74  if(slagSize==0) {
75  // get standard job list
76  jobList=TB.getJobList(cat1List, segLen, segMLS, segEdge);
77  } else {
78  // get slag job list
79  jobList=TB.getSlagJobList(cat1List, segLen);
80  }
81 
82  int job_start = jobList[cwb_jobid].start;
83  int job_stop = jobList[cwb_jobid].stop;
84 
85  cout << "job_start : " << job_start << " job_stop : " << job_stop << endl;
86 
87  // prepare frame list format for frdisplay
88  gRandom->SetSeed(0);
89  int baudline_rnID = gRandom->Uniform(0,10000000); // random name ID
90 
91  UserGroup_t* uinfo = gSystem->GetUserInfo();
92 
93  char cmd[256];
94  sprintf(cmd,"mkdir -p /dev/shm/%s",uinfo->fUser.Data());
95  gSystem->Exec(cmd);
96 
97  char baudline_FFL[512];
98  sprintf(baudline_FFL,"/dev/shm/%s/cwb_frdisplay_%d.ffl",uinfo->fUser.Data(),baudline_rnID);
99  cout << "baudline_FFL : " << baudline_FFL << endl;
100 
101  ofstream out;
102  out.open(baudline_FFL,ios::out);
103  if (!out.good()) {cout << "Error Opening File : " << baudline_FFL << endl;exit(1);}
104 
105  ifstream in;
106  in.open(frFiles[ifoID],ios::in);
107  if (!in.good()) {cout << "Error Opening File : " << frFiles[ifoID] << endl;exit(1);}
108 
109  TString pfile_path="";
110  char istring[1024];
111  while (1) {
112  in >> istring;
113  if (!in.good()) break;
115  file_path.ReplaceAll("file://localhost","");
116 
118  file_path_tmp.ReplaceAll(".gwf","");
119  TObjArray* token = TString(file_path_tmp).Tokenize(TString("-"));
120  int frfile_start = ((TObjString*)token->At(token->GetEntries()-2))->GetString().Atoi();
121  int frfile_len = ((TObjString*)token->At(token->GetEntries()-1))->GetString().Atoi();
122  int frfile_stop = frfile_start+frfile_len;
123  if(frfile_stop<job_start) continue;
124  if(frfile_start>job_stop) continue;
125  out << file_path.Data() << " " << 0 << " " << 0 << " " << 0 << " " << 0 << endl;
126  cout << file_path.Data() << endl;
127  }
128  in.close();
129  out.close();
130 
131  cout << "out file : " << baudline_FFL << endl;
132 
133  sprintf(cmd,"%s/FrDisplay -d 5 -proc -t %s -i %s -k \"-Bu -Hp -o 6 -a 50\"",home_frdisplay.Data(),channelNamesRaw[ifoID],baudline_FFL);
134  cout << cmd << endl;
135  gSystem->Exec(cmd);
136  sprintf(cmd,"ps | grep baudline | awk '{print $1}' | xargs kill -9");
137  cout << cmd << endl;
138  gSystem->Exec(cmd);
139 
140  exit(0);
141 }
double segMLS
Definition: test_config1.C:47
int slagSize
Definition: test_config1.C:65
int job_start
Definition: cwb_frdisplay.C:82
int baudline_rnID
Definition: cwb_frdisplay.C:89
TString file_path
char channelNamesRaw[NIFO_MAX][50]
int frfile_len
TString("c")
int frfile_stop
ofstream out
Definition: cwb_merge.C:214
char frFiles[NIFO_MAX+1][256]
Definition: test_config1.C:166
CWB::Toolbox TB
cout<< "baudline_FFL : "<< baudline_FFL<< endl;ofstream out;out.open(baudline_FFL, ios::out);if(!out.good()) {cout<< "Error Opening File : "<< baudline_FFL<< endl;exit(1);} ifstream in;in.open(frFiles[ifoID], ios::in);if(!in.good()) {cout<< "Error Opening File : "<< frFiles[ifoID]<< endl;exit(1);} TString pfile_path="";char istring[1024];while(1) { in > istring
double segEdge
Definition: test_config1.C:49
i drho i
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
TObjArray * token
char ifo[NIFO_MAX][8]
nDQF
Definition: cwb_eced.C:109
#define nIFO
int cwb_jobid
Definition: cwb_frdisplay.C:26
char cmd[256]
Definition: cwb_frdisplay.C:93
vector< int > jobList
dqfile DQF[12]
Definition: test_config1.C:171
static vector< waveSegment > getSlagJobList(vector< waveSegment > ilist, int seglen=600)
Definition: Toolbox.cc:1791
int frfile_start
segLen
Definition: cwb_eced.C:24
TString cwb_ifo
Definition: cwb_frdisplay.C:38
UserGroup_t * uinfo
Definition: cwb_frdisplay.C:91
vector< waveSegment > cat1List
static vector< waveSegment > getJobList(vector< waveSegment > ilist, double segLen=600., double segMLS=300., double segEdge=8.)
Definition: Toolbox.cc:646
int job_stop
Definition: cwb_frdisplay.C:83
static vector< waveSegment > readSegList(dqfile DQF)
Definition: Toolbox.cc:409
TString file_path_tmp
ifstream in
char baudline_FFL[512]
Definition: cwb_frdisplay.C:97
exit(0)
sprintf(cmd,"mkdir -p /dev/shm/%s", uinfo->fUser.Data())