CMS 3D CMS Logo

HLTLevel1Pattern.cc
Go to the documentation of this file.
1 
13 #include <vector>
14 
28 
29 //
30 // class declaration
31 //
32 
34 public:
35  explicit HLTLevel1Pattern(const edm::ParameterSet&);
36  ~HLTLevel1Pattern() override;
37  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
38  bool filter(edm::Event&, const edm::EventSetup&) override;
39 
40 private:
44  std::vector<int> m_bunchCrossings;
45  std::vector<int> m_triggerPattern;
46  unsigned int m_daqPartitions;
47  unsigned int m_triggerNumber;
51  bool m_invert;
52  bool m_throw;
53 
57 };
58 
64 
65 //
66 // constructors and destructor
67 //
69  : m_gtReadoutRecord(config.getParameter<edm::InputTag>("L1GtReadoutRecordTag")),
70  m_triggerBit(config.getParameter<std::string>("triggerBit")),
71  m_bunchCrossings(config.getParameter<std::vector<int> >("bunchCrossings")),
72  m_triggerPattern(m_bunchCrossings.size(), false),
73  m_daqPartitions(config.getParameter<unsigned int>("daqPartitions")),
74  m_triggerNumber(0),
75  m_triggerAlgo(true),
76  m_triggerMasked(false),
77  m_ignoreL1Mask(config.getParameter<bool>("ignoreL1Mask")),
78  m_invert(config.getParameter<bool>("invert")),
79  m_throw(config.getParameter<bool>("throw")) {
80  m_gtReadoutRecordToken = consumes<L1GlobalTriggerReadoutRecord>(m_gtReadoutRecord);
81  std::vector<int> pattern(config.getParameter<std::vector<int> >("triggerPattern"));
82  if (pattern.size() != m_bunchCrossings.size())
83  throw cms::Exception("Configuration") << "\"bunchCrossings\" and \"triggerPattern\" parameters do not match";
84 
85  for (unsigned int i = 0; i < pattern.size(); ++i)
86  m_triggerPattern[i] = (bool)pattern[i];
87 }
88 
90 
93  desc.add<edm::InputTag>("L1GtReadoutRecordTag", edm::InputTag("hltGtDigis"));
94  desc.add<std::string>("triggerBit", "L1Tech_RPC_TTU_pointing_Cosmics.v0");
95  {
96  std::vector<int> temp1;
97  temp1.reserve(5);
98  temp1.push_back(-2);
99  temp1.push_back(-1);
100  temp1.push_back(0);
101  temp1.push_back(1);
102  temp1.push_back(2);
103  desc.add<std::vector<int> >("bunchCrossings", temp1);
104  }
105  desc.add<unsigned int>("daqPartitions", 1);
106  desc.add<bool>("ignoreL1Mask", false);
107  desc.add<bool>("invert", false);
108  desc.add<bool>("throw", true);
109  {
110  std::vector<int> temp1;
111  temp1.reserve(5);
112  temp1.push_back(1);
113  temp1.push_back(1);
114  temp1.push_back(1);
115  temp1.push_back(0);
116  temp1.push_back(0);
117  desc.add<std::vector<int> >("triggerPattern", temp1);
118  }
119  descriptions.add("hltLevel1Pattern", desc);
120 }
121 
122 //
123 // member functions
124 //
125 
126 // ------------ method called to produce the data ------------
128  // determine the L1 algo or tech bit to use
129  if (m_watchL1Menu.check(setup)) {
131  setup.get<L1GtTriggerMenuRcd>().get(h_menu);
132 
133  // look for an Algo L1 bit
134  const AlgorithmMap& algoMap = h_menu->gtAlgorithmAliasMap();
135  const AlgorithmMap& techMap = h_menu->gtTechnicalTriggerMap();
136  AlgorithmMap::const_iterator entry;
137  if ((entry = algoMap.find(m_triggerBit)) != algoMap.end()) {
138  m_triggerAlgo = true;
139  m_triggerNumber = entry->second.algoBitNumber();
140  } else if ((entry = techMap.find(m_triggerBit)) != techMap.end()) {
141  m_triggerAlgo = false;
142  m_triggerNumber = entry->second.algoBitNumber();
143  } else {
144  if (m_throw) {
145  throw cms::Exception("Configuration")
146  << "requested L1 trigger \"" << m_triggerBit << "\" does not exist in the current L1 menu";
147  } else {
148  return m_invert;
149  }
150  }
151  }
152 
153  if (m_triggerAlgo) {
154  // check the L1 algorithms mask
155  // - mask & partition == part. --> fully masked
156  // - mask & partition == 0x00 --> fully unmasked
157  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
160  setup.get<L1GtTriggerMaskAlgoTrigRcd>().get(h_mask);
162  }
163  } else {
164  // check the L1 technical triggers mask
165  // - mask & partition == part. --> fully masked
166  // - mask & partition == 0x00 --> fully unmasked
167  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
170  setup.get<L1GtTriggerMaskTechTrigRcd>().get(h_mask);
172  }
173  }
174 
175  // is the L1 trigger masked ?
176  if (not m_ignoreL1Mask and m_triggerMasked)
177  return m_invert;
178 
179  // access the L1 decisions
181  event.getByToken(m_gtReadoutRecordToken, h_gtReadoutRecord);
182 
183  // check the L1 algorithms results
184  for (unsigned int i = 0; i < m_bunchCrossings.size(); ++i) {
185  int bx = m_bunchCrossings[i];
186  const std::vector<bool>& word =
187  (m_triggerAlgo) ? h_gtReadoutRecord->decisionWord(bx) : h_gtReadoutRecord->technicalTriggerWord(bx);
188  if (word.empty() or m_triggerNumber >= word.size())
189  // L1 results not available, bail out
190  return m_invert;
191  bool result = word[m_triggerNumber];
192  if (result != m_triggerPattern[i])
193  // comparison failed, bail out
194  return m_invert;
195  }
196 
197  // comparison successful
198  return not m_invert;
199 }
200 
201 // 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:48
L1GtTriggerMenu.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
MessageLogger.h
L1GtTriggerMaskAlgoTrigRcd.h
funct::false
false
Definition: Factorize.h:34
L1GtTriggerMask.h
edm::ESWatcher< L1GtTriggerMenuRcd >
ESHandle.h
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord >
edm
HLT enums.
Definition: AlignableModifier.h:19
mps_splice.entry
entry
Definition: mps_splice.py:68
L1GtTriggerMenuRcd.h
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
L1GtTriggerMaskTechTrigRcd.h
EDFilter.h
HLTLevel1Pattern::m_gtReadoutRecord
edm::InputTag m_gtReadoutRecord
Definition: HLTLevel1Pattern.cc:41
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:56
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
L1GtTriggerMaskTechTrigRcd
Definition: L1GtTriggerMaskTechTrigRcd.h:39
L1GtTriggerMenuRcd
Definition: L1GtTriggerMenuRcd.h:32
AlgorithmMap
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
Definition: L1GtTriggerMenuFwd.h:31
L1GtTriggerMaskAlgoTrigRcd
Definition: L1GtTriggerMaskAlgoTrigRcd.h:39
edm::ESHandle< L1GtTriggerMenu >
HLTLevel1Pattern::m_bunchCrossings
std::vector< int > m_bunchCrossings
Definition: HLTLevel1Pattern.cc:44
ParameterSetDescription.h
HLTLevel1Pattern::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTLevel1Pattern.cc:91
HLTLevel1Pattern::m_watchL1Menu
edm::ESWatcher< L1GtTriggerMenuRcd > m_watchL1Menu
Definition: HLTLevel1Pattern.cc:54
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
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
HLTLevel1Pattern::m_daqPartitions
unsigned int m_daqPartitions
Definition: HLTLevel1Pattern.cc:46
L1GtTriggerMask::gtTriggerMask
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
Definition: L1GtTriggerMask.h:47
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
edm::EDFilter
Definition: EDFilter.h:39
L1GtTriggerMenu::gtAlgorithmAliasMap
const AlgorithmMap & gtAlgorithmAliasMap() const
get / set the algorithm map (by alias)
Definition: L1GtTriggerMenu.h:192
edm::EventSetup
Definition: EventSetup.h:57
HLTLevel1Pattern::m_triggerNumber
unsigned int m_triggerNumber
Definition: HLTLevel1Pattern.cc:47
get
#define get
HLTLevel1Pattern::m_invert
bool m_invert
Definition: HLTLevel1Pattern.cc:51
InputTag.h
HLTLevel1Pattern::m_triggerMasked
bool m_triggerMasked
Definition: HLTLevel1Pattern.cc:49
std
Definition: JetResolutionObject.h:76
HLTLevel1Pattern::m_gtReadoutRecordToken
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_gtReadoutRecordToken
Definition: HLTLevel1Pattern.cc:42
Frameworkfwd.h
HLTLevel1Pattern
Definition: HLTLevel1Pattern.cc:33
ESWatcher.h
Exception
Definition: hltDiff.cc:246
HLTLevel1Pattern::m_watchPhysicsMask
edm::ESWatcher< L1GtTriggerMaskAlgoTrigRcd > m_watchPhysicsMask
Definition: HLTLevel1Pattern.cc:55
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:303
cms::Exception
Definition: Exception.h:70
L1GlobalTriggerReadoutRecord::technicalTriggerWord
const TechnicalTriggerWord & technicalTriggerWord(int bxInEventValue) const
Definition: L1GlobalTriggerReadoutRecord.cc:212
HLTLevel1Pattern::HLTLevel1Pattern
HLTLevel1Pattern(const edm::ParameterSet &)
Definition: HLTLevel1Pattern.cc:68
ParameterSet.h
HLTLevel1Pattern::m_triggerBit
std::string m_triggerBit
Definition: HLTLevel1Pattern.cc:43
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
HLTLevel1Pattern::m_throw
bool m_throw
Definition: HLTLevel1Pattern.cc:52
HLTLevel1Pattern::m_ignoreL1Mask
bool m_ignoreL1Mask
Definition: HLTLevel1Pattern.cc:50
HLTLevel1Pattern::m_triggerPattern
std::vector< int > m_triggerPattern
Definition: HLTLevel1Pattern.cc:45
L1GtTriggerMenu::gtTechnicalTriggerMap
const AlgorithmMap & gtTechnicalTriggerMap() const
get / set the technical trigger map
Definition: L1GtTriggerMenu.h:197
HLTLevel1Pattern::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: HLTLevel1Pattern.cc:127
edm::InputTag
Definition: InputTag.h:15
L1GlobalTriggerReadoutRecord.h
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443