FastJet 3.0beta1
|
00001 #ifndef __FASTJET_FUNCTION_OF_PSEUDOJET_HH__ 00002 #define __FASTJET_FUNCTION_OF_PSEUDOJET_HH__ 00003 00004 //STARTHEADER 00005 // $Id: FunctionOfPseudoJet.hh 2319 2011-06-30 12:46:38Z salam $ 00006 // 00007 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin 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, write to the Free Software 00029 // Foundation, Inc.: 00030 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00031 //---------------------------------------------------------------------- 00032 //ENDHEADER 00033 00034 #include <fastjet/PseudoJet.hh> 00035 #include <fastjet/Selector.hh> 00036 00037 FASTJET_BEGIN_NAMESPACE 00038 00039 /// \class FunctionOfPseudoJet 00040 /// base class providing interface for a generic function of a PseudoJet 00041 /// 00042 /// This class serves as a base class to provide a standard interface 00043 /// for a function that returns an object of a given (templated) type 00044 /// that depends on a PseudoJet argument. The rationale for using a 00045 /// class (rather than a pointer to a function) is that a class can be 00046 /// constructed with (and store) additional arguments. 00047 template<typename TOut> 00048 class FunctionOfPseudoJet{ 00049 public: 00050 /// default ctor 00051 FunctionOfPseudoJet(){} 00052 00053 /// ctor that creates a constant function 00054 FunctionOfPseudoJet(const TOut &constant_value); 00055 00056 /// default dtor (virtual to allow safe polymorphism) 00057 virtual ~FunctionOfPseudoJet(){} 00058 00059 /// returns a description of the function (an empty string by 00060 /// default) 00061 virtual std::string description() const{ return "";} 00062 00063 /// the action of the function 00064 /// this _has_ to be overloaded in derived classes 00065 /// \param pj the PseudoJet input to the function 00066 virtual TOut result(const PseudoJet &pj) const = 0; 00067 00068 /// apply the function using the "traditional" () operator. 00069 /// By default, this just calls the apply(...) method above. 00070 /// \param pj the PseudoJet input to the function 00071 TOut operator()(const PseudoJet &pj) const { return result(pj);} 00072 00073 /// apply the function on a vector of PseudoJet, returning a vector 00074 /// of the results. 00075 /// This just calls apply on every PseudoJet in the vector. 00076 /// \param pjs the vector of PseudoJet inputs to the function 00077 std::vector<TOut> operator()(const std::vector<PseudoJet> &pjs) const { 00078 std::vector<TOut> res(pjs.size()); 00079 for (unsigned int i=0; i<pjs.size(); i++) 00080 res[i] = result(pjs[i]); 00081 return res; 00082 } 00083 }; 00084 00085 // The following functions will not be for FJ3.0, because passing a 00086 // reference does not work when the argument is a temporary, which can 00087 // lead to hard-to-diagnose run-time errors. A workaround is to to 00088 // have a pointer rather than a reference as argument, since this 00089 // provides a clearer signal to the user that the object must remain 00090 // in scope. 00091 // 00092 // 00093 // // Selectors created from the ordering between a FunctionOfPseudoJet 00094 // // and a constant 00095 // //---------------------------------------------------------------------- 00096 // 00097 // /// 'larger than' operator 00098 // /// 00099 // /// Select jets for which the given function returns a result larger 00100 // /// than the specified constant 00101 // Selector operator >(const FunctionOfPseudoJet<double> & fn, const double & cut); 00102 // 00103 // /// 'smaller than' operator 00104 // /// 00105 // /// Select jets for which the given function returns a result smaller 00106 // /// than the specified constant 00107 // Selector operator <(const FunctionOfPseudoJet<double> & fn, const double & cut); 00108 // 00109 // /// 'larger or equal' operator 00110 // /// 00111 // /// Select jets for which the given function returns a result larger or equal 00112 // /// to the specified constant 00113 // Selector operator >=(const FunctionOfPseudoJet<double> & fn, const double & cut); 00114 // 00115 // /// 'smaller or equal' operator 00116 // /// 00117 // /// Select jets for which the given function returns a result smaller or equal 00118 // /// to the specified constant 00119 // Selector operator <=(const FunctionOfPseudoJet<double> & fn, const double & cut); 00120 00121 00122 FASTJET_END_NAMESPACE 00123 00124 #endif // __FASTJET_FUNCTION_OF_PSEUDOJET_HH__