CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
pat::EventHypothesis Class Reference

#include <EventHypothesis.h>

Classes

class  ByRole
 

Public Types

typedef eventhypothesis::Looper< reco::CandidateCandLooper
 
typedef eventhypothesis::CandRefType CandRefType
 
typedef vector_type::const_iterator const_iterator
 
typedef vector_type::const_reverse_iterator const_reverse_iterator
 
typedef eventhypothesis::ParticleFilter ParticleFilter
 
typedef eventhypothesis::ParticleFilterPtr ParticleFilterPtr
 
typedef std::pair< std::string, CandRefTypevalue_type
 
typedef std::vector< value_typevector_type
 

Public Member Functions

void add (const CandRefType &ref, const std::string &role)
 
std::vector< CandRefTypeall (const ParticleFilter &filter) const
 Return EDM references to all particles which satisfy some condition. More...
 
std::vector< CandRefTypeall (const std::string &roleRegexp) const
 Return EDM references to all particles which have certaint roles. More...
 
const_iterator begin () const
 
size_t count () const
 
size_t count (const ParticleFilter &role) const
 Counts particles which satisfy some condition. More...
 
size_t count (const std::string &roleRegexp) const
 Counts particles which have certaint roles. More...
 
const_iterator end () const
 
const CandRefTypeget (const ParticleFilter &filter, int index=0) const
 
const CandRefTypeget (const std::string &role, int index=0) const
 
template<typename T >
const TgetAs (const ParticleFilter &filter, int index=0) const
 
template<typename T >
const TgetAs (const std::string &role, int index=0) const
 
CandLooper loop () const
 Loops over all particles. More...
 
CandLooper loop (const ParticleFilter &filter) const
 
CandLooper loop (const ParticleFilter *filter) const
 
CandLooper loop (const ParticleFilterPtr &filter) const
 Loops over particles which satisfy some condition. More...
 
CandLooper loop (const std::string &roleRegexp) const
 Loops over particles which have certaint roles. More...
 
template<typename T >
eventhypothesis::Looper< TloopAs (const ParticleFilter &filter) const
 
template<typename T >
eventhypothesis::Looper< TloopAs (const ParticleFilter *filter) const
 
template<typename T >
eventhypothesis::Looper< TloopAs (const ParticleFilterPtr &filter) const
 Loops over particles which satisfy some condition. More...
 
template<typename T >
eventhypothesis::Looper< TloopAs (const std::string &roleRegexp) const
 Loops over particles which have certaint roles. More...
 
const CandRefTypeoperator[] (const ParticleFilter &filter) const
 
const CandRefTypeoperator[] (const std::string &role) const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 

Private Member Functions

template<typename T >
std::string createExceptionMessage (const CandRefType &ref) const
 
char * getDemangledSymbol (const char *mangledSymbol) const
 
template<typename Iterator , typename Predicate >
Iterator realGet (const Iterator &realBegin, const Iterator &realEnd, const Predicate &p, size_t idx) const
 

Private Attributes

std::vector< value_typeparticles_
 

Detailed Description

Definition at line 33 of file EventHypothesis.h.

Member Typedef Documentation

◆ CandLooper

Definition at line 40 of file EventHypothesis.h.

◆ CandRefType

Definition at line 35 of file EventHypothesis.h.

◆ const_iterator

typedef vector_type::const_iterator pat::EventHypothesis::const_iterator

Definition at line 38 of file EventHypothesis.h.

◆ const_reverse_iterator

typedef vector_type::const_reverse_iterator pat::EventHypothesis::const_reverse_iterator

Definition at line 39 of file EventHypothesis.h.

◆ ParticleFilter

Definition at line 58 of file EventHypothesis.h.

◆ ParticleFilterPtr

Definition at line 59 of file EventHypothesis.h.

◆ value_type

typedef std::pair<std::string, CandRefType> pat::EventHypothesis::value_type

Definition at line 36 of file EventHypothesis.h.

◆ vector_type

Definition at line 37 of file EventHypothesis.h.

Member Function Documentation

◆ add()

void pat::EventHypothesis::add ( const CandRefType ref,
const std::string &  role 
)

Definition at line 10 of file EventHypothesis.cc.

10  {
11  particles_.push_back(value_type(role, ref));
12 }

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

◆ all() [1/2]

std::vector< pat::EventHypothesis::CandRefType > pat::EventHypothesis::all ( const ParticleFilter filter) const

Return EDM references to all particles which satisfy some condition.

Definition at line 52 of file EventHypothesis.cc.

52  {
53  std::vector<pat::EventHypothesis::CandRefType> ret;
54  for (const_iterator it = begin(); it != end(); ++it) {
55  if (filter(*it))
56  ret.push_back(it->second);
57  }
58  return ret;
59 }

References begin, end, ALCARECOTkAlBeamHalo_cff::filter, and runTheMatrix::ret.

◆ all() [2/2]

std::vector< pat::EventHypothesis::CandRefType > pat::EventHypothesis::all ( const std::string &  roleRegexp) const

Return EDM references to all particles which have certaint roles.

Definition at line 48 of file EventHypothesis.cc.

48  {
49  return all(pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
50 }

References python.cmstools::all().

◆ begin()

const_iterator pat::EventHypothesis::begin ( void  ) const
inline

Definition at line 44 of file EventHypothesis.h.

44 { return particles_.begin(); }

References particles_.

Referenced by pat::eventhypothesis::Looper< T >::globalIndex().

◆ count() [1/3]

size_t pat::EventHypothesis::count ( void  ) const
inline

Definition at line 75 of file EventHypothesis.h.

75 { return particles_.size(); }

References particles_.

◆ count() [2/3]

size_t pat::EventHypothesis::count ( const ParticleFilter role) const

Counts particles which satisfy some condition.

Definition at line 65 of file EventHypothesis.cc.

65  {
66  size_t n = 0;
67  for (const_iterator it = begin(); it != end(); ++it) {
68  if (role(*it))
69  ++n;
70  }
71  return n;
72 }

References begin, end, and dqmiodumpmetadata::n.

◆ count() [3/3]

size_t pat::EventHypothesis::count ( const std::string &  roleRegexp) const

Counts particles which have certaint roles.

Definition at line 61 of file EventHypothesis.cc.

61  {
63 }

References KineDebug3::count().

◆ createExceptionMessage()

template<typename T >
std::string pat::EventHypothesis::createExceptionMessage ( const CandRefType ref) const
private

Definition at line 160 of file EventHypothesis.h.

160  {
161  std::stringstream message;
162  char *currentType = getDemangledSymbol(typeid(std::remove_reference<decltype(ref)>::type::value_type).name());
163  char *targetType = getDemangledSymbol(typeid(T).name());
164  if (currentType != nullptr && targetType != nullptr) {
165  message << "You can't convert a '" << currentType << "' to a '" << targetType << "'" << std::endl;
166  free(currentType);
167  free(targetType);
168  } else {
169  message << "You can't convert a '" << typeid(ref).name() << "' to a '" << typeid(T).name() << "'" << std::endl;
170  message << "Note: you can use 'c++filt -t' command to convert the above in human readable types." << std::endl;
171  }
172  return message.str();
173  }

References getDemangledSymbol(), and Skims_PA_cff::name.

◆ end()

const_iterator pat::EventHypothesis::end ( void  ) const
inline

Definition at line 45 of file EventHypothesis.h.

45 { return particles_.end(); }

References particles_.

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

◆ get() [1/2]

const pat::EventHypothesis::CandRefType & pat::EventHypothesis::get ( const ParticleFilter filter,
int  index = 0 
) const

◆ get() [2/2]

const pat::EventHypothesis::CandRefType & pat::EventHypothesis::get ( const std::string &  role,
int  index = 0 
) const

Definition at line 14 of file EventHypothesis.cc.

14  {
15  if (index >= 0) {
16  const_iterator it = realGet(begin(), end(), ByRole(role), index);
17  if (it == end()) {
18  throw cms::Exception("Index not found")
19  << "Can't find a particle with role " << role << " and index " << index << "\n";
20  }
21  return it->second;
22  } else {
23  const_reverse_iterator it = realGet(rbegin(), rend(), ByRole(role), -index);
24  if (it == rend()) {
25  throw cms::Exception("Index not found")
26  << "Can't find a particle with role " << role << " and index " << index << "\n";
27  }
28  return it->second;
29  }
30 }

References begin, end, and Exception.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), util.rrapi.RRApi::columns(), rrapi.RRApi::columns(), rrapi.RRApi::count(), util.rrapi.RRApi::count(), rrapi.RRApi::data(), util.rrapi.RRApi::data(), getAs(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), operator[](), util.rrapi.RRApi::report(), rrapi.RRApi::report(), rrapi.RRApi::reports(), util.rrapi.RRApi::reports(), rrapi.RRApi::tables(), util.rrapi.RRApi::tables(), util.rrapi.RRApi::tags(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), util.rrapi.RRApi::templates(), util.rrapi.RRApi::workspaces(), and rrapi.RRApi::workspaces().

◆ getAs() [1/2]

template<typename T >
const T * pat::EventHypothesis::getAs ( const ParticleFilter filter,
int  index = 0 
) const

Definition at line 184 of file EventHypothesis.h.

184  {
185  CandRefType ref = get(filter, index);
186  const T *ret = dynamic_cast<const T *>(ref.get());
187  if ((ret == 0) && (ref.get() != nullptr))
188  throw cms::Exception("Type Checking") << createExceptionMessage<T>(ref);
189  return ret;
190  }

References Exception, ALCARECOTkAlBeamHalo_cff::filter, get(), edm::Ptr< T >::get(), and runTheMatrix::ret.

◆ getAs() [2/2]

template<typename T >
const T * pat::EventHypothesis::getAs ( const std::string &  role,
int  index = 0 
) const

Definition at line 176 of file EventHypothesis.h.

176  {
177  CandRefType ref = get(role, index);
178  const T *ret = dynamic_cast<const T *>(ref.get());
179  if ((ret == nullptr) && (ref.get() != nullptr))
180  throw cms::Exception("Type Checking") << createExceptionMessage<T>(ref);
181  return ret;
182  }

References Exception, get(), edm::Ptr< T >::get(), and runTheMatrix::ret.

◆ getDemangledSymbol()

char * pat::EventHypothesis::getDemangledSymbol ( const char *  mangledSymbol) const
private

Definition at line 4 of file EventHypothesis.cc.

4  {
5  int status;
6  char *demangledSymbol = abi::__cxa_demangle(mangledSymbol, nullptr, nullptr, &status);
7  return (status == 0) ? demangledSymbol : nullptr;
8 }

References mps_update::status.

Referenced by createExceptionMessage().

◆ loop() [1/5]

pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( ) const

Loops over all particles.

Definition at line 74 of file EventHypothesis.cc.

74  {
76 }

References pat::eventhypothesis::AcceptAllFilter::get(), and heppy_loop::loop.

◆ loop() [2/5]

pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( const ParticleFilter filter) const

Loops over particles which satisfy some condition. The caller code owns the filter, and must take care it is not deleted while the looper is still being used

Definition at line 82 of file EventHypothesis.cc.

82  {
83  return CandLooper(*this, role);
84 }

◆ loop() [3/5]

pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( const ParticleFilter filter) const

Loops over particles which satisfy some condition. The looper owns the filter, which will be deleted when the looper is deleted. That is, you can call eventHypothesis.loop(new WhateverFilterYouLike(...))

Definition at line 86 of file EventHypothesis.cc.

86  {
87  return CandLooper(*this, role);
88 }

◆ loop() [4/5]

pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( const ParticleFilterPtr filter) const

Loops over particles which satisfy some condition.

Definition at line 90 of file EventHypothesis.cc.

90  {
91  return CandLooper(*this, role);
92 }

◆ loop() [5/5]

pat::EventHypothesis::CandLooper pat::EventHypothesis::loop ( const std::string &  roleRegexp) const

Loops over particles which have certaint roles.

Definition at line 78 of file EventHypothesis.cc.

78  {
79  return loop(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
80 }

References heppy_loop::loop.

◆ loopAs() [1/4]

template<typename T >
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs ( const ParticleFilter filter) const

Loops over particles which satisfy some condition. The caller code owns the filter, and must take care it is not deleted while the looper is still being used

Definition at line 197 of file EventHypothesis.h.

197  {
198  return pat::eventhypothesis::Looper<T>(*this, role);
199  }

◆ loopAs() [2/4]

template<typename T >
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs ( const ParticleFilter filter) const

Loops over particles which satisfy some condition. The looper owns the filter, which will be deleted when the looper is deleted. That is, you can call eventHypothesis.loopAs<...>(new WhateverFilterYouLike(...))

Definition at line 202 of file EventHypothesis.h.

202  {
203  return pat::eventhypothesis::Looper<T>(*this, role);
204  }

◆ loopAs() [3/4]

template<typename T >
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs ( const ParticleFilterPtr filter) const

Loops over particles which satisfy some condition.

Definition at line 207 of file EventHypothesis.h.

207  {
208  return pat::eventhypothesis::Looper<T>(*this, role);
209  }

◆ loopAs() [4/4]

template<typename T >
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs ( const std::string &  roleRegexp) const

Loops over particles which have certaint roles.

Definition at line 192 of file EventHypothesis.h.

192  {
193  return loopAs<T>(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
194  }

◆ operator[]() [1/2]

const CandRefType& pat::EventHypothesis::operator[] ( const ParticleFilter filter) const
inline

Definition at line 68 of file EventHypothesis.h.

68 { return get(filter, 0); }

References ALCARECOTkAlBeamHalo_cff::filter, and get().

◆ operator[]() [2/2]

const CandRefType& pat::EventHypothesis::operator[] ( const std::string &  role) const
inline

Definition at line 67 of file EventHypothesis.h.

67 { return get(role, 0); }

References get().

◆ rbegin()

const_reverse_iterator pat::EventHypothesis::rbegin ( ) const
inline

Definition at line 46 of file EventHypothesis.h.

46 { return particles_.rbegin(); }

References particles_.

◆ realGet()

template<typename Iterator , typename Predicate >
Iterator pat::EventHypothesis::realGet ( const Iterator realBegin,
const Iterator realEnd,
const Predicate &  p,
size_t  idx 
) const
private

Definition at line 143 of file EventHypothesis.h.

146  {
147  Iterator it = realBegin;
148  while (it != realEnd) {
149  if (pred(*it)) {
150  if (idx == 0)
151  return it;
152  idx--;
153  }
154  ++it;
155  }
156  return it;
157  }

References training_settings::idx.

◆ rend()

const_reverse_iterator pat::EventHypothesis::rend ( ) const
inline

Definition at line 47 of file EventHypothesis.h.

47 { return particles_.rend(); }

References particles_.

Member Data Documentation

◆ particles_

std::vector<value_type> pat::EventHypothesis::particles_
private

Definition at line 118 of file EventHypothesis.h.

Referenced by begin(), count(), end(), rbegin(), and rend().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
pat::EventHypothesis::count
size_t count() const
Definition: EventHypothesis.h:75
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
pat::EventHypothesis::CandLooper
eventhypothesis::Looper< reco::Candidate > CandLooper
Definition: EventHypothesis.h:40
mps_update.status
status
Definition: mps_update.py:69
pat::EventHypothesis::const_iterator
vector_type::const_iterator const_iterator
Definition: EventHypothesis.h:38
pat::EventHypothesis::begin
const_iterator begin() const
Definition: EventHypothesis.h:44
pat::EventHypothesis::CandRefType
eventhypothesis::CandRefType CandRefType
Definition: EventHypothesis.h:35
pat::EventHypothesis::loop
CandLooper loop() const
Loops over all particles.
Definition: EventHypothesis.cc:74
Iterator
Definition: DQMStoreStats.h:94
training_settings.idx
idx
Definition: training_settings.py:16
pat::EventHypothesis::const_reverse_iterator
vector_type::const_reverse_iterator const_reverse_iterator
Definition: EventHypothesis.h:39
pat::EventHypothesis::all
std::vector< CandRefType > all(const std::string &roleRegexp) const
Return EDM references to all particles which have certaint roles.
Definition: EventHypothesis.cc:48
pat::EventHypothesis::particles_
std::vector< value_type > particles_
Definition: EventHypothesis.h:118
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
pat::EventHypothesis::rend
const_reverse_iterator rend() const
Definition: EventHypothesis.h:47
pat::eventhypothesis::AcceptAllFilter::get
static const AcceptAllFilter & get()
Definition: EventHypothesis.h:124
pat::eventhypothesis::RoleRegexpFilter
Definition: EventHypothesis.h:130
pat::EventHypothesis::getDemangledSymbol
char * getDemangledSymbol(const char *mangledSymbol) const
Definition: EventHypothesis.cc:4
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
pat::EventHypothesis::rbegin
const_reverse_iterator rbegin() const
Definition: EventHypothesis.h:46
pat::EventHypothesis::realGet
Iterator realGet(const Iterator &realBegin, const Iterator &realEnd, const Predicate &p, size_t idx) const
Definition: EventHypothesis.h:143
pat::eventhypothesis::Looper
Definition: EventHypothesis.h:17
pat::EventHypothesis::end
const_iterator end() const
Definition: EventHypothesis.h:45
T
long double T
Definition: Basic3DVectorLD.h:48
Exception
Definition: hltDiff.cc:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
pat::EventHypothesis::value_type
std::pair< std::string, CandRefType > value_type
Definition: EventHypothesis.h:36
pat::EventHypothesis::get
const CandRefType & get(const std::string &role, int index=0) const
Definition: EventHypothesis.cc:14