// -*- mode: c++ -*-
/**
 * @file pyIrfLoader.in 
 * @brief Interface file for SWIG generated wrappers.  This needs to be
 * processed by setup.py in order to resolve package paths.
 * @author J. Chiang <jchiang@slac.stanford.edu>
 *
 * $Header$
 */
%module pyIrfLoader
%{
//#include <fenv.h>
#include "irfInterface/IAeff.h"
#include "irfInterface/IPsf.h"
#include "irfInterface/IEdisp.h"
#include "irfInterface/IEfficiencyFactor.h"
#include "irfInterface/Irfs.h"
#include "irfInterface/IrfsFactory.h"
#include "irfInterface/AcceptanceCone.h"
#include "irfLoader/Loader.h"
#include "CLHEP/Random/RandFlat.h"
#include "CLHEP/Vector/ThreeVector.h"
#include <map>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
%}
%include stl.i
%exception {
   try {
      $action
   } catch (std::exception & eObj) {
      PyErr_SetString(PyExc_RuntimeError, const_cast<char*>(eObj.what()));
      return NULL;
   }
}
%template(DoublePair) std::pair<double, double>;
%template(DoubleVector) std::vector<double>;
%template(StringVector) std::vector<std::string>;
%template(IrfVector) std::vector<irfInterface::Irfs>;
%template(ConeVector) std::vector<irfInterface::AcceptanceCone *>;
%include $(CLHEPBASE)/include/CLHEP/Vector/ThreeVector.h
%include $(ASTROROOT)/astro/SkyProj.h
%include $(ASTROROOT)/astro/SkyDir.h
%include $(IRFINTERFACEROOT)/irfInterface/AcceptanceCone.h
%include $(IRFINTERFACEROOT)/irfInterface/IAeff.h
%include $(IRFINTERFACEROOT)/irfInterface/IPsf.h
%include $(IRFINTERFACEROOT)/irfInterface/IEdisp.h
%include $(IRFINTERFACEROOT)/irfInterface/IEfficiencyFactor.h
%include $(IRFINTERFACEROOT)/irfInterface/Irfs.h
%include $(IRFINTERFACEROOT)/irfInterface/IrfsFactory.h
%include $(IRFLOADERROOT)/irfLoader/Loader.h
%extend astro::SkyDir {
   astro::SkyDir cross(const astro::SkyDir & other) {
      return astro::SkyDir(self->dir().cross(other.dir()));
   }
   double dot(const astro::SkyDir & other) {
      return self->dir().dot(other.dir());
   }
}
// %extend irfInterface::IrfsFactory {
//    static void enableFPE() {
//       feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
//    }
// }
%extend irfInterface::IPsf {
   std::pair<double, double> app_dir(double energy, double inclination) {
      astro::SkyDir srcDir(0, 0);
      astro::SkyDir scZAxis(0, inclination);
      astro::SkyDir scXAxis(90., 0);
      astro::SkyDir appDir = self->appDir(energy, srcDir, scZAxis, scXAxis);
      double separation = appDir.difference(srcDir)*180./M_PI;
      double phi = CLHEP::RandFlat::shoot()*360.;
      return std::make_pair(separation, phi);
   }
}
%extend irfInterface::IrfsFactory {
   std::vector<std::string> irfNames() {
      std::vector<std::string> names;
      self->getIrfsNames(names);
      return names;
   }
}
