ATLAS Offline Software
Volatility.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 using namespace std;
9 using namespace JetSubStructureUtils;
10 
11 double Volatility::result(const fastjet::PseudoJet &jet) const
12 {
13  vector<fastjet::PseudoJet> constit_pseudojets = jet.constituents();
14  if(constit_pseudojets.empty()) return -999;
15 
16  QjetsPlugin qjets_plugin(m_zcut, m_dcut_fctr, m_exp_min, m_exp_max, m_rigidity, m_truncation_fctr);
17  fastjet::JetDefinition qjets_def(&qjets_plugin);
18 
19  unsigned int n = 0;
20  double sum_mass = 0, sum_mass2 = 0;
21  for(unsigned int i=0; i < m_num_iterations; i++) {
22  if(m_seed != -1) { // Seed needs to be different for each run of Qjets, but this has consistent running
23  qjets_plugin.SetRandSeed(m_seed + i);
24  }
25  fastjet::ClusterSequence clust_seq(constit_pseudojets, qjets_def);
26  vector<fastjet::PseudoJet> qjets = fastjet::sorted_by_pt(clust_seq.inclusive_jets());
27 
28  if(qjets.empty()) {
29  //cout << "0 jets" << endl;
30  continue;
31  }
32 
33  n++;
34  sum_mass += qjets[0].m();
35  sum_mass2 += qjets[0].m2();
36  }
37 
38  if(n == 0) {
39  // Prevent div-0
40  return -999;
41  }
42 
43  double rms_dev2 = sum_mass2/n - pow(sum_mass/n, 2.0);
44  if(rms_dev2 < 0) {
45  // To prevent NaN. Small negative numbers can happen due to floating point inaccuracy
46  // when all qjets are same -> i.e. 0 rms
47  rms_dev2 = 0;
48  }
49 
50  double rms_dev = sqrt(rms_dev2);
51  double volatility = rms_dev / (sum_mass/n);
52 
53  return volatility;
54 }
55 
56 void Volatility::setSeed(unsigned int seed)
57 {
58  m_seed = seed;
59 }
get_generator_info.result
result
Definition: get_generator_info.py:21
Volatility.h
JetSubStructureUtils
Definition: Angularity.h:10
JetSubStructureUtils::QjetsPlugin
Definition: QjetsPlugin.h:13
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
jet::ClusterSequence
fastjet::ClusterSequence ClusterSequence
Definition: ClusterSequence.h:21
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
QjetsPlugin.h
JetSubStructureUtils::QjetsPlugin::SetRandSeed
void SetRandSeed(unsigned int seed)
Definition: QjetsPlugin.cxx:22
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15