Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_MakeScalogram.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 #define XIFO 4
20 
21 #pragma GCC system_header
22 
23 #include "cwb.hh"
24 #include "config.hh"
25 #include "network.hh"
26 #include "wavearray.hh"
27 #include "TString.h"
28 #include "TObjArray.h"
29 #include "TObjString.h"
30 #include "TRandom.h"
31 #include "Toolbox.hh"
32 #include "watplot.hh"
33 
34 void
36 //!DISPLAY_SPECTRA
37 // Plugin to produce scalograms of input data
38 
39  cout << endl;
40  cout << "-----> CWB_Plugin_MakeScalogram.C" << endl;
41  cout << "ifo " << ifo.Data() << endl;
42  cout << "type " << type << endl;
43  cout << endl;
44 
45 // CWB_PLUGIN stage = CWB_PLUGIN_STRAIN;
46 // CWB_PLUGIN stage = CWB_PLUGIN_MDC;
47 // CWB_PLUGIN stage = CWB_PLUGIN_STRAIN_AND_MDC;
49 
50  if(type==stage) {
51  TString data_type="unknown";
52  if(stage==CWB_PLUGIN_STRAIN) data_type="strain";
53  if(stage==CWB_PLUGIN_MDC) data_type="mdc";
54  if(stage==CWB_PLUGIN_STRAIN_AND_MDC) data_type="strain_and_mdc";
55  if(stage==CWB_PLUGIN_WHITE) data_type="white";
56 
57  bool isWavearray=false;
58  if(TString(cfg->analysis)=="1G") {
59  if(stage==CWB_PLUGIN_STRAIN) isWavearray=true;
60  if(stage==CWB_PLUGIN_MDC) isWavearray=true;
61  if(stage==CWB_PLUGIN_STRAIN_AND_MDC) isWavearray=false;
62  if(stage==CWB_PLUGIN_WHITE) isWavearray=false;
63  }
64  if(TString(cfg->analysis)=="2G") {
65  if(stage==CWB_PLUGIN_STRAIN) isWavearray=true;
66  if(stage==CWB_PLUGIN_MDC) isWavearray=true;
67  if(stage==CWB_PLUGIN_STRAIN_AND_MDC) isWavearray=true;
68  if(stage==CWB_PLUGIN_WHITE) isWavearray=true;
69  }
70 
71  WSeries<double>* w = NULL;
72  if(isWavearray) { // x is a wavearray
73  // input x is a wavearray and must be converted in a WSeries<double> type and apply Forward
74  cout << "Input data is a wavearray" << endl;
75  Meyer<double> S(1024,2);
76  w = new WSeries<double>();
77  w->Forward(*x,S,cfg->levelD);
78  } else { // x is wseries
79  cout << "Input data is a wseries" << endl;
80  w = x;
81  }
82 
83  cout << "Decomposition Level : " << w->getLevel() << endl;
84 
85  watplot WTS(const_cast<char*>("wtswrc"));
86  //scalogram maps
87  double start = w->start()+cfg->segEdge;
88  double stop = w->start()+w->size()/w->rate()-cfg->segEdge;
89  double flow = 64;
90  double fhigh = 2048;
91  WTS.plot(w, 2, start, stop,const_cast<char*>("COLZ"));
92  WTS.hist2D->GetYaxis()->SetRangeUser(flow, fhigh);
93  // dump spectrum
94  char fname[1024];
95  sprintf(fname,"%s/scalogram_%s_%s_%d_%s_lev%d_job%lu.root",cfg->dump_dir,data_type.Data(),ifo.Data(),
96  int(w->start()),cfg->data_label,w->getLevel(),net->nRun);
97  cout << endl << "Dump Scalogram : " << fname << endl << endl;
98  WTS.canvas->Print(fname);
99  int nIFO=net->ifoListSize();
100  if(isWavearray) delete w;
101  if(TString(ifo).CompareTo(net->ifoName[nIFO-1])==0) gSystem->Exit(0); // last ifo
102  }
103 
104  return;
105 }
std::vector< char * > ifoName
Definition: network.hh:609
CWB::config * cfg
char analysis[8]
Definition: config.hh:117
virtual void rate(double r)
Definition: wavearray.hh:141
TString("c")
size_t nRun
Definition: network.hh:572
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
CWB_PLUGIN
Definition: cwb.hh:92
virtual void start(double s)
Definition: wavearray.hh:137
void plot(wavearray< double > &, char *=NULL, int=1, double=0., double=0., bool=false, float=0., float=0., bool=false, float=0., bool=false)
Definition: watplot.cc:150
int levelD
Definition: config.hh:154
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
TH2F * hist2D
Definition: watplot.hh:193
size_t ifoListSize()
Definition: network.hh:431
wavearray< double > w
Definition: Test1.C:27
double segEdge
Definition: config.hh:164
#define nIFO
virtual size_t size() const
Definition: wavearray.hh:145
TCanvas * canvas
Definition: watplot.hh:192
int getLevel()
Definition: wseries.hh:109
jfile
Definition: cwb_job_obj.C:43
watplot * WTS
Definition: ChirpMass.C:119
i() int(T_cor *100))
double fhigh
char fname[1024]
double flow
Definition: Meyer.hh:36
char dump_dir[1024]
Definition: config.hh:328
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:246
Meyer< double > S(1024, 2)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
char data_label[1024]
Definition: config.hh:332
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.