ATLAS Offline Software
Loading...
Searching...
No Matches
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
8using namespace std;
9using namespace JetSubStructureUtils;
10
11double Volatility::result(const fastjet::PseudoJet &jet) const
12{
13 vector<fastjet::PseudoJet> constit_pseudojets = jet.constituents();
14 if(constit_pseudojets.empty()) return -999;
15
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
56void Volatility::setSeed(unsigned int seed)
57{
58 m_seed = seed;
59}
constexpr int pow(int base, int exp) noexcept
void SetRandSeed(unsigned int seed)
virtual double result(const fastjet::PseudoJet &jet) const
void setSeed(unsigned int seed)
STL namespace.