FACT++  1.0
void Fits::Close ( )

Close the currently opened file.

This closes the currently openned FITS file. it also updates the header to reflect the time of the last logged row

Definition at line 441 of file Fits.cc.

442 {
443  if (!fFile)
444  return;
445  if (fFile->IsOpen() && fFile->IsOwner())
446  {
447  // FIMXE: Check for error? (It is allowed that fFile is NULL)
448  fFile->WriteKeyNT("TSTOPI", uint32_t(floor(fEndMjD)), "Time when last event received (integral part)");
449  fFile->WriteKeyNT("TSTOPF", fmod(fEndMjD, 1), "Time when last event received (fractional part)");
450 
451  fFile->WriteKeyNT("DATE-END", Time(fEndMjD+40587).Iso(),
452  "Time when last event received");
453  }
454  if (fFile->IsOwner())
455  {
456  if (fNumOpenFitsFiles != NULL)
457  (*fNumOpenFitsFiles)--;
458  }
459  const string name = fFile->GetName();
460  delete fFile;
461  fFile = NULL;
462  fMess->Info("Closed: "+name);
463 // fMess = NULL;
464 }
bool IsOpen() const
Definition: FitsFile.h:97
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
bool IsOwner() const
Definition: FitsFile.h:101
MessageImp * fMess
were to log the errors
Definition: Fits.h:42
bool WriteKeyNT(const string &name, const T &value, const string &comment)
Definition: FitsFile.h:62
FitsFile * fFile
Definition: Fits.h:14
uint32_t * fNumOpenFitsFiles
Keep track of number of opened fits.
Definition: Fits.h:40
string GetName() const
Definition: FitsFile.h:100
int Info(const std::string &str)
Definition: MessageImp.h:47
double fEndMjD
to keep track of the time of the latest written entry (to update the header when closing the file) ...
Definition: Fits.h:38