1 | #ifndef __FASTJET_FUNCTION_OF_PSEUDOJET_HH__
|
---|
2 | #define __FASTJET_FUNCTION_OF_PSEUDOJET_HH__
|
---|
3 |
|
---|
4 | //FJSTARTHEADER
|
---|
5 | // $Id: FunctionOfPseudoJet.hh 4354 2018-04-22 07:12:37Z salam $
|
---|
6 | //
|
---|
7 | // Copyright (c) 2005-2018, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
|
---|
8 | //
|
---|
9 | //----------------------------------------------------------------------
|
---|
10 | // This file is part of FastJet.
|
---|
11 | //
|
---|
12 | // FastJet is free software; you can redistribute it and/or modify
|
---|
13 | // it under the terms of the GNU General Public License as published by
|
---|
14 | // the Free Software Foundation; either version 2 of the License, or
|
---|
15 | // (at your option) any later version.
|
---|
16 | //
|
---|
17 | // The algorithms that underlie FastJet have required considerable
|
---|
18 | // development. They are described in the original FastJet paper,
|
---|
19 | // hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
|
---|
20 | // FastJet as part of work towards a scientific publication, please
|
---|
21 | // quote the version you use and include a citation to the manual and
|
---|
22 | // optionally also to hep-ph/0512210.
|
---|
23 | //
|
---|
24 | // FastJet is distributed in the hope that it will be useful,
|
---|
25 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
26 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
27 | // GNU General Public License for more details.
|
---|
28 | //
|
---|
29 | // You should have received a copy of the GNU General Public License
|
---|
30 | // along with FastJet. If not, see <http://www.gnu.org/licenses/>.
|
---|
31 | //----------------------------------------------------------------------
|
---|
32 | //FJENDHEADER
|
---|
33 |
|
---|
34 | #include <fastjet/PseudoJet.hh>
|
---|
35 | #include <fastjet/Selector.hh>
|
---|
36 |
|
---|
37 | FASTJET_BEGIN_NAMESPACE
|
---|
38 |
|
---|
39 | /// \class FunctionOfPseudoJet
|
---|
40 | /// base class providing interface for a generic function of a PseudoJet
|
---|
41 | ///
|
---|
42 | /// This class serves as a base class to provide a standard interface
|
---|
43 | /// for a function that returns an object of a given (templated) type
|
---|
44 | /// that depends on a PseudoJet argument. The rationale for using a
|
---|
45 | /// class (rather than a pointer to a function) is that a class can be
|
---|
46 | /// constructed with (and store) additional arguments.
|
---|
47 | template<typename TOut>
|
---|
48 | class FunctionOfPseudoJet{
|
---|
49 | public:
|
---|
50 | /// default ctor
|
---|
51 | FunctionOfPseudoJet(){}
|
---|
52 |
|
---|
53 | // ctor that creates a constant function
|
---|
54 | //----------
|
---|
55 | // this declaration was present in versions of FJ from 3.0.0 to 3.0.6,
|
---|
56 | // but never implemented. It is being removed from 3.0.7 upwards
|
---|
57 | // to avoid misleading users
|
---|
58 | //FunctionOfPseudoJet(const TOut &constant_value);
|
---|
59 |
|
---|
60 | /// default dtor (virtual to allow safe polymorphism)
|
---|
61 | virtual ~FunctionOfPseudoJet(){}
|
---|
62 |
|
---|
63 | /// returns a description of the function (an empty string by
|
---|
64 | /// default)
|
---|
65 | virtual std::string description() const{ return "";}
|
---|
66 |
|
---|
67 | /// the action of the function
|
---|
68 | /// this _has_ to be overloaded in derived classes
|
---|
69 | /// \param pj the PseudoJet input to the function
|
---|
70 | virtual TOut result(const PseudoJet &pj) const = 0;
|
---|
71 |
|
---|
72 | /// apply the function using the "traditional" () operator.
|
---|
73 | /// By default, this just calls the apply(...) method above.
|
---|
74 | /// \param pj the PseudoJet input to the function
|
---|
75 | TOut operator()(const PseudoJet &pj) const { return result(pj);}
|
---|
76 |
|
---|
77 | /// apply the function on a vector of PseudoJet, returning a vector
|
---|
78 | /// of the results.
|
---|
79 | /// This just calls apply on every PseudoJet in the vector.
|
---|
80 | /// \param pjs the vector of PseudoJet inputs to the function
|
---|
81 | std::vector<TOut> operator()(const std::vector<PseudoJet> &pjs) const {
|
---|
82 | std::vector<TOut> res(pjs.size());
|
---|
83 | for (unsigned int i=0; i<pjs.size(); i++)
|
---|
84 | res[i] = result(pjs[i]);
|
---|
85 | return res;
|
---|
86 | }
|
---|
87 | };
|
---|
88 |
|
---|
89 | // The following functions will not be for FJ3.0, because passing a
|
---|
90 | // reference does not work when the argument is a temporary, which can
|
---|
91 | // lead to hard-to-diagnose run-time errors. A workaround is to to
|
---|
92 | // have a pointer rather than a reference as argument, since this
|
---|
93 | // provides a clearer signal to the user that the object must remain
|
---|
94 | // in scope.
|
---|
95 | //
|
---|
96 | //
|
---|
97 | // // Selectors created from the ordering between a FunctionOfPseudoJet
|
---|
98 | // // and a constant
|
---|
99 | // //----------------------------------------------------------------------
|
---|
100 | //
|
---|
101 | // /// 'larger than' operator
|
---|
102 | // ///
|
---|
103 | // /// Select jets for which the given function returns a result larger
|
---|
104 | // /// than the specified constant
|
---|
105 | // Selector operator >(const FunctionOfPseudoJet<double> & fn, const double & cut);
|
---|
106 | //
|
---|
107 | // /// 'smaller than' operator
|
---|
108 | // ///
|
---|
109 | // /// Select jets for which the given function returns a result smaller
|
---|
110 | // /// than the specified constant
|
---|
111 | // Selector operator <(const FunctionOfPseudoJet<double> & fn, const double & cut);
|
---|
112 | //
|
---|
113 | // /// 'larger or equal' operator
|
---|
114 | // ///
|
---|
115 | // /// Select jets for which the given function returns a result larger or equal
|
---|
116 | // /// to the specified constant
|
---|
117 | // Selector operator >=(const FunctionOfPseudoJet<double> & fn, const double & cut);
|
---|
118 | //
|
---|
119 | // /// 'smaller or equal' operator
|
---|
120 | // ///
|
---|
121 | // /// Select jets for which the given function returns a result smaller or equal
|
---|
122 | // /// to the specified constant
|
---|
123 | // Selector operator <=(const FunctionOfPseudoJet<double> & fn, const double & cut);
|
---|
124 |
|
---|
125 |
|
---|
126 | FASTJET_END_NAMESPACE
|
---|
127 |
|
---|
128 | #endif // __FASTJET_FUNCTION_OF_PSEUDOJET_HH__
|
---|