Commit 0fa57767a0f9c10de53327f2f1dfa41953e0cc12
1 parent
13954e0d
Compute DEADC from livetime and ontime in GCTAObservation::read_attributes (the …
…DEADC keyword is not set correctly in the actual event lists)
Showing
1 changed file
with
29 additions
and
15 deletions
inst/cta/src/GCTAObservation.cpp
| @@ -596,6 +596,7 @@ std::string GCTAObservation::print(void) const | @@ -596,6 +596,7 @@ std::string GCTAObservation::print(void) const | ||
| 596 | result.append("\n"+parformat("Statistics")+statistics()); | 596 | result.append("\n"+parformat("Statistics")+statistics()); |
| 597 | result.append("\n"+parformat("Ontime")+str(ontime())); | 597 | result.append("\n"+parformat("Ontime")+str(ontime())); |
| 598 | result.append("\n"+parformat("Livetime")+str(livetime())); | 598 | result.append("\n"+parformat("Livetime")+str(livetime())); |
| 599 | + result.append("\n"+parformat("Deadtime correction")+str(deadc())); | ||
| 599 | 600 | ||
| 600 | // Append pointing | 601 | // Append pointing |
| 601 | if (m_pointing != NULL) { | 602 | if (m_pointing != NULL) { |
| @@ -828,22 +829,25 @@ void GCTAObservation::free_members(void) | @@ -828,22 +829,25 @@ void GCTAObservation::free_members(void) | ||
| 828 | * | 829 | * |
| 829 | * Reads CTA observation attributes from HDU. Mandatory attributes are | 830 | * Reads CTA observation attributes from HDU. Mandatory attributes are |
| 830 | * | 831 | * |
| 831 | - * RA_PNT - Right Ascension of pointing | ||
| 832 | - * DEC_PNT - Declination of pointing | 832 | + * RA_PNT - Right Ascension of pointing |
| 833 | + * DEC_PNT - Declination of pointing | ||
| 834 | + * ONTIME - Exposure time | ||
| 835 | + * LIVETIME - Livetime | ||
| 833 | * | 836 | * |
| 834 | * and optional attributes are | 837 | * and optional attributes are |
| 835 | * | 838 | * |
| 836 | * OBJECT - Name of observed object | 839 | * OBJECT - Name of observed object |
| 840 | + * DEADC - Deadtime correction | ||
| 837 | * RA_OBJ - Right Ascension of observed object, | 841 | * RA_OBJ - Right Ascension of observed object, |
| 838 | * DEC_OBJ - Declination of observed object, | 842 | * DEC_OBJ - Declination of observed object, |
| 839 | * OBS_ID - Observation identifier | 843 | * OBS_ID - Observation identifier |
| 840 | - * LIVETIME - Livetime | ||
| 841 | - * DEADC - Deadtime correction | ||
| 842 | * ALT_PNT - Altitude of pointing above horizon | 844 | * ALT_PNT - Altitude of pointing above horizon |
| 843 | * AZ_PNT - Azimuth of pointing | 845 | * AZ_PNT - Azimuth of pointing |
| 844 | * | 846 | * |
| 845 | - * Based on RA_PNT and DEC_PNT, the CTA pointing direction is set. Nothing | ||
| 846 | - * is done if the HDU pointer is NULL. | 847 | + * Based on RA_PNT and DEC_PNT, the CTA pointing direction is set. Note that |
| 848 | + * DEADC is computed using DEADC=LIVETIME/ONTIME | ||
| 849 | + * | ||
| 850 | + * Nothing is done if the HDU pointer is NULL. | ||
| 847 | * | 851 | * |
| 848 | * @todo The actual reader is a minimal reader to accomodate as many | 852 | * @todo The actual reader is a minimal reader to accomodate as many |
| 849 | * different datasets as possible. Once the CTA data format is fixed | 853 | * different datasets as possible. Once the CTA data format is fixed |
| @@ -857,11 +861,11 @@ void GCTAObservation::read_attributes(const GFitsHDU* hdu) | @@ -857,11 +861,11 @@ void GCTAObservation::read_attributes(const GFitsHDU* hdu) | ||
| 857 | // Read mandatory attributes | 861 | // Read mandatory attributes |
| 858 | double ra_pnt = hdu->real("RA_PNT"); | 862 | double ra_pnt = hdu->real("RA_PNT"); |
| 859 | double dec_pnt = hdu->real("DEC_PNT"); | 863 | double dec_pnt = hdu->real("DEC_PNT"); |
| 864 | + m_ontime = (hdu->hascard("ONTIME")) ? hdu->real("ONTIME") : 0.0; | ||
| 865 | + m_livetime = (hdu->hascard("LIVETIME")) ? hdu->real("LIVETIME") : 0.0; | ||
| 860 | 866 | ||
| 861 | // Read optional attributes | 867 | // Read optional attributes |
| 862 | m_name = (hdu->hascard("OBJECT")) ? hdu->string("OBJECT") : "unknown"; | 868 | m_name = (hdu->hascard("OBJECT")) ? hdu->string("OBJECT") : "unknown"; |
| 863 | - m_ontime = (hdu->hascard("ONTIME")) ? hdu->real("ONTIME") : 0.0; | ||
| 864 | - m_livetime = (hdu->hascard("LIVETIME")) ? hdu->real("LIVETIME") : 0.0; | ||
| 865 | m_deadc = (hdu->hascard("DEADC")) ? hdu->real("DEADC") : 0.0; | 869 | m_deadc = (hdu->hascard("DEADC")) ? hdu->real("DEADC") : 0.0; |
| 866 | m_ra_obj = (hdu->hascard("RA_OBJ")) ? hdu->real("RA_OBJ") : 0.0; | 870 | m_ra_obj = (hdu->hascard("RA_OBJ")) ? hdu->real("RA_OBJ") : 0.0; |
| 867 | m_dec_obj = (hdu->hascard("DEC_OBJ")) ? hdu->real("DEC_OBJ") : 0.0; | 871 | m_dec_obj = (hdu->hascard("DEC_OBJ")) ? hdu->real("DEC_OBJ") : 0.0; |
| @@ -869,6 +873,16 @@ void GCTAObservation::read_attributes(const GFitsHDU* hdu) | @@ -869,6 +873,16 @@ void GCTAObservation::read_attributes(const GFitsHDU* hdu) | ||
| 869 | double alt = (hdu->hascard("ALT_PNT")) ? hdu->real("ALT_PNT") : 0.0; | 873 | double alt = (hdu->hascard("ALT_PNT")) ? hdu->real("ALT_PNT") : 0.0; |
| 870 | double az = (hdu->hascard("AZ_PNT")) ? hdu->real("AZ_PNT") : 0.0; | 874 | double az = (hdu->hascard("AZ_PNT")) ? hdu->real("AZ_PNT") : 0.0; |
| 871 | 875 | ||
| 876 | + // Kluge: compute DEADC from livetime and ontime instead of using the | ||
| 877 | + // keyword value as the original event lists had this values badly | ||
| 878 | + // assigned | ||
| 879 | + if (m_ontime > 0) { | ||
| 880 | + m_deadc = m_livetime / m_ontime; | ||
| 881 | + } | ||
| 882 | + else { | ||
| 883 | + m_deadc = 0.0; | ||
| 884 | + } | ||
| 885 | + | ||
| 872 | // Set pointing information | 886 | // Set pointing information |
| 873 | GSkyDir pnt; | 887 | GSkyDir pnt; |
| 874 | pnt.radec_deg(ra_pnt, dec_pnt); | 888 | pnt.radec_deg(ra_pnt, dec_pnt); |
| @@ -972,22 +986,22 @@ void GCTAObservation::write_attributes(GFitsHDU* hdu) const | @@ -972,22 +986,22 @@ void GCTAObservation::write_attributes(GFitsHDU* hdu) const | ||
| 972 | * @param[in] model Gamma-ray source model. | 986 | * @param[in] model Gamma-ray source model. |
| 973 | * | 987 | * |
| 974 | * Implement the temporal integration as a simple multiplication by the | 988 | * Implement the temporal integration as a simple multiplication by the |
| 975 | - * elapsed time. This assumes that the source is non-variable during the | 989 | + * ontime. This assumes that the source is non-variable during the |
| 976 | * observation and that the CTA pointing is stable. | 990 | * observation and that the CTA pointing is stable. |
| 991 | + * | ||
| 992 | + * Note that we use here the ontime as the GResponse::irf method returns | ||
| 993 | + * already deadtime corrected response values. | ||
| 977 | ***************************************************************************/ | 994 | ***************************************************************************/ |
| 978 | double GCTAObservation::npred_temp(const GModel& model) const | 995 | double GCTAObservation::npred_temp(const GModel& model) const |
| 979 | { | 996 | { |
| 980 | // Initialise result | 997 | // Initialise result |
| 981 | double result = 0.0; | 998 | double result = 0.0; |
| 982 | 999 | ||
| 983 | - // Determine ontime | ||
| 984 | - double ontime = events()->gti().ontime(); | ||
| 985 | - | ||
| 986 | // Integrate only if ontime is positive | 1000 | // Integrate only if ontime is positive |
| 987 | - if (ontime > 0.0) { | 1001 | + if (ontime() > 0.0) { |
| 988 | 1002 | ||
| 989 | - // Integration is a simple multiplication by the time | ||
| 990 | - result = npred_spec(model, events()->gti().tstart()) * ontime; | 1003 | + // Integration is a simple multiplication by the ontime |
| 1004 | + result = npred_spec(model, events()->gti().tstart()) * ontime(); | ||
| 991 | 1005 | ||
| 992 | } | 1006 | } |
| 993 | 1007 |