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;
69 
73 
77  const TriggerObjectStandAlone *triggerObjectMatch(const size_t idx = 0) const;
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  };
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  };
103  // for RooT command line
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 {
112  };
115  // for RooT command line
117  return triggerObjectMatchesByCondition(std::string(nameCondition));
118  };
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  };
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  };
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  };
173  // for RooT command line
175  return triggerObjectMatchesByFilter(std::string(labelFilter));
176  };
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  };
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 {
209  std::string(namePath), bool(pathLastFilterAccepted), bool(pathL3FilterAccepted));
210  };
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 {
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(),
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_; }
267 
271  if (idx >= genParticlesSize())
272  return reco::GenParticleRef();
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 {
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_; }
324 
326  template <typename T>
327  const T *userData(const std::string &key) const {
329  return (data != nullptr ? data->template get<T>() : nullptr);
330  }
332  bool hasUserData(const std::string &key) const { return (userDataObject_(key) != nullptr); }
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 {
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());
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 
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 
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>
524  PATObject<ObjectType>::PATObject(const edm::Ptr<ObjectType> &ref) : ObjectType(*ref), refToOrig_(ref) {}
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;
550  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, idx);
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;
575  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
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) {
584  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasCollection(coll))
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;
601  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
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;
626  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
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;
652  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
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;
677  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
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;
706  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
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)
752  embedGenParticle();
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) {
789  ret[i] = reco::GenParticleRef(&genParticleEmbedded_, 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;
833  return overlapItems_[std::distance(overlapLabels_.begin(), match)];
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);
865  userDataObjects_.insert(userDataObjects_.begin() + dist, std::move(data));
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);
871  userDataObjects_.insert(userDataObjects_.begin() + dist + 1, std::move(data));
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
trigger::TriggerObjectType
TriggerObjectType
Definition: TriggerTypeDefs.h:23
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
pat::PATObject::efficiencyValues
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
pat::PATObject::setOverlaps
void setOverlaps(const std::string &label, const reco::CandidatePtrVector &overlaps)
Definition: PATObject.h:837
pat::UserData
Base class for data that users can add to pat objects.
Definition: UserData.h:23
pat::CandKinResolution::resolP
double resolP(const LorentzVector &p4) const
Resolution on p, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:44
embed
#define embed
Definition: AMPTWrapper.h:188
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
reco::GenParticleRef
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
Definition: GenParticleFwd.h:17
pat::PATObject::overlapLabels
const std::vector< std::string > & overlapLabels() const
Returns the labels of the overlap tests that found at least one overlap.
Definition: PATObject.h:319
muonClassificationByHits_cfi.addGenParticleRef
def addGenParticleRef(patMuonProducer, label='classByHitsGlbOrTrk')
Definition: muonClassificationByHits_cfi.py:75
pat::throwMissingLabel
void throwMissingLabel(const std::string &what, const std::string &bad_label, const std::vector< std::string > &available)
Definition: throwMissingLabel.cc:7
pat::PATObject::efficiencyValues_
std::vector< pat::LookupTableRecord > efficiencyValues_
vector of the efficiencies (values)
Definition: PATObject.h:469
mps_fire.i
i
Definition: mps_fire.py:355
pat::PATObject::userDataBare
const void * userDataBare(const std::string &key) const
Definition: PATObject.h:343
pat::PATObject::triggerObjectMatchByPath
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
MessageLogger.h
pat::PATObject::triggerObjectMatches
const TriggerObjectStandAloneCollection & triggerObjectMatches() const
get all matched trigger objects
Definition: PATObject.h:75
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
pat::PATObject::triggerObjectMatchesByFilterID
const TriggerObjectStandAloneCollection triggerObjectMatchesByFilterID(const unsigned triggerObjectType) const
Definition: PATObject.h:86
pat::PATObject::hasUserData
bool hasUserData(const std::string &key) const
Check if user data with a specific type is present.
Definition: PATObject.h:332
pat::PATObject::userData
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
pat::PATObject::addTriggerObjectMatch
void addTriggerObjectMatch(const TriggerObjectStandAlone &trigObj)
add a trigger match
Definition: PATObject.h:243
pat::PATObject::triggerObjectMatchByAlgorithm
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const char *nameAlgorithm, const bool algoCondAccepted=true, const size_t idx=0) const
Definition: PATObject.h:154
pat::PATObject::triggerObjectMatchesByType
const TriggerObjectStandAloneCollection triggerObjectMatchesByType(const trigger::TriggerObjectType triggerObjectType) const
Definition: PATObject.h:555
cropTnPTrees.cloned
cloned
Definition: cropTnPTrees.py:37
pat::PATObject::triggerObjectMatchByFilter
const TriggerObjectStandAlone * triggerObjectMatchByFilter(const char *labelFilter, const size_t idx=0) const
Definition: PATObject.h:181
pat::PATObject::kinResolutionLabels_
std::vector< std::string > kinResolutionLabels_
Definition: PATObject.h:500
pat::PATObject::resolPInv
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
reco::GenParticle
Definition: GenParticle.h:21
mps_update.status
status
Definition: mps_update.py:69
pat::PATObject::genParticleById
reco::GenParticleRef genParticleById(int pdgId, int status, uint8_t autoCharge=0) const
Definition: PATObject.h:795
pat::TriggerObjectStandAlone
Analysis-level trigger object class (stand-alone)
Definition: TriggerObjectStandAlone.h:32
pat::CandKinResolution::resolPx
double resolPx(const LorentzVector &p4) const
Resolution on px, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:53
pat::PATObject::triggerObjectMatchByFilter
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
pat::PATObject::base_type
ObjectType base_type
Definition: PATObject.h:50
pat::CandKinResolution::resolPhi
double resolPhi(const LorentzVector &p4) const
Resolution on phi, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:32
pat::PATObject::triggerObjectMatchesByAlgorithm
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const std::string &nameAlgorithm, const bool algoCondAccepted=true) const
Definition: PATObject.h:631
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
pat::CandKinResolution::resolPInv
double resolPInv(const LorentzVector &p4) const
Resolution on 1/p, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:50
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
charmTagsComputerCvsB_cfi.idx
idx
Definition: charmTagsComputerCvsB_cfi.py:108
pat::PATObject::genParticlesSize
size_t genParticlesSize() const
Number of generator level particles stored as ref or embedded.
Definition: PATObject.h:295
CandKinResolution.h
pat::PATObject::addGenParticleRef
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:756
pat::PATObject::addUserInt
void addUserInt(const std::string &label, int32_t data, const bool overwrite=false)
Set user-defined int.
Definition: PATObject.h:934
pat::PATObject::triggerObjectMatchByAlgorithm
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const std::string &nameAlgorithm, const bool algoCondAccepted=true, const size_t idx=0) const
Definition: PATObject.h:642
pat::PATObject::hasOverlaps
bool hasOverlaps(const std::string &label) const
Returns true if there was at least one overlap for this test label.
Definition: PATObject.h:823
L1TObjectsTimingClient_cff.efficiency
efficiency
Definition: L1TObjectsTimingClient_cff.py:10
pat::PATObject::resolPhi
double resolPhi(const std::string &label="") const
Resolution on phi, possibly with a label to specify which resolution to use.
Definition: PATObject.h:431
pat::PATObject::efficiencies
std::vector< std::pair< std::string, pat::LookupTableRecord > > efficiencies() const
Returns the efficiencies as <name,value> pairs (by value)
Definition: PATObject.h:721
pat::PATObject::userFloat
float userFloat(const std::string &key) const
Definition: PATObject.h:876
pat::PATObject::userIntRange
std::vector< int > userIntRange(const std::string &key) const
returns a range of values corresponding to key
Definition: PATObject.h:923
pat::PATObject::triggerObjectMatchByCondition
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
pat::PATObject::hasUserCand
bool hasUserCand(const std::string &key) const
Return true if there is a user-defined int with a given name.
Definition: PATObject.h:408
pat::PATObject::triggerObjectMatchesByCondition
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
end
#define end
Definition: vmac.h:39
edm::Ref< GenParticleCollection >
pat::PATObject::userDataObjects_
pat::UserDataCollection userDataObjects_
Definition: PATObject.h:485
GenParticle.h
CandidateFwd.h
pat::PATObject::addUserDataFromPtr
void addUserDataFromPtr(const std::string &label, const edm::Ptr< pat::UserData > &data, bool overwrite=false)
Definition: PATObject.h:360
pat::PATObject::triggerObjectMatchesByFilter
const TriggerObjectStandAloneCollection triggerObjectMatchesByFilter(const char *labelFilter) const
Definition: PATObject.h:174
pat::PATObject::overlapLabels_
std::vector< std::string > overlapLabels_
Overlapping test labels (only if there are any overlaps)
Definition: PATObject.h:479
edm::errors::ProductNotFound
Definition: EDMException.h:33
pat::PATObject::userInts_
std::vector< int32_t > userInts_
Definition: PATObject.h:491
pat::PATObject::triggerObjectMatchByCollection
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
pat::PATObject::resolTheta
double resolTheta(const std::string &label="") const
Resolution on theta, possibly with a label to specify which resolution to use.
Definition: PATObject.h:428
pat::PATObject::resolP
double resolP(const std::string &label="") const
Resolution on p, possibly with a label to specify which resolution to use.
Definition: PATObject.h:440
pat::PATObject::refToOrig_
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:463
edm::PtrVector< Candidate >
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:122
pat::CandKinResolution::resolPy
double resolPy(const LorentzVector &p4) const
Resolution on py, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:56
pat::PATObject::triggerObjectMatchesByFilter
const TriggerObjectStandAloneCollection triggerObjectMatchesByFilter(const std::string &labelFilter) const
get all matched HLT objects used in a certain HLT filter
Definition: PATObject.h:657
pat::PATObject::genParticleRefs
std::vector< reco::GenParticleRef > genParticleRefs() const
Definition: PATObject.h:784
pat::PATObject::overlaps
const reco::CandidatePtrVector & overlaps(const std::string &label) const
Definition: PATObject.h:829
pat::PATObject::addUserData
void addUserData(const std::string &label, const T &data, bool transientOnly=false, bool overwrite=false)
Definition: PATObject.h:353
pat::PATObject::triggerObjectMatchByFilterID
const TriggerObjectStandAlone * triggerObjectMatchByFilterID(const unsigned triggerObjectType, const size_t idx=0) const
Definition: PATObject.h:97
pat::PATObject::hasUserFloat
bool hasUserFloat(const std::string &key) const
Return true if there is a user-defined float with a given name.
Definition: PATObject.h:378
pat::pat_statics::EMPTY_STR
static const std::string EMPTY_STR("")
pat::PATObject
Templated PAT object container.
Definition: PATObject.h:48
pat::PATObject::resolPy
double resolPy(const std::string &label="") const
Resolution on py, possibly with a label to specify which resolution to use.
Definition: PATObject.h:452
pat::PATObject::triggerObjectMatchByCondition
const TriggerObjectStandAlone * triggerObjectMatchByCondition(const char *nameCondition, const size_t idx=0) const
Definition: PATObject.h:123
pat::PATObject::userCand
reco::CandidatePtr userCand(const std::string &key) const
Definition: PATObject.h:950
pat::PATObject::~PATObject
~PATObject() override
destructor
Definition: PATObject.h:61
pat::PATObject::userFloatRange
std::vector< float > userFloatRange(const std::string &key) const
return a range of values corresponding to key
Definition: PATObject.h:886
pat::PATObject::triggerObjectMatchByAlgorithm
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const std::string &nameAlgorithm, const unsigned algoCondAccepted, const size_t idx=0) const
Definition: PATObject.h:160
pat::CandKinResolution::resolM
double resolM(const LorentzVector &p4) const
Definition: CandKinResolution.cc:41
pat::PATObject::hasUserFloat
bool hasUserFloat(const char *key) const
a CINT-friendly interface
Definition: PATObject.h:383
pat::PATObject::addUserDataObject_
void addUserDataObject_(const std::string &label, std::unique_ptr< pat::UserData > value, bool overwrite=false)
Definition: PATObject.h:858
pat::PATObject::addUserCand
void addUserCand(const std::string &label, const reco::CandidatePtr &data, const bool overwrite=false)
Set user-defined int.
Definition: PATObject.h:959
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
throwMissingLabel.h
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
pat::CandKinResolution
Definition: CandKinResolution.h:10
pat::PATObject::triggerObjectMatchByAlgorithm
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const char *nameAlgorithm, const unsigned algoCondAccepted, const size_t idx=0) const
Definition: PATObject.h:166
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pat::PATObject::efficiency
const pat::LookupTableRecord & efficiency(const std::string &name) const
Returns an efficiency given its name.
Definition: PATObject.h:711
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
analyzePatCleaning_cfg.overlaps
overlaps
Definition: analyzePatCleaning_cfg.py:9
pat::PATObject::originalObjectRef
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:542
pat::PATObject::hasUserInt
bool hasUserInt(const std::string &key) const
Return true if there is a user-defined int with a given name.
Definition: PATObject.h:395
pat::PATObject::userCands_
std::vector< reco::CandidatePtr > userCands_
Definition: PATObject.h:494
pat::PATObject::triggerObjectMatchByPath
const TriggerObjectStandAlone * triggerObjectMatchByPath(const std::string &namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1, const size_t idx=0) const
Definition: PATObject.h:228
pat::PATObject::userIntLabels_
std::vector< std::string > userIntLabels_
Definition: PATObject.h:490
pat::PATObject::triggerObjectMatchesByAlgorithm
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const std::string &nameAlgorithm, const unsigned algoCondAccepted) const
Definition: PATObject.h:138
pat::PATObject::userFloat
float userFloat(const char *key) const
a CINT-friendly interface
Definition: PATObject.h:371
ecaldqm::binning::ObjectType
ObjectType
Definition: MESetBinningUtils.h:17
pat::PATObject::userDataObjectType
const std::string & userDataObjectType(const std::string &key) const
Get human-readable type of user data object, for debugging.
Definition: PATObject.h:334
pat::PATObject::triggerObjectMatch
const TriggerObjectStandAlone * triggerObjectMatch(const size_t idx=0) const
get one matched trigger object by index
Definition: PATObject.h:547
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
pat::PATObject::genParticleRef_
std::vector< reco::GenParticleRef > genParticleRef_
Reference to a generator level particle.
Definition: PATObject.h:474
UserData.h
pat::CandKinResolution::resolPt
double resolPt(const LorentzVector &p4) const
Resolution on pt, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:47
pat::PATObject::triggerObjectMatchesByCollection
const TriggerObjectStandAloneCollection triggerObjectMatchesByCollection(const std::string &coll) const
get all matched trigger objects from a certain collection
Definition: PATObject.h:580
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
pat::PATObject::userDataObject_
const pat::UserData * userDataObject_(const std::string &key) const
Definition: PATObject.h:849
electronProducer_cfi.efficiencies
efficiencies
Definition: electronProducer_cfi.py:76
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
Ptr.h
pat::PATObject::setGenParticle
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
pat::PATObject::addUserFloat
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:897
pat::PATObject::resolPt
double resolPt(const std::string &label="") const
Resolution on pt, possibly with a label to specify which resolution to use.
Definition: PATObject.h:443
pat::TriggerObjectStandAloneCollection
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
Definition: TriggerObjectStandAlone.h:219
pat::PATObject::resolPx
double resolPx(const std::string &label="") const
Resolution on px, possibly with a label to specify which resolution to use.
Definition: PATObject.h:449
p4
double p4[4]
Definition: TauolaWrapper.h:92
value
Definition: value.py:1
pat::PATObject::userFloatNames
const std::vector< std::string > & userFloatNames() const
Get list of user-defined float names.
Definition: PATObject.h:376
pat::PATObject::efficiencyNames_
std::vector< std::string > efficiencyNames_
vector of the efficiencies (names)
Definition: PATObject.h:471
pat::PATObject::triggerObjectMatchesByPath
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:682
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
pat::CandKinResolution::resolE
double resolE(const LorentzVector &p4) const
Resolution on energy, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:35
pat
Definition: HeavyIon.h:7
pat::PATObject::genParticleEmbedded_
std::vector< reco::GenParticle > genParticleEmbedded_
vector to hold an embedded generator level particle
Definition: PATObject.h:476
pat::PATObject::triggerObjectMatchByPath
const TriggerObjectStandAlone * triggerObjectMatchByPath(const char *namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1, const size_t idx=0) const
Definition: PATObject.h:235
pat::PATObject::triggerObjectMatchesByAlgorithm
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const char *nameAlgorithm, const bool algoCondAccepted=true) const
Definition: PATObject.h:133
pat::PATObject::triggerObjectMatchByType
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
pat::PATObject::setGenParticleRef
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
Definition: PATObject.h:748
get
#define get
pat::PATObject::resolEta
double resolEta(const std::string &label="") const
Resolution on eta, possibly with a label to specify which resolution to use.
Definition: PATObject.h:425
pat::PATObject::efficiencyNames
const std::vector< std::string > & efficiencyNames() const
Returns the list of the names of the stored efficiencies.
Definition: PATObject.h:260
pat::PATObject::PATObject
PATObject()
default constructor
Definition: PATObject.h:509
pat::PATObject::kinResolutions_
std::vector< pat::CandKinResolution > kinResolutions_
Kinematic resolutions.
Definition: PATObject.h:497
edm::Ptr
Definition: AssociationVector.h:31
reco::Candidate
Definition: Candidate.h:27
pat::PATObject::originalObject
const reco::Candidate * originalObject() const
access to the original object; returns zero for null Ref and throws for unavailable collection
Definition: PATObject.h:527
pat::PATObject::triggerObjectMatchesByPath
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const char *namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:193
pat::PATObject::triggerObjectMatchesByCollection
const TriggerObjectStandAloneCollection triggerObjectMatchesByCollection(const char *coll) const
Definition: PATObject.h:104
pat::PATObject::userCandLabels_
std::vector< std::string > userCandLabels_
Definition: PATObject.h:493
pat::PATObject::triggerObjectMatchesByType
const TriggerObjectStandAloneCollection triggerObjectMatchesByType(const unsigned triggerObjectType) const
Definition: PATObject.h:82
pat::PATObject::setEfficiency
void setEfficiency(const std::string &name, const pat::LookupTableRecord &value)
Definition: PATObject.h:732
pat::PATObject::resolM
double resolM(const std::string &label="") const
Definition: PATObject.h:459
pat::CandKinResolution::resolTheta
double resolTheta(const LorentzVector &p4) const
Resolution on theta, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:29
pat::pat_statics::EMPTY_CPV
static const reco::CandidatePtrVector EMPTY_CPV
Definition: PATObject.h:43
eostools.move
def move(src, dest)
Definition: eostools.py:511
pat::CandKinResolution::resolPz
double resolPz(const LorentzVector &p4) const
Resolution on pz, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:59
pat::PATObject::triggerObjectMatchesByPath
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const char *namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1) const
Definition: PATObject.h:205
pat::PATObject::resolPz
double resolPz(const std::string &label="") const
Resolution on pz, possibly with a label to specify which resolution to use.
Definition: PATObject.h:455
pat::PATObject::triggerObjectMatchByPath
const TriggerObjectStandAlone * triggerObjectMatchByPath(const char *namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true, const size_t idx=0) const
Definition: PATObject.h:221
pat::PATObject::genParticle
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:290
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.value
value
Definition: relativeConstraints.py:53
Exception
Definition: hltDiff.cc:246
pat::PATObject::hasKinResolution
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
edm::TriggerNames
Definition: TriggerNames.h:55
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
pat::PATObject::userIntNames
const std::vector< std::string > & userIntNames() const
Get list of user-defined int names.
Definition: PATObject.h:393
pat::PATObject::resolEt
double resolEt(const std::string &label="") const
Resolution on et, possibly with a label to specify which resolution to use.
Definition: PATObject.h:437
edm::RefToBase
Definition: AssociativeIterator.h:54
pat::PATObject::triggerObjectMatchesByPath
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1) const
Definition: PATObject.h:199
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
patCandidatesForDimuonsSequences_cff.matches
matches
Definition: patCandidatesForDimuonsSequences_cff.py:131
pat::PATObject::triggerObjectMatchesEmbedded_
TriggerObjectStandAloneCollection triggerObjectMatchesEmbedded_
vector of trigger matches
Definition: PATObject.h:466
pat::PATObject::userDataLabels_
std::vector< std::string > userDataLabels_
User data object.
Definition: PATObject.h:484
mps_fire.result
result
Definition: mps_fire.py:303
cms::Exception
Definition: Exception.h:70
Candidate.h
reco::CandidatePtr
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
OwnVector.h
pat::PATObject::triggerObjectMatchByType
const TriggerObjectStandAlone * triggerObjectMatchByType(const unsigned triggerObjectType, const size_t idx=0) const
Definition: PATObject.h:92
pat::PATObject::triggerObjectMatchesByCondition
const TriggerObjectStandAloneCollection triggerObjectMatchesByCondition(const char *nameCondition) const
Definition: PATObject.h:116
pat::PATObject::userInt
int32_t userInt(const std::string &key) const
Definition: PATObject.h:913
pat::PATObject::embedGenParticle
void embedGenParticle()
Definition: PATObject.h:773
pat::PATObject::unpackTriggerObjectPathNames
void unpackTriggerObjectPathNames(const edm::TriggerNames &names)
unpack path names of matched trigger objects (if they were packed before embedding,...
Definition: PATObject.h:247
crabWrapper.key
key
Definition: crabWrapper.py:19
pat::CandKinResolution::resolEta
double resolEta(const LorentzVector &p4) const
Resolution on eta, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:26
pfClustersFromCombinedCaloHCal_cfi.resol
resol
Definition: pfClustersFromCombinedCaloHCal_cfi.py:47
TriggerObjectStandAlone.h
pat::LookupTableRecord
Class to store the result of a lookup table fetch, e.g. for efficiencies.
Definition: LookupTableRecord.h:19
pat::PATObject::triggerObjectMatchByCollection
const TriggerObjectStandAlone * triggerObjectMatchByCollection(const char *coll, const size_t idx=0) const
Definition: PATObject.h:110
pat::PATObject::triggerObjectMatchesByAlgorithm
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const char *nameAlgorithm, const unsigned algoCondAccepted) const
Definition: PATObject.h:143
label
const char * label
Definition: PFTauDecayModeTools.cc:11
pat::PATObject::genParticleRef
reco::GenParticleRef genParticleRef(size_t idx=0) const
Definition: PATObject.h:270
pat::PATObject::userDataNames
const std::vector< std::string > & userDataNames() const
Get list of user data object names.
Definition: PATObject.h:339
pat::CandKinResolution::resolEt
double resolEt(const LorentzVector &p4) const
Resolution on et, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:38
pat::PATObject::userFloatLabels_
std::vector< std::string > userFloatLabels_
Definition: PATObject.h:487
g
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
edm::OwnVector< pat::UserData >
pat::PATObject::resolE
double resolE(const std::string &label="") const
Resolution on energy, possibly with a label to specify which resolution to use.
Definition: PATObject.h:434
pat::PATObject::userFloats_
std::vector< float > userFloats_
Definition: PATObject.h:488
pat::PATObject::getKinResolution
const pat::CandKinResolution & getKinResolution(const std::string &label="") const
Definition: PATObject.h:976
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
LookupTableRecord.h
pat::PATObject::userCandNames
const std::vector< std::string > & userCandNames() const
Get list of user-defined cand names.
Definition: PATObject.h:406
pat::PATObject::overlapItems_
std::vector< reco::CandidatePtrVector > overlapItems_
Overlapping items (sorted by distance)
Definition: PATObject.h:481
pat::PATObject::setKinResolution
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