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); //blw
319 
320  // parse Energy Sums
321  } else if(condition.getType() == esConditionType::TotalEt ||
322  condition.getType() == esConditionType::TotalHt ||
323  condition.getType() == esConditionType::MissingEt ||
324  condition.getType() == esConditionType::MissingHt ||
325  //condition.getType() == esConditionType::MissingEt2 ||
326  condition.getType() == esConditionType::MinBiasHFP0 ||
327  condition.getType() == esConditionType::MinBiasHFM0 ||
328  condition.getType() == esConditionType::MinBiasHFP1 ||
329  condition.getType() == esConditionType::MinBiasHFM1 )
330  {
331  parseEnergySum(condition,chipNr,false);
332 
333  //parse Muons
334  } else if(condition.getType() == esConditionType::SingleMuon ||
335  condition.getType() == esConditionType::DoubleMuon ||
336  condition.getType() == esConditionType::TripleMuon ||
337  condition.getType() == esConditionType::QuadMuon )
338  {
339  parseMuon(condition,chipNr,false);
340 
341 
342  //parse Correlation Conditions
343  } else if(condition.getType() == esConditionType::MuonMuonCorrelation ||
344  condition.getType() == esConditionType::MuonEsumCorrelation ||
345  condition.getType() == esConditionType::CaloMuonCorrelation ||
346  condition.getType() == esConditionType::CaloCaloCorrelation ||
347  condition.getType() == esConditionType::CaloEsumCorrelation ||
348  condition.getType() == esConditionType::InvariantMass )
349  {
350  parseCorrelation(condition,chipNr);
351 
352  //parse Muons
353  } else if(condition.getType() == esConditionType::Externals )
354  {
355  parseExternal(condition,chipNr);
356 
357  }
358 
359  }//if condition is a new one
360  }//loop over conditions
361  }//loop over algorithms
362 
363  return;
364 
365 
366 }
367 
368 
369 
370 //
371 
373 
374  m_triggerMenuInterfaceDate = val;
375 
376 }
377 
379 
380  m_triggerMenuInterfaceAuthor = val;
381 
382 }
383 
385 
386  m_triggerMenuInterfaceDescription = val;
387 
388 }
389 
390 
392 
393  m_triggerMenuDate = val;
394 
395 }
396 
398 
399  m_triggerMenuAuthor = val;
400 
401 }
402 
404 
405  m_triggerMenuDescription = val;
406 
407 }
408 
410 
411  m_algorithmImplementation = val;
412 
413 }
414 
415 
416 
417 // methods for conditions and algorithms
418 
419 // clearMaps - delete all conditions and algorithms in
420 // the maps and clear the maps.
422 
423  // loop over condition maps (one map per condition chip)
424  // then loop over conditions in the map
425  for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip
426  != m_conditionMap.end(); itCondOnChip++) {
427 
428  // the conditions in the maps are deleted in L1uGtTriggerMenu, not here
429 
430  itCondOnChip->clear();
431 
432  }
433 
434  // the algorithms in the maps are deleted in L1uGtTriggerMenu, not here
435  m_algorithmMap.clear();
436 
437 }
438 
439 // insertConditionIntoMap - safe insert of condition into condition map.
440 // if the condition name already exists, do not insert it and return false
442 
443  std::string cName = cond.condName();
444  LogTrace("TriggerMenuParser")
445  << " Trying to insert condition \"" << cName << "\" in the condition map." ;
446 
447  // no condition name has to appear twice!
448  if ((m_conditionMap[chipNr]).count(cName) != 0) {
449  LogTrace("TriggerMenuParser") << " Condition " << cName
450  << " already exists - not inserted!" << std::endl;
451  return false;
452  }
453 
454  (m_conditionMap[chipNr])[cName] = &cond;
455  LogTrace("TriggerMenuParser")
456  << " OK - condition inserted!"
457  << std::endl;
458 
459 
460  return true;
461 
462 }
463 
464 // insert an algorithm into algorithm map
466 
467  std::string algName = alg.algoName();
468  std::string algAlias = alg.algoAlias();
469  //LogTrace("TriggerMenuParser")
470  //<< " Trying to insert algorithm \"" << algName << "\" in the algorithm map." ;
471 
472  // no algorithm name has to appear twice!
473  if (m_algorithmMap.count(algName) != 0) {
474  LogTrace("TriggerMenuParser") << " Algorithm \"" << algName
475  << "\"already exists in the algorithm map- not inserted!" << std::endl;
476  return false;
477  }
478 
479  if (m_algorithmAliasMap.count(algAlias) != 0) {
480  LogTrace("TriggerMenuParser") << " Algorithm alias \"" << algAlias
481  << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
482  return false;
483  }
484 
485  // bit number less than zero or greater than maximum number of algorithms
486  int bitNumber = alg.algoBitNumber();
487  if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
488  LogTrace("TriggerMenuParser") << " Bit number " << bitNumber
489  << " outside allowed range [0, " << m_numberPhysTriggers
490  << ") - algorithm not inserted!" << std::endl;
491  return false;
492  }
493 
494  // maximum number of algorithms
495  if (m_algorithmMap.size() >= m_numberPhysTriggers) {
496  LogTrace("TriggerMenuParser") << " More than maximum allowed "
497  << m_numberPhysTriggers << " algorithms in the algorithm map - not inserted!"
498  << std::endl;
499  return false;
500  }
501 
502 
503  // chip number outside allowed values
504  int chipNr = alg.algoChipNumber(static_cast<int>(m_numberConditionChips),
505  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
506 
507  if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
508  LogTrace("TriggerMenuParser") << " Chip number " << chipNr
509  << " outside allowed range [0, " << m_numberConditionChips
510  << ") - algorithm not inserted!" << std::endl;
511  return false;
512  }
513 
514  // output pin outside allowed values
515  int outputPin = alg.algoOutputPin(static_cast<int>(m_numberConditionChips),
516  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
517 
518  if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
519  LogTrace("TriggerMenuParser") << " Output pin " << outputPin
520  << " outside allowed range [0, " << m_pinsOnConditionChip
521  << "] - algorithm not inserted!" << std::endl;
522  return false;
523  }
524 
525  // no two algorithms on the same chip can have the same output pin
526  for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
527 
528  int iPin = (itAlgo->second).algoOutputPin( static_cast<int>(m_numberConditionChips),
529  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
530  std::string iName = itAlgo->first;
531  int iChip = (itAlgo->second).algoChipNumber(static_cast<int>(m_numberConditionChips),
532  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
533 
534  if ( (outputPin == iPin) && (chipNr == iChip)) {
535  LogTrace("TriggerMenuParser") << " Output pin " << outputPin
536  << " is the same as for algorithm " << iName
537  << "\n from the same chip number " << chipNr << " - algorithm not inserted!"
538  << std::endl;
539  return false;
540  }
541 
542  }
543 
544  // insert algorithm
545  m_algorithmMap[algName] = alg;
546  m_algorithmAliasMap[algAlias] = alg;
547 
548  //LogTrace("TriggerMenuParser")
549  //<< " OK - algorithm inserted!"
550  //<< std::endl;
551 
552  return true;
553 
554 }
555 
556 
558  std::stringstream ss;
559  ss << data;
560  return ss.str();
561 }
563  std::stringstream ss;
564  ss << data;
565  int value;
566  ss >> value;
567  return value;
568 }
569 
570 
578 bool l1t::TriggerMenuParser::parseScales(std::map<std::string, tmeventsetup::esScale> scaleMap) {
579 
580  using namespace tmeventsetup;
581 
582 // Setup ScaleParameter to hold information from parsing
591 
592 
593 // Start by parsing the Scale Map
594  for (std::map<std::string, esScale>::const_iterator cit = scaleMap.begin();
595  cit != scaleMap.end(); cit++)
596  {
597  const esScale& scale = cit->second;
598 
599  GlobalScales::ScaleParameters *scaleParam;
600  if (scale.getObjectType() == esObjectType::Muon) scaleParam = &muScales;
601  else if (scale.getObjectType() == esObjectType::Egamma) scaleParam = &egScales;
602  else if (scale.getObjectType() == esObjectType::Tau) scaleParam = &tauScales;
603  else if (scale.getObjectType() == esObjectType::Jet) scaleParam = &jetScales;
604  else if (scale.getObjectType() == esObjectType::ETT) scaleParam = &ettScales;
605  else if (scale.getObjectType() == esObjectType::ETM) scaleParam = &etmScales;
606  else if (scale.getObjectType() == esObjectType::HTT) scaleParam = &httScales;
607  else if (scale.getObjectType() == esObjectType::HTM) scaleParam = &htmScales;
608  else scaleParam = 0;
609 
610  if(scaleParam != 0) {
611  switch(scale.getScaleType()) {
612  case esScaleType::EtScale: {
613  scaleParam->etMin = scale.getMinimum();
614  scaleParam->etMax = scale.getMaximum();
615  scaleParam->etStep = scale.getStep();
616 
617  //Get bin edges
618  const std::vector<esBin> binsV = scale.getBins();
619  for(unsigned int i=0; i<binsV.size(); i++) {
620  const esBin& bin = binsV.at(i);
621  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
622  scaleParam->etBins.push_back(binLimits);
623  }
624 
625  // If this is an energy sum fill dummy values for eta and phi
626  // There are no scales for these in the XML so the other case statements will not be seen....do it here.
627  if(scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT ||
628  scale.getObjectType() == esObjectType::ETM || scale.getObjectType() == esObjectType::HTM ) {
629 
630  scaleParam->etaMin = -1.;
631  scaleParam->etaMax = -1.;
632  scaleParam->etaStep = -1.;
633  if(scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT) {
634  scaleParam->phiMin = -1.;
635  scaleParam->phiMax = -1.;
636  scaleParam->phiStep = -1.;
637  }
638  }
639  }
640  break;
641  case esScaleType::EtaScale: {
642  scaleParam->etaMin = scale.getMinimum();
643  scaleParam->etaMax = scale.getMaximum();
644  scaleParam->etaStep = scale.getStep();
645 
646  //Get bin edges
647  const std::vector<esBin> binsV = scale.getBins();
648  scaleParam->etaBins.resize(pow(2,scale.getNbits()));
649  for(unsigned int i=0; i<binsV.size(); i++) {
650  const esBin& bin = binsV.at(i);
651  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
652  scaleParam->etaBins.at(bin.hw_index) = binLimits;
653  }
654  }
655  break;
656  case esScaleType::PhiScale: {
657  scaleParam->phiMin = scale.getMinimum();
658  scaleParam->phiMax = scale.getMaximum();
659  scaleParam->phiStep = scale.getStep();
660 
661  //Get bin edges
662  const std::vector<esBin> binsV = scale.getBins();
663  scaleParam->phiBins.resize(pow(2,scale.getNbits()));
664  for(unsigned int i=0; i<binsV.size(); i++) {
665  const esBin& bin = binsV.at(i);
666  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
667  scaleParam->phiBins.at(bin.hw_index) = binLimits;
668  }
669  }
670  break;
671  default:
672 
673  break;
674  } //end switch
675  } //end valid scale
676  } //end loop over scaleMap
677 
678  // put the ScaleParameters into the class
679  m_gtScales.setMuonScales(muScales);
680  m_gtScales.setEGScales(egScales);
681  m_gtScales.setTauScales(tauScales);
682  m_gtScales.setJetScales(jetScales);
683  m_gtScales.setETTScales(ettScales);
684  m_gtScales.setETMScales(etmScales);
685  m_gtScales.setHTTScales(httScales);
686  m_gtScales.setHTMScales(htmScales);
687 
688 
689 
690 // Setup the LUT for the Scale Conversions
691  bool hasPrecision = false;
692  std::map<std::string, unsigned int> precisions;
693  getPrecisions(precisions, scaleMap);
694  for (std::map<std::string, unsigned int>::const_iterator cit = precisions.begin(); cit != precisions.end(); cit++)
695  {
696  //std::cout << cit->first << " = " << cit->second << "\n";
697  hasPrecision = true;
698  }
699 
700 
701  if (hasPrecision)
702  {
703 
704  //Start with the Cal - Muon Eta LUTS
705  //----------------------------------
706  parseCalMuEta_LUTS(scaleMap, "EG", "MU");
707  parseCalMuEta_LUTS(scaleMap, "JET", "MU");
708  parseCalMuEta_LUTS(scaleMap, "TAU", "MU");
709 
710  //Now the Cal - Muon Phi LUTS
711  //-------------------------------------
712  parseCalMuPhi_LUTS(scaleMap, "EG", "MU");
713  parseCalMuPhi_LUTS(scaleMap, "JET", "MU");
714  parseCalMuPhi_LUTS(scaleMap, "TAU", "MU");
715  parseCalMuPhi_LUTS(scaleMap, "HTM", "MU");
716  parseCalMuPhi_LUTS(scaleMap, "ETM", "MU");
717 
718  // Now the Pt LUTs (??? more combinations needed ??)
719  // ---------------
720  parsePt_LUTS(scaleMap, "EG", precisions["PRECISION-EG-MU-MassPt"] );
721  parsePt_LUTS(scaleMap, "MU", precisions["PRECISION-EG-MU-MassPt"] );
722  parsePt_LUTS(scaleMap, "JET", precisions["PRECISION-EG-JET-MassPt"] );
723  parsePt_LUTS(scaleMap, "TAU", precisions["PRECISION-EG-TAU-MassPt"] );
724 
725  // Now the Delta Eta/Cosh LUTs (must be done in groups)
726  // ----------------------------------------------------
727  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
728  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","JET",precisions["PRECISION-EG-JET-Delta"],precisions["PRECISION-EG-JET-Math"]);
729  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","TAU",precisions["PRECISION-EG-TAU-Delta"],precisions["PRECISION-EG-TAU-Math"]);
730  parseDeltaEta_Cosh_LUTS(scaleMap,"EG","MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
731 
732  parseDeltaEta_Cosh_LUTS(scaleMap,"JET","JET",precisions["PRECISION-JET-JET-Delta"],precisions["PRECISION-JET-JET-Math"]);
733  parseDeltaEta_Cosh_LUTS(scaleMap,"JET","TAU",precisions["PRECISION-JET-TAU-Delta"],precisions["PRECISION-JET-TAU-Math"]);
734  parseDeltaEta_Cosh_LUTS(scaleMap,"JET","MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
735 
736  parseDeltaEta_Cosh_LUTS(scaleMap,"TAU","TAU",precisions["PRECISION-TAU-TAU-Delta"],precisions["PRECISION-TAU-TAU-Math"]);
737  parseDeltaEta_Cosh_LUTS(scaleMap,"TAU","MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
738 
739  parseDeltaEta_Cosh_LUTS(scaleMap,"MU","MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
740 
741 
742  // Now the Delta Phi/Cos LUTs (must be done in groups)
743  // ----------------------------------------------------
744  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
745  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","JET",precisions["PRECISION-EG-JET-Delta"],precisions["PRECISION-EG-JET-Math"]);
746  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","TAU",precisions["PRECISION-EG-TAU-Delta"],precisions["PRECISION-EG-TAU-Math"]);
747  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","ETM",precisions["PRECISION-EG-ETM-Delta"],precisions["PRECISION-EG-ETM-Math"]);
748  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","HTM",precisions["PRECISION-EG-HTM-Delta"],precisions["PRECISION-EG-HTM-Math"]);
749  parseDeltaPhi_Cos_LUTS(scaleMap,"EG","MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
750 
751  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","JET",precisions["PRECISION-JET-JET-Delta"],precisions["PRECISION-JET-JET-Math"]);
752  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","TAU",precisions["PRECISION-JET-TAU-Delta"],precisions["PRECISION-JET-TAU-Math"]);
753  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","ETM",precisions["PRECISION-JET-ETM-Delta"],precisions["PRECISION-JET-ETM-Math"]);
754  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","HTM",precisions["PRECISION-JET-HTM-Delta"],precisions["PRECISION-JET-HTM-Math"]);
755  parseDeltaPhi_Cos_LUTS(scaleMap,"JET","MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
756 
757  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","TAU",precisions["PRECISION-TAU-TAU-Delta"],precisions["PRECISION-TAU-TAU-Math"]);
758  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","ETM",precisions["PRECISION-TAU-ETM-Delta"],precisions["PRECISION-TAU-ETM-Math"]);
759  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","HTM",precisions["PRECISION-TAU-HTM-Delta"],precisions["PRECISION-TAU-HTM-Math"]);
760  parseDeltaPhi_Cos_LUTS(scaleMap,"TAU","MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
761 
762  parseDeltaPhi_Cos_LUTS(scaleMap,"MU","ETM",precisions["PRECISION-MU-ETM-Delta"],precisions["PRECISION-MU-ETM-Math"]);
763  parseDeltaPhi_Cos_LUTS(scaleMap,"MU","HTM",precisions["PRECISION-MU-HTM-Delta"],precisions["PRECISION-MU-HTM-Math"]);
764  parseDeltaPhi_Cos_LUTS(scaleMap,"MU","MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
765 
766  //m_gtScales.dumpAllLUTs(std::cout);
767  //m_gtScales.print(std::cout);
768 
769  }
770 
771 
772 
773 
774 
775  return true;
776 }
777 
778 void l1t::TriggerMenuParser::parseCalMuEta_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string obj1, std::string obj2)
779 {
780 
781  using namespace tmeventsetup;
782 
783  // First Delta Eta for this set
784  std::string scLabel1 = obj1;
785  scLabel1 += "-ETA";
786  std::string scLabel2 = obj2;
787  scLabel2 += "-ETA";
788  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
789  const esScale* scale2 = &scaleMap.find(scLabel2)->second;
790 
791  std::vector<long long> lut_cal_2_mu_eta;
792  getCaloMuonEtaConversionLut(lut_cal_2_mu_eta, scale1, scale2);
793 
794  std::string lutName = obj1;
795  lutName += "-";
796  lutName += obj2;
797  m_gtScales.setLUT_CalMuEta(lutName,lut_cal_2_mu_eta);
798 
799 
800 }
801 
802 void l1t::TriggerMenuParser::parseCalMuPhi_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string obj1, std::string obj2)
803 {
804 
805  using namespace tmeventsetup;
806 
807  // First Delta Eta for this set
808  std::string scLabel1 = obj1;
809  scLabel1 += "-PHI";
810  std::string scLabel2 = obj2;
811  scLabel2 += "-PHI";
812  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
813  const esScale* scale2 = &scaleMap.find(scLabel2)->second;
814 
815  std::vector<long long> lut_cal_2_mu_phi;
816  getCaloMuonPhiConversionLut(lut_cal_2_mu_phi, scale1, scale2);
817 
818  std::string lutName = obj1;
819  lutName += "-";
820  lutName += obj2;
821  m_gtScales.setLUT_CalMuPhi(lutName,lut_cal_2_mu_phi);
822 
823 
824 }
825 
826 void l1t::TriggerMenuParser::parsePt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string obj1, unsigned int prec)
827 {
828 
829  using namespace tmeventsetup;
830 
831  // First Delta Eta for this set
832  std::string scLabel1 = obj1;
833  scLabel1 += "-ET";
834  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
835 
836  std::vector<long long> lut_pt;
837  getLut(lut_pt, scale1, prec);
838  m_gtScales.setLUT_Pt(scLabel1,lut_pt,prec);
839 
840 
841 }
842 
843 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)
844 {
845 
846  using namespace tmeventsetup;
847 
848  // First Delta Eta for this set
849  std::string scLabel1 = obj1;
850  scLabel1 += "-ETA";
851  std::string scLabel2 = obj2;
852  scLabel2 += "-ETA";
853  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
854  const esScale* scale2 = &scaleMap.find(scLabel2)->second;
855  std::vector<double> val_delta_eta;
856  std::vector<long long> lut_delta_eta;
857  size_t n = getDeltaVector(val_delta_eta, scale1, scale2);
858  setLut(lut_delta_eta, val_delta_eta, prec1);
859  std::string lutName = obj1;
860  lutName += "-";
861  lutName += obj2;
862  m_gtScales.setLUT_DeltaEta(lutName,lut_delta_eta,prec1);
863 
864  // Second Get the Cosh for this delta Eta Set
865  std::vector<long long> lut_cosh;
866  applyCosh(val_delta_eta, n);
867  setLut(lut_cosh, val_delta_eta, prec2);
868  m_gtScales.setLUT_Cosh(lutName,lut_cosh,prec2);
869 
870 }
871 
872 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)
873 {
874 
875  using namespace tmeventsetup;
876 
877  // First Delta phi for this set
878  std::string scLabel1 = obj1;
879  scLabel1 += "-PHI";
880  std::string scLabel2 = obj2;
881  scLabel2 += "-PHI";
882  const esScale* scale1 = &scaleMap.find(scLabel1)->second;
883  const esScale* scale2 = &scaleMap.find(scLabel2)->second;
884  std::vector<double> val_delta_phi;
885  std::vector<long long> lut_delta_phi;
886  size_t n = getDeltaVector(val_delta_phi, scale1, scale2);
887  setLut(lut_delta_phi, val_delta_phi, prec1);
888  std::string lutName = obj1;
889  lutName += "-";
890  lutName += obj2;
891  m_gtScales.setLUT_DeltaPhi(lutName,lut_delta_phi,prec1);
892 
893  // Second Get the Cosh for this delta phi Set
894  std::vector<long long> lut_cos;
895  applyCos(val_delta_phi, n);
896  setLut(lut_cos, val_delta_phi, prec2);
897  m_gtScales.setLUT_Cos(lutName,lut_cos,prec2);
898 
899 }
900 
912 bool l1t::TriggerMenuParser::parseMuon(tmeventsetup::esCondition condMu,
913  unsigned int chipNr, const bool corrFlag) {
914 
915  using namespace tmeventsetup;
916 
917  // get condition, particle name (must be muon) and type name
918  std::string condition = "muon";
919  std::string particle = "muon";//l1t2string( condMu.objectType() );
920  std::string type = l1t2string( condMu.getType() );
921  std::string name = l1t2string( condMu.getName() );
922  int nrObj = -1;
923 
924 
925 
927 
928  if (condMu.getType() == esConditionType::SingleMuon) {
929  type = "1_s";
930  cType = l1t::Type1s;
931  nrObj = 1;
932  } else if (condMu.getType() == esConditionType::DoubleMuon) {
933  type = "2_s";
934  cType = l1t::Type2s;
935  nrObj = 2;
936  } else if (condMu.getType() == esConditionType::TripleMuon) {
937  type = "3";
938  cType = l1t::Type3s;
939  nrObj = 3;
940  } else if (condMu.getType() == esConditionType::QuadMuon) {
941  type = "4";
942  cType = l1t::Type4s;
943  nrObj = 4;
944  } else {
945  edm::LogError("TriggerMenuParser") << "Wrong type for muon-condition ("
946  << type << ")" << std::endl;
947  return false;
948  }
949 
950  if (nrObj < 0) {
951  edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type
952  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
953  return false;
954  }
955 
956  LogDebug("TriggerMenuParser")
957  << "\n ****************************************** "
958  << "\n parseMuon "
959  << "\n condition = " << condition
960  << "\n particle = " << particle
961  << "\n type = " << type
962  << "\n name = " << name
963  << std::endl;
964 
965 
966 
967 // // get values
968 
969  // temporary storage of the parameters
970  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
971 
972  // Do we need this?
974 
975  // need at least two values for deltaPhi
976  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
977  tmpValues.reserve( nrObj );
978 
979  if( int(condMu.getObjects().size())!=nrObj ){
980  edm::LogError("TriggerMenuParser") << " condMu objects: nrObj = " << nrObj
981  << "condMu.getObjects().size() = "
982  << condMu.getObjects().size()
983  << std::endl;
984  return false;
985  }
986 
987 
988 // Look for cuts on the objects in the condition
989  unsigned int chargeCorrelation = 1;
990  const std::vector<esCut>& cuts = condMu.getCuts();
991  for (size_t jj = 0; jj < cuts.size(); jj++)
992  {
993  const esCut cut = cuts.at(jj);
994  if(cut.getCutType() == esCutType::ChargeCorrelation) {
995  if( cut.getData()=="ls" ) chargeCorrelation = 2;
996  else if( cut.getData()=="os" ) chargeCorrelation = 4;
997  else chargeCorrelation = 1; //ignore correlation
998  }
999  }
1000 
1001  //set charge correlation parameter
1002  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
1003 
1004 
1005  int cnt = 0;
1006 
1007 
1008 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1009  int relativeBx = 0;
1010  bool gEq = false;
1011 
1012 // Loop over objects and extract the cuts on the objects
1013  const std::vector<esObject>& objects = condMu.getObjects();
1014  for (size_t jj = 0; jj < objects.size(); jj++) {
1015 
1016  const esObject object = objects.at(jj);
1017  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1018 
1019 // BLW TO DO: This needs to be added to the Object Parameters
1020  relativeBx = object.getBxOffset();
1021 
1022 // Loop over the cuts for this object
1023  int upperThresholdInd = -1;
1024  int lowerThresholdInd = 0;
1025  int cntEta = 0;
1026  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1027  int cntPhi = 0;
1028  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1029  int isolationLUT = 0xF; //default is to ignore unless specified.
1030  int charge = -1; //default value is to ignore unless specified
1031  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
1032 
1033  const std::vector<esCut>& cuts = object.getCuts();
1034  for (size_t kk = 0; kk < cuts.size(); kk++)
1035  {
1036  const esCut cut = cuts.at(kk);
1037 
1038  switch(cut.getCutType()){
1039  case esCutType::Threshold:
1040  lowerThresholdInd = cut.getMinimum().index;
1041  upperThresholdInd = cut.getMaximum().index;
1042  break;
1043 
1044  case esCutType::Eta: {
1045 
1046  if(cntEta == 0) {
1047  etaWindow1Lower = cut.getMinimum().index;
1048  etaWindow1Upper = cut.getMaximum().index;
1049  } else if(cntEta == 1) {
1050  etaWindow2Lower = cut.getMinimum().index;
1051  etaWindow2Upper = cut.getMaximum().index;
1052  } else {
1053  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for muon-condition ("
1054  << particle << ")" << std::endl;
1055  return false;
1056  }
1057  cntEta++;
1058 
1059  } break;
1060 
1061  case esCutType::Phi: {
1062 
1063  if(cntPhi == 0) {
1064  phiWindow1Lower = cut.getMinimum().index;
1065  phiWindow1Upper = cut.getMaximum().index;
1066  } else if(cntPhi == 1) {
1067  phiWindow2Lower = cut.getMinimum().index;
1068  phiWindow2Upper = cut.getMaximum().index;
1069  } else {
1070  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for muon-condition ("
1071  << particle << ")" << std::endl;
1072  return false;
1073  }
1074  cntPhi++;
1075 
1076  }break;
1077 
1078  case esCutType::Charge:
1079  if( cut.getData()=="positive" ) charge = 0;
1080  else if( cut.getData()=="negative" ) charge = 1;
1081  else charge = -1;
1082  break;
1083  case esCutType::Quality:
1084 
1085  qualityLUT = l1tstr2int(cut.getData());
1086 
1087  break;
1088  case esCutType::Isolation: {
1089 
1090  isolationLUT = l1tstr2int(cut.getData());
1091 
1092  } break;
1093  default:
1094  break;
1095  } //end switch
1096 
1097  } //end loop over cuts
1098 
1099 
1100 // Set the parameter cuts
1101  objParameter[cnt].ptHighThreshold = upperThresholdInd;
1102  objParameter[cnt].ptLowThreshold = lowerThresholdInd;
1103 
1104  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
1105  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
1106  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
1107  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
1108 
1109  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1110  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1111  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1112  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1113 
1114 // BLW TO DO: Do we need these anymore? Drop them?
1115  objParameter[cnt].enableMip = false;//tmpMip[i];
1116  objParameter[cnt].enableIso = false;//tmpEnableIso[i];
1117  objParameter[cnt].requestIso = false;//tmpRequestIso[i];
1118 
1119  objParameter[cnt].charge = charge;
1120  objParameter[cnt].qualityLUT = qualityLUT;
1121  objParameter[cnt].isolationLUT = isolationLUT;
1122 
1123 
1124  cnt++;
1125  } //end loop over objects
1126 
1127 
1128  // object types - all muons
1129  std::vector<GlobalObject> objType(nrObj, gtMu);
1130 
1131 
1132 
1133  // now create a new CondMuonition
1134  MuonTemplate muonCond(name);
1135 
1136  muonCond.setCondType(cType);
1137  muonCond.setObjectType(objType);
1138  muonCond.setCondGEq(gEq);
1139  muonCond.setCondChipNr(chipNr);
1140  muonCond.setCondRelativeBx(relativeBx);
1141 
1142  muonCond.setConditionParameter(objParameter, corrParameter);
1143 
1144  if (edm::isDebugEnabled()) {
1145  std::ostringstream myCoutStream;
1146  muonCond.print(myCoutStream);
1147  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1148  }
1149 
1150  // insert condition into the map and into muon template vector
1151  if ( !insertConditionIntoMap(muonCond, chipNr)) {
1152  edm::LogError("TriggerMenuParser")
1153  << " Error: duplicate condition (" << name << ")"
1154  << std::endl;
1155  return false;
1156  }
1157  else {
1158  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1159  if (corrFlag) {
1160 
1161  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1162  }
1163  else {
1164  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the vecMuonTemplate vector" << std::endl;
1165  (m_vecMuonTemplate[chipNr]).push_back(muonCond);
1166  }
1167 
1168  }
1169 
1170  //
1171  return true;
1172 }
1173 
1174 
1175 bool l1t::TriggerMenuParser::parseMuonCorr(const tmeventsetup::esObject* corrMu,
1176  unsigned int chipNr) {
1177 
1178 
1179 // XERCES_CPP_NAMESPACE_USE
1180  using namespace tmeventsetup;
1181 
1182  // get condition, particle name (must be muon) and type name
1183  std::string condition = "muon";
1184  std::string particle = "muon";//l1t2string( condMu.objectType() );
1185  std::string type = l1t2string( corrMu->getType() );
1186  std::string name = l1t2string( corrMu->getName() );
1187  int nrObj = 1;
1188  type = "1_s";
1189  GtConditionType cType = l1t::Type1s;
1190 
1191 
1192 
1193  if (nrObj < 0) {
1194  edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type
1195  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1196  return false;
1197  }
1198 
1199  LogDebug("TriggerMenuParser")
1200  << "\n ****************************************** "
1201  << "\n parseMuon "
1202  << "\n condition = " << condition
1203  << "\n particle = " << particle
1204  << "\n type = " << type
1205  << "\n name = " << name
1206  << std::endl;
1207 
1208 
1209 
1210 // // get values
1211 
1212  // temporary storage of the parameters
1213  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1214 
1215  // Do we need this?
1216  MuonTemplate::CorrelationParameter corrParameter;
1217 
1218  // need at least two values for deltaPhi
1219  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1220  tmpValues.reserve( nrObj );
1221 
1222 
1223 // BLW TO DO: How do we deal with these in the new format
1224 // std::string str_chargeCorrelation = l1t2string( condMu.requestedChargeCorr() );
1225  std::string str_chargeCorrelation = "ig";
1226  unsigned int chargeCorrelation = 0;
1227  if( str_chargeCorrelation=="ig" ) chargeCorrelation = 1;
1228  else if( str_chargeCorrelation=="ls" ) chargeCorrelation = 2;
1229  else if( str_chargeCorrelation=="os" ) chargeCorrelation = 4;
1230 
1231  //getXMLHexTextValue("1", dst);
1232  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
1233 
1234 
1235 
1236  // BLW TO DO: These needs to the added to the object rather than the whole condition.
1237  int relativeBx = 0;
1238  bool gEq = false;
1239 
1240 
1241  //const esObject* object = condMu;
1242  gEq = (corrMu->getComparisonOperator() == esComparisonOperator::GE);
1243 
1244  // BLW TO DO: This needs to be added to the Object Parameters
1245  relativeBx = corrMu->getBxOffset();
1246 
1247  // Loop over the cuts for this object
1248  int upperThresholdInd = -1;
1249  int lowerThresholdInd = 0;
1250  int cntEta = 0;
1251  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1252  int cntPhi = 0;
1253  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1254  int isolationLUT = 0xF; //default is to ignore unless specified.
1255  int charge = -1; //defaut is to ignore unless specified
1256  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
1257 
1258  const std::vector<esCut>& cuts = corrMu->getCuts();
1259  for (size_t kk = 0; kk < cuts.size(); kk++)
1260  {
1261  const esCut cut = cuts.at(kk);
1262 
1263  switch(cut.getCutType()){
1264  case esCutType::Threshold:
1265  lowerThresholdInd = cut.getMinimum().index;
1266  upperThresholdInd = cut.getMaximum().index;
1267  break;
1268 
1269  case esCutType::Eta: {
1270 
1271  if(cntEta == 0) {
1272  etaWindow1Lower = cut.getMinimum().index;
1273  etaWindow1Upper = cut.getMaximum().index;
1274  } else if(cntEta == 1) {
1275  etaWindow2Lower = cut.getMinimum().index;
1276  etaWindow2Upper = cut.getMaximum().index;
1277  } else {
1278  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for muon-condition ("
1279  << particle << ")" << std::endl;
1280  return false;
1281  }
1282  cntEta++;
1283 
1284  } break;
1285 
1286  case esCutType::Phi: {
1287 
1288  if(cntPhi == 0) {
1289  phiWindow1Lower = cut.getMinimum().index;
1290  phiWindow1Upper = cut.getMaximum().index;
1291  } else if(cntPhi == 1) {
1292  phiWindow2Lower = cut.getMinimum().index;
1293  phiWindow2Upper = cut.getMaximum().index;
1294  } else {
1295  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for muon-condition ("
1296  << particle << ")" << std::endl;
1297  return false;
1298  }
1299  cntPhi++;
1300 
1301  }break;
1302 
1303  case esCutType::Charge:
1304  if( cut.getData()=="positive" ) charge = 0;
1305  else if( cut.getData()=="negative" ) charge = 1;
1306  else charge = -1;
1307  break;
1308  case esCutType::Quality:
1309 
1310  qualityLUT = l1tstr2int(cut.getData());
1311 
1312  break;
1313  case esCutType::Isolation: {
1314 
1315  isolationLUT = l1tstr2int(cut.getData());
1316 
1317  } break;
1318  default:
1319  break;
1320  } //end switch
1321 
1322  } //end loop over cuts
1323 
1324 
1325  // Set the parameter cuts
1326  objParameter[0].ptHighThreshold = upperThresholdInd;
1327  objParameter[0].ptLowThreshold = lowerThresholdInd;
1328 
1329  objParameter[0].etaWindow1Lower = etaWindow1Lower;
1330  objParameter[0].etaWindow1Upper = etaWindow1Upper;
1331  objParameter[0].etaWindow2Lower = etaWindow2Lower;
1332  objParameter[0].etaWindow2Upper = etaWindow2Upper;
1333 
1334  objParameter[0].phiWindow1Lower = phiWindow1Lower;
1335  objParameter[0].phiWindow1Upper = phiWindow1Upper;
1336  objParameter[0].phiWindow2Lower = phiWindow2Lower;
1337  objParameter[0].phiWindow2Upper = phiWindow2Upper;
1338 
1339  // BLW TO DO: Do we need these anymore? Drop them?
1340  objParameter[0].enableMip = false;//tmpMip[i];
1341  objParameter[0].enableIso = false;//tmpEnableIso[i];
1342  objParameter[0].requestIso = false;//tmpRequestIso[i];
1343 
1344  objParameter[0].charge = charge;
1345  objParameter[0].qualityLUT = qualityLUT;
1346  objParameter[0].isolationLUT = isolationLUT;
1347 
1348 
1349  // object types - all muons
1350  std::vector<GlobalObject> objType(nrObj, gtMu);
1351 
1352  // now create a new CondMuonition
1353  MuonTemplate muonCond(name);
1354 
1355  muonCond.setCondType(cType);
1356  muonCond.setObjectType(objType);
1357  muonCond.setCondGEq(gEq);
1358  muonCond.setCondChipNr(chipNr);
1359  muonCond.setCondRelativeBx(relativeBx);
1360  muonCond.setConditionParameter(objParameter, corrParameter);
1361 
1362  if (edm::isDebugEnabled()) {
1363  std::ostringstream myCoutStream;
1364  muonCond.print(myCoutStream);
1365  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1366  }
1367 
1368 /*
1369  // insert condition into the map and into muon template vector
1370  if ( !insertConditionIntoMap(muonCond, chipNr)) {
1371  edm::LogError("TriggerMenuParser")
1372  << " Error: duplicate condition (" << name << ")"
1373  << std::endl;
1374  return false;
1375  }
1376  else {
1377  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1378  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1379  }
1380 */
1381  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1382 
1383 
1384  //
1385  return true;
1386 }
1387 
1388 
1400 bool l1t::TriggerMenuParser::parseCalo(tmeventsetup::esCondition condCalo,
1401  unsigned int chipNr, const bool corrFlag) {
1402 
1403 
1404 // XERCES_CPP_NAMESPACE_USE
1405  using namespace tmeventsetup;
1406 
1407  // get condition, particle name and type name
1408 
1409  std::string condition = "calo";
1410  std::string particle = "test-fix" ;
1411  std::string type = l1t2string( condCalo.getType() );
1412  std::string name = l1t2string( condCalo.getName() );
1413 
1414  LogDebug("TriggerMenuParser")
1415  << "\n ****************************************** "
1416  << "\n (in parseCalo) "
1417  << "\n condition = " << condition
1418  << "\n particle = " << particle
1419  << "\n type = " << type
1420  << "\n name = " << name
1421  << std::endl;
1422 
1423 
1424  GtConditionType cType = l1t::TypeNull;
1425 
1426  // determine object type type
1427  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
1428  GlobalObject caloObjType;
1429  int nrObj = -1;
1430 
1431  if (condCalo.getType() == esConditionType::SingleEgamma) {
1432  caloObjType = gtEG;
1433  type = "1_s";
1434  cType= l1t::Type1s;
1435  nrObj = 1;
1436  } else if (condCalo.getType() == esConditionType::DoubleEgamma) {
1437  caloObjType = gtEG;
1438  type = "2_s";
1439  cType= l1t::Type2s;
1440  nrObj = 2;
1441  } else if (condCalo.getType() == esConditionType::TripleEgamma) {
1442  caloObjType = gtEG;
1443  cType= l1t::Type3s;
1444  type = "3";
1445  nrObj = 3;
1446  } else if (condCalo.getType() == esConditionType::QuadEgamma) {
1447  caloObjType = gtEG;
1448  cType= l1t::Type4s;
1449  type = "4";
1450  nrObj = 4;
1451  } else if (condCalo.getType() == esConditionType::SingleJet) {
1452  caloObjType = gtJet;
1453  cType= l1t::Type1s;
1454  type = "1_s";
1455  nrObj = 1;
1456  } else if (condCalo.getType() == esConditionType::DoubleJet) {
1457  caloObjType = gtJet;
1458  cType= l1t::Type2s;
1459  type = "2_s";
1460  nrObj = 2;
1461  } else if (condCalo.getType() == esConditionType::TripleJet) {
1462  caloObjType = gtJet;
1463  cType= l1t::Type3s;
1464  type = "3";
1465  nrObj = 3;
1466  } else if (condCalo.getType() == esConditionType::QuadJet) {
1467  caloObjType = gtJet;
1468  cType= l1t::Type4s;
1469  type = "4";
1470  nrObj = 4;
1471  } else if (condCalo.getType() == esConditionType::SingleTau) {
1472  caloObjType = gtTau;
1473  cType= l1t::Type1s;
1474  type = "1_s";
1475  nrObj = 1;
1476  } else if (condCalo.getType() == esConditionType::DoubleTau) {
1477  caloObjType = gtTau;
1478  cType= l1t::Type2s;
1479  type = "2_s";
1480  nrObj = 2;
1481  } else if (condCalo.getType() == esConditionType::TripleTau) {
1482  caloObjType = gtTau;
1483  cType= l1t::Type3s;
1484  type = "3";
1485  nrObj = 3;
1486  } else if (condCalo.getType() == esConditionType::QuadTau) {
1487  caloObjType = gtTau;
1488  cType= l1t::Type4s;
1489  type = "4";
1490  nrObj = 4;
1491  } else {
1492  edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition ("
1493  << particle << ")" << std::endl;
1494  return false;
1495  }
1496 
1497 // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1498 
1499  if (nrObj < 0) {
1500  edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type
1501  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1502  return false;
1503  }
1504 
1505  // get values
1506 
1507  // temporary storage of the parameters
1508  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1509 
1510  //BLW TO DO: Can this be dropped?
1511  CaloTemplate::CorrelationParameter corrParameter;
1512 
1513  // need at least one value for deltaPhiRange
1514  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1515  tmpValues.reserve( nrObj );
1516 
1517 
1518  if( int(condCalo.getObjects().size())!=nrObj ){
1519  edm::LogError("TriggerMenuParser") << " condCalo objects: nrObj = " << nrObj
1520  << "condCalo.getObjects().size() = "
1521  << condCalo.getObjects().size()
1522  << std::endl;
1523  return false;
1524  }
1525 
1526 
1527 // std::string str_condCalo = "";
1528 // boost::uint64_t tempUIntH, tempUIntL;
1529 // boost::uint64_t dst;
1530  int cnt = 0;
1531 
1532 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1533  int relativeBx = 0;
1534  bool gEq = false;
1535 
1536 // Loop over objects and extract the cuts on the objects
1537  const std::vector<esObject>& objects = condCalo.getObjects();
1538  for (size_t jj = 0; jj < objects.size(); jj++) {
1539 
1540  const esObject object = objects.at(jj);
1541  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1542 
1543 // BLW TO DO: This needs to be added to the Object Parameters
1544  relativeBx = object.getBxOffset();
1545 
1546 // Loop over the cuts for this object
1547  int upperThresholdInd = -1;
1548  int lowerThresholdInd = 0;
1549  int cntEta = 0;
1550  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1551  int cntPhi = 0;
1552  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1553  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
1554  int qualityLUT = 0xF; //default is to ignore quality unless specified.
1555 
1556 
1557  const std::vector<esCut>& cuts = object.getCuts();
1558  for (size_t kk = 0; kk < cuts.size(); kk++)
1559  {
1560  const esCut cut = cuts.at(kk);
1561 
1562  switch(cut.getCutType()){
1563  case esCutType::Threshold:
1564  lowerThresholdInd = cut.getMinimum().index;
1565  upperThresholdInd = cut.getMaximum().index;
1566  break;
1567  case esCutType::Eta: {
1568 
1569  if(cntEta == 0) {
1570  etaWindow1Lower = cut.getMinimum().index;
1571  etaWindow1Upper = cut.getMaximum().index;
1572  } else if(cntEta == 1) {
1573  etaWindow2Lower = cut.getMinimum().index;
1574  etaWindow2Upper = cut.getMaximum().index;
1575  } else {
1576  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for calo-condition ("
1577  << particle << ")" << std::endl;
1578  return false;
1579  }
1580  cntEta++;
1581 
1582  } break;
1583 
1584  case esCutType::Phi: {
1585 
1586  if(cntPhi == 0) {
1587  phiWindow1Lower = cut.getMinimum().index;
1588  phiWindow1Upper = cut.getMaximum().index;
1589  } else if(cntPhi == 1) {
1590  phiWindow2Lower = cut.getMinimum().index;
1591  phiWindow2Upper = cut.getMaximum().index;
1592  } else {
1593  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for calo-condition ("
1594  << particle << ")" << std::endl;
1595  return false;
1596  }
1597  cntPhi++;
1598 
1599  }break;
1600 
1601  case esCutType::Charge: {
1602 
1603  edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition ("
1604  << particle << ")" << std::endl;
1605  return false;
1606 
1607  }break;
1608  case esCutType::Quality: {
1609 
1610  qualityLUT = l1tstr2int(cut.getData());
1611 
1612  }break;
1613  case esCutType::Isolation: {
1614 
1615  isolationLUT = l1tstr2int(cut.getData());
1616 
1617  } break;
1618  default:
1619  break;
1620  } //end switch
1621 
1622  } //end loop over cuts
1623 
1624 // Fill the object parameters
1625  objParameter[cnt].etHighThreshold = upperThresholdInd;
1626  objParameter[cnt].etLowThreshold = lowerThresholdInd;
1627  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
1628  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
1629  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
1630  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
1631  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1632  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1633  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1634  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1635  objParameter[cnt].isolationLUT = isolationLUT;
1636  objParameter[cnt].qualityLUT = qualityLUT; //TO DO: Must add
1637 
1638  // Output for debugging
1639  LogDebug("TriggerMenuParser")
1640  << "\n Calo ET high thresholds (hex) for calo object " << caloObjType << " " << cnt << " = "
1641  << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold
1642  << "\n etaWindow Lower / Upper for calo object " << cnt << " = 0x"
1643  << objParameter[cnt].etaWindow1Lower << " / 0x" << objParameter[cnt].etaWindow1Upper
1644  << "\n etaWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
1645  << objParameter[cnt].etaWindow2Lower << " / 0x" << objParameter[cnt].etaWindow2Upper
1646  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
1647  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
1648  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
1649  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper
1650  << "\n Isolation LUT for calo object " << cnt << " = 0x"
1651  << objParameter[cnt].isolationLUT
1652  << "\n Quality LUT for calo object " << cnt << " = 0x"
1653  << objParameter[cnt].qualityLUT << std::dec
1654  << std::endl;
1655 
1656  cnt++;
1657  } //end loop over objects
1658 
1659 
1660 
1661  // object types - all same caloObjType
1662  std::vector<GlobalObject> objType(nrObj, caloObjType);
1663 
1664 
1665 
1666 
1667  // now create a new calo condition
1668  CaloTemplate caloCond(name);
1669 
1670  caloCond.setCondType(cType);
1671  caloCond.setObjectType(objType);
1672 
1673  //BLW TO DO: This needs to be added to the object rather than the whole condition
1674  caloCond.setCondGEq(gEq);
1675  caloCond.setCondChipNr(chipNr);
1676 
1677  //BLW TO DO: This needs to be added to the object rather than the whole condition
1678  caloCond.setCondRelativeBx(relativeBx);
1679 
1680  caloCond.setConditionParameter(objParameter, corrParameter);
1681 
1682  if (edm::isDebugEnabled() ) {
1683 
1684  std::ostringstream myCoutStream;
1685  caloCond.print(myCoutStream);
1686  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1687 
1688  }
1689 
1690 
1691  // insert condition into the map
1692  if ( !insertConditionIntoMap(caloCond, chipNr)) {
1693 
1694  edm::LogError("TriggerMenuParser")
1695  << " Error: duplicate condition (" << name << ")"
1696  << std::endl;
1697 
1698  return false;
1699  }
1700  else {
1701 
1702  if (corrFlag) {
1703  (m_corCaloTemplate[chipNr]).push_back(caloCond);
1704  }
1705  else {
1706  (m_vecCaloTemplate[chipNr]).push_back(caloCond);
1707  }
1708 
1709  }
1710 
1711 
1712  //
1713  return true;
1714 }
1715 
1716 
1717 
1729 bool l1t::TriggerMenuParser::parseCaloCorr(const tmeventsetup::esObject* corrCalo,
1730  unsigned int chipNr) {
1731 
1732 
1733 // XERCES_CPP_NAMESPACE_USE
1734  using namespace tmeventsetup;
1735 
1736  // get condition, particle name and type name
1737 
1738  std::string condition = "calo";
1739  std::string particle = "test-fix" ;
1740  std::string type = l1t2string( corrCalo->getType() );
1741  std::string name = l1t2string( corrCalo->getName() );
1742 
1743  LogDebug("TriggerMenuParser")
1744  << "\n ****************************************** "
1745  << "\n (in parseCalo) "
1746  << "\n condition = " << condition
1747  << "\n particle = " << particle
1748  << "\n type = " << type
1749  << "\n name = " << name
1750  << std::endl;
1751 
1752 
1753  // determine object type type
1754  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
1755  GlobalObject caloObjType;
1756  int nrObj = 1;
1757  type = "1_s";
1758  GtConditionType cType = l1t::Type1s;
1759 
1760 
1761  if (corrCalo->getType() == esObjectType::Egamma) {
1762  caloObjType = gtEG;
1763  } else if (corrCalo->getType() == esObjectType::Jet) {
1764  caloObjType = gtJet;
1765  } else if (corrCalo->getType() == esObjectType::Tau) {
1766  caloObjType = gtTau;
1767  } else {
1768  edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition ("
1769  << particle << ")" << std::endl;
1770  return false;
1771  }
1772 
1773 
1774 // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1775 
1776  if (nrObj < 0) {
1777  edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type
1778  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1779  return false;
1780  }
1781 
1782  // get values
1783 
1784  // temporary storage of the parameters
1785  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1786 
1787  //BLW TO DO: Can this be dropped?
1788  CaloTemplate::CorrelationParameter corrParameter;
1789 
1790  // need at least one value for deltaPhiRange
1791  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1792  tmpValues.reserve( nrObj );
1793 
1794 
1795 
1796 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1797  int relativeBx = 0;
1798  bool gEq = false;
1799 
1800 
1801  gEq = (corrCalo->getComparisonOperator() == esComparisonOperator::GE);
1802 
1803 // BLW TO DO: This needs to be added to the Object Parameters
1804  relativeBx = corrCalo->getBxOffset();
1805 
1806 // Loop over the cuts for this object
1807  int upperThresholdInd = -1;
1808  int lowerThresholdInd = 0;
1809  int cntEta = 0;
1810  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1811  int cntPhi = 0;
1812  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1813  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
1814  int qualityLUT = 0xF; //default is to ignore quality unless specified.
1815 
1816 
1817  const std::vector<esCut>& cuts = corrCalo->getCuts();
1818  for (size_t kk = 0; kk < cuts.size(); kk++)
1819  {
1820  const esCut cut = cuts.at(kk);
1821 
1822  switch(cut.getCutType()){
1823  case esCutType::Threshold:
1824  lowerThresholdInd = cut.getMinimum().index;
1825  upperThresholdInd = cut.getMaximum().index;
1826  break;
1827  case esCutType::Eta: {
1828 
1829  if(cntEta == 0) {
1830  etaWindow1Lower = cut.getMinimum().index;
1831  etaWindow1Upper = cut.getMaximum().index;
1832  } else if(cntEta == 1) {
1833  etaWindow2Lower = cut.getMinimum().index;
1834  etaWindow2Upper = cut.getMaximum().index;
1835  } else {
1836  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for calo-condition ("
1837  << particle << ")" << std::endl;
1838  return false;
1839  }
1840  cntEta++;
1841 
1842  } break;
1843 
1844  case esCutType::Phi: {
1845 
1846  if(cntPhi == 0) {
1847  phiWindow1Lower = cut.getMinimum().index;
1848  phiWindow1Upper = cut.getMaximum().index;
1849  } else if(cntPhi == 1) {
1850  phiWindow2Lower = cut.getMinimum().index;
1851  phiWindow2Upper = cut.getMaximum().index;
1852  } else {
1853  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for calo-condition ("
1854  << particle << ")" << std::endl;
1855  return false;
1856  }
1857  cntPhi++;
1858 
1859  }break;
1860 
1861  case esCutType::Charge: {
1862 
1863  edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition ("
1864  << particle << ")" << std::endl;
1865  return false;
1866 
1867  }break;
1868  case esCutType::Quality: {
1869 
1870  qualityLUT = l1tstr2int(cut.getData());
1871 
1872  }break;
1873  case esCutType::Isolation: {
1874 
1875  isolationLUT = l1tstr2int(cut.getData());
1876 
1877  } break;
1878  default:
1879  break;
1880  } //end switch
1881 
1882  } //end loop over cuts
1883 
1884 // Fill the object parameters
1885  objParameter[0].etLowThreshold = lowerThresholdInd;
1886  objParameter[0].etHighThreshold = upperThresholdInd;
1887  objParameter[0].etaWindow1Lower = etaWindow1Lower;
1888  objParameter[0].etaWindow1Upper = etaWindow1Upper;
1889  objParameter[0].etaWindow2Lower = etaWindow2Lower;
1890  objParameter[0].etaWindow2Upper = etaWindow2Upper;
1891  objParameter[0].phiWindow1Lower = phiWindow1Lower;
1892  objParameter[0].phiWindow1Upper = phiWindow1Upper;
1893  objParameter[0].phiWindow2Lower = phiWindow2Lower;
1894  objParameter[0].phiWindow2Upper = phiWindow2Upper;
1895  objParameter[0].isolationLUT = isolationLUT;
1896  objParameter[0].qualityLUT = qualityLUT; //TO DO: Must add
1897 
1898  // Output for debugging
1899  LogDebug("TriggerMenuParser")
1900  << "\n Calo ET high threshold (hex) for calo object " << caloObjType << " " << " = "
1901  << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etHighThreshold
1902  << "\n etaWindow Lower / Upper for calo object " << " = 0x"
1903  << objParameter[0].etaWindow1Lower << " / 0x" << objParameter[0].etaWindow1Upper
1904  << "\n etaWindowVeto Lower / Upper for calo object " << " = 0x"
1905  << objParameter[0].etaWindow2Lower << " / 0x" << objParameter[0].etaWindow2Upper
1906  << "\n phiWindow Lower / Upper for calo object " << " = 0x"
1907  << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
1908  << "\n phiWindowVeto Lower / Upper for calo object " << " = 0x"
1909  << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper
1910  << "\n Isolation LUT for calo object " << " = 0x"
1911  << objParameter[0].isolationLUT
1912  << "\n Quality LUT for calo object " << " = 0x"
1913  << objParameter[0].qualityLUT << std::dec
1914  << std::endl;
1915 
1916 
1917 
1918 
1919 
1920  // object types - all same caloObjType
1921  std::vector<GlobalObject> objType(nrObj, caloObjType);
1922 
1923 
1924 
1925 
1926  // now create a new calo condition
1927  CaloTemplate caloCond(name);
1928 
1929  caloCond.setCondType(cType);
1930  caloCond.setObjectType(objType);
1931 
1932  //BLW TO DO: This needs to be added to the object rather than the whole condition
1933  caloCond.setCondGEq(gEq);
1934  caloCond.setCondChipNr(chipNr);
1935 
1936  //BLW TO DO: This needs to be added to the object rather than the whole condition
1937  caloCond.setCondRelativeBx(relativeBx);
1938 
1939  caloCond.setConditionParameter(objParameter, corrParameter);
1940 
1941  if (edm::isDebugEnabled() ) {
1942 
1943  std::ostringstream myCoutStream;
1944  caloCond.print(myCoutStream);
1945  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1946 
1947  }
1948 
1949 /*
1950  // insert condition into the map
1951  if ( !insertConditionIntoMap(caloCond, chipNr)) {
1952 
1953  edm::LogError("TriggerMenuParser")
1954  << " Error: duplicate condition (" << name << ")"
1955  << std::endl;
1956 
1957  return false;
1958  }
1959  else {
1960  (m_corCaloTemplate[chipNr]).push_back(caloCond);
1961  }
1962 */
1963  (m_corCaloTemplate[chipNr]).push_back(caloCond);
1964 
1965  //
1966  return true;
1967 }
1968 
1969 
1970 
1982 bool l1t::TriggerMenuParser::parseEnergySum(tmeventsetup::esCondition condEnergySum,
1983  unsigned int chipNr, const bool corrFlag) {
1984 
1985 
1986 // XERCES_CPP_NAMESPACE_USE
1987  using namespace tmeventsetup;
1988 
1989  // get condition, particle name and type name
1990 
1991  std::string condition = "calo";
1992  std::string type = l1t2string( condEnergySum.getType() );
1993  std::string name = l1t2string( condEnergySum.getName() );
1994 
1995  LogDebug("TriggerMenuParser")
1996  << "\n ****************************************** "
1997  << "\n (in parseEnergySum) "
1998  << "\n condition = " << condition
1999  << "\n type = " << type
2000  << "\n name = " << name
2001  << std::endl;
2002 
2003 
2004 
2005  // determine object type type
2006  GlobalObject energySumObjType;
2007  GtConditionType cType;
2008 
2009  if( condEnergySum.getType() == esConditionType::MissingEt ){
2010  energySumObjType = GlobalObject::gtETM;
2011  cType = TypeETM;
2012  }
2013  else if( condEnergySum.getType() == esConditionType::TotalEt ){
2014  energySumObjType = GlobalObject::gtETT;
2015  cType = TypeETT;
2016  }
2017  else if( condEnergySum.getType() == esConditionType::TotalHt ){
2018  energySumObjType = GlobalObject::gtHTT;
2019  cType = TypeHTT;
2020  }
2021  else if( condEnergySum.getType() == esConditionType::MissingHt ){
2022  energySumObjType = GlobalObject::gtHTM;
2023  cType = TypeHTM;
2024  }
2025 /* else if( condEnergySum.getType() == esConditionType::MissingEt2 ){
2026  energySumObjType = GlobalObject::gtETM2;
2027  cType = TypeETM2;
2028  } */
2029  else if( condEnergySum.getType() == esConditionType::MinBiasHFP0 ){
2030  energySumObjType = GlobalObject::gtMinBiasHFP0;
2031  cType = TypeMinBiasHFP0;
2032  }
2033  else if( condEnergySum.getType() == esConditionType::MinBiasHFM0 ){
2034  energySumObjType = GlobalObject::gtMinBiasHFM0;
2035  cType = TypeMinBiasHFM0;
2036  }
2037  else if( condEnergySum.getType() == esConditionType::MinBiasHFP1 ){
2038  energySumObjType = GlobalObject::gtMinBiasHFP1;
2039  cType = TypeMinBiasHFP1;
2040  }
2041  else if( condEnergySum.getType() == esConditionType::MinBiasHFM1 ){
2042  energySumObjType = GlobalObject::gtMinBiasHFM1;
2043  cType = TypeMinBiasHFM1;
2044  }
2045  else {
2046  edm::LogError("TriggerMenuParser")
2047  << "Wrong type for energy-sum condition (" << type
2048  << ")" << std::endl;
2049  return false;
2050  }
2051 
2052 
2053 
2054  // global object
2055  int nrObj = 1;
2056 
2057 // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
2058 
2059  // get values
2060 
2061  // temporary storage of the parameters
2062  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2063 
2064 
2065  int cnt = 0;
2066 
2067 // BLW TO DO: These needs to the added to the object rather than the whole condition.
2068  int relativeBx = 0;
2069  bool gEq = false;
2070 
2071 // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
2072 
2073 // Loop over objects and extract the cuts on the objects
2074  const std::vector<esObject>& objects = condEnergySum.getObjects();
2075  for (size_t jj = 0; jj < objects.size(); jj++) {
2076 
2077  const esObject object = objects.at(jj);
2078  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
2079 
2080 // BLW TO DO: This needs to be added to the Object Parameters
2081  relativeBx = object.getBxOffset();
2082 
2083 // Loop over the cuts for this object
2084  int lowerThresholdInd = 0;
2085  int upperThresholdInd = -1;
2086  int cntPhi = 0;
2087  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
2088 
2089 
2090  const std::vector<esCut>& cuts = object.getCuts();
2091  for (size_t kk = 0; kk < cuts.size(); kk++)
2092  {
2093  const esCut cut = cuts.at(kk);
2094 
2095  switch(cut.getCutType()){
2096  case esCutType::Threshold:
2097  lowerThresholdInd = cut.getMinimum().index;
2098  upperThresholdInd = cut.getMaximum().index;
2099  break;
2100 
2101  case esCutType::Eta:
2102  break;
2103 
2104  case esCutType::Phi: {
2105 
2106  if(cntPhi == 0) {
2107  phiWindow1Lower = cut.getMinimum().index;
2108  phiWindow1Upper = cut.getMaximum().index;
2109  } else if(cntPhi == 1) {
2110  phiWindow2Lower = cut.getMinimum().index;
2111  phiWindow2Upper = cut.getMaximum().index;
2112  } else {
2113  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition ("
2114  << type << ")" << std::endl;
2115  return false;
2116  }
2117  cntPhi++;
2118 
2119  }
2120  break;
2121 
2122  case esCutType::Count:
2123  lowerThresholdInd = cut.getMinimum().index;
2124  upperThresholdInd = 0xffffff;
2125  break;
2126 
2127  default:
2128  break;
2129  } //end switch
2130 
2131  } //end loop over cuts
2132 
2133 
2134 
2135  // Fill the object parameters
2136  objParameter[cnt].etLowThreshold = lowerThresholdInd;
2137  objParameter[cnt].etHighThreshold = upperThresholdInd;
2138  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
2139  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
2140  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
2141  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
2142 
2143 
2144  // Output for debugging
2145  LogDebug("TriggerMenuParser")
2146  << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2147  << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold
2148  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2149  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
2150  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2151  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper << std::dec
2152  << std::endl;
2153 
2154  cnt++;
2155  } //end loop over objects
2156 
2157  // object types - all same energySumObjType
2158  std::vector<GlobalObject> objType(nrObj, energySumObjType);
2159 
2160  // now create a new energySum condition
2161 
2162  EnergySumTemplate energySumCond(name);
2163 
2164  energySumCond.setCondType(cType);
2165  energySumCond.setObjectType(objType);
2166  energySumCond.setCondGEq(gEq);
2167  energySumCond.setCondChipNr(chipNr);
2168  energySumCond.setCondRelativeBx(relativeBx);
2169 
2170  energySumCond.setConditionParameter(objParameter);
2171 
2172  if (edm::isDebugEnabled() ) {
2173 
2174  std::ostringstream myCoutStream;
2175  energySumCond.print(myCoutStream);
2176  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2177 
2178  }
2179 
2180  // insert condition into the map
2181  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2182 
2183  edm::LogError("TriggerMenuParser")
2184  << " Error: duplicate condition (" << name << ")"
2185  << std::endl;
2186 
2187  return false;
2188  }
2189  else {
2190 
2191  if (corrFlag) {
2192  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2193 
2194  }
2195  else {
2196  (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
2197  }
2198 
2199  }
2200 
2201 
2202 
2203  //
2204  return true;
2205 }
2206 
2207 
2219 bool l1t::TriggerMenuParser::parseEnergySumCorr(const tmeventsetup::esObject* corrESum,
2220  unsigned int chipNr) {
2221 
2222 
2223 // XERCES_CPP_NAMESPACE_USE
2224  using namespace tmeventsetup;
2225 
2226  // get condition, particle name and type name
2227 
2228  std::string condition = "calo";
2229  std::string type = l1t2string( corrESum->getType() );
2230  std::string name = l1t2string( corrESum->getName() );
2231 
2232  LogDebug("TriggerMenuParser")
2233  << "\n ****************************************** "
2234  << "\n (in parseEnergySum) "
2235  << "\n condition = " << condition
2236  << "\n type = " << type
2237  << "\n name = " << name
2238  << std::endl;
2239 
2240 
2241 
2242  // determine object type type
2243  GlobalObject energySumObjType;
2244  GtConditionType cType;
2245 
2246  if( corrESum->getType()== esObjectType::ETM ){
2247  energySumObjType = GlobalObject::gtETM;
2248  cType = TypeETM;
2249  }
2250  else if( corrESum->getType()== esObjectType::HTM ){
2251  energySumObjType = GlobalObject::gtHTM;
2252  cType = TypeHTM;
2253  }
2254 /* else if( corrESum->getType()== esObjectType::ETM2 ){
2255  energySumObjType = GlobalObject::gtETM2;
2256  cType = TypeETM2;
2257  } */
2258  else {
2259  edm::LogError("TriggerMenuParser")
2260  << "Wrong type for energy-sum correclation condition (" << type
2261  << ")" << std::endl;
2262  return false;
2263  }
2264 
2265 
2266 
2267  // global object
2268  int nrObj = 1;
2269 
2270 // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
2271 
2272  // get values
2273 
2274  // temporary storage of the parameters
2275  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2276 
2277 
2278  int cnt = 0;
2279 
2280 // BLW TO DO: These needs to the added to the object rather than the whole condition.
2281  int relativeBx = 0;
2282  bool gEq = false;
2283 
2284 // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
2285 
2286 
2287  gEq = (corrESum->getComparisonOperator() == esComparisonOperator::GE);
2288 
2289 // BLW TO DO: This needs to be added to the Object Parameters
2290  relativeBx = corrESum->getBxOffset();
2291 
2292 // Loop over the cuts for this object
2293  int lowerThresholdInd = 0;
2294  int upperThresholdInd = -1;
2295  int cntPhi = 0;
2296  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
2297 
2298 
2299  const std::vector<esCut>& cuts = corrESum->getCuts();
2300  for (size_t kk = 0; kk < cuts.size(); kk++)
2301  {
2302  const esCut cut = cuts.at(kk);
2303 
2304  switch(cut.getCutType()){
2305  case esCutType::Threshold:
2306  lowerThresholdInd = cut.getMinimum().index;
2307  upperThresholdInd = cut.getMaximum().index;
2308  break;
2309 
2310  case esCutType::Eta:
2311  break;
2312 
2313  case esCutType::Phi: {
2314 
2315  if(cntPhi == 0) {
2316  phiWindow1Lower = cut.getMinimum().index;
2317  phiWindow1Upper = cut.getMaximum().index;
2318  } else if(cntPhi == 1) {
2319  phiWindow2Lower = cut.getMinimum().index;
2320  phiWindow2Upper = cut.getMaximum().index;
2321  } else {
2322  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition ("
2323  << type << ")" << std::endl;
2324  return false;
2325  }
2326  cntPhi++;
2327 
2328  }
2329  break;
2330 
2331  default:
2332  break;
2333  } //end switch
2334 
2335  } //end loop over cuts
2336 
2337 
2338 
2339  // Fill the object parameters
2340  objParameter[0].etLowThreshold = lowerThresholdInd;
2341  objParameter[0].etHighThreshold = upperThresholdInd;
2342  objParameter[0].phiWindow1Lower = phiWindow1Lower;
2343  objParameter[0].phiWindow1Upper = phiWindow1Upper;
2344  objParameter[0].phiWindow2Lower = phiWindow2Lower;
2345  objParameter[0].phiWindow2Upper = phiWindow2Upper;
2346 
2347 
2348  // Output for debugging
2349  LogDebug("TriggerMenuParser")
2350  << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2351  << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etLowThreshold
2352  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2353  << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
2354  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2355  << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper << std::dec
2356  << std::endl;
2357 
2358 
2359  // object types - all same energySumObjType
2360  std::vector<GlobalObject> objType(nrObj, energySumObjType);
2361 
2362  // now create a new energySum condition
2363 
2364  EnergySumTemplate energySumCond(name);
2365 
2366  energySumCond.setCondType(cType);
2367  energySumCond.setObjectType(objType);
2368  energySumCond.setCondGEq(gEq);
2369  energySumCond.setCondChipNr(chipNr);
2370  energySumCond.setCondRelativeBx(relativeBx);
2371 
2372  energySumCond.setConditionParameter(objParameter);
2373 
2374  if (edm::isDebugEnabled() ) {
2375 
2376  std::ostringstream myCoutStream;
2377  energySumCond.print(myCoutStream);
2378  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2379 
2380  }
2381 /*
2382  // insert condition into the map
2383  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2384 
2385  edm::LogError("TriggerMenuParser")
2386  << " Error: duplicate condition (" << name << ")"
2387  << std::endl;
2388 
2389  return false;
2390  }
2391  else {
2392 
2393  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2394 
2395  }
2396 */
2397  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2398 
2399 
2400  //
2401  return true;
2402 }
2403 
2404 
2405 
2418 bool l1t::TriggerMenuParser::parseExternal(tmeventsetup::esCondition condExt,
2419  unsigned int chipNr) {
2420 
2421 
2422  using namespace tmeventsetup;
2423 
2424 
2425  // get condition, particle name and type name
2426  std::string condition = "ext";
2427  std::string particle = "test-fix";
2428  std::string type = l1t2string( condExt.getType() );
2429  std::string name = l1t2string( condExt.getName() );
2430 
2431 
2432  LogDebug("TriggerMenuParser")
2433  << "\n ****************************************** "
2434  << "\n (in parseExternal) "
2435  << "\n condition = " << condition
2436  << "\n particle = " << particle
2437  << "\n type = " << type
2438  << "\n name = " << name
2439  << std::endl;
2440 
2441 
2442  // object type and condition type
2443  // object type - irrelevant for External conditions
2444  GtConditionType cType = TypeExternal;
2445 
2446  int relativeBx = 0;
2447  unsigned int channelID = 0;
2448 
2449  // Get object for External conditions
2450  const std::vector<esObject>& objects = condExt.getObjects();
2451  for (size_t jj = 0; jj < objects.size(); jj++) {
2452 
2453  const esObject object = objects.at(jj);
2454  if(object.getType() == esObjectType::EXT) {
2455  relativeBx = object.getBxOffset();
2456  channelID = object.getExternalChannelId();
2457  }
2458  }
2459 
2460 
2461  // set the boolean value for the ge_eq mode - irrelevant for External conditions
2462  bool gEq = false;
2463 
2464  // now create a new External condition
2465  ExternalTemplate externalCond(name);
2466 
2467  externalCond.setCondType(cType);
2468  externalCond.setCondGEq(gEq);
2469  externalCond.setCondChipNr(chipNr);
2470  externalCond.setCondRelativeBx(relativeBx);
2471  externalCond.setExternalChannel(channelID);
2472 
2473  LogTrace("TriggerMenuParser")
2474  << externalCond << "\n" << std::endl;
2475 
2476  // insert condition into the map
2477  if ( !insertConditionIntoMap(externalCond, chipNr)) {
2478 
2479  edm::LogError("TriggerMenuParser")
2480  << " Error: duplicate condition (" << name
2481  << ")" << std::endl;
2482 
2483  return false;
2484  } else {
2485 
2486  (m_vecExternalTemplate[chipNr]).push_back(externalCond);
2487 
2488  }
2489 
2490  return true;
2491 }
2492 
2493 
2507  tmeventsetup::esCondition corrCond,
2508  unsigned int chipNr) {
2509 
2510  using namespace tmeventsetup;
2511 
2512  std::string condition = "corr";
2513  std::string particle = "test-fix" ;
2514  std::string type = l1t2string( corrCond.getType() );
2515  std::string name = l1t2string( corrCond.getName() );
2516 
2517  LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
2518  << " (in parseCorrelation) " << std::endl
2519  << " condition = " << condition << std::endl
2520  << " particle = " << particle << std::endl
2521  << " type = " << type << std::endl
2522  << " name = " << name << std::endl;
2523 
2524 
2525 
2526 
2527  // create a new correlation condition
2528  CorrelationTemplate correlationCond(name);
2529 
2530  // check that the condition does not exist already in the map
2531  if ( !insertConditionIntoMap(correlationCond, chipNr)) {
2532 
2533  edm::LogError("TriggerMenuParser")
2534  << " Error: duplicate correlation condition (" << name << ")"
2535  << std::endl;
2536 
2537  return false;
2538  }
2539 
2540 
2541 // Define some of the quantities to store the parased information
2542 
2543  // condition type BLW (Do we change this to the type of correlation condition?)
2545 
2546  // two objects (for sure)
2547  const int nrObj = 2;
2548 
2549  // object types and greater equal flag - filled in the loop
2550  int intGEq[nrObj] = { -1, -1 };
2551  std::vector<GlobalObject> objType(nrObj); //BLW do we want to define these as a different type?
2552  std::vector<GtConditionCategory> condCateg(nrObj); //BLW do we want to change these categories
2553 
2554  // correlation flag and index in the cor*vector
2555  const bool corrFlag = true;
2556  int corrIndexVal[nrObj] = { -1, -1 };
2557 
2558 
2559  // Storage of the correlation selection
2561  corrParameter.chargeCorrelation = 1; //ignore charge correlation
2562 
2563 // Get the correlation Cuts on the legs
2564  int cutType = 0;
2565  const std::vector<esCut>& cuts = corrCond.getCuts();
2566  for (size_t jj = 0; jj < cuts.size(); jj++)
2567  {
2568  const esCut cut = cuts.at(jj);
2569 
2570  if(cut.getCutType() == esCutType::ChargeCorrelation) {
2571  if( cut.getData()=="ls" ) corrParameter.chargeCorrelation = 2;
2572  else if( cut.getData()=="os" ) corrParameter.chargeCorrelation = 4;
2573  else corrParameter.chargeCorrelation = 1; //ignore charge correlation
2574  } else {
2575 
2576 //
2577 // Unitl utm has method to calculate these, do the integer value calculation with precision.
2578 //
2579  double minV = cut.getMinimum().value;
2580  double maxV = cut.getMaximum().value;
2581 
2582  //Scale down very large numbers out of xml
2583  if(maxV > 1.0e6) maxV = 1.0e6;
2584 
2585  if(cut.getCutType() == esCutType::DeltaEta) {
2586  //std::cout << "DeltaEta Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2587  corrParameter.minEtaCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2588  corrParameter.maxEtaCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2589  corrParameter.precEtaCut = cut.getMinimum().index;
2590  cutType = cutType | 0x1;
2591  } else if (cut.getCutType() == esCutType::DeltaPhi) {
2592  //std::cout << "DeltaPhi Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2593  corrParameter.minPhiCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2594  corrParameter.maxPhiCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2595  corrParameter.precPhiCut = cut.getMinimum().index;
2596  cutType = cutType | 0x2;
2597  } else if (cut.getCutType() == esCutType::DeltaR) {
2598  //std::cout << "DeltaR Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2599  corrParameter.minDRCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2600  corrParameter.maxDRCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2601  corrParameter.precDRCut = cut.getMinimum().index;
2602  cutType = cutType | 0x4;
2603  } else if (cut.getCutType() == esCutType::Mass) {
2604  //std::cout << "Mass Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
2605  corrParameter.minMassCutValue = (long long)(minV * pow(10.,cut.getMinimum().index));
2606  corrParameter.maxMassCutValue = (long long)(maxV * pow(10.,cut.getMaximum().index));
2607  corrParameter.precMassCut = cut.getMinimum().index;
2608  cutType = cutType | 0x8;
2609  }
2610  }
2611 
2612  }
2613  corrParameter.corrCutType = cutType;
2614 
2615 // Get the two objects that form the legs
2616  const std::vector<esObject>& objects = corrCond.getObjects();
2617  if(objects.size() != 2) {
2618  edm::LogError("TriggerMenuParser")
2619  << "incorrect number of objects for the correlation condition " << name << " corrFlag " << corrFlag << std::endl;
2620  return false;
2621  }
2622 
2623 // loop over legs
2624  for (size_t jj = 0; jj < objects.size(); jj++)
2625  {
2626  const esObject object = objects.at(jj);
2627 /* std::cout << " obj name = " << object->getName() << "\n";
2628  std::cout << " obj type = " << object->getType() << "\n";
2629  std::cout << " obj op = " << object->getComparisonOperator() << "\n";
2630  std::cout << " obj bx = " << object->getBxOffset() << "\n";
2631 */
2632 
2633 // check the leg type
2634  if(object.getType() == esObjectType::Muon) {
2635  // we have a muon
2636 
2637 /*
2638  //BLW Hold on to this code we may need to go back to it at some point.
2639  // Now we are putting ALL leg conditions into the vector (so there are duplicates)
2640  // This is potentially a place to slim down the code. Note: We currently evaluate the
2641  // conditions every time, so even if we put the condition in the vector once, we would
2642  // still evaluate it multiple times. This is a place for optimization.
2643 
2644  parseMuonCorr(&object,chipNr);
2645  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
2646 
2647  } else {
2648  LogDebug("TriggerMenuParser") << "Not Adding Correlation Muon Condition to Map...looking for the condition in Muon Cor Vector" << std::endl;
2649  bool found = false;
2650  int index = 0;
2651  while(!found && index<(int)((m_corMuonTemplate[chipNr]).size()) ) {
2652  if( (m_corMuonTemplate[chipNr]).at(index).condName() == object.getName() ) {
2653  LogDebug("TriggerMenuParser") << "Found condition " << object.getName() << " in vector at index " << index << std::endl;
2654  found = true;
2655  } else {
2656  index++;
2657  }
2658  }
2659  if(found) {
2660  corrIndexVal[jj] = index;
2661  } else {
2662  edm::LogError("TriggerMenuParser") << "FAILURE: Condition " << object.getName() << " is in map but not in cor. vector " << std::endl;
2663  }
2664 
2665  }
2666 */
2667  parseMuonCorr(&object,chipNr);
2668  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
2669 
2670  //Now set some flags for this subCondition
2671  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2672  objType[jj] = gtMu;
2673  condCateg[jj] = CondMuon;
2674 
2675  } else if(object.getType() == esObjectType::Egamma ||
2676  object.getType() == esObjectType::Jet ||
2677  object.getType() == esObjectType::Tau ) {
2678 
2679  // we have an Calo object
2680  parseCaloCorr(&object,chipNr);
2681  corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
2682 
2683  //Now set some flags for this subCondition
2684  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2685  switch(object.getType()) {
2686  case esObjectType::Egamma: {
2687  objType[jj] = gtEG;
2688  }
2689  break;
2690  case esObjectType::Jet: {
2691  objType[jj] = gtJet;
2692  }
2693  break;
2694  case esObjectType::Tau: {
2695  objType[jj] = gtTau;
2696  }
2697  break;
2698  default: {
2699  }
2700  break;
2701  }
2702  condCateg[jj] = CondCalo;
2703 
2704 
2705 
2706 
2707  } else if(object.getType() == esObjectType::ETM ||
2708  // object.getType() == esObjectType::ETM2 ||
2709  object.getType() == esObjectType::HTM ) {
2710 
2711  // we have Energy Sum
2712  parseEnergySumCorr(&object,chipNr);
2713  corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
2714 
2715  //Now set some flags for this subCondition
2716  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2717  switch(object.getType()) {
2718  case esObjectType::ETM: {
2719  objType[jj] = GlobalObject::gtETM;
2720  }
2721  break;
2722  case esObjectType::HTM: {
2723  objType[jj] = GlobalObject::gtHTM;
2724  }
2725  break;
2726 /* case esObjectType::ETM2: {
2727  objType[jj] = GlobalObject::gtETM2;
2728  }
2729  break; */
2730  default: {
2731  }
2732  break;
2733  }
2734  condCateg[jj] = CondEnergySum;
2735 
2736 
2737  } else {
2738 
2739  edm::LogError("TriggerMenuParser")
2740  << "Illegal Object Type "
2741  << " for the correlation condition " << name << std::endl;
2742  return false;
2743 
2744  } //if block on leg types
2745 
2746  } //loop over legs
2747 
2748 
2749  // get greater equal flag for the correlation condition
2750  bool gEq = true;
2751  if (intGEq[0] != intGEq[1]) {
2752  edm::LogError("TriggerMenuParser")
2753  << "Inconsistent GEq flags for sub-conditions "
2754  << " for the correlation condition " << name << std::endl;
2755  return false;
2756 
2757  }
2758  else {
2759  gEq = (intGEq[0] != 0);
2760 
2761  }
2762 
2763 
2764  // fill the correlation condition
2765  correlationCond.setCondType(cType);
2766  correlationCond.setObjectType(objType);
2767  correlationCond.setCondGEq(gEq);
2768  correlationCond.setCondChipNr(chipNr);
2769 
2770  correlationCond.setCond0Category(condCateg[0]);
2771  correlationCond.setCond1Category(condCateg[1]);
2772 
2773  correlationCond.setCond0Index(corrIndexVal[0]);
2774  correlationCond.setCond1Index(corrIndexVal[1]);
2775 
2776  correlationCond.setCorrelationParameter(corrParameter);
2777 
2778  if (edm::isDebugEnabled() ) {
2779 
2780  std::ostringstream myCoutStream;
2781  correlationCond.print(myCoutStream);
2782  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n"
2783  << std::endl;
2784 
2785  }
2786 
2787  // insert condition into the map
2788  // condition is not duplicate, check was done at the beginning
2789 
2790  (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
2791 
2792 
2793  //
2794  return true;
2795 }
2796 
2797 
2809 bool l1t::TriggerMenuParser::parseAlgorithm( tmeventsetup::esAlgorithm algorithm,
2810  unsigned int chipNr) {
2811 
2812 
2813  using namespace tmeventsetup;
2814  //using namespace Algorithm;
2815 
2816 
2817  // get alias
2818  std::string algAlias = algorithm.getName();
2819  std::string algName = algorithm.getName();
2820 
2821  if (algAlias == "") {
2822  algAlias = algName;
2823  LogDebug("TriggerMenuParser")
2824  << "\n No alias defined for algorithm. Alias set to algorithm name."
2825  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
2826  << std::endl;
2827  } else {
2828  //LogDebug("TriggerMenuParser")
2829  LogDebug("TriggerMenuParser") << "\n Alias defined for algorithm."
2830  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
2831  << std::endl;
2832  }
2833 
2834  // get the logical expression
2835  std::string logExpression = algorithm.getExpressionInCondition();
2836 
2837  LogDebug("TriggerMenuParser")
2838  << " Logical expression: " << logExpression
2839  << " Chip number: " << chipNr
2840  << std::endl;
2841 
2842  // determine output pin
2843  int outputPin = algorithm.getIndex();
2844 
2845 
2846  //LogTrace("TriggerMenuParser")
2847  LogDebug("TriggerMenuParser") << " Output pin: " << outputPin
2848  << std::endl;
2849 
2850 
2851  // compute the bit number from chip number, output pin and order of the chips
2852  // pin numbering start with 1, bit numbers with 0
2853  int bitNumber = outputPin;// + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
2854 
2855  //LogTrace("TriggerMenuParser")
2856  LogDebug("TriggerMenuParser") << " Bit number: " << bitNumber
2857  << std::endl;
2858 
2859  // create a new algorithm and insert it into algorithm map
2860  GlobalAlgorithm alg(algName, logExpression, bitNumber);
2861  alg.setAlgoChipNumber(static_cast<int>(chipNr));
2862  alg.setAlgoAlias(algAlias);
2863 
2864  if (edm::isDebugEnabled() ) {
2865 
2866  std::ostringstream myCoutStream;
2867  alg.print(myCoutStream);
2868  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2869 
2870  }
2871 
2872  // insert algorithm into the map
2873  if ( !insertAlgorithmIntoMap(alg)) {
2874  return false;
2875  }
2876 
2877  return true;
2878 
2879 }
2880 
2881 
2882 // static class members
2883 
#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< 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
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