CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
TwoPointCorrelation2D.h
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2010 by Federico Marulli and Alfonso Veropalumbo *
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 __TWOPOINT2D__
36 #define __TWOPOINT2D__
37 
38 
39 #include "TwoPointCorrelation.h"
40 
41 
42 // ===================================================================================================
43 
44 
45 namespace cbl {
46 
47  namespace measure {
48 
49  namespace twopt {
50 
68 
69  protected :
70 
75 
83  void write_pairs (const std::shared_ptr<pairs::Pair> PP, const std::string dir, const std::string file) const override;
84 
92  void read_pairs (std::shared_ptr<pairs::Pair> PP, const std::vector<std::string> dir, const std::string file) const override;
93 
101  void write_pairs (const std::vector<std::shared_ptr<pairs::Pair>> PP, const std::string dir, const std::string file) const override;
102 
110  void read_pairs (std::vector<std::shared_ptr<pairs::Pair>> PP, const std::vector<std::string> dir, const std::string file) const override;
111 
113 
118 
133  std::shared_ptr<data::Data> data_with_extra_info (const std::shared_ptr<pairs::Pair> dd, const std::vector<double> scale_D1, const std::vector<double> scale_D2, const std::vector<std::vector<double>> xi, const std::vector<std::vector<double>> error) const;
134 
158  std::shared_ptr<data::Data> correlation_NaturalEstimator (const std::shared_ptr<pairs::Pair> dd, const std::shared_ptr<pairs::Pair> rr, const int nData=0, const double nData_weighted=0., const int nRandom=0, const double nRandom_weighted=0.) override;
159 
186  std::shared_ptr<data::Data> correlation_LandySzalayEstimator (const std::shared_ptr<pairs::Pair> dd, const std::shared_ptr<pairs::Pair> rr, const std::shared_ptr<pairs::Pair> dr, const int nData=0, const double nData_weighted=0., const int nRandom=0, const double nRandom_weighted=0.) override;
187 
198  std::vector<std::shared_ptr<data::Data>> XiJackknife (const std::vector<std::shared_ptr<pairs::Pair>> dd, const std::vector<std::shared_ptr<pairs::Pair>> rr) override;
199 
212  std::vector<std::shared_ptr<data::Data>> XiJackknife (const std::vector<std::shared_ptr<pairs::Pair>> dd, const std::vector<std::shared_ptr<pairs::Pair>> rr, const std::vector<std::shared_ptr<pairs::Pair>> dr) override;
213 
229  std::vector<std::shared_ptr<data::Data>> XiBootstrap (const int nMocks, const std::vector<std::shared_ptr<pairs::Pair>> dd, const std::vector<std::shared_ptr<pairs::Pair>> rr, const int seed=3213) override;
230 
249  std::vector<std::shared_ptr<data::Data>> XiBootstrap (const int nMocks, const std::vector<std::shared_ptr<pairs::Pair>> dd, const std::vector<std::shared_ptr<pairs::Pair>> rr, const std::vector<std::shared_ptr<pairs::Pair>> dr, const int seed=3213) override;
250 
252 
253 
254  public:
255 
260 
266 
284 
290 
292 
297 
302  std::vector<double> xx () const override
303  { return m_dataset->xx(); }
304 
309  std::vector<double> yy () const override
310  { return m_dataset->yy(); }
311 
316  std::vector<std::vector<double>> xi2D () const override
317  { std::vector<std::vector<double>> vv; m_dataset->get_data(vv); return vv; }
318 
324  std::vector<std::vector<double>> error2D () const override
325  { std::vector<std::vector<double> > vv; m_dataset->get_error(vv); return vv; }
326 
328 
329 
334 
376  virtual void measure (const ErrorType errorType=ErrorType::_Poisson_, const std::string dir_output_pairs=par::defaultString, const std::vector<std::string> dir_input_pairs={}, const std::string dir_output_resample=par::defaultString, const int nMocks=0, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=Estimator::_LandySzalay_, const double fact=0.1, const int seed=3213) = 0;
377 
379 
380 
385 
391  virtual void read (const std::string dir, const std::string file)
392  { (void)dir; (void)file; ErrorCBL("", "read", "TwoPointCorrelation2D.h"); }
393 
400  virtual void write (const std::string dir, const std::string file, const int rank=0) const
401  { (void)dir; (void)file; (void)rank; ErrorCBL("", "write", "TwoPointCorrelation2D.h"); }
402 
404 
405 
410 
416  virtual void read_covariance (const std::string dir, const std::string file)
417  { (void)dir; (void)file; ErrorCBL("", "read_covariance", "TwoPointCorrelation2D.h"); }
418 
424  virtual void write_covariance (const std::string dir, const std::string file) const
425  { (void)dir; (void)file; ErrorCBL("", "write_covariance", "TwoPointCorrelation2D.h"); }
426 
434  virtual void compute_covariance (const std::vector<std::shared_ptr<data::Data>> xi, const bool JK)
435  { (void)xi; (void)JK; ErrorCBL("", "compute_covariance", "TwoPointCorrelation2D.h"); }
436 
445  virtual void compute_covariance (const std::vector<std::string> file, const bool JK)
446  { (void)file; (void)JK; ErrorCBL("", "compute_covariance", "TwoPointCorrelation2D.h"); }
447 
449 
450  };
451  }
452  }
453 }
454 
455 #endif
The class TwoPointCorrelation.
The class Catalogue.
Definition: Catalogue.h:654
static std::shared_ptr< Data > Create(const DataType dataType)
static factory used to construct objects of class Data1D
Definition: Data.cpp:50
std::shared_ptr< data::Data > m_dataset
the dataset of the measure
Definition: Measure.h:147
std::vector< double > yy() const override
get the protected member m_y
virtual void read(const std::string dir, const std::string file)
read the measured two-point correlation
std::vector< std::shared_ptr< data::Data > > XiBootstrap(const int nMocks, const std::vector< std::shared_ptr< pairs::Pair >> dd, const std::vector< std::shared_ptr< pairs::Pair >> rr, const int seed=3213) override
measure the bootstrap resampling of the two-point correlation function, ξ(r)
std::shared_ptr< data::Data > correlation_LandySzalayEstimator(const std::shared_ptr< pairs::Pair > dd, const std::shared_ptr< pairs::Pair > rr, const std::shared_ptr< pairs::Pair > dr, const int nData=0, const double nData_weighted=0., const int nRandom=0, const double nRandom_weighted=0.) override
get a dataset containing the two-point correlation function measured with the Landy-Szalay estimator,...
std::vector< std::shared_ptr< data::Data > > XiJackknife(const std::vector< std::shared_ptr< pairs::Pair >> dd, const std::vector< std::shared_ptr< pairs::Pair >> rr) override
measure the jackknife resampling of the two-point correlation function, ξ(r)
void read_pairs(std::shared_ptr< pairs::Pair > PP, const std::vector< std::string > dir, const std::string file) const override
read the number of pairs
virtual void compute_covariance(const std::vector< std::string > file, const bool JK)
compute the covariance matrix
std::shared_ptr< data::Data > data_with_extra_info(const std::shared_ptr< pairs::Pair > dd, const std::vector< double > scale_D1, const std::vector< double > scale_D2, const std::vector< std::vector< double >> xi, const std::vector< std::vector< double >> error) const
return a data object with extra info
std::vector< std::vector< double > > error2D() const override
get the protected member m_error_fxy
void write_pairs(const std::shared_ptr< pairs::Pair > PP, const std::string dir, const std::string file) const override
write the number of pairs
virtual void write(const std::string dir, const std::string file, const int rank=0) const
write the measured two-point correlation
virtual void compute_covariance(const std::vector< std::shared_ptr< data::Data >> xi, const bool JK)
compute the covariance matrix
virtual void write_covariance(const std::string dir, const std::string file) const
write the measured two-point correlation
virtual void measure(const ErrorType errorType=ErrorType::_Poisson_, const std::string dir_output_pairs=par::defaultString, const std::vector< std::string > dir_input_pairs={}, const std::string dir_output_resample=par::defaultString, const int nMocks=0, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=Estimator::_LandySzalay_, const double fact=0.1, const int seed=3213)=0
measure the two-point correlation function
TwoPointCorrelation2D(const catalogue::Catalogue data, const catalogue::Catalogue random, const bool compute_extra_info=false, const double random_dilution_fraction=1.)
constructor
~TwoPointCorrelation2D()=default
default destructor
std::shared_ptr< data::Data > correlation_NaturalEstimator(const std::shared_ptr< pairs::Pair > dd, const std::shared_ptr< pairs::Pair > rr, const int nData=0, const double nData_weighted=0., const int nRandom=0, const double nRandom_weighted=0.) override
get a dataset containing the two-point correlation function measured with the natural estimator,...
virtual void read_covariance(const std::string dir, const std::string file)
read the measured covariance matrix
std::vector< std::vector< double > > xi2D() const override
get the protected member m_fxy
std::vector< double > xx() const override
get the protected member m_x
std::shared_ptr< pairs::Pair > dr() const
get the protected member m_dr
std::shared_ptr< catalogue::Catalogue > random() const
get the protected member m_random
bool compute_extra_info() const
get the protected member m_compute_extra_info
bool random_dilution_fraction() const
get the protected member m_random_dilution_fraction
std::shared_ptr< pairs::Pair > rr() const
get the protected member m_rr
std::shared_ptr< pairs::Pair > dd() const
get the protected member m_dd
std::shared_ptr< catalogue::Catalogue > data() const
get the protected member m_data
static const std::string defaultString
default std::string value
Definition: Constants.h:336
@ _2D_extra_
2D dataset with extra information
Estimator
the two-point correlation estimator
@ _LandySzalay_
Landy&Szalay estimator.
ErrorType
the two-point correlation function error type
Definition: Measure.h:59
@ _Poisson_
Poissonian error.
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38
int ErrorCBL(const std::string msg, const std::string functionCBL, const std::string fileCBL, const cbl::glob::ExitCode exitCode=cbl::glob::ExitCode::_error_)
throw an exception: it is used for handling exceptions inside the CosmoBolognaLib
Definition: Kernel.h:780