CMS 3D CMS Logo

JetConstituentSelector.cc
Go to the documentation of this file.
1 /* \class PFJetSelector
2  *
3  * Selects jets with a configurable string-based cut,
4  * and also writes out the constituents of the jet
5  * into a separate collection.
6  *
7  * \author: Sal Rappoccio
8  *
9  *
10  * for more details about the cut syntax, see the documentation
11  * page below:
12  *
13  * https://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePhysicsCutParser
14  *
15  */
16 
30 
31 template <class T, typename C = std::vector<typename T::ConstituentTypeFwdPtr>>
33 public:
34  using JetsOutput = std::vector<T>;
36  using ValueType = typename C::value_type;
37 
39  : srcToken_{consumes<edm::View<T>>(params.getParameter<edm::InputTag>("src"))},
40  selector_{params.getParameter<std::string>("cut")} {
41  produces<JetsOutput>();
42  produces<ConstituentsOutput>("constituents");
43  }
44 
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
47  desc.add<edm::InputTag>("src")->setComment("InputTag used for retrieving jets in event.");
48  desc.add<std::string>("cut")->setComment(
49  "Cut used by which to select jets. For example:\n"
50  " \"pt > 100.0 && abs(rapidity()) < 2.4\".");
51 
52  // addDefault must be used here instead of add unless this function is specialized
53  // for different sets of template parameter types. Each specialization would need
54  // a different module label. Otherwise the generated cfi filenames will conflict
55  // for the different plugins.
56  descriptions.addDefault(desc);
57  }
58 
59  // Default initialization is for edm::FwdPtr. Specialization (below) is for edm::Ptr.
61  return typename ConstituentsOutput::value_type(dau, dau);
62  }
63 
64  void produce(edm::Event& iEvent, edm::EventSetup const& iSetup) override {
65  auto jets = std::make_unique<JetsOutput>();
66  auto candsOut = std::make_unique<ConstituentsOutput>();
67 
69  iEvent.getByToken(srcToken_, h_jets);
70 
71  // Now set the Ptrs with the orphan handles.
72  for (auto const& jet : *h_jets) {
73  // Check the selection
74  if (selector_(jet)) {
75  // Add the jets that pass to the output collection
76  jets->push_back(jet);
77 
78  for (unsigned int ida{}; ida < jet.numberOfDaughters(); ++ida) {
79  candsOut->emplace_back(initptr(jet.daughterPtr(ida)));
80  }
81  }
82  }
83 
84  iEvent.put(std::move(jets));
85  iEvent.put(std::move(candsOut), "constituents");
86  }
87 
88 private:
91 };
92 
93 template <>
96  edm::Ptr<reco::Candidate> const& dau) const {
98  return retval;
99 }
100 
101 template <>
104  edm::Ptr<reco::Candidate> const& dau) const {
106  return retval;
107 }
108 
121 
ConfigurationDescriptions.h
CaloJet.h
JetConstituentSelector::srcToken_
const edm::EDGetTokenT< edm::View< T > > srcToken_
Definition: JetConstituentSelector.cc:89
StringCutObjectSelector.h
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::EDGetTokenT
Definition: EDGetToken.h:33
PFJet.h
PackedGenParticle.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
JetConstituentSelector::ValueType
typename C::value_type ValueType
Definition: JetConstituentSelector.cc:36
EDProducer.h
Jet.h
JetConstituentSelector::JetsOutput
std::vector< T > JetsOutput
Definition: JetConstituentSelector.cc:34
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
JetConstituentSelector::produce
void produce(edm::Event &iEvent, edm::EventSetup const &iSetup) override
Definition: JetConstituentSelector.cc:64
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
JetConstituentSelector
Definition: JetConstituentSelector.cc:32
JetConstituentSelector::ConstituentsOutput
C ConstituentsOutput
Definition: JetConstituentSelector.cc:35
JetConstituentSelector::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: JetConstituentSelector.cc:45
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
PackedCandidate.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
Jet.h
edm::Ptr< reco::Candidate >
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
gen::C
C
Definition: PomwigHadronizer.cc:78
JetConstituentSelector::JetConstituentSelector
JetConstituentSelector(edm::ParameterSet const &params)
Definition: JetConstituentSelector.cc:38
metsig::jet
Definition: SignAlgoResolutions.h:47
StringCutObjectSelector< T >
JetConstituentSelector::selector_
const StringCutObjectSelector< T > selector_
Definition: JetConstituentSelector.cc:90
GenJet.h
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::InputTag
Definition: InputTag.h:15
JetConstituentSelector::initptr
const ConstituentsOutput::value_type initptr(edm::Ptr< reco::Candidate > const &dau) const
Definition: JetConstituentSelector.cc:60