49 #define G_CALDB "GLATResponse::caldb(std::string&)"
50 #define G_LOAD "GLATResponse::load(std::string&)"
51 #define G_IRF "GLATResponse::irf(GInstDir&, GEnergy&, GTime&, GSkyDir&,"\
52 " GEnergy&, GTime&, GObservation&)"
53 #define G_NROI "GLATResponse::nroi(GModelSky&, GEnergy&, GTime&, "\
55 #define G_EBOUNDS "GLATResponse::ebounds(GEnergy&)"
56 #define G_SAVE "GLATResponse::save(std::string&)"
57 #define G_AEFF "GLATResponse::aeff(int&)"
58 #define G_PSF "GLATResponse::psf(int&)"
59 #define G_EDISP "GLATResponse::edisp(int&)"
60 #define G_IRF_ATOM "GLATResponse::irf(GLATEventAtom&, GModel&, GEnergy&,"\
61 "GTime&, GObservation&)"
62 #define G_IRF_BIN "GLATResponse::irf(GLATEventBin&, GModel&, GEnergy&,"\
63 "GTime&, GObservation&)"
219 std::string cls = std::string(
typeid(&(event.
dir())).name());
220 std::string msg =
"Invalid instrument direction type \""+cls+
221 "\" specified. Please specify a \"GLATInstDir\" "
222 "instance as argument.";
232 for (
int i = 0; i <
m_ptsrc.size(); ++i) {
233 if (
m_ptsrc[i]->dir() == srcDir) {
258 #if defined(G_DUMP_MEAN_PSF)
259 std::cout <<
"Added new mean PSF \""+name+
"\"" << std::endl;
260 std::cout << *psf << std::endl;
266 double offset = dir->
dir().dist_deg(srcDir);
291 rsp =
irf_spatial_atom(static_cast<const GLATEventAtom&>(event), source, obs);
294 rsp =
irf_spatial_bin(static_cast<const GLATEventBin&>(event), source, obs);
373 for (
int i = 0; i < cube->
ndiffrsp(); ++i) {
389 const double* pixels = map->
pixels() +
event.ipix();
395 rsp /= (
event.solidangle() *
event.ontime());
408 for (
int i = 0; i <
m_ptsrc.size(); ++i) {
411 if (
m_ptsrc[i]->dir().dist_deg(ptsrc->
dir()) > 0.01) {
435 #if defined(G_DUMP_MEAN_PSF)
436 std::cout <<
"Added new mean PSF \""+source.
name();
437 std::cout <<
"\"" << std::endl << *psf << std::endl;
459 #if defined(G_DUMP_MEAN_PSF)
460 std::cout <<
"Replaced mean PSF \""+source.
name();
461 std::cout <<
"\"" << std::endl << *psf << std::endl;
468 double offset =
event.dir().dir().
dist_deg(srcDir);
472 #if defined(G_DEBUG_MEAN_PSF)
473 std::cout <<
"Energy=" << srcEng.
MeV();
474 std::cout <<
" MeanPsf=" << mean_psf;
475 std::cout <<
" DiffusePsf=" << rsp;
476 std::cout <<
" ratio(Mean/Diffuse)=" << mean_psf/rsp;
477 if (mean_psf/rsp < 0.99) {
478 std::cout <<
" <<< (1%)";
480 else if (mean_psf/rsp > 1.01) {
481 std::cout <<
" >>> (1%)";
483 std::cout << std::endl;
492 if ((idiff == -1) && ptsrc == NULL) {
493 std::string msg =
"No diffuse source with name \""+source.
name()+
494 "\" found and source is not a point source. So far "
495 "the LAT module can only handle diffuse sources and "
496 "point sources. Please adapt your model accordingly.";
519 const GTime& obsTime,
523 std::string msg =
"Spatial integration of sky model over the data space "
524 "is not implemented.";
547 std::string msg =
"Energy dispersion not implemented.";
578 static const std::string type_names[] = {
"FRONT",
593 GCaldb caldb(
"glast",
"lat");
599 if (array.size() == 1) {
603 else if (array.size() == 3) {
606 if (evtype ==
"front") {
609 else if (evtype ==
"back") {
612 else if (evtype ==
"psf0") {
615 else if (evtype ==
"psf1") {
618 else if (evtype ==
"psf2") {
621 else if (evtype ==
"psf3") {
624 else if (evtype ==
"psf") {
627 else if (evtype ==
"edisp0") {
630 else if (evtype ==
"edisp1") {
633 else if (evtype ==
"edisp2") {
636 else if (evtype ==
"edisp3") {
639 else if (evtype ==
"edisp") {
643 std::string msg =
"Invalid response type \""+array[2]+
"\". "
644 "Expect one of \"FRONT\", \"BACK\", "
645 "\"PSF(0-3)\", or \"EDISP(0-3)\" "
646 "(case insensitive).";
651 std::string msg =
"Invalid response \""+
m_rspname+
"\".";
657 for (
int i = 0; i < 10; ++i) {
660 int bitmask = 1 << i;
663 if ((event_type & bitmask) == 0) {
680 m_psf.push_back(psf);
700 std::string msg =
"Saving of LAT response not implemented.";
716 #if defined(G_RANGE_CHECK)
717 if (index < 0 || index >=
m_aeff.size()) {
736 #if defined(G_RANGE_CHECK)
737 if (index < 0 || index >=
m_psf.size()) {
756 #if defined(G_RANGE_CHECK)
757 if (index < 0 || index >=
m_edisp.size()) {
783 result.append(
"=== GLATResponse ===");
788 for (
int i = 0; i <
size(); ++i) {
789 result.append(
m_aeff[i]->evtype()+
" ");
792 if (chatter >
TERSE) {
793 for (
int i = 0; i <
size(); ++i) {
798 for (
int i = 0; i <
m_ptsrc.size(); ++i) {
847 for (
int i = 0; i < rsp.
m_aeff.size(); ++i) {
853 for (
int i = 0; i < rsp.
m_psf.size(); ++i) {
859 for (
int i = 0; i < rsp.
m_edisp.size(); ++i) {
865 for (
int i = 0; i < rsp.
m_ptsrc.size(); ++i) {
880 for (
int i = 0; i <
m_aeff.size(); ++i) {
887 for (
int i = 0; i <
m_psf.size(); ++i) {
894 for (
int i = 0; i <
m_edisp.size(); ++i) {
901 for (
int i = 0; i <
m_ptsrc.size(); ++i) {
931 irf =
irf_spatial_atom(static_cast<const GLATEventAtom&>(event), source, obs);
934 irf =
irf_spatial_bin(static_cast<const GLATEventBin&>(event), source, obs);
961 irf =
irf_spatial_atom(static_cast<const GLATEventAtom&>(event), source, obs);
964 irf =
irf_spatial_bin(static_cast<const GLATEventBin&>(event), source, obs);
virtual ~GLATResponse(void)
Destructor.
Fermi/LAT observation class.
double dist_deg(const GSkyDir &dir) const
Compute angular distance between sky directions in degrees.
GSkyMap * diffrsp(const int &index) const
Return diffuse response map.
std::string m_rspname
Name of the instrument response.
void dir(const GSkyDir &dir)
Set sky direction.
Fermi/LAT observation class definition.
virtual GEbounds ebounds(const GEnergy &obsEnergy) const
Return true energy boundaries for a specific observed energy.
int size(void) const
Return number of event types.
double dec_deg(void) const
Returns Declination in degrees.
Point source spatial model class interface definition.
const std::string & name(void) const
Return source name for mean PSF.
const GSkyDir & dir(void) const
Return position of point source.
virtual double irf_spatial(const GEvent &event, const GSource &source, const GObservation &obs) const
Return value of model instrument response function.
int ndiffrsp(void) const
Return number of diffuse model components.
Fermi/LAT instrument direction class.
Interface for the Fermi LAT energy dispersion.
Abstract interface for the event classes.
GLATPsf * psf(const int &index) const
Return pointer on point spread function.
GFilename filename(const std::string &detector, const std::string &filter, const std::string &codename, const std::string &date, const std::string &time, const std::string &expr)
Return calibration file name based on selection parameters.
const double & wgt_left(void) const
Returns left node weight.
Fermi/LAT Response class.
void load(const std::string &rspname)
Load Fermi LAT response from calibration database.
std::vector< GLATMeanPsf * > m_ptsrc
Mean PSFs for point sources.
double irf_spatial_bin(const GLATEventBin &event, const GSource &source, const GObservation &obs) const
Return value of model IRF for event bin.
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.
GLATResponse & operator=(const GLATResponse &rsp)
Assignment operator.
double MeV(void) const
Return energy in MeV.
FITS file class interface definition.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
virtual double irf_diffuse(const GEvent &event, const GSource &source, const GObservation &obs) const
Return instrument response to diffuse source.
const std::string & name(void) const
Return model name.
void init_members(void)
Initialise class members.
std::string strip_whitespace(const std::string &arg)
Strip leading and trailing whitespace from string.
bool m_force_mean
Use mean PSF in any case.
void init_members(void)
Initialise class members.
virtual void clear(void)
Clear response.
double log10MeV(void) const
Return log10 of energy in MeV.
GLATEdisp * edisp(const int &index) const
Return pointer on energy dispersion.
Class that handles photons.
Fermi/LAT event bin class.
Calibration database class.
Interface for the Fermi LAT point spread function.
Fermi/LAT event bin class interface definition.
const double & wgt_right(void) const
Returns right node weight.
Energy boundaries container class.
double ra_deg(void) const
Returns Right Ascension in degrees.
virtual double irf_ptsrc(const GEvent &event, const GSource &source, const GObservation &obs) const
Return instrument response to point source.
GLATResponse(void)
Void constructor.
Fermi/LAT event cube class definition.
void save(const std::string &rspname) const
Save Fermi LAT response in calibration database.
Interface for the Fermi/LAT effective area.
virtual double irf(const GEvent &event, const GPhoton &photon, const GObservation &obs) const
Return value of point source IRF.
const int & inx_left(void) const
Returns left node index.
void free_members(void)
Delete class members.
Fermi/LAT event cube class.
const GModelSpatial * model(void) const
Return spatial model component.
Abstract observation base class.
const GEnergy & energy(void) const
Return photon energy.
GLATAeff * aeff(const int &index) const
Return pointer on effective area.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print Fermi-LAT response information.
virtual GLATResponse * clone(void) const
Clone response.
const double & ontime(void) const
Return ontime of event bin.
Calibration database class interface definition.
std::vector< GLATAeff * > m_aeff
Effective areas.
Point source spatial model.
const int & inx_right(void) const
Returns right node index.
Fermi/LAT event atom class definition.
void free_members(void)
Delete class members.
virtual GResponse & operator=(const GResponse &rsp)
Assignment operator.
double irf_spatial_atom(const GLATEventAtom &event, const GSource &source, const GObservation &obs) const
Return value of model IRF for event atom.
virtual double nroi(const GModelSky &model, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return integral of event probability for a given sky model over ROI.
virtual bool is_atom(void) const =0
GChatter reduce(const GChatter &chatter)
Reduce chattiness by one level.
const GEnergy & energy(void) const
Return photon energy.
Fermi/LAT instrument direction class definition.
Exception handler interface definition.
std::string toupper(const std::string &s)
Convert string to upper case.
std::string tolower(const std::string &s)
Convert string to lower case.
Fermi/LAT mean PSF class.
void enodes(const GNodeArray &enodes)
Set event cube energy nodes.
Fermi LAT Response class definition.
virtual const GInstDir & dir(void) const =0
Abstract instrument response base class.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Class that handles gamma-ray sources.
const int & npix(void) const
Returns number of pixels.
std::vector< GLATPsf * > m_psf
Point spread functions.
const GSkyDir & dir(void) const
Return photon sky direction.
const double * pixels(void) const
Returns pointer to pixel data.
Fermi/LAT event atom class.
Class that handles energies in a unit independent way.
std::vector< GLATEdisp * > m_edisp
Energy dispersions.
std::string diffname(const int &index) const
Return name of diffuse model.
void copy_members(const GLATResponse &rsp)
Copy class members.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.