Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
frame.hh
Go to the documentation of this file.
1 /**********************************************************
2  * Package: frame Class Library
3  * File name: frame.hh
4  * Author: Gabriele Vedovato (vedovato@lnl.infn.it)
5  **********************************************************/
6 
7 
8 #ifndef CWBFRAME_HH
9 #define CWBFRAME_HH
10 
11 #include "TROOT.h"
12 #include "TMath.h"
13 #include "TSystem.h"
14 #include "TString.h"
15 #include "TTree.h"
16 #include "TFile.h"
17 #include "TRandom.h"
18 #include "TRandom3.h"
19 #include "TNamed.h"
20 
21 #include <string>
22 #include <iostream>
23 #include <fstream>
24 #include <stdlib.h>
25 #include <math.h>
26 #include <ctype.h>
27 #include <vector>
28 #include <string.h>
29 
30 #include "wavearray.hh"
31 #include "network.hh"
32 
33 #include "FrameL.h"
34 
35 #define LST_TREE_NAME "frl"
36 
37 #ifndef TOOLBOX_HH
38 struct frfile {
39  int start;
40  int stop;
41  int length;
42  vector<TString> file;
43 };
44 #endif
45 
46 using namespace std;
47 
48 namespace CWB {
49 
50 class frame : public TNamed {
51 
52 public:
53 
54  frame();
55  frame(TString ioFile, TString chName="", Option_t* option = "", bool onDisk=false, TString label=".gwf", unsigned int mode=0);
56  ~frame();
57 
58  void open(TString ioFile, TString chName="", Option_t* option = "", bool onDisk=false, TString label=".gwf", unsigned int mode=0);
59 
60  // read in w the channel data contained in the frames defined in the filename
61  // filename : in - name of frame file
62  // channel : in - name of channel to be extracted
63  // w : out - data array which contains the data read
64  void readFrames(char* filename, char *channel, wavearray<double> &w);
65 
66  // read in w the channel data contained in the frames defined in the frf structure
67  // frf : in - frame file structure
68  // channel : in - name of channel to be extracted
69  // w : out - data array which contains the data read
70  void readFrames(frfile frf, char *channel, wavearray<double> &w);
71 
72  // read in w the channel data contained in the frames
73  // w : out - data array which contains the data read
74  void readFrames(wavearray<double> &w);
75 
76  // write in frame the channel data contained in the wavearray x
78 
79  // dump to file ofName the list of frames defined in frf structures (list file used for the old cWB analysis)
80  int dumpFrList(frfile frf, TString ofName, double sRate=16384.);
81 
82  // return the frame list of frames contained in the range [start-segEdge,stop-segEdge]
83  frfile getFrList(int istart, int istop, int segEdge);
84 
85  // return the frame list of frames contained in the range [start,stop]
86  vector<frfile> getFrList(int istart=0, int istop=0);
87 
88  // return the begin and end range of the frame list
89  waveSegment getFrRange() {return getFrRange(NULL);}
90 
91  // return the number of frame files read from input list
92  int getNfiles() {return nfiles;}
93 
94  // set resample index : used to resample data after read from files
95  // resample rate = pow(2,srIndex)
96  void setSRIndex(int srIndex) {this->srIndex=srIndex;}
97 
98  // get resample index
99  int getSRIndex() {return srIndex;}
100 
101  // set data channel name
102  void setChName(TString chName) {this->chName=chName;}
103 
104  // get data channel name
106 
107  // set frame name
108  void setFrName(TString frName) {this->frName=frName;}
109 
110  // get frame name
112 
113  // get frame file option (READ/WRITE)
114  TString getOption() {return fOption;}
115 
116  void close();
117 
118  // if true then print more infos
119  void setVerbose(bool verbose=true) {this->verbose=verbose;}
120 
121  // frame reading retry time (sec) : 0 -> disable
122  // retry time = frRetryTime*(num of trials) : max trials = 3
123  void setRetryTime(int frRetryTime=60) {this->frRetryTime=frRetryTime;}
124 
125  bool fNameCheck(TString fName);
126 
127  // set the range interval for input files
128  // if xstart!=0 then only files with gps>=xstart are stored in the tree
129  // if xstop!=0 then only files with gps<=xstop are stored in the tree
130  void setTimeRange(int xstart=0, int xstop=0) {
131  this->xstart = xstart>0 ? this->xstart=xstart : 0;
132  this->xstop = xstop>0 ? this->xstop=xstop : 0;
133  }
134 
135 private:
136 
137  // return the frame list of frames contained in the range [start-segEdge,stop-segEdge]
138  // if itree=NULL use the private frtree_List
139  frfile getFrList(int istart, int istop, int segEdge, TTree* itree);
140 
141  // return the frame list of frames contained in the range [start-segEdge,stop-segEdge]
142  // use the tree contained in rfName root file
143  frfile getFrList(TString rfName, int istart, int istop, int segEdge=0);
144 
145  // return the begin and end range of the frame list
146  // if itree=NULL use the private frtree_List
147  waveSegment getFrRange(TTree* itree);
148 
149  // convert frl (frame file list) file to tree and save to rfName
150  // if rfName=="" the tree is saved & sorted to the private frtree_List
151  int frl2FrTree(TString iFile, TString rfName="", TString label=".gwf", unsigned int mode=0);
152 
153  // sort iFile Tree and save the sorted tree to rfName
154  int sortFrTree(TString iFile, TString rfName);
155 
156  int sortFrTree();
157 
158  TTree* frtree_List; //!auxiliary tree used to store frame file infos
159  TString chName; // data channel name
160  TString frName; // frame name
161  TString rfName; // auxiliary root file name containing the tree
162  int nfiles; // number of frame files read from input list
163  FrFile *frFile; //!frame file pointer
164  TString fOption; // define the READ/WRITE mode
165  int srIndex; // resample rate = pow(2,srIndex) - 0 : disabled resampling
166  bool verbose; // if true then print more infos
167  int frRetryTime; // frame reading retry time (sec) : 0 -> disable
168 
169  double xstart; // start time range used to fill frtree_List
170  double xstop; // stop time range used to fill frtree_List
171 
172  ClassDef(frame,3)
173 };
174 
175 } // end namespace
176 
177 // get operator
179 // put operator
180 CWB::frame& operator << (CWB::frame& fr, wavearray<double>& x);
181 // put operator
183 
184 #endif
TString getOption()
Definition: frame.hh:114
double sRate
Definition: TestFrame5.C:14
TString rfName
Definition: frame.hh:161
TString ofName
int nfiles
int stop
Definition: Toolbox.hh:76
Definition: ced.hh:24
TString getFrName()
Definition: frame.hh:111
void setFrName(TString frName)
Definition: frame.hh:108
TString("c")
int start
Definition: Toolbox.hh:75
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::frame fr(FRLIST_NAME)
STL namespace.
double segEdge
Definition: test_config1.C:49
int srIndex
Definition: frame.hh:165
TString chName
auxiliary tree used to store frame file infos
Definition: frame.hh:159
waveSegment getFrRange()
Definition: frame.hh:89
void setChName(TString chName)
Definition: frame.hh:102
TString frName
Definition: frame.hh:160
size_t mode
wavearray< double > w
Definition: Test1.C:27
int getSRIndex()
Definition: frame.hh:99
void setTimeRange(int xstart=0, int xstop=0)
Definition: frame.hh:130
int nfiles
Definition: frame.hh:162
TString chName[NIFO_MAX]
double xstart
Definition: frame.hh:169
fr writeFrame(x, frName, chName)
int length
Definition: Toolbox.hh:77
TString label
Definition: MergeTrees.C:21
frfile frf
void setVerbose(bool verbose=true)
Definition: frame.hh:119
int getNfiles()
Definition: frame.hh:92
void setSRIndex(int srIndex)
Definition: frame.hh:96
bool verbose
Definition: frame.hh:166
TString getChName()
Definition: frame.hh:105
TString frName[NIFO_MAX]
wavearray< double > & operator>>(CWB::frame &fr, wavearray< double > &x)
Definition: frame.cc:111
int frRetryTime
Definition: frame.hh:167
TString fOption
frame file pointer
Definition: frame.hh:164
TTree * frtree_List
Definition: frame.hh:158
in open(HEN_LIST, ios::in)
TTree * itree
FrFile * frFile
Definition: frame.hh:163
vector< TString > file
Definition: Toolbox.hh:78
in close()
void setRetryTime(int frRetryTime=60)
Definition: frame.hh:123
char fName[256]
double xstop
Definition: frame.hh:170