siscone is hosted by Hepforge, IPPP Durham

The SISCone Jet Algorithm

Version 3.0.6



SISCone 3.0.6
geom_2d.h
1// -*- C++ -*-
3// File: geom_2d.h //
4// Description: header file for two-dimensional geometry tools //
5// This file is part of the SISCone project. //
6// For more details, see http://projects.hepforge.org/siscone //
7// //
8// Copyright (c) 2006 Gavin Salam and Gregory Soyez //
9// //
10// This program is free software; you can redistribute it and/or modify //
11// it under the terms of the GNU General Public License as published by //
12// the Free Software Foundation; either version 2 of the License, or //
13// (at your option) any later version. //
14// //
15// This program is distributed in the hope that it will be useful, //
16// but WITHOUT ANY WARRANTY; without even the implied warranty of //
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
18// GNU General Public License for more details. //
19// //
20// You should have received a copy of the GNU General Public License //
21// along with this program; if not, write to the Free Software //
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
23// //
24// $Revision:: $//
25// $Date:: $//
27
28#ifndef __GEOM_2D_H__
29#define __GEOM_2D_H__
30
31#include <iostream>
32#include <math.h>
33#include "defines.h"
34
35#ifndef M_PI
36#define M_PI 3.141592653589793238462643383279502884197
37#endif
38
39namespace siscone{
40
43inline double phi_in_range(double phi) {
44 if (phi <= -M_PI) phi += twopi;
45 else if (phi > M_PI) phi -= twopi;
46 return phi;
47}
48
52inline double dphi(double phi1, double phi2) {
53 return phi_in_range(phi1-phi2);
54}
55
56
60inline double abs_dphi(double phi1, double phi2) {
61 double delta = fabs(phi1-phi2);
62 return delta > M_PI ? twopi-delta : delta;
63}
64
66inline double pow2(double x) {return x*x;}
67
68
73class Ctwovect {
74public:
76 Ctwovect() : x(0.0), y(0.0) {}
77
81 Ctwovect(double _x, double _y) : x(_x), y(_y) {}
82
84 double x, y;
85
87 inline double mod2() const {return pow2(x)+pow2(y);}
88
90 inline double modulus() const {return sqrt(mod2());}
91};
92
93
98inline double dot_product(const Ctwovect & a, const Ctwovect & b) {
99 return a.x*b.x + a.y*b.y;
100}
101
102
107inline double cross_product(const Ctwovect & a, const Ctwovect & b) {
108 return a.x*b.y - a.y*b.x;
109}
110
111
121public:
124
130 Ceta_phi_range(double c_eta, double c_phi, double R);
131
135
140 int add_particle(const double eta, const double phi);
141
143 unsigned int eta_range;
144
146 unsigned int phi_range;
147
148 // extremal value for eta
149 static double eta_min;
150 static double eta_max;
151
152private:
154 inline unsigned int get_eta_cell(double eta){
155 return (unsigned int) (1u << ((int) (32*((eta-eta_min)/(eta_max-eta_min)))));
156 }
157
159 inline unsigned int get_phi_cell(double phi){
160 return (unsigned int) (1u << ((int) (32*phi/twopi+16)%32));
161 }
162};
163
168bool is_range_overlap(const Ceta_phi_range &r1, const Ceta_phi_range &r2);
169
175const Ceta_phi_range range_union(const Ceta_phi_range &r1, const Ceta_phi_range &r2);
176
177}
178
179#endif
class for holding a covering range in eta-phi
Definition: geom_2d.h:120
unsigned int eta_range
eta range as a binary coding of covered cells
Definition: geom_2d.h:143
static double eta_max
maximal value for eta
Definition: geom_2d.h:150
int add_particle(const double eta, const double phi)
add a particle to the range
Definition: geom_2d.cpp:111
static double eta_min
minimal value for eta
Definition: geom_2d.h:149
Ceta_phi_range & operator=(const Ceta_phi_range &r)
assignment of range
Definition: geom_2d.cpp:99
Ceta_phi_range()
default ctor
Definition: geom_2d.cpp:52
unsigned int phi_range
phi range as a binary coding of covered cells
Definition: geom_2d.h:146
class for holding a two-vector
Definition: geom_2d.h:73
double mod2() const
norm (modulud square) of the vector
Definition: geom_2d.h:87
double x
vector coordinates
Definition: geom_2d.h:84
Ctwovect()
default ctor
Definition: geom_2d.h:76
double modulus() const
modulus of the vector
Definition: geom_2d.h:90
Ctwovect(double _x, double _y)
ctor with initialisation
Definition: geom_2d.h:81
const double twopi
definition of 2*M_PI which is useful a bit everyhere!
Definition: defines.h:114

The SISCone project has been developed by Gavin Salam and Gregory Soyez
Documentation generated on Tue Jun 20 2023 18:08:37 for SISCone by  Doxygen 1.9.4