Fork me on GitHub

Ignore:
Timestamp:
Sep 3, 2014, 3:18:54 PM (10 years ago)
Author:
Pavel Demin <demin@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
be2222c
Parents:
5b5a56b
Message:

upgrade FastJet to version 3.1.0-beta.1, upgrade Nsubjettiness to version 2.1.0, add SoftKiller version 1.0.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • external/fastjet/contribs/Nsubjettiness/Njettiness.hh

    r5b5a56b r35cdc46  
    55//  Jesse Thaler, Ken Van Tilburg, Christopher K. Vermilion, and TJ Wilkason
    66//
     7//  $Id: Njettiness.hh 670 2014-06-06 01:24:42Z jthaler $
    78//----------------------------------------------------------------------
    89// This file is part of FastJet contrib.
     
    2526#define __FASTJET_CONTRIB_NJETTINESS_HH__
    2627
     28
    2729#include "MeasureFunction.hh"
    2830#include "AxesFinder.hh"
     31#include "NjettinessDefinition.hh"
    2932
    3033#include "fastjet/PseudoJet.hh"
     34#include "fastjet/SharedPtr.hh"
     35#include <fastjet/LimitedWarning.hh>
     36
    3137#include <cmath>
    3238#include <vector>
    3339#include <list>
    3440
    35 
    3641FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
    3742
    3843namespace contrib {
    39 
     44   
    4045///////
    4146//
     
    5459   
    5560   // The various axes choices available to the user
     61   // It is recommended to use AxesDefinition instead of these.
    5662   enum AxesMode {
    5763      kt_axes,             // exclusive kt axes
     
    7884   // "normalized_cutoff_measure" was the default in v1.0 of Nsubjettiness
    7985   // "unnormalized_measure" is now the recommended default usage
     86   // But it is recommended to use MeasureDefinition instead of these.
    8087   enum MeasureMode {
    8188      normalized_measure,           //default normalized measure
     
    8794   };
    8895
    89 private:
    90    // The chosen axes/measure modes
    91    AxesFinder* _axesFinder;  // The chosen axes
    92    MeasureFunction* _measureFunction; // The chosen measure
     96   // Main constructor that uses AxesMode and MeasureDefinition to specify measure
     97   // Unlike Nsubjettiness or NjettinessPlugin, the value N is not chosen
     98   Njettiness(const AxesDefinition & axes_def, const MeasureDefinition & measure_def);
    9399
    94    // Enum information so functions can specify output based on specific options, primarily for setAxes
    95    AxesMode _current_axes_mode;
    96    MeasureMode _current_measure_mode;
    97    
    98    // Information about the current information
    99    TauComponents _current_tau_components; //automatically set to have components of 0; these values will be set by the getTau function call
    100    std::vector<fastjet::PseudoJet> _currentAxes;
    101    std::vector<fastjet::PseudoJet> _seedAxes; // axes used prior to minimization (if applicable)
    102    
    103    // Needed for compilation of non C++11 users
    104    bool isnan(double para) { return para != para; }
     100   // Intermediate constructor (needed to enable v1.0.3 backwards compatibility?)
     101   Njettiness(AxesMode axes_mode, const MeasureDefinition & measure_def);
    105102
    106    // Helpful function to check to make sure input has correct number of parameters
    107    bool correctParameterCount(int n, double para1, double para2, double para3, double para4){
    108       int numpara;
    109       if (!isnan(para1) && !isnan(para2) && !isnan(para3) && !isnan(para4)) numpara = 4;
    110       else if (!isnan(para1) && !isnan(para2) && !isnan(para3) && isnan(para4)) numpara = 3;
    111       else if (!isnan(para1) && !isnan(para2) && isnan(para3) && isnan(para4)) numpara = 2;
    112       else if (!isnan(para1) && isnan(para2) && isnan(para3) && isnan(para4)) numpara = 1;
    113       else numpara = 0;
    114       return n == numpara;
     103   // Alternative constructor which takes axes/measure information as enums with measure parameters
     104   // This version is not recommended
     105   Njettiness(AxesMode axes_mode,
     106              MeasureMode measure_mode,
     107              int num_para,
     108              double para1 = std::numeric_limits<double>::quiet_NaN(),
     109              double para2 = std::numeric_limits<double>::quiet_NaN(),
     110              double para3 = std::numeric_limits<double>::quiet_NaN())
     111   : _axes_def(createAxesDef(axes_mode)), _measure_def(createMeasureDef(measure_mode, num_para, para1, para2, para3)) {
     112      setMeasureFunctionAndAxesFinder();  // call helper function to do the hard work
    115113   }
    116114
    117    // Helper function to set onepass_axes depending on input measure_mode and startingFinder
    118    void setOnePassAxesFinder(MeasureMode measure_mode, AxesFinder* startingFinder, double para1, double Rcutoff);
    119  
    120    // created separate function to set MeasureFunction and AxesFinder in order to keep constructor cleaner.
    121    void setMeasureFunctionandAxesFinder(AxesMode axes_mode, MeasureMode measure_mode, double para1, double para2, double para3, double para4);
    122 
    123 public:
    124 
    125 
    126    // Main constructor which takes axes/measure information, and possible parameters.
    127    // Unlike Nsubjettiness or NjettinessPlugin, the value N is not chosen
    128    Njettiness(AxesMode axes_mode,
    129               MeasureMode measure_mode,
    130               double para1 = NAN,
    131               double para2 = NAN,
    132               double para3 = NAN,
    133               double para4 = NAN)
    134    : _current_axes_mode(axes_mode),
    135    _current_measure_mode(measure_mode) {
    136       setMeasureFunctionandAxesFinder(axes_mode, measure_mode, para1, para2, para3, para4);  // call helper function to do the hard work
    137    }
    138 
    139    ~Njettiness() {
    140       // clean house
    141       delete _measureFunction;
    142       delete _axesFinder;
    143    }
     115   // destructor
     116   ~Njettiness() {};
    144117   
    145118   // setAxes for Manual mode
    146    void setAxes(std::vector<fastjet::PseudoJet> myAxes);
     119   void setAxes(const std::vector<fastjet::PseudoJet> & myAxes);
    147120   
    148121   // Calculates and returns all TauComponents that user would want.
    149122   // This information is stored in _current_tau_components for later access as well.
    150    TauComponents getTauComponents(unsigned n_jets, const std::vector<fastjet::PseudoJet> & inputJets);
     123   TauComponents getTauComponents(unsigned n_jets, const std::vector<fastjet::PseudoJet> & inputJets) const;
    151124
    152125   // Calculates the value of N-subjettiness,
    153126   // but only returns the tau value from _current_tau_components
    154    double getTau(unsigned n_jets, const std::vector<fastjet::PseudoJet> & inputJets) {
     127   double getTau(unsigned n_jets, const std::vector<fastjet::PseudoJet> & inputJets) const {
    155128      return getTauComponents(n_jets, inputJets).tau();
    156129   }
    157    
    158    // returns enum information
    159    MeasureMode currentMeasureMode() { return _current_measure_mode;}
    160    AxesMode currentAxesMode() { return _current_axes_mode;}
    161130
    162131   // Return all relevant information about tau components
    163    TauComponents currentTauComponents() {return _current_tau_components;}
    164    
     132   TauComponents currentTauComponents() const {return _current_tau_components;}
    165133   // Return axes found by getTauComponents.
    166    std::vector<fastjet::PseudoJet> currentAxes() { return _currentAxes;}
     134   std::vector<fastjet::PseudoJet> currentAxes() const { return _currentAxes;}
    167135   // Return seedAxes used if onepass minimization (otherwise, same as currentAxes)
    168    std::vector<fastjet::PseudoJet> seedAxes() { return _seedAxes;}
     136   std::vector<fastjet::PseudoJet> seedAxes() const { return _seedAxes;}
     137   // Return jet partition found by getTauComponents.
     138   std::vector<fastjet::PseudoJet> currentJets() const {return _currentJets;}
     139   // Return beam partition found by getTauComponents.
     140   fastjet::PseudoJet currentBeam() const {return _currentBeam;}
    169141   
    170142   // partition inputs by Voronoi (each vector stores indices corresponding to inputJets)
    171    std::vector<std::list<int> > getPartition(const std::vector<fastjet::PseudoJet> & inputJets);
     143   std::vector<std::list<int> > getPartitionList(const std::vector<fastjet::PseudoJet> & inputJets) const;
    172144
    173    // partition inputs by Voronoi
    174    std::vector<fastjet::PseudoJet> getJets(const std::vector<fastjet::PseudoJet> & inputJets);
     145private:
     146   
     147   // Information about Axes and Measures to be Used
     148   // Implemented as SharedPtrs to avoid memory management headaches
     149   SharedPtr<const AxesDefinition> _axes_def;
     150   SharedPtr<const MeasureDefinition> _measure_def;
     151   
     152   // The chosen axes/measure mode workers
     153   // Implemented as SharedPtrs to avoid memory management headaches
     154   // TODO: make into a SharedPtr<const AxesFinder>?
     155   SharedPtr<MeasureFunction> _measureFunction;  // The chosen measure
     156   SharedPtr<AxesFinder> _startingAxesFinder;    // The initial axes finder
     157   SharedPtr<AxesFinder> _finishingAxesFinder;   // A possible minimization step
     158   
     159   // Information about the current information
     160   // Defined as mutables, so user should be aware that these change when getTau is called.
     161   mutable TauComponents _current_tau_components; //automatically set to have components of 0; these values will be set by the getTau function call
     162   mutable std::vector<fastjet::PseudoJet> _currentAxes; //axes found after minimization
     163   mutable std::vector<fastjet::PseudoJet> _seedAxes; // axes used prior to minimization (if applicable)
     164   mutable std::vector<fastjet::PseudoJet> _currentJets; //partitioning information
     165   mutable fastjet::PseudoJet _currentBeam; //return beam, if requested
     166   
     167   // created separate function to set MeasureFunction and AxesFinder in order to keep constructor cleaner.
     168   void setMeasureFunctionAndAxesFinder();
     169   
     170   // Convert old style enums into new style MeasureDefinition
     171   AxesDefinition* createAxesDef(AxesMode axes_mode) const;
     172   
     173   // Convert old style enums into new style MeasureDefinition
     174   MeasureDefinition* createMeasureDef(MeasureMode measure_mode, int num_para, double para1, double para2, double para3) const;
    175175
    176176};
    177 
     177   
    178178} // namespace contrib
    179179
Note: See TracChangeset for help on using the changeset viewer.