38 edm::FileInPath f1(
"L1Trigger/L1TGlobal/data/Luminosity/startup/prescale_L1TGlobal.csv");
65 m_PreScaleColumn = psColumn;
70 retrieveL1Setup(evSetup);
72 retrieveL1Event(iEvent,evSetup);
78 retrieveL1Setup(evSetup);
80 retrieveL1Event(iEvent,evSetup,gtAlgToken);
89 if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
93 m_l1GtMenu = l1GtMenu.
product();
96 m_algorithmMap = &(m_l1GtMenu->getAlgorithmMap());
99 resetDecisionVectors();
101 m_l1GtMenuCacheID = l1GtMenuCacheID;
105 if(!m_filledPrescales) {
108 resetPrescaleVectors();
112 if( !( m_algorithmTriggersUnprescaled && m_algorithmTriggersUnmasked ) ){
115 if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
121 m_prescaleFactorsAlgoTrig = &(m_l1GtPrescalesVetoes->prescaleTable());
122 m_triggerMaskVetoAlgoTrig = &(m_l1GtPrescalesVetoes->triggerMaskVeto());
124 m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
128 loadPrescalesAndMasks();
131 m_prescaleFactorsAlgoTrig = &m_initialPrescaleFactorsAlgoTrig;
132 m_triggerMaskAlgoTrig = &m_initialTriggerMaskAlgoTrig;
133 m_triggerMaskVetoAlgoTrig = &m_initialTriggerMaskVetoAlgoTrig;
137 if(m_PreScaleColumn > m_prescaleFactorsAlgoTrig->size() || m_PreScaleColumn < 1) {
139 <<
"\nNo Prescale Set: " << m_PreScaleColumn
140 <<
"\nMax Prescale Set value : " << m_prescaleFactorsAlgoTrig->size()
141 <<
"\nSetting prescale column to 1"
143 m_PreScaleColumn = 1;
145 LogDebug(
"l1t|Global") <<
"Grabing prescale column "<< m_PreScaleColumn << endl;
146 const std::vector<int>& prescaleSet = (*m_prescaleFactorsAlgoTrig)[m_PreScaleColumn-1];
149 if( !( m_algorithmTriggersUnprescaled && m_algorithmTriggersUnmasked ) ){
151 m_initialTriggerMaskAlgoTrig.clear();
152 for(
unsigned int iAlgo=0; iAlgo < prescaleSet.size(); iAlgo++ ){
153 unsigned int value = prescaleSet[iAlgo];
154 value = ( value==0 ) ? 0 : 1;
155 m_initialTriggerMaskAlgoTrig.push_back(value);
157 m_triggerMaskAlgoTrig = &m_initialTriggerMaskAlgoTrig;
160 for (std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->begin(); itAlgo != m_algorithmMap->end(); itAlgo++) {
164 int algBit = (itAlgo->second).getIndex();
166 (m_prescales[algBit]).
first = algName;
167 (m_prescales[algBit]).
second = prescaleSet[algBit];
169 (m_masks[algBit]).
first = algName;
170 (m_masks[algBit]).
second = (*m_triggerMaskAlgoTrig)[algBit];
172 (m_vetoMasks[algBit]).
first = algName;
173 (m_vetoMasks[algBit]).
second = (*m_triggerMaskVetoAlgoTrig)[algBit];
176 m_filledPrescales =
true;
181 retrieveL1Event(iEvent, evSetup, m_l1tGlobalUtilHelper->l1tAlgBlkToken());
192 if(m_uGtAlgBlk.isValid()) {
194 std::vector<GlobalAlgBlk>::const_iterator algBlk = m_uGtAlgBlk->begin(0);
195 if (algBlk != m_uGtAlgBlk->end(0)){
196 m_PreScaleColumn =
static_cast<unsigned int>(algBlk->getPreScColumn());
198 m_finalOR = algBlk->getFinalOR();
202 for (std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->begin(); itAlgo != m_algorithmMap->end(); itAlgo++) {
206 int algBit = (itAlgo->second).getIndex();
208 bool decisionInitial = algBlk->getAlgoDecisionInitial(algBit);
209 (m_decisionsInitial[algBit]).
first = algName;
210 (m_decisionsInitial[algBit]).
second = decisionInitial;
212 bool decisionInterm = algBlk->getAlgoDecisionInterm(algBit);
213 (m_decisionsInterm[algBit]).
first = algName;
214 (m_decisionsInterm[algBit]).
second = decisionInterm;
216 bool decisionFinal = algBlk->getAlgoDecisionFinal(algBit);
217 (m_decisionsFinal[algBit]).
first = algName;
218 (m_decisionsFinal[algBit]).
second = decisionFinal;
230 std::ifstream inputPrescaleFile;
231 inputPrescaleFile.open(m_preScaleFileName);
233 std::vector<std::vector<int> > vec;
234 std::vector<std::vector<int> > prescale_vec;
236 std::vector<unsigned int> temp_triggerMask;
237 std::vector<int> temp_triggerVetoMask;
239 if( inputPrescaleFile ){
247 while( getline(inputPrescaleFile,line) ){
249 if( !line.compare(0, prefix1.size(), prefix1) )
continue;
252 istringstream
split(line);
257 while( split >> value ){
260 vec.push_back(std::vector<int>());
263 vec[
col].push_back(value);
276 int NumPrescaleSets = 0;
279 int maskVetoColumn = -1;
280 for(
int iCol=0; iCol<int(vec.size()); iCol++ ){
281 if( vec[iCol].
size() > 0 ){
282 int firstRow = vec[iCol][0];
284 if( firstRow > 0 ) NumPrescaleSets++;
285 else if( firstRow==-2 ) maskColumn = iCol;
286 else if( firstRow==-3 ) maskVetoColumn = iCol;
291 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
292 unsigned int inputDefaultMask = 1;
293 unsigned int inputDefaultVetoMask = 0;
294 temp_triggerMask.push_back(inputDefaultMask);
295 temp_triggerVetoMask.push_back(inputDefaultVetoMask);
301 if( maskColumn>=0 || maskVetoColumn>=0 ){
302 for(
int iBit=1; iBit<int(vec[0].
size()); iBit++ ){
303 unsigned int algoBit = vec[0][iBit];
305 if( algoBit < m_numberPhysTriggers ){
307 unsigned int triggerMask = vec[maskColumn][iBit];
308 temp_triggerMask[algoBit] = triggerMask;
311 if( maskVetoColumn>=0 ){
312 int triggerVetoMask = vec[maskVetoColumn][iBit];
313 temp_triggerVetoMask[algoBit] = triggerVetoMask;
320 if( NumPrescaleSets > 0 ){
322 for(
int iSet=0; iSet<NumPrescaleSets; iSet++ ){
323 prescale_vec.push_back(std::vector<int>());
324 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
325 int inputDefaultPrescale = 1;
326 prescale_vec[iSet].push_back(inputDefaultPrescale);
331 for(
int iBit=1; iBit<int(vec[0].
size()); iBit++ ){
332 unsigned int algoBit = vec[0][iBit];
334 if( algoBit < m_numberPhysTriggers ){
335 for(
int iSet=0; iSet<int(vec.size()); iSet++ ){
337 if( vec[iSet].
size() > 0 ){
338 useSet = vec[iSet][0];
342 if( useSet<0 )
continue;
344 int prescale = vec[iSet][iBit];
345 prescale_vec[useSet][algoBit] = prescale;
350 <<
"\nPrescale file has algo bit: " << algoBit
351 <<
"\nThis is larger than the number of triggers: " << m_numberPhysTriggers
352 <<
"\nSomething is wrong. Ignoring."
361 <<
"\nCould not find file: " << m_preScaleFileName
362 <<
"\nFilling the prescale vectors with prescale 1"
363 <<
"\nSetting prescale set to 1"
366 m_PreScaleColumn = 1;
369 prescale_vec.push_back(std::vector<int>());
370 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
371 int inputDefaultPrescale = 1;
372 prescale_vec[
col].push_back(inputDefaultPrescale);
377 inputPrescaleFile.close();
379 m_initialPrescaleFactorsAlgoTrig = prescale_vec;
380 m_initialTriggerMaskAlgoTrig = temp_triggerMask;
381 m_initialTriggerMaskVetoAlgoTrig = temp_triggerVetoMask;
388 m_decisionsInitial.clear();
389 m_decisionsInitial.resize(m_numberPhysTriggers);
390 m_decisionsInterm.clear();
391 m_decisionsInterm.resize(m_numberPhysTriggers);
392 m_decisionsFinal.clear();
393 m_decisionsFinal.resize(m_numberPhysTriggers);
396 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
398 (m_decisionsInitial[algBit]).
first =
"NULL";
399 (m_decisionsInitial[algBit]).
second =
false;
401 (m_decisionsInterm[algBit]).
first =
"NULL";
402 (m_decisionsInterm[algBit]).
second =
false;
404 (m_decisionsFinal[algBit]).
first =
"NULL";
405 (m_decisionsFinal[algBit]).
second =
false;
416 m_prescales.resize(m_numberPhysTriggers);
418 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
420 (m_prescales[algBit]).
first =
"NULL";
421 (m_prescales[algBit]).
second = 1;
431 m_masks.resize(m_numberPhysTriggers);
433 m_vetoMasks.resize(m_numberPhysTriggers);
435 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
437 (m_masks[algBit]).
first =
"NULL";
438 (m_masks[algBit]).
second =
true;
440 (m_vetoMasks[algBit]).
first =
"NULL";
441 (m_vetoMasks[algBit]).
second =
false;
449 std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->find(algName);
450 if(itAlgo != m_algorithmMap->end()) {
451 bit = (itAlgo->second).getIndex();
461 if((m_decisionsInitial[bit]).
first !=
"NULL") {
462 algName = (m_decisionsInitial[bit]).
first;
477 if((m_decisionsInitial[bit]).
first !=
"NULL") {
478 decision = (m_decisionsInitial[bit]).
second;
487 if((m_decisionsInterm[bit]).
first !=
"NULL") {
488 decision = (m_decisionsInterm[bit]).
second;
497 if((m_decisionsFinal[bit]).
first !=
"NULL") {
498 decision = (m_decisionsFinal[bit]).
second;
507 if((m_prescales[bit]).
first !=
"NULL") {
508 prescale = (m_prescales[bit]).
second;
517 if((m_masks[bit]).
first !=
"NULL") {
518 mask = (m_masks[bit]).
second;
528 if((m_vetoMasks[bit]).
first !=
"NULL") {
529 veto = (m_vetoMasks[bit]).
second;
539 if(getAlgBitFromName(algName,bit)) {
540 decision = (m_decisionsInitial[bit]).
second;
550 if(getAlgBitFromName(algName,bit)) {
551 decision = (m_decisionsInterm[bit]).
second;
561 if(getAlgBitFromName(algName,bit)) {
562 decision = (m_decisionsFinal[bit]).
second;
571 if(getAlgBitFromName(algName,bit)) {
572 prescale = (m_prescales[bit]).
second;
581 if(getAlgBitFromName(algName,bit)) {
582 mask = (m_masks[bit]).
second;
591 if(getAlgBitFromName(algName,bit)) {
592 veto = (m_vetoMasks[bit]).
second;
const bool getInitialDecisionByBit(int &bit, bool &decision) const
std::string m_preScaleFileName
const bool getAlgBitFromName(const std::string &AlgName, int &bit) const
void retrieveL1Event(const edm::Event &iEvent, const edm::EventSetup &evSetup)
bool m_algorithmTriggersUnmasked
bool getByToken(EDGetToken token, Handle< PROD > &result) const
unsigned long long m_l1GtPfAlgoCacheID
const bool getPrescaleByBit(int &bit, int &prescale) const
const bool getIntermDecisionByBit(int &bit, bool &decision) const
unsigned int m_PreScaleColumn
std::unique_ptr< L1TGlobalUtilHelper > m_l1tGlobalUtilHelper
const bool getInitialDecisionByName(const std::string &algName, bool &decision) const
void resetDecisionVectors()
clear decision vectors on a menu change
const bool getMaskByName(const std::string &algName, bool &mask) const
U second(std::pair< T, U > const &p)
static const PrescalesVetosHelper * readFromEventSetup(const L1TGlobalPrescalesVetos *es)
const bool getFinalDecisionByName(const std::string &algName, bool &decision) const
void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn=1)
const bool getAlgNameFromBit(int &bit, std::string &AlgName) const
const bool getVetoMaskByBit(int &bit, bool &veto) const
unsigned long long m_l1GtMenuCacheID
const bool getMaskByBit(int &bit, bool &mask) const
T const * product() const
const bool getVetoMaskByName(const std::string &algName, bool &veto) const
void resetPrescaleVectors()
const bool getFinalDecisionByBit(int &bit, bool &decision) const
const bool getPrescaleByName(const std::string &algName, int &prescale) const
bool m_algorithmTriggersUnprescaled
std::string fullPath() const
const bool getIntermDecisionByName(const std::string &algName, bool &decision) const
virtual ~L1TGlobalUtil()
destructor
void retrieveL1Setup(const edm::EventSetup &evSetup)
void loadPrescalesAndMasks()
tuple size
Write out results.
unsigned int m_numberPhysTriggers
void retrieveL1(const edm::Event &iEvent, const edm::EventSetup &evSetup)
initialize the class (mainly reserve)