Action #1781

Finish implementation of on-off fitting

Added by Knödlseder Jürgen almost 8 years ago. Updated over 7 years ago.

Status:ClosedStart date:05/30/2016
Priority:UrgentDue date:
Assigned To:Knödlseder Jürgen% Done:


Target version:1.1.0


To avoid again the divergence of the on-off fitting code from the trunk, I merged in the existing code (see #1044), but there are a number of outstanding issues that should be solved before the 1.1.0 release:
  • there is no complete unit test that checks the On/Off fitting functionality. Such a test should be added to the script (there is already a unit test, but it does so far not perform On/Off fitting)
  • the computation of the Hessian in GCTAOnOffObservation::likelihood() looks strange. Could you please write down the intended formula in the documentation (can use LaTeX style), and then check whether the formula is indeed implemented?
  • the GCTAOnOffObservation::compute_alpha method actually computes the ratio between effective areas, not exposures. Am I correct that it should compute the ratio of exposures? What about the solid angle?
  • in the GCTAOnOffObservation::compute_rmf method, if a weighting is done, should it not be done over effective area times livetime? Where is the time coming in? Could you write down the formula in the documentation what the method should be doing? Also, should the aeff method not use true instead of reconstructed energy?
  • shoudn’t the model_on() and model_off() methods be private (it’s always simpler to make a private method public when really needed then vice versa)
  • are the alpha() and offtime() methods needed?


No recurrence.

Related issues

Follows GammaLib - Feature #1044: Implement ON-OFF fitting Closed


#1 Updated by Knödlseder Jürgen almost 8 years ago

#2 Updated by Knödlseder Jürgen almost 8 years ago

By the way: best is to make commits on individual fixes to prevent again that the code diverges.

#3 Updated by Knödlseder Jürgen over 7 years ago

  • Status changed from New to In Progress
  • Assigned To changed from Martin Pierrick to Knödlseder Jürgen

I have written down the formulae for the log-likelihood, its derivative and the curvature matrix and have corrected the implementation (there was an error in the mixed curvature matrix elements for background and sky components).

#4 Updated by Knödlseder Jürgen over 7 years ago

  • % Done changed from 0 to 50

The On/Off fitting has been implemented as Python unit test, including verification of fit values.

#5 Updated by Knödlseder Jürgen over 7 years ago

  • % Done changed from 50 to 70

The GCTAOnOffObservation::compute_alpha method should not use the effective area but the background acceptance, as alpha is a correction factor that translates the off-region background to the on-region background. In addition, the correction should include the solid angle of the background region.

The method was corrected accordingly.

#6 Updated by Knödlseder Jürgen over 7 years ago

  • % Done changed from 70 to 90

In order to allow loading of On/Off observations from an XML file I needed to modify a bit the way how the background response and the alpha parameters are stored (the information was in fact not written to any file, hence it was missing when analysing an On/Off observation on the basis of an XML file). I added C++ unit tests that check the On/Off observation and that do model fitting on basis of an XML file.

The ARF format allows to store additional columns, and I therefore added the background and alpha vectors as columns “BACKGROUND” and “ALPHA” to the ARF file. This needed some modifications of GArf so that additional columns are handled.

I furthermore simplified the class interface. Before, etrue has been specified for response computation while it is better specified during class construction, as is already done for ereco. In addition, I removed the fill() and compute_response() methods and now do both actions upon construction from a CTA observation. This furthermore assures that things are done consistently. Hence an On/Off observation is now build from a GCTAObservation object in a single shot.

#7 Updated by Knödlseder Jürgen over 7 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 90 to 100

Merged into devel.

Also available in: Atom PDF