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