Logo ROOT  
Reference Guide
FITS_tutorial4.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_FITS
3/// \notebook
4///
5/// Open a FITS file whose primary array represents
6/// a spectrum (flux vs wavelength).
7///
8/// \macro_code
9/// \macro_output
10///
11/// \author Claudi Martinez
12
13void FITS_tutorial4()
14{
15 // We open a FITS file that contains the primary HDU and a little data table.
16 // The data table is extension #1 and it has 2 rows.
17 // We want to read only the rows that have the column named DATAMAX greater than 2e-15 (there's only 1
18 // matching row Data copyright: NASA
19
20 TString dir = gROOT->GetTutorialDir();
21
22 // Open the table extension number 1)
23 TFITSHDU hdu(dir + "/fitsio/sample2.fits[1][DATAMAX > 2e-15]");
24
25 hdu.Print("T");
26
27 hdu.Print("T+");
28
29 std::unique_ptr<TVectorD> vp(hdu.GetTabRealVectorColumn("DATAMAX"));
30 const auto &v = *vp;
31 std::cout << "v[0] = " << v[0] << std::endl;
32 std::cout << "Does the matched row have DATAMAX > 2e-15? :-)" << std::endl;
33}
#define gROOT
Definition: TROOT.h:406
FITS file interface class.
Definition: TFITS.h:35
Basic string class.
Definition: TString.h:131