CMS 3D CMS Logo

PATJetProducer.cc
Go to the documentation of this file.
1 
47 
48 #include <algorithm>
49 #include <memory>
50 #include <vector>
51 
52 class JetFlavourIdentifier;
53 
54 namespace pat {
55 
57  public:
58  explicit PATJetProducer(const edm::ParameterSet &iConfig);
59  ~PATJetProducer() override;
60 
61  void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override;
62 
63  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
64 
65  private:
66  // configurables
82  // edm::EDGetTokenT<edm::View<reco::SomePartonJetType> > partonJetToken_;
84  std::vector<edm::EDGetTokenT<edm::ValueMap<JetCorrFactors>>> jetCorrFactorsTokens_;
85 
88  std::vector<edm::InputTag> discriminatorTags_;
89  std::vector<edm::EDGetTokenT<reco::JetFloatAssociation::Container>> discriminatorTokens_;
90  std::vector<std::string> discriminatorLabels_;
92  std::vector<edm::InputTag> tagInfoTags_;
93  std::vector<edm::EDGetTokenT<edm::View<reco::BaseTagInfo>>> tagInfoTokens_;
94  std::vector<std::string> tagInfoLabels_;
99  bool addJetID_;
101  // tools
104 
107 
110 
113  //
114  bool printWarning_; // this is introduced to issue warnings only once per job
115  };
116 
117 } // namespace pat
118 
119 using namespace pat;
120 
122  : useUserData_(iConfig.exists("userData")), printWarning_(true) {
123  // initialize configurables
124  jetsToken_ = consumes<edm::View<reco::Jet>>(iConfig.getParameter<edm::InputTag>("jetSource"));
125  embedCaloTowers_ = false; // parameter is optional
126  if (iConfig.exists("embedCaloTowers")) {
127  embedCaloTowers_ = iConfig.getParameter<bool>("embedCaloTowers");
128  }
129  embedPFCandidates_ = iConfig.getParameter<bool>("embedPFCandidates");
130  getJetMCFlavour_ = iConfig.getParameter<bool>("getJetMCFlavour");
131  useLegacyJetMCFlavour_ = iConfig.getParameter<bool>("useLegacyJetMCFlavour");
132  addJetFlavourInfo_ = (useLegacyJetMCFlavour_ ? false : iConfig.getParameter<bool>("addJetFlavourInfo"));
135  consumes<reco::JetFlavourMatchingCollection>(iConfig.getParameter<edm::InputTag>("JetPartonMapSource"));
138  consumes<reco::JetFlavourInfoMatchingCollection>(iConfig.getParameter<edm::InputTag>("JetFlavourInfoSource"));
139  addGenPartonMatch_ = iConfig.getParameter<bool>("addGenPartonMatch");
140  embedGenPartonMatch_ = iConfig.getParameter<bool>("embedGenPartonMatch");
141  if (addGenPartonMatch_)
143  consumes<edm::Association<reco::GenParticleCollection>>(iConfig.getParameter<edm::InputTag>("genPartonMatch"));
144  addGenJetMatch_ = iConfig.getParameter<bool>("addGenJetMatch");
145  embedGenJetMatch_ = iConfig.getParameter<bool>("embedGenJetMatch");
146  if (addGenJetMatch_)
147  genJetToken_ =
148  consumes<edm::Association<reco::GenJetCollection>>(iConfig.getParameter<edm::InputTag>("genJetMatch"));
149  addPartonJetMatch_ = iConfig.getParameter<bool>("addPartonJetMatch");
150  // partonJetToken_ = mayConsume<reco::SomePartonJetType>(iConfig.getParameter<edm::InputTag>( "partonJetSource" ));
151  addJetCorrFactors_ = iConfig.getParameter<bool>("addJetCorrFactors");
152  if (addJetCorrFactors_) {
154  iConfig.getParameter<std::vector<edm::InputTag>>("jetCorrFactorsSource"),
155  [this](edm::InputTag const &tag) { return consumes<edm::ValueMap<JetCorrFactors>>(tag); });
156  }
157  addBTagInfo_ = iConfig.getParameter<bool>("addBTagInfo");
158  addDiscriminators_ = iConfig.getParameter<bool>("addDiscriminators");
159  discriminatorTags_ = iConfig.getParameter<std::vector<edm::InputTag>>("discriminatorSources");
161  return mayConsume<reco::JetFloatAssociation::Container>(tag);
162  });
163  addTagInfos_ = iConfig.getParameter<bool>("addTagInfos");
164  tagInfoTags_ = iConfig.getParameter<std::vector<edm::InputTag>>("tagInfoSources");
166  tagInfoTags_, [this](edm::InputTag const &tag) { return mayConsume<edm::View<reco::BaseTagInfo>>(tag); });
167  addAssociatedTracks_ = iConfig.getParameter<bool>("addAssociatedTracks");
170  consumes<reco::JetTracksAssociation::Container>(iConfig.getParameter<edm::InputTag>("trackAssociationSource"));
171  addJetCharge_ = iConfig.getParameter<bool>("addJetCharge");
172  if (addJetCharge_)
174  consumes<reco::JetFloatAssociation::Container>(iConfig.getParameter<edm::InputTag>("jetChargeSource"));
175  addJetID_ = iConfig.getParameter<bool>("addJetID");
176  if (addJetID_)
177  jetIDMapToken_ = consumes<reco::JetIDValueMap>(iConfig.getParameter<edm::InputTag>("jetIDMap"));
178  // Efficiency configurables
179  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
180  if (addEfficiencies_) {
182  pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
183  }
184  // Resolution configurables
185  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
186  if (addResolutions_) {
188  pat::helper::KinResolutionsLoader(iConfig.getParameter<edm::ParameterSet>("resolutions"), consumesCollector());
189  }
190  if (discriminatorTags_.empty()) {
191  addDiscriminators_ = false;
192  } else {
193  for (std::vector<edm::InputTag>::const_iterator it = discriminatorTags_.begin(), ed = discriminatorTags_.end();
194  it != ed;
195  ++it) {
196  std::string label = it->label();
197  std::string::size_type pos = label.find("JetTags");
198  if ((pos != std::string::npos) && (pos != label.length() - 7)) {
199  label.erase(pos + 7); // trim a tail after "JetTags"
200  }
201  if (!it->instance().empty()) {
202  label = (label + std::string(":") + it->instance());
203  }
204  discriminatorLabels_.push_back(label);
205  }
206  }
207  if (tagInfoTags_.empty()) {
208  addTagInfos_ = false;
209  } else {
210  for (std::vector<edm::InputTag>::const_iterator it = tagInfoTags_.begin(), ed = tagInfoTags_.end(); it != ed;
211  ++it) {
212  std::string label = it->label();
213  std::string::size_type pos = label.find("TagInfos");
214  if ((pos != std::string::npos) && (pos != label.length() - 8)) {
215  label.erase(pos + 8); // trim a tail after "TagInfos"
216  }
217  tagInfoLabels_.push_back(label);
218  }
219  }
220  if (!addBTagInfo_) {
221  addDiscriminators_ = false;
222  addTagInfos_ = false;
223  }
224  // Check to see if the user wants to add user data
225  if (useUserData_) {
226  userDataHelper_ = PATUserDataHelper<Jet>(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector());
227  }
228  // produces vector of jets
229  produces<std::vector<Jet>>();
230  produces<reco::GenJetCollection>("genJets");
231  produces<std::vector<CaloTower>>("caloTowers");
232  produces<reco::PFCandidateCollection>("pfCandidates");
233  produces<edm::OwnVector<reco::BaseTagInfo>>("tagInfos");
234 }
235 
237 
239  // check whether dealing with MC or real data
240  if (iEvent.isRealData()) {
241  getJetMCFlavour_ = false;
242  useLegacyJetMCFlavour_ = false;
243  addJetFlavourInfo_ = false;
244  addGenPartonMatch_ = false;
245  addGenJetMatch_ = false;
246  addPartonJetMatch_ = false;
247  }
248 
249  // Get the vector of jets
251  iEvent.getByToken(jetsToken_, jets);
252 
257 
258  // for jet flavour
262  iEvent.getByToken(jetPartonMapToken_, jetFlavMatch);
264  iEvent.getByToken(jetFlavourInfoToken_, jetFlavInfoMatch);
265 
266  // Get the vector of generated particles from the event if needed
268  if (addGenPartonMatch_)
269  iEvent.getByToken(genPartonToken_, partonMatch);
270  // Get the vector of GenJets from the event if needed
272  if (addGenJetMatch_)
273  iEvent.getByToken(genJetToken_, genJetMatch);
274  /* TO BE IMPLEMENTED FOR >= 1_5_X
275  // Get the vector of PartonJets from the event if needed
276  edm::Handle<edm::View<reco::SomePartonJetType> > partonJets;
277  if (addPartonJetMatch_) iEvent.getByToken(partonJetToken_, partonJets);
278 */
279 
280  // read in the jet correction factors ValueMap
281  std::vector<edm::ValueMap<JetCorrFactors>> jetCorrs;
282  if (addJetCorrFactors_) {
283  for (size_t i = 0; i < jetCorrFactorsTokens_.size(); ++i) {
285  iEvent.getByToken(jetCorrFactorsTokens_[i], jetCorr);
286  jetCorrs.push_back(*jetCorr);
287  }
288  }
289 
290  // Get the vector of jet tags with b-tagging info
291  std::vector<edm::Handle<reco::JetFloatAssociation::Container>> jetDiscriminators;
293  jetDiscriminators.resize(discriminatorTokens_.size());
294  for (size_t i = 0; i < discriminatorTokens_.size(); ++i) {
295  iEvent.getByToken(discriminatorTokens_[i], jetDiscriminators[i]);
296  }
297  }
298  std::vector<edm::Handle<edm::View<reco::BaseTagInfo>>> jetTagInfos;
299  if (addBTagInfo_ && addTagInfos_) {
300  jetTagInfos.resize(tagInfoTokens_.size());
301  for (size_t i = 0; i < tagInfoTokens_.size(); ++i) {
302  iEvent.getByToken(tagInfoTokens_[i], jetTagInfos[i]);
303  }
304  }
305 
306  // tracks Jet Track Association
309  iEvent.getByToken(trackAssociationToken_, hTrackAss);
311  if (addJetCharge_)
312  iEvent.getByToken(jetChargeToken_, hJetChargeAss);
313 
314  // jet ID handle
316  if (addJetID_)
317  iEvent.getByToken(jetIDMapToken_, hJetIDMap);
318 
319  // loop over jets
320  auto patJets = std::make_unique<std::vector<Jet>>();
321 
322  auto genJetsOut = std::make_unique<reco::GenJetCollection>();
323  auto caloTowersOut = std::make_unique<std::vector<CaloTower>>();
324  auto pfCandidatesOut = std::make_unique<reco::PFCandidateCollection>();
325  auto tagInfosOut = std::make_unique<edm::OwnVector<reco::BaseTagInfo>>();
326 
327  edm::RefProd<reco::GenJetCollection> h_genJetsOut = iEvent.getRefBeforePut<reco::GenJetCollection>("genJets");
328  edm::RefProd<std::vector<CaloTower>> h_caloTowersOut = iEvent.getRefBeforePut<std::vector<CaloTower>>("caloTowers");
330  iEvent.getRefBeforePut<reco::PFCandidateCollection>("pfCandidates");
332  iEvent.getRefBeforePut<edm::OwnVector<reco::BaseTagInfo>>("tagInfos");
333 
334  for (edm::View<reco::Jet>::const_iterator itJet = jets->begin(); itJet != jets->end(); itJet++) {
335  // construct the Jet from the ref -> save ref to original object
336  unsigned int idx = itJet - jets->begin();
337  edm::RefToBase<reco::Jet> jetRef = jets->refAt(idx);
338  edm::Ptr<reco::Jet> jetPtr = jets->ptrAt(idx);
339  Jet ajet(jetRef);
340 
341  // add the FwdPtrs to the CaloTowers
342  if ((ajet.isCaloJet() || ajet.isJPTJet()) && embedCaloTowers_) {
343  const reco::CaloJet *cj = nullptr;
344  const reco::JPTJet *jptj = nullptr;
345  if (ajet.isCaloJet())
346  cj = dynamic_cast<const reco::CaloJet *>(jetRef.get());
347  else {
348  jptj = dynamic_cast<const reco::JPTJet *>(jetRef.get());
349  cj = dynamic_cast<const reco::CaloJet *>(jptj->getCaloJetRef().get());
350  }
352  std::vector<CaloTowerPtr> itowers = cj->getCaloConstituents();
353  for (std::vector<CaloTowerPtr>::const_iterator towBegin = itowers.begin(),
354  towEnd = itowers.end(),
355  itow = towBegin;
356  itow != towEnd;
357  ++itow) {
358  if (itow->isAvailable() && itow->isNonnull()) {
359  caloTowersOut->push_back(**itow);
360  // set the "forward" ref to the thinned collection
361  edm::Ref<std::vector<CaloTower>> caloTowerRef(h_caloTowersOut, caloTowersOut->size() - 1);
362  edm::Ptr<CaloTower> caloForwardRef(h_caloTowersOut.id(), caloTowerRef.key(), h_caloTowersOut.productGetter());
363  // set the "backward" ref to the original collection for association
364  const edm::Ptr<CaloTower> &caloBackRef(*itow);
365  // add to the list of FwdPtr's
366  itowersRef.push_back(pat::CaloTowerFwdPtrCollection::value_type(caloForwardRef, caloBackRef));
367  }
368  }
369  ajet.setCaloTowers(itowersRef);
370  }
371 
372  // add the FwdPtrs to the PFCandidates
373  if (ajet.isPFJet() && embedPFCandidates_) {
374  const reco::PFJet *cj = dynamic_cast<const reco::PFJet *>(jetRef.get());
375  pat::PFCandidateFwdPtrCollection iparticlesRef;
376  std::vector<reco::PFCandidatePtr> iparticles = cj->getPFConstituents();
377  for (std::vector<reco::PFCandidatePtr>::const_iterator partBegin = iparticles.begin(),
378  partEnd = iparticles.end(),
379  ipart = partBegin;
380  ipart != partEnd;
381  ++ipart) {
382  pfCandidatesOut->push_back(**ipart);
383  // set the "forward" ref to the thinned collection
384  edm::Ref<reco::PFCandidateCollection> pfCollectionRef(h_pfCandidatesOut, pfCandidatesOut->size() - 1);
385  edm::Ptr<reco::PFCandidate> pfForwardRef(
386  h_pfCandidatesOut.id(), pfCollectionRef.key(), h_pfCandidatesOut.productGetter());
387  // set the "backward" ref to the original collection for association
388  const edm::Ptr<reco::PFCandidate> &pfBackRef(*ipart);
389  // add to the list of FwdPtr's
390  iparticlesRef.push_back(pat::PFCandidateFwdPtrCollection::value_type(pfForwardRef, pfBackRef));
391  }
392  ajet.setPFCandidates(iparticlesRef);
393  }
394 
395  if (addJetCorrFactors_) {
396  // add additional JetCorrs to the jet
397  for (unsigned int i = 0; i < jetCorrFactorsTokens_.size(); ++i) {
398  const JetCorrFactors &jcf = jetCorrs[i][jetRef];
399  // uncomment for debugging
400  // jcf.print();
401  ajet.addJECFactors(jcf);
402  }
403  std::vector<std::string> levels = jetCorrs[0][jetRef].correctionLabels();
404  if (std::find(levels.begin(), levels.end(), "L2L3Residual") != levels.end()) {
405  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("L2L3Residual"));
406  } else if (std::find(levels.begin(), levels.end(), "L3Absolute") != levels.end()) {
407  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("L3Absolute"));
408  } else {
409  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("Uncorrected"));
410  if (printWarning_) {
411  edm::LogWarning("L3Absolute not found")
412  << "L2L3Residual and L3Absolute are not part of the jetCorrFactors\n"
413  << "of module " << jetCorrs[0][jetRef].jecSet() << ". Jets will remain"
414  << " uncorrected.";
415  printWarning_ = false;
416  }
417  }
418  }
419 
420  // get the MC flavour information for this jet
422  ajet.setPartonFlavour((*jetFlavMatch)[edm::RefToBase<reco::Jet>(jetRef)].getFlavour());
423  } else if (getJetMCFlavour_ && !useLegacyJetMCFlavour_) {
424  if (addJetFlavourInfo_)
425  ajet.setJetFlavourInfo((*jetFlavInfoMatch)[edm::RefToBase<reco::Jet>(jetRef)]);
426  else {
427  ajet.setPartonFlavour((*jetFlavInfoMatch)[edm::RefToBase<reco::Jet>(jetRef)].getPartonFlavour());
428  ajet.setHadronFlavour((*jetFlavInfoMatch)[edm::RefToBase<reco::Jet>(jetRef)].getHadronFlavour());
429  }
430  }
431  // store the match to the generated partons
432  if (addGenPartonMatch_) {
433  reco::GenParticleRef parton = (*partonMatch)[jetRef];
434  if (parton.isNonnull() && parton.isAvailable()) {
435  ajet.setGenParton(parton, embedGenPartonMatch_);
436  } // leave empty if no match found
437  }
438  // store the match to the GenJets
439  if (addGenJetMatch_) {
440  reco::GenJetRef genjet = (*genJetMatch)[jetRef];
441  if (genjet.isNonnull() && genjet.isAvailable()) {
442  genJetsOut->push_back(*genjet);
443  // set the "forward" ref to the thinned collection
444  edm::Ref<reco::GenJetCollection> genForwardRef(h_genJetsOut, genJetsOut->size() - 1);
445  // set the "backward" ref to the original collection
446  const edm::Ref<reco::GenJetCollection> &genBackRef(genjet);
447  // make the FwdPtr
448  edm::FwdRef<reco::GenJetCollection> genjetFwdRef(genForwardRef, genBackRef);
449  ajet.setGenJetRef(genjetFwdRef);
450  } // leave empty if no match found
451  }
452 
453  if (efficiencyLoader_.enabled()) {
454  efficiencyLoader_.setEfficiencies(ajet, jetRef);
455  }
456 
457  // IMPORTANT: DO THIS AFTER JES CORRECTIONS
458  if (resolutionLoader_.enabled()) {
460  }
461 
462  // TO BE IMPLEMENTED FOR >=1_5_X: do the PartonJet matching
463  if (addPartonJetMatch_) {
464  }
465 
466  // add b-tag info if available & required
467  if (addBTagInfo_) {
468  if (addDiscriminators_) {
469  for (size_t k = 0; k < jetDiscriminators.size(); ++k) {
470  float value = (*jetDiscriminators[k])[jetRef];
471  ajet.addBDiscriminatorPair(std::make_pair(discriminatorLabels_[k], value));
472  }
473  }
474  if (addTagInfos_) {
475  for (size_t k = 0; k < jetTagInfos.size(); ++k) {
476  const edm::View<reco::BaseTagInfo> &taginfos = *jetTagInfos[k];
477  // This is not associative, so we have to search the jet
479  // Try first by 'same index'
480  if ((idx < taginfos.size()) && (taginfos[idx].jet() == jetRef)) {
481  match = taginfos.ptrAt(idx);
482  } else {
483  // otherwise fail back to a simple search
484  for (edm::View<reco::BaseTagInfo>::const_iterator itTI = taginfos.begin(), edTI = taginfos.end();
485  itTI != edTI;
486  ++itTI) {
487  if (itTI->jet() == jetRef) {
488  match = taginfos.ptrAt(itTI - taginfos.begin());
489  break;
490  }
491  }
492  }
493  if (match.isNonnull()) {
494  tagInfosOut->push_back(match->clone());
495  // set the "forward" ptr to the thinned collection
496  edm::Ptr<reco::BaseTagInfo> tagInfoForwardPtr(
497  h_tagInfosOut.id(), &tagInfosOut->back(), tagInfosOut->size() - 1);
498  // set the "backward" ptr to the original collection for association
499  const edm::Ptr<reco::BaseTagInfo> &tagInfoBackPtr(match);
500  // make FwdPtr
501  TagInfoFwdPtrCollection::value_type tagInfoFwdPtr(tagInfoForwardPtr, tagInfoBackPtr);
502  ajet.addTagInfo(tagInfoLabels_[k], tagInfoFwdPtr);
503  }
504  }
505  }
506  }
507 
509  ajet.setAssociatedTracks((*hTrackAss)[jetRef]);
510 
511  if (addJetCharge_)
512  ajet.setJetCharge((*hJetChargeAss)[jetRef]);
513 
514  // add jet ID for calo jets
515  if (addJetID_ && ajet.isCaloJet()) {
516  reco::JetID jetId = (*hJetIDMap)[jetRef];
517  ajet.setJetID(jetId);
518  }
519  // add jet ID jpt jets
520  else if (addJetID_ && ajet.isJPTJet()) {
521  const reco::JPTJet *jptj = dynamic_cast<const reco::JPTJet *>(jetRef.get());
522  reco::JetID jetId = (*hJetIDMap)[jptj->getCaloJetRef()];
523  ajet.setJetID(jetId);
524  }
525  if (useUserData_) {
526  userDataHelper_.add(ajet, iEvent, iSetup);
527  }
528  patJets->push_back(ajet);
529  }
530 
531  // sort jets in pt
532  std::sort(patJets->begin(), patJets->end(), pTComparator_);
533 
534  // put genEvt in Event
535  iEvent.put(std::move(patJets));
536 
537  iEvent.put(std::move(genJetsOut), "genJets");
538  iEvent.put(std::move(caloTowersOut), "caloTowers");
539  iEvent.put(std::move(pfCandidatesOut), "pfCandidates");
540  iEvent.put(std::move(tagInfosOut), "tagInfos");
541 }
542 
543 // ParameterSet description for module
546  iDesc.setComment("PAT jet producer module");
547 
548  // input source
549  iDesc.add<edm::InputTag>("jetSource", edm::InputTag("no default"))->setComment("input collection");
550 
551  // embedding
552  iDesc.addOptional<bool>("embedCaloTowers", false)
553  ->setComment("embed external CaloTowers (not to be used on AOD input)");
554  iDesc.add<bool>("embedPFCandidates", true)->setComment("embed external PFCandidates");
555 
556  // MC matching configurables
557  iDesc.add<bool>("addGenPartonMatch", true)->setComment("add MC matching");
558  iDesc.add<bool>("embedGenPartonMatch", false)->setComment("embed MC matched MC information");
559  iDesc.add<edm::InputTag>("genPartonMatch", edm::InputTag())->setComment("input with MC match information");
560 
561  iDesc.add<bool>("addGenJetMatch", true)->setComment("add MC matching");
562  iDesc.add<bool>("embedGenJetMatch", false)->setComment("embed MC matched MC information");
563  iDesc.add<edm::InputTag>("genJetMatch", edm::InputTag())->setComment("input with MC match information");
564 
565  iDesc.add<bool>("addJetCharge", true);
566  iDesc.add<edm::InputTag>("jetChargeSource", edm::InputTag("patJetCharge"));
567 
568  // jet id
569  iDesc.add<bool>("addJetID", true)->setComment("Add jet ID information");
570  iDesc.add<edm::InputTag>("jetIDMap", edm::InputTag())->setComment("jet id map");
571 
572  iDesc.add<bool>("addPartonJetMatch", false);
573  iDesc.add<edm::InputTag>("partonJetSource", edm::InputTag("NOT IMPLEMENTED"));
574 
575  // track association
576  iDesc.add<bool>("addAssociatedTracks", true);
577  iDesc.add<edm::InputTag>("trackAssociationSource", edm::InputTag("ak4JTA"));
578 
579  // tag info
580  iDesc.add<bool>("addTagInfos", true);
581  std::vector<edm::InputTag> emptyVInputTags;
582  iDesc.add<std::vector<edm::InputTag>>("tagInfoSources", emptyVInputTags);
583 
584  // jet energy corrections
585  iDesc.add<bool>("addJetCorrFactors", true);
586  iDesc.add<std::vector<edm::InputTag>>("jetCorrFactorsSource", emptyVInputTags);
587 
588  // btag discriminator tags
589  iDesc.add<bool>("addBTagInfo", true);
590  iDesc.add<bool>("addDiscriminators", true);
591  iDesc.add<std::vector<edm::InputTag>>("discriminatorSources", emptyVInputTags);
592 
593  // jet flavour idetification configurables
594  iDesc.add<bool>("getJetMCFlavour", true);
595  iDesc.add<bool>("useLegacyJetMCFlavour", false);
596  iDesc.add<bool>("addJetFlavourInfo", false);
597  iDesc.add<edm::InputTag>("JetPartonMapSource", edm::InputTag("jetFlavourAssociationLegacy"));
598  iDesc.add<edm::InputTag>("JetFlavourInfoSource", edm::InputTag("jetFlavourAssociation"));
599 
601 
602  // Efficiency configurables
603  edm::ParameterSetDescription efficienciesPSet;
604  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
605  iDesc.add("efficiencies", efficienciesPSet);
606  iDesc.add<bool>("addEfficiencies", false);
607 
608  // Check to see if the user wants to add user data
609  edm::ParameterSetDescription userDataPSet;
611  iDesc.addOptional("userData", userDataPSet);
612 
613  descriptions.add("PATJetProducer", iDesc);
614 }
615 
void setJetID(reco::JetID const &id)
methods for jet ID
Definition: Jet.h:266
void initializeJEC(unsigned int level, const JetCorrFactors::Flavor &flavor=JetCorrFactors::NONE, unsigned int set=0)
initialize the jet to a given JEC level during creation starting from Uncorrected ...
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
pat::helper::EfficiencyLoader efficiencyLoader_
void setGenParton(const reco::GenParticleRef &gp, bool embed=false)
method to set the matched parton
Definition: Jet.h:255
virtual std::vector< CaloTowerPtr > getCaloConstituents() const
get all constituents
Definition: CaloJet.cc:78
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
GreaterByPt< CaloTower > caloPTComparator_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken_
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void addJECFactors(const JetCorrFactors &jec)
add more sets of energy correction factors
Definition: Jet.h:191
std::vector< edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > > tagInfoTokens_
edm::EDGetTokenT< reco::JetTracksAssociation::Container > trackAssociationToken_
Jets made from CaloTowers.
Definition: CaloJet.h:27
Ptr< value_type > ptrAt(size_type i) const
std::vector< std::string > tagInfoLabels_
std::vector< edm::EDGetTokenT< edm::ValueMap< JetCorrFactors > > > jetCorrFactorsTokens_
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
std::vector< edm::InputTag > tagInfoTags_
void setAllowAnything()
allow any parameter label/value pairs
pat::helper::KinResolutionsLoader resolutionLoader_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< GenJet > GenJetCollection
collection of GenJet objects
std::vector< std::string > discriminatorLabels_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isJPTJet() const
check to see if the jet is a reco::JPTJet
Definition: Jet.h:273
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
Jet ID object.
Definition: JetID.h:16
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void addBDiscriminatorPair(const std::pair< std::string, float > &thePair)
method to add a algolabel-discriminator pair
~PATJetProducer() override
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetFlavourInfoToken_
uint16_t size_type
Jets made from PFObjects.
Definition: PFJet.h:20
void setCaloTowers(const CaloTowerFwdPtrCollection &caloTowers)
method to store the CaloJet constituents internally
GreaterByPt< Jet > pTComparator_
size_type size() const
Definition: HeavyIon.h:7
static void fillDescription(edm::ParameterSetDescription &iDesc)
PATJetProducer(const edm::ParameterSet &iConfig)
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:41
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< reco::JetFloatAssociation::Container > jetChargeToken_
char const * label
void setHadronFlavour(int hadronFl)
method to set the hadron-based flavour of the jet
void setComment(std::string const &value)
int iEvent
Definition: GenABIO.cc:224
void setPartonFlavour(int partonFl)
method to set the parton-based flavour of the jet
void setPFCandidates(const PFCandidateFwdPtrCollection &pfCandidates)
method to store the PFCandidate constituents internally
Definition: Jet.py:1
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:28
Class for the storage of jet correction factors.
bool isAvailable() const
Definition: Ref.h:541
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
void setJetCharge(float jetCharge)
method to set the jet charge
edm::EDGetTokenT< reco::JetIDValueMap > jetIDMapToken_
Produces pat::Jet&#39;s.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
genJetMatch
switch on/off embedding of matched genJet&#39;s
void setJetFlavourInfo(const reco::JetFlavourInfo &jetFlavourInfo)
method to set the JetFlavourInfo of the jet
Definition: value.py:1
std::vector< edm::InputTag > discriminatorTags_
const edm::RefToBase< reco::Jet > & getCaloJetRef() const
Definition: JPTJet.h:118
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isPFJet() const
check to see if the jet is a reco::PFJet
Definition: Jet.h:275
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
bool isCaloJet() const
check to see if the jet is a reco::CaloJet
Definition: Jet.h:271
pat::PATUserDataHelper< pat::Jet > userDataHelper_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
void setAssociatedTracks(const reco::TrackRefVector &tracks)
method to set the vector of refs to the tracks associated to this jet
edm::EDGetTokenT< reco::JetFlavourMatchingCollection > jetPartonMapToken_
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
std::vector< edm::FwdPtr< CaloTower > > CaloTowerFwdPtrCollection
Definition: Jet.h:74
std::vector< edm::FwdPtr< reco::PFCandidate > > PFCandidateFwdPtrCollection
Definition: Jet.h:73
void setGenJetRef(const edm::FwdRef< reco::GenJetCollection > &gj)
method to set the matched generated jet reference, embedding if requested
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
edm::EDGetTokenT< edm::Association< reco::GenJetCollection > > genJetToken_
std::vector< edm::EDGetTokenT< reco::JetFloatAssociation::Container > > discriminatorTokens_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > genPartonToken_
const_iterator begin() const
Log< level::Warning, false > LogWarning
value_type const * get() const
Definition: RefToBase.h:211
const_iterator end() const
def move(src, dest)
Definition: eostools.py:511
void addTagInfo(const std::string &label, const TagInfoFwdPtrCollection::value_type &info)