FastJet  3.1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
GhostedAreaSpec.hh
1 //FJSTARTHEADER
2 // $Id: GhostedAreaSpec.hh 3433 2014-07-23 08:17:03Z salam $
3 //
4 // Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
5 //
6 //----------------------------------------------------------------------
7 // This file is part of FastJet.
8 //
9 // FastJet is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // The algorithms that underlie FastJet have required considerable
15 // development. They are described in the original FastJet paper,
16 // hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
17 // FastJet as part of work towards a scientific publication, please
18 // quote the version you use and include a citation to the manual and
19 // optionally also to hep-ph/0512210.
20 //
21 // FastJet is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with FastJet. If not, see <http://www.gnu.org/licenses/>.
28 //----------------------------------------------------------------------
29 //FJENDHEADER
30 
31 
32 #ifndef __FASTJET_GHOSTEDAREASPEC_HH__
33 #define __FASTJET_GHOSTEDAREASPEC_HH__
34 
35 #include<vector>
36 #include<string>
37 #include "fastjet/PseudoJet.hh"
38 #include "fastjet/internal/BasicRandom.hh"
39 #include "fastjet/Selector.hh"
40 #include "fastjet/LimitedWarning.hh"
41 
42 //
43 #define STATIC_GENERATOR 1
44 
45 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
46 
47 /// namespace to hold default parameters for the active area spec
48 namespace gas {
49  const double def_ghost_maxrap = 6.0;
50  const int def_repeat = 1;
51  const double def_ghost_area = 0.01;
52  const double def_grid_scatter = 1.0;
53  const double def_pt_scatter = 0.1;
54  const double def_mean_ghost_pt = 1e-100;
55 }
56 
57 //----------------------------------------------------------------------
58 /// @ingroup area_classes
59 /// \class GhostedAreaSpec
60 /// Parameters to configure the computation of jet areas using ghosts
61 ///
62 /// Class that defines the parameters that go into the measurement
63 /// of active jet areas.
65 public:
66  /// default constructor
67  GhostedAreaSpec(): _ghost_maxrap (gas::def_ghost_maxrap),
68  _ghost_rap_offset(0.0),
69  _repeat (gas::def_repeat),
70  _ghost_area (gas::def_ghost_area),
71  _grid_scatter (gas::def_grid_scatter),
72  _pt_scatter (gas::def_pt_scatter),
73  _mean_ghost_pt(gas::def_mean_ghost_pt),
74  _fj2_placement(false) {_initialize();}
75 
76  /// explicit constructor
77  explicit GhostedAreaSpec(double ghost_maxrap_in,
78  int repeat_in = gas::def_repeat,
79  double ghost_area_in = gas::def_ghost_area,
80  double grid_scatter_in = gas::def_grid_scatter,
81  double pt_scatter_in = gas::def_pt_scatter,
82  double mean_ghost_pt_in = gas::def_mean_ghost_pt
83  ):
84  _ghost_maxrap(ghost_maxrap_in),
85  _ghost_rap_offset(0.0),
86  _repeat(repeat_in),
87  _ghost_area(ghost_area_in),
88  _grid_scatter(grid_scatter_in),
89  _pt_scatter(pt_scatter_in),
90  _mean_ghost_pt(mean_ghost_pt_in),
91  _fj2_placement(false) {_initialize();}
92 
93  /// explicit constructor
94  explicit GhostedAreaSpec(double ghost_minrap_in,
95  double ghost_maxrap_in,
96  int repeat_in = gas::def_repeat,
97  double ghost_area_in = gas::def_ghost_area,
98  double grid_scatter_in = gas::def_grid_scatter,
99  double pt_scatter_in = gas::def_pt_scatter,
100  double mean_ghost_pt_in = gas::def_mean_ghost_pt
101  ):
102  _ghost_maxrap (0.5*(ghost_maxrap_in - ghost_minrap_in)),
103  _ghost_rap_offset(0.5*(ghost_maxrap_in + ghost_minrap_in)),
104  _repeat(repeat_in),
105  _ghost_area(ghost_area_in),
106  _grid_scatter(grid_scatter_in),
107  _pt_scatter(pt_scatter_in),
108  _mean_ghost_pt(mean_ghost_pt_in),
109  _fj2_placement(false) {_initialize();}
110 
111 
112  /// constructor based on a Selector
113  explicit GhostedAreaSpec(const Selector & selector,
114  int repeat_in = gas::def_repeat,
115  double ghost_area_in = gas::def_ghost_area,
116  double grid_scatter_in = gas::def_grid_scatter,
117  double pt_scatter_in = gas::def_pt_scatter,
118  double mean_ghost_pt_in = gas::def_mean_ghost_pt
119  );
120 
121 
122  /// does the initialization of actual ghost parameters
123  void _initialize();
124 
125  // for accessing values set by the user
126  inline double ghost_rapmax () const {return _ghost_maxrap;}
127  inline double ghost_maxrap () const {return _ghost_maxrap;}
128  inline double ghost_etamax () const {return _ghost_maxrap;}
129  inline double ghost_maxeta () const {return _ghost_maxrap;}
130  inline double ghost_area () const {return _ghost_area ;}
131  inline double grid_scatter () const {return _grid_scatter;}
132  inline double pt_scatter () const {return _pt_scatter ;}
133  inline double mean_ghost_pt() const {return _mean_ghost_pt ;}
134  inline int repeat () const {return _repeat ;}
135  inline bool fj2_placement() const {return _fj2_placement;}
136 
137  inline double kt_scatter () const {return _pt_scatter ;}
138  inline double mean_ghost_kt() const {return _mean_ghost_pt ;}
139 
140  // for accessing values
141  inline double actual_ghost_area() const {return _actual_ghost_area;}
142  inline int n_ghosts() const {return _n_ghosts;}
143 
144  // when explicitly modifying values, sometimes call the initializer
145  inline void set_ghost_area (double val) {_ghost_area = val; _initialize();}
146  inline void set_ghost_rapmax (double val) {_ghost_maxrap = val; _initialize();}
147  inline void set_ghost_maxrap (double val) {_ghost_maxrap = val; _initialize();}
148  inline void set_ghost_etamax (double val) {_ghost_maxrap = val; _initialize();}
149  inline void set_ghost_maxeta (double val) {_ghost_maxrap = val; _initialize();}
150  inline void set_grid_scatter (double val) {_grid_scatter = val; }
151  inline void set_pt_scatter (double val) {_pt_scatter = val; }
152  inline void set_mean_ghost_pt(double val) {_mean_ghost_pt = val; }
153  inline void set_repeat (int val) {_repeat = val; }
154 
155  inline void set_kt_scatter (double val) {_pt_scatter = val; }
156  inline void set_mean_ghost_kt(double val) {_mean_ghost_pt = val; }
157 
158  /// if val is true, set ghost placement as it was in FastJet 2.X. The
159  /// main differences between FJ2 and FJ3 ghost placement are
160  ///
161  /// - in FJ2 the rapidity spacing was
162  /// ceil((maxrap-minrap)/sqrt(area)), while in FJ3 it is
163  /// int((maxrap-minrap)/sqrt(area) + 0.5) [similarly for phi].
164  /// The FJ3 option offers more stability when trying to specify a
165  /// spacing that exactly fits the extent.
166  ///
167  /// - in FJ2, the ghosts are placed at the corners of grid cells
168  /// (i.e. extending up to maxrap), while in FJ3 they are placed at
169  /// the centres of grid cells (i.e. extending roughly up to
170  /// maxrap-sqrt(area)). The FJ2 behaviour effectively skews the
171  /// total area coverage when maxrap is small, by an amount
172  /// sqrt(area)/(2*maxrap).
173  ///
174  /// FJ2 placement is now deprecated.
175  void set_fj2_placement(bool val);
176 
177  /// return nphi (ghosts layed out (-nrap, 0..nphi-1), (-nrap+1,0..nphi-1),
178  /// ... (nrap,0..nphi-1)
179  inline int nphi() const {return _nphi;}
180  inline int nrap() const {return _nrap;}
181 
182  /// get all relevant information about the status of the
183  /// random number generator, so that it can be reset subsequently
184  /// with set_random_status.
185  inline void get_random_status(std::vector<int> & __iseed) const {
186  _random_generator.get_status(__iseed);}
187 
188  /// set the status of the random number generator, as obtained
189  /// previously with get_random_status. Note that the random
190  /// generator is a static member of the class, i.e. common to all
191  /// instances of the class --- so if you modify the random for this
192  /// instance, you modify it for all instances.
193  inline void set_random_status(const std::vector<int> & __iseed) {
194  _random_generator.set_status(__iseed);}
195 
196  inline void checkpoint_random() {get_random_status(_random_checkpoint);}
197  inline void restore_checkpoint_random() {set_random_status(_random_checkpoint);}
198 
199  /// for a summary
200  std::string description() const;
201 
202  /// push a set of ghost 4-momenta onto the back of the vector of
203  /// PseudoJets
204  void add_ghosts(std::vector<PseudoJet> & ) const;
205 
206  /// very deprecated public access to a random number
207  /// from the internal generator
208  inline double random_at_own_risk() const {return _our_rand();}
209  /// very deprecated public access to the generator itself
210  inline BasicRandom<double> & generator_at_own_risk() const {
211  return _random_generator;}
212 
213 private:
214 
215  // quantities that determine nature and distribution of ghosts
216  double _ghost_maxrap;
217  double _ghost_rap_offset;
218  int _repeat ;
219  double _ghost_area ;
220  double _grid_scatter;
221  double _pt_scatter ;
222  double _mean_ghost_pt;
223  bool _fj2_placement;
224 
225  Selector _selector;
226 
227  // derived quantities
228  double _actual_ghost_area, _dphi, _drap;
229  int _n_ghosts, _nphi, _nrap;
230 
231 
232  std::vector<int> _random_checkpoint;
233  static BasicRandom<double> _random_generator;
234  //mutable BasicRandom<double> _random_generator;
235 
236  static LimitedWarning _warn_fj2_placement_deprecated;
237 
238  inline double _our_rand() const {return _random_generator();}
239 
240 };
241 
242 /// just provide a typedef for backwards compatibility with programs
243 /// based on versions 2.0 and 2.1 of fastjet. Since there is no
244 /// easy way of telling people this is deprecated at compile or run
245 /// time, we should be careful before removing this in the future.
247 
248 
249 FASTJET_END_NAMESPACE
250 
251 #endif // __FASTJET_GHOSTEDAREASPEC_HH__
int nphi() const
return nphi (ghosts layed out (-nrap, 0..nphi-1), (-nrap+1,0..nphi-1), ...
void get_random_status(std::vector< int > &__iseed) const
get all relevant information about the status of the random number generator, so that it can be reset...
BasicRandom< double > & generator_at_own_risk() const
very deprecated public access to the generator itself
GhostedAreaSpec(double ghost_maxrap_in, int repeat_in=gas::def_repeat, double ghost_area_in=gas::def_ghost_area, double grid_scatter_in=gas::def_grid_scatter, double pt_scatter_in=gas::def_pt_scatter, double mean_ghost_pt_in=gas::def_mean_ghost_pt)
explicit constructor
GhostedAreaSpec(double ghost_minrap_in, double ghost_maxrap_in, int repeat_in=gas::def_repeat, double ghost_area_in=gas::def_ghost_area, double grid_scatter_in=gas::def_grid_scatter, double pt_scatter_in=gas::def_pt_scatter, double mean_ghost_pt_in=gas::def_mean_ghost_pt)
explicit constructor
GhostedAreaSpec()
default constructor
class to provide facilities for giving warnings up to some maximum number of times and to provide glo...
Class that encodes information about cuts and other selection criteria that can be applied to PseudoJ...
Definition: Selector.hh:149
double random_at_own_risk() const
very deprecated public access to a random number from the internal generator
void set_random_status(const std::vector< int > &__iseed)
set the status of the random number generator, as obtained previously with get_random_status.
Parameters to configure the computation of jet areas using ghosts.