CMS 3D CMS Logo

PATObject.h
Go to the documentation of this file.
1 //
2 //
3 
4 #ifndef DataFormats_PatCandidates_PATObject_h
5 #define DataFormats_PatCandidates_PATObject_h
6 
22 #include <vector>
23 #include <string>
24 #include <iosfwd>
25 
28 
30 
33 
35 
37 
39 
40 namespace pat {
41 
42  namespace pat_statics {
44  static const std::string EMPTY_STR("");
45  } // namespace pat_statics
46 
47  template <class ObjectType>
48  class PATObject : public ObjectType {
49  public:
51 
53  PATObject();
55  PATObject(const ObjectType &obj);
59  PATObject(const edm::Ptr<ObjectType> &ref);
61  ~PATObject() override {}
62  // returns a clone // NO: ObjectType can be an abstract type like reco::Candidate
63  // virtual PATObject<ObjectType> * clone() const ; // for which the clone() can't be defined
64 
66  const reco::Candidate *originalObject() const;
68  const edm::Ptr<reco::Candidate> &originalObjectRef() const;
69 
73 
75  const TriggerObjectStandAloneCollection &triggerObjectMatches() const { return triggerObjectMatchesEmbedded_; };
77  const TriggerObjectStandAlone *triggerObjectMatch(const size_t idx = 0) const;
80  const TriggerObjectStandAloneCollection triggerObjectMatchesByType(
81  const trigger::TriggerObjectType triggerObjectType) const;
82  const TriggerObjectStandAloneCollection triggerObjectMatchesByType(const unsigned triggerObjectType) const {
83  return triggerObjectMatchesByType(trigger::TriggerObjectType(triggerObjectType));
84  };
85  // for backward compatibility
86  const TriggerObjectStandAloneCollection triggerObjectMatchesByFilterID(const unsigned triggerObjectType) const {
87  return triggerObjectMatchesByType(trigger::TriggerObjectType(triggerObjectType));
88  };
90  const TriggerObjectStandAlone *triggerObjectMatchByType(const trigger::TriggerObjectType triggerObjectType,
91  const size_t idx = 0) const;
92  const TriggerObjectStandAlone *triggerObjectMatchByType(const unsigned triggerObjectType,
93  const size_t idx = 0) const {
94  return triggerObjectMatchByType(trigger::TriggerObjectType(triggerObjectType), idx);
95  };
96  // for backward compatibility
97  const TriggerObjectStandAlone *triggerObjectMatchByFilterID(const unsigned triggerObjectType,
98  const size_t idx = 0) const {
99  return triggerObjectMatchByType(trigger::TriggerObjectType(triggerObjectType), idx);
100  };
102  const TriggerObjectStandAloneCollection triggerObjectMatchesByCollection(const std::string &coll) const;
103  // for RooT command line
105  return triggerObjectMatchesByCollection(std::string(coll));
106  };
108  const TriggerObjectStandAlone *triggerObjectMatchByCollection(const std::string &coll, const size_t idx = 0) const;
109  // for RooT command line
110  const TriggerObjectStandAlone *triggerObjectMatchByCollection(const char *coll, const size_t idx = 0) const {
111  return triggerObjectMatchByCollection(std::string(coll), idx);
112  };
114  const TriggerObjectStandAloneCollection triggerObjectMatchesByCondition(const std::string &nameCondition) const;
115  // for RooT command line
117  return triggerObjectMatchesByCondition(std::string(nameCondition));
118  };
120  const TriggerObjectStandAlone *triggerObjectMatchByCondition(const std::string &nameCondition,
121  const size_t idx = 0) const;
122  // for RooT command line
123  const TriggerObjectStandAlone *triggerObjectMatchByCondition(const char *nameCondition,
124  const size_t idx = 0) const {
125  return triggerObjectMatchByCondition(std::string(nameCondition), idx);
126  };
130  const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const std::string &nameAlgorithm,
131  const bool algoCondAccepted = true) const;
132  // for RooT command line
134  const bool algoCondAccepted = true) const {
135  return triggerObjectMatchesByAlgorithm(std::string(nameAlgorithm), algoCondAccepted);
136  };
137  // for the cut string parser
139  const unsigned algoCondAccepted) const {
140  return triggerObjectMatchesByAlgorithm(nameAlgorithm, bool(algoCondAccepted));
141  };
142  // for RooT command line and the cut string parser
144  const unsigned algoCondAccepted) const {
145  return triggerObjectMatchesByAlgorithm(std::string(nameAlgorithm), bool(algoCondAccepted));
146  };
150  const TriggerObjectStandAlone *triggerObjectMatchByAlgorithm(const std::string &nameAlgorithm,
151  const bool algoCondAccepted = true,
152  const size_t idx = 0) const;
153  // for RooT command line
154  const TriggerObjectStandAlone *triggerObjectMatchByAlgorithm(const char *nameAlgorithm,
155  const bool algoCondAccepted = true,
156  const size_t idx = 0) const {
157  return triggerObjectMatchByAlgorithm(std::string(nameAlgorithm), algoCondAccepted, idx);
158  };
159  // for the cut string parser
161  const unsigned algoCondAccepted,
162  const size_t idx = 0) const {
163  return triggerObjectMatchByAlgorithm(nameAlgorithm, bool(algoCondAccepted), idx);
164  };
165  // for RooT command line and the cut string parser
166  const TriggerObjectStandAlone *triggerObjectMatchByAlgorithm(const char *nameAlgorithm,
167  const unsigned algoCondAccepted,
168  const size_t idx = 0) const {
169  return triggerObjectMatchByAlgorithm(std::string(nameAlgorithm), bool(algoCondAccepted), idx);
170  };
172  const TriggerObjectStandAloneCollection triggerObjectMatchesByFilter(const std::string &labelFilter) const;
173  // for RooT command line
175  return triggerObjectMatchesByFilter(std::string(labelFilter));
176  };
178  const TriggerObjectStandAlone *triggerObjectMatchByFilter(const std::string &labelFilter,
179  const size_t idx = 0) const;
180  // for RooT command line
181  const TriggerObjectStandAlone *triggerObjectMatchByFilter(const char *labelFilter, const size_t idx = 0) const {
182  return triggerObjectMatchByFilter(std::string(labelFilter), idx);
183  };
189  const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath,
190  const bool pathLastFilterAccepted = false,
191  const bool pathL3FilterAccepted = true) const;
192  // for RooT command line
194  const bool pathLastFilterAccepted = false,
195  const bool pathL3FilterAccepted = true) const {
196  return triggerObjectMatchesByPath(std::string(namePath), pathLastFilterAccepted, pathL3FilterAccepted);
197  };
198  // for the cut string parser
200  const unsigned pathLastFilterAccepted,
201  const unsigned pathL3FilterAccepted = 1) const {
202  return triggerObjectMatchesByPath(namePath, bool(pathLastFilterAccepted), bool(pathL3FilterAccepted));
203  };
204  // for RooT command line and the cut string parser
206  const unsigned pathLastFilterAccepted,
207  const unsigned pathL3FilterAccepted = 1) const {
208  return triggerObjectMatchesByPath(
209  std::string(namePath), bool(pathLastFilterAccepted), bool(pathL3FilterAccepted));
210  };
216  const TriggerObjectStandAlone *triggerObjectMatchByPath(const std::string &namePath,
217  const bool pathLastFilterAccepted = false,
218  const bool pathL3FilterAccepted = true,
219  const size_t idx = 0) const;
220  // for RooT command line
222  const bool pathLastFilterAccepted = false,
223  const bool pathL3FilterAccepted = true,
224  const size_t idx = 0) const {
225  return triggerObjectMatchByPath(std::string(namePath), pathLastFilterAccepted, pathL3FilterAccepted, idx);
226  };
227  // for the cut string parser
229  const unsigned pathLastFilterAccepted,
230  const unsigned pathL3FilterAccepted = 1,
231  const size_t idx = 0) const {
232  return triggerObjectMatchByPath(namePath, bool(pathLastFilterAccepted), bool(pathL3FilterAccepted), idx);
233  };
234  // for RooT command line and the cut string parser
236  const unsigned pathLastFilterAccepted,
237  const unsigned pathL3FilterAccepted = 1,
238  const size_t idx = 0) const {
239  return triggerObjectMatchByPath(
240  std::string(namePath), bool(pathLastFilterAccepted), bool(pathL3FilterAccepted), idx);
241  };
244  triggerObjectMatchesEmbedded_.push_back(trigObj);
245  };
248  for (std::vector<TriggerObjectStandAlone>::iterator it = triggerObjectMatchesEmbedded_.begin(),
249  ed = triggerObjectMatchesEmbedded_.end();
250  it != ed;
251  ++it)
252  it->unpackPathNames(names);
253  }
254 
256  const pat::LookupTableRecord &efficiency(const std::string &name) const;
258  std::vector<std::pair<std::string, pat::LookupTableRecord> > efficiencies() const;
260  const std::vector<std::string> &efficiencyNames() const { return efficiencyNames_; }
262  const std::vector<pat::LookupTableRecord> &efficiencyValues() const { return efficiencyValues_; }
266  void setEfficiency(const std::string &name, const pat::LookupTableRecord &value);
267 
271  if (idx >= genParticlesSize())
272  return reco::GenParticleRef();
273  return genParticleEmbedded_.empty() ? genParticleRef_[idx] : reco::GenParticleRef(&genParticleEmbedded_, idx);
274  }
285  // implementation note: uint8_t instead of bool, because the string parser doesn't allow bool currently
286  reco::GenParticleRef genParticleById(int pdgId, int status, uint8_t autoCharge = 0) const;
287 
290  const reco::GenParticle *genParticle(size_t idx = 0) const {
291  reco::GenParticleRef ref = genParticleRef(idx);
292  return ref.isNonnull() ? ref.get() : nullptr;
293  }
295  size_t genParticlesSize() const {
296  return genParticleEmbedded_.empty() ? genParticleRef_.size() : genParticleEmbedded_.size();
297  }
300  std::vector<reco::GenParticleRef> genParticleRefs() const;
301 
303  void setGenParticleRef(const reco::GenParticleRef &ref, bool embed = false);
306  void addGenParticleRef(const reco::GenParticleRef &ref);
308  void setGenParticle(const reco::GenParticle &particle);
311  void embedGenParticle();
312 
314  bool hasOverlaps(const std::string &label) const;
317  const reco::CandidatePtrVector &overlaps(const std::string &label) const;
319  const std::vector<std::string> &overlapLabels() const { return overlapLabels_; }
323  void setOverlaps(const std::string &label, const reco::CandidatePtrVector &overlaps);
324 
326  template <typename T>
327  const T *userData(const std::string &key) const {
328  const pat::UserData *data = userDataObject_(key);
329  return (data != nullptr ? data->template get<T>() : nullptr);
330  }
332  bool hasUserData(const std::string &key) const { return (userDataObject_(key) != nullptr); }
335  const pat::UserData *data = userDataObject_(key);
336  return (data != nullptr ? data->typeName() : pat_statics::EMPTY_STR);
337  };
339  const std::vector<std::string> &userDataNames() const { return userDataLabels_; }
340 
343  const void *userDataBare(const std::string &key) const {
344  const pat::UserData *data = userDataObject_(key);
345  return (data != nullptr ? data->bareData() : nullptr);
346  }
347 
352  template <typename T>
353  void addUserData(const std::string &label, const T &data, bool transientOnly = false, bool overwrite = false) {
354  std::unique_ptr<pat::UserData> made(pat::UserData::make<T>(data, transientOnly));
355  addUserDataObject_(label, std::move(made), overwrite);
356  }
357 
360  void addUserDataFromPtr(const std::string &label, const edm::Ptr<pat::UserData> &data, bool overwrite = false) {
361  std::unique_ptr<pat::UserData> cloned(data->clone());
362  addUserDataObject_(label, std::move(cloned), overwrite);
363  }
364 
367  float userFloat(const std::string &key) const;
369  std::vector<float> userFloatRange(const std::string &key) const;
371  float userFloat(const char *key) const { return userFloat(std::string(key)); }
372 
374  void addUserFloat(const std::string &label, float data, const bool overwrite = false);
376  const std::vector<std::string> &userFloatNames() const { return userFloatLabels_; }
378  bool hasUserFloat(const std::string &key) const {
379  auto it = std::lower_bound(userFloatLabels_.cbegin(), userFloatLabels_.cend(), key);
380  return (it != userFloatLabels_.cend() && *it == key);
381  }
383  bool hasUserFloat(const char *key) const { return hasUserFloat(std::string(key)); }
384 
387  int32_t userInt(const std::string &key) const;
389  std::vector<int> userIntRange(const std::string &key) const;
391  void addUserInt(const std::string &label, int32_t data, const bool overwrite = false);
393  const std::vector<std::string> &userIntNames() const { return userIntLabels_; }
395  bool hasUserInt(const std::string &key) const {
396  auto it = std::lower_bound(userIntLabels_.cbegin(), userIntLabels_.cend(), key);
397  return (it != userIntLabels_.cend() && *it == key);
398  }
399 
402  reco::CandidatePtr userCand(const std::string &key) const;
404  void addUserCand(const std::string &label, const reco::CandidatePtr &data, const bool overwrite = false);
406  const std::vector<std::string> &userCandNames() const { return userCandLabels_; }
408  bool hasUserCand(const std::string &key) const {
409  auto it = std::lower_bound(userCandLabels_.cbegin(), userCandLabels_.cend(), key);
410  return (it != userCandLabels_.cend() && *it == key);
411  }
412 
413  // === New Kinematic Resolutions
416  const pat::CandKinResolution &getKinResolution(const std::string &label = "") const;
417 
419  bool hasKinResolution(const std::string &label = "") const;
420 
422  void setKinResolution(const pat::CandKinResolution &resol, const std::string &label = "");
423 
425  double resolEta(const std::string &label = "") const { return getKinResolution(label).resolEta(this->p4()); }
426 
428  double resolTheta(const std::string &label = "") const { return getKinResolution(label).resolTheta(this->p4()); }
429 
431  double resolPhi(const std::string &label = "") const { return getKinResolution(label).resolPhi(this->p4()); }
432 
434  double resolE(const std::string &label = "") const { return getKinResolution(label).resolE(this->p4()); }
435 
437  double resolEt(const std::string &label = "") const { return getKinResolution(label).resolEt(this->p4()); }
438 
440  double resolP(const std::string &label = "") const { return getKinResolution(label).resolP(this->p4()); }
441 
443  double resolPt(const std::string &label = "") const { return getKinResolution(label).resolPt(this->p4()); }
444 
446  double resolPInv(const std::string &label = "") const { return getKinResolution(label).resolPInv(this->p4()); }
447 
449  double resolPx(const std::string &label = "") const { return getKinResolution(label).resolPx(this->p4()); }
450 
452  double resolPy(const std::string &label = "") const { return getKinResolution(label).resolPy(this->p4()); }
453 
455  double resolPz(const std::string &label = "") const { return getKinResolution(label).resolPz(this->p4()); }
456 
459  double resolM(const std::string &label = "") const { return getKinResolution(label).resolM(this->p4()); }
460 
461  protected:
462  // reference back to the original object
464 
467 
469  std::vector<pat::LookupTableRecord> efficiencyValues_;
471  std::vector<std::string> efficiencyNames_;
472 
474  std::vector<reco::GenParticleRef> genParticleRef_;
476  std::vector<reco::GenParticle> genParticleEmbedded_;
477 
479  std::vector<std::string> overlapLabels_;
481  std::vector<reco::CandidatePtrVector> overlapItems_;
482 
484  std::vector<std::string> userDataLabels_;
486  // User float values
487  std::vector<std::string> userFloatLabels_;
488  std::vector<float> userFloats_;
489  // User int values
490  std::vector<std::string> userIntLabels_;
491  std::vector<int32_t> userInts_;
492  // User candidate matches
493  std::vector<std::string> userCandLabels_;
494  std::vector<reco::CandidatePtr> userCands_;
495 
497  std::vector<pat::CandKinResolution> kinResolutions_;
500  std::vector<std::string> kinResolutionLabels_;
501 
502  void addUserDataObject_(const std::string &label, std::unique_ptr<pat::UserData> value, bool overwrite = false);
503 
504  private:
505  const pat::UserData *userDataObject_(const std::string &key) const;
506  };
507 
508  template <class ObjectType>
510 
511  template <class ObjectType>
513 
514  template <class ObjectType>
516  : ObjectType(*ref),
517  refToOrig_(ref.id(),
518  ref.get(),
519  ref.key()) // correct way to convert RefToBase=>Ptr, if ref is guaranteed to be available
520  // which happens to be true, otherwise the line before this throws ex. already
521  {}
522 
523  template <class ObjectType>
525 
526  template <class ObjectType>
528  if (refToOrig_.isNull()) {
529  // this object was not produced from a reference, so no link to the
530  // original object exists -> return a 0-pointer
531  return nullptr;
532  } else if (!refToOrig_.isAvailable()) {
534  << "The original collection from which this PAT object was made is not present any more in the event, hence "
535  "you cannot access the originating object anymore.";
536  } else {
537  return refToOrig_.get();
538  }
539  }
540 
541  template <class ObjectType>
543  return refToOrig_;
544  }
545 
546  template <class ObjectType>
548  if (idx >= triggerObjectMatches().size())
549  return nullptr;
551  return ref.isNonnull() ? ref.get() : nullptr;
552  }
553 
554  template <class ObjectType>
556  const trigger::TriggerObjectType triggerObjectType) const {
558  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
559  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasTriggerObjectType(triggerObjectType))
560  matches.push_back(*(triggerObjectMatch(i)));
561  }
562  return matches;
563  }
564 
565  template <class ObjectType>
567  const trigger::TriggerObjectType triggerObjectType, const size_t idx) const {
568  std::vector<size_t> refs;
569  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
570  if (triggerObjectMatch(i) != nullptr && triggerObjectMatch(i)->hasTriggerObjectType(triggerObjectType))
571  refs.push_back(i);
572  }
573  if (idx >= refs.size())
574  return nullptr;
576  return ref.isNonnull() ? ref.get() : nullptr;
577  }
578 
579  template <class ObjectType>
581  const std::string &coll) const {
583  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
585  matches.push_back(*(triggerObjectMatch(i)));
586  }
587  return matches;
588  }
589 
590  template <class ObjectType>
592  const size_t idx) const {
593  std::vector<size_t> refs;
594  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
595  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasCollection(coll)) {
596  refs.push_back(i);
597  }
598  }
599  if (idx >= refs.size())
600  return nullptr;
602  return ref.isNonnull() ? ref.get() : nullptr;
603  }
604 
605  template <class ObjectType>
607  const std::string &nameCondition) const {
609  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
610  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasConditionName(nameCondition))
611  matches.push_back(*(triggerObjectMatch(i)));
612  }
613  return matches;
614  }
615 
616  template <class ObjectType>
618  const size_t idx) const {
619  std::vector<size_t> refs;
620  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
621  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasConditionName(nameCondition))
622  refs.push_back(i);
623  }
624  if (idx >= refs.size())
625  return nullptr;
627  return ref.isNonnull() ? ref.get() : nullptr;
628  }
629 
630  template <class ObjectType>
632  const std::string &nameAlgorithm, const bool algoCondAccepted) const {
634  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
635  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasAlgorithmName(nameAlgorithm, algoCondAccepted))
636  matches.push_back(*(triggerObjectMatch(i)));
637  }
638  return matches;
639  }
640 
641  template <class ObjectType>
643  const bool algoCondAccepted,
644  const size_t idx) const {
645  std::vector<size_t> refs;
646  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
647  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasAlgorithmName(nameAlgorithm, algoCondAccepted))
648  refs.push_back(i);
649  }
650  if (idx >= refs.size())
651  return nullptr;
653  return ref.isNonnull() ? ref.get() : nullptr;
654  }
655 
656  template <class ObjectType>
658  const std::string &labelFilter) const {
660  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
661  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasFilterLabel(labelFilter))
662  matches.push_back(*(triggerObjectMatch(i)));
663  }
664  return matches;
665  }
666 
667  template <class ObjectType>
669  const size_t idx) const {
670  std::vector<size_t> refs;
671  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
672  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasFilterLabel(labelFilter))
673  refs.push_back(i);
674  }
675  if (idx >= refs.size())
676  return nullptr;
678  return ref.isNonnull() ? ref.get() : nullptr;
679  }
680 
681  template <class ObjectType>
683  const std::string &namePath, const bool pathLastFilterAccepted, const bool pathL3FilterAccepted) const {
685  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
686  if (triggerObjectMatch(i) != nullptr &&
687  triggerObjectMatch(i)->hasPathName(namePath, pathLastFilterAccepted, pathL3FilterAccepted))
688  matches.push_back(*(triggerObjectMatch(i)));
689  }
690  return matches;
691  }
692 
693  template <class ObjectType>
695  const bool pathLastFilterAccepted,
696  const bool pathL3FilterAccepted,
697  const size_t idx) const {
698  std::vector<size_t> refs;
699  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
700  if (triggerObjectMatch(i) != nullptr &&
701  triggerObjectMatch(i)->hasPathName(namePath, pathLastFilterAccepted, pathL3FilterAccepted))
702  refs.push_back(i);
703  }
704  if (idx >= refs.size())
705  return nullptr;
707  return ref.isNonnull() ? ref.get() : nullptr;
708  }
709 
710  template <class ObjectType>
712  // find the name in the (sorted) list of names
713  auto it = std::lower_bound(efficiencyNames_.cbegin(), efficiencyNames_.cend(), name);
714  if ((it == efficiencyNames_.end()) || (*it != name)) {
715  throw cms::Exception("Invalid Label") << "There is no efficiency with name '" << name << "' in this PAT Object\n";
716  }
717  return efficiencyValues_[std::distance(efficiencyNames_.cbegin(), it)];
718  }
719 
720  template <class ObjectType>
721  std::vector<std::pair<std::string, pat::LookupTableRecord> > PATObject<ObjectType>::efficiencies() const {
722  std::vector<std::pair<std::string, pat::LookupTableRecord> > ret;
723  std::vector<std::string>::const_iterator itn = efficiencyNames_.begin(), edn = efficiencyNames_.end();
724  std::vector<pat::LookupTableRecord>::const_iterator itv = efficiencyValues_.begin();
725  for (; itn != edn; ++itn, ++itv) {
726  ret.emplace_back(*itn, *itv);
727  }
728  return ret;
729  }
730 
731  template <class ObjectType>
733  // look for the name, or to the place where we can insert it without violating the alphabetic order
734  auto it = std::lower_bound(efficiencyNames_.begin(), efficiencyNames_.end(), name);
735  const auto dist = std::distance(efficiencyNames_.begin(), it);
736  if (it == efficiencyNames_.end()) { // insert at the end
737  efficiencyNames_.push_back(name);
738  efficiencyValues_.push_back(value);
739  } else if (*it == name) { // replace existing
740  efficiencyValues_[dist] = value;
741  } else { // insert in the middle :-(
742  efficiencyNames_.insert(it, name);
743  efficiencyValues_.insert(efficiencyValues_.begin() + dist, value);
744  }
745  }
746 
747  template <class ObjectType>
749  genParticleRef_ = std::vector<reco::GenParticleRef>(1, ref);
750  genParticleEmbedded_.clear();
751  if (embed)
753  }
754 
755  template <class ObjectType>
757  if (!genParticleEmbedded_.empty()) { // we're embedding
758  if (ref.isNonnull())
759  genParticleEmbedded_.push_back(*ref);
760  } else {
761  genParticleRef_.push_back(ref);
762  }
763  }
764 
765  template <class ObjectType>
767  genParticleEmbedded_.clear();
768  genParticleEmbedded_.push_back(particle);
769  genParticleRef_.clear();
770  }
771 
772  template <class ObjectType>
774  genParticleEmbedded_.clear();
775  for (std::vector<reco::GenParticleRef>::const_iterator it = genParticleRef_.begin(); it != genParticleRef_.end();
776  ++it) {
777  if (it->isNonnull())
778  genParticleEmbedded_.push_back(**it);
779  }
780  genParticleRef_.clear();
781  }
782 
783  template <class ObjectType>
784  std::vector<reco::GenParticleRef> PATObject<ObjectType>::genParticleRefs() const {
785  if (genParticleEmbedded_.empty())
786  return genParticleRef_;
787  std::vector<reco::GenParticleRef> ret(genParticleEmbedded_.size());
788  for (size_t i = 0, n = ret.size(); i < n; ++i) {
790  }
791  return ret;
792  }
793 
794  template <class ObjectType>
796  // get a vector, avoiding an unneeded copy if there is no embedding
797  const std::vector<reco::GenParticleRef> &vec = (genParticleEmbedded_.empty() ? genParticleRef_ : genParticleRefs());
798  for (std::vector<reco::GenParticleRef>::const_iterator ref = vec.begin(), end = vec.end(); ref != end; ++ref) {
799  if (ref->isNonnull()) {
800  const reco::GenParticle &g = **ref;
801  if ((status != 0) && (g.status() != status))
802  continue;
803  if (pdgId == 0) {
804  return *ref;
805  } else if (!autoCharge) {
806  if (pdgId == g.pdgId())
807  return *ref;
808  } else if (abs(pdgId) == abs(g.pdgId())) {
809  // I want pdgId > 0 to match "correct charge" (for charged particles)
810  if (g.charge() == 0)
811  return *ref;
812  else if ((this->charge() == 0) && (pdgId == g.pdgId()))
813  return *ref;
814  else if (g.charge() * this->charge() * pdgId > 0)
815  return *ref;
816  }
817  }
818  }
819  return reco::GenParticleRef();
820  }
821 
822  template <class ObjectType>
824  auto match = std::lower_bound(overlapLabels_.cbegin(), overlapLabels_.cend(), label);
825  return (match != overlapLabels_.end() && *match == label);
826  }
827 
828  template <class ObjectType>
830  auto match = std::lower_bound(overlapLabels_.cbegin(), overlapLabels_.cend(), label);
831  if (match == overlapLabels_.cend() || *match != label)
832  return pat_statics::EMPTY_CPV;
834  }
835 
836  template <class ObjectType>
838  auto match = std::lower_bound(overlapLabels_.begin(), overlapLabels_.end(), label);
839  const auto dist = std::distance(overlapLabels_.begin(), match);
840  if (match == overlapLabels_.end() || *match != label) {
841  overlapLabels_.insert(match, label);
842  overlapItems_.insert(overlapItems_.begin() + dist, overlaps);
843  } else {
844  overlapItems_[dist] = overlaps;
845  }
846  }
847 
848  template <class ObjectType>
850  auto it = std::lower_bound(userDataLabels_.cbegin(), userDataLabels_.cend(), key);
851  if (it != userDataLabels_.cend() && *it == key) {
852  return &userDataObjects_[std::distance(userDataLabels_.cbegin(), it)];
853  }
854  return nullptr;
855  }
856 
857  template <class ObjectType>
859  std::unique_ptr<pat::UserData> data,
860  bool overwrite) {
861  auto it = std::lower_bound(userDataLabels_.begin(), userDataLabels_.end(), label);
862  const auto dist = std::distance(userDataLabels_.begin(), it);
863  if (it == userDataLabels_.end() || *it != label) {
864  userDataLabels_.insert(it, label);
866  } else if (overwrite) {
867  userDataObjects_.set(dist, std::move(data));
868  } else {
869  //create a range by adding behind the first entry
870  userDataLabels_.insert(it + 1, label);
872  }
873  }
874 
875  template <class ObjectType>
877  auto it = std::lower_bound(userFloatLabels_.cbegin(), userFloatLabels_.cend(), key);
878  if (it != userFloatLabels_.cend() && *it == key) {
879  return userFloats_[std::distance(userFloatLabels_.cbegin(), it)];
880  }
881  throwMissingLabel("UserFloat", key, userFloatLabels_);
882  return std::numeric_limits<float>::quiet_NaN();
883  }
884 
885  template <class ObjectType>
886  std::vector<float> PATObject<ObjectType>::userFloatRange(const std::string &key) const {
887  auto range = std::equal_range(userFloatLabels_.cbegin(), userFloatLabels_.cend(), key);
888  std::vector<float> result;
889  result.reserve(std::distance(range.first, range.second));
890  for (auto it = range.first; it != range.second; ++it) {
891  result.push_back(userFloats_[std::distance(userFloatLabels_.cbegin(), it)]);
892  }
893  return result;
894  }
895 
896  template <class ObjectType>
897  void PATObject<ObjectType>::addUserFloat(const std::string &label, float data, const bool overwrite) {
898  auto it = std::lower_bound(userFloatLabels_.begin(), userFloatLabels_.end(), label);
899  const auto dist = std::distance(userFloatLabels_.begin(), it);
900  if (it == userFloatLabels_.end() || *it != label) {
901  userFloatLabels_.insert(it, label);
902  userFloats_.insert(userFloats_.begin() + dist, data);
903  } else if (overwrite) {
904  userFloats_[dist] = data;
905  } else {
906  //create a range by adding behind the first entry
907  userFloatLabels_.insert(it + 1, label);
908  userFloats_.insert(userFloats_.begin() + dist + 1, data);
909  }
910  }
911 
912  template <class ObjectType>
914  auto it = std::lower_bound(userIntLabels_.cbegin(), userIntLabels_.cend(), key);
915  if (it != userIntLabels_.cend() && *it == key) {
916  return userInts_[std::distance(userIntLabels_.cbegin(), it)];
917  }
918  throwMissingLabel("UserInt", key, userIntLabels_);
920  }
921 
922  template <class ObjectType>
923  std::vector<int> PATObject<ObjectType>::userIntRange(const std::string &key) const {
924  auto range = std::equal_range(userIntLabels_.cbegin(), userIntLabels_.cend(), key);
925  std::vector<int> result;
926  result.reserve(std::distance(range.first, range.second));
927  for (auto it = range.first; it != range.second; ++it) {
928  result.push_back(userInts_[std::distance(userIntLabels_.cbegin(), it)]);
929  }
930  return result;
931  }
932 
933  template <class ObjectType>
934  void PATObject<ObjectType>::addUserInt(const std::string &label, int data, bool overwrite) {
935  auto it = std::lower_bound(userIntLabels_.begin(), userIntLabels_.end(), label);
936  const auto dist = std::distance(userIntLabels_.begin(), it);
937  if (it == userIntLabels_.end() || *it != label) {
938  userIntLabels_.insert(it, label);
939  userInts_.insert(userInts_.begin() + dist, data);
940  } else if (overwrite) {
941  userInts_[dist] = data;
942  } else {
943  //create a range by adding behind the first entry
944  userIntLabels_.insert(it + 1, label);
945  userInts_.insert(userInts_.begin() + dist + 1, data);
946  }
947  }
948 
949  template <class ObjectType>
951  auto it = std::lower_bound(userCandLabels_.cbegin(), userCandLabels_.cend(), key);
952  if (it != userCandLabels_.cend()) {
953  return userCands_[std::distance(userCandLabels_.begin(), it)];
954  }
955  return reco::CandidatePtr();
956  }
957 
958  template <class ObjectType>
960  const reco::CandidatePtr &data,
961  const bool overwrite) {
962  auto it = std::lower_bound(userCandLabels_.begin(), userCandLabels_.end(), label);
963  const auto dist = std::distance(userCandLabels_.begin(), it);
964  if (it == userCandLabels_.end() || *it != label) {
965  userCandLabels_.insert(it, label);
966  userCands_.insert(userCands_.begin() + dist, data);
967  } else if (overwrite) {
968  userCands_[dist] = data;
969  } else {
970  userCandLabels_.insert(it + 1, label);
971  userCands_.insert(userCands_.begin() + dist + 1, data);
972  }
973  }
974 
975  template <class ObjectType>
977  const bool has_unlabelled = (kinResolutionLabels_.size() + 1 == kinResolutions_.size());
978  if (label.empty()) {
979  if (has_unlabelled) {
980  return kinResolutions_[0];
981  } else {
982  throw cms::Exception("Missing Data", "This object does not contain an un-labelled kinematic resolution");
983  }
984  } else {
985  auto match = std::lower_bound(kinResolutionLabels_.cbegin(), kinResolutionLabels_.cend(), label);
986  const auto dist = std::distance(kinResolutionLabels_.begin(), match);
987  const size_t increment = (has_unlabelled ? 1 : 0);
988  if (match == kinResolutionLabels_.end() || *match != label) {
989  cms::Exception ex("Missing Data");
990  ex << "This object does not contain a kinematic resolution with name '" << label << "'.\n";
991  ex << "The known labels are: ";
992  for (std::vector<std::string>::const_iterator it = kinResolutionLabels_.cbegin();
993  it != kinResolutionLabels_.cend();
994  ++it) {
995  ex << "'" << *it << "' ";
996  }
997  ex << "\n";
998  throw ex;
999  } else {
1000  return kinResolutions_[dist + increment];
1001  }
1002  }
1003  }
1004 
1005  template <class ObjectType>
1007  if (label.empty()) {
1008  return (kinResolutionLabels_.size() + 1 == kinResolutions_.size());
1009  } else {
1010  auto match = std::lower_bound(kinResolutionLabels_.cbegin(), kinResolutionLabels_.cend(), label);
1011  return (match != kinResolutionLabels_.cend() && *match == label);
1012  }
1013  }
1014 
1015  template <class ObjectType>
1017  const bool has_unlabelled = (kinResolutionLabels_.size() + 1 == kinResolutions_.size());
1018  if (label.empty()) {
1019  if (has_unlabelled) {
1020  // There is already an un-labelled object. Replace it
1021  kinResolutions_[0] = resol;
1022  } else {
1023  // Insert. Note that the un-labelled is always the first, so we need to insert before begin()
1024  // (for an empty vector, this should not cost more than push_back)
1025  kinResolutions_.insert(kinResolutions_.begin(), resol);
1026  }
1027  } else {
1028  auto match = std::lower_bound(kinResolutionLabels_.begin(), kinResolutionLabels_.end(), label);
1029  const auto dist = std::distance(kinResolutionLabels_.begin(), match);
1030  const size_t increment = (has_unlabelled ? 1 : 0);
1031  if (match != kinResolutionLabels_.end() && *match == label) {
1032  // Existing object: replace
1033  kinResolutions_[dist + increment] = resol;
1034  } else {
1035  kinResolutionLabels_.insert(match, label);
1036  kinResolutions_.insert(kinResolutions_.begin() + dist + increment, resol);
1037  }
1038  }
1039  }
1040 
1041 } // namespace pat
1042 
1043 #endif
size
Write out results.
std::vector< std::string > efficiencyNames_
vector of the efficiencies (names)
Definition: PATObject.h:471
const TriggerObjectStandAlone * triggerObjectMatchByCollection(const std::string &coll, const size_t idx=0) const
get one matched trigger object from a certain collection by index
Definition: PATObject.h:591
~PATObject() override
destructor
Definition: PATObject.h:61
bool hasUserFloat(const char *key) const
a CINT-friendly interface
Definition: PATObject.h:383
int pdgId() const final
PDG identifier.
void addUserCand(const std::string &label, const reco::CandidatePtr &data, const bool overwrite=false)
Set user-defined int.
Definition: PATObject.h:959
bool hasOverlaps(const std::string &label) const
Returns true if there was at least one overlap for this test label.
Definition: PATObject.h:823
const TriggerObjectStandAlone * triggerObjectMatchByPath(const std::string &namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1, const size_t idx=0) const
Definition: PATObject.h:228
void addUserDataObject_(const std::string &label, std::unique_ptr< pat::UserData > value, bool overwrite=false)
Definition: PATObject.h:858
def addGenParticleRef(patMuonProducer, label='classByHitsGlbOrTrk')
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const char *nameAlgorithm, const bool algoCondAccepted=true, const size_t idx=0) const
Definition: PATObject.h:154
bool hasPathName(const std::string &pathName, bool pathLastFilterAccepted=false, bool pathL3FilterAccepted=true) const
Checks, if a certain HLT path name is assigned.
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::vector< std::pair< std::string, pat::LookupTableRecord > > efficiencies() const
Returns the efficiencies as <name,value> pairs (by value)
Definition: PATObject.h:721
const TriggerObjectStandAlone * triggerObjectMatchByPath(const char *namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1, const size_t idx=0) const
Definition: PATObject.h:235
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const char *nameAlgorithm, const unsigned algoCondAccepted, const size_t idx=0) const
Definition: PATObject.h:166
double resolPhi(const LorentzVector &p4) const
Resolution on phi, given the 4-momentum of the associated Candidate.
std::vector< reco::GenParticleRef > genParticleRef_
Reference to a generator level particle.
Definition: PATObject.h:474
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
bool hasKinResolution(const std::string &label="") const
Check if the kinematic resolutions are stored into this object (possibly specifying a label for them)...
Definition: PATObject.h:1006
reco::GenParticleRef genParticleRef(size_t idx=0) const
Definition: PATObject.h:270
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:290
PATObject()
default constructor
Definition: PATObject.h:509
double resolP(const std::string &label="") const
Resolution on p, possibly with a label to specify which resolution to use.
Definition: PATObject.h:440
const TriggerObjectStandAlone * triggerObjectMatchByFilterID(const unsigned triggerObjectType, const size_t idx=0) const
Definition: PATObject.h:97
ret
prodAgent to be discontinued
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
size_t genParticlesSize() const
Number of generator level particles stored as ref or embedded.
Definition: PATObject.h:295
std::vector< reco::CandidatePtr > userCands_
Definition: PATObject.h:494
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const char *namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1) const
Definition: PATObject.h:205
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
bool isAvailable() const
Definition: Ptr.h:229
Class to store the result of a lookup table fetch, e.g. for efficiencies.
const TriggerObjectStandAloneCollection triggerObjectMatchesByFilter(const std::string &labelFilter) const
get all matched HLT objects used in a certain HLT filter
Definition: PATObject.h:657
double resolPInv(const std::string &label="") const
Resolution on 1/p, possibly with a label to specify which resolution to use.
Definition: PATObject.h:446
bool hasUserFloat(const std::string &key) const
Return true if there is a user-defined float with a given name.
Definition: PATObject.h:378
int charge() const final
electric charge
std::vector< pat::CandKinResolution > kinResolutions_
Kinematic resolutions.
Definition: PATObject.h:497
double resolPz(const std::string &label="") const
Resolution on pz, possibly with a label to specify which resolution to use.
Definition: PATObject.h:455
const TriggerObjectStandAlone * triggerObjectMatchByCondition(const char *nameCondition, const size_t idx=0) const
Definition: PATObject.h:123
bool hasUserCand(const std::string &key) const
Return true if there is a user-defined int with a given name.
Definition: PATObject.h:408
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:897
std::vector< std::string > userCandLabels_
Definition: PATObject.h:493
void setGenParticle(const reco::GenParticle &particle)
Set the generator level particle from a particle not in the Event (embedding it, of course) ...
Definition: PATObject.h:766
std::vector< reco::GenParticleRef > genParticleRefs() const
Definition: PATObject.h:784
std::vector< float > userFloatRange(const std::string &key) const
return a range of values corresponding to key
Definition: PATObject.h:886
void setEfficiency(const std::string &name, const pat::LookupTableRecord &value)
Definition: PATObject.h:732
TriggerObjectStandAloneCollection triggerObjectMatchesEmbedded_
vector of trigger matches
Definition: PATObject.h:466
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
Definition: PATObject.h:748
bool hasCollection(const std::string &collName) const override
Checks, if a certain label of original collection is assigned (method overrides)
std::vector< std::string > userDataLabels_
User data object.
Definition: PATObject.h:484
const std::string names[nVars_]
std::vector< reco::GenParticle > genParticleEmbedded_
vector to hold an embedded generator level particle
Definition: PATObject.h:476
const std::vector< std::string > & userCandNames() const
Get list of user-defined cand names.
Definition: PATObject.h:406
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
const std::vector< pat::LookupTableRecord > & efficiencyValues() const
Returns the list of the values of the stored efficiencies (the ordering is the same as in efficiencyN...
Definition: PATObject.h:262
std::vector< float > userFloats_
Definition: PATObject.h:488
float userFloat(const std::string &key) const
Definition: PATObject.h:876
#define embed
Definition: AMPTWrapper.h:188
Definition: HeavyIon.h:7
void setKinResolution(const pat::CandKinResolution &resol, const std::string &label="")
Add a kinematic resolution to this object (possibly with a label)
Definition: PATObject.h:1016
iterator begin()
Definition: OwnVector.h:280
void unpackTriggerObjectPathNames(const edm::TriggerNames &names)
unpack path names of matched trigger objects (if they were packed before embedding, which is not normally the case)
Definition: PATObject.h:247
bool hasUserInt(const std::string &key) const
Return true if there is a user-defined int with a given name.
Definition: PATObject.h:395
bool hasAlgorithmName(const std::string &algorithmName, bool algoCondAccepted=true) const
Checks, if a certain L1 algorithm name is assigned.
double resolPt(const std::string &label="") const
Resolution on pt, possibly with a label to specify which resolution to use.
Definition: PATObject.h:443
const reco::CandidatePtrVector & overlaps(const std::string &label) const
Definition: PATObject.h:829
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const std::string &nameAlgorithm, const bool algoCondAccepted=true, const size_t idx=0) const
Definition: PATObject.h:642
double resolPz(const LorentzVector &p4) const
Resolution on pz, given the 4-momentum of the associated Candidate.
char const * label
const TriggerObjectStandAlone * triggerObjectMatchByFilter(const std::string &labelFilter, const size_t idx=0) const
get one matched HLT object used in a certain HLT filter by index
Definition: PATObject.h:668
std::vector< pat::LookupTableRecord > efficiencyValues_
vector of the efficiencies (values)
Definition: PATObject.h:469
double resolPy(const std::string &label="") const
Resolution on py, possibly with a label to specify which resolution to use.
Definition: PATObject.h:452
double resolEt(const std::string &label="") const
Resolution on et, possibly with a label to specify which resolution to use.
Definition: PATObject.h:437
double resolPx(const std::string &label="") const
Resolution on px, possibly with a label to specify which resolution to use.
Definition: PATObject.h:449
double resolP(const LorentzVector &p4) const
Resolution on p, given the 4-momentum of the associated Candidate.
void embedGenParticle()
Definition: PATObject.h:773
double resolPy(const LorentzVector &p4) const
Resolution on py, given the 4-momentum of the associated Candidate.
const TriggerObjectStandAlone * triggerObjectMatchByPath(const char *namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true, const size_t idx=0) const
Definition: PATObject.h:221
static const std::string EMPTY_STR("")
virtual const std::string & typeName() const =0
Human readable name of the concrete type of stored data.
double p4[4]
Definition: TauolaWrapper.h:92
bool isNull() const
Checks for null.
Definition: Ptr.h:142
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double resolEta(const LorentzVector &p4) const
Resolution on eta, given the 4-momentum of the associated Candidate.
std::vector< std::string > userFloatLabels_
Definition: PATObject.h:487
void throwMissingLabel(const std::string &what, const std::string &bad_label, const std::vector< std::string > &available)
const TriggerObjectStandAlone * triggerObjectMatch(const size_t idx=0) const
get one matched trigger object by index
Definition: PATObject.h:547
void set(size_t i, D *&d)
Definition: OwnVector.h:357
const T * userData(const std::string &key) const
Returns user-defined data. Returns NULL if the data is not present, or not of type T...
Definition: PATObject.h:327
const TriggerObjectStandAlone * triggerObjectMatchByFilter(const char *labelFilter, const size_t idx=0) const
Definition: PATObject.h:181
#define end
Definition: vmac.h:39
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
Definition: value.py:1
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:682
double resolPhi(const std::string &label="") const
Resolution on phi, possibly with a label to specify which resolution to use.
Definition: PATObject.h:431
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:542
const TriggerObjectStandAlone * triggerObjectMatchByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true, const size_t idx=0) const
Definition: PATObject.h:694
const TriggerObjectStandAloneCollection triggerObjectMatchesByCondition(const char *nameCondition) const
Definition: PATObject.h:116
bool hasUserData(const std::string &key) const
Check if user data with a specific type is present.
Definition: PATObject.h:332
void addUserInt(const std::string &label, int32_t data, const bool overwrite=false)
Set user-defined int.
Definition: PATObject.h:934
double resolE(const std::string &label="") const
Resolution on energy, possibly with a label to specify which resolution to use.
Definition: PATObject.h:434
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const char *namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:193
bool hasTriggerObjectType(trigger::TriggerObjectType triggerObjectType) const
Checks, if a certain trigger object type identifier is assigned.
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const std::string &nameAlgorithm, const bool algoCondAccepted=true) const
Definition: PATObject.h:631
ObjectType base_type
Definition: PATObject.h:50
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const char *nameAlgorithm, const bool algoCondAccepted=true) const
Definition: PATObject.h:133
double resolM(const LorentzVector &p4) const
std::vector< reco::CandidatePtrVector > overlapItems_
Overlapping items (sorted by distance)
Definition: PATObject.h:481
std::vector< std::string > kinResolutionLabels_
Definition: PATObject.h:500
void setOverlaps(const std::string &label, const reco::CandidatePtrVector &overlaps)
Definition: PATObject.h:837
const TriggerObjectStandAloneCollection triggerObjectMatchesByFilterID(const unsigned triggerObjectType) const
Definition: PATObject.h:86
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:756
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
double resolPInv(const LorentzVector &p4) const
Resolution on 1/p, given the 4-momentum of the associated Candidate.
pat::UserDataCollection userDataObjects_
Definition: PATObject.h:485
const TriggerObjectStandAloneCollection triggerObjectMatchesByCollection(const std::string &coll) const
get all matched trigger objects from a certain collection
Definition: PATObject.h:580
double resolPx(const LorentzVector &p4) const
Resolution on px, given the 4-momentum of the associated Candidate.
JetCorrectorParametersCollection coll
Definition: classes.h:10
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const std::string &nameAlgorithm, const unsigned algoCondAccepted) const
Definition: PATObject.h:138
const pat::UserData * userDataObject_(const std::string &key) const
Definition: PATObject.h:849
bool hasFilterLabel(const std::string &filterLabel) const
Checks, if a certain HLT filter label is assigned.
bool hasConditionName(const std::string &conditionName) const
Checks, if a certain L1 condition name is assigned.
virtual UserData * clone() const =0
Necessary for deep copy in OwnVector.
int32_t userInt(const std::string &key) const
Definition: PATObject.h:913
const TriggerObjectStandAlone * triggerObjectMatchByType(const unsigned triggerObjectType, const size_t idx=0) const
Definition: PATObject.h:92
void addTriggerObjectMatch(const TriggerObjectStandAlone &trigObj)
add a trigger match
Definition: PATObject.h:243
const std::vector< std::string > & userDataNames() const
Get list of user data object names.
Definition: PATObject.h:339
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const std::string &nameAlgorithm, const unsigned algoCondAccepted, const size_t idx=0) const
Definition: PATObject.h:160
const TriggerObjectStandAloneCollection & triggerObjectMatches() const
get all matched trigger objects
Definition: PATObject.h:75
const void * userDataBare(const std::string &key) const
Definition: PATObject.h:343
reco::CandidatePtr userCand(const std::string &key) const
Definition: PATObject.h:950
const TriggerObjectStandAlone * triggerObjectMatchByCollection(const char *coll, const size_t idx=0) const
Definition: PATObject.h:110
const TriggerObjectStandAloneCollection triggerObjectMatchesByType(const unsigned triggerObjectType) const
Definition: PATObject.h:82
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
const TriggerObjectStandAlone * triggerObjectMatchByCondition(const std::string &nameCondition, const size_t idx=0) const
get one matched L1 object used in a succeeding object combination of a certain L1 condition by index ...
Definition: PATObject.h:617
double resolE(const LorentzVector &p4) const
Resolution on energy, given the 4-momentum of the associated Candidate.
const TriggerObjectStandAloneCollection triggerObjectMatchesByType(const trigger::TriggerObjectType triggerObjectType) const
Definition: PATObject.h:555
const TriggerObjectStandAloneCollection triggerObjectMatchesByCollection(const char *coll) const
Definition: PATObject.h:104
const TriggerObjectStandAloneCollection triggerObjectMatchesByCondition(const std::string &nameCondition) const
get all matched L1 objects used in a succeeding object combination of a certain L1 condition ...
Definition: PATObject.h:606
float userFloat(const char *key) const
a CINT-friendly interface
Definition: PATObject.h:371
int status() const final
status word
const pat::LookupTableRecord & efficiency(const std::string &name) const
Returns an efficiency given its name.
Definition: PATObject.h:711
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1) const
Definition: PATObject.h:199
const reco::Candidate * originalObject() const
access to the original object; returns zero for null Ref and throws for unavailable collection ...
Definition: PATObject.h:527
Templated PAT object container.
Definition: PATObject.h:48
const pat::CandKinResolution & getKinResolution(const std::string &label="") const
Definition: PATObject.h:976
const TriggerObjectStandAlone * triggerObjectMatchByType(const trigger::TriggerObjectType triggerObjectType, const size_t idx=0) const
get one matched trigger object of a certain type by index
Definition: PATObject.h:566
double resolTheta(const std::string &label="") const
Resolution on theta, possibly with a label to specify which resolution to use.
Definition: PATObject.h:428
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
Base class for data that users can add to pat objects.
Definition: UserData.h:23
std::vector< int > userIntRange(const std::string &key) const
returns a range of values corresponding to key
Definition: PATObject.h:923
std::vector< std::string > overlapLabels_
Overlapping test labels (only if there are any overlaps)
Definition: PATObject.h:479
double resolEt(const LorentzVector &p4) const
Resolution on et, given the 4-momentum of the associated Candidate.
const std::vector< std::string > & userFloatNames() const
Get list of user-defined float names.
Definition: PATObject.h:376
double resolPt(const LorentzVector &p4) const
Resolution on pt, given the 4-momentum of the associated Candidate.
static const reco::CandidatePtrVector EMPTY_CPV
Definition: PATObject.h:43
std::vector< int32_t > userInts_
Definition: PATObject.h:491
const TriggerObjectStandAloneCollection triggerObjectMatchesByFilter(const char *labelFilter) const
Definition: PATObject.h:174
long double T
const std::vector< std::string > & userIntNames() const
Get list of user-defined int names.
Definition: PATObject.h:393
void insert(const_iterator i, D *&d)
Definition: OwnVector.h:395
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const char *nameAlgorithm, const unsigned algoCondAccepted) const
Definition: PATObject.h:143
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:463
void addUserData(const std::string &label, const T &data, bool transientOnly=false, bool overwrite=false)
Definition: PATObject.h:353
double resolM(const std::string &label="") const
Definition: PATObject.h:459
reco::GenParticleRef genParticleById(int pdgId, int status, uint8_t autoCharge=0) const
Definition: PATObject.h:795
def move(src, dest)
Definition: eostools.py:511
void addUserDataFromPtr(const std::string &label, const edm::Ptr< pat::UserData > &data, bool overwrite=false)
Definition: PATObject.h:360
const void * bareData() const
Definition: UserData.h:50
double resolEta(const std::string &label="") const
Resolution on eta, possibly with a label to specify which resolution to use.
Definition: PATObject.h:425
const std::string & userDataObjectType(const std::string &key) const
Get human-readable type of user data object, for debugging.
Definition: PATObject.h:334
const std::vector< std::string > & efficiencyNames() const
Returns the list of the names of the stored efficiencies.
Definition: PATObject.h:260
Analysis-level trigger object class (stand-alone)
double resolTheta(const LorentzVector &p4) const
Resolution on theta, given the 4-momentum of the associated Candidate.
std::vector< std::string > userIntLabels_
Definition: PATObject.h:490
const std::vector< std::string > & overlapLabels() const
Returns the labels of the overlap tests that found at least one overlap.
Definition: PATObject.h:319