ATLAS Offline Software
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
CaloClusterVariables Class Reference

Provide calculations of cluster based variables using the clusters associated to the jet seed of the tau candidate. More...

#include <CaloClusterVariables.h>

Collaboration diagram for CaloClusterVariables:

Public Member Functions

 CaloClusterVariables ()
 
 ~CaloClusterVariables ()
 
bool update (const xAOD::TauJet &pTau)
 update the internal variables for the given tau More...
 
unsigned int numConstituents () const
 
double totalMass () const
 
double effectiveMass () const
 
double effectiveNumConstituents () const
 
int effectiveNumConstituents_int () const
 
double averageEffectiveRadius () const
 
double averageRadius () const
 
double totalEnergy ()
 
double effectiveEnergy ()
 

Static Public Attributes

static const double DEFAULT = -1111.
 

Private Member Functions

TLorentzVector calculateTauCentroid (int nConst, const std::vector< TLorentzVector > &clusterP4Vector) const
 

Private Attributes

int m_numConstit
 
int m_effNumConstit_int
 
double m_effNumConstit
 
double m_aveRadius
 
double m_aveEffRadius
 
double m_totMass
 
double m_effMass
 
double m_totEnergy
 
double m_effEnergy
 

Detailed Description

Provide calculations of cluster based variables using the clusters associated to the jet seed of the tau candidate.

Definition at line 16 of file CaloClusterVariables.h.

Constructor & Destructor Documentation

◆ CaloClusterVariables()

CaloClusterVariables::CaloClusterVariables ( )

Definition at line 18 of file CaloClusterVariables.cxx.

◆ ~CaloClusterVariables()

CaloClusterVariables::~CaloClusterVariables ( )
inline

Definition at line 23 of file CaloClusterVariables.h.

23  {
24  }

Member Function Documentation

◆ averageEffectiveRadius()

double CaloClusterVariables::averageEffectiveRadius ( ) const
inline

Definition at line 37 of file CaloClusterVariables.h.

37 { return m_aveEffRadius; }

◆ averageRadius()

double CaloClusterVariables::averageRadius ( ) const
inline

Definition at line 38 of file CaloClusterVariables.h.

38 { return m_aveRadius; }

◆ calculateTauCentroid()

TLorentzVector CaloClusterVariables::calculateTauCentroid ( int  nConst,
const std::vector< TLorentzVector > &  clusterP4Vector 
) const
private

Definition at line 142 of file CaloClusterVariables.cxx.

142  {
143 
144  double px = 0.;
145  double py = 0.;
146  double pz = 0.;
147  double modulus = 0.;
148 
149  for (const TLorentzVector& clusterP4: clusterP4Vector) {
150  if (nConst <= 0) break;
151  --nConst;
152 
153  modulus = std::sqrt((clusterP4.Px() * clusterP4.Px()) + (clusterP4.Py() * clusterP4.Py()) + (clusterP4.Pz() * clusterP4.Pz()));
154 
155  px += clusterP4.Px() / modulus;
156  py += clusterP4.Py() / modulus;
157  pz += clusterP4.Pz() / modulus;
158 
159  }
160 
161  TLorentzVector centroid(px, py, pz, 1);
162  return centroid;
163 }

◆ effectiveEnergy()

double CaloClusterVariables::effectiveEnergy ( )
inline

Definition at line 42 of file CaloClusterVariables.h.

42 { return m_effEnergy; }

◆ effectiveMass()

double CaloClusterVariables::effectiveMass ( ) const
inline

Definition at line 32 of file CaloClusterVariables.h.

32 { return m_effMass; }

◆ effectiveNumConstituents()

double CaloClusterVariables::effectiveNumConstituents ( ) const
inline

Definition at line 34 of file CaloClusterVariables.h.

34 { return m_effNumConstit; }

◆ effectiveNumConstituents_int()

int CaloClusterVariables::effectiveNumConstituents_int ( ) const
inline

Definition at line 35 of file CaloClusterVariables.h.

35 { return m_effNumConstit_int; }

◆ numConstituents()

unsigned int CaloClusterVariables::numConstituents ( ) const
inline

Definition at line 29 of file CaloClusterVariables.h.

29 { return (unsigned int) m_numConstit; }

◆ totalEnergy()

double CaloClusterVariables::totalEnergy ( )
inline

Definition at line 41 of file CaloClusterVariables.h.

41 { return m_totEnergy; }

◆ totalMass()

double CaloClusterVariables::totalMass ( ) const
inline

Definition at line 31 of file CaloClusterVariables.h.

31 { return m_totMass; }

◆ update()

bool CaloClusterVariables::update ( const xAOD::TauJet pTau)

update the internal variables for the given tau

Definition at line 34 of file CaloClusterVariables.cxx.

34  {
35 
36  const auto& vertexedClusterList = pTau.vertexedClusters();
37 
38  std::vector<TLorentzVector> clusterP4Vector;
39  clusterP4Vector.reserve(vertexedClusterList.size());
40 
41  for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : vertexedClusterList) {
42  clusterP4Vector.push_back(vertexedCluster.p4());
43  }
44 
45  this->m_numConstit = (int) clusterP4Vector.size();
46 
47  // Order constituents by energy
48  sort(clusterP4Vector.begin(), clusterP4Vector.end(), CaloClusterCompare());
49 
50  //****************************************
51  // Looping over all constituents
52  //****************************************
53 
54  double sum_px = 0.;
55  double sum_py = 0.;
56  double sum_pz = 0.;
57  double sum_e = 0.;
58  double sum_of_E2 = 0.;
59  double sum_radii = 0.;
60  TLorentzVector centroid = calculateTauCentroid(this->m_numConstit, clusterP4Vector);
61 
62  for (const TLorentzVector& clusterP4 : clusterP4Vector) {
63 
64  sum_of_E2 += clusterP4.E()*clusterP4.E();
65  sum_radii += clusterP4.DeltaR(centroid);
66  sum_e += clusterP4.E();
67  sum_px += clusterP4.Px();
68  sum_py += clusterP4.Py();
69  sum_pz += clusterP4.Pz();
70 
71  }
72 
73  // Sum up the energy for constituents
74  this->m_totEnergy = sum_e;
75 
76  // Calculate the mass of the constituents
77  if (this->m_numConstit < 2) this->m_totMass = DEFAULT;
78  else {
79  double mass2 = sum_e * sum_e - (sum_px * sum_px + sum_py * sum_py + sum_pz * sum_pz);
80  this->m_totMass = mass2 > 0 ? std::sqrt(mass2) : -std::sqrt(-mass2);
81  }
82 
83  // Calculate the average radius of the constituents wrt the tau centroid
84  this->m_aveRadius = this->m_numConstit > 0 ? sum_radii / this->m_numConstit : DEFAULT;
85 
86  // Effective number of constituents
87  this->m_effNumConstit = sum_of_E2 > 0 ? (sum_e * sum_e) / (sum_of_E2) : DEFAULT;
88 
89  this->m_effNumConstit_int = int(ceil(this->m_effNumConstit));
90 
91  // A problem!
92  if (this->m_effNumConstit_int > this->m_numConstit) return false;
93 
94  // Avoid segfault, happens when we try to iterate below if sum_of_E2 was 0 or negative
95  if (this->m_effNumConstit_int < 0) return false;
96 
97  //****************************************
98  // Now: Looping over effective constituents
99  //****************************************
100 
101  sum_px = 0.;
102  sum_py = 0.;
103  sum_pz = 0.;
104  sum_e = 0.;
105  sum_of_E2 = 0.;
106  sum_radii = 0.;
107  centroid = calculateTauCentroid(this->m_effNumConstit_int, clusterP4Vector);
108 
109  int icount = this->m_effNumConstit_int;
110  for (const TLorentzVector& clusterP4 : clusterP4Vector) {
111  if (icount <= 0) break;
112  --icount;
113 
114  sum_radii += clusterP4.DeltaR(centroid);
115  sum_e += clusterP4.E();
116  sum_px += clusterP4.Px();
117  sum_py += clusterP4.Py();
118  sum_pz += clusterP4.Pz();
119 
120  }
121 
122  // Sum up the energy for effective constituents
123  this->m_effEnergy = sum_e;
124 
125  // Calculate the mass of the constituents
126  if (this->m_effNumConstit_int < 2) this->m_effMass = DEFAULT;
127  else {
128  double mass2 = sum_e * sum_e - (sum_px * sum_px + sum_py * sum_py + sum_pz * sum_pz);
129  this->m_effMass = mass2 > 0 ? std::sqrt(mass2) : -std::sqrt(-mass2);
130  }
131 
132  // Calculate the average radius of the constituents wrt the tau centroid
133  this->m_aveEffRadius = this->m_effNumConstit_int > 0 ? sum_radii / this->m_effNumConstit_int : DEFAULT;
134 
135  return true;
136 }

Member Data Documentation

◆ DEFAULT

const double CaloClusterVariables::DEFAULT = -1111.
static

Definition at line 19 of file CaloClusterVariables.h.

◆ m_aveEffRadius

double CaloClusterVariables::m_aveEffRadius
private

Definition at line 49 of file CaloClusterVariables.h.

◆ m_aveRadius

double CaloClusterVariables::m_aveRadius
private

Definition at line 48 of file CaloClusterVariables.h.

◆ m_effEnergy

double CaloClusterVariables::m_effEnergy
private

Definition at line 53 of file CaloClusterVariables.h.

◆ m_effMass

double CaloClusterVariables::m_effMass
private

Definition at line 51 of file CaloClusterVariables.h.

◆ m_effNumConstit

double CaloClusterVariables::m_effNumConstit
private

Definition at line 47 of file CaloClusterVariables.h.

◆ m_effNumConstit_int

int CaloClusterVariables::m_effNumConstit_int
private

Definition at line 46 of file CaloClusterVariables.h.

◆ m_numConstit

int CaloClusterVariables::m_numConstit
private

Definition at line 45 of file CaloClusterVariables.h.

◆ m_totEnergy

double CaloClusterVariables::m_totEnergy
private

Definition at line 52 of file CaloClusterVariables.h.

◆ m_totMass

double CaloClusterVariables::m_totMass
private

Definition at line 50 of file CaloClusterVariables.h.


The documentation for this class was generated from the following files:
CaloClusterVariables::m_effEnergy
double m_effEnergy
Definition: CaloClusterVariables.h:53
test_pyathena.px
px
Definition: test_pyathena.py:18
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CaloClusterVariables::m_aveRadius
double m_aveRadius
Definition: CaloClusterVariables.h:48
CaloClusterVariables::m_totEnergy
double m_totEnergy
Definition: CaloClusterVariables.h:52
CaloClusterVariables::DEFAULT
static const double DEFAULT
Definition: CaloClusterVariables.h:19
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:554
CaloClusterVariables::calculateTauCentroid
TLorentzVector calculateTauCentroid(int nConst, const std::vector< TLorentzVector > &clusterP4Vector) const
Definition: CaloClusterVariables.cxx:142
CaloClusterVariables::m_totMass
double m_totMass
Definition: CaloClusterVariables.h:50
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
Amg::py
@ py
Definition: GeoPrimitives.h:39
xAOD::TauJet_v3::vertexedClusters
std::vector< xAOD::CaloVertexedTopoCluster > vertexedClusters() const
Definition: TauJet_v3.cxx:626
CaloClusterVariables::m_numConstit
int m_numConstit
Definition: CaloClusterVariables.h:45
CaloClusterVariables::m_effNumConstit
double m_effNumConstit
Definition: CaloClusterVariables.h:47
CaloClusterVariables::m_effNumConstit_int
int m_effNumConstit_int
Definition: CaloClusterVariables.h:46
CaloClusterCompare
Descending order by energy.
Definition: CaloClusterVariables.h:62
xAOD::CaloVertexedTopoCluster
Evaluate cluster kinematics with a different vertex / signal state.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloVertexedTopoCluster.h:38
NSWL1::centroid
Vertex centroid(const Polygon &p)
Definition: GeoUtils.cxx:59
CaloClusterVariables::m_effMass
double m_effMass
Definition: CaloClusterVariables.h:51
CaloClusterVariables::m_aveEffRadius
double m_aveEffRadius
Definition: CaloClusterVariables.h:49