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 
32 
35 
36 
37 #include "tmEventSetup/esTriggerMenu.hh"
38 #include "tmEventSetup/esAlgorithm.hh"
39 #include "tmEventSetup/esCondition.hh"
40 #include "tmEventSetup/esObject.hh"
41 #include "tmEventSetup/esCut.hh"
42 #include "tmEventSetup/esScale.hh"
43 #include "tmGrammar/Algorithm.hh"
44 
45 
46 
47 // constructor
49  m_triggerMenuInterface("NULL"),
50  m_triggerMenuName("NULL"), m_triggerMenuImplementation("NULL"), m_scaleDbKey("NULL")
51 
52 {
53 
54  // menu names, scale key initialized to NULL due to ORACLE treatment of strings
55 
56  // empty
57 
58 }
59 
60 // destructor
62 
63  clearMaps();
64 
65 }
66 
67 // set the number of condition chips in GTL
69  const unsigned int& numberConditionChipsValue) {
70 
71  m_numberConditionChips = numberConditionChipsValue;
72 
73 }
74 
75 // set the number of pins on the GTL condition chips
76 void l1t::TriggerMenuParser::setGtPinsOnConditionChip(const unsigned int& pinsOnConditionChipValue) {
77 
78  m_pinsOnConditionChip = pinsOnConditionChipValue;
79 
80 }
81 
82 // set the correspondence "condition chip - GTL algorithm word"
83 // in the hardware
85  const std::vector<int>& orderConditionChipValue) {
86 
87  m_orderConditionChip = orderConditionChipValue;
88 
89 }
90 
91 // set the number of physics trigger algorithms
93  const unsigned int& numberPhysTriggersValue) {
94 
95  m_numberPhysTriggers = numberPhysTriggersValue;
96 
97 }
98 
99 
100 // set the condition maps
101 void l1t::TriggerMenuParser::setGtConditionMap(const std::vector<ConditionMap>& condMap) {
102  m_conditionMap = condMap;
103 }
104 
105 // set the trigger menu name
107  m_triggerMenuInterface = menuInterface;
108 }
109 
111  m_triggerMenuName = menuName;
112 }
113 
115  m_triggerMenuImplementation = menuImplementation;
116 }
117 
118 // set menu associated scale key
120  m_scaleDbKey = scaleKey;
121 }
122 
123 // set the vectors containing the conditions
125  const std::vector<std::vector<MuonTemplate> >& vecMuonTempl) {
126 
127  m_vecMuonTemplate = vecMuonTempl;
128 }
129 
131  const std::vector<std::vector<CaloTemplate> >& vecCaloTempl) {
132 
133  m_vecCaloTemplate = vecCaloTempl;
134 }
135 
137  const std::vector<std::vector<EnergySumTemplate> >& vecEnergySumTempl) {
138 
139  m_vecEnergySumTemplate = vecEnergySumTempl;
140 }
141 
142 
143 
145  const std::vector<std::vector<ExternalTemplate> >& vecExternalTempl) {
146 
147  m_vecExternalTemplate = vecExternalTempl;
148 }
149 
150 
152  const std::vector<std::vector<CorrelationTemplate> >& vecCorrelationTempl) {
153 
154  m_vecCorrelationTemplate = vecCorrelationTempl;
155 }
156 
157 // set the vectors containing the conditions for correlation templates
158 //
160  const std::vector<std::vector<MuonTemplate> >& corMuonTempl) {
161 
162  m_corMuonTemplate = corMuonTempl;
163 }
164 
166  const std::vector<std::vector<CaloTemplate> >& corCaloTempl) {
167 
168  m_corCaloTemplate = corCaloTempl;
169 }
170 
172  const std::vector<std::vector<EnergySumTemplate> >& corEnergySumTempl) {
173 
174  m_corEnergySumTemplate = corEnergySumTempl;
175 }
176 
177 
178 
179 
180 // set the algorithm map (by algorithm names)
182  m_algorithmMap = algoMap;
183 }
184 
185 // set the algorithm map (by algorithm aliases)
187  m_algorithmAliasMap = algoMap;
188 }
189 
190 
191 
192 
193 
194 // parse def.xml file
196 
197 
198  // resize the vector of condition maps
199  // the number of condition chips should be correctly set before calling parseXmlFile
200  m_conditionMap.resize(m_numberConditionChips);
201 
202  m_vecMuonTemplate.resize(m_numberConditionChips);
203  m_vecCaloTemplate.resize(m_numberConditionChips);
204  m_vecEnergySumTemplate.resize(m_numberConditionChips);
205  m_vecExternalTemplate.resize(m_numberConditionChips);
206 
207  m_vecCorrelationTemplate.resize(m_numberConditionChips);
208  m_corMuonTemplate.resize(m_numberConditionChips);
209  m_corCaloTemplate.resize(m_numberConditionChips);
210  m_corEnergySumTemplate.resize(m_numberConditionChips);
211 
212  using namespace tmeventsetup;
213  using namespace Algorithm;
214 
215  const esTriggerMenu* menu = reinterpret_cast<const esTriggerMenu*> (utmMenu);
216 
217  //get the meta data
218  m_triggerMenuDescription = menu->getComment();
219  m_triggerMenuDate = menu->getDatetime();
220  m_triggerMenuImplementation = menu->getFirmwareUuid(); //BLW: correct descriptor?
221  m_triggerMenuName = menu->getName();
222  m_triggerMenuInterface = menu->getVersion(); //BLW: correct descriptor?
223 
224  const std::map<std::string, esAlgorithm>& algoMap = menu->getAlgorithmMap();
225  const std::map<std::string, esCondition>& condMap = menu->getConditionMap();
226  const std::map<std::string, esScale>& scaleMap = menu->getScaleMap();
227 
228  // parse the scales
229  m_gtScales.setScalesName( menu->getScaleSetName() );
230  parseScales(scaleMap);
231 
232 
233  //loop over the algorithms
234  for (std::map<std::string, esAlgorithm>::const_iterator cit = algoMap.begin();
235  cit != algoMap.end(); cit++)
236  {
237  //condition chip (artifact) TO DO: Update
238  int chipNr = 0;
239 
240  //get algorithm
241  const esAlgorithm& algo = cit->second;
242 
243  //parse the algorithm
244  parseAlgorithm(algo,chipNr); //blw
245 
246  //get conditions for this algorithm
247  const std::vector<std::string>& rpn_vec = algo.getRpnVector();
248  for (size_t ii = 0; ii < rpn_vec.size(); ii++)
249  {
250  const std::string& token = rpn_vec.at(ii);
251  if (isGate(token)) continue;
252 // long hash = getHash(token);
253  const esCondition& condition = condMap.find(token)->second;
254 
255  //check to see if this condtion already exists
256  if ((m_conditionMap[chipNr]).count(condition.getName()) == 0) {
257 
258  // parse Calo Conditions (EG, Jets, Taus)
259  if(condition.getType() == esConditionType::SingleEgamma ||
260  condition.getType() == esConditionType::DoubleEgamma ||
261  condition.getType() == esConditionType::TripleEgamma ||
262  condition.getType() == esConditionType::QuadEgamma ||
263  condition.getType() == esConditionType::SingleTau ||
264  condition.getType() == esConditionType::DoubleTau ||
265  condition.getType() == esConditionType::TripleTau ||
266  condition.getType() == esConditionType::QuadTau ||
267  condition.getType() == esConditionType::SingleJet ||
268  condition.getType() == esConditionType::DoubleJet ||
269  condition.getType() == esConditionType::TripleJet ||
270  condition.getType() == esConditionType::QuadJet )
271  {
272  parseCalo(condition,chipNr,false); //blw
273 
274  // parse Energy Sums
275  } else if(condition.getType() == esConditionType::TotalEt ||
276  condition.getType() == esConditionType::TotalHt ||
277  condition.getType() == esConditionType::MissingEt ||
278  condition.getType() == esConditionType::MissingHt )
279  {
280  parseEnergySum(condition,chipNr,false);
281 
282  //parse Muons
283  } else if(condition.getType() == esConditionType::SingleMuon ||
284  condition.getType() == esConditionType::DoubleMuon ||
285  condition.getType() == esConditionType::TripleMuon ||
286  condition.getType() == esConditionType::QuadMuon )
287  {
288  parseMuon(condition,chipNr,false);
289 
290 
291  //parse Correlation Conditions
292  } else if(condition.getType() == esConditionType::MuonMuonCorrelation ||
293  condition.getType() == esConditionType::MuonEsumCorrelation ||
294  condition.getType() == esConditionType::CaloMuonCorrelation ||
295  condition.getType() == esConditionType::CaloCaloCorrelation ||
296  condition.getType() == esConditionType::CaloEsumCorrelation ||
297  condition.getType() == esConditionType::InvariantMass )
298  {
299  parseCorrelation(condition,chipNr);
300 
301  //parse Muons
302  } else if(condition.getType() == esConditionType::Externals )
303  {
304  parseExternal(condition,chipNr);
305 
306  }
307 
308  }//if condition is a new one
309  }//loop over conditions
310  }//loop over algorithms
311 
312  return;
313 
314 
315 }
316 
317 
318 
319 //
320 
322 
323  m_triggerMenuInterfaceDate = val;
324 
325 }
326 
328 
329  m_triggerMenuInterfaceAuthor = val;
330 
331 }
332 
334 
335  m_triggerMenuInterfaceDescription = val;
336 
337 }
338 
339 
341 
342  m_triggerMenuDate = val;
343 
344 }
345 
347 
348  m_triggerMenuAuthor = val;
349 
350 }
351 
353 
354  m_triggerMenuDescription = val;
355 
356 }
357 
359 
360  m_algorithmImplementation = val;
361 
362 }
363 
364 
365 
366 // methods for conditions and algorithms
367 
368 // clearMaps - delete all conditions and algorithms in
369 // the maps and clear the maps.
371 
372  // loop over condition maps (one map per condition chip)
373  // then loop over conditions in the map
374  for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip
375  != m_conditionMap.end(); itCondOnChip++) {
376 
377  // the conditions in the maps are deleted in L1uGtTriggerMenu, not here
378 
379  itCondOnChip->clear();
380 
381  }
382 
383  // the algorithms in the maps are deleted in L1uGtTriggerMenu, not here
384  m_algorithmMap.clear();
385 
386 }
387 
388 // insertConditionIntoMap - safe insert of condition into condition map.
389 // if the condition name already exists, do not insert it and return false
391 
392  std::string cName = cond.condName();
393  LogTrace("TriggerMenuParser")
394  << " Trying to insert condition \"" << cName << "\" in the condition map." ;
395 
396  // no condition name has to appear twice!
397  if ((m_conditionMap[chipNr]).count(cName) != 0) {
398  LogTrace("TriggerMenuParser") << " Condition " << cName
399  << " already exists - not inserted!" << std::endl;
400  return false;
401  }
402 
403  (m_conditionMap[chipNr])[cName] = &cond;
404  LogTrace("TriggerMenuParser")
405  << " OK - condition inserted!"
406  << std::endl;
407 
408 
409  return true;
410 
411 }
412 
413 // insert an algorithm into algorithm map
415 
416  std::string algName = alg.algoName();
417  std::string algAlias = alg.algoAlias();
418  //LogTrace("TriggerMenuParser")
419  //<< " Trying to insert algorithm \"" << algName << "\" in the algorithm map." ;
420 
421  // no algorithm name has to appear twice!
422  if (m_algorithmMap.count(algName) != 0) {
423  LogTrace("TriggerMenuParser") << " Algorithm \"" << algName
424  << "\"already exists in the algorithm map- not inserted!" << std::endl;
425  return false;
426  }
427 
428  if (m_algorithmAliasMap.count(algAlias) != 0) {
429  LogTrace("TriggerMenuParser") << " Algorithm alias \"" << algAlias
430  << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
431  return false;
432  }
433 
434  // bit number less than zero or greater than maximum number of algorithms
435  int bitNumber = alg.algoBitNumber();
436  if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
437  LogTrace("TriggerMenuParser") << " Bit number " << bitNumber
438  << " outside allowed range [0, " << m_numberPhysTriggers
439  << ") - algorithm not inserted!" << std::endl;
440  return false;
441  }
442 
443  // maximum number of algorithms
444  if (m_algorithmMap.size() >= m_numberPhysTriggers) {
445  LogTrace("TriggerMenuParser") << " More than maximum allowed "
446  << m_numberPhysTriggers << " algorithms in the algorithm map - not inserted!"
447  << std::endl;
448  return false;
449  }
450 
451  // chip number outside allowed values
452  int chipNr = alg.algoChipNumber(static_cast<int>(m_numberConditionChips),
453  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
454 
455  if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
456  LogTrace("TriggerMenuParser") << " Chip number " << chipNr
457  << " outside allowed range [0, " << m_numberConditionChips
458  << ") - algorithm not inserted!" << std::endl;
459  return false;
460  }
461 
462  // output pin outside allowed values
463  int outputPin = alg.algoOutputPin(static_cast<int>(m_numberConditionChips),
464  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
465 
466  if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
467  LogTrace("TriggerMenuParser") << " Output pin " << outputPin
468  << " outside allowed range [0, " << m_pinsOnConditionChip
469  << "] - algorithm not inserted!" << std::endl;
470  return false;
471  }
472 
473  // no two algorithms on the same chip can have the same output pin
474  for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
475 
476  int iPin = (itAlgo->second).algoOutputPin( static_cast<int>(m_numberConditionChips),
477  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
478  std::string iName = itAlgo->first;
479  int iChip = (itAlgo->second).algoChipNumber(static_cast<int>(m_numberConditionChips),
480  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
481 
482  if ( (outputPin == iPin) && (chipNr == iChip)) {
483  LogTrace("TriggerMenuParser") << " Output pin " << outputPin
484  << " is the same as for algorithm " << iName
485  << "\n from the same chip number " << chipNr << " - algorithm not inserted!"
486  << std::endl;
487  return false;
488  }
489 
490  }
491 
492  // insert algorithm
493  m_algorithmMap[algName] = alg;
494  m_algorithmAliasMap[algAlias] = alg;
495 
496  //LogTrace("TriggerMenuParser")
497  //<< " OK - algorithm inserted!"
498  //<< std::endl;
499 
500  return true;
501 
502 }
503 
504 
506  std::stringstream ss;
507  ss << data;
508  return ss.str();
509 }
511  std::stringstream ss;
512  ss << std::setfill('0');
513  ss << std::setw(4) << date.year() << "-" << std::setw(2) << date.month() << "-" << std::setw(2) << date.day() << "T";
514  ss << std::setw(2) << date.hours() << ":" << std::setw(2) << date.minutes() << ":" << std::setw(2) << date.seconds();
515  //ss << data;
516  return ss.str();
517 }
518 int l1t::TriggerMenuParser::l1t2int( l1t::RelativeBx data ){ //l1t::RelativeBx
519  std::stringstream ss;
520  ss << data;
521  int value;
522  ss >> value;
523  return value;
524 }
526  std::stringstream ss;
527  ss << data;
528  int value;
529  ss >> value;
530  return value;
531 }
532 
533 
541 bool l1t::TriggerMenuParser::parseScales(std::map<std::string, tmeventsetup::esScale> scaleMap) {
542 
543  using namespace tmeventsetup;
544 
545 // Setup ScaleParameter to hold information from parsing
554 
555 // Start by parsing the Scale Map
556  for (std::map<std::string, esScale>::const_iterator cit = scaleMap.begin();
557  cit != scaleMap.end(); cit++)
558  {
559  const esScale& scale = cit->second;
560 
562  if (scale.getObjectType() == esObjectType::Muon) scaleParam = &muScales;
563  else if (scale.getObjectType() == esObjectType::Egamma) scaleParam = &egScales;
564  else if (scale.getObjectType() == esObjectType::Tau) scaleParam = &tauScales;
565  else if (scale.getObjectType() == esObjectType::Jet) scaleParam = &jetScales;
566  else if (scale.getObjectType() == esObjectType::ETT) scaleParam = &ettScales;
567  else if (scale.getObjectType() == esObjectType::ETM) scaleParam = &etmScales;
568  else if (scale.getObjectType() == esObjectType::HTT) scaleParam = &httScales;
569  else if (scale.getObjectType() == esObjectType::HTM) scaleParam = &htmScales;
570  else scaleParam = 0;
571 
572  if(scaleParam != 0) {
573  switch(scale.getScaleType()) {
574  case esScaleType::EtScale: {
575  scaleParam->etMin = scale.getMinimum();
576  scaleParam->etMax = scale.getMaximum();
577  scaleParam->etStep = scale.getStep();
578 
579  //Get bin edges
580  const std::vector<esBin> binsV = scale.getBins();
581  for(unsigned int i=0; i<binsV.size(); i++) {
582  const esBin& bin = binsV.at(i);
583  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
584  scaleParam->etBins.push_back(binLimits);
585  }
586 
587  // If this is an energy sum fill dummy values for eta and phi
588  // There are no scales for these in the XML so the other case statements will not be seen....do it here.
589  if(scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT ||
590  scale.getObjectType() == esObjectType::ETM || scale.getObjectType() == esObjectType::HTM ) {
591 
592  scaleParam->etaMin = -1.;
593  scaleParam->etaMax = -1.;
594  scaleParam->etaStep = -1.;
595  if(scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT) {
596  scaleParam->phiMin = -1.;
597  scaleParam->phiMax = -1.;
598  scaleParam->phiStep = -1.;
599  }
600  }
601  }
602  break;
603  case esScaleType::EtaScale: {
604  scaleParam->etaMin = scale.getMinimum();
605  scaleParam->etaMax = scale.getMaximum();
606  scaleParam->etaStep = scale.getStep();
607 
608  //Get bin edges
609  const std::vector<esBin> binsV = scale.getBins();
610  for(unsigned int i=0; i<binsV.size(); i++) {
611  const esBin& bin = binsV.at(i);
612  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
613  scaleParam->etaBins.push_back(binLimits);
614  }
615  }
616  break;
617  case esScaleType::PhiScale: {
618  scaleParam->phiMin = scale.getMinimum();
619  scaleParam->phiMax = scale.getMaximum();
620  scaleParam->phiStep = scale.getStep();
621 
622  //Get bin edges
623  const std::vector<esBin> binsV = scale.getBins();
624  for(unsigned int i=0; i<binsV.size(); i++) {
625  const esBin& bin = binsV.at(i);
626  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
627  scaleParam->phiBins.push_back(binLimits);
628  }
629  }
630  break;
631  default:
632 
633  break;
634  } //end switch
635  } //end valid scale
636  } //end loop over scaleMap
637 
638  // put the ScaleParameters into the class
639  m_gtScales.setMuonScales(muScales);
640  m_gtScales.setEGScales(egScales);
641  m_gtScales.setTauScales(tauScales);
642  m_gtScales.setJetScales(jetScales);
643  m_gtScales.setETTScales(ettScales);
644  m_gtScales.setETMScales(etmScales);
645  m_gtScales.setHTTScales(httScales);
646  m_gtScales.setHTMScales(htmScales);
647 
648 
649 
650  return true;
651 }
652 
653 
665 bool l1t::TriggerMenuParser::parseMuon(tmeventsetup::esCondition condMu,
666  unsigned int chipNr, const bool corrFlag) {
667 
668  using namespace tmeventsetup;
669 
670  // get condition, particle name (must be muon) and type name
671  std::string condition = "muon";
672  std::string particle = "muon";//l1t2string( condMu.objectType() );
673  std::string type = l1t2string( condMu.getType() );
674  std::string name = l1t2string( condMu.getName() );
675  int nrObj = -1;
676 
677 
678 
680 
681  if (condMu.getType() == esConditionType::SingleMuon) {
682  type = "1_s";
683  cType = l1t::Type1s;
684  nrObj = 1;
685  } else if (condMu.getType() == esConditionType::DoubleMuon) {
686  type = "2_s";
687  cType = l1t::Type2s;
688  nrObj = 2;
689  } else if (condMu.getType() == esConditionType::TripleMuon) {
690  type = "3";
691  cType = l1t::Type3s;
692  nrObj = 3;
693  } else if (condMu.getType() == esConditionType::QuadMuon) {
694  type = "4";
695  cType = l1t::Type4s;
696  nrObj = 4;
697  } else {
698  edm::LogError("TriggerMenuParser") << "Wrong type for muon-condition ("
699  << type << ")" << std::endl;
700  return false;
701  }
702 
703  if (nrObj < 0) {
704  edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type
705  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
706  return false;
707  }
708 
709  LogDebug("TriggerMenuParser")
710  << "\n ****************************************** "
711  << "\n parseMuon "
712  << "\n condition = " << condition
713  << "\n particle = " << particle
714  << "\n type = " << type
715  << "\n name = " << name
716  << std::endl;
717 
718 
719 
720 // // get values
721 
722  // temporary storage of the parameters
723  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
724 
725  // Do we need this?
727 
728  // need at least two values for deltaPhi
729  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
730  tmpValues.reserve( nrObj );
731 
732  if( int(condMu.getObjects().size())!=nrObj ){
733  edm::LogError("TriggerMenuParser") << " condMu objects: nrObj = " << nrObj
734  << "condMu.getObjects().size() = "
735  << condMu.getObjects().size()
736  << std::endl;
737  return false;
738  }
739 
740 
741 // Look for cuts on the objects in the condition
742  unsigned int chargeCorrelation = 1;
743  const std::vector<esCut>& cuts = condMu.getCuts();
744  for (size_t jj = 0; jj < cuts.size(); jj++)
745  {
746  const esCut cut = cuts.at(jj);
747  if(cut.getCutType() == esCutType::ChargeCorrelation) {
748  if( cut.getData()=="ls" ) chargeCorrelation = 2;
749  else if( cut.getData()=="os" ) chargeCorrelation = 4;
750  else chargeCorrelation = 1; //ignore correlation
751  }
752  }
753 
754  //set charge correlation parameter
755  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
756 
757 
758  int cnt = 0;
759 
760 
761 // BLW TO DO: These needs to the added to the object rather than the whole condition.
762  int relativeBx = 0;
763  bool gEq = false;
764 
765 // Loop over objects and extract the cuts on the objects
766  const std::vector<esObject>& objects = condMu.getObjects();
767  for (size_t jj = 0; jj < objects.size(); jj++) {
768 
769  const esObject object = objects.at(jj);
770  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
771 
772 // BLW TO DO: This needs to be added to the Object Parameters
773  relativeBx = object.getBxOffset();
774 
775 // Loop over the cuts for this object
776  int upperThresholdInd = -1;
777  int lowerThresholdInd = 0;
778  int cntEta = 0;
779  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
780  int cntPhi = 0;
781  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
782  int isolationLUT = 0xF; //default is to ignore unless specified.
783  int charge = -1; //default value is to ignore unless specified
784  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
785 
786  const std::vector<esCut>& cuts = object.getCuts();
787  for (size_t kk = 0; kk < cuts.size(); kk++)
788  {
789  const esCut cut = cuts.at(kk);
790 
791  switch(cut.getCutType()){
792  case esCutType::Threshold:
793  lowerThresholdInd = cut.getMinimum().index;
794  upperThresholdInd = cut.getMaximum().index;
795  break;
796 
797  case esCutType::Eta: {
798 
799  if(cntEta == 0) {
800  etaWindow1Lower = cut.getMinimum().index;
801  etaWindow1Upper = cut.getMaximum().index;
802  } else if(cntEta == 1) {
803  etaWindow2Lower = cut.getMinimum().index;
804  etaWindow2Upper = cut.getMaximum().index;
805  } else {
806  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for muon-condition ("
807  << particle << ")" << std::endl;
808  return false;
809  }
810  cntEta++;
811 
812  } break;
813 
814  case esCutType::Phi: {
815 
816  if(cntPhi == 0) {
817  phiWindow1Lower = cut.getMinimum().index;
818  phiWindow1Upper = cut.getMaximum().index;
819  } else if(cntPhi == 1) {
820  phiWindow2Lower = cut.getMinimum().index;
821  phiWindow2Upper = cut.getMaximum().index;
822  } else {
823  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for muon-condition ("
824  << particle << ")" << std::endl;
825  return false;
826  }
827  cntPhi++;
828 
829  }break;
830 
831  case esCutType::Charge:
832  std::cout << "Found Charge Cut " << std::endl;
833  if( cut.getData()=="positive" ) charge = 0;
834  else if( cut.getData()=="negative" ) charge = 1;
835  else charge = -1;
836  break;
837  case esCutType::Quality:
838 
839  qualityLUT = l1tstr2int(cut.getData());
840 
841  break;
842  case esCutType::Isolation: {
843 
844  isolationLUT = l1tstr2int(cut.getData());
845 
846  } break;
847  default:
848  break;
849  } //end switch
850 
851  } //end loop over cuts
852 
853 
854 // Set the parameter cuts
855  objParameter[cnt].ptHighThreshold = upperThresholdInd;
856  objParameter[cnt].ptLowThreshold = lowerThresholdInd;
857 
858  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
859  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
860  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
861  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
862 
863  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
864  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
865  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
866  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
867 
868 // BLW TO DO: Do we need these anymore? Drop them?
869  objParameter[cnt].enableMip = false;//tmpMip[i];
870  objParameter[cnt].enableIso = false;//tmpEnableIso[i];
871  objParameter[cnt].requestIso = false;//tmpRequestIso[i];
872 
873  objParameter[cnt].charge = charge;
874  objParameter[cnt].qualityLUT = qualityLUT;
875  objParameter[cnt].isolationLUT = isolationLUT;
876 
877 
878  cnt++;
879  } //end loop over objects
880 
881 
882  // object types - all muons
883  std::vector<L1GtObject> objType(nrObj, Mu);
884 
885 
886 
887  // now create a new CondMuonition
888  MuonTemplate muonCond(name);
889 
890  muonCond.setCondType(cType);
891  muonCond.setObjectType(objType);
892  muonCond.setCondGEq(gEq);
893  muonCond.setCondChipNr(chipNr);
894  muonCond.setCondRelativeBx(relativeBx);
895 
896  muonCond.setConditionParameter(objParameter, corrParameter);
897 
898  if (edm::isDebugEnabled()) {
899  std::ostringstream myCoutStream;
900  muonCond.print(myCoutStream);
901  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
902  }
903 
904  // insert condition into the map and into muon template vector
905  if ( !insertConditionIntoMap(muonCond, chipNr)) {
906  edm::LogError("TriggerMenuParser")
907  << " Error: duplicate condition (" << name << ")"
908  << std::endl;
909  return false;
910  }
911  else {
912  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
913  if (corrFlag) {
914 
915  (m_corMuonTemplate[chipNr]).push_back(muonCond);
916  }
917  else {
918  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the vecMuonTemplate vector" << std::endl;
919  (m_vecMuonTemplate[chipNr]).push_back(muonCond);
920  }
921 
922  }
923 
924  //
925  return true;
926 }
927 
928 
929 bool l1t::TriggerMenuParser::parseMuonCorr(const tmeventsetup::esObject* corrMu,
930  unsigned int chipNr) {
931 
932 
933 // XERCES_CPP_NAMESPACE_USE
934  using namespace tmeventsetup;
935 
936  // get condition, particle name (must be muon) and type name
937  std::string condition = "muon";
938  std::string particle = "muon";//l1t2string( condMu.objectType() );
939  std::string type = l1t2string( corrMu->getType() );
940  std::string name = l1t2string( corrMu->getName() );
941  int nrObj = 1;
942  type = "1_s";
944 
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 
977 // BLW TO DO: How do we deal with these in the new format
978 // std::string str_chargeCorrelation = l1t2string( condMu.requestedChargeCorr() );
979  std::string str_chargeCorrelation = "ig";
980  unsigned int chargeCorrelation = 0;
981  if( str_chargeCorrelation=="ig" ) chargeCorrelation = 1;
982  else if( str_chargeCorrelation=="ls" ) chargeCorrelation = 2;
983  else if( str_chargeCorrelation=="os" ) chargeCorrelation = 4;
984 
985  //getXMLHexTextValue("1", dst);
986  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
987 
988 
989 
990  // BLW TO DO: These needs to the added to the object rather than the whole condition.
991  int relativeBx = 0;
992  bool gEq = false;
993 
994 
995  //const esObject* object = condMu;
996  gEq = (corrMu->getComparisonOperator() == esComparisonOperator::GE);
997 
998  // BLW TO DO: This needs to be added to the Object Parameters
999  relativeBx = corrMu->getBxOffset();
1000 
1001  // Loop over the cuts for this object
1002  int upperThresholdInd = -1;
1003  int lowerThresholdInd = 0;
1004  int cntEta = 0;
1005  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1006  int cntPhi = 0;
1007  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1008  int isolationLUT = 0xF; //default is to ignore unless specified.
1009  int charge = -1; //defaut is to ignore unless specified
1010  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
1011 
1012  const std::vector<esCut>& cuts = corrMu->getCuts();
1013  for (size_t kk = 0; kk < cuts.size(); kk++)
1014  {
1015  const esCut cut = cuts.at(kk);
1016 
1017  switch(cut.getCutType()){
1018  case esCutType::Threshold:
1019  lowerThresholdInd = cut.getMinimum().index;
1020  upperThresholdInd = cut.getMaximum().index;
1021  break;
1022 
1023  case esCutType::Eta: {
1024 
1025  if(cntEta == 0) {
1026  etaWindow1Lower = cut.getMinimum().index;
1027  etaWindow1Upper = cut.getMaximum().index;
1028  } else if(cntEta == 1) {
1029  etaWindow2Lower = cut.getMinimum().index;
1030  etaWindow2Upper = cut.getMaximum().index;
1031  } else {
1032  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for muon-condition ("
1033  << particle << ")" << std::endl;
1034  return false;
1035  }
1036  cntEta++;
1037 
1038  } break;
1039 
1040  case esCutType::Phi: {
1041 
1042  if(cntPhi == 0) {
1043  phiWindow1Lower = cut.getMinimum().index;
1044  phiWindow1Upper = cut.getMaximum().index;
1045  } else if(cntPhi == 1) {
1046  phiWindow2Lower = cut.getMinimum().index;
1047  phiWindow2Upper = cut.getMaximum().index;
1048  } else {
1049  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for muon-condition ("
1050  << particle << ")" << std::endl;
1051  return false;
1052  }
1053  cntPhi++;
1054 
1055  }break;
1056 
1057  case esCutType::Charge:
1058  std::cout << "Found Charge Cut " << std::endl;
1059  if( cut.getData()=="positive" ) charge = 0;
1060  else if( cut.getData()=="negative" ) charge = 1;
1061  else charge = -1;
1062  break;
1063  case esCutType::Quality:
1064 
1065  qualityLUT = l1tstr2int(cut.getData());
1066 
1067  break;
1068  case esCutType::Isolation: {
1069 
1070  isolationLUT = l1tstr2int(cut.getData());
1071 
1072  } break;
1073  default:
1074  break;
1075  } //end switch
1076 
1077  } //end loop over cuts
1078 
1079 
1080  // Set the parameter cuts
1081  objParameter[0].ptHighThreshold = upperThresholdInd;
1082  objParameter[0].ptLowThreshold = lowerThresholdInd;
1083 
1084  objParameter[0].etaWindow1Lower = etaWindow1Lower;
1085  objParameter[0].etaWindow1Upper = etaWindow1Upper;
1086  objParameter[0].etaWindow2Lower = etaWindow2Lower;
1087  objParameter[0].etaWindow2Upper = etaWindow2Upper;
1088 
1089  objParameter[0].phiWindow1Lower = phiWindow1Lower;
1090  objParameter[0].phiWindow1Upper = phiWindow1Upper;
1091  objParameter[0].phiWindow2Lower = phiWindow2Lower;
1092  objParameter[0].phiWindow2Upper = phiWindow2Upper;
1093 
1094  // BLW TO DO: Do we need these anymore? Drop them?
1095  objParameter[0].enableMip = false;//tmpMip[i];
1096  objParameter[0].enableIso = false;//tmpEnableIso[i];
1097  objParameter[0].requestIso = false;//tmpRequestIso[i];
1098 
1099  objParameter[0].charge = charge;
1100  objParameter[0].qualityLUT = qualityLUT;
1101  objParameter[0].isolationLUT = isolationLUT;
1102 
1103 
1104  // object types - all muons
1105  std::vector<L1GtObject> objType(nrObj, Mu);
1106 
1107  // now create a new CondMuonition
1108  MuonTemplate muonCond(name);
1109 
1110  muonCond.setCondType(cType);
1111  muonCond.setObjectType(objType);
1112  muonCond.setCondGEq(gEq);
1113  muonCond.setCondChipNr(chipNr);
1114  muonCond.setCondRelativeBx(relativeBx);
1115  muonCond.setConditionParameter(objParameter, corrParameter);
1116 
1117  if (edm::isDebugEnabled()) {
1118  std::ostringstream myCoutStream;
1119  muonCond.print(myCoutStream);
1120  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1121  }
1122 
1123  // insert condition into the map and into muon template vector
1124  if ( !insertConditionIntoMap(muonCond, chipNr)) {
1125  edm::LogError("TriggerMenuParser")
1126  << " Error: duplicate condition (" << name << ")"
1127  << std::endl;
1128  return false;
1129  }
1130  else {
1131  LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1132  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1133  }
1134 
1135  //
1136  return true;
1137 }
1138 
1139 
1151 bool l1t::TriggerMenuParser::parseCalo(tmeventsetup::esCondition condCalo,
1152  unsigned int chipNr, const bool corrFlag) {
1153 
1154 
1155 // XERCES_CPP_NAMESPACE_USE
1156  using namespace tmeventsetup;
1157 
1158  // get condition, particle name and type name
1159 
1160  std::string condition = "calo";
1161  std::string particle = "test-fix" ;
1162  std::string type = l1t2string( condCalo.getType() );
1163  std::string name = l1t2string( condCalo.getName() );
1164 
1165  LogDebug("TriggerMenuParser")
1166  << "\n ****************************************** "
1167  << "\n (in parseCalo) "
1168  << "\n condition = " << condition
1169  << "\n particle = " << particle
1170  << "\n type = " << type
1171  << "\n name = " << name
1172  << std::endl;
1173 
1174 
1175  GtConditionType cType = l1t::TypeNull;
1176 
1177  // determine object type type
1178  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
1179  L1GtObject caloObjType;
1180  int nrObj = -1;
1181 
1182  if (condCalo.getType() == esConditionType::SingleEgamma) {
1183  caloObjType = NoIsoEG;
1184  type = "1_s";
1185  cType= l1t::Type1s;
1186  nrObj = 1;
1187  } else if (condCalo.getType() == esConditionType::DoubleEgamma) {
1188  caloObjType = NoIsoEG;
1189  type = "2_s";
1190  cType= l1t::Type2s;
1191  nrObj = 2;
1192  } else if (condCalo.getType() == esConditionType::TripleEgamma) {
1193  caloObjType = NoIsoEG;
1194  cType= l1t::Type3s;
1195  type = "3";
1196  nrObj = 3;
1197  } else if (condCalo.getType() == esConditionType::QuadEgamma) {
1198  caloObjType = NoIsoEG;
1199  cType= l1t::Type4s;
1200  type = "4";
1201  nrObj = 4;
1202  } else if (condCalo.getType() == esConditionType::SingleJet) {
1203  caloObjType = CenJet;
1204  cType= l1t::Type1s;
1205  type = "1_s";
1206  nrObj = 1;
1207  } else if (condCalo.getType() == esConditionType::DoubleJet) {
1208  caloObjType = CenJet;
1209  cType= l1t::Type2s;
1210  type = "2_s";
1211  nrObj = 2;
1212  } else if (condCalo.getType() == esConditionType::TripleJet) {
1213  caloObjType = CenJet;
1214  cType= l1t::Type3s;
1215  type = "3";
1216  nrObj = 3;
1217  } else if (condCalo.getType() == esConditionType::QuadJet) {
1218  caloObjType = CenJet;
1219  cType= l1t::Type4s;
1220  type = "4";
1221  nrObj = 4;
1222  } else if (condCalo.getType() == esConditionType::SingleTau) {
1223  caloObjType = TauJet;
1224  cType= l1t::Type1s;
1225  type = "1_s";
1226  nrObj = 1;
1227  } else if (condCalo.getType() == esConditionType::DoubleTau) {
1228  caloObjType = TauJet;
1229  cType= l1t::Type2s;
1230  type = "2_s";
1231  nrObj = 2;
1232  } else if (condCalo.getType() == esConditionType::TripleTau) {
1233  caloObjType = TauJet;
1234  cType= l1t::Type3s;
1235  type = "3";
1236  nrObj = 3;
1237  } else if (condCalo.getType() == esConditionType::QuadTau) {
1238  caloObjType = TauJet;
1239  cType= l1t::Type4s;
1240  type = "4";
1241  nrObj = 4;
1242  } else {
1243  edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition ("
1244  << particle << ")" << std::endl;
1245  return false;
1246  }
1247 
1248 // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1249 
1250  if (nrObj < 0) {
1251  edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type
1252  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1253  return false;
1254  }
1255 
1256  // get values
1257 
1258  // temporary storage of the parameters
1259  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1260 
1261  //BLW TO DO: Can this be dropped?
1262  CaloTemplate::CorrelationParameter corrParameter;
1263 
1264  // need at least one value for deltaPhiRange
1265  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1266  tmpValues.reserve( nrObj );
1267 
1268 
1269  if( int(condCalo.getObjects().size())!=nrObj ){
1270  edm::LogError("TriggerMenuParser") << " condCalo objects: nrObj = " << nrObj
1271  << "condCalo.getObjects().size() = "
1272  << condCalo.getObjects().size()
1273  << std::endl;
1274  return false;
1275  }
1276 
1277 
1278 // std::string str_condCalo = "";
1279 // boost::uint64_t tempUIntH, tempUIntL;
1280 // boost::uint64_t dst;
1281  int cnt = 0;
1282 
1283 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1284  int relativeBx = 0;
1285  bool gEq = false;
1286 
1287 // Loop over objects and extract the cuts on the objects
1288  const std::vector<esObject>& objects = condCalo.getObjects();
1289  for (size_t jj = 0; jj < objects.size(); jj++) {
1290 
1291  const esObject object = objects.at(jj);
1292  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1293 
1294 // BLW TO DO: This needs to be added to the Object Parameters
1295  relativeBx = object.getBxOffset();
1296 
1297 // Loop over the cuts for this object
1298  int upperThresholdInd = -1;
1299  int lowerThresholdInd = 0;
1300  int cntEta = 0;
1301  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1302  int cntPhi = 0;
1303  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1304  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
1305  int qualityLUT = 0xF; //default is to ignore quality unless specified.
1306 
1307 
1308  const std::vector<esCut>& cuts = object.getCuts();
1309  for (size_t kk = 0; kk < cuts.size(); kk++)
1310  {
1311  const esCut cut = cuts.at(kk);
1312 
1313  switch(cut.getCutType()){
1314  case esCutType::Threshold:
1315  lowerThresholdInd = cut.getMinimum().index;
1316  upperThresholdInd = cut.getMaximum().index;
1317  break;
1318  case esCutType::Eta: {
1319 
1320  if(cntEta == 0) {
1321  etaWindow1Lower = cut.getMinimum().index;
1322  etaWindow1Upper = cut.getMaximum().index;
1323  } else if(cntEta == 1) {
1324  etaWindow2Lower = cut.getMinimum().index;
1325  etaWindow2Upper = cut.getMaximum().index;
1326  } else {
1327  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for calo-condition ("
1328  << particle << ")" << std::endl;
1329  return false;
1330  }
1331  cntEta++;
1332 
1333  } break;
1334 
1335  case esCutType::Phi: {
1336 
1337  if(cntPhi == 0) {
1338  phiWindow1Lower = cut.getMinimum().index;
1339  phiWindow1Upper = cut.getMaximum().index;
1340  } else if(cntPhi == 1) {
1341  phiWindow2Lower = cut.getMinimum().index;
1342  phiWindow2Upper = cut.getMaximum().index;
1343  } else {
1344  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for calo-condition ("
1345  << particle << ")" << std::endl;
1346  return false;
1347  }
1348  cntPhi++;
1349 
1350  }break;
1351 
1352  case esCutType::Charge: {
1353 
1354  edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition ("
1355  << particle << ")" << std::endl;
1356  return false;
1357 
1358  }break;
1359  case esCutType::Quality: {
1360 
1361  qualityLUT = l1tstr2int(cut.getData());
1362 
1363  }break;
1364  case esCutType::Isolation: {
1365 
1366  isolationLUT = l1tstr2int(cut.getData());
1367 
1368  } break;
1369  default:
1370  break;
1371  } //end switch
1372 
1373  } //end loop over cuts
1374 
1375 // Fill the object parameters
1376  objParameter[cnt].etHighThreshold = upperThresholdInd;
1377  objParameter[cnt].etLowThreshold = lowerThresholdInd;
1378  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
1379  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
1380  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
1381  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
1382  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1383  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1384  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1385  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1386  objParameter[cnt].isolationLUT = isolationLUT;
1387  objParameter[cnt].qualityLUT = qualityLUT; //TO DO: Must add
1388 
1389  // Output for debugging
1390  LogDebug("TriggerMenuParser")
1391  << "\n Calo ET high thresholds (hex) for calo object " << caloObjType << " " << cnt << " = "
1392  << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold
1393  << "\n etaWindow Lower / Upper for calo object " << cnt << " = 0x"
1394  << objParameter[cnt].etaWindow1Lower << " / 0x" << objParameter[cnt].etaWindow1Upper
1395  << "\n etaWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
1396  << objParameter[cnt].etaWindow2Lower << " / 0x" << objParameter[cnt].etaWindow2Upper
1397  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
1398  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
1399  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
1400  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper
1401  << "\n Isolation LUT for calo object " << cnt << " = 0x"
1402  << objParameter[cnt].isolationLUT
1403  << "\n Quality LUT for calo object " << cnt << " = 0x"
1404  << objParameter[cnt].qualityLUT << std::dec
1405  << std::endl;
1406 
1407  cnt++;
1408  } //end loop over objects
1409 
1410 
1411 
1412  // object types - all same caloObjType
1413  std::vector<L1GtObject> objType(nrObj, caloObjType);
1414 
1415 
1416 
1417 
1418  // now create a new calo condition
1419  CaloTemplate caloCond(name);
1420 
1421  caloCond.setCondType(cType);
1422  caloCond.setObjectType(objType);
1423 
1424  //BLW TO DO: This needs to be added to the object rather than the whole condition
1425  caloCond.setCondGEq(gEq);
1426  caloCond.setCondChipNr(chipNr);
1427 
1428  //BLW TO DO: This needs to be added to the object rather than the whole condition
1429  caloCond.setCondRelativeBx(relativeBx);
1430 
1431  caloCond.setConditionParameter(objParameter, corrParameter);
1432 
1433  if (edm::isDebugEnabled() ) {
1434 
1435  std::ostringstream myCoutStream;
1436  caloCond.print(myCoutStream);
1437  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1438 
1439  }
1440 
1441 
1442  // insert condition into the map
1443  if ( !insertConditionIntoMap(caloCond, chipNr)) {
1444 
1445  edm::LogError("TriggerMenuParser")
1446  << " Error: duplicate condition (" << name << ")"
1447  << std::endl;
1448 
1449  return false;
1450  }
1451  else {
1452 
1453  if (corrFlag) {
1454  (m_corCaloTemplate[chipNr]).push_back(caloCond);
1455  }
1456  else {
1457  (m_vecCaloTemplate[chipNr]).push_back(caloCond);
1458  }
1459 
1460  }
1461 
1462 
1463  //
1464  return true;
1465 }
1466 
1467 
1468 
1480 bool l1t::TriggerMenuParser::parseCaloCorr(const tmeventsetup::esObject* corrCalo,
1481  unsigned int chipNr) {
1482 
1483 
1484 // XERCES_CPP_NAMESPACE_USE
1485  using namespace tmeventsetup;
1486 
1487  // get condition, particle name and type name
1488 
1489  std::string condition = "calo";
1490  std::string particle = "test-fix" ;
1491  std::string type = l1t2string( corrCalo->getType() );
1492  std::string name = l1t2string( corrCalo->getName() );
1493 
1494  LogDebug("TriggerMenuParser")
1495  << "\n ****************************************** "
1496  << "\n (in parseCalo) "
1497  << "\n condition = " << condition
1498  << "\n particle = " << particle
1499  << "\n type = " << type
1500  << "\n name = " << name
1501  << std::endl;
1502 
1503 
1504  // determine object type type
1505  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
1506  L1GtObject caloObjType;
1507  int nrObj = 1;
1508  type = "1_s";
1509  GtConditionType cType = l1t::Type1s;
1510 
1511 
1512  if (corrCalo->getType() == esObjectType::Egamma) {
1513  caloObjType = NoIsoEG;
1514  } else if (corrCalo->getType() == esObjectType::Jet) {
1515  caloObjType = CenJet;
1516  } else if (corrCalo->getType() == esObjectType::Tau) {
1517  caloObjType = TauJet;
1518  } else {
1519  edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition ("
1520  << particle << ")" << std::endl;
1521  return false;
1522  }
1523 
1524 
1525 // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1526 
1527  if (nrObj < 0) {
1528  edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type
1529  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1530  return false;
1531  }
1532 
1533  // get values
1534 
1535  // temporary storage of the parameters
1536  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1537 
1538  //BLW TO DO: Can this be dropped?
1539  CaloTemplate::CorrelationParameter corrParameter;
1540 
1541  // need at least one value for deltaPhiRange
1542  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1543  tmpValues.reserve( nrObj );
1544 
1545 
1546 
1547 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1548  int relativeBx = 0;
1549  bool gEq = false;
1550 
1551 
1552  gEq = (corrCalo->getComparisonOperator() == esComparisonOperator::GE);
1553 
1554 // BLW TO DO: This needs to be added to the Object Parameters
1555  relativeBx = corrCalo->getBxOffset();
1556 
1557 // Loop over the cuts for this object
1558  int upperThresholdInd = -1;
1559  int lowerThresholdInd = 0;
1560  int cntEta = 0;
1561  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1562  int cntPhi = 0;
1563  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1564  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
1565  int qualityLUT = 0xF; //default is to ignore quality unless specified.
1566 
1567 
1568  const std::vector<esCut>& cuts = corrCalo->getCuts();
1569  for (size_t kk = 0; kk < cuts.size(); kk++)
1570  {
1571  const esCut cut = cuts.at(kk);
1572 
1573  switch(cut.getCutType()){
1574  case esCutType::Threshold:
1575  lowerThresholdInd = cut.getMinimum().index;
1576  upperThresholdInd = cut.getMaximum().index;
1577  break;
1578  case esCutType::Eta: {
1579 
1580  if(cntEta == 0) {
1581  etaWindow1Lower = cut.getMinimum().index;
1582  etaWindow1Upper = cut.getMaximum().index;
1583  } else if(cntEta == 1) {
1584  etaWindow2Lower = cut.getMinimum().index;
1585  etaWindow2Upper = cut.getMaximum().index;
1586  } else {
1587  edm::LogError("TriggerMenuParser") << "Too Many Eta Cuts for calo-condition ("
1588  << particle << ")" << std::endl;
1589  return false;
1590  }
1591  cntEta++;
1592 
1593  } break;
1594 
1595  case esCutType::Phi: {
1596 
1597  if(cntPhi == 0) {
1598  phiWindow1Lower = cut.getMinimum().index;
1599  phiWindow1Upper = cut.getMaximum().index;
1600  } else if(cntPhi == 1) {
1601  phiWindow2Lower = cut.getMinimum().index;
1602  phiWindow2Upper = cut.getMaximum().index;
1603  } else {
1604  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for calo-condition ("
1605  << particle << ")" << std::endl;
1606  return false;
1607  }
1608  cntPhi++;
1609 
1610  }break;
1611 
1612  case esCutType::Charge: {
1613 
1614  edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition ("
1615  << particle << ")" << std::endl;
1616  return false;
1617 
1618  }break;
1619  case esCutType::Quality: {
1620 
1621  qualityLUT = l1tstr2int(cut.getData());
1622 
1623  }break;
1624  case esCutType::Isolation: {
1625 
1626  isolationLUT = l1tstr2int(cut.getData());
1627 
1628  } break;
1629  default:
1630  break;
1631  } //end switch
1632 
1633  } //end loop over cuts
1634 
1635 // Fill the object parameters
1636  objParameter[0].etLowThreshold = lowerThresholdInd;
1637  objParameter[0].etHighThreshold = upperThresholdInd;
1638  objParameter[0].etaWindow1Lower = etaWindow1Lower;
1639  objParameter[0].etaWindow1Upper = etaWindow1Upper;
1640  objParameter[0].etaWindow2Lower = etaWindow2Lower;
1641  objParameter[0].etaWindow2Upper = etaWindow2Upper;
1642  objParameter[0].phiWindow1Lower = phiWindow1Lower;
1643  objParameter[0].phiWindow1Upper = phiWindow1Upper;
1644  objParameter[0].phiWindow2Lower = phiWindow2Lower;
1645  objParameter[0].phiWindow2Upper = phiWindow2Upper;
1646  objParameter[0].isolationLUT = isolationLUT;
1647  objParameter[0].qualityLUT = qualityLUT; //TO DO: Must add
1648 
1649  // Output for debugging
1650  LogDebug("TriggerMenuParser")
1651  << "\n Calo ET high threshold (hex) for calo object " << caloObjType << " " << " = "
1652  << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etHighThreshold
1653  << "\n etaWindow Lower / Upper for calo object " << " = 0x"
1654  << objParameter[0].etaWindow1Lower << " / 0x" << objParameter[0].etaWindow1Upper
1655  << "\n etaWindowVeto Lower / Upper for calo object " << " = 0x"
1656  << objParameter[0].etaWindow2Lower << " / 0x" << objParameter[0].etaWindow2Upper
1657  << "\n phiWindow Lower / Upper for calo object " << " = 0x"
1658  << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
1659  << "\n phiWindowVeto Lower / Upper for calo object " << " = 0x"
1660  << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper
1661  << "\n Isolation LUT for calo object " << " = 0x"
1662  << objParameter[0].isolationLUT
1663  << "\n Quality LUT for calo object " << " = 0x"
1664  << objParameter[0].qualityLUT << std::dec
1665  << std::endl;
1666 
1667 
1668 
1669 
1670 
1671  // object types - all same caloObjType
1672  std::vector<L1GtObject> objType(nrObj, caloObjType);
1673 
1674 
1675 
1676 
1677  // now create a new calo condition
1678  CaloTemplate caloCond(name);
1679 
1680  caloCond.setCondType(cType);
1681  caloCond.setObjectType(objType);
1682 
1683  //BLW TO DO: This needs to be added to the object rather than the whole condition
1684  caloCond.setCondGEq(gEq);
1685  caloCond.setCondChipNr(chipNr);
1686 
1687  //BLW TO DO: This needs to be added to the object rather than the whole condition
1688  caloCond.setCondRelativeBx(relativeBx);
1689 
1690  caloCond.setConditionParameter(objParameter, corrParameter);
1691 
1692  if (edm::isDebugEnabled() ) {
1693 
1694  std::ostringstream myCoutStream;
1695  caloCond.print(myCoutStream);
1696  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1697 
1698  }
1699 
1700 
1701  // insert condition into the map
1702  if ( !insertConditionIntoMap(caloCond, chipNr)) {
1703 
1704  edm::LogError("TriggerMenuParser")
1705  << " Error: duplicate condition (" << name << ")"
1706  << std::endl;
1707 
1708  return false;
1709  }
1710  else {
1711  (m_corCaloTemplate[chipNr]).push_back(caloCond);
1712  }
1713 
1714 
1715  //
1716  return true;
1717 }
1718 
1719 
1720 
1732 bool l1t::TriggerMenuParser::parseEnergySum(tmeventsetup::esCondition condEnergySum,
1733  unsigned int chipNr, const bool corrFlag) {
1734 
1735 
1736 // XERCES_CPP_NAMESPACE_USE
1737  using namespace tmeventsetup;
1738 
1739  // get condition, particle name and type name
1740 
1741  std::string condition = "calo";
1742  std::string type = l1t2string( condEnergySum.getType() );
1743  std::string name = l1t2string( condEnergySum.getName() );
1744 
1745  LogDebug("TriggerMenuParser")
1746  << "\n ****************************************** "
1747  << "\n (in parseEnergySum) "
1748  << "\n condition = " << condition
1749  << "\n type = " << type
1750  << "\n name = " << name
1751  << std::endl;
1752 
1753 
1754 
1755  // determine object type type
1756  L1GtObject energySumObjType;
1757  GtConditionType cType;
1758 
1759  if( condEnergySum.getType() == esConditionType::MissingEt ){
1760  energySumObjType = L1GtObject::ETM;
1761  cType = TypeETM;
1762  }
1763  else if( condEnergySum.getType() == esConditionType::TotalEt ){
1764  energySumObjType = L1GtObject::ETT;
1765  cType = TypeETT;
1766  }
1767  else if( condEnergySum.getType() == esConditionType::TotalHt ){
1768  energySumObjType = L1GtObject::HTT;
1769  cType = TypeHTT;
1770  }
1771  else if( condEnergySum.getType() == esConditionType::MissingHt ){
1772  energySumObjType = L1GtObject::HTM;
1773  cType = TypeHTM;
1774  }
1775  else {
1776  edm::LogError("TriggerMenuParser")
1777  << "Wrong type for energy-sum condition (" << type
1778  << ")" << std::endl;
1779  return false;
1780  }
1781 
1782 
1783 
1784  // global object
1785  int nrObj = 1;
1786 
1787 // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
1788 
1789  // get values
1790 
1791  // temporary storage of the parameters
1792  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
1793 
1794 
1795  int cnt = 0;
1796 
1797 // BLW TO DO: These needs to the added to the object rather than the whole condition.
1798  int relativeBx = 0;
1799  bool gEq = false;
1800 
1801 // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
1802 
1803 // Loop over objects and extract the cuts on the objects
1804  const std::vector<esObject>& objects = condEnergySum.getObjects();
1805  for (size_t jj = 0; jj < objects.size(); jj++) {
1806 
1807  const esObject object = objects.at(jj);
1808  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1809 
1810 // BLW TO DO: This needs to be added to the Object Parameters
1811  relativeBx = object.getBxOffset();
1812 
1813 // Loop over the cuts for this object
1814  int lowerThresholdInd = 0;
1815  int upperThresholdInd = -1;
1816  int cntPhi = 0;
1817  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1818 
1819 
1820  const std::vector<esCut>& cuts = object.getCuts();
1821  for (size_t kk = 0; kk < cuts.size(); kk++)
1822  {
1823  const esCut cut = cuts.at(kk);
1824 
1825  switch(cut.getCutType()){
1826  case esCutType::Threshold:
1827  lowerThresholdInd = cut.getMinimum().index;
1828  upperThresholdInd = cut.getMaximum().index;
1829  break;
1830 
1831  case esCutType::Eta:
1832  break;
1833 
1834  case esCutType::Phi: {
1835 
1836  if(cntPhi == 0) {
1837  phiWindow1Lower = cut.getMinimum().index;
1838  phiWindow1Upper = cut.getMaximum().index;
1839  } else if(cntPhi == 1) {
1840  phiWindow2Lower = cut.getMinimum().index;
1841  phiWindow2Upper = cut.getMaximum().index;
1842  } else {
1843  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition ("
1844  << type << ")" << std::endl;
1845  return false;
1846  }
1847  cntPhi++;
1848 
1849  }
1850  break;
1851 
1852  default:
1853  break;
1854  } //end switch
1855 
1856  } //end loop over cuts
1857 
1858 
1859 
1860  // Fill the object parameters
1861  objParameter[cnt].etLowThreshold = lowerThresholdInd;
1862  objParameter[cnt].etHighThreshold = upperThresholdInd;
1863  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1864  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1865  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1866  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1867 
1868 
1869  // Output for debugging
1870  LogDebug("TriggerMenuParser")
1871  << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
1872  << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold
1873  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
1874  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
1875  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
1876  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper << std::dec
1877  << std::endl;
1878 
1879  cnt++;
1880  } //end loop over objects
1881 
1882  // object types - all same energySumObjType
1883  std::vector<L1GtObject> objType(nrObj, energySumObjType);
1884 
1885  // now create a new energySum condition
1886 
1887  EnergySumTemplate energySumCond(name);
1888 
1889  energySumCond.setCondType(cType);
1890  energySumCond.setObjectType(objType);
1891  energySumCond.setCondGEq(gEq);
1892  energySumCond.setCondChipNr(chipNr);
1893  energySumCond.setCondRelativeBx(relativeBx);
1894 
1895  energySumCond.setConditionParameter(objParameter);
1896 
1897  if (edm::isDebugEnabled() ) {
1898 
1899  std::ostringstream myCoutStream;
1900  energySumCond.print(myCoutStream);
1901  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1902 
1903  }
1904 
1905  // insert condition into the map
1906  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
1907 
1908  edm::LogError("TriggerMenuParser")
1909  << " Error: duplicate condition (" << name << ")"
1910  << std::endl;
1911 
1912  return false;
1913  }
1914  else {
1915 
1916  if (corrFlag) {
1917  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
1918 
1919  }
1920  else {
1921  (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
1922  }
1923 
1924  }
1925 
1926 
1927 
1928  //
1929  return true;
1930 }
1931 
1932 
1944 bool l1t::TriggerMenuParser::parseEnergySumCorr(const tmeventsetup::esObject* corrESum,
1945  unsigned int chipNr) {
1946 
1947 
1948 // XERCES_CPP_NAMESPACE_USE
1949  using namespace tmeventsetup;
1950 
1951  // get condition, particle name and type name
1952 
1953  std::string condition = "calo";
1954  std::string type = l1t2string( corrESum->getType() );
1955  std::string name = l1t2string( corrESum->getName() );
1956 
1957  LogDebug("TriggerMenuParser")
1958  << "\n ****************************************** "
1959  << "\n (in parseEnergySum) "
1960  << "\n condition = " << condition
1961  << "\n type = " << type
1962  << "\n name = " << name
1963  << std::endl;
1964 
1965 
1966 
1967  // determine object type type
1968  L1GtObject energySumObjType;
1969  GtConditionType cType;
1970 
1971  if( corrESum->getType()== esObjectType::ETM ){
1972  energySumObjType = L1GtObject::ETM;
1973  cType = TypeETM;
1974  }
1975  else if( corrESum->getType()== esObjectType::HTM ){
1976  energySumObjType = L1GtObject::HTM;
1977  cType = TypeHTM;
1978  }
1979  else {
1980  edm::LogError("TriggerMenuParser")
1981  << "Wrong type for energy-sum correclation condition (" << type
1982  << ")" << std::endl;
1983  return false;
1984  }
1985 
1986 
1987 
1988  // global object
1989  int nrObj = 1;
1990 
1991 // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
1992 
1993  // get values
1994 
1995  // temporary storage of the parameters
1996  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
1997 
1998 
1999  int cnt = 0;
2000 
2001 // BLW TO DO: These needs to the added to the object rather than the whole condition.
2002  int relativeBx = 0;
2003  bool gEq = false;
2004 
2005 // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
2006 
2007 
2008  gEq = (corrESum->getComparisonOperator() == esComparisonOperator::GE);
2009 
2010 // BLW TO DO: This needs to be added to the Object Parameters
2011  relativeBx = corrESum->getBxOffset();
2012 
2013 // Loop over the cuts for this object
2014  int lowerThresholdInd = 0;
2015  int upperThresholdInd = -1;
2016  int cntPhi = 0;
2017  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
2018 
2019 
2020  const std::vector<esCut>& cuts = corrESum->getCuts();
2021  for (size_t kk = 0; kk < cuts.size(); kk++)
2022  {
2023  const esCut cut = cuts.at(kk);
2024 
2025  switch(cut.getCutType()){
2026  case esCutType::Threshold:
2027  lowerThresholdInd = cut.getMinimum().index;
2028  upperThresholdInd = cut.getMaximum().index;
2029  break;
2030 
2031  case esCutType::Eta:
2032  break;
2033 
2034  case esCutType::Phi: {
2035 
2036  if(cntPhi == 0) {
2037  phiWindow1Lower = cut.getMinimum().index;
2038  phiWindow1Upper = cut.getMaximum().index;
2039  } else if(cntPhi == 1) {
2040  phiWindow2Lower = cut.getMinimum().index;
2041  phiWindow2Upper = cut.getMaximum().index;
2042  } else {
2043  edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition ("
2044  << type << ")" << std::endl;
2045  return false;
2046  }
2047  cntPhi++;
2048 
2049  }
2050  break;
2051 
2052  default:
2053  break;
2054  } //end switch
2055 
2056  } //end loop over cuts
2057 
2058 
2059 
2060  // Fill the object parameters
2061  objParameter[0].etLowThreshold = lowerThresholdInd;
2062  objParameter[0].etHighThreshold = upperThresholdInd;
2063  objParameter[0].phiWindow1Lower = phiWindow1Lower;
2064  objParameter[0].phiWindow1Upper = phiWindow1Upper;
2065  objParameter[0].phiWindow2Lower = phiWindow2Lower;
2066  objParameter[0].phiWindow2Upper = phiWindow2Upper;
2067 
2068 
2069  // Output for debugging
2070  LogDebug("TriggerMenuParser")
2071  << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2072  << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etLowThreshold
2073  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2074  << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
2075  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2076  << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper << std::dec
2077  << std::endl;
2078 
2079 
2080  // object types - all same energySumObjType
2081  std::vector<L1GtObject> objType(nrObj, energySumObjType);
2082 
2083  // now create a new energySum condition
2084 
2085  EnergySumTemplate energySumCond(name);
2086 
2087  energySumCond.setCondType(cType);
2088  energySumCond.setObjectType(objType);
2089  energySumCond.setCondGEq(gEq);
2090  energySumCond.setCondChipNr(chipNr);
2091  energySumCond.setCondRelativeBx(relativeBx);
2092 
2093  energySumCond.setConditionParameter(objParameter);
2094 
2095  if (edm::isDebugEnabled() ) {
2096 
2097  std::ostringstream myCoutStream;
2098  energySumCond.print(myCoutStream);
2099  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2100 
2101  }
2102 
2103  // insert condition into the map
2104  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2105 
2106  edm::LogError("TriggerMenuParser")
2107  << " Error: duplicate condition (" << name << ")"
2108  << std::endl;
2109 
2110  return false;
2111  }
2112  else {
2113 
2114  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2115 
2116  }
2117 
2118 
2119 
2120  //
2121  return true;
2122 }
2123 
2124 
2125 
2138 bool l1t::TriggerMenuParser::parseExternal(tmeventsetup::esCondition condExt,
2139  unsigned int chipNr) {
2140 
2141 
2142  using namespace tmeventsetup;
2143 
2144 
2145  // get condition, particle name and type name
2146  std::string condition = "ext";
2147  std::string particle = "test-fix";
2148  std::string type = l1t2string( condExt.getType() );
2149  std::string name = l1t2string( condExt.getName() );
2150 
2151 
2152  LogDebug("TriggerMenuParser")
2153  << "\n ****************************************** "
2154  << "\n (in parseExternal) "
2155  << "\n condition = " << condition
2156  << "\n particle = " << particle
2157  << "\n type = " << type
2158  << "\n name = " << name
2159  << std::endl;
2160 
2161 
2162  // object type and condition type
2163  // object type - irrelevant for External conditions
2164  GtConditionType cType = TypeExternal;
2165 
2166  int relativeBx = 0;
2167  unsigned int channelID = 0;
2168 
2169  // Get object for External conditions
2170  const std::vector<esObject>& objects = condExt.getObjects();
2171  for (size_t jj = 0; jj < objects.size(); jj++) {
2172 
2173  const esObject object = objects.at(jj);
2174  if(object.getType() == esObjectType::EXT) {
2175  relativeBx = object.getBxOffset();
2176  channelID = object.getExternalChannelId();
2177  }
2178  }
2179 
2180 
2181  // set the boolean value for the ge_eq mode - irrelevant for External conditions
2182  bool gEq = false;
2183 
2184  // now create a new External condition
2185  ExternalTemplate externalCond(name);
2186 
2187  externalCond.setCondType(cType);
2188  externalCond.setCondGEq(gEq);
2189  externalCond.setCondChipNr(chipNr);
2190  externalCond.setCondRelativeBx(relativeBx);
2191  externalCond.setExternalChannel(channelID);
2192 
2193  LogTrace("TriggerMenuParser")
2194  << externalCond << "\n" << std::endl;
2195 
2196  // insert condition into the map
2197  if ( !insertConditionIntoMap(externalCond, chipNr)) {
2198 
2199  edm::LogError("TriggerMenuParser")
2200  << " Error: duplicate condition (" << name
2201  << ")" << std::endl;
2202 
2203  return false;
2204  } else {
2205 
2206  (m_vecExternalTemplate[chipNr]).push_back(externalCond);
2207 
2208  }
2209 
2210  return true;
2211 }
2212 
2213 
2227  tmeventsetup::esCondition corrCond,
2228  unsigned int chipNr) {
2229 
2230  using namespace tmeventsetup;
2231 
2232  std::string condition = "corr";
2233  std::string particle = "test-fix" ;
2234  std::string type = l1t2string( corrCond.getType() );
2235  std::string name = l1t2string( corrCond.getName() );
2236 
2237  LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
2238  << " (in parseCorrelation) " << std::endl
2239  << " condition = " << condition << std::endl
2240  << " particle = " << particle << std::endl
2241  << " type = " << type << std::endl
2242  << " name = " << name << std::endl;
2243 
2244 
2245 
2246 
2247  // create a new correlation condition
2248  CorrelationTemplate correlationCond(name);
2249 
2250  // check that the condition does not exist already in the map
2251  if ( !insertConditionIntoMap(correlationCond, chipNr)) {
2252 
2253  edm::LogError("TriggerMenuParser")
2254  << " Error: duplicate correlation condition (" << name << ")"
2255  << std::endl;
2256 
2257  return false;
2258  }
2259 
2260 
2261 // Define some of the quantities to store the parased information
2262 
2263  // condition type BLW (Do we change this to the type of correlation condition?)
2265 
2266  // two objects (for sure)
2267  const int nrObj = 2;
2268 
2269  // object types and greater equal flag - filled in the loop
2270  int intGEq[nrObj] = { -1, -1 };
2271  std::vector<L1GtObject> objType(nrObj); //BLW do we want to define these as a different type?
2272  std::vector<GtConditionCategory> condCateg(nrObj); //BLW do we want to change these categories
2273 
2274  // correlation flag and index in the cor*vector
2275  const bool corrFlag = true;
2276  int corrIndexVal[nrObj] = { -1, -1 };
2277 
2278 
2279  // Storage of the correlation selection
2281  corrParameter.chargeCorrelation = 1; //ignore charge correlation
2282 
2283 // Get the correlation Cuts on the legs
2284 
2285  const std::vector<esCut>& cuts = corrCond.getCuts();
2286  for (size_t jj = 0; jj < cuts.size(); jj++)
2287  {
2288  const esCut cut = cuts.at(jj);
2289 
2290  if(cut.getCutType() == esCutType::ChargeCorrelation) {
2291  if( cut.getData()=="ls" ) corrParameter.chargeCorrelation = 2;
2292  else if( cut.getData()=="os" ) corrParameter.chargeCorrelation = 4;
2293  else corrParameter.chargeCorrelation = 1; //ignore charge correlation
2294  } else {
2295  //keep the type from what the correlation is.
2296  corrParameter.corrCutType = cut.getCutType();
2297  corrParameter.minCutValue = cut.getMinimum().value;
2298  corrParameter.maxCutValue = cut.getMaximum().value;
2299  }
2300 
2301  }
2302 
2303 
2304 // Get the two objects that form the legs
2305  const std::vector<esObject>& objects = corrCond.getObjects();
2306  if(objects.size() != 2) {
2307  edm::LogError("TriggerMenuParser")
2308  << "incorrect number of objects for the correlation condition " << name << " corrFlag " << corrFlag << std::endl;
2309  return false;
2310  }
2311 
2312 // loop over legs
2313  for (size_t jj = 0; jj < objects.size(); jj++)
2314  {
2315  const esObject object = objects.at(jj);
2316 /* std::cout << " obj name = " << object->getName() << "\n";
2317  std::cout << " obj type = " << object->getType() << "\n";
2318  std::cout << " obj op = " << object->getComparisonOperator() << "\n";
2319  std::cout << " obj bx = " << object->getBxOffset() << "\n";
2320 */
2321 
2322 // check the leg type
2323  if(object.getType() == esObjectType::Muon) {
2324  // we have a muon
2325 
2326  //BLW Is there a problem here with not entering second instanance into the m_corMuonTemplate[]?
2327  if ((m_conditionMap[chipNr]).count(object.getName()) == 0) {
2328 
2329  parseMuonCorr(&object,chipNr);
2330 
2331  } else {
2332  LogDebug("TriggerMenuParser") << "Not Adding Correlation Muon Condition." << std::endl;
2333  }
2334 
2335  //Now set some flags for this subCondition
2336  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2337  objType[jj] = Mu;
2338  condCateg[jj] = CondMuon;
2339  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
2340 
2341 
2342 
2343  } else if(object.getType() == esObjectType::Egamma ||
2344  object.getType() == esObjectType::Jet ||
2345  object.getType() == esObjectType::Tau ) {
2346  // we have an Calo object
2347 
2348  //BLW Is there a problem here with not entering second instanance into the m_corMuonTemplate[]?
2349  if ((m_conditionMap[chipNr]).count(object.getName()) == 0) {
2350 
2351  parseCaloCorr(&object,chipNr);
2352 
2353  } else {
2354  LogDebug("TriggerMenuParser") << "Not Adding Correlation Calo Condition." << std::endl;
2355  }
2356 
2357 
2358  //Now set some flags for this subCondition
2359  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2360  switch(object.getType()) {
2361  case esObjectType::Egamma: {
2362  objType[jj] = NoIsoEG;
2363  }
2364  break;
2365  case esObjectType::Jet: {
2366  objType[jj] = CenJet;
2367  }
2368  break;
2369  case esObjectType::Tau: {
2370  objType[jj] = TauJet;
2371  }
2372  break;
2373  default: {
2374  }
2375  break;
2376  }
2377  condCateg[jj] = CondCalo;
2378  corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
2379 
2380 
2381  } else if(object.getType() == esObjectType::ETM ||
2382  object.getType() == esObjectType::HTM ) {
2383  // we have Energy Sum
2384 
2385  //BLW Is there a problem here with not entering second instanance into the m_corMuonTemplate[]?
2386  if ((m_conditionMap[chipNr]).count(object.getName()) == 0) {
2387 
2388  parseEnergySumCorr(&object,chipNr);
2389 
2390  } else {
2391  LogDebug("TriggerMenuParser") << "Not Adding Correlation EtSum Condition." << std::endl;
2392  }
2393 
2394 
2395  //Now set some flags for this subCondition
2396  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2397  switch(object.getType()) {
2398  case esObjectType::ETM: {
2399  objType[jj] = L1GtObject::ETM;
2400  }
2401  break;
2402  case esObjectType::HTM: {
2403  objType[jj] = L1GtObject::HTM;
2404  }
2405  break;
2406  default: {
2407  }
2408  break;
2409  }
2410  condCateg[jj] = CondEnergySum;
2411  corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
2412 
2413  } else {
2414 
2415  edm::LogError("TriggerMenuParser")
2416  << "Illegal Object Type "
2417  << " for the correlation condition " << name << std::endl;
2418  return false;
2419 
2420  } //if block on leg types
2421 
2422  } //loop over legs
2423 
2424 
2425  // get greater equal flag for the correlation condition
2426  bool gEq = true;
2427  if (intGEq[0] != intGEq[1]) {
2428  edm::LogError("TriggerMenuParser")
2429  << "Inconsistent GEq flags for sub-conditions "
2430  << " for the correlation condition " << name << std::endl;
2431  return false;
2432 
2433  }
2434  else {
2435  gEq = (intGEq[0] != 0);
2436 
2437  }
2438 
2439 
2440  // fill the correlation condition
2441  correlationCond.setCondType(cType);
2442  correlationCond.setObjectType(objType);
2443  correlationCond.setCondGEq(gEq);
2444  correlationCond.setCondChipNr(chipNr);
2445 
2446  correlationCond.setCond0Category(condCateg[0]);
2447  correlationCond.setCond1Category(condCateg[1]);
2448 
2449  correlationCond.setCond0Index(corrIndexVal[0]);
2450  correlationCond.setCond1Index(corrIndexVal[1]);
2451 
2452  correlationCond.setCorrelationParameter(corrParameter);
2453 
2454  if (edm::isDebugEnabled() ) {
2455 
2456  std::ostringstream myCoutStream;
2457  correlationCond.print(myCoutStream);
2458  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n"
2459  << std::endl;
2460 
2461  }
2462 
2463  // insert condition into the map
2464  // condition is not duplicate, check was done at the beginning
2465 
2466  (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
2467 
2468 
2469  //
2470  return true;
2471 }
2472 
2473 
2485 bool l1t::TriggerMenuParser::parseAlgorithm( tmeventsetup::esAlgorithm algorithm,
2486  unsigned int chipNr) {
2487 
2488 
2489  using namespace tmeventsetup;
2490  //using namespace Algorithm;
2491 
2492 
2493  // get alias
2494  std::string algAlias = algorithm.getName();
2495  std::string algName = algorithm.getName();
2496 
2497  if (algAlias == "") {
2498  algAlias = algName;
2499  LogDebug("TriggerMenuParser")
2500  << "\n No alias defined for algorithm. Alias set to algorithm name."
2501  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
2502  << std::endl;
2503  } else {
2504  //LogDebug("TriggerMenuParser")
2505  LogDebug("TriggerMenuParser") << "\n Alias defined for algorithm."
2506  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
2507  << std::endl;
2508  }
2509 
2510  // get the logical expression
2511  std::string logExpression = algorithm.getExpressionInCondition();
2512 
2513  LogDebug("TriggerMenuParser")
2514  << " Logical expression: " << logExpression
2515  << " Chip number: " << chipNr
2516  << std::endl;
2517 
2518  // determine output pin
2519  int outputPin = algorithm.getIndex();
2520 
2521 
2522  //LogTrace("TriggerMenuParser")
2523  LogDebug("TriggerMenuParser") << " Output pin: " << outputPin
2524  << std::endl;
2525 
2526 
2527  // compute the bit number from chip number, output pin and order of the chips
2528  // pin numbering start with 1, bit numbers with 0
2529  int bitNumber = outputPin;// + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
2530 
2531  //LogTrace("TriggerMenuParser")
2532  LogDebug("TriggerMenuParser") << " Bit number: " << bitNumber
2533  << std::endl;
2534 
2535  // create a new algorithm and insert it into algorithm map
2536  L1GtAlgorithm alg(algName, logExpression, bitNumber);
2537  alg.setAlgoChipNumber(static_cast<int>(chipNr));
2538  alg.setAlgoAlias(algAlias);
2539 
2540  if (edm::isDebugEnabled() ) {
2541 
2542  std::ostringstream myCoutStream;
2543  alg.print(myCoutStream);
2544  LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2545 
2546  }
2547 
2548  // insert algorithm into the map
2549  if ( !insertAlgorithmIntoMap(alg)) {
2550  return false;
2551  }
2552 
2553  return true;
2554 
2555 }
2556 
2557 
2558 // static class members
2559 
#define LogDebug(id)
void setGtTriggerMenuName(const std::string &)
type
Definition: HCALResponse.h:21
bool isDebugEnabled()
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< double, double > > phiBins
void setGtScaleDbKey(const std::string &)
GtConditionType
Definition: GtDefinitions.h:99
void setGtOrderConditionChip(const std::vector< int > &)
Definition: L1GtObject.h:39
std::string l1tDateTime2string(l1t::DateTime)
void setCond0Index(const int &)
void setAlgoAlias(const std::string &algoAliasValue)
Definition: L1GtAlgorithm.h:72
virtual void print(std::ostream &myCout) const
print the condition
Definition: MuonTemplate.cc:98
Definition: L1GtObject.h:36
virtual void print(std::ostream &myCout) const
print condition
void setCondType(const l1t::GtConditionType &cType)
Definition: GtCondition.h:84
void setCorrelationParameter(const CorrelationParameter &corrParameter)
const std::string algoName() const
get / set algorithm name
Definition: L1GtAlgorithm.h:56
void setGtAlgorithmMap(const AlgorithmMap &)
void setCondGEq(const bool &cGEq)
Definition: GtCondition.h:106
void setVecCaloTemplate(const std::vector< std::vector< CaloTemplate > > &)
bool parseExternal(tmeventsetup::esCondition condExt, unsigned int chipNr=0)
virtual ~TriggerMenuParser()
destructor
bool insertConditionIntoMap(GtCondition &cond, const int chipNr)
virtual void print(std::ostream &myCout) const
print the condition
int ii
Definition: cuy.py:588
virtual void print(std::ostream &myCout) const
print the condition
std::string const & algoAlias() const
get / set algorithm alias
Definition: L1GtAlgorithm.h:67
void setVecEnergySumTemplate(const std::vector< std::vector< EnergySumTemplate > > &)
void setVecCorrelationTemplate(const std::vector< std::vector< CorrelationTemplate > > &)
void setAlgoChipNumber(const int algoChipNumberValue)
Definition: L1GtObject.h:38
void setVecMuonTemplate(const std::vector< std::vector< MuonTemplate > > &)
std::vector< std::pair< double, double > > etBins
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)
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 setGtTriggerMenuInterface(const std::string &)
void setCond1Category(const l1t::GtConditionCategory &)
void setGtTriggerMenuAuthor(const std::string &)
void setConditionParameter(const std::vector< ObjectParameter > &objParameter, const CorrelationParameter &corrParameter)
set functions
Definition: CaloTemplate.cc:87
int algoBitNumber() const
get / set algorithm bit number
Definition: L1GtAlgorithm.h:94
void setGtTriggerMenuInterfaceDescription(const std::string &)
#define LogTrace(id)
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
void setGtTriggerMenuDate(const std::string &)
bool parseScales(std::map< std::string, tmeventsetup::esScale > scaleMap)
parse scales
void setVecExternalTemplate(const std::vector< std::vector< ExternalTemplate > > &)
bool parseCaloCorr(const tmeventsetup::esObject *corrCalo, unsigned int chipNr=0)
typedef for a single object template
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 > > &)
const std::string & condName() const
get / set condition name
Definition: GtCondition.h:57
void setCorEnergySumTemplate(const std::vector< std::vector< EnergySumTemplate > > &)
Definition: L1GtObject.h:30
bool parseMuon(tmeventsetup::esCondition condMu, unsigned int chipNr=0, const bool corrFlag=false)
parse a muon condition
int l1t2int(l1t::RelativeBx)
void setCond0Category(const l1t::GtConditionCategory &)
void setGtNumberConditionChips(const unsigned int &)
void setGtTriggerMenuImplementation(const std::string &)
bool parseEnergySumCorr(const tmeventsetup::esObject *corrESum, unsigned int chipNr=0)
bool parseAlgorithm(tmeventsetup::esAlgorithm algorithm, unsigned int chipNr=0)
parse all algorithms
void setCondChipNr(const int &cChipNr)
Definition: GtCondition.h:117
int l1tstr2int(const std::string data)
bool insertAlgorithmIntoMap(const L1GtAlgorithm &alg)
insert an algorithm into algorithm map
void setConditionParameter(const std::vector< ObjectParameter > &objParameter, const CorrelationParameter &corrParameter)
set functions
Definition: MuonTemplate.cc:88
Definition: L1GtObject.h:37
typedef for correlation parameters
Definition: CaloTemplate.h:81
void setObjectType(const std::vector< L1GtObject > &objType)
Definition: GtCondition.h:95
const int algoChipNumber() const
get / set algorithm bit number
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 > > &)
std::vector< std::pair< double, double > > etaBins
bool parseMuonCorr(const tmeventsetup::esObject *condMu, unsigned int chipNr=0)
void setCondRelativeBx(const int &cRelativeBx)
Definition: GtCondition.h:128
void setGtTriggerMenuInterfaceDate(const std::string &)
tuple cout
Definition: gather_cfg.py:145
typedef for correlation parameters
virtual void print(std::ostream &myCout) const
print the condition
Definition: CaloTemplate.cc:97
long double T
void setGtConditionMap(const std::vector< ConditionMap > &)
tuple size
Write out results.
void setConditionParameter(const std::vector< ObjectParameter > &)
set functions
void setGtTriggerMenuInterfaceAuthor(const std::string &)
void setCond1Index(const int &)
void setGtNumberPhysTriggers(const unsigned int &)