Commit 9d815502ebd2c038308b325b7173003d8bdb541c

Authored by Jürgen Knödlseder
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 441 m_ra = (*this)["ra"].real();
442 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 451 // Optionally read ahead parameters so that they get correctly
452 452 // dumped into the log file
... ... @@ -537,8 +537,8 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename)
537 537 sprintf(cmax, "%.8f", tmax);
538 538 selection = "TIME >= "+std::string(cmin)+" && TIME <= "+std::string(cmax);
539 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 543 if (selection.length() > 0) {
544 544 selection += " && ";
... ... @@ -550,8 +550,8 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename)
550 550 sprintf(cmax, "%.8f", m_emax);
551 551 selection += "ENERGY >= "+std::string(cmin)+" && ENERGY <= "+std::string(cmax);
552 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 556 if (selection.length() > 0) {
557 557 selection += " && ";
... ... @@ -565,12 +565,15 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename)
565 565 std::string(cdec)+",RA,DEC) <= " +
566 566 std::string(crad);
567 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 578 // Add additional expression
576 579 if (strip_whitespace(m_expr).length() > 0) {
... ... @@ -584,8 +587,10 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename)
584 587 std::string expression = filename;
585 588 if (selection.length() > 0)
586 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 595 // Open FITS file
591 596 GFits file(expression);
... ... @@ -635,7 +640,8 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename)
635 640 }
636 641  
637 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 646 // Set ROI
641 647 GCTARoi roi;
... ... @@ -657,6 +663,11 @@ void ctselect::select_events(GCTAObservation* obs, const std::string&amp; filename)
657 663 ebounds.append(emin, emax);
658 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 671 // Return
661 672 return;
662 673 }
... ... @@ -810,8 +821,9 @@ std::string ctselect::check_infile(const std::string&amp; filename) const
810 821 + m_outfile + "\": ";
811 822 for (int i = 0; i < missing.size(); ++i) {
812 823 message += "\"" + missing[i] + "\"";
813   - if (i < missing.size()-1)
  824 + if (i < missing.size()-1) {
814 825 message += ", ";
  826 + }
815 827 }
816 828 }
817 829  
... ...