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;
138 iEvent.getByToken(tcdsRecordToken_, tcdsRecordH);
139 makeTriggerRulePrefireVetoBit_ = makeTriggerRulePrefireVetoBit_ && tcdsRecordH.
isValid();
141 bool TriggerRulePrefireVetoBit(
false);
144 if (
iEvent.isRealData() && makeTriggerRulePrefireVetoBit_) {
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) {
157 if (eventHistory[0] < 3ull) {
158 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (1 in 3)";
161 if (eventHistory[0] == 3ull)
162 TriggerRulePrefireVetoBit =
true;
165 if (eventHistory[0] < 25ull and eventHistory[1] < 25ull) {
166 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (2 in 25)";
168 if (eventHistory[0] < 25ull and eventHistory[1] == 25ull)
169 TriggerRulePrefireVetoBit =
true;
172 if (eventHistory[0] < 100ull and eventHistory[1] < 100ull and eventHistory[2] <= 100ull) {
173 if (eventHistory[2] == 100ull)
174 TriggerRulePrefireVetoBit =
true;
176 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (3 in 100)";
180 if (eventHistory[0] < 240ull and eventHistory[1] < 240ull and eventHistory[2] < 240ull and
181 eventHistory[3] <= 240ull) {
182 if (eventHistory[3] == 240ull)
183 TriggerRulePrefireVetoBit =
true;
185 edm::LogError(
"L1TExtCondProducer") <<
"Found an L1A in an impossible location?! (4 in 240)";
195 bool foundBptxAND = (m_extBitMap.find(
"BPTX_plus_AND_minus.v0") != m_extBitMap.end());
196 bool foundBptxPlus = (m_extBitMap.find(
"BPTX_plus.v0") != m_extBitMap.end());
197 bool foundBptxMinus = (m_extBitMap.find(
"BPTX_minus.v0") != m_extBitMap.end());
198 bool foundBptxOR = (m_extBitMap.find(
"BPTX_plus_OR_minus.v0") != m_extBitMap.end());
201 if (setBptxAND_ && foundBptxAND)
203 if (setBptxPlus_ && foundBptxPlus)
205 if (setBptxMinus_ && foundBptxMinus)
207 if (setBptxOR_ && foundBptxOR)
211 foundBptxAND = (m_extBitMap.find(
"ZeroBias_BPTX_AND_VME") != m_extBitMap.end());
212 foundBptxPlus = (m_extBitMap.find(
"BPTX_B1_VME") != m_extBitMap.end());
213 foundBptxMinus = (m_extBitMap.find(
"BPTX_B2_VME") != m_extBitMap.end());
214 foundBptxOR = (m_extBitMap.find(
"BPTX_OR_VME") != m_extBitMap.end());
217 if (setBptxAND_ && foundBptxAND)
219 if (setBptxPlus_ && foundBptxPlus)
221 if (setBptxMinus_ && foundBptxMinus)
223 if (setBptxOR_ && foundBptxOR)
227 if (TriggerRulePrefireVetoBit)
231 for (
int iBx = bxFirst_; iBx <= bxLast_; iBx++) {
232 extCond->push_back(iBx, extCond_bx);
242 desc.add<
bool>(
"setBptxMinus",
true);
243 desc.add<
bool>(
"setBptxAND",
true);
244 desc.add<
int>(
"bxFirst", -2);
245 desc.add<
bool>(
"setBptxOR",
true);
246 desc.add<
int>(
"bxLast", 2);
247 desc.add<
bool>(
"setBptxPlus",
true);
249 descriptions.
add(
"simGtExtFakeProd",
desc);
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > l1GtMenuToken_
BXVector< GlobalExtBlk > GlobalExtBlkBxCollection
~L1TExtCondProducer() override
edm::EDGetTokenT< TCDSRecord > tcdsRecordToken_
static const unsigned int maxExternalConditions
T const * product() const
Log< level::Error, false > LogError
T const * product() const
unsigned int m_triggerRulePrefireVetoBit
edm::InputTag tcdsInputTag_
#define DEFINE_FWK_MODULE(type)
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