ATLAS Offline Software
PlanarFlow.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "TMatrixDSym.h"
7 #include "TMatrixDSymEigen.h"
8 #include "TLorentzVector.h"
9 
10 using namespace std;
11 using namespace JetSubStructureUtils;
12 
13 double PlanarFlow::result(const fastjet::PseudoJet &jet) const
14 {
15 
16  double PF=-1.;
17  if(jet.m() == 0.0 ) return PF;
18  if(jet.constituents().empty() ) return PF;
19 
20  vector<fastjet::PseudoJet> constit_pseudojets = jet.constituents();
21 
22  TMatrixDSym MomentumTensor(2);
23  //Planar flow
24  double phi0=jet.phi();
25  double eta0=jet.eta();
26 
27  double nvec[3];
28  nvec[0]=(cos(phi0)/cosh(eta0));
29  nvec[1]=(sin(phi0)/cosh(eta0));
30  nvec[2]=tanh(eta0);
31 
32  //this is the rotation matrix
33  double RotationMatrix[3][3];
34 
35  for(int i=0; i<3; i++) {
36  for(int j=0; j<3; j++) {
37  RotationMatrix[i][j] = 0.;
38  }
39  }
40 
41  const double mag3 = sqrt(nvec[0]*nvec[0] + nvec[1]*nvec[1]+ nvec[2]*nvec[2]);
42  const double mag2 = sqrt(nvec[0]*nvec[0] + nvec[1]*nvec[1]);
43 
44  if(mag3 <= 0) {
45  // Rotation axis is null
46  return PF;
47  }
48 
49  const double inv_mag3 = 1. / mag3;
50 
51  double ctheta0 = nvec[2]*inv_mag3;
52  double stheta0 = mag2*inv_mag3;
53  double cphi0 = (mag2>0.) ? nvec[0]/mag2:0.;
54  double sphi0 = (mag2>0.) ? nvec[1]/mag2:0.;
55 
56  RotationMatrix[0][0] =- ctheta0*cphi0;
57  RotationMatrix[0][1] =- ctheta0*sphi0;
58  RotationMatrix[0][2] = stheta0;
59  RotationMatrix[1][0] = sphi0;
60  RotationMatrix[1][1] =- 1.*cphi0;
61  RotationMatrix[1][2] = 0.;
62  RotationMatrix[2][0] = stheta0*cphi0;
63  RotationMatrix[2][1] = stheta0*sphi0;
64  RotationMatrix[2][2] = ctheta0;
65 
66 
67  for(vector<fastjet::PseudoJet>::iterator cit=constit_pseudojets.begin(); cit != constit_pseudojets.end();
68  ++cit) {
69  const fastjet::PseudoJet & cp = *cit;
70  TLorentzVector p = TLorentzVector(cp.px(),cp.py(),cp.pz(),cp.e());
71  double n=1./(cp.e()*jet.m());
72  double px_rot = RotationMatrix[0][0] * (p.Px())+RotationMatrix[0][1]
73  * (p.Py())+RotationMatrix[0][2]*(p.Pz());
74  double py_rot = RotationMatrix[1][0] * (p.Px())+RotationMatrix[1][1]
75  * (p.Py())+RotationMatrix[1][2]*(p.Pz());
76  double pz_rot = RotationMatrix[2][0] * (p.Px())+RotationMatrix[2][1]
77  * (p.Py())+RotationMatrix[2][2]*(p.Pz());
78 
79  TLorentzVector prot;
80  prot.SetPxPyPzE(px_rot, py_rot, pz_rot, p.E() );
81 
82  MomentumTensor(0,0) += n * prot.Px() * prot.Px();
83  MomentumTensor(0,1) += n * prot.Py() * prot.Px();
84  MomentumTensor(1,0) += n * prot.Px() * prot.Py();
85  MomentumTensor(1,1) += n * prot.Py() * prot.Py();
86  }
87 
88  TMatrixDSymEigen eigen(MomentumTensor);
89  TVectorD Lambda = eigen.GetEigenValues();
90  double num = 4*Lambda[0]*Lambda[1];
91  double den = (Lambda[0]+Lambda[1]) * (Lambda[0]+Lambda[1]);
92  if ( fabs(den) < 1.e-20 ) return PF;
93  PF = num/den;
94  return PF;
95 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
get_generator_info.result
result
Definition: get_generator_info.py:21
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
JetSubStructureUtils
Definition: RCJet.h:49
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
LArNewCalib_PedestalAutoCorr.cp
cp
Definition: LArNewCalib_PedestalAutoCorr.py:175
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
mag2
Scalar mag2() const
mag2 method - forward to squaredNorm()
Definition: AmgMatrixBasePlugin.h:30
FlavorTagDiscriminants::TruthDecoratorHelpers::TruthType::Lambda
@ Lambda
Definition: TruthDecoratorHelpers.h:21
PlanarFlow.h