Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CWB_Plugin_MakeSpectrogram.C
Go to the documentation of this file.
1 #define XIFO 4
2 
3 #pragma GCC system_header
4 
5 #include "cwb.hh"
6 #include "config.hh"
7 #include "network.hh"
8 #include "wavearray.hh"
9 #include "TString.h"
10 #include "TObjArray.h"
11 #include "TObjString.h"
12 #include "TRandom.h"
13 #include "Toolbox.hh"
14 #include "STFT.hh"
15 
16 void
18 //!DISPLAY_SPECTRA
19 // Plugin to produce scalograms of input data
20 
21  cout << endl;
22  cout << "-----> CWB_Plugin_MakeSpectrogram.C" << endl;
23  cout << "ifo " << ifo.Data() << endl;
24  cout << "type " << type << endl;
25  cout << endl;
26 
27 // CWB_PLUGIN stage = CWB_PLUGIN_STRAIN;
28 // CWB_PLUGIN stage = CWB_PLUGIN_MDC;
30 // CWB_PLUGIN stage = CWB_PLUGIN_WHITE;
31 
32  if(type==stage) {
33  TString data_type="unknown";
34  if(stage==CWB_PLUGIN_STRAIN) data_type="strain";
35  if(stage==CWB_PLUGIN_MDC) data_type="mdc";
36  if(stage==CWB_PLUGIN_STRAIN_AND_MDC) data_type="strain_and_mdc";
37  if(stage==CWB_PLUGIN_WHITE) data_type="white";
38 
39  bool isWavearray=false;
40  if(TString(cfg->analysis)=="1G") {
41  if(stage==CWB_PLUGIN_STRAIN) isWavearray=true;
42  if(stage==CWB_PLUGIN_MDC) isWavearray=true;
43  if(stage==CWB_PLUGIN_STRAIN_AND_MDC) isWavearray=false;
44  if(stage==CWB_PLUGIN_WHITE) isWavearray=false;
45  }
46  if(TString(cfg->analysis)=="2G") {
47  if(stage==CWB_PLUGIN_STRAIN) isWavearray=true;
48  if(stage==CWB_PLUGIN_MDC) isWavearray=true;
49  if(stage==CWB_PLUGIN_STRAIN_AND_MDC) isWavearray=true;
50  if(stage==CWB_PLUGIN_WHITE) isWavearray=true;
51  }
52 
53  int level = 0;
54  if(isWavearray) { // x is a wavearray
55  cout << "Input data is a wavearray" << endl;
56  } else { // x is wseries
57  cout << "Input data is a wseries" << endl;
58  level = x->getLevel();
59  x->Inverse();
60  }
61 
62  cout << "Decomposition Level : " << level << endl;
63 
64  int nfact=4;
65  int nfft=nfact*512;
66  int noverlap=nfft-10;
67  double fparm=nfact*6;
68 
69  CWB::STFT stft(*x,nfft,noverlap,"energy","gauss",fparm);
70 
71  double start = x->start()+cfg->segEdge;
72  double stop = x->start()+x->size()/x->rate()-cfg->segEdge;
73  double flow = 64;
74  double fhigh = 2048;
75  stft.Draw(start,stop,flow,fhigh,0,0,1);
76  // dump spectrum
77  char fname[1024];
78  sprintf(fname,"%s/spectrogram_%s_%s_%d_%s_job%lu.root",cfg->dump_dir,data_type.Data(),ifo.Data(),
79  int(x->start()),cfg->data_label,net->nRun);
80  cout << endl << "Dump Spectrogram : " << fname << endl << endl;
81  stft.Print(fname);
82 
83  int nIFO=net->ifoListSize();
84  if(level) x->Forward(level);
85  if(TString(ifo).CompareTo(net->ifoName[nIFO-1])==0) gSystem->Exit(0); // last ifo
86  }
87 
88  return;
89 }
std::vector< char * > ifoName
Definition: network.hh:591
CWB::config * cfg
Definition: TestCWB_Plugin.C:5
char analysis[8]
Definition: config.hh:99
virtual size_t size() const
Definition: wavearray.hh:127
int noverlap
Definition: TestDelta.C:20
virtual void rate(double r)
Definition: wavearray.hh:123
void Print(TString pname)
Definition: STFT.cc:297
TString("c")
size_t nRun
Definition: network.hh:554
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<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t 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:74
int nfact
Definition: TestDelta.C:18
int nfft
Definition: TestDelta.C:19
virtual void start(double s)
Definition: wavearray.hh:119
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
void Draw(double t1=0.0, double t2=0.0, double f1=0.0, double f2=0.0, double z1=0.0, double z2=0.0, int dpaletteId=DUMMY_PALETTE_ID, Option_t *option="colfz")
Definition: STFT.cc:76
size_t ifoListSize()
Definition: network.hh:413
double segEdge
Definition: config.hh:146
#define nIFO
int getLevel()
Definition: wseries.hh:91
jfile
Definition: cwb_job_obj.C:25
i() int(T_cor *100))
double fhigh
char fname[1024]
double flow
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
char dump_dir[1024]
Definition: config.hh:310
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:228
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
char data_label[1024]
Definition: config.hh:314
void Inverse(int n=-1)
param: n - number of steps (-1 means full reconstruction)
Definition: wseries.cc:273
double fparm
Definition: TestDelta.C:22
CWB::STFT * stft
Definition: ChirpMass.C:117