test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 

Detailed Description

Definition at line 26 of file Qjets.h.

Constructor & Destructor Documentation

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 50 of file Qjets.h.

50  : _rand_seed_set(false),
51  _zcut(zcut),
52  _dcut(-1.),
53  _dcut_fctr(dcut_fctr),
54  _exp_min(exp_min),
55  _exp_max(exp_max),
56  _rigidity(rigidity),
57  _truncation_fctr(truncation_fctr),
58  _rnEngine(rnEngine)
59  {};
double _zcut
Definition: Qjets.h:30
double _dcut
Definition: Qjets.h:30
double _dcut_fctr
Definition: Qjets.h:30
double _exp_max
Definition: Qjets.h:30
double _exp_min
Definition: Qjets.h:30
bool _rand_seed_set
Definition: Qjets.h:28
double _truncation_fctr
Definition: Qjets.h:30
double _rigidity
Definition: Qjets.h:30
CLHEP::HepRandomEngine * _rnEngine
Definition: Qjets.h:33

Member Function Documentation

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

Definition at line 61 of file Qjets.cc.

References i.

Referenced by QjetsPlugin::run_clustering().

61  {
62  computeDCut(cs);
63 
64  // Populate all the distances
65  ComputeAllDistances(cs.jets());
67 
68  while(!_distances.empty() && jd.dij != -1.){
69  if(!Prune(jd,cs)){
70  // _merged_jets.push_back(jd.j1);
71  // _merged_jets.push_back(jd.j2);
72  _merged_jets[jd.j1] = true;
73  _merged_jets[jd.j2] = true;
74 
75  int new_jet=-1;
76  cs.plugin_record_ij_recombination(jd.j1, jd.j2, 1., new_jet);
77  if(!JetUnmerged(new_jet))
78  edm::LogError("QJets Clustering") << "Problem with FastJet::plugin_record_ij_recombination";
80  } else {
81  double j1pt = cs.jets()[jd.j1].perp();
82  double j2pt = cs.jets()[jd.j2].perp();
83  if(j1pt>j2pt){
84  // _merged_jets.push_back(jd.j2);
85  _merged_jets[jd.j2] = true;
86  cs.plugin_record_iB_recombination(jd.j2, 1.);
87  } else {
88  // _merged_jets.push_back(jd.j1);
89  _merged_jets[jd.j1] = true;
90  cs.plugin_record_iB_recombination(jd.j1, 1.);
91  }
92  }
93  jd = GetNextDistance();
94  }
95 
96  // merge remaining jets with beam
97  int num_merged_final(0);
98  for(unsigned int i = 0 ; i < cs.jets().size(); i++)
99  if(JetUnmerged(i)){
100  num_merged_final++;
101  cs.plugin_record_iB_recombination(i,1.);
102  }
103 
104  if(!(num_merged_final < 2))
105  edm::LogError("QJets Clustering") << "More than 1 jet remains after reclustering";
106 }
void ComputeNewDistanceMeasures(fastjet::ClusterSequence &cs, unsigned int new_jet)
Definition: Qjets.cc:141
int i
Definition: DBlmapReader.cc:9
auto_ptr< ClusterSequence > cs
bool JetUnmerged(int num) const
Definition: Qjets.cc:10
bool Prune(JetDistance &jd, fastjet::ClusterSequence &cs)
Definition: Qjets.cc:116
void computeDCut(fastjet::ClusterSequence &cs)
Definition: Qjets.cc:108
JetDistance GetNextDistance()
Definition: Qjets.cc:18
void ComputeAllDistances(const std::vector< fastjet::PseudoJet > &inp)
Definition: Qjets.cc:126
std::priority_queue< JetDistance, std::vector< JetDistance >, JetDistanceCompare > _distances
Definition: Qjets.h:32
std::map< int, bool > _merged_jets
Definition: Qjets.h:31
void Qjets::ComputeAllDistances ( const std::vector< fastjet::PseudoJet > &  inp)
private

Definition at line 126 of file Qjets.cc.

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

126  {
127  for(unsigned int i = 0 ; i < inp.size()-1; i++){
128  // jet-jet distances
129  for(unsigned int j = i+1 ; j < inp.size(); j++){
130  JetDistance jd;
131  jd.j1 = i;
132  jd.j2 = j;
133  if(jd.j1 != jd.j2){
134  jd.dij = d_ij(inp[i],inp[j]);
135  _distances.push(jd);
136  }
137  }
138  }
139 }
int i
Definition: DBlmapReader.cc:9
double dij
Definition: Qjets.h:15
int j2
Definition: Qjets.h:17
int j
Definition: DBlmapReader.cc:9
double d_ij(const fastjet::PseudoJet &v1, const fastjet::PseudoJet &v2) const
Definition: Qjets.cc:153
std::priority_queue< JetDistance, std::vector< JetDistance >, JetDistanceCompare > _distances
Definition: Qjets.h:32
int j1
Definition: Qjets.h:16
void Qjets::computeDCut ( fastjet::ClusterSequence &  cs)
private

Definition at line 108 of file Qjets.cc.

108  {
109  // assume all jets in cs form a single jet. compute mass and pt
110  fastjet::PseudoJet sum(0.,0.,0.,0.);
111  for(vector<fastjet::PseudoJet>::const_iterator it = cs.jets().begin(); it != cs.jets().end(); it++)
112  sum += (*it);
113  _dcut = 2. * _dcut_fctr * sum.m()/sum.perp();
114 }
auto_ptr< ClusterSequence > cs
double _dcut
Definition: Qjets.h:30
double _dcut_fctr
Definition: Qjets.h:30
double Qjets::ComputeMinimumDistance ( )
private
void Qjets::ComputeNewDistanceMeasures ( fastjet::ClusterSequence &  cs,
unsigned int  new_jet 
)
private

Definition at line 141 of file Qjets.cc.

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

141  {
142  // jet-jet distances
143  for(unsigned int i = 0; i < cs.jets().size(); i++)
144  if(JetUnmerged(i) && i != new_jet){
145  JetDistance jd;
146  jd.j1 = new_jet;
147  jd.j2 = i;
148  jd.dij = d_ij(cs.jets()[jd.j1], cs.jets()[jd.j2]);
149  _distances.push(jd);
150  }
151 }
int i
Definition: DBlmapReader.cc:9
auto_ptr< ClusterSequence > cs
bool JetUnmerged(int num) const
Definition: Qjets.cc:10
double dij
Definition: Qjets.h:15
int j2
Definition: Qjets.h:17
double d_ij(const fastjet::PseudoJet &v1, const fastjet::PseudoJet &v2) const
Definition: Qjets.cc:153
std::priority_queue< JetDistance, std::vector< JetDistance >, JetDistanceCompare > _distances
Definition: Qjets.h:32
int j1
Definition: Qjets.h:16
double Qjets::ComputeNormalization ( double  dmin)
private
double Qjets::d_ij ( const fastjet::PseudoJet &  v1,
const fastjet::PseudoJet &  v2 
) const
private

Definition at line 153 of file Qjets.cc.

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

153  {
154  double p1 = v1.perp();
155  double p2 = v2.perp();
156  double ret = pow(min(p1,p2),_exp_min) * pow(max(p1,p2),_exp_max) * v1.squared_distance(v2);
157  if(edm::isNotFinite(ret))
158  edm::LogError("QJets Clustering") << "d_ij is not finite";
159  return ret;
160 }
double _exp_max
Definition: Qjets.h:30
bool isNotFinite(T x)
Definition: isFinite.h:10
double _exp_min
Definition: Qjets.h:30
T min(T a, T b)
Definition: MathUtil.h:58
double p2[4]
Definition: TauolaWrapper.h:90
double p1[4]
Definition: TauolaWrapper.h:89
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
JetDistance Qjets::GetNextDistance ( )
private

Definition at line 18 of file Qjets.cc.

References JetDistance::dij, create_public_lumi_plots::exp, JetDistance::j1, JetDistance::j2, rand(), run_regression::ret, and histoStyle::weight.

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

Definition at line 14 of file Qjets.cc.

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

14  {
15  return JetUnmerged(jd.j1) && JetUnmerged(jd.j2);
16 }
bool JetUnmerged(int num) const
Definition: Qjets.cc:10
int j2
Definition: Qjets.h:17
int j1
Definition: Qjets.h:16
bool Qjets::JetUnmerged ( int  num) const
private

Definition at line 10 of file Qjets.cc.

10  {
11  return _merged_jets.find(num) == _merged_jets.end();
12 }
std::map< int, bool > _merged_jets
Definition: Qjets.h:31
bool Qjets::Prune ( JetDistance jd,
fastjet::ClusterSequence &  cs 
)
private

Definition at line 116 of file Qjets.cc.

References JetDistance::j1, JetDistance::j2, min(), and detailsBasic3DVector::z.

116  {
117  double pt1 = cs.jets()[jd.j1].perp();
118  double pt2 = cs.jets()[jd.j2].perp();
119  fastjet::PseudoJet sum_jet = cs.jets()[jd.j1]+cs.jets()[jd.j2];
120  double sum_pt = sum_jet.perp();
121  double z = min(pt1,pt2)/sum_pt;
122  double d2 = cs.jets()[jd.j1].plain_distance(cs.jets()[jd.j2]);
123  return (d2 > _dcut*_dcut) && (z < _zcut);
124 }
auto_ptr< ClusterSequence > cs
double _zcut
Definition: Qjets.h:30
double _dcut
Definition: Qjets.h:30
int j2
Definition: Qjets.h:17
float float float z
T min(T a, T b)
Definition: MathUtil.h:58
int j1
Definition: Qjets.h:16
double Qjets::Rand ( )
private

Definition at line 162 of file Qjets.cc.

References run_regression::ret.

162  {
163  double ret = 0.;
164  //if(_rand_seed_set)
165  // ret = rand_r(&_seed)/(double)RAND_MAX;
166  //else
167  //ret = rand()/(double)RAND_MAX;
168  ret = _rnEngine->flat();
169  return ret;
170 }
CLHEP::HepRandomEngine * _rnEngine
Definition: Qjets.h:33
bool Qjets::Same ( const JetDistance lhs,
const JetDistance rhs 
)
private
void Qjets::SetRandSeed ( unsigned int  seed)

Definition at line 5 of file Qjets.cc.

References fileCollector::seed.

Referenced by QjetsPlugin::run_clustering().

5  {
6  _rand_seed_set = true;
7  _seed = seed;
8 }
unsigned int _seed
Definition: Qjets.h:29
bool _rand_seed_set
Definition: Qjets.h:28

Member Data Documentation

double Qjets::_dcut
private

Definition at line 30 of file Qjets.h.

double Qjets::_dcut_fctr
private

Definition at line 30 of file Qjets.h.

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

Definition at line 32 of file Qjets.h.

double Qjets::_exp_max
private

Definition at line 30 of file Qjets.h.

double Qjets::_exp_min
private

Definition at line 30 of file Qjets.h.

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

Definition at line 31 of file Qjets.h.

bool Qjets::_rand_seed_set
private

Definition at line 28 of file Qjets.h.

double Qjets::_rigidity
private

Definition at line 30 of file Qjets.h.

CLHEP::HepRandomEngine* Qjets::_rnEngine
private

Definition at line 33 of file Qjets.h.

unsigned int Qjets::_seed
private

Definition at line 29 of file Qjets.h.

double Qjets::_truncation_fctr
private

Definition at line 30 of file Qjets.h.

double Qjets::_zcut
private

Definition at line 30 of file Qjets.h.