CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
TwoPointCorrelation1D.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 __TWOPOINT1D__
36 #define __TWOPOINT1D__
37 
38 
39 #include "TwoPointCorrelation.h"
40 
41 
42 // ===================================================================================================
43 
44 
45 namespace cbl {
46 
47  namespace measure {
48 
49  namespace twopt {
50 
67  class TwoPointCorrelation1D : public virtual TwoPointCorrelation {
68 
69  protected :
70 
75 
82  virtual void write_pairs (const std::shared_ptr<pairs::Pair> PP, const std::string dir, const std::string file) const override;
83 
90  virtual void read_pairs (std::shared_ptr<pairs::Pair> PP, const std::vector<std::string> dir, const std::string file) const override;
91 
98  virtual void write_pairs (const std::vector<std::shared_ptr<pairs::Pair>> PP, const std::string dir, const std::string file) const override;
99 
106  virtual void read_pairs (std::vector<std::shared_ptr<pairs::Pair>> PP, const std::vector<std::string> dir, const std::string file) const override;
107 
109 
110 
115 
128  virtual std::shared_ptr<data::Data> data_with_extra_info (const std::shared_ptr<pairs::Pair> dd, const std::vector<double> rad, const std::vector<double> xi, const std::vector<double> error) const;
129 
153  virtual 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;
154 
181  virtual 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;
182 
193  virtual 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;
194 
207  virtual 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;
208 
219  virtual std::vector<std::shared_ptr<data::Data>> XiJackknifeTest (const std::vector<std::shared_ptr<pairs::Pair>> dd, const std::vector<std::shared_ptr<pairs::Pair>> rr) override;
220 
234  virtual std::vector<std::shared_ptr<data::Data>> XiJackknifeTest (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;
235 
251  virtual 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;
252 
270  virtual 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;
271 
273 
274 
275  public:
276 
281 
286 
303 
309 
311 
312 
317 
322  std::vector<double> xx () const override
323  { return m_dataset->xx(); }
324 
329  std::vector<double> xi1D () const override
330  { std::vector<double> vv; m_dataset->get_data(vv); return vv; }
331 
337  std::vector<double> error1D () const override
338  { std::vector<double> vv; m_dataset->get_error(vv); return vv; }
339 
341 
346 
388  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;
389 
391 
396 
402  virtual void read (const std::string dir, const std::string file)
403  { (void)dir; (void)file; ErrorCBL("", "read", "TwoPointCorrelation1D.h"); }
404 
411  virtual void write (const std::string dir, const std::string file, const int rank=0) const
412  { (void)dir; (void)file; (void)rank; ErrorCBL("", "read", "TwoPointCorrelation1D.h"); }
413 
415 
416 
421 
427  void read_covariance (const std::string dir, const std::string file) override;
428 
435  void write_covariance (const std::string dir, const std::string file) const override;
436 
444  void compute_covariance (const std::vector<std::shared_ptr<data::Data>> xi, const bool JK) override;
445 
454  void compute_covariance (const std::vector<std::string> file, const bool JK) override;
455 
457 
458  };
459  }
460  }
461 }
462 
463 #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
virtual 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 write(const std::string dir, const std::string file, const int rank=0) const
write the measured two-point correlation
virtual 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,...
void read_covariance(const std::string dir, const std::string file) override
read the measured covariance matrix
virtual std::vector< std::shared_ptr< data::Data > > XiJackknifeTest(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), test
virtual 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
~TwoPointCorrelation1D()=default
default destructor
virtual void read(const std::string dir, const std::string file)
read the measured two-point correlation
virtual 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)
virtual std::shared_ptr< data::Data > data_with_extra_info(const std::shared_ptr< pairs::Pair > dd, const std::vector< double > rad, const std::vector< double > xi, const std::vector< double > error) const
return a data object with extra info
virtual 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,...
TwoPointCorrelation1D(const catalogue::Catalogue data, const catalogue::Catalogue random, const bool compute_extra_info=false, const double random_dilution_fraction=1.)
constructor
void write_covariance(const std::string dir, const std::string file) const override
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
std::vector< double > xi1D() const override
get the protected member m_fx
std::vector< double > xx() const override
get the protected member m_x
void compute_covariance(const std::vector< std::shared_ptr< data::Data >> xi, const bool JK) override
compute the covariance matrix
std::vector< double > error1D() const override
get the protected member m_error_fx
virtual 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< 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
@ _1D_extra_
1D 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