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