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 | 596 | result.append("\n"+parformat("Statistics")+statistics()); |
| 597 | 597 | result.append("\n"+parformat("Ontime")+str(ontime())); |
| 598 | 598 | result.append("\n"+parformat("Livetime")+str(livetime())); |
| 599 | + result.append("\n"+parformat("Deadtime correction")+str(deadc())); | |
| 599 | 600 | |
| 600 | 601 | // Append pointing |
| 601 | 602 | if (m_pointing != NULL) { |
| ... | ... | @@ -828,22 +829,25 @@ void GCTAObservation::free_members(void) |
| 828 | 829 | * |
| 829 | 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 | 837 | * and optional attributes are |
| 835 | 838 | * |
| 836 | 839 | * OBJECT - Name of observed object |
| 840 | + * DEADC - Deadtime correction | |
| 837 | 841 | * RA_OBJ - Right Ascension of observed object, |
| 838 | 842 | * DEC_OBJ - Declination of observed object, |
| 839 | 843 | * OBS_ID - Observation identifier |
| 840 | - * LIVETIME - Livetime | |
| 841 | - * DEADC - Deadtime correction | |
| 842 | 844 | * ALT_PNT - Altitude of pointing above horizon |
| 843 | 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 | 852 | * @todo The actual reader is a minimal reader to accomodate as many |
| 849 | 853 | * different datasets as possible. Once the CTA data format is fixed |
| ... | ... | @@ -857,11 +861,11 @@ void GCTAObservation::read_attributes(const GFitsHDU* hdu) |
| 857 | 861 | // Read mandatory attributes |
| 858 | 862 | double ra_pnt = hdu->real("RA_PNT"); |
| 859 | 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 | 867 | // Read optional attributes |
| 862 | 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 | 869 | m_deadc = (hdu->hascard("DEADC")) ? hdu->real("DEADC") : 0.0; |
| 866 | 870 | m_ra_obj = (hdu->hascard("RA_OBJ")) ? hdu->real("RA_OBJ") : 0.0; |
| 867 | 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 | 873 | double alt = (hdu->hascard("ALT_PNT")) ? hdu->real("ALT_PNT") : 0.0; |
| 870 | 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 | 886 | // Set pointing information |
| 873 | 887 | GSkyDir pnt; |
| 874 | 888 | pnt.radec_deg(ra_pnt, dec_pnt); |
| ... | ... | @@ -972,22 +986,22 @@ void GCTAObservation::write_attributes(GFitsHDU* hdu) const |
| 972 | 986 | * @param[in] model Gamma-ray source model. |
| 973 | 987 | * |
| 974 | 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 | 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 | 995 | double GCTAObservation::npred_temp(const GModel& model) const |
| 979 | 996 | { |
| 980 | 997 | // Initialise result |
| 981 | 998 | double result = 0.0; |
| 982 | 999 | |
| 983 | - // Determine ontime | |
| 984 | - double ontime = events()->gti().ontime(); | |
| 985 | - | |
| 986 | 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 | ... | ... |