Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:13:52

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: Njettiness.hh 822 2015-06-15 23:52:57Z 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_NJETTINESS_HH__
0026 #define __FASTJET_CONTRIB_NJETTINESS_HH__
0027 
0028 
0029 #include "MeasureDefinition.hh"
0030 #include "AxesDefinition.hh"
0031 #include "TauComponents.hh"
0032 
0033 #include "fastjet/PseudoJet.hh"
0034 #include "fastjet/SharedPtr.hh"
0035 #include <fastjet/LimitedWarning.hh>
0036 
0037 #include <cmath>
0038 #include <vector>
0039 #include <list>
0040 
0041 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
0042 
0043 namespace contrib {
0044 
0045 /** \mainpage Nsubjettiness Documentation
0046  *
0047  * These Doxygen pages provide automatically generated documentation for the
0048  * Nsubjettiness FastJet contrib.  This documentation is being slowly improved.
0049  *
0050  * \section core_classes Core Classes
0051  *
0052  * - Nsubjettiness:  Calculating N-subjettiness jet shapes
0053  * - NsubjettinessRatio:  Calculating N-subjettiness ratios
0054  * - XConePlugin:  Running the XCone jet algorithm
0055  * - NjettinessPlugin:  Running generic N-jettiness as a jet algorithm
0056  *
0057  * \subsection core_classes_helper Helper Classes for Core
0058  * - Njettiness:  Core code for all N-(sub)jettiness calculations
0059  * - NjettinessExtras:  Way to access additional N-jettiness information
0060  * - TauComponents:  Output format for all N-(sub)jettiness information
0061  * - TauPartition:  Access to N-(sub)jettiness partitioning information
0062  * - PseudoXConePlugin:  Testing code to compare to XConePlugin (doesn't use one-pass minimization)
0063  *
0064  * \section axes_classes Axes Definitions
0065  *
0066  * \subsection axes_classes_base Base Classes
0067  * - AxesDefinition:  Defines generic axes definition
0068  * - ExclusiveJetAxes:  Axes finder from exclusive jet algorithm
0069  * - ExclusiveCombinatorialJetAxes:  Axes finder from exclusive jet algorithm (with extra axes to test combinatoric options)
0070  * - HardestJetAxes:  Axes finder from inclusive jet algorithm
0071  *
0072  * \subsection axes_classes_derived Derived Classes
0073  *
0074  * \b OnePass means iterative improvement to a (local) N-(sub)jettiness minimum.
0075  *
0076  * \b MultiPass means using multiple random seed inputs
0077  *
0078  * \b Comb means checking N + Nextra choose N combinatorial options
0079  *
0080  * - KT_Axes / OnePass_KT_Axes:  Axes from exclusive kT
0081  * - CA_Axes / OnePass_CA_Axes:  Axes from exclusive Cambridge/Aachen
0082  * - AntiKT_Axes / OnePass_AntiKT_Axes:  Axes from inclusive anti-kT
0083  * - WTA_KT_Axes / OnePass_WTA_KT_Axes:  Axes from exclusive kT, using winner-take-all recombination
0084  * - WTA_CA_Axes / OnePass_WTA_CA_Axes:  Axes from exclusive CA, using winner-take-all recombination
0085  *
0086  * - GenET_GenKT_Axes / OnePass_GenET_GenKT_Axes / Comb_GenET_GenKT_Axes:  Axes from exclusive generalized kt, with generalized Et recombination
0087  * - WTA_GenKT_Axes / OnePass_WTA_GenKT_Axes / Comb_WTA_GenKT_Axes:  Axes from exclusive generalized kt, with winner-take-all recombination
0088  *
0089  * - Manual_Axes / OnePass_Manual_Axes / MultiPass_Manual_Axes:  Use manual axes
0090  * - MultiPass_Axes:  Multiple passes with random input seeds
0091  *
0092  * \subsection axes_classes_helper Helper Classes for Axes
0093  * - GeneralEtSchemeRecombiner:  Generalized Et-scheme recombiner
0094  * - WinnerTakeAllRecombiner:  Winner-take-all recombiner (similar functionality now in FastJet 3.1)
0095  * - JetDefinitionWrapper:  Wrapper for Jet Definitions to handle memory management
0096  *
0097  * \section measure_classes Measure Definitions
0098  *
0099  * \subsection measure_classes_bases Base Classes
0100  * - MeasureDefinition:  Defines generic measures
0101  * - DefaultMeasure:  Base class for the original N-subjettiness measures
0102  *
0103  * \subsection measure_classes_derived Derived Classes
0104  * - NormalizedMeasure / UnnormalizedMeasure / NormalizedCutoffMeasure / UnnormalizedCutoffMeasure : Variants on the default N-subjettiness measure.
0105  * - ConicalMeasure: Similar to default measure, but intended as N-jettiness event shape
0106  * - ConicalGeometricMeasure / XConeMeasure:  Measure used in XCone jet algorithm
0107  * - OriginalGeometricMeasure / ModifiedGeometricMeasure:  Dot product measures useful for theoretical calcualtions
0108  *
0109  * \subsection measure_classes_helper Helper Classes for Measures
0110  * - LightLikeAxis : Defines light-like axis
0111  */
0112 
0113 ///////
0114 //
0115 // Main Njettiness Class
0116 //
0117 ///////
0118 
0119 ///------------------------------------------------------------------------
0120 /// \class Njettiness
0121 /// \brief Core class for N-(sub)jettiness calculations
0122 ///
0123 /**
0124  * The N-jettiness event shape.
0125  *
0126  * This is the core class used to perform N-jettiness jet finding (via NjettinessPlugin or XConePluggin)
0127  * as well as find the N-subjettiness jet shape (via Nsubjettiness).
0128  *
0129  * In general, the user should never need to call this object.  In addition, its API should not be considered
0130  * fixed, since all code improvements effectively happen from reorganizing this class.
0131  *
0132  * Njettiness uses AxesDefinition and MeasureDefinition together in order to find tau_N for the event.
0133  * It also can return information about the axes and jets it used in the calculation, as well as
0134  * information about how the event was partitioned.
0135  */
0136 class Njettiness {
0137 public:
0138    
0139    /// Main constructor that uses AxesMode and MeasureDefinition to specify measure
0140    /// Unlike Nsubjettiness or NjettinessPlugin, the value N is not chosen
0141    Njettiness(const AxesDefinition & axes_def, const MeasureDefinition & measure_def);
0142 
0143    /// Destructor
0144    ~Njettiness() {};
0145    
0146    /// setAxes for Manual mode
0147    void setAxes(const std::vector<fastjet::PseudoJet> & myAxes);
0148    
0149    /// Calculates and returns all TauComponents that user would want.
0150    /// This information is stored in _current_tau_components for later access as well.
0151    TauComponents getTauComponents(unsigned n_jets, const std::vector<fastjet::PseudoJet> & inputJets) const;
0152 
0153    /// Calculates the value of N-subjettiness,
0154    /// but only returns the tau value from _current_tau_components
0155    double getTau(unsigned n_jets, const std::vector<fastjet::PseudoJet> & inputJets) const {
0156       return getTauComponents(n_jets, inputJets).tau();
0157    }
0158 
0159    /// Return all relevant information about tau components
0160    TauComponents currentTauComponents() const {return _current_tau_components;}
0161    /// Return axes found by getTauComponents.
0162    std::vector<fastjet::PseudoJet> currentAxes() const { return _currentAxes;}
0163    /// Return seedAxes used if onepass minimization (otherwise, same as currentAxes)
0164    std::vector<fastjet::PseudoJet> seedAxes() const { return _seedAxes;}
0165    /// Return jet partition found by getTauComponents.
0166    std::vector<fastjet::PseudoJet> currentJets() const {return _currentPartition.jets();}
0167    /// Return beam partition found by getTauComponents.
0168    fastjet::PseudoJet currentBeam() const {return _currentPartition.beam();}
0169    /// Return beam partition found by getTauComponents.
0170    TauPartition currentPartition() const {return _currentPartition;}
0171    
0172 
0173 private:
0174    
0175    /// AxesDefinition to use.  Implemented as SharedPtrs to avoid memory management headaches
0176    SharedPtr<const AxesDefinition> _axes_def;
0177    /// MeasureDefinition to use.  Implemented as SharedPtrs to avoid memory management headaches
0178    SharedPtr<const MeasureDefinition> _measure_def;
0179 
0180    
0181    // Information about the current information
0182    // Defined as mutables, so user should be aware that these change when getTau is called.
0183    // TODO:  These are not thread safe and should be fixed somehow
0184    mutable TauComponents _current_tau_components; //automatically set to have components of 0; these values will be set by the getTau function call
0185    mutable std::vector<fastjet::PseudoJet> _currentAxes; //axes found after minimization
0186    mutable std::vector<fastjet::PseudoJet> _seedAxes; // axes used prior to minimization (if applicable)
0187    mutable TauPartition _currentPartition; //partitioning information
0188 
0189    /// Warning if the user tries to use v1.0.3 measure style.
0190    static LimitedWarning _old_measure_warning;
0191    /// Warning if the user tries to use v1.0.3 axes style.
0192    static LimitedWarning _old_axes_warning;
0193 
0194    
0195 public:
0196    
0197    // These interfaces are included for backwards compability, and will be deprecated in a future release (scheduled for deletion in v3.0)
0198    
0199    /// \deprecated
0200    /// Deprecated enum to determine axes mode
0201    /// The various axes choices available to the user
0202    /// It is recommended to use AxesDefinition instead of these.
0203    enum AxesMode {
0204       kt_axes,             // exclusive kt axes
0205       ca_axes,             // exclusive ca axes
0206       antikt_0p2_axes,     // inclusive hardest axes with antikt-0.2
0207       wta_kt_axes,         // Winner Take All axes with kt
0208       wta_ca_axes,         // Winner Take All axes with CA
0209       onepass_kt_axes,     // one-pass minimization from kt starting point
0210       onepass_ca_axes,     // one-pass minimization from ca starting point
0211       onepass_antikt_0p2_axes,  // one-pass minimization from antikt-0.2 starting point
0212       onepass_wta_kt_axes, //one-pass minimization of WTA axes with kt
0213       onepass_wta_ca_axes, //one-pass minimization of WTA axes with ca
0214       min_axes,            // axes that minimize N-subjettiness (100 passes by default)
0215       manual_axes,         // set your own axes with setAxes()
0216       onepass_manual_axes  // one-pass minimization from manual starting point
0217    };
0218    
0219    /// \deprecated
0220    /// Deprecated enum to determine measure mode
0221    /// The measures available to the user.
0222    /// "normalized_cutoff_measure" was the default in v1.0 of Nsubjettiness
0223    /// "unnormalized_measure" is now the recommended default usage
0224    /// But it is recommended to use MeasureDefinition instead of these.
0225    enum MeasureMode {
0226       normalized_measure,           //default normalized measure
0227       unnormalized_measure,         //default unnormalized measure
0228       geometric_measure,            //geometric measure
0229       normalized_cutoff_measure,    //default normalized measure with explicit Rcutoff
0230       unnormalized_cutoff_measure,  //default unnormalized measure with explicit Rcutoff
0231       geometric_cutoff_measure      //geometric measure with explicit Rcutoff
0232    };
0233    
0234    /// \deprecated
0235    /// Intermediate constructor (needed to enable v1.0.3 backwards compatibility?)
0236    Njettiness(AxesMode axes_mode, const MeasureDefinition & measure_def);
0237    
0238    /// \deprecated
0239    /// Old-style constructor which takes axes/measure information as enums with measure parameters
0240    /// This version absolutely is not recommended
0241    Njettiness(AxesMode axes_mode,
0242               MeasureMode measure_mode,
0243               int num_para,
0244               double para1 = std::numeric_limits<double>::quiet_NaN(),
0245               double para2 = std::numeric_limits<double>::quiet_NaN(),
0246               double para3 = std::numeric_limits<double>::quiet_NaN())
0247    : _axes_def(createAxesDef(axes_mode)), _measure_def(createMeasureDef(measure_mode, num_para, para1, para2, para3)) {
0248    }
0249   
0250    /// \deprecated
0251    /// Convert old style enums into new style MeasureDefinition
0252    AxesDefinition* createAxesDef(AxesMode axes_mode) const;
0253    
0254    /// \deprecated
0255    /// Convert old style enums into new style MeasureDefinition
0256    MeasureDefinition* createMeasureDef(MeasureMode measure_mode, int num_para, double para1, double para2, double para3) const;
0257 
0258 };
0259    
0260 } // namespace contrib
0261 
0262 FASTJET_END_NAMESPACE
0263 
0264 #endif  // __FASTJET_CONTRIB_NJETTINESS_HH__
0265