CMS 3D CMS Logo

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