CMS 3D CMS Logo

HLTLevel1Pattern.cc
Go to the documentation of this file.
1 
13 #include <vector>
14 
31 
32 //
33 // class declaration
34 //
35 
37 public:
38  explicit HLTLevel1Pattern(const edm::ParameterSet&);
39  ~HLTLevel1Pattern() override;
40  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
41  bool filter(edm::Event&, const edm::EventSetup&) override;
42 
43 private:
47  std::vector<int> m_bunchCrossings;
48  std::vector<int> m_triggerPattern;
49  unsigned int m_daqPartitions;
50  unsigned int m_triggerNumber;
54  bool m_invert;
55  bool m_throw;
56 
60 
64 };
65 
70 
71 //
72 // constructors and destructor
73 //
75  : m_gtReadoutRecord(config.getParameter<edm::InputTag>("L1GtReadoutRecordTag")),
76  m_triggerBit(config.getParameter<std::string>("triggerBit")),
77  m_bunchCrossings(config.getParameter<std::vector<int> >("bunchCrossings")),
78  m_triggerPattern(m_bunchCrossings.size(), false),
79  m_daqPartitions(config.getParameter<unsigned int>("daqPartitions")),
80  m_triggerNumber(0),
81  m_triggerAlgo(true),
82  m_triggerMasked(false),
83  m_ignoreL1Mask(config.getParameter<bool>("ignoreL1Mask")),
84  m_invert(config.getParameter<bool>("invert")),
85  m_throw(config.getParameter<bool>("throw")),
86  m_l1GtTriggerMenuToken(esConsumes()),
87  m_l1GtTriggerMaskAlgoTrigRcdToken(esConsumes()),
88  m_l1GtTriggerMaskTechTrigRcdToken(esConsumes()) {
89  m_gtReadoutRecordToken = consumes<L1GlobalTriggerReadoutRecord>(m_gtReadoutRecord);
90  std::vector<int> pattern(config.getParameter<std::vector<int> >("triggerPattern"));
91  if (pattern.size() != m_bunchCrossings.size())
92  throw cms::Exception("Configuration") << "\"bunchCrossings\" and \"triggerPattern\" parameters do not match";
93 
94  for (unsigned int i = 0; i < pattern.size(); ++i)
95  m_triggerPattern[i] = (bool)pattern[i];
96 }
97 
99 
102  desc.add<edm::InputTag>("L1GtReadoutRecordTag", edm::InputTag("hltGtDigis"));
103  desc.add<std::string>("triggerBit", "L1Tech_RPC_TTU_pointing_Cosmics.v0");
104  {
105  std::vector<int> temp1;
106  temp1.reserve(5);
107  temp1.push_back(-2);
108  temp1.push_back(-1);
109  temp1.push_back(0);
110  temp1.push_back(1);
111  temp1.push_back(2);
112  desc.add<std::vector<int> >("bunchCrossings", temp1);
113  }
114  desc.add<unsigned int>("daqPartitions", 1);
115  desc.add<bool>("ignoreL1Mask", false);
116  desc.add<bool>("invert", false);
117  desc.add<bool>("throw", true);
118  {
119  std::vector<int> temp1;
120  temp1.reserve(5);
121  temp1.push_back(1);
122  temp1.push_back(1);
123  temp1.push_back(1);
124  temp1.push_back(0);
125  temp1.push_back(0);
126  desc.add<std::vector<int> >("triggerPattern", temp1);
127  }
128  descriptions.add("hltLevel1Pattern", desc);
129 }
130 
131 //
132 // member functions
133 //
134 
135 // ------------ method called to produce the data ------------
137  // determine the L1 algo or tech bit to use
138  if (m_watchL1Menu.check(setup)) {
139  auto const& h_menu = setup.getHandle(m_l1GtTriggerMenuToken);
140  // look for an Algo L1 bit
141  const AlgorithmMap& algoMap = h_menu->gtAlgorithmAliasMap();
142  const AlgorithmMap& techMap = h_menu->gtTechnicalTriggerMap();
143  AlgorithmMap::const_iterator entry;
144  if ((entry = algoMap.find(m_triggerBit)) != algoMap.end()) {
145  m_triggerAlgo = true;
146  m_triggerNumber = entry->second.algoBitNumber();
147  } else if ((entry = techMap.find(m_triggerBit)) != techMap.end()) {
148  m_triggerAlgo = false;
149  m_triggerNumber = entry->second.algoBitNumber();
150  } else {
151  if (m_throw) {
152  throw cms::Exception("Configuration")
153  << "requested L1 trigger \"" << m_triggerBit << "\" does not exist in the current L1 menu";
154  } else {
155  return m_invert;
156  }
157  }
158  }
159 
160  if (m_triggerAlgo) {
161  // check the L1 algorithms mask
162  // - mask & partition == part. --> fully masked
163  // - mask & partition == 0x00 --> fully unmasked
164  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
166  auto const& h_mask = setup.getHandle(m_l1GtTriggerMaskAlgoTrigRcdToken);
167  m_triggerMasked = ((h_mask->gtTriggerMask()[m_triggerNumber] & m_daqPartitions) == m_daqPartitions);
168  }
169  } else {
170  // check the L1 technical triggers mask
171  // - mask & partition == part. --> fully masked
172  // - mask & partition == 0x00 --> fully unmasked
173  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
175  auto const& h_mask = setup.getHandle(m_l1GtTriggerMaskTechTrigRcdToken);
176  m_triggerMasked = ((h_mask->gtTriggerMask()[m_triggerNumber] & m_daqPartitions) == m_daqPartitions);
177  }
178  }
179 
180  // is the L1 trigger masked ?
181  if (not m_ignoreL1Mask and m_triggerMasked)
182  return m_invert;
183 
184  // access the L1 decisions
186  event.getByToken(m_gtReadoutRecordToken, h_gtReadoutRecord);
187 
188  // check the L1 algorithms results
189  for (unsigned int i = 0; i < m_bunchCrossings.size(); ++i) {
190  int bx = m_bunchCrossings[i];
191  const std::vector<bool>& word =
192  (m_triggerAlgo) ? h_gtReadoutRecord->decisionWord(bx) : h_gtReadoutRecord->technicalTriggerWord(bx);
193  if (word.empty() or m_triggerNumber >= word.size())
194  // L1 results not available, bail out
195  return m_invert;
196  bool result = word[m_triggerNumber];
197  if (result != m_triggerPattern[i])
198  // comparison failed, bail out
199  return m_invert;
200  }
201 
202  // comparison successful
203  return not m_invert;
204 }
205 
206 // define as a framework plugin
ConfigurationDescriptions.h
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
HLTLevel1Pattern::m_triggerAlgo
bool m_triggerAlgo
Definition: HLTLevel1Pattern.cc:51
L1GtTriggerMenu.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
L1GtTriggerMaskAlgoTrigRcd.h
funct::false
false
Definition: Factorize.h:29
L1GtTriggerMask.h
edm::ESWatcher< L1GtTriggerMenuRcd >
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord >
edm
HLT enums.
Definition: AlignableModifier.h:19
mps_splice.entry
entry
Definition: mps_splice.py:68
L1GtTriggerMenuRcd.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HLTLevel1Pattern::m_l1GtTriggerMenuToken
const edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > m_l1GtTriggerMenuToken
Definition: HLTLevel1Pattern.cc:57
L1GtTriggerMaskTechTrigRcd.h
EDFilter.h
HLTLevel1Pattern::m_gtReadoutRecord
edm::InputTag m_gtReadoutRecord
Definition: HLTLevel1Pattern.cc:44
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
config
Definition: config.py:1
MakerMacros.h
HLTLevel1Pattern::m_watchTechnicalMask
edm::ESWatcher< L1GtTriggerMaskTechTrigRcd > m_watchTechnicalMask
Definition: HLTLevel1Pattern.cc:63
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
AlgorithmMap
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
Definition: L1GtTriggerMenuFwd.h:31
HLTLevel1Pattern::m_bunchCrossings
std::vector< int > m_bunchCrossings
Definition: HLTLevel1Pattern.cc:47
ParameterSetDescription.h
HLTLevel1Pattern::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTLevel1Pattern.cc:100
HLTLevel1Pattern::m_watchL1Menu
edm::ESWatcher< L1GtTriggerMenuRcd > m_watchL1Menu
Definition: HLTLevel1Pattern.cc:61
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
HLTLevel1Pattern::~HLTLevel1Pattern
~HLTLevel1Pattern() override
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HLTLevel1Pattern::m_daqPartitions
unsigned int m_daqPartitions
Definition: HLTLevel1Pattern.cc:49
L1GlobalTriggerReadoutRecord::decisionWord
const DecisionWord & decisionWord(int bxInEventValue) const
Definition: L1GlobalTriggerReadoutRecord.cc:186
createfilelist.int
int
Definition: createfilelist.py:10
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EDFilter
Definition: EDFilter.h:38
edm::EventSetup
Definition: EventSetup.h:58
HLTLevel1Pattern::m_triggerNumber
unsigned int m_triggerNumber
Definition: HLTLevel1Pattern.cc:50
HLTLevel1Pattern::m_invert
bool m_invert
Definition: HLTLevel1Pattern.cc:54
edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd >
InputTag.h
HLTLevel1Pattern::m_triggerMasked
bool m_triggerMasked
Definition: HLTLevel1Pattern.cc:52
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
HLTLevel1Pattern::m_gtReadoutRecordToken
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_gtReadoutRecordToken
Definition: HLTLevel1Pattern.cc:45
Frameworkfwd.h
HLTLevel1Pattern
Definition: HLTLevel1Pattern.cc:36
ESWatcher.h
Exception
Definition: hltDiff.cc:245
HLTLevel1Pattern::m_l1GtTriggerMaskTechTrigRcdToken
const edm::ESGetToken< L1GtTriggerMask, L1GtTriggerMaskTechTrigRcd > m_l1GtTriggerMaskTechTrigRcdToken
Definition: HLTLevel1Pattern.cc:59
HLTLevel1Pattern::m_watchPhysicsMask
edm::ESWatcher< L1GtTriggerMaskAlgoTrigRcd > m_watchPhysicsMask
Definition: HLTLevel1Pattern.cc:62
EventSetup.h
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Exception.h
mps_fire.result
result
Definition: mps_fire.py:311
cms::Exception
Definition: Exception.h:70
L1GlobalTriggerReadoutRecord::technicalTriggerWord
const TechnicalTriggerWord & technicalTriggerWord(int bxInEventValue) const
Definition: L1GlobalTriggerReadoutRecord.cc:212
L1GtTriggerMenuFwd.h
HLTLevel1Pattern::HLTLevel1Pattern
HLTLevel1Pattern(const edm::ParameterSet &)
Definition: HLTLevel1Pattern.cc:74
ParameterSet.h
HLTLevel1Pattern::m_triggerBit
std::string m_triggerBit
Definition: HLTLevel1Pattern.cc:46
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
HLTLevel1Pattern::m_throw
bool m_throw
Definition: HLTLevel1Pattern.cc:55
HLTLevel1Pattern::m_ignoreL1Mask
bool m_ignoreL1Mask
Definition: HLTLevel1Pattern.cc:53
HLTLevel1Pattern::m_triggerPattern
std::vector< int > m_triggerPattern
Definition: HLTLevel1Pattern.cc:48
HLTLevel1Pattern::m_l1GtTriggerMaskAlgoTrigRcdToken
const edm::ESGetToken< L1GtTriggerMask, L1GtTriggerMaskAlgoTrigRcd > m_l1GtTriggerMaskAlgoTrigRcdToken
Definition: HLTLevel1Pattern.cc:58
HLTLevel1Pattern::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: HLTLevel1Pattern.cc:136
edm::InputTag
Definition: InputTag.h:15
L1GlobalTriggerReadoutRecord.h
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443