Fork me on GitHub

source: git/external/fastjet/contribs/Nsubjettiness/NjettinessDefinition.hh@ 50d7259

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 50d7259 was 35cdc46, checked in by Pavel Demin <demin@…>, 10 years ago

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

  • Property mode set to 100644
File size: 21.5 KB
RevLine 
[35cdc46]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// $Id: NjettinessDefinition.hh 704 2014-07-07 14:30:43Z jthaler $
8//----------------------------------------------------------------------
9// This file is part of FastJet contrib.
10//
11// It is free software; you can redistribute it and/or modify it under
12// the terms of the GNU General Public License as published by the
13// Free Software Foundation; either version 2 of the License, or (at
14// your option) any later version.
15//
16// It is distributed in the hope that it will be useful, but WITHOUT
17// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19// License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this code. If not, see <http://www.gnu.org/licenses/>.
23//----------------------------------------------------------------------
24
25#ifndef __FASTJET_CONTRIB_NJETTINESS_DEFINITION_HH__
26#define __FASTJET_CONTRIB_NJETTINESS_DEFINITION_HH__
27
28
29#include "MeasureFunction.hh"
30#include "AxesFinder.hh"
31
32#include "fastjet/PseudoJet.hh"
33#include <fastjet/LimitedWarning.hh>
34
35#include <iomanip>
36#include <cmath>
37#include <vector>
38#include <list>
39
40FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
41
42namespace contrib {
43
44// Eventually this file might contains an NjettinessDefinition that combines an
45// AxesDefinition with a MeasureDefinition. It's not clear how useful that would be, though
46
47// The following Measures are available (and the relevant arguments):
48class NormalizedMeasure; // (beta,R0)
49class UnnormalizedMeasure; // (beta)
50class GeometricMeasure; // (beta)
51class NormalizedCutoffMeasure; // (beta,R0,Rcutoff)
52class UnnormalizedCutoffMeasure; // (beta,Rcutoff)
53class GeometricCutoffMeasure; // (beta,Rcutoff)
54
55// The following Axes are available (and the relevant arguments, if needed)
56class KT_Axes;
57class CA_Axes;
58class AntiKT_Axes; // (R0)
59class WTA_KT_Axes;
60class WTA_CA_Axes;
61class Manual_Axes;
62class OnePass_KT_Axes;
63class OnePass_CA_Axes;
64class OnePass_AntiKT_Axes; // (R0)
65class OnePass_WTA_KT_Axes;
66class OnePass_WTA_CA_Axes;
67class OnePass_Manual_Axes;
68class MultiPass_Axes;
69
70// Below are just technical implementations of the variable axes and measures.
71
72///////
73//
74// MeasureDefinition
75//
76///////
77
78//The MeasureDefinition is a way to set the MeasureMode and
79//parameters used by Njettiness, with errors in the number of parameters given at
80//compile time (instead of at run time). The MeasureDefintion knows which core objects
81//to call to make the measurement, as well as properties of the MeasureFunction
82class MeasureDefinition {
83
84public:
85
86 // Description of measure and parameters
87 virtual std::string description() const = 0;
88
89 // In derived classes, this should return a copy of the corresponding
90 // derived class
91 virtual MeasureDefinition* create() const = 0;
92
93 //Return the MeasureFunction corresponding to this definition
94 virtual MeasureFunction* createMeasureFunction() const = 0;
95
96 //Return the AxesFinder that should be used for one-pass minimization
97 virtual AxesFinder* createOnePassAxesFinder() const = 0;
98
99 //Specify whether multi-pass minimization makes sense, and if so, return the AxesFinder that should be used for multi-pass minimization
100 virtual bool supportsMultiPassMinimization() const = 0;
101 virtual AxesFinder* createMultiPassAxesFinder( unsigned int) const = 0;
102
103 virtual ~MeasureDefinition(){};
104};
105
106// The normalized measure, with two parameters: beta and R0
107class NormalizedMeasure : public MeasureDefinition {
108
109public:
110 NormalizedMeasure(double beta, double R0)
111 : _beta(beta), _R0(R0) {}
112
113 virtual std::string description() const;
114
115 virtual MeasureFunction* createMeasureFunction() const {
116 return (new DefaultNormalizedMeasureFunction(_beta,_R0,std::numeric_limits<double>::max()));
117 }
118
119 virtual NormalizedMeasure* create() const {return new NormalizedMeasure(*this);}
120
121 virtual AxesFinder* createOnePassAxesFinder() const {
122 return (new AxesFinderFromOnePassMinimization(_beta, std::numeric_limits<double>::max()));
123 }
124 virtual AxesFinder* createMultiPassAxesFinder( unsigned int Npass) const {
125 return (new AxesFinderFromKmeansMinimization(_beta, std::numeric_limits<double>::max(),Npass));
126 }
127
128 virtual bool supportsMultiPassMinimization() const { return true; }
129
130private:
131 double _beta;
132 double _R0;
133};
134
135// The unnormalized measure, with just one parameter: beta
136class UnnormalizedMeasure : public MeasureDefinition {
137
138public:
139 UnnormalizedMeasure(double beta)
140 : _beta(beta) {}
141
142 virtual UnnormalizedMeasure* create() const {return new UnnormalizedMeasure(*this);}
143
144 virtual std::string description() const;
145
146 virtual MeasureFunction* createMeasureFunction() const {
147 return (new DefaultUnnormalizedMeasureFunction(_beta,std::numeric_limits<double>::max()));
148 }
149
150
151 virtual AxesFinder* createOnePassAxesFinder() const {
152 return (new AxesFinderFromOnePassMinimization(_beta, std::numeric_limits<double>::max()));
153 }
154 virtual AxesFinder* createMultiPassAxesFinder( unsigned int Npass) const {
155 return (new AxesFinderFromKmeansMinimization(_beta, std::numeric_limits<double>::max(),Npass));
156 }
157
158 virtual bool supportsMultiPassMinimization() const { return true; }
159
160private:
161 double _beta;
162};
163
164
165// The geometric measure, with 1 parameter: beta
166// This measure is still evolving and shouldn't be used for any critial applications yet
167class GeometricMeasure : public MeasureDefinition {
168
169public:
170 GeometricMeasure(double beta)
171 : _beta(beta) {}
172
173 virtual GeometricMeasure* create() const {return new GeometricMeasure(*this);}
174
175 virtual std::string description() const;
176
177 virtual MeasureFunction* createMeasureFunction() const {
178 return (new GeometricMeasureFunction(_beta,std::numeric_limits<double>::max()));
179 }
180
181 virtual AxesFinder* createOnePassAxesFinder() const {
182 return (new AxesFinderFromGeometricMinimization(_beta, std::numeric_limits<double>::max()));
183 }
184 virtual AxesFinder* createMultiPassAxesFinder(unsigned int) const {
185 throw Error("GeometricMeasure does not support multi-pass minimization.");
186 return NULL;
187 }
188
189 virtual bool supportsMultiPassMinimization() const { return false; }
190
191private:
192 double _beta;
193
194};
195
196
197// The normalized cutoff measure, with 3 parameters: beta, R0, Rcutoff
198class NormalizedCutoffMeasure : public MeasureDefinition {
199
200public:
201 NormalizedCutoffMeasure(double beta, double R0, double Rcutoff)
202 : _beta(beta), _R0(R0), _Rcutoff(Rcutoff) {}
203
204 virtual std::string description() const;
205
206 virtual NormalizedCutoffMeasure* create() const {return new NormalizedCutoffMeasure(*this);}
207
208 virtual MeasureFunction* createMeasureFunction() const {
209 return (new DefaultNormalizedMeasureFunction(_beta,_R0,_Rcutoff));
210 }
211
212 virtual AxesFinder* createOnePassAxesFinder() const {
213 return (new AxesFinderFromOnePassMinimization(_beta, _Rcutoff));
214 }
215 virtual AxesFinder* createMultiPassAxesFinder( unsigned int Npass) const {
216 return (new AxesFinderFromKmeansMinimization(_beta, std::numeric_limits<double>::max(),Npass));
217 }
218
219 virtual bool supportsMultiPassMinimization() const { return true; }
220
221private:
222 double _beta;
223 double _R0;
224 double _Rcutoff;
225
226};
227
228// The unnormalized cutoff measure, with 2 parameters: beta, Rcutoff
229class UnnormalizedCutoffMeasure : public MeasureDefinition {
230
231public:
232 UnnormalizedCutoffMeasure(double beta, double Rcutoff)
233 : _beta(beta), _Rcutoff(Rcutoff) {}
234
235 virtual std::string description() const;
236
237 virtual UnnormalizedCutoffMeasure* create() const {return new UnnormalizedCutoffMeasure(*this);}
238
239 virtual MeasureFunction* createMeasureFunction() const {
240 return (new DefaultUnnormalizedMeasureFunction(_beta,_Rcutoff));
241 }
242
243 virtual AxesFinder* createOnePassAxesFinder() const {
244 return (new AxesFinderFromOnePassMinimization(_beta, _Rcutoff));
245 }
246 virtual AxesFinder* createMultiPassAxesFinder( unsigned int Npass) const {
247 return (new AxesFinderFromKmeansMinimization(_beta, std::numeric_limits<double>::max(),Npass));
248 }
249
250 virtual bool supportsMultiPassMinimization() const { return true; }
251
252private:
253 double _beta;
254 double _Rcutoff;
255
256};
257
258// The Geometric measure, with 2 parameters: beta, Rcutoff
259// This measure is still evolving and shouldn't be used for any critial applications yet
260class GeometricCutoffMeasure : public MeasureDefinition {
261
262public:
263 GeometricCutoffMeasure(double beta, double Rcutoff)
264 : _beta(beta), _Rcutoff(Rcutoff) {}
265
266 virtual GeometricCutoffMeasure* create() const {return new GeometricCutoffMeasure(*this);}
267
268 virtual std::string description() const;
269
270 virtual MeasureFunction* createMeasureFunction() const {
271 return (new GeometricMeasureFunction(_beta,_Rcutoff));
272 }
273
274 virtual AxesFinder* createOnePassAxesFinder() const {
275 return (new AxesFinderFromGeometricMinimization(_beta, _Rcutoff));
276 }
277 virtual AxesFinder* createMultiPassAxesFinder(unsigned int) const {
278 throw Error("GeometricCutoffMeasure does not support multi-pass minimization.");
279 return NULL;
280 }
281
282 virtual bool supportsMultiPassMinimization() const { return false; }
283
284private:
285 double _beta;
286 double _Rcutoff;
287
288};
289
290
291///////
292//
293// AxesDefinition
294//
295///////
296
297//Analogous to MeasureDefinition, AxesDefinition defines which AxesFinder to use
298//At the moment, most AxesDefinition do not have an arugment (except the Anti-KT ones)
299class AxesDefinition {
300
301public:
302 // description of axes (and any parameters)
303 virtual std::string short_description() const = 0;
304 virtual std::string description() const = 0;
305
306 // In derived classes, this should return a copy of the corresponding
307 // derived class
308 virtual AxesDefinition* create() const = 0;
309
310 // These describe how the axes finder works
311 virtual bool givesRandomizedResults() const = 0;
312 virtual bool supportsManualAxes() const = 0;
313
314 //for best testing
315 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition &) const = 0;
316 virtual AxesFinder* createFinishingAxesFinder(const MeasureDefinition &) const {
317 return NULL; //By default, nothing.
318 };
319
320 virtual ~AxesDefinition() {};
321};
322
323// kt axes
324class KT_Axes : public AxesDefinition {
325public:
326 KT_Axes() {}
327
328 virtual std::string short_description() const {
329 return "KT";
330 };
331
332 virtual std::string description() const {
333 std::stringstream stream;
334 stream << std::fixed << std::setprecision(2)
335 << "KT Axes";
336 return stream.str();
337 };
338
339 virtual KT_Axes* create() const {return new KT_Axes(*this);}
340
341 virtual bool givesRandomizedResults() const {return false;}
342 virtual bool supportsManualAxes() const {return false;}
343
344 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition &) const {
345 return (new AxesFinderFromKT());
346 }
347
348};
349
350// ca axes
351class CA_Axes : public AxesDefinition {
352public:
353 CA_Axes() {}
354
355 virtual std::string short_description() const {
356 return "CA";
357 };
358
359 virtual std::string description() const {
360 std::stringstream stream;
361 stream << std::fixed << std::setprecision(2)
362 << "CA Axes";
363 return stream.str();
364 };
365
366 virtual CA_Axes* create() const {return new CA_Axes(*this);}
367
368 virtual bool givesRandomizedResults() const {return false;}
369 virtual bool supportsManualAxes() const {return false;}
370
371 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition &) const {
372 return (new AxesFinderFromCA());
373 }
374
375};
376
377// anti-kt axes, one parameter R0 is subjet radius
378class AntiKT_Axes : public AxesDefinition {
379
380public:
381 AntiKT_Axes(double R0 = 0.2): _R0(R0) {}
382
383 virtual std::string short_description() const {
384 std::stringstream stream;
385 stream << std::fixed << std::setprecision(2)
386 << "AKT" << _R0;
387 return stream.str();
388 };
389
390 virtual std::string description() const {
391 std::stringstream stream;
392 stream << std::fixed << std::setprecision(2)
393 << "Anti-KT Axes (R0 = " << _R0 << ")";
394 return stream.str();
395 };
396
397 virtual AntiKT_Axes* create() const {return new AntiKT_Axes(*this);}
398
399 virtual bool givesRandomizedResults() const {return false;}
400 virtual bool supportsManualAxes() const {return false;}
401
402 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition &) const {
403 return (new AxesFinderFromAntiKT(_R0));
404 }
405
406
407private:
408 double _R0;
409
410};
411
412// winner-take-all recombination with kt axes
413class WTA_KT_Axes : public AxesDefinition {
414public:
415 WTA_KT_Axes() {}
416
417 virtual std::string short_description() const {
418 return "WTA KT";
419 };
420
421 virtual std::string description() const {
422 std::stringstream stream;
423 stream << std::fixed << std::setprecision(2)
424 << "Winner-Take-All KT Axes";
425 return stream.str();
426 };
427
428 virtual WTA_KT_Axes* create() const {return new WTA_KT_Axes(*this);}
429
430 virtual bool givesRandomizedResults() const {return false;}
431 virtual bool supportsManualAxes() const {return false;}
432
433 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition &) const {
434 return (new AxesFinderFromWTA_KT());
435 }
436
437
438};
439
440// winner-take-all recombination with CA axes
441class WTA_CA_Axes : public AxesDefinition {
442public:
443 WTA_CA_Axes() {}
444
445 virtual std::string short_description() const {
446 return "WTA CA";
447 };
448
449 virtual std::string description() const {
450 std::stringstream stream;
451 stream << std::fixed << std::setprecision(2)
452 << "Winner-Take-All CA Axes";
453 return stream.str();
454 };
455
456 virtual WTA_CA_Axes* create() const {return new WTA_CA_Axes(*this);}
457
458 virtual bool givesRandomizedResults() const {return false;}
459 virtual bool supportsManualAxes() const {return false;}
460
461 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition &) const {
462 return (new AxesFinderFromWTA_CA());
463 }
464
465};
466
467// Onepass minimization from kt axes
468class OnePass_KT_Axes : public AxesDefinition {
469public:
470 OnePass_KT_Axes() {}
471
472 virtual std::string short_description() const {
473 return "OnePass KT";
474 };
475
476 virtual std::string description() const {
477 std::stringstream stream;
478 stream << std::fixed << std::setprecision(2)
479 << "One-Pass Minimization from KT Axes";
480 return stream.str();
481 };
482
483 virtual OnePass_KT_Axes* create() const {return new OnePass_KT_Axes(*this);}
484
485 virtual bool givesRandomizedResults() const {return false;}
486 virtual bool supportsManualAxes() const {return false;}
487
488 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition & ) const {
489 return (new AxesFinderFromKT());
490 }
491 virtual AxesFinder* createFinishingAxesFinder(const MeasureDefinition & measure_def) const {
492 return measure_def.createOnePassAxesFinder();
493 }
494
495};
496
497// Onepass minimization from CA axes
498class OnePass_CA_Axes : public AxesDefinition {
499public:
500 OnePass_CA_Axes() {}
501
502 virtual std::string short_description() const {
503 return "OnePass CA";
504 };
505
506 virtual std::string description() const {
507 std::stringstream stream;
508 stream << std::fixed << std::setprecision(2)
509 << "One-Pass Minimization from CA Axes";
510 return stream.str();
511 };
512
513 virtual OnePass_CA_Axes* create() const {return new OnePass_CA_Axes(*this);}
514
515 virtual bool givesRandomizedResults() const {return false;}
516 virtual bool supportsManualAxes() const {return false;}
517
518 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition & ) const {
519 return (new AxesFinderFromCA());
520 }
521 virtual AxesFinder* createFinishingAxesFinder(const MeasureDefinition & measure_def) const {
522 return measure_def.createOnePassAxesFinder();
523 }
524};
525
526// Onepass minimization from AntiKT axes, one parameter R0
527class OnePass_AntiKT_Axes : public AxesDefinition {
528
529public:
530 OnePass_AntiKT_Axes(double R0): _R0(R0) {}
531
532 virtual std::string short_description() const {
533 std::stringstream stream;
534 stream << std::fixed << std::setprecision(2)
535 << "OnePassAKT" << _R0;
536 return stream.str();
537 };
538
539 virtual std::string description() const {
540 std::stringstream stream;
541 stream << std::fixed << std::setprecision(2)
542 << "One-Pass Minimization from Anti-KT Axes (R0 = " << _R0 << ")";
543 return stream.str();
544 };
545
546 virtual OnePass_AntiKT_Axes* create() const {return new OnePass_AntiKT_Axes(*this);}
547
548 virtual bool givesRandomizedResults() const {return false;}
549 virtual bool supportsManualAxes() const {return false;}
550
551 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition & ) const {
552 return (new AxesFinderFromAntiKT(_R0));
553 }
554 virtual AxesFinder* createFinishingAxesFinder(const MeasureDefinition & measure_def) const {
555 return measure_def.createOnePassAxesFinder();
556 }
557
558private:
559 double _R0;
560};
561
562// Onepass minimization from winner-take-all kt axes
563class OnePass_WTA_KT_Axes : public AxesDefinition {
564public:
565 OnePass_WTA_KT_Axes() {}
566
567 virtual std::string short_description() const {
568 return "OnePass WTA KT";
569 };
570
571 virtual std::string description() const {
572 std::stringstream stream;
573 stream << std::fixed << std::setprecision(2)
574 << "One-Pass Minimization from Winner-Take-All KT Axes";
575 return stream.str();
576 };
577
578 virtual OnePass_WTA_KT_Axes* create() const {return new OnePass_WTA_KT_Axes(*this);}
579
580 virtual bool givesRandomizedResults() const {return false;}
581 virtual bool supportsManualAxes() const {return false;}
582
583 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition & ) const {
584 return (new AxesFinderFromWTA_KT());
585 }
586 virtual AxesFinder* createFinishingAxesFinder(const MeasureDefinition & measure_def) const {
587 return measure_def.createOnePassAxesFinder();
588 }
589};
590
591
592// Onepass minimization from winner-take-all CA axes
593class OnePass_WTA_CA_Axes : public AxesDefinition {
594public:
595 OnePass_WTA_CA_Axes() {}
596
597 virtual std::string short_description() const {
598 return "OnePass WTA CA";
599 };
600
601 virtual std::string description() const {
602 std::stringstream stream;
603 stream << std::fixed << std::setprecision(2)
604 << "One-Pass Minimization from Winner-Take-All CA Axes";
605 return stream.str();
606 };
607
608 virtual OnePass_WTA_CA_Axes* create() const {return new OnePass_WTA_CA_Axes(*this);}
609
610
611 virtual bool givesRandomizedResults() const {return false;}
612 virtual bool supportsManualAxes() const {return false;}
613
614
615 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition & ) const {
616 return (new AxesFinderFromWTA_CA());
617 }
618 virtual AxesFinder* createFinishingAxesFinder(const MeasureDefinition & measure_def) const {
619 return measure_def.createOnePassAxesFinder();
620 }
621
622
623};
624
625// set axes manually
626class Manual_Axes : public AxesDefinition {
627public:
628 Manual_Axes() {}
629
630 virtual std::string short_description() const {
631 return "Manual";
632 };
633
634 virtual std::string description() const {
635 std::stringstream stream;
636 stream << std::fixed << std::setprecision(2)
637 << "Manual Axes";
638 return stream.str();
639 };
640
641 virtual Manual_Axes* create() const {return new Manual_Axes(*this);}
642
643 virtual bool givesRandomizedResults() const {return false;}
644 virtual bool supportsManualAxes() const {return true;}
645
646 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition &) const {
647 return (new AxesFinderFromUserInput());
648 }
649};
650
651// one pass minimization from manual starting point
652class OnePass_Manual_Axes : public AxesDefinition {
653public:
654 OnePass_Manual_Axes() {}
655
656 virtual std::string short_description() const {
657 return "OnePass Manual";
658 };
659
660 virtual std::string description() const {
661 std::stringstream stream;
662 stream << std::fixed << std::setprecision(2)
663 << "One-Pass Minimization from Manual Axes";
664 return stream.str();
665 };
666
667 virtual OnePass_Manual_Axes* create() const {return new OnePass_Manual_Axes(*this);}
668
669 virtual bool givesRandomizedResults() const {return false;}
670 virtual bool supportsManualAxes() const {return true;}
671
672 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition & ) const {
673 return (new AxesFinderFromUserInput());
674 }
675 virtual AxesFinder* createFinishingAxesFinder(const MeasureDefinition & measure_def) const {
676 return measure_def.createOnePassAxesFinder();
677 }
678
679
680};
681
682// multi-pass minimization from kT starting point
683class MultiPass_Axes : public AxesDefinition {
684
685public:
686 MultiPass_Axes(unsigned int Npass) : _Npass(Npass) {}
687
688 virtual std::string short_description() const {
689 return "MultiPass";
690 };
691
692 virtual std::string description() const {
693 std::stringstream stream;
694 stream << std::fixed << std::setprecision(2)
695 << "Multi-Pass Axes (Npass = " << _Npass << ")";
696 return stream.str();
697 };
698
699 virtual MultiPass_Axes* create() const {return new MultiPass_Axes(*this);}
700
701 virtual bool givesRandomizedResults() const {return true;}
702 virtual bool supportsManualAxes() const {return false;}
703
704 virtual AxesFinder* createStartingAxesFinder(const MeasureDefinition & ) const {
705 return (new AxesFinderFromKT());
706 }
707 virtual AxesFinder* createFnishingAxesFinder(const MeasureDefinition & measure_def) const {
708 return measure_def.createMultiPassAxesFinder(_Npass);
709 }
710
711private:
712 unsigned int _Npass;
713
714};
715
716} // namespace contrib
717
718FASTJET_END_NAMESPACE
719
720#endif // __FASTJET_CONTRIB_NJETTINESS_HH__
721
Note: See TracBrowser for help on using the repository browser.