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, int bitNr)
 
void setCode (const char *descript, TrigBitSet code)
 
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.

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 }

References c, codeDefs_, mps_fire::end, 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().

◆ getCode() [2/2]

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

Definition at line 37 of file EgHLTTrigCodes.h.

37 { return getCode(descript.c_str()); }

References getCode().

Referenced by getCode().

◆ getCodeName()

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

Definition at line 66 of file EgHLTTrigCodes.cc.

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 }

References codeDefs_, and relativeConstraints::empty.

◆ 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.

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

Referenced by sort().

◆ makeCodes()

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

Definition at line 9 of file EgHLTTrigCodes.cc.

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 }

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

◆ operator=()

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

◆ printCodes()

void TrigCodes::printCodes ( )
private

Definition at line 77 of file EgHLTTrigCodes.cc.

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 }

References codeDefs_, and mps_check::msg.

◆ setCode() [1/2]

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

Definition at line 20 of file EgHLTTrigCodes.cc.

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 }

References maxNrBits_, and setCode().

◆ setCode() [2/2]

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

Definition at line 31 of file EgHLTTrigCodes.cc.

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 }

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

Referenced by setCode().

◆ size()

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

Definition at line 51 of file EgHLTTrigCodes.h.

51 { return codeDefs_.size(); }

References codeDefs_.

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

◆ sort()

void egHLT::TrigCodes::sort ( )
inlineprivate

Definition at line 50 of file EgHLTTrigCodes.h.

50 { std::sort(codeDefs_.begin(), codeDefs_.end(), keyComp); }

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

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().

mps_fire.i
i
Definition: mps_fire.py:428
egHLT::TrigCodes::TrigCodes
TrigCodes()=default
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
mps_check.msg
tuple msg
Definition: mps_check.py:285
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
egHLT::TrigCodes::TrigBitSet
std::bitset< maxNrBits_ > TrigBitSet
Definition: EgHLTTrigCodes.h:23
mps_fire.end
end
Definition: mps_fire.py:242
egHLT::TrigCodes::maxNrBits_
static const int maxNrBits_
Definition: EgHLTTrigCodes.h:22
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
egHLT::TrigCodes::getCode
TrigBitSet getCode(const char *descript) const
Definition: EgHLTTrigCodes.cc:42
egHLT::TrigCodes::keyComp
static bool keyComp(const std::pair< std::string, TrigBitSet > &lhs, const std::pair< std::string, TrigBitSet > &rhs)
Definition: EgHLTTrigCodes.cc:62
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
egHLT::TrigCodes::setCode
void setCode(const char *descript, TrigBitSet code)
Definition: EgHLTTrigCodes.cc:31
egHLT::TrigCodes::codeDefs_
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
Definition: EgHLTTrigCodes.h:27
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316