CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
StackedDensityProfile.h
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2020 by Giorgio Lesci and Federico Marulli *
3  * federico.marulli3@unibo.it *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public *
16  * License along with this program; if not, write to the Free *
17  * Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ********************************************************************/
20 
35 #ifndef __STACKPROFILE__
36 #define __STACKPROFILE__
37 
38 #include "Catalogue.h"
39 #include "Cosmology.h"
40 #include "Measure.h"
41 
42 
43 // ===================================================================================================
44 
45 
46 namespace cbl {
47 
48  namespace measure {
49 
57  namespace stackprofile {
58 
70  class StackedDensityProfile : public Measure {
71 
72  protected :
73 
79 
80 
86 
99  bool m_colourSelection_gri (const int i_gal, const int clu_zbin);
100 
114  bool m_photzSelection (const int i_clu, const int i_gal, const int clu_zbin);
115 
122 
138  void m_resize(const double rad_min, const double rad_max, const int nRad, const bool log_rad);
139 
144  void m_linked_list();
145 
158  void m_add_galaxy(const int i_gal, const int clu_index, const double coscludec, const double clu_dist);
159 
166  void m_profile(const int clu_index);
167 
172  void m_stacker();
173 
185  std::shared_ptr<data::Data> m_make_bootstrap(const std::vector<int> z_proxy_bin);
186 
199  bool m_check_file(const std::string checked_file, const std::vector<int> z_proxy_bin);
200 
209  void m_write(const std::string output_dir, const std::string output_file);
210 
213 
215  std::shared_ptr<cosmology::Cosmology> m_cosm;
216 
218  std::shared_ptr<catalogue::Catalogue> m_galData;
219 
221  std::shared_ptr<catalogue::Catalogue> m_cluData;
222 
224  std::vector<bool (StackedDensityProfile::*)(const int, const int)> m_colourSel; // std::vector<std::function<bool(const int)>> m_colourSel;
225 
227  std::vector<bool (StackedDensityProfile::*)(const int, const int, const int)> m_photzSel;
228 
230  std::vector<std::function<bool(const std::vector<bool>)>> m_logicSel;
231 
233  std::vector<bool> m_isSet_colourSel;
234 
236  std::vector<bool> m_isSet_photzSel;
237 
239  std::vector<bool> m_isSet_logicSel;
240 
242  std::vector<std::vector<int>> m_background_idx_z;
243 
245  std::vector<std::vector<int>> m_background_idx_colour;
246 
249 
252 
254  double m_SN_min;
255 
257  double m_pix_size;
258 
260  std::vector<std::vector<double>> m_m_calib;
261 
263  std::vector<std::vector<double>> m_m_calib_zEdges;
264 
267 
269  std::vector<std::string> m_inputs_to_str;
270 
272  double m_rad_alpha;
273 
275  double m_obs_gamma;
276 
278  std::vector<std::vector<double>> m_colour_sel_pars;
279 
281  std::vector<std::vector<double>> m_zphot_sel_pars;
282 
284  std::vector<std::vector<std::string>> m_logic_sel_par;
285 
287  std::vector<double> m_rad_arr;
288 
290  std::vector<double> m_z_binEdges;
291 
293  std::vector<std::vector<double>> m_proxy_binEdges;
294 
296  std::vector<std::vector<int>> m_first;
297 
299  std::vector<std::vector<int>> m_last;
300 
302  std::vector<int> m_next;
303 
305  std::vector<std::vector<double>> m_nClu_inBin;
306 
308  std::vector<int> m_ngal_arr;
309 
311  std::vector<std::vector<std::vector<std::vector<int>>>> m_single_ngal_arr;
312 
314  std::vector<std::vector<std::vector<int>>> m_stacked_ngal_arr;
315 
317  std::vector<double> m_deltasigma_t;
318 
320  std::vector<std::vector<std::vector<std::vector<double>>>> m_single_deltasigma_t;
321 
323  std::vector<std::vector<std::vector<double>>> m_stacked_deltasigma_t;
324 
326  std::vector<std::vector<std::vector<double>>> m_stacked_deltasigma_t_err;
327 
329  std::vector<double> m_deltasigma_x;
330 
332  std::vector<std::vector<std::vector<std::vector<double>>>> m_single_deltasigma_x;
333 
335  std::vector<std::vector<std::vector<double>>> m_stacked_deltasigma_x;
336 
338  std::vector<std::vector<std::vector<double>>> m_stacked_deltasigma_x_err;
339 
341  std::vector<double> m_deltasigma_err;
342 
344  std::vector<std::vector<std::vector<std::vector<double>>>> m_single_deltasigma_err;
345 
347  std::vector<std::vector<std::vector<double>>> m_stacked_deltasigma_err;
348 
350  std::vector<double> m_wetasquareSum;
351 
353  std::vector<std::vector<std::vector<double>>> m_stacked_wetasquareSum;
354 
356  std::vector<double> m_wSum;
357 
359  std::vector<std::vector<std::vector<double>>> m_stacked_wSum;
360 
362  std::vector<double> m_wetaSum;
363 
365  std::vector<std::vector<std::vector<double>>> m_stacked_wetaSum;
366 
368  std::vector<double> m_deltasigmaSum;
369 
371  std::vector<std::vector<std::vector<double>>> m_stacked_deltasigmaSum;
372 
374  std::vector<std::vector<std::vector<double>>> m_stacked_deltasigma_wei;
375 
377  std::vector<double> m_rad_eff_arr;
378 
380  std::vector<std::vector<std::vector<double>>> m_stacked_rad_eff_arr;
381 
383  std::vector<double> m_rad_sigma_arr;
384 
386  std::vector<std::vector<std::vector<double>>> m_stacked_rad_sigma_arr;
387 
389  double m_sigma_fac;
390 
392  double m_ra_start;
393 
395  double m_dec_start;
396 
398  std::vector<int> m_nPix;
399 
401  std::vector<std::vector<double>> m_proxy_eff;
402 
404  std::vector<std::vector<double>> m_proxy_sigma;
405 
407  std::vector<std::vector<double>> m_z_eff;
408 
410  std::vector<std::vector<double>> m_z_sigma;
411 
413  std::vector<std::vector<std::vector<std::vector<double>>>> m_deltasigma_cov_matr;
414 
416 
418 
420 
421  public:
422 
427 
433  StackedDensityProfile () = default;
434 
439  virtual ~StackedDensityProfile () = default;
440 
441 
496  StackedDensityProfile (cosmology::Cosmology cosm, const catalogue::Catalogue gal_cat, const catalogue::Catalogue clu_cat, const double delta_redshift, std::vector<double> z_binEdges, std::vector<std::vector<double>> proxy_binEdges, const double rad_min, const double rad_max, const int nRad, const bool log_rad, const double SN_min, const double pix_size, const std::vector<std::vector<double>> multiplicative_calibration_stats={}, const std::vector<std::vector<double>> multiplicative_calibration_zEdges={}, const double rad_alpha=1., const double obs_gamma=1.);
498 
503 
527  void set_colour_selection(const std::string colour_space, const int z_bin, const double C1, const double C2, const double C3, const double C4, const double z_min);
528 
550  void set_colour_selection(const std::string colour_space, const double C1, const double C2, const double C3, const double C4, const double z_min);
551 
570  void set_zphot_selection(const int z_bin, const double deltaz, const double zgal_min, const double zgal_max, const double ODDS_min);
571 
588  void set_zphot_selection(const double deltaz, const double zgal_min, const double zgal_max, const double ODDS_min);
589 
600  void set_logic_selection(const int z_bin, const std::string sel);
601 
610  void set_logic_selection(const std::string sel);
611 
661  void measure(const std::vector<int> z_proxy_bin, const std::string output_dir, const std::string output_file_root, const ErrorType errorType=ErrorType::_Bootstrap_, const int n_resampling=10000, const bool write_background=false);
662 
664 
669 
679  void write(const std::string dir, const std::string file);
680 
682 
683  };
684  }
685  }
686 }
687 
688 #endif
The class Catalogue
The class Cosmology.
The class Measure.
The class Catalogue.
Definition: Catalogue.h:654
The class Cosmology.
Definition: Cosmology.h:277
The class Measure.
Definition: Measure.h:142
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_err
error on the stacked surface density
bool m_colourSelection_gri(const int i_gal, const int clu_zbin)
colour selection function in the colour-colour space ( ) vs ( )
void set_logic_selection(const int z_bin, const std::string sel)
Set the logic operator linking redshift and colour selections in the i-th cluster redshift bin.
std::vector< double > m_z_binEdges
phot-z bin edges
std::vector< std::vector< std::vector< std::vector< double > > > > m_single_deltasigma_x
cross surface density, stored for each single cluster
std::vector< std::vector< double > > m_z_sigma
error on the effective redshift linked to the stacked signal
double m_sigma_fac
constant factor for lensing quantities (c*c/(4piG) in M_sun/Mpc)
std::vector< double > m_deltasigmaSum
deltasigmaSum
std::vector< double > m_wetasquareSum
wetasquareSum
std::vector< double > m_deltasigma_t
tangential surface density
std::vector< std::vector< std::vector< double > > > m_stacked_rad_sigma_arr
stacked effective radii errors
std::vector< double > m_rad_arr
radius bin edges
std::vector< std::vector< double > > m_proxy_sigma
error on the effective mass proxy linked to the stacked signal
std::vector< std::vector< std::string > > m_logic_sel_par
the logic selection linking redshift and colour selections
StackedDensityProfile()=default
default constructor
std::vector< bool > m_isSet_colourSel
vector for checking if the colour selection is set in all the z bins
std::vector< int > m_nPix
number of pixels in RA and Dec
void m_add_galaxy(const int i_gal, const int clu_index, const double coscludec, const double clu_dist)
add galaxies to profiles
std::vector< bool(StackedDensityProfile::*)(const int, const int, const int)> m_photzSel
vector of pointers to the photo-z selection functions
std::vector< std::vector< int > > m_background_idx_z
vector of indices of the background galaxies selected through the redshift selection
std::vector< std::vector< std::vector< std::vector< double > > > > m_deltasigma_cov_matr
Bootstrap covariance matrix for the stacked signal.
std::vector< std::vector< double > > m_zphot_sel_pars
the parameters for the redshift selection
bool m_write_background
if true, create the folder containing the background galaxies indices
void m_profile(const int clu_index)
compute a single cluster profile
double m_delta_redshift
minimum interval between the cluster and the source redshifts
void m_resize(const double rad_min, const double rad_max, const int nRad, const bool log_rad)
resize the private member arrays
std::vector< std::string > m_inputs_to_str
vector of the inputs stored as strings
bool m_measure_is_read
bool stating if the measure is read from file
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_t_err
tangential stacked surface density error
std::shared_ptr< catalogue::Catalogue > m_galData
input galaxy catalogue
std::vector< std::vector< double > > m_z_eff
effective redshift linked to the stacked signal
void set_colour_selection(const std::string colour_space, const int z_bin, const double C1, const double C2, const double C3, const double C4, const double z_min)
Set the colour selection in the i-th cluster redshift bin.
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_x_err
cross stacked surface density error
double m_obs_gamma
gamma slope for lensing-weighted observables
std::vector< bool > m_isSet_logicSel
vector for checking if the logic selection linking colour and z selections is set in all the z bins
std::vector< std::vector< std::vector< std::vector< double > > > > m_single_deltasigma_err
error on the surface density, stored for each single cluster
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_t
tangential stacked surface density
double m_n_resampling
number of regions for the resampling
std::vector< std::vector< int > > m_last
a "last" for each pixel
std::shared_ptr< data::Data > m_make_bootstrap(const std::vector< int > z_proxy_bin)
bootstrap resampling to retrieve the covariance matrix of the stacked signal, providing the stacked p...
bool m_photzSelection(const int i_clu, const int i_gal, const int clu_zbin)
redshift selection function
bool m_check_file(const std::string checked_file, const std::vector< int > z_proxy_bin)
check if the results obtained from the stacking have already been written to a file
void measure(const std::vector< int > z_proxy_bin, const std::string output_dir, const std::string output_file_root, const ErrorType errorType=ErrorType::_Bootstrap_, const int n_resampling=10000, const bool write_background=false)
measure the stacked profiles in all the bins of redshift and mass proxy, providing in output the stac...
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_x
cross stacked surface density
void m_write(const std::string output_dir, const std::string output_file)
write the results obtained from the stacking on file
double m_rad_alpha
slope for the observable weighted mean
std::vector< double > m_deltasigma_x
cross surface density
void write(const std::string dir, const std::string file)
write on file the measure in a given bin of redshift and mass proxy
std::vector< std::vector< std::vector< std::vector< double > > > > m_single_deltasigma_t
tangential surface density, stored for each single cluster
std::vector< double > m_deltasigma_err
error on the surface density
std::vector< std::function< bool(const std::vector< bool >)> > m_logicSel
logic operator between colour and photo-z selection
std::vector< std::vector< std::vector< double > > > m_stacked_wetasquareSum
stacked wetasquareSum
void m_check_catalogue_variables()
check if all the necessary variables in the galaxy and cluster catalogues are set
std::vector< std::vector< std::vector< double > > > m_stacked_wetaSum
stacked wetaSum
void set_zphot_selection(const int z_bin, const double deltaz, const double zgal_min, const double zgal_max, const double ODDS_min)
Set the redshift selection in the i-th cluster redshift bin.
std::vector< std::vector< double > > m_proxy_eff
effective mass proxy linked to the stacked signal
std::vector< double > m_rad_eff_arr
effective radii
std::vector< int > m_next
a "next" for each galaxy
std::vector< std::vector< double > > m_colour_sel_pars
the parameters for the colour selection
std::vector< std::vector< double > > m_m_calib
the multiplicative calibration bias mean and standard deviation in the z bins
virtual ~StackedDensityProfile()=default
default destructor
std::shared_ptr< catalogue::Catalogue > m_cluData
input cluster catalogue
std::vector< bool > m_isSet_photzSel
vector for checking if the photo-z selection is set in all the z bins
std::vector< std::vector< std::vector< int > > > m_stacked_ngal_arr
stacked number of galaxies for annulus
std::vector< double > m_rad_sigma_arr
effective radii errors
std::vector< std::vector< std::vector< double > > > m_stacked_rad_eff_arr
stacked effective radii
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigmaSum
stacked deltasigmaSum
void m_set_multiplicative_calib()
set the multiplicative shear calibration, m
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_wei
stacked deltasigma_wei
std::vector< std::vector< int > > m_first
a "first" for each pixel
std::vector< bool(StackedDensityProfile::*)(const int, const int)> m_colourSel
vector of pointers to the colour selection function s
std::vector< std::vector< int > > m_background_idx_colour
vector of indices of the background galaxies selected through the colour selection
std::vector< int > m_ngal_arr
number of galaxies for annulus
std::vector< std::vector< std::vector< double > > > m_stacked_wSum
stacked wSum
std::vector< std::vector< double > > m_proxy_binEdges
mass proxy bin edges
std::shared_ptr< cosmology::Cosmology > m_cosm
input cosmology
std::vector< std::vector< double > > m_nClu_inBin
number of clusters in a bin of z and mass proxy
std::vector< std::vector< std::vector< std::vector< int > > > > m_single_ngal_arr
number of galaxies for annulus for cluster
std::vector< std::vector< double > > m_m_calib_zEdges
the redshift edges within which the multiplicative calibration bias is evaluated
ErrorType
the two-point correlation function error type
Definition: Measure.h:59
@ _Bootstrap_
Bootstrap resampling.
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38