|
SISCone
2.0.5
|
00001 00002 // File: momentum.cpp // 00003 // Description: source file for 4-momentum class Cmomentum // 00004 // This file is part of the SISCone project. // 00005 // WARNING: this is not the main SISCone trunk but // 00006 // an adaptation to spherical coordinates // 00007 // For more details, see http://projects.hepforge.org/siscone // 00008 // // 00009 // Copyright (c) 2006-2008 Gavin Salam and Gregory Soyez // 00010 // // 00011 // This program is free software; you can redistribute it and/or modify // 00012 // it under the terms of the GNU General Public License as published by // 00013 // the Free Software Foundation; either version 2 of the License, or // 00014 // (at your option) any later version. // 00015 // // 00016 // This program is distributed in the hope that it will be useful, // 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 00019 // GNU General Public License for more details. // 00020 // // 00021 // You should have received a copy of the GNU General Public License // 00022 // along with this program; if not, write to the Free Software // 00023 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA // 00024 // // 00025 // $Revision:: 255 $// 00026 // $Date:: 2008-07-12 17:40:35 +0200 (Sat, 12 Jul 2008) $// 00028 00029 #include "momentum.h" 00030 #include <math.h> 00031 #include <stdlib.h> 00032 00033 namespace siscone_spherical{ 00034 00035 /************************************************************************* 00036 * class CSph3vector * 00037 * This class contains the information for particle or group of * 00038 * particles management. * 00039 *************************************************************************/ 00040 00041 // default ctor 00042 //-------------- 00043 CSph3vector::CSph3vector(){ 00044 _theta = _phi = _norm = 0.0; 00045 px = py = pz = 0.0; 00046 ref = siscone::Creference(); 00047 } 00048 00049 // ctor with initialisation 00050 //-------------------------- 00051 CSph3vector::CSph3vector(double _px, double _py, double _pz){ 00052 px = _px; 00053 py = _py; 00054 pz = _pz; 00055 00056 // compute the norm 00057 build_norm(); 00058 00059 ref = siscone::Creference(); 00060 } 00061 00062 // default dtor 00063 //-------------- 00064 CSph3vector::~CSph3vector(){ 00065 00066 } 00067 00068 00069 // assignment of vectors 00070 //----------------------- 00071 CSph3vector& CSph3vector::operator = (const CSph3vector &v){ 00072 px = v.px; 00073 py = v.py; 00074 pz = v.pz; 00075 00076 _norm = v._norm; 00077 _theta = v._theta; 00078 _phi = v._phi; 00079 00080 ref = v.ref; 00081 return *this; 00082 } 00083 00084 // addition of vectors 00085 //------------------------------------------------ 00086 const CSph3vector CSph3vector::operator + (const CSph3vector &v){ 00087 CSph3vector tmp = *this; 00088 return tmp+=v; 00089 } 00090 00091 // subtraction of vectors 00092 //------------------------------------------------ 00093 const CSph3vector CSph3vector::operator - (const CSph3vector &v){ 00094 CSph3vector tmp = *this; 00095 return tmp-=v; 00096 } 00097 00098 // division by constant 00099 //------------------------------------------------ 00100 const CSph3vector CSph3vector::operator / (const double &r){ 00101 CSph3vector tmp = *this; 00102 return tmp/=r; 00103 } 00104 00105 // incrementation 00106 //------------------------------------------------ 00107 CSph3vector& CSph3vector::operator += (const CSph3vector &v){ 00108 px+=v.px; 00109 py+=v.py; 00110 pz+=v.pz; 00111 00112 return *this; 00113 } 00114 00115 // decrementation 00116 //------------------------------------------------ 00117 CSph3vector& CSph3vector::operator -= (const CSph3vector &v){ 00118 px-=v.px; 00119 py-=v.py; 00120 pz-=v.pz; 00121 00122 return *this; 00123 } 00124 00125 // multiplication by a constant 00126 //------------------------------------------------ 00127 CSph3vector& CSph3vector::operator *= (const double &r){ 00128 px*=r; 00129 py*=r; 00130 pz*=r; 00131 00132 return *this; 00133 } 00134 00135 // division by a constant 00136 //------------------------------------------------ 00137 CSph3vector& CSph3vector::operator /= (const double &r){ 00138 px/=r; 00139 py/=r; 00140 pz/=r; 00141 00142 _norm/=r; 00143 00144 return *this; 00145 } 00146 00147 // build norm from 3-momentum info 00148 void CSph3vector::build_norm(){ 00149 _norm = norm(); 00150 } 00151 00152 // build norm from 3-momentum info 00153 void CSph3vector::build_thetaphi(){ 00154 _theta = theta(); 00155 _phi = phi(); 00156 } 00157 00158 00159 // for this direction, compute the two reference directions 00160 // used to measure angles 00161 void CSph3vector::get_angular_directions(CSph3vector &angular_dir1, CSph3vector &angular_dir2){ 00162 if (px < py){ 00163 if (pz < px){ 00164 // z smallest 00165 angular_dir1 = CSph3vector(-py, px, 0.0); 00166 } else { 00167 // x smallest 00168 angular_dir1 = CSph3vector(0.0, -pz, py); 00169 } 00170 } else { 00171 if (pz < py){ 00172 // z smallest 00173 angular_dir1 = CSph3vector(-py, px, 0.0); 00174 } else { 00175 // y smallest 00176 angular_dir1 = CSph3vector(-pz, 0.0, px); 00177 } 00178 } 00179 angular_dir2 = cross_product3(*this, angular_dir1); 00180 // We'll simply take x & y so the reflection symmetry is not broken 00181 //angular_dir1 = CSph3vector(0.0, -pz, py); 00182 //angular_dir2 = CSph3vector(-pz, 0.0, -px); 00183 } 00184 00185 /************************************************************************* 00186 * class CSphmomentum * 00187 * This class contains the information for particle or group of * 00188 * particles management. * 00189 * It includes all Lorentz properties as well as tools for summing them. * 00190 *************************************************************************/ 00191 00192 // default ctor 00193 //-------------- 00194 CSphmomentum::CSphmomentum(){ 00195 E=0.0; 00196 index = -1; 00197 } 00198 00199 // ctor with initialisation 00200 //-------------------------- 00201 CSphmomentum::CSphmomentum(double _px, double _py, double _pz, double _E) 00202 : CSph3vector(_px, _py, _pz) { 00203 E = _E; 00204 00205 // compute the angles 00206 build_thetaphi(); 00207 } 00208 00209 // ctor with initialisation 00210 //-------------------------- 00211 CSphmomentum::CSphmomentum(CSph3vector &_v, double _E) 00212 : CSph3vector(_v.px, _v.py, _v.pz) { 00213 E = _E; 00214 } 00215 00216 // default dtor 00217 //-------------- 00218 CSphmomentum::~CSphmomentum(){ 00219 00220 } 00221 00222 // assignment of vectors 00223 //----------------------- 00224 CSphmomentum& CSphmomentum::operator = (const CSphmomentum &v){ 00225 px = v.px; 00226 py = v.py; 00227 pz = v.pz; 00228 E = v.E; 00229 00230 _norm = v._norm; 00231 _theta = v._theta; 00232 _phi = v._phi; 00233 00234 ref = v.ref; 00235 return *this; 00236 } 00237 00238 // addition of vectors 00239 // !!! WARNING !!! no updating of eta and phi !!! 00240 //------------------------------------------------ 00241 const CSphmomentum CSphmomentum::operator + (const CSphmomentum &v){ 00242 CSphmomentum tmp = *this; 00243 return tmp+=v; 00244 } 00245 00246 // incrementation of vectors 00247 // !!! WARNING !!! no updating of eta and phi !!! 00248 //------------------------------------------------ 00249 CSphmomentum& CSphmomentum::operator += (const CSphmomentum &v){ 00250 px+=v.px; 00251 py+=v.py; 00252 pz+=v.pz; 00253 E +=v.E; 00254 00255 ref+=v.ref; 00256 00257 return *this; 00258 } 00259 00260 // decrementation of vectors 00261 // !!! WARNING !!! no updating of eta and phi !!! 00262 //------------------------------------------------ 00263 CSphmomentum& CSphmomentum::operator -= (const CSphmomentum &v){ 00264 px-=v.px; 00265 py-=v.py; 00266 pz-=v.pz; 00267 E -=v.E; 00268 00269 ref-=v.ref; 00270 return *this; 00271 } 00272 00273 00274 // ordering of two vectors 00275 // the default ordering is w.r.t. their references 00276 //------------------------------------------------- 00277 bool operator < (const CSphmomentum &v1, const CSphmomentum &v2){ 00278 return v1.ref < v2.ref; 00279 } 00280 00281 // ordering of vectors in eta (e.g. used in collinear tests) 00282 //----------------------------------------------------------- 00283 bool momentum_theta_less(const CSphmomentum &v1, const CSphmomentum &v2){ 00284 return v1._theta < v2._theta; 00285 } 00286 00287 // ordering of vectors in pt 00288 //--------------------------- 00289 bool momentum_pt_less(const CSphmomentum &v1, const CSphmomentum &v2){ 00290 return v1.perp2() < v2.perp2(); 00291 } 00292 00293 } 00294