45 using namespace catalogue;
46 using namespace triplets;
47 using namespace measure;
48 using namespace threept;
58 double r12_binSize = r12*2.*perc_increase;
59 double r13 = side_s*side_u;
60 double r13_binSize = r13*2.*perc_increase;
62 m_ddd = move(Triplet::Create(tripletType, r12, r12_binSize, r13, r13_binSize, nbins));
63 m_rrr = move(Triplet::Create(tripletType, r12, r12_binSize, r13, r13_binSize, nbins));
64 m_ddr = move(Triplet::Create(tripletType, r12, r12_binSize, r13, r13_binSize, nbins));
65 m_drr = move(Triplet::Create(tripletType, r12, r12_binSize, r13, r13_binSize, nbins));
74 m_ddd = move(Triplet::Create(tripletType, r12, r12_binSize, r13, r13_binSize, nbins));
75 m_rrr = move(Triplet::Create(tripletType, r12, r12_binSize, r13, r13_binSize, nbins));
76 m_ddr = move(Triplet::Create(tripletType, r12, r12_binSize, r13, r13_binSize, nbins));
77 m_drr = move(Triplet::Create(tripletType, r12, r12_binSize, r13, r13_binSize, nbins));
90 count_allTriplets(dir_output_triplets, dir_input_triplets, count_ddd, count_rrr, count_ddr, count_drr, tcount, fact);
95 m_scale.resize(m_ddd->nbins()); m_zeta.resize(m_ddd->nbins()); m_error.resize(m_ddd->nbins());
97 double nGal = m_data->weightedN();
98 double nRan = m_random->weightedN();
100 coutCBL <<
"# Galaxies: " << nGal <<
" ; # Random: " << nRan << endl;
102 double norm1 = (double(nGal)*double(nGal-1)*double(nGal-2))/6.;
103 double norm2 = (double(nGal)*double(nGal-1)*double(nRan))*0.5;
104 double norm3 = (double(nGal)*double(nRan)*double(nRan-1))*0.5;
105 double norm4 = (double(nRan)*double(nRan-1)*double(nRan-2))/6.;
107 for (
int i=0; i<m_ddd->nbins(); i++) {
109 m_scale[i] = m_ddd->scale(i);
111 if (m_ddd->TT1D(i)>0 && m_rrr->TT1D(i)>0) {
112 m_zeta[i] = ((m_ddd->TT1D(i)/norm1)/(m_rrr->TT1D(i)/norm4))-3.*((m_ddr->TT1D(i)/norm2)/(m_rrr->TT1D(i)/norm4))+3.*(((m_drr->TT1D(i)/norm3)/(m_rrr->TT1D(i)/norm4)))-1.;
118 m_dataset = move(unique_ptr<data::Data1D>(
new data::Data1D(m_scale, m_zeta, m_error)));
125 void cbl::measure::threept::ThreePointCorrelation_comoving_connected::measure (
const std::vector<std::vector<double>> weight,
const bool doJK,
const std::string dir_output_triplets,
const std::vector<std::string> dir_input_triplets,
const bool count_ddd,
const bool count_rrr,
const bool count_ddr,
const bool count_drr,
const bool tcount,
const double fact,
const int seed)
131 count_allTriplets_region (weight, dir_output_triplets, dir_input_triplets, count_ddd, count_rrr, count_ddr, count_drr, tcount, fact);
136 m_scale.resize(m_ddd->nbins()); m_zeta.resize(m_ddd->nbins()); m_error.resize(m_ddd->nbins());
138 double nGal = m_data->weightedN();
139 double nRan = m_random->weightedN();
141 double norm1 = (double(nGal)*double(nGal-1)*double(nGal-2))/6.;
142 double norm2 = (double(nGal)*double(nGal-1)*double(nRan))*0.5;
143 double norm3 = (double(nGal)*double(nRan)*double(nRan-1))*0.5;
144 double norm4 = (double(nRan)*double(nRan-1)*double(nRan-2))/6.;
147 for (
int i=0; i<m_ddd->nbins(); i++) {
149 m_scale[i] = m_ddd->scale(i);
151 if (m_ddd->TT1D(i)>0 && m_rrr->TT1D(i)>0)
152 m_zeta[i] = ((m_ddd->TT1D(i)/norm1)/(m_rrr->TT1D(i)/norm4))-3.*((m_ddr->TT1D(i)/norm2)/(m_rrr->TT1D(i)/norm4))+3.*(((m_drr->TT1D(i)/norm3)/(m_rrr->TT1D(i)/norm4)))-1.;
158 vector<vector<double>> resampling_threept(weight.size(), vector<double>(m_ddd->nbins(), 0));
159 vector<long> region_list = m_data->region_list();
161 vector<double> nData_reg_weighted, nRandom_reg_weighted;
163 const int nRegions = m_data->nRegions();
165 for (
int i=0; i<nRegions; i++) {
166 nData_reg_weighted.push_back(m_data->weightedN_condition(Var::_Region_, region_list[i], region_list[i]+1, 0));
167 nRandom_reg_weighted.push_back(m_random->weightedN_condition(Var::_Region_, region_list[i], region_list[i]+1, 0));
171 for (
size_t i=0; i<weight.size(); i++) {
176 for (
size_t j=0; j<weight[i].size(); j++) {
177 nData += weight[i][j]*nData_reg_weighted[j];
178 nRan += weight[i][j]*nRandom_reg_weighted[j];
181 double norm1 = (double(nData)*double(nData-1)*double(nData-2))/6.;
182 double norm2 = (double(nData)*double(nData-1)*double(nRan))*0.5;
183 double norm3 = (double(nData)*double(nRan)*double(nRan-1))*0.5;
184 double norm4 = (double(nRan)*double(nRan-1)*double(nRan-2))/6.;
186 for (
int j=0; j<m_ddd->nbins(); j++)
187 if (m_ddd_regions[i]->TT1D(j)>0 && m_rrr_regions[i]->TT1D(j)>0)
188 resampling_threept[i][j] = ((m_ddd_regions[i]->TT1D(j)/norm1)/(m_rrr_regions[i]->TT1D(j)/norm4))-3.*((m_ddr_regions[i]->TT1D(j)/norm2)/(m_rrr_regions[i]->TT1D(j)/norm4))+3.*(((m_drr_regions[i]->TT1D(j)/norm3)/(m_rrr_regions[i]->TT1D(j)/norm4)))-1.;
191 vector<vector<double>> cov_mat;
193 m_dataset = move(unique_ptr<data::Data1D>(
new data::Data1D(m_scale, m_zeta, cov_mat)));
195 m_error = m_dataset->error();
203 void cbl::measure::threept::ThreePointCorrelation_comoving_connected::measure (
const cbl::measure::ErrorType errorType,
const std::string dir_output_triplets,
const std::vector<std::string> dir_input_triplets,
const int nResamplings,
const bool count_ddd,
const bool count_rrr,
const bool count_ddr,
const bool count_drr,
const bool tcount,
const double fact,
const int seed)
210 measure(dir_output_triplets, dir_input_triplets, count_ddd, count_rrr, count_ddr, count_drr, tcount, fact);
216 const int nRegions = m_data->nRegions();
218 vector<vector<double>> weight(nRegions, vector<double>(nRegions, 1));
219 for (
int i=0; i<nRegions; i++)
222 measure(weight,
true, dir_output_triplets, dir_input_triplets, count_ddd, count_rrr, count_ddr, count_drr, tcount, fact);
228 const int nRegions = m_data->nRegions();
234 vector<vector<double>> weight(nResamplings, vector<double>(nRegions, 0));
235 for (
int i=0; i<nResamplings; i++)
236 for (
int j=0; j<val*nRegions; j++)
239 measure(weight,
false, dir_output_triplets, dir_input_triplets, count_ddd, count_rrr, count_ddr, count_drr, tcount, fact);
244 ErrorCBL(
"no such kind of error type!",
"measure",
"ThreePointCorrelation_comoving_connected.cpp");
255 checkDim(m_scale, m_ddd->nbins(),
"scale");
257 string file_out = dir+file;
258 ofstream fout(file_out.c_str());
checkIO(fout, file_out);
260 fout <<
"# scale zeta error(work in progress)" << endl;
262 for (
size_t i=0; i<m_scale.size(); i++)
263 fout << setiosflags(ios::fixed) << setprecision(4) << setw(10) << right << m_scale[i]
264 <<
" " << setiosflags(ios::fixed) << setprecision(4) << setw(10) << right << m_zeta[i]
265 <<
" " << setiosflags(ios::fixed) << setprecision(4) << setw(10) << right << m_error[i] << endl;
267 fout.close();
coutCBL << endl <<
"I wrote the file: " << file_out << endl << endl;
276 m_dataset->write_covariance(dir, file);
#define coutCBL
CBL print message.
The class ThreePointCorrelation_comoving_connected.
void set_parameters(const triplets::TripletType tripletType, const double side_s, const double side_u, const double perc_increase, const int nbins)
set the binning parameters
void write(const std::string dir, const std::string file) const override
write the monopole of the two-point correlation function
void write_covariance(const std::string dir, const std::string file) const override
write the measured three-point correlation covariance
void measure(const std::string dir_output_triplets, const std::vector< std::string > dir_input_triplets={}, const bool count_ddd=true, const bool count_rrr=true, const bool count_ddr=true, const bool count_drr=true, const bool tcount=true, const double fact=0.1, const int seed=3213) override
method to measure the three-point correlation function
ErrorType
the two-point correlation function error type
@ _Bootstrap_
Bootstrap resampling.
@ _None_
No error computed.
@ _Jackknife_
Jackknife resampling.
TripletType
the triplet type
The global namespace of the CosmoBolognaLib
void checkDim(const std::vector< T > vect, const int val, const std::string vector, bool equal=true)
check if the dimension of a std::vector is equal/lower than an input value
void checkIO(const std::ifstream &fin, const std::string file="NULL")
check if an input file can be opened
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
void covariance_matrix(const std::vector< std::vector< double >> mat, std::vector< std::vector< double >> &cov, const bool JK=false)
compute the covariance matrix from an input dataset