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