#ifndef PM_HDU_UTILS_H
#define PM_HDU_UTILS_H

#include "pmFPA.h"
#include "pmHDU.h"

// Get the lowest HDU in the hierarchy, as supplied
pmHDU *pmHDUGetLowest(const pmFPA *fpa, // The FPA
                      const pmChip *chip, // The chip, or NULL
                      const pmCell *cell // The cell, or NULL
                     );

// Get the highest HDU in the hierarchy, as supplied
pmHDU *pmHDUGetHighest(const pmFPA *fpa, // The FPA
                       const pmChip *chip, // The chip, or NULL
                       const pmCell *cell // The cell, or NULL
                      );

// Find the HDU in the FPA hierarchy
pmHDU *pmHDUFromFPA(const pmFPA *fpa    // FPA for which to find HDU
                   );
pmHDU *pmHDUFromChip(const pmChip *chip // Chip for which to find HDU
                    );
pmHDU *pmHDUFromCell(const pmCell *cell // Cell for which to find HDU
                    );
pmHDU *pmHDUFromReadout(const pmReadout *readout // Readout for which to find HDU
                       );

// Print details about an HDU
void pmHDUPrint(FILE *fd,               // File descriptor to which to print
                const pmHDU *hdu,       // HDU to print
                int level,              // Level at which to print
                bool header             // Print header?
               );

#endif
