Commit 9d815502ebd2c038308b325b7173003d8bdb541c
1 parent
debcf44a
Correctly recompute ontime and livetime.
Showing
1 changed file
with
31 additions
and
19 deletions
src/ctselect/ctselect.cpp
| @@ -441,12 +441,12 @@ void ctselect::get_parameters(void) | @@ -441,12 +441,12 @@ void ctselect::get_parameters(void) | ||
| 441 | m_ra = (*this)["ra"].real(); | 441 | m_ra = (*this)["ra"].real(); |
| 442 | m_dec = (*this)["dec"].real(); | 442 | m_dec = (*this)["dec"].real(); |
| 443 | } | 443 | } |
| 444 | - m_rad = (*this)["rad"].real(); | ||
| 445 | - m_tmin = (*this)["tmin"].real(); | ||
| 446 | - m_tmax = (*this)["tmax"].real(); | ||
| 447 | - m_emin = (*this)["emin"].real(); | ||
| 448 | - m_emax = (*this)["emax"].real(); | ||
| 449 | - m_expr = (*this)["expr"].string(); | 444 | + m_rad = (*this)["rad"].real(); |
| 445 | + m_tmin = (*this)["tmin"].real(); | ||
| 446 | + m_tmax = (*this)["tmax"].real(); | ||
| 447 | + m_emin = (*this)["emin"].real(); | ||
| 448 | + m_emax = (*this)["emax"].real(); | ||
| 449 | + m_expr = (*this)["expr"].string(); | ||
| 450 | 450 | ||
| 451 | // Optionally read ahead parameters so that they get correctly | 451 | // Optionally read ahead parameters so that they get correctly |
| 452 | // dumped into the log file | 452 | // dumped into the log file |
| @@ -537,8 +537,8 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | @@ -537,8 +537,8 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | ||
| 537 | sprintf(cmax, "%.8f", tmax); | 537 | sprintf(cmax, "%.8f", tmax); |
| 538 | selection = "TIME >= "+std::string(cmin)+" && TIME <= "+std::string(cmax); | 538 | selection = "TIME >= "+std::string(cmin)+" && TIME <= "+std::string(cmax); |
| 539 | if (logTerse()) { | 539 | if (logTerse()) { |
| 540 | - log << " Time range ................: " << tmin << "-" << tmax | ||
| 541 | - << std::endl; | 540 | + log << parformat("Time range"); |
| 541 | + log << tmin << " - " << tmax << " s" << std::endl; | ||
| 542 | } | 542 | } |
| 543 | if (selection.length() > 0) { | 543 | if (selection.length() > 0) { |
| 544 | selection += " && "; | 544 | selection += " && "; |
| @@ -550,8 +550,8 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | @@ -550,8 +550,8 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | ||
| 550 | sprintf(cmax, "%.8f", m_emax); | 550 | sprintf(cmax, "%.8f", m_emax); |
| 551 | selection += "ENERGY >= "+std::string(cmin)+" && ENERGY <= "+std::string(cmax); | 551 | selection += "ENERGY >= "+std::string(cmin)+" && ENERGY <= "+std::string(cmax); |
| 552 | if (logTerse()) { | 552 | if (logTerse()) { |
| 553 | - log << " Energy range ..............: " << m_emin << "-" << m_emax | ||
| 554 | - << " TeV" << std::endl; | 553 | + log << parformat("Energy range"); |
| 554 | + log << m_emin << " - " << m_emax << " TeV" << std::endl; | ||
| 555 | } | 555 | } |
| 556 | if (selection.length() > 0) { | 556 | if (selection.length() > 0) { |
| 557 | selection += " && "; | 557 | selection += " && "; |
| @@ -565,12 +565,15 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | @@ -565,12 +565,15 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | ||
| 565 | std::string(cdec)+",RA,DEC) <= " + | 565 | std::string(cdec)+",RA,DEC) <= " + |
| 566 | std::string(crad); | 566 | std::string(crad); |
| 567 | if (logTerse()) { | 567 | if (logTerse()) { |
| 568 | - log << " Acceptance cone centre ....: RA=" << ra << ", DEC=" << dec | ||
| 569 | - << " deg" << std::endl; | ||
| 570 | - log << " Acceptance cone radius ....: " << m_rad << " deg" << std::endl; | 568 | + log << parformat("Acceptance cone centre"); |
| 569 | + log << "RA=" << ra << ", DEC=" << dec << " deg" << std::endl; | ||
| 570 | + log << parformat("Acceptance cone radius"); | ||
| 571 | + log << m_rad << " deg" << std::endl; | ||
| 572 | + } | ||
| 573 | + if (logTerse()) { | ||
| 574 | + log << parformat("cfitsio selection"); | ||
| 575 | + log << selection << std::endl; | ||
| 571 | } | 576 | } |
| 572 | - if (logTerse()) | ||
| 573 | - log << " cfitsio selection .........: " << selection << std::endl; | ||
| 574 | 577 | ||
| 575 | // Add additional expression | 578 | // Add additional expression |
| 576 | if (strip_whitespace(m_expr).length() > 0) { | 579 | if (strip_whitespace(m_expr).length() > 0) { |
| @@ -584,8 +587,10 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | @@ -584,8 +587,10 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | ||
| 584 | std::string expression = filename; | 587 | std::string expression = filename; |
| 585 | if (selection.length() > 0) | 588 | if (selection.length() > 0) |
| 586 | expression += "[EVENTS]["+selection+"]"; | 589 | expression += "[EVENTS]["+selection+"]"; |
| 587 | - if (logTerse()) | ||
| 588 | - log << " FITS filename .............: " << expression << std::endl; | 590 | + if (logTerse()) { |
| 591 | + log << parformat("FITS filename"); | ||
| 592 | + log << expression << std::endl; | ||
| 593 | + } | ||
| 589 | 594 | ||
| 590 | // Open FITS file | 595 | // Open FITS file |
| 591 | GFits file(expression); | 596 | GFits file(expression); |
| @@ -635,7 +640,8 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | @@ -635,7 +640,8 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | ||
| 635 | } | 640 | } |
| 636 | 641 | ||
| 637 | // Get CTA event list pointer | 642 | // Get CTA event list pointer |
| 638 | - GCTAEventList* list = static_cast<GCTAEventList*>(const_cast<GEvents*>(obs->events())); | 643 | + GCTAEventList* list = |
| 644 | + static_cast<GCTAEventList*>(const_cast<GEvents*>(obs->events())); | ||
| 639 | 645 | ||
| 640 | // Set ROI | 646 | // Set ROI |
| 641 | GCTARoi roi; | 647 | GCTARoi roi; |
| @@ -657,6 +663,11 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | @@ -657,6 +663,11 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | ||
| 657 | ebounds.append(emin, emax); | 663 | ebounds.append(emin, emax); |
| 658 | list->ebounds(ebounds); | 664 | list->ebounds(ebounds); |
| 659 | 665 | ||
| 666 | + // Recompute ontime and livetime. | ||
| 667 | + GTime meantime = 0.5 * (gti.tstart() + gti.tstop()); | ||
| 668 | + obs->ontime(gti.ontime()); | ||
| 669 | + obs->livetime(gti.ontime() * obs->deadc(meantime)); | ||
| 670 | + | ||
| 660 | // Return | 671 | // Return |
| 661 | return; | 672 | return; |
| 662 | } | 673 | } |
| @@ -810,8 +821,9 @@ std::string ctselect::check_infile(const std::string& filename) const | @@ -810,8 +821,9 @@ std::string ctselect::check_infile(const std::string& filename) const | ||
| 810 | + m_outfile + "\": "; | 821 | + m_outfile + "\": "; |
| 811 | for (int i = 0; i < missing.size(); ++i) { | 822 | for (int i = 0; i < missing.size(); ++i) { |
| 812 | message += "\"" + missing[i] + "\""; | 823 | message += "\"" + missing[i] + "\""; |
| 813 | - if (i < missing.size()-1) | 824 | + if (i < missing.size()-1) { |
| 814 | message += ", "; | 825 | message += ", "; |
| 826 | + } | ||
| 815 | } | 827 | } |
| 816 | } | 828 | } |
| 817 | 829 |