Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_nRMS.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 "cwb2G.hh"
25 #include "config.hh"
26 #include "network.hh"
27 #include "wavearray.hh"
28 #include "gwavearray.hh"
29 #include "TString.h"
30 #include "TObjArray.h"
31 #include "TObjString.h"
32 #include "TRandom.h"
33 #include "TComplex.h"
34 #include "TMath.h"
35 #include "mdc.hh"
36 #include <vector>
37 
38 //!DATA_CONDITIONING
39 
40 // This plugin is used to save the nRMS wseries into the job root file
41 // nRMS contains the estimated noise rms used to whitening the strain data
42 // Must be used with lagSize=1, slagSize=1, simulation=0 and input stage = CSTRAIN
43 //
44 // To use in interactive mode do :
45 // cwb_inet2G config/user_parameters.C CSTRAIN #job
46 // the cstrain job file is saved under the data directory
47 //
48 // To use in batch mode do :
49 // cwb_condor create CSTRAIN
50 // cwb_condor submit
51 // the cstrain job files are saved under the output directory
52 //
53 
54 void
56 
57  if(type==CWB_PLUGIN_CONFIG) {
58 
59  // import istage,jstage
60  int gISTAGE=-1; IMPORT(int,gISTAGE)
61  int gJSTAGE=-1; IMPORT(int,gJSTAGE)
62 
63  if(gJSTAGE!=CWB_STAGE_CSTRAIN)
64  {cout << "CWB_Plugin_nRMS - Error : input stage must be CSTRAIN" << endl;gSystem->Exit(1);}
65 
66  if(cfg->simulation!=0)
67  {cout << "CWB_Plugin_nRMS - Error : simulation must be 0" << endl;gSystem->Exit(1);}
68 
69  if(cfg->lagSize!=1)
70  {cout << "CWB_Plugin_nRMS - Error : lagSize must be 1" << endl;gSystem->Exit(1);}
71 
72  if(cfg->slagSize!=1)
73  {cout << "CWB_Plugin_nRMS - Error : slagSize must be 1" << endl;gSystem->Exit(1);}
74  }
75 
76  if(type==CWB_PLUGIN_OREADDATA) {
77 
78  // import pointer to object cwb2G
79  cwb2G* gCWB2G; IMPORT(cwb2G*,gCWB2G)
80 
81  // disable the builtin save cstrain & rms
83  }
84 
86 
87  // get ifo ID
88  int ifoID =0; for(int n=0;n<cfg->nIFO;n++) if(ifo==net->getifo(n)->Name) {ifoID=n;break;}
89  // get detector pointer
90  detector* pD = net->getifo(ifoID);
91  // import factor
92  int gIFACTOR=-1; IMPORT(int,gIFACTOR)
93 
94  // create the rms directory in root file
95  jfile->cd();
96  TDirectory* drms = (TDirectory*)jfile->Get("rms");
97  if(drms==NULL) drms=jfile->mkdir("rms");
98  drms->cd();
99  char cdrms_name[32];sprintf(cdrms_name,"rms-f%d",gIFACTOR);
100  TDirectory* cdrms = (TDirectory*)drms->Get(cdrms_name);
101  if(cdrms==NULL) cdrms=drms->mkdir(cdrms_name);
102 
103  // save nRMS
104  cdrms->cd();pD->nRMS.Write(pD->Name);
105  }
106 
107 }
detector * getifo(size_t n)
param: detector index
Definition: network.hh:436
CWB::config * cfg
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 CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
DATA_CONDITIONING.
char ifo[NIFO_MAX][8]
Definition: cwb2G.hh:33
network ** net
NOISE_MDC_SIMULATION.
jfile
Definition: cwb_job_obj.C:43
int simulation
Definition: config.hh:199
#define IMPORT(TYPE, VAR)
Definition: cwb.hh:69
WSeries< double > nRMS
Definition: detector.hh:358
int slagSize
Definition: config.hh:181
size_t lagSize
Definition: config.hh:168
char Name[16]
Definition: detector.hh:327
unsigned int jobfOptions
history object
Definition: cwb.hh:276
int gIFACTOR
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
int nIFO
Definition: config.hh:120
detector ** pD