Changeset 35cdc46 in git for external/fastjet/contribs/Nsubjettiness/Njettiness.hh
- Timestamp:
- Sep 3, 2014, 3:18:54 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- be2222c
- Parents:
- 5b5a56b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
external/fastjet/contribs/Nsubjettiness/Njettiness.hh
r5b5a56b r35cdc46 5 5 // Jesse Thaler, Ken Van Tilburg, Christopher K. Vermilion, and TJ Wilkason 6 6 // 7 // $Id: Njettiness.hh 670 2014-06-06 01:24:42Z jthaler $ 7 8 //---------------------------------------------------------------------- 8 9 // This file is part of FastJet contrib. … … 25 26 #define __FASTJET_CONTRIB_NJETTINESS_HH__ 26 27 28 27 29 #include "MeasureFunction.hh" 28 30 #include "AxesFinder.hh" 31 #include "NjettinessDefinition.hh" 29 32 30 33 #include "fastjet/PseudoJet.hh" 34 #include "fastjet/SharedPtr.hh" 35 #include <fastjet/LimitedWarning.hh> 36 31 37 #include <cmath> 32 38 #include <vector> 33 39 #include <list> 34 40 35 36 41 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh 37 42 38 43 namespace contrib { 39 44 40 45 /////// 41 46 // … … 54 59 55 60 // The various axes choices available to the user 61 // It is recommended to use AxesDefinition instead of these. 56 62 enum AxesMode { 57 63 kt_axes, // exclusive kt axes … … 78 84 // "normalized_cutoff_measure" was the default in v1.0 of Nsubjettiness 79 85 // "unnormalized_measure" is now the recommended default usage 86 // But it is recommended to use MeasureDefinition instead of these. 80 87 enum MeasureMode { 81 88 normalized_measure, //default normalized measure … … 87 94 }; 88 95 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); 93 99 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); 105 102 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 115 113 } 116 114 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() {}; 144 117 145 118 // setAxes for Manual mode 146 void setAxes( std::vector<fastjet::PseudoJet>myAxes);119 void setAxes(const std::vector<fastjet::PseudoJet> & myAxes); 147 120 148 121 // Calculates and returns all TauComponents that user would want. 149 122 // 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; 151 124 152 125 // Calculates the value of N-subjettiness, 153 126 // 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 { 155 128 return getTauComponents(n_jets, inputJets).tau(); 156 129 } 157 158 // returns enum information159 MeasureMode currentMeasureMode() { return _current_measure_mode;}160 AxesMode currentAxesMode() { return _current_axes_mode;}161 130 162 131 // Return all relevant information about tau components 163 TauComponents currentTauComponents() {return _current_tau_components;} 164 132 TauComponents currentTauComponents() const {return _current_tau_components;} 165 133 // Return axes found by getTauComponents. 166 std::vector<fastjet::PseudoJet> currentAxes() { return _currentAxes;}134 std::vector<fastjet::PseudoJet> currentAxes() const { return _currentAxes;} 167 135 // 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;} 169 141 170 142 // 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; 172 144 173 // partition inputs by Voronoi 174 std::vector<fastjet::PseudoJet> getJets(const std::vector<fastjet::PseudoJet> & inputJets); 145 private: 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; 175 175 176 176 }; 177 177 178 178 } // namespace contrib 179 179
Note:
See TracChangeset
for help on using the changeset viewer.