Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TestTObjectWavearray.C
Go to the documentation of this file.
1 {
2  //
3  // Write & Read wavearray object to/from root file
4  // Author : Gabriele Vedovato
5 
6 
7  wavearray<double> x1(1024*128);
8  x1.rate(1024*4);
9  for(int i=0;i<x1.size();i++) x1[i]=i;
10 
11  wavearray<double> x2(1024*128);
12  x2.rate(1024*4);
13  for(int i=0;i<x2.size();i++) x2[i]=i+1000;
14 
15  TFile *froot = new TFile("test.root", "RECREATE");
16  if(froot==NULL) {
17  cout << "Failed to create file !!! " << endl;
18  gSystem->Exit(1);
19  }
20 
21  x1.Write("wavearray<double>");
22  x2.Write("wavearray<double>");
23  froot->Close();
24 
25  TFile *f = new TFile("test.root");
26  if(f==NULL) {
27  cout << "Failed to open file test.root !!! " << endl;
28  gSystem->Exit(1);
29  }
30 
31  f->ls();
32 
33  wavearray<double>* w = (wavearray<double>*)f->Get("wavearray<double>;2");
34  if(w==NULL) {
35  cout << "Object wavearray not exist !!! " << endl;
36  gSystem->Exit(1);
37  }
38 
39  cout << w->size() << endl;
40  for(int i=0;i<10;i++) cout << i << " " << w->data[i] << endl;
41 
42  f->Close();
43 
44  exit(0);
45 }
virtual size_t size() const
Definition: wavearray.hh:127
wavearray< double > * w
i drho i
TFile * f
TFile * froot
DataType_t * data
Definition: wavearray.hh:301
exit(0)