Fork me on GitHub

source: svn/trunk/external/fastjet/contribs/Nsubjettiness/Njettiness.hh@ 1378

Last change on this file since 1378 was 1368, checked in by Michele Selvaggi, 10 years ago

added nsubjettiness

File size: 7.9 KB
RevLine 
[1368]1// Nsubjettiness Package
2// Questions/Comments? jthaler@jthaler.net
3//
4// Copyright (c) 2011-14
5// Jesse Thaler, Ken Van Tilburg, Christopher K. Vermilion, and TJ Wilkason
6//
7//----------------------------------------------------------------------
8// This file is part of FastJet contrib.
9//
10// It is free software; you can redistribute it and/or modify it under
11// the terms of the GNU General Public License as published by the
12// Free Software Foundation; either version 2 of the License, or (at
13// your option) any later version.
14//
15// It is distributed in the hope that it will be useful, but WITHOUT
16// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18// License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this code. If not, see <http://www.gnu.org/licenses/>.
22//----------------------------------------------------------------------
23
24#ifndef __FASTJET_CONTRIB_NJETTINESS_HH__
25#define __FASTJET_CONTRIB_NJETTINESS_HH__
26
27#include "MeasureFunction.hh"
28#include "AxesFinder.hh"
29
30#include "fastjet/PseudoJet.hh"
31#include <cmath>
32#include <vector>
33#include <list>
34
35
36FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
37
38namespace contrib {
39
40///////
41//
42// Main Njettiness Class
43//
44///////
45
46//------------------------------------------------------------------------
47/// \class Njettiness
48// Njettiness uses AxesFinder and MeasureFunction together in order to find tau_N for the event. The user specifies
49// which AxesFinder and which MeasureFunction to use in the calculation, and then Njettiness returns tau_N for the event.
50// It also can return information about the axes and jets it used in the calculation, as well as information about
51// how the event was partitioned.
52class Njettiness {
53public:
54
55 // The various axes choices available to the user
56 enum AxesMode {
57 kt_axes, // exclusive kt axes
58 ca_axes, // exclusive ca axes
59 antikt_0p2_axes, // inclusive hardest axes with antikt-0.2
60 wta_kt_axes, // Winner Take All axes with kt
61 wta_ca_axes, // Winner Take All axes with CA
62 onepass_kt_axes, // one-pass minimization from kt starting point
63 onepass_ca_axes, // one-pass minimization from ca starting point
64 onepass_antikt_0p2_axes, // one-pass minimization from antikt-0.2 starting point
65 onepass_wta_kt_axes, //one-pass minimization of WTA axes with kt
66 onepass_wta_ca_axes, //one-pass minimization of WTA axes with ca
67 min_axes, // axes that minimize N-subjettiness (100 passes by default)
68 manual_axes, // set your own axes with setAxes()
69 onepass_manual_axes // one-pass minimization from manual starting point
70 // These options are commented out because they have not been fully tested
71 // wta2_kt_axes, // Winner Take All (alpha = 2) with kt
72 // wta2_ca_axes, // Winner Take All (alpha = 2) with CA
73 // onepass_wta2_kt_axes, //one-pass minimization of WTA (alpha = 2) axes with kt
74 // onepass_wta2_ca_axes, //one-pass minimization of WTA (alpha = 2) axes with ca
75 };
76
77 // The measures available to the user.
78 // "normalized_cutoff_measure" was the default in v1.0 of Nsubjettiness
79 // "unnormalized_measure" is now the recommended default usage
80 enum MeasureMode {
81 normalized_measure, //default normalized measure
82 unnormalized_measure, //default unnormalized measure
83 geometric_measure, //geometric measure
84 normalized_cutoff_measure, //default normalized measure with explicit Rcutoff
85 unnormalized_cutoff_measure, //default unnormalized measure with explicit Rcutoff
86 geometric_cutoff_measure //geometric measure with explicit Rcutoff
87 };
88
89private:
90 // The chosen axes/measure modes
91 AxesFinder* _axesFinder; // The chosen axes
92 MeasureFunction* _measureFunction; // The chosen measure
93
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; }
105
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;
115 }
116
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
123public:
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 }
144
145 // setAxes for Manual mode
146 void setAxes(std::vector<fastjet::PseudoJet> myAxes);
147
148 // Calculates and returns all TauComponents that user would want.
149 // 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);
151
152 // Calculates the value of N-subjettiness,
153 // but only returns the tau value from _current_tau_components
154 double getTau(unsigned n_jets, const std::vector<fastjet::PseudoJet> & inputJets) {
155 return getTauComponents(n_jets, inputJets).tau();
156 }
157
158 // returns enum information
159 MeasureMode currentMeasureMode() { return _current_measure_mode;}
160 AxesMode currentAxesMode() { return _current_axes_mode;}
161
162 // Return all relevant information about tau components
163 TauComponents currentTauComponents() {return _current_tau_components;}
164
165 // Return axes found by getTauComponents.
166 std::vector<fastjet::PseudoJet> currentAxes() { return _currentAxes;}
167 // Return seedAxes used if onepass minimization (otherwise, same as currentAxes)
168 std::vector<fastjet::PseudoJet> seedAxes() { return _seedAxes;}
169
170 // partition inputs by Voronoi (each vector stores indices corresponding to inputJets)
171 std::vector<std::list<int> > getPartition(const std::vector<fastjet::PseudoJet> & inputJets);
172
173 // partition inputs by Voronoi
174 std::vector<fastjet::PseudoJet> getJets(const std::vector<fastjet::PseudoJet> & inputJets);
175
176};
177
178} // namespace contrib
179
180FASTJET_END_NAMESPACE
181
182#endif // __FASTJET_CONTRIB_NJETTINESS_HH__
183
Note: See TracBrowser for help on using the repository browser.