CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
Triplet.h
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2015 by Michele Moresco, Federico Marulli *
3  * and Alfonso Veropalumbo *
4  * *
5  * federico.marulli3@unibo.it *
6  * *
7  * This program is free software; you can redistribute it and/or *
8  * modify it under the terms of the GNU General Public License as *
9  * published by the Free Software Foundation; either version 2 of *
10  * the License, or (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public *
18  * License along with this program; if not, write to the Free *
19  * Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  *******************************************************************/
22 
37 #ifndef __TRIPLET__
38 #define __TRIPLET__
39 
40 
41 #include "Catalogue.h"
42 
43 
44 // ===================================================================================================
45 
46 
47 namespace cbl {
48 
56  namespace triplets {
57 
62  enum class TripletType {
63 
66 
69 
72 
75 
76  };
77 
84  inline std::vector<std::string> TripletTypeNames ()
85  { return {"comoving_theta", "comoving_side", "comoving_costheta", "multipoles_direct"}; }
86 
93  inline TripletType TripletTypeCast (const int tripletPTypeIndex)
94  { return castFromValue<TripletType>(tripletPTypeIndex); }
95 
102  inline TripletType TripletTypeCast (const std::string tripletPTypeName)
103  { return castFromName<TripletType>(tripletPTypeName, TripletTypeNames()); }
104 
111  inline std::vector<TripletType> TripletTypeCast (const std::vector<int> tripletPTypeIndeces)
112  { return castFromValues<TripletType>(tripletPTypeIndeces); }
113 
120  inline std::vector<TripletType> TripletTypeCast (const std::vector<std::string> tripletPTypeNames)
121  { return castFromNames<TripletType>(tripletPTypeNames, TripletTypeNames()); }
122 
123 
133  class Triplet {
134 
135  private:
136 
142 
146  virtual void set_parameters () = 0;
147 
149 
150 
151  protected:
152 
155 
158 
159 
160  public:
161 
166 
171  virtual ~Triplet () {}
172 
185  static std::shared_ptr<Triplet> Create (const TripletType type, const double r12, const double r12_binSize, const double r13, const double r13_binSize, const int nbins);
186 
188 
189 
194 
199  Dim tripletDim () const
200  { return m_tripletDim; }
201 
207  { return m_tripletType; }
208 
214  virtual double scale (const int i) const
215  { (void)i; cbl::ErrorCBL("", "scale", "Triplet.h"); return 0; }
216 
221  virtual std::vector<double> scale () const
222  { cbl::ErrorCBL("", "scale", "Triplet.h"); std::vector<double> vv; return vv; }
223 
230  virtual double TT1D (const int i) const { (void)i; cbl::ErrorCBL("", "TT1D", "Triplet.h"); return 0; }
231 
238  virtual std::vector<double> TT1D () const { cbl::ErrorCBL("", "TT1D", "Triplet.h"); std::vector<double> vv; return vv; }
239 
245  virtual double scale_D1 (const int i) const { (void)i; cbl::ErrorCBL("", "scale_D1", "Triplet.h"); return 0; }
246 
251  virtual std::vector<double> scale_D1 () const { cbl::ErrorCBL("", "scale_D1", "Triplet.h"); std::vector<double> vv; return vv; }
252 
258  virtual double scale_D2 (const int i) const { (void)i; cbl::ErrorCBL("", "scale_D2", "Triplet.h"); return 0; }
259 
264  virtual std::vector<double> scale_D2 () const { cbl::ErrorCBL("", "scale_D2", "Triplet.h"); std::vector<double> vv; return vv; }
265 
272  virtual double TT2D (const int i, const int j) const { (void)i; (void)j; cbl::ErrorCBL("", "TT2D", "Triplet.h"); return 0; }
273 
278  virtual std::vector<std::vector<double> > TT2D () const { cbl::ErrorCBL("", "TT2D", "Triplet.h"); std::vector<std::vector<double> > vv; return vv; }
279 
285  virtual double r12 () const { cbl::ErrorCBL("", "r12", "Triplet.h"); return 0; }
286 
292  virtual double r12_binSize () const { cbl::ErrorCBL("", "r12_binSize", "Triplet.h"); return 0; }
293 
299  virtual double r13 () const { cbl::ErrorCBL("", "r13", "Triplet.h"); return 0; }
300 
306  virtual double r13_binSize () const { cbl::ErrorCBL("", "r13_binSize", "Triplet.h"); return 0; }
307 
313  virtual int nbins () const { cbl::ErrorCBL("", "nbins", "Triplet.h"); return 0; }
314 
320  virtual double binSize () const { cbl::ErrorCBL("", "binSize", "Triplet.h"); return 0; }
321 
328  virtual double r12_D1 () const { cbl::ErrorCBL("", "r12_D1", "Triplet.h"); return 0; }
329 
336  virtual double r12_binSize_D1 () const { cbl::ErrorCBL("", "r12_binSize_D1", "Triplet.h"); return 0; }
337 
344  virtual double r13_D1 () const { cbl::ErrorCBL("", "r13_D1", "Triplet.h"); return 0; }
345 
352  virtual double r13_binSize_D1 () const { cbl::ErrorCBL("", "r13_binSize_D1", "Triplet.h"); return 0; }
353 
360  virtual int nbins_D1 () const { cbl::ErrorCBL("", "nbins_D1", "Triplet.h"); return 0; }
361 
368  virtual double binSize_D1 () const { cbl::ErrorCBL("", "binSize_D1", "Triplet.h"); return 0; }
369 
376  virtual double r12_D2 () const { cbl::ErrorCBL("", "r12_D2", "Triplet.h"); return 0; }
377 
384  virtual double r12_binSize_D2 () const { cbl::ErrorCBL("", "r12_binSize_D2", "Triplet.h"); return 0; }
385 
392  virtual double r13_D2 () const { cbl::ErrorCBL("", "r13_D2", "Triplet.h"); return 0; }
393 
400  virtual double r13_binSize_D2 () const { cbl::ErrorCBL("", "r13_binSize_D2", "Triplet.h"); return 0; }
401 
408  virtual int nbins_D2 () const { cbl::ErrorCBL("", "nbins_D2", "Triplet.h"); return 0; }
409 
416  virtual double binSize_D2 () const { cbl::ErrorCBL("", "binSize_D2", "Triplet.h"); return 0; }
417 
419 
420 
425 
431  virtual void set_TT1D (const int i, const double tt)
432  { (void)i; (void)tt; cbl::ErrorCBL("", "set_TT1D", "Triplet.h"); }
433 
440  virtual void add_TT1D (const int i, const double tt)
441  { (void)i; (void)tt; cbl::ErrorCBL("", "add_TT1D", "Triplet.h"); }
442 
444 
445 
450 
459  virtual void get_triplet (const double r12, const double r13, const double r23, int &klin) = 0;
460 
466  virtual void set_triplet (const int klin, const double ww=1.) = 0;
467 
476  virtual void put (const double r12, const double r13, const double r23, const double ww=1.) = 0;
477 
485  virtual void put (const std::shared_ptr<catalogue::Object> obj1, const std::shared_ptr<catalogue::Object> obj2, const std::shared_ptr<catalogue::Object> obj3) = 0;
486 
492  virtual void Sum (const std::shared_ptr<Triplet> tt, const double ww=1.) = 0;
493 
495 
496  };
497  }
498 }
499 
500 #endif
The class Catalogue
The class Triplet.
Definition: Triplet.h:133
Dim m_tripletDim
the dimension of the triplet vectors
Definition: Triplet.h:154
virtual double r12_D1() const
get the protected member Triplet1D::m_r12_D1
Definition: Triplet.h:328
virtual double r12_D2() const
get the protected member Triplet1D::m_r12_D1
Definition: Triplet.h:376
virtual double r12() const
get the private member m_r12
Definition: Triplet.h:285
virtual double r13_binSize_D2() const
get the protected member Triplet1D::m_r13_binSize_D2
Definition: Triplet.h:400
virtual double r13_D1() const
get the protected member Triplet1D::m_r13_D1
Definition: Triplet.h:344
virtual void set_TT1D(const int i, const double tt)
set the member m_TT1D[i]
Definition: Triplet.h:431
virtual double binSize_D1() const
get the protected member Triplet1D::m_binSize_D1
Definition: Triplet.h:368
virtual std::vector< double > TT1D() const
get the private member m_TT1D
Definition: Triplet.h:238
TripletType tripletType() const
get the triplet type
Definition: Triplet.h:206
virtual double r12_binSize_D2() const
get the protected member Triplet1D::m_r12_binSize_D1
Definition: Triplet.h:384
virtual std::vector< double > scale_D1() const
get the protected member m_scale_D1
Definition: Triplet.h:251
virtual double scale_D1(const int i) const
get the protected member m_scale_D1[i]
Definition: Triplet.h:245
virtual void set_triplet(const int klin, const double ww=1.)=0
update the triplet
virtual double r13_D2() const
get the protected member Triplet1D::m_r13_D2
Definition: Triplet.h:392
virtual double r12_binSize() const
get the private member m_r12
Definition: Triplet.h:292
virtual void Sum(const std::shared_ptr< Triplet > tt, const double ww=1.)=0
sum the number of triplets
virtual double scale_D2(const int i) const
get the protected member m_scale_D2[i]
Definition: Triplet.h:258
virtual void add_TT1D(const int i, const double tt)
set the protected member Triplet1D::m_TT1D[i] adding the number of triplets
Definition: Triplet.h:440
TripletType m_tripletType
triplet type
Definition: Triplet.h:157
virtual double r13_binSize_D1() const
get the protected member Triplet1D::m_r13_binSize_D1
Definition: Triplet.h:352
virtual double TT2D(const int i, const int j) const
get the protected member m_TT2D[i]
Definition: Triplet.h:272
Dim tripletDim() const
get the dimension of the triplet vectors
Definition: Triplet.h:199
virtual double binSize_D2() const
get the protected member Triplet1D::m_binSize_D2
Definition: Triplet.h:416
virtual std::vector< double > scale_D2() const
get the protected member m_scale_D2
Definition: Triplet.h:264
virtual int nbins_D2() const
get the protected member Triplet1D::m_nbins_D2
Definition: Triplet.h:408
virtual void set_parameters()=0
set the binning parameters
virtual double scale(const int i) const
get the protected member m_scale[i]
Definition: Triplet.h:214
virtual void get_triplet(const double r12, const double r13, const double r23, int &klin)=0
estimate the distance between two objects and update the triplet vectors accordingly
virtual int nbins() const
get the private member m_nbins
Definition: Triplet.h:313
virtual double r12_binSize_D1() const
get the protected member Triplet1D::m_r12_binSize_D1
Definition: Triplet.h:336
virtual double binSize() const
get the private member m_binSize
Definition: Triplet.h:320
virtual void put(const std::shared_ptr< catalogue::Object > obj1, const std::shared_ptr< catalogue::Object > obj2, const std::shared_ptr< catalogue::Object > obj3)=0
estimate the distance between three objects and update the triplet vectors accordingly
virtual double TT1D(const int i) const
get the private member m_TT1D[i]
Definition: Triplet.h:230
static std::shared_ptr< Triplet > Create(const TripletType type, const double r12, const double r12_binSize, const double r13, const double r13_binSize, const int nbins)
static factory used to construct triplets of any type
Definition: Triplet.cpp:51
virtual double r13_binSize() const
get the private member m_side_u
Definition: Triplet.h:306
virtual std::vector< std::vector< double > > TT2D() const
get the protected member m_TT2D
Definition: Triplet.h:278
virtual int nbins_D1() const
get the protected member Triplet1D::m_nbins_D1
Definition: Triplet.h:360
virtual std::vector< double > scale() const
get the protected member m_scale
Definition: Triplet.h:221
virtual ~Triplet()
default destructor
Definition: Triplet.h:171
virtual void put(const double r12, const double r13, const double r23, const double ww=1.)=0
estimate the distance between two objects and update the triplet vectors accordingly
virtual double r13() const
get the private member m_side_u
Definition: Triplet.h:299
TripletType TripletTypeCast(const int tripletPTypeIndex)
cast an enum of type TripletType from its index
Definition: Triplet.h:93
std::vector< std::string > TripletTypeNames()
return a vector containing the TripletType names
Definition: Triplet.h:84
TripletType
the triplet type
Definition: Triplet.h:62
@ _comoving_side_
1D triplet in comoving coordinates and linear bins
@ _comoving_costheta_
1D triplet in comoving coordinates and linear bins of the cosine of theta
@ _comoving_theta_
1D triplet in comoving coordinates and angular bins
@ _multipoles_direct_
multipoles of the triplets
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
Dim
the dimension, used e.g. for pair and triplet vectors
Definition: Kernel.h:483