CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
Qjets Class Reference

#include <Qjets.h>

Public Member Functions

void Cluster (fastjet::ClusterSequence &cs)
 
 Qjets (double zcut, double dcut_fctr, double exp_min, double exp_max, double rigidity, double truncation_fctr, CLHEP::HepRandomEngine *rnEngine)
 
void SetRandSeed (unsigned int seed)
 

Private Member Functions

void ComputeAllDistances (const std::vector< fastjet::PseudoJet > &inp)
 
void computeDCut (fastjet::ClusterSequence &cs)
 
double ComputeMinimumDistance ()
 
void ComputeNewDistanceMeasures (fastjet::ClusterSequence &cs, unsigned int new_jet)
 
double ComputeNormalization (double dmin)
 
double d_ij (const fastjet::PseudoJet &v1, const fastjet::PseudoJet &v2) const
 
JetDistance GetNextDistance ()
 
bool JetsUnmerged (const JetDistance &jd) const
 
bool JetUnmerged (int num) const
 
bool Prune (JetDistance &jd, fastjet::ClusterSequence &cs)
 
double Rand ()
 
bool Same (const JetDistance &lhs, const JetDistance &rhs)
 

Private Attributes

double _dcut
 
double _dcut_fctr
 
std::priority_queue< JetDistance, std::vector< JetDistance >, JetDistanceCompare_distances
 
double _exp_max
 
double _exp_min
 
std::map< int, bool > _merged_jets
 
bool _rand_seed_set
 
double _rigidity
 
CLHEP::HepRandomEngine * _rnEngine
 
unsigned int _seed
 
double _truncation_fctr
 
double _zcut
 
double omega
 

Detailed Description

Definition at line 28 of file Qjets.h.

Constructor & Destructor Documentation

◆ Qjets()

Qjets::Qjets ( double  zcut,
double  dcut_fctr,
double  exp_min,
double  exp_max,
double  rigidity,
double  truncation_fctr,
CLHEP::HepRandomEngine *  rnEngine 
)
inline

Definition at line 53 of file Qjets.h.

60  : _rand_seed_set(false),
61  _zcut(zcut),
62  _dcut(-1.),
63  _dcut_fctr(dcut_fctr),
64  _exp_min(exp_min),
65  _exp_max(exp_max),
67  _truncation_fctr(truncation_fctr),
68  _rnEngine(rnEngine){};

Member Function Documentation

◆ Cluster()

void Qjets::Cluster ( fastjet::ClusterSequence &  cs)

Definition at line 60 of file Qjets.cc.

60  {
61  omega = 1.;
62  QjetsBaseExtras* extras = new QjetsBaseExtras();
63  computeDCut(cs);
64 
65  // Populate all the distances
66  ComputeAllDistances(cs.jets());
68 
69  while (!_distances.empty() && jd.dij != -1.) {
70  if (!Prune(jd, cs)) {
71  // _merged_jets.push_back(jd.j1);
72  // _merged_jets.push_back(jd.j2);
73  _merged_jets[jd.j1] = true;
74  _merged_jets[jd.j2] = true;
75 
76  int new_jet = -1;
77  cs.plugin_record_ij_recombination(jd.j1, jd.j2, 1., new_jet);
78  if (!JetUnmerged(new_jet))
79  edm::LogError("QJets Clustering") << "Problem with FastJet::plugin_record_ij_recombination";
81  } else {
82  double j1pt = cs.jets()[jd.j1].perp();
83  double j2pt = cs.jets()[jd.j2].perp();
84  if (j1pt > j2pt) {
85  // _merged_jets.push_back(jd.j2);
86  _merged_jets[jd.j2] = true;
87  cs.plugin_record_iB_recombination(jd.j2, 1.);
88  } else {
89  // _merged_jets.push_back(jd.j1);
90  _merged_jets[jd.j1] = true;
91  cs.plugin_record_iB_recombination(jd.j1, 1.);
92  }
93  }
94  jd = GetNextDistance();
95  }
96 
97  extras->_wij = omega;
98  cs.plugin_associate_extras(extras);
99 
100  // merge remaining jets with beam
101  int num_merged_final(0);
102  for (unsigned int i = 0; i < cs.jets().size(); i++)
103  if (JetUnmerged(i)) {
104  num_merged_final++;
105  cs.plugin_record_iB_recombination(i, 1.);
106  }
107 
108  if (!(num_merged_final < 2))
109  edm::LogError("QJets Clustering") << "More than 1 jet remains after reclustering";
110 }

References QjetsBaseExtras::_wij, fwrapper::cs, and mps_fire::i.

Referenced by QjetsPlugin::run_clustering().

◆ ComputeAllDistances()

void Qjets::ComputeAllDistances ( const std::vector< fastjet::PseudoJet > &  inp)
private

Definition at line 130 of file Qjets.cc.

130  {
131  for (unsigned int i = 0; i < inp.size() - 1; i++) {
132  // jet-jet distances
133  for (unsigned int j = i + 1; j < inp.size(); j++) {
134  JetDistance jd;
135  jd.j1 = i;
136  jd.j2 = j;
137  if (jd.j1 != jd.j2) {
138  jd.dij = d_ij(inp[i], inp[j]);
139  _distances.push(jd);
140  }
141  }
142  }
143 }

References JetDistance::dij, mps_fire::i, dqmiolumiharvest::j, JetDistance::j1, and JetDistance::j2.

◆ computeDCut()

void Qjets::computeDCut ( fastjet::ClusterSequence &  cs)
private

Definition at line 112 of file Qjets.cc.

112  {
113  // assume all jets in cs form a single jet. compute mass and pt
114  fastjet::PseudoJet sum(0., 0., 0., 0.);
115  for (vector<fastjet::PseudoJet>::const_iterator it = cs.jets().begin(); it != cs.jets().end(); it++)
116  sum += (*it);
117  _dcut = 2. * _dcut_fctr * sum.m() / sum.perp();
118 }

References fwrapper::cs.

◆ ComputeMinimumDistance()

double Qjets::ComputeMinimumDistance ( )
private

◆ ComputeNewDistanceMeasures()

void Qjets::ComputeNewDistanceMeasures ( fastjet::ClusterSequence &  cs,
unsigned int  new_jet 
)
private

Definition at line 145 of file Qjets.cc.

145  {
146  // jet-jet distances
147  for (unsigned int i = 0; i < cs.jets().size(); i++)
148  if (JetUnmerged(i) && i != new_jet) {
149  JetDistance jd;
150  jd.j1 = new_jet;
151  jd.j2 = i;
152  jd.dij = d_ij(cs.jets()[jd.j1], cs.jets()[jd.j2]);
153  _distances.push(jd);
154  }
155 }

References fwrapper::cs, JetDistance::dij, mps_fire::i, JetDistance::j1, and JetDistance::j2.

◆ ComputeNormalization()

double Qjets::ComputeNormalization ( double  dmin)
private

◆ d_ij()

double Qjets::d_ij ( const fastjet::PseudoJet &  v1,
const fastjet::PseudoJet &  v2 
) const
private

Definition at line 157 of file Qjets.cc.

157  {
158  double p1 = v1.perp();
159  double p2 = v2.perp();
160  double ret = pow(min(p1, p2), _exp_min) * pow(max(p1, p2), _exp_max) * v1.squared_distance(v2);
161  if (edm::isNotFinite(ret))
162  edm::LogError("QJets Clustering") << "d_ij is not finite";
163  return ret;
164 }

References edm::isNotFinite(), SiStripPI::max, min(), p1, p2, funct::pow(), and runTheMatrix::ret.

◆ GetNextDistance()

JetDistance Qjets::GetNextDistance ( )
private

Definition at line 14 of file Qjets.cc.

14  {
15  vector<pair<JetDistance, double> > popped_distances;
16  double norm(0.);
18  ret.j1 = -1;
19  ret.j2 = -1;
20  ret.dij = -1.;
21  bool dmin_set(false);
22  double dmin(0.);
23 
24  while (!_distances.empty()) {
25  JetDistance dist = _distances.top();
26  _distances.pop();
27  if (JetsUnmerged(dist)) {
28  if (!dmin_set) {
29  dmin = dist.dij;
30  dmin_set = true;
31  }
32  double weight = exp(-_rigidity * (dist.dij - dmin) / dmin);
33  popped_distances.push_back(make_pair(dist, weight));
34  norm += weight;
35  if (weight / norm < _truncation_fctr)
36  break;
37  }
38  }
39 
40  double rand(Rand()), tot_weight(0.);
41  for (vector<pair<JetDistance, double> >::iterator it = popped_distances.begin(); it != popped_distances.end(); it++) {
42  tot_weight += (*it).second / norm;
43  if (tot_weight >= rand) {
44  ret = (*it).first;
45  omega *= ((*it).second);
46  break;
47  }
48  }
49 
50  // repopulate in reverse (maybe quicker?)
51  for (vector<pair<JetDistance, double> >::reverse_iterator it = popped_distances.rbegin();
52  it != popped_distances.rend();
53  it++)
54  if (JetsUnmerged((*it).first))
55  _distances.push((*it).first);
56 
57  return ret;
58 }

References JetDistance::dij, JetChargeProducer_cfi::exp, runTheMatrix::ret, trackerHitRTTI::vector, and mps_merge::weight.

◆ JetsUnmerged()

bool Qjets::JetsUnmerged ( const JetDistance jd) const
private

Definition at line 12 of file Qjets.cc.

12 { return JetUnmerged(jd.j1) && JetUnmerged(jd.j2); }

References JetDistance::j1, and JetDistance::j2.

◆ JetUnmerged()

bool Qjets::JetUnmerged ( int  num) const
private

Definition at line 10 of file Qjets.cc.

10 { return _merged_jets.find(num) == _merged_jets.end(); }

References EgammaValidation_cff::num.

◆ Prune()

bool Qjets::Prune ( JetDistance jd,
fastjet::ClusterSequence &  cs 
)
private

Definition at line 120 of file Qjets.cc.

120  {
121  double pt1 = cs.jets()[jd.j1].perp();
122  double pt2 = cs.jets()[jd.j2].perp();
123  fastjet::PseudoJet sum_jet = cs.jets()[jd.j1] + cs.jets()[jd.j2];
124  double sum_pt = sum_jet.perp();
125  double z = min(pt1, pt2) / sum_pt;
126  double d2 = cs.jets()[jd.j1].plain_distance(cs.jets()[jd.j2]);
127  return (d2 > _dcut * _dcut) && (z < _zcut);
128 }

References fwrapper::cs, JetDistance::j1, JetDistance::j2, min(), HLT_FULL_cff::pt1, and HLT_FULL_cff::pt2.

◆ Rand()

double Qjets::Rand ( )
private

Definition at line 166 of file Qjets.cc.

166  {
167  double ret = 0.;
168  //if(_rand_seed_set)
169  // ret = rand_r(&_seed)/(double)RAND_MAX;
170  //else
171  //ret = rand()/(double)RAND_MAX;
172  ret = _rnEngine->flat();
173  return ret;
174 }

References runTheMatrix::ret.

◆ Same()

bool Qjets::Same ( const JetDistance lhs,
const JetDistance rhs 
)
private

◆ SetRandSeed()

void Qjets::SetRandSeed ( unsigned int  seed)

Definition at line 5 of file Qjets.cc.

5  {
6  _rand_seed_set = true;
7  _seed = seed;
8 }

References fileCollector::seed.

Referenced by QjetsPlugin::run_clustering().

Member Data Documentation

◆ _dcut

double Qjets::_dcut
private

Definition at line 33 of file Qjets.h.

◆ _dcut_fctr

double Qjets::_dcut_fctr
private

Definition at line 33 of file Qjets.h.

◆ _distances

std::priority_queue<JetDistance, std::vector<JetDistance>, JetDistanceCompare> Qjets::_distances
private

Definition at line 35 of file Qjets.h.

◆ _exp_max

double Qjets::_exp_max
private

Definition at line 33 of file Qjets.h.

◆ _exp_min

double Qjets::_exp_min
private

Definition at line 33 of file Qjets.h.

◆ _merged_jets

std::map<int, bool> Qjets::_merged_jets
private

Definition at line 34 of file Qjets.h.

◆ _rand_seed_set

bool Qjets::_rand_seed_set
private

Definition at line 31 of file Qjets.h.

◆ _rigidity

double Qjets::_rigidity
private

Definition at line 33 of file Qjets.h.

◆ _rnEngine

CLHEP::HepRandomEngine* Qjets::_rnEngine
private

Definition at line 36 of file Qjets.h.

◆ _seed

unsigned int Qjets::_seed
private

Definition at line 32 of file Qjets.h.

◆ _truncation_fctr

double Qjets::_truncation_fctr
private

Definition at line 33 of file Qjets.h.

◆ _zcut

double Qjets::_zcut
private

Definition at line 33 of file Qjets.h.

◆ omega

double Qjets::omega
private

Definition at line 30 of file Qjets.h.

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
QjetsBaseExtras::_wij
double _wij
Definition: Qjets.h:82
mps_fire.i
i
Definition: mps_fire.py:428
Qjets::Prune
bool Prune(JetDistance &jd, fastjet::ClusterSequence &cs)
Definition: Qjets.cc:120
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:47
min
T min(T a, T b)
Definition: MathUtil.h:58
Qjets::JetsUnmerged
bool JetsUnmerged(const JetDistance &jd) const
Definition: Qjets.cc:12
Qjets::_dcut
double _dcut
Definition: Qjets.h:33
mps_merge.weight
weight
Definition: mps_merge.py:88
Qjets::_exp_max
double _exp_max
Definition: Qjets.h:33
Qjets::_zcut
double _zcut
Definition: Qjets.h:33
Qjets::_dcut_fctr
double _dcut_fctr
Definition: Qjets.h:33
Qjets::_seed
unsigned int _seed
Definition: Qjets.h:32
Qjets::computeDCut
void computeDCut(fastjet::ClusterSequence &cs)
Definition: Qjets.cc:112
Qjets::_merged_jets
std::map< int, bool > _merged_jets
Definition: Qjets.h:34
fileCollector.seed
seed
Definition: fileCollector.py:127
Qjets::omega
double omega
Definition: Qjets.h:30
qjetsadder_cfi.rigidity
rigidity
Definition: qjetsadder_cfi.py:9
JetDistance::j2
int j2
Definition: Qjets.h:19
DDAxes::z
p2
double p2[4]
Definition: TauolaWrapper.h:90
JetDistance::dij
double dij
Definition: Qjets.h:17
HLT_FULL_cff.pt1
pt1
Definition: HLT_FULL_cff.py:9870
Qjets::GetNextDistance
JetDistance GetNextDistance()
Definition: Qjets.cc:14
Qjets::_rand_seed_set
bool _rand_seed_set
Definition: Qjets.h:31
Qjets::_rigidity
double _rigidity
Definition: Qjets.h:33
Qjets::d_ij
double d_ij(const fastjet::PseudoJet &v1, const fastjet::PseudoJet &v2) const
Definition: Qjets.cc:157
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
Qjets::_exp_min
double _exp_min
Definition: Qjets.h:33
Qjets::_truncation_fctr
double _truncation_fctr
Definition: Qjets.h:33
QjetsBaseExtras
Definition: Qjets.h:74
JetDistance::j1
int j1
Definition: Qjets.h:18
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
p1
double p1[4]
Definition: TauolaWrapper.h:89
JetDistance
Definition: Qjets.h:16
HLT_FULL_cff.pt2
pt2
Definition: HLT_FULL_cff.py:9872
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
Qjets::_rnEngine
CLHEP::HepRandomEngine * _rnEngine
Definition: Qjets.h:36
HLT_FULL_cff.zcut
zcut
Definition: HLT_FULL_cff.py:8657
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
Qjets::JetUnmerged
bool JetUnmerged(int num) const
Definition: Qjets.cc:10
Qjets::Rand
double Rand()
Definition: Qjets.cc:166
Qjets::ComputeNewDistanceMeasures
void ComputeNewDistanceMeasures(fastjet::ClusterSequence &cs, unsigned int new_jet)
Definition: Qjets.cc:145
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
Qjets::ComputeAllDistances
void ComputeAllDistances(const std::vector< fastjet::PseudoJet > &inp)
Definition: Qjets.cc:130
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
Qjets::_distances
std::priority_queue< JetDistance, std::vector< JetDistance >, JetDistanceCompare > _distances
Definition: Qjets.h:35
weight
Definition: weight.py:1