CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
Pair1D.cpp
Go to the documentation of this file.
1 /*******************************************************************
2  * Copyright (C) 2015 by 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 
34 #include "Pair1D.h"
35 
36 using namespace std;
37 
38 using namespace cbl;
39 using namespace catalogue;
40 using namespace pairs;
41 
42 
43 // ============================================================================================
44 
45 
47 {
48  for (int i=0; i<m_nbins; i++) {
49  m_PP1D[i] = 0.;
50  m_PP1D_weighted[i] = 0;
51  }
52 }
53 
54 
55 // ============================================================================================
56 
57 
59 {
60  const double binSize = ((m_thetaMax-m_thetaMin)/m_nbins);
61  m_binSize_inv = 1./binSize;
62 
63  m_scale.resize(m_nbins);
64  for (int i=0; i<m_nbins; i++)
65  m_scale[i] = binSize*(i+m_shift)+m_thetaMin;
66 }
67 
68 
69 // ============================================================================================
70 
71 
73 {
74  m_nbins = nint((m_thetaMax-m_thetaMin)*m_binSize_inv);
75  m_thetaMax = m_nbins/m_binSize_inv+m_thetaMin;
76 
77  m_scale.resize(m_nbins);
78  for (int i=0; i<m_nbins; i++)
79  m_scale[i] = (i+m_shift)/m_binSize_inv+m_thetaMin;
80 }
81 
82 
83 // ============================================================================================
84 
85 
87 {
88  if (m_thetaMin<1.e-30) ErrorCBL("m_thetaMin must be >0!", "m_set_parameters_nbins", "Pair1D.cpp");
89 
90  const double binSize = ((log10(m_thetaMax)-log10(m_thetaMin))/m_nbins);
91  m_binSize_inv = 1./binSize;
92 
93  m_scale.resize(m_nbins);
94  for (int i=0; i<m_nbins; i++)
95  m_scale[i] = pow(10.,(i+m_shift)*binSize+log10(m_thetaMin));
96 }
97 
98 
99 // ============================================================================================
100 
101 
103 {
104  if (m_thetaMin<1.e-30) ErrorCBL("m_thetaMin must be >0!", "m_set_parameters_binSize", "Pair1D.cpp");
105 
106  m_nbins = nint((log10(m_thetaMax)-log10(m_thetaMin))*m_binSize_inv);
107  m_thetaMax = pow(10.,m_nbins/m_binSize_inv+log10(m_thetaMin));
108 
109  m_scale.resize(m_nbins);
110  for (int i=0; i<m_nbins; i++)
111  m_scale[i] = pow(10.,(i+m_shift)/m_binSize_inv+log10(m_thetaMin));
112 }
113 
114 
115 // ============================================================================================
116 
117 
119 {
120  const double binSize = ((m_rMax-m_rMin)/m_nbins);
121  m_binSize_inv = 1./binSize;
122 
123  m_scale.resize(m_nbins);
124  for (int i=0; i<m_nbins; i++)
125  m_scale[i] = (i+m_shift)*binSize+m_rMin;
126 }
127 
128 
129 // ============================================================================================
130 
131 
133 {
134  m_nbins = nint((m_rMax-m_rMin)*m_binSize_inv);
135  m_rMax = m_nbins/m_binSize_inv+m_rMin;
136 
137  m_scale.resize(m_nbins);
138  for (int i=0; i<m_nbins; i++)
139  m_scale[i] = (i+m_shift)/m_binSize_inv+m_rMin;
140 }
141 
142 
143 // ============================================================================================
144 
145 
147 {
148  if (m_rMin<1.e-30) ErrorCBL("m_rMin must be >0!", "m_set_parameters_nbins", "Pair1D.cpp");
149 
150  const double binSize = ((log10(m_rMax)-log10(m_rMin))/m_nbins);
151  m_binSize_inv = 1./binSize;
152 
153  m_scale.resize(m_nbins);
154  for (int i=0; i<m_nbins; i++)
155  m_scale[i] = pow(10.,(i+m_shift)*binSize+log10(m_rMin));
156 }
157 
158 
159 // ============================================================================================
160 
161 
163 {
164  if (m_rMin<1.e-30) ErrorCBL("m_rMin must be >0!", "m_set_parameters_binSize", "Pair1D.cpp");
165 
166  m_nbins = nint((log10(m_rMax)-log10(m_rMin))*m_binSize_inv);
167  m_rMax = pow(10.,m_nbins/m_binSize_inv+log10(m_rMin));
168 
169  m_scale.resize(m_nbins);
170  for (int i=0; i<m_nbins; i++)
171  m_scale[i] = pow(10.,(i+m_shift)/m_binSize_inv+log10(m_rMin));
172 }
173 
174 
175 // ============================================================================================
176 
177 
179 {
180  const double binSize = ((m_rMax-m_rMin)/m_nbins);
181  m_binSize_inv = 1./binSize;
182 
183  m_scale.resize(3*m_nbins);
184  for (int l=0; l<3; l++)
185  for (int i=0; i<m_nbins; i++)
186  m_scale[l*m_nbins+i] = (i+m_shift)*binSize+m_rMin;
187 }
188 
189 
190 // ============================================================================================
191 
192 
194 {
195  m_nbins = nint((m_rMax-m_rMin)*m_binSize_inv);
196  m_rMax = m_nbins/m_binSize_inv+m_rMin;
197 
198  m_scale.resize(3*m_nbins);
199  for (int l=0; l<3; l++)
200  for (int i=0; i<m_nbins; i++)
201  m_scale[l*m_nbins+i] = (i+m_shift)/m_binSize_inv+m_rMin;
202 }
203 
204 
205 // ============================================================================================
206 
207 
209 {
210  if (m_rMin<1.e-30) ErrorCBL("m_rMin must be >0!", "m_set_parameters_nbins", "Pair1D.cpp");
211 
212  const double binSize = ((log10(m_rMax)-log10(m_rMin))/m_nbins);
213  m_binSize_inv = 1./binSize;
214 
215  m_scale.resize(3*m_nbins);
216  for (int l=0; l<3; l++)
217  for (int i=0; i<m_nbins; i++)
218  m_scale[l*m_nbins+i] = pow(10.,(i+m_shift)*binSize+log10(m_rMin));
219 }
220 
221 
222 // ============================================================================================
223 
224 
226 {
227  if (m_rMin<1.e-30) ErrorCBL("m_rMin must be >0!", "m_set_parameters_binSize", "Pair1D.cpp");
228 
229  m_nbins = nint((log10(m_rMax)-log10(m_rMin))*m_binSize_inv);
230  m_rMax = pow(10.,m_nbins/m_binSize_inv+log10(m_rMin));
231 
232  m_scale.resize(3*m_nbins);
233  for (int l=0; l<3; l++)
234  for (int i=0; i<m_nbins; i++)
235  m_scale[l*m_nbins+i] = pow(10.,(i+m_shift)/m_binSize_inv+log10(m_rMin));
236 }
237 
238 
239 // ============================================================================================
240 
241 
242 void cbl::pairs::Pair1D_angular_lin::get (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2, int &kk, double &wkk)
243 {
244  kk = -1;
245  wkk = 0;
246 
247  const double dist = (m_angularUnits==CoordinateUnits::_radians_) ? angular_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz())
248  : converted_angle(angular_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz()), CoordinateUnits::_radians_, m_angularUnits);
249 
250  if (m_thetaMin < dist && dist < m_thetaMax) {
251  kk = max(0, min(int((dist-m_thetaMin)*m_binSize_inv), m_nbins));
252 
253  wkk += obj1->weight()*obj2->weight();
254  }
255 }
256 
257 
258 // ============================================================================================
259 
260 
261 void cbl::pairs::Pair1D_angular_log::get (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2, int &kk, double &wkk)
262 {
263  kk = -1;
264  wkk = 0;
265 
266  const double dist = (m_angularUnits==CoordinateUnits::_radians_) ? angular_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz())
267  : converted_angle(angular_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz()), CoordinateUnits::_radians_, m_angularUnits);
268 
269  if (m_thetaMin < dist && dist < m_thetaMax) {
270  kk = max(0, min(int((log10(dist)-log10(m_thetaMin))*m_binSize_inv), m_nbins));
271 
272  wkk = obj1->weight()*obj2->weight();
273  }
274 }
275 
276 
277 // ============================================================================================
278 
279 
280 void cbl::pairs::Pair1D_comoving_lin::get (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2, int &kk, double &wkk)
281 {
282  kk = -1;
283  wkk = 0;
284 
285  const double dist = Euclidean_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz());
286 
287  if (m_rMin < dist && dist < m_rMax) {
288  kk = max(0, min(int((dist-m_rMin)*m_binSize_inv), m_nbins));
289 
290  const double angWeight = (m_angularWeight==nullptr) ? 1.
291  : max(0., m_angularWeight(converted_angle(angular_distance(obj1->xx()/obj1->dc(), obj2->xx()/obj2->dc(), obj1->yy()/obj1->dc(), obj2->yy()/obj2->dc(), obj1->zz()/obj1->dc(), obj2->zz()/obj2->dc()), CoordinateUnits::_radians_, m_angularUnits)));
292 
293  wkk = obj1->weight()*obj2->weight()*angWeight;
294  }
295 }
296 
297 
298 // ============================================================================================
299 
300 
301 void cbl::pairs::Pair1D_comoving_log::get (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2, int &kk, double &wkk)
302 {
303  kk = -1;
304  wkk = 0;
305 
306  const double dist = Euclidean_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz());
307 
308  if (m_rMin < dist && dist < m_rMax) {
309  kk = max(0, min(int((log10(dist)-log10(m_rMin))*m_binSize_inv), m_nbins));
310 
311  const double angWeight = (m_angularWeight==nullptr) ? 1.
312  : max(0., m_angularWeight(converted_angle(angular_distance(obj1->xx()/obj1->dc(), obj2->xx()/obj2->dc(), obj1->yy()/obj1->dc(), obj2->yy()/obj2->dc(), obj1->zz()/obj1->dc(), obj2->zz()/obj2->dc()), CoordinateUnits::_radians_, m_angularUnits)));
313 
314  wkk = obj1->weight()*obj2->weight()*angWeight;
315  }
316 }
317 
318 
319 // ============================================================================================
320 
321 
322 void cbl::pairs::Pair1D_comoving_multipoles_lin::get (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2, int &kk, double &cosmu, double &wkk)
323 {
324  kk = -1;
325  wkk = 0;
326 
327  const double dist = Euclidean_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz());
328 
329  if (m_rMin < dist && dist < m_rMax) {
330  kk = max(0, min(int((dist-m_rMin)*m_binSize_inv), m_nbins));
331 
332  const double angWeight = (m_angularWeight==nullptr) ? 1.
333  : max(0., m_angularWeight(converted_angle(angular_distance(obj1->xx()/obj1->dc(), obj2->xx()/obj2->dc(), obj1->yy()/obj1->dc(), obj2->yy()/obj2->dc(), obj1->zz()/obj1->dc(), obj2->zz()/obj2->dc()), CoordinateUnits::_radians_, m_angularUnits)));
334 
335  wkk = obj1->weight()*obj2->weight()*angWeight;
336 
337  cosmu = (obj2->dc()-obj1->dc())/dist;
338  }
339 }
340 
341 
342 // ============================================================================================
343 
344 
345 void cbl::pairs::Pair1D_comoving_multipoles_log::get (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2, int &kk, double &cosmu, double &wkk)
346 {
347  kk = -1;
348  wkk = 0;
349 
350  const double dist = Euclidean_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz());
351 
352  if (m_rMin < dist && dist < m_rMax) {
353  kk = max(0, min(int((log10(dist)-log10(m_rMin))*m_binSize_inv), m_nbins));
354 
355  const double angWeight = (m_angularWeight==nullptr) ? 1.
356  : max(0., m_angularWeight(converted_angle(angular_distance(obj1->xx()/obj1->dc(), obj2->xx()/obj2->dc(), obj1->yy()/obj1->dc(), obj2->yy()/obj2->dc(), obj1->zz()/obj1->dc(), obj2->zz()/obj2->dc()), CoordinateUnits::_radians_, m_angularUnits)));
357 
358  wkk = obj1->weight()*obj2->weight()*angWeight;
359 
360  cosmu = (obj2->dc()-obj1->dc())/dist;
361  }
362 }
363 
364 // ============================================================================================
365 
366 
367 void cbl::pairs::Pair1D_angular_lin::set (const int kk, const double wkk, const double weight)
368 {
369  if (kk>-1) {
370  m_PP1D[kk] += weight;
371  m_PP1D_weighted[kk] += wkk*weight;
372  }
373 }
374 
375 
376 // ============================================================================================
377 
378 
379 void cbl::pairs::Pair1D_angular_log::set (const int kk, const double wkk, const double weight)
380 {
381  if (kk>-1) {
382  m_PP1D[kk] += weight;
383  m_PP1D_weighted[kk] += wkk*weight;
384  }
385 }
386 
387 
388 // ============================================================================================
389 
390 
391 void cbl::pairs::Pair1D_comoving_lin::set (const int kk, const double wkk, const double weight)
392 {
393  if (kk>-1) {
394  m_PP1D[kk] += weight;
395  m_PP1D_weighted[kk] += wkk*weight;
396  }
397 }
398 
399 
400 // ============================================================================================
401 
402 
403 void cbl::pairs::Pair1D_comoving_log::set (const int kk, const double wkk, const double weight)
404 {
405  if (kk>-1) {
406  m_PP1D[kk] += weight;
407  m_PP1D_weighted[kk] += wkk*weight;
408  }
409 }
410 
411 
412 // ============================================================================================
413 
414 
415 void cbl::pairs::Pair1D_comoving_multipoles_lin::set (const double cosmu, const int kk, const double wkk, const double weight)
416 {
417  if (kk>-1) {
418  double cosmu2 = cosmu*cosmu;
419  m_PP1D[kk] += weight;
420  m_PP1D_weighted[kk] += wkk*weight;
421 
422  double leg_pol_2 = 0.5*(3.*cosmu2-1);
423  m_PP1D[(m_nbins+1)+kk] += 5.*leg_pol_2*weight ;
424  m_PP1D_weighted[(m_nbins+1)+kk] += 5.*wkk*leg_pol_2*weight;
425 
426  double leg_pol_4 = 0.125*(35.*cosmu2*cosmu2-30.*cosmu2+3.);
427  m_PP1D[2.*(m_nbins+1)+kk] += 9.*leg_pol_4*weight;
428  m_PP1D_weighted[2.*(m_nbins+1)+kk] += 9.*wkk*leg_pol_4*weight;
429  }
430 }
431 
432 
433 // ============================================================================================
434 
435 
436 void cbl::pairs::Pair1D_comoving_multipoles_log::set (const double cosmu, const int kk, const double wkk, const double weight)
437 {
438  if (kk>-1) {
439  double cosmu2 = cosmu*cosmu;
440  m_PP1D[kk] += weight;
441  m_PP1D_weighted[kk] += wkk*weight;
442 
443  double leg_pol_2 = 0.5*(3.*cosmu2-1);
444  m_PP1D[(m_nbins+1)+kk] += 5.*leg_pol_2*weight ;
445  m_PP1D_weighted[(m_nbins+1)+kk] += 5.*wkk*leg_pol_2*weight;
446 
447  double leg_pol_4 = 0.125*(35.*cosmu2*cosmu2-30.*cosmu2+3.);
448  m_PP1D[2.*(m_nbins+1)+kk] += 9.*leg_pol_4*weight;
449  m_PP1D_weighted[2.*(m_nbins+1)+kk] += 9.*wkk*leg_pol_4*weight;
450  }
451 }
452 
453 // ============================================================================================
454 
455 
456 void cbl::pairs::Pair1D_angular_lin::put (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2)
457 {
458  const double dist = (m_angularUnits==CoordinateUnits::_radians_) ? angular_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz())
459  : converted_angle(angular_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz()), CoordinateUnits::_radians_, m_angularUnits);
460 
461  if (m_thetaMin < dist && dist < m_thetaMax) {
462 
463  const int kk = max(0, min(int((dist-m_thetaMin)*m_binSize_inv), m_nbins));
464 
465  m_PP1D[kk] ++;
466  m_PP1D_weighted[kk] += obj1->weight()*obj2->weight();
467 
468  }
469 }
470 
471 
472 // ============================================================================================
473 
474 
475 void cbl::pairs::Pair1D_angular_log::put (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2)
476 {
477  const double dist = (m_angularUnits==CoordinateUnits::_radians_) ? angular_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz())
478  : converted_angle(angular_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz()), CoordinateUnits::_radians_, m_angularUnits);
479 
480  if (m_thetaMin < dist && dist < m_thetaMax) {
481 
482  const int kk = max(0, min(int((log10(dist)-log10(m_thetaMin))*m_binSize_inv), m_nbins));
483 
484  m_PP1D[kk] ++;
485  m_PP1D_weighted[kk] += obj1->weight()*obj2->weight();
486 
487  }
488 }
489 
490 
491 // ============================================================================================
492 
493 
494 void cbl::pairs::Pair1D_comoving_lin::put (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2)
495 {
496  const double dist = Euclidean_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz());
497 
498  if (m_rMin < dist && dist < m_rMax) {
499 
500  const int kk = max(0, min(int((dist-m_rMin)*m_binSize_inv), m_nbins));
501 
502  const double angWeight = (m_angularWeight==nullptr) ? 1.
503  : max(0., m_angularWeight(converted_angle(angular_distance(obj1->xx()/obj1->dc(), obj2->xx()/obj2->dc(), obj1->yy()/obj1->dc(), obj2->yy()/obj2->dc(), obj1->zz()/obj1->dc(), obj2->zz()/obj2->dc()), CoordinateUnits::_radians_, m_angularUnits)));
504 
505  m_PP1D[kk] ++;
506  m_PP1D_weighted[kk] += obj1->weight()*obj2->weight()*angWeight;
507 
508  }
509 }
510 
511 
512 // ============================================================================================
513 
514 
515 void cbl::pairs::Pair1D_comoving_log::put (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2)
516 {
517  const double dist = Euclidean_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz());
518 
519  if (m_rMin < dist && dist < m_rMax) {
520 
521  const int kk = max(0, min(int((log10(dist)-log10(m_rMin))*m_binSize_inv), m_nbins));
522 
523  const double angWeight = (m_angularWeight==nullptr) ? 1.
524  : max(0., m_angularWeight(converted_angle(angular_distance(obj1->xx()/obj1->dc(), obj2->xx()/obj2->dc(), obj1->yy()/obj1->dc(), obj2->yy()/obj2->dc(), obj1->zz()/obj1->dc(), obj2->zz()/obj2->dc()), CoordinateUnits::_radians_, m_angularUnits)));
525 
526  m_PP1D[kk] ++;
527  m_PP1D_weighted[kk] += obj1->weight()*obj2->weight()*angWeight;
528 
529  }
530 }
531 
532 
533 // ============================================================================================
534 
535 
536 void cbl::pairs::Pair1D_comoving_multipoles_lin::put (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2)
537 {
538  const double dist = Euclidean_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz());
539 
540  if (m_rMin < dist && dist < m_rMax) {
541 
542  const int kk = max(0, min(int((dist-m_rMin)*m_binSize_inv), m_nbins));
543 
544  const double angWeight = (m_angularWeight==nullptr) ? 1.
545  : max(0., m_angularWeight(converted_angle(angular_distance(obj1->xx()/obj1->dc(), obj2->xx()/obj2->dc(), obj1->yy()/obj1->dc(), obj2->yy()/obj2->dc(), obj1->zz()/obj1->dc(), obj2->zz()/obj2->dc()), CoordinateUnits::_radians_, m_angularUnits)));
546 
547  const double ww = obj1->weight()*obj2->weight()*angWeight;
548  double cosmu2 = pow((obj2->dc()-obj1->dc())/dist, 2);
549 
550  m_PP1D[kk] += 1.;
551  m_PP1D_weighted[kk] += ww;
552 
553  double leg_pol_2 = 0.5*(3.*cosmu2-1.);
554  m_PP1D[(m_nbins+1)+kk] += 5.*leg_pol_2 ;
555  m_PP1D_weighted[(m_nbins+1)+kk] += 5.*ww*leg_pol_2;
556 
557  double leg_pol_4 = 0.125*(35.*cosmu2*cosmu2-30.*cosmu2+3.);
558  m_PP1D[2.*(m_nbins+1)+kk] += 9.*leg_pol_4;
559  m_PP1D_weighted[2.*(m_nbins+1)+kk] += 9.*ww*leg_pol_4;
560 
561 
562  }
563 }
564 
565 
566 // ============================================================================================
567 
568 
569 void cbl::pairs::Pair1D_comoving_multipoles_log::put (const shared_ptr<Object> obj1, const shared_ptr<Object> obj2)
570 {
571  const double dist = Euclidean_distance(obj1->xx(), obj2->xx(), obj1->yy(), obj2->yy(), obj1->zz(), obj2->zz());
572 
573  if (m_rMin < dist && dist < m_rMax) {
574 
575  const int kk = max(0, min(int((log10(dist)-log10(m_rMin))*m_binSize_inv), m_nbins));
576 
577  const double angWeight = (m_angularWeight==nullptr) ? 1.
578  : max(0., m_angularWeight(converted_angle(angular_distance(obj1->xx()/obj1->dc(), obj2->xx()/obj2->dc(), obj1->yy()/obj1->dc(), obj2->yy()/obj2->dc(), obj1->zz()/obj1->dc(), obj2->zz()/obj2->dc()), CoordinateUnits::_radians_, m_angularUnits)));
579 
580  const double ww = obj1->weight()*obj2->weight()*angWeight;
581  double cosmu2 = pow((obj2->dc()-obj1->dc())/dist, 2);
582 
583  m_PP1D[kk] += 1.;
584  m_PP1D_weighted[kk] += ww;
585 
586  double leg_pol_2 = 0.5*(3.*cosmu2-1);
587  m_PP1D[(m_nbins+1)+kk] += 5.*leg_pol_2 ;
588  m_PP1D_weighted[(m_nbins+1)+kk] += 5.*ww*leg_pol_2;
589 
590  double leg_pol_4 = 0.125*(35.*cosmu2*cosmu2-30.*cosmu2+3.);
591  m_PP1D[2.*(m_nbins+1)+kk] += 9.*leg_pol_4;
592  m_PP1D_weighted[2.*(m_nbins+1)+kk] += 9.*ww*leg_pol_4;
593 
594  }
595 }
596 
597 
598 // ============================================================================================
599 
600 
601 void cbl::pairs::Pair1D::add_data1D (const int i, const std::vector<double> data)
602 {
603  m_PP1D[i] += data[0];
604  m_PP1D_weighted[i] += data[1];
605 }
606 
607 
608 // ============================================================================================
609 
610 
611 void cbl::pairs::Pair1D::add_data1D (const int i, const std::shared_ptr<pairs::Pair> pair, const double ww)
612 {
613  add_data1D(i, {ww*pair->PP1D(i), ww*pair->PP1D_weighted(i)});
614 }
615 
616 
617 // ============================================================================================
618 
619 
620 void cbl::pairs::Pair1D::Sum (const std::shared_ptr<Pair> pair, const double ww)
621 {
622  if (m_nbins != pair->nbins())
623  ErrorCBL("dimension problems!", "Sum", "Pair1D.cpp");
624 
625  for (int i=0; i<m_nbins; ++i)
626  add_data1D(i, pair, ww);
627 }
628 
629 
630 // ============================================================================================
631 
632 
633 void cbl::pairs::Pair1D_comoving_multipoles_lin::Sum (const std::shared_ptr<Pair> pair, const double ww)
634 {
635  if (m_nbins != pair->nbins())
636  ErrorCBL("dimension problems!", "Sum", "Pair1D.cpp");
637 
638  for (int l=0; l<3; ++l)
639  for (int i=0; i<m_nbins; ++i)
640  add_data1D(l*(m_nbins+1)+i, pair, ww);
641 }
642 
643 
644 // ============================================================================================
645 
646 
647 void cbl::pairs::Pair1D_comoving_multipoles_log::Sum (const std::shared_ptr<Pair> pair, const double ww)
648 {
649  if (m_nbins != pair->nbins())
650  ErrorCBL("dimension problems!", "Sum", "Pair1D.cpp");
651 
652  for (int l=0; l<3; ++l)
653  for (int i=0; i<m_nbins; ++i)
654  add_data1D(l*(m_nbins+1)+i, pair, ww);
655 }
The classes Pair1D*.
void m_set_parameters_nbins() override
set the binning parameters given the number of bins
Definition: Pair1D.cpp:58
void put(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2) override
estimate the distance between two objects and update the pair vector accordingly
Definition: Pair1D.cpp:456
void set(const int kk, const double wkk, const double weight=1) override
set the pair vector
Definition: Pair1D.cpp:367
void m_set_parameters_binSize() override
set the binning parameters given the bin size
Definition: Pair1D.cpp:72
void get(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2, int &kk, double &wkk) override
get the pair index and weight
Definition: Pair1D.cpp:242
void set(const int kk, const double wkk, const double weight=1) override
set the pair vector
Definition: Pair1D.cpp:379
void put(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2) override
estimate the distance between two objects and update the pair vector accordingly
Definition: Pair1D.cpp:475
void get(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2, int &kk, double &wkk) override
get the pair index and weight
Definition: Pair1D.cpp:261
void m_set_parameters_nbins() override
set the binning parameters given the number of bins
Definition: Pair1D.cpp:86
void m_set_parameters_binSize() override
set the binning parameters given the bin size
Definition: Pair1D.cpp:102
void set(const int kk, const double wkk, const double weight=1) override
set the pair vector
Definition: Pair1D.cpp:391
void get(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2, int &kk, double &wkk) override
get the pair index and weight
Definition: Pair1D.cpp:280
void m_set_parameters_nbins() override
set the binning parameters given the number of bins
Definition: Pair1D.cpp:118
void put(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2) override
estimate the distance between two objects and update the pair vector accordingly
Definition: Pair1D.cpp:494
void m_set_parameters_binSize() override
set the binning parameters given the bin size
Definition: Pair1D.cpp:132
void get(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2, int &kk, double &wkk) override
get the pair index and weight
Definition: Pair1D.cpp:301
void m_set_parameters_nbins() override
set the binning parameters given the number of bins
Definition: Pair1D.cpp:146
void set(const int kk, const double wkk, const double weight=1) override
set the pair vector
Definition: Pair1D.cpp:403
void m_set_parameters_binSize() override
set the binning parameters given the bin size
Definition: Pair1D.cpp:162
void put(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2) override
estimate the distance between two objects and update the pair vector accordingly
Definition: Pair1D.cpp:515
void m_set_parameters_nbins() override
set the binning parameters given the number of bins
Definition: Pair1D.cpp:178
void set(const double cosmu, const int kk, const double wkk, const double weight=1) override
set the pair vector
Definition: Pair1D.cpp:415
void put(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2) override
estimate the distance between two objects and update the pair vector accordingly
Definition: Pair1D.cpp:536
void get(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2, int &kk, double &cosmu, double &wkk) override
get the pair index and weight
Definition: Pair1D.cpp:322
virtual void Sum(const std::shared_ptr< Pair > pair, const double ww=1) override
sum the number of binned pairs
Definition: Pair1D.cpp:633
void m_set_parameters_binSize() override
set the binning parameters given the bin size
Definition: Pair1D.cpp:193
void put(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2) override
estimate the distance between two objects and update the pair vector accordingly
Definition: Pair1D.cpp:569
void m_set_parameters_binSize() override
set the binning parameters given the bin size
Definition: Pair1D.cpp:225
virtual void Sum(const std::shared_ptr< Pair > pair, const double ww=1) override
sum the number of binned pairs
Definition: Pair1D.cpp:647
void set(const double cosmu, const int kk, const double wkk, const double weight=1) override
set the pair vector
Definition: Pair1D.cpp:436
void get(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2, int &kk, double &cosmu, double &wkk) override
get the pair index and weight
Definition: Pair1D.cpp:345
void m_set_parameters_nbins() override
set the binning parameters given the number of bins
Definition: Pair1D.cpp:208
virtual void Sum(const std::shared_ptr< Pair > pair, const double ww=1) override
sum the number of binned pairs
Definition: Pair1D.cpp:620
void add_data1D(const int i, const std::vector< double > data) override
set the protected member by adding new data
Definition: Pair1D.cpp:601
void reset() override
reset the pair counts
Definition: Pair1D.cpp:46
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38
double Euclidean_distance(const double x1, const double x2, const double y1, const double y2, const double z1, const double z2)
the Euclidean distance in 3D relative to the origin (0,0,0), i.e. the Euclidean norm
Definition: Func.cpp:250
double converted_angle(const double angle, const CoordinateUnits inputUnits=CoordinateUnits::_radians_, const CoordinateUnits outputUnits=CoordinateUnits::_degrees_)
conversion to angle units
Definition: Func.cpp:192
double angular_distance(const double x1, const double x2, const double y1, const double y2, const double z1, const double z2)
the angular separation in 3D
Definition: Func.cpp:277
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
int nint(const T val)
the nearest integer
Definition: Kernel.h:915