CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
pat::PackedTriggerPrescales Class Reference

#include <PackedTriggerPrescales.h>

Public Member Functions

void addPrescaledTrigger (int index, double prescale)
 
template<typename T = int>
T getPrescaleForIndex (int index) const
 
template<typename T = int>
T getPrescaleForName (const std::string &name, bool prefixOnly=false) const
 
 PackedTriggerPrescales ()
 
 PackedTriggerPrescales (const edm::Handle< edm::TriggerResults > &handle)
 
void setTriggerNames (const edm::TriggerNames &names)
 
const edm::TriggerResultstriggerResults () const
 
 ~PackedTriggerPrescales ()=default
 

Protected Attributes

std::vector< double > prescaleValues_
 
const edm::TriggerNamestriggerNames_
 
edm::RefCore triggerResults_
 

Detailed Description

Definition at line 13 of file PackedTriggerPrescales.h.

Constructor & Destructor Documentation

◆ PackedTriggerPrescales() [1/2]

pat::PackedTriggerPrescales::PackedTriggerPrescales ( )
inline

Definition at line 15 of file PackedTriggerPrescales.h.

15 : triggerNames_(nullptr) {}
const edm::TriggerNames * triggerNames_

◆ PackedTriggerPrescales() [2/2]

pat::PackedTriggerPrescales::PackedTriggerPrescales ( const edm::Handle< edm::TriggerResults > &  handle)

Definition at line 4 of file PackedTriggerPrescales.cc.

References patZpeak::handle, and prescaleValues_.

◆ ~PackedTriggerPrescales()

pat::PackedTriggerPrescales::~PackedTriggerPrescales ( )
default

Member Function Documentation

◆ addPrescaledTrigger()

void pat::PackedTriggerPrescales::addPrescaledTrigger ( int  index,
double  prescale 
)

Definition at line 9 of file PackedTriggerPrescales.cc.

References Exception, setupCalibrationTree_cff::prescale, findQualityFiles::size, and triggerResults.

9  {
10  if (unsigned(index) >= triggerResults().size())
11  throw cms::Exception("InvalidReference", "Index out of bounds");
13 }
size
Write out results.
const edm::TriggerResults & triggerResults() const
std::vector< double > prescaleValues_

◆ getPrescaleForIndex()

template<typename T >
T pat::PackedTriggerPrescales::getPrescaleForIndex ( int  index) const

Definition at line 48 of file PackedTriggerPrescales.h.

References Exception, prescaleValues_, and triggerResults().

48  {
49  static_assert(std::is_same_v<T, double>,
50  "\n\n\tPlease use getPrescaleForIndex<double> "
51  "(other types for trigger prescales are not supported anymore by PackedTriggerPrescales)");
52  if (unsigned(index) >= triggerResults().size())
53  throw cms::Exception("InvalidReference", "Index out of bounds");
54  return prescaleValues_[index];
55  }
size
Write out results.
const edm::TriggerResults & triggerResults() const
std::vector< double > prescaleValues_

◆ getPrescaleForName()

template<typename T >
T pat::PackedTriggerPrescales::getPrescaleForName ( const std::string &  name,
bool  prefixOnly = false 
) const

Definition at line 58 of file PackedTriggerPrescales.h.

References Exception, mps_fire::i, create_idmaps::n, mergeVDriftHistosByStation::name, names, edm::TriggerNames::triggerIndex(), edm::TriggerNames::triggerNames(), and triggerNames_.

58  {
59  static_assert(std::is_same_v<T, double>,
60  "\n\n\tPlease use getPrescaleForName<double> "
61  "(other types for trigger prescales are not supported anymore by PackedTriggerPrescales)");
62  if (triggerNames_ == nullptr)
63  throw cms::Exception("LogicError", "getPrescaleForName called without having called setTriggerNames first");
64  if (prefixOnly) {
65  auto const &names = triggerNames_->triggerNames();
66  if (name.empty())
67  throw cms::Exception("EmptyName",
68  "getPrescaleForName called with invalid arguments (name is empty, prefixOnly=true");
69  size_t siz = name.length() - 1;
70  while (siz > 0 && (name[siz] == '*' || name[siz] == '\0'))
71  siz--;
72  for (unsigned int i = 0, n = names.size(); i < n; ++i) {
73  if (strncmp(name.c_str(), names[i].c_str(), siz) == 0) {
74  return getPrescaleForIndex<T>(i);
75  }
76  }
77  throw cms::Exception("InvalidReference", "Index out of bounds");
78  } else {
80  return getPrescaleForIndex<T>(index);
81  }
82  }
Strings const & triggerNames() const
Definition: TriggerNames.cc:48
const std::string names[nVars_]
unsigned int triggerIndex(std::string_view name) const
Definition: TriggerNames.cc:52
const edm::TriggerNames * triggerNames_

◆ setTriggerNames()

void pat::PackedTriggerPrescales::setTriggerNames ( const edm::TriggerNames names)
inline

Definition at line 36 of file PackedTriggerPrescales.h.

References names, and triggerNames_.

36 { triggerNames_ = &names; }
const std::string names[nVars_]
const edm::TriggerNames * triggerNames_

◆ triggerResults()

const edm::TriggerResults& pat::PackedTriggerPrescales::triggerResults ( ) const
inline

Definition at line 32 of file PackedTriggerPrescales.h.

References triggerResults_.

Referenced by getPrescaleForIndex().

32 { return *edm::getProduct<edm::TriggerResults>(triggerResults_); }

Member Data Documentation

◆ prescaleValues_

std::vector<double> pat::PackedTriggerPrescales::prescaleValues_
protected

Definition at line 42 of file PackedTriggerPrescales.h.

Referenced by getPrescaleForIndex(), and PackedTriggerPrescales().

◆ triggerNames_

const edm::TriggerNames* pat::PackedTriggerPrescales::triggerNames_
protected

Definition at line 44 of file PackedTriggerPrescales.h.

Referenced by getPrescaleForName(), and setTriggerNames().

◆ triggerResults_

edm::RefCore pat::PackedTriggerPrescales::triggerResults_
protected

Definition at line 43 of file PackedTriggerPrescales.h.

Referenced by triggerResults().