88 : bxFirst_(iConfig.getParameter<int>(
"bxFirst")),
89 bxLast_(iConfig.getParameter<int>(
"bxLast")),
90 setBptxAND_(iConfig.getParameter<bool>(
"setBptxAND")),
91 setBptxPlus_(iConfig.getParameter<bool>(
"setBptxPlus")),
92 setBptxMinus_(iConfig.getParameter<bool>(
"setBptxMinus")),
93 setBptxOR_(iConfig.getParameter<bool>(
"setBptxOR")),
94 tcdsInputTag_(iConfig.getParameter<edm::
InputTag>(
"tcdsRecordLabel")),
106 produces<GlobalExtBlkBxCollection>();
120 LogDebug(
"L1TExtCondProducer") <<
"L1TExtCondProducer::produce function called...\n";
126 if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
133 std::map<std::string, unsigned int> extBitMap = gtParser.
getExternalSignals(utml1GtMenu);
135 m_l1GtMenuCacheID = l1GtMenuCacheID;
136 m_extBitMap = extBitMap;
139 bool TriggerRulePrefireVetoBit(
false);
140 if (makeTriggerRulePrefireVetoBit_) {
144 iEvent.
getByToken(tcdsRecordToken_, tcdsRecordH);
145 const auto& tcdsRecord = *tcdsRecordH.
product();
147 uint64_t thisEvent = (tcdsRecord.getBXID() - 1) + tcdsRecord.getOrbitNr() * 3564ull;
149 std::vector<uint64_t> eventHistory;
150 for (
auto&& l1a : tcdsRecord.getFullL1aHistory()) {
151 eventHistory.push_back(thisEvent - ((l1a.getBXID() - 1) + l1a.getOrbitNr() * 3564ull));
155 if (eventHistory.size() < 4) {
156 edm::LogError(
"L1TExtCondProducer") <<
"Unexpectedly small L1A history from TCDSRecord";
160 if (eventHistory[0] < 3ull) {
161 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (1 in 3)";
164 if (eventHistory[0] == 3ull)
165 TriggerRulePrefireVetoBit =
true;
168 if (eventHistory[0] < 25ull and eventHistory[1] < 25ull) {
169 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (2 in 25)";
171 if (eventHistory[0] < 25ull and eventHistory[1] == 25ull)
172 TriggerRulePrefireVetoBit =
true;
175 if (eventHistory[0] < 100ull and eventHistory[1] < 100ull and eventHistory[2] < 100ull) {
176 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (3 in 100)";
178 if (eventHistory[0] < 100ull and eventHistory[1] < 100ull and eventHistory[2] == 100ull)
179 TriggerRulePrefireVetoBit =
true;
182 if (eventHistory[0] < 240ull and eventHistory[1] < 240ull and eventHistory[2] < 240ull and
183 eventHistory[3] < 240ull) {
184 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (4 in 240)";
186 if (eventHistory[0] < 240ull and eventHistory[1] < 240ull and eventHistory[2] < 240ull and
187 eventHistory[3] == 240ull)
188 TriggerRulePrefireVetoBit =
true;
197 bool foundBptxAND = (m_extBitMap.find(
"BPTX_plus_AND_minus.v0") != m_extBitMap.end());
198 bool foundBptxPlus = (m_extBitMap.find(
"BPTX_plus.v0") != m_extBitMap.end());
199 bool foundBptxMinus = (m_extBitMap.find(
"BPTX_minus.v0") != m_extBitMap.end());
200 bool foundBptxOR = (m_extBitMap.find(
"BPTX_plus_OR_minus.v0") != m_extBitMap.end());
203 if (setBptxAND_ && foundBptxAND)
205 if (setBptxPlus_ && foundBptxPlus)
207 if (setBptxMinus_ && foundBptxMinus)
209 if (setBptxOR_ && foundBptxOR)
213 foundBptxAND = (m_extBitMap.find(
"ZeroBias_BPTX_AND_VME") != m_extBitMap.end());
214 foundBptxPlus = (m_extBitMap.find(
"BPTX_B1_VME") != m_extBitMap.end());
215 foundBptxMinus = (m_extBitMap.find(
"BPTX_B2_VME") != m_extBitMap.end());
216 foundBptxOR = (m_extBitMap.find(
"BPTX_OR_VME") != m_extBitMap.end());
219 if (setBptxAND_ && foundBptxAND)
221 if (setBptxPlus_ && foundBptxPlus)
223 if (setBptxMinus_ && foundBptxMinus)
225 if (setBptxOR_ && foundBptxOR)
229 if (TriggerRulePrefireVetoBit)
233 for (
int iBx = bxFirst_; iBx <= bxLast_; iBx++) {
234 extCond->push_back(iBx, extCond_bx);
244 desc.
add<
bool>(
"setBptxMinus",
true);
245 desc.
add<
bool>(
"setBptxAND",
true);
246 desc.
add<
int>(
"bxFirst", -2);
247 desc.
add<
bool>(
"setBptxOR",
true);
248 desc.
add<
int>(
"bxLast", 2);
249 desc.
add<
bool>(
"setBptxPlus",
true);
251 descriptions.
add(
"simGtExtFakeProd", desc);
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > l1GtMenuToken_
BXVector< GlobalExtBlk > GlobalExtBlkBxCollection
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
~L1TExtCondProducer() override
edm::EDGetTokenT< TCDSRecord > tcdsRecordToken_
static const unsigned int maxExternalConditions
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
Log< level::Error, false > LogError
unsigned int m_triggerRulePrefireVetoBit
edm::InputTag tcdsInputTag_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
L1TExtCondProducer(const ParameterSet &)
void setExternalDecision(unsigned int bit, bool val)
Set decision bits.
unsigned long long m_l1GtMenuCacheID
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
unsigned long long uint64_t
T const * product() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool makeTriggerRulePrefireVetoBit_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
std::map< std::string, unsigned int > m_extBitMap
void produce(edm::Event &, const edm::EventSetup &) override