27 edm::FileInPath f1(
"L1Trigger/L1TGlobal/data/Luminosity/startup/prescale_L1TGlobal.csv");
61 m_preScaleFileName =
f1.fullPath();
68 retrieveL1Setup(evSetup, isRun);
70 retrieveL1Event(
iEvent, evSetup);
78 retrieveL1Setup(evSetup, isRun);
80 retrieveL1Event(
iEvent, evSetup, gtAlgToken);
85 retrieveL1Setup(evSetup, isRun);
94 if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
96 m_l1GtMenu = &menuRcd.get(m_L1TUtmTriggerMenuRunToken);
98 m_l1GtMenu = &menuRcd.get(m_L1TUtmTriggerMenuEventToken);
102 m_algorithmMap = &(m_l1GtMenu->getAlgorithmMap());
105 resetDecisionVectors();
107 m_l1GtMenuCacheID = l1GtMenuCacheID;
110 if (!m_readPrescalesFromFile) {
114 if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
118 resetPrescaleVectors();
120 m_PreScaleColumn = 0;
121 m_numberOfPreScaleColumns = 0;
122 m_numberPhysTriggers = 0;
126 es = &vetosRcd.get(m_L1TGlobalPrescalesVetosRunToken);
128 es = &vetosRcd.get(m_L1TGlobalPrescalesVetosEventToken);
132 m_prescaleFactorsAlgoTrig = &(m_l1GtPrescalesVetoes->prescaleTable());
133 m_numberOfPreScaleColumns = m_prescaleFactorsAlgoTrig->size();
134 m_numberPhysTriggers =
135 (*m_prescaleFactorsAlgoTrig)[0].size();
137 m_triggerMaskAlgoTrig = &(m_l1GtPrescalesVetoes->triggerAlgoBxMask());
139 m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
144 if (!m_filledPrescales) {
145 resetPrescaleVectors();
148 loadPrescalesAndMasks();
151 m_prescaleFactorsAlgoTrig = &m_initialPrescaleFactorsAlgoTrig;
152 m_triggerMaskAlgoTrig = &m_initialTriggerMaskAlgoTrig;
153 m_filledPrescales =
true;
158 if (m_PreScaleColumn > m_prescaleFactorsAlgoTrig->size()) {
159 LogTrace(
"l1t|Global") <<
"\nNo Prescale Set: " << m_PreScaleColumn
160 <<
"\nMax Prescale Set value : " << m_prescaleFactorsAlgoTrig->size()
161 <<
"\nSetting prescale column to 0" << std::endl;
162 m_PreScaleColumn = 0;
165 const std::vector<int>& prescaleSet = (*m_prescaleFactorsAlgoTrig)[m_PreScaleColumn];
167 for (std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->begin();
168 itAlgo != m_algorithmMap->end();
172 int algBit = (itAlgo->second).getIndex();
174 (m_prescales[algBit]).
first = algName;
175 if (
size_t(algBit) < prescaleSet.size()) {
176 (m_prescales[algBit]).
second = prescaleSet[algBit];
178 LogDebug(
"l1t|Global") <<
"Number of bunch crossings stored: " << (*m_triggerMaskAlgoTrig).size() << endl;
180 const std::map<int, std::vector<int> >* triggerAlgoMaskAlgoTrig = m_triggerMaskAlgoTrig;
181 std::map<int, std::vector<int> >::const_iterator it = triggerAlgoMaskAlgoTrig->begin();
183 std::vector<int> maskedBxs;
184 (m_masks[algBit]).
first = algName;
185 (m_masks[algBit]).
second = maskedBxs;
186 while (it != triggerAlgoMaskAlgoTrig->end()) {
187 std::vector<int> masks = it->second;
190 for (
unsigned int imask = 0; imask < masks.size(); imask++) {
191 if (masks.at(imask) == algBit)
192 maskedBxs.push_back(it->first);
199 if (!maskedBxs.empty()) {
200 LogDebug(
"l1t|Global") <<
"i Algo: " << algBit <<
"\t" << algName <<
" masked\n";
201 for (
unsigned int ibx = 0; ibx < maskedBxs.size(); ibx++) {
203 (m_masks[algBit]).
second = maskedBxs;
210 retrieveL1Event(
iEvent, evSetup, m_l1tGlobalUtilHelper->l1tAlgBlkToken());
217 iEvent.getByToken(gtAlgToken, m_uGtAlgBlk);
221 if (m_uGtAlgBlk.isValid()) {
223 std::vector<GlobalAlgBlk>::const_iterator algBlk = m_uGtAlgBlk->begin(0);
224 if (algBlk != m_uGtAlgBlk->end(0)) {
225 if (!m_readPrescalesFromFile) {
226 m_PreScaleColumn = static_cast<unsigned int>(algBlk->getPreScColumn());
230 if (m_prescaleFactorsAlgoTrig->size() == 1 && m_PreScaleColumn == 1)
231 m_PreScaleColumn = 0;
235 if (m_PreScaleColumn >= m_prescaleFactorsAlgoTrig->size()) {
236 LogDebug(
"l1t|Global") <<
"Prescale column extracted from GlobalAlgBlk too large: " << m_PreScaleColumn
237 <<
"\tMaximum value allowed: " << m_prescaleFactorsAlgoTrig->size() - 1
238 <<
"\tResetting prescale column to 0" << std::endl;
239 m_PreScaleColumn = 0;
242 const std::vector<int>& prescaleSet = (*m_prescaleFactorsAlgoTrig)[m_PreScaleColumn];
245 m_finalOR = algBlk->getFinalOR();
249 for (std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->begin();
250 itAlgo != m_algorithmMap->end();
254 int algBit = (itAlgo->second).getIndex();
256 bool decisionInitial = algBlk->getAlgoDecisionInitial(algBit);
257 (m_decisionsInitial[algBit]).
first = algName;
258 (m_decisionsInitial[algBit]).
second = decisionInitial;
260 bool decisionInterm = algBlk->getAlgoDecisionInterm(algBit);
261 (m_decisionsInterm[algBit]).
first = algName;
262 (m_decisionsInterm[algBit]).
second = decisionInterm;
264 bool decisionFinal = algBlk->getAlgoDecisionFinal(algBit);
265 (m_decisionsFinal[algBit]).
first = algName;
266 (m_decisionsFinal[algBit]).
second = decisionFinal;
268 (m_prescales[algBit]).
first = algName;
269 if (
size_t(algBit) < prescaleSet.size()) {
270 (m_prescales[algBit]).
second = prescaleSet[algBit];
282 std::ifstream inputPrescaleFile;
284 inputPrescaleFile.open(m_preScaleFileName);
286 std::vector<std::vector<int> > vec;
287 std::vector<std::vector<int> > prescale_vec;
289 if (inputPrescaleFile) {
297 while (getline(inputPrescaleFile,
line)) {
298 if (!
line.compare(0, prefix1.size(), prefix1))
310 vec.push_back(std::vector<int>());
325 int NumPrescaleSets = 0;
326 for (
int iCol = 0; iCol <
int(vec.size()); iCol++) {
327 if (!vec[iCol].
empty()) {
328 int firstRow = vec[iCol][0];
338 if (NumPrescaleSets > 0) {
340 for (
int iSet = 0; iSet < NumPrescaleSets; iSet++) {
341 prescale_vec.push_back(std::vector<int>());
342 for (
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit) {
343 int inputDefaultPrescale = 1;
344 prescale_vec[iSet].push_back(inputDefaultPrescale);
349 for (
int iBit = 1; iBit <
int(vec[0].
size()); iBit++) {
350 unsigned int algoBit = vec[0][iBit];
352 if (algoBit < m_numberPhysTriggers) {
353 for (
int iSet = 0; iSet <
int(vec.size()); iSet++) {
355 if (!vec[iSet].
empty()) {
356 useSet = vec[iSet][0];
364 prescale_vec[useSet][algoBit] =
prescale;
367 LogTrace(
"l1t|Global") <<
"\nPrescale file has algo bit: " << algoBit
368 <<
"\nThis is larger than the number of triggers: " << m_numberPhysTriggers
369 <<
"\nSomething is wrong. Ignoring." << std::endl;
375 LogTrace(
"l1t|Global") <<
"\nCould not find file: " << m_preScaleFileName
376 <<
"\nFilling the prescale vectors with prescale 1"
377 <<
"\nSetting prescale set to 0" << std::endl;
379 m_PreScaleColumn = 0;
382 prescale_vec.push_back(std::vector<int>());
383 for (
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit) {
384 int inputDefaultPrescale = 0;
385 prescale_vec[
col].push_back(inputDefaultPrescale);
390 inputPrescaleFile.close();
392 m_initialPrescaleFactorsAlgoTrig = prescale_vec;
394 std::map<int, std::vector<int> > m_initialTriggerMaskAlgoTrig;
400 if (!m_readPrescalesFromFile) {
401 m_L1TGlobalPrescalesVetosRunToken =
407 if (!m_readPrescalesFromFile) {
415 m_decisionsInitial.clear();
416 m_decisionsInitial.resize(m_maxNumberPhysTriggers);
417 m_decisionsInterm.clear();
418 m_decisionsInterm.resize(m_maxNumberPhysTriggers);
419 m_decisionsFinal.clear();
420 m_decisionsFinal.resize(m_maxNumberPhysTriggers);
422 for (
unsigned int algBit = 0; algBit < m_maxNumberPhysTriggers; algBit++) {
423 (m_decisionsInitial[algBit]).
first =
"NULL";
424 (m_decisionsInitial[algBit]).
second =
false;
426 (m_decisionsInterm[algBit]).
first =
"NULL";
427 (m_decisionsInterm[algBit]).
second =
false;
429 (m_decisionsFinal[algBit]).
first =
"NULL";
430 (m_decisionsFinal[algBit]).
second =
false;
437 m_prescales.resize(m_maxNumberPhysTriggers);
439 for (
unsigned int algBit = 0; algBit < m_maxNumberPhysTriggers; algBit++) {
440 (m_prescales[algBit]).
first =
"NULL";
441 (m_prescales[algBit]).
second = 1;
448 m_masks.resize(m_maxNumberPhysTriggers);
450 for (
unsigned int algBit = 0; algBit < m_maxNumberPhysTriggers; algBit++) {
451 (m_masks[algBit]).
first =
"NULL";
457 std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->find(algName);
458 if (itAlgo != m_algorithmMap->end()) {
459 bit = (itAlgo->second).getIndex();
468 if ((m_decisionsInitial[bit]).
first !=
"NULL") {
469 algName = (m_decisionsInitial[bit]).
first;
482 if ((m_decisionsInitial[bit]).
first !=
"NULL") {
483 decision = (m_decisionsInitial[bit]).
second;
491 if ((m_decisionsInterm[bit]).
first !=
"NULL") {
492 decision = (m_decisionsInterm[bit]).
second;
500 if ((m_decisionsFinal[bit]).
first !=
"NULL") {
501 decision = (m_decisionsFinal[bit]).
second;
509 if ((m_prescales[bit]).
first !=
"NULL") {
518 if ((m_masks[bit]).
first !=
"NULL") {
519 mask = (m_masks[bit]).
second;
528 if (getAlgBitFromName(algName, bit)) {
529 decision = (m_decisionsInitial[bit]).
second;
538 if (getAlgBitFromName(algName, bit)) {
539 decision = (m_decisionsInterm[bit]).
second;
548 if (getAlgBitFromName(algName, bit)) {
549 decision = (m_decisionsFinal[bit]).
second;
557 if (getAlgBitFromName(algName, bit)) {
566 if (getAlgBitFromName(algName, bit)) {
567 mask = (m_masks[bit]).
second;