go-hep.org/x/hep@v0.38.1/fastjet/definition.go (about)

     1  // Copyright ©2017 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package fastjet
     6  
     7  import (
     8  	"fmt"
     9  )
    10  
    11  // JetDefinition contains a full specification of how to carry out jet clustering.
    12  type JetDefinition struct {
    13  	alg        JetAlgorithm
    14  	r          float64
    15  	extra      float64
    16  	strategy   Strategy
    17  	recombiner Recombiner
    18  	plugin     Plugin
    19  }
    20  
    21  // NewJetDefinition returns a new JetDefinition with the provided configuration.
    22  func NewJetDefinition(alg JetAlgorithm, r float64, scheme RecombinationScheme, strategy Strategy) JetDefinition {
    23  	return JetDefinition{
    24  		alg:        alg,
    25  		r:          r,
    26  		recombiner: NewRecombiner(scheme),
    27  		strategy:   strategy,
    28  	}
    29  }
    30  
    31  // NewJetDefinitionExtra returns a new JetDefinition with an extra float64 parameter.
    32  func NewJetDefinitionExtra(alg JetAlgorithm, r float64, scheme RecombinationScheme, strategy Strategy, extra float64) JetDefinition {
    33  	return JetDefinition{
    34  		alg:        alg,
    35  		r:          r,
    36  		extra:      extra,
    37  		recombiner: NewRecombiner(scheme),
    38  		strategy:   strategy,
    39  	}
    40  }
    41  
    42  // Description returns a string description of the current JetDefinition
    43  // matching the one from C++ FastJet.
    44  func (def JetDefinition) Description() string {
    45  	switch def.alg {
    46  	case PluginAlgorithm:
    47  		return def.plugin.Description()
    48  
    49  	case KtAlgorithm:
    50  		return fmt.Sprintf("Longitudinally invariant kt algorithm with R = %v and %s",
    51  			def.R(), def.Recombiner().Description(),
    52  		)
    53  
    54  	case CambridgeAlgorithm:
    55  		return fmt.Sprintf("Longitudinally invariant Cambridge/Aachen algorithm with R = %v and %s",
    56  			def.R(), def.Recombiner().Description(),
    57  		)
    58  
    59  	case AntiKtAlgorithm:
    60  		return fmt.Sprintf("Longitudinally invariant anti-kt algorithm with R = %v and %s",
    61  			def.R(), def.Recombiner().Description(),
    62  		)
    63  
    64  	case GenKtAlgorithm:
    65  		return fmt.Sprintf("Longitudinally invariant generalised kt algorithm with R = %v, p = %v and %s",
    66  			def.R(), def.ExtraParam(), def.Recombiner().Description(),
    67  		)
    68  
    69  	case CambridgeForPassiveAlgorithm:
    70  		return fmt.Sprintf("Longitudinally invariant Cambridge/Aache algorithm with R = %v, kt<%v as ghosts",
    71  			def.R(), def.ExtraParam(),
    72  		)
    73  
    74  	case EeKtAlgorithm:
    75  		return fmt.Sprintf("e+e- kt (Durham) algorithm with %s", def.Recombiner().Description())
    76  
    77  	case EeGenKtAlgorithm:
    78  		return fmt.Sprintf("e+e- generalised kt algorithm with R = %v, p = %v and %s",
    79  			def.R(), def.ExtraParam(), def.Recombiner().Description(),
    80  		)
    81  
    82  	case UndefinedJetAlgorithm:
    83  		return "uninitialised JetDefinition"
    84  
    85  	default:
    86  		panic(fmt.Errorf("fastjet.Description: invalid jet algorithm (%d)", int(def.alg)))
    87  	}
    88  }
    89  
    90  func (def JetDefinition) R() float64 {
    91  	return def.r
    92  }
    93  
    94  func (def JetDefinition) ExtraParam() float64 {
    95  	return def.extra
    96  }
    97  
    98  func (def JetDefinition) Strategy() Strategy {
    99  	return def.strategy
   100  }
   101  
   102  func (def JetDefinition) Recombiner() Recombiner {
   103  	return def.recombiner
   104  }
   105  
   106  func (def JetDefinition) RecombinationScheme() RecombinationScheme {
   107  	return def.recombiner.Scheme()
   108  }
   109  
   110  func (def JetDefinition) Algorithm() JetAlgorithm {
   111  	return def.alg
   112  }
   113  
   114  func (def JetDefinition) Plugin() Plugin {
   115  	return def.plugin
   116  }
   117  
   118  // to impl:
   119  //  - ClusterSequence
   120  //  - PseudoJet
   121  //  - Selector + JetMedianBkgEstimator (only if compute-rho)