Fork me on GitHub

source: git/external/fastjet/contribs/SoftKiller/SoftKiller.hh@ 21eab4f

Last change on this file since 21eab4f was 35cdc46, checked in by Pavel Demin <demin@…>, 10 years ago

upgrade FastJet to version 3.1.0-beta.1, upgrade Nsubjettiness to version 2.1.0, add SoftKiller version 1.0.0

  • Property mode set to 100644
File size: 5.6 KB
RevLine 
[35cdc46]1// $Id$
2//
3// Copyright (c) 2014-, Matteo Cacciari, Gavin. P. Salam and Gregory Soyez
4//
5//----------------------------------------------------------------------
6// This file is part of FastJet contrib.
7//
8// It is free software; you can redistribute it and/or modify it under
9// the terms of the GNU General Public License as published by the
10// Free Software Foundation; either version 2 of the License, or (at
11// your option) any later version.
12//
13// It is distributed in the hope that it will be useful, but WITHOUT
14// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16// License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this code. If not, see <http://www.gnu.org/licenses/>.
20//----------------------------------------------------------------------
21
22#ifndef __FASTJET_CONTRIB_SOFTKILLER_HH__
23#define __FASTJET_CONTRIB_SOFTKILLER_HH__
24
25#include <fastjet/internal/base.hh>
26#include <fastjet/Selector.hh>
27#include "fastjet/config.h"
28
29#if FASTJET_VERSION_NUMBER >= 30100
30#define FJCONTRIB_SOFTKILLER_USEFJGRID
31#endif
32
33#ifdef FJCONTRIB_SOFTKILLER_USEFJGRID
34#include "fastjet/RectangularGrid.hh"
35#endif
36
37FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
38
39
40namespace contrib{
41
42//------------------------------------------------------------------------
43/// \class SoftKiller
44/// Progressively kills soft particles in order of increasing pt until
45/// half of the event is empty.
46///
47/// More precisely, the event up to |rap|=rapmax is split into grid
48/// cells of size "cell_size". Soft particles are removed from the
49/// event in order of increasing pt until half the cells are empty.
50/// By default, that same pt cut is applied to _all_ the particles in
51/// the event, not just those in the grid region.
52///
53/// If a sifter is provided, then only particles that pass the selector
54/// are put onto the grid, and the pt threshold is then applied just
55/// to those particles, while all other particles are left untouched.
56///
57/// This is convenient, for example, if you want to apply SK just to
58/// neutral particles.
59#ifdef FJCONTRIB_SOFTKILLER_USEFJGRID
60class SoftKiller : public RectangularGrid {
61#else
62class SoftKiller {
63#endif
64public:
65 /// ctor with simple initialisation
66 /// \param rapmax the maximal absolute rapidity extent of the grid
67 /// \param tile_size the requested grid spacing (equivalently, tile size)
68 /// \param sifter when provided, the soft killer is applied
69 /// only to particles that pass the sifter (the
70 /// others are kept untouched)
71 SoftKiller(double rapmax, double tile_size,
72 Selector sifter = Selector());
73
74 /// ctor with more control over initialisation
75 /// \param rapmin the minimum rapidity extent of the grid
76 /// \param rapmax the maximum rapidity extent of the grid
77 /// \param drap the grid spacing in rapidity
78 /// \param dphi the grid spacing in azimuth
79 /// \param sifter when provided, the soft killer is applied
80 /// only to particles that pass the sifter (the
81 /// others are kept untouched)
82 SoftKiller(double rapmin, double rapmax, double drap, double dphi,
83 Selector sifter = Selector());
84
85#ifdef FJCONTRIB_SOFTKILLER_USEFJGRID
86 /// constructor that takes RectangularGrid object to flexibly
87 /// specify the details of the grid (works only with FJ3.1)
88 SoftKiller(const RectangularGrid & grid, Selector sifter = Selector());
89#endif
90
91 /// dummy ctor (will give an unusable SoftKiller)
92 SoftKiller();
93
94 /// returns description of the soft killer
95 std::string description() const;
96
97 /// applies the soft killer to a given event. The result is the
98 /// "reduced" event.
99 std::vector<PseudoJet> operator()(const std::vector<PseudoJet> & event) const{
100 return result(event);
101 }
102
103 /// similarly to Transformers in FastJet, introduce a 'result'
104 /// method equivalent to the () operator.
105 //std::vector<PseudoJet> result(const std::vector<PseudoJet> & event) const;
106 std::vector<PseudoJet> result(const std::vector<PseudoJet> & event) const {
107 double pt_threshold;
108 std::vector<PseudoJet> reduced_event;
109 apply(event, reduced_event, pt_threshold);
110 return reduced_event;
111 }
112
113 /// alternative invocation that puts the resulting SK "reduced" event
114 /// into the reduced_event vector, and also provides information about the
115 /// pt threshold that was applied.
116 ///
117 /// The event and reduced_event must _not_ be the same variable.
118 void apply(const std::vector<PseudoJet> & event,
119 std::vector<PseudoJet> & reduced_event,
120 double & pt_threshold) const;
121
122private:
123
124#ifndef FJCONTRIB_SOFTKILLER_USEFJGRID
125 /// initial setup of the grid
126 void _setup_grid();
127
128 // retrieve the grid cell index for a given PseudoJet
129 inline int tile_index(const PseudoJet & p) const;
130
131 inline int n_tiles() const {return _ntotal;}
132 inline int n_good_tiles() const {return n_tiles();}
133 inline bool tile_is_good(int itile) const {return true;}
134
135 inline bool all_tiles_equal_area() const {return true;}
136
137 // ctor arguments
138 double _ymax, _ymin; ///< maximal and minimal rapidity coverage of the grid
139 //double _cell_size; ///< grid cell size
140 double _requested_drap; ///< requested rapidity spacing
141 double _requested_dphi; ///< requested phi spacing
142
143 // information about the grid
144 double _dy, _dphi, _cell_area, _inverse_dy, _inverse_dphi;
145 int _ny, _nphi, _ntotal;
146
147#endif // FJCONTRIB_SOFTKILLER_USEFJGRID
148
149 Selector _sifter; ///< optional sifter
150
151};
152
153} // namespace contrib
154
155FASTJET_END_NAMESPACE
156
157#endif // __FASTJET_CONTRIB_SOFTKILLER_HH__
Note: See TracBrowser for help on using the repository browser.