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 std::string &roleRegexp) const
 Return EDM references to all particles which have certaint roles. More...
 
std::vector< CandRefTypeall (const ParticleFilter &filter) const
 Return EDM references to all particles which satisfy some condition. More...
 
const_iterator begin () const
 
size_t count () const
 
size_t count (const std::string &roleRegexp) const
 Counts particles which have certaint roles. More...
 
size_t count (const ParticleFilter &role) const
 Counts particles which satisfy some condition. More...
 
const_iterator end () const
 
const CandRefTypeget (const std::string &role, int index=0) const
 
const CandRefTypeget (const ParticleFilter &filter, int index=0) const
 
template<typename T >
const TgetAs (const std::string &role, int index=0) const
 
template<typename T >
const TgetAs (const ParticleFilter &filter, int index=0) const
 
CandLooper loop () const
 Loops over all particles. More...
 
CandLooper loop (const std::string &roleRegexp) const
 Loops over particles which have certaint roles. 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...
 
template<typename T >
eventhypothesis::Looper< TloopAs (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...
 
const CandRefTypeoperator[] (const std::string &role) const
 
const CandRefTypeoperator[] (const ParticleFilter &filter) 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.

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

10  {
11  particles_.push_back(value_type(role, ref));
12 }
std::vector< value_type > particles_
std::pair< std::string, CandRefType > value_type

◆ all() [1/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.

References python.cmstools::all().

48  {
49  return all(pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
50 }
std::vector< CandRefType > all(const std::string &roleRegexp) const
Return EDM references to all particles which have certaint roles.

◆ all() [2/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.

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

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 }
const_iterator end() const
ret
prodAgent to be discontinued
const_iterator begin() const
vector_type::const_iterator const_iterator

◆ begin()

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

Definition at line 44 of file EventHypothesis.h.

References particles_.

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

44 { return particles_.begin(); }
std::vector< value_type > particles_

◆ count() [1/3]

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

Definition at line 75 of file EventHypothesis.h.

References particles_.

75 { return particles_.size(); }
std::vector< value_type > particles_

◆ count() [2/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.

References submitPVResolutionJobs::count.

◆ count() [3/3]

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

Counts particles which satisfy some condition.

Definition at line 65 of file EventHypothesis.cc.

References dqmiodumpmetadata::n.

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 }
const_iterator end() const
const_iterator begin() const
vector_type::const_iterator const_iterator

◆ createExceptionMessage()

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

Definition at line 160 of file EventHypothesis.h.

References getDemangledSymbol(), and Skims_PA_cff::name.

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  }
char * getDemangledSymbol(const char *mangledSymbol) const
long double T

◆ end()

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

Definition at line 45 of file EventHypothesis.h.

References particles_.

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

45 { return particles_.end(); }
std::vector< value_type > particles_

◆ get() [1/2]

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

Definition at line 14 of file EventHypothesis.cc.

References Exception.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), submitPVValidationJobs.BetterConfigParser::__updateDict(), util.rrapi.RRApi::columns(), rrapi.RRApi::columns(), rrapi.RRApi::count(), util.rrapi.RRApi::count(), rrapi.RRApi::data(), util.rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), submitPVValidationJobs.BetterConfigParser::getResultingSection(), 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().

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 }
const_iterator end() const
const_reverse_iterator rend() const
Iterator realGet(const Iterator &realBegin, const Iterator &realEnd, const Predicate &p, size_t idx) const
const_iterator begin() const
vector_type::const_iterator const_iterator
const_reverse_iterator rbegin() const
vector_type::const_reverse_iterator const_reverse_iterator

◆ get() [2/2]

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

Definition at line 32 of file EventHypothesis.cc.

References Exception, and ALCARECOTkAlBeamHalo_cff::filter.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), submitPVValidationJobs.BetterConfigParser::__updateDict(), util.rrapi.RRApi::columns(), rrapi.RRApi::columns(), rrapi.RRApi::count(), util.rrapi.RRApi::count(), rrapi.RRApi::data(), util.rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), submitPVValidationJobs.BetterConfigParser::getResultingSection(), 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().

32  {
33  if (index >= 0) {
35  if (it == end()) {
36  throw cms::Exception("Index not found") << "Can't find a particle matching filter with index " << index << "\n";
37  }
38  return it->second;
39  } else {
41  if (it == rend()) {
42  throw cms::Exception("Index not found") << "Can't find a particle matching filter with index " << index << "\n";
43  }
44  return it->second;
45  }
46 }
const_iterator end() const
const_reverse_iterator rend() const
Iterator realGet(const Iterator &realBegin, const Iterator &realEnd, const Predicate &p, size_t idx) const
const_iterator begin() const
vector_type::const_iterator const_iterator
const_reverse_iterator rbegin() const
vector_type::const_reverse_iterator const_reverse_iterator

◆ getAs() [1/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.

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

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  }
ret
prodAgent to be discontinued
eventhypothesis::CandRefType CandRefType
long double T

◆ getAs() [2/2]

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

Definition at line 184 of file EventHypothesis.h.

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

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  }
ret
prodAgent to be discontinued
eventhypothesis::CandRefType CandRefType
long double T

◆ getDemangledSymbol()

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

Definition at line 4 of file EventHypothesis.cc.

References mps_update::status.

Referenced by createExceptionMessage().

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

◆ loop() [1/5]

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

Loops over all particles.

Definition at line 74 of file EventHypothesis.cc.

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

74  {
76 }
static const AcceptAllFilter & get()
CandLooper loop() const
Loops over all particles.

◆ loop() [2/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.

References heppy_loop::loop.

78  {
79  return loop(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp));
80 }
CandLooper loop() const
Loops over all particles.

◆ loop() [3/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 }
eventhypothesis::Looper< reco::Candidate > CandLooper

◆ loop() [4/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 }
eventhypothesis::Looper< reco::Candidate > CandLooper

◆ loop() [5/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 }
eventhypothesis::Looper< reco::Candidate > CandLooper

◆ loopAs() [1/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  }

◆ loopAs() [2/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() [3/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() [4/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  }

◆ operator[]() [1/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); }

◆ operator[]() [2/2]

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

Definition at line 68 of file EventHypothesis.h.

References ALCARECOTkAlBeamHalo_cff::filter.

◆ rbegin()

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

Definition at line 46 of file EventHypothesis.h.

References particles_.

46 { return particles_.rbegin(); }
std::vector< value_type > 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.

References heavyIonCSV_trainingSettings::idx.

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  }

◆ rend()

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

Definition at line 47 of file EventHypothesis.h.

References particles_.

47 { return particles_.rend(); }
std::vector< value_type > 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().