SISCone  3.0.5
split_merge.h
1 // -*- C++ -*-
3 // File: split_merge.h //
4 // Description: header file for splitting/merging (contains the CJet class) //
5 // This file is part of the SISCone project. //
6 // For more details, see http://projects.hepforge.org/siscone //
7 // //
8 // Copyright (c) 2006 Gavin Salam and Gregory Soyez //
9 // //
10 // This program is free software; you can redistribute it and/or modify //
11 // it under the terms of the GNU General Public License as published by //
12 // the Free Software Foundation; either version 2 of the License, or //
13 // (at your option) any later version. //
14 // //
15 // This program is distributed in the hope that it will be useful, //
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
18 // GNU General Public License for more details. //
19 // //
20 // You should have received a copy of the GNU General Public License //
21 // along with this program; if not, write to the Free Software //
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
23 // //
24 // $Revision:: 405 $//
25 // $Date:: 2016-05-23 20:15:02 +0200 (Mon, 23 May 2016) $//
27 
28 #ifndef __SPLIT_MERGE_H__
29 #define __SPLIT_MERGE_H__
30 
31 #include <siscone/config.h>
32 #include "defines.h"
33 #include "geom_2d.h"
34 #include "momentum.h"
35 #include <stdio.h>
36 #include <vector>
37 #include <set>
38 #include <memory>
39 #include <string>
40 
41 namespace siscone{
42 
43 const int CJET_INEXISTENT_PASS = -2;
44 
54 class Cjet{
55  public:
57  Cjet();
58 
60  ~Cjet();
61 
63  double pt_tilde;
64  int n;
65  std::vector<int> contents;
66 
73  double sm_var2;
74 
77 
82  int pass;
83 };
84 
86 bool jets_pt_less(const Cjet &j1, const Cjet &j2);
87 
88 
96 enum Esplit_merge_scale {
97  SM_pt,
98  SM_Et,
100  SM_mt,
102  SM_pttilde
104 };
105 
107 std::string split_merge_scale_name(Esplit_merge_scale sms);
108 
117 public:
120  particles(0), split_merge_scale(SM_pttilde){};
121 
123  std::string SM_scale_name() const {
124  return split_merge_scale_name(split_merge_scale);}
125 
126  std::vector<Cmomentum> * particles;
127  std::vector<double> * pt;
128 
130  bool operator()(const Cjet &jet1, const Cjet &jet2) const;
131 
143  void get_difference(const Cjet &j1, const Cjet &j2, Cmomentum *v, double *pt_tilde) const;
144 
163  Esplit_merge_scale split_merge_scale;
164 };
165 
166 
167 // iterator types
169 typedef std::multiset<siscone::Cjet,Csplit_merge_ptcomparison>::iterator cjet_iterator;
170 
172 typedef std::vector<siscone::Cjet>::iterator jet_iterator;
173 
174 
175 
181  public:
183  Csplit_merge();
184 
186  ~Csplit_merge();
187 
188 
190  // initialisation functions //
192 
201  int init(std::vector<Cmomentum> &_particles, std::vector<Cmomentum> *protocones, double R2, double ptmin=0.0);
202 
208  int init_particles(std::vector<Cmomentum> &_particles);
209 
213  int init_pleft();
214 
226  inline int set_pt_weighted_splitting(bool _use_pt_weighted_splitting){
227  use_pt_weighted_splitting = _use_pt_weighted_splitting;
228  return 0;
229  }
230 
232  // cleaning functions //
234 
236  int partial_clear();
237 
239  int full_clear();
240 
242  // user-defined stable-cone ordering //
244 
251  public:
253  virtual ~Cuser_scale_base(){}
254 
259  virtual double operator()(const Cjet & jet) const = 0;
260 
271  virtual bool is_larger(const Cjet & a, const Cjet & b) const{
272  return (a.sm_var2 > b.sm_var2);
273  }
274  };
275 
280  void set_user_scale(const Cuser_scale_base * user_scale_in){
281  _user_scale = user_scale_in;
282  }
283 
285  const Cuser_scale_base * user_scale() const { return _user_scale; }
286 
287 
289  // main parts of the algorithm //
291 
300 
308  int add_protocones(std::vector<Cmomentum> *protocones, double R2, double ptmin=0.0);
309 
320  int add_hardest_protocone_to_jets(std::vector<Cmomentum> *protocones, double R2, double ptmin=0.0);
321 
331  int perform(double overlap_tshold, double ptmin=0.0);
332 
333 
335  // save and debug functions //
337 
340  int save_contents(FILE *flux);
341 
343  int show();
344 
345  // particle information
346  int n;
347  std::vector<Cmomentum> particles;
348  std::vector<double> pt;
349  int n_left;
350  std::vector<Cmomentum> p_remain;
351  std::vector<Cmomentum> p_uncol_hard;
352  int n_pass;
353 
358 
359  // jets information
360  std::vector<Cjet> jets;
361 
362  // working entries
363  int *indices;
364  int idx_size;
365 
375 
378 
386 
395 
396  private:
404  bool get_overlap(const Cjet &j1, const Cjet &j2, double *v);
405 
406 
418  bool split(cjet_iterator &it_j1, cjet_iterator &it_j2);
419 
428  bool merge(cjet_iterator &it_j1, cjet_iterator &it_j2);
429 
436  bool insert(Cjet &jet);
437 
444  double get_sm_var2(Cmomentum &v, double &pt_tilde);
445 
446  // jet information
448 #ifdef SISCONE_USES_UNIQUE_PTR_AS_AUTO_PTR
449  std::unique_ptr<std::multiset<Cjet,Csplit_merge_ptcomparison> > candidates;
450 #else
451  std::auto_ptr<std::multiset<Cjet,Csplit_merge_ptcomparison> > candidates;
452 #endif
453 
455  double pt_min2;
456 
462  bool use_pt_weighted_splitting;
463 
466  const Cuser_scale_base *_user_scale;
467 
468 #ifdef ALLOW_MERGE_IDENTICAL_PROTOCONES
470  std::set<Creference> cand_refs;
471 #endif
472 };
473 
474 }
475 
476 
477 #endif
class for holding a covering range in eta-phi
Definition: geom_2d.h:120
real Jet information.
Definition: split_merge.h:54
double pt_tilde
p-scheme pt
Definition: split_merge.h:63
Cmomentum v
jet momentum
Definition: split_merge.h:62
double sm_var2
ordering variable used for ordering and overlap in the split–merge.
Definition: split_merge.h:73
~Cjet()
default dtor
Definition: split_merge.cpp:62
Cjet()
default ctor
Definition: split_merge.cpp:51
int n
number of particles inside
Definition: split_merge.h:64
int pass
pass at which the jet has been found It starts at 0 (first pass), -1 means infinite rapidity (it will...
Definition: split_merge.h:82
Ceta_phi_range range
covered range in eta-phi
Definition: split_merge.h:76
std::vector< int > contents
particle contents (list of indices)
Definition: split_merge.h:65
base class for dynamic coordinates management
Definition: momentum.h:49
base class for user-defined ordering of stable cones
Definition: split_merge.h:250
virtual ~Cuser_scale_base()
empty virtual dtor
Definition: split_merge.h:253
virtual double operator()(const Cjet &jet) const =0
the scale associated with a given jet
virtual bool is_larger(const Cjet &a, const Cjet &b) const
returns true when the scale associated with jet a is larger than the scale associated with jet b
Definition: split_merge.h:271
comparison of jets for split–merge ordering
Definition: split_merge.h:116
std::vector< double > * pt
pointer to the pt of the particles
Definition: split_merge.h:127
bool operator()(const Cjet &jet1, const Cjet &jet2) const
comparison between 2 jets
Definition: split_merge.cpp:94
void get_difference(const Cjet &j1, const Cjet &j2, Cmomentum *v, double *pt_tilde) const
get the difference between 2 jets, calculated such that rounding errors will not affect the result ev...
std::vector< Cmomentum > * particles
pointer to the list of particles
Definition: split_merge.h:126
std::string SM_scale_name() const
return the name corresponding to the SM scale variable
Definition: split_merge.h:123
Esplit_merge_scale split_merge_scale
the following parameter controls the variable we're using for the split-merge process i....
Definition: split_merge.h:163
Class used to split and merge jets.
Definition: split_merge.h:180
int init(std::vector< Cmomentum > &_particles, std::vector< Cmomentum > *protocones, double R2, double ptmin=0.0)
initialisation function
int set_pt_weighted_splitting(bool _use_pt_weighted_splitting)
use a pt-dependent boundary for splitting When called with true, the criterium for splitting two prot...
Definition: split_merge.h:226
int n_pass
index of the run
Definition: split_merge.h:352
int idx_size
number of elements in indices1
Definition: split_merge.h:364
double SM_var2_hardest_cut_off
stop split–merge or progressive-removal when the squared SM_var of the hardest protojet is below this...
Definition: split_merge.h:385
int n_left
numer of particles that does not belong to any jet
Definition: split_merge.h:349
int * indices
maximal size array for indices works
Definition: split_merge.h:363
const Cuser_scale_base * user_scale() const
return the user-defined scale (NULL if none)
Definition: split_merge.h:285
int add_hardest_protocone_to_jets(std::vector< Cmomentum > *protocones, double R2, double ptmin=0.0)
remove the hardest protocone and declare it a jet
bool merge_identical_protocones
The following flag indicates that identical protocones are to be merged automatically each time aroun...
Definition: split_merge.h:374
std::vector< double > pt
list of particles' pt
Definition: split_merge.h:348
int partial_clear()
partial clearance
int show()
show jets/candidates status
void set_user_scale(const Cuser_scale_base *user_scale_in)
associate a user-defined scale to order the stable cones
Definition: split_merge.h:280
int init_pleft()
build initial list of left particles
Csplit_merge_ptcomparison ptcomparison
member used for detailed comparisons of pt's
Definition: split_merge.h:377
int merge_collinear_and_remove_soft()
build the list 'p_uncol_hard' from p_remain by clustering collinear particles and removing particles ...
int perform(double overlap_tshold, double ptmin=0.0)
really do the splitting and merging At the end, the vector jets is filled with the jets found.
std::vector< Cmomentum > particles
list of particles
Definition: split_merge.h:347
double most_ambiguous_split
minimal difference in squared distance between a particle and two overlapping protojets when doing a ...
Definition: split_merge.h:357
int add_protocones(std::vector< Cmomentum > *protocones, double R2, double ptmin=0.0)
add a list of protocones
int n
number of particles
Definition: split_merge.h:346
~Csplit_merge()
default dtor
int save_contents(FILE *flux)
save final jets
double stable_cone_soft_pt2_cutoff
pt cutoff for the particles to put in p_uncol_hard this is meant to allow removing soft particles in ...
Definition: split_merge.h:394
std::vector< Cmomentum > p_uncol_hard
list of particles remaining with collinear clustering
Definition: split_merge.h:351
std::vector< Cjet > jets
list of jets
Definition: split_merge.h:360
Csplit_merge()
default ctor
int full_clear()
full clearance
std::vector< Cmomentum > p_remain
list of particles remaining to deal with
Definition: split_merge.h:350
int init_particles(std::vector< Cmomentum > &_particles)
initialisation function for particle list