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  parsePt_LUTS(scaleMap, "Mass" ,"ETM", precisions["PRECISION-EG-ETM-MassPt"] );
786  parsePt_LUTS(scaleMap, "Mass" ,"ETMHF", precisions["PRECISION-EG-ETMHF-MassPt"] );
787  parsePt_LUTS(scaleMap, "Mass" ,"HTM", precisions["PRECISION-EG-HTM-MassPt"] );
788 
789  // Now the Pt LUTs for TBPT calculation (??? CCLA following what was done for MASS pt LUTs for now ??)
790  // ---------------
791  parsePt_LUTS(scaleMap,"TwoBody" ,"EG", precisions["PRECISION-EG-MU-TwoBodyPt"] );
792  parsePt_LUTS(scaleMap,"TwoBody" ,"MU", precisions["PRECISION-EG-MU-TwoBodyPt"] );
793  parsePt_LUTS(scaleMap,"TwoBody" ,"JET", precisions["PRECISION-EG-JET-TwoBodyPt"] );
794  parsePt_LUTS(scaleMap,"TwoBody" ,"TAU", precisions["PRECISION-EG-TAU-TwoBodyPt"] );
795  parsePt_LUTS(scaleMap,"TwoBody" ,"ETM", precisions["PRECISION-EG-ETM-TwoBodyPt"] );
796  parsePt_LUTS(scaleMap,"TwoBody" ,"ETMHF", precisions["PRECISION-EG-ETMHF-TwoBodyPt"] );
797  parsePt_LUTS(scaleMap,"TwoBody" ,"HTM", precisions["PRECISION-EG-HTM-TwoBodyPt"] );
798 
799 
800 
801  // Now the Delta Eta/Cosh LUTs (must be done in groups)
802  // ----------------------------------------------------
803  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
804  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","JET",precisions["PRECISION-EG-JET-Delta"],precisions["PRECISION-EG-JET-Math"]);
805  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","TAU",precisions["PRECISION-EG-TAU-Delta"],precisions["PRECISION-EG-TAU-Math"]);
806  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
807 
808  parseDeltaEta_Cosh_LUTS(scaleMap,"JET","JET",precisions["PRECISION-JET-JET-Delta"],precisions["PRECISION-JET-JET-Math"]);
809  parseDeltaEta_Cosh_LUTS(scaleMap,"JET","TAU",precisions["PRECISION-JET-TAU-Delta"],precisions["PRECISION-JET-TAU-Math"]);
810  parseDeltaEta_Cosh_LUTS(scaleMap,"JET","MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
811 
812  parseDeltaEta_Cosh_LUTS(scaleMap,"TAU","TAU",precisions["PRECISION-TAU-TAU-Delta"],precisions["PRECISION-TAU-TAU-Math"]);
813  parseDeltaEta_Cosh_LUTS(scaleMap,"TAU","MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
814 
815  parseDeltaEta_Cosh_LUTS(scaleMap,"MU","MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
816 
817 
818  // Now the Delta Phi/Cos LUTs (must be done in groups)
819  // ----------------------------------------------------
820  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
821  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","JET",precisions["PRECISION-EG-JET-Delta"],precisions["PRECISION-EG-JET-Math"]);
822  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","TAU",precisions["PRECISION-EG-TAU-Delta"],precisions["PRECISION-EG-TAU-Math"]);
823  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","ETM",precisions["PRECISION-EG-ETM-Delta"],precisions["PRECISION-EG-ETM-Math"]);
824  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","ETMHF",precisions["PRECISION-EG-ETMHF-Delta"],precisions["PRECISION-EG-ETMHF-Math"]);
825  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","HTM",precisions["PRECISION-EG-HTM-Delta"],precisions["PRECISION-EG-HTM-Math"]);
826  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
827 
828  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","JET",precisions["PRECISION-JET-JET-Delta"],precisions["PRECISION-JET-JET-Math"]);
829  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","TAU",precisions["PRECISION-JET-TAU-Delta"],precisions["PRECISION-JET-TAU-Math"]);
830  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","ETM",precisions["PRECISION-JET-ETM-Delta"],precisions["PRECISION-JET-ETM-Math"]);
831  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","ETMHF",precisions["PRECISION-JET-ETMHF-Delta"],precisions["PRECISION-JET-ETMHF-Math"]);
832  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","HTM",precisions["PRECISION-JET-HTM-Delta"],precisions["PRECISION-JET-HTM-Math"]);
833  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
834 
835  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","TAU",precisions["PRECISION-TAU-TAU-Delta"],precisions["PRECISION-TAU-TAU-Math"]);
836  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","ETM",precisions["PRECISION-TAU-ETM-Delta"],precisions["PRECISION-TAU-ETM-Math"]);
837  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","ETMHF",precisions["PRECISION-TAU-ETMHF-Delta"],precisions["PRECISION-TAU-ETMHF-Math"]);
838  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","HTM",precisions["PRECISION-TAU-HTM-Delta"],precisions["PRECISION-TAU-HTM-Math"]);
839  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
840 
841  parseDeltaPhi_Cos_LUTS(scaleMap,"MU","ETM",precisions["PRECISION-MU-ETM-Delta"],precisions["PRECISION-MU-ETM-Math"]);
842  parseDeltaPhi_Cos_LUTS(scaleMap,"MU","ETMHF",precisions["PRECISION-MU-ETMHF-Delta"],precisions["PRECISION-MU-ETMHF-Math"]);
843  parseDeltaPhi_Cos_LUTS(scaleMap,"MU","HTM",precisions["PRECISION-MU-HTM-Delta"],precisions["PRECISION-MU-HTM-Math"]);
844  parseDeltaPhi_Cos_LUTS(scaleMap,"MU","MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
845 
846  parsePhi_Trig_LUTS(scaleMap,"EG", l1t::COS , precisions["PRECISION-EG-EG-Math"]);
847  parsePhi_Trig_LUTS(scaleMap,"JET", l1t::COS , precisions["PRECISION-JET-JET-Math"]);
848  parsePhi_Trig_LUTS(scaleMap,"TAU", l1t::COS , precisions["PRECISION-TAU-TAU-Math"]);
849  parsePhi_Trig_LUTS(scaleMap,"MU", l1t::COS , precisions["PRECISION-MU-MU-Math"]);
850 
851  parsePhi_Trig_LUTS(scaleMap,"EG", l1t::SIN , precisions["PRECISION-EG-EG-Math"]);
852  parsePhi_Trig_LUTS(scaleMap,"JET", l1t::SIN , precisions["PRECISION-JET-JET-Math"]);
853  parsePhi_Trig_LUTS(scaleMap,"TAU", l1t::SIN , precisions["PRECISION-TAU-TAU-Math"]);
854  parsePhi_Trig_LUTS(scaleMap,"MU", l1t::SIN , precisions["PRECISION-MU-MU-Math"]);
855 
856 
857  //CCLA
858  //m_gtScales.dumpAllLUTs(std::cout);
859  //m_gtScales.print(std::cout);
860 
861  }
862 
863 
864 
865 
866 
867  return true;
868 }
869 
870 void l1t::TriggerMenuParser::parseCalMuEta_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string obj1, std::string obj2)
871 {
872 
873  using namespace tmeventsetup;
874 
875  // First Delta Eta for this set
876  std::string scLabel1 = obj1;
877  scLabel1 += "-ETA";
878  std::string scLabel2 = obj2;
879  scLabel2 += "-ETA";
880 
881  //This LUT does not exist in L1 Menu file, don't fill it
882  if( scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end()) return;
883 
884  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
885  const esScale* scale2 = &scaleMap.find(scLabel2)->second;
886 
887  std::vector<long long> lut_cal_2_mu_eta;
888  getCaloMuonEtaConversionLut(lut_cal_2_mu_eta, scale1, scale2);
889 
890  std::string lutName = obj1;
891  lutName += "-";
892  lutName += obj2;
893  m_gtScales.setLUT_CalMuEta(lutName,lut_cal_2_mu_eta);
894 
895 
896 }
897 
898 void l1t::TriggerMenuParser::parseCalMuPhi_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string obj1, std::string obj2)
899 {
900 
901  using namespace tmeventsetup;
902 
903  // First Delta Eta for this set
904  std::string scLabel1 = obj1;
905  scLabel1 += "-PHI";
906  std::string scLabel2 = obj2;
907  scLabel2 += "-PHI";
908 
909  //This LUT does not exist in L1 Menu file, don't fill it
910  if( scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end()) return;
911 
912  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
913  const esScale* scale2 = &scaleMap.find(scLabel2)->second;
914 
915 
916  std::vector<long long> lut_cal_2_mu_phi;
917  getCaloMuonPhiConversionLut(lut_cal_2_mu_phi, scale1, scale2);
918 
919  std::string lutName = obj1;
920  lutName += "-";
921  lutName += obj2;
922  m_gtScales.setLUT_CalMuPhi(lutName,lut_cal_2_mu_phi);
923 
924 
925 }
926 
927 void l1t::TriggerMenuParser::parsePt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string lutpfx, std::string obj1, unsigned int prec)
928 {
929 
930  using namespace tmeventsetup;
931 
932  // First Delta Eta for this set
933  std::string scLabel1 = obj1;
934  scLabel1 += "-ET";
935 
936  //This LUT does not exist in L1 Menu file, don't fill it
937  if( scaleMap.find(scLabel1) == scaleMap.end()) return;
938 
939  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
940 
941  std::vector<long long> lut_pt;
942  getLut(lut_pt, scale1, prec);
943 
944  m_gtScales.setLUT_Pt(lutpfx + "_" + scLabel1,lut_pt,prec);
945 
946 
947 }
948 
949 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)
950 {
951 
952  using namespace tmeventsetup;
953 
954  // First Delta Eta for this set
955  std::string scLabel1 = obj1;
956  scLabel1 += "-ETA";
957  std::string scLabel2 = obj2;
958  scLabel2 += "-ETA";
959 
960  //This LUT does not exist in L1 Menu file, don't fill it
961  if( scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end()) return;
962 
963  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
964  const esScale* scale2 = &scaleMap.find(scLabel2)->second;
965  std::vector<double> val_delta_eta;
966  std::vector<long long> lut_delta_eta;
967  size_t n = getDeltaVector(val_delta_eta, scale1, scale2);
968  setLut(lut_delta_eta, val_delta_eta, prec1);
969  std::string lutName = obj1;
970  lutName += "-";
971  lutName += obj2;
972  m_gtScales.setLUT_DeltaEta(lutName,lut_delta_eta,prec1);
973 
974  // Second Get the Cosh for this delta Eta Set
975  std::vector<long long> lut_cosh;
976  applyCosh(val_delta_eta, n);
977  setLut(lut_cosh, val_delta_eta, prec2);
978  m_gtScales.setLUT_Cosh(lutName,lut_cosh,prec2);
979 
980 }
981 
982 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)
983 {
984 
985  using namespace tmeventsetup;
986 
987  // First Delta phi for this set
988  std::string scLabel1 = obj1;
989  scLabel1 += "-PHI";
990  std::string scLabel2 = obj2;
991  scLabel2 += "-PHI";
992 
993  //This LUT does not exist in L1 Menu file, don't fill it
994  if( scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end()) return;
995 
996  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
997  const esScale* scale2 = &scaleMap.find(scLabel2)->second;
998  std::vector<double> val_delta_phi;
999  std::vector<long long> lut_delta_phi;
1000  size_t n = getDeltaVector(val_delta_phi, scale1, scale2);
1001  setLut(lut_delta_phi, val_delta_phi, prec1);
1002  std::string lutName = obj1;
1003  lutName += "-";
1004  lutName += obj2;
1005  m_gtScales.setLUT_DeltaPhi(lutName,lut_delta_phi,prec1);
1006 
1007  // Second Get the Cosh for this delta phi Set
1008  std::vector<long long> lut_cos;
1009  applyCos(val_delta_phi, n);
1010  setLut(lut_cos, val_delta_phi, prec2);
1011  m_gtScales.setLUT_Cos(lutName,lut_cos,prec2);
1012 
1013 }
1014 
1015 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)
1016 {
1017 
1018  using namespace tmeventsetup;
1019 
1020  std::string scLabel = obj;
1021  scLabel += "-PHI";
1022 
1023  //This LUT does not exist in L1 Menu file, don't fill it
1024  if( scaleMap.find(scLabel) == scaleMap.end() ) return;
1025  if( func != l1t::SIN and func != l1t::COS) return;
1026 
1027  const esScale* scale = &scaleMap.find(scLabel)->second;
1028 
1029  const double step = scale->getStep();
1030  const double range = scale->getMaximum() - scale->getMinimum();
1031  const size_t n = std::ceil(range / step);
1032  const size_t bitwidth = std::ceil(std::log10(n) / std::log10(2));
1033 
1034  std::vector<double> array(std::pow(2,bitwidth),0);
1035 
1036  for (size_t ii = 0; ii < n; ii++)
1037  {
1038  array.at(ii) = step * ii;
1039  }
1040 
1041  std::string lutName = obj;
1042  std::vector<long long> lut;
1043  if ( func == l1t::SIN ) {
1044  applySin(array, n);
1045  setLut(lut, array, prec);
1046  m_gtScales.setLUT_Sin(lutName,lut,prec);
1047  }else if ( func == l1t::COS ) {
1048  applyCos(array, n);
1049  setLut(lut, array, prec);
1050  m_gtScales.setLUT_Cos(lutName,lut,prec);
1051  }
1052 }
1053 
1054 
1055 
1056 
1068 bool l1t::TriggerMenuParser::parseMuon(tmeventsetup::esCondition condMu,
1069  unsigned int chipNr, const bool corrFlag) {
1070 
1071  using namespace tmeventsetup;
1072 
1073  // get condition, particle name (must be muon) and type name
1074  std::string condition = "muon";
1075  std::string particle = "muon";//l1t2string( condMu.objectType() );
1076  std::string type = l1t2string( condMu.getType() );
1077  std::string name = l1t2string( condMu.getName() );
1078  int nrObj = -1;
1079 
1080 
1081 
1083 
1084  if (condMu.getType() == esConditionType::SingleMuon) {
1085  type = "1_s";
1086  cType = l1t::Type1s;
1087  nrObj = 1;
1088  } else if (condMu.getType() == esConditionType::DoubleMuon) {
1089  type = "2_s";
1090  cType = l1t::Type2s;
1091  nrObj = 2;
1092  } else if (condMu.getType() == esConditionType::TripleMuon) {
1093  type = "3";
1094  cType = l1t::Type3s;
1095  nrObj = 3;
1096  } else if (condMu.getType() == esConditionType::QuadMuon) {
1097  type = "4";
1098  cType = l1t::Type4s;
1099  nrObj = 4;
1100  } else {
1101  edm::LogError("TriggerMenuParser") << "Wrong type for muon-condition ("
1102  << type << ")" << std::endl;
1103  return false;
1104  }
1105 
1106  if (nrObj < 0) {
1107  edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type
1108  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1109  return false;
1110  }
1111 
1112  LogDebug("TriggerMenuParser")
1113  << "\n ****************************************** "
1114  << "\n parseMuon "
1115  << "\n condition = " << condition
1116  << "\n particle = " << particle
1117  << "\n type = " << type
1118  << "\n name = " << name
1119  << std::endl;
1120 
1121 
1122 
1123 // // get values
1124 
1125  // temporary storage of the parameters
1126  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1127 
1128  // Do we need this?
1129  MuonTemplate::CorrelationParameter corrParameter;
1130 
1131  // need at least two values for deltaPhi
1132  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1133  tmpValues.reserve( nrObj );
1134 
1135  if( int(condMu.getObjects().size())!=nrObj ){
1136  edm::LogError("TriggerMenuParser") << " condMu objects: nrObj = " << nrObj
1137  << "condMu.getObjects().size() = "
1138  << condMu.getObjects().size()
1139  << std::endl;
1140  return false;
1141  }
1142 
1143 
1144 // Look for cuts on the objects in the condition
1145  unsigned int chargeCorrelation = 1;
1146  const std::vector<esCut>& cuts = condMu.getCuts();
1147  for (size_t jj = 0; jj < cuts.size(); jj++)
1148  {
1149  const esCut cut = cuts.at(jj);
1150  if(cut.getCutType() == esCutType::ChargeCorrelation) {
1151  if( cut.getData()=="ls" ) chargeCorrelation = 2;
1152  else if( cut.getData()=="os" ) chargeCorrelation = 4;
1153  else chargeCorrelation = 1; //ignore correlation
1154  }
1155  }
1156 
1157  //set charge correlation parameter
1158  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
1159 
1160 
1161  int cnt = 0;
1162 
1163 
1164 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1165  int relativeBx = 0;
1166  bool gEq = false;
1167 
1168 // Loop over objects and extract the cuts on the objects
1169  const std::vector<esObject>& objects = condMu.getObjects();
1170  for (size_t jj = 0; jj < objects.size(); jj++) {
1171 
1172  const esObject object = objects.at(jj);
1173  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1174 
1175 // BLW TO DO: This needs to be added to the Object Parameters
1176  relativeBx = object.getBxOffset();
1177 
1178 // Loop over the cuts for this object
1179  int upperThresholdInd = -1;
1180  int lowerThresholdInd = 0;
1181  int upperIndexInd = -1;
1182  int lowerIndexInd = 0;
1183  int cntEta = 0;
1184  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1185  int cntPhi = 0;
1186  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1187  int isolationLUT = 0xF; //default is to ignore unless specified.
1188  int charge = -1; //default value is to ignore unless specified
1189  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
1190 
1191  const std::vector<esCut>& cuts = object.getCuts();
1192  for (size_t kk = 0; kk < cuts.size(); kk++)
1193  {
1194  const esCut cut = cuts.at(kk);
1195 
1196  switch(cut.getCutType()){
1197  case esCutType::Threshold:
1198  lowerThresholdInd = cut.getMinimum().index;
1199  upperThresholdInd = cut.getMaximum().index;
1200  break;
1201 
1202  case esCutType::Slice:
1203  lowerIndexInd = int(cut.getMinimum().value);
1204  upperIndexInd = int(cut.getMaximum().value);
1205  break;
1206 
1207  case esCutType::Eta: {
1208 
1209  if(cntEta == 0) {
1210  etaWindow1Lower = cut.getMinimum().index;
1211  etaWindow1Upper = cut.getMaximum().index;
1212  } else if(cntEta == 1) {
1213  etaWindow2Lower = cut.getMinimum().index;
1214  etaWindow2Upper = cut.getMaximum().index;
1215  } else {
1216  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for muon-condition ("
1217  << particle << ")" << std::endl;
1218  return false;
1219  }
1220  cntEta++;
1221 
1222  } break;
1223 
1224  case esCutType::Phi: {
1225 
1226  if(cntPhi == 0) {
1227  phiWindow1Lower = cut.getMinimum().index;
1228  phiWindow1Upper = cut.getMaximum().index;
1229  } else if(cntPhi == 1) {
1230  phiWindow2Lower = cut.getMinimum().index;
1231  phiWindow2Upper = cut.getMaximum().index;
1232  } else {
1233  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for muon-condition ("
1234  << particle << ")" << std::endl;
1235  return false;
1236  }
1237  cntPhi++;
1238 
1239  }break;
1240 
1241  case esCutType::Charge:
1242  if( cut.getData()=="positive" ) charge = 0;
1243  else if( cut.getData()=="negative" ) charge = 1;
1244  else charge = -1;
1245  break;
1246  case esCutType::Quality:
1247 
1248  qualityLUT = l1tstr2int(cut.getData());
1249 
1250  break;
1251  case esCutType::Isolation: {
1252 
1253  isolationLUT = l1tstr2int(cut.getData());
1254 
1255  } break;
1256  default:
1257  break;
1258  } //end switch
1259 
1260  } //end loop over cuts
1261 
1262 
1263 // Set the parameter cuts
1264  objParameter[cnt].ptHighThreshold = upperThresholdInd;
1265  objParameter[cnt].ptLowThreshold = lowerThresholdInd;
1266 
1267  objParameter[cnt].indexHigh = upperIndexInd;
1268  objParameter[cnt].indexLow = lowerIndexInd;
1269 
1270  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
1271  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
1272  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
1273  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
1274 
1275  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1276  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1277  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1278  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1279 
1280 // BLW TO DO: Do we need these anymore? Drop them?
1281  objParameter[cnt].enableMip = false;//tmpMip[i];
1282  objParameter[cnt].enableIso = false;//tmpEnableIso[i];
1283  objParameter[cnt].requestIso = false;//tmpRequestIso[i];
1284 
1285  objParameter[cnt].charge = charge;
1286  objParameter[cnt].qualityLUT = qualityLUT;
1287  objParameter[cnt].isolationLUT = isolationLUT;
1288 
1289 
1290  cnt++;
1291  } //end loop over objects
1292 
1293 
1294  // object types - all muons
1295  std::vector<GlobalObject> objType(nrObj, gtMu);
1296 
1297 
1298 
1299  // now create a new CondMuonition
1300  MuonTemplate muonCond(name);
1301 
1302  muonCond.setCondType(cType);
1303  muonCond.setObjectType(objType);
1304  muonCond.setCondGEq(gEq);
1305  muonCond.setCondChipNr(chipNr);
1306  muonCond.setCondRelativeBx(relativeBx);
1307 
1308  muonCond.setConditionParameter(objParameter, corrParameter);
1309 
1310  if (edm::isDebugEnabled()) {
1311  std::ostringstream myCoutStream;
1312  muonCond.print(myCoutStream);
1313  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1314  }
1315 
1316  // insert condition into the map and into muon template vector
1317  if ( !insertConditionIntoMap(muonCond, chipNr)) {
1318  edm::LogError("TriggerMenuParser")
1319  << " Error: duplicate condition (" << name << ")"
1320  << std::endl;
1321  return false;
1322  }
1323  else {
1324  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1325  if (corrFlag) {
1326 
1327  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1328  }
1329  else {
1330  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the vecMuonTemplate vector" << std::endl;
1331  (m_vecMuonTemplate[chipNr]).push_back(muonCond);
1332  }
1333 
1334  }
1335 
1336  //
1337  return true;
1338 }
1339 
1340 
1341 bool l1t::TriggerMenuParser::parseMuonCorr(const tmeventsetup::esObject* corrMu,
1342  unsigned int chipNr) {
1343 
1344 
1345 // XERCES_CPP_NAMESPACE_USE
1346  using namespace tmeventsetup;
1347 
1348  // get condition, particle name (must be muon) and type name
1349  std::string condition = "muon";
1350  std::string particle = "muon";//l1t2string( condMu.objectType() );
1351  std::string type = l1t2string( corrMu->getType() );
1352  std::string name = l1t2string( corrMu->getName() );
1353  int nrObj = 1;
1354  type = "1_s";
1355  GtConditionType cType = l1t::Type1s;
1356 
1357 
1358 
1359  if (nrObj < 0) {
1360  edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type
1361  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1362  return false;
1363  }
1364 
1365  LogDebug("TriggerMenuParser")
1366  << "\n ****************************************** "
1367  << "\n parseMuon "
1368  << "\n condition = " << condition
1369  << "\n particle = " << particle
1370  << "\n type = " << type
1371  << "\n name = " << name
1372  << std::endl;
1373 
1374 
1375 
1376 // // get values
1377 
1378  // temporary storage of the parameters
1379  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1380 
1381  // Do we need this?
1382  MuonTemplate::CorrelationParameter corrParameter;
1383 
1384  // need at least two values for deltaPhi
1385  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1386  tmpValues.reserve( nrObj );
1387 
1388 
1389 // BLW TO DO: How do we deal with these in the new format
1390 // std::string str_chargeCorrelation = l1t2string( condMu.requestedChargeCorr() );
1391  std::string str_chargeCorrelation = "ig";
1392  unsigned int chargeCorrelation = 0;
1393  if( str_chargeCorrelation=="ig" ) chargeCorrelation = 1;
1394  else if( str_chargeCorrelation=="ls" ) chargeCorrelation = 2;
1395  else if( str_chargeCorrelation=="os" ) chargeCorrelation = 4;
1396 
1397  //getXMLHexTextValue("1", dst);
1398  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
1399 
1400 
1401 
1402  // BLW TO DO: These needs to the added to the object rather than the whole condition.
1403  int relativeBx = 0;
1404  bool gEq = false;
1405 
1406 
1407  //const esObject* object = condMu;
1408  gEq = (corrMu->getComparisonOperator() == esComparisonOperator::GE);
1409 
1410  // BLW TO DO: This needs to be added to the Object Parameters
1411  relativeBx = corrMu->getBxOffset();
1412 
1413  // Loop over the cuts for this object
1414  int upperThresholdInd = -1;
1415  int lowerThresholdInd = 0;
1416  int upperIndexInd = -1;
1417  int lowerIndexInd = 0;
1418  int cntEta = 0;
1419  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1420  int cntPhi = 0;
1421  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1422  int isolationLUT = 0xF; //default is to ignore unless specified.
1423  int charge = -1; //defaut is to ignore unless specified
1424  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
1425 
1426  const std::vector<esCut>& cuts = corrMu->getCuts();
1427  for (size_t kk = 0; kk < cuts.size(); kk++)
1428  {
1429  const esCut cut = cuts.at(kk);
1430 
1431  switch(cut.getCutType()){
1432  case esCutType::Threshold:
1433  lowerThresholdInd = cut.getMinimum().index;
1434  upperThresholdInd = cut.getMaximum().index;
1435  break;
1436 
1437  case esCutType::Slice:
1438  lowerIndexInd = int(cut.getMinimum().value);
1439  upperIndexInd = int(cut.getMaximum().value);
1440  break;
1441 
1442  case esCutType::Eta: {
1443 
1444  if(cntEta == 0) {
1445  etaWindow1Lower = cut.getMinimum().index;
1446  etaWindow1Upper = cut.getMaximum().index;
1447  } else if(cntEta == 1) {
1448  etaWindow2Lower = cut.getMinimum().index;
1449  etaWindow2Upper = cut.getMaximum().index;
1450  } else {
1451  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for muon-condition ("
1452  << particle << ")" << std::endl;
1453  return false;
1454  }
1455  cntEta++;
1456 
1457  } break;
1458 
1459  case esCutType::Phi: {
1460 
1461  if(cntPhi == 0) {
1462  phiWindow1Lower = cut.getMinimum().index;
1463  phiWindow1Upper = cut.getMaximum().index;
1464  } else if(cntPhi == 1) {
1465  phiWindow2Lower = cut.getMinimum().index;
1466  phiWindow2Upper = cut.getMaximum().index;
1467  } else {
1468  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for muon-condition ("
1469  << particle << ")" << std::endl;
1470  return false;
1471  }
1472  cntPhi++;
1473 
1474  }break;
1475 
1476  case esCutType::Charge:
1477  if( cut.getData()=="positive" ) charge = 0;
1478  else if( cut.getData()=="negative" ) charge = 1;
1479  else charge = -1;
1480  break;
1481  case esCutType::Quality:
1482 
1483  qualityLUT = l1tstr2int(cut.getData());
1484 
1485  break;
1486  case esCutType::Isolation: {
1487 
1488  isolationLUT = l1tstr2int(cut.getData());
1489 
1490  } break;
1491  default:
1492  break;
1493  } //end switch
1494 
1495  } //end loop over cuts
1496 
1497 
1498  // Set the parameter cuts
1499  objParameter[0].ptHighThreshold = upperThresholdInd;
1500  objParameter[0].ptLowThreshold = lowerThresholdInd;
1501 
1502  objParameter[0].indexHigh = upperIndexInd;
1503  objParameter[0].indexLow = lowerIndexInd;
1504 
1505  objParameter[0].etaWindow1Lower = etaWindow1Lower;
1506  objParameter[0].etaWindow1Upper = etaWindow1Upper;
1507  objParameter[0].etaWindow2Lower = etaWindow2Lower;
1508  objParameter[0].etaWindow2Upper = etaWindow2Upper;
1509 
1510  objParameter[0].phiWindow1Lower = phiWindow1Lower;
1511  objParameter[0].phiWindow1Upper = phiWindow1Upper;
1512  objParameter[0].phiWindow2Lower = phiWindow2Lower;
1513  objParameter[0].phiWindow2Upper = phiWindow2Upper;
1514 
1515  // BLW TO DO: Do we need these anymore? Drop them?
1516  objParameter[0].enableMip = false;//tmpMip[i];
1517  objParameter[0].enableIso = false;//tmpEnableIso[i];
1518  objParameter[0].requestIso = false;//tmpRequestIso[i];
1519 
1520  objParameter[0].charge = charge;
1521  objParameter[0].qualityLUT = qualityLUT;
1522  objParameter[0].isolationLUT = isolationLUT;
1523 
1524 
1525  // object types - all muons
1526  std::vector<GlobalObject> objType(nrObj, gtMu);
1527 
1528  // now create a new CondMuonition
1529  MuonTemplate muonCond(name);
1530 
1531  muonCond.setCondType(cType);
1532  muonCond.setObjectType(objType);
1533  muonCond.setCondGEq(gEq);
1534  muonCond.setCondChipNr(chipNr);
1535  muonCond.setCondRelativeBx(relativeBx);
1536  muonCond.setConditionParameter(objParameter, corrParameter);
1537 
1538  if (edm::isDebugEnabled()) {
1539  std::ostringstream myCoutStream;
1540  muonCond.print(myCoutStream);
1541  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1542  }
1543 
1544 /*
1545  // insert condition into the map and into muon template vector
1546  if ( !insertConditionIntoMap(muonCond, chipNr)) {
1547  edm::LogError("TriggerMenuParser")
1548  << " Error: duplicate condition (" << name << ")"
1549  << std::endl;
1550  return false;
1551  }
1552  else {
1553  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1554  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1555  }
1556 */
1557  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1558 
1559 
1560  //
1561  return true;
1562 }
1563 
1564 
1576 bool l1t::TriggerMenuParser::parseCalo(tmeventsetup::esCondition condCalo,
1577  unsigned int chipNr, const bool corrFlag) {
1578 
1579 
1580 // XERCES_CPP_NAMESPACE_USE
1581  using namespace tmeventsetup;
1582 
1583  // get condition, particle name and type name
1584 
1585  std::string condition = "calo";
1586  std::string particle = "test-fix" ;
1587  std::string type = l1t2string( condCalo.getType() );
1588  std::string name = l1t2string( condCalo.getName() );
1589 
1590  LogDebug("TriggerMenuParser")
1591  << "\n ****************************************** "
1592  << "\n (in parseCalo) "
1593  << "\n condition = " << condition
1594  << "\n particle = " << particle
1595  << "\n type = " << type
1596  << "\n name = " << name
1597  << std::endl;
1598 
1599 
1601 
1602  // determine object type type
1603  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
1604  GlobalObject caloObjType;
1605  int nrObj = -1;
1606 
1607  if (condCalo.getType() == esConditionType::SingleEgamma) {
1608  caloObjType = gtEG;
1609  type = "1_s";
1610  cType= l1t::Type1s;
1611  nrObj = 1;
1612  } else if (condCalo.getType() == esConditionType::DoubleEgamma) {
1613  caloObjType = gtEG;
1614  type = "2_s";
1615  cType= l1t::Type2s;
1616  nrObj = 2;
1617  } else if (condCalo.getType() == esConditionType::TripleEgamma) {
1618  caloObjType = gtEG;
1619  cType= l1t::Type3s;
1620  type = "3";
1621  nrObj = 3;
1622  } else if (condCalo.getType() == esConditionType::QuadEgamma) {
1623  caloObjType = gtEG;
1624  cType= l1t::Type4s;
1625  type = "4";
1626  nrObj = 4;
1627  } else if (condCalo.getType() == esConditionType::SingleJet) {
1628  caloObjType = gtJet;
1629  cType= l1t::Type1s;
1630  type = "1_s";
1631  nrObj = 1;
1632  } else if (condCalo.getType() == esConditionType::DoubleJet) {
1633  caloObjType = gtJet;
1634  cType= l1t::Type2s;
1635  type = "2_s";
1636  nrObj = 2;
1637  } else if (condCalo.getType() == esConditionType::TripleJet) {
1638  caloObjType = gtJet;
1639  cType= l1t::Type3s;
1640  type = "3";
1641  nrObj = 3;
1642  } else if (condCalo.getType() == esConditionType::QuadJet) {
1643  caloObjType = gtJet;
1644  cType= l1t::Type4s;
1645  type = "4";
1646  nrObj = 4;
1647  } else if (condCalo.getType() == esConditionType::SingleTau) {
1648  caloObjType = gtTau;
1649  cType= l1t::Type1s;
1650  type = "1_s";
1651  nrObj = 1;
1652  } else if (condCalo.getType() == esConditionType::DoubleTau) {
1653  caloObjType = gtTau;
1654  cType= l1t::Type2s;
1655  type = "2_s";
1656  nrObj = 2;
1657  } else if (condCalo.getType() == esConditionType::TripleTau) {
1658  caloObjType = gtTau;
1659  cType= l1t::Type3s;
1660  type = "3";
1661  nrObj = 3;
1662  } else if (condCalo.getType() == esConditionType::QuadTau) {
1663  caloObjType = gtTau;
1664  cType= l1t::Type4s;
1665  type = "4";
1666  nrObj = 4;
1667  } else {
1668  edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition ("
1669  << particle << ")" << std::endl;
1670  return false;
1671  }
1672 
1673 // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1674 
1675  if (nrObj < 0) {
1676  edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type
1677  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1678  return false;
1679  }
1680 
1681  // get values
1682 
1683  // temporary storage of the parameters
1684  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1685 
1686  //BLW TO DO: Can this be dropped?
1687  CaloTemplate::CorrelationParameter corrParameter;
1688 
1689  // need at least one value for deltaPhiRange
1690  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1691  tmpValues.reserve( nrObj );
1692 
1693 
1694  if( int(condCalo.getObjects().size())!=nrObj ){
1695  edm::LogError("TriggerMenuParser") << " condCalo objects: nrObj = " << nrObj
1696  << "condCalo.getObjects().size() = "
1697  << condCalo.getObjects().size()
1698  << std::endl;
1699  return false;
1700  }
1701 
1702 
1703 // std::string str_condCalo = "";
1704 // boost::uint64_t tempUIntH, tempUIntL;
1705 // boost::uint64_t dst;
1706  int cnt = 0;
1707 
1708 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1709  int relativeBx = 0;
1710  bool gEq = false;
1711 
1712 // Loop over objects and extract the cuts on the objects
1713  const std::vector<esObject>& objects = condCalo.getObjects();
1714  for (size_t jj = 0; jj < objects.size(); jj++) {
1715 
1716  const esObject object = objects.at(jj);
1717  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1718 
1719 // BLW TO DO: This needs to be added to the Object Parameters
1720  relativeBx = object.getBxOffset();
1721 
1722 // Loop over the cuts for this object
1723  int upperThresholdInd = -1;
1724  int lowerThresholdInd = 0;
1725  int upperIndexInd = -1;
1726  int lowerIndexInd = 0;
1727  int cntEta = 0;
1728  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1729  int cntPhi = 0;
1730  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1731  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
1732  int qualityLUT = 0xF; //default is to ignore quality unless specified.
1733 
1734 
1735  const std::vector<esCut>& cuts = object.getCuts();
1736  for (size_t kk = 0; kk < cuts.size(); kk++)
1737  {
1738  const esCut cut = cuts.at(kk);
1739 
1740  switch(cut.getCutType()){
1741  case esCutType::Threshold:
1742  lowerThresholdInd = cut.getMinimum().index;
1743  upperThresholdInd = cut.getMaximum().index;
1744  break;
1745  case esCutType::Slice:
1746  lowerIndexInd = int(cut.getMinimum().value);
1747  upperIndexInd = int(cut.getMaximum().value);
1748  break;
1749  case esCutType::Eta: {
1750 
1751  if(cntEta == 0) {
1752  etaWindow1Lower = cut.getMinimum().index;
1753  etaWindow1Upper = cut.getMaximum().index;
1754  } else if(cntEta == 1) {
1755  etaWindow2Lower = cut.getMinimum().index;
1756  etaWindow2Upper = cut.getMaximum().index;
1757  } else {
1758  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for calo-condition ("
1759  << particle << ")" << std::endl;
1760  return false;
1761  }
1762  cntEta++;
1763 
1764  } break;
1765 
1766  case esCutType::Phi: {
1767 
1768  if(cntPhi == 0) {
1769  phiWindow1Lower = cut.getMinimum().index;
1770  phiWindow1Upper = cut.getMaximum().index;
1771  } else if(cntPhi == 1) {
1772  phiWindow2Lower = cut.getMinimum().index;
1773  phiWindow2Upper = cut.getMaximum().index;
1774  } else {
1775  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for calo-condition ("
1776  << particle << ")" << std::endl;
1777  return false;
1778  }
1779  cntPhi++;
1780 
1781  }break;
1782 
1783  case esCutType::Charge: {
1784 
1785  edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition ("
1786  << particle << ")" << std::endl;
1787  return false;
1788 
1789  }break;
1790  case esCutType::Quality: {
1791 
1792  qualityLUT = l1tstr2int(cut.getData());
1793 
1794  }break;
1795  case esCutType::Isolation: {
1796 
1797  isolationLUT = l1tstr2int(cut.getData());
1798 
1799  } break;
1800  default:
1801  break;
1802  } //end switch
1803 
1804  } //end loop over cuts
1805 
1806 // Fill the object parameters
1807  objParameter[cnt].etHighThreshold = upperThresholdInd;
1808  objParameter[cnt].etLowThreshold = lowerThresholdInd;
1809  objParameter[cnt].indexHigh = upperIndexInd;
1810  objParameter[cnt].indexLow = lowerIndexInd;
1811  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
1812  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
1813  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
1814  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
1815  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1816  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1817  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1818  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1819  objParameter[cnt].isolationLUT = isolationLUT;
1820  objParameter[cnt].qualityLUT = qualityLUT; //TO DO: Must add
1821 
1822  // Output for debugging
1823  LogDebug("TriggerMenuParser")
1824  << "\n Calo ET high thresholds (hex) for calo object " << caloObjType << " " << cnt << " = "
1825  << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold
1826  << "\n etaWindow Lower / Upper for calo object " << cnt << " = 0x"
1827  << objParameter[cnt].etaWindow1Lower << " / 0x" << objParameter[cnt].etaWindow1Upper
1828  << "\n etaWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
1829  << objParameter[cnt].etaWindow2Lower << " / 0x" << objParameter[cnt].etaWindow2Upper
1830  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
1831  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
1832  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
1833  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper
1834  << "\n Isolation LUT for calo object " << cnt << " = 0x"
1835  << objParameter[cnt].isolationLUT
1836  << "\n Quality LUT for calo object " << cnt << " = 0x"
1837  << objParameter[cnt].qualityLUT << std::dec
1838  << std::endl;
1839 
1840  cnt++;
1841  } //end loop over objects
1842 
1843 
1844 
1845  // object types - all same caloObjType
1846  std::vector<GlobalObject> objType(nrObj, caloObjType);
1847 
1848 
1849 
1850 
1851  // now create a new calo condition
1852  CaloTemplate caloCond(name);
1853 
1854  caloCond.setCondType(cType);
1855  caloCond.setObjectType(objType);
1856 
1857  //BLW TO DO: This needs to be added to the object rather than the whole condition
1858  caloCond.setCondGEq(gEq);
1859  caloCond.setCondChipNr(chipNr);
1860 
1861  //BLW TO DO: This needs to be added to the object rather than the whole condition
1862  caloCond.setCondRelativeBx(relativeBx);
1863 
1864  caloCond.setConditionParameter(objParameter, corrParameter);
1865 
1866  if (edm::isDebugEnabled() ) {
1867 
1868  std::ostringstream myCoutStream;
1869  caloCond.print(myCoutStream);
1870  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1871 
1872  }
1873 
1874 
1875  // insert condition into the map
1876  if ( !insertConditionIntoMap(caloCond, chipNr)) {
1877 
1878  edm::LogError("TriggerMenuParser")
1879  << " Error: duplicate condition (" << name << ")"
1880  << std::endl;
1881 
1882  return false;
1883  }
1884  else {
1885 
1886  if (corrFlag) {
1887  (m_corCaloTemplate[chipNr]).push_back(caloCond);
1888  }
1889  else {
1890  (m_vecCaloTemplate[chipNr]).push_back(caloCond);
1891  }
1892 
1893  }
1894 
1895 
1896  //
1897  return true;
1898 }
1899 
1900 
1901 
1913 bool l1t::TriggerMenuParser::parseCaloCorr(const tmeventsetup::esObject* corrCalo,
1914  unsigned int chipNr) {
1915 
1916 
1917 // XERCES_CPP_NAMESPACE_USE
1918  using namespace tmeventsetup;
1919 
1920  // get condition, particle name and type name
1921 
1922  std::string condition = "calo";
1923  std::string particle = "test-fix" ;
1924  std::string type = l1t2string( corrCalo->getType() );
1925  std::string name = l1t2string( corrCalo->getName() );
1926 
1927  LogDebug("TriggerMenuParser")
1928  << "\n ****************************************** "
1929  << "\n (in parseCalo) "
1930  << "\n condition = " << condition
1931  << "\n particle = " << particle
1932  << "\n type = " << type
1933  << "\n name = " << name
1934  << std::endl;
1935 
1936 
1937  // determine object type type
1938  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
1939  GlobalObject caloObjType;
1940  int nrObj = 1;
1941  type = "1_s";
1942  GtConditionType cType = l1t::Type1s;
1943 
1944 
1945  if (corrCalo->getType() == esObjectType::Egamma) {
1946  caloObjType = gtEG;
1947  } else if (corrCalo->getType() == esObjectType::Jet) {
1948  caloObjType = gtJet;
1949  } else if (corrCalo->getType() == esObjectType::Tau) {
1950  caloObjType = gtTau;
1951  } else {
1952  edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition ("
1953  << particle << ")" << std::endl;
1954  return false;
1955  }
1956 
1957 
1958 // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1959 
1960  if (nrObj < 0) {
1961  edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type
1962  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1963  return false;
1964  }
1965 
1966  // get values
1967 
1968  // temporary storage of the parameters
1969  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1970 
1971  //BLW TO DO: Can this be dropped?
1972  CaloTemplate::CorrelationParameter corrParameter;
1973 
1974  // need at least one value for deltaPhiRange
1975  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1976  tmpValues.reserve( nrObj );
1977 
1978 
1979 
1980 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1981  int relativeBx = 0;
1982  bool gEq = false;
1983 
1984 
1985  gEq = (corrCalo->getComparisonOperator() == esComparisonOperator::GE);
1986 
1987 // BLW TO DO: This needs to be added to the Object Parameters
1988  relativeBx = corrCalo->getBxOffset();
1989 
1990 // Loop over the cuts for this object
1991  int upperThresholdInd = -1;
1992  int lowerThresholdInd = 0;
1993  int upperIndexInd = -1;
1994  int lowerIndexInd = 0;
1995  int cntEta = 0;
1996  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1997  int cntPhi = 0;
1998  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1999  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
2000  int qualityLUT = 0xF; //default is to ignore quality unless specified.
2001 
2002 
2003  const std::vector<esCut>& cuts = corrCalo->getCuts();
2004  for (size_t kk = 0; kk < cuts.size(); kk++)
2005  {
2006  const esCut cut = cuts.at(kk);
2007 
2008  switch(cut.getCutType()){
2009  case esCutType::Threshold:
2010  lowerThresholdInd = cut.getMinimum().index;
2011  upperThresholdInd = cut.getMaximum().index;
2012  break;
2013  case esCutType::Slice:
2014  lowerIndexInd = int(cut.getMinimum().value);
2015  upperIndexInd = int(cut.getMaximum().value);
2016  break;
2017  case esCutType::Eta: {
2018 
2019  if(cntEta == 0) {
2020  etaWindow1Lower = cut.getMinimum().index;
2021  etaWindow1Upper = cut.getMaximum().index;
2022  } else if(cntEta == 1) {
2023  etaWindow2Lower = cut.getMinimum().index;
2024  etaWindow2Upper = cut.getMaximum().index;
2025  } else {
2026  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for calo-condition ("
2027  << particle << ")" << std::endl;
2028  return false;
2029  }
2030  cntEta++;
2031 
2032  } break;
2033 
2034  case esCutType::Phi: {
2035 
2036  if(cntPhi == 0) {
2037  phiWindow1Lower = cut.getMinimum().index;
2038  phiWindow1Upper = cut.getMaximum().index;
2039  } else if(cntPhi == 1) {
2040  phiWindow2Lower = cut.getMinimum().index;
2041  phiWindow2Upper = cut.getMaximum().index;
2042  } else {
2043  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for calo-condition ("
2044  << particle << ")" << std::endl;
2045  return false;
2046  }
2047  cntPhi++;
2048 
2049  }break;
2050 
2051  case esCutType::Charge: {
2052 
2053  edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition ("
2054  << particle << ")" << std::endl;
2055  return false;
2056 
2057  }break;
2058  case esCutType::Quality: {
2059 
2060  qualityLUT = l1tstr2int(cut.getData());
2061 
2062  }break;
2063  case esCutType::Isolation: {
2064 
2065  isolationLUT = l1tstr2int(cut.getData());
2066 
2067  } break;
2068  default:
2069  break;
2070  } //end switch
2071 
2072  } //end loop over cuts
2073 
2074 // Fill the object parameters
2075  objParameter[0].etLowThreshold = lowerThresholdInd;
2076  objParameter[0].etHighThreshold = upperThresholdInd;
2077  objParameter[0].indexHigh = upperIndexInd;
2078  objParameter[0].indexLow = lowerIndexInd;
2079  objParameter[0].etaWindow1Lower = etaWindow1Lower;
2080  objParameter[0].etaWindow1Upper = etaWindow1Upper;
2081  objParameter[0].etaWindow2Lower = etaWindow2Lower;
2082  objParameter[0].etaWindow2Upper = etaWindow2Upper;
2083  objParameter[0].phiWindow1Lower = phiWindow1Lower;
2084  objParameter[0].phiWindow1Upper = phiWindow1Upper;
2085  objParameter[0].phiWindow2Lower = phiWindow2Lower;
2086  objParameter[0].phiWindow2Upper = phiWindow2Upper;
2087  objParameter[0].isolationLUT = isolationLUT;
2088  objParameter[0].qualityLUT = qualityLUT; //TO DO: Must add
2089 
2090  // Output for debugging
2091  LogDebug("TriggerMenuParser")
2092  << "\n Calo ET high threshold (hex) for calo object " << caloObjType << " " << " = "
2093  << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etHighThreshold
2094  << "\n etaWindow Lower / Upper for calo object " << " = 0x"
2095  << objParameter[0].etaWindow1Lower << " / 0x" << objParameter[0].etaWindow1Upper
2096  << "\n etaWindowVeto Lower / Upper for calo object " << " = 0x"
2097  << objParameter[0].etaWindow2Lower << " / 0x" << objParameter[0].etaWindow2Upper
2098  << "\n phiWindow Lower / Upper for calo object " << " = 0x"
2099  << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
2100  << "\n phiWindowVeto Lower / Upper for calo object " << " = 0x"
2101  << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper
2102  << "\n Isolation LUT for calo object " << " = 0x"
2103  << objParameter[0].isolationLUT
2104  << "\n Quality LUT for calo object " << " = 0x"
2105  << objParameter[0].qualityLUT << std::dec
2106  << std::endl;
2107 
2108 
2109 
2110 
2111 
2112  // object types - all same caloObjType
2113  std::vector<GlobalObject> objType(nrObj, caloObjType);
2114 
2115 
2116 
2117 
2118  // now create a new calo condition
2119  CaloTemplate caloCond(name);
2120 
2121  caloCond.setCondType(cType);
2122  caloCond.setObjectType(objType);
2123 
2124  //BLW TO DO: This needs to be added to the object rather than the whole condition
2125  caloCond.setCondGEq(gEq);
2126  caloCond.setCondChipNr(chipNr);
2127 
2128  //BLW TO DO: This needs to be added to the object rather than the whole condition
2129  caloCond.setCondRelativeBx(relativeBx);
2130 
2131  caloCond.setConditionParameter(objParameter, corrParameter);
2132 
2133  if (edm::isDebugEnabled() ) {
2134 
2135  std::ostringstream myCoutStream;
2136  caloCond.print(myCoutStream);
2137  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2138 
2139  }
2140 
2141 /*
2142  // insert condition into the map
2143  if ( !insertConditionIntoMap(caloCond, chipNr)) {
2144 
2145  edm::LogError("TriggerMenuParser")
2146  << " Error: duplicate condition (" << name << ")"
2147  << std::endl;
2148 
2149  return false;
2150  }
2151  else {
2152  (m_corCaloTemplate[chipNr]).push_back(caloCond);
2153  }
2154 */
2155  (m_corCaloTemplate[chipNr]).push_back(caloCond);
2156 
2157  //
2158  return true;
2159 }
2160 
2161 
2162 
2174 bool l1t::TriggerMenuParser::parseEnergySum(tmeventsetup::esCondition condEnergySum,
2175  unsigned int chipNr, const bool corrFlag) {
2176 
2177 
2178 // XERCES_CPP_NAMESPACE_USE
2179  using namespace tmeventsetup;
2180 
2181  // get condition, particle name and type name
2182 
2183  std::string condition = "calo";
2184  std::string type = l1t2string( condEnergySum.getType() );
2185  std::string name = l1t2string( condEnergySum.getName() );
2186 
2187  LogDebug("TriggerMenuParser")
2188  << "\n ****************************************** "
2189  << "\n (in parseEnergySum) "
2190  << "\n condition = " << condition
2191  << "\n type = " << type
2192  << "\n name = " << name
2193  << std::endl;
2194 
2195 
2196 
2197  // determine object type type
2198  GlobalObject energySumObjType;
2199  GtConditionType cType;
2200 
2201  if( condEnergySum.getType() == esConditionType::MissingEt ){
2202  energySumObjType = GlobalObject::gtETM;
2203  cType = TypeETM;
2204  }
2205  else if( condEnergySum.getType() == esConditionType::TotalEt ){
2206  energySumObjType = GlobalObject::gtETT;
2207  cType = TypeETT;
2208  }
2209  else if( condEnergySum.getType() == esConditionType::TotalEtEM ){
2210  energySumObjType = GlobalObject::gtETTem;
2211  cType = TypeETTem;
2212  }
2213  else if( condEnergySum.getType() == esConditionType::TotalHt ){
2214  energySumObjType = GlobalObject::gtHTT;
2215  cType = TypeHTT;
2216  }
2217  else if( condEnergySum.getType() == esConditionType::MissingHt ){
2218  energySumObjType = GlobalObject::gtHTM;
2219  cType = TypeHTM;
2220  }
2221  else if( condEnergySum.getType() == esConditionType::MissingEtHF ){
2222  energySumObjType = GlobalObject::gtETMHF;
2223  cType = TypeETMHF;
2224  }
2225  else if( condEnergySum.getType() == esConditionType::TowerCount ){
2226  energySumObjType = GlobalObject::gtTowerCount;
2227  cType = TypeTowerCount;
2228  }
2229  else if( condEnergySum.getType() == esConditionType::MinBiasHFP0 ){
2230  energySumObjType = GlobalObject::gtMinBiasHFP0;
2231  cType = TypeMinBiasHFP0;
2232  }
2233  else if( condEnergySum.getType() == esConditionType::MinBiasHFM0 ){
2234  energySumObjType = GlobalObject::gtMinBiasHFM0;
2235  cType = TypeMinBiasHFM0;
2236  }
2237  else if( condEnergySum.getType() == esConditionType::MinBiasHFP1 ){
2238  energySumObjType = GlobalObject::gtMinBiasHFP1;
2239  cType = TypeMinBiasHFP1;
2240  }
2241  else if( condEnergySum.getType() == esConditionType::MinBiasHFM1 ){
2242  energySumObjType = GlobalObject::gtMinBiasHFM1;
2243  cType = TypeMinBiasHFM1;
2244  }
2245  else {
2246  edm::LogError("TriggerMenuParser")
2247  << "Wrong type for energy-sum condition (" << type
2248  << ")" << std::endl;
2249  return false;
2250  }
2251 
2252 
2253 
2254  // global object
2255  int nrObj = 1;
2256 
2257 // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
2258 
2259  // get values
2260 
2261  // temporary storage of the parameters
2262  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2263 
2264 
2265  int cnt = 0;
2266 
2267 // BLW TO DO: These needs to the added to the object rather than the whole condition.
2268  int relativeBx = 0;
2269  bool gEq = false;
2270 
2271 // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
2272 
2273 // Loop over objects and extract the cuts on the objects
2274  const std::vector<esObject>& objects = condEnergySum.getObjects();
2275  for (size_t jj = 0; jj < objects.size(); jj++) {
2276 
2277  const esObject object = objects.at(jj);
2278  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
2279 
2280 // BLW TO DO: This needs to be added to the Object Parameters
2281  relativeBx = object.getBxOffset();
2282 
2283 // Loop over the cuts for this object
2284  int lowerThresholdInd = 0;
2285  int upperThresholdInd = -1;
2286  int cntPhi = 0;
2287  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
2288 
2289 
2290  const std::vector<esCut>& cuts = object.getCuts();
2291  for (size_t kk = 0; kk < cuts.size(); kk++)
2292  {
2293  const esCut cut = cuts.at(kk);
2294 
2295  switch(cut.getCutType()){
2296  case esCutType::Threshold:
2297  lowerThresholdInd = cut.getMinimum().index;
2298  upperThresholdInd = cut.getMaximum().index;
2299  break;
2300 
2301  case esCutType::Eta:
2302  break;
2303 
2304  case esCutType::Phi: {
2305 
2306  if(cntPhi == 0) {
2307  phiWindow1Lower = cut.getMinimum().index;
2308  phiWindow1Upper = cut.getMaximum().index;
2309  } else if(cntPhi == 1) {
2310  phiWindow2Lower = cut.getMinimum().index;
2311  phiWindow2Upper = cut.getMaximum().index;
2312  } else {
2313  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition ("
2314  << type << ")" << std::endl;
2315  return false;
2316  }
2317  cntPhi++;
2318 
2319  }
2320  break;
2321 
2322  case esCutType::Count:
2323  lowerThresholdInd = cut.getMinimum().index;
2324  upperThresholdInd = 0xffffff;
2325  break;
2326 
2327  default:
2328  break;
2329  } //end switch
2330 
2331  } //end loop over cuts
2332 
2333 
2334 
2335  // Fill the object parameters
2336  objParameter[cnt].etLowThreshold = lowerThresholdInd;
2337  objParameter[cnt].etHighThreshold = upperThresholdInd;
2338  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
2339  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
2340  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
2341  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
2342 
2343 
2344  // Output for debugging
2345  LogDebug("TriggerMenuParser")
2346  << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2347  << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold
2348  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2349  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
2350  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2351  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper << std::dec
2352  << std::endl;
2353 
2354  cnt++;
2355  } //end loop over objects
2356 
2357  // object types - all same energySumObjType
2358  std::vector<GlobalObject> objType(nrObj, energySumObjType);
2359 
2360  // now create a new energySum condition
2361 
2362  EnergySumTemplate energySumCond(name);
2363 
2364  energySumCond.setCondType(cType);
2365  energySumCond.setObjectType(objType);
2366  energySumCond.setCondGEq(gEq);
2367  energySumCond.setCondChipNr(chipNr);
2368  energySumCond.setCondRelativeBx(relativeBx);
2369 
2370  energySumCond.setConditionParameter(objParameter);
2371 
2372  if (edm::isDebugEnabled() ) {
2373 
2374  std::ostringstream myCoutStream;
2375  energySumCond.print(myCoutStream);
2376  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2377 
2378  }
2379 
2380  // insert condition into the map
2381  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2382 
2383  edm::LogError("TriggerMenuParser")
2384  << " Error: duplicate condition (" << name << ")"
2385  << std::endl;
2386 
2387  return false;
2388  }
2389  else {
2390 
2391  if (corrFlag) {
2392  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2393 
2394  }
2395  else {
2396  (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
2397  }
2398 
2399  }
2400 
2401 
2402 
2403  //
2404  return true;
2405 }
2406 
2407 
2419 bool l1t::TriggerMenuParser::parseEnergySumCorr(const tmeventsetup::esObject* corrESum,
2420  unsigned int chipNr) {
2421 
2422 
2423 // XERCES_CPP_NAMESPACE_USE
2424  using namespace tmeventsetup;
2425 
2426  // get condition, particle name and type name
2427 
2428  std::string condition = "calo";
2429  std::string type = l1t2string( corrESum->getType() );
2430  std::string name = l1t2string( corrESum->getName() );
2431 
2432  LogDebug("TriggerMenuParser")
2433  << "\n ****************************************** "
2434  << "\n (in parseEnergySum) "
2435  << "\n condition = " << condition
2436  << "\n type = " << type
2437  << "\n name = " << name
2438  << std::endl;
2439 
2440 
2441 
2442  // determine object type type
2443  GlobalObject energySumObjType;
2444  GtConditionType cType;
2445 
2446  if( corrESum->getType()== esObjectType::ETM ){
2447  energySumObjType = GlobalObject::gtETM;
2448  cType = TypeETM;
2449  }
2450  else if( corrESum->getType()== esObjectType::HTM ){
2451  energySumObjType = GlobalObject::gtHTM;
2452  cType = TypeHTM;
2453  }
2454  else if( corrESum->getType()== esObjectType::ETMHF ){
2455  energySumObjType = GlobalObject::gtETMHF;
2456  cType = TypeETMHF;
2457  }
2458  else if( corrESum->getType()== esObjectType::TOWERCOUNT ){
2459  energySumObjType = GlobalObject::gtTowerCount;
2460  cType = TypeTowerCount;
2461  }
2462  else {
2463  edm::LogError("TriggerMenuParser")
2464  << "Wrong type for energy-sum correclation condition (" << type
2465  << ")" << std::endl;
2466  return false;
2467  }
2468 
2469 
2470 
2471  // global object
2472  int nrObj = 1;
2473 
2474 // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
2475 
2476  // get values
2477 
2478  // temporary storage of the parameters
2479  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2480 
2481 
2482  int cnt = 0;
2483 
2484 // BLW TO DO: These needs to the added to the object rather than the whole condition.
2485  int relativeBx = 0;
2486  bool gEq = false;
2487 
2488 // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
2489 
2490 
2491  gEq = (corrESum->getComparisonOperator() == esComparisonOperator::GE);
2492 
2493 // BLW TO DO: This needs to be added to the Object Parameters
2494  relativeBx = corrESum->getBxOffset();
2495 
2496 // Loop over the cuts for this object
2497  int lowerThresholdInd = 0;
2498  int upperThresholdInd = -1;
2499  int cntPhi = 0;
2500  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
2501 
2502 
2503  const std::vector<esCut>& cuts = corrESum->getCuts();
2504  for (size_t kk = 0; kk < cuts.size(); kk++)
2505  {
2506  const esCut cut = cuts.at(kk);
2507 
2508  switch(cut.getCutType()){
2509  case esCutType::Threshold:
2510  lowerThresholdInd = cut.getMinimum().index;
2511  upperThresholdInd = cut.getMaximum().index;
2512  break;
2513 
2514  case esCutType::Eta:
2515  break;
2516 
2517  case esCutType::Phi: {
2518 
2519  if(cntPhi == 0) {
2520  phiWindow1Lower = cut.getMinimum().index;
2521  phiWindow1Upper = cut.getMaximum().index;
2522  } else if(cntPhi == 1) {
2523  phiWindow2Lower = cut.getMinimum().index;
2524  phiWindow2Upper = cut.getMaximum().index;
2525  } else {
2526  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition ("
2527  << type << ")" << std::endl;
2528  return false;
2529  }
2530  cntPhi++;
2531 
2532  }
2533  break;
2534 
2535  default:
2536  break;
2537  } //end switch
2538 
2539  } //end loop over cuts
2540 
2541 
2542 
2543  // Fill the object parameters
2544  objParameter[0].etLowThreshold = lowerThresholdInd;
2545  objParameter[0].etHighThreshold = upperThresholdInd;
2546  objParameter[0].phiWindow1Lower = phiWindow1Lower;
2547  objParameter[0].phiWindow1Upper = phiWindow1Upper;
2548  objParameter[0].phiWindow2Lower = phiWindow2Lower;
2549  objParameter[0].phiWindow2Upper = phiWindow2Upper;
2550 
2551 
2552  // Output for debugging
2553  LogDebug("TriggerMenuParser")
2554  << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2555  << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etLowThreshold
2556  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2557  << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
2558  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2559  << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper << std::dec
2560  << std::endl;
2561 
2562 
2563  // object types - all same energySumObjType
2564  std::vector<GlobalObject> objType(nrObj, energySumObjType);
2565 
2566  // now create a new energySum condition
2567 
2568  EnergySumTemplate energySumCond(name);
2569 
2570  energySumCond.setCondType(cType);
2571  energySumCond.setObjectType(objType);
2572  energySumCond.setCondGEq(gEq);
2573  energySumCond.setCondChipNr(chipNr);
2574  energySumCond.setCondRelativeBx(relativeBx);
2575 
2576  energySumCond.setConditionParameter(objParameter);
2577 
2578  if (edm::isDebugEnabled() ) {
2579 
2580  std::ostringstream myCoutStream;
2581  energySumCond.print(myCoutStream);
2582  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2583 
2584  }
2585 /*
2586  // insert condition into the map
2587  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2588 
2589  edm::LogError("TriggerMenuParser")
2590  << " Error: duplicate condition (" << name << ")"
2591  << std::endl;
2592 
2593  return false;
2594  }
2595  else {
2596 
2597  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2598 
2599  }
2600 */
2601  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2602 
2603 
2604  //
2605  return true;
2606 }
2607 
2608 
2609 
2622 bool l1t::TriggerMenuParser::parseExternal(tmeventsetup::esCondition condExt,
2623  unsigned int chipNr) {
2624 
2625 
2626  using namespace tmeventsetup;
2627 
2628 
2629  // get condition, particle name and type name
2630  std::string condition = "ext";
2631  std::string particle = "test-fix";
2632  std::string type = l1t2string( condExt.getType() );
2633  std::string name = l1t2string( condExt.getName() );
2634 
2635 
2636  LogDebug("TriggerMenuParser")
2637  << "\n ****************************************** "
2638  << "\n (in parseExternal) "
2639  << "\n condition = " << condition
2640  << "\n particle = " << particle
2641  << "\n type = " << type
2642  << "\n name = " << name
2643  << std::endl;
2644 
2645 
2646  // object type and condition type
2647  // object type - irrelevant for External conditions
2648  GtConditionType cType = TypeExternal;
2649  GlobalObject extSignalType = GlobalObject::gtExternal;
2650  int nrObj = 1; //only one object for these conditions
2651 
2652  int relativeBx = 0;
2653  unsigned int channelID = 0;
2654 
2655  // Get object for External conditions
2656  const std::vector<esObject>& objects = condExt.getObjects();
2657  for (size_t jj = 0; jj < objects.size(); jj++) {
2658 
2659  const esObject object = objects.at(jj);
2660  if(object.getType() == esObjectType::EXT) {
2661  relativeBx = object.getBxOffset();
2662  channelID = object.getExternalChannelId();
2663  }
2664  }
2665 
2666 
2667  // set the boolean value for the ge_eq mode - irrelevant for External conditions
2668  bool gEq = false;
2669 
2670  //object types - all same for external conditions
2671  std::vector<GlobalObject> objType(nrObj, extSignalType);
2672 
2673  // now create a new External condition
2674  ExternalTemplate externalCond(name);
2675 
2676  externalCond.setCondType(cType);
2677  externalCond.setObjectType(objType);
2678  externalCond.setCondGEq(gEq);
2679  externalCond.setCondChipNr(chipNr);
2680  externalCond.setCondRelativeBx(relativeBx);
2681  externalCond.setExternalChannel(channelID);
2682 
2683  LogTrace("TriggerMenuParser")
2684  << externalCond << "\n" << std::endl;
2685 
2686  // insert condition into the map
2687  if ( !insertConditionIntoMap(externalCond, chipNr)) {
2688 
2689  edm::LogError("TriggerMenuParser")
2690  << " Error: duplicate condition (" << name
2691  << ")" << std::endl;
2692 
2693  return false;
2694  } else {
2695 
2696  (m_vecExternalTemplate[chipNr]).push_back(externalCond);
2697 
2698  }
2699 
2700  return true;
2701 }
2702 
2703 
2717  tmeventsetup::esCondition corrCond,
2718  unsigned int chipNr) {
2719 
2720  using namespace tmeventsetup;
2721 
2722  std::string condition = "corr";
2723  std::string particle = "test-fix" ;
2724  std::string type = l1t2string( corrCond.getType() );
2725  std::string name = l1t2string( corrCond.getName() );
2726 
2727  LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
2728  << " (in parseCorrelation) " << std::endl
2729  << " condition = " << condition << std::endl
2730  << " particle = " << particle << std::endl
2731  << " type = " << type << std::endl
2732  << " name = " << name << std::endl;
2733 
2734 
2735 
2736 
2737  // create a new correlation condition
2738  CorrelationTemplate correlationCond(name);
2739 
2740  // check that the condition does not exist already in the map
2741  if ( !insertConditionIntoMap(correlationCond, chipNr)) {
2742 
2743  edm::LogError("TriggerMenuParser")
2744  << " Error: duplicate correlation condition (" << name << ")"
2745  << std::endl;
2746 
2747  return false;
2748  }
2749 
2750 
2751 // Define some of the quantities to store the parased information
2752 
2753  // condition type BLW (Do we change this to the type of correlation condition?)
2755 
2756  // two objects (for sure)
2757  const int nrObj = 2;
2758 
2759  // object types and greater equal flag - filled in the loop
2760  int intGEq[nrObj] = { -1, -1 };
2761  std::vector<GlobalObject> objType(nrObj); //BLW do we want to define these as a different type?
2762  std::vector<GtConditionCategory> condCateg(nrObj); //BLW do we want to change these categories
2763 
2764  // correlation flag and index in the cor*vector
2765  const bool corrFlag = true;
2766  int corrIndexVal[nrObj] = { -1, -1 };
2767 
2768 
2769  // Storage of the correlation selection
2771  corrParameter.chargeCorrelation = 1; //ignore charge correlation
2772 
2773 // Get the correlation Cuts on the legs
2774  int cutType = 0;
2775  const std::vector<esCut>& cuts = corrCond.getCuts();
2776  for (size_t jj = 0; jj < cuts.size(); jj++)
2777  {
2778  const esCut cut = cuts.at(jj);
2779 
2780  if(cut.getCutType() == esCutType::ChargeCorrelation) {
2781  if( cut.getData()=="ls" ) corrParameter.chargeCorrelation = 2;
2782  else if( cut.getData()=="os" ) corrParameter.chargeCorrelation = 4;
2783  else corrParameter.chargeCorrelation = 1; //ignore charge correlation
2784  } else {
2785 
2786 //
2787 // Unitl utm has method to calculate these, do the integer value calculation with precision.
2788 //
2789  double minV = cut.getMinimum().value;
2790  double maxV = cut.getMaximum().value;
2791 
2792  //Scale down very large numbers out of xml
2793  if(maxV > 1.0e8) maxV = 1.0e8;
2794 
2795  if(cut.getCutType() == esCutType::DeltaEta) {
2796  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaEta Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2797  corrParameter.minEtaCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2798  corrParameter.maxEtaCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2799  corrParameter.precEtaCut = cut.getMinimum().index;
2800  cutType = cutType | 0x1;
2801  } else if (cut.getCutType() == esCutType::DeltaPhi) {
2802  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaPhi Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2803  corrParameter.minPhiCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2804  corrParameter.maxPhiCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2805  corrParameter.precPhiCut = cut.getMinimum().index;
2806  cutType = cutType | 0x2;
2807  } else if (cut.getCutType() == esCutType::DeltaR) {
2808  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaR Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2809  corrParameter.minDRCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2810  corrParameter.maxDRCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2811  corrParameter.precDRCut = cut.getMinimum().index;
2812  cutType = cutType | 0x4;
2813  } else if (cut.getCutType() == esCutType::TwoBodyPt) {
2814  corrParameter.minTBPTCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2815  corrParameter.maxTBPTCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2816  corrParameter.precTBPTCut = cut.getMinimum().index;
2817  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tTPBT Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2818  cutType = cutType | 0x20;
2819  } else if (cut.getCutType() == esCutType::Mass) {
2820  LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tMass Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2821  corrParameter.minMassCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2822  corrParameter.maxMassCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2823  corrParameter.precMassCut = cut.getMinimum().index;
2824  // cutType = cutType | 0x8;
2825  if (corrCond.getType() == esConditionType::TransverseMass){
2826  cutType = cutType | 0x10;
2827  //std::cout << "CCLA running Transverse mass cutType= " << cutType << std::endl;
2828  }else{
2829  cutType = cutType | 0x8;
2830  //std::cout << "CCLA running Invarient mass cutType= " << cutType << std::endl;
2831  }
2832  }
2833  }
2834 
2835  }
2836  corrParameter.corrCutType = cutType;
2837 
2838 // Get the two objects that form the legs
2839  const std::vector<esObject>& objects = corrCond.getObjects();
2840  if(objects.size() != 2) {
2841  edm::LogError("TriggerMenuParser")
2842  << "incorrect number of objects for the correlation condition " << name << " corrFlag " << corrFlag << std::endl;
2843  return false;
2844  }
2845 
2846 // loop over legs
2847  for (size_t jj = 0; jj < objects.size(); jj++)
2848  {
2849  const esObject object = objects.at(jj);
2850  //std::cout << " obj name = " << object.getName() << "\n";
2851  //std::cout << " obj type = " << object.getType() << "\n";
2852  //std::cout << " obj op = " << object.getComparisonOperator() << "\n";
2853  //std::cout << " obj bx = " << object.getBxOffset() << "\n";
2854 
2855 
2856 // check the leg type
2857  if(object.getType() == esObjectType::Muon) {
2858  // we have a muon
2859 
2860 /*
2861  //BLW Hold on to this code we may need to go back to it at some point.
2862  // Now we are putting ALL leg conditions into the vector (so there are duplicates)
2863  // This is potentially a place to slim down the code. Note: We currently evaluate the
2864  // conditions every time, so even if we put the condition in the vector once, we would
2865  // still evaluate it multiple times. This is a place for optimization.
2866  {
2867 
2868  parseMuonCorr(&object,chipNr);
2869  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
2870 
2871  } else {
2872  LogDebug("TriggerMenuParser") << "Not Adding Correlation Muon Condition to Map...looking for the condition in Muon Cor Vector" << std::endl;
2873  bool found = false;
2874  int index = 0;
2875  while(!found && index<(int)((m_corMuonTemplate[chipNr]).size()) ) {
2876  if( (m_corMuonTemplate[chipNr]).at(index).condName() == object.getName() ) {
2877  LogDebug("TriggerMenuParser") << "Found condition " << object.getName() << " in vector at index " << index << std::endl;
2878  found = true;
2879  } else {
2880  index++;
2881  }
2882  }
2883  if(found) {
2884  corrIndexVal[jj] = index;
2885  } else {
2886  edm::LogError("TriggerMenuParser") << "FAILURE: Condition " << object.getName() << " is in map but not in cor. vector " << std::endl;
2887  }
2888 
2889  }
2890 */
2891  parseMuonCorr(&object,chipNr);
2892  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
2893 
2894  //Now set some flags for this subCondition
2895  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2896  objType[jj] = gtMu;
2897  condCateg[jj] = CondMuon;
2898 
2899  } else if(object.getType() == esObjectType::Egamma ||
2900  object.getType() == esObjectType::Jet ||
2901  object.getType() == esObjectType::Tau ) {
2902 
2903  // we have an Calo object
2904  parseCaloCorr(&object,chipNr);
2905  corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
2906 
2907  //Now set some flags for this subCondition
2908  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2909  switch(object.getType()) {
2910  case esObjectType::Egamma: {
2911  objType[jj] = gtEG;
2912  }
2913  break;
2914  case esObjectType::Jet: {
2915  objType[jj] = gtJet;
2916  }
2917  break;
2918  case esObjectType::Tau: {
2919  objType[jj] = gtTau;
2920  }
2921  break;
2922  default: {
2923  }
2924  break;
2925  }
2926  condCateg[jj] = CondCalo;
2927 
2928 
2929 
2930 
2931  } else if(object.getType() == esObjectType::ETM ||
2932  object.getType() == esObjectType::ETMHF ||
2933  object.getType() == esObjectType::TOWERCOUNT ||
2934  object.getType() == esObjectType::HTM ) {
2935 
2936  // we have Energy Sum
2937  parseEnergySumCorr(&object,chipNr);
2938  corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
2939 
2940  //Now set some flags for this subCondition
2941  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2942  switch(object.getType()) {
2943  case esObjectType::ETM: {
2944  objType[jj] = GlobalObject::gtETM;
2945  }
2946  break;
2947  case esObjectType::HTM: {
2948  objType[jj] = GlobalObject::gtHTM;
2949  }
2950  break;
2951  case esObjectType::ETMHF: {
2952  objType[jj] = GlobalObject::gtETMHF;
2953  }
2954  break;
2955  case esObjectType::TOWERCOUNT: {
2956  objType[jj] = GlobalObject::gtTowerCount;
2957  }
2958  break;
2959  default: {
2960  }
2961  break;
2962  }
2963  condCateg[jj] = CondEnergySum;
2964 
2965 
2966  } else {
2967 
2968  edm::LogError("TriggerMenuParser")
2969  << "Illegal Object Type " << object.getType()
2970  << " for the correlation condition " << name << std::endl;
2971  return false;
2972 
2973  } //if block on leg types
2974 
2975  } //loop over legs
2976 
2977 
2978  // get greater equal flag for the correlation condition
2979  bool gEq = true;
2980  if (intGEq[0] != intGEq[1]) {
2981  edm::LogError("TriggerMenuParser")
2982  << "Inconsistent GEq flags for sub-conditions "
2983  << " for the correlation condition " << name << std::endl;
2984  return false;
2985 
2986  }
2987  else {
2988  gEq = (intGEq[0] != 0);
2989 
2990  }
2991 
2992 
2993  // fill the correlation condition
2994  correlationCond.setCondType(cType);
2995  correlationCond.setObjectType(objType);
2996  correlationCond.setCondGEq(gEq);
2997  correlationCond.setCondChipNr(chipNr);
2998 
2999  correlationCond.setCond0Category(condCateg[0]);
3000  correlationCond.setCond1Category(condCateg[1]);
3001 
3002  correlationCond.setCond0Index(corrIndexVal[0]);
3003  correlationCond.setCond1Index(corrIndexVal[1]);
3004 
3005  correlationCond.setCorrelationParameter(corrParameter);
3006 
3007  if (edm::isDebugEnabled() ) {
3008 
3009  std::ostringstream myCoutStream;
3010  correlationCond.print(myCoutStream);
3011  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n"
3012  << std::endl;
3013 
3014  }
3015 
3016  // insert condition into the map
3017  // condition is not duplicate, check was done at the beginning
3018 
3019  (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
3020 
3021 
3022  //
3023  return true;
3024 }
3025 
3039  const tmeventsetup::esCondition& corrCond,
3040  unsigned int chipNr) {
3041 
3042  using namespace tmeventsetup;
3043 
3044  std::string condition = "corrWithOverlapRemoval";
3045  std::string particle = "test-fix" ;
3046  std::string type = l1t2string( corrCond.getType() );
3047  std::string name = l1t2string( corrCond.getName() );
3048 
3049  LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
3050  << " (in parseCorrelationWithOverlapRemoval) " << std::endl
3051  << " condition = " << condition << std::endl
3052  << " particle = " << particle << std::endl
3053  << " type = " << type << std::endl
3054  << " name = " << name << std::endl;
3055 
3056 
3057 
3058 
3059  // create a new correlation condition
3060  CorrelationWithOverlapRemovalTemplate correlationWORCond(name);
3061 
3062  // check that the condition does not exist already in the map
3063  if ( !insertConditionIntoMap(correlationWORCond, chipNr)) {
3064 
3065  edm::LogError("TriggerMenuParser")
3066  << " Error: duplicate correlation condition (" << name << ")"
3067  << std::endl;
3068 
3069  return false;
3070  }
3071 
3072 
3073 // Define some of the quantities to store the parased information
3074 
3075  // condition type BLW (Do we change this to the type of correlation condition?)
3077 
3078  // three objects (for sure)
3079  const int nrObj = 3;
3080 
3081  // object types and greater equal flag - filled in the loop
3082  int intGEq[nrObj] = { -1, -1, -1 };
3083  std::vector<GlobalObject> objType(nrObj); //BLW do we want to define these as a different type?
3084  std::vector<GtConditionCategory> condCateg(nrObj); //BLW do we want to change these categories
3085 
3086  // correlation flag and index in the cor*vector
3087  const bool corrFlag = true;
3088  int corrIndexVal[nrObj] = { -1, -1, -1 };
3089 
3090 
3091  // Storage of the correlation selection
3093  corrParameter.chargeCorrelation = 1; //ignore charge correlation for corr-legs
3094 
3095 // Get the correlation Cuts on the legs
3096  int cutType = 0;
3097  const std::vector<esCut>& cuts = corrCond.getCuts();
3098  for (size_t jj = 0; jj < cuts.size(); jj++)
3099  {
3100  const esCut cut = cuts.at(jj);
3101 
3102  if(cut.getCutType() == esCutType::ChargeCorrelation) {
3103  if( cut.getData()=="ls" ) corrParameter.chargeCorrelation = 2;
3104  else if( cut.getData()=="os" ) corrParameter.chargeCorrelation = 4;
3105  else corrParameter.chargeCorrelation = 1; //ignore charge correlation
3106  } else {
3107 
3108  //
3109  // Unitl utm has method to calculate these, do the integer value calculation with precision.
3110  //
3111  double minV = cut.getMinimum().value;
3112  double maxV = cut.getMaximum().value;
3113 
3114  //Scale down very large numbers out of xml
3115  if(maxV > 1.0e8) maxV = 1.0e8;
3116 
3117  if(cut.getCutType() == esCutType::DeltaEta) {
3118  //std::cout << "DeltaEta Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3119  corrParameter.minEtaCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
3120  corrParameter.maxEtaCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
3121  corrParameter.precEtaCut = cut.getMinimum().index;
3122  cutType = cutType | 0x1;
3123  } else if (cut.getCutType() == esCutType::DeltaPhi) {
3124  //std::cout << "DeltaPhi Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3125  corrParameter.minPhiCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
3126  corrParameter.maxPhiCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
3127  corrParameter.precPhiCut = cut.getMinimum().index;
3128  cutType = cutType | 0x2;
3129  } else if (cut.getCutType() == esCutType::DeltaR) {
3130  //std::cout << "DeltaR Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3131  corrParameter.minDRCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
3132  corrParameter.maxDRCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
3133  corrParameter.precDRCut = cut.getMinimum().index;
3134  cutType = cutType | 0x4;
3135  } else if (cut.getCutType() == esCutType::Mass) {
3136  //std::cout << "Mass Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3137  corrParameter.minMassCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
3138  corrParameter.maxMassCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
3139  corrParameter.precMassCut = cut.getMinimum().index;
3140  cutType = cutType | 0x8;
3141  }
3142  if(cut.getCutType() == esCutType::OvRmDeltaEta) {
3143  //std::cout << "OverlapRemovalDeltaEta Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3144  corrParameter.minOverlapRemovalEtaCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
3145  corrParameter.maxOverlapRemovalEtaCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
3146  corrParameter.precOverlapRemovalEtaCut = cut.getMinimum().index;
3147  cutType = cutType | 0x10;
3148  } else if (cut.getCutType() == esCutType::OvRmDeltaPhi) {
3149  //std::cout << "OverlapRemovalDeltaPhi Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3150  corrParameter.minOverlapRemovalPhiCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
3151  corrParameter.maxOverlapRemovalPhiCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
3152  corrParameter.precOverlapRemovalPhiCut = cut.getMinimum().index;
3153  cutType = cutType | 0x20;
3154  } else if (cut.getCutType() == esCutType::OvRmDeltaR) {
3155  //std::cout << "DeltaR Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3156  corrParameter.minOverlapRemovalDRCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
3157  corrParameter.maxOverlapRemovalDRCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
3158  corrParameter.precOverlapRemovalDRCut = cut.getMinimum().index;
3159  cutType = cutType | 0x40;
3160  }
3161 
3162  }
3163 
3164  }
3165  corrParameter.corrCutType = cutType;
3166 
3167 // Get the two objects that form the legs
3168  const std::vector<esObject>& objects = corrCond.getObjects();
3169  if(objects.size() != 3) {
3170  edm::LogError("TriggerMenuParser")
3171  << "incorrect number of objects for the correlation condition with overlap removal " << name << " corrFlag " << corrFlag << std::endl;
3172  return false;
3173  }
3174 
3175 // loop over legs
3176  for (size_t jj = 0; jj < objects.size(); jj++)
3177  {
3178  const esObject& object = objects.at(jj);
3179  //std::cout << " obj name = " << object.getName() << "\n";
3180  //std::cout << " obj type = " << object.getType() << "\n";
3181  //std::cout << " obj op = " << object.getComparisonOperator() << "\n";
3182  //std::cout << " obj bx = " << object.getBxOffset() << "\n";
3183  //std::cout << "type = done" << std::endl;
3184 
3185 
3186 // check the leg type
3187  if(object.getType() == esObjectType::Muon) {
3188  // we have a muon
3189 
3190 /*
3191  //BLW Hold on to this code we may need to go back to it at some point.
3192  // Now we are putting ALL leg conditions into the vector (so there are duplicates)
3193  // This is potentially a place to slim down the code. Note: We currently evaluate the
3194  // conditions every time, so even if we put the condition in the vector once, we would
3195  // still evaluate it multiple times. This is a place for optimization.
3196  {
3197 
3198  parseMuonCorr(&object,chipNr);
3199  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
3200 
3201  } else {
3202  LogDebug("TriggerMenuParser") << "Not Adding Correlation Muon Condition to Map...looking for the condition in Muon Cor Vector" << std::endl;
3203  bool found = false;
3204  int index = 0;
3205  while(!found && index<(int)((m_corMuonTemplate[chipNr]).size()) ) {
3206  if( (m_corMuonTemplate[chipNr]).at(index).condName() == object.getName() ) {
3207  LogDebug("TriggerMenuParser") << "Found condition " << object.getName() << " in vector at index " << index << std::endl;
3208  found = true;
3209  } else {
3210  index++;
3211  }
3212  }
3213  if(found) {
3214  corrIndexVal[jj] = index;
3215  } else {
3216  edm::LogError("TriggerMenuParser") << "FAILURE: Condition " << object.getName() << " is in map but not in cor. vector " << std::endl;
3217  }
3218 
3219  }
3220 */
3221  parseMuonCorr(&object,chipNr);
3222  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
3223 
3224  //Now set some flags for this subCondition
3225  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3226  objType[jj] = gtMu;
3227  condCateg[jj] = CondMuon;
3228 
3229  } else if(object.getType() == esObjectType::Egamma ||
3230  object.getType() == esObjectType::Jet ||
3231  object.getType() == esObjectType::Tau ) {
3232 
3233  // we have an Calo object
3234  parseCaloCorr(&object,chipNr);
3235  corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
3236 
3237  //Now set some flags for this subCondition
3238  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3239  switch(object.getType()) {
3240  case esObjectType::Egamma: {
3241  objType[jj] = gtEG;
3242  }
3243  break;
3244  case esObjectType::Jet: {
3245  objType[jj] = gtJet;
3246  }
3247  break;
3248  case esObjectType::Tau: {
3249  objType[jj] = gtTau;
3250  }
3251  break;
3252  default: {
3253  }
3254  break;
3255  }
3256  condCateg[jj] = CondCalo;
3257 
3258 
3259 
3260 
3261  } else if(object.getType() == esObjectType::ETM ||
3262  object.getType() == esObjectType::ETMHF ||
3263  object.getType() == esObjectType::TOWERCOUNT ||
3264  object.getType() == esObjectType::HTM ) {
3265 
3266  // we have Energy Sum
3267  parseEnergySumCorr(&object,chipNr);
3268  corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
3269 
3270  //Now set some flags for this subCondition
3271  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3272  switch(object.getType()) {
3273  case esObjectType::ETM: {
3274  objType[jj] = GlobalObject::gtETM;
3275  }
3276  break;
3277  case esObjectType::HTM: {
3278  objType[jj] = GlobalObject::gtHTM;
3279  }
3280  break;
3281  case esObjectType::ETMHF: {
3282  objType[jj] = GlobalObject::gtETMHF;
3283  }
3284  break;
3285  case esObjectType::TOWERCOUNT: {
3286  objType[jj] = GlobalObject::gtTowerCount;
3287  }
3288  break;
3289  default: {
3290  }
3291  break;
3292  }
3293  condCateg[jj] = CondEnergySum;
3294 
3295 
3296  } else {
3297 
3298  edm::LogError("TriggerMenuParser")
3299  << "Illegal Object Type " << object.getType()
3300  << " for the correlation condition " << name << std::endl;
3301  return false;
3302 
3303  } //if block on leg types
3304 
3305  } //loop over legs
3306 
3307 
3308  // get greater equal flag for the correlation condition
3309  bool gEq = true;
3310  if (intGEq[0] != intGEq[1]) {
3311  edm::LogError("TriggerMenuParser")
3312  << "Inconsistent GEq flags for sub-conditions "
3313  << " for the correlation condition " << name << std::endl;
3314  return false;
3315 
3316  }
3317  else {
3318  gEq = (intGEq[0] != 0);
3319 
3320  }
3321 
3322 
3323  // fill the correlation condition
3324  correlationWORCond.setCondType(cType);
3325  correlationWORCond.setObjectType(objType);
3326  correlationWORCond.setCondGEq(gEq);
3327  correlationWORCond.setCondChipNr(chipNr);
3328 
3329  correlationWORCond.setCond0Category(condCateg[0]);
3330  correlationWORCond.setCond1Category(condCateg[1]);
3331  correlationWORCond.setCond2Category(condCateg[2]);
3332 
3333  correlationWORCond.setCond0Index(corrIndexVal[0]);
3334  correlationWORCond.setCond1Index(corrIndexVal[1]);
3335  correlationWORCond.setCond2Index(corrIndexVal[2]);
3336 
3337  correlationWORCond.setCorrelationWithOverlapRemovalParameter(corrParameter);
3338 
3339  if (edm::isDebugEnabled() ) {
3340 
3341  std::ostringstream myCoutStream;
3342  correlationWORCond.print(myCoutStream);
3343  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n"
3344  << std::endl;
3345 
3346  }
3347 
3348  // insert condition into the map
3349  // condition is not duplicate, check was done at the beginning
3350 
3351  (m_vecCorrelationWithOverlapRemovalTemplate[chipNr]).push_back(correlationWORCond);
3352 
3353 
3354  //
3355  return true;
3356 }
3357 
3358 
3370 bool l1t::TriggerMenuParser::parseAlgorithm( tmeventsetup::esAlgorithm algorithm,
3371  unsigned int chipNr) {
3372 
3373 
3374  using namespace tmeventsetup;
3375  //using namespace Algorithm;
3376 
3377 
3378  // get alias
3379  std::string algAlias = algorithm.getName();
3380  std::string algName = algorithm.getName();
3381 
3382  if (algAlias == "") {
3383  algAlias = algName;
3384  LogDebug("TriggerMenuParser")
3385  << "\n No alias defined for algorithm. Alias set to algorithm name."
3386  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3387  << std::endl;
3388  } else {
3389  //LogDebug("TriggerMenuParser")
3390  LogDebug("TriggerMenuParser") << "\n Alias defined for algorithm."
3391  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3392  << std::endl;
3393  }
3394 
3395  // get the logical expression
3396  std::string logExpression = algorithm.getExpressionInCondition();
3397 
3398  LogDebug("TriggerMenuParser")
3399  << " Logical expression: " << logExpression
3400  << " Chip number: " << chipNr
3401  << std::endl;
3402 
3403  // determine output pin
3404  int outputPin = algorithm.getIndex();
3405 
3406 
3407  //LogTrace("TriggerMenuParser")
3408  LogDebug("TriggerMenuParser") << " Output pin: " << outputPin
3409  << std::endl;
3410 
3411 
3412  // compute the bit number from chip number, output pin and order of the chips
3413  // pin numbering start with 1, bit numbers with 0
3414  int bitNumber = outputPin;// + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
3415 
3416  //LogTrace("TriggerMenuParser")
3417  LogDebug("TriggerMenuParser") << " Bit number: " << bitNumber
3418  << std::endl;
3419 
3420  // create a new algorithm and insert it into algorithm map
3421  GlobalAlgorithm alg(algName, logExpression, bitNumber);
3422  alg.setAlgoChipNumber(static_cast<int>(chipNr));
3423  alg.setAlgoAlias(algAlias);
3424 
3425  if (edm::isDebugEnabled() ) {
3426 
3427  std::ostringstream myCoutStream;
3428  alg.print(myCoutStream);
3429  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
3430 
3431  }
3432 
3433  // insert algorithm into the map
3434  if ( !insertAlgorithmIntoMap(alg)) {
3435  return false;
3436  }
3437 
3438  return true;
3439 
3440 }
3441 
3442 
3443 // 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