From 056df92382d28a96e45df588cb02227b50e5c911 Mon Sep 17 00:00:00 2001 From: Josh Cardenzana Date: Fri, 16 Nov 2018 13:55:48 +0100 Subject: [PATCH] Apply style formatting according to ctools standard (#2713) --- src/ctfindvar/ctfindvar.cpp | 98 +++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------- src/ctfindvar/ctfindvar.hpp | 29 ++++++++++++++++------------- 2 files changed, 61 insertions(+), 66 deletions(-) diff --git a/src/ctfindvar/ctfindvar.cpp b/src/ctfindvar/ctfindvar.cpp index c6ac648..5c29921 100644 --- a/src/ctfindvar/ctfindvar.cpp +++ b/src/ctfindvar/ctfindvar.cpp @@ -32,7 +32,6 @@ #include "GammaLib.hpp" #include "GCTALib.hpp" #include -#include /* __ OpenMP section _____________________________________________________ */ #ifdef _OPENMP @@ -288,12 +287,9 @@ void ctfindvar::run(void) // ... otherwise only one source position is queried else { GSkyDir srcSkyDir; - if ((*this)["coordsys"].string()=="CEL") - { + if ((*this)["coordsys"].string() == "CEL") { srcSkyDir.radec_deg((*this)["xsrc"].real(),(*this)["ysrc"].real()); - } - else - { + } else { srcSkyDir.lb_deg((*this)["xsrc"].real(),(*this)["ysrc"].real()); } @@ -308,13 +304,13 @@ void ctfindvar::run(void) m_pixsigmax = GNdarray(nbins); //Prepare the final skymap with the max significance of each pixel - double max_sig=0; + double max_sig = 0; log_header1(NORMAL, "Looping Over Pixels"); //looping over all the pixels in the cube #pragma omp parallel for - for (int pix_number=0; pix_number max_sig) - { + if (max(pixSig) > max_sig) { // Update the pixel position with the maximum sigma max_sig = max(pixSig); m_max_sig_dir = m_counts.inx2dir(pix_number); @@ -384,7 +379,7 @@ void ctfindvar::run(void) //If the significance is greater than sig threshold, the position //is stored in a model - if (max(pixSig)> m_sig_threshold) { + if (max(pixSig) > m_sig_threshold) { GSkyDir dir_pix = m_counts.inx2dir(pix_number); fill_model_sig_pos(dir_pix); } @@ -411,9 +406,8 @@ void ctfindvar::get_variability_sig(const int& pix_number, const int& nbins, GNdarray& sig_histogram) { - std::vector accepted_bin_bckg_vector(nbins, true); - std::vector excess_bin_vector(nbins, 0.0); - bool background_validated=false; + std::vector accepted_bin_bckg_vector(nbins, true); + bool background_validated = false; double non, noff; double alpha, sig; @@ -421,39 +415,38 @@ void ctfindvar::get_variability_sig(const int& pix_number, std::vector alpha_vector(nbins, 0.0); fill_alpha_vector(pix_number, alpha_vector); - while (background_validated==false) - { - background_validated=true; + // Loop over pixels until all background pixls are removed + while (background_validated == false) { + background_validated = true; + + // Loop over all the GTIs of the pixel + for (int i = 0; i < nbins; i++) { - for (int i=0; i< nbins; i++) //looping over all the GTIs of the pixel - { - //the GTI is discared from bckg calculation and not checked again. - if (accepted_bin_bckg_vector[i]==0) { + // The GTI is discared from bckg calculation and not checked again. + if (!accepted_bin_bckg_vector[i]) { continue; } // Check if bin fails minoff check or no observations overlap it - else if (m_counts(pix_number, i) < m_minoff || alpha_vector[i]==0) { - accepted_bin_bckg_vector[i]=0; + else if (m_counts(pix_number, i) < m_minoff || alpha_vector[i] == 0) { + accepted_bin_bckg_vector[i] = false; continue; } noff = 0.0; - alpha = 0; - for (int j=0;jm_sig_threshold ) // if the bin is significant, it is removed from the bckg and we loop again. - { - accepted_bin_bckg_vector[i]=0; - background_validated=false; + // If the bin is significant, it is removed from the bckg and we loop again. + if (sig > m_sig_threshold) { + accepted_bin_bckg_vector[i] = false; + background_validated = false; } } @@ -511,9 +503,9 @@ void ctfindvar::fill_model_sig_pos(const GSkyDir& dir_pix) //Extracting the coordinate to name the model double ra = dir_pix.ra_deg(); double dec = dir_pix.dec_deg(); - std::stringstream name; - name << "Sky_direction_"<< ra << "_" << dec ; - model.name(name.str()); + std::string name = "Sky_direction_" + gammalib::str(ra, 4) + + "_" + gammalib::str(dec, 4); + model.name(name); //Add the model for this pixel to the output mode m_model_above_thr.append(model); @@ -532,7 +524,7 @@ void ctfindvar::fill_alpha_vector(const int& pix_number, GSkyDir pix_dir = m_counts.inx2dir(pix_number); // Loop over all observations - for (int i=0; i(m_obs[i]); GCTARoi roi = obs->roi(); @@ -549,7 +541,7 @@ void ctfindvar::fill_alpha_vector(const int& pix_number, const GGti& obs_gti(obs->gti()); // Loop over all time bins - for (int j=0; j 2){ + if (m_model_above_thr.size() > 2) { GFilename model_filename = prefix + "model_significant_directions.xml"; m_model_above_thr.save(model_filename); } @@ -987,10 +980,9 @@ void ctfindvar::init_gtis(void) throw GException::invalid_value(G_INIT_GTIS, "Start time is equal to stop time"); } else if (bins < 2) { - std::stringstream msg; - msg << "Method requires at least two time bins (" - << bins << " bins found)."; - throw GException::invalid_value(G_INIT_GTIS, msg.str()); + std::string msg = "Method requires at least two time bins (" + + gammalib::str(bins) + " bins found)."; + throw GException::invalid_value(G_INIT_GTIS, msg); } for (int i=0; i& alpha_vector); - void get_parameters(void); - void get_variability_sig(const int& pix_number, const int& nbins, GNdarray& sig_histogram); - double gti_overlap(const GGti& gti1, const GGti& gti2); + void init_cube(void); + void fill_model_sig_pos(const GSkyDir& dir_pix); + void init_gtis(void); + void init_members(void); + void copy_members(const ctfindvar& app); + void free_members(void); + void fill_cube(GCTAObservation* obs); + void fill_alpha_vector(const int& pix_number, + std::vector& alpha_vector); + void get_parameters(void); + void get_variability_sig(const int& pix_number, + const int& nbins, + GNdarray& sig_histogram); + double gti_overlap(const GGti& gti1, + const GGti& gti2); // Writing methods for individual source histograms void write_srchist(void); @@ -97,7 +100,7 @@ protected: GSkyDir m_max_sig_dir; //!< Sky direction associated with maximum significance double m_minoff; //!< Minimum counts for use in significance calculation double m_sig_threshold; //!< Minimum significance required to set source as variable - GFits m_outfile; //!< FITS object to store output + GFits m_outfile; //!< FITS object to store output GSkyMap m_peaksigmap; //!< Skymap holding the maximum significance GNdarray m_pixsigsrc; //!< Store distributions of the source significances GNdarray m_pixsigmax; //!< Store distribution for pixel with max significance -- libgit2 0.21.4