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 //
26 
27  fRecords.push_back(ZCountingTrigger::TriggerRecord("HLT_IsoMu27_v*",0));
28  fRecords.back().objectMap.push_back(std::pair<std::string, int>("hltL3crIsoL1sMu22Or25L1f0L2f10QL3f27QL3trkIsoFiltered0p07",0));
29  fRecords.push_back(ZCountingTrigger::TriggerRecord("HLT_Ele35_WPTight_Gsf_v*",1));
30  fRecords.back().objectMap.push_back(std::pair<std::string, int>("hltEle35noerWPTightGsfTrackIsoFilter",0));
31  fRecords.push_back(ZCountingTrigger::TriggerRecord("HLT_Ele27_WPTight_Gsf_v*",2));
32  fRecords.back().objectMap.push_back(std::pair<std::string, int>("hltEle27WPTightGsfTrackIsoFilter",0));
33 }
34 
35 //--------------------------------------------------------------------------------------------------
36 int TTrigger::getTriggerBit(const std::string &iName) const {
37  int lId = -1;
38  for(unsigned int i0 = 0; i0 < fRecords.size(); i0++) {
39  if(iName == fRecords[i0].hltPattern) lId = i0;
40  }
41  if(lId == -1) edm::LogWarning("ZCounting") << "=== Missing Trigger ==" << iName << std::endl;
42  return lId;
43 }
44 
45 //--------------------------------------------------------------------------------------------------
46 int TTrigger::getTriggerObjectBit(const std::string &iName, const std::string &iObjName) const {
47  int lId = getTriggerBit(iName);
48  if(lId == -1) return -1;
49 
50  for(unsigned int i0 = 0; i0 < fRecords[lId].objectMap.size(); i0++) {
51  if(iObjName != fRecords[lId].objectMap[i0].first) continue;
52  return fRecords[lId].objectMap[i0].second;
53  }
54 
55  return -1;
56 }
57 
58 //--------------------------------------------------------------------------------------------------
59 bool TTrigger::pass(const std::string &iName, const TriggerBits &iTrig) const {
60  int lId = getTriggerBit(iName);
61  if(lId == -1) return false;
62 
63  return iTrig[lId];
64 }
65 
66 //--------------------------------------------------------------------------------------------------
67 bool TTrigger::passObj(const std::string &iName, const std::string &iObjName, const TriggerObjects &iTrigObj) const {
68  int lId = getTriggerObjectBit(iName,iObjName);
69  if(lId == -1) return false;
70 
71  return iTrigObj[lId];
72 }
bool passObj(const std::string &iName, const std::string &iObjName, const TriggerObjects &iTrigObj) const
Definition: TTrigger.cc:67
std::bitset< kNTrigObjectBit > TriggerObjects
Definition: TriggerDefs.h:9
int getTriggerBit(const std::string &iName) const
Definition: TTrigger.cc:36
std::vector< ZCountingTrigger::TriggerRecord > fRecords
Definition: TTrigger.h:21
std::bitset< kNTrigBit > TriggerBits
Definition: TriggerDefs.h:7
bool pass(const std::string &iName, const TriggerBits &iTrig) const
Definition: TTrigger.cc:59
int getTriggerObjectBit(const std::string &iName, const std::string &iObjName) const
Definition: TTrigger.cc:46