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, const std::vector<std::string> &muonTriggerObjectNames) {
26 
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) lId = i0;
42  }
43  if(lId == -1) edm::LogWarning("ZCounting") << "=== Missing Trigger ==" << iName << std::endl;
44  return lId;
45 }
46 
47 //--------------------------------------------------------------------------------------------------
48 int TTrigger::getTriggerObjectBit(const std::string &iName, const std::string &iObjName) const {
49  int lId = getTriggerBit(iName);
50  if(lId == -1) return -1;
51 
52  for(unsigned int i0 = 0; i0 < fRecords[lId].objectMap.size(); i0++) {
53  if(iObjName != fRecords[lId].objectMap[i0].first) continue;
54  return fRecords[lId].objectMap[i0].second;
55  }
56 
57  return -1;
58 }
59 
60 //--------------------------------------------------------------------------------------------------
61 bool TTrigger::pass(const std::string &iName, const TriggerBits &iTrig) const {
62  int lId = getTriggerBit(iName);
63  if(lId == -1) return false;
64 
65  return iTrig[lId];
66 }
67 
68 //--------------------------------------------------------------------------------------------------
69 bool TTrigger::passObj(const std::string &iName, const std::string &iObjName, const TriggerObjects &iTrigObj) const {
70  int lId = getTriggerObjectBit(iName,iObjName);
71  if(lId == -1) return false;
72 
73  return iTrigObj[lId];
74 }
bool passObj(const std::string &iName, const std::string &iObjName, const TriggerObjects &iTrigObj) const
Definition: TTrigger.cc:69
std::bitset< kNTrigObjectBit > TriggerObjects
Definition: TriggerDefs.h:9
TTrigger(const std::vector< std::string > &muonTriggerNames, const std::vector< std::string > &muonTriggerObjectNames)
Definition: TTrigger.cc:25
int getTriggerBit(const std::string &iName) const
Definition: TTrigger.cc:38
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:61
int getTriggerObjectBit(const std::string &iName, const std::string &iObjName) const
Definition: TTrigger.cc:48