ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FITS_tutorial6.C
Go to the documentation of this file.
1 // Open a FITS file whose primary array represents
2 // a spectrum table (flux vs wavelength) and dump its columns
4 {
5  TVectorD *v;
6 
7  printf("\n\n--------------------------------\n");
8  printf("WELCOME TO FITS tutorial #6 !!!!\n");
9  printf("--------------------------------\n");
10  printf("We are going to open a table from a FITS file\n");
11  printf("and dump its columns.\n\n");
12 
13  TString dir = gSystem->DirName(__FILE__);
14 
15  //Open the table
16  TFITSHDU *hdu = new TFITSHDU(dir+"/sample4.fits[1]");
17  if (hdu == 0) {
18  printf("ERROR: could not access the HDU\n"); return;
19  }
20 
21  //Show columns
22  Int_t nColumns = hdu->GetTabNColumns();
23  printf("The table has %d columns:\n", nColumns);
24  for (Int_t i = 0; i < nColumns; i++) {
25  printf("...Column %d: %s\n", i, hdu->GetColumnName(i).Data());
26  }
27  puts("");
28 
29  delete hdu;
30 }
31 
32 
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
Definition: TSystem.cxx:980
const char * Data() const
Definition: TString.h:349
FITS file interface class.
Definition: TFITS.h:40
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
SVector< double, 2 > v
Definition: Dict.h:5
void FITS_tutorial6()
Definition: FITS_tutorial6.C:3
Int_t GetTabNColumns() const
Definition: TFITS.h:124
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
void dir(char *path=0)
Definition: rootalias.C:30
const TString & GetColumnName(Int_t colnum)
Get the name of a column given its index (column>=0).
Definition: TFITS.cxx:1426