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