Commit 866440e8d7b5435245827ac0353f5e31aa10d666

Authored by Jürgen Knödlseder
1 parent 1c81f76b

Apply event bin weighting in ctmodel for stacked computation (#2721)

ChangeLog
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 * Version 1.6.0 released 3 * Version 1.6.0 released
4 ======================== 4 ========================
5 5
  6 + Apply event bin weighting in ctmodel for stacked computation (#2721)
6 Add code generator (#2709) 7 Add code generator (#2709)
7 Add csbkgmodel script (#2694) 8 Add csbkgmodel script (#2694)
8 Compute DETX and DETY in ctmodel if they are not available (#2694) 9 Compute DETX and DETY in ctmodel if they are not available (#2694)
@@ -118,6 +118,13 @@ None @@ -118,6 +118,13 @@ None
118 118
119 ctmodel - CTA counts cube modelling 119 ctmodel - CTA counts cube modelling
120 ----------------------------------- 120 -----------------------------------
  121 +When running ctmodel on a counts cube, and specifically a stacked count cube,
  122 +the event bin weighting is taken into account in the model evaluation. This
  123 +is needed to properly take into account the changing thresholds. No such
  124 +weighting is done if the model is computed from an event list, since in that
  125 +case the model is properly computed for each observation using the run-wise
  126 +response (#2721).
  127 +
121 The tools now computes DETX and DETY for every event bin if they are not 128 The tools now computes DETX and DETY for every event bin if they are not
122 available so that model that rely on the existence of these parameters can 129 available so that model that rely on the existence of these parameters can
123 be handled (#2694). 130 be handled (#2694).
doc/source/admin/release_history/1.6.rst
@@ -21,6 +21,8 @@ In particular, this release provides: @@ -21,6 +21,8 @@ In particular, this release provides:
21 Bug fixes 21 Bug fixes
22 --------- 22 ---------
23 23
  24 +* [`2721 <https://cta-redmine.irap.omp.eu/issues/2721>`_] -
  25 + Apply event bin weighting in :ref:`ctmodel` for stacked computation
24 * [`2694 <https://cta-redmine.irap.omp.eu/issues/2694>`_] - 26 * [`2694 <https://cta-redmine.irap.omp.eu/issues/2694>`_] -
25 Compute ``DETX`` and ``DETY`` in :ref:`ctmodel` if they are not available 27 Compute ``DETX`` and ``DETY`` in :ref:`ctmodel` if they are not available
26 * [`2686 <https://cta-redmine.irap.omp.eu/issues/2686>`_] - 28 * [`2686 <https://cta-redmine.irap.omp.eu/issues/2686>`_] -
src/ctmodel/ctmodel.cpp
@@ -893,6 +893,9 @@ void ctmodel::fill_cube(const GCTAObservation* obs, GModels&amp; models) @@ -893,6 +893,9 @@ void ctmodel::fill_cube(const GCTAObservation* obs, GModels&amp; models)
893 bin.ontime(obs->ontime()); 893 bin.ontime(obs->ontime());
894 bin.weight(1.0); 894 bin.weight(1.0);
895 895
  896 + // Flag if the CTA observation is a counts cube
  897 + bool obs_is_cube = (obs->eventtype() == "CountsCube");
  898 +
896 // Loop over all the spatial bins 899 // Loop over all the spatial bins
897 for (int i = 0; i < npix; ++i) { 900 for (int i = 0; i < npix; ++i) {
898 901
@@ -923,11 +926,16 @@ void ctmodel::fill_cube(const GCTAObservation* obs, GModels&amp; models) @@ -923,11 +926,16 @@ void ctmodel::fill_cube(const GCTAObservation* obs, GModels&amp; models)
923 continue; 926 continue;
924 } 927 }
925 928
926 - // Set energy, energy width, energy index and weight of bin 929 + // Set energy, energy width and energy index
927 bin.energy(m_energy[iebin]); 930 bin.energy(m_energy[iebin]);
928 bin.ewidth(m_ewidth[iebin]); 931 bin.ewidth(m_ewidth[iebin]);
929 bin.ieng(iebin); 932 bin.ieng(iebin);
930 - //bin.weight(m_cube[ibin]->weight()); // Bad residuals for H.E.S.S. Crab 933 +
  934 + // If observation is a counts cube then set the proper weight for
  935 + // this bin
  936 + if (obs_is_cube) {
  937 + bin.weight(m_cube[ibin]->weight());
  938 + }
931 939
932 // Compute model value for cube bin 940 // Compute model value for cube bin
933 double model = models.eval(bin, *obs) * bin.size(); 941 double model = models.eval(bin, *obs) * bin.size();