CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
23 #include <vector>
24 #include <string>
25 #include <iosfwd>
26 
29 
31 
34 
36 
38 
40 
41 namespace pat {
42 
43  namespace pat_statics {
45  static const std::string EMPTY_STR("");
46  }
47 
48  template <class ObjectType>
49  class PATObject : public ObjectType {
50  public:
51 
53 
55  PATObject();
57  PATObject(const ObjectType & obj);
61  PATObject(const edm::Ptr<ObjectType> & ref);
63  virtual ~PATObject() {}
64  // returns a clone // NO: ObjectType can be an abstract type like reco::Candidate
65  // virtual PATObject<ObjectType> * clone() const ; // for which the clone() can't be defined
66 
68  const reco::Candidate * originalObject() const;
71 
75 
79  const TriggerObjectStandAlone * triggerObjectMatch( const size_t idx = 0 ) const;
83  const TriggerObjectStandAloneCollection triggerObjectMatchesByType( const unsigned triggerObjectType ) const {
84  return triggerObjectMatchesByType( trigger::TriggerObjectType( triggerObjectType ) );
85  };
86  // for backward compatibility
87  const TriggerObjectStandAloneCollection triggerObjectMatchesByFilterID( const unsigned triggerObjectType ) const {
88  return triggerObjectMatchesByType( trigger::TriggerObjectType( triggerObjectType ) );
89  };
91  const TriggerObjectStandAlone * triggerObjectMatchByType( const trigger::TriggerObjectType triggerObjectType, const size_t idx = 0 ) const;
92  const TriggerObjectStandAlone * triggerObjectMatchByType( const unsigned triggerObjectType, const size_t idx = 0 ) const {
93  return triggerObjectMatchByType( trigger::TriggerObjectType( triggerObjectType ), idx );
94  };
95  // for backward compatibility
96  const TriggerObjectStandAlone * triggerObjectMatchByFilterID( const unsigned triggerObjectType, const size_t idx = 0 ) const {
97  return triggerObjectMatchByType( trigger::TriggerObjectType( triggerObjectType ), idx );
98  };
101  // for RooT command line
104  };
106  const TriggerObjectStandAlone * triggerObjectMatchByCollection( const std::string & coll, const size_t idx = 0 ) const;
107  // for RooT command line
108  const TriggerObjectStandAlone * triggerObjectMatchByCollection( const char * coll, const size_t idx = 0 ) const {
110  };
113  // for RooT command line
114  const TriggerObjectStandAloneCollection triggerObjectMatchesByCondition( const char * nameCondition ) const {
115  return triggerObjectMatchesByCondition( std::string( nameCondition ) );
116  };
118  const TriggerObjectStandAlone * triggerObjectMatchByCondition( const std::string & nameCondition, const size_t idx = 0 ) const;
119  // for RooT command line
120  const TriggerObjectStandAlone * triggerObjectMatchByCondition( const char * nameCondition, const size_t idx = 0 ) const {
121  return triggerObjectMatchByCondition( std::string( nameCondition ), idx );
122  };
126  const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm( const std::string & nameAlgorithm, const bool algoCondAccepted = true ) const;
127  // for RooT command line
128  const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm( const char * nameAlgorithm, const bool algoCondAccepted = true ) const {
129  return triggerObjectMatchesByAlgorithm( std::string( nameAlgorithm ), algoCondAccepted );
130  };
131  // for the cut string parser
132  const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm( const std::string & nameAlgorithm, const unsigned algoCondAccepted ) const {
133  return triggerObjectMatchesByAlgorithm( nameAlgorithm, bool( algoCondAccepted ) );
134  };
135  // for RooT command line and the cut string parser
136  const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm( const char * nameAlgorithm, const unsigned algoCondAccepted ) const {
137  return triggerObjectMatchesByAlgorithm( std::string( nameAlgorithm ), bool( algoCondAccepted ) );
138  };
142  const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm( const std::string & nameAlgorithm, const bool algoCondAccepted = true, const size_t idx = 0 ) const;
143  // for RooT command line
144  const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm( const char * nameAlgorithm, const bool algoCondAccepted = true, const size_t idx = 0 ) const {
145  return triggerObjectMatchByAlgorithm( std::string( nameAlgorithm ), algoCondAccepted, idx );
146  };
147  // for the cut string parser
148  const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm( const std::string & nameAlgorithm, const unsigned algoCondAccepted, const size_t idx = 0 ) const {
149  return triggerObjectMatchByAlgorithm( nameAlgorithm, bool( algoCondAccepted ), idx );
150  };
151  // for RooT command line and the cut string parser
152  const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm( const char * nameAlgorithm, const unsigned algoCondAccepted, const size_t idx = 0 ) const {
153  return triggerObjectMatchByAlgorithm( std::string( nameAlgorithm ), bool( algoCondAccepted ), idx );
154  };
157  // for RooT command line
158  const TriggerObjectStandAloneCollection triggerObjectMatchesByFilter( const char * labelFilter ) const {
159  return triggerObjectMatchesByFilter( std::string( labelFilter ) );
160  };
162  const TriggerObjectStandAlone * triggerObjectMatchByFilter( const std::string & labelFilter, const size_t idx = 0 ) const;
163  // for RooT command line
164  const TriggerObjectStandAlone * triggerObjectMatchByFilter( const char * labelFilter, const size_t idx = 0 ) const {
165  return triggerObjectMatchByFilter( std::string( labelFilter ), idx );
166  };
172  const TriggerObjectStandAloneCollection triggerObjectMatchesByPath( const std::string & namePath, const bool pathLastFilterAccepted = false, const bool pathL3FilterAccepted = true ) const;
173  // for RooT command line
174  const TriggerObjectStandAloneCollection triggerObjectMatchesByPath( const char * namePath, const bool pathLastFilterAccepted = false, const bool pathL3FilterAccepted = true ) const {
175  return triggerObjectMatchesByPath( std::string( namePath ), pathLastFilterAccepted, pathL3FilterAccepted );
176  };
177  // for the cut string parser
178  const TriggerObjectStandAloneCollection triggerObjectMatchesByPath( const std::string & namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted = 1 ) const {
179  return triggerObjectMatchesByPath( namePath, bool( pathLastFilterAccepted ), bool( pathL3FilterAccepted ) );
180  };
181  // for RooT command line and the cut string parser
182  const TriggerObjectStandAloneCollection triggerObjectMatchesByPath( const char * namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted = 1 ) const {
183  return triggerObjectMatchesByPath( std::string( namePath ), bool( pathLastFilterAccepted ), bool( pathL3FilterAccepted ) );
184  };
190  const TriggerObjectStandAlone * triggerObjectMatchByPath( const std::string & namePath, const bool pathLastFilterAccepted = false, const bool pathL3FilterAccepted = true, const size_t idx = 0 ) const;
191  // for RooT command line
192  const TriggerObjectStandAlone * triggerObjectMatchByPath( const char * namePath, const bool pathLastFilterAccepted = false, const bool pathL3FilterAccepted = true, const size_t idx = 0 ) const {
193  return triggerObjectMatchByPath( std::string( namePath ), pathLastFilterAccepted, pathL3FilterAccepted, idx );
194  };
195  // for the cut string parser
196  const TriggerObjectStandAlone * triggerObjectMatchByPath( const std::string & namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted = 1, const size_t idx = 0 ) const {
197  return triggerObjectMatchByPath( namePath, bool( pathLastFilterAccepted ), bool( pathL3FilterAccepted ), idx );
198  };
199  // for RooT command line and the cut string parser
200  const TriggerObjectStandAlone * triggerObjectMatchByPath( const char * namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted = 1, const size_t idx = 0 ) const {
201  return triggerObjectMatchByPath( std::string( namePath ), bool( pathLastFilterAccepted ), bool( pathL3FilterAccepted ), idx );
202  };
204  void addTriggerObjectMatch( const TriggerObjectStandAlone & trigObj ) { triggerObjectMatchesEmbedded_.push_back( trigObj ); };
207  for (std::vector<TriggerObjectStandAlone>::iterator it = triggerObjectMatchesEmbedded_.begin(), ed = triggerObjectMatchesEmbedded_.end(); it != ed; ++it) it->unpackPathNames(names);
208  }
209 
211  const pat::LookupTableRecord & efficiency(const std::string &name) const ;
213  std::vector<std::pair<std::string,pat::LookupTableRecord> > efficiencies() const ;
215  const std::vector<std::string> & efficiencyNames() const { return efficiencyNames_; }
217  const std::vector<pat::LookupTableRecord> & efficiencyValues() const { return efficiencyValues_; }
222 
226  if (idx >= genParticlesSize()) return reco::GenParticleRef();
228  }
239  // implementation note: uint8_t instead of bool, because the string parser doesn't allow bool currently
240  reco::GenParticleRef genParticleById(int pdgId, int status, uint8_t autoCharge=0) const ;
241 
244  const reco::GenParticle * genParticle(size_t idx=0) const {
246  return ref.isNonnull() ? ref.get() : 0;
247  }
249  size_t genParticlesSize() const {
250  return genParticleEmbedded_.empty() ? genParticleRef_.size() : genParticleEmbedded_.size();
251  }
254  std::vector<reco::GenParticleRef> genParticleRefs() const ;
255 
257  void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false) ;
260  void addGenParticleRef(const reco::GenParticleRef &ref) ;
262  void setGenParticle( const reco::GenParticle &particle ) ;
265  void embedGenParticle() ;
266 
268  bool hasOverlaps(const std::string &label) const ;
271  const reco::CandidatePtrVector & overlaps(const std::string &label) const ;
273  const std::vector<std::string> & overlapLabels() const { return overlapLabels_; }
278 
280  template<typename T> const T * userData(const std::string &key) const {
281  const pat::UserData * data = userDataObject_(key);
282  return (data != nullptr ? data->template get<T>() : nullptr);
283 
284  }
286  bool hasUserData(const std::string &key) const {
287  return (userDataObject_(key) != nullptr);
288  }
291  const pat::UserData * data = userDataObject_(key);
292  return (data != nullptr ? data->typeName() : pat_statics::EMPTY_STR);
293  };
295  const std::vector<std::string> & userDataNames() const { return userDataLabels_; }
296 
299  const void * userDataBare(const std::string &key) const {
300  const pat::UserData * data = userDataObject_(key);
301  return (data != nullptr ? data->bareData() : nullptr);
302  }
303 
308  template<typename T>
309  void addUserData( const std::string & label, const T & data, bool transientOnly=false ) {
310  userDataLabels_.push_back(label);
311  userDataObjects_.push_back(pat::UserData::make<T>(data, transientOnly));
312  }
313 
317  userDataLabels_.push_back(label);
318  userDataObjects_.push_back(data->clone());
319  }
320 
323  float userFloat( const std::string & key ) const;
325  std::vector<float> userFloatRange( const std::string& key ) const;
327  float userFloat( const char* key ) const { return userFloat( std::string(key) ); }
328 
330  void addUserFloat( const std::string & label, float data, const bool overwrite = false );
332  const std::vector<std::string> & userFloatNames() const { return userFloatLabels_; }
334  bool hasUserFloat( const std::string & key ) const {
335  auto it = std::lower_bound(userFloatLabels_.cbegin(), userFloatLabels_.cend(), key);
336  return ( it != userFloatLabels_.cend() && *it == key );
337  }
339  bool hasUserFloat( const char* key ) const {return hasUserFloat( std::string(key) );}
340 
343  int32_t userInt( const std::string & key ) const;
345  std::vector<int> userIntRange( const std::string& key ) const;
347  void addUserInt( const std::string & label, int32_t data );
349  const std::vector<std::string> & userIntNames() const { return userIntLabels_; }
351  bool hasUserInt( const std::string & key ) const {
352  auto it = std::lower_bound(userIntLabels_.cbegin(), userIntLabels_.cend(), key);
353  return ( it != userIntLabels_.cend() && *it == key );
354  }
355 
358  reco::CandidatePtr userCand( const std::string & key ) const;
360  void addUserCand( const std::string & label, const reco::CandidatePtr & data, const bool overwrite = false );
362  const std::vector<std::string> & userCandNames() const { return userCandLabels_; }
364  bool hasUserCand( const std::string & key ) const {
365  auto it = std::lower_bound(userCandLabels_.cbegin(), userCandLabels_.cend(), key);
366  return ( it != userCandLabels_.cend() && *it == key );
367  }
368 
369  // === New Kinematic Resolutions
372  const pat::CandKinResolution & getKinResolution(const std::string &label="") const ;
373 
375  bool hasKinResolution(const std::string &label="") const ;
376 
378  void setKinResolution(const pat::CandKinResolution &resol, const std::string &label="") ;
379 
381  double resolEta(const std::string &label="") const { return getKinResolution(label).resolEta(this->p4()); }
382 
384  double resolTheta(const std::string &label="") const { return getKinResolution(label).resolTheta(this->p4()); }
385 
387  double resolPhi(const std::string &label="") const { return getKinResolution(label).resolPhi(this->p4()); }
388 
390  double resolE(const std::string &label="") const { return getKinResolution(label).resolE(this->p4()); }
391 
393  double resolEt(const std::string &label="") const { return getKinResolution(label).resolEt(this->p4()); }
394 
396  double resolP(const std::string &label="") const { return getKinResolution(label).resolP(this->p4()); }
397 
399  double resolPt(const std::string &label="") const { return getKinResolution(label).resolPt(this->p4()); }
400 
402  double resolPInv(const std::string &label="") const { return getKinResolution(label).resolPInv(this->p4()); }
403 
405  double resolPx(const std::string &label="") const { return getKinResolution(label).resolPx(this->p4()); }
406 
408  double resolPy(const std::string &label="") const { return getKinResolution(label).resolPy(this->p4()); }
409 
411  double resolPz(const std::string &label="") const { return getKinResolution(label).resolPz(this->p4()); }
412 
415  double resolM(const std::string &label="") const { return getKinResolution(label).resolM(this->p4()); }
416 
417 
418 
419  protected:
420  // reference back to the original object
422 
425 
427  std::vector<pat::LookupTableRecord> efficiencyValues_;
429  std::vector<std::string> efficiencyNames_;
430 
432  std::vector<reco::GenParticleRef> genParticleRef_;
434  std::vector<reco::GenParticle> genParticleEmbedded_;
435 
437  std::vector<std::string> overlapLabels_;
439  std::vector<reco::CandidatePtrVector> overlapItems_;
440 
442  std::vector<std::string> userDataLabels_;
444  // User float values
445  std::vector<std::string> userFloatLabels_;
446  std::vector<float> userFloats_;
447  // User int values
448  std::vector<std::string> userIntLabels_;
449  std::vector<int32_t> userInts_;
450  // User candidate matches
451  std::vector<std::string> userCandLabels_;
452  std::vector<reco::CandidatePtr> userCands_;
453 
455  std::vector<pat::CandKinResolution> kinResolutions_;
458  std::vector<std::string> kinResolutionLabels_;
459 
460  private:
461  const pat::UserData * userDataObject_(const std::string &key) const ;
462  };
463 
464 
465  template <class ObjectType> PATObject<ObjectType>::PATObject() {
466  }
467 
468  template <class ObjectType> PATObject<ObjectType>::PATObject(const ObjectType & obj) :
469  ObjectType(obj),
470  refToOrig_() {
471  }
472 
473  template <class ObjectType> PATObject<ObjectType>::PATObject(const edm::RefToBase<ObjectType> & ref) :
474  ObjectType(*ref),
475  refToOrig_(ref.id(), ref.get(), ref.key()) // correct way to convert RefToBase=>Ptr, if ref is guaranteed to be available
476  // which happens to be true, otherwise the line before this throws ex. already
477  {
478  }
479 
480  template <class ObjectType> PATObject<ObjectType>::PATObject(const edm::Ptr<ObjectType> & ref) :
481  ObjectType(*ref),
482  refToOrig_(ref) {
483  }
484 
485  template <class ObjectType> const reco::Candidate * PATObject<ObjectType>::originalObject() const {
486  if (refToOrig_.isNull()) {
487  // this object was not produced from a reference, so no link to the
488  // original object exists -> return a 0-pointer
489  return 0;
490  } else if (!refToOrig_.isAvailable()) {
491  throw edm::Exception(edm::errors::ProductNotFound) << "The original collection from which this PAT object was made is not present any more in the event, hence you cannot access the originating object anymore.";
492  } else {
493  return refToOrig_.get();
494  }
495  }
496 
497  template <class ObjectType>
499 
500  template <class ObjectType>
502  if ( idx >= triggerObjectMatches().size() ) return 0;
503  TriggerObjectStandAloneRef ref( &triggerObjectMatchesEmbedded_, idx );
504  return ref.isNonnull() ? ref.get() : 0;
505  }
506 
507  template <class ObjectType>
510  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
511  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasTriggerObjectType( triggerObjectType ) ) matches.push_back( *( triggerObjectMatch( i ) ) );
512  }
513  return matches;
514  }
515 
516  template <class ObjectType>
518  std::vector< size_t > refs;
519  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
520  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasTriggerObjectType( triggerObjectType ) ) refs.push_back( i );
521  }
522  if ( idx >= refs.size() ) return 0;
523  TriggerObjectStandAloneRef ref( &triggerObjectMatchesEmbedded_, refs.at( idx ) );
524  return ref.isNonnull() ? ref.get() : 0;
525  }
526 
527  template <class ObjectType>
530  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
531  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasCollection( coll ) ) matches.push_back( *( triggerObjectMatch( i ) ) );
532  }
533  return matches;
534  }
535 
536  template <class ObjectType>
538  std::vector< size_t > refs;
539  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
540  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasCollection( coll ) ) {
541  refs.push_back( i );
542  }
543  }
544  if ( idx >= refs.size() ) return 0;
545  TriggerObjectStandAloneRef ref( &triggerObjectMatchesEmbedded_, refs.at( idx ) );
546  return ref.isNonnull() ? ref.get() : 0;
547  }
548 
549  template <class ObjectType>
552  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
553  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasConditionName( nameCondition ) ) matches.push_back( *( triggerObjectMatch( i ) ) );
554  }
555  return matches;
556  }
557 
558  template <class ObjectType>
560  std::vector< size_t > refs;
561  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
562  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasConditionName( nameCondition ) ) refs.push_back( i );
563  }
564  if ( idx >= refs.size() ) return 0;
565  TriggerObjectStandAloneRef ref( &triggerObjectMatchesEmbedded_, refs.at( idx ) );
566  return ref.isNonnull() ? ref.get() : 0;
567  }
568 
569  template <class ObjectType>
570  const TriggerObjectStandAloneCollection PATObject<ObjectType>::triggerObjectMatchesByAlgorithm( const std::string & nameAlgorithm, const bool algoCondAccepted ) const {
572  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
573  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasAlgorithmName( nameAlgorithm, algoCondAccepted ) ) matches.push_back( *( triggerObjectMatch( i ) ) );
574  }
575  return matches;
576  }
577 
578  template <class ObjectType>
579  const TriggerObjectStandAlone * PATObject<ObjectType>::triggerObjectMatchByAlgorithm( const std::string & nameAlgorithm, const bool algoCondAccepted, const size_t idx ) const {
580  std::vector< size_t > refs;
581  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
582  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasAlgorithmName( nameAlgorithm, algoCondAccepted ) ) refs.push_back( i );
583  }
584  if ( idx >= refs.size() ) return 0;
585  TriggerObjectStandAloneRef ref( &triggerObjectMatchesEmbedded_, refs.at( idx ) );
586  return ref.isNonnull() ? ref.get() : 0;
587  }
588 
589  template <class ObjectType>
592  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
593  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasFilterLabel( labelFilter ) ) matches.push_back( *( triggerObjectMatch( i ) ) );
594  }
595  return matches;
596  }
597 
598  template <class ObjectType>
600  std::vector< size_t > refs;
601  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
602  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasFilterLabel( labelFilter ) ) refs.push_back( i );
603  }
604  if ( idx >= refs.size() ) return 0;
605  TriggerObjectStandAloneRef ref( &triggerObjectMatchesEmbedded_, refs.at( idx ) );
606  return ref.isNonnull() ? ref.get() : 0;
607  }
608 
609  template <class ObjectType>
610  const TriggerObjectStandAloneCollection PATObject<ObjectType>::triggerObjectMatchesByPath( const std::string & namePath, const bool pathLastFilterAccepted, const bool pathL3FilterAccepted ) const {
612  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
613  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasPathName( namePath, pathLastFilterAccepted, pathL3FilterAccepted ) ) matches.push_back( *( triggerObjectMatch( i ) ) );
614  }
615  return matches;
616  }
617 
618  template <class ObjectType>
619  const TriggerObjectStandAlone * PATObject<ObjectType>::triggerObjectMatchByPath( const std::string & namePath, const bool pathLastFilterAccepted, const bool pathL3FilterAccepted, const size_t idx ) const {
620  std::vector< size_t > refs;
621  for ( size_t i = 0; i < triggerObjectMatches().size(); ++i ) {
622  if ( triggerObjectMatch( i ) != 0 && triggerObjectMatch( i )->hasPathName( namePath, pathLastFilterAccepted, pathL3FilterAccepted ) ) refs.push_back( i );
623  }
624  if ( idx >= refs.size() ) return 0;
625  TriggerObjectStandAloneRef ref( &triggerObjectMatchesEmbedded_, refs.at( idx ) );
626  return ref.isNonnull() ? ref.get() : 0;
627  }
628 
629  template <class ObjectType>
630  const pat::LookupTableRecord &
632  // find the name in the (sorted) list of names
633  auto it = std::lower_bound(efficiencyNames_.cbegin(), efficiencyNames_.cend(), name);
634  if ((it == efficiencyNames_.end()) || (*it != name)) {
635  throw cms::Exception("Invalid Label") << "There is no efficiency with name '" << name << "' in this PAT Object\n";
636  }
637  return efficiencyValues_[std::distance(efficiencyNames_.cbegin(),it)];
638  }
639 
640  template <class ObjectType>
641  std::vector<std::pair<std::string,pat::LookupTableRecord> >
643  std::vector<std::pair<std::string,pat::LookupTableRecord> > ret;
644  std::vector<std::string>::const_iterator itn = efficiencyNames_.begin(), edn = efficiencyNames_.end();
645  std::vector<pat::LookupTableRecord>::const_iterator itv = efficiencyValues_.begin();
646  for ( ; itn != edn; ++itn, ++itv) {
647  ret.emplace_back( *itn, *itv);
648  }
649  return ret;
650  }
651 
652  template <class ObjectType>
654  // look for the name, or to the place where we can insert it without violating the alphabetic order
655  auto it = std::lower_bound(efficiencyNames_.begin(), efficiencyNames_.end(), name);
656  const auto dist = std::distance(efficiencyNames_.begin(),it);
657  if (it == efficiencyNames_.end()) { // insert at the end
658  efficiencyNames_.push_back(name);
659  efficiencyValues_.push_back(value);
660  } else if (*it == name) { // replace existing
661  efficiencyValues_[dist] = value;
662  } else { // insert in the middle :-(
663  efficiencyNames_. insert(it, name);
664  efficiencyValues_.insert( efficiencyValues_.begin() + dist, value );
665  }
666  }
667 
668  template <class ObjectType>
670  genParticleRef_ = std::vector<reco::GenParticleRef>(1,ref);
671  genParticleEmbedded_.clear();
672  if (embed) embedGenParticle();
673  }
674 
675  template <class ObjectType>
677  if (!genParticleEmbedded_.empty()) { // we're embedding
678  if (ref.isNonnull()) genParticleEmbedded_.push_back(*ref);
679  } else {
680  genParticleRef_.push_back(ref);
681  }
682  }
683 
684  template <class ObjectType>
686  genParticleEmbedded_.clear();
687  genParticleEmbedded_.push_back(particle);
688  genParticleRef_.clear();
689  }
690 
691  template <class ObjectType>
693  genParticleEmbedded_.clear();
694  for (std::vector<reco::GenParticleRef>::const_iterator it = genParticleRef_.begin(); it != genParticleRef_.end(); ++it) {
695  if (it->isNonnull()) genParticleEmbedded_.push_back(**it);
696  }
697  genParticleRef_.clear();
698  }
699 
700  template <class ObjectType>
701  std::vector<reco::GenParticleRef> PATObject<ObjectType>::genParticleRefs() const {
702  if (genParticleEmbedded_.empty()) return genParticleRef_;
703  std::vector<reco::GenParticleRef> ret(genParticleEmbedded_.size());
704  for (size_t i = 0, n = ret.size(); i < n; ++i) {
705  ret[i] = reco::GenParticleRef(&genParticleEmbedded_, i);
706  }
707  return ret;
708  }
709 
710  template <class ObjectType>
712  // get a vector, avoiding an unneeded copy if there is no embedding
713  const std::vector<reco::GenParticleRef> & vec = (genParticleEmbedded_.empty() ? genParticleRef_ : genParticleRefs());
714  for (std::vector<reco::GenParticleRef>::const_iterator ref = vec.begin(), end = vec.end(); ref != end; ++ref) {
715  if (ref->isNonnull()) {
716  const reco::GenParticle & g = **ref;
717  if ((status != 0) && (g.status() != status)) continue;
718  if (pdgId == 0) {
719  return *ref;
720  } else if (!autoCharge) {
721  if (pdgId == g.pdgId()) return *ref;
722  } else if (abs(pdgId) == abs(g.pdgId())) {
723  // I want pdgId > 0 to match "correct charge" (for charged particles)
724  if (g.charge() == 0) return *ref;
725  else if ((this->charge() == 0) && (pdgId == g.pdgId())) return *ref;
726  else if (g.charge()*this->charge()*pdgId > 0) return *ref;
727  }
728  }
729  }
730  return reco::GenParticleRef();
731  }
732 
733  template <class ObjectType>
735  auto match = std::lower_bound(overlapLabels_.cbegin(), overlapLabels_.cend(), label);
736  return ( match != overlapLabels_.end() && *match == label );
737  }
738 
739  template <class ObjectType>
741 
742  auto match = std::lower_bound(overlapLabels_.cbegin(), overlapLabels_.cend(), label);
743  if( match == overlapLabels_.cend() || *match != label ) return pat_statics::EMPTY_CPV;
744  return overlapItems_[std::distance(overlapLabels_.begin(),match)];
745  }
746 
747  template <class ObjectType>
749 
750  auto match = std::lower_bound(overlapLabels_.begin(), overlapLabels_.end(), label);
751  const auto dist = std::distance(overlapLabels_.begin(),match);
752  if ( match == overlapLabels_.end() || *match != label ) {
753  overlapLabels_.insert(match,label);
754  overlapItems_.insert(overlapItems_.begin()+dist,overlaps);
755  } else {
756  overlapItems_[dist] = overlaps;
757  }
758  }
759 
760  template <class ObjectType>
762  {
763  auto it = std::lower_bound(userDataLabels_.cbegin(),userDataLabels_.cend(),key);
764  if ( it != userDataLabels_.cend() && *it == key) {
765  return &userDataObjects_[std::distance(userDataLabels_.cbegin(),it)];
766  }
767  return nullptr;
768  }
769 
770  template <class ObjectType>
772  {
773  auto it = std::lower_bound(userFloatLabels_.cbegin(),userFloatLabels_.cend(),key);
774  if( it != userFloatLabels_.cend() && *it == key ) {
775  return userFloats_[std::distance(userFloatLabels_.cbegin(),it)];
776  }
777  throwMissingLabel("UserFloat",key,userFloatLabels_);
778  return std::numeric_limits<float>::quiet_NaN();
779  }
780 
781  template<class ObjectType>
782  std::vector<float> PATObject<ObjectType>::userFloatRange( const std::string& key ) const {
783  auto range = std::equal_range(userFloatLabels_.cbegin(),userFloatLabels_.cend(),key);
784  std::vector<float> result;
785  result.reserve(std::distance(range.first,range.second));
786  for( auto it = range.first; it != range.second; ++it ) {
787  result.push_back(userFloats_[std::distance(userFloatLabels_.cbegin(),it)]);
788  }
789  return result;
790  }
791 
792  template <class ObjectType>
794  float data,
795  const bool overwrite )
796  {
797  auto it = std::lower_bound(userFloatLabels_.begin(),userFloatLabels_.end(),label);
798  const auto dist = std::distance(userFloatLabels_.begin(),it);
799  if( it == userFloatLabels_.end() || *it != label ) {
800  userFloatLabels_.insert(it,label);
801  userFloats_.insert(userFloats_.begin()+dist,data);
802  } else if( *it == label ) {
803  //create a range by adding behind the first entry
804  userFloats_.insert(userFloats_.begin()+dist+1, data);
805  }
806  }
807 
808 
809  template <class ObjectType>
811  {
812  auto it = std::lower_bound(userIntLabels_.cbegin(), userIntLabels_.cend(), key);
813  if ( it != userIntLabels_.cend() && *it == key ) {
814  return userInts_[std::distance(userIntLabels_.cbegin(),it)];
815  }
816  throwMissingLabel("UserInt",key,userIntLabels_);
818  }
819 
820  template<class ObjectType>
821  std::vector<int> PATObject<ObjectType>::userIntRange( const std::string& key ) const{
822  auto range = std::equal_range(userIntLabels_.cbegin(),userIntLabels_.cend(),key);
823  std::vector<int> result;
824  result.reserve(std::distance(range.first,range.second));
825  for( auto it = range.first; it != range.second; ++it ) {
826  result.push_back(userInts_[std::distance(userIntLabels_.cbegin(),it)]);
827  }
828  return result;
829  }
830 
831  template <class ObjectType>
833  int data )
834  {
835  auto it = std::lower_bound(userIntLabels_.begin(),userIntLabels_.end(),label);
836  const auto dist = std::distance(userIntLabels_.begin(),it);
837  if( it == userIntLabels_.end() || *it != label ) {
838  userIntLabels_.insert(it,label);
839  userInts_.insert(userInts_.begin()+dist,data);
840  } else if( *it == label ) {
841  //create a range by adding behind the first entry
842  userInts_.insert(userInts_.begin()+dist+1,data);
843  }
844  }
845 
846  template <class ObjectType>
848  {
849  auto it = std::lower_bound(userCandLabels_.cbegin(), userCandLabels_.cend(), key);
850  if (it != userCandLabels_.cend()) {
851  return userCands_[std::distance(userCandLabels_.begin(),it)];
852  }
853  return reco::CandidatePtr();
854  }
855 
856  template <class ObjectType>
858  const reco::CandidatePtr & data,
859  const bool overwrite )
860  {
861  auto it = std::lower_bound(userCandLabels_.begin(),userCandLabels_.end(),label);
862  const auto dist = std::distance(userCandLabels_.begin(),it);
863  if( it == userCandLabels_.end() || *it != label ) {
864  userCandLabels_.insert(it,label);
865  userCands_.insert(userCands_.begin()+dist,data);
866  } else if( overwrite && *it == label ) {
867  userCands_[dist] = data;
868  } else {
869  edm::LogWarning("addUserCand")
870  << "Attempting to add userCand " << label << " failed, Ptr exists already!";
871  }
872  }
873 
874 
875  template <class ObjectType>
877  const bool has_unlabelled = (kinResolutionLabels_.size()+1 == kinResolutions_.size());
878  if (label.empty()) {
879  if ( has_unlabelled ) {
880  return kinResolutions_[0];
881  } else {
882  throw cms::Exception("Missing Data", "This object does not contain an un-labelled kinematic resolution");
883  }
884  } else {
885  auto match = std::lower_bound(kinResolutionLabels_.cbegin(), kinResolutionLabels_.cend(), label);
886  const auto dist = std::distance(kinResolutionLabels_.begin(),match);
887  const size_t increment = ( has_unlabelled ? 1 : 0 );
888  if ( match == kinResolutionLabels_.end() || *match != label ) {
889  cms::Exception ex("Missing Data");
890  ex << "This object does not contain a kinematic resolution with name '" << label << "'.\n";
891  ex << "The known labels are: " ;
892  for (std::vector<std::string>::const_iterator it = kinResolutionLabels_.cbegin(); it != kinResolutionLabels_.cend(); ++it) {
893  ex << "'" << *it << "' ";
894  }
895  ex << "\n";
896  throw ex;
897  } else {
898  return kinResolutions_[dist+increment];
899  }
900  }
901  }
902 
903  template <class ObjectType>
905  if (label.empty()) {
906  return (kinResolutionLabels_.size()+1 == kinResolutions_.size());
907  } else {
908  auto match = std::lower_bound(kinResolutionLabels_.cbegin(), kinResolutionLabels_.cend(), label);
909  return ( match != kinResolutionLabels_.cend() && *match == label );
910  }
911  }
912 
913  template <class ObjectType>
915  const bool has_unlabelled = (kinResolutionLabels_.size()+1 == kinResolutions_.size());
916  if (label.empty()) {
917  if (has_unlabelled) {
918  // There is already an un-labelled object. Replace it
919  kinResolutions_[0] = resol;
920  } else {
921  // Insert. Note that the un-labelled is always the first, so we need to insert before begin()
922  // (for an empty vector, this should not cost more than push_back)
923  kinResolutions_.insert(kinResolutions_.begin(), resol);
924  }
925  } else {
926  auto match = std::lower_bound(kinResolutionLabels_.begin(), kinResolutionLabels_.end(), label);
927  const auto dist = std::distance(kinResolutionLabels_.begin(),match);
928  const size_t increment = ( has_unlabelled ? 1 : 0 );
929  if ( match != kinResolutionLabels_.end() && *match == label ) {
930  // Existing object: replace
931  kinResolutions_[dist+increment] = resol;
932  } else {
933  kinResolutionLabels_.insert(match,label);
934  kinResolutions_.insert(kinResolutions_.begin()+dist+increment,resol);
935  }
936  }
937  }
938 
939 
940 
941 
942 }
943 
944 #endif
std::vector< std::string > efficiencyNames_
vector of the efficiencies (names)
Definition: PATObject.h:429
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:537
bool hasUserFloat(const char *key) const
a CINT-friendly interface
Definition: PATObject.h:339
void addUserCand(const std::string &label, const reco::CandidatePtr &data, const bool overwrite=false)
Set user-defined int.
Definition: PATObject.h:857
bool hasOverlaps(const std::string &label) const
Returns true if there was at least one overlap for this test label.
Definition: PATObject.h:734
const TriggerObjectStandAlone * triggerObjectMatchByPath(const std::string &namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1, const size_t idx=0) const
Definition: PATObject.h:196
int i
Definition: DBlmapReader.cc:9
virtual int pdgId() const
PDG identifier.
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const char *nameAlgorithm, const bool algoCondAccepted=true, const size_t idx=0) const
Definition: PATObject.h:144
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
std::vector< std::pair< std::string, pat::LookupTableRecord > > efficiencies() const
Returns the efficiencies as &lt;name,value&gt; pairs (by value)
Definition: PATObject.h:642
const TriggerObjectStandAlone * triggerObjectMatchByPath(const char *namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1, const size_t idx=0) const
Definition: PATObject.h:200
void addUserDataFromPtr(const std::string &label, const edm::Ptr< pat::UserData > &data)
Definition: PATObject.h:316
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const char *nameAlgorithm, const unsigned algoCondAccepted, const size_t idx=0) const
Definition: PATObject.h:152
double resolPhi(const LorentzVector &p4) const
Resolution on phi, given the 4-momentum of the associated Candidate.
static const HistoName names[]
std::vector< reco::GenParticleRef > genParticleRef_
Reference to a generator level particle.
Definition: PATObject.h:432
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:904
reco::GenParticleRef genParticleRef(size_t idx=0) const
Definition: PATObject.h:225
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:244
PATObject()
default constructor
Definition: PATObject.h:465
double resolP(const std::string &label="") const
Resolution on p, possibly with a label to specify which resolution to use.
Definition: PATObject.h:396
const TriggerObjectStandAlone * triggerObjectMatchByFilterID(const unsigned triggerObjectType, const size_t idx=0) const
Definition: PATObject.h:96
virtual int status() const
status word
size_t genParticlesSize() const
Number of generator level particles stored as ref or embedded.
Definition: PATObject.h:249
std::vector< reco::CandidatePtr > userCands_
Definition: PATObject.h:452
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const char *namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1) const
Definition: PATObject.h:182
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
Class to store the result of a lookup table fetch, e.g. for efficiencies.
const TriggerObjectStandAloneCollection triggerObjectMatchesByFilter(const std::string &labelFilter) const
get all matched HLT objects used in a certain HLT filter
Definition: PATObject.h:590
double resolPInv(const std::string &label="") const
Resolution on 1/p, possibly with a label to specify which resolution to use.
Definition: PATObject.h:402
bool hasUserFloat(const std::string &key) const
Return true if there is a user-defined float with a given name.
Definition: PATObject.h:334
std::vector< pat::CandKinResolution > kinResolutions_
Kinematic resolutions.
Definition: PATObject.h:455
double resolPz(const std::string &label="") const
Resolution on pz, possibly with a label to specify which resolution to use.
Definition: PATObject.h:411
const TriggerObjectStandAlone * triggerObjectMatchByCondition(const char *nameCondition, const size_t idx=0) const
Definition: PATObject.h:120
bool hasUserCand(const std::string &key) const
Return true if there is a user-defined int with a given name.
Definition: PATObject.h:364
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:793
std::vector< std::string > userCandLabels_
Definition: PATObject.h:451
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
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:685
std::vector< reco::GenParticleRef > genParticleRefs() const
Definition: PATObject.h:701
std::vector< float > userFloatRange(const std::string &key) const
return a range of values corresponding to key
Definition: PATObject.h:782
void setEfficiency(const std::string &name, const pat::LookupTableRecord &value)
Definition: PATObject.h:653
TriggerObjectStandAloneCollection triggerObjectMatchesEmbedded_
vector of trigger matches
Definition: PATObject.h:424
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
Definition: PATObject.h:669
std::vector< std::string > userDataLabels_
User data object.
Definition: PATObject.h:442
std::vector< reco::GenParticle > genParticleEmbedded_
vector to hold an embedded generator level particle
Definition: PATObject.h:434
const std::vector< std::string > & userCandNames() const
Get list of user-defined cand names.
Definition: PATObject.h:362
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
const std::vector< pat::LookupTableRecord > & efficiencyValues() const
Returns the list of the values of the stored efficiencies (the ordering is the same as in efficiencyN...
Definition: PATObject.h:217
std::vector< float > userFloats_
Definition: PATObject.h:446
float userFloat(const std::string &key) const
Definition: PATObject.h:771
virtual ~PATObject()
destructor
Definition: PATObject.h:63
#define embed
Definition: AMPTWrapper.h:178
void setKinResolution(const pat::CandKinResolution &resol, const std::string &label="")
Add a kinematic resolution to this object (possibly with a label)
Definition: PATObject.h:914
void unpackTriggerObjectPathNames(const edm::TriggerNames &names)
unpack path names of matched trigger objects (if they were packed before embedding, which is not normally the case)
Definition: PATObject.h:206
bool hasUserInt(const std::string &key) const
Return true if there is a user-defined int with a given name.
Definition: PATObject.h:351
double resolPt(const std::string &label="") const
Resolution on pt, possibly with a label to specify which resolution to use.
Definition: PATObject.h:399
const reco::CandidatePtrVector & overlaps(const std::string &label) const
Definition: PATObject.h:740
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const std::string &nameAlgorithm, const bool algoCondAccepted=true, const size_t idx=0) const
Definition: PATObject.h:579
double resolPz(const LorentzVector &p4) const
Resolution on pz, given the 4-momentum of the associated Candidate.
void push_back(D *&d)
Definition: OwnVector.h:280
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:599
std::vector< pat::LookupTableRecord > efficiencyValues_
vector of the efficiencies (values)
Definition: PATObject.h:427
double resolPy(const std::string &label="") const
Resolution on py, possibly with a label to specify which resolution to use.
Definition: PATObject.h:408
double resolEt(const std::string &label="") const
Resolution on et, possibly with a label to specify which resolution to use.
Definition: PATObject.h:393
double resolPx(const std::string &label="") const
Resolution on px, possibly with a label to specify which resolution to use.
Definition: PATObject.h:405
double resolP(const LorentzVector &p4) const
Resolution on p, given the 4-momentum of the associated Candidate.
void embedGenParticle()
Definition: PATObject.h:692
double resolPy(const LorentzVector &p4) const
Resolution on py, given the 4-momentum of the associated Candidate.
const TriggerObjectStandAlone * triggerObjectMatchByPath(const char *namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true, const size_t idx=0) const
Definition: PATObject.h:192
static const std::string EMPTY_STR("")
double p4[4]
Definition: TauolaWrapper.h:92
tuple result
Definition: query.py:137
virtual int charge() const
electric charge
Definition: LeafCandidate.h:91
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double resolEta(const LorentzVector &p4) const
Resolution on eta, given the 4-momentum of the associated Candidate.
std::vector< std::string > userFloatLabels_
Definition: PATObject.h:445
void throwMissingLabel(const std::string &what, const std::string &bad_label, const std::vector< std::string > &available)
const TriggerObjectStandAlone * triggerObjectMatch(const size_t idx=0) const
get one matched trigger object by index
Definition: PATObject.h:501
void addUserInt(const std::string &label, int32_t data)
Set user-defined int.
Definition: PATObject.h:832
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:280
const TriggerObjectStandAlone * triggerObjectMatchByFilter(const char *labelFilter, const size_t idx=0) const
Definition: PATObject.h:164
#define end
Definition: vmac.h:37
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:610
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
double resolPhi(const std::string &label="") const
Resolution on phi, possibly with a label to specify which resolution to use.
Definition: PATObject.h:387
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:498
const TriggerObjectStandAlone * triggerObjectMatchByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true, const size_t idx=0) const
Definition: PATObject.h:619
const TriggerObjectStandAloneCollection triggerObjectMatchesByCondition(const char *nameCondition) const
Definition: PATObject.h:114
bool hasUserData(const std::string &key) const
Check if user data with a specific type is present.
Definition: PATObject.h:286
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
double resolE(const std::string &label="") const
Resolution on energy, possibly with a label to specify which resolution to use.
Definition: PATObject.h:390
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const char *namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:174
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const std::string &nameAlgorithm, const bool algoCondAccepted=true) const
Definition: PATObject.h:570
ObjectType base_type
Definition: PATObject.h:52
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const char *nameAlgorithm, const bool algoCondAccepted=true) const
Definition: PATObject.h:128
double resolM(const LorentzVector &p4) const
std::vector< reco::CandidatePtrVector > overlapItems_
Overlapping items (sorted by distance)
Definition: PATObject.h:439
std::vector< std::string > kinResolutionLabels_
Definition: PATObject.h:458
void setOverlaps(const std::string &label, const reco::CandidatePtrVector &overlaps)
Definition: PATObject.h:748
const TriggerObjectStandAloneCollection triggerObjectMatchesByFilterID(const unsigned triggerObjectType) const
Definition: PATObject.h:87
void addUserData(const std::string &label, const T &data, bool transientOnly=false)
Definition: PATObject.h:309
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:676
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
double resolPInv(const LorentzVector &p4) const
Resolution on 1/p, given the 4-momentum of the associated Candidate.
pat::UserDataCollection userDataObjects_
Definition: PATObject.h:443
const TriggerObjectStandAloneCollection triggerObjectMatchesByCollection(const std::string &coll) const
get all matched trigger objects from a certain collection
Definition: PATObject.h:528
double resolPx(const LorentzVector &p4) const
Resolution on px, given the 4-momentum of the associated Candidate.
JetCorrectorParametersCollection coll
Definition: classes.h:10
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const std::string &nameAlgorithm, const unsigned algoCondAccepted) const
Definition: PATObject.h:132
const pat::UserData * userDataObject_(const std::string &key) const
Definition: PATObject.h:761
int32_t userInt(const std::string &key) const
Definition: PATObject.h:810
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
const TriggerObjectStandAlone * triggerObjectMatchByType(const unsigned triggerObjectType, const size_t idx=0) const
Definition: PATObject.h:92
void addTriggerObjectMatch(const TriggerObjectStandAlone &trigObj)
add a trigger match
Definition: PATObject.h:204
const std::vector< std::string > & userDataNames() const
Get list of user data object names.
Definition: PATObject.h:295
const TriggerObjectStandAlone * triggerObjectMatchByAlgorithm(const std::string &nameAlgorithm, const unsigned algoCondAccepted, const size_t idx=0) const
Definition: PATObject.h:148
const TriggerObjectStandAloneCollection & triggerObjectMatches() const
get all matched trigger objects
Definition: PATObject.h:77
const void * userDataBare(const std::string &key) const
Definition: PATObject.h:299
reco::CandidatePtr userCand(const std::string &key) const
Definition: PATObject.h:847
const TriggerObjectStandAlone * triggerObjectMatchByCollection(const char *coll, const size_t idx=0) const
Definition: PATObject.h:108
const TriggerObjectStandAloneCollection triggerObjectMatchesByType(const unsigned triggerObjectType) const
Definition: PATObject.h:83
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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:559
virtual const std::string & typeName() const =0
Human readable name of the concrete type of stored data.
double resolE(const LorentzVector &p4) const
Resolution on energy, given the 4-momentum of the associated Candidate.
const TriggerObjectStandAloneCollection triggerObjectMatchesByType(const trigger::TriggerObjectType triggerObjectType) const
Definition: PATObject.h:508
const TriggerObjectStandAloneCollection triggerObjectMatchesByCollection(const char *coll) const
Definition: PATObject.h:102
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:550
float userFloat(const char *key) const
a CINT-friendly interface
Definition: PATObject.h:327
const pat::LookupTableRecord & efficiency(const std::string &name) const
Returns an efficiency given its name.
Definition: PATObject.h:631
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const unsigned pathLastFilterAccepted, const unsigned pathL3FilterAccepted=1) const
Definition: PATObject.h:178
const reco::Candidate * originalObject() const
access to the original object; returns zero for null Ref and throws for unavailable collection ...
Definition: PATObject.h:485
Templated PAT object container.
Definition: PATObject.h:49
const pat::CandKinResolution & getKinResolution(const std::string &label="") const
Definition: PATObject.h:876
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:517
double resolTheta(const std::string &label="") const
Resolution on theta, possibly with a label to specify which resolution to use.
Definition: PATObject.h:384
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
Base class for data that users can add to pat objects.
Definition: UserData.h:24
std::vector< int > userIntRange(const std::string &key) const
returns a range of values corresponding to key
Definition: PATObject.h:821
std::vector< std::string > overlapLabels_
Overlapping test labels (only if there are any overlaps)
Definition: PATObject.h:437
double resolEt(const LorentzVector &p4) const
Resolution on et, given the 4-momentum of the associated Candidate.
const std::vector< std::string > & userFloatNames() const
Get list of user-defined float names.
Definition: PATObject.h:332
double resolPt(const LorentzVector &p4) const
Resolution on pt, given the 4-momentum of the associated Candidate.
tuple status
Definition: ntuplemaker.py:245
static const reco::CandidatePtrVector EMPTY_CPV
Definition: PATObject.h:44
std::vector< int32_t > userInts_
Definition: PATObject.h:449
const TriggerObjectStandAloneCollection triggerObjectMatchesByFilter(const char *labelFilter) const
Definition: PATObject.h:158
long double T
const std::vector< std::string > & userIntNames() const
Get list of user-defined int names.
Definition: PATObject.h:349
const TriggerObjectStandAloneCollection triggerObjectMatchesByAlgorithm(const char *nameAlgorithm, const unsigned algoCondAccepted) const
Definition: PATObject.h:136
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:421
tuple size
Write out results.
double resolM(const std::string &label="") const
Definition: PATObject.h:415
reco::GenParticleRef genParticleById(int pdgId, int status, uint8_t autoCharge=0) const
Definition: PATObject.h:711
const void * bareData() const
Definition: UserData.h:49
T get(const Candidate &c)
Definition: component.h:55
double resolEta(const std::string &label="") const
Resolution on eta, possibly with a label to specify which resolution to use.
Definition: PATObject.h:381
const std::string & userDataObjectType(const std::string &key) const
Get human-readable type of user data object, for debugging.
Definition: PATObject.h:290
const std::vector< std::string > & efficiencyNames() const
Returns the list of the names of the stored efficiencies.
Definition: PATObject.h:215
Analysis-level trigger object class (stand-alone)
double resolTheta(const LorentzVector &p4) const
Resolution on theta, given the 4-momentum of the associated Candidate.
std::vector< std::string > userIntLabels_
Definition: PATObject.h:448
const std::vector< std::string > & overlapLabels() const
Returns the labels of the overlap tests that found at least one overlap.
Definition: PATObject.h:273