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, p, and python.multivaluedict::sort().

14  :eigenvalues(3)
15 {
16  for(reco::TrackCollection::const_iterator itTrack = tracks.begin(); itTrack<tracks.end(); ++itTrack) {
17  p.push_back(TVector3(itTrack->px(),itTrack->py(),itTrack->pz()));
18  }
19 
20  // first fill the momentum tensor
21  TMatrixDSym MomentumTensor(3);
22  for(std::vector<TVector3>::const_iterator momentum = p.begin();momentum<p.end();++momentum) {
23  for(unsigned int i=0;i<3;i++)
24  for(unsigned int j=0;j<=i;j++) {
25  MomentumTensor[i][j] += momentum[i]*momentum[j];
26  }
27  }
28  MomentumTensor*=1/(MomentumTensor[0][0]+MomentumTensor[1][1]+MomentumTensor[2][2]);
29  // find the eigen values
30  TMatrixDSymEigen eigen(MomentumTensor);
31  TVectorD eigenvals = eigen.GetEigenValues();
32  eigenvalues[0] = eigenvals[0];
33  eigenvalues[1] = eigenvals[1];
34  eigenvalues[2] = eigenvals[2];
35  sort(eigenvalues.begin(),eigenvalues.end());
36 }
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
std::vector< TVector3 > p
Definition: EventShape.h:24

Member Function Documentation

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

Definition at line 243 of file EventShape.cc.

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

Referenced by TrackerDpgAnalysis::analyze().

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

References eigenvalues.

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

Definition at line 272 of file EventShape.cc.

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

Referenced by TrackerDpgAnalysis::analyze().

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

References eigenvalues.

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

Definition at line 212 of file EventShape.cc.

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

Referenced by TrackerDpgAnalysis::analyze().

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

References eigenvalues.

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

Definition at line 123 of file EventShape.cc.

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

Referenced by TrackerDpgAnalysis::analyze().

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

Definition at line 38 of file EventShape.cc.

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

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