Commit b8a73133651e41571190bafe2103b533adea62b5
1 parent
82a4a8ec
Conserve observation container information and single CTA observation information.
In the adaption to cube-style analysis, response and model information was lost in the observation container. Now, model information is conserved, and in case of a single CTA observation, response information is carried over. This provides support for the original binned analysis.
Showing
1 changed file
with
60 additions
and
24 deletions
src/ctbin/ctbin.cpp
| ... | ... | @@ -851,39 +851,75 @@ void ctbin::fill_cube(GCTAObservation* obs) |
| 851 | 851 | |
| 852 | 852 | |
| 853 | 853 | /***********************************************************************//** |
| 854 | - * @brief Put cube as single element in observation container. | |
| 854 | + * @brief Create output observation container. | |
| 855 | + * | |
| 856 | + * Creates an output observation container that combines all input CTA | |
| 857 | + * observation into a single cube-style observation. All non CTA observations | |
| 858 | + * present in the observation container are kept. The method furthermore | |
| 859 | + * conserves any response information in case that a single CTA observation | |
| 860 | + * is provided. This supports the original binned analysis. | |
| 855 | 861 | ***************************************************************************/ |
| 856 | 862 | void ctbin::obs_cube(void) |
| 857 | 863 | { |
| 858 | - // Clear observation container | |
| 859 | - m_obs.clear(); | |
| 864 | + // If we have only a single CTA observation in the container, then | |
| 865 | + // keep that observation and just attach the event cube to it | |
| 866 | + if (m_obs.size() == 1) { | |
| 867 | + | |
| 868 | + // Attach event cube to CTA observation | |
| 869 | + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[0]); | |
| 870 | + if (obs != NULL) { | |
| 871 | + obs->events(this->cube()); | |
| 872 | + } | |
| 860 | 873 | |
| 861 | - // Allocate CTA observation. We need this to make sure that all | |
| 862 | - // attributes are set correctly | |
| 863 | - GCTAObservation obs; | |
| 874 | + } | |
| 875 | + | |
| 876 | + // ... otherwise put a single CTA observation in container | |
| 877 | + else { | |
| 864 | 878 | |
| 865 | - // Attach event cube to CTA observation | |
| 866 | - obs.events(this->cube()); | |
| 879 | + // Allocate observation container | |
| 880 | + GObservations container; | |
| 881 | + | |
| 882 | + // Allocate CTA observation. | |
| 883 | + GCTAObservation obs; | |
| 867 | 884 | |
| 868 | - // Set map centre as pointing | |
| 869 | - GSkyPixel pixel(0.5*double(m_cube.nx()), 0.5*double(m_cube.ny())); | |
| 870 | - GSkyDir centre = m_cube.pix2dir(pixel); | |
| 871 | - GCTAPointing pointing(centre); | |
| 885 | + // Attach event cube to CTA observation | |
| 886 | + obs.events(this->cube()); | |
| 872 | 887 | |
| 873 | - // Compute deadtime correction | |
| 874 | - double deadc = (m_ontime > 0.0) ? m_livetime / m_ontime : 0.0; | |
| 888 | + // Set map centre as pointing | |
| 889 | + GSkyPixel pixel(0.5*double(m_cube.nx()), 0.5*double(m_cube.ny())); | |
| 890 | + GSkyDir centre = m_cube.pix2dir(pixel); | |
| 891 | + GCTAPointing pointing(centre); | |
| 892 | + | |
| 893 | + // Compute deadtime correction | |
| 894 | + double deadc = (m_ontime > 0.0) ? m_livetime / m_ontime : 0.0; | |
| 895 | + | |
| 896 | + // Set CTA observation attributes | |
| 897 | + obs.pointing(pointing); | |
| 898 | + obs.obs_id(0); | |
| 899 | + obs.ra_obj(centre.ra_deg()); //!< Dummy | |
| 900 | + obs.dec_obj(centre.dec_deg()); //!< Dummy | |
| 901 | + obs.ontime(m_ontime); | |
| 902 | + obs.livetime(m_livetime); | |
| 903 | + obs.deadc(deadc); | |
| 904 | + | |
| 905 | + // Set models in observation container | |
| 906 | + container.models(m_obs.models()); | |
| 907 | + | |
| 908 | + // Append CTA observation | |
| 909 | + m_obs.append(obs); | |
| 910 | + | |
| 911 | + // Copy over all remaining non-CTA observations | |
| 912 | + for (int i = 0; i < m_obs.size(); ++i) { | |
| 913 | + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); | |
| 914 | + if (obs == NULL) { | |
| 915 | + container.append(*m_obs[i]); | |
| 916 | + } | |
| 917 | + } | |
| 875 | 918 | |
| 876 | - // Set CTA observation attributes | |
| 877 | - obs.pointing(pointing); | |
| 878 | - obs.obs_id(0); | |
| 879 | - obs.ra_obj(centre.ra_deg()); //!< Dummy | |
| 880 | - obs.dec_obj(centre.dec_deg()); //!< Dummy | |
| 881 | - obs.ontime(m_ontime); | |
| 882 | - obs.livetime(m_livetime); | |
| 883 | - obs.deadc(deadc); | |
| 919 | + // Set observation container | |
| 920 | + m_obs = container; | |
| 884 | 921 | |
| 885 | - // Append observation to container | |
| 886 | - m_obs.append(obs); | |
| 922 | + } // endelse: there was not a single CTA observation | |
| 887 | 923 | |
| 888 | 924 | // Return |
| 889 | 925 | return; | ... | ... |