From d75a15f2155b5f292ebbb48133e72233d68ed66d Mon Sep 17 00:00:00 2001 From: Rene Brun <Rene.Brun@cern.ch> Date: Mon, 2 Aug 2010 05:44:57 +0000 Subject: [PATCH] From Claudi Martinez: add new tutorial git-svn-id: http://root.cern.ch/svn/root/trunk@34697 27541ba8-7e3a-0410-8455-c3a389f83636 --- tutorials/fitsio/FITS_tutorial4.C | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tutorials/fitsio/FITS_tutorial4.C diff --git a/tutorials/fitsio/FITS_tutorial4.C b/tutorials/fitsio/FITS_tutorial4.C new file mode 100644 index 00000000000..6c44ef2bb69 --- /dev/null +++ b/tutorials/fitsio/FITS_tutorial4.C @@ -0,0 +1,46 @@ +// Open a FITS file whose primary array represents +// a spectrum (flux vs wavelength) +void FITS_tutorial4() +{ + printf("\n\n--------------------------------\n"); + printf("WELCOME TO FITS tutorial #4 !!!!\n"); + printf("--------------------------------\n"); + printf("We're gonna open a FITS file that contains the\n"); + printf("primary HDU and a little data table.\n"); + printf("The data table is extension #1 and it has 2 rows.\n"); + printf("We want to read only the rows that have the column\n"); + printf("named DATAMAX greater than 2e-15 (there's only 1\n"); + printf("matching row)\n"); + printf("Data copyright: NASA\n\n"); + + if (!gROOT->IsBatch()) { + printf("Press ENTER to start..."); getchar(); + } + + //Open the table extension number 1) + TFITSHDU *hdu = new TFITSHDU("sample2.fits[1][DATAMAX > 2e-15]"); + if (hdu == 0) { + printf("ERROR: could not access the HDU\n"); return; + } + printf("Press ENTER to see information about the table's columns..."); getchar(); + hdu->Print("T"); + + printf("\n\n........................................\n"); + printf("Press ENTER to see full table contents (maybe you should resize\n"); + printf("this window as large as possible before)..."); getchar(); + hdu->Print("T+"); + + printf("\n\n........................................\n"); + printf("Press ENTER to get only the DATAMAX value of the matched row..."); getchar(); + TVectorD *v = hdu->GetTabRealVectorColumn("DATAMAX"); + printf("%lg\n", (*v)[0]); + + + printf("Does the matched row have DATAMAX > 2e-15? :-)\n"); + + //Clean up + delete v; + delete hdu; +} + + \ No newline at end of file -- GitLab