CMS 3D CMS Logo

TTrigger.cc
Go to the documentation of this file.
3 
4 #include <cstring>
5 #include <cassert>
6 #include <iostream>
7 #include <fstream>
8 #include <limits>
9 
10 using namespace ZCountingTrigger;
11 
12 //--------------------------------------------------------------------------------------------------
13 //
14 // Reads in an input file specifying the triggers we're interested in.
15 // The input file has the format:
16 // <trigger name> <trigger object name> <trigger object leg #>
17 //
18 // A trigger with multiple objects will have multiple entries with the same <trigger name> but
19 // one entry for each <trigger object name>.
20 //
21 // The trigger object leg numbering is to account for the possibility that a particular object of
22 // the trigger can evolve and obtain a different trigger object name, but we still want this to
23 // be associated with the same leg (e.g. the trailing electron in a dielectron trigger)
24 //
25 TTrigger::TTrigger(const std::vector<std::string> &muonTriggerNames,
26  const std::vector<std::string> &muonTriggerObjectNames) {
27  for (unsigned int i = 0; i < muonTriggerNames.size(); ++i) {
28  fRecords.push_back(ZCountingTrigger::TriggerRecord(muonTriggerNames.at(i), 0));
29  fRecords.back().objectMap.push_back(std::pair<std::string, int>(muonTriggerObjectNames.at(i), 0));
30  }
31  fRecords.push_back(ZCountingTrigger::TriggerRecord("HLT_Ele35_WPTight_Gsf_v*", 1));
32  fRecords.back().objectMap.push_back(std::pair<std::string, int>("hltEle35noerWPTightGsfTrackIsoFilter", 0));
33  fRecords.push_back(ZCountingTrigger::TriggerRecord("HLT_Ele27_WPTight_Gsf_v*", 2));
34  fRecords.back().objectMap.push_back(std::pair<std::string, int>("hltEle27WPTightGsfTrackIsoFilter", 0));
35 }
36 
37 //--------------------------------------------------------------------------------------------------
38 int TTrigger::getTriggerBit(const std::string &iName) const {
39  int lId = -1;
40  for (unsigned int i0 = 0; i0 < fRecords.size(); i0++) {
41  if (iName == fRecords[i0].hltPattern)
42  lId = i0;
43  }
44  if (lId == -1)
45  edm::LogWarning("ZCounting") << "=== Missing Trigger ==" << iName << std::endl;
46  return lId;
47 }
48 
49 //--------------------------------------------------------------------------------------------------
50 int TTrigger::getTriggerObjectBit(const std::string &iName, const std::string &iObjName) const {
51  int lId = getTriggerBit(iName);
52  if (lId == -1)
53  return -1;
54 
55  for (unsigned int i0 = 0; i0 < fRecords[lId].objectMap.size(); i0++) {
56  if (iObjName != fRecords[lId].objectMap[i0].first)
57  continue;
58  return fRecords[lId].objectMap[i0].second;
59  }
60 
61  return -1;
62 }
63 
64 //--------------------------------------------------------------------------------------------------
65 bool TTrigger::pass(const std::string &iName, const TriggerBits &iTrig) const {
66  int lId = getTriggerBit(iName);
67  if (lId == -1)
68  return false;
69 
70  return iTrig[lId];
71 }
72 
73 //--------------------------------------------------------------------------------------------------
74 bool TTrigger::passObj(const std::string &iName, const std::string &iObjName, const TriggerObjects &iTrigObj) const {
75  int lId = getTriggerObjectBit(iName, iObjName);
76  if (lId == -1)
77  return false;
78 
79  return iTrigObj[lId];
80 }
TTrigger.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
ZCountingTrigger::TriggerRecord
Definition: TriggerRecord.h:10
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
ZCountingTrigger::TTrigger::passObj
bool passObj(const std::string &iName, const std::string &iObjName, const TriggerObjects &iTrigObj) const
Definition: TTrigger.cc:74
ZCountingTrigger::TTrigger::pass
bool pass(const std::string &iName, const TriggerBits &iTrig) const
Definition: TTrigger.cc:65
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
TriggerObjects
std::bitset< kNTrigObjectBit > TriggerObjects
Definition: TriggerDefs.h:9
ZCountingTrigger
Definition: TriggerRecord.h:8
TriggerBits
std::bitset< kNTrigBit > TriggerBits
Definition: TriggerDefs.h:7
ZCountingTrigger::TTrigger::getTriggerObjectBit
int getTriggerObjectBit(const std::string &iName, const std::string &iObjName) const
Definition: TTrigger.cc:50
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ZCountingTrigger::TTrigger::TTrigger
TTrigger(const std::vector< std::string > &muonTriggerNames, const std::vector< std::string > &muonTriggerObjectNames)
Definition: TTrigger.cc:25
ZCountingTrigger::TTrigger::getTriggerBit
int getTriggerBit(const std::string &iName) const
Definition: TTrigger.cc:38
ZCountingTrigger::TTrigger::fRecords
std::vector< ZCountingTrigger::TriggerRecord > fRecords
Definition: TTrigger.h:19