63 if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
73 resetDecisionVectors();
75 m_l1GtMenuCacheID = l1GtMenuCacheID;
79 if(!m_filledPrescales) {
82 resetPrescaleVectors();
86 loadPrescalesAndMasks();
89 m_prescaleFactorsAlgoTrig = &m_initialPrescaleFactorsAlgoTrig;
90 m_triggerMaskAlgoTrig = &m_initialTriggerMaskAlgoTrig;
91 m_triggerMaskVetoAlgoTrig = &m_initialTriggerMaskVetoAlgoTrig;
95 if(m_PreScaleColumn > m_prescaleFactorsAlgoTrig->size() || m_PreScaleColumn < 1) {
97 <<
"\nNo Prescale Set: " << m_PreScaleColumn
98 <<
"\nMax Prescale Set value : " << m_prescaleFactorsAlgoTrig->size()
99 <<
"\nSetting prescale column to 1"
101 m_PreScaleColumn = 1;
103 LogDebug(
"l1t|Global") <<
"Grabing prescale column "<< m_PreScaleColumn << endl;
104 const std::vector<int>& prescaleSet = (*m_prescaleFactorsAlgoTrig)[m_PreScaleColumn-1];
106 for (std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->begin(); itAlgo != m_algorithmMap->end(); itAlgo++) {
110 int algBit = (itAlgo->second).getIndex();
112 (m_prescales[algBit]).
first = algName;
113 (m_prescales[algBit]).
second = prescaleSet[algBit];
115 (m_masks[algBit]).
first = algName;
116 (m_masks[algBit]).
second = (*m_triggerMaskAlgoTrig)[algBit];
118 (m_vetoMasks[algBit]).
first = algName;
119 (m_vetoMasks[algBit]).
second = (*m_triggerMaskVetoAlgoTrig)[algBit];
122 m_filledPrescales =
true;
132 if(m_uGtAlgBlk.isValid()) {
134 std::vector<GlobalAlgBlk>::const_iterator algBlk = m_uGtAlgBlk->begin(0);
137 m_finalOR = algBlk->getFinalOR();
141 for (std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->begin(); itAlgo != m_algorithmMap->end(); itAlgo++) {
145 int algBit = (itAlgo->second).getIndex();
147 bool decisionInitial = algBlk->getAlgoDecisionInitial(algBit);
148 (m_decisionsInitial[algBit]).
first = algName;
149 (m_decisionsInitial[algBit]).
second = decisionInitial;
151 bool decisionPrescaled = algBlk->getAlgoDecisionPreScaled(algBit);
152 (m_decisionsPrescaled[algBit]).
first = algName;
153 (m_decisionsPrescaled[algBit]).
second = decisionPrescaled;
155 bool decisionFinal = algBlk->getAlgoDecisionFinal(algBit);
156 (m_decisionsFinal[algBit]).
first = algName;
157 (m_decisionsFinal[algBit]).
second = decisionFinal;
163 <<
"Error no valid uGT Algorithm Data with Token provided " << endl;
170 std::fstream inputPrescaleFile;
171 inputPrescaleFile.open(m_preScaleFileName);
173 std::vector<std::vector<int> > vec;
174 std::vector<std::vector<int> > prescale_vec;
176 std::vector<unsigned int> temp_triggerMask;
177 std::vector<unsigned int> temp_triggerVetoMask;
179 if( inputPrescaleFile ){
187 while( getline(inputPrescaleFile,line) ){
189 if( !line.compare(0, prefix1.size(), prefix1) )
continue;
192 istringstream
split(line);
197 while( split >> value ){
200 vec.push_back(std::vector<int>());
203 vec[
col].push_back(value);
216 int NumPrescaleSets = 0;
219 int maskVetoColumn = -1;
220 for(
int iCol=0; iCol<int(vec.size()); iCol++ ){
221 if( vec[iCol].
size() > 0 ){
222 int firstRow = vec[iCol][0];
224 if( firstRow > 0 ) NumPrescaleSets++;
225 else if( firstRow==-2 ) maskColumn = iCol;
226 else if( firstRow==-3 ) maskVetoColumn = iCol;
231 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
232 unsigned int inputDefaultMask = 1;
233 unsigned int inputDefaultVetoMask = 0;
234 temp_triggerMask.push_back(inputDefaultMask);
235 temp_triggerVetoMask.push_back(inputDefaultVetoMask);
241 if( maskColumn>=0 || maskVetoColumn>=0 ){
242 for(
int iBit=1; iBit<int(vec[0].
size()); iBit++ ){
243 unsigned int algoBit = vec[0][iBit];
245 if( algoBit < m_numberPhysTriggers ){
247 unsigned int triggerMask = vec[maskColumn][iBit];
248 temp_triggerMask[algoBit] = triggerMask;
251 if( maskVetoColumn>=0 ){
252 unsigned int triggerVetoMask = vec[maskVetoColumn][iBit];
253 temp_triggerVetoMask[algoBit] = triggerVetoMask;
260 if( NumPrescaleSets > 0 ){
262 for(
int iSet=0; iSet<NumPrescaleSets; iSet++ ){
263 prescale_vec.push_back(std::vector<int>());
264 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
265 int inputDefaultPrescale = 1;
266 prescale_vec[iSet].push_back(inputDefaultPrescale);
271 for(
int iBit=1; iBit<int(vec[0].
size()); iBit++ ){
272 unsigned int algoBit = vec[0][iBit];
274 if( algoBit < m_numberPhysTriggers ){
275 for(
int iSet=0; iSet<int(vec.size()); iSet++ ){
277 if( vec[iSet].
size() > 0 ){
278 useSet = vec[iSet][0];
282 if( useSet<0 )
continue;
284 int prescale = vec[iSet][iBit];
285 prescale_vec[useSet][algoBit] = prescale;
290 <<
"\nPrescale file has algo bit: " << algoBit
291 <<
"\nThis is larger than the number of triggers: " << m_numberPhysTriggers
292 <<
"\nSomething is wrong. Ignoring."
301 <<
"\nCould not find file: " << m_preScaleFileName
302 <<
"\nFilling the prescale vectors with prescale 1"
303 <<
"\nSetting prescale set to 1"
306 m_PreScaleColumn = 1;
309 prescale_vec.push_back(std::vector<int>());
310 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
311 int inputDefaultPrescale = 1;
312 prescale_vec[
col].push_back(inputDefaultPrescale);
317 inputPrescaleFile.close();
319 m_initialPrescaleFactorsAlgoTrig = prescale_vec;
320 m_initialTriggerMaskAlgoTrig = temp_triggerMask;
321 m_initialTriggerMaskVetoAlgoTrig = temp_triggerVetoMask;
328 m_decisionsInitial.clear();
329 m_decisionsInitial.resize(m_numberPhysTriggers);
330 m_decisionsPrescaled.clear();
331 m_decisionsPrescaled.resize(m_numberPhysTriggers);
332 m_decisionsFinal.clear();
333 m_decisionsFinal.resize(m_numberPhysTriggers);
336 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
338 (m_decisionsInitial[algBit]).
first =
"NULL";
339 (m_decisionsInitial[algBit]).
second =
false;
341 (m_decisionsPrescaled[algBit]).
first =
"NULL";
342 (m_decisionsPrescaled[algBit]).
second =
false;
344 (m_decisionsFinal[algBit]).
first =
"NULL";
345 (m_decisionsFinal[algBit]).
second =
false;
356 m_prescales.resize(m_numberPhysTriggers);
358 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
360 (m_prescales[algBit]).
first =
"NULL";
361 (m_prescales[algBit]).
second = 1;
371 m_masks.resize(m_numberPhysTriggers);
373 m_vetoMasks.resize(m_numberPhysTriggers);
375 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
377 (m_masks[algBit]).
first =
"NULL";
378 (m_masks[algBit]).
second =
true;
380 (m_vetoMasks[algBit]).
first =
"NULL";
381 (m_vetoMasks[algBit]).
second =
false;
389 std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->find(algName);
390 if(itAlgo != m_algorithmMap->end()) {
391 bit = (itAlgo->second).getIndex();
401 if((m_decisionsInitial[bit]).
first !=
"NULL") {
402 algName = (m_decisionsInitial[bit]).
first;
417 if((m_decisionsInitial[bit]).
first !=
"NULL") {
418 decision = (m_decisionsInitial[bit]).
second;
427 if((m_decisionsPrescaled[bit]).
first !=
"NULL") {
428 decision = (m_decisionsPrescaled[bit]).
second;
437 if((m_decisionsFinal[bit]).
first !=
"NULL") {
438 decision = (m_decisionsFinal[bit]).
second;
447 if((m_prescales[bit]).
first !=
"NULL") {
448 prescale = (m_prescales[bit]).
second;
457 if((m_masks[bit]).
first !=
"NULL") {
458 mask = (m_masks[bit]).
second;
468 if((m_vetoMasks[bit]).
first !=
"NULL") {
469 veto = (m_vetoMasks[bit]).
second;
479 if(getAlgBitFromName(algName,bit)) {
480 decision = (m_decisionsInitial[bit]).
second;
490 if(getAlgBitFromName(algName,bit)) {
491 decision = (m_decisionsPrescaled[bit]).
second;
501 if(getAlgBitFromName(algName,bit)) {
502 decision = (m_decisionsFinal[bit]).
second;
511 if(getAlgBitFromName(algName,bit)) {
512 prescale = (m_prescales[bit]).
second;
521 if(getAlgBitFromName(algName,bit)) {
522 mask = (m_masks[bit]).
second;
531 if(getAlgBitFromName(algName,bit)) {
532 veto = (m_vetoMasks[bit]).
second;
const bool getAlgNameFromBit(int &bit, std::string &AlgName) const
const bool getFinalDecisionByBit(int &bit, bool &decision) const
std::string m_preScaleFileName
void resetDecisionVectors()
clear decision vectors on a menu change
bool getByToken(EDGetToken token, Handle< PROD > &result) const
unsigned int m_PreScaleColumn
void loadPrescalesAndMasks()
const bool getPrescaledDecisionByBit(int &bit, bool &decision) const
L1TGlobalUtil(std::string preScaleFileName, unsigned int psColumn)
const bool getAlgBitFromName(const std::string &AlgName, int &bit) const
const bool getVetoMaskByBit(int &bit, bool &veto) const
const bool getPrescaleByBit(int &bit, int &prescale) const
U second(std::pair< T, U > const &p)
void resetPrescaleVectors()
const bool getPrescaledDecisionByName(const std::string &algName, bool &decision) const
const bool getInitialDecisionByBit(int &bit, bool &decision) const
const bool getVetoMaskByName(const std::string &algName, bool &veto) const
const bool getMaskByBit(int &bit, bool &mask) const
unsigned long long m_l1GtMenuCacheID
T const * product() const
const bool getMaskByName(const std::string &algName, bool &mask) const
void retrieveL1(const edm::Event &iEvent, const edm::EventSetup &evSetup, edm::EDGetToken gtAlgToken)
initialize the class (mainly reserve)
const bool getPrescaleByName(const std::string &algName, int &prescale) const
const bool getInitialDecisionByName(const std::string &algName, bool &decision) const
const bool getFinalDecisionByName(const std::string &algName, bool &decision) const
tuple size
Write out results.
unsigned int m_numberPhysTriggers