43 const GModelRegistry g_com_drb_fitting_registry(&g_com_drb_fitting_seed);
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())
329 scale =
m_values[inx_left].value() * wgt_left +
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) {
void phibar(const double &phibar)
Set event Compton scatter angle.
void free_members(void)
Delete class members.
const int & index(void) const
Return bin index.
bool m_scale
Model is a scale factor.
const std::string & name(void) const
Return parameter name.
std::string print_attributes(void) const
Print model attributes.
virtual void write(GXmlElement &xml) const
Write model into XML element.
Interface definition for the model registry class.
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.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
COMPTEL DRB Phibar nodes model fitting class interface definition.
std::vector< double > m_old_phibars
Old Phibar values.
void init_members(void)
Initialise class members.
COMPTEL observation class interface definition.
Abstract interface for the event classes.
void set_cache(void) const
Set evaluation cache.
const double & wgt_left(void) const
Returns left node weight.
void free_members(void)
Delete class members.
void clear(void)
Clear node array.
const GCOMDri & drb(void) const
Return background model.
virtual GCOMModelDRBPhibarNodes * clone(void) const
Clone instance.
Random number generator class.
virtual int elements(void) const
Return number of GXMLElement children of node.
const GCOMModelDRBPhibarNodes g_com_drb_fitting_seed
std::vector< GModelPar > m_phibars
Node Phibar values.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Evaluate function.
virtual std::string type(void) const
Return model type.
COMPTEL event bin class interface definition.
bool is_notanumber(const double &x)
Signal if argument is not a number.
std::vector< GModelPar * > m_pars
Pointers to all model parameters.
int size(void) const
Return number of parameters in model.
bool is_infinite(const double &x)
Signal if argument is infinite.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
virtual GCOMModelDRBPhibarNodes & operator=(const GCOMModelDRBPhibarNodes &model)
Assignment operator.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
const double & wgt_right(void) const
Returns right node weight.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
COMPTEL DRB Phibar nodes model fitting class.
const std::string & name(void) const
Return parameter name.
const GSkyMap & map(void) const
Return DRI sky map.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
Abstract data model class.
virtual GCOMEventCube * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
virtual GModelData & operator=(const GModelData &model)
Assignment operator.
std::string instruments(void) const
Returns instruments to which model applies.
const int & inx_left(void) const
Returns left node index.
virtual ~GCOMModelDRBPhibarNodes(void)
Destructor.
GNodeArray m_nodes
Phibar node values.
Abstract observation base class.
COMPTEL event bin container class.
GModelPar & scale(const int &index)
Returns reference to scale parameter by index.
const int & inx_right(void) const
Returns right node index.
void write_attributes(GXmlElement &xml) const
Write model attributes.
void update_cache(void) const
Update evaluation cache.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
std::vector< GModelPar > m_values
Node values.
void set_pointers(void)
Set pointers.
virtual const GCOMInstDir & dir(void) const
Return instrument direction of event bin.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
Interface class for COMPTEL observations.
const std::string & unit(void) const
Return parameter unit.
Exception handler interface definition.
void read_attributes(const GXmlElement &xml)
Read model attributes.
Model registry class definition.
void copy_members(const GCOMModelDRBPhibarNodes &model)
Copy class members.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
virtual double size(void) const
Return size of event bin.
void append(const double &node)
Append one node to array.
bool m_fixed
All Phibar values are fixed.
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.
const double * pixels(void) const
Returns pointer to pixel data.
GCOMModelDRBPhibarNodes(void)
Void constructor.
void init_members(void)
Initialise class members.
Class that handles energies in a unit independent way.
virtual void clear(void)
Clear instance.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.