42 : bbMin_m(3, -
std::numeric_limits<double>::
max()/10.),
43 bbMax_m(3,
std::numeric_limits<double>::
max()/10.),
44 polarBBMin_m(3, 0), polarBBMax_m(3, 0) {
55 double x =
std::sqrt(position[0]*position[0]+position[2]*position[2]);
56 double z =
std::atan2(position[2], position[0]);
62 double x = +value[0]*
std::cos(position[2])
64 double z = +value[2]*
std::cos(position[2])
71 double x = position[0]*
std::cos(position[2]);
72 double z = position[0]*
std::sin(position[2]);
78 double x = +value[0]*
std::cos(position[2])
80 double z = +value[2]*
std::cos(position[2])
87 (
double bbMinR,
double bbMinY,
double bbMinPhi,
88 double bbMaxR,
double bbMaxY,
double bbMaxPhi,
89 double bbTolR,
double bbTolY,
double bbTolPhi) {
90 if (bbMinR > bbMaxR) {
92 "SectorField::SetPolarBoundingBox",
93 "Bounding box minimum radius was greater than maximum radius"));
97 "SectorField::SetPolarBoundingBox",
98 "Bounding box radius must be positive"
101 if (bbMinY > bbMaxY) {
103 "SectorField::SetPolarBoundingBox",
104 "Bounding box minimum y was greater than maximum y"
107 if (bbMinPhi > bbMaxPhi) {
109 "SectorField::SetPolarBoundingBox",
110 "Bounding box minimum angle was greater than maximum angle"
113 if (bbMinPhi < -2.*M_PI || bbMinPhi > 2.*M_PI ||
114 bbMaxPhi < -2.*M_PI || bbMaxPhi > 2.*M_PI) {
116 "SectorField::SetPolarBoundingBox",
117 "Bounding box angles must be in range -2*M_PI < phi < 2*M_PI"
130 std::vector< std::vector<double> > corner_coords(
131 getCorners(bbMinR, bbMinPhi, bbMaxR, bbMaxPhi));
133 *std::min_element(corner_coords[0].
begin(), corner_coords[0].
end());
135 *std::max_element(corner_coords[0].
begin(), corner_coords[0].
end());
139 *std::min_element(corner_coords[1].
begin(), corner_coords[1].
end());
141 *std::max_element(corner_coords[1].
begin(), corner_coords[1].
end());
145 if ( (bbMaxPhi > 0.5*M_PI && bbMinPhi < 0.5*M_PI) ||
146 (bbMaxPhi > -1.5*M_PI && bbMinPhi < -1.5*M_PI) ) {
149 if ((bbMaxPhi > M_PI && bbMinPhi < M_PI) ||
150 (bbMaxPhi > -M_PI && bbMinPhi < -M_PI)) {
153 if ((bbMaxPhi > 1.5*M_PI && bbMinPhi < 1.5*M_PI) ||
154 (bbMaxPhi > -0.5*M_PI && bbMinPhi < -0.5*M_PI)) {
157 if ((bbMaxPhi > 0.*M_PI && bbMinPhi < 0.*M_PI)) {
163 (
double bbMinR,
double bbMinPhi,
double bbMaxR,
double bbMaxPhi) {
164 std::vector< std::vector<double> > corner_coords(2);
165 corner_coords[0] = std::vector<double>(4);
166 corner_coords[1] = std::vector<double>(4);
168 double corner_0[3] = {bbMinR, 0., bbMinPhi};
169 double corner_1[3] = {bbMinR, 0., bbMaxPhi};
170 double corner_2[3] = {bbMaxR, 0., bbMaxPhi};
171 double corner_3[3] = {bbMaxR, 0., bbMinPhi};
177 corner_coords[0][0] = corner_0[0];
178 corner_coords[0][1] = corner_1[0];
179 corner_coords[0][2] = corner_2[0];
180 corner_coords[0][3] = corner_3[0];
181 corner_coords[1][0] = corner_0[2];
182 corner_coords[1][1] = corner_1[2];
183 corner_coords[1][2] = corner_2[2];
184 corner_coords[1][3] = corner_3[2];
185 return corner_coords;
198 double &rBegin,
double &rEnd)
const {
206 double &yIni,
double &yFinal,
207 double &zIni,
double &zFinal)
const {
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > sin(const Tps< T > &x)
Sine.
Tps< T > sqrt(const Tps< T > &x)
Square root.
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
std::vector< double > bbMin_m
std::vector< std::vector< double > > getCorners(double bbMinR, double bbMinPhi, double bbMaxR, double bbMaxPhi)
std::vector< double > polarBBMin_m
void getFieldDimensions(double &zBegin, double &zEnd, double &rBegin, double &rEnd) const
virtual std::vector< double > getPolarBoundingBoxMin() const
static void convertToCartesian(double *position)
std::vector< double > polarBBMax_m
std::vector< double > bbMax_m
SectorField(const std::string &file_name)
virtual std::vector< double > getPolarBoundingBoxMax() const
static void convertToPolar(double *position)
void setPolarBoundingBox(double bbMinR, double bbMinY, double bbMinPhi, double bbMaxR, double bbMaxY, double bbMaxPhi, double bbTolR, double bbTolY, double bbTolPhi)