Logo coherent WaveBurst  
Library Reference Guide
Logo
MergeDataPE.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 int ReadConfig(TString ifconfig, vector<TString> &gwname, vector<TString> &wpath, vector<TString> &rdir);
20 
21 void MergeDataPE(TString side, TString odir, TString ifconfig) {
22 
23  cout<<"MergeDataPE.C init ..."<<endl;
24 
25 // CWB::Toolbox::checkFile(odir); // check if odir exist
26 
27  gSystem->Exec("date");
28 
29  vector<TString> gwname;
30  vector<TString> wpath;
31  vector<TString> rdir;
32  int gwsize = ReadConfig(ifconfig, gwname, wpath, rdir);
33 
34  vector<TString> rpath(gwsize);
35 
36 // for(int i=0;i<gwsize;i++) rpath[i] = wpath[i]+"/report/dump/"+rdir[i]+"/"+side;
37 // for(int i=0;i<gwsize;i++) cout << rpath[i] << endl;
38 
39  for(int i=0;i<gwsize;i++) {
40  rpath[i] = wpath[i]+"/report/dump/"+rdir[i]+"/"+side+"/distributions";
41  char cmd1[1024];
42  char cmd2[1024];
43  char cmd3[1024];
44  if(i==0) {
45  sprintf(cmd1,"cat %s/*_ResidualEnergy.txt > %s/ResidualEnergy.txt",rpath[i].Data(),odir.Data());
46  sprintf(cmd2,"cat %s/*_FittingFactor.txt > %s/FittingFactor.txt",rpath[i].Data(),odir.Data());
47  sprintf(cmd3,"cat %s/*_OverlapFactor.txt > %s/OverlapFactor.txt",rpath[i].Data(),odir.Data());
48  } else {
49  sprintf(cmd1,"cat %s/*_ResidualEnergy.txt >> %s/ResidualEnergy.txt",rpath[i].Data(),odir.Data());
50  sprintf(cmd2,"cat %s/*_FittingFactor.txt >> %s/FittingFactor.txt",rpath[i].Data(),odir.Data());
51  sprintf(cmd3,"cat %s/*_OverlapFactor.txt >> %s/OverlapFactor.txt",rpath[i].Data(),odir.Data());
52  }
53  cout << cmd1 << endl;
54  gSystem->Exec(cmd1);
55  cout << cmd2 << endl;
56  gSystem->Exec(cmd2);
57  cout << cmd3 << endl;
58  gSystem->Exec(cmd3);
59  }
60 
61  for(int i=0;i<gwsize;i++) {
62  rpath[i] = wpath[i]+"/report/dump/"+rdir[i]+"/"+side+"/distributions";
63  char cmd1[1024];
64  char cmd2[1024];
65  char cmd3[1024];
66  if(i==0) {
67  sprintf(cmd1,"cat %s/*_ResidualEnergy_sensitivity.txt > %s/ResidualEnergy_sensitivity.txt",rpath[i].Data(),odir.Data());
68  sprintf(cmd2,"cat %s/*_FittingFactor_sensitivity.txt > %s/FittingFactor_sensitivity.txt",rpath[i].Data(),odir.Data());
69  sprintf(cmd3,"cat %s/*_OverlapFactor_sensitivity.txt > %s/OverlapFactor_sensitivity.txt",rpath[i].Data(),odir.Data());
70  } else {
71  sprintf(cmd1,"cat %s/*_ResidualEnergy_sensitivity.txt >> %s/ResidualEnergy_sensitivity.txt",rpath[i].Data(),odir.Data());
72  sprintf(cmd2,"cat %s/*_FittingFactor_sensitivity.txt >> %s/FittingFactor_sensitivity.txt",rpath[i].Data(),odir.Data());
73  sprintf(cmd3,"cat %s/*_OverlapFactor_sensitivity.txt >> %s/OverlapFactor_sensitivity.txt",rpath[i].Data(),odir.Data());
74  }
75  cout << cmd1 << endl;
76  gSystem->Exec(cmd1);
77  cout << cmd2 << endl;
78  gSystem->Exec(cmd2);
79  cout << cmd3 << endl;
80  gSystem->Exec(cmd3);
81  }
82 
83  for(int i=0;i<gwsize;i++) {
84  rpath[i] = wpath[i]+"/report/dump/"+rdir[i]+"/"+side+"/distributions";
85  char cmd1[1024];
86  char cmd2[1024];
87  char cmd3[1024];
88  if(i==0) {
89  sprintf(cmd1,"cat %s/*_ResidualEnergy_onsource_prob.txt > %s/ResidualEnergy_onsource_prob.txt",rpath[i].Data(),odir.Data());
90  sprintf(cmd2,"cat %s/*_FittingFactor_onsource_prob.txt > %s/FittingFactor_onsource_prob.txt",rpath[i].Data(),odir.Data());
91  sprintf(cmd3,"cat %s/*_OverlapFactor_onsource_prob.txt > %s/OverlapFactor_onsource_prob.txt",rpath[i].Data(),odir.Data());
92  } else {
93  sprintf(cmd1,"cat %s/*_ResidualEnergy_onsource_prob.txt >> %s/ResidualEnergy_onsource_prob.txt",rpath[i].Data(),odir.Data());
94  sprintf(cmd2,"cat %s/*_FittingFactor_onsource_prob.txt >> %s/FittingFactor_onsource_prob.txt",rpath[i].Data(),odir.Data());
95  sprintf(cmd3,"cat %s/*_OverlapFactor_onsource_prob.txt >> %s/OverlapFactor_onsource_prob.txt",rpath[i].Data(),odir.Data());
96  }
97  cout << cmd1 << endl;
98  gSystem->Exec(cmd1);
99  cout << cmd2 << endl;
100  gSystem->Exec(cmd2);
101  cout << cmd3 << endl;
102  gSystem->Exec(cmd3);
103  }
104 
105  exit(0);
106 }
107 
108 int ReadConfig(TString ifconfig, vector<TString> &gwname, vector<TString> &wpath, vector<TString> &rdir) {
109 
110  ifstream in;
111  in.open(ifconfig.Data(),ios::in);
112  if (!in.good()) {cout << "MergeDataPE::ReadConfig Error Opening File : " << ifconfig.Data() << endl;exit(1);}
113 
114  bool start=false;
115  char log[1024];
116  while(true) {
117  in.getline(log,1024);
118  if (!in.good()) break;
119  if(log[0]=='#') continue;
120  TString line = log;
121  if(line.Contains("ifeq") && line.Contains("$(GW_NAME)")) {
122  start=true;
123  TString gw = line(line.Index(',')+1, line.Last(')')-line.Index(',')-1);
124  gwname.push_back(gw);
125  //cout << gw << endl;
126  }
127  if(line.Contains("endif") && start==true) start=false;
128  if(start) {
129  if(line.Contains("PE_OFFPATH")) {
130  TString path = line(line.Index('/'), line.Sizeof()-line.Index(',')-1);
131  wpath.push_back(path);
132  //cout << path << endl;
133  }
134  if(line.Contains("PE_RDIR")) {
135  TString dir = line(line.Index('=')+1, line.Sizeof()-line.Index(',')-2);
136  dir.ReplaceAll(" ","");
137  rdir.push_back(dir);
138  //cout << dir << endl;
139  }
140  }
141  }
142 
143  in.close();
144 
145  if((wpath.size() != gwname.size())) {
146  cout << "MergeDataPE::ReadConfig - missing PE_OFFPATH config declarations: MISSED = "
147  << gwname.size()-wpath.size() << " in file " << ifconfig << endl;exit(1);
148  }
149  if((rdir.size() != gwname.size())) {
150  cout << "MergeDataPE::ReadConfig - missing PE_RDIR config declarations: MISSED = "
151  << gwname.size()-rdir.size() << " in file " << ifconfig << endl;exit(1);
152  }
153 
154  for(int i=0;i<gwname.size();i++) cout << i << "\t" << gwname[i] << endl;
155  for(int i=0;i<gwname.size();i++) cout << i << "\t" << wpath[i] << endl;
156  for(int i=0;i<gwname.size();i++) cout << i << "\t" << rdir[i] << endl;
157 
158  return gwname.size();
159 }
160 
TString("c")
char odir[1024]
i drho i
gWSeries< double > gw(w)
bool log
Definition: WaveMDC.C:41
void MergeDataPE(TString side, TString odir, TString ifconfig)
Definition: MergeDataPE.C:21
ifstream in
int ReadConfig(TString ifconfig, vector< TString > &gwname, vector< TString > &wpath, vector< TString > &rdir)
Definition: MergeDataPE.C:108
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
char line[1024]
exit(0)