CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
EventShape Class Reference

#include <EventShape.h>

Public Member Functions

float aplanarity () const
 
 EventShape (reco::TrackCollection &)
 
float planarity () const
 
float sphericity () const
 
math::XYZTLorentzVectorF thrust () const
 

Static Public Member Functions

static float aplanarity (const reco::TrackCollection &)
 
static float planarity (const reco::TrackCollection &)
 
static float sphericity (const reco::TrackCollection &)
 
static math::XYZTLorentzVectorF thrust (const reco::TrackCollection &)
 

Private Attributes

std::vector< float > eigenvalues
 
std::vector< TVector3 > p
 

Detailed Description

Definition at line 6 of file EventShape.h.

Constructor & Destructor Documentation

EventShape::EventShape ( reco::TrackCollection tracks)

Definition at line 14 of file EventShape.cc.

References eigenvalues, i, j, convertSQLitetoXML_cfg::output, p, and python.multivaluedict::sort().

14  :eigenvalues(3)
15 {
17  for(reco::TrackCollection::const_iterator itTrack = tracks.begin(); itTrack<tracks.end(); ++itTrack) {
18  p.push_back(TVector3(itTrack->px(),itTrack->py(),itTrack->pz()));
19  }
20 
21  // first fill the momentum tensor
22  TMatrixDSym MomentumTensor(3);
23  for(std::vector<TVector3>::const_iterator momentum = p.begin();momentum<p.end();++momentum) {
24  for(unsigned int i=0;i<3;i++)
25  for(unsigned int j=0;j<=i;j++) {
26  MomentumTensor[i][j] += momentum[i]*momentum[j];
27  }
28  }
29  MomentumTensor*=1/(MomentumTensor[0][0]+MomentumTensor[1][1]+MomentumTensor[2][2]);
30  // find the eigen values
31  TMatrixDSymEigen eigen(MomentumTensor);
32  TVectorD eigenvals = eigen.GetEigenValues();
33  eigenvalues[0] = eigenvals[0];
34  eigenvalues[1] = eigenvals[1];
35  eigenvalues[2] = eigenvals[2];
36  sort(eigenvalues.begin(),eigenvalues.end());
37 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
std::vector< float > eigenvalues
Definition: EventShape.h:25
tuple tracks
Definition: testEve_cfg.py:39
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:23
std::vector< TVector3 > p
Definition: EventShape.h:24

Member Function Documentation

float EventShape::aplanarity ( const reco::TrackCollection tracks)
static

Definition at line 244 of file EventShape.cc.

References i, j, and python.multivaluedict::sort().

Referenced by TrackerDpgAnalysis::analyze().

245 {
246  // a critical check
247  if (tracks.size()==0) return 0;
248  // first fill the momentum tensor
249  TMatrixDSym MomentumTensor(3);
250  for(reco::TrackCollection::const_iterator itTrack = tracks.begin(); itTrack<tracks.end(); ++itTrack) {
251  std::vector<double> momentum(3);
252  momentum[0] = itTrack->px();
253  momentum[1] = itTrack->py();
254  momentum[2] = itTrack->pz();
255  for(unsigned int i=0;i<3;i++)
256  for(unsigned int j=0;j<=i;j++) {
257  MomentumTensor[i][j] += momentum[i]*momentum[j];
258  }
259  }
260  MomentumTensor*=1/(MomentumTensor[0][0]+MomentumTensor[1][1]+MomentumTensor[2][2]);
261  // find the eigen values
262  TMatrixDSymEigen eigen(MomentumTensor);
263  TVectorD eigenvals = eigen.GetEigenValues();
264  vector<float> eigenvaluess(3);
265  eigenvaluess[0] = eigenvals[0];
266  eigenvaluess[1] = eigenvals[1];
267  eigenvaluess[2] = eigenvals[2];
268  sort(eigenvaluess.begin(),eigenvaluess.end());
269  // compute aplanarity
270  return ( 1.5*eigenvaluess[0]);
271 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
tuple tracks
Definition: testEve_cfg.py:39
float EventShape::aplanarity ( ) const

Definition at line 308 of file EventShape.cc.

References eigenvalues.

309 {
310  // compute aplanarity
311  return ( 1.5*eigenvalues[0]);
312 }
std::vector< float > eigenvalues
Definition: EventShape.h:25
float EventShape::planarity ( const reco::TrackCollection tracks)
static

Definition at line 273 of file EventShape.cc.

References i, j, and python.multivaluedict::sort().

Referenced by TrackerDpgAnalysis::analyze().

274 {
275  // First a critical check
276  if (tracks.size()==0) return 0;
277  // first fill the momentum tensor
278  TMatrixDSym MomentumTensor(3);
279  for(reco::TrackCollection::const_iterator itTrack = tracks.begin(); itTrack<tracks.end(); ++itTrack) {
280  std::vector<double> momentum(3);
281  momentum[0] = itTrack->px();
282  momentum[1] = itTrack->py();
283  momentum[2] = itTrack->pz();
284  for(unsigned int i=0;i<3;i++)
285  for(unsigned int j=0;j<=i;j++) {
286  MomentumTensor[i][j] += momentum[i]*momentum[j];
287  }
288  }
289  MomentumTensor*=1/(MomentumTensor[0][0]+MomentumTensor[1][1]+MomentumTensor[2][2]);
290  // find the eigen values
291  TMatrixDSymEigen eigen(MomentumTensor);
292  TVectorD eigenvals = eigen.GetEigenValues();
293  vector<float> eigenvaluess(3);
294  eigenvaluess[0] = eigenvals[0];
295  eigenvaluess[1] = eigenvals[1];
296  eigenvaluess[2] = eigenvals[2];
297  sort(eigenvaluess.begin(),eigenvaluess.end());
298  // compute planarity
299  return (eigenvaluess[0]/eigenvaluess[1]);
300 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
tuple tracks
Definition: testEve_cfg.py:39
float EventShape::planarity ( ) const

Definition at line 314 of file EventShape.cc.

References eigenvalues.

315 {
316  // compute planarity
317  return (eigenvalues[0]/eigenvalues[1]);
318 }
std::vector< float > eigenvalues
Definition: EventShape.h:25
float EventShape::sphericity ( const reco::TrackCollection tracks)
static

Definition at line 213 of file EventShape.cc.

References i, j, and python.multivaluedict::sort().

Referenced by TrackerDpgAnalysis::analyze().

214 {
215  // a critical check
216  if(tracks.size()==0) return 0;
217 
218  // first fill the momentum tensor
219  TMatrixDSym MomentumTensor(3);
220  for(reco::TrackCollection::const_iterator itTrack = tracks.begin(); itTrack<tracks.end(); ++itTrack) {
221  std::vector<double> momentum(3);
222  momentum[0] = itTrack->px();
223  momentum[1] = itTrack->py();
224  momentum[2] = itTrack->pz();
225  for(unsigned int i=0;i<3;i++)
226  for(unsigned int j=0;j<=i;j++) {
227  MomentumTensor[i][j] += momentum[i]*momentum[j];
228  }
229  }
230  MomentumTensor*=1/(MomentumTensor[0][0]+MomentumTensor[1][1]+MomentumTensor[2][2]);
231  // find the eigen values
232  TMatrixDSymEigen eigen(MomentumTensor);
233  TVectorD eigenvals = eigen.GetEigenValues();
234  vector<float> eigenvaluess(3);
235  eigenvaluess[0] = eigenvals[0];
236  eigenvaluess[1] = eigenvals[1];
237  eigenvaluess[2] = eigenvals[2];
238  sort(eigenvaluess.begin(),eigenvaluess.end());
239  // compute spericity
240  float sph = ( 1.5*(1-eigenvaluess[2]));
241  return sph;
242 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
tuple tracks
Definition: testEve_cfg.py:39
float EventShape::sphericity ( ) const

Definition at line 302 of file EventShape.cc.

References eigenvalues.

303 {
304  // compute sphericity
305  return ( 1.5*(1-eigenvalues[2]));
306 }
std::vector< float > eigenvalues
Definition: EventShape.h:25
math::XYZTLorentzVectorF EventShape::thrust ( const reco::TrackCollection tracks)
static

Definition at line 124 of file EventShape.cc.

References i, j, gen::k, convertSQLitetoXML_cfg::output, createTree::pp, v, x, detailsBasic3DVector::y, detailsBasic3DVector::z, and zero.

Referenced by TrackerDpgAnalysis::analyze().

125 {
126  std::vector<TVector3> pp;
127  uint32_t Np = tracks.size();
129  for(reco::TrackCollection::const_iterator itTrack = tracks.begin(); itTrack<tracks.end(); ++itTrack) {
130  pp.push_back(TVector3(itTrack->px(),itTrack->py(),itTrack->pz()));
131  }
132  TVector3 qtbo;
133  TVector3 zero(0.,0.,0.);
134  float vnew = 0.;
135 
136  // for more than 2 tracks
137  if (Np > 2) {
138  float vmax = 0.;
139  TVector3 vn, vm, vc, vl;
140  for(unsigned int i=0; i< Np-1; i++)
141  for(unsigned int j=i+1; j < Np; j++) {
142  vc = pp[i].Cross(pp[j]);
143  vl = zero;
144  for(unsigned int k=0; k<Np; k++)
145  if ((k != i) && (k != j)) {
146  if (pp[k].Dot(vc) >= 0.) vl = vl + pp[k];
147  else vl = vl - pp[k];
148  }
149  // make all four sign-combinations for i,j
150  vn = vl + pp[j] + pp[i];
151  vnew = vn.Mag2();
152  if (vnew > vmax) {
153  vmax = vnew;
154  vm = vn;
155  }
156  vn = vl + pp[j] - pp[i];
157  vnew = vn.Mag2();
158  if (vnew > vmax) {
159  vmax = vnew;
160  vm = vn;
161  }
162  vn = vl - pp[j] + pp[i];
163  vnew = vn.Mag2();
164  if (vnew > vmax) {
165  vmax = vnew;
166  vm = vn;
167  }
168  vn = vl - pp[j] - pp[i];
169  vnew = vn.Mag2();
170  if (vnew > vmax) {
171  vmax = vnew;
172  vm = vn;
173  }
174  }
175  // sum momenta of all particles and iterate
176  for(int iter=1; iter<=4; iter++) {
177  qtbo = zero;
178  for(unsigned int i=0; i< Np; i++)
179  if (vm.Dot(pp[i]) >= 0.)
180  qtbo = qtbo + pp[i];
181  else
182  qtbo = qtbo - pp[i];
183  vnew = qtbo.Mag2();
184  if (vnew == vmax) break;
185  vmax = vnew;
186  vm = qtbo;
187  }
188  } // of if Np > 2
189  else
190  if (Np == 2)
191  if (pp[0].Dot(pp[1]) >= 0.)
192  qtbo = pp[0] + pp[1];
193  else
194  qtbo = pp[0] - pp[1];
195  else if (Np == 1)
196  qtbo = pp[0];
197  else {
198  qtbo = zero;
199  return output;
200  }
201  // normalize thrust -division by total momentum-
202  float vsum = 0.;
203  for(unsigned int i=0; i < Np; i++) vsum = vsum + pp[i].Mag();
204  vnew = qtbo.Mag();
205  float v = vnew/vsum;
206  float x = qtbo.X()/vnew;
207  float y = qtbo.Y()/vnew;
208  float z = qtbo.Z()/vnew;
209  output.SetPxPyPzE(x, y, z, v);
210  return output;
211 }
int i
Definition: DBlmapReader.cc:9
tuple pp
Definition: createTree.py:15
double double double z
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
tuple tracks
Definition: testEve_cfg.py:39
Definition: DDAxes.h:10
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:23
mathSSE::Vec4< T > v
math::XYZTLorentzVectorF EventShape::thrust ( ) const

Definition at line 39 of file EventShape.cc.

References i, j, gen::k, convertSQLitetoXML_cfg::output, p, v, x, detailsBasic3DVector::y, detailsBasic3DVector::z, and zero.

40 {
42  TVector3 qtbo;
43  TVector3 zero(0.,0.,0.);
44  float vnew = 0.;
45  uint32_t Np = p.size();
46 
47  // for more than 2 tracks
48  if (Np > 2) {
49  float vmax = 0.;
50  TVector3 vn, vm, vc, vl;
51  for(unsigned int i=0; i< Np-1; i++)
52  for(unsigned int j=i+1; j < Np; j++) {
53  vc = p[i].Cross(p[j]);
54  vl = zero;
55  for(unsigned int k=0; k<Np; k++)
56  if ((k != i) && (k != j)) {
57  if (p[k].Dot(vc) >= 0.) vl = vl + p[k];
58  else vl = vl - p[k];
59  }
60  // make all four sign-combinations for i,j
61  vn = vl + p[j] + p[i];
62  vnew = vn.Mag2();
63  if (vnew > vmax) {
64  vmax = vnew;
65  vm = vn;
66  }
67  vn = vl + p[j] - p[i];
68  vnew = vn.Mag2();
69  if (vnew > vmax) {
70  vmax = vnew;
71  vm = vn;
72  }
73  vn = vl - p[j] + p[i];
74  vnew = vn.Mag2();
75  if (vnew > vmax) {
76  vmax = vnew;
77  vm = vn;
78  }
79  vn = vl - p[j] - p[i];
80  vnew = vn.Mag2();
81  if (vnew > vmax) {
82  vmax = vnew;
83  vm = vn;
84  }
85  }
86  // sum momenta of all particles and iterate
87  for(int iter=1; iter<=4; iter++) {
88  qtbo = zero;
89  for(unsigned int i=0; i< Np; i++)
90  if (vm.Dot(p[i]) >= 0.)
91  qtbo = qtbo + p[i];
92  else
93  qtbo = qtbo - p[i];
94  vnew = qtbo.Mag2();
95  if (vnew == vmax) break;
96  vmax = vnew;
97  vm = qtbo;
98  }
99  } // of if Np > 2
100  else
101  if (Np == 2)
102  if (p[0].Dot(p[1]) >= 0.)
103  qtbo = p[0] + p[1];
104  else
105  qtbo = p[0] - p[1];
106  else if (Np == 1)
107  qtbo = p[0];
108  else {
109  qtbo = zero;
110  return output;
111  }
112  // normalize thrust -division by total momentum-
113  float vsum = 0.;
114  for(unsigned int i=0; i < Np; i++) vsum = vsum + p[i].Mag();
115  vnew = qtbo.Mag();
116  float v = vnew/vsum;
117  float x = qtbo.X()/vnew;
118  float y = qtbo.Y()/vnew;
119  float z = qtbo.Z()/vnew;
120  output.SetPxPyPzE(x, y, z, v);
121  return output;
122 }
int i
Definition: DBlmapReader.cc:9
double double double z
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
Definition: DDAxes.h:10
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:23
std::vector< TVector3 > p
Definition: EventShape.h:24
mathSSE::Vec4< T > v

Member Data Documentation

std::vector<float> EventShape::eigenvalues
private

Definition at line 25 of file EventShape.h.

Referenced by aplanarity(), EventShape(), planarity(), and sphericity().

std::vector<TVector3> EventShape::p
private