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 {
42  const std::string &get_empty_str();
43 
44  template <class ObjectType>
45  class PATObject : public ObjectType {
46  public:
48 
50  PATObject();
52  PATObject(const ObjectType &obj);
56  PATObject(const edm::Ptr<ObjectType> &ref);
58  ~PATObject() override {}
59  // returns a clone // NO: ObjectType can be an abstract type like reco::Candidate
60  // virtual PATObject<ObjectType> * clone() const ; // for which the clone() can't be defined
61 
63  const reco::Candidate *originalObject() const;
66 
70 
74  const TriggerObjectStandAlone *triggerObjectMatch(const size_t idx = 0) const;
78  const trigger::TriggerObjectType triggerObjectType) const;
79  const TriggerObjectStandAloneCollection triggerObjectMatchesByType(const unsigned triggerObjectType) const {
80  return triggerObjectMatchesByType(trigger::TriggerObjectType(triggerObjectType));
81  };
82  // for backward compatibility
83  const TriggerObjectStandAloneCollection triggerObjectMatchesByFilterID(const unsigned triggerObjectType) const {
84  return triggerObjectMatchesByType(trigger::TriggerObjectType(triggerObjectType));
85  };
88  const size_t idx = 0) const;
89  const TriggerObjectStandAlone *triggerObjectMatchByType(const unsigned triggerObjectType,
90  const size_t idx = 0) const {
91  return triggerObjectMatchByType(trigger::TriggerObjectType(triggerObjectType), idx);
92  };
93  // for backward compatibility
94  const TriggerObjectStandAlone *triggerObjectMatchByFilterID(const unsigned triggerObjectType,
95  const size_t idx = 0) const {
96  return triggerObjectMatchByType(trigger::TriggerObjectType(triggerObjectType), idx);
97  };
100  // for RooT command line
103  };
105  const TriggerObjectStandAlone *triggerObjectMatchByCollection(const std::string &coll, const size_t idx = 0) const;
106  // for RooT command line
107  const TriggerObjectStandAlone *triggerObjectMatchByCollection(const char *coll, const size_t idx = 0) const {
109  };
112  // for RooT command line
114  return triggerObjectMatchesByCondition(std::string(nameCondition));
115  };
118  const size_t idx = 0) const;
119  // for RooT command line
120  const TriggerObjectStandAlone *triggerObjectMatchByCondition(const char *nameCondition,
121  const size_t idx = 0) const {
122  return triggerObjectMatchByCondition(std::string(nameCondition), idx);
123  };
128  const bool algoCondAccepted = true) const;
129  // for RooT command line
131  const bool algoCondAccepted = true) const {
132  return triggerObjectMatchesByAlgorithm(std::string(nameAlgorithm), algoCondAccepted);
133  };
134  // for the cut string parser
136  const unsigned algoCondAccepted) const {
137  return triggerObjectMatchesByAlgorithm(nameAlgorithm, bool(algoCondAccepted));
138  };
139  // for RooT command line and the cut string parser
141  const unsigned algoCondAccepted) const {
142  return triggerObjectMatchesByAlgorithm(std::string(nameAlgorithm), bool(algoCondAccepted));
143  };
148  const bool algoCondAccepted = true,
149  const size_t idx = 0) const;
150  // for RooT command line
151  const TriggerObjectStandAlone *triggerObjectMatchByAlgorithm(const char *nameAlgorithm,
152  const bool algoCondAccepted = true,
153  const size_t idx = 0) const {
154  return triggerObjectMatchByAlgorithm(std::string(nameAlgorithm), algoCondAccepted, idx);
155  };
156  // for the cut string parser
158  const unsigned algoCondAccepted,
159  const size_t idx = 0) const {
160  return triggerObjectMatchByAlgorithm(nameAlgorithm, bool(algoCondAccepted), idx);
161  };
162  // for RooT command line and the cut string parser
163  const TriggerObjectStandAlone *triggerObjectMatchByAlgorithm(const char *nameAlgorithm,
164  const unsigned algoCondAccepted,
165  const size_t idx = 0) const {
166  return triggerObjectMatchByAlgorithm(std::string(nameAlgorithm), bool(algoCondAccepted), idx);
167  };
170  // for RooT command line
172  return triggerObjectMatchesByFilter(std::string(labelFilter));
173  };
176  const size_t idx = 0) const;
177  // for RooT command line
178  const TriggerObjectStandAlone *triggerObjectMatchByFilter(const char *labelFilter, const size_t idx = 0) const {
179  return triggerObjectMatchByFilter(std::string(labelFilter), idx);
180  };
187  const bool pathLastFilterAccepted = false,
188  const bool pathL3FilterAccepted = true) const;
189  // for RooT command line
191  const bool pathLastFilterAccepted = false,
192  const bool pathL3FilterAccepted = true) const {
193  return triggerObjectMatchesByPath(std::string(namePath), pathLastFilterAccepted, pathL3FilterAccepted);
194  };
195  // for the cut string parser
197  const unsigned pathLastFilterAccepted,
198  const unsigned pathL3FilterAccepted = 1) const {
199  return triggerObjectMatchesByPath(namePath, bool(pathLastFilterAccepted), bool(pathL3FilterAccepted));
200  };
201  // for RooT command line and the cut string parser
203  const unsigned pathLastFilterAccepted,
204  const unsigned pathL3FilterAccepted = 1) const {
206  std::string(namePath), bool(pathLastFilterAccepted), bool(pathL3FilterAccepted));
207  };
214  const bool pathLastFilterAccepted = false,
215  const bool pathL3FilterAccepted = true,
216  const size_t idx = 0) const;
217  // for RooT command line
219  const bool pathLastFilterAccepted = false,
220  const bool pathL3FilterAccepted = true,
221  const size_t idx = 0) const {
222  return triggerObjectMatchByPath(std::string(namePath), pathLastFilterAccepted, pathL3FilterAccepted, idx);
223  };
224  // for the cut string parser
226  const unsigned pathLastFilterAccepted,
227  const unsigned pathL3FilterAccepted = 1,
228  const size_t idx = 0) const {
229  return triggerObjectMatchByPath(namePath, bool(pathLastFilterAccepted), bool(pathL3FilterAccepted), idx);
230  };
231  // for RooT command line and the cut string parser
233  const unsigned pathLastFilterAccepted,
234  const unsigned pathL3FilterAccepted = 1,
235  const size_t idx = 0) const {
237  std::string(namePath), bool(pathLastFilterAccepted), bool(pathL3FilterAccepted), idx);
238  };
241  triggerObjectMatchesEmbedded_.push_back(trigObj);
242  };
245  for (std::vector<TriggerObjectStandAlone>::iterator it = triggerObjectMatchesEmbedded_.begin(),
247  it != ed;
248  ++it)
249  it->unpackPathNames(names);
250  }
251 
253  const pat::LookupTableRecord &efficiency(const std::string &name) const;
255  std::vector<std::pair<std::string, pat::LookupTableRecord> > efficiencies() const;
257  const std::vector<std::string> &efficiencyNames() const { return efficiencyNames_; }
259  const std::vector<pat::LookupTableRecord> &efficiencyValues() const { return efficiencyValues_; }
264 
268  if (idx >= genParticlesSize())
269  return reco::GenParticleRef();
271  }
282  // implementation note: uint8_t instead of bool, because the string parser doesn't allow bool currently
283  reco::GenParticleRef genParticleById(int pdgId, int status, uint8_t autoCharge = 0) const;
284 
287  const reco::GenParticle *genParticle(size_t idx = 0) const {
289  return ref.isNonnull() ? ref.get() : nullptr;
290  }
292  size_t genParticlesSize() const {
293  return genParticleEmbedded_.empty() ? genParticleRef_.size() : genParticleEmbedded_.size();
294  }
297  std::vector<reco::GenParticleRef> genParticleRefs() const;
298 
300  void setGenParticleRef(const reco::GenParticleRef &ref, bool embed = false);
303  void addGenParticleRef(const reco::GenParticleRef &ref);
305  void setGenParticle(const reco::GenParticle &particle);
308  void embedGenParticle();
309 
311  bool hasOverlaps(const std::string &label) const;
314  const reco::CandidatePtrVector &overlaps(const std::string &label) const;
316  const std::vector<std::string> &overlapLabels() const { return overlapLabels_; }
321 
323  template <typename T>
324  const T *userData(const std::string &key) const {
326  return (data != nullptr ? data->template get<T>() : nullptr);
327  }
329  bool hasUserData(const std::string &key) const { return (userDataObject_(key) != nullptr); }
333  return (data != nullptr ? data->typeName() : get_empty_str());
334  };
336  const std::vector<std::string> &userDataNames() const { return userDataLabels_; }
337 
340  const void *userDataBare(const std::string &key) const {
342  return (data != nullptr ? data->bareData() : nullptr);
343  }
344 
349  template <typename T>
350  void addUserData(const std::string &label, const T &data, bool transientOnly = false, bool overwrite = false) {
351  std::unique_ptr<pat::UserData> made(pat::UserData::make<T>(data, transientOnly));
352  addUserDataObject_(label, std::move(made), overwrite);
353  }
354 
357  void addUserDataFromPtr(const std::string &label, const edm::Ptr<pat::UserData> &data, bool overwrite = false) {
358  std::unique_ptr<pat::UserData> cloned(data->clone());
360  }
361 
364  float userFloat(const std::string &key) const;
366  std::vector<float> userFloatRange(const std::string &key) const;
368  float userFloat(const char *key) const { return userFloat(std::string(key)); }
369 
371  void addUserFloat(const std::string &label, float data, const bool overwrite = false);
373  const std::vector<std::string> &userFloatNames() const { return userFloatLabels_; }
375  bool hasUserFloat(const std::string &key) const {
376  auto it = std::lower_bound(userFloatLabels_.cbegin(), userFloatLabels_.cend(), key);
377  return (it != userFloatLabels_.cend() && *it == key);
378  }
380  bool hasUserFloat(const char *key) const { return hasUserFloat(std::string(key)); }
381 
384  int32_t userInt(const std::string &key) const;
386  std::vector<int> userIntRange(const std::string &key) const;
388  void addUserInt(const std::string &label, int32_t data, const bool overwrite = false);
390  const std::vector<std::string> &userIntNames() const { return userIntLabels_; }
392  bool hasUserInt(const std::string &key) const {
393  auto it = std::lower_bound(userIntLabels_.cbegin(), userIntLabels_.cend(), key);
394  return (it != userIntLabels_.cend() && *it == key);
395  }
396 
401  void addUserCand(const std::string &label, const reco::CandidatePtr &data, const bool overwrite = false);
403  const std::vector<std::string> &userCandNames() const { return userCandLabels_; }
405  bool hasUserCand(const std::string &key) const {
406  auto it = std::lower_bound(userCandLabels_.cbegin(), userCandLabels_.cend(), key);
407  return (it != userCandLabels_.cend() && *it == key);
408  }
409 
410  // === New Kinematic Resolutions
413  const pat::CandKinResolution &getKinResolution(const std::string &label = "") const;
414 
416  bool hasKinResolution(const std::string &label = "") const;
417 
420 
422  double resolEta(const std::string &label = "") const { return getKinResolution(label).resolEta(this->p4()); }
423 
425  double resolTheta(const std::string &label = "") const { return getKinResolution(label).resolTheta(this->p4()); }
426 
428  double resolPhi(const std::string &label = "") const { return getKinResolution(label).resolPhi(this->p4()); }
429 
431  double resolE(const std::string &label = "") const { return getKinResolution(label).resolE(this->p4()); }
432 
434  double resolEt(const std::string &label = "") const { return getKinResolution(label).resolEt(this->p4()); }
435 
437  double resolP(const std::string &label = "") const { return getKinResolution(label).resolP(this->p4()); }
438 
440  double resolPt(const std::string &label = "") const { return getKinResolution(label).resolPt(this->p4()); }
441 
443  double resolPInv(const std::string &label = "") const { return getKinResolution(label).resolPInv(this->p4()); }
444 
446  double resolPx(const std::string &label = "") const { return getKinResolution(label).resolPx(this->p4()); }
447 
449  double resolPy(const std::string &label = "") const { return getKinResolution(label).resolPy(this->p4()); }
450 
452  double resolPz(const std::string &label = "") const { return getKinResolution(label).resolPz(this->p4()); }
453 
456  double resolM(const std::string &label = "") const { return getKinResolution(label).resolM(this->p4()); }
457 
458  protected:
459  // reference back to the original object
461 
464 
466  std::vector<pat::LookupTableRecord> efficiencyValues_;
468  std::vector<std::string> efficiencyNames_;
469 
471  std::vector<reco::GenParticleRef> genParticleRef_;
473  std::vector<reco::GenParticle> genParticleEmbedded_;
474 
476  std::vector<std::string> overlapLabels_;
478  std::vector<reco::CandidatePtrVector> overlapItems_;
479 
481  std::vector<std::string> userDataLabels_;
483  // User float values
484  std::vector<std::string> userFloatLabels_;
485  std::vector<float> userFloats_;
486  // User int values
487  std::vector<std::string> userIntLabels_;
488  std::vector<int32_t> userInts_;
489  // User candidate matches
490  std::vector<std::string> userCandLabels_;
491  std::vector<reco::CandidatePtr> userCands_;
492 
494  std::vector<pat::CandKinResolution> kinResolutions_;
497  std::vector<std::string> kinResolutionLabels_;
498 
499  void addUserDataObject_(const std::string &label, std::unique_ptr<pat::UserData> value, bool overwrite = false);
500 
501  private:
502  const pat::UserData *userDataObject_(const std::string &key) const;
503  };
504 
505  template <class ObjectType>
507 
508  template <class ObjectType>
510 
511  template <class ObjectType>
513  : ObjectType(*ref),
514  refToOrig_(ref.id(),
515  ref.get(),
516  ref.key()) // correct way to convert RefToBase=>Ptr, if ref is guaranteed to be available
517  // which happens to be true, otherwise the line before this throws ex. already
518  {}
519 
520  template <class ObjectType>
521  PATObject<ObjectType>::PATObject(const edm::Ptr<ObjectType> &ref) : ObjectType(*ref), refToOrig_(ref) {}
522 
523  template <class ObjectType>
525  if (refToOrig_.isNull()) {
526  // this object was not produced from a reference, so no link to the
527  // original object exists -> return a 0-pointer
528  return nullptr;
529  } else if (!refToOrig_.isAvailable()) {
531  << "The original collection from which this PAT object was made is not present any more in the event, hence "
532  "you cannot access the originating object anymore.";
533  } else {
534  return refToOrig_.get();
535  }
536  }
537 
538  template <class ObjectType>
540  return refToOrig_;
541  }
542 
543  template <class ObjectType>
545  if (idx >= triggerObjectMatches().size())
546  return nullptr;
547  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, idx);
548  return ref.isNonnull() ? ref.get() : nullptr;
549  }
550 
551  template <class ObjectType>
553  const trigger::TriggerObjectType triggerObjectType) const {
555  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
556  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasTriggerObjectType(triggerObjectType))
557  matches.push_back(*(triggerObjectMatch(i)));
558  }
559  return matches;
560  }
561 
562  template <class ObjectType>
564  const trigger::TriggerObjectType triggerObjectType, const size_t idx) const {
565  std::vector<size_t> refs;
566  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
567  if (triggerObjectMatch(i) != nullptr && triggerObjectMatch(i)->hasTriggerObjectType(triggerObjectType))
568  refs.push_back(i);
569  }
570  if (idx >= refs.size())
571  return nullptr;
572  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
573  return ref.isNonnull() ? ref.get() : nullptr;
574  }
575 
576  template <class ObjectType>
578  const std::string &coll) const {
580  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
581  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasCollection(coll))
582  matches.push_back(*(triggerObjectMatch(i)));
583  }
584  return matches;
585  }
586 
587  template <class ObjectType>
589  const size_t idx) const {
590  std::vector<size_t> refs;
591  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
592  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasCollection(coll)) {
593  refs.push_back(i);
594  }
595  }
596  if (idx >= refs.size())
597  return nullptr;
598  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
599  return ref.isNonnull() ? ref.get() : nullptr;
600  }
601 
602  template <class ObjectType>
604  const std::string &nameCondition) const {
606  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
607  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasConditionName(nameCondition))
608  matches.push_back(*(triggerObjectMatch(i)));
609  }
610  return matches;
611  }
612 
613  template <class ObjectType>
615  const size_t idx) const {
616  std::vector<size_t> refs;
617  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
618  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasConditionName(nameCondition))
619  refs.push_back(i);
620  }
621  if (idx >= refs.size())
622  return nullptr;
623  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
624  return ref.isNonnull() ? ref.get() : nullptr;
625  }
626 
627  template <class ObjectType>
629  const std::string &nameAlgorithm, const bool algoCondAccepted) const {
631  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
632  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasAlgorithmName(nameAlgorithm, algoCondAccepted))
633  matches.push_back(*(triggerObjectMatch(i)));
634  }
635  return matches;
636  }
637 
638  template <class ObjectType>
640  const bool algoCondAccepted,
641  const size_t idx) const {
642  std::vector<size_t> refs;
643  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
644  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasAlgorithmName(nameAlgorithm, algoCondAccepted))
645  refs.push_back(i);
646  }
647  if (idx >= refs.size())
648  return nullptr;
649  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
650  return ref.isNonnull() ? ref.get() : nullptr;
651  }
652 
653  template <class ObjectType>
655  const std::string &labelFilter) const {
657  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
658  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasFilterLabel(labelFilter))
659  matches.push_back(*(triggerObjectMatch(i)));
660  }
661  return matches;
662  }
663 
664  template <class ObjectType>
666  const size_t idx) const {
667  std::vector<size_t> refs;
668  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
669  if (triggerObjectMatch(i) != 0 && triggerObjectMatch(i)->hasFilterLabel(labelFilter))
670  refs.push_back(i);
671  }
672  if (idx >= refs.size())
673  return nullptr;
674  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
675  return ref.isNonnull() ? ref.get() : nullptr;
676  }
677 
678  template <class ObjectType>
680  const std::string &namePath, const bool pathLastFilterAccepted, const bool pathL3FilterAccepted) const {
682  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
683  if (triggerObjectMatch(i) != nullptr &&
684  triggerObjectMatch(i)->hasPathName(namePath, pathLastFilterAccepted, pathL3FilterAccepted))
685  matches.push_back(*(triggerObjectMatch(i)));
686  }
687  return matches;
688  }
689 
690  template <class ObjectType>
692  const bool pathLastFilterAccepted,
693  const bool pathL3FilterAccepted,
694  const size_t idx) const {
695  std::vector<size_t> refs;
696  for (size_t i = 0; i < triggerObjectMatches().size(); ++i) {
697  if (triggerObjectMatch(i) != nullptr &&
698  triggerObjectMatch(i)->hasPathName(namePath, pathLastFilterAccepted, pathL3FilterAccepted))
699  refs.push_back(i);
700  }
701  if (idx >= refs.size())
702  return nullptr;
703  TriggerObjectStandAloneRef ref(&triggerObjectMatchesEmbedded_, refs.at(idx));
704  return ref.isNonnull() ? ref.get() : nullptr;
705  }
706 
707  template <class ObjectType>
709  // find the name in the (sorted) list of names
710  auto it = std::lower_bound(efficiencyNames_.cbegin(), efficiencyNames_.cend(), name);
711  if ((it == efficiencyNames_.end()) || (*it != name)) {
712  throw cms::Exception("Invalid Label") << "There is no efficiency with name '" << name << "' in this PAT Object\n";
713  }
714  return efficiencyValues_[std::distance(efficiencyNames_.cbegin(), it)];
715  }
716 
717  template <class ObjectType>
718  std::vector<std::pair<std::string, pat::LookupTableRecord> > PATObject<ObjectType>::efficiencies() const {
719  std::vector<std::pair<std::string, pat::LookupTableRecord> > ret;
720  std::vector<std::string>::const_iterator itn = efficiencyNames_.begin(), edn = efficiencyNames_.end();
721  std::vector<pat::LookupTableRecord>::const_iterator itv = efficiencyValues_.begin();
722  for (; itn != edn; ++itn, ++itv) {
723  ret.emplace_back(*itn, *itv);
724  }
725  return ret;
726  }
727 
728  template <class ObjectType>
730  // look for the name, or to the place where we can insert it without violating the alphabetic order
731  auto it = std::lower_bound(efficiencyNames_.begin(), efficiencyNames_.end(), name);
732  const auto dist = std::distance(efficiencyNames_.begin(), it);
733  if (it == efficiencyNames_.end()) { // insert at the end
734  efficiencyNames_.push_back(name);
735  efficiencyValues_.push_back(value);
736  } else if (*it == name) { // replace existing
737  efficiencyValues_[dist] = value;
738  } else { // insert in the middle :-(
739  efficiencyNames_.insert(it, name);
740  efficiencyValues_.insert(efficiencyValues_.begin() + dist, value);
741  }
742  }
743 
744  template <class ObjectType>
746  genParticleRef_ = std::vector<reco::GenParticleRef>(1, ref);
747  genParticleEmbedded_.clear();
748  if (embed)
749  embedGenParticle();
750  }
751 
752  template <class ObjectType>
754  if (!genParticleEmbedded_.empty()) { // we're embedding
755  if (ref.isNonnull())
756  genParticleEmbedded_.push_back(*ref);
757  } else {
758  genParticleRef_.push_back(ref);
759  }
760  }
761 
762  template <class ObjectType>
764  genParticleEmbedded_.clear();
765  genParticleEmbedded_.push_back(particle);
766  genParticleRef_.clear();
767  }
768 
769  template <class ObjectType>
771  genParticleEmbedded_.clear();
772  for (std::vector<reco::GenParticleRef>::const_iterator it = genParticleRef_.begin(); it != genParticleRef_.end();
773  ++it) {
774  if (it->isNonnull())
775  genParticleEmbedded_.push_back(**it);
776  }
777  genParticleRef_.clear();
778  }
779 
780  template <class ObjectType>
781  std::vector<reco::GenParticleRef> PATObject<ObjectType>::genParticleRefs() const {
782  if (genParticleEmbedded_.empty())
783  return genParticleRef_;
784  std::vector<reco::GenParticleRef> ret(genParticleEmbedded_.size());
785  for (size_t i = 0, n = ret.size(); i < n; ++i) {
786  ret[i] = reco::GenParticleRef(&genParticleEmbedded_, i);
787  }
788  return ret;
789  }
790 
791  template <class ObjectType>
793  // get a vector, avoiding an unneeded copy if there is no embedding
794  const std::vector<reco::GenParticleRef> &vec = (genParticleEmbedded_.empty() ? genParticleRef_ : genParticleRefs());
795  for (std::vector<reco::GenParticleRef>::const_iterator ref = vec.begin(), end = vec.end(); ref != end; ++ref) {
796  if (ref->isNonnull()) {
797  const reco::GenParticle &g = **ref;
798  if ((status != 0) && (g.status() != status))
799  continue;
800  if (pdgId == 0) {
801  return *ref;
802  } else if (!autoCharge) {
803  if (pdgId == g.pdgId())
804  return *ref;
805  } else if (abs(pdgId) == abs(g.pdgId())) {
806  // I want pdgId > 0 to match "correct charge" (for charged particles)
807  if (g.charge() == 0)
808  return *ref;
809  else if ((this->charge() == 0) && (pdgId == g.pdgId()))
810  return *ref;
811  else if (g.charge() * this->charge() * pdgId > 0)
812  return *ref;
813  }
814  }
815  }
816  return reco::GenParticleRef();
817  }
818 
819  template <class ObjectType>
821  auto match = std::lower_bound(overlapLabels_.cbegin(), overlapLabels_.cend(), label);
822  return (match != overlapLabels_.end() && *match == label);
823  }
824 
825  template <class ObjectType>
827  auto match = std::lower_bound(overlapLabels_.cbegin(), overlapLabels_.cend(), label);
828  if (match == overlapLabels_.cend() || *match != label)
829  return get_empty_cpv();
830  return overlapItems_[std::distance(overlapLabels_.begin(), match)];
831  }
832 
833  template <class ObjectType>
835  auto match = std::lower_bound(overlapLabels_.begin(), overlapLabels_.end(), label);
836  const auto dist = std::distance(overlapLabels_.begin(), match);
837  if (match == overlapLabels_.end() || *match != label) {
838  overlapLabels_.insert(match, label);
839  overlapItems_.insert(overlapItems_.begin() + dist, overlaps);
840  } else {
841  overlapItems_[dist] = overlaps;
842  }
843  }
844 
845  template <class ObjectType>
847  auto it = std::lower_bound(userDataLabels_.cbegin(), userDataLabels_.cend(), key);
848  if (it != userDataLabels_.cend() && *it == key) {
849  return &userDataObjects_[std::distance(userDataLabels_.cbegin(), it)];
850  }
851  return nullptr;
852  }
853 
854  template <class ObjectType>
856  std::unique_ptr<pat::UserData> data,
857  bool overwrite) {
858  auto it = std::lower_bound(userDataLabels_.begin(), userDataLabels_.end(), label);
859  const auto dist = std::distance(userDataLabels_.begin(), it);
860  if (it == userDataLabels_.end() || *it != label) {
861  userDataLabels_.insert(it, label);
862  userDataObjects_.insert(userDataObjects_.begin() + dist, std::move(data));
863  } else if (overwrite) {
864  userDataObjects_.set(dist, std::move(data));
865  } else {
866  //create a range by adding behind the first entry
867  userDataLabels_.insert(it + 1, label);
868  userDataObjects_.insert(userDataObjects_.begin() + dist + 1, std::move(data));
869  }
870  }
871 
872  template <class ObjectType>
874  auto it = std::lower_bound(userFloatLabels_.cbegin(), userFloatLabels_.cend(), key);
875  if (it != userFloatLabels_.cend() && *it == key) {
876  return userFloats_[std::distance(userFloatLabels_.cbegin(), it)];
877  }
878  throwMissingLabel("UserFloat", key, userFloatLabels_);
879  return std::numeric_limits<float>::quiet_NaN();
880  }
881 
882  template <class ObjectType>
883  std::vector<float> PATObject<ObjectType>::userFloatRange(const std::string &key) const {
884  auto range = std::equal_range(userFloatLabels_.cbegin(), userFloatLabels_.cend(), key);
885  std::vector<float> result;
886  result.reserve(std::distance(range.first, range.second));
887  for (auto it = range.first; it != range.second; ++it) {
888  result.push_back(userFloats_[std::distance(userFloatLabels_.cbegin(), it)]);
889  }
890  return result;
891  }
892 
893  template <class ObjectType>
894  void PATObject<ObjectType>::addUserFloat(const std::string &label, float data, const bool overwrite) {
895  auto it = std::lower_bound(userFloatLabels_.begin(), userFloatLabels_.end(), label);
896  const auto dist = std::distance(userFloatLabels_.begin(), it);
897  if (it == userFloatLabels_.end() || *it != label) {
898  userFloatLabels_.insert(it, label);
899  userFloats_.insert(userFloats_.begin() + dist, data);
900  } else if (overwrite) {
901  userFloats_[dist] = data;
902  } else {
903  //create a range by adding behind the first entry
904  userFloatLabels_.insert(it + 1, label);
905  userFloats_.insert(userFloats_.begin() + dist + 1, data);
906  }
907  }
908 
909  template <class ObjectType>
911  auto it = std::lower_bound(userIntLabels_.cbegin(), userIntLabels_.cend(), key);
912  if (it != userIntLabels_.cend() && *it == key) {
913  return userInts_[std::distance(userIntLabels_.cbegin(), it)];
914  }
915  throwMissingLabel("UserInt", key, userIntLabels_);
917  }
918 
919  template <class ObjectType>
920  std::vector<int> PATObject<ObjectType>::userIntRange(const std::string &key) const {
921  auto range = std::equal_range(userIntLabels_.cbegin(), userIntLabels_.cend(), key);
922  std::vector<int> result;
923  result.reserve(std::distance(range.first, range.second));
924  for (auto it = range.first; it != range.second; ++it) {
925  result.push_back(userInts_[std::distance(userIntLabels_.cbegin(), it)]);
926  }
927  return result;
928  }
929 
930  template <class ObjectType>
931  void PATObject<ObjectType>::addUserInt(const std::string &label, int data, bool overwrite) {
932  auto it = std::lower_bound(userIntLabels_.begin(), userIntLabels_.end(), label);
933  const auto dist = std::distance(userIntLabels_.begin(), it);
934  if (it == userIntLabels_.end() || *it != label) {
935  userIntLabels_.insert(it, label);
936  userInts_.insert(userInts_.begin() + dist, data);
937  } else if (overwrite) {
938  userInts_[dist] = data;
939  } else {
940  //create a range by adding behind the first entry
941  userIntLabels_.insert(it + 1, label);
942  userInts_.insert(userInts_.begin() + dist + 1, data);
943  }
944  }
945 
946  template <class ObjectType>
948  auto it = std::lower_bound(userCandLabels_.cbegin(), userCandLabels_.cend(), key);
949  if (it != userCandLabels_.cend()) {
950  return userCands_[std::distance(userCandLabels_.begin(), it)];
951  }
952  return reco::CandidatePtr();
953  }
954 
955  template <class ObjectType>
957  const reco::CandidatePtr &data,
958  const bool overwrite) {
959  auto it = std::lower_bound(userCandLabels_.begin(), userCandLabels_.end(), label);
960  const auto dist = std::distance(userCandLabels_.begin(), it);
961  if (it == userCandLabels_.end() || *it != label) {
962  userCandLabels_.insert(it, label);
963  userCands_.insert(userCands_.begin() + dist, data);
964  } else if (overwrite) {
965  userCands_[dist] = data;
966  } else {
967  userCandLabels_.insert(it + 1, label);
968  userCands_.insert(userCands_.begin() + dist + 1, data);
969  }
970  }
971 
972  template <class ObjectType>
974  const bool has_unlabelled = (kinResolutionLabels_.size() + 1 == kinResolutions_.size());
975  if (label.empty()) {
976  if (has_unlabelled) {
977  return kinResolutions_[0];
978  } else {
979  throw cms::Exception("Missing Data", "This object does not contain an un-labelled kinematic resolution");
980  }
981  } else {
982  auto match = std::lower_bound(kinResolutionLabels_.cbegin(), kinResolutionLabels_.cend(), label);
983  const auto dist = std::distance(kinResolutionLabels_.begin(), match);
984  const size_t increment = (has_unlabelled ? 1 : 0);
985  if (match == kinResolutionLabels_.end() || *match != label) {
986  cms::Exception ex("Missing Data");
987  ex << "This object does not contain a kinematic resolution with name '" << label << "'.\n";
988  ex << "The known labels are: ";
989  for (std::vector<std::string>::const_iterator it = kinResolutionLabels_.cbegin();
990  it != kinResolutionLabels_.cend();
991  ++it) {
992  ex << "'" << *it << "' ";
993  }
994  ex << "\n";
995  throw ex;
996  } else {
997  return kinResolutions_[dist + increment];
998  }
999  }
1000  }
1001 
1002  template <class ObjectType>
1004  if (label.empty()) {
1005  return (kinResolutionLabels_.size() + 1 == kinResolutions_.size());
1006  } else {
1007  auto match = std::lower_bound(kinResolutionLabels_.cbegin(), kinResolutionLabels_.cend(), label);
1008  return (match != kinResolutionLabels_.cend() && *match == label);
1009  }
1010  }
1011 
1012  template <class ObjectType>
1014  const bool has_unlabelled = (kinResolutionLabels_.size() + 1 == kinResolutions_.size());
1015  if (label.empty()) {
1016  if (has_unlabelled) {
1017  // There is already an un-labelled object. Replace it
1018  kinResolutions_[0] = resol;
1019  } else {
1020  // Insert. Note that the un-labelled is always the first, so we need to insert before begin()
1021  // (for an empty vector, this should not cost more than push_back)
1022  kinResolutions_.insert(kinResolutions_.begin(), resol);
1023  }
1024  } else {
1025  auto match = std::lower_bound(kinResolutionLabels_.begin(), kinResolutionLabels_.end(), label);
1026  const auto dist = std::distance(kinResolutionLabels_.begin(), match);
1027  const size_t increment = (has_unlabelled ? 1 : 0);
1028  if (match != kinResolutionLabels_.end() && *match == label) {
1029  // Existing object: replace
1030  kinResolutions_[dist + increment] = resol;
1031  } else {
1032  kinResolutionLabels_.insert(match, label);
1033  kinResolutions_.insert(kinResolutions_.begin() + dist + increment, resol);
1034  }
1035  }
1036  }
1037 
1038 } // namespace pat
1039 
1040 #endif
trigger::TriggerObjectType
TriggerObjectType
Definition: TriggerTypeDefs.h:23
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
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:259
pat::PATObject::setOverlaps
void setOverlaps(const std::string &label, const reco::CandidatePtrVector &overlaps)
Definition: PATObject.h:834
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:316
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:466
mps_fire.i
i
Definition: mps_fire.py:428
pat::PATObject::userDataBare
const void * userDataBare(const std::string &key) const
Definition: PATObject.h:340
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:691
l1ParticleFlow_cff.resol
resol
Definition: l1ParticleFlow_cff.py:17
MessageLogger.h
pat::PATObject::triggerObjectMatches
const TriggerObjectStandAloneCollection & triggerObjectMatches() const
get all matched trigger objects
Definition: PATObject.h:72
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
pat::PATObject::triggerObjectMatchesByFilterID
const TriggerObjectStandAloneCollection triggerObjectMatchesByFilterID(const unsigned triggerObjectType) const
Definition: PATObject.h:83
pat::PATObject::hasUserData
bool hasUserData(const std::string &key) const
Check if user data with a specific type is present.
Definition: PATObject.h:329
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:324
pat::PATObject::addTriggerObjectMatch
void addTriggerObjectMatch(const TriggerObjectStandAlone &trigObj)
add a trigger match
Definition: PATObject.h:240
pat::PATObject::triggerObjectMatchByAlgorithm
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const char *nameAlgorithm, const bool algoCondAccepted=true, const size_t idx=0) const
Definition: PATObject.h:151
pat::PATObject::triggerObjectMatchesByType
const TriggerObjectStandAloneCollection triggerObjectMatchesByType(const trigger::TriggerObjectType triggerObjectType) const
Definition: PATObject.h:552
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:178
pat::PATObject::kinResolutionLabels_
std::vector< std::string > kinResolutionLabels_
Definition: PATObject.h:497
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:443
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:792
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:665
pat::PATObject::base_type
ObjectType base_type
Definition: PATObject.h:47
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:628
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
pat::PATObject::genParticlesSize
size_t genParticlesSize() const
Number of generator level particles stored as ref or embedded.
Definition: PATObject.h:292
CandKinResolution.h
pat::PATObject::addGenParticleRef
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:753
pat::PATObject::addUserInt
void addUserInt(const std::string &label, int32_t data, const bool overwrite=false)
Set user-defined int.
Definition: PATObject.h:931
pat::PATObject::triggerObjectMatchByAlgorithm
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const std::string &nameAlgorithm, const bool algoCondAccepted=true, const size_t idx=0) const
Definition: PATObject.h:639
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:820
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:428
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:718
pat::PATObject::userFloat
float userFloat(const std::string &key) const
Definition: PATObject.h:873
pat::PATObject::userIntRange
std::vector< int > userIntRange(const std::string &key) const
returns a range of values corresponding to key
Definition: PATObject.h:920
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:614
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:405
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:603
edm::Ref< GenParticleCollection >
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
pat::PATObject::userDataObjects_
pat::UserDataCollection userDataObjects_
Definition: PATObject.h:482
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:357
pat::PATObject::triggerObjectMatchesByFilter
const TriggerObjectStandAloneCollection triggerObjectMatchesByFilter(const char *labelFilter) const
Definition: PATObject.h:171
pat::PATObject::overlapLabels_
std::vector< std::string > overlapLabels_
Overlapping test labels (only if there are any overlaps)
Definition: PATObject.h:476
edm::errors::ProductNotFound
Definition: EDMException.h:33
pat::PATObject::userInts_
std::vector< int32_t > userInts_
Definition: PATObject.h:488
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:588
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:425
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:437
pat::PATObject::refToOrig_
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:460
edm::PtrVector< Candidate >
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
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:654
pat::PATObject::genParticleRefs
std::vector< reco::GenParticleRef > genParticleRefs() const
Definition: PATObject.h:781
pat::PATObject::overlaps
const reco::CandidatePtrVector & overlaps(const std::string &label) const
Definition: PATObject.h:826
pat::PATObject::addUserData
void addUserData(const std::string &label, const T &data, bool transientOnly=false, bool overwrite=false)
Definition: PATObject.h:350
pat::PATObject::triggerObjectMatchByFilterID
const TriggerObjectStandAlone * triggerObjectMatchByFilterID(const unsigned triggerObjectType, const size_t idx=0) const
Definition: PATObject.h:94
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:375
mps_fire.end
end
Definition: mps_fire.py:242
pat::PATObject
Templated PAT object container.
Definition: PATObject.h:45
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:449
pat::get_empty_cpv
const reco::CandidatePtrVector & get_empty_cpv()
Definition: PATObject.cc:4
pat::PATObject::triggerObjectMatchByCondition
const TriggerObjectStandAlone * triggerObjectMatchByCondition(const char *nameCondition, const size_t idx=0) const
Definition: PATObject.h:120
pat::PATObject::userCand
reco::CandidatePtr userCand(const std::string &key) const
Definition: PATObject.h:947
pat::PATObject::~PATObject
~PATObject() override
destructor
Definition: PATObject.h:58
pat::PATObject::userFloatRange
std::vector< float > userFloatRange(const std::string &key) const
return a range of values corresponding to key
Definition: PATObject.h:883
pat::PATObject::triggerObjectMatchByAlgorithm
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const std::string &nameAlgorithm, const unsigned algoCondAccepted, const size_t idx=0) const
Definition: PATObject.h:157
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:380
pat::PATObject::addUserDataObject_
void addUserDataObject_(const std::string &label, std::unique_ptr< pat::UserData > value, bool overwrite=false)
Definition: PATObject.h:855
pat::PATObject::addUserCand
void addUserCand(const std::string &label, const reco::CandidatePtr &data, const bool overwrite=false)
Set user-defined int.
Definition: PATObject.h:956
pat::get_empty_str
const std::string & get_empty_str()
Definition: PATObject.cc:9
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:163
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:708
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:539
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:392
pat::PATObject::userCands_
std::vector< reco::CandidatePtr > userCands_
Definition: PATObject.h:491
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
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:225
pat::PATObject::userIntLabels_
std::vector< std::string > userIntLabels_
Definition: PATObject.h:487
pat::PATObject::triggerObjectMatchesByAlgorithm
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const std::string &nameAlgorithm, const unsigned algoCondAccepted) const
Definition: PATObject.h:135
pat::PATObject::userFloat
float userFloat(const char *key) const
a CINT-friendly interface
Definition: PATObject.h:368
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:331
pat::PATObject::triggerObjectMatch
const TriggerObjectStandAlone * triggerObjectMatch(const size_t idx=0) const
get one matched trigger object by index
Definition: PATObject.h:544
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
pat::PATObject::genParticleRef_
std::vector< reco::GenParticleRef > genParticleRef_
Reference to a generator level particle.
Definition: PATObject.h:471
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:577
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:846
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:763
pat::PATObject::addUserFloat
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:894
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:440
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:446
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:373
pat::PATObject::efficiencyNames_
std::vector< std::string > efficiencyNames_
vector of the efficiencies (names)
Definition: PATObject.h:468
pat::PATObject::triggerObjectMatchesByPath
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:679
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:473
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:232
pat::PATObject::triggerObjectMatchesByAlgorithm
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const char *nameAlgorithm, const bool algoCondAccepted=true) const
Definition: PATObject.h:130
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:563
pat::PATObject::setGenParticleRef
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
Definition: PATObject.h:745
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:422
pat::PATObject::efficiencyNames
const std::vector< std::string > & efficiencyNames() const
Returns the list of the names of the stored efficiencies.
Definition: PATObject.h:257
pat::PATObject::PATObject
PATObject()
default constructor
Definition: PATObject.h:506
pat::PATObject::kinResolutions_
std::vector< pat::CandKinResolution > kinResolutions_
Kinematic resolutions.
Definition: PATObject.h:494
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:524
pat::PATObject::triggerObjectMatchesByPath
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const char *namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:190
pat::PATObject::triggerObjectMatchesByCollection
const TriggerObjectStandAloneCollection triggerObjectMatchesByCollection(const char *coll) const
Definition: PATObject.h:101
pat::PATObject::userCandLabels_
std::vector< std::string > userCandLabels_
Definition: PATObject.h:490
pat::PATObject::triggerObjectMatchesByType
const TriggerObjectStandAloneCollection triggerObjectMatchesByType(const unsigned triggerObjectType) const
Definition: PATObject.h:79
pat::PATObject::setEfficiency
void setEfficiency(const std::string &name, const pat::LookupTableRecord &value)
Definition: PATObject.h:729
pat::PATObject::resolM
double resolM(const std::string &label="") const
Definition: PATObject.h:456
pat::CandKinResolution::resolTheta
double resolTheta(const LorentzVector &p4) const
Resolution on theta, given the 4-momentum of the associated Candidate.
Definition: CandKinResolution.cc:29
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:202
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:452
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:218
pat::PATObject::genParticle
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:287
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:1003
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:390
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:434
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:196
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:463
pat::PATObject::userDataLabels_
std::vector< std::string > userDataLabels_
User data object.
Definition: PATObject.h:481
mps_fire.result
result
Definition: mps_fire.py:311
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:89
pat::PATObject::triggerObjectMatchesByCondition
const TriggerObjectStandAloneCollection triggerObjectMatchesByCondition(const char *nameCondition) const
Definition: PATObject.h:113
pat::PATObject::userInt
int32_t userInt(const std::string &key) const
Definition: PATObject.h:910
pat::PATObject::embedGenParticle
void embedGenParticle()
Definition: PATObject.h:770
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:244
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
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
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:107
pat::PATObject::triggerObjectMatchesByAlgorithm
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const char *nameAlgorithm, const unsigned algoCondAccepted) const
Definition: PATObject.h:140
label
const char * label
Definition: PFTauDecayModeTools.cc:11
pat::PATObject::genParticleRef
reco::GenParticleRef genParticleRef(size_t idx=0) const
Definition: PATObject.h:267
pat::PATObject::userDataNames
const std::vector< std::string > & userDataNames() const
Get list of user data object names.
Definition: PATObject.h:336
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:484
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:431
pat::PATObject::userFloats_
std::vector< float > userFloats_
Definition: PATObject.h:485
pat::PATObject::getKinResolution
const pat::CandKinResolution & getKinResolution(const std::string &label="") const
Definition: PATObject.h:973
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:403
pat::PATObject::overlapItems_
std::vector< reco::CandidatePtrVector > overlapItems_
Overlapping items (sorted by distance)
Definition: PATObject.h:478
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:1013