CMS 3D CMS Logo

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