46#define G_EVAL "GCOMModelDRBPhibarNodes::eval(GEvent&, GObservation&, bool&)"
47#define G_NRED "GCOMModelDRBPhibarNodes::npred(GEnergy&, GTime&, "\
49#define G_MC "GCOMModelDRBPhibarNodes::mc(GObservation&, GRan&)"
50#define G_READ "GCOMModelDRBPhibarNodes::read(GXmlElement&)"
51#define G_WRITE "GCOMModelDRBPhibarNodes::write(GXmlElement&)"
162 if (
this != &model) {
243 const bool& gradients)
const
247 if (observation == NULL) {
248 std::string cls = std::string(
typeid(&obs).
name());
249 std::string msg =
"Observation of type \""+cls+
"\" is not a COMPTEL "
250 "observations. Please specify a COMPTEL observation "
258 std::string cls = std::string(
typeid(&event).
name());
259 std::string msg =
"Event of type \""+cls+
"\" is not a COMPTEL event. "
260 "Please specify a COMPTEL event as argument.";
269 for (
int i = 0; i <
m_values.size(); ++i) {
275 int index = bin->
index();
300 double grad = (
m_values[0].is_free())
330 m_values[inx_right].value() * wgt_right;
336 double g_left = (
m_values[inx_left].is_free())
339 double g_right = (
m_values[inx_right].is_free())
344 m_values[inx_left].factor_gradient(g_left);
345 m_values[inx_right].factor_gradient(g_right);
355 #if defined(G_NAN_CHECK)
357 std::cout <<
"*** ERROR: GCOMModelDRBPhibarNodes::eval";
358 std::cout <<
"(index=" << index <<
"):";
359 std::cout <<
" NaN/Inf encountered";
360 std::cout <<
" (value=" << value;
361 std::cout <<
", scale=" <<
scale;
362 std::cout <<
")" << std::endl;
390 const GTime& obsTime,
397 std::string msg =
"Spatial integration of data model is not implemented.";
427 std::string msg =
"Monte Carlo simulation of data model is not implemented.";
471 std::string msg =
"DRB fitting model requires at least one Phibar "
472 "node. Please correct XML format.";
477 for (
int i = 0; i < nodes; ++i) {
492 normalization.
read(*par);
496 std::string normalization_name =
"Scale factor "+
gammalib::str(i);
499 phibar.
name(phibar_name);
504 normalization.
name(normalization_name);
505 normalization.
unit(
"");
564 for (
int k = 0; k < n; ++k) {
575 src = xml.
append(
"source");
585 std::string msg =
"Invalid model type \""+src->
attribute(
"type")+
"\" "
586 "found in XML file. Model type \""+
type()+
"\" "
596 for (
int i = 0; i < nodes; ++i) {
603 std::string msg =
"Invalid number of nodes "+
605 " found in XML file, but model requires exactly "+
611 for (
int i = 0; i < nodes; ++i) {
625 mpar.
name(
"Normalization");
653 result.append(
"=== GCOMModelDRBPhibarNodes ===");
663 for (
int i = 0; i <
size(); ++i) {
750 for (
int i = 0; i < nodes; ++i) {
795 for (
int i = 0; i < num; ++i) {
826 for (
int i = 0; i < num; ++i) {
COMPTEL event bin class interface definition.
const GCOMModelDRBPhibarNodes g_com_drb_fitting_seed
COMPTEL DRB Phibar nodes model fitting class interface definition.
COMPTEL observation class interface definition.
Exception handler interface definition.
Model registry class definition.
const GSkyMap & map(void) const
Return DRI sky map.
virtual const GCOMInstDir & dir(void) const
Return instrument direction of event bin.
const int & index(void) const
Return bin index.
virtual double size(void) const
Return size of event bin.
COMPTEL event bin container class.
void phibar(const double &phibar)
Set event Compton scatter angle.
COMPTEL DRB Phibar nodes model fitting class.
void free_members(void)
Delete class members.
GNodeArray m_nodes
Phibar node values.
std::vector< GModelPar > m_values
Node values.
void set_cache(void) const
Set evaluation cache.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated data model.
virtual GCOMEventCube * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
virtual GCOMModelDRBPhibarNodes & operator=(const GCOMModelDRBPhibarNodes &model)
Assignment operator.
std::vector< double > m_old_phibars
Old Phibar values.
bool m_scale
Model is a scale factor.
GCOMModelDRBPhibarNodes(void)
Void constructor.
void init_members(void)
Initialise class members.
virtual GCOMModelDRBPhibarNodes * clone(void) const
Clone instance.
virtual ~GCOMModelDRBPhibarNodes(void)
Destructor.
virtual void clear(void)
Clear instance.
void set_pointers(void)
Set pointers.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Evaluate function.
void update_cache(void) const
Update evaluation cache.
bool m_fixed
All Phibar values are fixed.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
virtual void write(GXmlElement &xml) const
Write model into XML element.
std::vector< GModelPar > m_phibars
Node Phibar values.
virtual std::string type(void) const
Return model type.
void copy_members(const GCOMModelDRBPhibarNodes &model)
Copy class members.
Interface class for COMPTEL observations.
const GCOMDri & drb(void) const
Return background model.
Class that handles energies in a unit independent way.
Abstract interface for the event classes.
Abstract data model class.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
virtual GModelData & operator=(const GModelData &model)
Assignment operator.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
Interface definition for the model registry class.
GModelPar & scale(const int &index)
Returns reference to scale parameter by index.
std::vector< GModelPar * > m_pars
Pointers to all model parameters.
void write_attributes(GXmlElement &xml) const
Write model attributes.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
std::string print_attributes(void) const
Print model attributes.
int size(void) const
Return number of parameters in model.
std::string instruments(void) const
Returns instruments to which model applies.
void read_attributes(const GXmlElement &xml)
Read model attributes.
const std::string & name(void) const
Return parameter name.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
const int & inx_right(void) const
Returns right node index.
const int & inx_left(void) const
Returns left node index.
const double & wgt_right(void) const
Returns right node weight.
const double & wgt_left(void) const
Returns left node weight.
void clear(void)
Clear node array.
void append(const double &node)
Append one node to array.
Abstract observation base class.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
const std::string & unit(void) const
Return parameter unit.
const std::string & name(void) const
Return parameter name.
Random number generator class.
const double * pixels(void) const
Returns pointer to pixel data.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
virtual int elements(void) const
Return number of GXMLElement children of node.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
bool is_infinite(const double &x)
Signal if argument is infinite.
bool is_notanumber(const double &x)
Signal if argument is not a number.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.