CMS 3D CMS Logo

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