FastJet 3.0.2
FunctionOfPseudoJet.hh
00001 #ifndef __FASTJET_FUNCTION_OF_PSEUDOJET_HH__
00002 #define __FASTJET_FUNCTION_OF_PSEUDOJET_HH__
00003 
00004 //STARTHEADER
00005 // $Id: FunctionOfPseudoJet.hh 2577 2011-09-13 15:11:38Z salam $
00006 //
00007 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
00008 //
00009 //----------------------------------------------------------------------
00010 // This file is part of FastJet.
00011 //
00012 //  FastJet is free software; you can redistribute it and/or modify
00013 //  it under the terms of the GNU General Public License as published by
00014 //  the Free Software Foundation; either version 2 of the License, or
00015 //  (at your option) any later version.
00016 //
00017 //  The algorithms that underlie FastJet have required considerable
00018 //  development and are described in hep-ph/0512210. If you use
00019 //  FastJet as part of work towards a scientific publication, please
00020 //  include a citation to the FastJet paper.
00021 //
00022 //  FastJet is distributed in the hope that it will be useful,
00023 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025 //  GNU General Public License for more details.
00026 //
00027 //  You should have received a copy of the GNU General Public License
00028 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
00029 //----------------------------------------------------------------------
00030 //ENDHEADER
00031 
00032 #include <fastjet/PseudoJet.hh>
00033 #include <fastjet/Selector.hh>
00034 
00035 FASTJET_BEGIN_NAMESPACE
00036 
00037 /// \class FunctionOfPseudoJet
00038 /// base class providing interface for a generic function of a PseudoJet
00039 ///
00040 /// This class serves as a base class to provide a standard interface
00041 /// for a function that returns an object of a given (templated) type
00042 /// that depends on a PseudoJet argument. The rationale for using a
00043 /// class (rather than a pointer to a function) is that a class can be
00044 /// constructed with (and store) additional arguments.
00045 template<typename TOut>
00046 class FunctionOfPseudoJet{
00047 public:
00048   /// default ctor
00049   FunctionOfPseudoJet(){}
00050 
00051   /// ctor that creates a constant function
00052   FunctionOfPseudoJet(const TOut &constant_value);
00053 
00054   /// default dtor (virtual to allow safe polymorphism)
00055   virtual ~FunctionOfPseudoJet(){}
00056 
00057   /// returns a description of the function (an empty string by
00058   /// default)
00059   virtual std::string description() const{ return "";}
00060 
00061   /// the action of the function
00062   /// this _has_ to be overloaded in derived classes
00063   ///  \param pj   the PseudoJet input to the function
00064   virtual TOut result(const PseudoJet &pj) const = 0;
00065 
00066   /// apply the function using the "traditional" () operator.
00067   /// By default, this just calls the apply(...) method above.
00068   ///  \param pj   the PseudoJet input to the function
00069   TOut operator()(const PseudoJet &pj) const { return result(pj);}
00070 
00071   /// apply the function on a vector of PseudoJet, returning a vector
00072   /// of the results.
00073   /// This just calls apply on every PseudoJet in the vector.
00074   ///  \param pjs  the vector of PseudoJet inputs to the function
00075   std::vector<TOut> operator()(const std::vector<PseudoJet> &pjs) const {
00076     std::vector<TOut> res(pjs.size());
00077     for (unsigned int i=0; i<pjs.size(); i++)
00078       res[i] = result(pjs[i]);
00079     return res;
00080   }
00081 };
00082 
00083 // The following functions will not be for FJ3.0, because passing a
00084 // reference does not work when the argument is a temporary, which can
00085 // lead to hard-to-diagnose run-time errors. A workaround is to to
00086 // have a pointer rather than a reference as argument, since this
00087 // provides a clearer signal to the user that the object must remain
00088 // in scope.
00089 //
00090 //
00091 // // Selectors created from the ordering between a FunctionOfPseudoJet
00092 // // and a constant
00093 // //----------------------------------------------------------------------
00094 // 
00095 // /// 'larger than' operator
00096 // ///
00097 // /// Select jets for which the given function returns a result larger
00098 // /// than the specified constant
00099 // Selector operator >(const FunctionOfPseudoJet<double> & fn, const double & cut);
00100 // 
00101 // /// 'smaller than' operator
00102 // ///
00103 // /// Select jets for which the given function returns a result smaller
00104 // /// than the specified constant
00105 // Selector operator <(const FunctionOfPseudoJet<double> & fn, const double & cut);
00106 // 
00107 // /// 'larger or equal' operator
00108 // ///
00109 // /// Select jets for which the given function returns a result larger or equal 
00110 // /// to the specified constant
00111 // Selector operator >=(const FunctionOfPseudoJet<double> & fn, const double & cut);
00112 // 
00113 // /// 'smaller or equal' operator
00114 // ///
00115 // /// Select jets for which the given function returns a result smaller or equal
00116 // /// to the specified constant
00117 // Selector operator <=(const FunctionOfPseudoJet<double> & fn, const double & cut);
00118 
00119 
00120 FASTJET_END_NAMESPACE
00121 
00122 #endif  // __FASTJET_FUNCTION_OF_PSEUDOJET_HH__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends