36 #define G_EVALUATE_PROB "ctprob::evaluate_probability(GCTAObservation*)"
186 this->GApplication::clear();
221 log_header1(TERSE,
"Compute event probabilities");
224 int n_observations = 0;
240 if (n_observations > 1) {
251 if ((*
this)[
"publish"].
boolean()) {
282 log_header1(TERSE, gammalib::number(
"Save event list",
m_obs.size()));
307 log_header1(TERSE, gammalib::number(
"Publish event list",
m_obs.size()));
310 for (
int i = 0; i <
m_obs.size(); ++i) {
313 GCTAObservation*
obs =
dynamic_cast<GCTAObservation*
>(
m_obs[i]);
319 if (obs->events()->size() != 0) {
322 std::string user_name(name);
323 if (user_name.empty()) {
329 user_name += gammalib::str(i);
333 log_value(NORMAL,
"Event list name", user_name);
340 fits.publish(gammalib::extname_cta_events, user_name);
414 if (
m_obs.models().size() == 0) {
417 std::string inmodel = (*this)[
"inmodel"].filename();
420 m_obs.models(inmodel);
428 m_publish = (*this)[
"publish"].boolean();
429 m_chatter =
static_cast<GChatter
>((*this)[
"chatter"].integer());
433 (*this)[
"outobs"].query();
434 (*this)[
"prefix"].query();
466 log_header3(NORMAL,
"Evaluate events probabilities");
470 GCTAEventList* events =
dynamic_cast<GCTAEventList*
>(
const_cast<GEvents*
>
472 if (events == NULL) {
473 std::string msg =
"CTA Observation does not contain an event list. An "
474 "event list is needed to compute the event "
480 int nmodels =
m_obs.models().size();
484 std::vector<GFitsTableFloatCol*> columns;
485 for (
int k = 0; k < nmodels; ++k) {
486 const std::string colname =
"PROB_" +
m_obs.models()[k] ->name();
487 GFitsTableFloatCol* col =
488 new GFitsTableFloatCol(colname, events->size());
489 columns.push_back(col);
493 for (
int i = 0; i < events->size(); ++i) {
499 const GEvent*
event = (*events)[i];
502 std::vector<double> probabilities(nmodels, 0.0);
505 for (
int k = 0; k < nmodels; ++k) {
506 double value =
m_obs.models()[k]->eval(*event, *obs);
507 probabilities[k] = value;
513 for (
int k = 0; k < nmodels; ++k) {
514 probabilities[k] /= total;
519 for (
int k = 0; k < nmodels; ++k) {
520 (*(columns[k]))(i) = probabilities[k];
526 for (
int k = 0; k < nmodels; ++k) {
527 events->append_column(*columns[k]);
void copy_members(const ctprob &app)
Copy class members.
void clear(void)
Clear ctprob tool.
Event probability computation tool.
bool m_publish
Publish event list?
void init_members(void)
Initialise class members.
const GObservations & obs(void) const
Return observation container.
GCTAObservation * next_unbinned_observation(void)
Return next unbinned CTA observation.
ctprob(void)
Void constructor.
void free_members(void)
Delete class members.
bool m_apply_edisp
Apply energy dispersion?
void get_parameters(void)
Get application parameters.
Base class for observation tools.
void save_events_fits(void)
Save event list in FITS format.
void evaluate_probability(GCTAObservation *obs)
Evaluate probability for events.
void free_members(void)
Delete class members.
Event probability computation tool interface definition.
void save(void)
Save the selected event list(s)
void init_members(void)
Initialise class members.
virtual ~ctprob(void)
Destructor.
GCTAObservation * first_unbinned_observation(void)
Return first unbinned CTA observation.
ctprob & operator=(const ctprob &app)
Assignment operator.
GChatter m_chatter
Chattiness.
ctobservation & operator=(const ctobservation &app)
Assignment operator.
void process(void)
Process the ctprob tool.
void publish(const std::string &name="")
Publish event lists.
GObservations m_obs
Observation container.
void save_events_xml(void)
Save event list(s) in XML format.