Why root can't read 16X type of data in fits files?

Hi,
I used root-6-20-8, and the code in tutorials/fitsio/ can run well.

But when I read a fits file in the same way as shown in code in tutorials/fitsio/, there is an error as following:

Warning in TFITSHDU::LoadHDU: error opening FITS file. Details: bad first row number
Error in TRint::HandleTermInput(): Exception caught!

The problem is the HDU including data with TFORM of 16X (bit) that can not be read,while other HDUs without 16X type data can be read.

Because there was some errors when I installed the latest version root and I could not fix it, I am using an older version. If anyone has the latest root, could you please check if fits data attached can be read well, you can use your own code or the code attached?

If anyone can check it and tell me the outcomes, I will be very grateful. Any advice is welcome.

Best wishes,
Zoey

PleaseCheck.zip (2.3 MB)

Check_Fits.evt: original data
Delete16X_Check_Fits.evt: delete the 16X type data in Check_Fits.evt

We’ll try to have a look but it can take time.
To speedup things, Do you have the possibility to use one of our containers or to log into some portal, e.g. CERN’s lxplus, to check the latest ROOT version and verify whether the issue is still present? 6.20 is a pretty old release by now.

Best,
D

Hi Danilo,
Thank you very much for your replying. Please try to check if latest root can read my FITS data.

I tried to register LXPLUS, when I tried to log in and failed, I received the following message.

Best wishes,
Zoey

Hi Danilo,
Have you tried the latest version root for reading the fits file Check_Fits.evt ?
Does it work ?

Regards,
Zoey

Hi Zoey,

We do not have resources to start the debugging from there. I hope we can find a middle ground here, apologies.

best,
D

Danilo, thank you all the same.

I tried, and it also fails with latest ROOT version.

   ------------------------------------------------------------------
  | Welcome to ROOT 6.32.00                        https://root.cern |
  | (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on May 28 2024, 05:02:02                 |
  | From tags/v6-32-00@v6-32-00                                      |
  | With c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0                   |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] 
Processing Read_ufevt.C+...
Info in <TUnixSystem::ACLiC>: creating shared library /tmp//tmp/PleaseCheck/./Read_ufevt_C.so
Info in <TFITSHDU::LoadHDU>: The selected HDU contains a Table Extension
Warning in <TFITSHDU::LoadHDU>: error opening FITS file. Details: bad first row number

This is the same error as that with ROOT 6.20.

Ferhue, thank you very much for letting me know.

By the way, you can install the latest ROOT version without needing to use CMake, etc.
Just download a precompiled binary for your platform:

On another note, if you want to support 16X, you may open a new feature request here: Sign in to GitHub · GitHub

@cosimoNigro your expert help might be welcome here :wink: thanks

Hi ferhue,

Are you able to read 16X data in fits files now with latest root ?
May I know What you did in details?

regards,
Zoey

No, it doesn’t work.

you could do it with go-hep:

## install the latest version of fits2root
$> go install go-hep.org/x/hep/cmd/fits2root@latest
$> fits2root -h
 fits2root converts the content of a FITS table to a ROOT file and tree.

Usage: fits2root [OPTIONS] -f input.fits

Example:

 $> fits2root -f ./input.fits -t MyHDU

Options:
  -f string
    	path to input FITS file name
  -o string
    	path to output ROOT file name (default "output.root")
  -t string
    	name of the FITS table to convert

## converting the HDUs whose columns ROOT/C++ chokes on
$> fits2root -f ./Check_Fits.evt -o f1.root -t EVENTS
$> fits2root -f ./Delete16X_Check_Fits.evt -o f2.root -t EVENTS
$> ll
total 8.3M
-rw-r--r-- 1 binet binet 2.1M Jun 17 10:24 Check_Fits.evt
-rw-r--r-- 1 binet binet 2.1M Jun 17 10:24 Delete16X_Check_Fits.evt
-rw-r--r-- 1 binet binet 981K Jul 12 13:39 f1.root
-rw-r--r-- 1 binet binet 981K Jul 12 13:39 f2.root
-rw-r--r-- 1 binet binet 2.3M Jul 12 13:24 PleaseCheck.zip
-rw-r--r-- 1 binet binet 2.3K Jun 17 10:24 Read_ufevt.C

## display the layout of the resulting TTree
$> root-ls -t ./f2.root 
=== [./f2.root] ===
version: 63200
  TTree       EVENTS                (entries=27423)
    TIME      "TIME/D"      TBranch
    CMOSFRAM  "CMOSFRAM/I"  TBranch
    RAWX      "RAWX/S"      TBranch
    RAWY      "RAWY/S"      TBranch
    PHAS      "PHAS[9]/S"   TBranch
    Amp       "Amp/b"       TBranch
    PHA       "PHA/I"       TBranch
    STATUS    "STATUS[2]/b" TBranch
    DETX      "DETX/S"      TBranch
    DETY      "DETY/S"      TBranch
    X         "X/S"         TBranch
    Y         "Y/S"         TBranch
    GRADE     "GRADE/S"     TBranch
    PixsAbove "PixsAbove/S" TBranch
    PHASO     "PHASO[9]/S"  TBranch
    PI        "PI/I"        TBranch

## display the content of the resulting TTree
$> root-dump ./f2.root | head
>>> file[./f2.root]
key[000]: EVENTS;1 "" (TTree)
[000][TIME]: 1.369975777999e+08
[000][CMOSFRAM]: -2144512531
[000][RAWX]: 552
[000][RAWY]: 22
[000][PHAS]: [3364 1 -3 -2 76 -1 12 164 2]
[000][Amp]: 1
[000][PHA]: 3613
[000][STATUS]: [8 0]

## make sure ROOT/C++ can still read the resulting TTree and the data is meaningful
$> root ./f2.root
root [0] 
Attaching file ./f2.root as _file0...
(TFile *) 0x59462d8c2c40
root [1] auto t = (TTree*)_file0->Get("EVENTS");
root [2] t->Scan("X:Y:STATUS")
***********************************************************
*    Row   * Instance *         X *         Y *    STATUS *
***********************************************************
*        0 *        0 *      4623 *      9218 *         8 *
*        0 *        1 *      4623 *      9218 *         0 *
*        1 *        0 *      3816 *      5872 *         0 *
*        1 *        1 *      3816 *      5872 *         0 *
*        2 *        0 *      5000 *      7130 *         0 *
*        2 *        1 *      5000 *      7130 *         0 *
*        3 *        0 *      5307 *      5962 *         0 *
*        3 *        1 *      5307 *      5962 *         0 *
*        4 *        0 *      7522 *      7235 *         0 *
*        4 *        1 *      7522 *      7235 *         0 *
*        5 *        0 *      6734 *      4987 *         8 *
*        5 *        1 *      6734 *      4987 *         0 *
*        6 *        0 *      4768 *      3888 *         0 *
*        6 *        1 *      4768 *      3888 *         0 *
*        7 *        0 *      4991 *      3085 *         0 *
*        7 *        1 *      4991 *      3085 *         0 *
*        8 *        0 *      4789 *      3334 *         0 *
*        8 *        1 *      4789 *      3334 *         0 *
*        9 *        0 *      5046 *      2425 *         0 *
*        9 *        1 *      5046 *      2425 *         0 *
*       10 *        0 *      5409 *      2523 *         8 *
*       10 *        1 *      5409 *      2523 *         0 *
*       11 *        0 *      6737 *      5743 *         8 *
*       11 *        1 *      6737 *      5743 *         0 *
*       12 *        0 *      4974 *      2977 *         0 *
Type <CR> to continue or q to quit ==> q
***********************************************************
(long long) 25

you can also download the fits2root binary from:

(and choose the one suitable for your OS and architecture)

hth.

Hi Sébastien,
Thank you for your suggestion very much. Before your reply, I tried another method and it worked. So I have not tried your way.

I installed cfitsio, then linked its library and include folder to ROOT. In this way, I can read my fits files well with cfitsio in ROOT.

Thank you again and best wishes for you.
Zoey