Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ReadCStrainFromJobFile.C
Go to the documentation of this file.
1 //
2 // read & display conditioned strain from job cstrain file
3 // Author : Gabriele Vedovato
4 
5 {
6  //#define DISPLAY_TIME
7  #define DISPLAY_PSD
8  #define JOB_CSTRAIN_FILE "data/cstrain_XXXX_jobYY.root" // define cstrain root file
9  #define FACTOR_INDEX 0
10 
11  #define SCRATCH_TIME 10 // is the segEdge parameter (sec)
12 
13  int nIFO = 2;
14  TString ifo[2] = {"L1","H1"};
15  wavearray<double> hot[2]; //! temporary time series
18  double factor=10.*sqrt(nIFO);
20 
21  // open input job file
22  TFile* jfile = new TFile(jname);
23  if(jfile==NULL||!jfile->IsOpen())
24  {cout << "Error : file " << jname << " not found" << endl;exit(1);}
25 
26  char cstrain_dir[32];sprintf(cstrain_dir,"cstrain/cstrain-f%d",FACTOR_INDEX);
27  for(int i=0; i<nIFO; i++) {
28  // read ifo strain from temporary job file
29  px = (wavearray<double>*)jfile->Get(TString(cstrain_dir)+"/"+ifo[i]);
30  if(px==NULL) {cout<<"Error : "<<cstrain_dir<<" not present"<<endl;exit(1);}
31  hot[i] = *px; delete px;
32 
33  cout.precision(14);
34  cout << hot[i].size() << " " << hot[i].rate() << " " << hot[i].start() << endl;
35 
36  int jS = SCRATCH_TIME*hot[i].rate();
37  int jE = hot[i].size()-jS;
38  cout << "DEB SIZE " << hot[i].size() << " " << hot[i].rate() << " " << int(hot[i].start()) << endl;
39 
40  double rms=0;
41  for(int j=jS; j<jE; j++) {
42  //if(fabs(hot[i].data[j])>1) cout << "DEB0 " << i << " " << n << " " << hot[i].data[j] << endl;
43  rms+=pow(hot[i].data[j],2);
44  }
45  rms/=(jE-jS);
46  cout << "DEB RMS = " << sqrt(rms) << endl;
47 
48  }
49 
50 #if defined (DISPLAY_TIME) || defined (DISPLAY_PSD)
51  for(int n=0;n<nIFO;n++) hot[n].start(0);
52  watplot plot(const_cast<char*>("plot"),200,20,800,500);
53  char gtitle[256];
54  sprintf(gtitle,"Network : ");
55  for(int n=0;n<nIFO;n++) {
56  if(n==0) sprintf(gtitle,"%s %s (black) ", gtitle, ifo[n].Data());
57  if(n==1) sprintf(gtitle,"%s %s (red) ", gtitle, ifo[n].Data());
58  if(n==2) sprintf(gtitle,"%s %s (green) ", gtitle, ifo[n].Data());
59  }
60 
61 #ifdef DISPLAY_TIME
62  plot.gtitle(gtitle,"time (sec)","strain");
63  plot.goptions(const_cast<char*>("alp"), 1, 0., 0.);
64 #endif
65 
66 #ifdef DISPLAY_PSD
67  double flow=64;
68  double fhigh=2048;
69  double tstart = hot[0].start();
70  double tstop = tstart+hot[0].size()/hot[0].rate();
71  plot.gtitle(gtitle,"frequency (Hz)","strain/#sqrt{Hz}");
72  plot.goptions(const_cast<char*>("alp logx logy"), 1, tstart, tstop, true, flow,fhigh, true, 4);
73 #endif
74 
75  for(int n=0;n<nIFO;n++) hot[n] >> plot;
76 #endif
77 
78 }
char cstrain_dir[32]
virtual size_t size() const
Definition: wavearray.hh:127
#define FACTOR_INDEX
virtual void rate(double r)
Definition: wavearray.hh:123
int n
Definition: cwb_net.C:10
#define SCRATCH_TIME
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
TString("c")
wavearray< double > x
temporary time series
plot gtitle(gtitle,"frequency (Hz)","strain/#sqrt{Hz}")
virtual void start(double s)
Definition: wavearray.hh:119
int j
Definition: cwb_net.C:10
i drho i
#define nIFO
double tstart
double factor
x plot
wavearray< double > hot[2]
wavearray< double > * px
sprintf(cstrain_dir,"cstrain/cstrain-f%d", FACTOR_INDEX)
i() int(T_cor *100))
double fhigh
TFile * jfile
double tstop
double flow
TString ifo[2]
TString jname
exit(0)
#define JOB_CSTRAIN_FILE