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_
 
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_
 

Detailed Description

Definition at line 14 of file NjettinessAdder.h.

Member Enumeration Documentation

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.

Enumerator
NormalizedMeasure 
UnnormalizedMeasure 
OriginalGeometricMeasure 
NormalizedCutoffMeasure 
UnnormalizedCutoffMeasure 
GeometricCutoffMeasure 
N_MEASURE_DEFINITIONS 

Definition at line 16 of file NjettinessAdder.h.

Constructor & Destructor Documentation

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

Definition at line 5 of file NjettinessAdder.cc.

References akAxesR0_, AntiKT_Axes, axesDefinition_, beta_, CA_Axes, 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_, UnnormalizedCutoffMeasure, UnnormalizedMeasure, WTA_CA_Axes, and WTA_KT_Axes.

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  for (std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n) {
17  std::ostringstream tauN_str;
18  tauN_str << "tau" << *n;
19 
20  produces<edm::ValueMap<float>>(tauN_str.str());
21  }
22 
23  // Get the measure definition
24  fastjet::contrib::NormalizedMeasure normalizedMeasure(beta_, R0_);
25  fastjet::contrib::UnnormalizedMeasure unnormalizedMeasure(beta_);
26  fastjet::contrib::OriginalGeometricMeasure geometricMeasure(beta_); // changed in 1.020
27  fastjet::contrib::NormalizedCutoffMeasure normalizedCutoffMeasure(beta_, R0_, Rcutoff_);
28  fastjet::contrib::UnnormalizedCutoffMeasure unnormalizedCutoffMeasure(beta_, Rcutoff_);
29  //fastjet::contrib::GeometricCutoffMeasure geometricCutoffMeasure (beta_,Rcutoff_); // removed in 1.020
30 
31  fastjet::contrib::MeasureDefinition const* measureDef = nullptr;
32  switch (measureDefinition_) {
34  measureDef = &unnormalizedMeasure;
35  break;
37  measureDef = &geometricMeasure;
38  break; // changed in 1.020
40  measureDef = &normalizedCutoffMeasure;
41  break;
43  measureDef = &unnormalizedCutoffMeasure;
44  break;
45  //case GeometricCutoffMeasure : measureDef = &geometricCutoffMeasure; break; // removed in 1.020
46  case NormalizedMeasure:
47  default:
48  measureDef = &normalizedMeasure;
49  break;
50  }
51 
52  // Get the axes definition
53  fastjet::contrib::KT_Axes kt_axes;
54  fastjet::contrib::CA_Axes ca_axes;
55  fastjet::contrib::AntiKT_Axes antikt_axes(akAxesR0_);
56  fastjet::contrib::WTA_KT_Axes wta_kt_axes;
57  fastjet::contrib::WTA_CA_Axes wta_ca_axes;
58  fastjet::contrib::OnePass_KT_Axes onepass_kt_axes;
59  fastjet::contrib::OnePass_CA_Axes onepass_ca_axes;
60  fastjet::contrib::OnePass_AntiKT_Axes onepass_antikt_axes(akAxesR0_);
61  fastjet::contrib::OnePass_WTA_KT_Axes onepass_wta_kt_axes;
62  fastjet::contrib::OnePass_WTA_CA_Axes onepass_wta_ca_axes;
63  fastjet::contrib::MultiPass_Axes multipass_axes(nPass_);
64 
65  fastjet::contrib::AxesDefinition const* axesDef = nullptr;
66  switch (axesDefinition_) {
67  case KT_Axes:
68  default:
69  axesDef = &kt_axes;
70  break;
71  case CA_Axes:
72  axesDef = &ca_axes;
73  break;
74  case AntiKT_Axes:
75  axesDef = &antikt_axes;
76  break;
77  case WTA_KT_Axes:
78  axesDef = &wta_kt_axes;
79  break;
80  case WTA_CA_Axes:
81  axesDef = &wta_ca_axes;
82  break;
83  case OnePass_KT_Axes:
84  axesDef = &onepass_kt_axes;
85  break;
86  case OnePass_CA_Axes:
87  axesDef = &onepass_ca_axes;
88  break;
90  axesDef = &onepass_antikt_axes;
91  break;
93  axesDef = &onepass_wta_kt_axes;
94  break;
96  axesDef = &onepass_wta_ca_axes;
97  break;
98  case MultiPass_Axes:
99  axesDef = &multipass_axes;
100  break;
101  };
102 
103  routine_ = std::unique_ptr<fastjet::contrib::Njettiness>(new fastjet::contrib::Njettiness(*axesDef, *measureDef));
104 }
T getParameter(std::string const &) const
unsigned measureDefinition_
unsigned axesDefinition_
std::unique_ptr< fastjet::contrib::Njettiness > routine_
std::vector< unsigned > Njets_
edm::InputTag src_
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_
NjettinessAdder::~NjettinessAdder ( )
inlineoverride

Definition at line 44 of file NjettinessAdder.h.

References getTau(), iEvent, EgammaValidation_cff::num, and produce().

44 {}

Member Function Documentation

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

Definition at line 136 of file NjettinessAdder.cc.

References DEFINE_FWK_MODULE, Calorimetry_cff::dp, edm::Ptr< T >::isAvailable(), edm::Ptr< T >::isNonnull(), dqmdumpme::k, and routine_.

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

136  {
137  std::vector<fastjet::PseudoJet> FJparticles;
138  for (unsigned k = 0; k < object->numberOfDaughters(); ++k) {
139  const reco::CandidatePtr& dp = object->daughterPtr(k);
140  if (dp.isNonnull() && dp.isAvailable())
141  FJparticles.push_back(fastjet::PseudoJet(dp->px(), dp->py(), dp->pz(), dp->energy()));
142  else
143  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for N-subjettiness computation is missing!";
144  }
145 
146  return routine_->getTau(num, FJparticles);
147 }
std::unique_ptr< fastjet::contrib::Njettiness > routine_
bool isAvailable() const
Definition: Ptr.h:229
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
void NjettinessAdder::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 106 of file NjettinessAdder.cc.

References edm::Event::getByToken(), getTau(), singleTopDQM_cfi::jets, eostools::move(), dqmiodumpmetadata::n, Njets_, edm::Event::put(), src_token_, and OrderedSet::t.

Referenced by ~NjettinessAdder().

106  {
107  // read input collection
109  iEvent.getByToken(src_token_, jets);
110 
111  for (std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n) {
112  std::ostringstream tauN_str;
113  tauN_str << "tau" << *n;
114 
115  // prepare room for output
116  std::vector<float> tauN;
117  tauN.reserve(jets->size());
118 
119  for (typename edm::View<reco::Jet>::const_iterator jetIt = jets->begin(); jetIt != jets->end(); ++jetIt) {
120  edm::Ptr<reco::Jet> jetPtr = jets->ptrAt(jetIt - jets->begin());
121 
122  float t = getTau(*n, jetPtr);
123 
124  tauN.push_back(t);
125  }
126 
127  auto outT = std::make_unique<edm::ValueMap<float>>();
128  edm::ValueMap<float>::Filler fillerT(*outT);
129  fillerT.insert(jets, tauN.begin(), tauN.end());
130  fillerT.fill();
131 
132  iEvent.put(std::move(outT), tauN_str.str());
133  }
134 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< unsigned > Njets_
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

double NjettinessAdder::akAxesR0_
private

Definition at line 63 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

unsigned NjettinessAdder::axesDefinition_
private

Definition at line 61 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

double NjettinessAdder::beta_
private

Definition at line 56 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

unsigned NjettinessAdder::measureDefinition_
private

Definition at line 55 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

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

Definition at line 52 of file NjettinessAdder.h.

Referenced by NjettinessAdder(), and produce().

int NjettinessAdder::nPass_
private

Definition at line 62 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

double NjettinessAdder::R0_
private

Definition at line 57 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

double NjettinessAdder::Rcutoff_
private

Definition at line 58 of file NjettinessAdder.h.

Referenced by NjettinessAdder().

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

Definition at line 65 of file NjettinessAdder.h.

Referenced by getTau(), and NjettinessAdder().

edm::InputTag NjettinessAdder::src_
private

Definition at line 50 of file NjettinessAdder.h.

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

Definition at line 51 of file NjettinessAdder.h.

Referenced by produce().