diff --git a/ChangeLog b/ChangeLog index e20044c..2d2b0c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2015-02-23 Juergen Knoedlseder +2015-03-28 Juergen Knoedlseder * Version 1.0.0 released ======================== @@ -9,6 +9,7 @@ Modify cssens parameter interface (#1426) Add csobsdef script (#1429) Add ctulimit tool (#1363) + Handle background cubes for stacked analysis (#1371) 2015-01-08 Juergen Knoedlseder diff --git a/NEWS b/NEWS index 0a6eddc..5079bf7 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 1.0.0 Author(s) : Juergen Knoedlseder -23 February 2015 +28 March 2015 1. Introduction @@ -49,12 +49,14 @@ None 8. ctlike - Maximum likelihood fitting -------------------------------------- -None +The bkgcube parameter has been added to allow specification of a background +cube for stacked analysis. 9. cttsmap - Generation of Test Statistics map ---------------------------------------------- -None +The bkgcube parameter has been added to allow specification of a background +cube for stacked analysis. 10. ctskymap - CTA sky mapping @@ -64,7 +66,8 @@ None 11. ctmodel - CTA counts cube modelling --------------------------------------- -None +The bkgcube parameter has been added to allow specification of a background +cube for stacked analysis. 12. ctexpcube - CTA exposure cube generation @@ -89,13 +92,17 @@ None 16. ctbutterfly - Generate butterfly diagrams --------------------------------------------- -None +The bkgcube parameter has been added to allow specification of a background +cube for stacked analysis. 17. ctulimit - Compute upper limit ---------------------------------- Added an initial version of the upper limit computation tool. +The bkgcube parameter has been added to allow specification of a background +cube for stacked analysis. + 18. Examples ------------ diff --git a/pyext/ctbkgcube.i b/pyext/ctbkgcube.i index 45e18eb..c8631b0 100644 --- a/pyext/ctbkgcube.i +++ b/pyext/ctbkgcube.i @@ -1,7 +1,7 @@ /*************************************************************************** * ctbkgcube - Background cube generation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014 by Chia-Chun Lu * + * copyright (C) 2014-2015 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -44,11 +44,11 @@ public: virtual ~ctbkgcube(void); // Methods - void clear(void); - void run(void); - void save(void); + void clear(void); + void run(void); + void save(void); const GCTACubeBackground& cube(void) const; - const GModels& models(void) const; + const GModels& models(void) const; }; /***********************************************************************//** diff --git a/src/ctbkgcube/ctbkgcube.cpp b/src/ctbkgcube/ctbkgcube.cpp index e1cec89..acdbb86 100644 --- a/src/ctbkgcube/ctbkgcube.cpp +++ b/src/ctbkgcube/ctbkgcube.cpp @@ -34,7 +34,6 @@ /* __ Method name definitions ____________________________________________ */ #define G_GET_PARAMETERS "ctbkgcube::get_parameters()" -#define G_FILL_CUBE "ctbkgcube::fill_cube(GCTAObservation*)" /* __ Debug definitions __________________________________________________ */ @@ -246,14 +245,13 @@ void ctbkgcube::run(void) // Copy models from observation container and reset output model // container GModels models_orig = m_obs.models(); - m_bkgmdl = m_obs.models(); + m_bkgmdl = m_obs.models(); m_outmdl.clear(); // Remove all models that are not CTA background models from the // container and put all removed components in the output // container int num = m_bkgmdl.size(); - for (int i = num-1; i >= 0; --i) { // Flag removal @@ -315,21 +313,18 @@ void ctbkgcube::run(void) // Create a background model for the output background cube and append // that model to the input model in place of the original // background models - // Todo: We might think of creating the spectral model via user parameter - GCTAModelCubeBackground model(GModelSpectralConst(1.0)); + // TODO: We might think of creating the spectral model via user parameter + GModelSpectralPlaw spectral(1.0, 0.0, GEnergy(1.0, "TeV")); + GCTAModelCubeBackground model(spectral); // Set model name model.name("BackgroundModel"); // Set model instrument - // Todo: Account for possibility to have observations from different + // TODO: Account for possibility to have observations from different // IACTs in the same container model.instruments("CTA,HESS,MAGIC,VERITAS"); - // Set model identifier to "0". This is coupled to ctbin, where the binned output - // observation id is set to 0. - model.ids("0"); - // Append model to output container m_outmdl.append(model); @@ -361,7 +356,6 @@ void ctbkgcube::save(void) log.header1("Save background cube"); } - // Get output filenames std::string outfile = (*this)["outcube"].filename(); std::string outmodel = (*this)["outmodel"].filename(); @@ -374,6 +368,7 @@ void ctbkgcube::save(void) // Save output model for binned analyses m_outmdl.save(outmodel); + } // Return @@ -399,7 +394,6 @@ void ctbkgcube::init_members(void) m_background.clear(); m_bkgmdl.clear(); m_outmdl.clear(); - m_ebounds.clear(); // Return return; @@ -420,7 +414,6 @@ void ctbkgcube::copy_members(const ctbkgcube& app) m_background = app.m_background; m_bkgmdl = app.m_bkgmdl; m_outmdl = app.m_outmdl; - m_ebounds = app.m_ebounds; // Return return; @@ -498,9 +491,6 @@ void ctbkgcube::get_parameters(void) m_obs.models(models); } -// // Get energy definition -// m_ebounds = m_background.ebounds(); - // Read output filenames (if needed) if (read_ahead()) { m_outcube = (*this)["outcube"].filename(); diff --git a/src/ctbkgcube/ctbkgcube.hpp b/src/ctbkgcube/ctbkgcube.hpp index eb1b30c..9d64ef1 100644 --- a/src/ctbkgcube/ctbkgcube.hpp +++ b/src/ctbkgcube/ctbkgcube.hpp @@ -56,11 +56,11 @@ public: ctbkgcube& operator=(const ctbkgcube& app); // Methods - void clear(void); - void run(void); - void save(void); + void clear(void); + void run(void); + void save(void); const GCTACubeBackground& cube(void) const; - const GModels& models(void) const; + const GModels& models(void) const; protected: // Protected methods @@ -71,14 +71,12 @@ protected: void fill_cube(GCTAObservation* obs); // Protected members - std::string m_outcube; //!< Filename of output cube - std::string m_outmodel; //!< Filename of output XML model - GObservations m_obs; //!< Observation container - GCTACubeBackground m_background; //!< Background cube response - GModels m_bkgmdl; //!< CTA background models - GModels m_outmdl; //!< Output models - GEbounds m_ebounds; //!< Energy boundaries - + std::string m_outcube; //!< Filename of output cube + std::string m_outmodel; //!< Filename of output XML model + GObservations m_obs; //!< Observation container + GCTACubeBackground m_background; //!< Background cube response + GModels m_bkgmdl; //!< CTA background models + GModels m_outmdl; //!< Output models }; diff --git a/test/test_ctools.sh b/test/test_ctools.sh index 302de80..0a0b27d 100755 --- a/test/test_ctools.sh +++ b/test/test_ctools.sh @@ -179,20 +179,20 @@ $ECHO -n "Test ctexpcube: " # # Run 1 $ctexpcube inobs="data/crab_events.fits" \ -incube="NONE" \ -outcube="expcube1.fits" \ -caldb="irf" \ -irf="cta_dummy_irf" \ -emin=0.1 \ -emax=100.0 \ -enumbins=20 \ -nxpix=200 \ -nypix=200 \ -binsz=0.02 \ -coordsys="CEL" \ -xref=83.63 \ -yref=22.01 \ -proj="CAR" + incube="NONE" \ + outcube="expcube1.fits" \ + caldb="irf" \ + irf="cta_dummy_irf" \ + emin=0.1 \ + emax=100.0 \ + enumbins=20 \ + nxpix=200 \ + nypix=200 \ + binsz=0.02 \ + coordsys="CEL" \ + xref=83.63 \ + yref=22.01 \ + proj="CAR" $ECHO -n "." if [ -s "expcube1.fits" ] then @@ -204,10 +204,10 @@ fi # # Run 2 $ctexpcube inobs="events.fits" \ -incube="cntmap2.fits" \ -outcube="expcube2.fits" \ -caldb="irf" \ -irf="cta_dummy_irf" + incube="cntmap2.fits" \ + outcube="expcube2.fits" \ + caldb="irf" \ + irf="cta_dummy_irf" $ECHO -n "." if [ -s "expcube2.fits" ] then @@ -226,22 +226,22 @@ $ECHO -n "Test ctpsfcube: " # # Run 1 $ctpsfcube inobs="data/crab_events.fits" \ -incube="NONE" \ -outcube="psfcube1.fits" \ -caldb="irf" \ -irf="cta_dummy_irf" \ -emin=0.1 \ -emax=100.0 \ -enumbins=20 \ -nxpix=10 \ -nypix=10 \ -binsz=0.4 \ -coordsys="CEL" \ -xref=83.63 \ -yref=22.01 \ -proj="CAR" \ -amax=0.3 \ -anumbins=10 + incube="NONE" \ + outcube="psfcube1.fits" \ + caldb="irf" \ + irf="cta_dummy_irf" \ + emin=0.1 \ + emax=100.0 \ + enumbins=20 \ + nxpix=10 \ + nypix=10 \ + binsz=0.4 \ + coordsys="CEL" \ + xref=83.63 \ + yref=22.01 \ + proj="CAR" \ + amax=0.3 \ + anumbins=10 $ECHO -n "." if [ -s "psfcube1.fits" ] then @@ -253,12 +253,12 @@ fi # # Run 2 $ctpsfcube inobs="events.fits" \ -incube="cntmap2.fits" \ -outcube="psfcube2.fits" \ -caldb="irf" \ -irf="cta_dummy_irf" \ -amax=0.3 \ -anumbins=2 + incube="cntmap2.fits" \ + outcube="psfcube2.fits" \ + caldb="irf" \ + irf="cta_dummy_irf" \ + amax=0.3 \ + anumbins=2 $ECHO -n "." if [ -s "psfcube2.fits" ] then @@ -277,22 +277,22 @@ $ECHO -n "Test ctbkgcube: " # # Run 1 $ctbkgcube inobs="data/crab_events.fits" \ -inmodel="data/crab.xml" \ -incube="NONE" \ -outcube="bkgcube1.fits" \ -outmodel="bkgcube1.xml" \ -caldb="irf" \ -irf="cta_dummy_irf" \ -emin=0.1 \ -emax=100.0 \ -enumbins=20 \ -nxpix=10 \ -nypix=10 \ -binsz=0.4 \ -coordsys="CEL" \ -xref=83.63 \ -yref=22.01 \ -proj="CAR" + inmodel="data/crab.xml" \ + incube="NONE" \ + outcube="bkgcube1.fits" \ + outmodel="bkgcube1.xml" \ + caldb="irf" \ + irf="cta_dummy_irf" \ + emin=0.1 \ + emax=100.0 \ + enumbins=20 \ + nxpix=10 \ + nypix=10 \ + binsz=0.4 \ + coordsys="CEL" \ + xref=83.63 \ + yref=22.01 \ + proj="CAR" $ECHO -n "." if [ -s "bkgcube1.fits" ] then @@ -311,12 +311,12 @@ fi # # Run 2 $ctbkgcube inobs="events.fits" \ -inmodel="data/crab.xml" \ -incube="cntmap2.fits" \ -caldb="irf" \ -irf="cta_dummy_irf" \ -outcube="bkgcube2.fits" \ -outmodel="bkgcube2.xml" + inmodel="data/crab.xml" \ + incube="cntmap2.fits" \ + caldb="irf" \ + irf="cta_dummy_irf" \ + outcube="bkgcube2.fits" \ + outmodel="bkgcube2.xml" $ECHO -n "." if [ -s "bkgcube2.fits" ] then @@ -347,7 +347,7 @@ $ctmodel inobs="cntmap1.fits" \ outcube="modmap1.fits" \ expcube="NONE" \ psfcube="NONE" \ - bgcube="NONE" \ + bkgcube="NONE" \ caldb="irf" \ irf="cta_dummy_irf" \ inmodel="data/crab.xml" @@ -362,14 +362,14 @@ fi # # Run 2 $ctmodel inobs="cntmap2.fits" \ -incube="cntmap2.fits" \ -outcube="modmap2.fits" \ -expcube="expcube2.fits" \ -psfcube="psfcube2.fits" \ -bgcube="bkgcube2.fits" \ -caldb="irf" \ -irf="cta_dummy_irf" \ -inmodel="bkgcube2.xml" + incube="cntmap2.fits" \ + outcube="modmap2.fits" \ + expcube="expcube2.fits" \ + psfcube="psfcube2.fits" \ + bkgcube="bkgcube2.fits" \ + caldb="irf" \ + irf="cta_dummy_irf" \ + inmodel="bkgcube2.xml" $ECHO -n "." if [ -s "modmap2.fits" ] then @@ -448,7 +448,7 @@ $ctlike inobs="cntmap1.fits" \ outmodel="results_binned.xml" \ expcube="NONE" \ psfcube="NONE" \ - bgcube="NONE" \ + bkgcube="NONE" \ caldb="irf" \ irf="cta_dummy_irf" $ECHO -n "." @@ -482,7 +482,7 @@ $ctlike inobs="cntmap2.fits" \ outmodel="results_binned_cube_background.xml" \ expcube="expcube2.fits" \ psfcube="psfcube2.fits" \ - bgcube="bkgcube2.fits" \ + bkgcube="bkgcube2.fits" \ caldb="irf" \ irf="cta_dummy_irf" $ECHO -n "." @@ -577,10 +577,10 @@ $ECHO " ok" # =============== $ECHO -n "Test ctulimit: " $ctulimit inobs="data/crab_events.fits.gz" \ - inmodel="data/crab.xml" \ - srcname="Crab" \ - caldb="irf" \ - irf="cta_dummy_irf" + inmodel="data/crab.xml" \ + srcname="Crab" \ + caldb="irf" \ + irf="cta_dummy_irf" $ECHO -n "." if [ -s "ctulimit.log" ] then