Spherocity.cc
Go to the documentation of this file.00001
00002 #include "Rivet/Rivet.hh"
00003 #include "Rivet/Projections/Spherocity.hh"
00004 #include "Rivet/Tools/Logging.hh"
00005
00006
00007 namespace Rivet {
00008
00009
00010 void Spherocity::calc(const FinalState& fs) {
00011 calc(fs.particles());
00012 }
00013
00014
00015 void Spherocity::calc(const vector<Particle>& fsparticles) {
00016 vector<Vector3> threeMomenta;
00017 threeMomenta.reserve(fsparticles.size());
00018 foreach (const Particle& p, fsparticles) {
00019 const Vector3 p3 = p.momentum().vector3();
00020 threeMomenta.push_back(p3);
00021 }
00022 _calcSpherocity(threeMomenta);
00023 }
00024
00025
00026 void Spherocity::calc(const vector<FourMomentum>& fsmomenta) {
00027 vector<Vector3> threeMomenta;
00028 threeMomenta.reserve(fsmomenta.size());
00029 foreach (const FourMomentum& v, fsmomenta) {
00030 threeMomenta.push_back(v.vector3());
00031 }
00032 _calcSpherocity(threeMomenta);
00033 }
00034
00035
00036 void Spherocity::calc(const vector<Vector3>& fsmomenta) {
00037 _calcSpherocity(fsmomenta);
00038 }
00039
00040
00041
00042
00043
00044
00045 void _calcS(const vector<Vector3 >& perpmomenta, double& sphero, Vector3& saxis) {
00046
00047
00048
00049
00050
00051
00052 vector<Vector3> p = perpmomenta;
00053 vector<double> sval;
00054
00055
00056 vector<Vector3> units;
00057 foreach (const Vector3& p, perpmomenta) {
00058 units.push_back(Vector3(p.x(), p.y(), 0.0).unit());
00059 }
00060
00061
00062
00063
00064 sphero = 99999.;
00065
00066 foreach (const Vector3& u, units){
00067 double s =0.0;
00068 for (unsigned int k=0 ; k<p.size() ; k++) {
00069 s += fabs( p[k].cross(u).mod() );
00070 }
00071 if (s < sphero) {
00072 sphero = s;
00073 saxis = u;
00074 }
00075 }
00076 }
00077
00078
00079 void Spherocity::_calcSpherocity(const vector<Vector3>& fsmomenta) {
00080
00081
00082
00083
00084
00085
00086
00087 vector<Vector3> fsperpmomenta;
00088 foreach (const Vector3& p, fsmomenta) {
00089 fsperpmomenta.push_back(Vector3(p.x(), p.y(), 0.0));
00090 }
00091
00092
00093 double perpmomentumSum(0.0);
00094 foreach (const Vector3& p, fsperpmomenta) {
00095 perpmomentumSum += mod(p);
00096 }
00097
00098
00099 _spherocities.clear();
00100 _spherocityAxes.clear();
00101
00102
00103
00104 Vector3 axis(0,0,0);
00105 double val = 0.;
00106
00107
00108 _calcS(fsperpmomenta, val, axis);
00109 MSG_DEBUG("Mom sum = " << perpmomentumSum);
00110 double spherocity = 0.25 * PI * PI * val * val / (perpmomentumSum * perpmomentumSum);
00111 _spherocities.push_back(spherocity);
00112
00113
00114 if (spherocity < 0.0 || spherocity > 1.0) {
00115 MSG_WARNING("Spherocity = " << spherocity);
00116 }
00117
00118 MSG_DEBUG("Spherocity value = " << spherocity);
00119
00120 MSG_DEBUG("Sperocity axis = " << axis);
00121
00122 _spherocityAxes.push_back(axis);
00123
00124
00125 }
00126 }