CMS 3D CMS Logo

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

Class for the calculation of several event shape variables. More...

#include "PhysicsTools/CandUtils/interface/EventShapeVariables.h"

Public Member Functions

double aplanarity (double=2.) const
 
double C (double=2.) const
 
double circularity (const unsigned int &numberOfSteps=1000) const
 
double D (double=2.) const
 
 EventShapeVariables (const edm::View< reco::Candidate > &inputVectors)
 constructor from reco::Candidates More...
 
 EventShapeVariables (const std::vector< math::XYZVector > &inputVectors)
 constructor from XYZ coordinates More...
 
 EventShapeVariables (const std::vector< math::RhoEtaPhiVector > &inputVectors)
 constructor from rho eta phi coordinates More...
 
 EventShapeVariables (const std::vector< math::RThetaPhiVector > &inputVectors)
 constructor from r theta phi coordinates More...
 
double isotropy (const unsigned int &numberOfSteps=1000) const
 
double sphericity (double=2.) const
 
 ~EventShapeVariables ()
 default destructor More...
 

Private Member Functions

TVectorD compEigenValues (double=2.) const
 
TMatrixDSym compMomentumTensor (double=2.) const
 helper function to fill the 3 dimensional momentum tensor from the inputVecotrs where needed More...
 

Private Attributes

std::vector< math::XYZVectorinputVectors_
 cashing of input vectors More...
 

Detailed Description

Class for the calculation of several event shape variables.

Class for the calculation of several event shape variables. Isotropy, sphericity, aplanarity and circularity are supported. The class supports vectors of 3d vectors and edm::Views of reco::Candidates as input. The 3d vectors can be given in cartesian, cylindrical or polar coordinates. It exploits the ROOT::TMatrixDSym for the calculation of the sphericity and aplanarity.

See http://cepa.fnal.gov/psm/simulation/mcgen/lund/pythia_manual/pythia6.3/pythia6301/node213.html for an explanation of sphericity, aplanarity and the quantities C and D.

Author: Sebastian Naumann-Emme, University of Hamburg Roger Wolf, University of Hamburg Christian Veelken, UC Davis

Definition at line 32 of file EventShapeVariables.h.

Constructor & Destructor Documentation

EventShapeVariables::EventShapeVariables ( const edm::View< reco::Candidate > &  inputVectors)
explicit

constructor from reco::Candidates

Definition at line 6 of file EventShapeVariables.cc.

References edm::View< T >::begin(), gather_cfg::cout, edm::View< T >::end(), inputVectors_, and edm::View< T >::size().

7 {
8  std::cout << "inputVectors.size = " << inputVectors.size() << std::endl;
9  inputVectors_.reserve( inputVectors.size() );
10  for ( edm::View<reco::Candidate>::const_iterator vec = inputVectors.begin(); vec != inputVectors.end(); ++vec){
11  inputVectors_.push_back(math::XYZVector(vec->px(), vec->py(), vec->pz()));
12  }
13 }
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
std::vector< math::XYZVector > inputVectors_
cashing of input vectors
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
size_type size() const
const_iterator begin() const
tuple cout
Definition: gather_cfg.py:121
const_iterator end() const
EventShapeVariables::EventShapeVariables ( const std::vector< math::XYZVector > &  inputVectors)
explicit

constructor from XYZ coordinates

Definition at line 16 of file EventShapeVariables.cc.

17  : inputVectors_(inputVectors)
18 {}
std::vector< math::XYZVector > inputVectors_
cashing of input vectors
EventShapeVariables::EventShapeVariables ( const std::vector< math::RhoEtaPhiVector > &  inputVectors)
explicit

constructor from rho eta phi coordinates

Definition at line 21 of file EventShapeVariables.cc.

References inputVectors_.

22 {
23  inputVectors_.reserve( inputVectors.size() );
24  for ( std::vector<math::RhoEtaPhiVector>::const_iterator vec = inputVectors.begin(); vec != inputVectors.end(); ++vec ){
25  inputVectors_.push_back(math::XYZVector(vec->x(), vec->y(), vec->z()));
26  }
27 }
std::vector< math::XYZVector > inputVectors_
cashing of input vectors
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
EventShapeVariables::EventShapeVariables ( const std::vector< math::RThetaPhiVector > &  inputVectors)
explicit

constructor from r theta phi coordinates

Definition at line 30 of file EventShapeVariables.cc.

References inputVectors_.

31 {
32  inputVectors_.reserve( inputVectors.size() );
33  for(std::vector<math::RThetaPhiVector>::const_iterator vec = inputVectors.begin(); vec != inputVectors.end(); ++vec ){
34  inputVectors_.push_back(math::XYZVector(vec->x(), vec->y(), vec->z()));
35  }
36 }
std::vector< math::XYZVector > inputVectors_
cashing of input vectors
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
EventShapeVariables::~EventShapeVariables ( )
inline

default destructor

Definition at line 44 of file EventShapeVariables.h.

44 {};

Member Function Documentation

double EventShapeVariables::aplanarity ( double  r = 2.) const

1.5*q1 where 0<=q1<=q2<=q3 are the eigenvalues of the momemtum tensor sum{p_j[a]*p_j[b]}/sum{p_j**2} normalized to 1. Return values are 0.5 for spherical and 0 for plane and linear events

1.5*q1 where 0<=q1<=q2<=q3 are the eigenvalues of the momentum tensor sum{p_j[a]*p_j[b]}/sum{p_j**2} normalized to 1. Return values are 0.5 for spherical and 0 for plane and linear events

Definition at line 153 of file EventShapeVariables.cc.

References compEigenValues().

Referenced by TtFullHadSignalSel::TtFullHadSignalSel().

154 {
155  TVectorD eigenValues = compEigenValues(r);
156  return 1.5*eigenValues(2);
157 }
TVectorD compEigenValues(double=2.) const
double EventShapeVariables::C ( double  r = 2.) const

3.*(q1*q2+q1*q3+q2*q3) where 0<=q1<=q2<=q3 are the eigenvalues of the momemtum tensor sum{p_j[a]*p_j[b]}/sum{p_j**2} normalized to 1. Return value is between 0 and 1 and measures the 3-jet structure of the event (C vanishes for a "perfect" 2-jet event)

3.*(q1*q2+q1*q3+q2*q3) where 0<=q1<=q2<=q3 are the eigenvalues of the momentum tensor sum{p_j[a]*p_j[b]}/sum{p_j**2} normalized to 1. Return value is between 0 and 1 and measures the 3-jet structure of the event (C vanishes for a "perfect" 2-jet event)

Definition at line 163 of file EventShapeVariables.cc.

References compEigenValues().

Referenced by TtFullHadSignalSel::TtFullHadSignalSel().

164 {
165  TVectorD eigenValues = compEigenValues(r);
166  return 3.*(eigenValues(0)*eigenValues(1) + eigenValues(0)*eigenValues(2) + eigenValues(1)*eigenValues(2));
167 }
TVectorD compEigenValues(double=2.) const
double EventShapeVariables::circularity ( const unsigned int &  numberOfSteps = 1000) const

the return value is 1 for spherical and 0 linear events in r-phi. This function needs the number of steps to determine how fine the granularity of the algorithm in phi should be

Definition at line 62 of file EventShapeVariables.cc.

References Abs(), SiPixelRawToDigiRegional_cfi::deltaPhi, i, inputVectors_, j, phi, Pi, tmp, x, and detailsBasic3DVector::y.

Referenced by TtFullHadSignalSel::TtFullHadSignalSel().

63 {
64  const double deltaPhi=2*TMath::Pi()/numberOfSteps;
65  double circularity=-1, phi=0, area = 0;
66  for(unsigned int i=0;i<inputVectors_.size();i++) {
67  area+=TMath::Sqrt(inputVectors_[i].x()*inputVectors_[i].x()+inputVectors_[i].y()*inputVectors_[i].y());
68  }
69  for(unsigned int i=0; i<numberOfSteps; ++i){
70  phi+=deltaPhi;
71  double sum=0, tmp=0.;
72  for(unsigned int j=0; j<inputVectors_.size(); ++j){
73  sum+=TMath::Abs(TMath::Cos(phi)*inputVectors_[j].x()+TMath::Sin(phi)*inputVectors_[j].y());
74  }
75  tmp=TMath::Pi()/2*sum/area;
76  if( circularity<0 || tmp<circularity ){
77  circularity=tmp;
78  }
79  }
80  return circularity;
81 }
const double Pi
int i
Definition: DBlmapReader.cc:9
double circularity(const unsigned int &numberOfSteps=1000) const
T Abs(T a)
Definition: MathUtil.h:49
int j
Definition: DBlmapReader.cc:9
std::vector< math::XYZVector > inputVectors_
cashing of input vectors
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
Definition: DDAxes.h:10
Definition: DDAxes.h:10
TVectorD EventShapeVariables::compEigenValues ( double  r = 2.) const
private

helper function to fill the 3 dimensional vector of eigen-values; the largest (smallest) eigen-value is stored at index position 0 (2)

Definition at line 124 of file EventShapeVariables.cc.

References compMomentumTensor().

Referenced by aplanarity(), C(), D(), and sphericity().

125 {
126  TVectorD eigenValues(3);
127  TMatrixDSym myTensor = compMomentumTensor(r);
128  if( myTensor.IsSymmetric() ){
129  if( myTensor.NonZeros() != 0 ) myTensor.EigenVectors(eigenValues);
130  }
131 
132  // CV: TMatrixDSym::EigenVectors returns eigen-values and eigen-vectors
133  // ordered by descending eigen-values, so no need to do any sorting here...
134  //std::cout << "eigenValues(0) = " << eigenValues(0) << ","
135  // << " eigenValues(1) = " << eigenValues(1) << ","
136  // << " eigenValues(2) = " << eigenValues(2) << std::endl;
137 
138  return eigenValues;
139 }
TMatrixDSym compMomentumTensor(double=2.) const
helper function to fill the 3 dimensional momentum tensor from the inputVecotrs where needed ...
TMatrixDSym EventShapeVariables::compMomentumTensor ( double  r = 2.) const
private

helper function to fill the 3 dimensional momentum tensor from the inputVecotrs where needed

helper function to fill the 3 dimensional momentum tensor from the inputVectors where needed

Definition at line 85 of file EventShapeVariables.cc.

References i, inputVectors_, and p2.

Referenced by compEigenValues().

86 {
87  TMatrixDSym momentumTensor(3);
88  momentumTensor.Zero();
89 
90  if ( inputVectors_.size() < 2 ){
91  return momentumTensor;
92  }
93 
94  // fill momentumTensor from inputVectors
95  double norm = 0.;
96  for ( int i = 0; i < (int)inputVectors_.size(); ++i ){
97  double p2 = inputVectors_[i].Dot(inputVectors_[i]);
98  double pR = ( r == 2. ) ? p2 : TMath::Power(p2, 0.5*r);
99  norm += pR;
100  double pRminus2 = ( r == 2. ) ? 1. : TMath::Power(p2, 0.5*r - 1.);
101  momentumTensor(0,0) += pRminus2*inputVectors_[i].x()*inputVectors_[i].x();
102  momentumTensor(0,1) += pRminus2*inputVectors_[i].x()*inputVectors_[i].y();
103  momentumTensor(0,2) += pRminus2*inputVectors_[i].x()*inputVectors_[i].z();
104  momentumTensor(1,0) += pRminus2*inputVectors_[i].y()*inputVectors_[i].x();
105  momentumTensor(1,1) += pRminus2*inputVectors_[i].y()*inputVectors_[i].y();
106  momentumTensor(1,2) += pRminus2*inputVectors_[i].y()*inputVectors_[i].z();
107  momentumTensor(2,0) += pRminus2*inputVectors_[i].z()*inputVectors_[i].x();
108  momentumTensor(2,1) += pRminus2*inputVectors_[i].z()*inputVectors_[i].y();
109  momentumTensor(2,2) += pRminus2*inputVectors_[i].z()*inputVectors_[i].z();
110  }
111 
112  //std::cout << "momentumTensor:" << std::endl;
113  //std::cout << momentumTensor(0,0) << " " << momentumTensor(0,1) << " " << momentumTensor(0,2)
114  // << momentumTensor(1,0) << " " << momentumTensor(1,1) << " " << momentumTensor(1,2)
115  // << momentumTensor(2,0) << " " << momentumTensor(2,1) << " " << momentumTensor(2,2) << std::endl;
116 
117  // return momentumTensor normalized to determinant 1
118  return (1./norm)*momentumTensor;
119 }
int i
Definition: DBlmapReader.cc:9
double p2[4]
Definition: TauolaWrapper.h:90
std::vector< math::XYZVector > inputVectors_
cashing of input vectors
double EventShapeVariables::D ( double  r = 2.) const

27.*(q1*q2*q3) where 0<=q1<=q2<=q3 are the eigenvalues of the momemtum tensor sum{p_j[a]*p_j[b]}/sum{p_j**2} normalized to 1. Return value is between 0 and 1 and measures the 4-jet structure of the event (D vanishes for a planar event)

Definition at line 173 of file EventShapeVariables.cc.

References compEigenValues().

Referenced by TtFullHadSignalSel::TtFullHadSignalSel().

174 {
175  TVectorD eigenValues = compEigenValues(r);
176  return 27.*eigenValues(0)*eigenValues(1)*eigenValues(2);
177 }
TVectorD compEigenValues(double=2.) const
double EventShapeVariables::isotropy ( const unsigned int &  numberOfSteps = 1000) const

the return value is 1 for spherical events and 0 for events linear in r-phi. This function needs the number of steps to determine how fine the granularity of the algorithm in phi should be

Definition at line 42 of file EventShapeVariables.cc.

References Abs(), SiPixelRawToDigiRegional_cfi::deltaPhi, i, inputVectors_, j, phi, Pi, x, and detailsBasic3DVector::y.

Referenced by TtFullHadSignalSel::TtFullHadSignalSel().

43 {
44  const double deltaPhi=2*TMath::Pi()/numberOfSteps;
45  double phi = 0, eIn =-1., eOut=-1.;
46  for(unsigned int i=0; i<numberOfSteps; ++i){
47  phi+=deltaPhi;
48  double sum=0;
49  for(unsigned int j=0; j<inputVectors_.size(); ++j){
50  // sum over inner product of unit vectors and momenta
51  sum+=TMath::Abs(TMath::Cos(phi)*inputVectors_[j].x()+TMath::Sin(phi)*inputVectors_[j].y());
52  }
53  if( eOut<0. || sum<eOut ) eOut=sum;
54  if( eIn <0. || sum>eIn ) eIn =sum;
55  }
56  return (eIn-eOut)/eIn;
57 }
const double Pi
int i
Definition: DBlmapReader.cc:9
T Abs(T a)
Definition: MathUtil.h:49
int j
Definition: DBlmapReader.cc:9
std::vector< math::XYZVector > inputVectors_
cashing of input vectors
Definition: DDAxes.h:10
Definition: DDAxes.h:10
double EventShapeVariables::sphericity ( double  r = 2.) const

1.5*(q1+q2) where 0<=q1<=q2<=q3 are the eigenvalues of the momemtum tensor sum{p_j[a]*p_j[b]}/sum{p_j**2} normalized to 1. Return values are 1 for spherical, 3/4 for plane and 0 for linear events

1.5*(q1+q2) where 0<=q1<=q2<=q3 are the eigenvalues of the momentum tensor sum{p_j[a]*p_j[b]}/sum{p_j**2} normalized to 1. Return values are 1 for spherical, 3/4 for plane and 0 for linear events

Definition at line 144 of file EventShapeVariables.cc.

References compEigenValues().

Referenced by TtFullHadSignalSel::TtFullHadSignalSel().

145 {
146  TVectorD eigenValues = compEigenValues(r);
147  return 1.5*(eigenValues(1) + eigenValues(2));
148 }
TVectorD compEigenValues(double=2.) const

Member Data Documentation

std::vector<math::XYZVector> EventShapeVariables::inputVectors_
private

cashing of input vectors

Definition at line 79 of file EventShapeVariables.h.

Referenced by circularity(), compMomentumTensor(), EventShapeVariables(), and isotropy().