Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_SGW.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 "TComplex.h"
32 #include "TMath.h"
33 #include "mdc.hh"
34 #include <vector>
35 
36 
37 // ---------------------------------------------------------------------------------
38 // DEFINES
39 // ---------------------------------------------------------------------------------
40 
41 #define SGW_MDC_POLARIZATION "SCALAR"
42 #define SGW_SEARCH_POLARIZATION "SCALAR"
43 
44 // ---------------------------------------------------------------------------------
45 // USER SGW PLUGIN OPTIONS
46 // ---------------------------------------------------------------------------------
47 
48 struct uoptions {
49  TString mdc_polarization; // SCALAR/TENSOR polarizations used for MDC
50  TString search_polarization; // SCALAR/TENSOR polarizations used for SEARCH
51 };
52 
53 // ---------------------------------------------------------------------------------
54 // FUNCTIONS
55 // ---------------------------------------------------------------------------------
56 
57 void ResetUserOptions();
60 
61 // ---------------------------------------------------------------------------------
62 // Global Variables
63 // ---------------------------------------------------------------------------------
64 
65 uoptions gOPT; // global User Options
66 
67 void
69 
70  cout << endl;
71  cout << "-----> macro/CWB_Plugin_SGW.C" << endl;
72  cout << "ifo " << ifo.Data() << endl;
73  cout << "type " << type << endl;
74  cout << endl;
75 
76 
77  if(type==CWB_PLUGIN_CONFIG) {
78  ResetUserOptions(); // set default config options
79  ReadUserOptions(cfg->parPlugin); // user config options : read from parPlugin
80 
81  if(gOPT.search_polarization=="SCALAR") cfg->gamma = -1.0; // force hard constrain for SGW
82  }
83 
84  if(type==CWB_PLUGIN_NETWORK) {
85  // set polarization for MDC
86  PrintUserOptions(cfg); // print config options
87  for(int n=0;n<(int)net->ifoListSize();n++) {
88  detector *d = net->getifo(n);
89  d->setPolarization(gOPT.mdc_polarization=="SCALAR" ? SCALAR : TENSOR);
90  }
91  // restore skymaps
92  if(cfg->healpix) net->setSkyMaps(int(cfg->healpix));
93  else net->setSkyMaps(cfg->angle,cfg->Theta1,cfg->Theta2,cfg->Phi1,cfg->Phi2);
94  net->setAntenna();
95  net->setDelay(cfg->refIFO);
96  }
97 
98 
99  if(type==CWB_PLUGIN_ICOHERENCE) {
100  // set polarization for SEARCH
101  PrintUserOptions(cfg); // print config options
102  for(int n=0;n<(int)net->ifoListSize();n++) {
103  detector *d = net->getifo(n);
104  d->setPolarization(gOPT.search_polarization=="SCALAR" ? SCALAR : TENSOR);
105  }
106  // restore skymaps
107  if(cfg->healpix) net->setSkyMaps(int(cfg->healpix));
108  else net->setSkyMaps(cfg->angle,cfg->Theta1,cfg->Theta2,cfg->Phi1,cfg->Phi2);
109  net->setAntenna();
110  net->setDelay(cfg->refIFO);
111  }
112 
113  return;
114 }
115 
117 
118  // get plugin options
119 
120  if(TString(options)!="") {
121 
122  //cout << "SGW options : " << options << endl;
123  TObjArray* token = TString(options).Tokenize(TString(' '));
124  for(int j=0;j<token->GetEntries();j++) {
125 
126  TObjString* tok = (TObjString*)token->At(j);
127  TString stok = tok->GetString();
128 
129  if(stok.Contains("--sgw_mdc_polarization=")) {
130  gOPT.mdc_polarization=stok;
131  gOPT.mdc_polarization.Remove(0,gOPT.mdc_polarization.Last('=')+1);
132  gOPT.mdc_polarization.ToUpper();;
133  }
134  if(gOPT.mdc_polarization!="TENSOR" && gOPT.mdc_polarization!="SCALAR") {
135  cout << "CWB_Plugin_SGW Error : parameter sgw_mdc_polarization must be : SCALAR/TENSOR" << endl;
136  gSystem->Exit(1);
137  }
138 
139  if(stok.Contains("--sgw_search_polarization=")) {
140  gOPT.search_polarization=stok;
141  gOPT.search_polarization.Remove(0,gOPT.search_polarization.Last('=')+1);
142  gOPT.search_polarization.ToUpper();;
143  }
144  if(gOPT.search_polarization!="TENSOR" && gOPT.search_polarization!="SCALAR") {
145  cout << "CWB_Plugin_SGW Error : parameter sgw_search_polarization must be : SCALAR/TENSOR" << endl;
146  gSystem->Exit(1);
147  }
148 
149  }
150  }
151 }
152 
154 
155  gOPT.mdc_polarization = SGW_MDC_POLARIZATION;
156  gOPT.search_polarization = SGW_SEARCH_POLARIZATION;
157 }
158 
159 
161 
162  cout << "-----------------------------------------" << endl;
163  cout << "SGW config options " << endl;
164  cout << "-----------------------------------------" << endl << endl;
165  cout << "SGW_MDC_POLARIZATION " << gOPT.mdc_polarization << endl;
166  cout << "SGW_SEARCH_POLARIZATION " << gOPT.search_polarization << endl;
167  cout << endl;
168 }
169 
detector * getifo(size_t n)
param: detector index
Definition: network.hh:436
CWB::config * cfg
uoptions gOPT
void setAntenna(detector *)
param: detector (use theta, phi index array)
Definition: network.cc:2846
int n
Definition: cwb_net.C:28
TString("c")
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
void PrintUserOptions(CWB::config *cfg)
void setPolarization(POLARIZATION polarization=TENSOR)
Definition: detector.hh:306
int j
Definition: cwb_net.C:28
double Phi1
Definition: config.hh:279
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
size_t ifoListSize()
Definition: network.hh:431
double Theta2
Definition: config.hh:278
void ResetUserOptions()
jfile
Definition: cwb_job_obj.C:43
i() int(T_cor *100))
char parPlugin[1024]
Definition: config.hh:363
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
#define SGW_SEARCH_POLARIZATION
size_t healpix
Definition: config.hh:282
char refIFO[4]
Definition: config.hh:125
TObjArray * token
void setDelay(const char *="L1")
Definition: network.cc:2767
void ReadUserOptions(TString options)
char options[256]
double Phi2
Definition: config.hh:280
double Theta1
Definition: config.hh:277
double gamma
Definition: config.hh:258
double angle
Definition: config.hh:276
void setSkyMaps(double, double=0., double=180., double=0., double=360.)
param: sky map granularity step, degrees param: theta begin, degrees param: theta end...
Definition: network.cc:2687
#define SGW_MDC_POLARIZATION