Commit 22b07d06c3d4a48cd3e2bee373e1db6f5367d1de
1 parent
1a11125e
added phase selection functionality
Showing
3 changed files
with
45 additions
and
0 deletions
src/ctselect/ctselect.cpp
| ... | ... | @@ -484,6 +484,7 @@ void ctselect::init_members(void) |
| 484 | 484 | m_select_energy = true; |
| 485 | 485 | m_select_roi = true; |
| 486 | 486 | m_select_time = true; |
| 487 | + m_select_phase = true; | |
| 487 | 488 | |
| 488 | 489 | // Return |
| 489 | 490 | return; |
| ... | ... | @@ -519,6 +520,7 @@ void ctselect::copy_members(const ctselect& app) |
| 519 | 520 | m_select_energy = app.m_select_energy; |
| 520 | 521 | m_select_roi = app.m_select_roi; |
| 521 | 522 | m_select_time = app.m_select_time; |
| 523 | + m_select_phase = app.m_select_phase; | |
| 522 | 524 | |
| 523 | 525 | // Return |
| 524 | 526 | return; |
| ... | ... | @@ -551,6 +553,7 @@ void ctselect::get_parameters(void) |
| 551 | 553 | m_select_energy = true; |
| 552 | 554 | m_select_roi = true; |
| 553 | 555 | m_select_time = true; |
| 556 | + m_select_phase = true; | |
| 554 | 557 | |
| 555 | 558 | // Setup observations from "inobs" parameter. Do not request response |
| 556 | 559 | // information and do not accept counts cubes. |
| ... | ... | @@ -592,6 +595,16 @@ void ctselect::get_parameters(void) |
| 592 | 595 | m_select_energy = false; |
| 593 | 596 | } |
| 594 | 597 | |
| 598 | + // Check for sanity of phase selection parameters | |
| 599 | + if ((*this)["phasemin"].is_valid() && (*this)["phasemax"].is_valid()) { | |
| 600 | + m_phasemin = (*this)["phasemin"].real(); | |
| 601 | + m_phasemax = (*this)["phasemax"].real(); | |
| 602 | + m_select_phase = true; | |
| 603 | + } | |
| 604 | + else { | |
| 605 | + m_select_phase = false; | |
| 606 | + } | |
| 607 | + | |
| 595 | 608 | // Get other User parameters |
| 596 | 609 | m_expr = (*this)["expr"].string(); |
| 597 | 610 | m_usethres = (*this)["usethres"].string(); |
| ... | ... | @@ -722,6 +735,33 @@ void ctselect::select_events(GCTAObservation* obs, |
| 722 | 735 | |
| 723 | 736 | } // endif: made time selection |
| 724 | 737 | |
| 738 | + // Make phase selection | |
| 739 | + if (m_select_phase) { | |
| 740 | + // Check if event_list has phase (m_has_phase) | |
| 741 | + if (list->has_phase()) { // gammalib version from branch 1982-add-phase-info necessary | |
| 742 | + // Check if phasemax is larger than phasemin | |
| 743 | + if (m_phasemax > m_phasemin) { | |
| 744 | + // Format phase with sufficient accuracy and add to selection string | |
| 745 | + char cmin[80]; | |
| 746 | + char cmax[80]; | |
| 747 | + sprintf(cmin, "%.8f", m_phasemin); | |
| 748 | + sprintf(cmax, "%.8f", m_phasemax); | |
| 749 | + selection += add + "PHASE >= "+std::string(cmin)+" && PHASE <= "+std::string(cmax); | |
| 750 | + add = " && "; | |
| 751 | + log_value(NORMAL, "Phase range", | |
| 752 | + gammalib::str(m_phasemin)+" - "+gammalib::str(m_phasemax)); | |
| 753 | + } | |
| 754 | + else { | |
| 755 | + log << "Invalid values for phasemin and phasemax. "; | |
| 756 | + log << "Phase selection skipped." << std::endl; | |
| 757 | + } | |
| 758 | + } | |
| 759 | + else { | |
| 760 | + log << "Event list has no PHASE column. "; | |
| 761 | + log << "Phase selection skipped." << std::endl; | |
| 762 | + } | |
| 763 | + } // endif: made phase selection | |
| 764 | + | |
| 725 | 765 | // Make energy selection |
| 726 | 766 | if (m_select_energy) { |
| 727 | 767 | ... | ... |
src/ctselect/ctselect.hpp
| ... | ... | @@ -97,6 +97,8 @@ protected: |
| 97 | 97 | double m_tmax; //!< Stop time |
| 98 | 98 | double m_emin; //!< Lower energy |
| 99 | 99 | double m_emax; //!< Upper energy |
| 100 | + double m_phasemin; //!< Lower phase | |
| 101 | + double m_phasemax; //!< Upper phase | |
| 100 | 102 | std::string m_expr; //!< Selection expression |
| 101 | 103 | std::string m_usethres; //!< Energy threshold type |
| 102 | 104 | GChatter m_chatter; //!< Chattiness |
| ... | ... | @@ -110,6 +112,7 @@ protected: |
| 110 | 112 | bool m_select_energy; //!< Perform energy selection |
| 111 | 113 | bool m_select_roi; //!< Perform RoI selection |
| 112 | 114 | bool m_select_time; //!< Perform time selection |
| 115 | + bool m_select_phase; //!< Perform phase selection | |
| 113 | 116 | }; |
| 114 | 117 | |
| 115 | 118 | ... | ... |
src/ctselect/ctselect.par
| ... | ... | @@ -32,6 +32,8 @@ tmin, r, a, 0.0,,, "Start time (CTA MET in seconds)" |
| 32 | 32 | tmax, r, a, 0.0,,, "End time (CTA MET in seconds)" |
| 33 | 33 | emin, r, a, 0.1,,, "Lower energy limit (TeV)" |
| 34 | 34 | emax, r, a, 100.0,,, "Upper energy limit (TeV)" |
| 35 | +phasemin,r, h, 0.0,,, "Lower phase limit" | |
| 36 | +phasemax,r, h, 1.0,,, "Upper phase limit" | |
| 35 | 37 | expr, s, h, "",,, "Additional selection expression" |
| 36 | 38 | usethres,s, h, "NONE",NONE|DEFAULT|USER,, "Energy threshold type" |
| 37 | 39 | ... | ... |