CMS 3D CMS Logo

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