siscone is hosted by Hepforge, IPPP Durham

The SISCone Jet Algorithm

Version 3.0.6



SISCone 3.0.6
momentum.cpp
1
2// File: momentum.cpp //
3// Description: source file for 4-momentum class Cmomentum //
4// This file is part of the SISCone project. //
5// WARNING: this is not the main SISCone trunk but //
6// an adaptation to spherical coordinates //
7// For more details, see http://projects.hepforge.org/siscone //
8// //
9// Copyright (c) 2006-2008 Gavin Salam and Gregory Soyez //
10// //
11// This program is free software; you can redistribute it and/or modify //
12// it under the terms of the GNU General Public License as published by //
13// the Free Software Foundation; either version 2 of the License, or //
14// (at your option) any later version. //
15// //
16// This program is distributed in the hope that it will be useful, //
17// but WITHOUT ANY WARRANTY; without even the implied warranty of //
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
19// GNU General Public License for more details. //
20// //
21// You should have received a copy of the GNU General Public License //
22// along with this program; if not, write to the Free Software //
23// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
24// //
25// $Revision:: $//
26// $Date:: $//
28
29#include "momentum.h"
30#include <math.h>
31#include <stdlib.h>
32
33namespace siscone_spherical{
34
35/*************************************************************************
36 * class CSph3vector *
37 * This class contains the information for particle or group of *
38 * particles management. *
39 *************************************************************************/
40
41// default ctor
42//--------------
44 _theta = _phi = _norm = 0.0;
45 px = py = pz = 0.0;
47}
48
49// ctor with initialisation
50//--------------------------
51CSph3vector::CSph3vector(double _px, double _py, double _pz){
52 px = _px;
53 py = _py;
54 pz = _pz;
55
56 // compute the norm
57 build_norm();
58
60}
61
62// default dtor
63//--------------
65
66}
67
68
69// assignment of vectors
70//-----------------------
72 px = v.px;
73 py = v.py;
74 pz = v.pz;
75
76 _norm = v._norm;
77 _theta = v._theta;
78 _phi = v._phi;
79
80 ref = v.ref;
81 return *this;
82}
83
84// addition of vectors
85//------------------------------------------------
87 CSph3vector tmp = *this;
88 return tmp+=v;
89}
90
91// subtraction of vectors
92//------------------------------------------------
94 CSph3vector tmp = *this;
95 return tmp-=v;
96}
97
98// division by constant
99//------------------------------------------------
101 CSph3vector tmp = *this;
102 return tmp/=r;
103}
104
105// incrementation
106//------------------------------------------------
108 px+=v.px;
109 py+=v.py;
110 pz+=v.pz;
111
112 return *this;
113}
114
115// decrementation
116//------------------------------------------------
118 px-=v.px;
119 py-=v.py;
120 pz-=v.pz;
121
122 return *this;
123}
124
125// multiplication by a constant
126//------------------------------------------------
128 px*=r;
129 py*=r;
130 pz*=r;
131
132 return *this;
133}
134
135// division by a constant
136//------------------------------------------------
138 px/=r;
139 py/=r;
140 pz/=r;
141
142 _norm/=r;
143
144 return *this;
145}
146
147// build norm from 3-momentum info
149 _norm = norm();
150}
151
152// build norm from 3-momentum info
154 _theta = theta();
155 _phi = phi();
156}
157
158
159// for this direction, compute the two reference directions
160// used to measure angles
162 if (px < py){
163 if (pz < px){
164 // z smallest
165 angular_dir1 = CSph3vector(-py, px, 0.0);
166 } else {
167 // x smallest
168 angular_dir1 = CSph3vector(0.0, -pz, py);
169 }
170 } else {
171 if (pz < py){
172 // z smallest
173 angular_dir1 = CSph3vector(-py, px, 0.0);
174 } else {
175 // y smallest
176 angular_dir1 = CSph3vector(-pz, 0.0, px);
177 }
178 }
179 angular_dir2 = cross_product3(*this, angular_dir1);
180 // We'll simply take x & y so the reflection symmetry is not broken
181 //angular_dir1 = CSph3vector(0.0, -pz, py);
182 //angular_dir2 = CSph3vector(-pz, 0.0, -px);
183}
184
185/*************************************************************************
186 * class CSphmomentum *
187 * This class contains the information for particle or group of *
188 * particles management. *
189 * It includes all Lorentz properties as well as tools for summing them. *
190 *************************************************************************/
191
192// default ctor
193//--------------
195 E=0.0;
196 index = -1;
197}
198
199// ctor with initialisation
200//--------------------------
201CSphmomentum::CSphmomentum(double _px, double _py, double _pz, double _E)
202 : CSph3vector(_px, _py, _pz) {
203 E = _E;
204
205 // compute the angles
207}
208
209// ctor with initialisation
210//--------------------------
212 : CSph3vector(_v.px, _v.py, _v.pz) {
213 E = _E;
214}
215
216// default dtor
217//--------------
219
220}
221
222// assignment of vectors
223//-----------------------
225 px = v.px;
226 py = v.py;
227 pz = v.pz;
228 E = v.E;
229
230 _norm = v._norm;
231 _theta = v._theta;
232 _phi = v._phi;
233
234 ref = v.ref;
235 return *this;
236}
237
238// addition of vectors
239// !!! WARNING !!! no updating of eta and phi !!!
240//------------------------------------------------
242 CSphmomentum tmp = *this;
243 return tmp+=v;
244}
245
246// incrementation of vectors
247// !!! WARNING !!! no updating of eta and phi !!!
248//------------------------------------------------
250 px+=v.px;
251 py+=v.py;
252 pz+=v.pz;
253 E +=v.E;
254
255 ref+=v.ref;
256
257 return *this;
258}
259
260// decrementation of vectors
261// !!! WARNING !!! no updating of eta and phi !!!
262//------------------------------------------------
264 px-=v.px;
265 py-=v.py;
266 pz-=v.pz;
267 E -=v.E;
268
269 ref-=v.ref;
270 return *this;
271}
272
273
274// ordering of two vectors
275// the default ordering is w.r.t. their references
276//-------------------------------------------------
277bool operator < (const CSphmomentum &v1, const CSphmomentum &v2){
278 return v1.ref < v2.ref;
279}
280
281// ordering of vectors in eta (e.g. used in collinear tests)
282//-----------------------------------------------------------
283bool momentum_theta_less(const CSphmomentum &v1, const CSphmomentum &v2){
284 return v1._theta < v2._theta;
285}
286
287// ordering of vectors in pt
288//---------------------------
289bool momentum_pt_less(const CSphmomentum &v1, const CSphmomentum &v2){
290 return v1.perp2() < v2.perp2();
291}
292
293}
294
references used for checksums.
Definition: reference.h:43
base class for managing the spatial part of Cmomentum (defined after)
Definition: momentum.h:54
void build_norm()
build the spatial normfrom 4-momentum info !!! WARNING !!! !!! computing the norm is the only time-co...
Definition: momentum.cpp:148
double norm() const
3-vect norm
Definition: momentum.h:103
void get_angular_directions(CSph3vector &angular_dir1, CSph3vector &angular_dir2)
for this direction, compute the two reference directions used to measure angles
Definition: momentum.cpp:161
const CSph3vector operator+(const CSph3vector &v)
addition of vectors WARNING= norm is not updated
Definition: momentum.cpp:86
CSph3vector & operator=(const CSph3vector &v)
assignment of vectors
Definition: momentum.cpp:71
double phi() const
3-vect azimuthal angle
Definition: momentum.h:109
CSph3vector & operator+=(const CSph3vector &v)
incrementation of vectors WARNING= norm is not updated
Definition: momentum.cpp:107
const CSph3vector operator-(const CSph3vector &v)
subtraction of vectors WARNING= norm is not updated
Definition: momentum.cpp:93
CSph3vector & operator/=(const double &r)
division by a constant WARNING= norm is not updated
Definition: momentum.cpp:137
CSph3vector & operator-=(const CSph3vector &v)
decrementation of vectors WARNING= norm is not updated
Definition: momentum.cpp:117
CSph3vector & operator*=(const double &r)
multiplication by a constant WARNING= norm is not updated
Definition: momentum.cpp:127
double _theta
particle theta angle (available ONLY after a call to build_thetaphi)
Definition: momentum.h:136
double _phi
particle phi angle (available ONLY after a call to build_thetaphi)
Definition: momentum.h:137
const CSph3vector operator/(const double &r)
division by a constant WARNING= norm is not updated
Definition: momentum.cpp:100
double _norm
particle spatial norm (available ONLY after a call to build_norm)
Definition: momentum.h:135
siscone::Creference ref
reference number for the vector
Definition: momentum.h:142
double theta() const
3-vect polar angle
Definition: momentum.h:112
void build_thetaphi()
just a useful tool to store theta and phi locally (in _theta and _phi) in case you need repeated acce...
Definition: momentum.cpp:153
base class for dynamic coordinates management
Definition: momentum.h:158
CSphmomentum & operator=(const CSphmomentum &v)
assignment of vectors
Definition: momentum.cpp:224
const CSphmomentum operator+(const CSphmomentum &v)
addition of vectors !!! WARNING !!! no updating of eta and phi !!!
Definition: momentum.cpp:241
~CSphmomentum()
ctor with detailed initialisation
Definition: momentum.cpp:218
int index
internal particle number
Definition: momentum.h:211
CSphmomentum & operator+=(const CSphmomentum &v)
incrementation of vectors !!! WARNING !!! no updating of eta and phi !!!
Definition: momentum.cpp:249
CSphmomentum & operator-=(const CSphmomentum &v)
decrementation of vectors !!! WARNING !!! no updating of eta and phi !!!
Definition: momentum.cpp:263

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