File indexing completed on 2022-12-03 01:10:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #include "TriggerMenuParser.h"
0031
0032
0033 #include <string>
0034 #include <vector>
0035
0036 #include <iostream>
0037 #include <fstream>
0038 #include <iomanip>
0039 #include <cmath>
0040
0041 #include "L1Trigger/L1TGlobal/interface/GlobalCondition.h"
0042
0043 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0044 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0045
0046 #include "tmEventSetup/tmEventSetup.hh"
0047 #include "tmEventSetup/esTriggerMenu.hh"
0048 #include "tmEventSetup/esAlgorithm.hh"
0049 #include "tmEventSetup/esCondition.hh"
0050 #include "tmEventSetup/esObject.hh"
0051 #include "tmEventSetup/esCut.hh"
0052 #include "tmEventSetup/esScale.hh"
0053 #include "tmGrammar/Algorithm.hh"
0054 #include <cstdint>
0055
0056
0057 l1t::TriggerMenuParser::TriggerMenuParser()
0058 : m_triggerMenuInterface("NULL"),
0059 m_triggerMenuName("NULL"),
0060 m_triggerMenuImplementation(0x0),
0061 m_scaleDbKey("NULL")
0062
0063 {
0064
0065
0066
0067 }
0068
0069
0070 l1t::TriggerMenuParser::~TriggerMenuParser() { clearMaps(); }
0071
0072
0073 void l1t::TriggerMenuParser::setGtNumberConditionChips(const unsigned int& numberConditionChipsValue) {
0074 m_numberConditionChips = numberConditionChipsValue;
0075 }
0076
0077
0078 void l1t::TriggerMenuParser::setGtPinsOnConditionChip(const unsigned int& pinsOnConditionChipValue) {
0079 m_pinsOnConditionChip = pinsOnConditionChipValue;
0080 }
0081
0082
0083
0084 void l1t::TriggerMenuParser::setGtOrderConditionChip(const std::vector<int>& orderConditionChipValue) {
0085 m_orderConditionChip = orderConditionChipValue;
0086 }
0087
0088
0089 void l1t::TriggerMenuParser::setGtNumberPhysTriggers(const unsigned int& numberPhysTriggersValue) {
0090 m_numberPhysTriggers = numberPhysTriggersValue;
0091 }
0092
0093
0094 void l1t::TriggerMenuParser::setGtConditionMap(const std::vector<ConditionMap>& condMap) { m_conditionMap = condMap; }
0095
0096
0097 void l1t::TriggerMenuParser::setGtTriggerMenuInterface(const std::string& menuInterface) {
0098 m_triggerMenuInterface = menuInterface;
0099 }
0100
0101
0102 void l1t::TriggerMenuParser::setGtTriggerMenuUUID(const int uuid) { m_triggerMenuUUID = uuid; }
0103
0104 void l1t::TriggerMenuParser::setGtTriggerMenuName(const std::string& menuName) { m_triggerMenuName = menuName; }
0105
0106 void l1t::TriggerMenuParser::setGtTriggerMenuImplementation(const unsigned long& menuImplementation) {
0107 m_triggerMenuImplementation = menuImplementation;
0108 }
0109
0110
0111 void l1t::TriggerMenuParser::setGtScaleDbKey(const std::string& scaleKey) { m_scaleDbKey = scaleKey; }
0112
0113
0114 void l1t::TriggerMenuParser::setVecMuonTemplate(const std::vector<std::vector<MuonTemplate> >& vecMuonTempl) {
0115 m_vecMuonTemplate = vecMuonTempl;
0116 }
0117
0118 void l1t::TriggerMenuParser::setVecMuonShowerTemplate(
0119 const std::vector<std::vector<MuonShowerTemplate> >& vecMuonShowerTempl) {
0120 m_vecMuonShowerTemplate = vecMuonShowerTempl;
0121 }
0122
0123 void l1t::TriggerMenuParser::setVecCaloTemplate(const std::vector<std::vector<CaloTemplate> >& vecCaloTempl) {
0124 m_vecCaloTemplate = vecCaloTempl;
0125 }
0126
0127 void l1t::TriggerMenuParser::setVecEnergySumTemplate(
0128 const std::vector<std::vector<EnergySumTemplate> >& vecEnergySumTempl) {
0129 m_vecEnergySumTemplate = vecEnergySumTempl;
0130 }
0131
0132 void l1t::TriggerMenuParser::setVecExternalTemplate(
0133 const std::vector<std::vector<ExternalTemplate> >& vecExternalTempl) {
0134 m_vecExternalTemplate = vecExternalTempl;
0135 }
0136
0137 void l1t::TriggerMenuParser::setVecCorrelationTemplate(
0138 const std::vector<std::vector<CorrelationTemplate> >& vecCorrelationTempl) {
0139 m_vecCorrelationTemplate = vecCorrelationTempl;
0140 }
0141
0142 void l1t::TriggerMenuParser::setVecCorrelationThreeBodyTemplate(
0143 const std::vector<std::vector<CorrelationThreeBodyTemplate> >& vecCorrelationThreeBodyTempl) {
0144 m_vecCorrelationThreeBodyTemplate = vecCorrelationThreeBodyTempl;
0145 }
0146
0147 void l1t::TriggerMenuParser::setVecCorrelationWithOverlapRemovalTemplate(
0148 const std::vector<std::vector<CorrelationWithOverlapRemovalTemplate> >& vecCorrelationWithOverlapRemovalTempl) {
0149 m_vecCorrelationWithOverlapRemovalTemplate = vecCorrelationWithOverlapRemovalTempl;
0150 }
0151
0152
0153
0154 void l1t::TriggerMenuParser::setCorMuonTemplate(const std::vector<std::vector<MuonTemplate> >& corMuonTempl) {
0155 m_corMuonTemplate = corMuonTempl;
0156 }
0157
0158 void l1t::TriggerMenuParser::setCorCaloTemplate(const std::vector<std::vector<CaloTemplate> >& corCaloTempl) {
0159 m_corCaloTemplate = corCaloTempl;
0160 }
0161
0162 void l1t::TriggerMenuParser::setCorEnergySumTemplate(
0163 const std::vector<std::vector<EnergySumTemplate> >& corEnergySumTempl) {
0164 m_corEnergySumTemplate = corEnergySumTempl;
0165 }
0166
0167
0168 void l1t::TriggerMenuParser::setGtAlgorithmMap(const AlgorithmMap& algoMap) { m_algorithmMap = algoMap; }
0169
0170
0171 void l1t::TriggerMenuParser::setGtAlgorithmAliasMap(const AlgorithmMap& algoMap) { m_algorithmAliasMap = algoMap; }
0172
0173 std::map<std::string, unsigned int> l1t::TriggerMenuParser::getExternalSignals(const L1TUtmTriggerMenu* utmMenu) {
0174 using namespace tmeventsetup;
0175 const esTriggerMenu* menu = reinterpret_cast<const esTriggerMenu*>(utmMenu);
0176 const std::map<std::string, esCondition>& condMap = menu->getConditionMap();
0177
0178 std::map<std::string, unsigned int> extBitMap;
0179
0180
0181 for (std::map<std::string, esCondition>::const_iterator cit = condMap.begin(); cit != condMap.end(); cit++) {
0182 const esCondition& condition = cit->second;
0183 if (condition.getType() == esConditionType::Externals) {
0184
0185 const std::vector<esObject>& objects = condition.getObjects();
0186 for (size_t jj = 0; jj < objects.size(); jj++) {
0187 const esObject object = objects.at(jj);
0188 if (object.getType() == esObjectType::EXT) {
0189 unsigned int channelID = object.getExternalChannelId();
0190 std::string name = object.getExternalSignalName();
0191
0192 if (extBitMap.count(name) == 0)
0193 extBitMap.insert(std::map<std::string, unsigned int>::value_type(name, channelID));
0194 }
0195 }
0196 }
0197 }
0198
0199
0200
0201
0202
0203
0204 return extBitMap;
0205 }
0206
0207
0208 void l1t::TriggerMenuParser::parseCondFormats(const L1TUtmTriggerMenu* utmMenu) {
0209
0210
0211 m_conditionMap.resize(m_numberConditionChips);
0212
0213 m_vecMuonTemplate.resize(m_numberConditionChips);
0214 m_vecMuonShowerTemplate.resize(m_numberConditionChips);
0215 m_vecCaloTemplate.resize(m_numberConditionChips);
0216 m_vecEnergySumTemplate.resize(m_numberConditionChips);
0217 m_vecExternalTemplate.resize(m_numberConditionChips);
0218
0219 m_vecCorrelationTemplate.resize(m_numberConditionChips);
0220 m_vecCorrelationThreeBodyTemplate.resize(m_numberConditionChips);
0221 m_vecCorrelationWithOverlapRemovalTemplate.resize(m_numberConditionChips);
0222 m_corMuonTemplate.resize(m_numberConditionChips);
0223 m_corCaloTemplate.resize(m_numberConditionChips);
0224 m_corEnergySumTemplate.resize(m_numberConditionChips);
0225
0226 using namespace tmeventsetup;
0227 using namespace Algorithm;
0228
0229 const esTriggerMenu* menu = reinterpret_cast<const esTriggerMenu*>(utmMenu);
0230
0231
0232 m_triggerMenuDescription = menu->getComment();
0233 m_triggerMenuDate = menu->getDatetime();
0234 m_triggerMenuImplementation = (getMmHashN(menu->getFirmwareUuid()) & 0xFFFFFFFF);
0235 m_triggerMenuName = menu->getName();
0236 m_triggerMenuInterface = menu->getVersion();
0237 m_triggerMenuUUID = (getMmHashN(menu->getName()) & 0xFFFFFFFF);
0238
0239 const std::map<std::string, esAlgorithm>& algoMap = menu->getAlgorithmMap();
0240 const std::map<std::string, esCondition>& condMap = menu->getConditionMap();
0241 const std::map<std::string, esScale>& scaleMap = menu->getScaleMap();
0242
0243
0244 m_gtScales.setScalesName(menu->getScaleSetName());
0245 parseScales(scaleMap);
0246
0247
0248 for (std::map<std::string, esAlgorithm>::const_iterator cit = algoMap.begin(); cit != algoMap.end(); cit++) {
0249
0250 int chipNr = 0;
0251
0252
0253 const esAlgorithm& algo = cit->second;
0254
0255
0256 parseAlgorithm(algo, chipNr);
0257
0258
0259 const std::vector<std::string>& rpn_vec = algo.getRpnVector();
0260 for (size_t ii = 0; ii < rpn_vec.size(); ii++) {
0261 const std::string& token = rpn_vec.at(ii);
0262 if (isGate(token))
0263 continue;
0264
0265 const esCondition& condition = condMap.find(token)->second;
0266
0267
0268 if ((m_conditionMap[chipNr]).count(condition.getName()) == 0) {
0269
0270 if (condition.getType() == esConditionType::SingleEgamma ||
0271 condition.getType() == esConditionType::DoubleEgamma ||
0272 condition.getType() == esConditionType::TripleEgamma ||
0273 condition.getType() == esConditionType::QuadEgamma || condition.getType() == esConditionType::SingleTau ||
0274 condition.getType() == esConditionType::DoubleTau || condition.getType() == esConditionType::TripleTau ||
0275 condition.getType() == esConditionType::QuadTau || condition.getType() == esConditionType::SingleJet ||
0276 condition.getType() == esConditionType::DoubleJet || condition.getType() == esConditionType::TripleJet ||
0277 condition.getType() == esConditionType::QuadJet) {
0278 parseCalo(condition, chipNr, false);
0279
0280
0281 } else if (condition.getType() == esConditionType::TotalEt ||
0282 condition.getType() == esConditionType::TotalEtEM ||
0283 condition.getType() == esConditionType::TotalHt ||
0284 condition.getType() == esConditionType::MissingEt ||
0285 condition.getType() == esConditionType::MissingHt ||
0286 condition.getType() == esConditionType::MissingEtHF ||
0287 condition.getType() == esConditionType::TowerCount ||
0288 condition.getType() == esConditionType::MinBiasHFP0 ||
0289 condition.getType() == esConditionType::MinBiasHFM0 ||
0290 condition.getType() == esConditionType::MinBiasHFP1 ||
0291 condition.getType() == esConditionType::MinBiasHFM1 ||
0292 condition.getType() == esConditionType::AsymmetryEt ||
0293 condition.getType() == esConditionType::AsymmetryHt ||
0294 condition.getType() == esConditionType::AsymmetryEtHF ||
0295 condition.getType() == esConditionType::AsymmetryHtHF ||
0296 condition.getType() == esConditionType::Centrality0 ||
0297 condition.getType() == esConditionType::Centrality1 ||
0298 condition.getType() == esConditionType::Centrality2 ||
0299 condition.getType() == esConditionType::Centrality3 ||
0300 condition.getType() == esConditionType::Centrality4 ||
0301 condition.getType() == esConditionType::Centrality5 ||
0302 condition.getType() == esConditionType::Centrality6 ||
0303 condition.getType() == esConditionType::Centrality7) {
0304 parseEnergySum(condition, chipNr, false);
0305
0306
0307 } else if (condition.getType() == esConditionType::SingleMuon ||
0308 condition.getType() == esConditionType::DoubleMuon ||
0309 condition.getType() == esConditionType::TripleMuon ||
0310 condition.getType() == esConditionType::QuadMuon) {
0311 parseMuon(condition, chipNr, false);
0312
0313 } else if (condition.getType() == esConditionType::MuonShower0 ||
0314 condition.getType() == esConditionType::MuonShower1 ||
0315 condition.getType() == esConditionType::MuonShowerOutOfTime0 ||
0316 condition.getType() == esConditionType::MuonShowerOutOfTime1) {
0317 parseMuonShower(condition, chipNr, false);
0318
0319
0320 } else if (condition.getType() == esConditionType::MuonMuonCorrelation ||
0321 condition.getType() == esConditionType::MuonEsumCorrelation ||
0322 condition.getType() == esConditionType::CaloMuonCorrelation ||
0323 condition.getType() == esConditionType::CaloCaloCorrelation ||
0324 condition.getType() == esConditionType::CaloEsumCorrelation ||
0325 condition.getType() == esConditionType::InvariantMass ||
0326 condition.getType() == esConditionType::InvariantMassDeltaR ||
0327 condition.getType() == esConditionType::TransverseMass ||
0328 condition.getType() == esConditionType::InvariantMassUpt) {
0329 parseCorrelation(condition, chipNr);
0330
0331
0332 } else if (condition.getType() == esConditionType::InvariantMass3) {
0333 parseCorrelationThreeBody(condition, chipNr);
0334
0335
0336 } else if (condition.getType() == esConditionType::Externals) {
0337 parseExternal(condition, chipNr);
0338
0339
0340 } else if (condition.getType() == esConditionType::CaloCaloCorrelationOvRm ||
0341 condition.getType() == esConditionType::InvariantMassOvRm ||
0342 condition.getType() == esConditionType::TransverseMassOvRm ||
0343 condition.getType() == esConditionType::DoubleJetOvRm ||
0344 condition.getType() == esConditionType::DoubleTauOvRm) {
0345 parseCorrelationWithOverlapRemoval(condition, chipNr);
0346
0347 } else if (condition.getType() == esConditionType::SingleEgammaOvRm ||
0348 condition.getType() == esConditionType::DoubleEgammaOvRm ||
0349 condition.getType() == esConditionType::TripleEgammaOvRm ||
0350 condition.getType() == esConditionType::QuadEgammaOvRm ||
0351 condition.getType() == esConditionType::SingleTauOvRm ||
0352 condition.getType() == esConditionType::TripleTauOvRm ||
0353 condition.getType() == esConditionType::QuadTauOvRm ||
0354 condition.getType() == esConditionType::SingleJetOvRm ||
0355 condition.getType() == esConditionType::TripleJetOvRm ||
0356 condition.getType() == esConditionType::QuadJetOvRm) {
0357 edm::LogError("TriggerMenuParser") << std::endl
0358 << "\n SingleEgammaOvRm"
0359 << "\n DoubleEgammaOvRm"
0360 << "\n TripleEgammaOvRm"
0361 << "\n QuadEgammaOvRm"
0362 << "\n SingleTauOvRm"
0363 << "\n TripleTauOvRm"
0364 << "\n QuadTauOvRm"
0365 << "\n SingleJetOvRm"
0366 << "\n TripleJetOvRm"
0367 << "\n QuadJetOvRm"
0368 << "\n The above conditions types OvRm are not implemented yet in the "
0369 "parser. Please remove alogrithms that "
0370 "use this type of condtion from L1T Menu!"
0371 << std::endl;
0372 }
0373
0374 }
0375 }
0376 }
0377
0378 return;
0379 }
0380
0381
0382
0383 void l1t::TriggerMenuParser::setGtTriggerMenuInterfaceDate(const std::string& val) { m_triggerMenuInterfaceDate = val; }
0384
0385 void l1t::TriggerMenuParser::setGtTriggerMenuInterfaceAuthor(const std::string& val) {
0386 m_triggerMenuInterfaceAuthor = val;
0387 }
0388
0389 void l1t::TriggerMenuParser::setGtTriggerMenuInterfaceDescription(const std::string& val) {
0390 m_triggerMenuInterfaceDescription = val;
0391 }
0392
0393 void l1t::TriggerMenuParser::setGtTriggerMenuDate(const std::string& val) { m_triggerMenuDate = val; }
0394
0395 void l1t::TriggerMenuParser::setGtTriggerMenuAuthor(const std::string& val) { m_triggerMenuAuthor = val; }
0396
0397 void l1t::TriggerMenuParser::setGtTriggerMenuDescription(const std::string& val) { m_triggerMenuDescription = val; }
0398
0399 void l1t::TriggerMenuParser::setGtAlgorithmImplementation(const std::string& val) { m_algorithmImplementation = val; }
0400
0401
0402
0403
0404
0405 void l1t::TriggerMenuParser::clearMaps() {
0406
0407
0408 for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip != m_conditionMap.end();
0409 itCondOnChip++) {
0410
0411
0412 itCondOnChip->clear();
0413 }
0414
0415
0416 m_algorithmMap.clear();
0417 }
0418
0419
0420
0421 bool l1t::TriggerMenuParser::insertConditionIntoMap(GlobalCondition& cond, const int chipNr) {
0422 std::string cName = cond.condName();
0423 LogTrace("TriggerMenuParser") << " Trying to insert condition \"" << cName << "\" in the condition map."
0424 << std::endl;
0425
0426
0427 if ((m_conditionMap[chipNr]).count(cName) != 0) {
0428 LogTrace("TriggerMenuParser") << " Condition " << cName << " already exists - not inserted!" << std::endl;
0429 return false;
0430 }
0431
0432 (m_conditionMap[chipNr])[cName] = &cond;
0433 LogTrace("TriggerMenuParser") << " OK - condition inserted!" << std::endl;
0434
0435 return true;
0436 }
0437
0438
0439 bool l1t::TriggerMenuParser::insertAlgorithmIntoMap(const GlobalAlgorithm& alg) {
0440 std::string algName = alg.algoName();
0441 const std::string& algAlias = alg.algoAlias();
0442
0443
0444
0445
0446 if (m_algorithmMap.count(algName) != 0) {
0447 LogTrace("TriggerMenuParser") << " Algorithm \"" << algName
0448 << "\"already exists in the algorithm map- not inserted!" << std::endl;
0449 return false;
0450 }
0451
0452 if (m_algorithmAliasMap.count(algAlias) != 0) {
0453 LogTrace("TriggerMenuParser") << " Algorithm alias \"" << algAlias
0454 << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
0455 return false;
0456 }
0457
0458
0459 int bitNumber = alg.algoBitNumber();
0460 if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
0461 LogTrace("TriggerMenuParser") << " Bit number " << bitNumber << " outside allowed range [0, "
0462 << m_numberPhysTriggers << ") - algorithm not inserted!" << std::endl;
0463 return false;
0464 }
0465
0466
0467 if (m_algorithmMap.size() >= m_numberPhysTriggers) {
0468 LogTrace("TriggerMenuParser") << " More than maximum allowed " << m_numberPhysTriggers
0469 << " algorithms in the algorithm map - not inserted!" << std::endl;
0470 return false;
0471 }
0472
0473
0474 int chipNr = alg.algoChipNumber(
0475 static_cast<int>(m_numberConditionChips), static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
0476
0477 if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
0478 LogTrace("TriggerMenuParser") << " Chip number " << chipNr << " outside allowed range [0, "
0479 << m_numberConditionChips << ") - algorithm not inserted!" << std::endl;
0480 return false;
0481 }
0482
0483
0484 int outputPin = alg.algoOutputPin(
0485 static_cast<int>(m_numberConditionChips), static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
0486
0487 if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
0488 LogTrace("TriggerMenuParser") << " Output pin " << outputPin << " outside allowed range [0, "
0489 << m_pinsOnConditionChip << "] - algorithm not inserted!" << std::endl;
0490 return false;
0491 }
0492
0493
0494 for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
0495 int iPin = (itAlgo->second)
0496 .algoOutputPin(static_cast<int>(m_numberConditionChips),
0497 static_cast<int>(m_pinsOnConditionChip),
0498 m_orderConditionChip);
0499 std::string iName = itAlgo->first;
0500 int iChip = (itAlgo->second)
0501 .algoChipNumber(static_cast<int>(m_numberConditionChips),
0502 static_cast<int>(m_pinsOnConditionChip),
0503 m_orderConditionChip);
0504
0505 if ((outputPin == iPin) && (chipNr == iChip)) {
0506 LogTrace("TriggerMenuParser") << " Output pin " << outputPin << " is the same as for algorithm " << iName
0507 << "\n from the same chip number " << chipNr << " - algorithm not inserted!"
0508 << std::endl;
0509 return false;
0510 }
0511 }
0512
0513
0514 m_algorithmMap[algName] = alg;
0515 m_algorithmAliasMap[algAlias] = alg;
0516
0517
0518
0519
0520
0521 return true;
0522 }
0523
0524 template <typename T>
0525 std::string l1t::TriggerMenuParser::l1t2string(T data) {
0526 std::stringstream ss;
0527 ss << data;
0528 return ss.str();
0529 }
0530 int l1t::TriggerMenuParser::l1tstr2int(const std::string data) {
0531 std::stringstream ss;
0532 ss << data;
0533 int value;
0534 ss >> value;
0535 return value;
0536 }
0537
0538
0539
0540
0541
0542
0543
0544
0545 bool l1t::TriggerMenuParser::parseScales(std::map<std::string, tmeventsetup::esScale> scaleMap) {
0546 using namespace tmeventsetup;
0547
0548
0549 GlobalScales::ScaleParameters muScales;
0550 GlobalScales::ScaleParameters egScales;
0551 GlobalScales::ScaleParameters tauScales;
0552 GlobalScales::ScaleParameters jetScales;
0553 GlobalScales::ScaleParameters ettScales;
0554 GlobalScales::ScaleParameters ettEmScales;
0555 GlobalScales::ScaleParameters etmScales;
0556 GlobalScales::ScaleParameters etmHfScales;
0557 GlobalScales::ScaleParameters httScales;
0558 GlobalScales::ScaleParameters htmScales;
0559
0560
0561 for (std::map<std::string, esScale>::const_iterator cit = scaleMap.begin(); cit != scaleMap.end(); cit++) {
0562 const esScale& scale = cit->second;
0563
0564 GlobalScales::ScaleParameters* scaleParam;
0565 if (scale.getObjectType() == esObjectType::Muon)
0566 scaleParam = &muScales;
0567 else if (scale.getObjectType() == esObjectType::Egamma)
0568 scaleParam = &egScales;
0569 else if (scale.getObjectType() == esObjectType::Tau)
0570 scaleParam = &tauScales;
0571 else if (scale.getObjectType() == esObjectType::Jet)
0572 scaleParam = &jetScales;
0573 else if (scale.getObjectType() == esObjectType::ETT)
0574 scaleParam = &ettScales;
0575 else if (scale.getObjectType() == esObjectType::ETTEM)
0576 scaleParam = &ettEmScales;
0577 else if (scale.getObjectType() == esObjectType::ETM)
0578 scaleParam = &etmScales;
0579 else if (scale.getObjectType() == esObjectType::ETMHF)
0580 scaleParam = &etmHfScales;
0581 else if (scale.getObjectType() == esObjectType::HTT)
0582 scaleParam = &httScales;
0583 else if (scale.getObjectType() == esObjectType::HTM)
0584 scaleParam = &htmScales;
0585 else
0586 scaleParam = nullptr;
0587
0588 if (scaleParam != nullptr) {
0589 switch (scale.getScaleType()) {
0590 case esScaleType::EtScale: {
0591 scaleParam->etMin = scale.getMinimum();
0592 scaleParam->etMax = scale.getMaximum();
0593 scaleParam->etStep = scale.getStep();
0594
0595
0596 const std::vector<esBin>& binsV = scale.getBins();
0597 for (unsigned int i = 0; i < binsV.size(); i++) {
0598 const esBin& bin = binsV.at(i);
0599 std::pair<double, double> binLimits(bin.minimum, bin.maximum);
0600 scaleParam->etBins.push_back(binLimits);
0601 }
0602
0603
0604
0605 if (scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT ||
0606 scale.getObjectType() == esObjectType::ETM || scale.getObjectType() == esObjectType::HTM ||
0607 scale.getObjectType() == esObjectType::ETTEM || scale.getObjectType() == esObjectType::ETMHF) {
0608 scaleParam->etaMin = -1.;
0609 scaleParam->etaMax = -1.;
0610 scaleParam->etaStep = -1.;
0611 if (scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT ||
0612 scale.getObjectType() == esObjectType::ETTEM) {
0613
0614 scaleParam->phiMin = -1.;
0615 scaleParam->phiMax = -1.;
0616 scaleParam->phiStep = -1.;
0617 }
0618 }
0619 } break;
0620 case esScaleType::UnconstrainedPtScale: {
0621 scaleParam->uptMin = scale.getMinimum();
0622 scaleParam->uptMax = scale.getMaximum();
0623 scaleParam->uptStep = scale.getStep();
0624
0625
0626 const std::vector<esBin>& binsV = scale.getBins();
0627 for (unsigned int i = 0; i < binsV.size(); i++) {
0628 const esBin& bin = binsV.at(i);
0629 std::pair<double, double> binLimits(bin.minimum, bin.maximum);
0630 scaleParam->uptBins.push_back(binLimits);
0631 }
0632 } break;
0633 case esScaleType::EtaScale: {
0634 scaleParam->etaMin = scale.getMinimum();
0635 scaleParam->etaMax = scale.getMaximum();
0636 scaleParam->etaStep = scale.getStep();
0637
0638
0639 const std::vector<esBin>& binsV = scale.getBins();
0640 scaleParam->etaBins.resize(pow(2, scale.getNbits()));
0641 for (unsigned int i = 0; i < binsV.size(); i++) {
0642 const esBin& bin = binsV.at(i);
0643 std::pair<double, double> binLimits(bin.minimum, bin.maximum);
0644 scaleParam->etaBins.at(bin.hw_index) = binLimits;
0645 }
0646 } break;
0647 case esScaleType::PhiScale: {
0648 scaleParam->phiMin = scale.getMinimum();
0649 scaleParam->phiMax = scale.getMaximum();
0650 scaleParam->phiStep = scale.getStep();
0651
0652
0653 const std::vector<esBin>& binsV = scale.getBins();
0654 scaleParam->phiBins.resize(pow(2, scale.getNbits()));
0655 for (unsigned int i = 0; i < binsV.size(); i++) {
0656 const esBin& bin = binsV.at(i);
0657 std::pair<double, double> binLimits(bin.minimum, bin.maximum);
0658 scaleParam->phiBins.at(bin.hw_index) = binLimits;
0659 }
0660 } break;
0661 default:
0662
0663 break;
0664 }
0665 }
0666 }
0667
0668
0669 m_gtScales.setMuonScales(muScales);
0670 m_gtScales.setEGScales(egScales);
0671 m_gtScales.setTauScales(tauScales);
0672 m_gtScales.setJetScales(jetScales);
0673 m_gtScales.setETTScales(ettScales);
0674 m_gtScales.setETTEmScales(ettEmScales);
0675 m_gtScales.setETMScales(etmScales);
0676 m_gtScales.setETMHfScales(etmHfScales);
0677 m_gtScales.setHTTScales(httScales);
0678 m_gtScales.setHTMScales(htmScales);
0679
0680
0681 bool hasPrecision = false;
0682 std::map<std::string, unsigned int> precisions;
0683 getPrecisions(precisions, scaleMap);
0684 for (std::map<std::string, unsigned int>::const_iterator cit = precisions.begin(); cit != precisions.end(); cit++) {
0685 hasPrecision = true;
0686 }
0687
0688 if (hasPrecision) {
0689
0690
0691 parseCalMuEta_LUTS(scaleMap, "EG", "MU");
0692 parseCalMuEta_LUTS(scaleMap, "JET", "MU");
0693 parseCalMuEta_LUTS(scaleMap, "TAU", "MU");
0694
0695
0696
0697 parseCalMuPhi_LUTS(scaleMap, "EG", "MU");
0698 parseCalMuPhi_LUTS(scaleMap, "JET", "MU");
0699 parseCalMuPhi_LUTS(scaleMap, "TAU", "MU");
0700 parseCalMuPhi_LUTS(scaleMap, "HTM", "MU");
0701 parseCalMuPhi_LUTS(scaleMap, "ETM", "MU");
0702 parseCalMuPhi_LUTS(scaleMap, "ETMHF", "MU");
0703
0704
0705
0706 parsePt_LUTS(scaleMap, "Mass", "EG", precisions["PRECISION-EG-MU-MassPt"]);
0707 parsePt_LUTS(scaleMap, "Mass", "MU", precisions["PRECISION-EG-MU-MassPt"]);
0708 parseUpt_LUTS(scaleMap, "Mass", "MU", precisions["PRECISION-EG-MU-MassPt"]);
0709 parsePt_LUTS(scaleMap, "Mass", "JET", precisions["PRECISION-EG-JET-MassPt"]);
0710 parsePt_LUTS(scaleMap, "Mass", "TAU", precisions["PRECISION-EG-TAU-MassPt"]);
0711 parsePt_LUTS(scaleMap, "Mass", "ETM", precisions["PRECISION-EG-ETM-MassPt"]);
0712 parsePt_LUTS(scaleMap, "Mass", "ETMHF", precisions["PRECISION-EG-ETMHF-MassPt"]);
0713 parsePt_LUTS(scaleMap, "Mass", "HTM", precisions["PRECISION-EG-HTM-MassPt"]);
0714
0715
0716
0717 parsePt_LUTS(scaleMap, "TwoBody", "EG", precisions["PRECISION-EG-MU-TwoBodyPt"]);
0718 parsePt_LUTS(scaleMap, "TwoBody", "MU", precisions["PRECISION-EG-MU-TwoBodyPt"]);
0719 parsePt_LUTS(scaleMap, "TwoBody", "JET", precisions["PRECISION-EG-JET-TwoBodyPt"]);
0720 parsePt_LUTS(scaleMap, "TwoBody", "TAU", precisions["PRECISION-EG-TAU-TwoBodyPt"]);
0721 parsePt_LUTS(scaleMap, "TwoBody", "ETM", precisions["PRECISION-EG-ETM-TwoBodyPt"]);
0722 parsePt_LUTS(scaleMap, "TwoBody", "ETMHF", precisions["PRECISION-EG-ETMHF-TwoBodyPt"]);
0723 parsePt_LUTS(scaleMap, "TwoBody", "HTM", precisions["PRECISION-EG-HTM-TwoBodyPt"]);
0724
0725
0726
0727 parseDeltaEta_Cosh_LUTS(
0728 scaleMap, "EG", "EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
0729 parseDeltaEta_Cosh_LUTS(
0730 scaleMap, "EG", "JET", precisions["PRECISION-EG-JET-Delta"], precisions["PRECISION-EG-JET-Math"]);
0731 parseDeltaEta_Cosh_LUTS(
0732 scaleMap, "EG", "TAU", precisions["PRECISION-EG-TAU-Delta"], precisions["PRECISION-EG-TAU-Math"]);
0733 parseDeltaEta_Cosh_LUTS(
0734 scaleMap, "EG", "MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
0735
0736 parseDeltaEta_Cosh_LUTS(
0737 scaleMap, "JET", "JET", precisions["PRECISION-JET-JET-Delta"], precisions["PRECISION-JET-JET-Math"]);
0738 parseDeltaEta_Cosh_LUTS(
0739 scaleMap, "JET", "TAU", precisions["PRECISION-JET-TAU-Delta"], precisions["PRECISION-JET-TAU-Math"]);
0740 parseDeltaEta_Cosh_LUTS(
0741 scaleMap, "JET", "MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
0742
0743 parseDeltaEta_Cosh_LUTS(
0744 scaleMap, "TAU", "TAU", precisions["PRECISION-TAU-TAU-Delta"], precisions["PRECISION-TAU-TAU-Math"]);
0745 parseDeltaEta_Cosh_LUTS(
0746 scaleMap, "TAU", "MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
0747
0748 parseDeltaEta_Cosh_LUTS(
0749 scaleMap, "MU", "MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
0750
0751
0752
0753 parseDeltaPhi_Cos_LUTS(
0754 scaleMap, "EG", "EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
0755 parseDeltaPhi_Cos_LUTS(
0756 scaleMap, "EG", "JET", precisions["PRECISION-EG-JET-Delta"], precisions["PRECISION-EG-JET-Math"]);
0757 parseDeltaPhi_Cos_LUTS(
0758 scaleMap, "EG", "TAU", precisions["PRECISION-EG-TAU-Delta"], precisions["PRECISION-EG-TAU-Math"]);
0759 parseDeltaPhi_Cos_LUTS(
0760 scaleMap, "EG", "ETM", precisions["PRECISION-EG-ETM-Delta"], precisions["PRECISION-EG-ETM-Math"]);
0761 parseDeltaPhi_Cos_LUTS(
0762 scaleMap, "EG", "ETMHF", precisions["PRECISION-EG-ETMHF-Delta"], precisions["PRECISION-EG-ETMHF-Math"]);
0763 parseDeltaPhi_Cos_LUTS(
0764 scaleMap, "EG", "HTM", precisions["PRECISION-EG-HTM-Delta"], precisions["PRECISION-EG-HTM-Math"]);
0765 parseDeltaPhi_Cos_LUTS(
0766 scaleMap, "EG", "MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
0767
0768 parseDeltaPhi_Cos_LUTS(
0769 scaleMap, "JET", "JET", precisions["PRECISION-JET-JET-Delta"], precisions["PRECISION-JET-JET-Math"]);
0770 parseDeltaPhi_Cos_LUTS(
0771 scaleMap, "JET", "TAU", precisions["PRECISION-JET-TAU-Delta"], precisions["PRECISION-JET-TAU-Math"]);
0772 parseDeltaPhi_Cos_LUTS(
0773 scaleMap, "JET", "ETM", precisions["PRECISION-JET-ETM-Delta"], precisions["PRECISION-JET-ETM-Math"]);
0774 parseDeltaPhi_Cos_LUTS(
0775 scaleMap, "JET", "ETMHF", precisions["PRECISION-JET-ETMHF-Delta"], precisions["PRECISION-JET-ETMHF-Math"]);
0776 parseDeltaPhi_Cos_LUTS(
0777 scaleMap, "JET", "HTM", precisions["PRECISION-JET-HTM-Delta"], precisions["PRECISION-JET-HTM-Math"]);
0778 parseDeltaPhi_Cos_LUTS(
0779 scaleMap, "JET", "MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
0780
0781 parseDeltaPhi_Cos_LUTS(
0782 scaleMap, "TAU", "TAU", precisions["PRECISION-TAU-TAU-Delta"], precisions["PRECISION-TAU-TAU-Math"]);
0783 parseDeltaPhi_Cos_LUTS(
0784 scaleMap, "TAU", "ETM", precisions["PRECISION-TAU-ETM-Delta"], precisions["PRECISION-TAU-ETM-Math"]);
0785 parseDeltaPhi_Cos_LUTS(
0786 scaleMap, "TAU", "ETMHF", precisions["PRECISION-TAU-ETMHF-Delta"], precisions["PRECISION-TAU-ETMHF-Math"]);
0787 parseDeltaPhi_Cos_LUTS(
0788 scaleMap, "TAU", "HTM", precisions["PRECISION-TAU-HTM-Delta"], precisions["PRECISION-TAU-HTM-Math"]);
0789 parseDeltaPhi_Cos_LUTS(
0790 scaleMap, "TAU", "MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
0791
0792 parseDeltaPhi_Cos_LUTS(
0793 scaleMap, "MU", "ETM", precisions["PRECISION-MU-ETM-Delta"], precisions["PRECISION-MU-ETM-Math"]);
0794 parseDeltaPhi_Cos_LUTS(
0795 scaleMap, "MU", "ETMHF", precisions["PRECISION-MU-ETMHF-Delta"], precisions["PRECISION-MU-ETMHF-Math"]);
0796 parseDeltaPhi_Cos_LUTS(
0797 scaleMap, "MU", "HTM", precisions["PRECISION-MU-HTM-Delta"], precisions["PRECISION-MU-HTM-Math"]);
0798 parseDeltaPhi_Cos_LUTS(
0799 scaleMap, "MU", "MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
0800
0801 parsePhi_Trig_LUTS(scaleMap, "EG", l1t::COS, precisions["PRECISION-EG-EG-Math"]);
0802 parsePhi_Trig_LUTS(scaleMap, "JET", l1t::COS, precisions["PRECISION-JET-JET-Math"]);
0803 parsePhi_Trig_LUTS(scaleMap, "TAU", l1t::COS, precisions["PRECISION-TAU-TAU-Math"]);
0804 parsePhi_Trig_LUTS(scaleMap, "MU", l1t::COS, precisions["PRECISION-MU-MU-Math"]);
0805
0806 parsePhi_Trig_LUTS(scaleMap, "EG", l1t::SIN, precisions["PRECISION-EG-EG-Math"]);
0807 parsePhi_Trig_LUTS(scaleMap, "JET", l1t::SIN, precisions["PRECISION-JET-JET-Math"]);
0808 parsePhi_Trig_LUTS(scaleMap, "TAU", l1t::SIN, precisions["PRECISION-TAU-TAU-Math"]);
0809 parsePhi_Trig_LUTS(scaleMap, "MU", l1t::SIN, precisions["PRECISION-MU-MU-Math"]);
0810
0811
0812
0813
0814 }
0815
0816 return true;
0817 }
0818
0819 void l1t::TriggerMenuParser::parseCalMuEta_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0820 std::string obj1,
0821 std::string obj2) {
0822 using namespace tmeventsetup;
0823
0824
0825 std::string scLabel1 = obj1;
0826 scLabel1 += "-ETA";
0827 std::string scLabel2 = obj2;
0828 scLabel2 += "-ETA";
0829
0830
0831 if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
0832 return;
0833
0834 const esScale* scale1 = &scaleMap.find(scLabel1)->second;
0835 const esScale* scale2 = &scaleMap.find(scLabel2)->second;
0836
0837 std::vector<long long> lut_cal_2_mu_eta;
0838 getCaloMuonEtaConversionLut(lut_cal_2_mu_eta, scale1, scale2);
0839
0840 std::string lutName = obj1;
0841 lutName += "-";
0842 lutName += obj2;
0843 m_gtScales.setLUT_CalMuEta(lutName, lut_cal_2_mu_eta);
0844 }
0845
0846 void l1t::TriggerMenuParser::parseCalMuPhi_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0847 std::string obj1,
0848 std::string obj2) {
0849 using namespace tmeventsetup;
0850
0851
0852 std::string scLabel1 = obj1;
0853 scLabel1 += "-PHI";
0854 std::string scLabel2 = obj2;
0855 scLabel2 += "-PHI";
0856
0857
0858 if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
0859 return;
0860
0861 const esScale* scale1 = &scaleMap.find(scLabel1)->second;
0862 const esScale* scale2 = &scaleMap.find(scLabel2)->second;
0863
0864 std::vector<long long> lut_cal_2_mu_phi;
0865 getCaloMuonPhiConversionLut(lut_cal_2_mu_phi, scale1, scale2);
0866
0867 std::string lutName = obj1;
0868 lutName += "-";
0869 lutName += obj2;
0870 m_gtScales.setLUT_CalMuPhi(lutName, lut_cal_2_mu_phi);
0871 }
0872
0873 void l1t::TriggerMenuParser::parsePt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0874 std::string lutpfx,
0875 std::string obj1,
0876 unsigned int prec) {
0877 using namespace tmeventsetup;
0878
0879
0880 std::string scLabel1 = obj1;
0881 scLabel1 += "-ET";
0882
0883
0884 if (scaleMap.find(scLabel1) == scaleMap.end())
0885 return;
0886
0887 const esScale* scale1 = &scaleMap.find(scLabel1)->second;
0888
0889 std::vector<long long> lut_pt;
0890 getLut(lut_pt, scale1, prec);
0891
0892 m_gtScales.setLUT_Pt(lutpfx + "_" + scLabel1, lut_pt, prec);
0893 }
0894
0895
0896 void l1t::TriggerMenuParser::parseUpt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0897 std::string lutpfx,
0898 std::string obj1,
0899 unsigned int prec) {
0900 using namespace tmeventsetup;
0901
0902
0903 std::string scLabel1 = obj1;
0904 scLabel1 += "-UPT";
0905
0906
0907 if (scaleMap.find(scLabel1) == scaleMap.end())
0908 return;
0909
0910 const esScale* scale1 = &scaleMap.find(scLabel1)->second;
0911
0912 std::vector<long long> lut_pt;
0913 getLut(lut_pt, scale1, prec);
0914
0915 m_gtScales.setLUT_Upt(lutpfx + "_" + scLabel1, lut_pt, prec);
0916 }
0917
0918 void l1t::TriggerMenuParser::parseDeltaEta_Cosh_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0919 std::string obj1,
0920 std::string obj2,
0921 unsigned int prec1,
0922 unsigned int prec2) {
0923 using namespace tmeventsetup;
0924
0925
0926 std::string scLabel1 = obj1;
0927 scLabel1 += "-ETA";
0928 std::string scLabel2 = obj2;
0929 scLabel2 += "-ETA";
0930
0931
0932 if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
0933 return;
0934
0935 const esScale* scale1 = &scaleMap.find(scLabel1)->second;
0936 const esScale* scale2 = &scaleMap.find(scLabel2)->second;
0937 std::vector<double> val_delta_eta;
0938 std::vector<long long> lut_delta_eta;
0939 size_t n = getDeltaVector(val_delta_eta, scale1, scale2);
0940 setLut(lut_delta_eta, val_delta_eta, prec1);
0941 std::string lutName = obj1;
0942 lutName += "-";
0943 lutName += obj2;
0944 m_gtScales.setLUT_DeltaEta(lutName, lut_delta_eta, prec1);
0945
0946
0947 std::vector<long long> lut_cosh;
0948 applyCosh(val_delta_eta, n);
0949 setLut(lut_cosh, val_delta_eta, prec2);
0950 m_gtScales.setLUT_Cosh(lutName, lut_cosh, prec2);
0951 }
0952
0953 void l1t::TriggerMenuParser::parseDeltaPhi_Cos_LUTS(const std::map<std::string, tmeventsetup::esScale>& scaleMap,
0954 const std::string& obj1,
0955 const std::string& obj2,
0956 unsigned int prec1,
0957 unsigned int prec2) {
0958 using namespace tmeventsetup;
0959
0960
0961 std::string scLabel1 = obj1;
0962 scLabel1 += "-PHI";
0963 std::string scLabel2 = obj2;
0964 scLabel2 += "-PHI";
0965
0966
0967 if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
0968 return;
0969
0970 const esScale* scale1 = &scaleMap.find(scLabel1)->second;
0971 const esScale* scale2 = &scaleMap.find(scLabel2)->second;
0972 std::vector<double> val_delta_phi;
0973 std::vector<long long> lut_delta_phi;
0974 size_t n = getDeltaVector(val_delta_phi, scale1, scale2);
0975 setLut(lut_delta_phi, val_delta_phi, prec1);
0976 std::string lutName = obj1;
0977 lutName += "-";
0978 lutName += obj2;
0979 m_gtScales.setLUT_DeltaPhi(lutName, lut_delta_phi, prec1);
0980
0981
0982 std::vector<long long> lut_cos;
0983 applyCos(val_delta_phi, n);
0984 setLut(lut_cos, val_delta_phi, prec2);
0985 m_gtScales.setLUT_Cos(lutName, lut_cos, prec2);
0986 }
0987
0988 void l1t::TriggerMenuParser::parsePhi_Trig_LUTS(const std::map<std::string, tmeventsetup::esScale>& scaleMap,
0989 const std::string& obj,
0990 l1t::TrigFunc_t func,
0991 unsigned int prec) {
0992 using namespace tmeventsetup;
0993
0994 std::string scLabel = obj;
0995 scLabel += "-PHI";
0996
0997
0998 if (scaleMap.find(scLabel) == scaleMap.end())
0999 return;
1000 if (func != l1t::SIN and func != l1t::COS)
1001 return;
1002
1003 const esScale* scale = &scaleMap.find(scLabel)->second;
1004
1005 const double step = scale->getStep();
1006 const double range = scale->getMaximum() - scale->getMinimum();
1007 const size_t n = std::ceil(range / step);
1008 const size_t bitwidth = std::ceil(std::log10(n) / std::log10(2));
1009
1010 std::vector<double> array(std::pow(2, bitwidth), 0);
1011
1012 for (size_t ii = 0; ii < n; ii++) {
1013 array.at(ii) = step * ii;
1014 }
1015
1016 const std::string& lutName = obj;
1017 std::vector<long long> lut;
1018 if (func == l1t::SIN) {
1019 applySin(array, n);
1020 setLut(lut, array, prec);
1021 m_gtScales.setLUT_Sin(lutName, lut, prec);
1022 } else if (func == l1t::COS) {
1023 applyCos(array, n);
1024 setLut(lut, array, prec);
1025 m_gtScales.setLUT_Cos(lutName, lut, prec);
1026 }
1027 }
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040 bool l1t::TriggerMenuParser::parseMuon(tmeventsetup::esCondition condMu, unsigned int chipNr, const bool corrFlag) {
1041 using namespace tmeventsetup;
1042
1043
1044 std::string condition = "muon";
1045 std::string particle = "muon";
1046 std::string type = l1t2string(condMu.getType());
1047 std::string name = l1t2string(condMu.getName());
1048 int nrObj = -1;
1049
1050 GtConditionType cType = l1t::TypeNull;
1051
1052 if (condMu.getType() == esConditionType::SingleMuon) {
1053 type = "1_s";
1054 cType = l1t::Type1s;
1055 nrObj = 1;
1056 } else if (condMu.getType() == esConditionType::DoubleMuon) {
1057 type = "2_s";
1058 cType = l1t::Type2s;
1059 nrObj = 2;
1060 } else if (condMu.getType() == esConditionType::TripleMuon) {
1061 type = "3";
1062 cType = l1t::Type3s;
1063 nrObj = 3;
1064 } else if (condMu.getType() == esConditionType::QuadMuon) {
1065 type = "4";
1066 cType = l1t::Type4s;
1067 nrObj = 4;
1068 } else {
1069 edm::LogError("TriggerMenuParser") << "Wrong type for muon-condition (" << type << ")" << std::endl;
1070 return false;
1071 }
1072
1073 if (nrObj < 0) {
1074 edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type << ")"
1075 << "\nCan not determine number of trigger objects. " << std::endl;
1076 return false;
1077 }
1078
1079 LogDebug("TriggerMenuParser") << "\n ****************************************** "
1080 << "\n parseMuon "
1081 << "\n condition = " << condition << "\n particle = " << particle
1082 << "\n type = " << type << "\n name = " << name << std::endl;
1083
1084
1085
1086
1087 std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1088
1089
1090 MuonTemplate::CorrelationParameter corrParameter;
1091
1092
1093 std::vector<uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1094 tmpValues.reserve(nrObj);
1095
1096 if (int(condMu.getObjects().size()) != nrObj) {
1097 edm::LogError("TriggerMenuParser") << " condMu objects: nrObj = " << nrObj
1098 << "condMu.getObjects().size() = " << condMu.getObjects().size() << std::endl;
1099 return false;
1100 }
1101
1102
1103 unsigned int chargeCorrelation = 1;
1104 const std::vector<esCut>& cuts = condMu.getCuts();
1105 for (size_t jj = 0; jj < cuts.size(); jj++) {
1106 const esCut& cut = cuts.at(jj);
1107 if (cut.getCutType() == esCutType::ChargeCorrelation) {
1108 if (cut.getData() == "ls")
1109 chargeCorrelation = 2;
1110 else if (cut.getData() == "os")
1111 chargeCorrelation = 4;
1112 else
1113 chargeCorrelation = 1;
1114 }
1115 }
1116
1117
1118 corrParameter.chargeCorrelation = chargeCorrelation;
1119
1120 int cnt = 0;
1121
1122
1123 int relativeBx = 0;
1124 bool gEq = false;
1125
1126
1127 const std::vector<esObject>& objects = condMu.getObjects();
1128 for (size_t jj = 0; jj < objects.size(); jj++) {
1129 const esObject& object = objects.at(jj);
1130 gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1131
1132
1133 relativeBx = object.getBxOffset();
1134
1135
1136 int upperUnconstrainedPtInd = -1;
1137 int lowerUnconstrainedPtInd = 0;
1138 int upperImpactParameterInd = -1;
1139 int lowerImpactParameterInd = 0;
1140 int upperThresholdInd = -1;
1141 int lowerThresholdInd = 0;
1142 int upperIndexInd = -1;
1143 int lowerIndexInd = 0;
1144 int cntEta = 0;
1145 unsigned int etaWindow1Lower = -1, etaWindow1Upper = -1, etaWindow2Lower = -1, etaWindow2Upper = -1;
1146 int cntPhi = 0;
1147 unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
1148 int isolationLUT = 0xF;
1149 int impactParameterLUT = 0xF;
1150 int charge = -1;
1151 int qualityLUT = 0xFFFF;
1152
1153 const std::vector<esCut>& cuts = object.getCuts();
1154 for (size_t kk = 0; kk < cuts.size(); kk++) {
1155 const esCut& cut = cuts.at(kk);
1156
1157 switch (cut.getCutType()) {
1158 case esCutType::UnconstrainedPt:
1159 lowerUnconstrainedPtInd = cut.getMinimum().index;
1160 upperUnconstrainedPtInd = cut.getMaximum().index;
1161 break;
1162
1163 case esCutType::ImpactParameter:
1164 lowerImpactParameterInd = cut.getMinimum().index;
1165 upperImpactParameterInd = cut.getMaximum().index;
1166 impactParameterLUT = l1tstr2int(cut.getData());
1167 break;
1168
1169 case esCutType::Threshold:
1170 lowerThresholdInd = cut.getMinimum().index;
1171 upperThresholdInd = cut.getMaximum().index;
1172 break;
1173
1174 case esCutType::Slice:
1175 lowerIndexInd = int(cut.getMinimum().value);
1176 upperIndexInd = int(cut.getMaximum().value);
1177 break;
1178
1179 case esCutType::Eta: {
1180 if (cntEta == 0) {
1181 etaWindow1Lower = cut.getMinimum().index;
1182 etaWindow1Upper = cut.getMaximum().index;
1183 } else if (cntEta == 1) {
1184 etaWindow2Lower = cut.getMinimum().index;
1185 etaWindow2Upper = cut.getMaximum().index;
1186 } else {
1187 edm::LogError("TriggerMenuParser")
1188 << "Too Many Eta Cuts for muon-condition (" << particle << ")" << std::endl;
1189 return false;
1190 }
1191 cntEta++;
1192
1193 } break;
1194
1195 case esCutType::Phi: {
1196 if (cntPhi == 0) {
1197 phiWindow1Lower = cut.getMinimum().index;
1198 phiWindow1Upper = cut.getMaximum().index;
1199 } else if (cntPhi == 1) {
1200 phiWindow2Lower = cut.getMinimum().index;
1201 phiWindow2Upper = cut.getMaximum().index;
1202 } else {
1203 edm::LogError("TriggerMenuParser")
1204 << "Too Many Phi Cuts for muon-condition (" << particle << ")" << std::endl;
1205 return false;
1206 }
1207 cntPhi++;
1208
1209 } break;
1210
1211 case esCutType::Charge:
1212 if (cut.getData() == "positive")
1213 charge = 0;
1214 else if (cut.getData() == "negative")
1215 charge = 1;
1216 else
1217 charge = -1;
1218 break;
1219 case esCutType::Quality:
1220
1221 qualityLUT = l1tstr2int(cut.getData());
1222
1223 break;
1224 case esCutType::Isolation: {
1225 isolationLUT = l1tstr2int(cut.getData());
1226
1227 } break;
1228 default:
1229 break;
1230 }
1231
1232 }
1233
1234
1235 objParameter[cnt].unconstrainedPtHigh = upperUnconstrainedPtInd;
1236 objParameter[cnt].unconstrainedPtLow = lowerUnconstrainedPtInd;
1237 objParameter[cnt].impactParameterHigh = upperImpactParameterInd;
1238 objParameter[cnt].impactParameterLow = lowerImpactParameterInd;
1239 objParameter[cnt].impactParameterLUT = impactParameterLUT;
1240
1241 objParameter[cnt].ptHighThreshold = upperThresholdInd;
1242 objParameter[cnt].ptLowThreshold = lowerThresholdInd;
1243
1244 objParameter[cnt].indexHigh = upperIndexInd;
1245 objParameter[cnt].indexLow = lowerIndexInd;
1246
1247 objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
1248 objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
1249 objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
1250 objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
1251
1252 objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1253 objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1254 objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1255 objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1256
1257
1258 objParameter[cnt].enableMip = false;
1259 objParameter[cnt].enableIso = false;
1260 objParameter[cnt].requestIso = false;
1261
1262 objParameter[cnt].charge = charge;
1263 objParameter[cnt].qualityLUT = qualityLUT;
1264 objParameter[cnt].isolationLUT = isolationLUT;
1265
1266 cnt++;
1267 }
1268
1269
1270 std::vector<GlobalObject> objType(nrObj, gtMu);
1271
1272
1273 MuonTemplate muonCond(name);
1274
1275 muonCond.setCondType(cType);
1276 muonCond.setObjectType(objType);
1277 muonCond.setCondGEq(gEq);
1278 muonCond.setCondChipNr(chipNr);
1279 muonCond.setCondRelativeBx(relativeBx);
1280
1281 muonCond.setConditionParameter(objParameter, corrParameter);
1282
1283 if (edm::isDebugEnabled()) {
1284 std::ostringstream myCoutStream;
1285 muonCond.print(myCoutStream);
1286 LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1287 }
1288
1289
1290 if (!insertConditionIntoMap(muonCond, chipNr)) {
1291 edm::LogError("TriggerMenuParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1292 return false;
1293 } else {
1294 LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1295 if (corrFlag) {
1296 (m_corMuonTemplate[chipNr]).push_back(muonCond);
1297 } else {
1298 LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the vecMuonTemplate vector" << std::endl;
1299 (m_vecMuonTemplate[chipNr]).push_back(muonCond);
1300 }
1301 }
1302
1303
1304 return true;
1305 }
1306
1307 bool l1t::TriggerMenuParser::parseMuonCorr(const tmeventsetup::esObject* corrMu, unsigned int chipNr) {
1308
1309 using namespace tmeventsetup;
1310
1311
1312 std::string condition = "muon";
1313 std::string particle = "muon";
1314 std::string type = l1t2string(corrMu->getType());
1315 std::string name = l1t2string(corrMu->getName());
1316 int nrObj = 1;
1317 type = "1_s";
1318 GtConditionType cType = l1t::Type1s;
1319
1320 if (nrObj < 0) {
1321 edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type << ")"
1322 << "\nCan not determine number of trigger objects. " << std::endl;
1323 return false;
1324 }
1325
1326 LogDebug("TriggerMenuParser") << "\n ****************************************** "
1327 << "\n parseMuon "
1328 << "\n condition = " << condition << "\n particle = " << particle
1329 << "\n type = " << type << "\n name = " << name << std::endl;
1330
1331
1332
1333
1334 std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1335
1336
1337 MuonTemplate::CorrelationParameter corrParameter;
1338
1339
1340 std::vector<uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1341 tmpValues.reserve(nrObj);
1342
1343
1344
1345 std::string str_chargeCorrelation = "ig";
1346 unsigned int chargeCorrelation = 0;
1347 if (str_chargeCorrelation == "ig")
1348 chargeCorrelation = 1;
1349 else if (str_chargeCorrelation == "ls")
1350 chargeCorrelation = 2;
1351 else if (str_chargeCorrelation == "os")
1352 chargeCorrelation = 4;
1353
1354
1355 corrParameter.chargeCorrelation = chargeCorrelation;
1356
1357
1358 int relativeBx = 0;
1359 bool gEq = false;
1360
1361
1362 gEq = (corrMu->getComparisonOperator() == esComparisonOperator::GE);
1363
1364
1365 relativeBx = corrMu->getBxOffset();
1366
1367
1368 int upperUnconstrainedPtInd = -1;
1369 int lowerUnconstrainedPtInd = 0;
1370 int upperImpactParameterInd = -1;
1371 int lowerImpactParameterInd = 0;
1372 int impactParameterLUT = 0xF;
1373 int upperThresholdInd = -1;
1374 int lowerThresholdInd = 0;
1375 int upperIndexInd = -1;
1376 int lowerIndexInd = 0;
1377 int cntEta = 0;
1378 unsigned int etaWindow1Lower = -1, etaWindow1Upper = -1, etaWindow2Lower = -1, etaWindow2Upper = -1;
1379 int cntPhi = 0;
1380 unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
1381 int isolationLUT = 0xF;
1382 int charge = -1;
1383 int qualityLUT = 0xFFFF;
1384
1385 const std::vector<esCut>& cuts = corrMu->getCuts();
1386 for (size_t kk = 0; kk < cuts.size(); kk++) {
1387 const esCut& cut = cuts.at(kk);
1388
1389 switch (cut.getCutType()) {
1390 case esCutType::UnconstrainedPt:
1391 lowerUnconstrainedPtInd = cut.getMinimum().index;
1392 upperUnconstrainedPtInd = cut.getMaximum().index;
1393 break;
1394
1395 case esCutType::ImpactParameter:
1396 lowerImpactParameterInd = cut.getMinimum().index;
1397 upperImpactParameterInd = cut.getMaximum().index;
1398 impactParameterLUT = l1tstr2int(cut.getData());
1399 break;
1400
1401 case esCutType::Threshold:
1402 lowerThresholdInd = cut.getMinimum().index;
1403 upperThresholdInd = cut.getMaximum().index;
1404 break;
1405
1406 case esCutType::Slice:
1407 lowerIndexInd = int(cut.getMinimum().value);
1408 upperIndexInd = int(cut.getMaximum().value);
1409 break;
1410
1411 case esCutType::Eta: {
1412 if (cntEta == 0) {
1413 etaWindow1Lower = cut.getMinimum().index;
1414 etaWindow1Upper = cut.getMaximum().index;
1415 } else if (cntEta == 1) {
1416 etaWindow2Lower = cut.getMinimum().index;
1417 etaWindow2Upper = cut.getMaximum().index;
1418 } else {
1419 edm::LogError("TriggerMenuParser")
1420 << "Too Many Eta Cuts for muon-condition (" << particle << ")" << std::endl;
1421 return false;
1422 }
1423 cntEta++;
1424
1425 } break;
1426
1427 case esCutType::Phi: {
1428 if (cntPhi == 0) {
1429 phiWindow1Lower = cut.getMinimum().index;
1430 phiWindow1Upper = cut.getMaximum().index;
1431 } else if (cntPhi == 1) {
1432 phiWindow2Lower = cut.getMinimum().index;
1433 phiWindow2Upper = cut.getMaximum().index;
1434 } else {
1435 edm::LogError("TriggerMenuParser")
1436 << "Too Many Phi Cuts for muon-condition (" << particle << ")" << std::endl;
1437 return false;
1438 }
1439 cntPhi++;
1440
1441 } break;
1442
1443 case esCutType::Charge:
1444 if (cut.getData() == "positive")
1445 charge = 0;
1446 else if (cut.getData() == "negative")
1447 charge = 1;
1448 else
1449 charge = -1;
1450 break;
1451 case esCutType::Quality:
1452
1453 qualityLUT = l1tstr2int(cut.getData());
1454
1455 break;
1456 case esCutType::Isolation: {
1457 isolationLUT = l1tstr2int(cut.getData());
1458
1459 } break;
1460 default:
1461 break;
1462 }
1463
1464 }
1465
1466
1467 objParameter[0].unconstrainedPtHigh = upperUnconstrainedPtInd;
1468 objParameter[0].unconstrainedPtLow = lowerUnconstrainedPtInd;
1469 objParameter[0].impactParameterHigh = upperImpactParameterInd;
1470 objParameter[0].impactParameterLow = lowerImpactParameterInd;
1471 objParameter[0].impactParameterLUT = impactParameterLUT;
1472
1473 objParameter[0].ptHighThreshold = upperThresholdInd;
1474 objParameter[0].ptLowThreshold = lowerThresholdInd;
1475
1476 objParameter[0].indexHigh = upperIndexInd;
1477 objParameter[0].indexLow = lowerIndexInd;
1478
1479 objParameter[0].etaWindow1Lower = etaWindow1Lower;
1480 objParameter[0].etaWindow1Upper = etaWindow1Upper;
1481 objParameter[0].etaWindow2Lower = etaWindow2Lower;
1482 objParameter[0].etaWindow2Upper = etaWindow2Upper;
1483
1484 objParameter[0].phiWindow1Lower = phiWindow1Lower;
1485 objParameter[0].phiWindow1Upper = phiWindow1Upper;
1486 objParameter[0].phiWindow2Lower = phiWindow2Lower;
1487 objParameter[0].phiWindow2Upper = phiWindow2Upper;
1488
1489
1490 objParameter[0].enableMip = false;
1491 objParameter[0].enableIso = false;
1492 objParameter[0].requestIso = false;
1493
1494 objParameter[0].charge = charge;
1495 objParameter[0].qualityLUT = qualityLUT;
1496 objParameter[0].isolationLUT = isolationLUT;
1497
1498
1499 std::vector<GlobalObject> objType(nrObj, gtMu);
1500
1501
1502 MuonTemplate muonCond(name);
1503
1504 muonCond.setCondType(cType);
1505 muonCond.setObjectType(objType);
1506 muonCond.setCondGEq(gEq);
1507 muonCond.setCondChipNr(chipNr);
1508 muonCond.setCondRelativeBx(relativeBx);
1509 muonCond.setConditionParameter(objParameter, corrParameter);
1510
1511 if (edm::isDebugEnabled()) {
1512 std::ostringstream myCoutStream;
1513 muonCond.print(myCoutStream);
1514 LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1515 }
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530 (m_corMuonTemplate[chipNr]).push_back(muonCond);
1531
1532
1533 return true;
1534 }
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547 bool l1t::TriggerMenuParser::parseMuonShower(tmeventsetup::esCondition condMu,
1548 unsigned int chipNr,
1549 const bool corrFlag) {
1550 using namespace tmeventsetup;
1551
1552
1553 std::string condition = "muonShower";
1554 std::string particle = "muonShower";
1555 std::string type = l1t2string(condMu.getType());
1556 std::string name = l1t2string(condMu.getName());
1557
1558 int nrObj = 1;
1559
1560
1561 GtConditionType cType = l1t::Type1s;
1562
1563
1564 std::vector<MuonShowerTemplate::ObjectParameter> objParameter(nrObj);
1565
1566 if (int(condMu.getObjects().size()) != nrObj) {
1567 edm::LogError("TriggerMenuParser") << " condMu objects: nrObj = " << nrObj
1568 << "condMu.getObjects().size() = " << condMu.getObjects().size() << std::endl;
1569 return false;
1570 }
1571
1572
1573 esObject object = condMu.getObjects().at(0);
1574 int relativeBx = object.getBxOffset();
1575
1576 if (condMu.getType() == esConditionType::MuonShower0) {
1577 objParameter[0].MuonShower0 = true;
1578 } else if (condMu.getType() == esConditionType::MuonShower1) {
1579 objParameter[0].MuonShower1 = true;
1580 } else if (condMu.getType() == esConditionType::MuonShowerOutOfTime0) {
1581 objParameter[0].MuonShowerOutOfTime0 = true;
1582 } else if (condMu.getType() == esConditionType::MuonShowerOutOfTime1) {
1583 objParameter[0].MuonShowerOutOfTime1 = true;
1584 }
1585
1586
1587 std::vector<GlobalObject> objType(nrObj, gtMuShower);
1588
1589
1590 MuonShowerTemplate muonShowerCond(name);
1591 muonShowerCond.setCondType(cType);
1592 muonShowerCond.setObjectType(objType);
1593 muonShowerCond.setCondChipNr(chipNr);
1594 muonShowerCond.setCondRelativeBx(relativeBx);
1595
1596 muonShowerCond.setConditionParameter(objParameter);
1597
1598 if (edm::isDebugEnabled()) {
1599 std::ostringstream myCoutStream;
1600 muonShowerCond.print(myCoutStream);
1601 }
1602
1603
1604 if (!insertConditionIntoMap(muonShowerCond, chipNr)) {
1605 edm::LogError("TriggerMenuParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1606 return false;
1607 } else {
1608 (m_vecMuonShowerTemplate[chipNr]).push_back(muonShowerCond);
1609 }
1610
1611 return true;
1612 }
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625 bool l1t::TriggerMenuParser::parseCalo(tmeventsetup::esCondition condCalo, unsigned int chipNr, const bool corrFlag) {
1626
1627 using namespace tmeventsetup;
1628
1629
1630
1631 std::string condition = "calo";
1632 std::string particle = "test-fix";
1633 std::string type = l1t2string(condCalo.getType());
1634 std::string name = l1t2string(condCalo.getName());
1635
1636 LogDebug("TriggerMenuParser") << "\n ****************************************** "
1637 << "\n (in parseCalo) "
1638 << "\n condition = " << condition << "\n particle = " << particle
1639 << "\n type = " << type << "\n name = " << name << std::endl;
1640
1641 GtConditionType cType = l1t::TypeNull;
1642
1643
1644
1645 GlobalObject caloObjType;
1646 int nrObj = -1;
1647
1648 if (condCalo.getType() == esConditionType::SingleEgamma) {
1649 caloObjType = gtEG;
1650 type = "1_s";
1651 cType = l1t::Type1s;
1652 nrObj = 1;
1653 } else if (condCalo.getType() == esConditionType::DoubleEgamma) {
1654 caloObjType = gtEG;
1655 type = "2_s";
1656 cType = l1t::Type2s;
1657 nrObj = 2;
1658 } else if (condCalo.getType() == esConditionType::TripleEgamma) {
1659 caloObjType = gtEG;
1660 cType = l1t::Type3s;
1661 type = "3";
1662 nrObj = 3;
1663 } else if (condCalo.getType() == esConditionType::QuadEgamma) {
1664 caloObjType = gtEG;
1665 cType = l1t::Type4s;
1666 type = "4";
1667 nrObj = 4;
1668 } else if (condCalo.getType() == esConditionType::SingleJet) {
1669 caloObjType = gtJet;
1670 cType = l1t::Type1s;
1671 type = "1_s";
1672 nrObj = 1;
1673 } else if (condCalo.getType() == esConditionType::DoubleJet) {
1674 caloObjType = gtJet;
1675 cType = l1t::Type2s;
1676 type = "2_s";
1677 nrObj = 2;
1678 } else if (condCalo.getType() == esConditionType::TripleJet) {
1679 caloObjType = gtJet;
1680 cType = l1t::Type3s;
1681 type = "3";
1682 nrObj = 3;
1683 } else if (condCalo.getType() == esConditionType::QuadJet) {
1684 caloObjType = gtJet;
1685 cType = l1t::Type4s;
1686 type = "4";
1687 nrObj = 4;
1688 } else if (condCalo.getType() == esConditionType::SingleTau) {
1689 caloObjType = gtTau;
1690 cType = l1t::Type1s;
1691 type = "1_s";
1692 nrObj = 1;
1693 } else if (condCalo.getType() == esConditionType::DoubleTau) {
1694 caloObjType = gtTau;
1695 cType = l1t::Type2s;
1696 type = "2_s";
1697 nrObj = 2;
1698 } else if (condCalo.getType() == esConditionType::TripleTau) {
1699 caloObjType = gtTau;
1700 cType = l1t::Type3s;
1701 type = "3";
1702 nrObj = 3;
1703 } else if (condCalo.getType() == esConditionType::QuadTau) {
1704 caloObjType = gtTau;
1705 cType = l1t::Type4s;
1706 type = "4";
1707 nrObj = 4;
1708 } else {
1709 edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition (" << particle << ")" << std::endl;
1710 return false;
1711 }
1712
1713
1714
1715 if (nrObj < 0) {
1716 edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type << ")"
1717 << "\nCan not determine number of trigger objects. " << std::endl;
1718 return false;
1719 }
1720
1721
1722
1723
1724 std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1725
1726
1727 CaloTemplate::CorrelationParameter corrParameter;
1728
1729
1730 std::vector<uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1731 tmpValues.reserve(nrObj);
1732
1733 if (int(condCalo.getObjects().size()) != nrObj) {
1734 edm::LogError("TriggerMenuParser") << " condCalo objects: nrObj = " << nrObj
1735 << "condCalo.getObjects().size() = " << condCalo.getObjects().size()
1736 << std::endl;
1737 return false;
1738 }
1739
1740
1741
1742
1743 int cnt = 0;
1744
1745
1746 int relativeBx = 0;
1747 bool gEq = false;
1748
1749
1750 const std::vector<esObject>& objects = condCalo.getObjects();
1751 for (size_t jj = 0; jj < objects.size(); jj++) {
1752 const esObject& object = objects.at(jj);
1753 gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1754
1755
1756 relativeBx = object.getBxOffset();
1757
1758
1759 int upperThresholdInd = -1;
1760 int lowerThresholdInd = 0;
1761 int upperIndexInd = -1;
1762 int lowerIndexInd = 0;
1763 int cntEta = 0;
1764 unsigned int etaWindow1Lower = -1, etaWindow1Upper = -1, etaWindow2Lower = -1, etaWindow2Upper = -1;
1765 int cntPhi = 0;
1766 unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
1767 int isolationLUT = 0xF;
1768 int qualityLUT = 0xF;
1769 int displacedLUT = 0x0;
1770
1771
1772
1773 const std::vector<esCut>& cuts = object.getCuts();
1774 for (size_t kk = 0; kk < cuts.size(); kk++) {
1775 const esCut& cut = cuts.at(kk);
1776
1777 switch (cut.getCutType()) {
1778 case esCutType::Threshold:
1779 lowerThresholdInd = cut.getMinimum().index;
1780 upperThresholdInd = cut.getMaximum().index;
1781 break;
1782 case esCutType::Slice:
1783 lowerIndexInd = int(cut.getMinimum().value);
1784 upperIndexInd = int(cut.getMaximum().value);
1785 break;
1786 case esCutType::Eta: {
1787 if (cntEta == 0) {
1788 etaWindow1Lower = cut.getMinimum().index;
1789 etaWindow1Upper = cut.getMaximum().index;
1790 } else if (cntEta == 1) {
1791 etaWindow2Lower = cut.getMinimum().index;
1792 etaWindow2Upper = cut.getMaximum().index;
1793 } else {
1794 edm::LogError("TriggerMenuParser")
1795 << "Too Many Eta Cuts for calo-condition (" << particle << ")" << std::endl;
1796 return false;
1797 }
1798 cntEta++;
1799
1800 } break;
1801
1802 case esCutType::Phi: {
1803 if (cntPhi == 0) {
1804 phiWindow1Lower = cut.getMinimum().index;
1805 phiWindow1Upper = cut.getMaximum().index;
1806 } else if (cntPhi == 1) {
1807 phiWindow2Lower = cut.getMinimum().index;
1808 phiWindow2Upper = cut.getMaximum().index;
1809 } else {
1810 edm::LogError("TriggerMenuParser")
1811 << "Too Many Phi Cuts for calo-condition (" << particle << ")" << std::endl;
1812 return false;
1813 }
1814 cntPhi++;
1815
1816 } break;
1817
1818 case esCutType::Charge: {
1819 edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition (" << particle << ")" << std::endl;
1820 return false;
1821
1822 } break;
1823 case esCutType::Quality: {
1824 qualityLUT = l1tstr2int(cut.getData());
1825
1826 } break;
1827 case esCutType::Displaced: {
1828 displacedLUT = l1tstr2int(cut.getData());
1829
1830 } break;
1831 case esCutType::Isolation: {
1832 isolationLUT = l1tstr2int(cut.getData());
1833
1834 } break;
1835 default:
1836 break;
1837 }
1838
1839 }
1840
1841
1842 objParameter[cnt].etHighThreshold = upperThresholdInd;
1843 objParameter[cnt].etLowThreshold = lowerThresholdInd;
1844 objParameter[cnt].indexHigh = upperIndexInd;
1845 objParameter[cnt].indexLow = lowerIndexInd;
1846 objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
1847 objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
1848 objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
1849 objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
1850 objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1851 objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1852 objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1853 objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1854 objParameter[cnt].isolationLUT = isolationLUT;
1855 objParameter[cnt].qualityLUT = qualityLUT;
1856 objParameter[cnt].displacedLUT = displacedLUT;
1857
1858
1859 LogDebug("TriggerMenuParser") << "\n Calo ET high thresholds (hex) for calo object " << caloObjType << " "
1860 << cnt << " = " << std::hex << objParameter[cnt].etLowThreshold << " - "
1861 << objParameter[cnt].etHighThreshold
1862 << "\n etaWindow Lower / Upper for calo object " << cnt << " = 0x"
1863 << objParameter[cnt].etaWindow1Lower << " / 0x" << objParameter[cnt].etaWindow1Upper
1864 << "\n etaWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
1865 << objParameter[cnt].etaWindow2Lower << " / 0x" << objParameter[cnt].etaWindow2Upper
1866 << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
1867 << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
1868 << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
1869 << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper
1870 << "\n Isolation LUT for calo object " << cnt << " = 0x"
1871 << objParameter[cnt].isolationLUT << "\n Quality LUT for calo object " << cnt
1872 << " = 0x" << objParameter[cnt].qualityLUT << "\n LLP DISP LUT for calo object "
1873 << cnt << " = 0x" << objParameter[cnt].displacedLUT << std::dec << std::endl;
1874
1875 cnt++;
1876 }
1877
1878
1879 std::vector<GlobalObject> objType(nrObj, caloObjType);
1880
1881
1882 CaloTemplate caloCond(name);
1883
1884 caloCond.setCondType(cType);
1885 caloCond.setObjectType(objType);
1886
1887
1888 caloCond.setCondGEq(gEq);
1889 caloCond.setCondChipNr(chipNr);
1890
1891
1892 caloCond.setCondRelativeBx(relativeBx);
1893
1894 caloCond.setConditionParameter(objParameter, corrParameter);
1895
1896 if (edm::isDebugEnabled()) {
1897 std::ostringstream myCoutStream;
1898 caloCond.print(myCoutStream);
1899 LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1900 }
1901
1902
1903 if (!insertConditionIntoMap(caloCond, chipNr)) {
1904 edm::LogError("TriggerMenuParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1905
1906 return false;
1907 } else {
1908 if (corrFlag) {
1909 (m_corCaloTemplate[chipNr]).push_back(caloCond);
1910 } else {
1911 (m_vecCaloTemplate[chipNr]).push_back(caloCond);
1912 }
1913 }
1914
1915
1916 return true;
1917 }
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930 bool l1t::TriggerMenuParser::parseCaloCorr(const tmeventsetup::esObject* corrCalo, unsigned int chipNr) {
1931
1932 using namespace tmeventsetup;
1933
1934
1935
1936 std::string condition = "calo";
1937 std::string particle = "test-fix";
1938 std::string type = l1t2string(corrCalo->getType());
1939 std::string name = l1t2string(corrCalo->getName());
1940
1941 LogDebug("TriggerMenuParser") << "\n ****************************************** "
1942 << "\n (in parseCalo) "
1943 << "\n condition = " << condition << "\n particle = " << particle
1944 << "\n type = " << type << "\n name = " << name << std::endl;
1945
1946
1947
1948 GlobalObject caloObjType;
1949 int nrObj = 1;
1950 type = "1_s";
1951 GtConditionType cType = l1t::Type1s;
1952
1953 if (corrCalo->getType() == esObjectType::Egamma) {
1954 caloObjType = gtEG;
1955 } else if (corrCalo->getType() == esObjectType::Jet) {
1956 caloObjType = gtJet;
1957 } else if (corrCalo->getType() == esObjectType::Tau) {
1958 caloObjType = gtTau;
1959 } else {
1960 edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition (" << particle << ")" << std::endl;
1961 return false;
1962 }
1963
1964
1965
1966 if (nrObj < 0) {
1967 edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type << ")"
1968 << "\nCan not determine number of trigger objects. " << std::endl;
1969 return false;
1970 }
1971
1972
1973
1974
1975 std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1976
1977
1978 CaloTemplate::CorrelationParameter corrParameter;
1979
1980
1981 std::vector<uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1982 tmpValues.reserve(nrObj);
1983
1984
1985 int relativeBx = 0;
1986 bool gEq = false;
1987
1988 gEq = (corrCalo->getComparisonOperator() == esComparisonOperator::GE);
1989
1990
1991 relativeBx = corrCalo->getBxOffset();
1992
1993
1994 int upperThresholdInd = -1;
1995 int lowerThresholdInd = 0;
1996 int upperIndexInd = -1;
1997 int lowerIndexInd = 0;
1998 int cntEta = 0;
1999 unsigned int etaWindow1Lower = -1, etaWindow1Upper = -1, etaWindow2Lower = -1, etaWindow2Upper = -1;
2000 int cntPhi = 0;
2001 unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
2002 int isolationLUT = 0xF;
2003 int qualityLUT = 0xF;
2004 int displacedLUT = 0x0;
2005
2006
2007
2008 const std::vector<esCut>& cuts = corrCalo->getCuts();
2009 for (size_t kk = 0; kk < cuts.size(); kk++) {
2010 const esCut& cut = cuts.at(kk);
2011
2012 switch (cut.getCutType()) {
2013 case esCutType::Threshold:
2014 lowerThresholdInd = cut.getMinimum().index;
2015 upperThresholdInd = cut.getMaximum().index;
2016 break;
2017 case esCutType::Slice:
2018 lowerIndexInd = int(cut.getMinimum().value);
2019 upperIndexInd = int(cut.getMaximum().value);
2020 break;
2021 case esCutType::Eta: {
2022 if (cntEta == 0) {
2023 etaWindow1Lower = cut.getMinimum().index;
2024 etaWindow1Upper = cut.getMaximum().index;
2025 } else if (cntEta == 1) {
2026 etaWindow2Lower = cut.getMinimum().index;
2027 etaWindow2Upper = cut.getMaximum().index;
2028 } else {
2029 edm::LogError("TriggerMenuParser")
2030 << "Too Many Eta Cuts for calo-condition (" << particle << ")" << std::endl;
2031 return false;
2032 }
2033 cntEta++;
2034
2035 } break;
2036
2037 case esCutType::Phi: {
2038 if (cntPhi == 0) {
2039 phiWindow1Lower = cut.getMinimum().index;
2040 phiWindow1Upper = cut.getMaximum().index;
2041 } else if (cntPhi == 1) {
2042 phiWindow2Lower = cut.getMinimum().index;
2043 phiWindow2Upper = cut.getMaximum().index;
2044 } else {
2045 edm::LogError("TriggerMenuParser")
2046 << "Too Many Phi Cuts for calo-condition (" << particle << ")" << std::endl;
2047 return false;
2048 }
2049 cntPhi++;
2050
2051 } break;
2052
2053 case esCutType::Charge: {
2054 edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition (" << particle << ")" << std::endl;
2055 return false;
2056
2057 } break;
2058 case esCutType::Quality: {
2059 qualityLUT = l1tstr2int(cut.getData());
2060
2061 } break;
2062 case esCutType::Displaced: {
2063 displacedLUT = l1tstr2int(cut.getData());
2064
2065 } break;
2066 case esCutType::Isolation: {
2067 isolationLUT = l1tstr2int(cut.getData());
2068
2069 } break;
2070 default:
2071 break;
2072 }
2073
2074 }
2075
2076
2077 objParameter[0].etLowThreshold = lowerThresholdInd;
2078 objParameter[0].etHighThreshold = upperThresholdInd;
2079 objParameter[0].indexHigh = upperIndexInd;
2080 objParameter[0].indexLow = lowerIndexInd;
2081 objParameter[0].etaWindow1Lower = etaWindow1Lower;
2082 objParameter[0].etaWindow1Upper = etaWindow1Upper;
2083 objParameter[0].etaWindow2Lower = etaWindow2Lower;
2084 objParameter[0].etaWindow2Upper = etaWindow2Upper;
2085 objParameter[0].phiWindow1Lower = phiWindow1Lower;
2086 objParameter[0].phiWindow1Upper = phiWindow1Upper;
2087 objParameter[0].phiWindow2Lower = phiWindow2Lower;
2088 objParameter[0].phiWindow2Upper = phiWindow2Upper;
2089 objParameter[0].isolationLUT = isolationLUT;
2090 objParameter[0].qualityLUT = qualityLUT;
2091 objParameter[0].displacedLUT = displacedLUT;
2092
2093
2094 LogDebug("TriggerMenuParser") << "\n Calo ET high threshold (hex) for calo object " << caloObjType << " "
2095 << " = " << std::hex << objParameter[0].etLowThreshold << " - "
2096 << objParameter[0].etHighThreshold << "\n etaWindow Lower / Upper for calo object "
2097 << " = 0x" << objParameter[0].etaWindow1Lower << " / 0x"
2098 << objParameter[0].etaWindow1Upper
2099 << "\n etaWindowVeto Lower / Upper for calo object "
2100 << " = 0x" << objParameter[0].etaWindow2Lower << " / 0x"
2101 << objParameter[0].etaWindow2Upper << "\n phiWindow Lower / Upper for calo object "
2102 << " = 0x" << objParameter[0].phiWindow1Lower << " / 0x"
2103 << objParameter[0].phiWindow1Upper
2104 << "\n phiWindowVeto Lower / Upper for calo object "
2105 << " = 0x" << objParameter[0].phiWindow2Lower << " / 0x"
2106 << objParameter[0].phiWindow2Upper << "\n Isolation LUT for calo object "
2107 << " = 0x" << objParameter[0].isolationLUT << "\n Quality LUT for calo object "
2108 << " = 0x" << objParameter[0].qualityLUT << "\n LLP DISP LUT for calo object "
2109 << " = 0x" << objParameter[0].displacedLUT << std::dec << std::endl;
2110
2111
2112 std::vector<GlobalObject> objType(nrObj, caloObjType);
2113
2114
2115 CaloTemplate caloCond(name);
2116
2117 caloCond.setCondType(cType);
2118 caloCond.setObjectType(objType);
2119
2120
2121 caloCond.setCondGEq(gEq);
2122 caloCond.setCondChipNr(chipNr);
2123
2124
2125 caloCond.setCondRelativeBx(relativeBx);
2126
2127 caloCond.setConditionParameter(objParameter, corrParameter);
2128
2129 if (edm::isDebugEnabled()) {
2130 std::ostringstream myCoutStream;
2131 caloCond.print(myCoutStream);
2132 LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2133 }
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149 (m_corCaloTemplate[chipNr]).push_back(caloCond);
2150
2151
2152 return true;
2153 }
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166 bool l1t::TriggerMenuParser::parseEnergySum(tmeventsetup::esCondition condEnergySum,
2167 unsigned int chipNr,
2168 const bool corrFlag) {
2169
2170 using namespace tmeventsetup;
2171
2172
2173
2174 std::string condition = "calo";
2175 std::string type = l1t2string(condEnergySum.getType());
2176 std::string name = l1t2string(condEnergySum.getName());
2177
2178 LogDebug("TriggerMenuParser") << "\n ****************************************** "
2179 << "\n (in parseEnergySum) "
2180 << "\n condition = " << condition << "\n type = " << type
2181 << "\n name = " << name << std::endl;
2182
2183
2184 GlobalObject energySumObjType;
2185 GtConditionType cType;
2186
2187 if (condEnergySum.getType() == esConditionType::MissingEt) {
2188 energySumObjType = GlobalObject::gtETM;
2189 cType = TypeETM;
2190 } else if (condEnergySum.getType() == esConditionType::TotalEt) {
2191 energySumObjType = GlobalObject::gtETT;
2192 cType = TypeETT;
2193 } else if (condEnergySum.getType() == esConditionType::TotalEtEM) {
2194 energySumObjType = GlobalObject::gtETTem;
2195 cType = TypeETTem;
2196 } else if (condEnergySum.getType() == esConditionType::TotalHt) {
2197 energySumObjType = GlobalObject::gtHTT;
2198 cType = TypeHTT;
2199 } else if (condEnergySum.getType() == esConditionType::MissingHt) {
2200 energySumObjType = GlobalObject::gtHTM;
2201 cType = TypeHTM;
2202 } else if (condEnergySum.getType() == esConditionType::MissingEtHF) {
2203 energySumObjType = GlobalObject::gtETMHF;
2204 cType = TypeETMHF;
2205 } else if (condEnergySum.getType() == esConditionType::TowerCount) {
2206 energySumObjType = GlobalObject::gtTowerCount;
2207 cType = TypeTowerCount;
2208 } else if (condEnergySum.getType() == esConditionType::MinBiasHFP0) {
2209 energySumObjType = GlobalObject::gtMinBiasHFP0;
2210 cType = TypeMinBiasHFP0;
2211 } else if (condEnergySum.getType() == esConditionType::MinBiasHFM0) {
2212 energySumObjType = GlobalObject::gtMinBiasHFM0;
2213 cType = TypeMinBiasHFM0;
2214 } else if (condEnergySum.getType() == esConditionType::MinBiasHFP1) {
2215 energySumObjType = GlobalObject::gtMinBiasHFP1;
2216 cType = TypeMinBiasHFP1;
2217 } else if (condEnergySum.getType() == esConditionType::MinBiasHFM1) {
2218 energySumObjType = GlobalObject::gtMinBiasHFM1;
2219 cType = TypeMinBiasHFM1;
2220 } else if (condEnergySum.getType() == esConditionType::AsymmetryEt) {
2221 energySumObjType = GlobalObject::gtAsymmetryEt;
2222 cType = TypeAsymEt;
2223 } else if (condEnergySum.getType() == esConditionType::AsymmetryHt) {
2224 energySumObjType = GlobalObject::gtAsymmetryHt;
2225 cType = TypeAsymHt;
2226 } else if (condEnergySum.getType() == esConditionType::AsymmetryEtHF) {
2227 energySumObjType = GlobalObject::gtAsymmetryEtHF;
2228 cType = TypeAsymEtHF;
2229 } else if (condEnergySum.getType() == esConditionType::AsymmetryHtHF) {
2230 energySumObjType = GlobalObject::gtAsymmetryHtHF;
2231 cType = TypeAsymHtHF;
2232 } else if (condEnergySum.getType() == esConditionType::Centrality0) {
2233 energySumObjType = GlobalObject::gtCentrality0;
2234 cType = TypeCent0;
2235 } else if (condEnergySum.getType() == esConditionType::Centrality1) {
2236 energySumObjType = GlobalObject::gtCentrality1;
2237 cType = TypeCent1;
2238 } else if (condEnergySum.getType() == esConditionType::Centrality2) {
2239 energySumObjType = GlobalObject::gtCentrality2;
2240 cType = TypeCent2;
2241 } else if (condEnergySum.getType() == esConditionType::Centrality3) {
2242 energySumObjType = GlobalObject::gtCentrality3;
2243 cType = TypeCent3;
2244 } else if (condEnergySum.getType() == esConditionType::Centrality4) {
2245 energySumObjType = GlobalObject::gtCentrality4;
2246 cType = TypeCent4;
2247 } else if (condEnergySum.getType() == esConditionType::Centrality5) {
2248 energySumObjType = GlobalObject::gtCentrality5;
2249 cType = TypeCent5;
2250 } else if (condEnergySum.getType() == esConditionType::Centrality6) {
2251 energySumObjType = GlobalObject::gtCentrality6;
2252 cType = TypeCent6;
2253 } else if (condEnergySum.getType() == esConditionType::Centrality7) {
2254 energySumObjType = GlobalObject::gtCentrality7;
2255 cType = TypeCent7;
2256 } else {
2257 edm::LogError("TriggerMenuParser") << "Wrong type for energy-sum condition (" << type << ")" << std::endl;
2258 return false;
2259 }
2260
2261
2262 int nrObj = 1;
2263
2264
2265
2266
2267
2268
2269 std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2270
2271 int cnt = 0;
2272
2273
2274 int relativeBx = 0;
2275 bool gEq = false;
2276
2277
2278
2279
2280 const std::vector<esObject>& objects = condEnergySum.getObjects();
2281 for (size_t jj = 0; jj < objects.size(); jj++) {
2282 const esObject& object = objects.at(jj);
2283 gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
2284
2285
2286 relativeBx = object.getBxOffset();
2287
2288
2289 int lowerThresholdInd = 0;
2290 int upperThresholdInd = -1;
2291 int cntPhi = 0;
2292 unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
2293
2294 const std::vector<esCut>& cuts = object.getCuts();
2295 for (size_t kk = 0; kk < cuts.size(); kk++) {
2296 const esCut& cut = cuts.at(kk);
2297
2298 switch (cut.getCutType()) {
2299 case esCutType::Threshold:
2300 lowerThresholdInd = cut.getMinimum().index;
2301 upperThresholdInd = cut.getMaximum().index;
2302 break;
2303
2304 case esCutType::Eta:
2305 break;
2306
2307 case esCutType::Phi: {
2308 if (cntPhi == 0) {
2309 phiWindow1Lower = cut.getMinimum().index;
2310 phiWindow1Upper = cut.getMaximum().index;
2311 } else if (cntPhi == 1) {
2312 phiWindow2Lower = cut.getMinimum().index;
2313 phiWindow2Upper = cut.getMaximum().index;
2314 } else {
2315 edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition (" << type << ")" << std::endl;
2316 return false;
2317 }
2318 cntPhi++;
2319
2320 } break;
2321
2322 case esCutType::Count:
2323 lowerThresholdInd = cut.getMinimum().index;
2324 upperThresholdInd = 0xffffff;
2325 break;
2326
2327 default:
2328 break;
2329 }
2330
2331 }
2332
2333
2334 objParameter[cnt].etLowThreshold = lowerThresholdInd;
2335 objParameter[cnt].etHighThreshold = upperThresholdInd;
2336 objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
2337 objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
2338 objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
2339 objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
2340
2341
2342 LogDebug("TriggerMenuParser") << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2343 << std::hex << objParameter[cnt].etLowThreshold << " - "
2344 << objParameter[cnt].etHighThreshold
2345 << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2346 << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
2347 << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2348 << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper
2349 << std::dec << std::endl;
2350
2351 cnt++;
2352 }
2353
2354
2355 std::vector<GlobalObject> objType(nrObj, energySumObjType);
2356
2357
2358
2359 EnergySumTemplate energySumCond(name);
2360
2361 energySumCond.setCondType(cType);
2362 energySumCond.setObjectType(objType);
2363 energySumCond.setCondGEq(gEq);
2364 energySumCond.setCondChipNr(chipNr);
2365 energySumCond.setCondRelativeBx(relativeBx);
2366
2367 energySumCond.setConditionParameter(objParameter);
2368
2369 if (edm::isDebugEnabled()) {
2370 std::ostringstream myCoutStream;
2371 energySumCond.print(myCoutStream);
2372 LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2373 }
2374
2375
2376 if (!insertConditionIntoMap(energySumCond, chipNr)) {
2377 edm::LogError("TriggerMenuParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2378
2379 return false;
2380 } else {
2381 if (corrFlag) {
2382 (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2383
2384 } else {
2385 (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
2386 }
2387 }
2388
2389
2390 return true;
2391 }
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404 bool l1t::TriggerMenuParser::parseEnergySumCorr(const tmeventsetup::esObject* corrESum, unsigned int chipNr) {
2405
2406 using namespace tmeventsetup;
2407
2408
2409
2410 std::string condition = "calo";
2411 std::string type = l1t2string(corrESum->getType());
2412 std::string name = l1t2string(corrESum->getName());
2413
2414 LogDebug("TriggerMenuParser") << "\n ****************************************** "
2415 << "\n (in parseEnergySum) "
2416 << "\n condition = " << condition << "\n type = " << type
2417 << "\n name = " << name << std::endl;
2418
2419
2420 GlobalObject energySumObjType;
2421 GtConditionType cType;
2422
2423 if (corrESum->getType() == esObjectType::ETM) {
2424 energySumObjType = GlobalObject::gtETM;
2425 cType = TypeETM;
2426 } else if (corrESum->getType() == esObjectType::HTM) {
2427 energySumObjType = GlobalObject::gtHTM;
2428 cType = TypeHTM;
2429 } else if (corrESum->getType() == esObjectType::ETMHF) {
2430 energySumObjType = GlobalObject::gtETMHF;
2431 cType = TypeETMHF;
2432 } else if (corrESum->getType() == esObjectType::TOWERCOUNT) {
2433 energySumObjType = GlobalObject::gtTowerCount;
2434 cType = TypeTowerCount;
2435 } else {
2436 edm::LogError("TriggerMenuParser") << "Wrong type for energy-sum correclation condition (" << type << ")"
2437 << std::endl;
2438 return false;
2439 }
2440
2441
2442 int nrObj = 1;
2443
2444
2445
2446
2447
2448
2449 std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2450
2451 int cnt = 0;
2452
2453
2454 int relativeBx = 0;
2455 bool gEq = false;
2456
2457
2458
2459 gEq = (corrESum->getComparisonOperator() == esComparisonOperator::GE);
2460
2461
2462 relativeBx = corrESum->getBxOffset();
2463
2464
2465 int lowerThresholdInd = 0;
2466 int upperThresholdInd = -1;
2467 int cntPhi = 0;
2468 unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
2469
2470 const std::vector<esCut>& cuts = corrESum->getCuts();
2471 for (size_t kk = 0; kk < cuts.size(); kk++) {
2472 const esCut& cut = cuts.at(kk);
2473
2474 switch (cut.getCutType()) {
2475 case esCutType::Threshold:
2476 lowerThresholdInd = cut.getMinimum().index;
2477 upperThresholdInd = cut.getMaximum().index;
2478 break;
2479
2480 case esCutType::Eta:
2481 break;
2482
2483 case esCutType::Phi: {
2484 if (cntPhi == 0) {
2485 phiWindow1Lower = cut.getMinimum().index;
2486 phiWindow1Upper = cut.getMaximum().index;
2487 } else if (cntPhi == 1) {
2488 phiWindow2Lower = cut.getMinimum().index;
2489 phiWindow2Upper = cut.getMaximum().index;
2490 } else {
2491 edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition (" << type << ")" << std::endl;
2492 return false;
2493 }
2494 cntPhi++;
2495
2496 } break;
2497
2498 default:
2499 break;
2500 }
2501
2502 }
2503
2504
2505 objParameter[0].etLowThreshold = lowerThresholdInd;
2506 objParameter[0].etHighThreshold = upperThresholdInd;
2507 objParameter[0].phiWindow1Lower = phiWindow1Lower;
2508 objParameter[0].phiWindow1Upper = phiWindow1Upper;
2509 objParameter[0].phiWindow2Lower = phiWindow2Lower;
2510 objParameter[0].phiWindow2Upper = phiWindow2Upper;
2511
2512
2513 LogDebug("TriggerMenuParser") << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2514 << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etLowThreshold
2515 << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2516 << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
2517 << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2518 << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper
2519 << std::dec << std::endl;
2520
2521
2522 std::vector<GlobalObject> objType(nrObj, energySumObjType);
2523
2524
2525
2526 EnergySumTemplate energySumCond(name);
2527
2528 energySumCond.setCondType(cType);
2529 energySumCond.setObjectType(objType);
2530 energySumCond.setCondGEq(gEq);
2531 energySumCond.setCondChipNr(chipNr);
2532 energySumCond.setCondRelativeBx(relativeBx);
2533
2534 energySumCond.setConditionParameter(objParameter);
2535
2536 if (edm::isDebugEnabled()) {
2537 std::ostringstream myCoutStream;
2538 energySumCond.print(myCoutStream);
2539 LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2540 }
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557 (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2558
2559
2560 return true;
2561 }
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575 bool l1t::TriggerMenuParser::parseExternal(tmeventsetup::esCondition condExt, unsigned int chipNr) {
2576 using namespace tmeventsetup;
2577
2578
2579 std::string condition = "ext";
2580 std::string particle = "test-fix";
2581 std::string type = l1t2string(condExt.getType());
2582 std::string name = l1t2string(condExt.getName());
2583
2584 LogDebug("TriggerMenuParser") << "\n ****************************************** "
2585 << "\n (in parseExternal) "
2586 << "\n condition = " << condition << "\n particle = " << particle
2587 << "\n type = " << type << "\n name = " << name << std::endl;
2588
2589
2590
2591 GtConditionType cType = TypeExternal;
2592 GlobalObject extSignalType = GlobalObject::gtExternal;
2593 int nrObj = 1;
2594
2595 int relativeBx = 0;
2596 unsigned int channelID = 0;
2597
2598
2599 const std::vector<esObject>& objects = condExt.getObjects();
2600 for (size_t jj = 0; jj < objects.size(); jj++) {
2601 const esObject& object = objects.at(jj);
2602 if (object.getType() == esObjectType::EXT) {
2603 relativeBx = object.getBxOffset();
2604 channelID = object.getExternalChannelId();
2605 }
2606 }
2607
2608
2609 bool gEq = false;
2610
2611
2612 std::vector<GlobalObject> objType(nrObj, extSignalType);
2613
2614
2615 ExternalTemplate externalCond(name);
2616
2617 externalCond.setCondType(cType);
2618 externalCond.setObjectType(objType);
2619 externalCond.setCondGEq(gEq);
2620 externalCond.setCondChipNr(chipNr);
2621 externalCond.setCondRelativeBx(relativeBx);
2622 externalCond.setExternalChannel(channelID);
2623
2624 LogTrace("TriggerMenuParser") << externalCond << "\n" << std::endl;
2625
2626
2627 if (!insertConditionIntoMap(externalCond, chipNr)) {
2628 edm::LogError("TriggerMenuParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2629
2630 return false;
2631 } else {
2632 (m_vecExternalTemplate[chipNr]).push_back(externalCond);
2633 }
2634
2635 return true;
2636 }
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650 bool l1t::TriggerMenuParser::parseCorrelation(tmeventsetup::esCondition corrCond, unsigned int chipNr) {
2651 using namespace tmeventsetup;
2652
2653 std::string condition = "corr";
2654 std::string particle = "test-fix";
2655 std::string type = l1t2string(corrCond.getType());
2656 std::string name = l1t2string(corrCond.getName());
2657
2658 LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
2659 << " (in parseCorrelation) " << std::endl
2660 << " condition = " << condition << std::endl
2661 << " particle = " << particle << std::endl
2662 << " type = " << type << std::endl
2663 << " name = " << name << std::endl;
2664
2665
2666 CorrelationTemplate correlationCond(name);
2667
2668
2669 if (!insertConditionIntoMap(correlationCond, chipNr)) {
2670 edm::LogError("TriggerMenuParser") << " Error: duplicate correlation condition (" << name << ")" << std::endl;
2671
2672 return false;
2673 }
2674
2675
2676
2677
2678 GtConditionType cType = l1t::Type2cor;
2679
2680
2681 const int nrObj = 2;
2682
2683
2684 int intGEq[nrObj] = {-1, -1};
2685 std::vector<GlobalObject> objType(nrObj);
2686 std::vector<GtConditionCategory> condCateg(nrObj);
2687
2688
2689 const bool corrFlag = true;
2690 int corrIndexVal[nrObj] = {-1, -1};
2691
2692
2693 CorrelationTemplate::CorrelationParameter corrParameter;
2694 corrParameter.chargeCorrelation = 1;
2695
2696
2697 int cutType = 0;
2698 const std::vector<esCut>& cuts = corrCond.getCuts();
2699 for (size_t jj = 0; jj < cuts.size(); jj++) {
2700 const esCut& cut = cuts.at(jj);
2701
2702 if (cut.getCutType() == esCutType::ChargeCorrelation) {
2703 if (cut.getData() == "ls")
2704 corrParameter.chargeCorrelation = 2;
2705 else if (cut.getData() == "os")
2706 corrParameter.chargeCorrelation = 4;
2707 else
2708 corrParameter.chargeCorrelation = 1;
2709 } else {
2710
2711
2712
2713 double minV = cut.getMinimum().value;
2714 double maxV = cut.getMaximum().value;
2715
2716
2717 if (maxV > 1.0e8)
2718 maxV = 1.0e8;
2719
2720 if (cut.getCutType() == esCutType::DeltaEta) {
2721 LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaEta Cut minV = " << minV
2722 << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2723 << " precMax = " << cut.getMaximum().index << std::endl;
2724 corrParameter.minEtaCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2725 corrParameter.maxEtaCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2726 corrParameter.precEtaCut = cut.getMinimum().index;
2727 cutType = cutType | 0x1;
2728 } else if (cut.getCutType() == esCutType::DeltaPhi) {
2729 LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaPhi Cut minV = " << minV
2730 << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2731 << " precMax = " << cut.getMaximum().index << std::endl;
2732 corrParameter.minPhiCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2733 corrParameter.maxPhiCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2734 corrParameter.precPhiCut = cut.getMinimum().index;
2735 cutType = cutType | 0x2;
2736 } else if (cut.getCutType() == esCutType::DeltaR) {
2737 LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaR Cut minV = " << minV
2738 << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2739 << " precMax = " << cut.getMaximum().index << std::endl;
2740 corrParameter.minDRCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2741 corrParameter.maxDRCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2742 corrParameter.precDRCut = cut.getMinimum().index;
2743 cutType = cutType | 0x4;
2744 } else if (cut.getCutType() == esCutType::TwoBodyPt) {
2745 corrParameter.minTBPTCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2746 corrParameter.maxTBPTCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2747 corrParameter.precTBPTCut = cut.getMinimum().index;
2748 LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tTPBT Cut minV = " << minV
2749 << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2750 << " precMax = " << cut.getMaximum().index << std::endl;
2751 cutType = cutType | 0x20;
2752 } else if ((cut.getCutType() == esCutType::Mass) ||
2753 (cut.getCutType() == esCutType::MassDeltaR)) {
2754 LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tMass Cut minV = " << minV
2755 << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2756 << " precMax = " << cut.getMaximum().index << std::endl;
2757 corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2758 corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2759 corrParameter.precMassCut = cut.getMinimum().index;
2760
2761 if (corrCond.getType() == esConditionType::TransverseMass) {
2762 cutType = cutType | 0x10;
2763 } else if (corrCond.getType() == esConditionType::InvariantMassDeltaR) {
2764 cutType = cutType | 0x80;
2765 } else {
2766 cutType = cutType | 0x8;
2767 }
2768 } else if (cut.getCutType() == esCutType::MassUpt) {
2769 LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tMass Cut minV = " << minV
2770 << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2771 << " precMax = " << cut.getMaximum().index << std::endl;
2772 corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2773 corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2774 corrParameter.precMassCut = cut.getMinimum().index;
2775 cutType = cutType | 0x40;
2776 }
2777 }
2778 }
2779 corrParameter.corrCutType = cutType;
2780
2781
2782 const std::vector<esObject>& objects = corrCond.getObjects();
2783 if (objects.size() != 2) {
2784 edm::LogError("TriggerMenuParser") << "incorrect number of objects for the correlation condition " << name
2785 << " corrFlag " << corrFlag << std::endl;
2786 return false;
2787 }
2788
2789
2790 for (size_t jj = 0; jj < objects.size(); jj++) {
2791 const esObject& object = objects.at(jj);
2792 LogDebug("TriggerMenuParser") << " obj name = " << object.getName() << "\n";
2793 LogDebug("TriggerMenuParser") << " obj type = " << object.getType() << "\n";
2794 LogDebug("TriggerMenuParser") << " obj op = " << object.getComparisonOperator() << "\n";
2795 LogDebug("TriggerMenuParser") << " obj bx = " << object.getBxOffset() << "\n";
2796
2797
2798 if (object.getType() == esObjectType::Muon) {
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832 parseMuonCorr(&object, chipNr);
2833 corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
2834
2835
2836 intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2837 objType[jj] = gtMu;
2838 condCateg[jj] = CondMuon;
2839
2840 } else if (object.getType() == esObjectType::Egamma || object.getType() == esObjectType::Jet ||
2841 object.getType() == esObjectType::Tau) {
2842
2843 parseCaloCorr(&object, chipNr);
2844 corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
2845
2846
2847 intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2848 switch (object.getType()) {
2849 case esObjectType::Egamma: {
2850 objType[jj] = gtEG;
2851 } break;
2852 case esObjectType::Jet: {
2853 objType[jj] = gtJet;
2854 } break;
2855 case esObjectType::Tau: {
2856 objType[jj] = gtTau;
2857 } break;
2858 default: {
2859 } break;
2860 }
2861 condCateg[jj] = CondCalo;
2862
2863 } else if (object.getType() == esObjectType::ETM || object.getType() == esObjectType::ETMHF ||
2864 object.getType() == esObjectType::TOWERCOUNT || object.getType() == esObjectType::HTM) {
2865
2866 parseEnergySumCorr(&object, chipNr);
2867 corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
2868
2869
2870 intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
2871 switch (object.getType()) {
2872 case esObjectType::ETM: {
2873 objType[jj] = GlobalObject::gtETM;
2874 } break;
2875 case esObjectType::HTM: {
2876 objType[jj] = GlobalObject::gtHTM;
2877 } break;
2878 case esObjectType::ETMHF: {
2879 objType[jj] = GlobalObject::gtETMHF;
2880 } break;
2881 case esObjectType::TOWERCOUNT: {
2882 objType[jj] = GlobalObject::gtTowerCount;
2883 } break;
2884 default: {
2885 } break;
2886 }
2887 condCateg[jj] = CondEnergySum;
2888
2889 } else {
2890 edm::LogError("TriggerMenuParser") << "Illegal Object Type " << object.getType()
2891 << " for the correlation condition " << name << std::endl;
2892 return false;
2893
2894 }
2895
2896 }
2897
2898
2899 bool gEq = true;
2900 if (intGEq[0] != intGEq[1]) {
2901 edm::LogError("TriggerMenuParser") << "Inconsistent GEq flags for sub-conditions "
2902 << " for the correlation condition " << name << std::endl;
2903 return false;
2904
2905 } else {
2906 gEq = (intGEq[0] != 0);
2907 }
2908
2909
2910 correlationCond.setCondType(cType);
2911 correlationCond.setObjectType(objType);
2912 correlationCond.setCondGEq(gEq);
2913 correlationCond.setCondChipNr(chipNr);
2914
2915 correlationCond.setCond0Category(condCateg[0]);
2916 correlationCond.setCond1Category(condCateg[1]);
2917
2918 correlationCond.setCond0Index(corrIndexVal[0]);
2919 correlationCond.setCond1Index(corrIndexVal[1]);
2920
2921 correlationCond.setCorrelationParameter(corrParameter);
2922
2923 if (edm::isDebugEnabled()) {
2924 std::ostringstream myCoutStream;
2925 correlationCond.print(myCoutStream);
2926 LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2927 }
2928
2929
2930
2931
2932 (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
2933
2934
2935 return true;
2936 }
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951 bool l1t::TriggerMenuParser::parseCorrelationThreeBody(tmeventsetup::esCondition corrCond, unsigned int chipNr) {
2952 using namespace tmeventsetup;
2953
2954 std::string condition = "corrThreeBody";
2955 std::string particle = "muon";
2956 std::string type = l1t2string(corrCond.getType());
2957 std::string name = l1t2string(corrCond.getName());
2958
2959 LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
2960 << " (in parseCorrelationThreeBody) " << std::endl
2961 << " condition = " << condition << std::endl
2962 << " particle = " << particle << std::endl
2963 << " type = " << type << std::endl
2964 << " name = " << name << std::endl;
2965
2966
2967 CorrelationThreeBodyTemplate correlationThreeBodyCond(name);
2968
2969
2970 if (!insertConditionIntoMap(correlationThreeBodyCond, chipNr)) {
2971 edm::LogError("TriggerMenuParser") << " Error: duplicate correlation condition (" << name << ")" << std::endl;
2972 return false;
2973 }
2974
2975
2976 GtConditionType cType = l1t::Type3s;
2977
2978
2979 const int nrObj = 3;
2980
2981
2982 std::vector<GlobalObject> objType(nrObj);
2983 std::vector<GtConditionCategory> condCateg(nrObj);
2984
2985
2986 const bool corrFlag = true;
2987 int corrIndexVal[nrObj] = {-1, -1, -1};
2988
2989
2990 CorrelationThreeBodyTemplate::CorrelationThreeBodyParameter corrThreeBodyParameter;
2991
2992
2993
2994
2995
2996 int cutType = 0;
2997 const std::vector<esCut>& cuts = corrCond.getCuts();
2998 for (size_t lll = 0; lll < cuts.size(); lll++) {
2999 const esCut& cut = cuts.at(lll);
3000
3001 if (cut.getCutType() == esCutType::ChargeCorrelation) {
3002 if (cut.getData() == "ls")
3003 corrThreeBodyParameter.chargeCorrelation = 2;
3004 else if (cut.getData() == "os")
3005 corrThreeBodyParameter.chargeCorrelation = 4;
3006 else
3007 corrThreeBodyParameter.chargeCorrelation = 1;
3008 }
3009
3010
3011
3012
3013 double minV = cut.getMinimum().value;
3014 double maxV = cut.getMaximum().value;
3015
3016 if (maxV > 1.0e8)
3017 maxV = 1.0e8;
3018
3019 if (cut.getCutType() == esCutType::Mass) {
3020 LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tMass Cut minV = " << minV
3021 << "\tMass Cut maxV = " << maxV << " precMin = " << cut.getMinimum().index
3022 << " precMax = " << cut.getMaximum().index << std::endl;
3023 corrThreeBodyParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3024 corrThreeBodyParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3025 corrThreeBodyParameter.precMassCut = cut.getMinimum().index;
3026 cutType = cutType | 0x8;
3027 } else if (cut.getCutType() == esCutType::MassDeltaR) {
3028 corrThreeBodyParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3029 corrThreeBodyParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3030 corrThreeBodyParameter.precMassCut = cut.getMinimum().index;
3031 cutType = cutType | 0x80;
3032 }
3033 }
3034 corrThreeBodyParameter.corrCutType = cutType;
3035
3036
3037 const std::vector<esObject>& objects = corrCond.getObjects();
3038 if (objects.size() != 3) {
3039 edm::LogError("TriggerMenuParser") << "incorrect number of objects for the correlation condition " << name
3040 << " corrFlag " << corrFlag << std::endl;
3041 return false;
3042 }
3043
3044
3045 for (size_t lll = 0; lll < objects.size(); lll++) {
3046 const esObject& object = objects.at(lll);
3047 LogDebug("TriggerMenuParser") << " obj name = " << object.getName() << "\n";
3048 LogDebug("TriggerMenuParser") << " obj type = " << object.getType() << "\n";
3049 LogDebug("TriggerMenuParser") << " obj bx = " << object.getBxOffset() << "\n";
3050
3051
3052 if (object.getType() == esObjectType::Muon) {
3053
3054 parseMuonCorr(&object, chipNr);
3055 corrIndexVal[lll] = (m_corMuonTemplate[chipNr]).size() - 1;
3056
3057
3058 objType[lll] = gtMu;
3059 condCateg[lll] = CondMuon;
3060
3061 } else {
3062 edm::LogError("TriggerMenuParser") << "Checked the object Type " << object.getType()
3063 << " for the correlation condition " << name
3064 << ": no three muons in the event!" << std::endl;
3065 }
3066 }
3067
3068
3069 correlationThreeBodyCond.setCondType(cType);
3070 correlationThreeBodyCond.setObjectType(objType);
3071 correlationThreeBodyCond.setCondChipNr(chipNr);
3072
3073 correlationThreeBodyCond.setCond0Category(condCateg[0]);
3074 correlationThreeBodyCond.setCond1Category(condCateg[1]);
3075 correlationThreeBodyCond.setCond2Category(condCateg[2]);
3076
3077 correlationThreeBodyCond.setCond0Index(corrIndexVal[0]);
3078 correlationThreeBodyCond.setCond1Index(corrIndexVal[1]);
3079 correlationThreeBodyCond.setCond2Index(corrIndexVal[2]);
3080
3081 correlationThreeBodyCond.setCorrelationThreeBodyParameter(corrThreeBodyParameter);
3082
3083 if (edm::isDebugEnabled()) {
3084 std::ostringstream myCoutStream;
3085 correlationThreeBodyCond.print(myCoutStream);
3086 LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
3087 }
3088
3089
3090
3091
3092 (m_vecCorrelationThreeBodyTemplate[chipNr]).push_back(correlationThreeBodyCond);
3093
3094
3095 return true;
3096 }
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111 bool l1t::TriggerMenuParser::parseCorrelationWithOverlapRemoval(const tmeventsetup::esCondition& corrCond,
3112 unsigned int chipNr) {
3113 using namespace tmeventsetup;
3114
3115 std::string condition = "corrWithOverlapRemoval";
3116 std::string particle = "test-fix";
3117 std::string type = l1t2string(corrCond.getType());
3118 std::string name = l1t2string(corrCond.getName());
3119
3120 LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
3121 << " (in parseCorrelationWithOverlapRemoval) " << std::endl
3122 << " condition = " << condition << std::endl
3123 << " particle = " << particle << std::endl
3124 << " type = " << type << std::endl
3125 << " name = " << name << std::endl;
3126
3127
3128 CorrelationWithOverlapRemovalTemplate correlationWORCond(name);
3129
3130
3131 if (!insertConditionIntoMap(correlationWORCond, chipNr)) {
3132 edm::LogError("TriggerMenuParser") << " Error: duplicate correlation condition (" << name << ")" << std::endl;
3133
3134 return false;
3135 }
3136
3137
3138
3139
3140 GtConditionType cType = l1t::Type2corWithOverlapRemoval;
3141
3142
3143 const int nrObj = 3;
3144
3145
3146 int intGEq[nrObj] = {-1, -1, -1};
3147 std::vector<GlobalObject> objType(nrObj);
3148 std::vector<GtConditionCategory> condCateg(nrObj);
3149
3150
3151 const bool corrFlag = true;
3152 int corrIndexVal[nrObj] = {-1, -1, -1};
3153
3154
3155 CorrelationWithOverlapRemovalTemplate::CorrelationWithOverlapRemovalParameter corrParameter;
3156 corrParameter.chargeCorrelation = 1;
3157
3158
3159 int cutType = 0;
3160 const std::vector<esCut>& cuts = corrCond.getCuts();
3161 for (size_t jj = 0; jj < cuts.size(); jj++) {
3162 const esCut& cut = cuts.at(jj);
3163
3164 if (cut.getCutType() == esCutType::ChargeCorrelation) {
3165 if (cut.getData() == "ls")
3166 corrParameter.chargeCorrelation = 2;
3167 else if (cut.getData() == "os")
3168 corrParameter.chargeCorrelation = 4;
3169 else
3170 corrParameter.chargeCorrelation = 1;
3171 } else {
3172
3173
3174
3175 double minV = cut.getMinimum().value;
3176 double maxV = cut.getMaximum().value;
3177
3178
3179 if (maxV > 1.0e8)
3180 maxV = 1.0e8;
3181
3182 if (cut.getCutType() == esCutType::DeltaEta) {
3183
3184 corrParameter.minEtaCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3185 corrParameter.maxEtaCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3186 corrParameter.precEtaCut = cut.getMinimum().index;
3187 cutType = cutType | 0x1;
3188 } else if (cut.getCutType() == esCutType::DeltaPhi) {
3189
3190 corrParameter.minPhiCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3191 corrParameter.maxPhiCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3192 corrParameter.precPhiCut = cut.getMinimum().index;
3193 cutType = cutType | 0x2;
3194 } else if (cut.getCutType() == esCutType::DeltaR) {
3195
3196 corrParameter.minDRCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3197 corrParameter.maxDRCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3198 corrParameter.precDRCut = cut.getMinimum().index;
3199 cutType = cutType | 0x4;
3200 } else if (cut.getCutType() == esCutType::Mass) {
3201
3202 corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3203 corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3204 corrParameter.precMassCut = cut.getMinimum().index;
3205 cutType = cutType | 0x8;
3206 } else if (cut.getCutType() == esCutType::MassDeltaR) {
3207 corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3208 corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3209 corrParameter.precMassCut = cut.getMinimum().index;
3210 cutType = cutType | 0x80;
3211 }
3212 if (cut.getCutType() == esCutType::OvRmDeltaEta) {
3213
3214 corrParameter.minOverlapRemovalEtaCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3215 corrParameter.maxOverlapRemovalEtaCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3216 corrParameter.precOverlapRemovalEtaCut = cut.getMinimum().index;
3217 cutType = cutType | 0x10;
3218 } else if (cut.getCutType() == esCutType::OvRmDeltaPhi) {
3219
3220 corrParameter.minOverlapRemovalPhiCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3221 corrParameter.maxOverlapRemovalPhiCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3222 corrParameter.precOverlapRemovalPhiCut = cut.getMinimum().index;
3223 cutType = cutType | 0x20;
3224 } else if (cut.getCutType() == esCutType::OvRmDeltaR) {
3225
3226 corrParameter.minOverlapRemovalDRCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3227 corrParameter.maxOverlapRemovalDRCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3228 corrParameter.precOverlapRemovalDRCut = cut.getMinimum().index;
3229 cutType = cutType | 0x40;
3230 }
3231 }
3232 }
3233 corrParameter.corrCutType = cutType;
3234
3235
3236 const std::vector<esObject>& objects = corrCond.getObjects();
3237 if (objects.size() != 3) {
3238 edm::LogError("TriggerMenuParser")
3239 << "incorrect number of objects for the correlation condition with overlap removal " << name << " corrFlag "
3240 << corrFlag << std::endl;
3241 return false;
3242 }
3243
3244
3245 for (size_t jj = 0; jj < objects.size(); jj++) {
3246 const esObject& object = objects.at(jj);
3247 LogDebug("TriggerMenuParser") << " obj name = " << object.getName() << "\n";
3248 LogDebug("TriggerMenuParser") << " obj type = " << object.getType() << "\n";
3249 LogDebug("TriggerMenuParser") << " obj op = " << object.getComparisonOperator() << "\n";
3250 LogDebug("TriggerMenuParser") << " obj bx = " << object.getBxOffset() << "\n";
3251 LogDebug("TriggerMenuParser") << "type = done" << std::endl;
3252
3253
3254 if (object.getType() == esObjectType::Muon) {
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288 parseMuonCorr(&object, chipNr);
3289 corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
3290
3291
3292 intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3293 objType[jj] = gtMu;
3294 condCateg[jj] = CondMuon;
3295
3296 } else if (object.getType() == esObjectType::Egamma || object.getType() == esObjectType::Jet ||
3297 object.getType() == esObjectType::Tau) {
3298
3299 parseCaloCorr(&object, chipNr);
3300 corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
3301
3302
3303 intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3304 switch (object.getType()) {
3305 case esObjectType::Egamma: {
3306 objType[jj] = gtEG;
3307 } break;
3308 case esObjectType::Jet: {
3309 objType[jj] = gtJet;
3310 } break;
3311 case esObjectType::Tau: {
3312 objType[jj] = gtTau;
3313 } break;
3314 default: {
3315 } break;
3316 }
3317 condCateg[jj] = CondCalo;
3318
3319 } else if (object.getType() == esObjectType::ETM || object.getType() == esObjectType::ETMHF ||
3320 object.getType() == esObjectType::TOWERCOUNT || object.getType() == esObjectType::HTM) {
3321
3322 parseEnergySumCorr(&object, chipNr);
3323 corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
3324
3325
3326 intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3327 switch (object.getType()) {
3328 case esObjectType::ETM: {
3329 objType[jj] = GlobalObject::gtETM;
3330 } break;
3331 case esObjectType::HTM: {
3332 objType[jj] = GlobalObject::gtHTM;
3333 } break;
3334 case esObjectType::ETMHF: {
3335 objType[jj] = GlobalObject::gtETMHF;
3336 } break;
3337 case esObjectType::TOWERCOUNT: {
3338 objType[jj] = GlobalObject::gtTowerCount;
3339 } break;
3340 default: {
3341 } break;
3342 }
3343 condCateg[jj] = CondEnergySum;
3344
3345 } else {
3346 edm::LogError("TriggerMenuParser") << "Illegal Object Type " << object.getType()
3347 << " for the correlation condition " << name << std::endl;
3348 return false;
3349
3350 }
3351
3352 }
3353
3354
3355 bool gEq = true;
3356 if (intGEq[0] != intGEq[1]) {
3357 edm::LogError("TriggerMenuParser") << "Inconsistent GEq flags for sub-conditions "
3358 << " for the correlation condition " << name << std::endl;
3359 return false;
3360
3361 } else {
3362 gEq = (intGEq[0] != 0);
3363 }
3364
3365
3366 correlationWORCond.setCondType(cType);
3367 correlationWORCond.setObjectType(objType);
3368 correlationWORCond.setCondGEq(gEq);
3369 correlationWORCond.setCondChipNr(chipNr);
3370
3371 correlationWORCond.setCond0Category(condCateg[0]);
3372 correlationWORCond.setCond1Category(condCateg[1]);
3373 correlationWORCond.setCond2Category(condCateg[2]);
3374
3375 correlationWORCond.setCond0Index(corrIndexVal[0]);
3376 correlationWORCond.setCond1Index(corrIndexVal[1]);
3377 correlationWORCond.setCond2Index(corrIndexVal[2]);
3378
3379 correlationWORCond.setCorrelationWithOverlapRemovalParameter(corrParameter);
3380
3381 if (edm::isDebugEnabled()) {
3382 std::ostringstream myCoutStream;
3383 correlationWORCond.print(myCoutStream);
3384 LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
3385 }
3386
3387
3388
3389
3390 (m_vecCorrelationWithOverlapRemovalTemplate[chipNr]).push_back(correlationWORCond);
3391
3392
3393 return true;
3394 }
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407 bool l1t::TriggerMenuParser::parseAlgorithm(tmeventsetup::esAlgorithm algorithm, unsigned int chipNr) {
3408 using namespace tmeventsetup;
3409
3410
3411
3412 std::string algAlias = algorithm.getName();
3413 const std::string& algName = algorithm.getName();
3414
3415 if (algAlias.empty()) {
3416 algAlias = algName;
3417 LogDebug("TriggerMenuParser") << "\n No alias defined for algorithm. Alias set to algorithm name."
3418 << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3419 << std::endl;
3420 } else {
3421
3422 LogDebug("TriggerMenuParser") << "\n Alias defined for algorithm."
3423 << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3424 << std::endl;
3425 }
3426
3427
3428 const std::string& logExpression = algorithm.getExpressionInCondition();
3429
3430 LogDebug("TriggerMenuParser") << " Logical expression: " << logExpression
3431 << " Chip number: " << chipNr << std::endl;
3432
3433
3434 int outputPin = algorithm.getIndex();
3435
3436
3437 LogDebug("TriggerMenuParser") << " Output pin: " << outputPin << std::endl;
3438
3439
3440
3441 int bitNumber = outputPin;
3442
3443
3444 LogDebug("TriggerMenuParser") << " Bit number: " << bitNumber << std::endl;
3445
3446
3447 GlobalAlgorithm alg(algName, logExpression, bitNumber);
3448 alg.setAlgoChipNumber(static_cast<int>(chipNr));
3449 alg.setAlgoAlias(algAlias);
3450
3451 if (edm::isDebugEnabled()) {
3452 std::ostringstream myCoutStream;
3453 alg.print(myCoutStream);
3454 LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
3455 }
3456
3457
3458 if (!insertAlgorithmIntoMap(alg)) {
3459 return false;
3460 }
3461
3462 return true;
3463 }
3464
3465