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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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.

25  {
26  KT_Axes = 0,
27  CA_Axes,
28  AntiKT_Axes, // (axAxesR0)
34  OnePass_AntiKT_Axes, // (axAxesR0)
40  };

◆ MeasureDefinition_t

Enumerator
NormalizedMeasure 
UnnormalizedMeasure 
OriginalGeometricMeasure 
NormalizedCutoffMeasure 
UnnormalizedCutoffMeasure 
GeometricCutoffMeasure 
N_MEASURE_DEFINITIONS 

Definition at line 16 of file NjettinessAdder.h.

16  {
17  NormalizedMeasure = 0, // (beta,R0)
18  UnnormalizedMeasure, // (beta)
19  OriginalGeometricMeasure, // (beta)
20  NormalizedCutoffMeasure, // (beta,R0,Rcutoff)
21  UnnormalizedCutoffMeasure, // (beta,Rcutoff)
22  GeometricCutoffMeasure, // (beta,Rcutoff)
24  };

Constructor & Destructor Documentation

◆ NjettinessAdder()

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

Definition at line 5 of file NjettinessAdder.cc.

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

References akAxesR0_, AntiKT_Axes, axesDefinition_, beta_, CA_Axes, edm::ParameterSet::getParameter(), input_weights_token_, KT_Axes, measureDefinition_, MultiPass_Axes, dqmiodumpmetadata::n, Njets_, nJettinessAdder_cfi::Njettiness, 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_2018_cff::srcWeights, UnnormalizedCutoffMeasure, UnnormalizedMeasure, WTA_CA_Axes, and WTA_KT_Axes.

◆ ~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 144 of file NjettinessAdder.cc.

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

References 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().

◆ produce()

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

Definition at line 110 of file NjettinessAdder.cc.

110  {
111  // read input collection
113  iEvent.getByToken(src_token_, jets);
114 
115  // Get Weights Collection
118 
119  for (std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n) {
120  std::ostringstream tauN_str;
121  tauN_str << "tau" << *n;
122 
123  // prepare room for output
124  std::vector<float> tauN;
125  tauN.reserve(jets->size());
126 
127  for (typename edm::View<reco::Jet>::const_iterator jetIt = jets->begin(); jetIt != jets->end(); ++jetIt) {
128  edm::Ptr<reco::Jet> jetPtr = jets->ptrAt(jetIt - jets->begin());
129 
130  float t = getTau(*n, jetPtr);
131 
132  tauN.push_back(t);
133  }
134 
135  auto outT = std::make_unique<edm::ValueMap<float>>();
136  edm::ValueMap<float>::Filler fillerT(*outT);
137  fillerT.insert(jets, tauN.begin(), tauN.end());
138  fillerT.fill();
139 
140  iEvent.put(std::move(outT), tauN_str.str());
141  }
142 }

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

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().

NjettinessAdder::KT_Axes
Definition: NjettinessAdder.h:26
NjettinessAdder::N_MEASURE_DEFINITIONS
Definition: NjettinessAdder.h:23
NjettinessAdder::OnePass_WTA_KT_Axes
Definition: NjettinessAdder.h:35
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
NjettinessAdder::Manual_Axes
Definition: NjettinessAdder.h:31
NjettinessAdder::routine_
std::unique_ptr< fastjet::contrib::Njettiness > routine_
Definition: NjettinessAdder.h:68
NjettinessAdder::OnePass_WTA_CA_Axes
Definition: NjettinessAdder.h:36
NjettinessAdder::OriginalGeometricMeasure
Definition: NjettinessAdder.h:19
NjettinessAdder::CA_Axes
Definition: NjettinessAdder.h:27
NjettinessAdder::OnePass_CA_Axes
Definition: NjettinessAdder.h:33
NjettinessAdder::N_AXES_DEFINITIONS
Definition: NjettinessAdder.h:39
nJettinessAdder_cfi.Njettiness
Njettiness
Definition: nJettinessAdder_cfi.py:4
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
NjettinessAdder::nPass_
int nPass_
Definition: NjettinessAdder.h:62
NjettinessAdder::OnePass_AntiKT_Axes
Definition: NjettinessAdder.h:34
edm::Handle
Definition: AssociativeIterator.h:50
NjettinessAdder::NormalizedCutoffMeasure
Definition: NjettinessAdder.h:20
NjettinessAdder::AntiKT_Axes
Definition: NjettinessAdder.h:28
NjettinessAdder::NormalizedMeasure
Definition: NjettinessAdder.h:17
Calorimetry_cff.dp
dp
Definition: Calorimetry_cff.py:157
NjettinessAdder::measureDefinition_
unsigned measureDefinition_
Definition: NjettinessAdder.h:55
w
const double w
Definition: UKUtility.cc:23
edm::EDGetTokenT::isUninitialized
bool isUninitialized() const
Definition: EDGetToken.h:70
dqmdumpme.k
k
Definition: dqmdumpme.py:60
OrderedSet.t
t
Definition: OrderedSet.py:90
HLT_2018_cff.srcWeights
srcWeights
Definition: HLT_2018_cff.py:7335
edm::LogWarning
Definition: MessageLogger.h:141
edm::View
Definition: CaloClusterFwd.h:14
NjettinessAdder::Rcutoff_
double Rcutoff_
Definition: NjettinessAdder.h:58
NjettinessAdder::beta_
double beta_
Definition: NjettinessAdder.h:56
NjettinessAdder::src_
edm::InputTag src_
Definition: NjettinessAdder.h:50
iEvent
int iEvent
Definition: GenABIO.cc:224
NjettinessAdder::akAxesR0_
double akAxesR0_
Definition: NjettinessAdder.h:63
NjettinessAdder::Njets_
std::vector< unsigned > Njets_
Definition: NjettinessAdder.h:52
NjettinessAdder::UnnormalizedMeasure
Definition: NjettinessAdder.h:18
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
NjettinessAdder::weightsHandle_
edm::ValueMap< float > const * weightsHandle_
Definition: NjettinessAdder.h:66
NjettinessAdder::axesDefinition_
unsigned axesDefinition_
Definition: NjettinessAdder.h:61
edm::Ptr< Candidate >
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
NjettinessAdder::WTA_CA_Axes
Definition: NjettinessAdder.h:30
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ValueMap< float >
NjettinessAdder::input_weights_token_
edm::EDGetTokenT< edm::ValueMap< float > > input_weights_token_
Definition: NjettinessAdder.h:65
NjettinessAdder::UnnormalizedCutoffMeasure
Definition: NjettinessAdder.h:21
NjettinessAdder::R0_
double R0_
Definition: NjettinessAdder.h:57
NjettinessAdder::src_token_
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_
Definition: NjettinessAdder.h:51
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
NjettinessAdder::OnePass_Manual_Axes
Definition: NjettinessAdder.h:37
cms::Exception
Definition: Exception.h:70
edm::helper::Filler
Definition: ValueMap.h:22
NjettinessAdder::WTA_KT_Axes
Definition: NjettinessAdder.h:29
NjettinessAdder::MultiPass_Axes
Definition: NjettinessAdder.h:38
edm::InputTag
Definition: InputTag.h:15
NjettinessAdder::OnePass_KT_Axes
Definition: NjettinessAdder.h:32
NjettinessAdder::getTau
float getTau(unsigned num, const edm::Ptr< reco::Jet > &object) const
Definition: NjettinessAdder.cc:144
NjettinessAdder::GeometricCutoffMeasure
Definition: NjettinessAdder.h:22