Commit 9ad00911a841a23410bdae0ba6dc3f33bf783d65

Authored by Jürgen Knödlseder
2 parents 92d0c21e d687c011

Dump number of events before and after filtering into log file in ctcubemask.

src/ctcubemask/ctcubemask.cpp
@@ -221,7 +221,7 @@ void ctcubemask::run(void) @@ -221,7 +221,7 @@ void ctcubemask::run(void)
221 // Write observation(s) into logger 221 // Write observation(s) into logger
222 if (logTerse()) { 222 if (logTerse()) {
223 log << std::endl; 223 log << std::endl;
224 - log.header1("Observations for applying mask"); 224 + log.header1("Observations");
225 log << m_obs << std::endl; 225 log << m_obs << std::endl;
226 } 226 }
227 227
@@ -363,7 +363,7 @@ void ctcubemask::get_parameters(void) @@ -363,7 +363,7 @@ void ctcubemask::get_parameters(void)
363 std::string msg = "A valid file needs to be specified for the " 363 std::string msg = "A valid file needs to be specified for the "
364 "\"inobs\" parameter, yet \""+ 364 "\"inobs\" parameter, yet \""+
365 (*this)["inobs"].filename()+"\" was given." 365 (*this)["inobs"].filename()+"\" was given."
366 - " Specify a vaild observation definition or " 366 + " Specify a valid observation definition or "
367 "event list FITS file to proceed."; 367 "event list FITS file to proceed.";
368 throw GException::invalid_value(G_GET_PARAMETERS, msg); 368 throw GException::invalid_value(G_GET_PARAMETERS, msg);
369 } 369 }
@@ -444,10 +444,21 @@ void ctcubemask::apply_mask(GCTAObservation* obs) @@ -444,10 +444,21 @@ void ctcubemask::apply_mask(GCTAObservation* obs)
444 } 444 }
445 445
446 // Initialise energy selection 446 // Initialise energy selection
  447 + int npix = map.npix();
447 int n_ebin = ebounds.size(); 448 int n_ebin = ebounds.size();
448 int e_idx1 = 0; 449 int e_idx1 = 0;
449 int e_idx2 = n_ebin; 450 int e_idx2 = n_ebin;
450 451
  452 + // Determine number of events before masking
  453 + double sum_before = 0.0;
  454 + for (int i = 0; i < n_ebin; ++i) {
  455 + for (int pixel = 0; pixel < npix; ++pixel) {
  456 + if (map(pixel, i) >= 0.0) {
  457 + sum_before += map(pixel, i);
  458 + }
  459 + }
  460 + }
  461 +
451 // Loop over ebounds to find the first valid energy band 462 // Loop over ebounds to find the first valid energy band
452 for (int i = 0; i < n_ebin; ++i) { 463 for (int i = 0; i < n_ebin; ++i) {
453 double emin = ebounds.emin(i).TeV() + 1.0e-6; // Rounding tolerance 464 double emin = ebounds.emin(i).TeV() + 1.0e-6; // Rounding tolerance
@@ -467,7 +478,6 @@ void ctcubemask::apply_mask(GCTAObservation* obs) @@ -467,7 +478,6 @@ void ctcubemask::apply_mask(GCTAObservation* obs)
467 } 478 }
468 479
469 // Set all pixels outside the desired energy bands to -1.0 480 // Set all pixels outside the desired energy bands to -1.0
470 - int npix = map.npix();  
471 for (int i = 0; i < e_idx1; ++i) { 481 for (int i = 0; i < e_idx1; ++i) {
472 for (int pixel = 0; pixel < npix; ++pixel) { 482 for (int pixel = 0; pixel < npix; ++pixel) {
473 map(pixel,i) = -1.0; 483 map(pixel,i) = -1.0;
@@ -538,6 +548,24 @@ void ctcubemask::apply_mask(GCTAObservation* obs) @@ -538,6 +548,24 @@ void ctcubemask::apply_mask(GCTAObservation* obs)
538 } 548 }
539 } 549 }
540 550
  551 + // Determine number of events after masking
  552 + double sum_after = 0.0;
  553 + for (int i = 0; i < n_ebin; ++i) {
  554 + for (int pixel = 0; pixel < npix; ++pixel) {
  555 + if (map(pixel, i) >= 0.0) {
  556 + sum_after += map(pixel, i);
  557 + }
  558 + }
  559 + }
  560 +
  561 + // Dump number of events before and after masking
  562 + if (logTerse()) {
  563 + log << gammalib::parformat("Events before masking");
  564 + log << sum_before << std::endl;
  565 + log << gammalib::parformat("Events after masking");
  566 + log << sum_after << std::endl;
  567 + }
  568 +
541 // Put back map into the event cube 569 // Put back map into the event cube
542 cube->map(map); 570 cube->map(map);
543 571
@@ -600,8 +628,8 @@ void ctcubemask::copy_members(const ctcubemask&amp; app) @@ -600,8 +628,8 @@ void ctcubemask::copy_members(const ctcubemask&amp; app)
600 m_emax = app.m_emax; 628 m_emax = app.m_emax;
601 629
602 // Copy protected members 630 // Copy protected members
603 - m_obs = app.m_obs;  
604 - m_infiles = app.m_infiles; 631 + m_obs = app.m_obs;
  632 + m_infiles = app.m_infiles;
605 m_select_energy = app.m_select_energy; 633 m_select_energy = app.m_select_energy;
606 m_select_roi = app.m_select_roi; 634 m_select_roi = app.m_select_roi;
607 635
src/ctcubemask/ctcubemask.hpp
@@ -90,8 +90,8 @@ protected: @@ -90,8 +90,8 @@ protected:
90 double m_emax; //!< Upper energy 90 double m_emax; //!< Upper energy
91 91
92 // Protected members 92 // Protected members
93 - GObservations m_obs; //!< Observations container  
94 - std::vector<std::string> m_infiles; //!< Input event filenames 93 + GObservations m_obs; //!< Observations container
  94 + std::vector<std::string> m_infiles; //!< Input event filenames
95 bool m_select_energy; //!< Perform energy selection 95 bool m_select_energy; //!< Perform energy selection
96 bool m_select_roi; //!< Perform ROI selection 96 bool m_select_roi; //!< Perform ROI selection
97 }; 97 };