CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
egHLT::TrigCodes Class Reference

#include <EgHLTTrigCodes.h>

Public Types

using TrigBitSet = std::bitset< maxNrBits_ >
 

Public Member Functions

TrigBitSet getCode (const char *descript) const
 
TrigBitSet getCode (const std::string &descript) const
 
TrigCodesoperator= (const TrigCodes &)=delete
 
 TrigCodes (const TrigCodes &)=delete
 
 ~TrigCodes ()=default
 

Static Public Member Functions

static TrigCodesmakeCodes (std::vector< std::string > &filterNames)
 

Static Public Attributes

static const int maxNrBits_ = 128
 

Private Member Functions

void getCodeName (TrigBitSet code, std::string &id) const
 
void printCodes ()
 
void setCode (const char *descript, TrigBitSet code)
 
void setCode (const char *descript, int bitNr)
 
size_t size () const
 
void sort ()
 
 TrigCodes ()=default
 

Static Private Member Functions

static bool keyComp (const std::pair< std::string, TrigBitSet > &lhs, const std::pair< std::string, TrigBitSet > &rhs)
 

Private Attributes

std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
 

Detailed Description

Definition at line 20 of file EgHLTTrigCodes.h.

Member Typedef Documentation

◆ TrigBitSet

Definition at line 23 of file EgHLTTrigCodes.h.

Constructor & Destructor Documentation

◆ ~TrigCodes()

egHLT::TrigCodes::~TrigCodes ( )
default

◆ TrigCodes() [1/2]

egHLT::TrigCodes::TrigCodes ( const TrigCodes )
delete

◆ TrigCodes() [2/2]

egHLT::TrigCodes::TrigCodes ( )
privatedefault

Referenced by makeCodes().

Member Function Documentation

◆ getCode() [1/2]

TrigCodes::TrigBitSet TrigCodes::getCode ( const char *  descript) const

Definition at line 42 of file EgHLTTrigCodes.cc.

References DummyCfis::c, codeDefs_, spr::find(), and unpackBuffers-CaloStage2::token.

Referenced by egHLT::MonElemFuncs::addTightLooseTrigHist(), egHLT::trigTools::getFiltersPassed(), egHLT::MonElemFuncs::initTightLooseDiObjTrigHistsTrigCuts(), egHLT::MonElemFuncs::initTightLooseTrigHistsTrigCuts(), egHLT::MonElemFuncs::initTrigTagProbeHist(), egHLT::MonElemFuncs::initTrigTagProbeHist_2Leg(), egHLT::MonElemFuncs::initTrigTagProbeHists(), egHLT::trigTools::setFiltersObjPasses(), egHLT::OffHelper::setTrigInfo(), and egHLT::OffHelper::setupTriggers().

42  {
43  TrigBitSet code;
44 
45  char const* const end = descript + strlen(descript);
46  char const* codeKey = descript;
47  char const* token = nullptr;
48  do {
49  token = std::find(codeKey, end, ':');
50 
51  for (auto const& c : codeDefs_) {
52  if (0 == c.first.compare(0, std::string::npos, codeKey, token - codeKey)) {
53  code |= c.second;
54  break;
55  }
56  }
57  codeKey = token + 1;
58  } while (token != end);
59  return code;
60 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
std::bitset< maxNrBits_ > TrigBitSet

◆ getCode() [2/2]

TrigBitSet egHLT::TrigCodes::getCode ( const std::string &  descript) const
inline

Definition at line 37 of file EgHLTTrigCodes.h.

References getCode().

Referenced by getCode().

37 { return getCode(descript.c_str()); }
TrigBitSet getCode(const char *descript) const

◆ getCodeName()

void TrigCodes::getCodeName ( TrigBitSet  code,
std::string &  id 
) const
private

Definition at line 66 of file EgHLTTrigCodes.cc.

References codeDefs_, and relativeConstraints::empty.

66  {
67  id.clear();
68  for (auto const& codeDef : codeDefs_) {
69  if ((code & codeDef.second) == codeDef.second) {
70  if (!id.empty())
71  id += ":"; //seperating entries by a ':'
72  id += codeDef.first;
73  }
74  }
75 }
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_

◆ keyComp()

bool TrigCodes::keyComp ( const std::pair< std::string, TrigBitSet > &  lhs,
const std::pair< std::string, TrigBitSet > &  rhs 
)
staticprivate

Definition at line 62 of file EgHLTTrigCodes.cc.

Referenced by sort().

62  {
63  return lhs.first < rhs.first;
64 }

◆ makeCodes()

TrigCodes * TrigCodes::makeCodes ( std::vector< std::string > &  filterNames)
static

Definition at line 9 of file EgHLTTrigCodes.cc.

References mps_fire::i, AlCaHLTBitMon_ParallelJobs::p, and TrigCodes().

9  {
10  auto* p = new TrigCodes();
11 
12  for (size_t i = 0; i < filterNames.size(); i++) {
13  p->setCode(filterNames[i].c_str(), i);
14  }
15  p->sort();
16 
17  return p;
18 }
TrigCodes()=default

◆ operator=()

TrigCodes& egHLT::TrigCodes::operator= ( const TrigCodes )
delete

◆ printCodes()

void TrigCodes::printCodes ( )
private

Definition at line 77 of file EgHLTTrigCodes.cc.

References codeDefs_, and mps_check::msg.

77  {
78  std::ostringstream msg;
79  msg << " trig bits defined: " << std::endl;
80  for (auto& codeDef : codeDefs_)
81  msg << " key : " << codeDef.first << " bit " << codeDef.second << std::endl;
82  edm::LogInfo("TrigCodes") << msg.str();
83 }
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
Log< level::Info, false > LogInfo
tuple msg
Definition: mps_check.py:286

◆ setCode() [1/2]

void TrigCodes::setCode ( const char *  descript,
TrigBitSet  code 
)
private

Definition at line 31 of file EgHLTTrigCodes.cc.

References codeDefs_, dqmdumpme::first, newFWLiteAna::found, and mps_fire::i.

Referenced by setCode().

31  {
32  bool found = false;
33  for (size_t i = 0; i < codeDefs_.size() && !found; i++) {
34  if (codeDefs_[i].first == descript)
35  found = true;
36  }
37  if (!found)
38  codeDefs_.emplace_back(descript, code);
39  //_codeDefs[descript] = code;
40 }
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_

◆ setCode() [2/2]

void TrigCodes::setCode ( const char *  descript,
int  bitNr 
)
private

Definition at line 20 of file EgHLTTrigCodes.cc.

References maxNrBits_, and setCode().

20  {
21  if (bitNr < maxNrBits_) {
22  TrigBitSet code;
23  code.set(bitNr);
24  setCode(descript, code);
25  } else {
26  edm::LogWarning("TrigCodes::TrigBitSetMap")
27  << " Warning, trying to store at bit " << bitNr << " but max nr bits is " << maxNrBits_;
28  }
29 }
void setCode(const char *descript, TrigBitSet code)
static const int maxNrBits_
Log< level::Warning, false > LogWarning
std::bitset< maxNrBits_ > TrigBitSet

◆ size()

size_t egHLT::TrigCodes::size ( void  ) const
inlineprivate

Definition at line 51 of file EgHLTTrigCodes.h.

References codeDefs_.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

51 { return codeDefs_.size(); }
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_

◆ sort()

void egHLT::TrigCodes::sort ( )
inlineprivate

Definition at line 50 of file EgHLTTrigCodes.h.

References codeDefs_, keyComp(), and jetUpdater_cfi::sort.

50 { std::sort(codeDefs_.begin(), codeDefs_.end(), keyComp); }
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
static bool keyComp(const std::pair< std::string, TrigBitSet > &lhs, const std::pair< std::string, TrigBitSet > &rhs)

Member Data Documentation

◆ codeDefs_

std::vector<std::pair<std::string, TrigBitSet> > egHLT::TrigCodes::codeDefs_
private

Definition at line 27 of file EgHLTTrigCodes.h.

Referenced by getCode(), getCodeName(), printCodes(), setCode(), size(), and sort().

◆ maxNrBits_

const int egHLT::TrigCodes::maxNrBits_ = 128
static

Definition at line 22 of file EgHLTTrigCodes.h.

Referenced by setCode().