Fork me on GitHub

source: git/external/fastjet/plugins/SISCone/momentum.cc@ b31dce0

ImprovedOutputFile Timing dual_readout llp
Last change on this file since b31dce0 was d7d2da3, checked in by pavel <pavel@…>, 12 years ago

move branches/ModularDelphes to trunk

  • Property mode set to 100644
File size: 5.1 KB
RevLine 
[d7d2da3]1///////////////////////////////////////////////////////////////////////////////
2// File: momentum.cpp //
3// Description: source file for 4-momentum class Cmomentum //
4// This file is part of the SISCone project. //
5// For more details, see http://projects.hepforge.org/siscone //
6// //
7// Copyright (c) 2006 Gavin Salam and Gregory Soyez //
8// //
9// This program is free software; you can redistribute it and/or modify //
10// it under the terms of the GNU General Public License as published by //
11// the Free Software Foundation; either version 2 of the License, or //
12// (at your option) any later version. //
13// //
14// This program is distributed in the hope that it will be useful, //
15// but WITHOUT ANY WARRANTY; without even the implied warranty of //
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
17// GNU General Public License for more details. //
18// //
19// You should have received a copy of the GNU General Public License //
20// along with this program; if not, write to the Free Software //
21// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
22// //
23// $Revision:: $//
24// $Date:: $//
25///////////////////////////////////////////////////////////////////////////////
26
27#include "momentum.h"
28#include <math.h>
29#include <stdlib.h>
30
31namespace siscone{
32
33/*************************************************************************
34 * class Cmomentum *
35 * This class contains the information for particle or group of *
36 * particles management. *
37 * It includes all Lorentz properties as well as tools for summing them. *
38 *************************************************************************/
39
40// default ctor
41//--------------
42Cmomentum::Cmomentum(){
43 eta = 0.0;
44 phi = 0.0;
45 px = py = pz = E = 0.0;
46 ref = Creference();
47 index = -1;
48}
49
50// ctor with initialisation
51//--------------------------
52Cmomentum::Cmomentum(double _px, double _py, double _pz, double _E){
53 px = _px;
54 py = _py;
55 pz = _pz;
56 E = _E;
57
58 // compute eta and phi
59 build_etaphi();
60 ref = Creference();
61}
62
63// ctor with detailed initialisation
64//-----------------------------------
65Cmomentum::Cmomentum(double _eta, double _phi, Creference _ref){
66 eta = _eta;
67 phi = _phi;
68
69 ref = _ref;
70}
71
72// default dtor
73//--------------
74Cmomentum::~Cmomentum(){
75
76}
77
78// assignment of vectors
79//-----------------------
80Cmomentum& Cmomentum::operator = (const Cmomentum &v){
81 px = v.px;
82 py = v.py;
83 pz = v.pz;
84 E = v.E;
85
86 eta = v.eta;
87 phi = v.phi;
88
89 ref = v.ref;
90 return *this;
91}
92
93// addition of vectors
94// !!! WARNING !!! no updating of eta and phi !!!
95//------------------------------------------------
96const Cmomentum Cmomentum::operator + (const Cmomentum &v){
97 Cmomentum tmp = *this;
98 return tmp+=v;
99}
100
101// incrementation of vectors
102// !!! WARNING !!! no updating of eta and phi !!!
103//------------------------------------------------
104Cmomentum& Cmomentum::operator += (const Cmomentum &v){
105 px+=v.px;
106 py+=v.py;
107 pz+=v.pz;
108 E +=v.E;
109
110 ref+=v.ref;
111
112 return *this;
113}
114
115// incrementation of vectors
116// !!! WARNING !!! no updating of eta and phi !!!
117//------------------------------------------------
118Cmomentum& Cmomentum::operator -= (const Cmomentum &v){
119 px-=v.px;
120 py-=v.py;
121 pz-=v.pz;
122 E -=v.E;
123
124 ref-=v.ref;
125 return *this;
126}
127
128// build eta-phi from 4-momentum info
129// !!! WARNING !!!
130// !!! computing eta and phi is time-consuming !!!
131// !!! use this whenever you need eta or phi !!!
132// !!! automatically called for single-particle !!!
133//--------------------------------------------------
134void Cmomentum::build_etaphi(){
135 // note: the factor n (ref.nb) cancels in all expressions !!
136 eta = 0.5*log((E+pz)/(E-pz));
137 phi = atan2(py,px);
138}
139
140
141// ordering of two vectors
142// the default ordering is w.r.t. their references
143//-------------------------------------------------
144bool operator < (const Cmomentum &v1, const Cmomentum &v2){
145 return v1.ref < v2.ref;
146}
147
148// ordering of vectors in eta (e.g. used in collinear tests)
149//-----------------------------------------------------------
150bool momentum_eta_less(const Cmomentum &v1, const Cmomentum &v2){
151 return v1.eta < v2.eta;
152}
153
154// ordering of vectors in pt
155//---------------------------
156bool momentum_pt_less(const Cmomentum &v1, const Cmomentum &v2){
157 return v1.perp2() < v2.perp2();
158}
159
160}
161
Note: See TracBrowser for help on using the repository browser.