Logo coherent WaveBurst  
Library Reference Guide
Logo
MakePeriodicDQ.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 // This macro is used to generate periodic DQ when CWB_Plugin_Periodic_Frames.C is used
20 
21 void MakePeriodicDQ(TString dq_idir, double period, int nperiod=10, TString dq_odir="") {
22 //
23 // dq_idir: input Data Quality directory
24 // period: period to generate periodc DQ
25 // nperiod: number of periods to be generated
26 // dq_odir: output Data Quality directory
27 
28  #include <vector>
29 
31 
32  vector<TString> dqfList = TB.getFileListFromDir(dq_idir, ".txt","","_cat");
33 
34  dqfile* DQF = new dqfile[dqfList.size()];
35  for(int i=0;i<dqfList.size();i++) {
36  cout << i << " MakePeriodicDQ - Input File: " << dqfList[i] << endl;
37  vector<waveSegment> dqList = TB.readSegments(dqfList[i]);
38 // cout<<endl<<"-------------------------------------------------------------------------------------"<< endl;
39 // for(int j=0;j<dqList.size();j++) cout << j << " " << (int)dqList[j].start << " " << (int)dqList[j].stop << endl;
40 
41  vector<waveSegment> xdqList = dqList;
42  for(int j=0;j<dqList.size();j++) {
43  for(int k=-nperiod; k<=nperiod; k++) {
44  waveSegment seg = dqList[j];
45  seg.start += k*period;
46  seg.stop += k*period;
47  xdqList.push_back(seg);
48  }
49  }
50  xdqList = TB.unionSegments(xdqList);
51 // cout<<endl<<"-------------------------------------------------------------------------------------"<< endl;
52 // for(int j=0;j<xdqList.size();j++) cout << j << " " << (int)xdqList[j].start << " " << (int)xdqList[j].stop << endl;
53 
54  if(dq_odir!="") {
55  TString fName = TString::Format("%s/%s",dq_odir.Data(),gSystem->BaseName(dqfList[i]));
56  TB.dumpSegList(xdqList, fName, false);
57  }
58  }
59 
60  exit(0);
61 }
double start
Definition: network.hh:55
static vector< TString > getFileListFromDir(TString dir_name, TString endString="", TString beginString="", TString containString="", bool fast=false)
Definition: Toolbox.cc:5108
TString("c")
CWB::Toolbox TB
int j
Definition: cwb_net.C:28
i drho i
static vector< waveSegment > unionSegments(vector< waveSegment > &ilist)
Definition: Toolbox.cc:119
dqfile DQF[12]
Definition: test_config1.C:171
static int dumpSegList(vector< waveSegment > list, TString fName, bool c4=false)
Definition: Toolbox.cc:571
int k
waveSegment seg
static vector< waveSegment > readSegments(TString ifile)
Definition: Toolbox.cc:74
char fName[256]
double stop
Definition: network.hh:56
exit(0)
void MakePeriodicDQ(TString dq_idir, double period, int nperiod=10, TString dq_odir="")