ATLAS Offline Software
Loading...
Searching...
No Matches
SphericityTensor.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "TMatrixD.h"
8#include "TDecompSVD.h"
9#include "TLorentzVector.h"
11
12using namespace std;
13using namespace JetSubStructureUtils;
14
15map<string, double> SphericityTensor::result(const fastjet::PseudoJet &jet) const
16{
17 map<string, double> Variables;
18 Variables["Sphericity"] = -999.*1000.;
19 Variables["Aplanarity"] = -999.*1000.;
20
21 vector<fastjet::PseudoJet> clusters = boostToCenterOfMass(jet, jet.constituents());
22 if(clusters.size() < 2) return Variables;
23
24 TMatrixD MomentumTensor(3,3);
25 double P2Sum = 0;
26
27 for(std::vector<fastjet::PseudoJet>::const_iterator Itr=clusters.begin(); Itr!=clusters.end(); ++Itr) {
28 MomentumTensor(0,0) += (*Itr).px()*(*Itr).px();
29 MomentumTensor(0,1) += (*Itr).px()*(*Itr).py();
30 MomentumTensor(0,2) += (*Itr).px()*(*Itr).pz();
31 MomentumTensor(1,0) += (*Itr).py()*(*Itr).px();
32 MomentumTensor(1,1) += (*Itr).py()*(*Itr).py();
33 MomentumTensor(1,2) += (*Itr).py()*(*Itr).pz();
34 MomentumTensor(2,0) += (*Itr).pz()*(*Itr).px();
35 MomentumTensor(2,1) += (*Itr).pz()*(*Itr).py();
36 MomentumTensor(2,2) += (*Itr).pz()*(*Itr).pz();
37
38 P2Sum += (*Itr).px()*(*Itr).px()+(*Itr).py()*(*Itr).py()+(*Itr).pz()*(*Itr).pz();
39 }
40
41 double Aplanarity = -1;
42 double Sphericity = -1;
43
44 if(P2Sum > 0) {
45 const double inv_P2Sum = 1. / P2Sum;
46 for(int i=0; i<3; i++) {
47 for(int j=0; j<3; j++) {
48 MomentumTensor(i,j) *= inv_P2Sum;
49 }
50 }
51
52 TDecompSVD * aSVD = new TDecompSVD(MomentumTensor);
53 TVectorD Lambda = aSVD->GetSig();
54
55 Aplanarity = 1.5*Lambda[2];
56 Sphericity = 1.5*(Lambda[1]+Lambda[2]);
57
58 delete aSVD;
59 }
60 else {
61 return Variables;
62 }
63
64 Variables["Aplanarity"] = Aplanarity;
65 Variables["Sphericity"] = Sphericity;
66 return Variables;
67}
virtual std::map< std::string, double > result(const fastjet::PseudoJet &jet) const
std::vector< fastjet::PseudoJet > boostToCenterOfMass(const fastjet::PseudoJet &jet, std::vector< fastjet::PseudoJet > constituents)
STL namespace.