ATLAS Offline Software
Dipolarity.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 "fastjet/ClusterSequence.hh"
7 #include "fastjet/JetDefinition.hh"
8 #include "TVector2.h"
9 #include <math.h>
10 #include <iostream>
11 
12 using namespace std;
13 using namespace JetSubStructureUtils;
14 
15 Dipolarity::Dipolarity(unsigned int n1, unsigned int n2, bool exclusive, double subjetR) :
16  m_exclusive(exclusive),
17  m_n1(n1),
18  m_n2(n2),
19  m_subjetR(subjetR) {
20 
21  if(m_n2 <= m_n1 || m_n1 == 0) {
22  cout << "dipolarity was called with invalid arguments" << endl;
23  }
24 }
25 
26 double Dipolarity::result(const fastjet::PseudoJet &jet) const
27 {
28  vector<fastjet::PseudoJet> constit_pseudojets = jet.constituents();
29  if(constit_pseudojets.empty()) return -1;
30 
31  vector<fastjet::PseudoJet> kt_subjets;
32  fastjet::PseudoJet jet1, jet2;
33 
34  if(!m_exclusive) {
35  fastjet::JetDefinition jet_def = fastjet::JetDefinition(fastjet::kt_algorithm, m_subjetR,
36  fastjet::E_scheme, fastjet::Best);
37  fastjet::ClusterSequence kt_clust_seq(constit_pseudojets, jet_def);
38  kt_subjets = fastjet::sorted_by_pt(kt_clust_seq.inclusive_jets(5000.0));
39 
40  if(kt_subjets.size() < m_n2) {
41  //Not enough subjets
42  return 0.0;
43  }
44  }
45  else {
46  if(m_n2 > constit_pseudojets.size()) {
47  //We were asked to calculate exclusiveDipolarity, but there are not enough constituents
48  return 0.0;
49  }
50 
51  fastjet::JetDefinition jet_def = fastjet::JetDefinition(fastjet::kt_algorithm, 1.5,
52  fastjet::E_scheme, fastjet::Best);
53  fastjet::ClusterSequence kt_clust_seq(constit_pseudojets, jet_def);
54  kt_subjets = fastjet::sorted_by_pt(kt_clust_seq.exclusive_jets((int)m_n2));
55  }
56 
57  jet1 = kt_subjets[m_n1-1];
58  jet2 = kt_subjets[m_n2-1];
59  return dipolarity(constit_pseudojets, jet1, jet2);
60 }
61 
62 double Dipolarity::dipolarity(vector<fastjet::PseudoJet> &constit_pseudojets,
63  const fastjet::PseudoJet& jet1, const fastjet::PseudoJet& jet2) const
64 {
65  float dipolarity = 0;
66  float sumpt = 0;
67 
68  TVector2 v12(jet2.eta() - jet1.eta(), jet1.delta_phi_to(jet2));
69  if(v12.Mod2() < 0.001) return -1;
70 
71  for(unsigned int iConstit = 0; iConstit < constit_pseudojets.size(); iConstit++) {
72  fastjet::PseudoJet constituent = constit_pseudojets[iConstit];
73 
74  sumpt += constituent.perp();
75 
76  TVector2 v;
77 
78  v.Set(constituent.eta() - jet1.eta(), jet1.delta_phi_to(constituent));
79  float test = v * v12.Unit();
80 
81  if(test < 0)
82  dipolarity += constituent.perp()*v.Mod2();
83  else if(test < v12.Mod())
84  dipolarity += constituent.perp()*(v.Mod2() - pow(v * v12.Unit(), 2));
85  else {
86  v.Set(constituent.eta() - jet2.eta(), jet2.delta_phi_to(constituent));
87  dipolarity += constituent.perp()*v.Mod2();
88  }
89  }
90 
91  if(sumpt < 0.001) return -1;
92  return dipolarity/(sumpt*v12.Mod2());
93 }
JetSubStructureUtils::Dipolarity::dipolarity
double dipolarity(std::vector< fastjet::PseudoJet > &constit_pseudojets, const fastjet::PseudoJet &jet1, const fastjet::PseudoJet &jet2) const
Definition: Dipolarity.cxx:62
xAOD::JetAlgorithmType::kt_algorithm
@ kt_algorithm
Definition: JetContainerInfo.h:31
JetSubStructureUtils::Dipolarity::result
virtual double result(const fastjet::PseudoJet &jet) const
Definition: Dipolarity.cxx:26
JetSubStructureUtils::Dipolarity::m_n2
unsigned int m_n2
Definition: Dipolarity.h:25
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
JetSubStructureUtils
Definition: Angularity.h:10
JetSubStructureUtils::Dipolarity::m_subjetR
double m_subjetR
Definition: Dipolarity.h:26
JetSubStructureUtils::Dipolarity::m_exclusive
bool m_exclusive
Definition: Dipolarity.h:23
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
jet::ClusterSequence
fastjet::ClusterSequence ClusterSequence
Definition: ClusterSequence.h:21
Dipolarity.h
Rtt_histogram.n1
n1
Definition: Rtt_histogram.py:21
python.PyAthena.v
v
Definition: PyAthena.py:154
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
JetSubStructureUtils::Dipolarity::m_n1
unsigned int m_n1
Definition: Dipolarity.h:24