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