CMS 3D CMS Logo

L1TCommon.cc
Go to the documentation of this file.
4 
5 #include <iostream>
6 
7 namespace dqmoffline {
8  namespace l1t {
9 
10  std::vector<unsigned int> getTriggerIndices(const std::vector<std::string> &requestedTriggers,
11  const std::vector<std::string> &triggersInEvent) {
12  std::vector<unsigned int> triggerIndices;
13 
14  for (const auto &requestedTriggerName : requestedTriggers) {
15  std::string name(requestedTriggerName);
16  std::size_t wildcarPosition = name.find('*');
17  if (wildcarPosition != std::string::npos) {
18  // take everything up to the wildcard
19  name = name.substr(0, wildcarPosition - 1);
20  }
21 
22  unsigned int triggerIndex = 0;
23  for (const auto &triggerName : triggersInEvent) {
24  if (triggerName.find(name) != std::string::npos) {
25  triggerIndices.push_back(triggerIndex);
26  break;
27  }
28  ++triggerIndex;
29  }
30  }
31  return triggerIndices;
32  }
33 
34  std::vector<bool> getTriggerResults(const std::vector<unsigned int> &triggers,
36  std::vector<bool> results;
37  results.resize(triggers.size());
38 
39  for (unsigned int index = 0; index < triggers.size(); ++index) {
40  if (triggers[index] >= triggerResults.size()) {
41  results[index] = false;
42  continue;
43  }
44 
45  if (triggerResults.accept(triggers[index])) {
46  results[index] = true;
47  } else {
48  results[index] = false;
49  }
50  }
51  return results;
52  }
53 
54  std::vector<unsigned int> getFiredTriggerIndices(const std::vector<unsigned int> &triggers,
55  const std::vector<bool> &triggerResults) {
56  std::vector<unsigned int> results;
57  // std::copy_if instead?
58  for (unsigned int i = 0; i < triggerResults.size(); ++i) {
59  if (triggerResults[i]) {
60  results.push_back(triggers[i]);
61  }
62  }
63  return results;
64  }
65 
66  bool passesAnyTriggerFromList(const std::vector<unsigned int> &triggers,
68  std::vector<bool> results = dqmoffline::l1t::getTriggerResults(triggers, triggerResults);
69  if (std::count(results.begin(), results.end(), true) == 0) {
70  return false;
71  }
72  return true;
73  }
74 
75  trigger::TriggerObjectCollection getTriggerObjects(const std::vector<edm::InputTag> &hltFilters,
79 
80  for (const auto &filter : hltFilters) {
81  const unsigned filterIndex = triggerEvent.filterIndex(filter);
82 
83  if (filterIndex < triggerEvent.sizeFilters()) {
84  const trigger::Keys &triggerKeys(triggerEvent.filterKeys(filterIndex));
85  const size_t nTriggers = triggerEvent.filterIds(filterIndex).size();
86  for (size_t i = 0; i < nTriggers; ++i) {
87  results.push_back(triggerObjects[triggerKeys[i]]);
88  }
89  }
90  }
91  // sort by ET
92  typedef trigger::TriggerObject trigObj;
93  std::sort(results.begin(), results.end(), [](const trigObj &obj1, const trigObj &obj2) {
94  return obj1.et() > obj2.et();
95  });
96  return results;
97  }
98 
99  std::vector<edm::InputTag> getHLTFilters(const std::vector<unsigned int> &triggers,
101  const std::string triggerProcess) {
102  std::vector<edm::InputTag> results;
103  for (auto trigger : triggers) {
104  unsigned int hltIndexOffset(2);
105  unsigned int moduleIndex = hltConfig.size(trigger) - hltIndexOffset;
106  const std::vector<std::string> &modules(hltConfig.moduleLabels(trigger));
107  std::string module(modules[moduleIndex]);
108  edm::InputTag filterInputTag = edm::InputTag(module, "", triggerProcess);
109  results.push_back(filterInputTag);
110  }
111  return results;
112  }
113 
115  double phi,
116  double maxDeltaR,
119  typedef trigger::TriggerObject trigObj;
120  std::copy_if(
121  triggerObjects.begin(),
122  triggerObjects.end(),
123  std::back_inserter(results),
124  [eta, phi, maxDeltaR](const trigObj &obj) { return deltaR(obj.eta(), obj.phi(), eta, phi) < maxDeltaR; });
125  return results;
126  }
127 
128  } // namespace l1t
129 } // namespace dqmoffline
mps_fire.i
i
Definition: mps_fire.py:428
LogMessageMonitor_cff.modules
modules
Definition: LogMessageMonitor_cff.py:7
MessageLogger.h
triggerMatchMonitor_cfi.triggerObjects
triggerObjects
Definition: triggerMatchMonitor_cfi.py:15
modules
Definition: MuonCleanerBySegments.cc:35
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
dqmoffline::l1t::getTriggerIndices
std::vector< unsigned int > getTriggerIndices(const std::vector< std::string > &requestedTriggers, const std::vector< std::string > &triggersInEvent)
Definition: L1TCommon.cc:10
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
L1TCommon.h
L1TEGammaOffline_cfi.triggerProcess
triggerProcess
Definition: L1TEGammaOffline_cfi.py:38
bookConverter.results
results
Definition: bookConverter.py:144
dqmoffline::l1t::getTriggerObjects
trigger::TriggerObjectCollection getTriggerObjects(const std::vector< edm::InputTag > &hltFilters, const trigger::TriggerEvent &triggerEvent)
Definition: L1TCommon.cc:75
PVValHelper::eta
Definition: PVValidationHelpers.h:70
dqmoffline::l1t::passesAnyTriggerFromList
bool passesAnyTriggerFromList(const std::vector< unsigned int > &triggers, const edm::TriggerResults &triggerResults)
Definition: L1TCommon.cc:66
dqmoffline::l1t::getTriggerResults
std::vector< bool > getTriggerResults(const std::vector< unsigned int > &triggers, const edm::TriggerResults &triggerResults)
Definition: L1TCommon.cc:34
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
dqmoffline::l1t::getHLTFilters
std::vector< edm::InputTag > getHLTFilters(const std::vector< unsigned int > &triggers, const HLTConfigProvider &hltConfig, const std::string triggerProcess)
Definition: L1TCommon.cc:99
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
trigger::TriggerObject
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
deltaR.h
l1t
delete x;
Definition: CaloConfig.h:22
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
dqmoffline
Definition: HistDefinition.h:48
trigger::TriggerObjectCollection
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
dqmoffline::l1t::getFiredTriggerIndices
std::vector< unsigned int > getFiredTriggerIndices(const std::vector< unsigned int > &triggers, const std::vector< bool > &triggerResults)
Definition: L1TCommon.cc:54
trigger::Keys
std::vector< size_type > Keys
Definition: TriggerTypeDefs.h:19
dqmoffline::l1t::getMatchedTriggerObjects
trigger::TriggerObjectCollection getMatchedTriggerObjects(double eta, double phi, double maxDeltaR, const trigger::TriggerObjectCollection triggerObjects)
Definition: L1TCommon.cc:114
trigger::TriggerEvent
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
PDWG_DiPhoton_SD_cff.triggerEvent
triggerEvent
Definition: PDWG_DiPhoton_SD_cff.py:39
HLTConfigProvider
Definition: HLTConfigProvider.h:29
ewkMuLumiMonitorDQM_cfi.maxDeltaR
maxDeltaR
Definition: ewkMuLumiMonitorDQM_cfi.py:44
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HltComparatorCreateWorkflow.hltConfig
hltConfig
Definition: HltComparatorCreateWorkflow.py:161
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
trigger
Definition: HLTPrescaleTableCond.h:8
edm::InputTag
Definition: InputTag.h:15
edm::TriggerResults
Definition: TriggerResults.h:35
PDWG_DiPhoton_SD_cff.triggerName
triggerName
Definition: PDWG_DiPhoton_SD_cff.py:37