test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerMenuParser.cc
Go to the documentation of this file.
1 
17 // this class header
18 #include "TriggerMenuParser.h"
19 
20 // system include files
21 #include <string>
22 #include <vector>
23 
24 #include <iostream>
25 #include <fstream>
26 #include <iomanip>
27 
28 #include <boost/cstdint.hpp>
29 
31 
34 
35 #include "tmEventSetup/tmEventSetup.hh"
36 #include "tmEventSetup/esTriggerMenu.hh"
37 #include "tmEventSetup/esAlgorithm.hh"
38 #include "tmEventSetup/esCondition.hh"
39 #include "tmEventSetup/esObject.hh"
40 #include "tmEventSetup/esCut.hh"
41 #include "tmEventSetup/esScale.hh"
42 #include "tmGrammar/Algorithm.hh"
43 
44 
45 
46 // constructor
48  m_triggerMenuInterface("NULL"),
49  m_triggerMenuName("NULL"), m_triggerMenuImplementation(0x0), m_scaleDbKey("NULL")
50 
51 {
52 
53  // menu names, scale key initialized to NULL due to ORACLE treatment of strings
54 
55  // empty
56 
57 }
58 
59 // destructor
61 
62  clearMaps();
63 
64 }
65 
66 // set the number of condition chips in GTL
68  const unsigned int& numberConditionChipsValue) {
69 
70  m_numberConditionChips = numberConditionChipsValue;
71 
72 }
73 
74 // set the number of pins on the GTL condition chips
75 void l1t::TriggerMenuParser::setGtPinsOnConditionChip(const unsigned int& pinsOnConditionChipValue) {
76 
77  m_pinsOnConditionChip = pinsOnConditionChipValue;
78 
79 }
80 
81 // set the correspondence "condition chip - GTL algorithm word"
82 // in the hardware
84  const std::vector<int>& orderConditionChipValue) {
85 
86  m_orderConditionChip = orderConditionChipValue;
87 
88 }
89 
90 // set the number of physics trigger algorithms
92  const unsigned int& numberPhysTriggersValue) {
93 
94  m_numberPhysTriggers = numberPhysTriggersValue;
95 
96 }
97 
98 
99 // set the condition maps
100 void l1t::TriggerMenuParser::setGtConditionMap(const std::vector<ConditionMap>& condMap) {
101  m_conditionMap = condMap;
102 }
103 
104 // set the trigger menu name
106  m_triggerMenuInterface = menuInterface;
107 }
108 
109 // set the trigger menu uuid
111  m_triggerMenuUUID = uuid;
112 }
113 
115  m_triggerMenuName = menuName;
116 }
117 
118 void l1t::TriggerMenuParser::setGtTriggerMenuImplementation(const unsigned long& menuImplementation) {
119  m_triggerMenuImplementation = menuImplementation;
120 }
121 
122 // set menu associated scale key
124  m_scaleDbKey = scaleKey;
125 }
126 
127 // set the vectors containing the conditions
129  const std::vector<std::vector<MuonTemplate> >& vecMuonTempl) {
130 
131  m_vecMuonTemplate = vecMuonTempl;
132 }
133 
135  const std::vector<std::vector<CaloTemplate> >& vecCaloTempl) {
136 
137  m_vecCaloTemplate = vecCaloTempl;
138 }
139 
141  const std::vector<std::vector<EnergySumTemplate> >& vecEnergySumTempl) {
142 
143  m_vecEnergySumTemplate = vecEnergySumTempl;
144 }
145 
146 
147 
149  const std::vector<std::vector<ExternalTemplate> >& vecExternalTempl) {
150 
151  m_vecExternalTemplate = vecExternalTempl;
152 }
153 
154 
156  const std::vector<std::vector<CorrelationTemplate> >& vecCorrelationTempl) {
157 
158  m_vecCorrelationTemplate = vecCorrelationTempl;
159 }
160 
161 // set the vectors containing the conditions for correlation templates
162 //
164  const std::vector<std::vector<MuonTemplate> >& corMuonTempl) {
165 
166  m_corMuonTemplate = corMuonTempl;
167 }
168 
170  const std::vector<std::vector<CaloTemplate> >& corCaloTempl) {
171 
172  m_corCaloTemplate = corCaloTempl;
173 }
174 
176  const std::vector<std::vector<EnergySumTemplate> >& corEnergySumTempl) {
177 
178  m_corEnergySumTemplate = corEnergySumTempl;
179 }
180 
181 
182 
183 
184 // set the algorithm map (by algorithm names)
186  m_algorithmMap = algoMap;
187 }
188 
189 // set the algorithm map (by algorithm aliases)
191  m_algorithmAliasMap = algoMap;
192 }
193 
194 
195 
196 std::map<std::string, unsigned int> l1t::TriggerMenuParser::getExternalSignals(const L1TUtmTriggerMenu* utmMenu) {
197 
198  using namespace tmeventsetup;
199  const esTriggerMenu* menu = reinterpret_cast<const esTriggerMenu*> (utmMenu);
200  const std::map<std::string, esCondition>& condMap = menu->getConditionMap();
201 
202  std::map<std::string, unsigned int> extBitMap;
203 
204  //loop over the algorithms
205  for (std::map<std::string, esCondition>::const_iterator cit = condMap.begin();
206  cit != condMap.end(); cit++)
207  {
208  const esCondition& condition = cit->second;
209  if(condition.getType() == esConditionType::Externals ) {
210 
211  // Get object for External conditions
212  const std::vector<esObject>& objects = condition.getObjects();
213  for (size_t jj = 0; jj < objects.size(); jj++) {
214 
215  const esObject object = objects.at(jj);
216  if(object.getType() == esObjectType::EXT) {
217 
218  unsigned int channelID = object.getExternalChannelId();
219  std::string name = object.getExternalSignalName();
220 
221  if (extBitMap.count(name) == 0) extBitMap.insert(std::map<std::string, unsigned int>::value_type(name,channelID));
222  }
223  }
224 
225  }
226 
227  }
228 /*
229  for (std::map<std::string, unsigned int>::const_iterator cit = extBitMap.begin();
230  cit != extBitMap.end(); cit++) {
231  std::cout << " Ext Map: Name " << cit->first << " Bit " << cit->second << std::endl;
232  }
233 */
234  return extBitMap;
235 
236 }
237 
238 // parse def.xml file
240 
241 
242  // resize the vector of condition maps
243  // the number of condition chips should be correctly set before calling parseXmlFile
244  m_conditionMap.resize(m_numberConditionChips);
245 
246  m_vecMuonTemplate.resize(m_numberConditionChips);
247  m_vecCaloTemplate.resize(m_numberConditionChips);
248  m_vecEnergySumTemplate.resize(m_numberConditionChips);
249  m_vecExternalTemplate.resize(m_numberConditionChips);
250 
251  m_vecCorrelationTemplate.resize(m_numberConditionChips);
252  m_corMuonTemplate.resize(m_numberConditionChips);
253  m_corCaloTemplate.resize(m_numberConditionChips);
254  m_corEnergySumTemplate.resize(m_numberConditionChips);
255 
256  using namespace tmeventsetup;
257  using namespace Algorithm;
258 
259  const esTriggerMenu* menu = reinterpret_cast<const esTriggerMenu*> (utmMenu);
260 
261  //get the meta data
262  m_triggerMenuDescription = menu->getComment();
263  m_triggerMenuDate = menu->getDatetime();
264  m_triggerMenuImplementation = ( getMmHashN(menu->getFirmwareUuid()) & 0xFFFFFFFF); //make sure we only have 32 bits
265  m_triggerMenuName = menu->getName();
266  m_triggerMenuInterface = menu->getVersion(); //BLW: correct descriptor?
267  m_triggerMenuUUID = ( getMmHashN(menu->getName()) & 0xFFFFFFFF); //make sure we only have 32 bits
268 
269  const std::map<std::string, esAlgorithm>& algoMap = menu->getAlgorithmMap();
270  const std::map<std::string, esCondition>& condMap = menu->getConditionMap();
271  const std::map<std::string, esScale>& scaleMap = menu->getScaleMap();
272 
273  // parse the scales
274  m_gtScales.setScalesName( menu->getScaleSetName() );
275  parseScales(scaleMap);
276 
277 
278  //loop over the algorithms
279  for (std::map<std::string, esAlgorithm>::const_iterator cit = algoMap.begin();
280  cit != algoMap.end(); cit++)
281  {
282  //condition chip (artifact) TO DO: Update
283  int chipNr = 0;
284 
285  //get algorithm
286  const esAlgorithm& algo = cit->second;
287 
288  //parse the algorithm
289  parseAlgorithm(algo,chipNr); //blw
290 
291  //get conditions for this algorithm
292  const std::vector<std::string>& rpn_vec = algo.getRpnVector();
293  for (size_t ii = 0; ii < rpn_vec.size(); ii++)
294  {
295  const std::string& token = rpn_vec.at(ii);
296  if (isGate(token)) continue;
297 // long hash = getHash(token);
298  const esCondition& condition = condMap.find(token)->second;
299 
300 
301  //check to see if this condtion already exists
302  if ((m_conditionMap[chipNr]).count(condition.getName()) == 0) {
303 
304  // parse Calo Conditions (EG, Jets, Taus)
305  if(condition.getType() == esConditionType::SingleEgamma ||
306  condition.getType() == esConditionType::DoubleEgamma ||
307  condition.getType() == esConditionType::TripleEgamma ||
308  condition.getType() == esConditionType::QuadEgamma ||
309  condition.getType() == esConditionType::SingleTau ||
310  condition.getType() == esConditionType::DoubleTau ||
311  condition.getType() == esConditionType::TripleTau ||
312  condition.getType() == esConditionType::QuadTau ||
313  condition.getType() == esConditionType::SingleJet ||
314  condition.getType() == esConditionType::DoubleJet ||
315  condition.getType() == esConditionType::TripleJet ||
316  condition.getType() == esConditionType::QuadJet )
317  {
318  parseCalo(condition,chipNr,false);
319 
320  // parse Energy Sums
321  } else if(condition.getType() == esConditionType::TotalEt ||
322  condition.getType() == esConditionType::TotalEtEM ||
323  condition.getType() == esConditionType::TotalHt ||
324  condition.getType() == esConditionType::MissingEt ||
325  condition.getType() == esConditionType::MissingHt ||
326  condition.getType() == esConditionType::MissingEtHF ||
327  condition.getType() == esConditionType::TowerCount ||
328  condition.getType() == esConditionType::MinBiasHFP0 ||
329  condition.getType() == esConditionType::MinBiasHFM0 ||
330  condition.getType() == esConditionType::MinBiasHFP1 ||
331  condition.getType() == esConditionType::MinBiasHFM1 )
332  {
333  parseEnergySum(condition,chipNr,false);
334 
335  //parse Muons
336  } else if(condition.getType() == esConditionType::SingleMuon ||
337  condition.getType() == esConditionType::DoubleMuon ||
338  condition.getType() == esConditionType::TripleMuon ||
339  condition.getType() == esConditionType::QuadMuon )
340  {
341  parseMuon(condition,chipNr,false);
342 
343 
344  //parse Correlation Conditions
345  } else if(condition.getType() == esConditionType::MuonMuonCorrelation ||
346  condition.getType() == esConditionType::MuonEsumCorrelation ||
347  condition.getType() == esConditionType::CaloMuonCorrelation ||
348  condition.getType() == esConditionType::CaloCaloCorrelation ||
349  condition.getType() == esConditionType::CaloEsumCorrelation ||
350  condition.getType() == esConditionType::InvariantMass )
351  {
352  parseCorrelation(condition,chipNr);
353 
354  //parse Muons
355  } else if(condition.getType() == esConditionType::Externals )
356  {
357  parseExternal(condition,chipNr);
358 
359  }
360 
361  }//if condition is a new one
362  }//loop over conditions
363  }//loop over algorithms
364 
365  return;
366 
367 
368 }
369 
370 
371 
372 //
373 
375 
376  m_triggerMenuInterfaceDate = val;
377 
378 }
379 
381 
382  m_triggerMenuInterfaceAuthor = val;
383 
384 }
385 
387 
388  m_triggerMenuInterfaceDescription = val;
389 
390 }
391 
392 
394 
395  m_triggerMenuDate = val;
396 
397 }
398 
400 
401  m_triggerMenuAuthor = val;
402 
403 }
404 
406 
407  m_triggerMenuDescription = val;
408 
409 }
410 
412 
413  m_algorithmImplementation = val;
414 
415 }
416 
417 
418 
419 // methods for conditions and algorithms
420 
421 // clearMaps - delete all conditions and algorithms in
422 // the maps and clear the maps.
424 
425  // loop over condition maps (one map per condition chip)
426  // then loop over conditions in the map
427  for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip
428  != m_conditionMap.end(); itCondOnChip++) {
429 
430  // the conditions in the maps are deleted in L1uGtTriggerMenu, not here
431 
432  itCondOnChip->clear();
433 
434  }
435 
436  // the algorithms in the maps are deleted in L1uGtTriggerMenu, not here
437  m_algorithmMap.clear();
438 
439 }
440 
441 // insertConditionIntoMap - safe insert of condition into condition map.
442 // if the condition name already exists, do not insert it and return false
444 
445  std::string cName = cond.condName();
446  LogTrace("TriggerMenuParser")
447  << " Trying to insert condition \"" << cName << "\" in the condition map." ;
448 
449  // no condition name has to appear twice!
450  if ((m_conditionMap[chipNr]).count(cName) != 0) {
451  LogTrace("TriggerMenuParser") << " Condition " << cName
452  << " already exists - not inserted!" << std::endl;
453  return false;
454  }
455 
456  (m_conditionMap[chipNr])[cName] = &cond;
457  LogTrace("TriggerMenuParser")
458  << " OK - condition inserted!"
459  << std::endl;
460 
461 
462  return true;
463 
464 }
465 
466 // insert an algorithm into algorithm map
468 
469  std::string algName = alg.algoName();
470  std::string algAlias = alg.algoAlias();
471  //LogTrace("TriggerMenuParser")
472  //<< " Trying to insert algorithm \"" << algName << "\" in the algorithm map." ;
473 
474  // no algorithm name has to appear twice!
475  if (m_algorithmMap.count(algName) != 0) {
476  LogTrace("TriggerMenuParser") << " Algorithm \"" << algName
477  << "\"already exists in the algorithm map- not inserted!" << std::endl;
478  return false;
479  }
480 
481  if (m_algorithmAliasMap.count(algAlias) != 0) {
482  LogTrace("TriggerMenuParser") << " Algorithm alias \"" << algAlias
483  << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
484  return false;
485  }
486 
487  // bit number less than zero or greater than maximum number of algorithms
488  int bitNumber = alg.algoBitNumber();
489  if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
490  LogTrace("TriggerMenuParser") << " Bit number " << bitNumber
491  << " outside allowed range [0, " << m_numberPhysTriggers
492  << ") - algorithm not inserted!" << std::endl;
493  return false;
494  }
495 
496  // maximum number of algorithms
497  if (m_algorithmMap.size() >= m_numberPhysTriggers) {
498  LogTrace("TriggerMenuParser") << " More than maximum allowed "
499  << m_numberPhysTriggers << " algorithms in the algorithm map - not inserted!"
500  << std::endl;
501  return false;
502  }
503 
504 
505  // chip number outside allowed values
506  int chipNr = alg.algoChipNumber(static_cast<int>(m_numberConditionChips),
507  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
508 
509  if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
510  LogTrace("TriggerMenuParser") << " Chip number " << chipNr
511  << " outside allowed range [0, " << m_numberConditionChips
512  << ") - algorithm not inserted!" << std::endl;
513  return false;
514  }
515 
516  // output pin outside allowed values
517  int outputPin = alg.algoOutputPin(static_cast<int>(m_numberConditionChips),
518  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
519 
520  if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
521  LogTrace("TriggerMenuParser") << " Output pin " << outputPin
522  << " outside allowed range [0, " << m_pinsOnConditionChip
523  << "] - algorithm not inserted!" << std::endl;
524  return false;
525  }
526 
527  // no two algorithms on the same chip can have the same output pin
528  for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
529 
530  int iPin = (itAlgo->second).algoOutputPin( static_cast<int>(m_numberConditionChips),
531  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
532  std::string iName = itAlgo->first;
533  int iChip = (itAlgo->second).algoChipNumber(static_cast<int>(m_numberConditionChips),
534  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
535 
536  if ( (outputPin == iPin) && (chipNr == iChip)) {
537  LogTrace("TriggerMenuParser") << " Output pin " << outputPin
538  << " is the same as for algorithm " << iName
539  << "\n from the same chip number " << chipNr << " - algorithm not inserted!"
540  << std::endl;
541  return false;
542  }
543 
544  }
545 
546  // insert algorithm
547  m_algorithmMap[algName] = alg;
548  m_algorithmAliasMap[algAlias] = alg;
549 
550  //LogTrace("TriggerMenuParser")
551  //<< " OK - algorithm inserted!"
552  //<< std::endl;
553 
554  return true;
555 
556 }
557 
558 
560  std::stringstream ss;
561  ss << data;
562  return ss.str();
563 }
565  std::stringstream ss;
566  ss << data;
567  int value;
568  ss >> value;
569  return value;
570 }
571 
572 
580 bool l1t::TriggerMenuParser::parseScales(std::map<std::string, tmeventsetup::esScale> scaleMap) {
581 
582  using namespace tmeventsetup;
583 
584 // Setup ScaleParameter to hold information from parsing
590  GlobalScales::ScaleParameters ettEmScales;
592  GlobalScales::ScaleParameters etmHfScales;
595 
596 
597 // Start by parsing the Scale Map
598  for (std::map<std::string, esScale>::const_iterator cit = scaleMap.begin();
599  cit != scaleMap.end(); cit++)
600  {
601  const esScale& scale = cit->second;
602 
603  GlobalScales::ScaleParameters *scaleParam;
604  if (scale.getObjectType() == esObjectType::Muon) scaleParam = &muScales;
605  else if (scale.getObjectType() == esObjectType::Egamma) scaleParam = &egScales;
606  else if (scale.getObjectType() == esObjectType::Tau) scaleParam = &tauScales;
607  else if (scale.getObjectType() == esObjectType::Jet) scaleParam = &jetScales;
608  else if (scale.getObjectType() == esObjectType::ETT) scaleParam = &ettScales;
609  else if (scale.getObjectType() == esObjectType::ETTEM) scaleParam = &ettEmScales;
610  else if (scale.getObjectType() == esObjectType::ETM) scaleParam = &etmScales;
611  else if (scale.getObjectType() == esObjectType::ETMHF) scaleParam = &etmHfScales;
612  else if (scale.getObjectType() == esObjectType::HTT) scaleParam = &httScales;
613  else if (scale.getObjectType() == esObjectType::HTM) scaleParam = &htmScales;
614  else scaleParam = 0;
615 
616  if(scaleParam != 0) {
617  switch(scale.getScaleType()) {
618  case esScaleType::EtScale: {
619  scaleParam->etMin = scale.getMinimum();
620  scaleParam->etMax = scale.getMaximum();
621  scaleParam->etStep = scale.getStep();
622 
623  //Get bin edges
624  const std::vector<esBin> binsV = scale.getBins();
625  for(unsigned int i=0; i<binsV.size(); i++) {
626  const esBin& bin = binsV.at(i);
627  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
628  scaleParam->etBins.push_back(binLimits);
629  }
630 
631  // If this is an energy sum fill dummy values for eta and phi
632  // There are no scales for these in the XML so the other case statements will not be seen....do it here.
633  if(scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT ||
634  scale.getObjectType() == esObjectType::ETM || scale.getObjectType() == esObjectType::HTM ||
635  scale.getObjectType() == esObjectType::ETTEM || scale.getObjectType() == esObjectType::ETMHF) {
636 
637  scaleParam->etaMin = -1.;
638  scaleParam->etaMax = -1.;
639  scaleParam->etaStep = -1.;
640  if(scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT || scale.getObjectType() == esObjectType::ETTEM) {
641 // if(scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT) {
642  scaleParam->phiMin = -1.;
643  scaleParam->phiMax = -1.;
644  scaleParam->phiStep = -1.;
645  }
646  }
647  }
648  break;
649  case esScaleType::EtaScale: {
650  scaleParam->etaMin = scale.getMinimum();
651  scaleParam->etaMax = scale.getMaximum();
652  scaleParam->etaStep = scale.getStep();
653 
654  //Get bin edges
655  const std::vector<esBin> binsV = scale.getBins();
656  scaleParam->etaBins.resize(pow(2,scale.getNbits()));
657  for(unsigned int i=0; i<binsV.size(); i++) {
658  const esBin& bin = binsV.at(i);
659  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
660  scaleParam->etaBins.at(bin.hw_index) = binLimits;
661  }
662  }
663  break;
664  case esScaleType::PhiScale: {
665  scaleParam->phiMin = scale.getMinimum();
666  scaleParam->phiMax = scale.getMaximum();
667  scaleParam->phiStep = scale.getStep();
668 
669  //Get bin edges
670  const std::vector<esBin> binsV = scale.getBins();
671  scaleParam->phiBins.resize(pow(2,scale.getNbits()));
672  for(unsigned int i=0; i<binsV.size(); i++) {
673  const esBin& bin = binsV.at(i);
674  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
675  scaleParam->phiBins.at(bin.hw_index) = binLimits;
676  }
677  }
678  break;
679  default:
680 
681  break;
682  } //end switch
683  } //end valid scale
684  } //end loop over scaleMap
685 
686  // put the ScaleParameters into the class
687  m_gtScales.setMuonScales(muScales);
688  m_gtScales.setEGScales(egScales);
689  m_gtScales.setTauScales(tauScales);
690  m_gtScales.setJetScales(jetScales);
691  m_gtScales.setETTScales(ettScales);
692  m_gtScales.setETTEmScales(ettEmScales);
693  m_gtScales.setETMScales(etmScales);
694  m_gtScales.setETMHfScales(etmHfScales);
695  m_gtScales.setHTTScales(httScales);
696  m_gtScales.setHTMScales(htmScales);
697 
698 
699 
700 // Setup the LUT for the Scale Conversions
701  bool hasPrecision = false;
702  std::map<std::string, unsigned int> precisions;
703  getPrecisions(precisions, scaleMap);
704  for (std::map<std::string, unsigned int>::const_iterator cit = precisions.begin(); cit != precisions.end(); cit++)
705  {
706  //std::cout << cit->first << " = " << cit->second << "\n";
707  hasPrecision = true;
708  }
709 
710 
711  if (hasPrecision)
712  {
713 
714  //Start with the Cal - Muon Eta LUTS
715  //----------------------------------
716  parseCalMuEta_LUTS(scaleMap, "EG", "MU");
717  parseCalMuEta_LUTS(scaleMap, "JET", "MU");
718  parseCalMuEta_LUTS(scaleMap, "TAU", "MU");
719 
720  //Now the Cal - Muon Phi LUTS
721  //-------------------------------------
722  parseCalMuPhi_LUTS(scaleMap, "EG", "MU");
723  parseCalMuPhi_LUTS(scaleMap, "JET", "MU");
724  parseCalMuPhi_LUTS(scaleMap, "TAU", "MU");
725  parseCalMuPhi_LUTS(scaleMap, "HTM", "MU");
726  parseCalMuPhi_LUTS(scaleMap, "ETM", "MU");
727  parseCalMuPhi_LUTS(scaleMap, "ETMHF", "MU");
728 
729  // Now the Pt LUTs (??? more combinations needed ??)
730  // ---------------
731  parsePt_LUTS(scaleMap, "EG", precisions["PRECISION-EG-MU-MassPt"] );
732  parsePt_LUTS(scaleMap, "MU", precisions["PRECISION-EG-MU-MassPt"] );
733  parsePt_LUTS(scaleMap, "JET", precisions["PRECISION-EG-JET-MassPt"] );
734  parsePt_LUTS(scaleMap, "TAU", precisions["PRECISION-EG-TAU-MassPt"] );
735 
736  // Now the Delta Eta/Cosh LUTs (must be done in groups)
737  // ----------------------------------------------------
738  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
739  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","JET",precisions["PRECISION-EG-JET-Delta"],precisions["PRECISION-EG-JET-Math"]);
740  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","TAU",precisions["PRECISION-EG-TAU-Delta"],precisions["PRECISION-EG-TAU-Math"]);
741  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
742 
743  parseDeltaEta_Cosh_LUTS(scaleMap,"JET","JET",precisions["PRECISION-JET-JET-Delta"],precisions["PRECISION-JET-JET-Math"]);
744  parseDeltaEta_Cosh_LUTS(scaleMap,"JET","TAU",precisions["PRECISION-JET-TAU-Delta"],precisions["PRECISION-JET-TAU-Math"]);
745  parseDeltaEta_Cosh_LUTS(scaleMap,"JET","MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
746 
747  parseDeltaEta_Cosh_LUTS(scaleMap,"TAU","TAU",precisions["PRECISION-TAU-TAU-Delta"],precisions["PRECISION-TAU-TAU-Math"]);
748  parseDeltaEta_Cosh_LUTS(scaleMap,"TAU","MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
749 
750  parseDeltaEta_Cosh_LUTS(scaleMap,"MU","MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
751 
752 
753  // Now the Delta Phi/Cos LUTs (must be done in groups)
754  // ----------------------------------------------------
755  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
756  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","JET",precisions["PRECISION-EG-JET-Delta"],precisions["PRECISION-EG-JET-Math"]);
757  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","TAU",precisions["PRECISION-EG-TAU-Delta"],precisions["PRECISION-EG-TAU-Math"]);
758  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","ETM",precisions["PRECISION-EG-ETM-Delta"],precisions["PRECISION-EG-ETM-Math"]);
759  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","ETMHF",precisions["PRECISION-EG-ETMHF-Delta"],precisions["PRECISION-EG-ETMHF-Math"]);
760  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","HTM",precisions["PRECISION-EG-HTM-Delta"],precisions["PRECISION-EG-HTM-Math"]);
761  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
762 
763  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","JET",precisions["PRECISION-JET-JET-Delta"],precisions["PRECISION-JET-JET-Math"]);
764  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","TAU",precisions["PRECISION-JET-TAU-Delta"],precisions["PRECISION-JET-TAU-Math"]);
765  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","ETM",precisions["PRECISION-JET-ETM-Delta"],precisions["PRECISION-JET-ETM-Math"]);
766  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","ETMHF",precisions["PRECISION-JET-ETMHF-Delta"],precisions["PRECISION-JET-ETMHF-Math"]);
767  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","HTM",precisions["PRECISION-JET-HTM-Delta"],precisions["PRECISION-JET-HTM-Math"]);
768  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
769 
770  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","TAU",precisions["PRECISION-TAU-TAU-Delta"],precisions["PRECISION-TAU-TAU-Math"]);
771  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","ETM",precisions["PRECISION-TAU-ETM-Delta"],precisions["PRECISION-TAU-ETM-Math"]);
772  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","ETMHF",precisions["PRECISION-TAU-ETMHF-Delta"],precisions["PRECISION-TAU-ETMHF-Math"]);
773  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","HTM",precisions["PRECISION-TAU-HTM-Delta"],precisions["PRECISION-TAU-HTM-Math"]);
774  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
775 
776  parseDeltaPhi_Cos_LUTS(scaleMap,"MU","ETM",precisions["PRECISION-MU-ETM-Delta"],precisions["PRECISION-MU-ETM-Math"]);
777  parseDeltaPhi_Cos_LUTS(scaleMap,"MU","ETMHF",precisions["PRECISION-MU-ETMHF-Delta"],precisions["PRECISION-MU-ETMHF-Math"]);
778  parseDeltaPhi_Cos_LUTS(scaleMap,"MU","HTM",precisions["PRECISION-MU-HTM-Delta"],precisions["PRECISION-MU-HTM-Math"]);
779  parseDeltaPhi_Cos_LUTS(scaleMap,"MU","MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
780 
781  //m_gtScales.dumpAllLUTs(std::cout);
782  //m_gtScales.print(std::cout);
783 
784  }
785 
786 
787 
788 
789 
790  return true;
791 }
792 
793 void l1t::TriggerMenuParser::parseCalMuEta_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string obj1, std::string obj2)
794 {
795 
796  using namespace tmeventsetup;
797 
798  // First Delta Eta for this set
799  std::string scLabel1 = obj1;
800  scLabel1 += "-ETA";
801  std::string scLabel2 = obj2;
802  scLabel2 += "-ETA";
803 
804  //This LUT does not exist in L1 Menu file, don't fill it
805  if( scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end()) return;
806 
807  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
808  const esScale* scale2 = &scaleMap.find(scLabel2)->second;
809 
810  std::vector<long long> lut_cal_2_mu_eta;
811  getCaloMuonEtaConversionLut(lut_cal_2_mu_eta, scale1, scale2);
812 
813  std::string lutName = obj1;
814  lutName += "-";
815  lutName += obj2;
816  m_gtScales.setLUT_CalMuEta(lutName,lut_cal_2_mu_eta);
817 
818 
819 }
820 
821 void l1t::TriggerMenuParser::parseCalMuPhi_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string obj1, std::string obj2)
822 {
823 
824  using namespace tmeventsetup;
825 
826  // First Delta Eta for this set
827  std::string scLabel1 = obj1;
828  scLabel1 += "-PHI";
829  std::string scLabel2 = obj2;
830  scLabel2 += "-PHI";
831 
832  //This LUT does not exist in L1 Menu file, don't fill it
833  if( scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end()) return;
834 
835  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
836  const esScale* scale2 = &scaleMap.find(scLabel2)->second;
837 
838 
839  std::vector<long long> lut_cal_2_mu_phi;
840  getCaloMuonPhiConversionLut(lut_cal_2_mu_phi, scale1, scale2);
841 
842  std::string lutName = obj1;
843  lutName += "-";
844  lutName += obj2;
845  m_gtScales.setLUT_CalMuPhi(lutName,lut_cal_2_mu_phi);
846 
847 
848 }
849 
850 void l1t::TriggerMenuParser::parsePt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string obj1, unsigned int prec)
851 {
852 
853  using namespace tmeventsetup;
854 
855  // First Delta Eta for this set
856  std::string scLabel1 = obj1;
857  scLabel1 += "-ET";
858 
859  //This LUT does not exist in L1 Menu file, don't fill it
860  if( scaleMap.find(scLabel1) == scaleMap.end()) return;
861 
862  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
863 
864  std::vector<long long> lut_pt;
865  getLut(lut_pt, scale1, prec);
866  m_gtScales.setLUT_Pt(scLabel1,lut_pt,prec);
867 
868 
869 }
870 
871 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)
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  std::vector<double> val_delta_eta;
888  std::vector<long long> lut_delta_eta;
889  size_t n = getDeltaVector(val_delta_eta, scale1, scale2);
890  setLut(lut_delta_eta, val_delta_eta, prec1);
891  std::string lutName = obj1;
892  lutName += "-";
893  lutName += obj2;
894  m_gtScales.setLUT_DeltaEta(lutName,lut_delta_eta,prec1);
895 
896  // Second Get the Cosh for this delta Eta Set
897  std::vector<long long> lut_cosh;
898  applyCosh(val_delta_eta, n);
899  setLut(lut_cosh, val_delta_eta, prec2);
900  m_gtScales.setLUT_Cosh(lutName,lut_cosh,prec2);
901 
902 }
903 
904 void l1t::TriggerMenuParser::parseDeltaPhi_Cos_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string obj1, std::string obj2, unsigned int prec1, unsigned int prec2)
905 {
906 
907  using namespace tmeventsetup;
908 
909  // First Delta phi for this set
910  std::string scLabel1 = obj1;
911  scLabel1 += "-PHI";
912  std::string scLabel2 = obj2;
913  scLabel2 += "-PHI";
914 
915  //This LUT does not exist in L1 Menu file, don't fill it
916  if( scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end()) return;
917 
918  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
919  const esScale* scale2 = &scaleMap.find(scLabel2)->second;
920  std::vector<double> val_delta_phi;
921  std::vector<long long> lut_delta_phi;
922  size_t n = getDeltaVector(val_delta_phi, scale1, scale2);
923  setLut(lut_delta_phi, val_delta_phi, prec1);
924  std::string lutName = obj1;
925  lutName += "-";
926  lutName += obj2;
927  m_gtScales.setLUT_DeltaPhi(lutName,lut_delta_phi,prec1);
928 
929  // Second Get the Cosh for this delta phi Set
930  std::vector<long long> lut_cos;
931  applyCos(val_delta_phi, n);
932  setLut(lut_cos, val_delta_phi, prec2);
933  m_gtScales.setLUT_Cos(lutName,lut_cos,prec2);
934 
935 }
936 
948 bool l1t::TriggerMenuParser::parseMuon(tmeventsetup::esCondition condMu,
949  unsigned int chipNr, const bool corrFlag) {
950 
951  using namespace tmeventsetup;
952 
953  // get condition, particle name (must be muon) and type name
954  std::string condition = "muon";
955  std::string particle = "muon";//l1t2string( condMu.objectType() );
956  std::string type = l1t2string( condMu.getType() );
957  std::string name = l1t2string( condMu.getName() );
958  int nrObj = -1;
959 
960 
961 
963 
964  if (condMu.getType() == esConditionType::SingleMuon) {
965  type = "1_s";
966  cType = l1t::Type1s;
967  nrObj = 1;
968  } else if (condMu.getType() == esConditionType::DoubleMuon) {
969  type = "2_s";
970  cType = l1t::Type2s;
971  nrObj = 2;
972  } else if (condMu.getType() == esConditionType::TripleMuon) {
973  type = "3";
974  cType = l1t::Type3s;
975  nrObj = 3;
976  } else if (condMu.getType() == esConditionType::QuadMuon) {
977  type = "4";
978  cType = l1t::Type4s;
979  nrObj = 4;
980  } else {
981  edm::LogError("TriggerMenuParser") << "Wrong type for muon-condition ("
982  << type << ")" << std::endl;
983  return false;
984  }
985 
986  if (nrObj < 0) {
987  edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type
988  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
989  return false;
990  }
991 
992  LogDebug("TriggerMenuParser")
993  << "\n ****************************************** "
994  << "\n parseMuon "
995  << "\n condition = " << condition
996  << "\n particle = " << particle
997  << "\n type = " << type
998  << "\n name = " << name
999  << std::endl;
1000 
1001 
1002 
1003 // // get values
1004 
1005  // temporary storage of the parameters
1006  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1007 
1008  // Do we need this?
1009  MuonTemplate::CorrelationParameter corrParameter;
1010 
1011  // need at least two values for deltaPhi
1012  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1013  tmpValues.reserve( nrObj );
1014 
1015  if( int(condMu.getObjects().size())!=nrObj ){
1016  edm::LogError("TriggerMenuParser") << " condMu objects: nrObj = " << nrObj
1017  << "condMu.getObjects().size() = "
1018  << condMu.getObjects().size()
1019  << std::endl;
1020  return false;
1021  }
1022 
1023 
1024 // Look for cuts on the objects in the condition
1025  unsigned int chargeCorrelation = 1;
1026  const std::vector<esCut>& cuts = condMu.getCuts();
1027  for (size_t jj = 0; jj < cuts.size(); jj++)
1028  {
1029  const esCut cut = cuts.at(jj);
1030  if(cut.getCutType() == esCutType::ChargeCorrelation) {
1031  if( cut.getData()=="ls" ) chargeCorrelation = 2;
1032  else if( cut.getData()=="os" ) chargeCorrelation = 4;
1033  else chargeCorrelation = 1; //ignore correlation
1034  }
1035  }
1036 
1037  //set charge correlation parameter
1038  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
1039 
1040 
1041  int cnt = 0;
1042 
1043 
1044 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1045  int relativeBx = 0;
1046  bool gEq = false;
1047 
1048 // Loop over objects and extract the cuts on the objects
1049  const std::vector<esObject>& objects = condMu.getObjects();
1050  for (size_t jj = 0; jj < objects.size(); jj++) {
1051 
1052  const esObject object = objects.at(jj);
1053  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1054 
1055 // BLW TO DO: This needs to be added to the Object Parameters
1056  relativeBx = object.getBxOffset();
1057 
1058 // Loop over the cuts for this object
1059  int upperThresholdInd = -1;
1060  int lowerThresholdInd = 0;
1061  int cntEta = 0;
1062  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1063  int cntPhi = 0;
1064  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1065  int isolationLUT = 0xF; //default is to ignore unless specified.
1066  int charge = -1; //default value is to ignore unless specified
1067  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
1068 
1069  const std::vector<esCut>& cuts = object.getCuts();
1070  for (size_t kk = 0; kk < cuts.size(); kk++)
1071  {
1072  const esCut cut = cuts.at(kk);
1073 
1074  switch(cut.getCutType()){
1075  case esCutType::Threshold:
1076  lowerThresholdInd = cut.getMinimum().index;
1077  upperThresholdInd = cut.getMaximum().index;
1078  break;
1079 
1080  case esCutType::Eta: {
1081 
1082  if(cntEta == 0) {
1083  etaWindow1Lower = cut.getMinimum().index;
1084  etaWindow1Upper = cut.getMaximum().index;
1085  } else if(cntEta == 1) {
1086  etaWindow2Lower = cut.getMinimum().index;
1087  etaWindow2Upper = cut.getMaximum().index;
1088  } else {
1089  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for muon-condition ("
1090  << particle << ")" << std::endl;
1091  return false;
1092  }
1093  cntEta++;
1094 
1095  } break;
1096 
1097  case esCutType::Phi: {
1098 
1099  if(cntPhi == 0) {
1100  phiWindow1Lower = cut.getMinimum().index;
1101  phiWindow1Upper = cut.getMaximum().index;
1102  } else if(cntPhi == 1) {
1103  phiWindow2Lower = cut.getMinimum().index;
1104  phiWindow2Upper = cut.getMaximum().index;
1105  } else {
1106  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for muon-condition ("
1107  << particle << ")" << std::endl;
1108  return false;
1109  }
1110  cntPhi++;
1111 
1112  }break;
1113 
1114  case esCutType::Charge:
1115  if( cut.getData()=="positive" ) charge = 0;
1116  else if( cut.getData()=="negative" ) charge = 1;
1117  else charge = -1;
1118  break;
1119  case esCutType::Quality:
1120 
1121  qualityLUT = l1tstr2int(cut.getData());
1122 
1123  break;
1124  case esCutType::Isolation: {
1125 
1126  isolationLUT = l1tstr2int(cut.getData());
1127 
1128  } break;
1129  default:
1130  break;
1131  } //end switch
1132 
1133  } //end loop over cuts
1134 
1135 
1136 // Set the parameter cuts
1137  objParameter[cnt].ptHighThreshold = upperThresholdInd;
1138  objParameter[cnt].ptLowThreshold = lowerThresholdInd;
1139 
1140  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
1141  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
1142  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
1143  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
1144 
1145  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1146  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1147  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1148  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1149 
1150 // BLW TO DO: Do we need these anymore? Drop them?
1151  objParameter[cnt].enableMip = false;//tmpMip[i];
1152  objParameter[cnt].enableIso = false;//tmpEnableIso[i];
1153  objParameter[cnt].requestIso = false;//tmpRequestIso[i];
1154 
1155  objParameter[cnt].charge = charge;
1156  objParameter[cnt].qualityLUT = qualityLUT;
1157  objParameter[cnt].isolationLUT = isolationLUT;
1158 
1159 
1160  cnt++;
1161  } //end loop over objects
1162 
1163 
1164  // object types - all muons
1165  std::vector<GlobalObject> objType(nrObj, gtMu);
1166 
1167 
1168 
1169  // now create a new CondMuonition
1170  MuonTemplate muonCond(name);
1171 
1172  muonCond.setCondType(cType);
1173  muonCond.setObjectType(objType);
1174  muonCond.setCondGEq(gEq);
1175  muonCond.setCondChipNr(chipNr);
1176  muonCond.setCondRelativeBx(relativeBx);
1177 
1178  muonCond.setConditionParameter(objParameter, corrParameter);
1179 
1180  if (edm::isDebugEnabled()) {
1181  std::ostringstream myCoutStream;
1182  muonCond.print(myCoutStream);
1183  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1184  }
1185 
1186  // insert condition into the map and into muon template vector
1187  if ( !insertConditionIntoMap(muonCond, chipNr)) {
1188  edm::LogError("TriggerMenuParser")
1189  << " Error: duplicate condition (" << name << ")"
1190  << std::endl;
1191  return false;
1192  }
1193  else {
1194  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1195  if (corrFlag) {
1196 
1197  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1198  }
1199  else {
1200  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the vecMuonTemplate vector" << std::endl;
1201  (m_vecMuonTemplate[chipNr]).push_back(muonCond);
1202  }
1203 
1204  }
1205 
1206  //
1207  return true;
1208 }
1209 
1210 
1211 bool l1t::TriggerMenuParser::parseMuonCorr(const tmeventsetup::esObject* corrMu,
1212  unsigned int chipNr) {
1213 
1214 
1215 // XERCES_CPP_NAMESPACE_USE
1216  using namespace tmeventsetup;
1217 
1218  // get condition, particle name (must be muon) and type name
1219  std::string condition = "muon";
1220  std::string particle = "muon";//l1t2string( condMu.objectType() );
1221  std::string type = l1t2string( corrMu->getType() );
1222  std::string name = l1t2string( corrMu->getName() );
1223  int nrObj = 1;
1224  type = "1_s";
1225  GtConditionType cType = l1t::Type1s;
1226 
1227 
1228 
1229  if (nrObj < 0) {
1230  edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type
1231  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1232  return false;
1233  }
1234 
1235  LogDebug("TriggerMenuParser")
1236  << "\n ****************************************** "
1237  << "\n parseMuon "
1238  << "\n condition = " << condition
1239  << "\n particle = " << particle
1240  << "\n type = " << type
1241  << "\n name = " << name
1242  << std::endl;
1243 
1244 
1245 
1246 // // get values
1247 
1248  // temporary storage of the parameters
1249  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1250 
1251  // Do we need this?
1252  MuonTemplate::CorrelationParameter corrParameter;
1253 
1254  // need at least two values for deltaPhi
1255  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1256  tmpValues.reserve( nrObj );
1257 
1258 
1259 // BLW TO DO: How do we deal with these in the new format
1260 // std::string str_chargeCorrelation = l1t2string( condMu.requestedChargeCorr() );
1261  std::string str_chargeCorrelation = "ig";
1262  unsigned int chargeCorrelation = 0;
1263  if( str_chargeCorrelation=="ig" ) chargeCorrelation = 1;
1264  else if( str_chargeCorrelation=="ls" ) chargeCorrelation = 2;
1265  else if( str_chargeCorrelation=="os" ) chargeCorrelation = 4;
1266 
1267  //getXMLHexTextValue("1", dst);
1268  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
1269 
1270 
1271 
1272  // BLW TO DO: These needs to the added to the object rather than the whole condition.
1273  int relativeBx = 0;
1274  bool gEq = false;
1275 
1276 
1277  //const esObject* object = condMu;
1278  gEq = (corrMu->getComparisonOperator() == esComparisonOperator::GE);
1279 
1280  // BLW TO DO: This needs to be added to the Object Parameters
1281  relativeBx = corrMu->getBxOffset();
1282 
1283  // Loop over the cuts for this object
1284  int upperThresholdInd = -1;
1285  int lowerThresholdInd = 0;
1286  int cntEta = 0;
1287  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1288  int cntPhi = 0;
1289  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1290  int isolationLUT = 0xF; //default is to ignore unless specified.
1291  int charge = -1; //defaut is to ignore unless specified
1292  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
1293 
1294  const std::vector<esCut>& cuts = corrMu->getCuts();
1295  for (size_t kk = 0; kk < cuts.size(); kk++)
1296  {
1297  const esCut cut = cuts.at(kk);
1298 
1299  switch(cut.getCutType()){
1300  case esCutType::Threshold:
1301  lowerThresholdInd = cut.getMinimum().index;
1302  upperThresholdInd = cut.getMaximum().index;
1303  break;
1304 
1305  case esCutType::Eta: {
1306 
1307  if(cntEta == 0) {
1308  etaWindow1Lower = cut.getMinimum().index;
1309  etaWindow1Upper = cut.getMaximum().index;
1310  } else if(cntEta == 1) {
1311  etaWindow2Lower = cut.getMinimum().index;
1312  etaWindow2Upper = cut.getMaximum().index;
1313  } else {
1314  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for muon-condition ("
1315  << particle << ")" << std::endl;
1316  return false;
1317  }
1318  cntEta++;
1319 
1320  } break;
1321 
1322  case esCutType::Phi: {
1323 
1324  if(cntPhi == 0) {
1325  phiWindow1Lower = cut.getMinimum().index;
1326  phiWindow1Upper = cut.getMaximum().index;
1327  } else if(cntPhi == 1) {
1328  phiWindow2Lower = cut.getMinimum().index;
1329  phiWindow2Upper = cut.getMaximum().index;
1330  } else {
1331  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for muon-condition ("
1332  << particle << ")" << std::endl;
1333  return false;
1334  }
1335  cntPhi++;
1336 
1337  }break;
1338 
1339  case esCutType::Charge:
1340  if( cut.getData()=="positive" ) charge = 0;
1341  else if( cut.getData()=="negative" ) charge = 1;
1342  else charge = -1;
1343  break;
1344  case esCutType::Quality:
1345 
1346  qualityLUT = l1tstr2int(cut.getData());
1347 
1348  break;
1349  case esCutType::Isolation: {
1350 
1351  isolationLUT = l1tstr2int(cut.getData());
1352 
1353  } break;
1354  default:
1355  break;
1356  } //end switch
1357 
1358  } //end loop over cuts
1359 
1360 
1361  // Set the parameter cuts
1362  objParameter[0].ptHighThreshold = upperThresholdInd;
1363  objParameter[0].ptLowThreshold = lowerThresholdInd;
1364 
1365  objParameter[0].etaWindow1Lower = etaWindow1Lower;
1366  objParameter[0].etaWindow1Upper = etaWindow1Upper;
1367  objParameter[0].etaWindow2Lower = etaWindow2Lower;
1368  objParameter[0].etaWindow2Upper = etaWindow2Upper;
1369 
1370  objParameter[0].phiWindow1Lower = phiWindow1Lower;
1371  objParameter[0].phiWindow1Upper = phiWindow1Upper;
1372  objParameter[0].phiWindow2Lower = phiWindow2Lower;
1373  objParameter[0].phiWindow2Upper = phiWindow2Upper;
1374 
1375  // BLW TO DO: Do we need these anymore? Drop them?
1376  objParameter[0].enableMip = false;//tmpMip[i];
1377  objParameter[0].enableIso = false;//tmpEnableIso[i];
1378  objParameter[0].requestIso = false;//tmpRequestIso[i];
1379 
1380  objParameter[0].charge = charge;
1381  objParameter[0].qualityLUT = qualityLUT;
1382  objParameter[0].isolationLUT = isolationLUT;
1383 
1384 
1385  // object types - all muons
1386  std::vector<GlobalObject> objType(nrObj, gtMu);
1387 
1388  // now create a new CondMuonition
1389  MuonTemplate muonCond(name);
1390 
1391  muonCond.setCondType(cType);
1392  muonCond.setObjectType(objType);
1393  muonCond.setCondGEq(gEq);
1394  muonCond.setCondChipNr(chipNr);
1395  muonCond.setCondRelativeBx(relativeBx);
1396  muonCond.setConditionParameter(objParameter, corrParameter);
1397 
1398  if (edm::isDebugEnabled()) {
1399  std::ostringstream myCoutStream;
1400  muonCond.print(myCoutStream);
1401  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1402  }
1403 
1404 /*
1405  // insert condition into the map and into muon template vector
1406  if ( !insertConditionIntoMap(muonCond, chipNr)) {
1407  edm::LogError("TriggerMenuParser")
1408  << " Error: duplicate condition (" << name << ")"
1409  << std::endl;
1410  return false;
1411  }
1412  else {
1413  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1414  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1415  }
1416 */
1417  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1418 
1419 
1420  //
1421  return true;
1422 }
1423 
1424 
1436 bool l1t::TriggerMenuParser::parseCalo(tmeventsetup::esCondition condCalo,
1437  unsigned int chipNr, const bool corrFlag) {
1438 
1439 
1440 // XERCES_CPP_NAMESPACE_USE
1441  using namespace tmeventsetup;
1442 
1443  // get condition, particle name and type name
1444 
1445  std::string condition = "calo";
1446  std::string particle = "test-fix" ;
1447  std::string type = l1t2string( condCalo.getType() );
1448  std::string name = l1t2string( condCalo.getName() );
1449 
1450  LogDebug("TriggerMenuParser")
1451  << "\n ****************************************** "
1452  << "\n (in parseCalo) "
1453  << "\n condition = " << condition
1454  << "\n particle = " << particle
1455  << "\n type = " << type
1456  << "\n name = " << name
1457  << std::endl;
1458 
1459 
1460  GtConditionType cType = l1t::TypeNull;
1461 
1462  // determine object type type
1463  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
1464  GlobalObject caloObjType;
1465  int nrObj = -1;
1466 
1467  if (condCalo.getType() == esConditionType::SingleEgamma) {
1468  caloObjType = gtEG;
1469  type = "1_s";
1470  cType= l1t::Type1s;
1471  nrObj = 1;
1472  } else if (condCalo.getType() == esConditionType::DoubleEgamma) {
1473  caloObjType = gtEG;
1474  type = "2_s";
1475  cType= l1t::Type2s;
1476  nrObj = 2;
1477  } else if (condCalo.getType() == esConditionType::TripleEgamma) {
1478  caloObjType = gtEG;
1479  cType= l1t::Type3s;
1480  type = "3";
1481  nrObj = 3;
1482  } else if (condCalo.getType() == esConditionType::QuadEgamma) {
1483  caloObjType = gtEG;
1484  cType= l1t::Type4s;
1485  type = "4";
1486  nrObj = 4;
1487  } else if (condCalo.getType() == esConditionType::SingleJet) {
1488  caloObjType = gtJet;
1489  cType= l1t::Type1s;
1490  type = "1_s";
1491  nrObj = 1;
1492  } else if (condCalo.getType() == esConditionType::DoubleJet) {
1493  caloObjType = gtJet;
1494  cType= l1t::Type2s;
1495  type = "2_s";
1496  nrObj = 2;
1497  } else if (condCalo.getType() == esConditionType::TripleJet) {
1498  caloObjType = gtJet;
1499  cType= l1t::Type3s;
1500  type = "3";
1501  nrObj = 3;
1502  } else if (condCalo.getType() == esConditionType::QuadJet) {
1503  caloObjType = gtJet;
1504  cType= l1t::Type4s;
1505  type = "4";
1506  nrObj = 4;
1507  } else if (condCalo.getType() == esConditionType::SingleTau) {
1508  caloObjType = gtTau;
1509  cType= l1t::Type1s;
1510  type = "1_s";
1511  nrObj = 1;
1512  } else if (condCalo.getType() == esConditionType::DoubleTau) {
1513  caloObjType = gtTau;
1514  cType= l1t::Type2s;
1515  type = "2_s";
1516  nrObj = 2;
1517  } else if (condCalo.getType() == esConditionType::TripleTau) {
1518  caloObjType = gtTau;
1519  cType= l1t::Type3s;
1520  type = "3";
1521  nrObj = 3;
1522  } else if (condCalo.getType() == esConditionType::QuadTau) {
1523  caloObjType = gtTau;
1524  cType= l1t::Type4s;
1525  type = "4";
1526  nrObj = 4;
1527  } else {
1528  edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition ("
1529  << particle << ")" << std::endl;
1530  return false;
1531  }
1532 
1533 // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1534 
1535  if (nrObj < 0) {
1536  edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type
1537  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1538  return false;
1539  }
1540 
1541  // get values
1542 
1543  // temporary storage of the parameters
1544  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1545 
1546  //BLW TO DO: Can this be dropped?
1547  CaloTemplate::CorrelationParameter corrParameter;
1548 
1549  // need at least one value for deltaPhiRange
1550  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1551  tmpValues.reserve( nrObj );
1552 
1553 
1554  if( int(condCalo.getObjects().size())!=nrObj ){
1555  edm::LogError("TriggerMenuParser") << " condCalo objects: nrObj = " << nrObj
1556  << "condCalo.getObjects().size() = "
1557  << condCalo.getObjects().size()
1558  << std::endl;
1559  return false;
1560  }
1561 
1562 
1563 // std::string str_condCalo = "";
1564 // boost::uint64_t tempUIntH, tempUIntL;
1565 // boost::uint64_t dst;
1566  int cnt = 0;
1567 
1568 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1569  int relativeBx = 0;
1570  bool gEq = false;
1571 
1572 // Loop over objects and extract the cuts on the objects
1573  const std::vector<esObject>& objects = condCalo.getObjects();
1574  for (size_t jj = 0; jj < objects.size(); jj++) {
1575 
1576  const esObject object = objects.at(jj);
1577  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1578 
1579 // BLW TO DO: This needs to be added to the Object Parameters
1580  relativeBx = object.getBxOffset();
1581 
1582 // Loop over the cuts for this object
1583  int upperThresholdInd = -1;
1584  int lowerThresholdInd = 0;
1585  int cntEta = 0;
1586  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1587  int cntPhi = 0;
1588  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1589  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
1590  int qualityLUT = 0xF; //default is to ignore quality unless specified.
1591 
1592 
1593  const std::vector<esCut>& cuts = object.getCuts();
1594  for (size_t kk = 0; kk < cuts.size(); kk++)
1595  {
1596  const esCut cut = cuts.at(kk);
1597 
1598  switch(cut.getCutType()){
1599  case esCutType::Threshold:
1600  lowerThresholdInd = cut.getMinimum().index;
1601  upperThresholdInd = cut.getMaximum().index;
1602  break;
1603  case esCutType::Eta: {
1604 
1605  if(cntEta == 0) {
1606  etaWindow1Lower = cut.getMinimum().index;
1607  etaWindow1Upper = cut.getMaximum().index;
1608  } else if(cntEta == 1) {
1609  etaWindow2Lower = cut.getMinimum().index;
1610  etaWindow2Upper = cut.getMaximum().index;
1611  } else {
1612  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for calo-condition ("
1613  << particle << ")" << std::endl;
1614  return false;
1615  }
1616  cntEta++;
1617 
1618  } break;
1619 
1620  case esCutType::Phi: {
1621 
1622  if(cntPhi == 0) {
1623  phiWindow1Lower = cut.getMinimum().index;
1624  phiWindow1Upper = cut.getMaximum().index;
1625  } else if(cntPhi == 1) {
1626  phiWindow2Lower = cut.getMinimum().index;
1627  phiWindow2Upper = cut.getMaximum().index;
1628  } else {
1629  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for calo-condition ("
1630  << particle << ")" << std::endl;
1631  return false;
1632  }
1633  cntPhi++;
1634 
1635  }break;
1636 
1637  case esCutType::Charge: {
1638 
1639  edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition ("
1640  << particle << ")" << std::endl;
1641  return false;
1642 
1643  }break;
1644  case esCutType::Quality: {
1645 
1646  qualityLUT = l1tstr2int(cut.getData());
1647 
1648  }break;
1649  case esCutType::Isolation: {
1650 
1651  isolationLUT = l1tstr2int(cut.getData());
1652 
1653  } break;
1654  default:
1655  break;
1656  } //end switch
1657 
1658  } //end loop over cuts
1659 
1660 // Fill the object parameters
1661  objParameter[cnt].etHighThreshold = upperThresholdInd;
1662  objParameter[cnt].etLowThreshold = lowerThresholdInd;
1663  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
1664  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
1665  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
1666  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
1667  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1668  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1669  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1670  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1671  objParameter[cnt].isolationLUT = isolationLUT;
1672  objParameter[cnt].qualityLUT = qualityLUT; //TO DO: Must add
1673 
1674  // Output for debugging
1675  LogDebug("TriggerMenuParser")
1676  << "\n Calo ET high thresholds (hex) for calo object " << caloObjType << " " << cnt << " = "
1677  << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold
1678  << "\n etaWindow Lower / Upper for calo object " << cnt << " = 0x"
1679  << objParameter[cnt].etaWindow1Lower << " / 0x" << objParameter[cnt].etaWindow1Upper
1680  << "\n etaWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
1681  << objParameter[cnt].etaWindow2Lower << " / 0x" << objParameter[cnt].etaWindow2Upper
1682  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
1683  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
1684  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
1685  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper
1686  << "\n Isolation LUT for calo object " << cnt << " = 0x"
1687  << objParameter[cnt].isolationLUT
1688  << "\n Quality LUT for calo object " << cnt << " = 0x"
1689  << objParameter[cnt].qualityLUT << std::dec
1690  << std::endl;
1691 
1692  cnt++;
1693  } //end loop over objects
1694 
1695 
1696 
1697  // object types - all same caloObjType
1698  std::vector<GlobalObject> objType(nrObj, caloObjType);
1699 
1700 
1701 
1702 
1703  // now create a new calo condition
1704  CaloTemplate caloCond(name);
1705 
1706  caloCond.setCondType(cType);
1707  caloCond.setObjectType(objType);
1708 
1709  //BLW TO DO: This needs to be added to the object rather than the whole condition
1710  caloCond.setCondGEq(gEq);
1711  caloCond.setCondChipNr(chipNr);
1712 
1713  //BLW TO DO: This needs to be added to the object rather than the whole condition
1714  caloCond.setCondRelativeBx(relativeBx);
1715 
1716  caloCond.setConditionParameter(objParameter, corrParameter);
1717 
1718  if (edm::isDebugEnabled() ) {
1719 
1720  std::ostringstream myCoutStream;
1721  caloCond.print(myCoutStream);
1722  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1723 
1724  }
1725 
1726 
1727  // insert condition into the map
1728  if ( !insertConditionIntoMap(caloCond, chipNr)) {
1729 
1730  edm::LogError("TriggerMenuParser")
1731  << " Error: duplicate condition (" << name << ")"
1732  << std::endl;
1733 
1734  return false;
1735  }
1736  else {
1737 
1738  if (corrFlag) {
1739  (m_corCaloTemplate[chipNr]).push_back(caloCond);
1740  }
1741  else {
1742  (m_vecCaloTemplate[chipNr]).push_back(caloCond);
1743  }
1744 
1745  }
1746 
1747 
1748  //
1749  return true;
1750 }
1751 
1752 
1753 
1765 bool l1t::TriggerMenuParser::parseCaloCorr(const tmeventsetup::esObject* corrCalo,
1766  unsigned int chipNr) {
1767 
1768 
1769 // XERCES_CPP_NAMESPACE_USE
1770  using namespace tmeventsetup;
1771 
1772  // get condition, particle name and type name
1773 
1774  std::string condition = "calo";
1775  std::string particle = "test-fix" ;
1776  std::string type = l1t2string( corrCalo->getType() );
1777  std::string name = l1t2string( corrCalo->getName() );
1778 
1779  LogDebug("TriggerMenuParser")
1780  << "\n ****************************************** "
1781  << "\n (in parseCalo) "
1782  << "\n condition = " << condition
1783  << "\n particle = " << particle
1784  << "\n type = " << type
1785  << "\n name = " << name
1786  << std::endl;
1787 
1788 
1789  // determine object type type
1790  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
1791  GlobalObject caloObjType;
1792  int nrObj = 1;
1793  type = "1_s";
1794  GtConditionType cType = l1t::Type1s;
1795 
1796 
1797  if (corrCalo->getType() == esObjectType::Egamma) {
1798  caloObjType = gtEG;
1799  } else if (corrCalo->getType() == esObjectType::Jet) {
1800  caloObjType = gtJet;
1801  } else if (corrCalo->getType() == esObjectType::Tau) {
1802  caloObjType = gtTau;
1803  } else {
1804  edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition ("
1805  << particle << ")" << std::endl;
1806  return false;
1807  }
1808 
1809 
1810 // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1811 
1812  if (nrObj < 0) {
1813  edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type
1814  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1815  return false;
1816  }
1817 
1818  // get values
1819 
1820  // temporary storage of the parameters
1821  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1822 
1823  //BLW TO DO: Can this be dropped?
1824  CaloTemplate::CorrelationParameter corrParameter;
1825 
1826  // need at least one value for deltaPhiRange
1827  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1828  tmpValues.reserve( nrObj );
1829 
1830 
1831 
1832 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1833  int relativeBx = 0;
1834  bool gEq = false;
1835 
1836 
1837  gEq = (corrCalo->getComparisonOperator() == esComparisonOperator::GE);
1838 
1839 // BLW TO DO: This needs to be added to the Object Parameters
1840  relativeBx = corrCalo->getBxOffset();
1841 
1842 // Loop over the cuts for this object
1843  int upperThresholdInd = -1;
1844  int lowerThresholdInd = 0;
1845  int cntEta = 0;
1846  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1847  int cntPhi = 0;
1848  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1849  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
1850  int qualityLUT = 0xF; //default is to ignore quality unless specified.
1851 
1852 
1853  const std::vector<esCut>& cuts = corrCalo->getCuts();
1854  for (size_t kk = 0; kk < cuts.size(); kk++)
1855  {
1856  const esCut cut = cuts.at(kk);
1857 
1858  switch(cut.getCutType()){
1859  case esCutType::Threshold:
1860  lowerThresholdInd = cut.getMinimum().index;
1861  upperThresholdInd = cut.getMaximum().index;
1862  break;
1863  case esCutType::Eta: {
1864 
1865  if(cntEta == 0) {
1866  etaWindow1Lower = cut.getMinimum().index;
1867  etaWindow1Upper = cut.getMaximum().index;
1868  } else if(cntEta == 1) {
1869  etaWindow2Lower = cut.getMinimum().index;
1870  etaWindow2Upper = cut.getMaximum().index;
1871  } else {
1872  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for calo-condition ("
1873  << particle << ")" << std::endl;
1874  return false;
1875  }
1876  cntEta++;
1877 
1878  } break;
1879 
1880  case esCutType::Phi: {
1881 
1882  if(cntPhi == 0) {
1883  phiWindow1Lower = cut.getMinimum().index;
1884  phiWindow1Upper = cut.getMaximum().index;
1885  } else if(cntPhi == 1) {
1886  phiWindow2Lower = cut.getMinimum().index;
1887  phiWindow2Upper = cut.getMaximum().index;
1888  } else {
1889  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for calo-condition ("
1890  << particle << ")" << std::endl;
1891  return false;
1892  }
1893  cntPhi++;
1894 
1895  }break;
1896 
1897  case esCutType::Charge: {
1898 
1899  edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition ("
1900  << particle << ")" << std::endl;
1901  return false;
1902 
1903  }break;
1904  case esCutType::Quality: {
1905 
1906  qualityLUT = l1tstr2int(cut.getData());
1907 
1908  }break;
1909  case esCutType::Isolation: {
1910 
1911  isolationLUT = l1tstr2int(cut.getData());
1912 
1913  } break;
1914  default:
1915  break;
1916  } //end switch
1917 
1918  } //end loop over cuts
1919 
1920 // Fill the object parameters
1921  objParameter[0].etLowThreshold = lowerThresholdInd;
1922  objParameter[0].etHighThreshold = upperThresholdInd;
1923  objParameter[0].etaWindow1Lower = etaWindow1Lower;
1924  objParameter[0].etaWindow1Upper = etaWindow1Upper;
1925  objParameter[0].etaWindow2Lower = etaWindow2Lower;
1926  objParameter[0].etaWindow2Upper = etaWindow2Upper;
1927  objParameter[0].phiWindow1Lower = phiWindow1Lower;
1928  objParameter[0].phiWindow1Upper = phiWindow1Upper;
1929  objParameter[0].phiWindow2Lower = phiWindow2Lower;
1930  objParameter[0].phiWindow2Upper = phiWindow2Upper;
1931  objParameter[0].isolationLUT = isolationLUT;
1932  objParameter[0].qualityLUT = qualityLUT; //TO DO: Must add
1933 
1934  // Output for debugging
1935  LogDebug("TriggerMenuParser")
1936  << "\n Calo ET high threshold (hex) for calo object " << caloObjType << " " << " = "
1937  << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etHighThreshold
1938  << "\n etaWindow Lower / Upper for calo object " << " = 0x"
1939  << objParameter[0].etaWindow1Lower << " / 0x" << objParameter[0].etaWindow1Upper
1940  << "\n etaWindowVeto Lower / Upper for calo object " << " = 0x"
1941  << objParameter[0].etaWindow2Lower << " / 0x" << objParameter[0].etaWindow2Upper
1942  << "\n phiWindow Lower / Upper for calo object " << " = 0x"
1943  << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
1944  << "\n phiWindowVeto Lower / Upper for calo object " << " = 0x"
1945  << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper
1946  << "\n Isolation LUT for calo object " << " = 0x"
1947  << objParameter[0].isolationLUT
1948  << "\n Quality LUT for calo object " << " = 0x"
1949  << objParameter[0].qualityLUT << std::dec
1950  << std::endl;
1951 
1952 
1953 
1954 
1955 
1956  // object types - all same caloObjType
1957  std::vector<GlobalObject> objType(nrObj, caloObjType);
1958 
1959 
1960 
1961 
1962  // now create a new calo condition
1963  CaloTemplate caloCond(name);
1964 
1965  caloCond.setCondType(cType);
1966  caloCond.setObjectType(objType);
1967 
1968  //BLW TO DO: This needs to be added to the object rather than the whole condition
1969  caloCond.setCondGEq(gEq);
1970  caloCond.setCondChipNr(chipNr);
1971 
1972  //BLW TO DO: This needs to be added to the object rather than the whole condition
1973  caloCond.setCondRelativeBx(relativeBx);
1974 
1975  caloCond.setConditionParameter(objParameter, corrParameter);
1976 
1977  if (edm::isDebugEnabled() ) {
1978 
1979  std::ostringstream myCoutStream;
1980  caloCond.print(myCoutStream);
1981  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1982 
1983  }
1984 
1985 /*
1986  // insert condition into the map
1987  if ( !insertConditionIntoMap(caloCond, chipNr)) {
1988 
1989  edm::LogError("TriggerMenuParser")
1990  << " Error: duplicate condition (" << name << ")"
1991  << std::endl;
1992 
1993  return false;
1994  }
1995  else {
1996  (m_corCaloTemplate[chipNr]).push_back(caloCond);
1997  }
1998 */
1999  (m_corCaloTemplate[chipNr]).push_back(caloCond);
2000 
2001  //
2002  return true;
2003 }
2004 
2005 
2006 
2018 bool l1t::TriggerMenuParser::parseEnergySum(tmeventsetup::esCondition condEnergySum,
2019  unsigned int chipNr, const bool corrFlag) {
2020 
2021 
2022 // XERCES_CPP_NAMESPACE_USE
2023  using namespace tmeventsetup;
2024 
2025  // get condition, particle name and type name
2026 
2027  std::string condition = "calo";
2028  std::string type = l1t2string( condEnergySum.getType() );
2029  std::string name = l1t2string( condEnergySum.getName() );
2030 
2031  LogDebug("TriggerMenuParser")
2032  << "\n ****************************************** "
2033  << "\n (in parseEnergySum) "
2034  << "\n condition = " << condition
2035  << "\n type = " << type
2036  << "\n name = " << name
2037  << std::endl;
2038 
2039 
2040 
2041  // determine object type type
2042  GlobalObject energySumObjType;
2043  GtConditionType cType;
2044 
2045  if( condEnergySum.getType() == esConditionType::MissingEt ){
2046  energySumObjType = GlobalObject::gtETM;
2047  cType = TypeETM;
2048  }
2049  else if( condEnergySum.getType() == esConditionType::TotalEt ){
2050  energySumObjType = GlobalObject::gtETT;
2051  cType = TypeETT;
2052  }
2053  else if( condEnergySum.getType() == esConditionType::TotalEtEM ){
2054  energySumObjType = GlobalObject::gtETTem;
2055  cType = TypeETTem;
2056  }
2057  else if( condEnergySum.getType() == esConditionType::TotalHt ){
2058  energySumObjType = GlobalObject::gtHTT;
2059  cType = TypeHTT;
2060  }
2061  else if( condEnergySum.getType() == esConditionType::MissingHt ){
2062  energySumObjType = GlobalObject::gtHTM;
2063  cType = TypeHTM;
2064  }
2065  else if( condEnergySum.getType() == esConditionType::MissingEtHF ){
2066  energySumObjType = GlobalObject::gtETMHF;
2067  cType = TypeETMHF;
2068  }
2069  else if( condEnergySum.getType() == esConditionType::TowerCount ){
2070  energySumObjType = GlobalObject::gtTowerCount;
2071  cType = TypeTowerCount;
2072  }
2073  else if( condEnergySum.getType() == esConditionType::MinBiasHFP0 ){
2074  energySumObjType = GlobalObject::gtMinBiasHFP0;
2075  cType = TypeMinBiasHFP0;
2076  }
2077  else if( condEnergySum.getType() == esConditionType::MinBiasHFM0 ){
2078  energySumObjType = GlobalObject::gtMinBiasHFM0;
2079  cType = TypeMinBiasHFM0;
2080  }
2081  else if( condEnergySum.getType() == esConditionType::MinBiasHFP1 ){
2082  energySumObjType = GlobalObject::gtMinBiasHFP1;
2083  cType = TypeMinBiasHFP1;
2084  }
2085  else if( condEnergySum.getType() == esConditionType::MinBiasHFM1 ){
2086  energySumObjType = GlobalObject::gtMinBiasHFM1;
2087  cType = TypeMinBiasHFM1;
2088  }
2089  else {
2090  edm::LogError("TriggerMenuParser")
2091  << "Wrong type for energy-sum condition (" << type
2092  << ")" << std::endl;
2093  return false;
2094  }
2095 
2096 
2097 
2098  // global object
2099  int nrObj = 1;
2100 
2101 // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
2102 
2103  // get values
2104 
2105  // temporary storage of the parameters
2106  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2107 
2108 
2109  int cnt = 0;
2110 
2111 // BLW TO DO: These needs to the added to the object rather than the whole condition.
2112  int relativeBx = 0;
2113  bool gEq = false;
2114 
2115 // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
2116 
2117 // Loop over objects and extract the cuts on the objects
2118  const std::vector<esObject>& objects = condEnergySum.getObjects();
2119  for (size_t jj = 0; jj < objects.size(); jj++) {
2120 
2121  const esObject object = objects.at(jj);
2122  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
2123 
2124 // BLW TO DO: This needs to be added to the Object Parameters
2125  relativeBx = object.getBxOffset();
2126 
2127 // Loop over the cuts for this object
2128  int lowerThresholdInd = 0;
2129  int upperThresholdInd = -1;
2130  int cntPhi = 0;
2131  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
2132 
2133 
2134  const std::vector<esCut>& cuts = object.getCuts();
2135  for (size_t kk = 0; kk < cuts.size(); kk++)
2136  {
2137  const esCut cut = cuts.at(kk);
2138 
2139  switch(cut.getCutType()){
2140  case esCutType::Threshold:
2141  lowerThresholdInd = cut.getMinimum().index;
2142  upperThresholdInd = cut.getMaximum().index;
2143  break;
2144 
2145  case esCutType::Eta:
2146  break;
2147 
2148  case esCutType::Phi: {
2149 
2150  if(cntPhi == 0) {
2151  phiWindow1Lower = cut.getMinimum().index;
2152  phiWindow1Upper = cut.getMaximum().index;
2153  } else if(cntPhi == 1) {
2154  phiWindow2Lower = cut.getMinimum().index;
2155  phiWindow2Upper = cut.getMaximum().index;
2156  } else {
2157  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition ("
2158  << type << ")" << std::endl;
2159  return false;
2160  }
2161  cntPhi++;
2162 
2163  }
2164  break;
2165 
2166  case esCutType::Count:
2167  lowerThresholdInd = cut.getMinimum().index;
2168  upperThresholdInd = 0xffffff;
2169  break;
2170 
2171  default:
2172  break;
2173  } //end switch
2174 
2175  } //end loop over cuts
2176 
2177 
2178 
2179  // Fill the object parameters
2180  objParameter[cnt].etLowThreshold = lowerThresholdInd;
2181  objParameter[cnt].etHighThreshold = upperThresholdInd;
2182  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
2183  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
2184  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
2185  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
2186 
2187 
2188  // Output for debugging
2189  LogDebug("TriggerMenuParser")
2190  << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2191  << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold
2192  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2193  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
2194  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2195  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper << std::dec
2196  << std::endl;
2197 
2198  cnt++;
2199  } //end loop over objects
2200 
2201  // object types - all same energySumObjType
2202  std::vector<GlobalObject> objType(nrObj, energySumObjType);
2203 
2204  // now create a new energySum condition
2205 
2206  EnergySumTemplate energySumCond(name);
2207 
2208  energySumCond.setCondType(cType);
2209  energySumCond.setObjectType(objType);
2210  energySumCond.setCondGEq(gEq);
2211  energySumCond.setCondChipNr(chipNr);
2212  energySumCond.setCondRelativeBx(relativeBx);
2213 
2214  energySumCond.setConditionParameter(objParameter);
2215 
2216  if (edm::isDebugEnabled() ) {
2217 
2218  std::ostringstream myCoutStream;
2219  energySumCond.print(myCoutStream);
2220  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2221 
2222  }
2223 
2224  // insert condition into the map
2225  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2226 
2227  edm::LogError("TriggerMenuParser")
2228  << " Error: duplicate condition (" << name << ")"
2229  << std::endl;
2230 
2231  return false;
2232  }
2233  else {
2234 
2235  if (corrFlag) {
2236  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2237 
2238  }
2239  else {
2240  (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
2241  }
2242 
2243  }
2244 
2245 
2246 
2247  //
2248  return true;
2249 }
2250 
2251 
2263 bool l1t::TriggerMenuParser::parseEnergySumCorr(const tmeventsetup::esObject* corrESum,
2264  unsigned int chipNr) {
2265 
2266 
2267 // XERCES_CPP_NAMESPACE_USE
2268  using namespace tmeventsetup;
2269 
2270  // get condition, particle name and type name
2271 
2272  std::string condition = "calo";
2273  std::string type = l1t2string( corrESum->getType() );
2274  std::string name = l1t2string( corrESum->getName() );
2275 
2276  LogDebug("TriggerMenuParser")
2277  << "\n ****************************************** "
2278  << "\n (in parseEnergySum) "
2279  << "\n condition = " << condition
2280  << "\n type = " << type
2281  << "\n name = " << name
2282  << std::endl;
2283 
2284 
2285 
2286  // determine object type type
2287  GlobalObject energySumObjType;
2288  GtConditionType cType;
2289 
2290  if( corrESum->getType()== esObjectType::ETM ){
2291  energySumObjType = GlobalObject::gtETM;
2292  cType = TypeETM;
2293  }
2294  else if( corrESum->getType()== esObjectType::HTM ){
2295  energySumObjType = GlobalObject::gtHTM;
2296  cType = TypeHTM;
2297  }
2298  else if( corrESum->getType()== esObjectType::ETMHF ){
2299  energySumObjType = GlobalObject::gtETMHF;
2300  cType = TypeETMHF;
2301  }
2302  else if( corrESum->getType()== esObjectType::TOWERCOUNT ){
2303  energySumObjType = GlobalObject::gtTowerCount;
2304  cType = TypeTowerCount;
2305  }
2306  else {
2307  edm::LogError("TriggerMenuParser")
2308  << "Wrong type for energy-sum correclation condition (" << type
2309  << ")" << std::endl;
2310  return false;
2311  }
2312 
2313 
2314 
2315  // global object
2316  int nrObj = 1;
2317 
2318 // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
2319 
2320  // get values
2321 
2322  // temporary storage of the parameters
2323  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2324 
2325 
2326  int cnt = 0;
2327 
2328 // BLW TO DO: These needs to the added to the object rather than the whole condition.
2329  int relativeBx = 0;
2330  bool gEq = false;
2331 
2332 // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
2333 
2334 
2335  gEq = (corrESum->getComparisonOperator() == esComparisonOperator::GE);
2336 
2337 // BLW TO DO: This needs to be added to the Object Parameters
2338  relativeBx = corrESum->getBxOffset();
2339 
2340 // Loop over the cuts for this object
2341  int lowerThresholdInd = 0;
2342  int upperThresholdInd = -1;
2343  int cntPhi = 0;
2344  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
2345 
2346 
2347  const std::vector<esCut>& cuts = corrESum->getCuts();
2348  for (size_t kk = 0; kk < cuts.size(); kk++)
2349  {
2350  const esCut cut = cuts.at(kk);
2351 
2352  switch(cut.getCutType()){
2353  case esCutType::Threshold:
2354  lowerThresholdInd = cut.getMinimum().index;
2355  upperThresholdInd = cut.getMaximum().index;
2356  break;
2357 
2358  case esCutType::Eta:
2359  break;
2360 
2361  case esCutType::Phi: {
2362 
2363  if(cntPhi == 0) {
2364  phiWindow1Lower = cut.getMinimum().index;
2365  phiWindow1Upper = cut.getMaximum().index;
2366  } else if(cntPhi == 1) {
2367  phiWindow2Lower = cut.getMinimum().index;
2368  phiWindow2Upper = cut.getMaximum().index;
2369  } else {
2370  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition ("
2371  << type << ")" << std::endl;
2372  return false;
2373  }
2374  cntPhi++;
2375 
2376  }
2377  break;
2378 
2379  default:
2380  break;
2381  } //end switch
2382 
2383  } //end loop over cuts
2384 
2385 
2386 
2387  // Fill the object parameters
2388  objParameter[0].etLowThreshold = lowerThresholdInd;
2389  objParameter[0].etHighThreshold = upperThresholdInd;
2390  objParameter[0].phiWindow1Lower = phiWindow1Lower;
2391  objParameter[0].phiWindow1Upper = phiWindow1Upper;
2392  objParameter[0].phiWindow2Lower = phiWindow2Lower;
2393  objParameter[0].phiWindow2Upper = phiWindow2Upper;
2394 
2395 
2396  // Output for debugging
2397  LogDebug("TriggerMenuParser")
2398  << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2399  << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etLowThreshold
2400  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2401  << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
2402  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2403  << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper << std::dec
2404  << std::endl;
2405 
2406 
2407  // object types - all same energySumObjType
2408  std::vector<GlobalObject> objType(nrObj, energySumObjType);
2409 
2410  // now create a new energySum condition
2411 
2412  EnergySumTemplate energySumCond(name);
2413 
2414  energySumCond.setCondType(cType);
2415  energySumCond.setObjectType(objType);
2416  energySumCond.setCondGEq(gEq);
2417  energySumCond.setCondChipNr(chipNr);
2418  energySumCond.setCondRelativeBx(relativeBx);
2419 
2420  energySumCond.setConditionParameter(objParameter);
2421 
2422  if (edm::isDebugEnabled() ) {
2423 
2424  std::ostringstream myCoutStream;
2425  energySumCond.print(myCoutStream);
2426  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2427 
2428  }
2429 /*
2430  // insert condition into the map
2431  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2432 
2433  edm::LogError("TriggerMenuParser")
2434  << " Error: duplicate condition (" << name << ")"
2435  << std::endl;
2436 
2437  return false;
2438  }
2439  else {
2440 
2441  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2442 
2443  }
2444 */
2445  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2446 
2447 
2448  //
2449  return true;
2450 }
2451 
2452 
2453 
2466 bool l1t::TriggerMenuParser::parseExternal(tmeventsetup::esCondition condExt,
2467  unsigned int chipNr) {
2468 
2469 
2470  using namespace tmeventsetup;
2471 
2472 
2473  // get condition, particle name and type name
2474  std::string condition = "ext";
2475  std::string particle = "test-fix";
2476  std::string type = l1t2string( condExt.getType() );
2477  std::string name = l1t2string( condExt.getName() );
2478 
2479 
2480  LogDebug("TriggerMenuParser")
2481  << "\n ****************************************** "
2482  << "\n (in parseExternal) "
2483  << "\n condition = " << condition
2484  << "\n particle = " << particle
2485  << "\n type = " << type
2486  << "\n name = " << name
2487  << std::endl;
2488 
2489 
2490  // object type and condition type
2491  // object type - irrelevant for External conditions
2492  GtConditionType cType = TypeExternal;
2493  GlobalObject extSignalType = GlobalObject::gtExternal;
2494  int nrObj = 1; //only one object for these conditions
2495 
2496  int relativeBx = 0;
2497  unsigned int channelID = 0;
2498 
2499  // Get object for External conditions
2500  const std::vector<esObject>& objects = condExt.getObjects();
2501  for (size_t jj = 0; jj < objects.size(); jj++) {
2502 
2503  const esObject object = objects.at(jj);
2504  if(object.getType() == esObjectType::EXT) {
2505  relativeBx = object.getBxOffset();
2506  channelID = object.getExternalChannelId();
2507  }
2508  }
2509 
2510 
2511  // set the boolean value for the ge_eq mode - irrelevant for External conditions
2512  bool gEq = false;
2513 
2514  //object types - all same for external conditions
2515  std::vector<GlobalObject> objType(nrObj, extSignalType);
2516 
2517  // now create a new External condition
2518  ExternalTemplate externalCond(name);
2519 
2520  externalCond.setCondType(cType);
2521  externalCond.setObjectType(objType);
2522  externalCond.setCondGEq(gEq);
2523  externalCond.setCondChipNr(chipNr);
2524  externalCond.setCondRelativeBx(relativeBx);
2525  externalCond.setExternalChannel(channelID);
2526 
2527  LogTrace("TriggerMenuParser")
2528  << externalCond << "\n" << std::endl;
2529 
2530  // insert condition into the map
2531  if ( !insertConditionIntoMap(externalCond, chipNr)) {
2532 
2533  edm::LogError("TriggerMenuParser")
2534  << " Error: duplicate condition (" << name
2535  << ")" << std::endl;
2536 
2537  return false;
2538  } else {
2539 
2540  (m_vecExternalTemplate[chipNr]).push_back(externalCond);
2541 
2542  }
2543 
2544  return true;
2545 }
2546 
2547 
2561  tmeventsetup::esCondition corrCond,
2562  unsigned int chipNr) {
2563 
2564  using namespace tmeventsetup;
2565 
2566  std::string condition = "corr";
2567  std::string particle = "test-fix" ;
2568  std::string type = l1t2string( corrCond.getType() );
2569  std::string name = l1t2string( corrCond.getName() );
2570 
2571  LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
2572  << " (in parseCorrelation) " << std::endl
2573  << " condition = " << condition << std::endl
2574  << " particle = " << particle << std::endl
2575  << " type = " << type << std::endl
2576  << " name = " << name << std::endl;
2577 
2578 
2579 
2580 
2581  // create a new correlation condition
2582  CorrelationTemplate correlationCond(name);
2583 
2584  // check that the condition does not exist already in the map
2585  if ( !insertConditionIntoMap(correlationCond, chipNr)) {
2586 
2587  edm::LogError("TriggerMenuParser")
2588  << " Error: duplicate correlation condition (" << name << ")"
2589  << std::endl;
2590 
2591  return false;
2592  }
2593 
2594 
2595 // Define some of the quantities to store the parased information
2596 
2597  // condition type BLW (Do we change this to the type of correlation condition?)
2599 
2600  // two objects (for sure)
2601  const int nrObj = 2;
2602 
2603  // object types and greater equal flag - filled in the loop
2604  int intGEq[nrObj] = { -1, -1 };
2605  std::vector<GlobalObject> objType(nrObj); //BLW do we want to define these as a different type?
2606  std::vector<GtConditionCategory> condCateg(nrObj); //BLW do we want to change these categories
2607 
2608  // correlation flag and index in the cor*vector
2609  const bool corrFlag = true;
2610  int corrIndexVal[nrObj] = { -1, -1 };
2611 
2612 
2613  // Storage of the correlation selection
2615  corrParameter.chargeCorrelation = 1; //ignore charge correlation
2616 
2617 // Get the correlation Cuts on the legs
2618  int cutType = 0;
2619  const std::vector<esCut>& cuts = corrCond.getCuts();
2620  for (size_t jj = 0; jj < cuts.size(); jj++)
2621  {
2622  const esCut cut = cuts.at(jj);
2623 
2624  if(cut.getCutType() == esCutType::ChargeCorrelation) {
2625  if( cut.getData()=="ls" ) corrParameter.chargeCorrelation = 2;
2626  else if( cut.getData()=="os" ) corrParameter.chargeCorrelation = 4;
2627  else corrParameter.chargeCorrelation = 1; //ignore charge correlation
2628  } else {
2629 
2630 //
2631 // Unitl utm has method to calculate these, do the integer value calculation with precision.
2632 //
2633  double minV = cut.getMinimum().value;
2634  double maxV = cut.getMaximum().value;
2635 
2636  //Scale down very large numbers out of xml
2637  if(maxV > 1.0e6) maxV = 1.0e6;
2638 
2639  if(cut.getCutType() == esCutType::DeltaEta) {
2640  //std::cout << "DeltaEta Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2641  corrParameter.minEtaCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2642  corrParameter.maxEtaCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2643  corrParameter.precEtaCut = cut.getMinimum().index;
2644  cutType = cutType | 0x1;
2645  } else if (cut.getCutType() == esCutType::DeltaPhi) {
2646  //std::cout << "DeltaPhi Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2647  corrParameter.minPhiCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2648  corrParameter.maxPhiCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2649  corrParameter.precPhiCut = cut.getMinimum().index;
2650  cutType = cutType | 0x2;
2651  } else if (cut.getCutType() == esCutType::DeltaR) {
2652  //std::cout << "DeltaR Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2653  corrParameter.minDRCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2654  corrParameter.maxDRCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2655  corrParameter.precDRCut = cut.getMinimum().index;
2656  cutType = cutType | 0x4;
2657  } else if (cut.getCutType() == esCutType::Mass) {
2658  //std::cout << "Mass Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2659  corrParameter.minMassCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2660  corrParameter.maxMassCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2661  corrParameter.precMassCut = cut.getMinimum().index;
2662  cutType = cutType | 0x8;
2663  }
2664  }
2665 
2666  }
2667  corrParameter.corrCutType = cutType;
2668 
2669 // Get the two objects that form the legs
2670  const std::vector<esObject>& objects = corrCond.getObjects();
2671  if(objects.size() != 2) {
2672  edm::LogError("TriggerMenuParser")
2673  << "incorrect number of objects for the correlation condition " << name << " corrFlag " << corrFlag << std::endl;
2674  return false;
2675  }
2676 
2677 // loop over legs
2678  for (size_t jj = 0; jj < objects.size(); jj++)
2679  {
2680  const esObject object = objects.at(jj);
2681 /* std::cout << " obj name = " << object->getName() << "\n";
2682  std::cout << " obj type = " << object->getType() << "\n";
2683  std::cout << " obj op = " << object->getComparisonOperator() << "\n";
2684  std::cout << " obj bx = " << object->getBxOffset() << "\n";
2685 */
2686 
2687 // check the leg type
2688  if(object.getType() == esObjectType::Muon) {
2689  // we have a muon
2690 
2691 /*
2692  //BLW Hold on to this code we may need to go back to it at some point.
2693  // Now we are putting ALL leg conditions into the vector (so there are duplicates)
2694  // This is potentially a place to slim down the code. Note: We currently evaluate the
2695  // conditions every time, so even if we put the condition in the vector once, we would
2696  // still evaluate it multiple times. This is a place for optimization.
2697 
2698  parseMuonCorr(&object,chipNr);
2699  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
2700 
2701  } else {
2702  LogDebug("TriggerMenuParser") << "Not Adding Correlation Muon Condition to Map...looking for the condition in Muon Cor Vector" << std::endl;
2703  bool found = false;
2704  int index = 0;
2705  while(!found && index<(int)((m_corMuonTemplate[chipNr]).size()) ) {
2706  if( (m_corMuonTemplate[chipNr]).at(index).condName() == object.getName() ) {
2707  LogDebug("TriggerMenuParser") << "Found condition " << object.getName() << " in vector at index " << index << std::endl;
2708  found = true;
2709  } else {
2710  index++;
2711  }
2712  }
2713  if(found) {
2714  corrIndexVal[jj] = index;
2715  } else {
2716  edm::LogError("TriggerMenuParser") << "FAILURE: Condition " << object.getName() << " is in map but not in cor. vector " << std::endl;
2717  }
2718 
2719  }
2720 */
2721  parseMuonCorr(&object,chipNr);
2722  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
2723 
2724  //Now set some flags for this subCondition
2725  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2726  objType[jj] = gtMu;
2727  condCateg[jj] = CondMuon;
2728 
2729  } else if(object.getType() == esObjectType::Egamma ||
2730  object.getType() == esObjectType::Jet ||
2731  object.getType() == esObjectType::Tau ) {
2732 
2733  // we have an Calo object
2734  parseCaloCorr(&object,chipNr);
2735  corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
2736 
2737  //Now set some flags for this subCondition
2738  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2739  switch(object.getType()) {
2740  case esObjectType::Egamma: {
2741  objType[jj] = gtEG;
2742  }
2743  break;
2744  case esObjectType::Jet: {
2745  objType[jj] = gtJet;
2746  }
2747  break;
2748  case esObjectType::Tau: {
2749  objType[jj] = gtTau;
2750  }
2751  break;
2752  default: {
2753  }
2754  break;
2755  }
2756  condCateg[jj] = CondCalo;
2757 
2758 
2759 
2760 
2761  } else if(object.getType() == esObjectType::ETM ||
2762  object.getType() == esObjectType::ETMHF ||
2763  object.getType() == esObjectType::TOWERCOUNT ||
2764  object.getType() == esObjectType::HTM ) {
2765 
2766  // we have Energy Sum
2767  parseEnergySumCorr(&object,chipNr);
2768  corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
2769 
2770  //Now set some flags for this subCondition
2771  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2772  switch(object.getType()) {
2773  case esObjectType::ETM: {
2774  objType[jj] = GlobalObject::gtETM;
2775  }
2776  break;
2777  case esObjectType::HTM: {
2778  objType[jj] = GlobalObject::gtHTM;
2779  }
2780  break;
2781  case esObjectType::ETMHF: {
2782  objType[jj] = GlobalObject::gtETMHF;
2783  }
2784  break;
2785  case esObjectType::TOWERCOUNT: {
2786  objType[jj] = GlobalObject::gtTowerCount;
2787  }
2788  break;
2789  default: {
2790  }
2791  break;
2792  }
2793  condCateg[jj] = CondEnergySum;
2794 
2795 
2796  } else {
2797 
2798  edm::LogError("TriggerMenuParser")
2799  << "Illegal Object Type " << object.getType()
2800  << " for the correlation condition " << name << std::endl;
2801  return false;
2802 
2803  } //if block on leg types
2804 
2805  } //loop over legs
2806 
2807 
2808  // get greater equal flag for the correlation condition
2809  bool gEq = true;
2810  if (intGEq[0] != intGEq[1]) {
2811  edm::LogError("TriggerMenuParser")
2812  << "Inconsistent GEq flags for sub-conditions "
2813  << " for the correlation condition " << name << std::endl;
2814  return false;
2815 
2816  }
2817  else {
2818  gEq = (intGEq[0] != 0);
2819 
2820  }
2821 
2822 
2823  // fill the correlation condition
2824  correlationCond.setCondType(cType);
2825  correlationCond.setObjectType(objType);
2826  correlationCond.setCondGEq(gEq);
2827  correlationCond.setCondChipNr(chipNr);
2828 
2829  correlationCond.setCond0Category(condCateg[0]);
2830  correlationCond.setCond1Category(condCateg[1]);
2831 
2832  correlationCond.setCond0Index(corrIndexVal[0]);
2833  correlationCond.setCond1Index(corrIndexVal[1]);
2834 
2835  correlationCond.setCorrelationParameter(corrParameter);
2836 
2837  if (edm::isDebugEnabled() ) {
2838 
2839  std::ostringstream myCoutStream;
2840  correlationCond.print(myCoutStream);
2841  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n"
2842  << std::endl;
2843 
2844  }
2845 
2846  // insert condition into the map
2847  // condition is not duplicate, check was done at the beginning
2848 
2849  (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
2850 
2851 
2852  //
2853  return true;
2854 }
2855 
2856 
2868 bool l1t::TriggerMenuParser::parseAlgorithm( tmeventsetup::esAlgorithm algorithm,
2869  unsigned int chipNr) {
2870 
2871 
2872  using namespace tmeventsetup;
2873  //using namespace Algorithm;
2874 
2875 
2876  // get alias
2877  std::string algAlias = algorithm.getName();
2878  std::string algName = algorithm.getName();
2879 
2880  if (algAlias == "") {
2881  algAlias = algName;
2882  LogDebug("TriggerMenuParser")
2883  << "\n No alias defined for algorithm. Alias set to algorithm name."
2884  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
2885  << std::endl;
2886  } else {
2887  //LogDebug("TriggerMenuParser")
2888  LogDebug("TriggerMenuParser") << "\n Alias defined for algorithm."
2889  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
2890  << std::endl;
2891  }
2892 
2893  // get the logical expression
2894  std::string logExpression = algorithm.getExpressionInCondition();
2895 
2896  LogDebug("TriggerMenuParser")
2897  << " Logical expression: " << logExpression
2898  << " Chip number: " << chipNr
2899  << std::endl;
2900 
2901  // determine output pin
2902  int outputPin = algorithm.getIndex();
2903 
2904 
2905  //LogTrace("TriggerMenuParser")
2906  LogDebug("TriggerMenuParser") << " Output pin: " << outputPin
2907  << std::endl;
2908 
2909 
2910  // compute the bit number from chip number, output pin and order of the chips
2911  // pin numbering start with 1, bit numbers with 0
2912  int bitNumber = outputPin;// + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
2913 
2914  //LogTrace("TriggerMenuParser")
2915  LogDebug("TriggerMenuParser") << " Bit number: " << bitNumber
2916  << std::endl;
2917 
2918  // create a new algorithm and insert it into algorithm map
2919  GlobalAlgorithm alg(algName, logExpression, bitNumber);
2920  alg.setAlgoChipNumber(static_cast<int>(chipNr));
2921  alg.setAlgoAlias(algAlias);
2922 
2923  if (edm::isDebugEnabled() ) {
2924 
2925  std::ostringstream myCoutStream;
2926  alg.print(myCoutStream);
2927  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2928 
2929  }
2930 
2931  // insert algorithm into the map
2932  if ( !insertAlgorithmIntoMap(alg)) {
2933  return false;
2934  }
2935 
2936  return true;
2937 
2938 }
2939 
2940 
2941 // static class members
2942 
#define LogDebug(id)
void setGtTriggerMenuName(const std::string &)
type
Definition: HCALResponse.h:21
bool isDebugEnabled()
int i
Definition: DBlmapReader.cc:9
void setCondGEq(const bool &cGEq)
void setAlgoAlias(const std::string &algoAliasValue)
void setGtScaleDbKey(const std::string &)
void parseCalMuEta_LUTS(std::map< std::string, tmeventsetup::esScale > scaleMap, std::string obj1, std::string obj2)
void parseCalMuPhi_LUTS(std::map< std::string, tmeventsetup::esScale > scaleMap, std::string obj1, std::string obj2)
void setGtOrderConditionChip(const std::vector< int > &)
Definition: L1GtObject.h:39
void setCond0Index(const int &)
virtual void print(std::ostream &myCout) const
print the condition
Definition: MuonTemplate.cc:97
Definition: L1GtObject.h:36
std::vector< std::pair< double, double > > etaBins
Definition: GlobalScales.h:54
virtual void print(std::ostream &myCout) const
print condition
std::vector< std::pair< double, double > > phiBins
Definition: GlobalScales.h:49
void setCondType(const l1t::GtConditionType &cType)
void setCorrelationParameter(const CorrelationParameter &corrParameter)
void setGtAlgorithmMap(const AlgorithmMap &)
void setVecCaloTemplate(const std::vector< std::vector< CaloTemplate > > &)
bool parseExternal(tmeventsetup::esCondition condExt, unsigned int chipNr=0)
virtual ~TriggerMenuParser()
destructor
std::map< std::string, unsigned int > getExternalSignals(const L1TUtmTriggerMenu *utmMenu)
virtual void print(std::ostream &myCout) const
print the condition
int ii
Definition: cuy.py:588
void setCondRelativeBx(const int &cRelativeBx)
virtual void print(std::ostream &myCout) const
print the condition
void setCondChipNr(const int &cChipNr)
void setVecEnergySumTemplate(const std::vector< std::vector< EnergySumTemplate > > &)
void setVecCorrelationTemplate(const std::vector< std::vector< CorrelationTemplate > > &)
Definition: L1GtObject.h:38
void setVecMuonTemplate(const std::vector< std::vector< MuonTemplate > > &)
int algoBitNumber() const
get / set algorithm bit number
void setGtAlgorithmAliasMap(const AlgorithmMap &)
void setGtPinsOnConditionChip(const unsigned int &)
void setGtAlgorithmImplementation(const std::string &)
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
void setExternalChannel(unsigned int extCh)
set functions
void parseCondFormats(const L1TUtmTriggerMenu *utmMenu)
void parseDeltaEta_Cosh_LUTS(std::map< std::string, tmeventsetup::esScale > scaleMap, std::string obj1, std::string obj2, unsigned int prec1, unsigned int prec2)
void setGtTriggerMenuInterface(const std::string &)
void setCond1Category(const l1t::GtConditionCategory &)
const int algoOutputPin(const int numberConditionChips, const int pinsOnConditionChip, const std::vector< int > &orderConditionChip) const
get the output pin on the condition chip for the algorithm
void setGtTriggerMenuAuthor(const std::string &)
void setConditionParameter(const std::vector< ObjectParameter > &objParameter, const CorrelationParameter &corrParameter)
set functions
Definition: CaloTemplate.cc:86
void setGtTriggerMenuInterfaceDescription(const std::string &)
bool insertConditionIntoMap(GlobalCondition &cond, const int chipNr)
void parseDeltaPhi_Cos_LUTS(std::map< std::string, tmeventsetup::esScale > scaleMap, std::string obj1, std::string obj2, unsigned int prec1, unsigned int prec2)
#define LogTrace(id)
void setObjectType(const std::vector< l1t::GlobalObject > &objType)
void setGtTriggerMenuDate(const std::string &)
const std::string & condName() const
get / set condition name
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 > > &)
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 &quot;energy sum&quot; condition
void setGtTriggerMenuDescription(const std::string &)
void setCorMuonTemplate(const std::vector< std::vector< MuonTemplate > > &)
void setCorEnergySumTemplate(const std::vector< std::vector< EnergySumTemplate > > &)
bool parseMuon(tmeventsetup::esCondition condMu, unsigned int chipNr=0, const bool corrFlag=false)
parse a muon condition
void setCond0Category(const l1t::GtConditionCategory &)
void setGtNumberConditionChips(const unsigned int &)
void parsePt_LUTS(std::map< std::string, tmeventsetup::esScale > scaleMap, std::string obj1, unsigned int prec)
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
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:87
void setGtTriggerMenuUUID(const int)
Definition: L1GtObject.h:37
typedef for correlation parameters
Definition: CaloTemplate.h:81
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool parseCalo(tmeventsetup::esCondition condCalo, unsigned int chipNr=0, const bool corrFlag=false)
parse a calorimeter condition
bool parseCorrelation(tmeventsetup::esCondition corrCond, unsigned int chipNr=0)
parse a correlation condition
void setCorCaloTemplate(const std::vector< std::vector< CaloTemplate > > &)
bool parseMuonCorr(const tmeventsetup::esObject *condMu, unsigned int chipNr=0)
void setGtTriggerMenuInterfaceDate(const std::string &)
void setGtTriggerMenuImplementation(const unsigned long &)
bool insertAlgorithmIntoMap(const GlobalAlgorithm &alg)
insert an algorithm into algorithm map
typedef for correlation parameters
virtual void print(std::ostream &myCout) const
print the condition
Definition: CaloTemplate.cc:96
long double T
void setGtConditionMap(const std::vector< ConditionMap > &)
std::map< std::string, GlobalAlgorithm > AlgorithmMap
map containing the algorithms
tuple size
Write out results.
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 setCond1Index(const int &)
void setGtNumberPhysTriggers(const unsigned int &)
const int algoChipNumber() const
get / set algorithm bit number