85 : bxFirst_(iConfig.getParameter<
int>(
"bxFirst")),
86 bxLast_(iConfig.getParameter<
int>(
"bxLast")),
87 setBptxAND_(iConfig.getParameter<
bool>(
"setBptxAND")),
88 setBptxPlus_(iConfig.getParameter<
bool>(
"setBptxPlus")),
89 setBptxMinus_(iConfig.getParameter<
bool>(
"setBptxMinus")),
90 setBptxOR_(iConfig.getParameter<
bool>(
"setBptxOR")),
91 tcdsInputTag_(iConfig.getParameter<
edm::
InputTag>(
"tcdsRecordLabel")),
104 produces<GlobalExtBlkBxCollection>();
118 LogDebug(
"L1TExtCondProducer") <<
"L1TExtCondProducer::produce function called...\n";
124 if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
131 std::map<std::string, unsigned int> extBitMap = gtParser.
getExternalSignals(utml1GtMenu);
133 m_l1GtMenuCacheID = l1GtMenuCacheID;
134 m_extBitMap = extBitMap;
137 bool TriggerRulePrefireVetoBit(
false);
140 if (
iEvent.isRealData() && makeTriggerRulePrefireVetoBit_) {
142 iEvent.getByToken(tcdsRecordToken_, tcdsRecordH);
147 std::vector<uint64_t> eventHistory;
148 for (
auto&& l1a :
tcdsRecord.getFullL1aHistory()) {
149 eventHistory.push_back(thisEvent - ((l1a.getBXID() - 1) + l1a.getOrbitNr() * 3564ull));
153 if (eventHistory.size() < 4) {
155 <<
"Unexpectedly small L1A history from TCDSRecord: (size = " << eventHistory.size() <<
" < 4)";
159 if (eventHistory[0] < 3ull) {
160 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (1 in 3)";
163 if (eventHistory[0] == 3ull)
164 TriggerRulePrefireVetoBit =
true;
167 if (eventHistory[0] < 25ull and eventHistory[1] < 25ull) {
168 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (2 in 25)";
170 if (eventHistory[0] < 25ull and eventHistory[1] == 25ull)
171 TriggerRulePrefireVetoBit =
true;
174 if (eventHistory[0] < 100ull and eventHistory[1] < 100ull and eventHistory[2] < 100ull) {
175 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (3 in 100)";
177 if (eventHistory[0] < 100ull and eventHistory[1] < 100ull and eventHistory[2] == 100ull)
178 TriggerRulePrefireVetoBit =
true;
181 if (eventHistory[0] < 240ull and eventHistory[1] < 240ull and eventHistory[2] < 240ull and
182 eventHistory[3] < 240ull) {
183 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (4 in 240)";
185 if (eventHistory[0] < 240ull and eventHistory[1] < 240ull and eventHistory[2] < 240ull and
186 eventHistory[3] == 240ull)
187 TriggerRulePrefireVetoBit =
true;
196 bool foundBptxAND = (m_extBitMap.find(
"BPTX_plus_AND_minus.v0") != m_extBitMap.end());
197 bool foundBptxPlus = (m_extBitMap.find(
"BPTX_plus.v0") != m_extBitMap.end());
198 bool foundBptxMinus = (m_extBitMap.find(
"BPTX_minus.v0") != m_extBitMap.end());
199 bool foundBptxOR = (m_extBitMap.find(
"BPTX_plus_OR_minus.v0") != m_extBitMap.end());
202 if (setBptxAND_ && foundBptxAND)
204 if (setBptxPlus_ && foundBptxPlus)
206 if (setBptxMinus_ && foundBptxMinus)
208 if (setBptxOR_ && foundBptxOR)
212 foundBptxAND = (m_extBitMap.find(
"ZeroBias_BPTX_AND_VME") != m_extBitMap.end());
213 foundBptxPlus = (m_extBitMap.find(
"BPTX_B1_VME") != m_extBitMap.end());
214 foundBptxMinus = (m_extBitMap.find(
"BPTX_B2_VME") != m_extBitMap.end());
215 foundBptxOR = (m_extBitMap.find(
"BPTX_OR_VME") != m_extBitMap.end());
218 if (setBptxAND_ && foundBptxAND)
220 if (setBptxPlus_ && foundBptxPlus)
222 if (setBptxMinus_ && foundBptxMinus)
224 if (setBptxOR_ && foundBptxOR)
228 if (TriggerRulePrefireVetoBit)
232 for (
int iBx = bxFirst_; iBx <= bxLast_; iBx++) {
233 extCond->push_back(iBx, extCond_bx);
243 desc.add<
bool>(
"setBptxMinus",
true);
244 desc.add<
bool>(
"setBptxAND",
true);
245 desc.add<
int>(
"bxFirst", -2);
246 desc.add<
bool>(
"setBptxOR",
true);
247 desc.add<
int>(
"bxLast", 2);
248 desc.add<
bool>(
"setBptxPlus",
true);
250 descriptions.
add(
"simGtExtFakeProd",
desc);
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > l1GtMenuToken_
BXVector< GlobalExtBlk > GlobalExtBlkBxCollection
~L1TExtCondProducer() override
edm::EDGetTokenT< TCDSRecord > tcdsRecordToken_
static const unsigned int maxExternalConditions
#define DEFINE_FWK_MODULE(type)
T const * product() const
Log< level::Error, false > LogError
T const * product() const
unsigned int m_triggerRulePrefireVetoBit
edm::InputTag tcdsInputTag_
static void fillDescriptions(ConfigurationDescriptions &descriptions)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
L1TExtCondProducer(const ParameterSet &)
void setExternalDecision(unsigned int bit, bool val)
Set decision bits.
unsigned long long m_l1GtMenuCacheID
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned long long uint64_t
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool makeTriggerRulePrefireVetoBit_
std::map< std::string, unsigned int > m_extBitMap
void produce(edm::Event &, const edm::EventSetup &) override