Logo coherent WaveBurst  
Library Reference Guide
Logo
TestTObjectSkymap.C
Go to the documentation of this file.
1 {
2  //
3  // Write & Read skymap object to/from root file
4  // Author : Gabriele Vedovato
5 
6  skymap sm(3);
7 
8  for(int l=0;l<sm.size();l++) sm.set(l,l);
9 
10  TFile *froot = new TFile("test.root", "RECREATE");
11  if(froot==NULL) {
12  cout << "Failed to create file !!! " << endl;
13  gSystem->Exit(1);
14  }
15 
16  sm.Write("skymap");
17  froot->Close();
18 
19  TFile *f = new TFile("test.root");
20  if(f==NULL) {
21  cout << "Failed to open file test.root !!! " << endl;
22  gSystem->Exit(1);
23  }
24 
25  f->ls();
26 
27  skymap* sm2 = (skymap*)f->Get("skymap");
28  if(sm2==NULL) {
29  cout << "Object skymap not exist !!! " << endl;
30  gSystem->Exit(1);
31  }
32 
33  for(int l=0;l<sm2->size();l++) cout << l << " " << sm2->get(l) << endl;
34 
35  f->Close();
36 
37  exit(0);
38 }
skymap * sm2
int l
Definition: skymap.hh:63
TFile * froot
exit(0)
TFile * f
double get(size_t i)
param: sky index
Definition: skymap.cc:699
size_t size()
Definition: skymap.hh:136