CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
ECFAdder Class Reference

#include <ECFAdder.h>

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

Public Member Functions

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

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

double alpha_
 
double beta_
 
std::vector< std::string > cuts_
 
std::string ecftype_
 
edm::EDGetTokenT< edm::ValueMap< float > > input_weights_token_
 
std::vector< unsigned > Njets_
 
std::vector< std::shared_ptr< fastjet::FunctionOfPseudoJet< double > > > routine_
 
std::vector< StringCutObjectSelector< reco::Jet > > selectors_
 
edm::InputTag src_
 
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_
 
std::vector< std::string > variables_
 
edm::ValueMap< float > const * weightsHandle_
 

Additional Inherited Members

- 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
 

Detailed Description

Definition at line 15 of file ECFAdder.h.

Constructor & Destructor Documentation

◆ ECFAdder()

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

Definition at line 9 of file ECFAdder.cc.

10  : src_(iConfig.getParameter<edm::InputTag>("src")),
12  Njets_(iConfig.getParameter<std::vector<unsigned>>("Njets")),
13  cuts_(iConfig.getParameter<std::vector<std::string>>("cuts")),
14  ecftype_(iConfig.getParameter<std::string>("ecftype")),
15  alpha_(iConfig.getParameter<double>("alpha")),
16  beta_(iConfig.getParameter<double>("beta")) {
17  if (cuts_.size() != Njets_.size()) {
18  throw cms::Exception("ConfigurationError") << "cuts and Njets must be the same size in ECFAdder" << std::endl;
19  }
20 
21  edm::InputTag srcWeights = iConfig.getParameter<edm::InputTag>("srcWeights");
22  if (!srcWeights.label().empty())
24 
25  for (std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n) {
26  std::ostringstream ecfN_str;
27  std::shared_ptr<fastjet::FunctionOfPseudoJet<double>> pfunc;
28 
29  if (ecftype_ == "ECF" || ecftype_.empty()) {
30  ecfN_str << "ecf" << *n;
31  pfunc.reset(new fastjet::contrib::EnergyCorrelator(*n, beta_, fastjet::contrib::EnergyCorrelator::pt_R));
32  } else if (ecftype_ == "C") {
33  ecfN_str << "ecfC" << *n;
34  pfunc.reset(new fastjet::contrib::EnergyCorrelatorCseries(*n, beta_, fastjet::contrib::EnergyCorrelator::pt_R));
35  } else if (ecftype_ == "D") {
36  ecfN_str << "ecfD" << *n;
37  pfunc.reset(
38  new fastjet::contrib::EnergyCorrelatorGeneralizedD2(alpha_, beta_, fastjet::contrib::EnergyCorrelator::pt_R));
39  } else if (ecftype_ == "N") {
40  ecfN_str << "ecfN" << *n;
41  pfunc.reset(new fastjet::contrib::EnergyCorrelatorNseries(*n, beta_, fastjet::contrib::EnergyCorrelator::pt_R));
42  } else if (ecftype_ == "M") {
43  ecfN_str << "ecfM" << *n;
44  pfunc.reset(new fastjet::contrib::EnergyCorrelatorMseries(*n, beta_, fastjet::contrib::EnergyCorrelator::pt_R));
45  } else if (ecftype_ == "U") {
46  ecfN_str << "ecfU" << *n;
47  pfunc.reset(new fastjet::contrib::EnergyCorrelatorUseries(*n, beta_, fastjet::contrib::EnergyCorrelator::pt_R));
48  }
49  variables_.push_back(ecfN_str.str());
50  produces<edm::ValueMap<float>>(ecfN_str.str());
51  routine_.push_back(pfunc);
52 
54  }
55 }

References alpha_, beta_, cuts_, ecftype_, Exception, edm::ParameterSet::getParameter(), input_weights_token_, dqmiodumpmetadata::n, Njets_, routine_, selectors_, HLT_FULL_cff::srcWeights, and variables_.

Member Function Documentation

◆ fillDescriptions()

void ECFAdder::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 137 of file ECFAdder.cc.

137  {
139  iDesc.setComment("Energy Correlation Functions adder");
140 
141  iDesc.add<edm::InputTag>("src", edm::InputTag("no default"))->setComment("input collection");
142  iDesc.add<std::vector<unsigned>>("Njets", {1, 2, 3})->setComment("Number of jets to emulate");
143  iDesc.add<std::vector<std::string>>("cuts", {"", "", ""})
144  ->setComment("Jet selections for each N value. Size must match Njets.");
145  iDesc.add<double>("alpha", 1.0)->setComment("alpha factor, only valid for N2");
146  iDesc.add<double>("beta", 1.0)->setComment("angularity factor");
147  iDesc.add<std::string>("ecftype", "")->setComment("ECF type: ECF or empty; C; D; N; M; U;");
148  iDesc.add<edm::InputTag>("srcWeights", edm::InputTag("puppi"));
149  descriptions.add("ECFAdder", iDesc);
150 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), HLT_FULL_cff::InputTag, edm::ParameterSetDescription::setComment(), edm::ParameterDescriptionNode::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ getECF()

float ECFAdder::getECF ( unsigned  index,
const edm::Ptr< reco::Jet > &  object 
) const

Definition at line 92 of file ECFAdder.cc.

92  {
93  std::vector<fastjet::PseudoJet> fjParticles;
94  for (unsigned k = 0; k < object->numberOfDaughters(); ++k) {
95  const reco::CandidatePtr& dp = object->daughterPtr(k);
96  if (dp.isNonnull() && dp.isAvailable()) {
97  // Here, the daughters are the "end" node, so this is a PFJet
98  if (dp->numberOfDaughters() == 0) {
99  if (object->isWeighted()) {
101  throw cms::Exception("MissingConstituentWeight")
102  << "ECFAdder: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl;
103  float w = (*weightsHandle_)[dp];
104  fjParticles.push_back(fastjet::PseudoJet(dp->px() * w, dp->py() * w, dp->pz() * w, dp->energy() * w));
105  } else
106  fjParticles.push_back(fastjet::PseudoJet(dp->px(), dp->py(), dp->pz(), dp->energy()));
107  } else { // Otherwise, this is a BasicJet, so you need to descend further.
108  auto subjet = dynamic_cast<reco::Jet const*>(dp.get());
109  for (unsigned l = 0; l < subjet->numberOfDaughters(); ++l) {
110  if (subjet != nullptr) {
111  const reco::CandidatePtr& ddp = subjet->daughterPtr(l);
112  if (subjet->isWeighted()) {
114  throw cms::Exception("MissingConstituentWeight")
115  << "ECFAdder: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl;
116  float w = (*weightsHandle_)[ddp];
117  fjParticles.push_back(fastjet::PseudoJet(ddp->px() * w, ddp->py() * w, ddp->pz() * w, ddp->energy() * w));
118  } else
119  fjParticles.push_back(fastjet::PseudoJet(ddp->px(), ddp->py(), ddp->pz(), ddp->energy()));
120  } else {
121  edm::LogWarning("MissingJetConstituent") << "BasicJet constituent required for ECF computation is missing!";
122  }
123  }
124  } // end if basic jet
125  } // end if daughter pointer is nonnull and available
126  else
127  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for ECF computation is missing!";
128  }
129  if (fjParticles.size() > Njets_[index]) {
130  return routine_[index]->result(join(fjParticles));
131  } else {
132  return -1.0;
133  }
134 }

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

Referenced by produce().

◆ produce()

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

Definition at line 57 of file ECFAdder.cc.

57  {
58  // read input collection
60  iEvent.getByToken(src_token_, jets);
61 
62  // Get Weights Collection
65 
66  unsigned i = 0;
67  for (std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n) {
68  // prepare room for output
69  std::vector<float> ecfN;
70  ecfN.reserve(jets->size());
71 
72  for (typename edm::View<reco::Jet>::const_iterator jetIt = jets->begin(); jetIt != jets->end(); ++jetIt) {
73  edm::Ptr<reco::Jet> jetPtr = jets->ptrAt(jetIt - jets->begin());
74 
75  float t = -1.0;
76  if (selectors_[n - Njets_.begin()](*jetIt))
77  t = getECF(i, jetPtr);
78 
79  ecfN.push_back(t);
80  }
81 
82  auto outT = std::make_unique<edm::ValueMap<float>>();
83  edm::ValueMap<float>::Filler fillerT(*outT);
84  fillerT.insert(jets, ecfN.begin(), ecfN.end());
85  fillerT.fill();
86 
87  iEvent.put(std::move(outT), variables_[i]);
88  ++i;
89  }
90 }

References getECF(), mps_fire::i, iEvent, input_weights_token_, edm::EDGetTokenT< T >::isUninitialized(), singleTopDQM_cfi::jets, eostools::move(), dqmiodumpmetadata::n, Njets_, selectors_, src_token_, submitPVValidationJobs::t, variables_, and weightsHandle_.

Member Data Documentation

◆ alpha_

double ECFAdder::alpha_
private

Definition at line 31 of file ECFAdder.h.

Referenced by ECFAdder().

◆ beta_

double ECFAdder::beta_
private

Definition at line 32 of file ECFAdder.h.

Referenced by ECFAdder().

◆ cuts_

std::vector<std::string> ECFAdder::cuts_
private

Definition at line 28 of file ECFAdder.h.

Referenced by ECFAdder().

◆ ecftype_

std::string ECFAdder::ecftype_
private

Definition at line 29 of file ECFAdder.h.

Referenced by ECFAdder().

◆ input_weights_token_

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

Definition at line 36 of file ECFAdder.h.

Referenced by ECFAdder(), getECF(), and produce().

◆ Njets_

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

Definition at line 27 of file ECFAdder.h.

Referenced by ECFAdder(), getECF(), and produce().

◆ routine_

std::vector<std::shared_ptr<fastjet::FunctionOfPseudoJet<double> > > ECFAdder::routine_
private

Definition at line 34 of file ECFAdder.h.

Referenced by ECFAdder(), and getECF().

◆ selectors_

std::vector<StringCutObjectSelector<reco::Jet> > ECFAdder::selectors_
private

Definition at line 35 of file ECFAdder.h.

Referenced by ECFAdder(), and produce().

◆ src_

edm::InputTag ECFAdder::src_
private

Definition at line 25 of file ECFAdder.h.

◆ src_token_

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

Definition at line 26 of file ECFAdder.h.

Referenced by produce().

◆ variables_

std::vector<std::string> ECFAdder::variables_
private

Definition at line 30 of file ECFAdder.h.

Referenced by ECFAdder(), and produce().

◆ weightsHandle_

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

Definition at line 37 of file ECFAdder.h.

Referenced by produce().

ECFAdder::beta_
double beta_
Definition: ECFAdder.h:32
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
mps_fire.i
i
Definition: mps_fire.py:428
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
ECFAdder::weightsHandle_
edm::ValueMap< float > const * weightsHandle_
Definition: ECFAdder.h:37
ECFAdder::variables_
std::vector< std::string > variables_
Definition: ECFAdder.h:30
ECFAdder::src_token_
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_
Definition: ECFAdder.h:26
ECFAdder::getECF
float getECF(unsigned index, const edm::Ptr< reco::Jet > &object) const
Definition: ECFAdder.cc:92
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
ECFAdder::cuts_
std::vector< std::string > cuts_
Definition: ECFAdder.h:28
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
Calorimetry_cff.dp
dp
Definition: Calorimetry_cff.py:157
w
const double w
Definition: UKUtility.cc:23
ECFAdder::routine_
std::vector< std::shared_ptr< fastjet::FunctionOfPseudoJet< double > > > routine_
Definition: ECFAdder.h:34
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View
Definition: CaloClusterFwd.h:14
ECFAdder::selectors_
std::vector< StringCutObjectSelector< reco::Jet > > selectors_
Definition: ECFAdder.h:35
edm::ParameterSetDescription::setComment
void setComment(std::string const &value)
Definition: ParameterSetDescription.cc:33
iEvent
int iEvent
Definition: GenABIO.cc:224
ECFAdder::ecftype_
std::string ecftype_
Definition: ECFAdder.h:29
HLT_FULL_cff.srcWeights
srcWeights
Definition: HLT_FULL_cff.py:8647
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
edm::Ptr< Candidate >
ECFAdder::src_
edm::InputTag src_
Definition: ECFAdder.h:25
ECFAdder::input_weights_token_
edm::EDGetTokenT< edm::ValueMap< float > > input_weights_token_
Definition: ECFAdder.h:36
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ValueMap< float >
StringCutObjectSelector< reco::Jet >
ECFAdder::alpha_
double alpha_
Definition: ECFAdder.h:31
Exception
Definition: hltDiff.cc:246
ECFAdder::Njets_
std::vector< unsigned > Njets_
Definition: ECFAdder.h:27
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
cms::Exception
Definition: Exception.h:70
edm::helper::Filler
Definition: ValueMap.h:22
edm::ParameterDescriptionNode::setComment
void setComment(std::string const &value)
Definition: ParameterDescriptionNode.cc:106
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::InputTag
Definition: InputTag.h:15