From ad241909a633bfe6143da4fd8b246c377f949ced Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Tue, 25 Aug 2015 01:17:51 +0200 Subject: [PATCH 1/5] cleanup some const_cast - L1GtVhdlWriterCore: get rid of an unnecessary const_cast - L1GtTriggerMenuXmlParser: fix the input parameter of strtol --- .../src/L1GtTriggerMenuXmlParser.cc | 6 +++--- .../L1GtConfigProducers/src/L1GtVhdlWriterCore.cc | 12 ++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/L1TriggerConfig/L1GtConfigProducers/src/L1GtTriggerMenuXmlParser.cc b/L1TriggerConfig/L1GtConfigProducers/src/L1GtTriggerMenuXmlParser.cc index 542044d699d31..56d0e22a4c8d1 100644 --- a/L1TriggerConfig/L1GtConfigProducers/src/L1GtTriggerMenuXmlParser.cc +++ b/L1TriggerConfig/L1GtConfigProducers/src/L1GtTriggerMenuXmlParser.cc @@ -2178,7 +2178,7 @@ bool L1GtTriggerMenuXmlParser::parseJetCounts(XERCES_CPP_NAMESPACE::DOMNode* nod // get countIndex value and fill into structure // they are expressed in base 10 (values: 0 - m_numberL1JetCounts) - char* endPtr = const_cast(type.c_str()); + char* endPtr = nullptr; long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10 if (*endPtr != 0) { @@ -2426,7 +2426,7 @@ bool L1GtTriggerMenuXmlParser::parseHfBitCounts(XERCES_CPP_NAMESPACE::DOMNode* n // get countIndex value and fill into structure // they are expressed in base 10 - char* endPtr = const_cast(type.c_str()); + char* endPtr = nullptr; long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10 if (*endPtr != 0) { @@ -2558,7 +2558,7 @@ bool L1GtTriggerMenuXmlParser::parseHfRingEtSums(XERCES_CPP_NAMESPACE::DOMNode* // get etSumIndex value and fill into structure // they are expressed in base 10 - char* endPtr = const_cast(type.c_str()); + char* endPtr = nullptr; long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10 if (*endPtr != 0) { diff --git a/L1TriggerConfig/L1GtConfigProducers/src/L1GtVhdlWriterCore.cc b/L1TriggerConfig/L1GtConfigProducers/src/L1GtVhdlWriterCore.cc index 5e8f10a7b31cb..686816ec10573 100644 --- a/L1TriggerConfig/L1GtConfigProducers/src/L1GtVhdlWriterCore.cc +++ b/L1TriggerConfig/L1GtConfigProducers/src/L1GtVhdlWriterCore.cc @@ -847,18 +847,14 @@ bool L1GtVhdlWriterCore::processAlgorithmMap(std::vector< std::map * conditionMapCp = const_cast< std::vector* >(conditionMap_); - - L1GtCondition* cond = (*conditionMapCp).at((algoIter->second).algoChipNumber())[conditions.at(i)]; + ConditionMap const& chip = conditionMap_->at(algoIter->second.algoChipNumber()); + L1GtCondition const* cond = (chip.find(conditions.at(i)) == chip.end()) ? nullptr : chip.at(conditions.at(i)); // check weather condition exists if (cond!=NULL) { - newExpr<objectType()).at(0)]; - - newExpr <<"_" << condType2Str_[cond->condType()] << "("; - + newExpr << objType2Str_[(cond->objectType()).at(0)]; + newExpr << "_" << condType2Str_[cond->condType()] << "("; newExpr << conditionToIntegerMap_[conditions.at(i)] << ")"; dummy.findAndReplaceString(logicalExpr, conditions.at(i), newExpr.str()); From 4ae7d8c86d1f1750133bdaef270130abb23d8b24 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Thu, 27 Aug 2015 09:10:29 +0200 Subject: [PATCH 2/5] initialise L1GtTriggerMenu objects before making them available in the EventSetup --- CondCore/L1TPlugins/src/plugin.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CondCore/L1TPlugins/src/plugin.cc b/CondCore/L1TPlugins/src/plugin.cc index 8c2b723060ee8..64eebb17bb5eb 100644 --- a/CondCore/L1TPlugins/src/plugin.cc +++ b/CondCore/L1TPlugins/src/plugin.cc @@ -182,7 +182,10 @@ REGISTER_PLUGIN(L1GtTriggerMaskVetoTechTrigRcd, L1GtTriggerMask); #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h" #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h" -REGISTER_PLUGIN(L1GtTriggerMenuRcd, L1GtTriggerMenu); +namespace { + struct L1GtTriggerMenuInitializer { void operator()(L1GtTriggerMenu & _) { _.buildGtConditionMap(); } }; +} +REGISTER_PLUGIN_INIT(L1GtTriggerMenuRcd, L1GtTriggerMenu, L1GtTriggerMenuInitializer); #include "CondFormats/L1TObjects/interface/L1GtPsbSetup.h" #include "CondFormats/DataRecord/interface/L1GtPsbSetupRcd.h" From 6c422358c0144955b8c04314b6cb407ccda1b12e Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Thu, 27 Aug 2015 09:34:44 +0200 Subject: [PATCH 3/5] fix use of L1GtTriggerMenu L1GtTriggerMenu is now properly initialised by the EventSetup framework, so there is no longer need to call (const_cast(l1GtTriggerMenu))->buildGtConditionMap(); or to keep a local copy for that purpose --- DQM/HLTEvF/plugins/TriggerRatesMonitor.cc | 2 -- DQM/L1TMonitor/src/L1GtHwValidation.cc | 1 - HLTrigger/HLTcore/src/TriggerExpressionData.cc | 1 - HLTrigger/HLTfilters/interface/HLTLevel1GTSeed.h | 2 +- HLTrigger/HLTfilters/src/HLTLevel1GTSeed.cc | 15 ++++++--------- L1Trigger/GlobalTrigger/src/L1GlobalTriggerGTL.cc | 3 --- .../src/L1GtTriggerMenuTester.cc | 3 --- .../PatAlgos/plugins/PATTriggerProducer.cc | 8 +++----- 8 files changed, 10 insertions(+), 25 deletions(-) diff --git a/DQM/HLTEvF/plugins/TriggerRatesMonitor.cc b/DQM/HLTEvF/plugins/TriggerRatesMonitor.cc index 7dbe76f7938b3..c57c38ba0299a 100644 --- a/DQM/HLTEvF/plugins/TriggerRatesMonitor.cc +++ b/DQM/HLTEvF/plugins/TriggerRatesMonitor.cc @@ -186,8 +186,6 @@ void TriggerRatesMonitor::dqmBeginRun(edm::Run const & run, edm::EventSetup cons // cache the L1 trigger menu m_l1tMenu = get(setup); - // FIXME - do we really need this ? - //(const_cast(m_l1tMenu))->buildGtConditionMap(); m_l1tAlgoMask = get(setup); m_l1tTechMask = get(setup); if (m_l1tMenu and m_l1tAlgoMask and m_l1tTechMask) { diff --git a/DQM/L1TMonitor/src/L1GtHwValidation.cc b/DQM/L1TMonitor/src/L1GtHwValidation.cc index 09d4a8f1566f6..2d5afb31a2cfc 100644 --- a/DQM/L1TMonitor/src/L1GtHwValidation.cc +++ b/DQM/L1TMonitor/src/L1GtHwValidation.cc @@ -2330,7 +2330,6 @@ void L1GtHwValidation::excludedAlgoList() { const AlgorithmMap& algorithmMap = m_l1GtMenu->gtAlgorithmMap(); - (const_cast (m_l1GtMenu))->buildGtConditionMap(); //...ugly for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) { diff --git a/HLTrigger/HLTcore/src/TriggerExpressionData.cc b/HLTrigger/HLTcore/src/TriggerExpressionData.cc index e1ce340188ef5..d4a7396965d3f 100644 --- a/HLTrigger/HLTcore/src/TriggerExpressionData.cc +++ b/HLTrigger/HLTcore/src/TriggerExpressionData.cc @@ -62,7 +62,6 @@ bool Data::setEvent(const edm::Event & event, const edm::EventSetup & setup) { m_l1tUpdated = false; } else { m_l1tMenu = get(setup); - (const_cast(m_l1tMenu))->buildGtConditionMap(); m_l1tCacheID = l1tCacheID; m_l1tUpdated = true; } diff --git a/HLTrigger/HLTfilters/interface/HLTLevel1GTSeed.h b/HLTrigger/HLTfilters/interface/HLTLevel1GTSeed.h index 949136999ca98..8ed55c20fe2be 100644 --- a/HLTrigger/HLTfilters/interface/HLTLevel1GTSeed.h +++ b/HLTrigger/HLTfilters/interface/HLTLevel1GTSeed.h @@ -112,7 +112,7 @@ class HLTLevel1GTSeed : public HLTStreamFilter // cached stuff /// trigger menu - L1GtTriggerMenu * m_l1GtMenu; + const L1GtTriggerMenu * m_l1GtMenu; unsigned long long m_l1GtMenuCacheID; /// logic parser for m_l1SeedsLogicalExpression diff --git a/HLTrigger/HLTfilters/src/HLTLevel1GTSeed.cc b/HLTrigger/HLTfilters/src/HLTLevel1GTSeed.cc index e739ca9b453c7..991910f63baf6 100644 --- a/HLTrigger/HLTfilters/src/HLTLevel1GTSeed.cc +++ b/HLTrigger/HLTfilters/src/HLTLevel1GTSeed.cc @@ -74,7 +74,11 @@ // constructors HLTLevel1GTSeed::HLTLevel1GTSeed(const edm::ParameterSet& parSet) : HLTStreamFilter(parSet), - // seeding done via L1 trigger object maps, with objects that fired + // initialize the cache + m_l1GtMenu( nullptr ), + m_l1GtMenuCacheID( 0ULL ), + + // seeding done via L1 trigger object maps, with objects that fired m_l1UseL1TriggerObjectMaps(parSet.getParameter ( "L1UseL1TriggerObjectMaps")), @@ -180,10 +184,6 @@ HLTLevel1GTSeed::HLTLevel1GTSeed(const edm::ParameterSet& parSet) : HLTStreamFil << m_l1CollectionsTag << " \n" << "Input tag for L1 muon collections: " << m_l1MuonCollectionTag << " \n" << std::endl; - - // initialize cache - m_l1GtMenu = nullptr; - m_l1GtMenuCacheID = 0ULL; } // destructor @@ -348,10 +348,7 @@ bool HLTLevel1GTSeed::hltFilter(edm::Event& iEvent, const edm::EventSetup& evSet edm::ESHandle l1GtMenu; evSetup.get().get(l1GtMenu); - // make a copy of the L1GtTriggerMenu in order to call buildGtConditionMap() (FIXME - is this really needed ?) - delete m_l1GtMenu; - m_l1GtMenu = new L1GtTriggerMenu(* l1GtMenu.product()); - m_l1GtMenu->buildGtConditionMap(); + m_l1GtMenu = l1GtMenu.product(); m_l1GtMenuCacheID = l1GtMenuCacheID; const AlgorithmMap& algorithmMap = l1GtMenu->gtAlgorithmMap(); diff --git a/L1Trigger/GlobalTrigger/src/L1GlobalTriggerGTL.cc b/L1Trigger/GlobalTrigger/src/L1GlobalTriggerGTL.cc index d04565675a1ef..a854c9b7545af 100644 --- a/L1Trigger/GlobalTrigger/src/L1GlobalTriggerGTL.cc +++ b/L1Trigger/GlobalTrigger/src/L1GlobalTriggerGTL.cc @@ -197,10 +197,7 @@ void L1GlobalTriggerGTL::run( edm::ESHandle< L1GtTriggerMenu> l1GtMenu; evSetup.get< L1GtTriggerMenuRcd>().get(l1GtMenu) ; m_l1GtMenu = l1GtMenu.product(); - (const_cast(m_l1GtMenu))->buildGtConditionMap(); - m_l1GtMenuCacheID = l1GtMenuCacheID; - } const std::vector& conditionMap = m_l1GtMenu->gtConditionMap(); diff --git a/L1TriggerConfig/L1GtConfigProducers/src/L1GtTriggerMenuTester.cc b/L1TriggerConfig/L1GtConfigProducers/src/L1GtTriggerMenuTester.cc index b498acb5d45d3..c4e45f5f76dc7 100644 --- a/L1TriggerConfig/L1GtConfigProducers/src/L1GtTriggerMenuTester.cc +++ b/L1TriggerConfig/L1GtConfigProducers/src/L1GtTriggerMenuTester.cc @@ -230,11 +230,8 @@ void L1GtTriggerMenuTester::retrieveL1EventSetup(const edm::EventSetup& evSetup) edm::ESHandle l1GtMenu; evSetup.get ().get(l1GtMenu); m_l1GtMenu = l1GtMenu.product(); - (const_cast (m_l1GtMenu))->buildGtConditionMap(); - m_algorithmMap = &(m_l1GtMenu->gtAlgorithmMap()); m_algorithmAliasMap = &(m_l1GtMenu->gtAlgorithmAliasMap()); - m_technicalTriggerMap = &(m_l1GtMenu->gtTechnicalTriggerMap()); } diff --git a/PhysicsTools/PatAlgos/plugins/PATTriggerProducer.cc b/PhysicsTools/PatAlgos/plugins/PATTriggerProducer.cc index d160737a4d4d3..1c9807fa26964 100644 --- a/PhysicsTools/PatAlgos/plugins/PATTriggerProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTriggerProducer.cc @@ -822,11 +822,9 @@ void PATTriggerProducer::produce( Event& iEvent, const EventSetup& iSetup ) l1GtUtils_.getL1GtRunCache( iEvent, iSetup, useL1EventSetup, useL1GtTriggerMenuLite ); ESHandle< L1GtTriggerMenu > handleL1GtTriggerMenu; iSetup.get< L1GtTriggerMenuRcd >().get( handleL1GtTriggerMenu ); - L1GtTriggerMenu l1GtTriggerMenu( *handleL1GtTriggerMenu ); - const AlgorithmMap l1GtAlgorithms( l1GtTriggerMenu.gtAlgorithmMap() ); - const AlgorithmMap l1GtTechTriggers( l1GtTriggerMenu.gtTechnicalTriggerMap() ); - l1GtTriggerMenu.buildGtConditionMap(); - const std::vector< ConditionMap > l1GtConditionsVector( l1GtTriggerMenu.gtConditionMap() ); + auto const & l1GtAlgorithms = handleL1GtTriggerMenu->gtAlgorithmMap(); + auto const & l1GtTechTriggers = handleL1GtTriggerMenu->gtTechnicalTriggerMap(); + auto const & l1GtConditionsVector = handleL1GtTriggerMenu->gtConditionMap(); // cache conditions in one single condition map ConditionMap l1GtConditions; for ( size_t iCv = 0; iCv < l1GtConditionsVector.size(); ++iCv ) { From f465703fc4b9d3693f38965fb0915b9525f15943 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Sun, 23 Aug 2015 23:23:26 +0200 Subject: [PATCH 4/5] L1GlobalTrigger: change into a stream::EDProducer - change most configuration parameters into const members - change into a stream::EDProducer --- .../GlobalTrigger/plugins/L1GlobalTrigger.h | 50 ++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/L1Trigger/GlobalTrigger/plugins/L1GlobalTrigger.h b/L1Trigger/GlobalTrigger/plugins/L1GlobalTrigger.h index 48fa41c3e6b99..1832c34dce813 100644 --- a/L1Trigger/GlobalTrigger/plugins/L1GlobalTrigger.h +++ b/L1Trigger/GlobalTrigger/plugins/L1GlobalTrigger.h @@ -31,7 +31,7 @@ #include "CondFormats/L1TObjects/interface/L1GtBoard.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -52,7 +52,7 @@ class L1GtPrescaleFactors; class L1GtTriggerMask; // class declaration -class L1GlobalTrigger : public edm::EDProducer +class L1GlobalTrigger : public edm::stream::EDProducer<> { public: @@ -164,39 +164,36 @@ class L1GlobalTrigger : public edm::EDProducer std::vector m_triggerMaskVetoAlgoTrig; std::vector m_triggerMaskVetoTechTrig; -private: - - L1GlobalTriggerPSB* m_gtPSB; L1GlobalTriggerGTL* m_gtGTL; L1GlobalTriggerFDL* m_gtFDL; /// input tag for muon collection from GMT - edm::InputTag m_muGmtInputTag; + const edm::InputTag m_muGmtInputTag; /// input tag for calorimeter collections from GCT - edm::InputTag m_caloGctInputTag; + const edm::InputTag m_caloGctInputTag; /// input tag for CASTOR record - edm::InputTag m_castorInputTag; + const edm::InputTag m_castorInputTag; /// input tag for technical triggers - std::vector m_technicalTriggersInputTags; + const std::vector m_technicalTriggersInputTags; /// logical flag to produce the L1 GT DAQ readout record - bool m_produceL1GtDaqRecord; + const bool m_produceL1GtDaqRecord; /// logical flag to produce the L1 GT EVM readout record - bool m_produceL1GtEvmRecord; + const bool m_produceL1GtEvmRecord; /// logical flag to produce the L1 GT object map record - bool m_produceL1GtObjectMapRecord; + const bool m_produceL1GtObjectMapRecord; /// logical flag to write the PSB content in the L1 GT DAQ record - bool m_writePsbL1GtDaqRecord; + const bool m_writePsbL1GtDaqRecord; /// logical flag to read the technical trigger records - bool m_readTechnicalTriggerRecords; + const bool m_readTechnicalTriggerRecords; /// number of "bunch crossing in the event" (BxInEvent) to be emulated /// symmetric around L1Accept (BxInEvent = 0): @@ -207,47 +204,44 @@ class L1GlobalTrigger : public edm::EDProducer /// number of BXs in the event corresponding to alternative 0 and 1 in altNrBxBoard() /// EmulateBxInEvent >= max(RecordLength[0], RecordLength[1]) /// negative values: take the numbers from event setup, from L1GtParameters - std::vector m_recordLength; + const std::vector m_recordLength; /// alternative for number of BX per active board in GT DAQ record: 0 or 1 /// the position is identical with the active board bit - unsigned int m_alternativeNrBxBoardDaq; + const unsigned int m_alternativeNrBxBoardDaq; /// alternative for number of BX per active board in GT EVM record: 0 or 1 /// the position is identical with the active board bit - unsigned int m_alternativeNrBxBoardEvm; + const unsigned int m_alternativeNrBxBoardEvm; /// length of BST record (in bytes) from parameter set - int m_psBstLengthBytes; + const int m_psBstLengthBytes; /// run algorithm triggers /// if true, unprescaled (all prescale factors 1) /// will overwrite the event setup - bool m_algorithmTriggersUnprescaled; + const bool m_algorithmTriggersUnprescaled; /// if true, unmasked - all enabled (all trigger masks set to 0) /// will overwrite the event setup - bool m_algorithmTriggersUnmasked; + const bool m_algorithmTriggersUnmasked; /// run technical triggers /// if true, unprescaled (all prescale factors 1) /// will overwrite the event setup - bool m_technicalTriggersUnprescaled; + const bool m_technicalTriggersUnprescaled; /// if true, unmasked - all enabled (all trigger masks set to 0) /// will overwrite the event setup - bool m_technicalTriggersUnmasked; + const bool m_technicalTriggersUnmasked; /// if true, veto unmasked - all enabled (all trigger veto masks set to 0) /// will overwrite the event setup - bool m_technicalTriggersVetoUnmasked; - - -private: + const bool m_technicalTriggersVetoUnmasked; /// verbosity level - int m_verbosity; - bool m_isDebugEnabled; + const int m_verbosity; + const bool m_isDebugEnabled; }; From f1173fc007630518d3c3c37f1448770cb26d26b9 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Mon, 24 Aug 2015 00:24:23 +0200 Subject: [PATCH 5/5] TriggerResultsFilter: change into a edm::stream::EDFilter --- HLTrigger/HLTfilters/interface/TriggerResultsFilter.h | 5 +++-- HLTrigger/HLTfilters/interface/TriggerResultsFilterFromDB.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/HLTrigger/HLTfilters/interface/TriggerResultsFilter.h b/HLTrigger/HLTfilters/interface/TriggerResultsFilter.h index 1a533d376cf2d..c95edabcdb51e 100644 --- a/HLTrigger/HLTfilters/interface/TriggerResultsFilter.h +++ b/HLTrigger/HLTfilters/interface/TriggerResultsFilter.h @@ -19,7 +19,7 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" #include "HLTrigger/HLTcore/interface/TriggerExpressionData.h" @@ -36,7 +36,8 @@ namespace triggerExpression { // class declaration // -class TriggerResultsFilter : public edm::EDFilter { +class TriggerResultsFilter : public edm::stream::EDFilter<> +{ public: explicit TriggerResultsFilter(const edm::ParameterSet &); ~TriggerResultsFilter(); diff --git a/HLTrigger/HLTfilters/interface/TriggerResultsFilterFromDB.h b/HLTrigger/HLTfilters/interface/TriggerResultsFilterFromDB.h index f48deb7281db7..78e99df9ff9e6 100644 --- a/HLTrigger/HLTfilters/interface/TriggerResultsFilterFromDB.h +++ b/HLTrigger/HLTfilters/interface/TriggerResultsFilterFromDB.h @@ -19,7 +19,7 @@ #include #include "FWCore/Framework/interface/ESWatcher.h" -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "CondFormats/DataRecord/interface/AlCaRecoTriggerBitsRcd.h" #include "HLTrigger/HLTcore/interface/TriggerExpressionData.h" @@ -35,7 +35,8 @@ namespace triggerExpression { // class declaration // -class TriggerResultsFilterFromDB : public edm::EDFilter { +class TriggerResultsFilterFromDB : public edm::stream::EDFilter<> +{ public: explicit TriggerResultsFilterFromDB(const edm::ParameterSet &); ~TriggerResultsFilterFromDB();