CMS 3D CMS Logo

TriggerMenuParser.cc
Go to the documentation of this file.
1 
31 // this class header
32 #include "TriggerMenuParser.h"
33 
34 // system include files
35 #include <string>
36 #include <vector>
37 
38 #include <iostream>
39 #include <fstream>
40 #include <iomanip>
41 #include <cmath>
42 
44 
47 
48 #include "tmEventSetup/tmEventSetup.hh"
49 #include "tmEventSetup/esTypes.hh"
50 
57 #include "tmGrammar/Algorithm.hh"
58 
59 #include <cstdint>
60 
61 // constructor
63  : m_triggerMenuInterface("NULL"),
64  m_triggerMenuName("NULL"),
65  m_triggerMenuImplementation(0x0),
66  m_scaleDbKey("NULL")
67 
68 {
69  // menu names, scale key initialized to NULL due to ORACLE treatment of strings
70 
71  // empty
72 }
73 
74 // destructor
76 
77 // set the number of condition chips in GTL
78 void l1t::TriggerMenuParser::setGtNumberConditionChips(const unsigned int& numberConditionChipsValue) {
79  m_numberConditionChips = numberConditionChipsValue;
80 }
81 
82 // set the number of pins on the GTL condition chips
83 void l1t::TriggerMenuParser::setGtPinsOnConditionChip(const unsigned int& pinsOnConditionChipValue) {
84  m_pinsOnConditionChip = pinsOnConditionChipValue;
85 }
86 
87 // set the correspondence "condition chip - GTL algorithm word"
88 // in the hardware
89 void l1t::TriggerMenuParser::setGtOrderConditionChip(const std::vector<int>& orderConditionChipValue) {
90  m_orderConditionChip = orderConditionChipValue;
91 }
92 
93 // set the number of physics trigger algorithms
94 void l1t::TriggerMenuParser::setGtNumberPhysTriggers(const unsigned int& numberPhysTriggersValue) {
95  m_numberPhysTriggers = numberPhysTriggersValue;
96 }
97 
98 // set the condition maps
99 void l1t::TriggerMenuParser::setGtConditionMap(const std::vector<ConditionMap>& condMap) { m_conditionMap = condMap; }
100 
101 // set the trigger menu name
103  m_triggerMenuInterface = menuInterface;
104 }
105 
106 // set the trigger menu uuid
107 void l1t::TriggerMenuParser::setGtTriggerMenuUUID(const int uuid) { m_triggerMenuUUID = uuid; }
108 
109 void l1t::TriggerMenuParser::setGtTriggerMenuName(const std::string& menuName) { m_triggerMenuName = menuName; }
110 
111 void l1t::TriggerMenuParser::setGtTriggerMenuImplementation(const unsigned long& menuImplementation) {
112  m_triggerMenuImplementation = menuImplementation;
113 }
114 
115 // set menu associated scale key
116 void l1t::TriggerMenuParser::setGtScaleDbKey(const std::string& scaleKey) { m_scaleDbKey = scaleKey; }
117 
118 // set the vectors containing the conditions
119 void l1t::TriggerMenuParser::setVecMuonTemplate(const std::vector<std::vector<MuonTemplate> >& vecMuonTempl) {
120  m_vecMuonTemplate = vecMuonTempl;
121 }
122 
124  const std::vector<std::vector<MuonShowerTemplate> >& vecMuonShowerTempl) {
125  m_vecMuonShowerTemplate = vecMuonShowerTempl;
126 }
127 
128 void l1t::TriggerMenuParser::setVecCaloTemplate(const std::vector<std::vector<CaloTemplate> >& vecCaloTempl) {
129  m_vecCaloTemplate = vecCaloTempl;
130 }
131 
133  const std::vector<std::vector<EnergySumTemplate> >& vecEnergySumTempl) {
134  m_vecEnergySumTemplate = vecEnergySumTempl;
135 }
136 
138  const std::vector<std::vector<ExternalTemplate> >& vecExternalTempl) {
139  m_vecExternalTemplate = vecExternalTempl;
140 }
141 
143  const std::vector<std::vector<CorrelationTemplate> >& vecCorrelationTempl) {
144  m_vecCorrelationTemplate = vecCorrelationTempl;
145 }
146 
148  const std::vector<std::vector<CorrelationThreeBodyTemplate> >& vecCorrelationThreeBodyTempl) {
149  m_vecCorrelationThreeBodyTemplate = vecCorrelationThreeBodyTempl;
150 }
151 
153  const std::vector<std::vector<CorrelationWithOverlapRemovalTemplate> >& vecCorrelationWithOverlapRemovalTempl) {
154  m_vecCorrelationWithOverlapRemovalTemplate = vecCorrelationWithOverlapRemovalTempl;
155 }
156 
157 // set the vectors containing the conditions for correlation templates
158 //
159 void l1t::TriggerMenuParser::setCorMuonTemplate(const std::vector<std::vector<MuonTemplate> >& corMuonTempl) {
160  m_corMuonTemplate = corMuonTempl;
161 }
162 
163 void l1t::TriggerMenuParser::setCorCaloTemplate(const std::vector<std::vector<CaloTemplate> >& corCaloTempl) {
164  m_corCaloTemplate = corCaloTempl;
165 }
166 
168  const std::vector<std::vector<EnergySumTemplate> >& corEnergySumTempl) {
169  m_corEnergySumTemplate = corEnergySumTempl;
170 }
171 
172 // set the algorithm map (by algorithm names)
173 void l1t::TriggerMenuParser::setGtAlgorithmMap(const AlgorithmMap& algoMap) { m_algorithmMap = algoMap; }
174 
175 // set the algorithm map (by algorithm aliases)
176 void l1t::TriggerMenuParser::setGtAlgorithmAliasMap(const AlgorithmMap& algoMap) { m_algorithmAliasMap = algoMap; }
177 
178 std::map<std::string, unsigned int> l1t::TriggerMenuParser::getExternalSignals(const L1TUtmTriggerMenu* utmMenu) {
179  using namespace tmeventsetup;
180  const std::map<std::string, L1TUtmCondition>& condMap = utmMenu->getConditionMap();
181 
182  std::map<std::string, unsigned int> extBitMap;
183 
184  //loop over the algorithms
185  for (const auto& cit : condMap) {
186  const L1TUtmCondition& condition = cit.second;
187  if (condition.getType() == esConditionType::Externals) {
188  // Get object for External conditions
189  const std::vector<L1TUtmObject>& objects = condition.getObjects();
190  for (const auto& object : objects) {
191  if (object.getType() == esObjectType::EXT) {
192  unsigned int channelID = object.getExternalChannelId();
193  std::string name = object.getExternalSignalName();
194 
195  if (extBitMap.count(name) == 0)
196  extBitMap.insert(std::map<std::string, unsigned int>::value_type(name, channelID));
197  }
198  }
199  }
200  }
201 
202  return extBitMap;
203 }
204 
205 // parse def.xml file
207  // resize the vector of condition maps
208  // the number of condition chips should be correctly set before calling parseXmlFile
209  m_conditionMap.resize(m_numberConditionChips);
210 
211  m_vecMuonTemplate.resize(m_numberConditionChips);
212  m_vecMuonShowerTemplate.resize(m_numberConditionChips);
213  m_vecCaloTemplate.resize(m_numberConditionChips);
214  m_vecEnergySumTemplate.resize(m_numberConditionChips);
215  m_vecExternalTemplate.resize(m_numberConditionChips);
216 
217  m_vecCorrelationTemplate.resize(m_numberConditionChips);
218  m_vecCorrelationThreeBodyTemplate.resize(m_numberConditionChips);
219  m_vecCorrelationWithOverlapRemovalTemplate.resize(m_numberConditionChips);
220  m_corMuonTemplate.resize(m_numberConditionChips);
221  m_corCaloTemplate.resize(m_numberConditionChips);
222  m_corEnergySumTemplate.resize(m_numberConditionChips);
223 
224  using namespace tmeventsetup;
225  using namespace Algorithm;
226 
227  //get the meta data
228  m_triggerMenuDescription = utmMenu->getComment();
229  m_triggerMenuDate = utmMenu->getDatetime();
230  m_triggerMenuImplementation = (getMmHashN(utmMenu->getFirmwareUuid()) & 0xFFFFFFFF); //make sure we only have 32 bits
231  m_triggerMenuName = utmMenu->getName();
232  m_triggerMenuInterface = utmMenu->getVersion(); //BLW: correct descriptor?
233  m_triggerMenuUUID = (getMmHashN(utmMenu->getName()) & 0xFFFFFFFF); //make sure we only have 32 bits
234 
235  const std::map<std::string, L1TUtmAlgorithm>& algoMap = utmMenu->getAlgorithmMap();
236  const std::map<std::string, L1TUtmCondition>& condMap = utmMenu->getConditionMap();
237  //We use es types for scale map to use auxiliary functions without having to duplicate code
238  const std::map<std::string, tmeventsetup::esScale> scaleMap(std::begin(utmMenu->getScaleMap()),
239  std::end(utmMenu->getScaleMap()));
240 
241  // parse the scales
242  m_gtScales.setScalesName(utmMenu->getScaleSetName());
243  parseScales(scaleMap);
244 
245  //loop over the algorithms
246  for (const auto& cit : algoMap) {
247  //condition chip (artifact) TO DO: Update
248  int chipNr = 0;
249 
250  //get algorithm
251  const L1TUtmAlgorithm& algo = cit.second;
252 
253  //parse the algorithm
254  parseAlgorithm(algo, chipNr); //blw
255 
256  //get conditions for this algorithm
257  const std::vector<std::string>& rpn_vec = algo.getRpnVector();
258  for (size_t ii = 0; ii < rpn_vec.size(); ii++) {
259  const std::string& token = rpn_vec.at(ii);
260  if (isGate(token))
261  continue;
262  // long hash = getHash(token);
263  const L1TUtmCondition& condition = condMap.find(token)->second;
264 
265  //check to see if this condtion already exists
266  if ((m_conditionMap[chipNr]).count(condition.getName()) == 0) {
267  // parse Calo Conditions (EG, Jets, Taus)
268  if (condition.getType() == esConditionType::SingleEgamma ||
269  condition.getType() == esConditionType::DoubleEgamma ||
270  condition.getType() == esConditionType::TripleEgamma ||
271  condition.getType() == esConditionType::QuadEgamma || condition.getType() == esConditionType::SingleTau ||
272  condition.getType() == esConditionType::DoubleTau || condition.getType() == esConditionType::TripleTau ||
273  condition.getType() == esConditionType::QuadTau || condition.getType() == esConditionType::SingleJet ||
274  condition.getType() == esConditionType::DoubleJet || condition.getType() == esConditionType::TripleJet ||
275  condition.getType() == esConditionType::QuadJet) {
276  parseCalo(condition, chipNr, false);
277 
278  // parse Energy Sums
279  } else if (condition.getType() == esConditionType::TotalEt ||
280  condition.getType() == esConditionType::TotalEtEM ||
281  condition.getType() == esConditionType::TotalHt ||
282  condition.getType() == esConditionType::MissingEt ||
283  condition.getType() == esConditionType::MissingHt ||
284  condition.getType() == esConditionType::MissingEtHF ||
285  condition.getType() == esConditionType::TowerCount ||
286  condition.getType() == esConditionType::MinBiasHFP0 ||
287  condition.getType() == esConditionType::MinBiasHFM0 ||
288  condition.getType() == esConditionType::MinBiasHFP1 ||
289  condition.getType() == esConditionType::MinBiasHFM1 ||
290  condition.getType() == esConditionType::AsymmetryEt ||
291  condition.getType() == esConditionType::AsymmetryHt ||
292  condition.getType() == esConditionType::AsymmetryEtHF ||
293  condition.getType() == esConditionType::AsymmetryHtHF ||
294  condition.getType() == esConditionType::Centrality0 ||
295  condition.getType() == esConditionType::Centrality1 ||
296  condition.getType() == esConditionType::Centrality2 ||
297  condition.getType() == esConditionType::Centrality3 ||
298  condition.getType() == esConditionType::Centrality4 ||
299  condition.getType() == esConditionType::Centrality5 ||
300  condition.getType() == esConditionType::Centrality6 ||
301  condition.getType() == esConditionType::Centrality7) {
302  parseEnergySum(condition, chipNr, false);
303 
304  //parse Muons
305  } else if (condition.getType() == esConditionType::SingleMuon ||
306  condition.getType() == esConditionType::DoubleMuon ||
307  condition.getType() == esConditionType::TripleMuon ||
308  condition.getType() == esConditionType::QuadMuon) {
309  parseMuon(condition, chipNr, false);
310 
311  } else if (condition.getType() == esConditionType::MuonShower0 ||
312  condition.getType() == esConditionType::MuonShower1 ||
313  condition.getType() == esConditionType::MuonShower2 ||
314  condition.getType() == esConditionType::MuonShowerOutOfTime0 ||
315  condition.getType() == esConditionType::MuonShowerOutOfTime1) {
316  parseMuonShower(condition, chipNr, false);
317 
318  //parse Correlation Conditions
319  } else if (condition.getType() == esConditionType::MuonMuonCorrelation ||
320  condition.getType() == esConditionType::MuonEsumCorrelation ||
321  condition.getType() == esConditionType::CaloMuonCorrelation ||
322  condition.getType() == esConditionType::CaloCaloCorrelation ||
323  condition.getType() == esConditionType::CaloEsumCorrelation ||
324  condition.getType() == esConditionType::InvariantMass ||
325  condition.getType() == esConditionType::InvariantMassDeltaR ||
326  condition.getType() == esConditionType::TransverseMass ||
327  condition.getType() == esConditionType::InvariantMassUpt) { // Added for displaced muons
328  parseCorrelation(condition, chipNr);
329 
330  //parse three-body Correlation Conditions
331  } else if (condition.getType() == esConditionType::InvariantMass3) {
332  parseCorrelationThreeBody(condition, chipNr);
333 
334  //parse Externals
335  } else if (condition.getType() == esConditionType::Externals) {
336  parseExternal(condition, chipNr);
337 
338  //parse CorrelationWithOverlapRemoval
339  } else if (condition.getType() == esConditionType::CaloCaloCorrelationOvRm ||
340  condition.getType() == esConditionType::InvariantMassOvRm ||
341  condition.getType() == esConditionType::TransverseMassOvRm ||
342  condition.getType() == esConditionType::DoubleJetOvRm ||
343  condition.getType() == esConditionType::DoubleTauOvRm) {
344  parseCorrelationWithOverlapRemoval(condition, chipNr);
345 
346  } else if (condition.getType() == esConditionType::SingleEgammaOvRm ||
347  condition.getType() == esConditionType::DoubleEgammaOvRm ||
348  condition.getType() == esConditionType::TripleEgammaOvRm ||
349  condition.getType() == esConditionType::QuadEgammaOvRm ||
350  condition.getType() == esConditionType::SingleTauOvRm ||
351  condition.getType() == esConditionType::TripleTauOvRm ||
352  condition.getType() == esConditionType::QuadTauOvRm ||
353  condition.getType() == esConditionType::SingleJetOvRm ||
354  condition.getType() == esConditionType::TripleJetOvRm ||
355  condition.getType() == esConditionType::QuadJetOvRm) {
356  edm::LogError("TriggerMenuParser") << std::endl
357  << "\n SingleEgammaOvRm"
358  << "\n DoubleEgammaOvRm"
359  << "\n TripleEgammaOvRm"
360  << "\n QuadEgammaOvRm"
361  << "\n SingleTauOvRm"
362  << "\n TripleTauOvRm"
363  << "\n QuadTauOvRm"
364  << "\n SingleJetOvRm"
365  << "\n TripleJetOvRm"
366  << "\n QuadJetOvRm"
367  << "\n The above conditions types OvRm are not implemented yet in the "
368  "parser. Please remove alogrithms that "
369  "use this type of condtion from L1T Menu!"
370  << std::endl;
371  }
372 
373  } //if condition is a new one
374  } //loop over conditions
375  } //loop over algorithms
376 
377  return;
378 }
379 
380 //
381 
382 void l1t::TriggerMenuParser::setGtTriggerMenuInterfaceDate(const std::string& val) { m_triggerMenuInterfaceDate = val; }
383 
385  m_triggerMenuInterfaceAuthor = val;
386 }
387 
389  m_triggerMenuInterfaceDescription = val;
390 }
391 
393 
394 void l1t::TriggerMenuParser::setGtTriggerMenuAuthor(const std::string& val) { m_triggerMenuAuthor = val; }
395 
396 void l1t::TriggerMenuParser::setGtTriggerMenuDescription(const std::string& val) { m_triggerMenuDescription = val; }
397 
398 void l1t::TriggerMenuParser::setGtAlgorithmImplementation(const std::string& val) { m_algorithmImplementation = val; }
399 
400 // methods for conditions and algorithms
401 
402 // clearMaps - delete all conditions and algorithms in
403 // the maps and clear the maps.
405  // loop over condition maps (one map per condition chip)
406  // then loop over conditions in the map
407  for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip != m_conditionMap.end();
408  itCondOnChip++) {
409  // the conditions in the maps are deleted in L1uGtTriggerMenu, not here
410 
411  itCondOnChip->clear();
412  }
413 
414  // the algorithms in the maps are deleted in L1uGtTriggerMenu, not here
415  m_algorithmMap.clear();
416 }
417 
418 // insertConditionIntoMap - safe insert of condition into condition map.
419 // if the condition name already exists, do not insert it and return false
421  std::string cName = cond.condName();
422  LogTrace("TriggerMenuParser") << " Trying to insert condition \"" << cName << "\" in the condition map."
423  << std::endl;
424 
425  // no condition name has to appear twice!
426  if ((m_conditionMap[chipNr]).count(cName) != 0) {
427  LogTrace("TriggerMenuParser") << " Condition " << cName << " already exists - not inserted!" << std::endl;
428  return false;
429  }
430 
431  (m_conditionMap[chipNr])[cName] = &cond;
432  LogTrace("TriggerMenuParser") << " OK - condition inserted!" << std::endl;
433 
434  return true;
435 }
436 
437 // insert an algorithm into algorithm map
439  std::string algName = alg.algoName();
440  const std::string& algAlias = alg.algoAlias();
441  //LogTrace("TriggerMenuParser")
442  //<< " Trying to insert algorithm \"" << algName << "\" in the algorithm map." ;
443 
444  // no algorithm name has to appear twice!
445  if (m_algorithmMap.count(algName) != 0) {
446  LogTrace("TriggerMenuParser") << " Algorithm \"" << algName
447  << "\"already exists in the algorithm map- not inserted!" << std::endl;
448  return false;
449  }
450 
451  if (m_algorithmAliasMap.count(algAlias) != 0) {
452  LogTrace("TriggerMenuParser") << " Algorithm alias \"" << algAlias
453  << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
454  return false;
455  }
456 
457  // bit number less than zero or greater than maximum number of algorithms
458  int bitNumber = alg.algoBitNumber();
459  if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
460  LogTrace("TriggerMenuParser") << " Bit number " << bitNumber << " outside allowed range [0, "
461  << m_numberPhysTriggers << ") - algorithm not inserted!" << std::endl;
462  return false;
463  }
464 
465  // maximum number of algorithms
466  if (m_algorithmMap.size() >= m_numberPhysTriggers) {
467  LogTrace("TriggerMenuParser") << " More than maximum allowed " << m_numberPhysTriggers
468  << " algorithms in the algorithm map - not inserted!" << std::endl;
469  return false;
470  }
471 
472  // chip number outside allowed values
473  int chipNr = alg.algoChipNumber(
474  static_cast<int>(m_numberConditionChips), static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
475 
476  if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
477  LogTrace("TriggerMenuParser") << " Chip number " << chipNr << " outside allowed range [0, "
478  << m_numberConditionChips << ") - algorithm not inserted!" << std::endl;
479  return false;
480  }
481 
482  // output pin outside allowed values
483  int outputPin = alg.algoOutputPin(
484  static_cast<int>(m_numberConditionChips), static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
485 
486  if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
487  LogTrace("TriggerMenuParser") << " Output pin " << outputPin << " outside allowed range [0, "
488  << m_pinsOnConditionChip << "] - algorithm not inserted!" << std::endl;
489  return false;
490  }
491 
492  // no two algorithms on the same chip can have the same output pin
493  for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
494  int iPin = (itAlgo->second)
495  .algoOutputPin(static_cast<int>(m_numberConditionChips),
496  static_cast<int>(m_pinsOnConditionChip),
497  m_orderConditionChip);
498  std::string iName = itAlgo->first;
499  int iChip = (itAlgo->second)
500  .algoChipNumber(static_cast<int>(m_numberConditionChips),
501  static_cast<int>(m_pinsOnConditionChip),
502  m_orderConditionChip);
503 
504  if ((outputPin == iPin) && (chipNr == iChip)) {
505  LogTrace("TriggerMenuParser") << " Output pin " << outputPin << " is the same as for algorithm " << iName
506  << "\n from the same chip number " << chipNr << " - algorithm not inserted!"
507  << std::endl;
508  return false;
509  }
510  }
511 
512  // insert algorithm
513  m_algorithmMap[algName] = alg;
514  m_algorithmAliasMap[algAlias] = alg;
515 
516  //LogTrace("TriggerMenuParser")
517  //<< " OK - algorithm inserted!"
518  //<< std::endl;
519 
520  return true;
521 }
522 
523 template <typename T>
525  std::stringstream ss;
526  ss << data;
527  return ss.str();
528 }
530  std::stringstream ss;
531  ss << data;
532  int value;
533  ss >> value;
534  return value;
535 }
536 
544 bool l1t::TriggerMenuParser::parseScales(std::map<std::string, tmeventsetup::esScale> scaleMap) {
545  using namespace tmeventsetup;
546 
547  // Setup ScaleParameter to hold information from parsing
553  GlobalScales::ScaleParameters ettEmScales;
555  GlobalScales::ScaleParameters etmHfScales;
558 
559  // Start by parsing the Scale Map
560  for (std::map<std::string, tmeventsetup::esScale>::const_iterator cit = scaleMap.begin(); cit != scaleMap.end();
561  cit++) {
562  const tmeventsetup::esScale& scale = cit->second;
563 
564  GlobalScales::ScaleParameters* scaleParam;
565  if (scale.getObjectType() == esObjectType::Muon)
566  scaleParam = &muScales;
567  else if (scale.getObjectType() == esObjectType::Egamma)
568  scaleParam = &egScales;
569  else if (scale.getObjectType() == esObjectType::Tau)
570  scaleParam = &tauScales;
571  else if (scale.getObjectType() == esObjectType::Jet)
572  scaleParam = &jetScales;
573  else if (scale.getObjectType() == esObjectType::ETT)
574  scaleParam = &ettScales;
575  else if (scale.getObjectType() == esObjectType::ETTEM)
576  scaleParam = &ettEmScales;
577  else if (scale.getObjectType() == esObjectType::ETM)
578  scaleParam = &etmScales;
579  else if (scale.getObjectType() == esObjectType::ETMHF)
580  scaleParam = &etmHfScales;
581  else if (scale.getObjectType() == esObjectType::HTT)
582  scaleParam = &httScales;
583  else if (scale.getObjectType() == esObjectType::HTM)
584  scaleParam = &htmScales;
585  else
586  scaleParam = nullptr;
587 
588  if (scaleParam != nullptr) {
589  switch (scale.getScaleType()) {
590  case esScaleType::EtScale: {
591  scaleParam->etMin = scale.getMinimum();
592  scaleParam->etMax = scale.getMaximum();
593  scaleParam->etStep = scale.getStep();
594 
595  //Get bin edges
596  const std::vector<tmeventsetup::esBin>& binsV = scale.getBins();
597  for (unsigned int i = 0; i < binsV.size(); i++) {
598  const tmeventsetup::esBin& bin = binsV.at(i);
599  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
600  scaleParam->etBins.push_back(binLimits);
601  }
602 
603  // If this is an energy sum fill dummy values for eta and phi
604  // There are no scales for these in the XML so the other case statements will not be seen....do it here.
605  if (scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT ||
606  scale.getObjectType() == esObjectType::ETM || scale.getObjectType() == esObjectType::HTM ||
607  scale.getObjectType() == esObjectType::ETTEM || scale.getObjectType() == esObjectType::ETMHF) {
608  scaleParam->etaMin = -1.;
609  scaleParam->etaMax = -1.;
610  scaleParam->etaStep = -1.;
611  if (scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT ||
612  scale.getObjectType() == esObjectType::ETTEM) {
613  // if(scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT) {
614  scaleParam->phiMin = -1.;
615  scaleParam->phiMax = -1.;
616  scaleParam->phiStep = -1.;
617  }
618  }
619  } break;
620  case esScaleType::UnconstrainedPtScale: { // Added for displaced muons
621  scaleParam->uptMin = scale.getMinimum();
622  scaleParam->uptMax = scale.getMaximum();
623  scaleParam->uptStep = scale.getStep();
624 
625  //Get bin edges
626  const std::vector<tmeventsetup::esBin>& binsV = scale.getBins();
627  for (unsigned int i = 0; i < binsV.size(); i++) {
628  const tmeventsetup::esBin& bin = binsV.at(i);
629  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
630  scaleParam->uptBins.push_back(binLimits);
631  }
632  } break;
633  case esScaleType::EtaScale: {
634  scaleParam->etaMin = scale.getMinimum();
635  scaleParam->etaMax = scale.getMaximum();
636  scaleParam->etaStep = scale.getStep();
637 
638  //Get bin edges
639  const std::vector<tmeventsetup::esBin>& binsV = scale.getBins();
640  scaleParam->etaBins.resize(pow(2, scale.getNbits()));
641  for (unsigned int i = 0; i < binsV.size(); i++) {
642  const tmeventsetup::esBin& bin = binsV.at(i);
643  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
644  scaleParam->etaBins.at(bin.hw_index) = binLimits;
645  }
646  } break;
647  case esScaleType::PhiScale: {
648  scaleParam->phiMin = scale.getMinimum();
649  scaleParam->phiMax = scale.getMaximum();
650  scaleParam->phiStep = scale.getStep();
651 
652  //Get bin edges
653  const std::vector<tmeventsetup::esBin>& binsV = scale.getBins();
654  scaleParam->phiBins.resize(pow(2, scale.getNbits()));
655  for (unsigned int i = 0; i < binsV.size(); i++) {
656  const tmeventsetup::esBin& bin = binsV.at(i);
657  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
658  scaleParam->phiBins.at(bin.hw_index) = binLimits;
659  }
660  } break;
661  default:
662 
663  break;
664  } //end switch
665  } //end valid scale
666  } //end loop over scaleMap
667 
668  // put the ScaleParameters into the class
669  m_gtScales.setMuonScales(muScales);
670  m_gtScales.setEGScales(egScales);
671  m_gtScales.setTauScales(tauScales);
672  m_gtScales.setJetScales(jetScales);
673  m_gtScales.setETTScales(ettScales);
674  m_gtScales.setETTEmScales(ettEmScales);
675  m_gtScales.setETMScales(etmScales);
676  m_gtScales.setETMHfScales(etmHfScales);
677  m_gtScales.setHTTScales(httScales);
678  m_gtScales.setHTMScales(htmScales);
679 
680  // Setup the LUT for the Scale Conversions
681  bool hasPrecision = false;
682  std::map<std::string, unsigned int> precisions;
683  getPrecisions(precisions, scaleMap);
684  for (std::map<std::string, unsigned int>::const_iterator cit = precisions.begin(); cit != precisions.end(); cit++) {
685  hasPrecision = true;
686  }
687 
688  if (hasPrecision) {
689  //Start with the Cal - Muon Eta LUTS
690  //----------------------------------
691  parseCalMuEta_LUTS(scaleMap, "EG", "MU");
692  parseCalMuEta_LUTS(scaleMap, "JET", "MU");
693  parseCalMuEta_LUTS(scaleMap, "TAU", "MU");
694 
695  //Now the Cal - Muon Phi LUTS
696  //-------------------------------------
697  parseCalMuPhi_LUTS(scaleMap, "EG", "MU");
698  parseCalMuPhi_LUTS(scaleMap, "JET", "MU");
699  parseCalMuPhi_LUTS(scaleMap, "TAU", "MU");
700  parseCalMuPhi_LUTS(scaleMap, "HTM", "MU");
701  parseCalMuPhi_LUTS(scaleMap, "ETM", "MU");
702  parseCalMuPhi_LUTS(scaleMap, "ETMHF", "MU");
703 
704  // Now the Pt LUTs (??? more combinations needed ??)
705  // ---------------
706  parsePt_LUTS(scaleMap, "Mass", "EG", precisions["PRECISION-EG-MU-MassPt"]);
707  parsePt_LUTS(scaleMap, "Mass", "MU", precisions["PRECISION-EG-MU-MassPt"]);
708  parseUpt_LUTS(scaleMap, "Mass", "MU", precisions["PRECISION-EG-MU-MassPt"]); // Added for displaced muons
709  parsePt_LUTS(scaleMap, "Mass", "JET", precisions["PRECISION-EG-JET-MassPt"]);
710  parsePt_LUTS(scaleMap, "Mass", "TAU", precisions["PRECISION-EG-TAU-MassPt"]);
711  parsePt_LUTS(scaleMap, "Mass", "ETM", precisions["PRECISION-EG-ETM-MassPt"]);
712  parsePt_LUTS(scaleMap, "Mass", "ETMHF", precisions["PRECISION-EG-ETMHF-MassPt"]);
713  parsePt_LUTS(scaleMap, "Mass", "HTM", precisions["PRECISION-EG-HTM-MassPt"]);
714 
715  // Now the Pt LUTs for TBPT calculation (??? CCLA following what was done for MASS pt LUTs for now ??)
716  // ---------------
717  parsePt_LUTS(scaleMap, "TwoBody", "EG", precisions["PRECISION-EG-MU-TwoBodyPt"]);
718  parsePt_LUTS(scaleMap, "TwoBody", "MU", precisions["PRECISION-EG-MU-TwoBodyPt"]);
719  parsePt_LUTS(scaleMap, "TwoBody", "JET", precisions["PRECISION-EG-JET-TwoBodyPt"]);
720  parsePt_LUTS(scaleMap, "TwoBody", "TAU", precisions["PRECISION-EG-TAU-TwoBodyPt"]);
721  parsePt_LUTS(scaleMap, "TwoBody", "ETM", precisions["PRECISION-EG-ETM-TwoBodyPt"]);
722  parsePt_LUTS(scaleMap, "TwoBody", "ETMHF", precisions["PRECISION-EG-ETMHF-TwoBodyPt"]);
723  parsePt_LUTS(scaleMap, "TwoBody", "HTM", precisions["PRECISION-EG-HTM-TwoBodyPt"]);
724 
725  // Now the Delta Eta/Cosh LUTs (must be done in groups)
726  // ----------------------------------------------------
727  parseDeltaEta_Cosh_LUTS(
728  scaleMap, "EG", "EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
729  parseDeltaEta_Cosh_LUTS(
730  scaleMap, "EG", "JET", precisions["PRECISION-EG-JET-Delta"], precisions["PRECISION-EG-JET-Math"]);
731  parseDeltaEta_Cosh_LUTS(
732  scaleMap, "EG", "TAU", precisions["PRECISION-EG-TAU-Delta"], precisions["PRECISION-EG-TAU-Math"]);
733  parseDeltaEta_Cosh_LUTS(
734  scaleMap, "EG", "MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
735 
736  parseDeltaEta_Cosh_LUTS(
737  scaleMap, "JET", "JET", precisions["PRECISION-JET-JET-Delta"], precisions["PRECISION-JET-JET-Math"]);
738  parseDeltaEta_Cosh_LUTS(
739  scaleMap, "JET", "TAU", precisions["PRECISION-JET-TAU-Delta"], precisions["PRECISION-JET-TAU-Math"]);
740  parseDeltaEta_Cosh_LUTS(
741  scaleMap, "JET", "MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
742 
743  parseDeltaEta_Cosh_LUTS(
744  scaleMap, "TAU", "TAU", precisions["PRECISION-TAU-TAU-Delta"], precisions["PRECISION-TAU-TAU-Math"]);
745  parseDeltaEta_Cosh_LUTS(
746  scaleMap, "TAU", "MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
747 
748  parseDeltaEta_Cosh_LUTS(
749  scaleMap, "MU", "MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
750 
751  // Now the Delta Phi/Cos LUTs (must be done in groups)
752  // ----------------------------------------------------
753  parseDeltaPhi_Cos_LUTS(
754  scaleMap, "EG", "EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
755  parseDeltaPhi_Cos_LUTS(
756  scaleMap, "EG", "JET", precisions["PRECISION-EG-JET-Delta"], precisions["PRECISION-EG-JET-Math"]);
757  parseDeltaPhi_Cos_LUTS(
758  scaleMap, "EG", "TAU", precisions["PRECISION-EG-TAU-Delta"], precisions["PRECISION-EG-TAU-Math"]);
759  parseDeltaPhi_Cos_LUTS(
760  scaleMap, "EG", "ETM", precisions["PRECISION-EG-ETM-Delta"], precisions["PRECISION-EG-ETM-Math"]);
761  parseDeltaPhi_Cos_LUTS(
762  scaleMap, "EG", "ETMHF", precisions["PRECISION-EG-ETMHF-Delta"], precisions["PRECISION-EG-ETMHF-Math"]);
763  parseDeltaPhi_Cos_LUTS(
764  scaleMap, "EG", "HTM", precisions["PRECISION-EG-HTM-Delta"], precisions["PRECISION-EG-HTM-Math"]);
765  parseDeltaPhi_Cos_LUTS(
766  scaleMap, "EG", "MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
767 
768  parseDeltaPhi_Cos_LUTS(
769  scaleMap, "JET", "JET", precisions["PRECISION-JET-JET-Delta"], precisions["PRECISION-JET-JET-Math"]);
770  parseDeltaPhi_Cos_LUTS(
771  scaleMap, "JET", "TAU", precisions["PRECISION-JET-TAU-Delta"], precisions["PRECISION-JET-TAU-Math"]);
772  parseDeltaPhi_Cos_LUTS(
773  scaleMap, "JET", "ETM", precisions["PRECISION-JET-ETM-Delta"], precisions["PRECISION-JET-ETM-Math"]);
774  parseDeltaPhi_Cos_LUTS(
775  scaleMap, "JET", "ETMHF", precisions["PRECISION-JET-ETMHF-Delta"], precisions["PRECISION-JET-ETMHF-Math"]);
776  parseDeltaPhi_Cos_LUTS(
777  scaleMap, "JET", "HTM", precisions["PRECISION-JET-HTM-Delta"], precisions["PRECISION-JET-HTM-Math"]);
778  parseDeltaPhi_Cos_LUTS(
779  scaleMap, "JET", "MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
780 
781  parseDeltaPhi_Cos_LUTS(
782  scaleMap, "TAU", "TAU", precisions["PRECISION-TAU-TAU-Delta"], precisions["PRECISION-TAU-TAU-Math"]);
783  parseDeltaPhi_Cos_LUTS(
784  scaleMap, "TAU", "ETM", precisions["PRECISION-TAU-ETM-Delta"], precisions["PRECISION-TAU-ETM-Math"]);
785  parseDeltaPhi_Cos_LUTS(
786  scaleMap, "TAU", "ETMHF", precisions["PRECISION-TAU-ETMHF-Delta"], precisions["PRECISION-TAU-ETMHF-Math"]);
787  parseDeltaPhi_Cos_LUTS(
788  scaleMap, "TAU", "HTM", precisions["PRECISION-TAU-HTM-Delta"], precisions["PRECISION-TAU-HTM-Math"]);
789  parseDeltaPhi_Cos_LUTS(
790  scaleMap, "TAU", "MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
791 
792  parseDeltaPhi_Cos_LUTS(
793  scaleMap, "MU", "ETM", precisions["PRECISION-MU-ETM-Delta"], precisions["PRECISION-MU-ETM-Math"]);
794  parseDeltaPhi_Cos_LUTS(
795  scaleMap, "MU", "ETMHF", precisions["PRECISION-MU-ETMHF-Delta"], precisions["PRECISION-MU-ETMHF-Math"]);
796  parseDeltaPhi_Cos_LUTS(
797  scaleMap, "MU", "HTM", precisions["PRECISION-MU-HTM-Delta"], precisions["PRECISION-MU-HTM-Math"]);
798  parseDeltaPhi_Cos_LUTS(
799  scaleMap, "MU", "MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
800 
801  parsePhi_Trig_LUTS(scaleMap, "EG", l1t::COS, precisions["PRECISION-EG-EG-Math"]);
802  parsePhi_Trig_LUTS(scaleMap, "JET", l1t::COS, precisions["PRECISION-JET-JET-Math"]);
803  parsePhi_Trig_LUTS(scaleMap, "TAU", l1t::COS, precisions["PRECISION-TAU-TAU-Math"]);
804  parsePhi_Trig_LUTS(scaleMap, "MU", l1t::COS, precisions["PRECISION-MU-MU-Math"]);
805 
806  parsePhi_Trig_LUTS(scaleMap, "EG", l1t::SIN, precisions["PRECISION-EG-EG-Math"]);
807  parsePhi_Trig_LUTS(scaleMap, "JET", l1t::SIN, precisions["PRECISION-JET-JET-Math"]);
808  parsePhi_Trig_LUTS(scaleMap, "TAU", l1t::SIN, precisions["PRECISION-TAU-TAU-Math"]);
809  parsePhi_Trig_LUTS(scaleMap, "MU", l1t::SIN, precisions["PRECISION-MU-MU-Math"]);
810 
811  //CCLA
812  //m_gtScales.dumpAllLUTs(std::cout);
813  //m_gtScales.print(std::cout);
814  }
815 
816  return true;
817 }
818 
819 void l1t::TriggerMenuParser::parseCalMuEta_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
820  std::string obj1,
821  std::string obj2) {
822  using namespace tmeventsetup;
823 
824  // First Delta Eta for this set
825  std::string scLabel1 = obj1;
826  scLabel1 += "-ETA";
827  std::string scLabel2 = obj2;
828  scLabel2 += "-ETA";
829 
830  //This LUT does not exist in L1 Menu file, don't fill it
831  if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
832  return;
833 
834  const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
835  const tmeventsetup::esScale* scale2 = &scaleMap.find(scLabel2)->second;
836 
837  std::vector<long long> lut_cal_2_mu_eta;
838  getCaloMuonEtaConversionLut(lut_cal_2_mu_eta, scale1, scale2);
839 
840  std::string lutName = obj1;
841  lutName += "-";
842  lutName += obj2;
843  m_gtScales.setLUT_CalMuEta(lutName, lut_cal_2_mu_eta);
844 }
845 
846 void l1t::TriggerMenuParser::parseCalMuPhi_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
847  std::string obj1,
848  std::string obj2) {
849  using namespace tmeventsetup;
850 
851  // First Delta Eta for this set
852  std::string scLabel1 = obj1;
853  scLabel1 += "-PHI";
854  std::string scLabel2 = obj2;
855  scLabel2 += "-PHI";
856 
857  //This LUT does not exist in L1 Menu file, don't fill it
858  if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
859  return;
860 
861  const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
862  const tmeventsetup::esScale* scale2 = &scaleMap.find(scLabel2)->second;
863 
864  std::vector<long long> lut_cal_2_mu_phi;
865  getCaloMuonPhiConversionLut(lut_cal_2_mu_phi, scale1, scale2);
866 
867  std::string lutName = obj1;
868  lutName += "-";
869  lutName += obj2;
870  m_gtScales.setLUT_CalMuPhi(lutName, lut_cal_2_mu_phi);
871 }
872 
873 void l1t::TriggerMenuParser::parsePt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
874  std::string lutpfx,
875  std::string obj1,
876  unsigned int prec) {
877  using namespace tmeventsetup;
878 
879  // First Delta Eta for this set
880  std::string scLabel1 = obj1;
881  scLabel1 += "-ET";
882 
883  //This LUT does not exist in L1 Menu file, don't fill it
884  if (scaleMap.find(scLabel1) == scaleMap.end())
885  return;
886 
887  const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
888 
889  std::vector<long long> lut_pt;
890  getLut(lut_pt, scale1, prec);
891 
892  m_gtScales.setLUT_Pt(lutpfx + "_" + scLabel1, lut_pt, prec);
893 }
894 
895 // Added for displaced muons
896 void l1t::TriggerMenuParser::parseUpt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
897  std::string lutpfx,
898  std::string obj1,
899  unsigned int prec) {
900  using namespace tmeventsetup;
901 
902  // First Delta Eta for this set
903  std::string scLabel1 = obj1;
904  scLabel1 += "-UPT";
905 
906  //This LUT does not exist in L1 Menu file, don't fill it
907  if (scaleMap.find(scLabel1) == scaleMap.end())
908  return;
909 
910  const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
911 
912  std::vector<long long> lut_pt;
913  getLut(lut_pt, scale1, prec);
914 
915  m_gtScales.setLUT_Upt(lutpfx + "_" + scLabel1, lut_pt, prec);
916 }
917 
918 void l1t::TriggerMenuParser::parseDeltaEta_Cosh_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
919  std::string obj1,
920  std::string obj2,
921  unsigned int prec1,
922  unsigned int prec2) {
923  using namespace tmeventsetup;
924 
925  // First Delta Eta for this set
926  std::string scLabel1 = obj1;
927  scLabel1 += "-ETA";
928  std::string scLabel2 = obj2;
929  scLabel2 += "-ETA";
930 
931  //This LUT does not exist in L1 Menu file, don't fill it
932  if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
933  return;
934 
935  const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
936  const tmeventsetup::esScale* scale2 = &scaleMap.find(scLabel2)->second;
937  std::vector<double> val_delta_eta;
938  std::vector<long long> lut_delta_eta;
939  size_t n = getDeltaVector(val_delta_eta, scale1, scale2);
940  setLut(lut_delta_eta, val_delta_eta, prec1);
941  std::string lutName = obj1;
942  lutName += "-";
943  lutName += obj2;
944  m_gtScales.setLUT_DeltaEta(lutName, lut_delta_eta, prec1);
945 
946  // Second Get the Cosh for this delta Eta Set
947  std::vector<long long> lut_cosh;
948  applyCosh(val_delta_eta, n);
949  setLut(lut_cosh, val_delta_eta, prec2);
950  m_gtScales.setLUT_Cosh(lutName, lut_cosh, prec2);
951 }
952 
953 void l1t::TriggerMenuParser::parseDeltaPhi_Cos_LUTS(const std::map<std::string, tmeventsetup::esScale>& scaleMap,
954  const std::string& obj1,
955  const std::string& obj2,
956  unsigned int prec1,
957  unsigned int prec2) {
958  using namespace tmeventsetup;
959 
960  // First Delta phi for this set
961  std::string scLabel1 = obj1;
962  scLabel1 += "-PHI";
963  std::string scLabel2 = obj2;
964  scLabel2 += "-PHI";
965 
966  //This LUT does not exist in L1 Menu file, don't fill it
967  if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
968  return;
969 
970  const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
971  const tmeventsetup::esScale* scale2 = &scaleMap.find(scLabel2)->second;
972  std::vector<double> val_delta_phi;
973  std::vector<long long> lut_delta_phi;
974  size_t n = getDeltaVector(val_delta_phi, scale1, scale2);
975  setLut(lut_delta_phi, val_delta_phi, prec1);
976  std::string lutName = obj1;
977  lutName += "-";
978  lutName += obj2;
979  m_gtScales.setLUT_DeltaPhi(lutName, lut_delta_phi, prec1);
980 
981  // Second Get the Cosh for this delta phi Set
982  std::vector<long long> lut_cos;
983  applyCos(val_delta_phi, n);
984  setLut(lut_cos, val_delta_phi, prec2);
985  m_gtScales.setLUT_Cos(lutName, lut_cos, prec2);
986 }
987 
988 void l1t::TriggerMenuParser::parsePhi_Trig_LUTS(const std::map<std::string, tmeventsetup::esScale>& scaleMap,
989  const std::string& obj,
991  unsigned int prec) {
992  using namespace tmeventsetup;
993 
994  std::string scLabel = obj;
995  scLabel += "-PHI";
996 
997  //This LUT does not exist in L1 Menu file, don't fill it
998  if (scaleMap.find(scLabel) == scaleMap.end())
999  return;
1000  if (func != l1t::SIN and func != l1t::COS)
1001  return;
1002 
1003  const tmeventsetup::esScale* scale = &scaleMap.find(scLabel)->second;
1004 
1005  const double step = scale->getStep();
1006  const double range = scale->getMaximum() - scale->getMinimum();
1007  const size_t n = std::ceil(range / step);
1008  const size_t bitwidth = std::ceil(std::log10(n) / std::log10(2));
1009 
1010  std::vector<double> array(std::pow(2, bitwidth), 0);
1011 
1012  for (size_t ii = 0; ii < n; ii++) {
1013  array.at(ii) = step * ii;
1014  }
1015 
1016  const std::string& lutName = obj;
1017  std::vector<long long> lut;
1018  if (func == l1t::SIN) {
1019  applySin(array, n);
1020  setLut(lut, array, prec);
1021  m_gtScales.setLUT_Sin(lutName, lut, prec);
1022  } else if (func == l1t::COS) {
1023  applyCos(array, n);
1024  setLut(lut, array, prec);
1025  m_gtScales.setLUT_Cos(lutName, lut, prec);
1026  }
1027 }
1028 
1040 bool l1t::TriggerMenuParser::parseMuon(L1TUtmCondition condMu, unsigned int chipNr, const bool corrFlag) {
1041  using namespace tmeventsetup;
1042  // get condition, particle name (must be muon) and type name
1043  std::string condition = "muon";
1044  std::string particle = "muon"; //l1t2string( condMu.objectType() );
1045  std::string type = l1t2string(condMu.getType());
1046  std::string name = l1t2string(condMu.getName());
1047  int nrObj = -1;
1048 
1050 
1051  if (condMu.getType() == esConditionType::SingleMuon) {
1052  type = "1_s";
1053  cType = l1t::Type1s;
1054  nrObj = 1;
1055  } else if (condMu.getType() == esConditionType::DoubleMuon) {
1056  type = "2_s";
1057  cType = l1t::Type2s;
1058  nrObj = 2;
1059  } else if (condMu.getType() == esConditionType::TripleMuon) {
1060  type = "3";
1061  cType = l1t::Type3s;
1062  nrObj = 3;
1063  } else if (condMu.getType() == esConditionType::QuadMuon) {
1064  type = "4";
1065  cType = l1t::Type4s;
1066  nrObj = 4;
1067  } else {
1068  edm::LogError("TriggerMenuParser") << "Wrong type for muon-condition (" << type << ")" << std::endl;
1069  return false;
1070  }
1071 
1072  if (nrObj < 0) {
1073  edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type << ")"
1074  << "\nCan not determine number of trigger objects. " << std::endl;
1075  return false;
1076  }
1077 
1078  LogDebug("TriggerMenuParser") << "\n ****************************************** "
1079  << "\n parseMuon "
1080  << "\n condition = " << condition << "\n particle = " << particle
1081  << "\n type = " << type << "\n name = " << name << std::endl;
1082 
1083  // // get values
1084 
1085  // temporary storage of the parameters
1086  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1087 
1088  // Do we need this?
1089  MuonTemplate::CorrelationParameter corrParameter;
1090 
1091  // need at least two values for deltaPhi
1092  std::vector<uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1093  tmpValues.reserve(nrObj);
1094 
1095  if (int(condMu.getObjects().size()) != nrObj) {
1096  edm::LogError("TriggerMenuParser") << " condMu objects: nrObj = " << nrObj
1097  << "condMu.getObjects().size() = " << condMu.getObjects().size() << std::endl;
1098  return false;
1099  }
1100 
1101  // Look for cuts on the objects in the condition
1102  unsigned int chargeCorrelation = 1;
1103  const std::vector<L1TUtmCut>& cuts = condMu.getCuts();
1104  for (size_t jj = 0; jj < cuts.size(); jj++) {
1105  const L1TUtmCut& cut = cuts.at(jj);
1106  if (cut.getCutType() == esCutType::ChargeCorrelation) {
1107  if (cut.getData() == "ls")
1108  chargeCorrelation = 2;
1109  else if (cut.getData() == "os")
1110  chargeCorrelation = 4;
1111  else
1112  chargeCorrelation = 1; //ignore correlation
1113  }
1114  }
1115 
1116  //set charge correlation parameter
1117  corrParameter.chargeCorrelation = chargeCorrelation; //tmpValues[0];
1118 
1119  int cnt = 0;
1120 
1121  // BLW TO DO: These needs to the added to the object rather than the whole condition.
1122  int relativeBx = 0;
1123  bool gEq = false;
1124 
1125  // Loop over objects and extract the cuts on the objects
1126  const std::vector<L1TUtmObject>& objects = condMu.getObjects();
1127  for (size_t jj = 0; jj < objects.size(); jj++) {
1128  const L1TUtmObject& object = objects.at(jj);
1129  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1130 
1131  // BLW TO DO: This needs to be added to the Object Parameters
1132  relativeBx = object.getBxOffset();
1133 
1134  // Loop over the cuts for this object
1135  int upperUnconstrainedPtInd = -1;
1136  int lowerUnconstrainedPtInd = 0;
1137  int upperImpactParameterInd = -1;
1138  int lowerImpactParameterInd = 0;
1139  int upperThresholdInd = -1;
1140  int lowerThresholdInd = 0;
1141  int upperIndexInd = -1;
1142  int lowerIndexInd = 0;
1143  int cntPhi = 0;
1144  unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
1145  int isolationLUT = 0xF; //default is to ignore unless specified.
1146  int impactParameterLUT = 0xF; //default is to ignore unless specified
1147  int charge = -1; //default value is to ignore unless specified
1148  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
1149 
1150  std::vector<MuonTemplate::Window> etaWindows;
1151  std::vector<MuonTemplate::Window> tfMuonIndexWindows;
1152 
1153  const std::vector<L1TUtmCut>& cuts = object.getCuts();
1154  for (size_t kk = 0; kk < cuts.size(); kk++) {
1155  const L1TUtmCut& cut = cuts.at(kk);
1156 
1157  switch (cut.getCutType()) {
1158  case esCutType::UnconstrainedPt:
1159  lowerUnconstrainedPtInd = cut.getMinimum().index;
1160  upperUnconstrainedPtInd = cut.getMaximum().index;
1161  break;
1162 
1163  case esCutType::ImpactParameter:
1164  lowerImpactParameterInd = cut.getMinimum().index;
1165  upperImpactParameterInd = cut.getMaximum().index;
1166  impactParameterLUT = l1tstr2int(cut.getData());
1167  break;
1168 
1169  case esCutType::Threshold:
1170  lowerThresholdInd = cut.getMinimum().index;
1171  upperThresholdInd = cut.getMaximum().index;
1172  break;
1173 
1174  case esCutType::Slice:
1175  lowerIndexInd = int(cut.getMinimum().value);
1176  upperIndexInd = int(cut.getMaximum().value);
1177  break;
1178 
1179  case esCutType::Eta: {
1180  if (etaWindows.size() < 5) {
1181  etaWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
1182  } else {
1183  edm::LogError("TriggerMenuParser")
1184  << "Too Many Eta Cuts for muon-condition (" << particle << ")" << std::endl;
1185  return false;
1186  }
1187  } break;
1188 
1189  case esCutType::Phi: {
1190  if (cntPhi == 0) {
1191  phiWindow1Lower = cut.getMinimum().index;
1192  phiWindow1Upper = cut.getMaximum().index;
1193  } else if (cntPhi == 1) {
1194  phiWindow2Lower = cut.getMinimum().index;
1195  phiWindow2Upper = cut.getMaximum().index;
1196  } else {
1197  edm::LogError("TriggerMenuParser")
1198  << "Too Many Phi Cuts for muon-condition (" << particle << ")" << std::endl;
1199  return false;
1200  }
1201  cntPhi++;
1202 
1203  } break;
1204 
1205  case esCutType::Charge:
1206  if (cut.getData() == "positive")
1207  charge = 0;
1208  else if (cut.getData() == "negative")
1209  charge = 1;
1210  else
1211  charge = -1;
1212  break;
1213  case esCutType::Quality:
1214 
1215  qualityLUT = l1tstr2int(cut.getData());
1216 
1217  break;
1218  case esCutType::Isolation: {
1219  isolationLUT = l1tstr2int(cut.getData());
1220 
1221  } break;
1222 
1223  case esCutType::Index: {
1224  tfMuonIndexWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
1225  } break;
1226 
1227  default:
1228  break;
1229  } //end switch
1230 
1231  } //end loop over cuts
1232 
1233  // Set the parameter cuts
1234  objParameter[cnt].unconstrainedPtHigh = upperUnconstrainedPtInd;
1235  objParameter[cnt].unconstrainedPtLow = lowerUnconstrainedPtInd;
1236  objParameter[cnt].impactParameterHigh = upperImpactParameterInd;
1237  objParameter[cnt].impactParameterLow = lowerImpactParameterInd;
1238  objParameter[cnt].impactParameterLUT = impactParameterLUT;
1239 
1240  objParameter[cnt].ptHighThreshold = upperThresholdInd;
1241  objParameter[cnt].ptLowThreshold = lowerThresholdInd;
1242 
1243  objParameter[cnt].indexHigh = upperIndexInd;
1244  objParameter[cnt].indexLow = lowerIndexInd;
1245 
1246  objParameter[cnt].etaWindows = etaWindows;
1247 
1248  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1249  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1250  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1251  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1252 
1253  // BLW TO DO: Do we need these anymore? Drop them?
1254  objParameter[cnt].enableMip = false; //tmpMip[i];
1255  objParameter[cnt].enableIso = false; //tmpEnableIso[i];
1256  objParameter[cnt].requestIso = false; //tmpRequestIso[i];
1257 
1258  objParameter[cnt].charge = charge;
1259  objParameter[cnt].qualityLUT = qualityLUT;
1260  objParameter[cnt].isolationLUT = isolationLUT;
1261 
1262  objParameter[cnt].tfMuonIndexWindows = tfMuonIndexWindows;
1263 
1264  cnt++;
1265  } //end loop over objects
1266 
1267  // object types - all muons
1268  std::vector<GlobalObject> objType(nrObj, gtMu);
1269 
1270  // now create a new CondMuonition
1271  MuonTemplate muonCond(name);
1272 
1273  muonCond.setCondType(cType);
1274  muonCond.setObjectType(objType);
1275  muonCond.setCondGEq(gEq);
1276  muonCond.setCondChipNr(chipNr);
1277  muonCond.setCondRelativeBx(relativeBx);
1278 
1279  muonCond.setConditionParameter(objParameter, corrParameter);
1280 
1281  if (edm::isDebugEnabled()) {
1282  std::ostringstream myCoutStream;
1283  muonCond.print(myCoutStream);
1284  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1285  }
1286 
1287  // insert condition into the map and into muon template vector
1288  if (!insertConditionIntoMap(muonCond, chipNr)) {
1289  edm::LogError("TriggerMenuParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1290  return false;
1291  } else {
1292  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1293  if (corrFlag) {
1294  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1295  } else {
1296  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the vecMuonTemplate vector" << std::endl;
1297  (m_vecMuonTemplate[chipNr]).push_back(muonCond);
1298  }
1299  }
1300 
1301  //
1302  return true;
1303 }
1304 
1305 bool l1t::TriggerMenuParser::parseMuonCorr(const L1TUtmObject* corrMu, unsigned int chipNr) {
1306  // XERCES_CPP_NAMESPACE_USE
1307  using namespace tmeventsetup;
1308 
1309  // get condition, particle name (must be muon) and type name
1310  std::string condition = "muon";
1311  std::string particle = "muon"; //l1t2string( condMu.objectType() );
1312  std::string type = l1t2string(corrMu->getType());
1313  std::string name = l1t2string(corrMu->getName());
1314  int nrObj = 1;
1315  type = "1_s";
1316  GtConditionType cType = l1t::Type1s;
1317 
1318  if (nrObj < 0) {
1319  edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type << ")"
1320  << "\nCan not determine number of trigger objects. " << std::endl;
1321  return false;
1322  }
1323 
1324  LogDebug("TriggerMenuParser") << "\n ****************************************** "
1325  << "\n parseMuon "
1326  << "\n condition = " << condition << "\n particle = " << particle
1327  << "\n type = " << type << "\n name = " << name << std::endl;
1328 
1329  // // get values
1330 
1331  // temporary storage of the parameters
1332  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1333 
1334  // Do we need this?
1335  MuonTemplate::CorrelationParameter corrParameter;
1336 
1337  // need at least two values for deltaPhi
1338  std::vector<uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1339  tmpValues.reserve(nrObj);
1340 
1341  // BLW TO DO: How do we deal with these in the new format
1342  // std::string str_chargeCorrelation = l1t2string( condMu.requestedChargeCorr() );
1343  std::string str_chargeCorrelation = "ig";
1344  unsigned int chargeCorrelation = 0;
1345  if (str_chargeCorrelation == "ig")
1346  chargeCorrelation = 1;
1347  else if (str_chargeCorrelation == "ls")
1348  chargeCorrelation = 2;
1349  else if (str_chargeCorrelation == "os")
1350  chargeCorrelation = 4;
1351 
1352  //getXMLHexTextValue("1", dst);
1353  corrParameter.chargeCorrelation = chargeCorrelation; //tmpValues[0];
1354 
1355  // BLW TO DO: These needs to the added to the object rather than the whole condition.
1356  int relativeBx = 0;
1357  bool gEq = false;
1358 
1359  //const esObject* object = condMu;
1360  gEq = (corrMu->getComparisonOperator() == esComparisonOperator::GE);
1361 
1362  // BLW TO DO: This needs to be added to the Object Parameters
1363  relativeBx = corrMu->getBxOffset();
1364 
1365  // Loop over the cuts for this object
1366  int upperUnconstrainedPtInd = -1; // Added for displaced muons
1367  int lowerUnconstrainedPtInd = 0; // Added for displaced muons
1368  int upperImpactParameterInd = -1; // Added for displaced muons
1369  int lowerImpactParameterInd = 0; // Added for displaced muons
1370  int impactParameterLUT = 0xF; // Added for displaced muons, default is to ignore unless specified
1371  int upperThresholdInd = -1;
1372  int lowerThresholdInd = 0;
1373  int upperIndexInd = -1;
1374  int lowerIndexInd = 0;
1375  int cntPhi = 0;
1376  unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
1377  int isolationLUT = 0xF; //default is to ignore unless specified.
1378  int charge = -1; //defaut is to ignore unless specified
1379  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
1380 
1381  std::vector<MuonTemplate::Window> etaWindows;
1382  std::vector<MuonTemplate::Window> tfMuonIndexWindows;
1383 
1384  const std::vector<L1TUtmCut>& cuts = corrMu->getCuts();
1385  for (size_t kk = 0; kk < cuts.size(); kk++) {
1386  const L1TUtmCut& cut = cuts.at(kk);
1387 
1388  switch (cut.getCutType()) {
1389  case esCutType::UnconstrainedPt: // Added for displaced muons
1390  lowerUnconstrainedPtInd = cut.getMinimum().index;
1391  upperUnconstrainedPtInd = cut.getMaximum().index;
1392  break;
1393 
1394  case esCutType::ImpactParameter: // Added for displaced muons
1395  lowerImpactParameterInd = cut.getMinimum().index;
1396  upperImpactParameterInd = cut.getMaximum().index;
1397  impactParameterLUT = l1tstr2int(cut.getData());
1398  break;
1399 
1400  case esCutType::Threshold:
1401  lowerThresholdInd = cut.getMinimum().index;
1402  upperThresholdInd = cut.getMaximum().index;
1403  break;
1404 
1405  case esCutType::Slice:
1406  lowerIndexInd = int(cut.getMinimum().value);
1407  upperIndexInd = int(cut.getMaximum().value);
1408  break;
1409 
1410  case esCutType::Eta: {
1411  if (etaWindows.size() < 5) {
1412  etaWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
1413  } else {
1414  edm::LogError("TriggerMenuParser")
1415  << "Too Many Eta Cuts for muon-condition (" << particle << ")" << std::endl;
1416  return false;
1417  }
1418  } break;
1419 
1420  case esCutType::Phi: {
1421  if (cntPhi == 0) {
1422  phiWindow1Lower = cut.getMinimum().index;
1423  phiWindow1Upper = cut.getMaximum().index;
1424  } else if (cntPhi == 1) {
1425  phiWindow2Lower = cut.getMinimum().index;
1426  phiWindow2Upper = cut.getMaximum().index;
1427  } else {
1428  edm::LogError("TriggerMenuParser")
1429  << "Too Many Phi Cuts for muon-condition (" << particle << ")" << std::endl;
1430  return false;
1431  }
1432  cntPhi++;
1433 
1434  } break;
1435 
1436  case esCutType::Charge:
1437  if (cut.getData() == "positive")
1438  charge = 0;
1439  else if (cut.getData() == "negative")
1440  charge = 1;
1441  else
1442  charge = -1;
1443  break;
1444  case esCutType::Quality:
1445 
1446  qualityLUT = l1tstr2int(cut.getData());
1447 
1448  break;
1449  case esCutType::Isolation: {
1450  isolationLUT = l1tstr2int(cut.getData());
1451 
1452  } break;
1453 
1454  case esCutType::Index: {
1455  tfMuonIndexWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
1456  } break;
1457 
1458  default:
1459  break;
1460  } //end switch
1461 
1462  } //end loop over cuts
1463 
1464  // Set the parameter cuts
1465  objParameter[0].unconstrainedPtHigh = upperUnconstrainedPtInd; // Added for displacd muons
1466  objParameter[0].unconstrainedPtLow = lowerUnconstrainedPtInd; // Added for displacd muons
1467  objParameter[0].impactParameterHigh = upperImpactParameterInd; // Added for displacd muons
1468  objParameter[0].impactParameterLow = lowerImpactParameterInd; // Added for displacd muons
1469  objParameter[0].impactParameterLUT = impactParameterLUT; // Added for displacd muons
1470 
1471  objParameter[0].ptHighThreshold = upperThresholdInd;
1472  objParameter[0].ptLowThreshold = lowerThresholdInd;
1473 
1474  objParameter[0].indexHigh = upperIndexInd;
1475  objParameter[0].indexLow = lowerIndexInd;
1476 
1477  objParameter[0].etaWindows = etaWindows;
1478 
1479  objParameter[0].phiWindow1Lower = phiWindow1Lower;
1480  objParameter[0].phiWindow1Upper = phiWindow1Upper;
1481  objParameter[0].phiWindow2Lower = phiWindow2Lower;
1482  objParameter[0].phiWindow2Upper = phiWindow2Upper;
1483 
1484  // BLW TO DO: Do we need these anymore? Drop them?
1485  objParameter[0].enableMip = false; //tmpMip[i];
1486  objParameter[0].enableIso = false; //tmpEnableIso[i];
1487  objParameter[0].requestIso = false; //tmpRequestIso[i];
1488 
1489  objParameter[0].charge = charge;
1490  objParameter[0].qualityLUT = qualityLUT;
1491  objParameter[0].isolationLUT = isolationLUT;
1492 
1493  objParameter[0].tfMuonIndexWindows = tfMuonIndexWindows;
1494 
1495  // object types - all muons
1496  std::vector<GlobalObject> objType(nrObj, gtMu);
1497 
1498  // now create a new CondMuonition
1499  MuonTemplate muonCond(name);
1500 
1501  muonCond.setCondType(cType);
1502  muonCond.setObjectType(objType);
1503  muonCond.setCondGEq(gEq);
1504  muonCond.setCondChipNr(chipNr);
1505  muonCond.setCondRelativeBx(relativeBx);
1506  muonCond.setConditionParameter(objParameter, corrParameter);
1507 
1508  if (edm::isDebugEnabled()) {
1509  std::ostringstream myCoutStream;
1510  muonCond.print(myCoutStream);
1511  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1512  }
1513 
1514  /*
1515  // insert condition into the map and into muon template vector
1516  if ( !insertConditionIntoMap(muonCond, chipNr)) {
1517  edm::LogError("TriggerMenuParser")
1518  << " Error: duplicate condition (" << name << ")"
1519  << std::endl;
1520  return false;
1521  }
1522  else {
1523  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1524  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1525  }
1526 */
1527  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1528 
1529  //
1530  return true;
1531 }
1532 
1544 bool l1t::TriggerMenuParser::parseMuonShower(L1TUtmCondition condMu, unsigned int chipNr, const bool corrFlag) {
1545  using namespace tmeventsetup;
1546 
1547  // get condition, particle name (must be muon) and type name
1548  std::string condition = "muonShower";
1549  std::string particle = "muonShower"; //l1t2string( condMu.objectType() );
1550  std::string type = l1t2string(condMu.getType());
1551  std::string name = l1t2string(condMu.getName());
1552  // the number of muon shower objects is always 1
1553  int nrObj = 1;
1554 
1555  // condition type is always 1 particle, thus Type1s
1556  GtConditionType cType = l1t::Type1s;
1557 
1558  // temporary storage of the parameters
1559  std::vector<MuonShowerTemplate::ObjectParameter> objParameter(nrObj);
1560 
1561  if (int(condMu.getObjects().size()) != nrObj) {
1562  edm::LogError("TriggerMenuParser") << " condMu objects: nrObj = " << nrObj
1563  << "condMu.getObjects().size() = " << condMu.getObjects().size() << std::endl;
1564  return false;
1565  }
1566 
1567  // Get the muon shower object
1568  L1TUtmObject object = condMu.getObjects().at(0);
1569  int relativeBx = object.getBxOffset();
1570 
1571  if (condMu.getType() == esConditionType::MuonShower0) {
1572  objParameter[0].MuonShower0 = true;
1573  } else if (condMu.getType() == esConditionType::MuonShower1) {
1574  objParameter[0].MuonShower1 = true;
1575  } else if (condMu.getType() == esConditionType::MuonShower2) {
1576  objParameter[0].MuonShower2 = true;
1577  } else if (condMu.getType() == esConditionType::MuonShowerOutOfTime0) {
1578  objParameter[0].MuonShowerOutOfTime0 = true;
1579  } else if (condMu.getType() == esConditionType::MuonShowerOutOfTime1) {
1580  objParameter[0].MuonShowerOutOfTime1 = true;
1581  }
1582 
1583  // object types - all muons
1584  std::vector<GlobalObject> objType(nrObj, gtMuShower);
1585 
1586  // now create a new CondMuonition
1587  MuonShowerTemplate muonShowerCond(name);
1588  muonShowerCond.setCondType(cType);
1589  muonShowerCond.setObjectType(objType);
1590  muonShowerCond.setCondChipNr(chipNr);
1591  muonShowerCond.setCondRelativeBx(relativeBx);
1592 
1593  muonShowerCond.setConditionParameter(objParameter);
1594 
1595  if (edm::isDebugEnabled()) {
1596  std::ostringstream myCoutStream;
1597  muonShowerCond.print(myCoutStream);
1598  }
1599 
1600  // insert condition into the map and into muon template vector
1601  if (!insertConditionIntoMap(muonShowerCond, chipNr)) {
1602  edm::LogError("TriggerMenuParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1603  return false;
1604  } else {
1605  (m_vecMuonShowerTemplate[chipNr]).push_back(muonShowerCond);
1606  }
1607 
1608  return true;
1609 }
1610 
1622 bool l1t::TriggerMenuParser::parseCalo(L1TUtmCondition condCalo, unsigned int chipNr, const bool corrFlag) {
1623  // XERCES_CPP_NAMESPACE_USE
1624  using namespace tmeventsetup;
1625 
1626  // get condition, particle name and type name
1627 
1628  std::string condition = "calo";
1629  std::string particle = "test-fix";
1630  std::string type = l1t2string(condCalo.getType());
1631  std::string name = l1t2string(condCalo.getName());
1632 
1633  LogDebug("TriggerMenuParser") << "\n ****************************************** "
1634  << "\n (in parseCalo) "
1635  << "\n condition = " << condition << "\n particle = " << particle
1636  << "\n type = " << type << "\n name = " << name << std::endl;
1637 
1639 
1640  // determine object type type
1641  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
1642  GlobalObject caloObjType;
1643  int nrObj = -1;
1644 
1645  if (condCalo.getType() == esConditionType::SingleEgamma) {
1646  caloObjType = gtEG;
1647  type = "1_s";
1648  cType = l1t::Type1s;
1649  nrObj = 1;
1650  } else if (condCalo.getType() == esConditionType::DoubleEgamma) {
1651  caloObjType = gtEG;
1652  type = "2_s";
1653  cType = l1t::Type2s;
1654  nrObj = 2;
1655  } else if (condCalo.getType() == esConditionType::TripleEgamma) {
1656  caloObjType = gtEG;
1657  cType = l1t::Type3s;
1658  type = "3";
1659  nrObj = 3;
1660  } else if (condCalo.getType() == esConditionType::QuadEgamma) {
1661  caloObjType = gtEG;
1662  cType = l1t::Type4s;
1663  type = "4";
1664  nrObj = 4;
1665  } else if (condCalo.getType() == esConditionType::SingleJet) {
1666  caloObjType = gtJet;
1667  cType = l1t::Type1s;
1668  type = "1_s";
1669  nrObj = 1;
1670  } else if (condCalo.getType() == esConditionType::DoubleJet) {
1671  caloObjType = gtJet;
1672  cType = l1t::Type2s;
1673  type = "2_s";
1674  nrObj = 2;
1675  } else if (condCalo.getType() == esConditionType::TripleJet) {
1676  caloObjType = gtJet;
1677  cType = l1t::Type3s;
1678  type = "3";
1679  nrObj = 3;
1680  } else if (condCalo.getType() == esConditionType::QuadJet) {
1681  caloObjType = gtJet;
1682  cType = l1t::Type4s;
1683  type = "4";
1684  nrObj = 4;
1685  } else if (condCalo.getType() == esConditionType::SingleTau) {
1686  caloObjType = gtTau;
1687  cType = l1t::Type1s;
1688  type = "1_s";
1689  nrObj = 1;
1690  } else if (condCalo.getType() == esConditionType::DoubleTau) {
1691  caloObjType = gtTau;
1692  cType = l1t::Type2s;
1693  type = "2_s";
1694  nrObj = 2;
1695  } else if (condCalo.getType() == esConditionType::TripleTau) {
1696  caloObjType = gtTau;
1697  cType = l1t::Type3s;
1698  type = "3";
1699  nrObj = 3;
1700  } else if (condCalo.getType() == esConditionType::QuadTau) {
1701  caloObjType = gtTau;
1702  cType = l1t::Type4s;
1703  type = "4";
1704  nrObj = 4;
1705  } else {
1706  edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition (" << particle << ")" << std::endl;
1707  return false;
1708  }
1709 
1710  // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1711 
1712  if (nrObj < 0) {
1713  edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type << ")"
1714  << "\nCan not determine number of trigger objects. " << std::endl;
1715  return false;
1716  }
1717 
1718  // get values
1719 
1720  // temporary storage of the parameters
1721  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1722 
1723  //BLW TO DO: Can this be dropped?
1724  CaloTemplate::CorrelationParameter corrParameter;
1725 
1726  // need at least one value for deltaPhiRange
1727  std::vector<uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1728  tmpValues.reserve(nrObj);
1729 
1730  if (int(condCalo.getObjects().size()) != nrObj) {
1731  edm::LogError("TriggerMenuParser") << " condCalo objects: nrObj = " << nrObj
1732  << "condCalo.getObjects().size() = " << condCalo.getObjects().size()
1733  << std::endl;
1734  return false;
1735  }
1736 
1737  // std::string str_condCalo = "";
1738  // uint64_t tempUIntH, tempUIntL;
1739  // uint64_t dst;
1740  int cnt = 0;
1741 
1742  // BLW TO DO: These needs to the added to the object rather than the whole condition.
1743  int relativeBx = 0;
1744  bool gEq = false;
1745 
1746  // Loop over objects and extract the cuts on the objects
1747  const std::vector<L1TUtmObject>& objects = condCalo.getObjects();
1748  for (size_t jj = 0; jj < objects.size(); jj++) {
1749  const L1TUtmObject& object = objects.at(jj);
1750  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1751 
1752  // BLW TO DO: This needs to be added to the Object Parameters
1753  relativeBx = object.getBxOffset();
1754 
1755  // Loop over the cuts for this object
1756  int upperThresholdInd = -1;
1757  int lowerThresholdInd = 0;
1758  int upperIndexInd = -1;
1759  int lowerIndexInd = 0;
1760  int cntPhi = 0;
1761  unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
1762  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
1763  int qualityLUT = 0xF; //default is to ignore quality unless specified.
1764  int displacedLUT = 0x0; // Added for LLP Jets: single bit LUT: { 0 = noLLP default, 1 = LLP }
1765  // Note: Currently assumes that the LSB from hwQual() getter in L1Candidate provides the
1766  // (single bit) information for the displacedLUT
1767 
1768  std::vector<CaloTemplate::Window> etaWindows;
1769 
1770  const std::vector<L1TUtmCut>& cuts = object.getCuts();
1771  for (size_t kk = 0; kk < cuts.size(); kk++) {
1772  const L1TUtmCut& cut = cuts.at(kk);
1773 
1774  switch (cut.getCutType()) {
1775  case esCutType::Threshold:
1776  lowerThresholdInd = cut.getMinimum().index;
1777  upperThresholdInd = cut.getMaximum().index;
1778  break;
1779  case esCutType::Slice:
1780  lowerIndexInd = int(cut.getMinimum().value);
1781  upperIndexInd = int(cut.getMaximum().value);
1782  break;
1783  case esCutType::Eta: {
1784  if (etaWindows.size() < 5) {
1785  etaWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
1786  } else {
1787  edm::LogError("TriggerMenuParser")
1788  << "Too Many Eta Cuts for calo-condition (" << particle << ")" << std::endl;
1789  return false;
1790  }
1791  } break;
1792 
1793  case esCutType::Phi: {
1794  if (cntPhi == 0) {
1795  phiWindow1Lower = cut.getMinimum().index;
1796  phiWindow1Upper = cut.getMaximum().index;
1797  } else if (cntPhi == 1) {
1798  phiWindow2Lower = cut.getMinimum().index;
1799  phiWindow2Upper = cut.getMaximum().index;
1800  } else {
1801  edm::LogError("TriggerMenuParser")
1802  << "Too Many Phi Cuts for calo-condition (" << particle << ")" << std::endl;
1803  return false;
1804  }
1805  cntPhi++;
1806 
1807  } break;
1808 
1809  case esCutType::Charge: {
1810  edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition (" << particle << ")" << std::endl;
1811  return false;
1812 
1813  } break;
1814  case esCutType::Quality: {
1815  qualityLUT = l1tstr2int(cut.getData());
1816 
1817  } break;
1818  case esCutType::Displaced: { // Added for LLP Jets
1819  displacedLUT = l1tstr2int(cut.getData());
1820 
1821  } break;
1822  case esCutType::Isolation: {
1823  isolationLUT = l1tstr2int(cut.getData());
1824 
1825  } break;
1826  default:
1827  break;
1828  } //end switch
1829 
1830  } //end loop over cuts
1831 
1832  // Fill the object parameters
1833  objParameter[cnt].etHighThreshold = upperThresholdInd;
1834  objParameter[cnt].etLowThreshold = lowerThresholdInd;
1835  objParameter[cnt].indexHigh = upperIndexInd;
1836  objParameter[cnt].indexLow = lowerIndexInd;
1837  objParameter[cnt].etaWindows = etaWindows;
1838  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1839  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1840  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1841  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1842  objParameter[cnt].isolationLUT = isolationLUT;
1843  objParameter[cnt].qualityLUT = qualityLUT; //TO DO: Must add
1844  objParameter[cnt].displacedLUT = displacedLUT; // Added for LLP Jets
1845 
1846  // Output for debugging
1847  {
1848  std::ostringstream oss;
1849  oss << "\n Calo ET high thresholds (hex) for calo object " << caloObjType << " " << cnt << " = " << std::hex
1850  << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold;
1851  for (const auto& window : objParameter[cnt].etaWindows) {
1852  oss << "\n etaWindow Lower / Upper for calo object " << cnt << " = 0x" << window.lower << " / 0x"
1853  << window.upper;
1854  }
1855  oss << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x" << objParameter[cnt].phiWindow1Lower
1856  << " / 0x" << objParameter[cnt].phiWindow1Upper << "\n phiWindowVeto Lower / Upper for calo object "
1857  << cnt << " = 0x" << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper
1858  << "\n Isolation LUT for calo object " << cnt << " = 0x" << objParameter[cnt].isolationLUT
1859  << "\n Quality LUT for calo object " << cnt << " = 0x" << objParameter[cnt].qualityLUT
1860  << "\n LLP DISP LUT for calo object " << cnt << " = 0x" << objParameter[cnt].displacedLUT;
1861  LogDebug("TriggerMenuParser") << oss.str() << std::endl;
1862  }
1863 
1864  cnt++;
1865  } //end loop over objects
1866 
1867  // object types - all same caloObjType
1868  std::vector<GlobalObject> objType(nrObj, caloObjType);
1869 
1870  // now create a new calo condition
1871  CaloTemplate caloCond(name);
1872 
1873  caloCond.setCondType(cType);
1874  caloCond.setObjectType(objType);
1875 
1876  //BLW TO DO: This needs to be added to the object rather than the whole condition
1877  caloCond.setCondGEq(gEq);
1878  caloCond.setCondChipNr(chipNr);
1879 
1880  //BLW TO DO: This needs to be added to the object rather than the whole condition
1881  caloCond.setCondRelativeBx(relativeBx);
1882 
1883  caloCond.setConditionParameter(objParameter, corrParameter);
1884 
1885  if (edm::isDebugEnabled()) {
1886  std::ostringstream myCoutStream;
1887  caloCond.print(myCoutStream);
1888  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1889  }
1890 
1891  // insert condition into the map
1892  if (!insertConditionIntoMap(caloCond, chipNr)) {
1893  edm::LogError("TriggerMenuParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1894 
1895  return false;
1896  } else {
1897  if (corrFlag) {
1898  (m_corCaloTemplate[chipNr]).push_back(caloCond);
1899  } else {
1900  (m_vecCaloTemplate[chipNr]).push_back(caloCond);
1901  }
1902  }
1903 
1904  //
1905  return true;
1906 }
1907 
1919 bool l1t::TriggerMenuParser::parseCaloCorr(const L1TUtmObject* corrCalo, unsigned int chipNr) {
1920  // XERCES_CPP_NAMESPACE_USE
1921  using namespace tmeventsetup;
1922 
1923  // get condition, particle name and type name
1924 
1925  std::string condition = "calo";
1926  std::string particle = "test-fix";
1927  std::string type = l1t2string(corrCalo->getType());
1928  std::string name = l1t2string(corrCalo->getName());
1929 
1930  LogDebug("TriggerMenuParser") << "\n ****************************************** "
1931  << "\n (in parseCalo) "
1932  << "\n condition = " << condition << "\n particle = " << particle
1933  << "\n type = " << type << "\n name = " << name << std::endl;
1934 
1935  // determine object type type
1936  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
1937  GlobalObject caloObjType;
1938  int nrObj = 1;
1939  type = "1_s";
1940  GtConditionType cType = l1t::Type1s;
1941 
1942  if (corrCalo->getType() == esObjectType::Egamma) {
1943  caloObjType = gtEG;
1944  } else if (corrCalo->getType() == esObjectType::Jet) {
1945  caloObjType = gtJet;
1946  } else if (corrCalo->getType() == esObjectType::Tau) {
1947  caloObjType = gtTau;
1948  } else {
1949  edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition (" << particle << ")" << std::endl;
1950  return false;
1951  }
1952 
1953  // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1954 
1955  if (nrObj < 0) {
1956  edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type << ")"
1957  << "\nCan not determine number of trigger objects. " << std::endl;
1958  return false;
1959  }
1960 
1961  // get values
1962 
1963  // temporary storage of the parameters
1964  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1965 
1966  //BLW TO DO: Can this be dropped?
1967  CaloTemplate::CorrelationParameter corrParameter;
1968 
1969  // need at least one value for deltaPhiRange
1970  std::vector<uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1971  tmpValues.reserve(nrObj);
1972 
1973  // BLW TO DO: These needs to the added to the object rather than the whole condition.
1974  int relativeBx = 0;
1975  bool gEq = false;
1976 
1977  gEq = (corrCalo->getComparisonOperator() == esComparisonOperator::GE);
1978 
1979  // BLW TO DO: This needs to be added to the Object Parameters
1980  relativeBx = corrCalo->getBxOffset();
1981 
1982  // Loop over the cuts for this object
1983  int upperThresholdInd = -1;
1984  int lowerThresholdInd = 0;
1985  int upperIndexInd = -1;
1986  int lowerIndexInd = 0;
1987  int cntPhi = 0;
1988  unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
1989  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
1990  int qualityLUT = 0xF; //default is to ignore quality unless specified.
1991  int displacedLUT = 0x0; // Added for LLP Jets: single bit LUT: { 0 = noLLP default, 1 = LLP }
1992  // Note: Currently assume that the hwQual() getter in L1Candidate provides the
1993  // (single bit) information for the displacedLUT
1994 
1995  std::vector<CaloTemplate::Window> etaWindows;
1996 
1997  const std::vector<L1TUtmCut>& cuts = corrCalo->getCuts();
1998  for (size_t kk = 0; kk < cuts.size(); kk++) {
1999  const L1TUtmCut& cut = cuts.at(kk);
2000 
2001  switch (cut.getCutType()) {
2002  case esCutType::Threshold:
2003  lowerThresholdInd = cut.getMinimum().index;
2004  upperThresholdInd = cut.getMaximum().index;
2005  break;
2006  case esCutType::Slice:
2007  lowerIndexInd = int(cut.getMinimum().value);
2008  upperIndexInd = int(cut.getMaximum().value);
2009  break;
2010  case esCutType::Eta: {
2011  if (etaWindows.size() < 5) {
2012  etaWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
2013  } else {
2014  edm::LogError("TriggerMenuParser")
2015  << "Too Many Eta Cuts for calo-condition (" << particle << ")" << std::endl;
2016  return false;
2017  }
2018  } break;
2019 
2020  case esCutType::Phi: {
2021  if (cntPhi == 0) {
2022  phiWindow1Lower = cut.getMinimum().index;
2023  phiWindow1Upper = cut.getMaximum().index;
2024  } else if (cntPhi == 1) {
2025  phiWindow2Lower = cut.getMinimum().index;
2026  phiWindow2Upper = cut.getMaximum().index;
2027  } else {
2028  edm::LogError("TriggerMenuParser")
2029  << "Too Many Phi Cuts for calo-condition (" << particle << ")" << std::endl;
2030  return false;
2031  }
2032  cntPhi++;
2033 
2034  } break;
2035 
2036  case esCutType::Charge: {
2037  edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition (" << particle << ")" << std::endl;
2038  return false;
2039 
2040  } break;
2041  case esCutType::Quality: {
2042  qualityLUT = l1tstr2int(cut.getData());
2043 
2044  } break;
2045  case esCutType::Displaced: { // Added for LLP Jets
2046  displacedLUT = l1tstr2int(cut.getData());
2047 
2048  } break;
2049  case esCutType::Isolation: {
2050  isolationLUT = l1tstr2int(cut.getData());
2051 
2052  } break;
2053  default:
2054  break;
2055  } //end switch
2056 
2057  } //end loop over cuts
2058 
2059  // Fill the object parameters
2060  objParameter[0].etLowThreshold = lowerThresholdInd;
2061  objParameter[0].etHighThreshold = upperThresholdInd;
2062  objParameter[0].indexHigh = upperIndexInd;
2063  objParameter[0].indexLow = lowerIndexInd;
2064  objParameter[0].etaWindows = etaWindows;
2065  objParameter[0].phiWindow1Lower = phiWindow1Lower;
2066  objParameter[0].phiWindow1Upper = phiWindow1Upper;
2067  objParameter[0].phiWindow2Lower = phiWindow2Lower;
2068  objParameter[0].phiWindow2Upper = phiWindow2Upper;
2069  objParameter[0].isolationLUT = isolationLUT;
2070  objParameter[0].qualityLUT = qualityLUT; //TO DO: Must add
2071  objParameter[0].displacedLUT = displacedLUT; // Added for LLP Jets
2072 
2073  // Output for debugging
2074  {
2075  std::ostringstream oss;
2076  oss << "\n Calo ET high threshold (hex) for calo object " << caloObjType << " "
2077  << " = " << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etHighThreshold;
2078  for (const auto& window : objParameter[0].etaWindows) {
2079  oss << "\n etaWindow Lower / Upper for calo object "
2080  << " = 0x" << window.lower << " / 0x" << window.upper;
2081  }
2082  oss << "\n phiWindow Lower / Upper for calo object "
2083  << " = 0x" << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
2084  << "\n phiWindowVeto Lower / Upper for calo object "
2085  << " = 0x" << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper
2086  << "\n Isolation LUT for calo object "
2087  << " = 0x" << objParameter[0].isolationLUT << "\n Quality LUT for calo object "
2088  << " = 0x" << objParameter[0].qualityLUT << "\n LLP DISP LUT for calo object "
2089  << " = 0x" << objParameter[0].displacedLUT;
2090  LogDebug("TriggerMenuParser") << oss.str() << std::endl;
2091  }
2092 
2093  // object types - all same caloObjType
2094  std::vector<GlobalObject> objType(nrObj, caloObjType);
2095 
2096  // now create a new calo condition
2097  CaloTemplate caloCond(name);
2098 
2099  caloCond.setCondType(cType);
2100  caloCond.setObjectType(objType);
2101 
2102  //BLW TO DO: This needs to be added to the object rather than the whole condition
2103  caloCond.setCondGEq(gEq);
2104  caloCond.setCondChipNr(chipNr);
2105 
2106  //BLW TO DO: This needs to be added to the object rather than the whole condition
2107  caloCond.setCondRelativeBx(relativeBx);
2108 
2109  caloCond.setConditionParameter(objParameter, corrParameter);
2110 
2111  if (edm::isDebugEnabled()) {
2112  std::ostringstream myCoutStream;
2113  caloCond.print(myCoutStream);
2114  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2115  }
2116 
2117  /*
2118  // insert condition into the map
2119  if ( !insertConditionIntoMap(caloCond, chipNr)) {
2120 
2121  edm::LogError("TriggerMenuParser")
2122  << " Error: duplicate condition (" << name << ")"
2123  << std::endl;
2124 
2125  return false;
2126  }
2127  else {
2128  (m_corCaloTemplate[chipNr]).push_back(caloCond);
2129  }
2130 */
2131  (m_corCaloTemplate[chipNr]).push_back(caloCond);
2132 
2133  //
2134  return true;
2135 }
2136 
2148 bool l1t::TriggerMenuParser::parseEnergySum(L1TUtmCondition condEnergySum, unsigned int chipNr, const bool corrFlag) {
2149  // XERCES_CPP_NAMESPACE_USE
2150  using namespace tmeventsetup;
2151 
2152  // get condition, particle name and type name
2153 
2154  std::string condition = "calo";
2155  std::string type = l1t2string(condEnergySum.getType());
2156  std::string name = l1t2string(condEnergySum.getName());
2157 
2158  LogDebug("TriggerMenuParser") << "\n ****************************************** "
2159  << "\n (in parseEnergySum) "
2160  << "\n condition = " << condition << "\n type = " << type
2161  << "\n name = " << name << std::endl;
2162 
2163  // determine object type type
2164  GlobalObject energySumObjType;
2165  GtConditionType cType;
2166 
2167  if (condEnergySum.getType() == esConditionType::MissingEt) {
2168  energySumObjType = GlobalObject::gtETM;
2169  cType = TypeETM;
2170  } else if (condEnergySum.getType() == esConditionType::TotalEt) {
2171  energySumObjType = GlobalObject::gtETT;
2172  cType = TypeETT;
2173  } else if (condEnergySum.getType() == esConditionType::TotalEtEM) {
2174  energySumObjType = GlobalObject::gtETTem;
2175  cType = TypeETTem;
2176  } else if (condEnergySum.getType() == esConditionType::TotalHt) {
2177  energySumObjType = GlobalObject::gtHTT;
2178  cType = TypeHTT;
2179  } else if (condEnergySum.getType() == esConditionType::MissingHt) {
2180  energySumObjType = GlobalObject::gtHTM;
2181  cType = TypeHTM;
2182  } else if (condEnergySum.getType() == esConditionType::MissingEtHF) {
2183  energySumObjType = GlobalObject::gtETMHF;
2184  cType = TypeETMHF;
2185  } else if (condEnergySum.getType() == esConditionType::TowerCount) {
2186  energySumObjType = GlobalObject::gtTowerCount;
2187  cType = TypeTowerCount;
2188  } else if (condEnergySum.getType() == esConditionType::MinBiasHFP0) {
2189  energySumObjType = GlobalObject::gtMinBiasHFP0;
2190  cType = TypeMinBiasHFP0;
2191  } else if (condEnergySum.getType() == esConditionType::MinBiasHFM0) {
2192  energySumObjType = GlobalObject::gtMinBiasHFM0;
2193  cType = TypeMinBiasHFM0;
2194  } else if (condEnergySum.getType() == esConditionType::MinBiasHFP1) {
2195  energySumObjType = GlobalObject::gtMinBiasHFP1;
2196  cType = TypeMinBiasHFP1;
2197  } else if (condEnergySum.getType() == esConditionType::MinBiasHFM1) {
2198  energySumObjType = GlobalObject::gtMinBiasHFM1;
2199  cType = TypeMinBiasHFM1;
2200  } else if (condEnergySum.getType() == esConditionType::AsymmetryEt) {
2201  energySumObjType = GlobalObject::gtAsymmetryEt;
2202  cType = TypeAsymEt;
2203  } else if (condEnergySum.getType() == esConditionType::AsymmetryHt) {
2204  energySumObjType = GlobalObject::gtAsymmetryHt;
2205  cType = TypeAsymHt;
2206  } else if (condEnergySum.getType() == esConditionType::AsymmetryEtHF) {
2207  energySumObjType = GlobalObject::gtAsymmetryEtHF;
2208  cType = TypeAsymEtHF;
2209  } else if (condEnergySum.getType() == esConditionType::AsymmetryHtHF) {
2210  energySumObjType = GlobalObject::gtAsymmetryHtHF;
2211  cType = TypeAsymHtHF;
2212  } else if (condEnergySum.getType() == esConditionType::Centrality0) {
2213  energySumObjType = GlobalObject::gtCentrality0;
2214  cType = TypeCent0;
2215  } else if (condEnergySum.getType() == esConditionType::Centrality1) {
2216  energySumObjType = GlobalObject::gtCentrality1;
2217  cType = TypeCent1;
2218  } else if (condEnergySum.getType() == esConditionType::Centrality2) {
2219  energySumObjType = GlobalObject::gtCentrality2;
2220  cType = TypeCent2;
2221  } else if (condEnergySum.getType() == esConditionType::Centrality3) {
2222  energySumObjType = GlobalObject::gtCentrality3;
2223  cType = TypeCent3;
2224  } else if (condEnergySum.getType() == esConditionType::Centrality4) {
2225  energySumObjType = GlobalObject::gtCentrality4;
2226  cType = TypeCent4;
2227  } else if (condEnergySum.getType() == esConditionType::Centrality5) {
2228  energySumObjType = GlobalObject::gtCentrality5;
2229  cType = TypeCent5;
2230  } else if (condEnergySum.getType() == esConditionType::Centrality6) {
2231  energySumObjType = GlobalObject::gtCentrality6;
2232  cType = TypeCent6;
2233  } else if (condEnergySum.getType() == esConditionType::Centrality7) {
2234  energySumObjType = GlobalObject::gtCentrality7;
2235  cType = TypeCent7;
2236  } else {
2237  edm::LogError("TriggerMenuParser") << "Wrong type for energy-sum condition (" << type << ")" << std::endl;
2238  return false;
2239  }
2240 
2241  // global object
2242  int nrObj = 1;
2243 
2244  // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
2245 
2246  // get values
2247 
2248  // temporary storage of the parameters
2249  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2250 
2251  int cnt = 0;
2252 
2253  // BLW TO DO: These needs to the added to the object rather than the whole condition.
2254  int relativeBx = 0;
2255  bool gEq = false;
2256 
2257  // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
2258 
2259  // Loop over objects and extract the cuts on the objects
2260  const std::vector<L1TUtmObject>& objects = condEnergySum.getObjects();
2261  for (size_t jj = 0; jj < objects.size(); jj++) {
2262  const L1TUtmObject& object = objects.at(jj);
2263  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
2264 
2265  // BLW TO DO: This needs to be added to the Object Parameters
2266  relativeBx = object.getBxOffset();
2267 
2268  // Loop over the cuts for this object
2269  int lowerThresholdInd = 0;
2270  int upperThresholdInd = -1;
2271  int cntPhi = 0;
2272  unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
2273 
2274  const std::vector<L1TUtmCut>& cuts = object.getCuts();
2275  for (size_t kk = 0; kk < cuts.size(); kk++) {
2276  const L1TUtmCut& cut = cuts.at(kk);
2277 
2278  switch (cut.getCutType()) {
2279  case esCutType::Threshold:
2280  lowerThresholdInd = cut.getMinimum().index;
2281  upperThresholdInd = cut.getMaximum().index;
2282  break;
2283 
2284  case esCutType::Eta:
2285  break;
2286 
2287  case esCutType::Phi: {
2288  if (cntPhi == 0) {
2289  phiWindow1Lower = cut.getMinimum().index;
2290  phiWindow1Upper = cut.getMaximum().index;
2291  } else if (cntPhi == 1) {
2292  phiWindow2Lower = cut.getMinimum().index;
2293  phiWindow2Upper = cut.getMaximum().index;
2294  } else {
2295  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition (" << type << ")" << std::endl;
2296  return false;
2297  }
2298  cntPhi++;
2299 
2300  } break;
2301 
2302  case esCutType::Count:
2303  lowerThresholdInd = cut.getMinimum().index;
2304  upperThresholdInd = 0xffffff;
2305  break;
2306 
2307  default:
2308  break;
2309  } //end switch
2310 
2311  } //end loop over cuts
2312 
2313  // Fill the object parameters
2314  objParameter[cnt].etLowThreshold = lowerThresholdInd;
2315  objParameter[cnt].etHighThreshold = upperThresholdInd;
2316  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
2317  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
2318  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
2319  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
2320 
2321  // Output for debugging
2322  LogDebug("TriggerMenuParser") << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2323  << std::hex << objParameter[cnt].etLowThreshold << " - "
2324  << objParameter[cnt].etHighThreshold
2325  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2326  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
2327  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2328  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper
2329  << std::dec << std::endl;
2330 
2331  cnt++;
2332  } //end loop over objects
2333 
2334  // object types - all same energySumObjType
2335  std::vector<GlobalObject> objType(nrObj, energySumObjType);
2336 
2337  // now create a new energySum condition
2338 
2339  EnergySumTemplate energySumCond(name);
2340 
2341  energySumCond.setCondType(cType);
2342  energySumCond.setObjectType(objType);
2343  energySumCond.setCondGEq(gEq);
2344  energySumCond.setCondChipNr(chipNr);
2345  energySumCond.setCondRelativeBx(relativeBx);
2346 
2347  energySumCond.setConditionParameter(objParameter);
2348 
2349  if (edm::isDebugEnabled()) {
2350  std::ostringstream myCoutStream;
2351  energySumCond.print(myCoutStream);
2352  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2353  }
2354 
2355  // insert condition into the map
2356  if (!insertConditionIntoMap(energySumCond, chipNr)) {
2357  edm::LogError("TriggerMenuParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2358 
2359  return false;
2360  } else {
2361  if (corrFlag) {
2362  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2363 
2364  } else {
2365  (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
2366  }
2367  }
2368 
2369  //
2370  return true;
2371 }
2372 
2384 bool l1t::TriggerMenuParser::parseEnergySumCorr(const L1TUtmObject* corrESum, unsigned int chipNr) {
2385  // XERCES_CPP_NAMESPACE_USE
2386  using namespace tmeventsetup;
2387 
2388  // get condition, particle name and type name
2389 
2390  std::string condition = "calo";
2391  std::string type = l1t2string(corrESum->getType());
2392  std::string name = l1t2string(corrESum->getName());
2393 
2394  LogDebug("TriggerMenuParser") << "\n ****************************************** "
2395  << "\n (in parseEnergySum) "
2396  << "\n condition = " << condition << "\n type = " << type
2397  << "\n name = " << name << std::endl;
2398 
2399  // determine object type type
2400  GlobalObject energySumObjType;
2401  GtConditionType cType;
2402 
2403  if (corrESum->getType() == esObjectType::ETM) {
2404  energySumObjType = GlobalObject::gtETM;
2405  cType = TypeETM;
2406  } else if (corrESum->getType() == esObjectType::HTM) {
2407  energySumObjType = GlobalObject::gtHTM;
2408  cType = TypeHTM;
2409  } else if (corrESum->getType() == esObjectType::ETMHF) {
2410  energySumObjType = GlobalObject::gtETMHF;
2411  cType = TypeETMHF;
2412  } else if (corrESum->getType() == esObjectType::TOWERCOUNT) {
2413  energySumObjType = GlobalObject::gtTowerCount;
2414  cType = TypeTowerCount;
2415  } else {
2416  edm::LogError("TriggerMenuParser") << "Wrong type for energy-sum correclation condition (" << type << ")"
2417  << std::endl;
2418  return false;
2419  }
2420 
2421  // global object
2422  int nrObj = 1;
2423 
2424  // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
2425 
2426  // get values
2427 
2428  // temporary storage of the parameters
2429  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2430 
2431  int cnt = 0;
2432 
2433  // BLW TO DO: These needs to the added to the object rather than the whole condition.
2434  int relativeBx = 0;
2435  bool gEq = false;
2436 
2437  // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
2438 
2439  gEq = (corrESum->getComparisonOperator() == esComparisonOperator::GE);
2440 
2441  // BLW TO DO: This needs to be added to the Object Parameters
2442  relativeBx = corrESum->getBxOffset();
2443 
2444  // Loop over the cuts for this object
2445  int lowerThresholdInd = 0;
2446  int upperThresholdInd = -1;
2447  int cntPhi = 0;
2448  unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
2449 
2450  const std::vector<L1TUtmCut>& cuts = corrESum->getCuts();
2451  for (size_t kk = 0; kk < cuts.size(); kk++) {
2452  const L1TUtmCut& cut = cuts.at(kk);
2453 
2454  switch (cut.getCutType()) {
2455  case esCutType::Threshold:
2456  lowerThresholdInd = cut.getMinimum().index;
2457  upperThresholdInd = cut.getMaximum().index;
2458  break;
2459 
2460  case esCutType::Eta:
2461  break;
2462 
2463  case esCutType::Phi: {
2464  if (cntPhi == 0) {
2465  phiWindow1Lower = cut.getMinimum().index;
2466  phiWindow1Upper = cut.getMaximum().index;
2467  } else if (cntPhi == 1) {
2468  phiWindow2Lower = cut.getMinimum().index;
2469  phiWindow2Upper = cut.getMaximum().index;
2470  } else {
2471  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition (" << type << ")" << std::endl;
2472  return false;
2473  }
2474  cntPhi++;
2475 
2476  } break;
2477 
2478  default:
2479  break;
2480  } //end switch
2481 
2482  } //end loop over cuts
2483 
2484  // Fill the object parameters
2485  objParameter[0].etLowThreshold = lowerThresholdInd;
2486  objParameter[0].etHighThreshold = upperThresholdInd;
2487  objParameter[0].phiWindow1Lower = phiWindow1Lower;
2488  objParameter[0].phiWindow1Upper = phiWindow1Upper;
2489  objParameter[0].phiWindow2Lower = phiWindow2Lower;
2490  objParameter[0].phiWindow2Upper = phiWindow2Upper;
2491 
2492  // Output for debugging
2493  LogDebug("TriggerMenuParser") << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2494  << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etLowThreshold
2495  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2496  << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
2497  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2498  << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper
2499  << std::dec << std::endl;
2500 
2501  // object types - all same energySumObjType
2502  std::vector<GlobalObject> objType(nrObj, energySumObjType);
2503 
2504  // now create a new energySum condition
2505 
2506  EnergySumTemplate energySumCond(name);
2507 
2508  energySumCond.setCondType(cType);
2509  energySumCond.setObjectType(objType);
2510  energySumCond.setCondGEq(gEq);
2511  energySumCond.setCondChipNr(chipNr);
2512  energySumCond.setCondRelativeBx(relativeBx);
2513 
2514  energySumCond.setConditionParameter(objParameter);
2515 
2516  if (edm::isDebugEnabled()) {
2517  std::ostringstream myCoutStream;
2518  energySumCond.print(myCoutStream);
2519  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2520  }
2521  /*
2522  // insert condition into the map
2523  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2524 
2525  edm::LogError("TriggerMenuParser")
2526  << " Error: duplicate condition (" << name << ")"
2527  << std::endl;
2528 
2529  return false;
2530  }
2531  else {
2532 
2533  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2534 
2535  }
2536 */
2537  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2538 
2539  //
2540  return true;
2541 }
2542 
2555 bool l1t::TriggerMenuParser::parseExternal(L1TUtmCondition condExt, unsigned int chipNr) {
2556  using namespace tmeventsetup;
2557  // get condition, particle name and type name
2558  std::string condition = "ext";
2559  std::string particle = "test-fix";
2560  std::string type = l1t2string(condExt.getType());
2561  std::string name = l1t2string(condExt.getName());
2562 
2563  LogDebug("TriggerMenuParser") << "\n ****************************************** "
2564  << "\n (in parseExternal) "
2565  << "\n condition = " << condition << "\n particle = " << particle
2566  << "\n type = " << type << "\n name = " << name << std::endl;
2567 
2568  // object type and condition type
2569  // object type - irrelevant for External conditions
2570  GtConditionType cType = TypeExternal;
2571  GlobalObject extSignalType = GlobalObject::gtExternal;
2572  int nrObj = 1; //only one object for these conditions
2573 
2574  int relativeBx = 0;
2575  unsigned int channelID = 0;
2576 
2577  // Get object for External conditions
2578  const std::vector<L1TUtmObject>& objects = condExt.getObjects();
2579  for (size_t jj = 0; jj < objects.size(); jj++) {
2580  const L1TUtmObject& object = objects.at(jj);
2581  if (object.getType() == esObjectType::EXT) {
2582  relativeBx = object.getBxOffset();
2583  channelID = object.getExternalChannelId();
2584  }
2585  }
2586 
2587  // set the boolean value for the ge_eq mode - irrelevant for External conditions
2588  bool gEq = false;
2589 
2590  //object types - all same for external conditions
2591  std::vector<GlobalObject> objType(nrObj, extSignalType);
2592 
2593  // now create a new External condition
2594  ExternalTemplate externalCond(name);
2595 
2596  externalCond.setCondType(cType);
2597  externalCond.setObjectType(objType);
2598  externalCond.setCondGEq(gEq);
2599  externalCond.setCondChipNr(chipNr);
2600  externalCond.setCondRelativeBx(relativeBx);
2601  externalCond.setExternalChannel(channelID);
2602 
2603  LogTrace("TriggerMenuParser") << externalCond << "\n" << std::endl;
2604 
2605  // insert condition into the map
2606  if (!insertConditionIntoMap(externalCond, chipNr)) {
2607  edm::LogError("TriggerMenuParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2608 
2609  return false;
2610  } else {
2611  (m_vecExternalTemplate[chipNr]).push_back(externalCond);
2612  }
2613 
2614  return true;
2615 }
2616 
2629 bool l1t::TriggerMenuParser::parseCorrelation(L1TUtmCondition corrCond, unsigned int chipNr) {
2630  using namespace tmeventsetup;
2631  std::string condition = "corr";
2632  std::string particle = "test-fix";
2633  std::string type = l1t2string(corrCond.getType());
2634  std::string name = l1t2string(corrCond.getName());
2635 
2636  LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
2637  << " (in parseCorrelation) " << std::endl
2638  << " condition = " << condition << std::endl
2639  << " particle = " << particle << std::endl
2640  << " type = " << type << std::endl
2641  << " name = " << name << std::endl;
2642 
2643  // create a new correlation condition
2644  CorrelationTemplate correlationCond(name);
2645 
2646  // check that the condition does not exist already in the map
2647  if (!insertConditionIntoMap(correlationCond, chipNr)) {
2648  edm::LogError("TriggerMenuParser") << " Error: duplicate correlation condition (" << name << ")" << std::endl;
2649 
2650  return false;
2651  }
2652 
2653  // Define some of the quantities to store the parased information
2654 
2655  // condition type BLW (Do we change this to the type of correlation condition?)
2657 
2658  // two objects (for sure)
2659  const int nrObj = 2;
2660 
2661  // object types and greater equal flag - filled in the loop
2662  int intGEq[nrObj] = {-1, -1};
2663  std::vector<GlobalObject> objType(nrObj); //BLW do we want to define these as a different type?
2664  std::vector<GtConditionCategory> condCateg(nrObj); //BLW do we want to change these categories
2665 
2666  // correlation flag and index in the cor*vector
2667  const bool corrFlag = true;
2668  int corrIndexVal[nrObj] = {-1, -1};
2669 
2670  // Storage of the correlation selection
2672  corrParameter.chargeCorrelation = 1; //ignore charge correlation
2673 
2674  // Get the correlation Cuts on the legs
2675  int cutType = 0;
2676  const std::vector<L1TUtmCut>& cuts = corrCond.getCuts();
2677  for (size_t jj = 0; jj < cuts.size(); jj++) {
2678  const L1TUtmCut& cut = cuts.at(jj);
2679 
2680  if (cut.getCutType() == esCutType::ChargeCorrelation) {
2681  if (cut.getData() == "ls")
2682  corrParameter.chargeCorrelation = 2;
2683  else if (cut.getData() == "os")
2684  corrParameter.chargeCorrelation = 4;
2685  else
2686  corrParameter.chargeCorrelation = 1; //ignore charge correlation
2687  } else {
2688  //
2689  // Until utm has method to calculate these, do the integer value calculation with precision.
2690  //
2691  double minV = cut.getMinimum().value;
2692  double maxV = cut.getMaximum().value;
2693 
2694  //Scale down very large numbers out of xml
2695  if (maxV > 1.0e8)
2696  maxV = 1.0e8;
2697 
2698  if (cut.getCutType() == esCutType::DeltaEta) {
2699  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaEta Cut minV = " << minV
2700  << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2701  << " precMax = " << cut.getMaximum().index << std::endl;
2702  corrParameter.minEtaCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2703  corrParameter.maxEtaCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2704  corrParameter.precEtaCut = cut.getMinimum().index;
2705  cutType = cutType | 0x1;
2706  } else if (cut.getCutType() == esCutType::DeltaPhi) {
2707  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaPhi Cut minV = " << minV
2708  << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2709  << " precMax = " << cut.getMaximum().index << std::endl;
2710  corrParameter.minPhiCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2711  corrParameter.maxPhiCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2712  corrParameter.precPhiCut = cut.getMinimum().index;
2713  cutType = cutType | 0x2;
2714  } else if (cut.getCutType() == esCutType::DeltaR) {
2715  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaR Cut minV = " << minV
2716  << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2717  << " precMax = " << cut.getMaximum().index << std::endl;
2718  corrParameter.minDRCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2719  corrParameter.maxDRCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2720  corrParameter.precDRCut = cut.getMinimum().index;
2721  cutType = cutType | 0x4;
2722  } else if (cut.getCutType() == esCutType::TwoBodyPt) {
2723  corrParameter.minTBPTCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2724  corrParameter.maxTBPTCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2725  corrParameter.precTBPTCut = cut.getMinimum().index;
2726  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tTPBT Cut minV = " << minV
2727  << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2728  << " precMax = " << cut.getMaximum().index << std::endl;
2729  cutType = cutType | 0x20;
2730  } else if ((cut.getCutType() == esCutType::Mass) ||
2731  (cut.getCutType() == esCutType::MassDeltaR)) { //Invariant Mass, MassOverDeltaR
2732  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tMass Cut minV = " << minV
2733  << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2734  << " precMax = " << cut.getMaximum().index << std::endl;
2735  corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2736  corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2737  corrParameter.precMassCut = cut.getMinimum().index;
2738  // cutType = cutType | 0x8;
2739  if (corrCond.getType() == esConditionType::TransverseMass) {
2740  cutType = cutType | 0x10;
2741  } else if (corrCond.getType() == esConditionType::InvariantMassDeltaR) {
2742  cutType = cutType | 0x80;
2743  } else {
2744  cutType = cutType | 0x8;
2745  }
2746  } else if (cut.getCutType() == esCutType::MassUpt) { // Added for displaced muons
2747  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tMass Cut minV = " << minV
2748  << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2749  << " precMax = " << cut.getMaximum().index << std::endl;
2750  corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2751  corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2752  corrParameter.precMassCut = cut.getMinimum().index;
2753  cutType = cutType | 0x40; // Note: 0x40 (MassUpt) is next available bit after 0x20 (TwoBodyPt)
2754  } // Careful: cutType carries same info as esCutType, but is hard coded!!
2755  } // This seems like a historical hack, which may be error prone.
2756  } // cutType is defined here, for use later in CorrCondition.cc
2757  corrParameter.corrCutType = cutType;
2758 
2759  // Get the two objects that form the legs
2760  const std::vector<L1TUtmObject>& objects = corrCond.getObjects();
2761  if (objects.size() != 2) {
2762  edm::LogError("TriggerMenuParser") << "incorrect number of objects for the correlation condition " << name
2763  << " corrFlag " << corrFlag << std::endl;
2764  return false;
2765  }
2766 
2767  // loop over legs
2768  for (size_t jj = 0; jj < objects.size(); jj++) {
2769  const L1TUtmObject& object = objects.at(jj);
2770  LogDebug("TriggerMenuParser") << " obj name = " << object.getName() << "\n";
2771  LogDebug("TriggerMenuParser") << " obj type = " << object.getType() << "\n";
2772  LogDebug("TriggerMenuParser") << " obj op = " << object.getComparisonOperator() << "\n";
2773  LogDebug("TriggerMenuParser") << " obj bx = " << object.getBxOffset() << "\n";
2774 
2775  // check the leg type
2776  if (object.getType() == esObjectType::Muon) {
2777  // we have a muon
2778 
2779  /*
2780  //BLW Hold on to this code we may need to go back to it at some point.
2781  // Now we are putting ALL leg conditions into the vector (so there are duplicates)
2782  // This is potentially a place to slim down the code. Note: We currently evaluate the
2783  // conditions every time, so even if we put the condition in the vector once, we would
2784  // still evaluate it multiple times. This is a place for optimization.
2785  {
2786 
2787  parseMuonCorr(&object,chipNr);
2788  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
2789 
2790  } else {
2791  LogDebug("TriggerMenuParser") << "Not Adding Correlation Muon Condition to Map...looking for the condition in Muon Cor Vector" << std::endl;
2792  bool found = false;
2793  int index = 0;
2794  while(!found && index<(int)((m_corMuonTemplate[chipNr]).size()) ) {
2795  if( (m_corMuonTemplate[chipNr]).at(index).condName() == object.getName() ) {
2796  LogDebug("TriggerMenuParser") << "Found condition " << object.getName() << " in vector at index " << index << std::endl;
2797  found = true;
2798  } else {
2799  index++;
2800  }
2801  }
2802  if(found) {
2803  corrIndexVal[jj] = index;
2804  } else {
2805  edm::LogError("TriggerMenuParser") << "FAILURE: Condition " << object.getName() << " is in map but not in cor. vector " << std::endl;
2806  }
2807 
2808  }
2809 */
2810  parseMuonCorr(&object, chipNr);
2811  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
2812 
2813  //Now set some flags for this subCondition
2814  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2815  objType[jj] = gtMu;
2816  condCateg[jj] = CondMuon;
2817 
2818  } else if (object.getType() == esObjectType::Egamma || object.getType() == esObjectType::Jet ||
2819  object.getType() == esObjectType::Tau) {
2820  // we have an Calo object
2821  parseCaloCorr(&object, chipNr);
2822  corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
2823 
2824  //Now set some flags for this subCondition
2825  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2826  switch (object.getType()) {
2827  case esObjectType::Egamma: {
2828  objType[jj] = gtEG;
2829  } break;
2830  case esObjectType::Jet: {
2831  objType[jj] = gtJet;
2832  } break;
2833  case esObjectType::Tau: {
2834  objType[jj] = gtTau;
2835  } break;
2836  default: {
2837  } break;
2838  }
2839  condCateg[jj] = CondCalo;
2840 
2841  } else if (object.getType() == esObjectType::ETM || object.getType() == esObjectType::ETMHF ||
2842  object.getType() == esObjectType::TOWERCOUNT || object.getType() == esObjectType::HTM) {
2843  // we have Energy Sum
2844  parseEnergySumCorr(&object, chipNr);
2845  corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
2846 
2847  //Now set some flags for this subCondition
2848  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2849  switch (object.getType()) {
2850  case esObjectType::ETM: {
2852  } break;
2853  case esObjectType::HTM: {
2855  } break;
2856  case esObjectType::ETMHF: {
2858  } break;
2859  case esObjectType::TOWERCOUNT: {
2861  } break;
2862  default: {
2863  } break;
2864  }
2865  condCateg[jj] = CondEnergySum;
2866 
2867  } else {
2868  edm::LogError("TriggerMenuParser") << "Illegal Object Type " << object.getType()
2869  << " for the correlation condition " << name << std::endl;
2870  return false;
2871 
2872  } //if block on leg types
2873 
2874  } //loop over legs
2875 
2876  // get greater equal flag for the correlation condition
2877  bool gEq = true;
2878  if (intGEq[0] != intGEq[1]) {
2879  edm::LogError("TriggerMenuParser") << "Inconsistent GEq flags for sub-conditions "
2880  << " for the correlation condition " << name << std::endl;
2881  return false;
2882 
2883  } else {
2884  gEq = (intGEq[0] != 0);
2885  }
2886 
2887  // fill the correlation condition
2888  correlationCond.setCondType(cType);
2889  correlationCond.setObjectType(objType);
2890  correlationCond.setCondGEq(gEq);
2891  correlationCond.setCondChipNr(chipNr);
2892 
2893  correlationCond.setCond0Category(condCateg[0]);
2894  correlationCond.setCond1Category(condCateg[1]);
2895 
2896  correlationCond.setCond0Index(corrIndexVal[0]);
2897  correlationCond.setCond1Index(corrIndexVal[1]);
2898 
2899  correlationCond.setCorrelationParameter(corrParameter);
2900 
2901  if (edm::isDebugEnabled()) {
2902  std::ostringstream myCoutStream;
2903  correlationCond.print(myCoutStream);
2904  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2905  }
2906 
2907  // insert condition into the map
2908  // condition is not duplicate, check was done at the beginning
2909 
2910  (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
2911 
2912  //
2913  return true;
2914 }
2915 
2917 
2930  using namespace tmeventsetup;
2931  std::string condition = "corrThreeBody";
2932  std::string particle = "muon";
2933  std::string type = l1t2string(corrCond.getType());
2934  std::string name = l1t2string(corrCond.getName());
2935 
2936  LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
2937  << " (in parseCorrelationThreeBody) " << std::endl
2938  << " condition = " << condition << std::endl
2939  << " particle = " << particle << std::endl
2940  << " type = " << type << std::endl
2941  << " name = " << name << std::endl;
2942 
2943  // create a new correlation condition
2944  CorrelationThreeBodyTemplate correlationThreeBodyCond(name);
2945 
2946  // check that the condition does not exist already in the map
2947  if (!insertConditionIntoMap(correlationThreeBodyCond, chipNr)) {
2948  edm::LogError("TriggerMenuParser") << " Error: duplicate correlation condition (" << name << ")" << std::endl;
2949  return false;
2950  }
2951 
2952  // Define some of the quantities to store the parsed information
2953  GtConditionType cType = l1t::Type3s;
2954 
2955  // three objects (for sure)
2956  const int nrObj = 3;
2957 
2958  // object types and greater equal flag - filled in the loop
2959  std::vector<GlobalObject> objType(nrObj);
2960  std::vector<GtConditionCategory> condCateg(nrObj);
2961 
2962  // correlation flag and index in the cor*vector
2963  const bool corrFlag = true;
2964  int corrIndexVal[nrObj] = {-1, -1, -1};
2965 
2966  // Storage of the correlation selection
2968  // Set charge correlation parameter
2969  //corrThreeBodyParameter.chargeCorrelation = chargeCorrelation; //tmpValues[0];
2970  //corrThreeBodyParameter.chargeCorrelation = 1; //ignore charge correlation for corr-legs
2971 
2972  // Get the correlation cuts on the legs
2973  int cutType = 0;
2974  const std::vector<L1TUtmCut>& cuts = corrCond.getCuts();
2975  for (size_t lll = 0; lll < cuts.size(); lll++) { // START esCut lll
2976  const L1TUtmCut& cut = cuts.at(lll);
2977 
2978  if (cut.getCutType() == esCutType::ChargeCorrelation) {
2979  if (cut.getData() == "ls")
2980  corrThreeBodyParameter.chargeCorrelation = 2;
2981  else if (cut.getData() == "os")
2982  corrThreeBodyParameter.chargeCorrelation = 4;
2983  else
2984  corrThreeBodyParameter.chargeCorrelation = 1; //ignore charge correlation
2985  }
2986 
2987  //
2988  // Until utm has method to calculate these, do the integer value calculation with precision.
2989  //
2990  double minV = cut.getMinimum().value;
2991  double maxV = cut.getMaximum().value;
2992  //Scale down very large numbers out of xml
2993  if (maxV > 1.0e8)
2994  maxV = 1.0e8;
2995 
2996  if (cut.getCutType() == esCutType::Mass) {
2997  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tMass Cut minV = " << minV
2998  << "\tMass Cut maxV = " << maxV << " precMin = " << cut.getMinimum().index
2999  << " precMax = " << cut.getMaximum().index << std::endl;
3000  corrThreeBodyParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3001  corrThreeBodyParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3002  corrThreeBodyParameter.precMassCut = cut.getMinimum().index;
3003  cutType = cutType | 0x8;
3004  } else if (cut.getCutType() == esCutType::MassDeltaR) {
3005  corrThreeBodyParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3006  corrThreeBodyParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3007  corrThreeBodyParameter.precMassCut = cut.getMinimum().index;
3008  cutType = cutType | 0x80;
3009  }
3010  } // END esCut lll
3011  corrThreeBodyParameter.corrCutType = cutType;
3012 
3013  // Get the three objects that form the legs
3014  const std::vector<L1TUtmObject>& objects = corrCond.getObjects();
3015  if (objects.size() != 3) {
3016  edm::LogError("TriggerMenuParser") << "incorrect number of objects for the correlation condition " << name
3017  << " corrFlag " << corrFlag << std::endl;
3018  return false;
3019  }
3020 
3021  // Loop over legs
3022  for (size_t lll = 0; lll < objects.size(); lll++) {
3023  const L1TUtmObject& object = objects.at(lll);
3024  LogDebug("TriggerMenuParser") << " obj name = " << object.getName() << "\n";
3025  LogDebug("TriggerMenuParser") << " obj type = " << object.getType() << "\n";
3026  LogDebug("TriggerMenuParser") << " obj bx = " << object.getBxOffset() << "\n";
3027 
3028  // check the leg type
3029  if (object.getType() == esObjectType::Muon) {
3030  // we have a muon
3031  parseMuonCorr(&object, chipNr);
3032  corrIndexVal[lll] = (m_corMuonTemplate[chipNr]).size() - 1;
3033 
3034  //Now set some flags for this subCondition
3035  objType[lll] = gtMu;
3036  condCateg[lll] = CondMuon;
3037 
3038  } else {
3039  edm::LogError("TriggerMenuParser") << "Checked the object Type " << object.getType()
3040  << " for the correlation condition " << name
3041  << ": no three muons in the event!" << std::endl;
3042  }
3043  } // End loop over legs
3044 
3045  // fill the three-body correlation condition
3046  correlationThreeBodyCond.setCondType(cType);
3047  correlationThreeBodyCond.setObjectType(objType);
3048  correlationThreeBodyCond.setCondChipNr(chipNr);
3049 
3050  correlationThreeBodyCond.setCond0Category(condCateg[0]);
3051  correlationThreeBodyCond.setCond1Category(condCateg[1]);
3052  correlationThreeBodyCond.setCond2Category(condCateg[2]);
3053 
3054  correlationThreeBodyCond.setCond0Index(corrIndexVal[0]);
3055  correlationThreeBodyCond.setCond1Index(corrIndexVal[1]);
3056  correlationThreeBodyCond.setCond2Index(corrIndexVal[2]);
3057 
3058  correlationThreeBodyCond.setCorrelationThreeBodyParameter(corrThreeBodyParameter);
3059 
3060  if (edm::isDebugEnabled()) {
3061  std::ostringstream myCoutStream;
3062  correlationThreeBodyCond.print(myCoutStream);
3063  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
3064  }
3065 
3066  // insert condition into the map
3067  // condition is not duplicate, check was done at the beginning
3068 
3069  (m_vecCorrelationThreeBodyTemplate[chipNr]).push_back(correlationThreeBodyCond);
3070 
3071  //
3072  return true;
3073 }
3074 
3076 
3089  using namespace tmeventsetup;
3090  std::string condition = "corrWithOverlapRemoval";
3091  std::string particle = "test-fix";
3092  std::string type = l1t2string(corrCond.getType());
3093  std::string name = l1t2string(corrCond.getName());
3094 
3095  LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
3096  << " (in parseCorrelationWithOverlapRemoval) " << std::endl
3097  << " condition = " << condition << std::endl
3098  << " particle = " << particle << std::endl
3099  << " type = " << type << std::endl
3100  << " name = " << name << std::endl;
3101 
3102  // create a new correlation condition
3103  CorrelationWithOverlapRemovalTemplate correlationWORCond(name);
3104 
3105  // check that the condition does not exist already in the map
3106  if (!insertConditionIntoMap(correlationWORCond, chipNr)) {
3107  edm::LogError("TriggerMenuParser") << " Error: duplicate correlation condition (" << name << ")" << std::endl;
3108 
3109  return false;
3110  }
3111 
3112  // Define some of the quantities to store the parased information
3113 
3114  // condition type BLW (Do we change this to the type of correlation condition?)
3116 
3117  // three objects (for sure)
3118  const int nrObj = 3;
3119 
3120  // object types and greater equal flag - filled in the loop
3121  int intGEq[nrObj] = {-1, -1, -1};
3122  std::vector<GlobalObject> objType(nrObj); //BLW do we want to define these as a different type?
3123  std::vector<GtConditionCategory> condCateg(nrObj); //BLW do we want to change these categories
3124 
3125  // correlation flag and index in the cor*vector
3126  const bool corrFlag = true;
3127  int corrIndexVal[nrObj] = {-1, -1, -1};
3128 
3129  // Storage of the correlation selection
3131  corrParameter.chargeCorrelation = 1; //ignore charge correlation for corr-legs
3132 
3133  // Get the correlation Cuts on the legs
3134  int cutType = 0;
3135  const std::vector<L1TUtmCut>& cuts = corrCond.getCuts();
3136  for (size_t jj = 0; jj < cuts.size(); jj++) {
3137  const L1TUtmCut& cut = cuts.at(jj);
3138 
3139  if (cut.getCutType() == esCutType::ChargeCorrelation) {
3140  if (cut.getData() == "ls")
3141  corrParameter.chargeCorrelation = 2;
3142  else if (cut.getData() == "os")
3143  corrParameter.chargeCorrelation = 4;
3144  else
3145  corrParameter.chargeCorrelation = 1; //ignore charge correlation
3146  } else {
3147  //
3148  // Unitl utm has method to calculate these, do the integer value calculation with precision.
3149  //
3150  double minV = cut.getMinimum().value;
3151  double maxV = cut.getMaximum().value;
3152 
3153  //Scale down very large numbers out of xml
3154  if (maxV > 1.0e8)
3155  maxV = 1.0e8;
3156 
3157  if (cut.getCutType() == esCutType::DeltaEta) {
3158  //std::cout << "DeltaEta Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3159  corrParameter.minEtaCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3160  corrParameter.maxEtaCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3161  corrParameter.precEtaCut = cut.getMinimum().index;
3162  cutType = cutType | 0x1;
3163  } else if (cut.getCutType() == esCutType::DeltaPhi) {
3164  //std::cout << "DeltaPhi Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3165  corrParameter.minPhiCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3166  corrParameter.maxPhiCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3167  corrParameter.precPhiCut = cut.getMinimum().index;
3168  cutType = cutType | 0x2;
3169  } else if (cut.getCutType() == esCutType::DeltaR) {
3170  //std::cout << "DeltaR Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3171  corrParameter.minDRCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3172  corrParameter.maxDRCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3173  corrParameter.precDRCut = cut.getMinimum().index;
3174  cutType = cutType | 0x4;
3175  } else if (cut.getCutType() == esCutType::Mass) {
3176  //std::cout << "Mass Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3177  corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3178  corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3179  corrParameter.precMassCut = cut.getMinimum().index;
3180  cutType = cutType | 0x8;
3181  } else if (cut.getCutType() == esCutType::MassDeltaR) {
3182  corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3183  corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3184  corrParameter.precMassCut = cut.getMinimum().index;
3185  cutType = cutType | 0x80;
3186  }
3187  if (cut.getCutType() == esCutType::OvRmDeltaEta) {
3188  //std::cout << "OverlapRemovalDeltaEta Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3189  corrParameter.minOverlapRemovalEtaCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3190  corrParameter.maxOverlapRemovalEtaCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3191  corrParameter.precOverlapRemovalEtaCut = cut.getMinimum().index;
3192  cutType = cutType | 0x10;
3193  } else if (cut.getCutType() == esCutType::OvRmDeltaPhi) {
3194  //std::cout << "OverlapRemovalDeltaPhi Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3195  corrParameter.minOverlapRemovalPhiCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3196  corrParameter.maxOverlapRemovalPhiCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3197  corrParameter.precOverlapRemovalPhiCut = cut.getMinimum().index;
3198  cutType = cutType | 0x20;
3199  } else if (cut.getCutType() == esCutType::OvRmDeltaR) {
3200  //std::cout << "DeltaR Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3201  corrParameter.minOverlapRemovalDRCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3202  corrParameter.maxOverlapRemovalDRCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3203  corrParameter.precOverlapRemovalDRCut = cut.getMinimum().index;
3204  cutType = cutType | 0x40;
3205  }
3206  }
3207  }
3208  corrParameter.corrCutType = cutType;
3209 
3210  // Get the two objects that form the legs
3211  const std::vector<L1TUtmObject>& objects = corrCond.getObjects();
3212  if (objects.size() != 3) {
3213  edm::LogError("TriggerMenuParser")
3214  << "incorrect number of objects for the correlation condition with overlap removal " << name << " corrFlag "
3215  << corrFlag << std::endl;
3216  return false;
3217  }
3218 
3219  // Loop over legs
3220  for (size_t jj = 0; jj < objects.size(); jj++) {
3221  const L1TUtmObject& object = objects.at(jj);
3222  LogDebug("TriggerMenuParser") << " obj name = " << object.getName() << "\n";
3223  LogDebug("TriggerMenuParser") << " obj type = " << object.getType() << "\n";
3224  LogDebug("TriggerMenuParser") << " obj op = " << object.getComparisonOperator() << "\n";
3225  LogDebug("TriggerMenuParser") << " obj bx = " << object.getBxOffset() << "\n";
3226  LogDebug("TriggerMenuParser") << "type = done" << std::endl;
3227 
3228  // check the leg type
3229  if (object.getType() == esObjectType::Muon) {
3230  // we have a muon
3231 
3232  /*
3233  //BLW Hold on to this code we may need to go back to it at some point.
3234  // Now we are putting ALL leg conditions into the vector (so there are duplicates)
3235  // This is potentially a place to slim down the code. Note: We currently evaluate the
3236  // conditions every time, so even if we put the condition in the vector once, we would
3237  // still evaluate it multiple times. This is a place for optimization.
3238  {
3239 
3240  parseMuonCorr(&object,chipNr);
3241  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
3242 
3243  } else {
3244  LogDebug("TriggerMenuParser") << "Not Adding Correlation Muon Condition to Map...looking for the condition in Muon Cor Vector" << std::endl;
3245  bool found = false;
3246  int index = 0;
3247  while(!found && index<(int)((m_corMuonTemplate[chipNr]).size()) ) {
3248  if( (m_corMuonTemplate[chipNr]).at(index).condName() == object.getName() ) {
3249  LogDebug("TriggerMenuParser") << "Found condition " << object.getName() << " in vector at index " << index << std::endl;
3250  found = true;
3251  } else {
3252  index++;
3253  }
3254  }
3255  if(found) {
3256  corrIndexVal[jj] = index;
3257  } else {
3258  edm::LogError("TriggerMenuParser") << "FAILURE: Condition " << object.getName() << " is in map but not in cor. vector " << std::endl;
3259  }
3260 
3261  }
3262 */
3263  parseMuonCorr(&object, chipNr);
3264  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
3265 
3266  //Now set some flags for this subCondition
3267  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3268  objType[jj] = gtMu;
3269  condCateg[jj] = CondMuon;
3270 
3271  } else if (object.getType() == esObjectType::Egamma || object.getType() == esObjectType::Jet ||
3272  object.getType() == esObjectType::Tau) {
3273  // we have an Calo object
3274  parseCaloCorr(&object, chipNr);
3275  corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
3276 
3277  //Now set some flags for this subCondition
3278  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3279  switch (object.getType()) {
3280  case esObjectType::Egamma: {
3281  objType[jj] = gtEG;
3282  } break;
3283  case esObjectType::Jet: {
3284  objType[jj] = gtJet;
3285  } break;
3286  case esObjectType::Tau: {
3287  objType[jj] = gtTau;
3288  } break;
3289  default: {
3290  } break;
3291  }
3292  condCateg[jj] = CondCalo;
3293 
3294  } else if (object.getType() == esObjectType::ETM || object.getType() == esObjectType::ETMHF ||
3295  object.getType() == esObjectType::TOWERCOUNT || object.getType() == esObjectType::HTM) {
3296  // we have Energy Sum
3297  parseEnergySumCorr(&object, chipNr);
3298  corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
3299 
3300  //Now set some flags for this subCondition
3301  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3302  switch (object.getType()) {
3303  case esObjectType::ETM: {
3305  } break;
3306  case esObjectType::HTM: {
3308  } break;
3309  case esObjectType::ETMHF: {
3311  } break;
3312  case esObjectType::TOWERCOUNT: {
3314  } break;
3315  default: {
3316  } break;
3317  }
3318  condCateg[jj] = CondEnergySum;
3319 
3320  } else {
3321  edm::LogError("TriggerMenuParser") << "Illegal Object Type " << object.getType()
3322  << " for the correlation condition " << name << std::endl;
3323  return false;
3324 
3325  } //if block on leg types
3326 
3327  } //loop over legs
3328 
3329  // get greater equal flag for the correlation condition
3330  bool gEq = true;
3331  if (intGEq[0] != intGEq[1]) {
3332  edm::LogError("TriggerMenuParser") << "Inconsistent GEq flags for sub-conditions "
3333  << " for the correlation condition " << name << std::endl;
3334  return false;
3335 
3336  } else {
3337  gEq = (intGEq[0] != 0);
3338  }
3339 
3340  // fill the correlation condition
3341  correlationWORCond.setCondType(cType);
3342  correlationWORCond.setObjectType(objType);
3343  correlationWORCond.setCondGEq(gEq);
3344  correlationWORCond.setCondChipNr(chipNr);
3345 
3346  correlationWORCond.setCond0Category(condCateg[0]);
3347  correlationWORCond.setCond1Category(condCateg[1]);
3348  correlationWORCond.setCond2Category(condCateg[2]);
3349 
3350  correlationWORCond.setCond0Index(corrIndexVal[0]);
3351  correlationWORCond.setCond1Index(corrIndexVal[1]);
3352  correlationWORCond.setCond2Index(corrIndexVal[2]);
3353 
3354  correlationWORCond.setCorrelationWithOverlapRemovalParameter(corrParameter);
3355 
3356  if (edm::isDebugEnabled()) {
3357  std::ostringstream myCoutStream;
3358  correlationWORCond.print(myCoutStream);
3359  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
3360  }
3361 
3362  // insert condition into the map
3363  // condition is not duplicate, check was done at the beginning
3364 
3365  (m_vecCorrelationWithOverlapRemovalTemplate[chipNr]).push_back(correlationWORCond);
3366 
3367  //
3368  return true;
3369 }
3370 
3383  // get alias
3384  std::string algAlias = algorithm.getName();
3385  const std::string& algName = algorithm.getName();
3386 
3387  if (algAlias.empty()) {
3388  algAlias = algName;
3389  LogDebug("TriggerMenuParser") << "\n No alias defined for algorithm. Alias set to algorithm name."
3390  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3391  << std::endl;
3392  } else {
3393  //LogDebug("TriggerMenuParser")
3394  LogDebug("TriggerMenuParser") << "\n Alias defined for algorithm."
3395  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3396  << std::endl;
3397  }
3398 
3399  // get the logical expression
3400  const std::string& logExpression = algorithm.getExpressionInCondition();
3401 
3402  LogDebug("TriggerMenuParser") << " Logical expression: " << logExpression
3403  << " Chip number: " << chipNr << std::endl;
3404 
3405  // determine output pin
3406  int outputPin = algorithm.getIndex();
3407 
3408  //LogTrace("TriggerMenuParser")
3409  LogDebug("TriggerMenuParser") << " Output pin: " << outputPin << std::endl;
3410 
3411  // compute the bit number from chip number, output pin and order of the chips
3412  // pin numbering start with 1, bit numbers with 0
3413  int bitNumber = outputPin; // + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
3414 
3415  //LogTrace("TriggerMenuParser")
3416  LogDebug("TriggerMenuParser") << " Bit number: " << bitNumber << std::endl;
3417 
3418  // create a new algorithm and insert it into algorithm map
3419  GlobalAlgorithm alg(algName, logExpression, bitNumber);
3420  alg.setAlgoChipNumber(static_cast<int>(chipNr));
3421  alg.setAlgoAlias(algAlias);
3422 
3423  if (edm::isDebugEnabled()) {
3424  std::ostringstream myCoutStream;
3425  alg.print(myCoutStream);
3426  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
3427  }
3428 
3429  // insert algorithm into the map
3430  if (!insertAlgorithmIntoMap(alg)) {
3431  return false;
3432  }
3433 
3434  return true;
3435 }
3436 // static class members
size
Write out results.
void setGtTriggerMenuName(const std::string &)
constexpr int32_t ceil(float num)
bool isDebugEnabled()
void setCondGEq(const bool &cGEq)
const std::string & getName() const
bool parseAlgorithm(L1TUtmAlgorithm algorithm, unsigned int chipNr=0)
parse all algorithms
const std::string & getComment() const
void setAlgoAlias(const std::string &algoAliasValue)
void setGtScaleDbKey(const std::string &)
const int getType() const
const std::vector< L1TUtmCut > & getCuts() const
Definition: L1TUtmObject.h:118
void parseCalMuEta_LUTS(std::map< std::string, tmeventsetup::esScale > scaleMap, std::string obj1, std::string obj2)
void parseCalMuPhi_LUTS(std::map< std::string, tmeventsetup::esScale > scaleMap, std::string obj1, std::string obj2)
void setGtOrderConditionChip(const std::vector< int > &)
int algoBitNumber() const
get / set algorithm bit number
Definition: L1GtObject.h:38
void parseUpt_LUTS(std::map< std::string, tmeventsetup::esScale > scaleMap, std::string lutpfx, std::string obj1, unsigned int prec)
void setCorrelationThreeBodyParameter(const CorrelationThreeBodyParameter &corrThreeBodyParameter)
bool parseEnergySumCorr(const L1TUtmObject *corrESum, unsigned int chipNr=0)
void setCond0Index(const int &)
void print(std::ostream &myCout) const override
print the condition
void parseDeltaPhi_Cos_LUTS(const std::map< std::string, tmeventsetup::esScale > &scaleMap, const std::string &obj1, const std::string &obj2, unsigned int prec1, unsigned int prec2)
Definition: L1GtObject.h:35
bool parseExternal(L1TUtmCondition condExt, unsigned int chipNr=0)
const int algoOutputPin(const int numberConditionChips, const int pinsOnConditionChip, const std::vector< int > &orderConditionChip) const
get the output pin on the condition chip for the algorithm
void setCondType(const l1t::GtConditionType &cType)
void setConditionParameter(const std::vector< ObjectParameter > &objParameter)
set functions
void setCorrelationParameter(const CorrelationParameter &corrParameter)
void setGtAlgorithmMap(const AlgorithmMap &)
const std::vector< L1TUtmObject > & getObjects() const
void print(std::ostream &myCout) const override
print the condition
void setVecCaloTemplate(const std::vector< std::vector< CaloTemplate > > &)
virtual ~TriggerMenuParser()
destructor
std::map< std::string, unsigned int > getExternalSignals(const L1TUtmTriggerMenu *utmMenu)
const std::string & getScaleSetName() const
Log< level::Error, false > LogError
const int getComparisonOperator() const
Definition: L1TUtmObject.h:103
const std::string & getName() const
Definition: L1TUtmObject.h:97
void setCondRelativeBx(const int &cRelativeBx)
const std::map< std::string, L1TUtmScale > & getScaleMap() const
std::vector< std::pair< double, double > > phiBins
Definition: GlobalScales.h:50
void setCond0Category(const l1t::GtConditionCategory &)
void print(std::ostream &myCout) const override
print the condition
void setCondChipNr(const int &cChipNr)
#define LogTrace(id)
void setVecEnergySumTemplate(const std::vector< std::vector< EnergySumTemplate > > &)
void setVecCorrelationTemplate(const std::vector< std::vector< CorrelationTemplate > > &)
const int algoChipNumber() const
get / set algorithm bit number
void print(std::ostream &myCout) const override
print the condition
Definition: MuonTemplate.cc:71
Definition: L1GtObject.h:37
void setCorrelationWithOverlapRemovalParameter(const CorrelationWithOverlapRemovalParameter &corrParameter)
void setVecMuonTemplate(const std::vector< std::vector< MuonTemplate > > &)
bool parseMuonShower(L1TUtmCondition condMu, unsigned int chipNr=0, const bool corrFlag=false)
parse a muon shower condition
const int getBxOffset() const
Definition: L1TUtmObject.h:106
void setCond0Category(const l1t::GtConditionCategory &)
void setGtAlgorithmAliasMap(const AlgorithmMap &)
void setGtPinsOnConditionChip(const unsigned int &)
void setGtAlgorithmImplementation(const std::string &)
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
void setExternalChannel(unsigned int extCh)
set functions
bool parseCorrelationWithOverlapRemoval(const L1TUtmCondition &corrCond, unsigned int chipNr=0)
parse a correlation condition with overlap removal
void parseCondFormats(const L1TUtmTriggerMenu *utmMenu)
void parseDeltaEta_Cosh_LUTS(std::map< std::string, tmeventsetup::esScale > scaleMap, std::string obj1, std::string obj2, unsigned int prec1, unsigned int prec2)
virtual void print(std::ostream &myCout) const
print condition
const int getType() const
Definition: L1TUtmObject.h:100
void setGtTriggerMenuInterface(const std::string &)
void setCond1Category(const l1t::GtConditionCategory &)
void setGtTriggerMenuAuthor(const std::string &)
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:643
void setConditionParameter(const std::vector< ObjectParameter > &objParameter, const CorrelationParameter &corrParameter)
set functions
Definition: CaloTemplate.cc:63
const std::map< std::string, L1TUtmCondition > & getConditionMap() const
void setGtTriggerMenuInterfaceDescription(const std::string &)
const std::string & getName() const
void setVecCorrelationThreeBodyTemplate(const std::vector< std::vector< CorrelationThreeBodyTemplate > > &)
bool insertConditionIntoMap(GlobalCondition &cond, const int chipNr)
void setObjectType(const std::vector< l1t::GlobalObject > &objType)
void setCond1Category(const l1t::GtConditionCategory &)
ii
Definition: cuy.py:589
void setGtTriggerMenuDate(const std::string &)
bool parseMuonCorr(const L1TUtmObject *condMu, unsigned int chipNr=0)
void setCond2Category(const l1t::GtConditionCategory &)
bool parseMuon(L1TUtmCondition condMu, unsigned int chipNr=0, const bool corrFlag=false)
parse a muon condition
bool parseScales(std::map< std::string, tmeventsetup::esScale > scaleMap)
parse scales
const std::string & getFirmwareUuid() const
void setVecExternalTemplate(const std::vector< std::vector< ExternalTemplate > > &)
bool parseCaloCorr(const L1TUtmObject *corrCalo, unsigned int chipNr=0)
void setGtTriggerMenuDescription(const std::string &)
void setCorMuonTemplate(const std::vector< std::vector< MuonTemplate > > &)
void setCorEnergySumTemplate(const std::vector< std::vector< EnergySumTemplate > > &)
void setCond0Category(const l1t::GtConditionCategory &)
void setGtNumberConditionChips(const unsigned int &)
void print(std::ostream &myCout) const override
print the condition
void print(std::ostream &myCout) const override
print the condition
Definition: CaloTemplate.cc:69
const std::vector< L1TUtmCut > & getCuts() const
int l1tstr2int(const std::string data)
std::vector< std::pair< double, double > > etBins
Definition: GlobalScales.h:39
bool parseCalo(L1TUtmCondition condCalo, unsigned int chipNr=0, const bool corrFlag=false)
parse a calorimeter condition
void setAlgoChipNumber(const int algoChipNumberValue)
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
bool parseCorrelation(L1TUtmCondition corrCond, unsigned int chipNr=0)
parse a correlation condition
typedef for a single object template
Definition: GlobalScales.h:35
void setConditionParameter(const std::vector< ObjectParameter > &objParameter, const CorrelationParameter &corrParameter)
set functions
Definition: MuonTemplate.cc:65
void setGtTriggerMenuUUID(const int)
Definition: L1GtObject.h:36
typedef for correlation parameters
Definition: CaloTemplate.h:88
Definition: plugin.cc:23
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void setVecMuonShowerTemplate(const std::vector< std::vector< MuonShowerTemplate > > &)
std::string const & algoAlias() const
get / set algorithm alias
std::vector< std::pair< double, double > > uptBins
Definition: GlobalScales.h:45
void setCorCaloTemplate(const std::vector< std::vector< CaloTemplate > > &)
void setVecCorrelationWithOverlapRemovalTemplate(const std::vector< std::vector< CorrelationWithOverlapRemovalTemplate > > &)
void setGtTriggerMenuInterfaceDate(const std::string &)
void setGtTriggerMenuImplementation(const unsigned long &)
step
Definition: StallMonitor.cc:98
void print(std::ostream &myCout) const override
print the condition
const std::map< std::string, L1TUtmAlgorithm > & getAlgorithmMap() const
void setCond1Category(const l1t::GtConditionCategory &)
const std::string & getVersion() const
bool insertAlgorithmIntoMap(const GlobalAlgorithm &alg)
insert an algorithm into algorithm map
typedef for correlation parameters
long double T
void setCond2Category(const l1t::GtConditionCategory &)
bool parseEnergySum(L1TUtmCondition condEnergySums, unsigned int chipNr=0, const bool corrFlag=false)
parse an "energy sum" condition
void setGtConditionMap(const std::vector< ConditionMap > &)
std::map< std::string, GlobalAlgorithm > AlgorithmMap
map containing the algorithms
bool parseCorrelationThreeBody(L1TUtmCondition corrCond, unsigned int chipNr=0)
parse a three-body correlation condition
void parsePhi_Trig_LUTS(const std::map< std::string, tmeventsetup::esScale > &scaleMap, const std::string &obj, TrigFunc_t func, unsigned int prec)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
void setConditionParameter(const std::vector< ObjectParameter > &)
set functions
const std::string algoName() const
get / set algorithm name
void setGtTriggerMenuInterfaceAuthor(const std::string &)
std::vector< std::pair< double, double > > etaBins
Definition: GlobalScales.h:55
void parsePt_LUTS(std::map< std::string, tmeventsetup::esScale > scaleMap, std::string lutpfx, std::string obj1, unsigned int prec)
const std::string & getDatetime() const
void setCond1Index(const int &)
void setGtNumberPhysTriggers(const unsigned int &)
#define LogDebug(id)