Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:14

0001 //  Nsubjettiness Package
0002 //  Questions/Comments?  jthaler@jthaler.net
0003 //
0004 //  Copyright (c) 2011-14
0005 //  Jesse Thaler, Ken Van Tilburg, Christopher K. Vermilion, and TJ Wilkason
0006 //
0007 //  $Id: MeasureDefinition.hh 828 2015-07-20 14:52:06Z jthaler $
0008 //----------------------------------------------------------------------
0009 // This file is part of FastJet contrib.
0010 //
0011 // It is free software; you can redistribute it and/or modify it under
0012 // the terms of the GNU General Public License as published by the
0013 // Free Software Foundation; either version 2 of the License, or (at
0014 // your option) any later version.
0015 //
0016 // It is distributed in the hope that it will be useful, but WITHOUT
0017 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
0018 // or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
0019 // License for more details.
0020 //
0021 // You should have received a copy of the GNU General Public License
0022 // along with this code. If not, see <http://www.gnu.org/licenses/>.
0023 //----------------------------------------------------------------------
0024 
0025 #ifndef __FASTJET_CONTRIB_MEASUREDEFINITION_HH__
0026 #define __FASTJET_CONTRIB_MEASUREDEFINITION_HH__
0027 
0028 #include "fastjet/PseudoJet.hh"
0029 #include <cmath>
0030 #include <vector>
0031 #include <list>
0032 #include <limits>
0033 
0034 #include "TauComponents.hh"
0035 
0036 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
0037 
0038 namespace contrib{
0039 
0040 
0041 
0042 // The following Measures are available (and their relevant arguments):
0043 // Recommended for usage as jet shapes
0044 class DefaultMeasure;               // Default measure from which next classes derive (should not be called directly)
0045 class NormalizedMeasure;            // (beta,R0)
0046 class UnnormalizedMeasure;          // (beta)
0047 class NormalizedCutoffMeasure;      // (beta,R0,Rcutoff)
0048 class UnnormalizedCutoffMeasure;    // (beta,Rcutoff)
0049 
0050 // New measures as of v2.2
0051 // Recommended for usage as event shapes (or for jet finding)
0052 class ConicalMeasure;               // (beta,R)
0053 class OriginalGeometricMeasure;     // (R)
0054 class ModifiedGeometricMeasure;     // (R)
0055 class ConicalGeometricMeasure;      // (beta, gamma, R)
0056 class XConeMeasure;                 // (beta, R)
0057    
0058 // Formerly GeometricMeasure, now no longer recommended, kept commented out only for cross-check purposes
0059 //class DeprecatedGeometricMeasure;         // (beta)
0060 //class DeprecatedGeometricCutoffMeasure;   // (beta,Rcutoff)
0061 
0062    
0063 ///////
0064 //
0065 // MeasureDefinition
0066 //
0067 ///////
0068 
0069 //This is a helper class for the Minimum Axes Finders. It is defined later.
0070 class LightLikeAxis;                                          
0071    
0072 ///------------------------------------------------------------------------
0073 /// \class MeasureDefinition
0074 /// \brief Base class for measure definitions
0075 ///
0076 /// This is the base class for measure definitions.  Derived classes will calculate
0077 /// the tau_N of a jet given a specific measure and a set of axes.  The measure is
0078 /// determined by various jet and beam distances (and possible normalization factors).
0079 ///------------------------------------------------------------------------
0080 class MeasureDefinition {
0081    
0082 public:
0083    
0084    /// Description of measure and parameters
0085    virtual std::string description() const = 0;
0086    
0087    /// In derived classes, this should return a copy of the corresponding derived class
0088    virtual MeasureDefinition* create() const = 0;
0089 
0090    //The following five functions define the measure by which tau_N is calculated,
0091    //and are overloaded by the various measures below
0092    
0093    /// Distanes to jet axis.  This is called many times, so needs to be as fast as possible
0094    /// Unless overloaded, it just calls jet_numerator
0095    virtual double jet_distance_squared(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const {
0096       return jet_numerator(particle,axis);
0097    }
0098 
0099    /// Distanes to beam.  This is called many times, so needs to be as fast as possible
0100    /// Unless overloaded, it just calls beam_numerator
0101    virtual double beam_distance_squared(const fastjet::PseudoJet& particle) const {
0102       return beam_numerator(particle);
0103    }
0104    
0105    /// The jet measure used in N-(sub)jettiness
0106    virtual double jet_numerator(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const = 0;
0107    /// The beam measure used in N-(sub)jettiness
0108    virtual double beam_numerator(const fastjet::PseudoJet& particle) const = 0;
0109    
0110    /// A possible normalization factor
0111    virtual double denominator(const fastjet::PseudoJet& particle) const = 0;
0112    
0113    /// Run a one-pass minimization routine.  There is a generic one-pass minimization that works for a wide variety of measures.
0114    /// This should be overloaded to create a measure-specific minimization scheme
0115    virtual std::vector<fastjet::PseudoJet> get_one_pass_axes(int n_jets,
0116                                                              const std::vector<fastjet::PseudoJet>& inputs,
0117                                                              const std::vector<fastjet::PseudoJet>& seedAxes,
0118                                                              int nAttempts = 1000,         // cap number of iterations
0119                                                              double accuracy = 0.0001      // cap distance of closest approach
0120    ) const;
0121    
0122 public:
0123    
0124    /// Returns the tau value for a give set of particles and axes
0125    double result(const std::vector<fastjet::PseudoJet>& particles, const std::vector<fastjet::PseudoJet>& axes) const {
0126       return component_result(particles,axes).tau();
0127    }
0128    
0129    /// Short-hand for the result() function
0130    inline double operator() (const std::vector<fastjet::PseudoJet>& particles, const std::vector<fastjet::PseudoJet>& axes) const {
0131       return result(particles,axes);
0132    }
0133    
0134    /// Return all of the TauComponents for specific input particles and axes
0135    TauComponents component_result(const std::vector<fastjet::PseudoJet>& particles, const std::vector<fastjet::PseudoJet>& axes) const;
0136    
0137    /// Create the partitioning according the jet/beam distances and stores them a TauPartition
0138    TauPartition get_partition(const std::vector<fastjet::PseudoJet>& particles, const std::vector<fastjet::PseudoJet>& axes) const;
0139 
0140    /// Calculate the tau result using an existing partition
0141    TauComponents component_result_from_partition(const TauPartition& partition, const std::vector<fastjet::PseudoJet>& axes) const;
0142 
0143    
0144 
0145    /// virtual destructor
0146    virtual ~MeasureDefinition(){}
0147    
0148 protected:
0149    
0150    /// Flag set by derived classes to choose whether or not to use beam/denominator
0151    TauMode _tau_mode;
0152    
0153    /// Flag set by derived classes to say whether cheap get_one_pass_axes method can be used (true by default)
0154    bool _useAxisScaling;
0155 
0156    /// This is the only constructor, which requires _tau_mode and _useAxisScaling to be manually set by derived classes.
0157    MeasureDefinition() : _tau_mode(UNDEFINED_SHAPE), _useAxisScaling(true) {}
0158 
0159    
0160    /// Used by derived classes to set whether or not to use beam/denominator information
0161    void setTauMode(TauMode tau_mode) {
0162       _tau_mode = tau_mode;
0163    }
0164 
0165    /// Used by derived classes to say whether one can use cheap get_one_pass_axes
0166    void setAxisScaling(bool useAxisScaling) {
0167       _useAxisScaling = useAxisScaling;
0168    }
0169 
0170    /// Uses denominator information?
0171    bool has_denominator() const { return (_tau_mode == NORMALIZED_JET_SHAPE || _tau_mode == NORMALIZED_EVENT_SHAPE);}
0172    /// Uses beam information?
0173    bool has_beam() const {return (_tau_mode == UNNORMALIZED_EVENT_SHAPE || _tau_mode == NORMALIZED_EVENT_SHAPE);}
0174 
0175    /// Create light-like axis (used in default one-pass minimization routine)
0176    fastjet::PseudoJet lightFrom(const fastjet::PseudoJet& input) const {
0177       double length = sqrt(pow(input.px(),2) + pow(input.py(),2) + pow(input.pz(),2));
0178       return fastjet::PseudoJet(input.px()/length,input.py()/length,input.pz()/length,1.0);
0179    }
0180    
0181    /// Shorthand for squaring
0182    static inline double sq(double x) {return x*x;}
0183 
0184 };
0185    
0186 
0187 ///////
0188 //
0189 // Default Measures
0190 //
0191 ///////
0192    
0193    
0194 ///------------------------------------------------------------------------
0195 /// \enum DefaultMeasureType
0196 /// \brief Options for default measure
0197 ///
0198 /// Can be used to switch between pp and ee measure types in the DefaultMeasure
0199 ///------------------------------------------------------------------------
0200 enum DefaultMeasureType {
0201    pt_R,       ///  use transverse momenta and boost-invariant angles,
0202    E_theta,    ///  use energies and angles,
0203    lorentz_dot, ///  use dot product inspired measure
0204    perp_lorentz_dot /// use conical geometric inspired measures
0205 };
0206 
0207 ///------------------------------------------------------------------------
0208 /// \class DefaultMeasure
0209 /// \brief Base class for default N-subjettiness measure definitions
0210 ///
0211 /// This class is the default measure as defined in the original N-subjettiness papers.
0212 /// Based on the conical measure, but with a normalization factor
0213 /// This measure is defined as the pT of the particle multiplied by deltaR
0214 /// to the power of beta. This class includes the normalization factor determined by R0
0215 ///------------------------------------------------------------------------
0216 class DefaultMeasure : public MeasureDefinition {
0217    
0218 public:
0219 
0220    /// Description
0221    virtual std::string description() const;
0222    /// To allow copying around of these objects
0223    virtual DefaultMeasure* create() const {return new DefaultMeasure(*this);}
0224 
0225    /// fast jet distance
0226    virtual double jet_distance_squared(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const {
0227       return angleSquared(particle, axis);
0228    }
0229    
0230    /// fast beam distance
0231    virtual double beam_distance_squared(const fastjet::PseudoJet& /*particle*/) const {
0232       return _RcutoffSq;
0233    }
0234    
0235    /// true jet distance (given by general definitions of energy and angle)
0236    virtual double jet_numerator(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const{
0237       double jet_dist = angleSquared(particle, axis);
0238       if (jet_dist > 0.0) {
0239          return energy(particle) * std::pow(jet_dist,_beta/2.0);
0240       } else {
0241          return 0.0;
0242       }
0243    }
0244    
0245    /// true beam distance
0246    virtual double beam_numerator(const fastjet::PseudoJet& particle) const {
0247       return energy(particle) * std::pow(_Rcutoff,_beta);
0248    }
0249    
0250    /// possible denominator for normalization
0251    virtual double denominator(const fastjet::PseudoJet& particle) const {
0252       return energy(particle) * std::pow(_R0,_beta);
0253    }
0254 
0255    /// Special minimization routine (from v1.0 of N-subjettiness)
0256    virtual std::vector<fastjet::PseudoJet> get_one_pass_axes(int n_jets,
0257                                                              const std::vector<fastjet::PseudoJet>& inputs,
0258                                                              const std::vector<fastjet::PseudoJet>& seedAxes,
0259                                                              int nAttempts,   // cap number of iterations
0260                                                              double accuracy  // cap distance of closest approach
0261                                                              ) const;
0262    
0263 protected:
0264    double _beta;      ///< Angular exponent
0265    double _R0;        ///< Normalization factor
0266    double _Rcutoff;   ///< Cutoff radius
0267    double _RcutoffSq; ///< Cutoff radius squared
0268    DefaultMeasureType _measure_type;  ///< Type of measure used (i.e. pp style or ee style)
0269    
0270    
0271    /// Constructor is protected so that no one tries to call this directly.
0272    DefaultMeasure(double beta, double R0, double Rcutoff, DefaultMeasureType measure_type = pt_R)
0273    : MeasureDefinition(), _beta(beta), _R0(R0), _Rcutoff(Rcutoff), _RcutoffSq(sq(Rcutoff)), _measure_type(measure_type)
0274    {
0275       if (beta <= 0) throw Error("DefaultMeasure:  You must choose beta > 0.");
0276       if (R0 <= 0) throw Error("DefaultMeasure:  You must choose R0 > 0.");
0277       if (Rcutoff <= 0) throw Error("DefaultMeasure:  You must choose Rcutoff > 0.");
0278    }
0279    
0280    /// Added set measure method in case it becomes useful later
0281    void setDefaultMeasureType(DefaultMeasureType measure_type) {
0282       _measure_type = measure_type;
0283    }
0284 
0285    /// Generalized energy value (determined by _measure_type)
0286    double energy(const PseudoJet& jet) const;
0287    /// Generalized angle value (determined by _measure_type)
0288    double angleSquared(const PseudoJet& jet1, const PseudoJet& jet2) const;
0289 
0290    /// Name of _measure_type, so description will include the measure type
0291    std::string measure_type_name() const {
0292       if (_measure_type == pt_R) return "pt_R";
0293       else if (_measure_type == E_theta) return "E_theta";
0294       else if (_measure_type == lorentz_dot) return "lorentz_dot";
0295       else if (_measure_type == perp_lorentz_dot) return "perp_lorentz_dot";
0296       else return "Measure Type Undefined";
0297    }      
0298 
0299    /// templated for speed (TODO: probably should remove, since not clear that there is a speed gain)
0300    template <int N> std::vector<LightLikeAxis> UpdateAxesFast(const std::vector <LightLikeAxis> & old_axes,
0301                                                               const std::vector <fastjet::PseudoJet> & inputJets,
0302                                                               double accuracy) const;
0303    
0304    /// called by get_one_pass_axes to update axes iteratively
0305    std::vector<LightLikeAxis> UpdateAxes(const std::vector <LightLikeAxis> & old_axes,
0306                                          const std::vector <fastjet::PseudoJet> & inputJets,
0307                                          double accuracy) const;
0308 };
0309    
0310 
0311 ///------------------------------------------------------------------------
0312 /// \class NormalizedCutoffMeasure
0313 /// \brief Dimensionless default measure, with radius cutoff
0314 ///
0315 /// This measure is just a wrapper for DefaultMeasure
0316 ///------------------------------------------------------------------------
0317 class NormalizedCutoffMeasure : public DefaultMeasure {
0318 
0319 public:
0320 
0321    /// Constructor
0322    NormalizedCutoffMeasure(double beta, double R0, double Rcutoff, DefaultMeasureType measure_type = pt_R) 
0323    : DefaultMeasure(beta, R0, Rcutoff, measure_type) {
0324       setTauMode(NORMALIZED_JET_SHAPE);
0325    }
0326 
0327    /// Description
0328    virtual std::string description() const;
0329 
0330    /// For copying purposes
0331    virtual NormalizedCutoffMeasure* create() const {return new NormalizedCutoffMeasure(*this);}
0332 
0333 };
0334 
0335 ///------------------------------------------------------------------------
0336 /// \class NormalizedMeasure
0337 /// \brief Dimensionless default measure, with no cutoff
0338 ///
0339 /// This measure is the same as NormalizedCutoffMeasure, with Rcutoff taken to infinity.
0340 ///------------------------------------------------------------------------
0341 class NormalizedMeasure : public NormalizedCutoffMeasure {
0342 
0343 public:
0344 
0345    /// Constructor
0346    NormalizedMeasure(double beta, double R0, DefaultMeasureType measure_type = pt_R)
0347    : NormalizedCutoffMeasure(beta, R0, std::numeric_limits<double>::max(), measure_type) {
0348       _RcutoffSq = std::numeric_limits<double>::max();
0349       setTauMode(NORMALIZED_JET_SHAPE);
0350    }
0351    
0352    /// Description
0353    virtual std::string description() const;
0354    /// For copying purposes
0355    virtual NormalizedMeasure* create() const {return new NormalizedMeasure(*this);}
0356 
0357 };
0358    
0359 
0360 ///------------------------------------------------------------------------
0361 /// \class UnnormalizedCutoffMeasure
0362 /// \brief Dimensionful default measure, with radius cutoff
0363 ///
0364 /// This class is the unnormalized conical measure. The only difference from NormalizedCutoffMeasure
0365 /// is that the denominator is defined to be 1.0 by setting _has_denominator to false.
0366 /// class UnnormalizedCutoffMeasure : public NormalizedCutoffMeasure {
0367 ///------------------------------------------------------------------------
0368 class UnnormalizedCutoffMeasure : public DefaultMeasure {
0369    
0370 public:
0371    
0372    /// Since all methods are identical, UnnormalizedMeasure inherits directly
0373    /// from NormalizedMeasure. R0 is a dummy value since the value of R0 is unecessary for this class,
0374    /// and the "false" flag sets _has_denominator in MeasureDefinition to false so no denominator is used.
0375    UnnormalizedCutoffMeasure(double beta, double Rcutoff, DefaultMeasureType measure_type = pt_R)
0376    : DefaultMeasure(beta, std::numeric_limits<double>::quiet_NaN(), Rcutoff, measure_type) {
0377       setTauMode(UNNORMALIZED_EVENT_SHAPE);
0378    }
0379 
0380    /// Description
0381    virtual std::string description() const;
0382    /// For copying purposes
0383    virtual UnnormalizedCutoffMeasure* create() const {return new UnnormalizedCutoffMeasure(*this);}
0384 
0385 };
0386 
0387    
0388 ///------------------------------------------------------------------------
0389 /// \class UnnormalizedMeasure
0390 /// \brief Dimensionless default measure, with no cutoff
0391 ///
0392 /// This measure is the same as UnnormalizedCutoffMeasure, with Rcutoff taken to infinity.
0393 ///------------------------------------------------------------------------
0394 class UnnormalizedMeasure : public UnnormalizedCutoffMeasure {
0395    
0396 public:
0397    /// Since all methods are identical, UnnormalizedMeasure inherits directly
0398    /// from NormalizedMeasure. R0 is a dummy value since the value of R0 is unecessary for this class,
0399    /// and the "false" flag sets _has_denominator in MeasureDefinition to false so no denominator is used.
0400    UnnormalizedMeasure(double beta, DefaultMeasureType measure_type = pt_R)
0401    : UnnormalizedCutoffMeasure(beta, std::numeric_limits<double>::max(), measure_type) {
0402       _RcutoffSq = std::numeric_limits<double>::max();
0403       setTauMode(UNNORMALIZED_JET_SHAPE);
0404    }
0405 
0406    /// Description
0407    virtual std::string description() const;
0408    
0409    /// For copying purposes
0410    virtual UnnormalizedMeasure* create() const {return new UnnormalizedMeasure(*this);}
0411    
0412 };
0413 
0414 
0415 ///------------------------------------------------------------------------
0416 /// \class ConicalMeasure
0417 /// \brief Dimensionful event-shape measure, with radius cutoff
0418 ///
0419 /// Very similar to UnnormalizedCutoffMeasure, but with different normalization convention
0420 /// and using the new default one-pass minimization algorithm.
0421 /// Axes are also made to be light-like to ensure sensible behavior
0422 /// Intended to be used as an event shape.
0423 ///------------------------------------------------------------------------
0424 class ConicalMeasure : public MeasureDefinition {
0425    
0426 public:
0427    
0428    /// Constructor
0429    ConicalMeasure(double beta, double Rcutoff)
0430    :   MeasureDefinition(), _beta(beta), _Rcutoff(Rcutoff), _RcutoffSq(sq(Rcutoff)) {
0431       if (beta <= 0) throw Error("ConicalMeasure:  You must choose beta > 0.");
0432       if (Rcutoff <= 0) throw Error("ConicalMeasure:  You must choose Rcutoff > 0.");
0433       setTauMode(UNNORMALIZED_EVENT_SHAPE);
0434    }
0435    
0436    /// Description
0437    virtual std::string description() const;
0438    /// For copying purposes
0439    virtual ConicalMeasure* create() const {return new ConicalMeasure(*this);}
0440    
0441    /// fast jet distance
0442    virtual double jet_distance_squared(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const {
0443       PseudoJet lightAxis = lightFrom(axis);
0444       return particle.squared_distance(lightAxis);
0445    }
0446    
0447    /// fast beam distance
0448    virtual double beam_distance_squared(const fastjet::PseudoJet&  /*particle*/) const {
0449       return _RcutoffSq;
0450    }
0451    
0452    
0453    /// true jet distance
0454    virtual double jet_numerator(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const {
0455       PseudoJet lightAxis = lightFrom(axis);
0456       double jet_dist = particle.squared_distance(lightAxis)/_RcutoffSq;
0457       double jet_perp = particle.perp();
0458       
0459       if (_beta == 2.0) {
0460          return jet_perp * jet_dist;
0461       } else {
0462          return jet_perp * pow(jet_dist,_beta/2.0);
0463       }
0464    }
0465    
0466    /// true beam distance
0467    virtual double beam_numerator(const fastjet::PseudoJet& particle) const {
0468       return particle.perp();
0469    }
0470    
0471    /// no denominator used for this measure
0472    virtual double denominator(const fastjet::PseudoJet&  /*particle*/) const {
0473       return std::numeric_limits<double>::quiet_NaN();
0474    }
0475    
0476 protected:
0477    double _beta;     ///< angular exponent
0478    double _Rcutoff;  ///< effective jet radius
0479    double _RcutoffSq;///< effective jet radius squared
0480 };
0481    
0482 
0483 
0484 ///------------------------------------------------------------------------
0485 /// \class OriginalGeometricMeasure
0486 /// \brief Dimensionful event-shape measure, with dot-product distances
0487 ///
0488 /// This class is the original (and hopefully now correctly coded) geometric measure.
0489 /// This measure is defined by the Lorentz dot product between
0490 /// the particle and the axis.  This class does not include normalization of tau_N.
0491 /// New in Nsubjettiness v2.2
0492 /// NOTE: This is defined differently from the DeprecatedGeometricMeasure which are now commented out.
0493 ///------------------------------------------------------------------------
0494 class OriginalGeometricMeasure : public MeasureDefinition {
0495 
0496 public:
0497    /// Constructor
0498    OriginalGeometricMeasure(double Rcutoff)
0499    : MeasureDefinition(), _Rcutoff(Rcutoff), _RcutoffSq(sq(Rcutoff)) {
0500       if (Rcutoff <= 0) throw Error("OriginalGeometricMeasure:  You must choose Rcutoff > 0.");
0501       setTauMode(UNNORMALIZED_EVENT_SHAPE);
0502       setAxisScaling(false);  // No need to rescale axes (for speed up in one-pass minimization)
0503    }
0504 
0505    /// Description
0506    virtual std::string description() const;
0507    /// For copying purposes
0508    virtual OriginalGeometricMeasure* create() const {return new OriginalGeometricMeasure(*this);}
0509    
0510    // This class uses the default jet_distance_squared and beam_distance_squared
0511 
0512    /// true jet measure
0513    virtual double jet_numerator(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const {
0514       return dot_product(lightFrom(axis), particle)/_RcutoffSq;
0515    }
0516 
0517    /// true beam measure
0518    virtual double beam_numerator(const fastjet::PseudoJet& particle) const {
0519       fastjet::PseudoJet beam_a(0,0,1,1);
0520       fastjet::PseudoJet beam_b(0,0,-1,1);
0521       double min_perp = std::min(dot_product(beam_a, particle),dot_product(beam_b, particle));
0522       return min_perp;
0523    }
0524 
0525    /// no denominator needed for this measure.
0526    virtual double denominator(const fastjet::PseudoJet&  /*particle*/) const {
0527       return std::numeric_limits<double>::quiet_NaN();
0528    }
0529    
0530 protected:
0531    double _Rcutoff;   ///< Effective jet radius (rho = R^2)
0532    double _RcutoffSq; ///< Effective jet radius squared
0533 
0534 };
0535 
0536 
0537 ///------------------------------------------------------------------------
0538 /// \class ModifiedGeometricMeasure
0539 /// \brief Dimensionful event-shape measure, with dot-product distances, modified beam measure
0540 ///
0541 /// This class is the Modified geometric measure.  This jet measure is defined by the Lorentz dot product between
0542 /// the particle and the axis, as in the Original Geometric Measure. The beam measure is defined differently from
0543 /// the above OriginalGeometric to allow for more conical jets. New in Nsubjettiness v2.2
0544 ///------------------------------------------------------------------------
0545 class ModifiedGeometricMeasure : public MeasureDefinition {
0546 
0547 public:
0548    /// Constructor
0549    ModifiedGeometricMeasure(double Rcutoff)
0550    :  MeasureDefinition(), _Rcutoff(Rcutoff), _RcutoffSq(sq(Rcutoff)) {
0551       if (Rcutoff <= 0) throw Error("ModifiedGeometricMeasure:  You must choose Rcutoff > 0.");
0552       setTauMode(UNNORMALIZED_EVENT_SHAPE);
0553       setAxisScaling(false);  // No need to rescale axes (for speed up in one-pass minimization)
0554    }
0555 
0556    /// Description
0557    virtual std::string description() const;
0558    /// For copying purposes
0559    virtual ModifiedGeometricMeasure* create() const {return new ModifiedGeometricMeasure(*this);}
0560    
0561    // This class uses the default jet_distance_squared and beam_distance_squared
0562 
0563    /// True jet measure
0564    virtual double jet_numerator(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const {
0565       return dot_product(lightFrom(axis), particle)/_RcutoffSq;
0566    }
0567 
0568    /// True beam measure
0569    virtual double beam_numerator(const fastjet::PseudoJet& particle) const {
0570       fastjet::PseudoJet lightParticle = lightFrom(particle);
0571       return 0.5*particle.mperp()*lightParticle.pt();
0572    }
0573 
0574    /// This measure does not require a denominator
0575    virtual double denominator(const fastjet::PseudoJet&  /*particle*/) const {
0576       return std::numeric_limits<double>::quiet_NaN();
0577    }
0578    
0579 protected:
0580    double _Rcutoff;   ///< Effective jet radius (rho = R^2)
0581    double _RcutoffSq; ///< Effective jet radius squared
0582 
0583 
0584 };
0585 
0586 ///------------------------------------------------------------------------
0587 /// \class ConicalGeometricMeasure
0588 /// \brief Dimensionful event-shape measure, basis for XCone jet algorithm
0589 ///
0590 /// This class is the Conical Geometric measure.  This measure is defined by the Lorentz dot product between
0591 /// the particle and the axis normalized by the axis and particle pT, as well as a factor of cosh(y) to vary
0592 /// the rapidity depepdence of the beam. New in Nsubjettiness v2.2, and the basis for the XCone jet algorithm
0593 ///------------------------------------------------------------------------
0594 class ConicalGeometricMeasure : public MeasureDefinition {
0595 
0596 public:
0597    
0598    /// Constructor
0599    ConicalGeometricMeasure(double jet_beta, double beam_gamma, double Rcutoff)
0600    :  MeasureDefinition(),  _jet_beta(jet_beta), _beam_gamma(beam_gamma), _Rcutoff(Rcutoff), _RcutoffSq(sq(Rcutoff)){
0601       if (jet_beta <= 0)   throw Error("ConicalGeometricMeasure:  You must choose beta > 0.");
0602       if (beam_gamma <= 0) throw Error("ConicalGeometricMeasure:  You must choose gamma > 0.");
0603       if (Rcutoff <= 0)   throw Error("ConicalGeometricMeasure:  You must choose Rcutoff > 0.");
0604       setTauMode(UNNORMALIZED_EVENT_SHAPE);
0605    }
0606 
0607    /// Description
0608    virtual std::string description() const;
0609    /// For copying purposes
0610    virtual ConicalGeometricMeasure* create() const {return new ConicalGeometricMeasure(*this);}
0611    
0612    /// fast jet measure
0613    virtual double jet_distance_squared(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const {
0614       fastjet::PseudoJet lightAxis = lightFrom(axis);
0615       double pseudoRsquared = 2.0*dot_product(lightFrom(axis),particle)/(lightAxis.pt()*particle.pt());
0616       return pseudoRsquared;
0617    }
0618 
0619    /// fast beam measure
0620    virtual double beam_distance_squared(const fastjet::PseudoJet&  /*particle*/) const {
0621       return _RcutoffSq;
0622    }
0623 
0624    /// true jet measure
0625    virtual double jet_numerator(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const {
0626       double jet_dist = jet_distance_squared(particle,axis)/_RcutoffSq;
0627       if (jet_dist > 0.0) {
0628          fastjet::PseudoJet lightParticle = lightFrom(particle);
0629          double weight = (_beam_gamma == 1.0) ? 1.0 : std::pow(0.5*lightParticle.pt(),_beam_gamma - 1.0);
0630          return particle.pt() * weight * std::pow(jet_dist,_jet_beta/2.0);
0631       } else {
0632          return 0.0;
0633       }
0634    }
0635 
0636    /// true beam measure
0637    virtual double beam_numerator(const fastjet::PseudoJet& particle) const {
0638       fastjet::PseudoJet lightParticle = lightFrom(particle);
0639       double weight = (_beam_gamma == 1.0) ? 1.0 : std::pow(0.5*lightParticle.pt(),_beam_gamma - 1.0);
0640       return particle.pt() * weight;
0641    }
0642 
0643    /// no denominator needed
0644    virtual double denominator(const fastjet::PseudoJet&  /*particle*/) const {
0645       return std::numeric_limits<double>::quiet_NaN();
0646    }
0647       
0648 protected:
0649    double _jet_beta;   ///< jet angular exponent
0650    double _beam_gamma; ///< beam angular exponent (gamma = 1.0 is recommended)
0651    double _Rcutoff;    ///< effective jet radius
0652    double _RcutoffSq;  ///< effective jet radius squared
0653    
0654 };
0655 
0656 ///------------------------------------------------------------------------
0657 /// \class XConeMeasure
0658 /// \brief Dimensionful event-shape measure used in XCone jet algorithm
0659 ///
0660 /// This class is the XCone Measure.  This is the default measure for use with the
0661 /// XCone algorithm. It is identical to the conical geometric measure but with gamma = 1.0.
0662 ///------------------------------------------------------------------------
0663 class XConeMeasure : public ConicalGeometricMeasure {
0664 
0665 public:
0666    /// Constructor
0667    XConeMeasure(double jet_beta, double R)
0668    :   ConicalGeometricMeasure(jet_beta,
0669                                1.0, // beam_gamma, hard coded at gamma = 1.0 default
0670                                R    // Rcutoff scale
0671                                ) { }
0672 
0673    /// Description
0674    virtual std::string description() const;
0675    /// For copying purposes
0676    virtual XConeMeasure* create() const {return new XConeMeasure(*this);}
0677 
0678 };
0679 
0680 ///------------------------------------------------------------------------
0681 /// \class LightLikeAxis
0682 /// \brief Helper class to define light-like axes directions
0683 ///
0684 /// This is a helper class for the minimization routines.
0685 /// It creates a convenient way of defining axes in order to better facilitate calculations.
0686 ///------------------------------------------------------------------------
0687 class LightLikeAxis {
0688 
0689 public:
0690    /// Bare constructor
0691    LightLikeAxis() : _rap(0.0), _phi(0.0), _weight(0.0), _mom(0.0) {}
0692    /// Constructor
0693    LightLikeAxis(double my_rap, double my_phi, double my_weight, double my_mom) :
0694    _rap(my_rap), _phi(my_phi), _weight(my_weight), _mom(my_mom) {}
0695    
0696    /// Rapidity
0697    double rap() const {return _rap;}
0698    /// Azimuth
0699    double phi() const {return _phi;}
0700    /// weight factor
0701    double weight() const {return _weight;}
0702    /// pt momentum
0703    double mom() const {return _mom;}
0704    
0705    /// set rapidity
0706    void set_rap(double my_set_rap) {_rap = my_set_rap;}
0707    /// set azimuth
0708    void set_phi(double my_set_phi) {_phi = my_set_phi;}
0709    /// set weight factor
0710    void set_weight(double my_set_weight) {_weight = my_set_weight;}
0711    /// set pt momentum
0712    void set_mom(double my_set_mom) {_mom = my_set_mom;}
0713    /// set all kinematics
0714    void reset(double my_rap, double my_phi, double my_weight, double my_mom) {_rap=my_rap; _phi=my_phi; _weight=my_weight; _mom=my_mom;}
0715 
0716    /// Return PseudoJet version
0717    fastjet::PseudoJet ConvertToPseudoJet();
0718    
0719    /// Squared distance to PseudoJet
0720    double DistanceSq(const fastjet::PseudoJet& input) const {
0721       return DistanceSq(input.rap(),input.phi());
0722    }
0723 
0724    /// Distance to PseudoJet
0725    double Distance(const fastjet::PseudoJet& input) const {
0726       return std::sqrt(DistanceSq(input));
0727    }
0728 
0729    /// Squared distance to Lightlikeaxis
0730    double DistanceSq(const LightLikeAxis& input) const {
0731       return DistanceSq(input.rap(),input.phi());
0732    }
0733 
0734    /// Distance to Lightlikeaxis
0735    double Distance(const LightLikeAxis& input) const {
0736       return std::sqrt(DistanceSq(input));
0737    }
0738 
0739 private:
0740    double _rap;    ///< rapidity
0741    double _phi;    ///< azimuth
0742    double _weight; ///< weight factor
0743    double _mom;    ///< pt momentum
0744    
0745    /// Internal squared distance calculation
0746    double DistanceSq(double rap2, double phi2) const {
0747       double rap1 = _rap;
0748       double phi1 = _phi;
0749       
0750       double distRap = rap1-rap2;
0751       double distPhi = std::fabs(phi1-phi2);
0752       if (distPhi > M_PI) {distPhi = 2.0*M_PI - distPhi;}
0753       return distRap*distRap + distPhi*distPhi;
0754    }
0755    
0756    /// Internal distance calculation
0757    double Distance(double rap2, double phi2) const {
0758       return std::sqrt(DistanceSq(rap2,phi2));
0759    }
0760       
0761 };
0762    
0763    
0764 ////------------------------------------------------------------------------
0765 ///// \class DeprecatedGeometricCutoffMeasure
0766 //// This class is the old, incorrectly coded geometric measure.
0767 //// It is kept in case anyone wants to check old code, but should not be used for production purposes.
0768 //class DeprecatedGeometricCutoffMeasure : public MeasureDefinition {
0769 //
0770 //public:
0771 //
0772 //   // Please, please don't use this.
0773 //   DeprecatedGeometricCutoffMeasure(double jet_beta, double Rcutoff)
0774 //   :   MeasureDefinition(),
0775 //      _jet_beta(jet_beta),
0776 //      _beam_beta(1.0), // This is hard coded, since alternative beta_beam values were never checked.
0777 //      _Rcutoff(Rcutoff),
0778 //      _RcutoffSq(sq(Rcutoff)) {
0779 //         setTauMode(UNNORMALIZED_EVENT_SHAPE);
0780 //         setAxisScaling(false);
0781 //         if (jet_beta != 2.0) {
0782 //         throw Error("Geometric minimization is currently only defined for beta = 2.0.");
0783 //      }
0784 //   }
0785 //
0786 //   virtual std::string description() const;
0787 //
0788 //   virtual DeprecatedGeometricCutoffMeasure* create() const {return new DeprecatedGeometricCutoffMeasure(*this);}
0789 //
0790 //   virtual double jet_distance_squared(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const {
0791 //      fastjet::PseudoJet lightAxis = lightFrom(axis);
0792 //      double pseudoRsquared = 2.0*dot_product(lightFrom(axis),particle)/(lightAxis.pt()*particle.pt());
0793 //      return pseudoRsquared;
0794 //   }
0795 //
0796 //   virtual double beam_distance_squared(const fastjet::PseudoJet&  /*particle*/) const {
0797 //      return _RcutoffSq;
0798 //   }
0799 //
0800 //   virtual double jet_numerator(const fastjet::PseudoJet& particle, const fastjet::PseudoJet& axis) const {
0801 //      fastjet::PseudoJet lightAxis = lightFrom(axis);
0802 //      double weight = (_beam_beta == 1.0) ? 1.0 : std::pow(lightAxis.pt(),_beam_beta - 1.0);
0803 //      return particle.pt() * weight * std::pow(jet_distance_squared(particle,axis),_jet_beta/2.0);
0804 //   }
0805 //
0806 //   virtual double beam_numerator(const fastjet::PseudoJet& particle) const {
0807 //      double weight = (_beam_beta == 1.0) ? 1.0 : std::pow(particle.pt()/particle.e(),_beam_beta - 1.0);
0808 //      return particle.pt() * weight * std::pow(_Rcutoff,_jet_beta);
0809 //   }
0810 //
0811 //   virtual double denominator(const fastjet::PseudoJet&  /*particle*/) const {
0812 //      return std::numeric_limits<double>::quiet_NaN();
0813 //   }
0814 //
0815 //   virtual std::vector<fastjet::PseudoJet> get_one_pass_axes(int n_jets,
0816 //                                                             const std::vector<fastjet::PseudoJet>& inputs,
0817 //                                                             const std::vector<fastjet::PseudoJet>& seedAxes,
0818 //                                                             int nAttempts,    // cap number of iterations
0819 //                                                             double accuracy   // cap distance of closest approach
0820 //                                                            ) const;
0821 //
0822 //protected:
0823 //   double _jet_beta;
0824 //   double _beam_beta;
0825 //   double _Rcutoff;
0826 //   double _RcutoffSq;
0827 //
0828 //};
0829 //
0830 //// ------------------------------------------------------------------------
0831 //// / \class DeprecatedGeometricMeasure
0832 //// Same as DeprecatedGeometricMeasureCutoffMeasure, but with Rcutoff taken to infinity.
0833 //// NOTE:  This class should not be used for production purposes.
0834 //class DeprecatedGeometricMeasure : public DeprecatedGeometricCutoffMeasure {
0835 //
0836 //public:
0837 //   DeprecatedGeometricMeasure(double beta)
0838 //   : DeprecatedGeometricCutoffMeasure(beta,std::numeric_limits<double>::max()) {
0839 //      _RcutoffSq = std::numeric_limits<double>::max();
0840 //      setTauMode(UNNORMALIZED_JET_SHAPE);
0841 //   }
0842 //
0843 //   virtual std::string description() const;
0844 //
0845 //   virtual DeprecatedGeometricMeasure* create() const {return new DeprecatedGeometricMeasure(*this);}
0846 //};
0847 
0848 
0849 } //namespace contrib
0850 
0851 FASTJET_END_NAMESPACE
0852 
0853 #endif  // __FASTJET_CONTRIB_MEASUREDEFINITION_HH__