CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
Object.cpp
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2015 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 #include "Catalogue.h"
36 
37 using namespace std;
38 
39 using namespace cbl;
40 using namespace catalogue;
41 
42 
43 // ============================================================================
44 
45 
46 std::shared_ptr<Object> cbl::catalogue::Object::Create (const ObjectType objType)
47 {
48  if (objType==ObjectType::_Random_) return move(unique_ptr<RandomObject>(new RandomObject()));
49  else if (objType==ObjectType::_Mock_) return move(unique_ptr<Mock>(new Mock()));
50  else if (objType==ObjectType::_Halo_) return move(unique_ptr<Halo>(new Halo()));
51  else if (objType==ObjectType::_Galaxy_) return move(unique_ptr<Galaxy>(new Galaxy()));
52  else if (objType==ObjectType::_Cluster_) return move(unique_ptr<Cluster>(new Cluster()));
53  else if (objType==ObjectType::_Void_) return move(unique_ptr<Void>(new Void()));
54  else if (objType==ObjectType::_HostHalo_) return move(unique_ptr<HostHalo>(new HostHalo()));
55  else if (objType==ObjectType::_ChainMeshCell_) return move(unique_ptr<ChainMeshCell>(new ChainMeshCell()));
56  else ErrorCBL("no such type of object!", "Create", "Object.cpp");
57  return NULL;
58 }
59 
60 
61 // ============================================================================
62 
63 
64 std::shared_ptr<Object> cbl::catalogue::Object::Create (const ObjectType objType, const comovingCoordinates coord, const double weight, const long region, const int ID, const std::string field, const double x_displacement, const double y_displacement, const double z_displacement)
65 {
66  if (objType==ObjectType::_Random_) return move(unique_ptr<RandomObject>(new RandomObject(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
67  else if (objType==ObjectType::_Mock_) return move(unique_ptr<Mock>(new Mock(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
68  else if (objType==ObjectType::_Halo_) return move(unique_ptr<Halo>(new Halo(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
69  else if (objType==ObjectType::_Galaxy_) return move(unique_ptr<Galaxy>(new Galaxy(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
70  else if (objType==ObjectType::_Cluster_) return move(unique_ptr<Cluster>(new Cluster(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
71  else if (objType==ObjectType::_Void_) return move(unique_ptr<Void>(new Void(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
72  else if (objType==ObjectType::_HostHalo_) return move(unique_ptr<HostHalo>(new HostHalo(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
73  else ErrorCBL("no such type of object!", "Create", "Object.cpp");
74  return NULL;
75 }
76 
77 
78 // ============================================================================
79 
80 
81 std::shared_ptr<Object> cbl::catalogue::Object::Create (const ObjectType objType, const comovingCoordinates coord, const cosmology::Cosmology &cosm, const double z1_guess, const double z2_guess, const double weight, const long region, const int ID, const std::string field, const double x_displacement, const double y_displacement, const double z_displacement)
82 {
83  if (objType==ObjectType::_Random_) return move(unique_ptr<RandomObject>(new RandomObject(coord, cosm, z1_guess, z2_guess, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
84  else if (objType==ObjectType::_Mock_) return move(unique_ptr<Mock>(new Mock(coord, cosm, z1_guess, z2_guess, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
85  else if (objType==ObjectType::_Halo_) return move(unique_ptr<Halo>(new Halo(coord, cosm, z1_guess, z2_guess, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
86  else if (objType==ObjectType::_Galaxy_) return move(unique_ptr<Galaxy>(new Galaxy(coord, cosm, z1_guess, z2_guess, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
87  else if (objType==ObjectType::_Cluster_) return move(unique_ptr<Cluster>(new Cluster(coord, cosm, z1_guess, z2_guess, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
88  else if (objType==ObjectType::_Void_) return move(unique_ptr<Void>(new Void(coord, cosm, z1_guess, z2_guess, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
89  else if (objType==ObjectType::_HostHalo_) return move(unique_ptr<HostHalo>(new HostHalo(coord, cosm, z1_guess, z2_guess, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
90  else ErrorCBL("no such type of object!", "Create", "Object.cpp");
91  return NULL;
92 }
93 
94 // ============================================================================
95 
96 
97 std::shared_ptr<Object> cbl::catalogue::Object::Create (const ObjectType objType, const observedCoordinates coord, const double weight, const long region, const int ID, const std::string field, const double x_displacement, const double y_displacement, const double z_displacement)
98 {
99  if (objType==ObjectType::_Random_) return move(unique_ptr<RandomObject>(new RandomObject(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
100  else if (objType==ObjectType::_Mock_) return move(unique_ptr<Mock>(new Mock(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
101  else if (objType==ObjectType::_Halo_) return move(unique_ptr<Halo>(new Halo(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
102  else if (objType==ObjectType::_Galaxy_) return move(unique_ptr<Galaxy>(new Galaxy(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
103  else if (objType==ObjectType::_Cluster_) return move(unique_ptr<Cluster>(new Cluster(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
104  else if (objType==ObjectType::_Void_) return move(unique_ptr<Void>(new Void(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
105  else if (objType==ObjectType::_HostHalo_) return move(unique_ptr<HostHalo>(new HostHalo(coord, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
106  else ErrorCBL("no such type of object!", "Create", "Object.cpp");
107  return NULL;
108 }
109 
110 // ============================================================================
111 
112 
113 std::shared_ptr<Object> cbl::catalogue::Object::Create (const ObjectType objType, const observedCoordinates coord, const CoordinateUnits inputUnits, const double weight, const long region, const int ID, const std::string field, const double x_displacement, const double y_displacement, const double z_displacement)
114 {
115  if (objType==ObjectType::_Random_) return move(unique_ptr<RandomObject>(new RandomObject(coord, inputUnits, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
116  else if (objType==ObjectType::_Mock_) return move(unique_ptr<Mock>(new Mock(coord, inputUnits, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
117  else if (objType==ObjectType::_Halo_) return move(unique_ptr<Halo>(new Halo(coord, inputUnits, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
118  else if (objType==ObjectType::_Galaxy_) return move(unique_ptr<Galaxy>(new Galaxy(coord, inputUnits, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
119  else if (objType==ObjectType::_Cluster_) return move(unique_ptr<Cluster>(new Cluster(coord, inputUnits, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
120  else if (objType==ObjectType::_Void_) return move(unique_ptr<Void>(new Void(coord, inputUnits, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
121  else if (objType==ObjectType::_HostHalo_) return move(unique_ptr<HostHalo>(new HostHalo(coord, inputUnits, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
122  else ErrorCBL("no such type of object!", "Create", "Object.cpp");
123  return NULL;
124 }
125 
126 // ============================================================================
127 
128 
129 std::shared_ptr<Object> cbl::catalogue::Object::Create (const ObjectType objType, const observedCoordinates coord, const cosmology::Cosmology &cosm, const double weight, const long region, const int ID, const std::string field, const double x_displacement, const double y_displacement, const double z_displacement)
130 {
131  if (objType==ObjectType::_Random_) return move(unique_ptr<RandomObject>(new RandomObject(coord, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
132  else if (objType==ObjectType::_Mock_) return move(unique_ptr<Mock>(new Mock(coord, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
133  else if (objType==ObjectType::_Halo_) return move(unique_ptr<Halo>(new Halo(coord, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
134  else if (objType==ObjectType::_Galaxy_) return move(unique_ptr<Galaxy>(new Galaxy(coord, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
135  else if (objType==ObjectType::_Cluster_) return move(unique_ptr<Cluster>(new Cluster(coord, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
136  else if (objType==ObjectType::_Void_) return move(unique_ptr<Void>(new Void(coord, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
137  else if (objType==ObjectType::_HostHalo_) return move(unique_ptr<HostHalo>(new HostHalo(coord, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
138  else ErrorCBL("no such type of object!", "Create", "Object.cpp");
139  return NULL;
140 }
141 
142 // ============================================================================
143 
144 
145 std::shared_ptr<Object> cbl::catalogue::Object::Create (const ObjectType objType, const observedCoordinates coord, const CoordinateUnits inputUnits, const cosmology::Cosmology &cosm, const double weight, const long region, const int ID, const std::string field, const double x_displacement, const double y_displacement, const double z_displacement)
146 {
147  if (objType==ObjectType::_Random_) return move(unique_ptr<RandomObject>(new RandomObject(coord, inputUnits, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
148  else if (objType==ObjectType::_Mock_) return move(unique_ptr<Mock>(new Mock(coord, inputUnits, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
149  else if (objType==ObjectType::_Halo_) return move(unique_ptr<Halo>(new Halo(coord, inputUnits, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
150  else if (objType==ObjectType::_Galaxy_) return move(unique_ptr<Galaxy>(new Galaxy(coord, inputUnits, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
151  else if (objType==ObjectType::_Cluster_) return move(unique_ptr<Cluster>(new Cluster(coord, inputUnits, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
152  else if (objType==ObjectType::_Void_) return move(unique_ptr<Void>(new Void(coord, inputUnits, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
153  else if (objType==ObjectType::_HostHalo_) return move(unique_ptr<HostHalo>(new HostHalo(coord, inputUnits, cosm, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
154  else ErrorCBL("no such type of object!", "Create", "Object.cpp");
155  return NULL;
156 }
157 
158 // ============================================================================
159 
160 
161 std::shared_ptr<Object> cbl::catalogue::Object::Create (const ObjectType objType, const double xx, const double yy, const double zz, const double ra, const double dec, const double redshift, const double weight, const long region, const int ID, const std::string field, const double x_displacement, const double y_displacement, const double z_displacement)
162 {
163  if (objType==ObjectType::_Random_) return move(unique_ptr<RandomObject>(new RandomObject(xx, yy, zz, ra, dec, redshift, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
164  else if (objType==ObjectType::_Mock_) return move(unique_ptr<Mock>(new Mock(xx, yy, zz, ra, dec, redshift, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
165  else if (objType==ObjectType::_Halo_) return move(unique_ptr<Halo>(new Halo(xx, yy, zz, ra, dec, redshift, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
166  else if (objType==ObjectType::_Galaxy_) return move(unique_ptr<Galaxy>(new Galaxy(xx, yy, zz, ra, dec, redshift, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
167  else if (objType==ObjectType::_Cluster_) return move(unique_ptr<Cluster>(new Cluster(xx, yy, zz, ra, dec, redshift, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
168  else if (objType==ObjectType::_Void_) return move(unique_ptr<Void>(new Void(xx, yy, zz, ra, dec, redshift, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
169  else if (objType==ObjectType::_HostHalo_) return move(unique_ptr<HostHalo>(new HostHalo(xx, yy, zz, ra, dec, redshift, weight, region, ID, field, x_displacement, y_displacement, z_displacement)));
170  else ErrorCBL("no such type of object!", "Create", "Object.cpp");
171  return NULL;
172 }
173 
174 // ============================================================================
175 std::shared_ptr<Object> cbl::catalogue::Object::Create (const int ID, const std::vector<unsigned int> part, std::vector<std::vector<unsigned int>> nearCells)
176 {
177  return move(unique_ptr<ChainMeshCell>(new ChainMeshCell(ID, part, nearCells)));
178 }
179 
180 
The class Catalogue
The class ChainMeshCell.
Definition: ChainMeshCell.h:53
The class Cluster.
Definition: Cluster.h:55
The class Galaxy.
Definition: Galaxy.h:54
The class CatalogueChainMesh.
Definition: Halo.h:53
The class HostHalo.
Definition: HostHalo.h:53
The class Mock.
Definition: Mock.h:53
static std::shared_ptr< Object > Create(const ObjectType ObjectType)
static factory used to construct objects of any type, providing in input comoving coordinates
Definition: Object.cpp:46
The class RandomObject.
Definition: RandomObject.h:55
The class Void.
Definition: Void.h:52
The class Cosmology.
Definition: Cosmology.h:277
ObjectType
the object types
Definition: Object.h:51
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
CoordinateUnits
the coordinate units
Definition: Kernel.h:562