CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
NjettinessAdder Class Reference

#include <NjettinessAdder.h>

Inheritance diagram for NjettinessAdder:
edm::stream::EDProducer<>

Public Types

enum  AxesDefinition_t {
  KT_Axes = 0, CA_Axes, AntiKT_Axes, WTA_KT_Axes,
  WTA_CA_Axes, Manual_Axes, OnePass_KT_Axes, OnePass_CA_Axes,
  OnePass_AntiKT_Axes, OnePass_WTA_KT_Axes, OnePass_WTA_CA_Axes, OnePass_Manual_Axes,
  MultiPass_Axes, N_AXES_DEFINITIONS
}
 
enum  MeasureDefinition_t {
  NormalizedMeasure = 0, UnnormalizedMeasure, OriginalGeometricMeasure, NormalizedCutoffMeasure,
  UnnormalizedCutoffMeasure, GeometricCutoffMeasure, N_MEASURE_DEFINITIONS
}
 
- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Public Member Functions

float getTau (unsigned num, const edm::Ptr< reco::Jet > &object) const
 
 NjettinessAdder (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~NjettinessAdder () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

double akAxesR0_
 
unsigned axesDefinition_
 
double beta_
 
edm::EDGetTokenT< edm::ValueMap< float > > input_weights_token_
 
unsigned measureDefinition_
 
std::vector< unsigned > Njets_
 
int nPass_
 
double R0_
 
double Rcutoff_
 
std::unique_ptr< fastjet::contrib::Njettiness > routine_
 
edm::InputTag src_
 
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_
 
edm::ValueMap< float > const * weightsHandle_
 

Detailed Description

Definition at line 14 of file NjettinessAdder.h.

Member Enumeration Documentation

◆ AxesDefinition_t

Enumerator
KT_Axes 
CA_Axes 
AntiKT_Axes 
WTA_KT_Axes 
WTA_CA_Axes 
Manual_Axes 
OnePass_KT_Axes 
OnePass_CA_Axes 
OnePass_AntiKT_Axes 
OnePass_WTA_KT_Axes 
OnePass_WTA_CA_Axes 
OnePass_Manual_Axes 
MultiPass_Axes 
N_AXES_DEFINITIONS 

Definition at line 25 of file NjettinessAdder.h.

◆ MeasureDefinition_t

Enumerator
NormalizedMeasure 
UnnormalizedMeasure 
OriginalGeometricMeasure 
NormalizedCutoffMeasure 
UnnormalizedCutoffMeasure 
GeometricCutoffMeasure 
N_MEASURE_DEFINITIONS 

Definition at line 16 of file NjettinessAdder.h.

Constructor & Destructor Documentation

◆ NjettinessAdder()

NjettinessAdder::NjettinessAdder ( const edm::ParameterSet iConfig)
explicit

Definition at line 7 of file NjettinessAdder.cc.

References akAxesR0_, AntiKT_Axes, axesDefinition_, beta_, CA_Axes, edm::ParameterSet::getParameter(), input_weights_token_, KT_Axes, measureDefinition_, MultiPass_Axes, dqmiodumpmetadata::n, Njets_, NormalizedCutoffMeasure, NormalizedMeasure, nPass_, OnePass_AntiKT_Axes, OnePass_CA_Axes, OnePass_KT_Axes, OnePass_WTA_CA_Axes, OnePass_WTA_KT_Axes, OriginalGeometricMeasure, R0_, Rcutoff_, routine_, HLT_2022v12_cff::srcWeights, UnnormalizedCutoffMeasure, UnnormalizedMeasure, WTA_CA_Axes, and WTA_KT_Axes.

8  : src_(iConfig.getParameter<edm::InputTag>("src")),
10  Njets_(iConfig.getParameter<std::vector<unsigned>>("Njets")),
11  measureDefinition_(iConfig.getParameter<unsigned>("measureDefinition")),
12  beta_(iConfig.getParameter<double>("beta")),
13  R0_(iConfig.getParameter<double>("R0")),
14  Rcutoff_(iConfig.getParameter<double>("Rcutoff")),
15  axesDefinition_(iConfig.getParameter<unsigned>("axesDefinition")),
16  nPass_(iConfig.getParameter<int>("nPass")),
17  akAxesR0_(iConfig.getParameter<double>("akAxesR0")) {
18  edm::InputTag srcWeights = iConfig.getParameter<edm::InputTag>("srcWeights");
19  if (!srcWeights.label().empty())
21 
22  for (std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n) {
23  std::ostringstream tauN_str;
24  tauN_str << "tau" << *n;
25 
26  produces<edm::ValueMap<float>>(tauN_str.str());
27  }
28 
29  // Get the measure definition
30  fastjet::contrib::NormalizedMeasure normalizedMeasure(beta_, R0_);
31  fastjet::contrib::UnnormalizedMeasure unnormalizedMeasure(beta_);
32  fastjet::contrib::OriginalGeometricMeasure geometricMeasure(beta_); // changed in 1.020
33  fastjet::contrib::NormalizedCutoffMeasure normalizedCutoffMeasure(beta_, R0_, Rcutoff_);
34  fastjet::contrib::UnnormalizedCutoffMeasure unnormalizedCutoffMeasure(beta_, Rcutoff_);
35  //fastjet::contrib::GeometricCutoffMeasure geometricCutoffMeasure (beta_,Rcutoff_); // removed in 1.020
36 
37  fastjet::contrib::MeasureDefinition const* measureDef = nullptr;
38  switch (measureDefinition_) {
40  measureDef = &unnormalizedMeasure;
41  break;
43  measureDef = &geometricMeasure;
44  break; // changed in 1.020
46  measureDef = &normalizedCutoffMeasure;
47  break;
49  measureDef = &unnormalizedCutoffMeasure;
50  break;
51  //case GeometricCutoffMeasure : measureDef = &geometricCutoffMeasure; break; // removed in 1.020
52  case NormalizedMeasure:
53  default:
54  measureDef = &normalizedMeasure;
55  break;
56  }
57 
58  // Get the axes definition
59  fastjet::contrib::KT_Axes kt_axes;
60  fastjet::contrib::CA_Axes ca_axes;
61  fastjet::contrib::AntiKT_Axes antikt_axes(akAxesR0_);
62  fastjet::contrib::WTA_KT_Axes wta_kt_axes;
63  fastjet::contrib::WTA_CA_Axes wta_ca_axes;
64  fastjet::contrib::OnePass_KT_Axes onepass_kt_axes;
65  fastjet::contrib::OnePass_CA_Axes onepass_ca_axes;
66  fastjet::contrib::OnePass_AntiKT_Axes onepass_antikt_axes(akAxesR0_);
67  fastjet::contrib::OnePass_WTA_KT_Axes onepass_wta_kt_axes;
68  fastjet::contrib::OnePass_WTA_CA_Axes onepass_wta_ca_axes;
69  fastjet::contrib::MultiPass_Axes multipass_axes(nPass_);
70 
71  fastjet::contrib::AxesDefinition const* axesDef = nullptr;
72  switch (axesDefinition_) {
73  case KT_Axes:
74  default:
75  axesDef = &kt_axes;
76  break;
77  case CA_Axes:
78  axesDef = &ca_axes;
79  break;
80  case AntiKT_Axes:
81  axesDef = &antikt_axes;
82  break;
83  case WTA_KT_Axes:
84  axesDef = &wta_kt_axes;
85  break;
86  case WTA_CA_Axes:
87  axesDef = &wta_ca_axes;
88  break;
89  case OnePass_KT_Axes:
90  axesDef = &onepass_kt_axes;
91  break;
92  case OnePass_CA_Axes:
93  axesDef = &onepass_ca_axes;
94  break;
96  axesDef = &onepass_antikt_axes;
97  break;
99  axesDef = &onepass_wta_kt_axes;
100  break;
101  case OnePass_WTA_CA_Axes:
102  axesDef = &onepass_wta_ca_axes;
103  break;
104  case MultiPass_Axes:
105  axesDef = &multipass_axes;
106  break;
107  };
108 
109  routine_ = std::make_unique<fastjet::contrib::Njettiness>(*axesDef, *measureDef);
110 }
unsigned measureDefinition_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
unsigned axesDefinition_
std::unique_ptr< fastjet::contrib::Njettiness > routine_
std::vector< unsigned > Njets_
edm::EDGetTokenT< edm::ValueMap< float > > input_weights_token_
edm::InputTag src_
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_

◆ ~NjettinessAdder()

NjettinessAdder::~NjettinessAdder ( )
inlineoverride

Definition at line 44 of file NjettinessAdder.h.

44 {}

Member Function Documentation

◆ getTau()

float NjettinessAdder::getTau ( unsigned  num,
const edm::Ptr< reco::Jet > &  object 
) const

Definition at line 146 of file NjettinessAdder.cc.

References runTheMatrix::const, Calorimetry_cff::dp, input_weights_token_, edm::EDGetTokenT< T >::isUninitialized(), dqmdumpme::k, cmsLHEtoEOSManager::l, EgammaValidation_cff::num, resolutioncreator_cfi::object, routine_, and w().

Referenced by produce().

146  {
147  std::vector<fastjet::PseudoJet> fjParticles;
148  for (unsigned k = 0; k < object->numberOfDaughters(); ++k) {
149  const reco::CandidatePtr& dp = object->daughterPtr(k);
150  if (dp.isNonnull() && dp.isAvailable()) {
151  // Here, the daughters are the "end" node, so this is a PFJet
152  if (dp->numberOfDaughters() == 0) {
153  if (object->isWeighted()) {
155  throw cms::Exception("MissingConstituentWeight")
156  << "ECFAdder: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl;
157  float w = (*weightsHandle_)[dp];
158  fjParticles.push_back(fastjet::PseudoJet(dp->px() * w, dp->py() * w, dp->pz() * w, dp->energy() * w));
159  } else
160  fjParticles.push_back(fastjet::PseudoJet(dp->px(), dp->py(), dp->pz(), dp->energy()));
161  } else { // Otherwise, this is a BasicJet, so you need to descend further.
162  auto subjet = dynamic_cast<reco::Jet const*>(dp.get());
163  for (unsigned l = 0; l < subjet->numberOfDaughters(); ++l) {
164  if (subjet != nullptr) {
165  const reco::CandidatePtr& ddp = subjet->daughterPtr(l);
166  if (subjet->isWeighted()) {
168  throw cms::Exception("MissingConstituentWeight")
169  << "ECFAdder: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl;
170  float w = (*weightsHandle_)[ddp];
171  fjParticles.push_back(fastjet::PseudoJet(ddp->px() * w, ddp->py() * w, ddp->pz() * w, ddp->energy() * w));
172  } else
173  fjParticles.push_back(fastjet::PseudoJet(ddp->px(), ddp->py(), ddp->pz(), ddp->energy()));
174  } else {
175  edm::LogWarning("MissingJetConstituent")
176  << "BasicJet constituent required for N-jettiness computation is missing!";
177  }
178  }
179  } // end if basic jet
180  } // end if daughter pointer is nonnull and available
181  else
182  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for N-jettiness computation is missing!";
183  }
184 
185  return routine_->getTau(num, fjParticles);
186 }
std::unique_ptr< fastjet::contrib::Njettiness > routine_
T w() const
Base class for all types of Jets.
Definition: Jet.h:20
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
edm::EDGetTokenT< edm::ValueMap< float > > input_weights_token_
Log< level::Warning, false > LogWarning

◆ produce()

void NjettinessAdder::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 112 of file NjettinessAdder.cc.

References getTau(), iEvent, input_weights_token_, edm::EDGetTokenT< T >::isUninitialized(), PDWG_EXODelayedJetMET_cff::jets, eostools::move(), dqmiodumpmetadata::n, Njets_, src_token_, submitPVValidationJobs::t, and weightsHandle_.

112  {
113  // read input collection
115  iEvent.getByToken(src_token_, jets);
116 
117  // Get Weights Collection
120 
121  for (std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n) {
122  std::ostringstream tauN_str;
123  tauN_str << "tau" << *n;
124 
125  // prepare room for output
126  std::vector<float> tauN;
127  tauN.reserve(jets->size());
128 
129  for (typename edm::View<reco::Jet>::const_iterator jetIt = jets->begin(); jetIt != jets->end(); ++jetIt) {
130  edm::Ptr<reco::Jet> jetPtr = jets->ptrAt(jetIt - jets->begin());
131 
132  float t = getTau(*n, jetPtr);
133 
134  tauN.push_back(t);
135  }
136 
137  auto outT = std::make_unique<edm::ValueMap<float>>();
138  edm::ValueMap<float>::Filler fillerT(*outT);
139  fillerT.insert(jets, tauN.begin(), tauN.end());
140  fillerT.fill();
141 
142  iEvent.put(std::move(outT), tauN_str.str());
143  }
144 }
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
edm::ValueMap< float > const * weightsHandle_
int iEvent
Definition: GenABIO.cc:224
std::vector< unsigned > Njets_
edm::EDGetTokenT< edm::ValueMap< float > > input_weights_token_
float getTau(unsigned num, const edm::Ptr< reco::Jet > &object) const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ akAxesR0_

double NjettinessAdder::akAxesR0_
private

Definition at line 63 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

◆ axesDefinition_

unsigned NjettinessAdder::axesDefinition_
private

Definition at line 61 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

◆ beta_

double NjettinessAdder::beta_
private

Definition at line 56 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

◆ input_weights_token_

edm::EDGetTokenT<edm::ValueMap<float> > NjettinessAdder::input_weights_token_
private

Definition at line 65 of file NjettinessAdder.h.

Referenced by getTau(), NjettinessAdder(), and produce().

◆ measureDefinition_

unsigned NjettinessAdder::measureDefinition_
private

Definition at line 55 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

◆ Njets_

std::vector<unsigned> NjettinessAdder::Njets_
private

Definition at line 52 of file NjettinessAdder.h.

Referenced by NjettinessAdder(), and produce().

◆ nPass_

int NjettinessAdder::nPass_
private

Definition at line 62 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

◆ R0_

double NjettinessAdder::R0_
private

Definition at line 57 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

◆ Rcutoff_

double NjettinessAdder::Rcutoff_
private

Definition at line 58 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

◆ routine_

std::unique_ptr<fastjet::contrib::Njettiness> NjettinessAdder::routine_
private

Definition at line 68 of file NjettinessAdder.h.

Referenced by getTau(), and NjettinessAdder().

◆ src_

edm::InputTag NjettinessAdder::src_
private

Definition at line 50 of file NjettinessAdder.h.

◆ src_token_

edm::EDGetTokenT<edm::View<reco::Jet> > NjettinessAdder::src_token_
private

Definition at line 51 of file NjettinessAdder.h.

Referenced by produce().

◆ weightsHandle_

edm::ValueMap<float> const* NjettinessAdder::weightsHandle_
private

Definition at line 66 of file NjettinessAdder.h.

Referenced by produce().