Commit 02f23c957cb6529db65eeb4301872a11f460afe2

Authored by Jürgen Knödlseder
2 parents 67eea5ef 866440e8

Merge branch '2721-stacked-analysis' into integration

# Conflicts:
#	ChangeLog
ChangeLog
... ... @@ -3,6 +3,7 @@
3 3 * Version 1.6.0 released
4 4 ========================
5 5  
  6 + Apply event bin weighting in ctmodel for stacked computation (#2721)
6 7 Add Jupyter notebooks for H.E.S.S. DR1 (#2712)
7 8 Add code generator (#2709)
8 9 Add csbkgmodel script (#2694)
... ...
... ... @@ -124,6 +124,13 @@ None
124 124  
125 125 ctmodel - CTA counts cube modelling
126 126 -----------------------------------
  127 +When running ctmodel on a counts cube, and specifically a stacked count cube,
  128 +the event bin weighting is taken into account in the model evaluation. This
  129 +is needed to properly take into account the changing thresholds. No such
  130 +weighting is done if the model is computed from an event list, since in that
  131 +case the model is properly computed for each observation using the run-wise
  132 +response (#2721).
  133 +
127 134 The tools now computes DETX and DETY for every event bin if they are not
128 135 available so that model that rely on the existence of these parameters can
129 136 be handled (#2694).
... ...
doc/source/admin/release_history/1.6.rst
... ... @@ -21,6 +21,8 @@ In particular, this release provides:
21 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 26 * [`2694 <https://cta-redmine.irap.omp.eu/issues/2694>`_] -
25 27 Compute ``DETX`` and ``DETY`` in :ref:`ctmodel` if they are not available
26 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 893 bin.ontime(obs->ontime());
894 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 899 // Loop over all the spatial bins
897 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 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 930 bin.energy(m_energy[iebin]);
928 931 bin.ewidth(m_ewidth[iebin]);
929 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 940 // Compute model value for cube bin
933 941 double model = models.eval(bin, *obs) * bin.size();
... ...