From c98315461cd368704dafe25cc96a6941a8133abe Mon Sep 17 00:00:00 2001 From: Orel Gueta Date: Mon, 11 May 2026 18:03:25 +0200 Subject: [PATCH 01/10] Add uncertainty column to effective area and fix PSF_TABLE column names - Add optional include_uncertainty parameter to write_histo2D function - Enable uncertainty column (EFFAREA_ERR) for effective area table - Fix PSF_TABLE column names: MIGRA->RAD and swap THETA/RAD positions for GADF compliance - Uncomment write_psf_table call to enable 3D PSF table generation --- DL3-IRFs/inc/VDL3IRFs.h | 3 +- DL3-IRFs/src/VDL3IRFs.cpp | 89 ++++++++++++++----- .../src/convertSensitivityFilesToFITS.cpp | 2 - 3 files changed, 69 insertions(+), 25 deletions(-) diff --git a/DL3-IRFs/inc/VDL3IRFs.h b/DL3-IRFs/inc/VDL3IRFs.h index a7e0148..bdbf738 100644 --- a/DL3-IRFs/inc/VDL3IRFs.h +++ b/DL3-IRFs/inc/VDL3IRFs.h @@ -32,7 +32,8 @@ class VDL3IRFs string name, char* col_name, char* col_unit, - bool MEV_BACKGROUND_UNIT = false ); + bool MEV_BACKGROUND_UNIT = false, + bool include_uncertainty = false ); public: diff --git a/DL3-IRFs/src/VDL3IRFs.cpp b/DL3-IRFs/src/VDL3IRFs.cpp index a43b85a..4ea6ec3 100644 --- a/DL3-IRFs/src/VDL3IRFs.cpp +++ b/DL3-IRFs/src/VDL3IRFs.cpp @@ -363,10 +363,10 @@ bool VDL3IRFs::write_psf_table( TH3F *h, char *instrument ) nRows = 0; char* tType[nCol] = { (char*)"ENERG_LO", (char*)"ENERG_HI", + (char*)"RAD_LO", + (char*)"RAD_HI", (char*)"THETA_LO", (char*)"THETA_HI", - (char*)"MIGRA_LO", - (char*)"MIGRA_HI", (char*)"RPSF" }; char* tUnit[nCol] = { (char*)"TeV", (char*)"TeV", @@ -378,10 +378,10 @@ bool VDL3IRFs::write_psf_table( TH3F *h, char *instrument ) // e_true axis is x-axis char x_form[10]; sprintf( x_form, "%dE", h->GetNbinsX() ); - // Offset angle from source position + // Offset angle from source position (y-axis, RAD) char y_form[10]; sprintf( y_form, "%dE", h->GetNbinsY() ); - // offset angle axis is z-axis + // Field of view offset angle (z-axis, THETA) char z_form[10]; sprintf( z_form, "%dE", h->GetNbinsZ() ); // mig @@ -764,7 +764,8 @@ bool VDL3IRFs::write_effarea( TH2F *h, char *instrument ) "EFFECTIVE AREA", (char*)"EFFAREA", (char*)"m**2", - false ); + false, + true ); write_fits_table_header( "AEFF_2D", instrument ); return writing_success; } @@ -791,35 +792,50 @@ bool VDL3IRFs::write_histo2D( TH2F *h, string name, char* col_name, char* col_unit, - bool MEV_BACKGROUND_UNIT ) + bool MEV_BACKGROUND_UNIT, + bool include_uncertainty ) { if( !h ) return false; int status = 0; - const int nCol = 5; + const int nCol = include_uncertainty ? 6 : 5; + const int maxCol = 6; // Maximum possible columns (with uncertainty) long nRows = h->GetNbinsX() * h->GetNbinsY(); nRows = 0; - char* tType[nCol] = { (char*)"ENERG_LO", - (char*)"ENERG_HI", - (char*)"THETA_LO", - (char*)"THETA_HI", - (char*)col_name }; - char* tUnit[nCol] = { (char*)"TeV", - (char*)"TeV", - (char*)"deg", - (char*)"deg", - (char*)col_unit }; + + // Column names - create error column name in static buffer + char err_col_name[50]; + if( include_uncertainty ) + { + snprintf( err_col_name, sizeof(err_col_name), "%s_ERR", col_name ); + } + + // Arrays sized for maximum columns; fits_create_tbl uses only first nCol entries + char* tType[maxCol] = { (char*)"ENERG_LO", + (char*)"ENERG_HI", + (char*)"THETA_LO", + (char*)"THETA_HI", + (char*)col_name, + include_uncertainty ? err_col_name : (char*)"" }; + + char* tUnit[maxCol] = { (char*)"TeV", + (char*)"TeV", + (char*)"deg", + (char*)"deg", + (char*)col_unit, + (char*)col_unit }; char x_form[10]; sprintf( x_form, "%dE", h->GetNbinsX() ); char y_form[10]; sprintf( y_form, "%dE", h->GetNbinsY() ); char z_form[10]; sprintf( z_form, "%dE", h->GetNbinsX()*h->GetNbinsY() ); - char* tForm[nCol] = { &x_form[0], - &x_form[0], - &y_form[0], - &y_form[0], - &z_form[0] }; + char* tForm[maxCol] = { &x_form[0], + &x_form[0], + &y_form[0], + &y_form[0], + &z_form[0], + &z_form[0] }; /////////////// // create empty table @@ -845,6 +861,18 @@ bool VDL3IRFs::write_histo2D( TH2F *h, { return printerror( status ); } + // set dimensions for uncertainty column if present + if( include_uncertainty ) + { + if( fits_write_tdim( fptr, + 6, + 2, + naxes, + &status ) ) + { + return printerror( status ); + } + } /////////////// // write data vector< vector< float > > table = get_baseline_axes( h ); @@ -858,6 +886,7 @@ bool VDL3IRFs::write_histo2D( TH2F *h, // data vector< float > data; + vector< float > errors; for( int j = 0; j < h->GetNbinsY(); j++ ) { for( int i = 0; i < h->GetNbinsX(); i++ ) @@ -868,15 +897,31 @@ bool VDL3IRFs::write_histo2D( TH2F *h, { data.push_back( h->GetBinContent( i+1, j+1 ) * norm_mev_background[i] ); + if( include_uncertainty ) + { + // Get bin error (averaging asymmetric errors if available) + float error = h->GetBinError( i+1, j+1 ); + errors.push_back( error * norm_mev_background[i] ); + } } else { data.push_back( h->GetBinContent( i+1, j+1 ) ); + if( include_uncertainty ) + { + errors.push_back( h->GetBinError( i+1, j+1 ) ); + } } } } table.push_back( data ); + + // Add uncertainty column if requested + if( include_uncertainty ) + { + table.push_back( errors ); + } return write_table( table ); } diff --git a/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp b/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp index 371240c..37a91ed 100644 --- a/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp +++ b/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp @@ -87,12 +87,10 @@ int main( int argc, char* argv[] ) (TH2F*)fData->Get( "AngResEtrue_offaxis" ), (char*)getArrayName(fData) ); - /* cout << "Writing gamma-ray point-spread function (3D table)" << endl; a.write_psf_table( (TH3F*)fData->Get( "AngularPSF2DEtrue_offaxis" ), (char*)getArrayName(fData) ); - */ // edisp // note: note using migration matrix MigMatrixNoTheta2cut_offaxis From d11d1a5a4a4ef1a6e871aaa771fa744c9bc397e4 Mon Sep 17 00:00:00 2001 From: orelgueta Date: Mon, 11 May 2026 18:55:42 +0200 Subject: [PATCH 02/10] Fix comment about asymetric errors Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- DL3-IRFs/src/VDL3IRFs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DL3-IRFs/src/VDL3IRFs.cpp b/DL3-IRFs/src/VDL3IRFs.cpp index 4ea6ec3..aa5b372 100644 --- a/DL3-IRFs/src/VDL3IRFs.cpp +++ b/DL3-IRFs/src/VDL3IRFs.cpp @@ -899,7 +899,7 @@ bool VDL3IRFs::write_histo2D( TH2F *h, * norm_mev_background[i] ); if( include_uncertainty ) { - // Get bin error (averaging asymmetric errors if available) + // Get the symmetric bin error and scale it with the background normalisation float error = h->GetBinError( i+1, j+1 ); errors.push_back( error * norm_mev_background[i] ); } From 93e520708d4f586fb7a1f92f39966e5332772dbf Mon Sep 17 00:00:00 2001 From: Orel Gueta Date: Mon, 11 May 2026 20:31:43 +0200 Subject: [PATCH 03/10] Fix PSF_TABLE GADF classification keywords Set HDUCLAS2=PSF for PSF_TABLE type in write_fits_table_header(). Previously only PSF_3GAUSS was handled, causing PSF_TABLE to miss required GADF classification keywords. --- DL3-IRFs/src/VDL3IRFs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DL3-IRFs/src/VDL3IRFs.cpp b/DL3-IRFs/src/VDL3IRFs.cpp index 4ea6ec3..4b3fa23 100644 --- a/DL3-IRFs/src/VDL3IRFs.cpp +++ b/DL3-IRFs/src/VDL3IRFs.cpp @@ -151,7 +151,7 @@ bool VDL3IRFs::write_fits_table_header( string irftype, char *instrument ) (char*)"RESPONSE", (char*)"HDUCLAS1" ); - if( irftype == "PSF_3GAUSS" ) + if( irftype == "PSF_3GAUSS" || irftype == "PSF_TABLE" ) { write_fits_keyword( (char*)"HDUCLAS2", (char*)"PSF", From 60b6a0607d1acb72f99d743696d619b944fcc8ec Mon Sep 17 00:00:00 2001 From: Orel Gueta Date: Mon, 11 May 2026 20:43:03 +0200 Subject: [PATCH 04/10] Give unique EXTNAME to each PSF HDU to avoid ambiguity Change PSF HDU names to match their HDUCLAS4 values: - write_psf_table: 'POINT SPREAD FUNCTION' -> 'PSF_TABLE' - write_psf_gauss: 'POINT SPREAD FUNCTION' -> 'PSF_3GAUSS' This prevents duplicate EXTNAME values and makes HDU lookups unambiguous. --- DL3-IRFs/src/VDL3IRFs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DL3-IRFs/src/VDL3IRFs.cpp b/DL3-IRFs/src/VDL3IRFs.cpp index eca3869..1d3b91a 100644 --- a/DL3-IRFs/src/VDL3IRFs.cpp +++ b/DL3-IRFs/src/VDL3IRFs.cpp @@ -406,7 +406,7 @@ bool VDL3IRFs::write_psf_table( TH3F *h, char *instrument ) tType, tForm, tUnit, - "POINT SPREAD FUNCTION", + "PSF_TABLE", &status ) ) { return printerror( status ); @@ -503,7 +503,7 @@ bool VDL3IRFs::write_psf_gauss( TH2F *h, char *instrument ) tType, tForm, tUnit, - "POINT SPREAD FUNCTION", + "PSF_3GAUSS", &status ) ) { return printerror( status ); From 20fb089a1103c1ece9170759112b336e40b23632 Mon Sep 17 00:00:00 2001 From: Orel Gueta Date: Mon, 11 May 2026 20:44:26 +0200 Subject: [PATCH 05/10] Use std::string for error column name to avoid truncation risk Replace fixed-size char buffer with std::string for err_col_name: - Eliminates potential truncation risk from snprintf - No need to check snprintf return value - Fix comment: 'static buffer' -> 'using std::string' - More idiomatic C++ code --- DL3-IRFs/src/VDL3IRFs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DL3-IRFs/src/VDL3IRFs.cpp b/DL3-IRFs/src/VDL3IRFs.cpp index 1d3b91a..4388c32 100644 --- a/DL3-IRFs/src/VDL3IRFs.cpp +++ b/DL3-IRFs/src/VDL3IRFs.cpp @@ -803,11 +803,11 @@ bool VDL3IRFs::write_histo2D( TH2F *h, long nRows = h->GetNbinsX() * h->GetNbinsY(); nRows = 0; - // Column names - create error column name in static buffer - char err_col_name[50]; + // Column names - create error column name using std::string + string err_col_name; if( include_uncertainty ) { - snprintf( err_col_name, sizeof(err_col_name), "%s_ERR", col_name ); + err_col_name = string(col_name) + "_ERR"; } // Arrays sized for maximum columns; fits_create_tbl uses only first nCol entries @@ -816,7 +816,7 @@ bool VDL3IRFs::write_histo2D( TH2F *h, (char*)"THETA_LO", (char*)"THETA_HI", (char*)col_name, - include_uncertainty ? err_col_name : (char*)"" }; + include_uncertainty ? (char*)err_col_name.c_str() : (char*)"" }; char* tUnit[maxCol] = { (char*)"TeV", (char*)"TeV", From 00a009f2f0c3304ce30e7d842913192137fa4538 Mon Sep 17 00:00:00 2001 From: Orel Gueta Date: Mon, 11 May 2026 21:09:44 +0200 Subject: [PATCH 06/10] Fix PSF EXTNAME backward compatibility and add error handling Address reviewer feedback: - Revert PSF_3GAUSS EXTNAME to 'POINT SPREAD FUNCTION' for backward compatibility with existing tools (e.g., test_cta_file.py) - Keep PSF_TABLE EXTNAME as 'PSF_TABLE' for the 3D table - Update HDUCLAS2 condition to recognize 'POINT SPREAD FUNCTION' - Add null pointer check for AngularPSF2DEtrue_offaxis histogram - Check write_psf_table() return value and log errors - Skip PSF_TABLE writing with warning if histogram not found This maintains compatibility with downstream consumers while still providing unique EXTNAME values for the two different PSF formats. --- DL3-IRFs/src/VDL3IRFs.cpp | 6 +++--- DL3-IRFs/src/convertSensitivityFilesToFITS.cpp | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/DL3-IRFs/src/VDL3IRFs.cpp b/DL3-IRFs/src/VDL3IRFs.cpp index 4388c32..e94a966 100644 --- a/DL3-IRFs/src/VDL3IRFs.cpp +++ b/DL3-IRFs/src/VDL3IRFs.cpp @@ -151,7 +151,7 @@ bool VDL3IRFs::write_fits_table_header( string irftype, char *instrument ) (char*)"RESPONSE", (char*)"HDUCLAS1" ); - if( irftype == "PSF_3GAUSS" || irftype == "PSF_TABLE" ) + if( irftype == "POINT SPREAD FUNCTION" || irftype == "PSF_TABLE" ) { write_fits_keyword( (char*)"HDUCLAS2", (char*)"PSF", @@ -503,7 +503,7 @@ bool VDL3IRFs::write_psf_gauss( TH2F *h, char *instrument ) tType, tForm, tUnit, - "PSF_3GAUSS", + "POINT SPREAD FUNCTION", &status ) ) { return printerror( status ); @@ -555,7 +555,7 @@ bool VDL3IRFs::write_psf_gauss( TH2F *h, char *instrument ) } bool writing_success = write_table( table ); - write_fits_table_header( "PSF_3GAUSS", instrument ); + write_fits_table_header( "POINT SPREAD FUNCTION", instrument ); return writing_success; } diff --git a/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp b/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp index 37a91ed..ea20167 100644 --- a/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp +++ b/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp @@ -88,9 +88,14 @@ int main( int argc, char* argv[] ) (char*)getArrayName(fData) ); cout << "Writing gamma-ray point-spread function (3D table)" << endl; - a.write_psf_table( - (TH3F*)fData->Get( "AngularPSF2DEtrue_offaxis" ), - (char*)getArrayName(fData) ); + TH3F* psf_table_hist = (TH3F*)fData->Get( "AngularPSF2DEtrue_offaxis" ); + if( psf_table_hist ) { + if( !a.write_psf_table( psf_table_hist, (char*)getArrayName(fData) ) ) { + cerr << "Error: Failed to write PSF_TABLE" << endl; + } + } else { + cout << "Warning: AngularPSF2DEtrue_offaxis histogram not found, skipping PSF_TABLE" << endl; + } // edisp // note: note using migration matrix MigMatrixNoTheta2cut_offaxis From 5ab41233d83a61aba2f8501f810ed2e1d88973ea Mon Sep 17 00:00:00 2001 From: Orel Gueta Date: Tue, 12 May 2026 10:22:05 +0200 Subject: [PATCH 07/10] Separate EXTNAME from HDUCLAS4 in PSF_3GAUSS HDU Fix GADF compliance issue where HDUCLAS4 was set to 'POINT SPREAD FUNCTION' instead of 'PSF_3GAUSS': - write_psf_gauss() now passes 'PSF_3GAUSS' to write_fits_table_header() - Update write_fits_table_header() condition to recognize 'PSF_3GAUSS' - EXTNAME remains 'POINT SPREAD FUNCTION' (backward compatible) - HDUCLAS4 is now 'PSF_3GAUSS' (GADF/ogadf_schema compliant) This properly separates the display name (EXTNAME) from the IRF class identifier (HDUCLAS4) used for validation. --- DL3-IRFs/src/VDL3IRFs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DL3-IRFs/src/VDL3IRFs.cpp b/DL3-IRFs/src/VDL3IRFs.cpp index e94a966..08f0ede 100644 --- a/DL3-IRFs/src/VDL3IRFs.cpp +++ b/DL3-IRFs/src/VDL3IRFs.cpp @@ -151,7 +151,7 @@ bool VDL3IRFs::write_fits_table_header( string irftype, char *instrument ) (char*)"RESPONSE", (char*)"HDUCLAS1" ); - if( irftype == "POINT SPREAD FUNCTION" || irftype == "PSF_TABLE" ) + if( irftype == "PSF_3GAUSS" || irftype == "PSF_TABLE" ) { write_fits_keyword( (char*)"HDUCLAS2", (char*)"PSF", @@ -555,7 +555,7 @@ bool VDL3IRFs::write_psf_gauss( TH2F *h, char *instrument ) } bool writing_success = write_table( table ); - write_fits_table_header( "POINT SPREAD FUNCTION", instrument ); + write_fits_table_header( "PSF_3GAUSS", instrument ); return writing_success; } From 074e6557559ef44ccdc94d26dbc2bc9a8509fc94 Mon Sep 17 00:00:00 2001 From: Orel Gueta Date: Tue, 12 May 2026 13:16:55 +0200 Subject: [PATCH 08/10] Propagate write_table() failures in PSF writing functions Fix error handling so write_psf_table() and write_psf_gauss() properly report write failures: - Capture write_table() return value (write_psf_table was ignoring it) - Only write FITS headers if table write succeeded - Return actual success/failure status instead of always returning true This allows the error check in convertSensitivityFilesToFITS.cpp to actually detect and report PSF_TABLE write failures. --- DL3-IRFs/src/VDL3IRFs.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/DL3-IRFs/src/VDL3IRFs.cpp b/DL3-IRFs/src/VDL3IRFs.cpp index 08f0ede..fa21b57 100644 --- a/DL3-IRFs/src/VDL3IRFs.cpp +++ b/DL3-IRFs/src/VDL3IRFs.cpp @@ -440,10 +440,12 @@ bool VDL3IRFs::write_psf_table( TH3F *h, char *instrument ) } table.push_back( data ); - write_table( table ); - write_fits_table_header( "PSF_TABLE", instrument ); - - return true; + bool writing_success = write_table( table ); + if( writing_success ) + { + write_fits_table_header( "PSF_TABLE", instrument ); + } + return writing_success; } /* @@ -555,8 +557,10 @@ bool VDL3IRFs::write_psf_gauss( TH2F *h, char *instrument ) } bool writing_success = write_table( table ); - write_fits_table_header( "PSF_3GAUSS", instrument ); - + if( writing_success ) + { + write_fits_table_header( "PSF_3GAUSS", instrument ); + } return writing_success; } From 5d2508ee95548753771971030b8123ffea1b743b Mon Sep 17 00:00:00 2001 From: orelgueta Date: Tue, 12 May 2026 13:28:30 +0200 Subject: [PATCH 09/10] Change brackets Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- DL3-IRFs/src/convertSensitivityFilesToFITS.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp b/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp index ea20167..3d90e92 100644 --- a/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp +++ b/DL3-IRFs/src/convertSensitivityFilesToFITS.cpp @@ -89,11 +89,15 @@ int main( int argc, char* argv[] ) cout << "Writing gamma-ray point-spread function (3D table)" << endl; TH3F* psf_table_hist = (TH3F*)fData->Get( "AngularPSF2DEtrue_offaxis" ); - if( psf_table_hist ) { - if( !a.write_psf_table( psf_table_hist, (char*)getArrayName(fData) ) ) { + if( psf_table_hist ) + { + if( !a.write_psf_table( psf_table_hist, (char*)getArrayName(fData) ) ) + { cerr << "Error: Failed to write PSF_TABLE" << endl; } - } else { + } + else + { cout << "Warning: AngularPSF2DEtrue_offaxis histogram not found, skipping PSF_TABLE" << endl; } From 5dd93cb28c7a6f36b36fc3ed05275c54b0cf104b Mon Sep 17 00:00:00 2001 From: Orel Gueta Date: Tue, 12 May 2026 13:29:40 +0200 Subject: [PATCH 10/10] Gate header writes on table write success in all IRF functions Prevent write_fits_table_header() from being called on write failures, which could corrupt previously-open HDUs. Applied to: - write_edisp(): EDISP_2D header - write_background_3D_from_2d(): BKG_3D header - write_background(): BKG_2D header - write_effarea(): AEFF_2D header - write_diffsens(): DIFFSENS_2D header This matches the pattern already applied to write_psf_gauss() and write_psf_table() and ensures FITS file integrity when writes fail. --- DL3-IRFs/src/VDL3IRFs.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/DL3-IRFs/src/VDL3IRFs.cpp b/DL3-IRFs/src/VDL3IRFs.cpp index fa21b57..3aa6084 100644 --- a/DL3-IRFs/src/VDL3IRFs.cpp +++ b/DL3-IRFs/src/VDL3IRFs.cpp @@ -337,8 +337,10 @@ bool VDL3IRFs::write_edisp( TH3F *h, char *instrument ) table.push_back( data ); bool writing_success = write_table( table ); - write_fits_table_header( "EDISP_2D", instrument ); - + if( writing_success ) + { + write_fits_table_header( "EDISP_2D", instrument ); + } return writing_success; } @@ -739,7 +741,10 @@ bool VDL3IRFs::write_background_3D_from_2d( TH2F* h, char *instrument ) bool writing_success = write_table( table ); - write_fits_table_header( "BKG_3D", instrument ); + if( writing_success ) + { + write_fits_table_header( "BKG_3D", instrument ); + } return writing_success; } @@ -754,7 +759,10 @@ bool VDL3IRFs::write_background( TH2F *h, char *instrument ) (char*)"BKG", (char*)"s^-1 MeV^-1 sr^-1", true ); - write_fits_table_header( "BKG_2D", instrument ); + if( writing_success ) + { + write_fits_table_header( "BKG_2D", instrument ); + } return writing_success; } @@ -770,7 +778,10 @@ bool VDL3IRFs::write_effarea( TH2F *h, char *instrument ) (char*)"m**2", false, true ); - write_fits_table_header( "AEFF_2D", instrument ); + if( writing_success ) + { + write_fits_table_header( "AEFF_2D", instrument ); + } return writing_success; } @@ -785,7 +796,10 @@ bool VDL3IRFs::write_diffsens( TH2F *h, char *instrument ) (char*)"DIFFSENS", (char*)"erg cm^-2 s^-1", false ); - write_fits_table_header( "DIFFSENS_2D", instrument ); + if( writing_success ) + { + write_fits_table_header( "DIFFSENS_2D", instrument ); + } return writing_success; }