From 79d73fe45d95280f73b660601e466322982c3656 Mon Sep 17 00:00:00 2001 From: Francesca Pastore <francesca.pastore@cern.ch> Date: Thu, 29 Mar 2018 19:50:38 +0200 Subject: [PATCH] changes to have egamma.menu test running Former-commit-id: e39fac29a5ead1b62019730fb60e3550a3eb9f8a --- .../python/TrigL2CaloHypoTool.py | 8 +- .../src/TestTrigL2CaloHypoAlg.cxx | 17 +- .../src/TestTrigL2CaloHypoAlg.h | 4 +- .../src/TestTrigL2ElectronHypoAlg.cxx | 139 +++++ .../src/TestTrigL2ElectronHypoAlg.h | 56 ++ .../src/TrigL2ElectronFexMT.cxx | 10 +- .../DecisionHandling/src/RoRSeqFilter.cxx | 4 +- .../src/TestEventViewCreatorAlgorithm.cxx | 127 +++-- .../src/TestEventViewCreatorAlgorithm.h | 4 +- .../TrigUpgradeTest/python/HLTCFConfig.py | 252 +++++++-- .../{share => python}/HLTSignatureConfig.py | 104 ++-- .../TrigUpgradeTest/python/MenuComponents.py | 36 +- .../TrigUpgradeTest/python/MenuHypoTools.py | 19 + .../share/EmuStepProcessingTest.py | 35 +- .../TrigUpgradeTest/share/egamma.menu.py | 532 +++++------------- .../TrigUpgradeTest/share/egamma.withViews.py | 9 +- .../TrigUpgradeTest/src/TestHypoAlg.cxx | 3 +- .../TrigUpgradeTest/src/TestHypoTool.cxx | 60 +- .../TrigUpgradeTest/src/TestHypoTool.h | 5 +- .../TrigUpgradeTest/src/TestInputMaker.cxx | 184 +++--- .../TrigUpgradeTest/src/TestInputMaker.h | 5 +- 21 files changed, 970 insertions(+), 643 deletions(-) create mode 100644 Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2ElectronHypoAlg.cxx create mode 100644 Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2ElectronHypoAlg.h rename Trigger/TrigValidation/TrigUpgradeTest/{share => python}/HLTSignatureConfig.py (70%) create mode 100644 Trigger/TrigValidation/TrigUpgradeTest/python/MenuHypoTools.py diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2CaloHypoTool.py b/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2CaloHypoTool.py index 63a045f0fb1..0416d08711f 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2CaloHypoTool.py +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigL2CaloHypoTool.py @@ -121,7 +121,7 @@ def _MultTool(name): def decodeThreshold( threshold ): """ decodes the thresholds of the form e10, 2e10, e10e15, ... """ - print "decoding ", threshold + print "TrigL2CaloHypoToolFromName: decoding threshold ", threshold if threshold[0].isdigit(): # is if the from NeX, return as list [X,X,X...N times...] assert threshold[1] == 'e', "Two digit multiplicity not supported" return [ threshold[2:] ] * int( threshold[0] ) @@ -140,13 +140,15 @@ def TrigL2CaloHypoToolFromName( name ): threshold = bname[1] sel = bname[2] + print "TrigL2CaloHypoToolFromName: name = %s, threshold = %s, sel =%s"%(name,threshold,sel) + dt = decodeThreshold( threshold ) assert len(dt) >= 1, "Threshold "+ threshold +" not decoded properly" if len( dt ) > 1: tool = _MultTool(name) for cutNumber, th in enumerate( dt ): - print "cut and threshold ", cutNumber, th + print "TrigL2CaloHypoToolFromName: cut and threshold ", cutNumber, th tool.SubTools += [ _IncTool( name+"_"+str(cutNumber), th, sel ) ] for t in tool.SubTools: t.OutputLevel=DEBUG @@ -188,4 +190,4 @@ if __name__ == "__main__": assert len(t.SubTools) == 2, "Sub-tools not configured" #print t - print ( "\n\nALL OK\n\n" ) + print ( "\n\n TrigL2CaloHypoToolFromName ALL OK\n\n" ) diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2CaloHypoAlg.cxx b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2CaloHypoAlg.cxx index 0715e65f5de..a086684e1e5 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2CaloHypoAlg.cxx +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2CaloHypoAlg.cxx @@ -4,6 +4,9 @@ #include "GaudiKernel/Property.h" #include "TestTrigL2CaloHypoAlg.h" +#include "DecisionHandling/HLTIdentifier.h" +#include "DecisionHandling/TrigCompositeUtils.h" + using namespace TrigCompositeUtils; @@ -93,7 +96,8 @@ StatusCode TestTrigL2CaloHypoAlg::execute_r( const EventContext& context ) const } d->setObjectLink( "roi", roiEL ); d->setObjectLink( "view", viewEL ); - d->setObjectLink( "previousDecisions", ElementLink<DecisionContainer>(m_previousDecisionsKey.key(), counter) );// link to previous decision object + TrigCompositeUtils::linkToPrevious( d, m_previousDecisionsKey.key(), counter ); + // d->setObjectLink( "previousDecisions", ElementLink<DecisionContainer>(m_previousDecisionsKey.key(), counter) );// link to previous decision object ATH_MSG_DEBUG( "Added view, roi, cluster, previous decision to new decision "<<counter <<" for view "<<view->name() ); counter++; @@ -107,10 +111,19 @@ StatusCode TestTrigL2CaloHypoAlg::execute_r( const EventContext& context ) const CHECK( tool->decide( toolInput ) ); } - { + {// make output handle and debug auto handle = SG::makeHandle( m_decisionsKey, context ); CHECK( handle.record( std::move( decisions ), std::move( aux ) ) ); ATH_MSG_DEBUG ( "Exit with "<<handle->size() <<" decision objects"); + TrigCompositeUtils::DecisionIDContainer allPassingIDs; + if ( handle.isValid() ) { + for ( auto decisionObject: *handle ) { + TrigCompositeUtils::decisionIDs( decisionObject, allPassingIDs ); + } + for ( TrigCompositeUtils::DecisionID id : allPassingIDs ) { + ATH_MSG_DEBUG( " +++ " << HLT::Identifier( id ) ); + } + } } return StatusCode::SUCCESS; diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2CaloHypoAlg.h b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2CaloHypoAlg.h index 4065cf10c1f..193db8281ae 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2CaloHypoAlg.h +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2CaloHypoAlg.h @@ -35,8 +35,8 @@ class TestTrigL2CaloHypoAlg : public ::AthReentrantAlgorithm { ToolHandleArray< ITrigL2CaloHypoTool > m_hypoTools { this, "HypoTools", {}, "Hypo tools" }; SG::ReadHandleKey< xAOD::TrigEMClusterContainer > m_clustersKey { this, "CaloClusters", "CaloClusters", "CaloClusters in view" }; - SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer> m_previousDecisionsKey { this, "previousDecisions", "Unspecified", "Input decisions" }; - SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > m_decisionsKey { this, "Decisions", "Unspecified", "Output Decisions" }; + SG::ReadHandleKey < TrigCompositeUtils::DecisionContainer > m_previousDecisionsKey { this, "previousDecisions", "Unspecified", "Input decisions" }; + SG::WriteHandleKey < TrigCompositeUtils::DecisionContainer > m_decisionsKey { this, "Decisions", "Unspecified", "Output Decisions" }; Gaudi::Property< bool > m_runInView { this, "RunInView", false , "Set input DH for running in views" }; diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2ElectronHypoAlg.cxx b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2ElectronHypoAlg.cxx new file mode 100644 index 00000000000..ab34805fc01 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2ElectronHypoAlg.cxx @@ -0,0 +1,139 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ +#include <map> +#include "GaudiKernel/Property.h" +#include "TestTrigL2ElectronHypoAlg.h" +#include "xAODTrigCalo/TrigEMClusterContainer.h" + + +using TrigCompositeUtils::DecisionContainer; +using TrigCompositeUtils::DecisionAuxContainer; +using TrigCompositeUtils::DecisionIDContainer; +using TrigCompositeUtils::decisionIDs; +using TrigCompositeUtils::newDecisionIn; +using TrigCompositeUtils::linkToPrevious; + + +TestTrigL2ElectronHypoAlg::TestTrigL2ElectronHypoAlg( const std::string& name, + ISvcLocator* pSvcLocator ) : + ::AthReentrantAlgorithm( name, pSvcLocator ) {} + +TestTrigL2ElectronHypoAlg::~TestTrigL2ElectronHypoAlg() {} + +StatusCode TestTrigL2ElectronHypoAlg::initialize() { + ATH_MSG_INFO ( "Initializing " << name() << "..." ); + + CHECK( m_hypoTools.retrieve() ); + + CHECK( m_electronsKey.initialize() ); + if ( m_runInView) renounce( m_electronsKey );// clusters are made in views, so they are not in the EvtStore: hide them + + CHECK( m_previousDecisionsKey.initialize() ); + renounce(m_previousDecisionsKey); + + CHECK( m_decisionsKey.initialize() ); + + + return StatusCode::SUCCESS; +} + + +StatusCode TestTrigL2ElectronHypoAlg::execute_r( const EventContext& context ) const { + ATH_MSG_DEBUG ( "Executing " << name() << "..." ); + + + // prepare decisions container and link back to the clusters, and decision on clusters + auto decisions = std::make_unique<DecisionContainer>(); + auto aux = std::make_unique<DecisionAuxContainer>(); + decisions->setStore( aux.get() ); + + // // extract mapping of cluster pointer to an index in the cluster decision collection + auto previousDecisionsHandle = SG::makeHandle( m_previousDecisionsKey, context ); + + std::map<const xAOD::TrigEMCluster*, size_t> clusterToIndexMap; + size_t clusterCounter = 0; + for ( auto previousDecision : *previousDecisionsHandle){ + ElementLink<xAOD::TrigEMClusterContainer> clusterLink; + recursivelyFindFeature(previousDecision, clusterLink); + ATH_CHECK( clusterLink.isValid() ); + const xAOD::TrigEMCluster* cluster = *clusterLink; + clusterToIndexMap.insert( std::make_pair( cluster, clusterCounter ) ); + clusterCounter++; + } + ATH_MSG_DEBUG( "Cluster ptr to decision map has size " << clusterToIndexMap.size() ); + + // prepare imput for tools + std::vector<TrigL2ElectronHypoTool::ElectronInfo> hypoToolInput; + + // auto viewsHandle = SG::makeHandle( m_views, context ); + // for ( auto view: *viewsHandle ) { + for ( auto previousDecision: *previousDecisionsHandle ) { + // get View + auto viewEL = previousDecision->objectLink<std::vector<SG::View*>>( "view" ); + CHECK( viewEL.isValid() ); + const SG::View* view_const = *viewEL; + SG::View* view = const_cast<SG::View*>(view_const); // CHECK THIS! + + // get electron from that view: + size_t electronCounter = 0; + auto electronsHandle = SG::makeHandle( m_electronsKey, context ); + CHECK( electronsHandle.setProxyDict( view ) ); + CHECK( electronsHandle.isValid() ); + ATH_MSG_DEBUG ( "electron handle size: " << electronsHandle->size() << "..." ); + + for ( auto electronIter = electronsHandle->begin(); electronIter != electronsHandle->end(); ++electronIter, electronCounter++ ) { + auto d = newDecisionIn( decisions.get() ); + d->setObjectLink( "feature", ElementLink<xAOD::TrigElectronContainer>( view->name()+"_"+m_electronsKey.key(), electronCounter ) ); + + auto clusterPtr = (*electronIter)->emCluster(); + CHECK( clusterPtr != nullptr ); + + // now find matching cluster + // could use geometric matching but in fact the cluster owned by the decision object and the cluster owned by the electron should be the same + // since we have a map made in advance we can make use of the index lookup w/o the need for additional loop + auto origCluster = clusterToIndexMap.find( clusterPtr ); + ATH_CHECK( origCluster != clusterToIndexMap.end() ); + linkToPrevious( d, m_previousDecisionsKey.key(), origCluster->second ); + + // now we have DecisionObject ready to be passed to hypo tool. it has link to electron, + // and decisions on clusters + // we shall avoid calling the tools for chains which were already rejected on certain cluster, but this is left to hypo tools + DecisionIDContainer clusterDecisionIDs; + decisionIDs( previousDecisionsHandle->at( origCluster->second ), clusterDecisionIDs ); + + hypoToolInput.emplace_back( TrigL2ElectronHypoTool::ElectronInfo{ d, *electronIter, origCluster->first, clusterDecisionIDs } ); + } + } + + for ( auto & tool: m_hypoTools ) { + ATH_CHECK( tool->decide( hypoToolInput ) ); + } + + + { + auto handle = SG::makeHandle( m_decisionsKey, context ); + CHECK( handle.record( std::move( decisions ), std::move( aux ) ) ); + } + + return StatusCode::SUCCESS; +} + + + + +bool TestTrigL2ElectronHypoAlg::recursivelyFindFeature( const TrigCompositeUtils::Decision* start, ElementLink<xAOD::TrigEMClusterContainer>& clusterlink) const{ // ){ + //recursively find in the seeds + if ( start->hasObjectLink( "feature" ) ) { + clusterlink=start->objectLink<xAOD::TrigEMClusterContainer>( "feature" ); + return true; + } + if (TrigCompositeUtils::hasLinkToPrevious(start) ){ + auto thelinkToPrevious =TrigCompositeUtils::linkToPrevious( start); + return recursivelyFindFeature( *thelinkToPrevious, clusterlink); + } + return false; + } + + + diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2ElectronHypoAlg.h b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2ElectronHypoAlg.h new file mode 100644 index 00000000000..4f440c55e0a --- /dev/null +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TestTrigL2ElectronHypoAlg.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ +#ifndef TRIGEGAMMAHYPO_TESTTRIGL2ELECTRONHYPOALG_H +#define TRIGEGAMMAHYPO_TESTTRIGL2ELECTRONHYPOALG_H 1 + +#include <string> + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "xAODTrigEgamma/TrigElectronContainer.h" +#include "DecisionHandling/TrigCompositeUtils.h" +#include "AthViews/View.h" + +#include "TrigL2ElectronHypoTool.h" +#include "xAODTrigCalo/TrigEMClusterContainer.h" + + +/** + * @class Implements Hypo selection on L2 electrons + * @brief + **/ + +class TestTrigL2ElectronHypoAlg + : public ::AthReentrantAlgorithm +{ + public: + + TestTrigL2ElectronHypoAlg( const std::string& name, ISvcLocator* pSvcLocator ); + + virtual ~TestTrigL2ElectronHypoAlg(); + + virtual StatusCode initialize() override; + virtual StatusCode execute_r(const EventContext& context) const override; + + + + private: + TestTrigL2ElectronHypoAlg(); + ToolHandleArray< TrigL2ElectronHypoTool > m_hypoTools {this, "HypoTools", {}, "Tools to perfrom selection"}; + + SG::ReadHandleKey < TrigCompositeUtils::DecisionContainer > m_previousDecisionsKey { this, "previousDecisions", "Unspecified", "Input decisions" }; + SG::WriteHandleKey < TrigCompositeUtils::DecisionContainer > m_decisionsKey { this, "Decisions", "Unspecified", "Output Decisions" }; + + Gaudi::Property< bool > m_runInView { this, "RunInView", false , "Set input DH for running in views" }; + + // internally used to getch from views + SG::ReadHandleKey< xAOD::TrigElectronContainer > m_electronsKey {this, "Electrons", "L2ElectronContainer", "Input"}; + + + bool recursivelyFindFeature( const TrigCompositeUtils::Decision* d, ElementLink<xAOD::TrigEMClusterContainer>& clusterlink) const; + + +}; +DECLARE_ALGORITHM_FACTORY( TestTrigL2ElectronHypoAlg ) + +#endif //> !TRIGEGAMMAHYPO_TRIGL2ELECTRONHYPOALG_H diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2ElectronFexMT.cxx b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2ElectronFexMT.cxx index 2d3e170607a..33cd2164f84 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2ElectronFexMT.cxx +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2ElectronFexMT.cxx @@ -100,14 +100,20 @@ StatusCode TrigL2ElectronFexMT::execute() { using namespace Monitored; using namespace xAOD; + ATH_MSG_DEBUG( "Executing " <<name()); auto ctx = getContext(); auto trigElecColl = SG::makeHandle (m_outputElectronsKey, ctx); ATH_CHECK( trigElecColl.record (std::make_unique<xAOD::TrigElectronContainer>(), std::make_unique<xAOD::TrigEMClusterAuxContainer>()) ); - auto roiCollection = SG::makeHandle(m_roiCollectionKey, ctx); + ATH_MSG_DEBUG( "Made WriteHandle " << m_outputElectronsKey ); + ATH_MSG_INFO( name() << " running with store " << getContext().getExtension<Atlas::ExtendedEventContext>()->proxy()->name() ); + + auto roiCollection = SG::makeHandle(m_roiCollectionKey, ctx); + ATH_MSG_DEBUG( "Made handle " << m_roiCollectionKey ); + //JTB For the moment assume 1 RoI (as in TrigL2ElectronFex) - could change to SuperRoI later //TrigRoiDescriptorCollection::const_iterator roiDescriptor = roiCollection->begin(); @@ -127,6 +133,7 @@ StatusCode TrigL2ElectronFexMT::execute() { float calo_eta(999), calo_phi(999), calo_et(-1); auto clusContainer = SG::makeHandle (m_TrigEMClusterContainerKey, ctx); + ATH_MSG_DEBUG( "Made handle " << m_TrigEMClusterContainerKey ); //JTB Should only be 1 cluster in each RoI @@ -147,6 +154,7 @@ StatusCode TrigL2ElectronFexMT::execute() { SG::ReadHandle<xAOD::TrackParticleContainer> tracks(m_TrackParticleContainerKey, ctx); + ATH_MSG_DEBUG( "Made handle " << m_TrackParticleContainerKey ); if (tracks->size() == 0){ diff --git a/Trigger/TrigSteer/DecisionHandling/src/RoRSeqFilter.cxx b/Trigger/TrigSteer/DecisionHandling/src/RoRSeqFilter.cxx index 778072bebf8..30c64cfd851 100644 --- a/Trigger/TrigSteer/DecisionHandling/src/RoRSeqFilter.cxx +++ b/Trigger/TrigSteer/DecisionHandling/src/RoRSeqFilter.cxx @@ -122,9 +122,9 @@ StatusCode RoRSeqFilter::execute() { } } - ATH_MSG_DEBUG( "Filter " << ( passCounter != 0 ? "passed" : "rejected") <<" creating "<< outputIndex<<" outDecisions DH"); + ATH_MSG_DEBUG( "Filter " << ( passCounter != 0 ? "passed" : "rejected") <<" creating "<< outputIndex<<" valid outDecisions DH"); for (auto output: outputHandles){ - ATH_MSG_DEBUG(output.key()); + if( output.isValid() ) ATH_MSG_DEBUG(" "<<output.key()); } setFilterPassed( passCounter != 0 ); return StatusCode::SUCCESS; diff --git a/Trigger/TrigSteer/ViewAlgs/src/TestEventViewCreatorAlgorithm.cxx b/Trigger/TrigSteer/ViewAlgs/src/TestEventViewCreatorAlgorithm.cxx index 40c649bc1dd..7b0abeb02bd 100644 --- a/Trigger/TrigSteer/ViewAlgs/src/TestEventViewCreatorAlgorithm.cxx +++ b/Trigger/TrigSteer/ViewAlgs/src/TestEventViewCreatorAlgorithm.cxx @@ -23,14 +23,21 @@ StatusCode TestEventViewCreatorAlgorithm::initialize() { CHECK( m_inputDecisionsKey.initialize() ); - renounceArray(m_inputDecisionsKey); +xs renounceArray(m_inputDecisionsKey); ATH_MSG_DEBUG("Will consume implicit input data:" ); for (auto& input: m_inputDecisionsKey){ ATH_MSG_DEBUG(" "<<input.key()); } - ATH_MSG_DEBUG(" and produce Decisions=" << m_outputDecisionsKey <<" views="<<m_viewsKey<<" roIs="<<m_inViewRoIs ); - CHECK( m_outputDecisionsKey.initialize() ); + CHECK( m_outputDecisionsKey.initialize() ); + + ATH_MSG_DEBUG("Will produce decisions: "); + for (auto& output: m_outputDecisionsKey){ + ATH_MSG_DEBUG(" - "<<output.key()); + } + + ATH_MSG_DEBUG("Will produce views="<<m_viewsKey<<" roIs="<<m_inViewRoIs ); + CHECK( m_viewsKey.initialize() ); CHECK( m_inViewRoIs.initialize() ); CHECK( m_scheduler.retrieve() ); @@ -47,65 +54,85 @@ StatusCode TestEventViewCreatorAlgorithm::execute() const EventContext& ctx = *getContext(); #endif + size_t validInput=0; + {// print valid inputs + for ( auto inputKey: m_inputDecisionsKey ) { + auto inputHandle = SG::makeHandle( inputKey ); + ATH_MSG_DEBUG(" "<<inputKey.key()<<(inputHandle.isValid()? " is valid": " is NOT valid" ) ); + if (inputHandle.isValid()) validInput++; + } + ATH_MSG_DEBUG( "number of implicit ReadHandles is " << m_inputDecisionsKey.size() <<", "<< validInput<<" are valid" ); + } - ATH_MSG_DEBUG( "number of implicit ReadHandles is " << m_inputDecisionsKey.size() ); + auto outputHandles = m_outputDecisionsKey.makeHandles(); - + // make the views auto viewVector = std::make_unique<std::vector<SG::View*>>(); auto contexts = std::vector<EventContext>( ); - - // prepare output decisions - auto OutputDecisions = std::make_unique<TrigCompositeUtils::DecisionContainer>(); - auto aux = std::make_unique<TrigCompositeUtils::DecisionAuxContainer>(); - OutputDecisions->setStore( aux.get() ); - unsigned int viewCounter = 0; unsigned int conditionsRun = getContext().getExtension<Atlas::ExtendedEventContext>()->conditionsRun(); const TrigRoiDescriptor* previousRoI = 0; - + size_t outputIndex = 0; // Loop over all input containers, which are of course TrigComposites, and request their features for ( auto inputKey: m_inputDecisionsKey ) { - auto inputDecisions = SG::makeHandle( inputKey ); - ATH_MSG_DEBUG( "Got DecisionContainer from input "<< inputKey.key()<<" with " << inputDecisions->size() << " elements" ); - ATH_MSG_DEBUG( "Preparing " << inputDecisions.cptr()->size() << " views (one per input decision)" ); + // sme as inputmaker: + auto inputHandle = SG::makeHandle( inputKey ); + if( not inputHandle.isValid() ) { + ATH_MSG_DEBUG( "Got no decisions from input "<< inputKey.key()); + outputIndex++; + continue; + } - size_t counter = 0; - for ( auto Idecision: *inputDecisions ) { - + if( inputHandle->size() == 0){ // input filtered out + ATH_MSG_ERROR( "Got 0 decisions from valid input "<< inputKey.key()<<". Is it expected?"); + return StatusCode::FAILURE; + } + ATH_MSG_DEBUG( "Got input "<< inputKey.key()<<" with " << inputHandle->size() << " elements" ); + + // prepare output decisions + auto OutputDecisions = std::make_unique<TrigCompositeUtils::DecisionContainer>(); + auto dec_aux = std::make_unique<TrigCompositeUtils::DecisionAuxContainer>(); + OutputDecisions->setStore( dec_aux.get() ); + + size_t input_counter = 0; + for ( auto Idecision: *inputHandle ) { //make one TC decision output per input and connect to previous auto newd = TrigCompositeUtils::newDecisionIn(OutputDecisions.get()); - // link to previous decision object - newd->setObjectLink( "previousDecisions", ElementLink<TrigCompositeUtils::DecisionContainer>(inputKey.key(), counter) ); - + TrigCompositeUtils::linkToPrevious( newd, inputKey.key(), input_counter ); { //copy decisions ID TrigCompositeUtils::DecisionIDContainer objDecisions; TrigCompositeUtils::decisionIDs( Idecision, objDecisions ); - for ( const HLT::Identifier& id: objDecisions ) TrigCompositeUtils::addDecisionID( id, newd ); + for ( const HLT::Identifier& id: objDecisions ) { + TrigCompositeUtils::addDecisionID( id, newd ); + } } - ATH_MSG_DEBUG( "Positive decisions on RoI, preparing view" ); // pull RoI descriptor CHECK( Idecision->hasObjectLink( m_roisLink ) ); auto roiDescriptorEL = Idecision->objectLink<TrigRoiDescriptorCollection>( m_roisLink ); CHECK( roiDescriptorEL.isValid() ); - + // associate this RoI to output decisions auto roiDescriptor = *roiDescriptorEL; ATH_MSG_DEBUG( "Placing TrigRoiDescriptor " << *roiDescriptor ); - + newd->setObjectLink( "initialRoI", roiDescriptorEL ); - if ( previousRoI == roiDescriptor ) continue; - // TODO here code supporting the case wnen we have many decisions associated to a single RoI + // this is added for EVCreator explicitally, differently from InputMaker: + if ( previousRoI == roiDescriptor ) { + // TODO here code supporting the case wnen we have many decisions associated to a single RoI + continue; + } + + ATH_MSG_DEBUG( "Positive decisions on RoI, preparing view" ); previousRoI = roiDescriptor; - + + // fill the RoI output collection auto oneRoIColl = std::make_unique< ConstDataVector<TrigRoiDescriptorCollection> >(); oneRoIColl->clear( SG::VIEW_ELEMENTS ); //Don't delete the RoIs oneRoIColl->push_back( roiDescriptor ); - newd->setObjectLink( "initialRoI", roiDescriptorEL ); //FPP add this roi to the output - // make the view ATH_MSG_DEBUG( "Making the View" ); auto newview = ViewHelper::makeView( name()+"_view", viewCounter++, m_viewFallThrough ); //pointer to the view @@ -130,9 +157,14 @@ StatusCode TestEventViewCreatorAlgorithm::execute() CHECK( handle.setProxyDict( viewVector->back() ) ); CHECK( handle.record( std::move( oneRoIColl ) ) ); - counter++; + input_counter++; } + + ATH_MSG_DEBUG( "Recording output key " << m_outputDecisionsKey[ outputIndex ].key() <<" of size "<<OutputDecisions->size() <<" at index "<< outputIndex); + CHECK( outputHandles[outputIndex].record( std::move( OutputDecisions ), std::move( dec_aux ) ) ); + outputIndex++; + } @@ -144,15 +176,38 @@ StatusCode TestEventViewCreatorAlgorithm::execute() // store views - auto viewsHandle = SG::makeHandle( m_viewsKey ); CHECK( viewsHandle.record( std::move( viewVector ) ) ); + ATH_MSG_DEBUG( "Store "<< viewsHandle->size() <<" Views"); + + //debug - the same as inputmaker + size_t validOutput=0; + for ( auto outHandle: outputHandles ) { + if( not outHandle.isValid() ) continue; + validOutput++; + } + ATH_MSG_DEBUG("Produced "<<validOutput<<" decisions containers"); + if(validInput != validOutput) { + ATH_MSG_ERROR("Found "<<validInput<<" inputs and "<<validOutput<<" outputs"); + } + + for ( auto outHandle: outputHandles ) { + if( not outHandle.isValid() ) continue; + ATH_MSG_DEBUG(outHandle.key() <<" with "<< outHandle->size() <<" decisions:"); + for (auto outdecision: *outHandle){ + TrigCompositeUtils::DecisionIDContainer objDecisions; + TrigCompositeUtils::decisionIDs( outdecision, objDecisions ); + + ATH_MSG_DEBUG("Number of positive decisions for this output: " << objDecisions.size() ); + + for ( TrigCompositeUtils::DecisionID id : objDecisions ) { + ATH_MSG_DEBUG( " --- decision " << HLT::Identifier( id ) ); + } + } + } - //store decisions with all - auto outputHandle = SG::makeHandle(m_outputDecisionsKey, ctx); - CHECK( outputHandle.record(std::move(OutputDecisions), std::move(aux) ) ); - ATH_MSG_DEBUG( "Store "<< viewsHandle->size() <<" Views and "<<outputHandle->size()<<" output decisions" ); + return StatusCode::SUCCESS; } diff --git a/Trigger/TrigSteer/ViewAlgs/src/TestEventViewCreatorAlgorithm.h b/Trigger/TrigSteer/ViewAlgs/src/TestEventViewCreatorAlgorithm.h index c70a5879968..1dff6611ea2 100644 --- a/Trigger/TrigSteer/ViewAlgs/src/TestEventViewCreatorAlgorithm.h +++ b/Trigger/TrigSteer/ViewAlgs/src/TestEventViewCreatorAlgorithm.h @@ -34,7 +34,9 @@ class TestEventViewCreatorAlgorithm : public AthAlgorithm SG::ReadHandleKeyArray<TrigCompositeUtils::DecisionContainer> m_inputDecisionsKey { this, "InputDecisions", {}, "The vector name of input decision container (implicit)" } ; // Ouput decisions - SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > m_outputDecisionsKey{ this, "OutputDecisions", "Unspecified", "The name of output decision container" }; + //SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > m_outputDecisionsKey{ this, "OutputDecisions", "Unspecified", "The name of output decision container" }; + // SG::WriteHandleKeyArray< ConstDataVector<TrigCompositeUtils::DecisionContainer> > m_outputDecisionsKey{ this, "OutputDecisions", {}, "Output Decisions" }; + SG::WriteHandleKeyArray<TrigCompositeUtils::DecisionContainer> m_outputDecisionsKey { this, "OutputDecisions", {}, "Ouput Decisions" }; //Output views for merging SG::WriteHandleKey< std::vector< SG::View* > > m_viewsKey{ this, "Views", "Unspecified", "The key of views collection produced" }; diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/HLTCFConfig.py b/Trigger/TrigValidation/TrigUpgradeTest/python/HLTCFConfig.py index d801858f596..29c8e5ef1bc 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/HLTCFConfig.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/HLTCFConfig.py @@ -1,6 +1,8 @@ # Classes to configure the CF graph, via Nodes from AthenaCommon.CFElements import parOR, seqAND, stepSeq import sys +import re + allAlgs={} @@ -20,20 +22,22 @@ def remember(name, instance): class AlgNode(): - def __init__(self, Alg, inputProp='', outputProp=''): + def __init__(self, Alg, inputProp='', outputProp='', ViewNodeName=''): self.name = ("%s_%s_%s")%( Alg.name(), inputProp, outputProp) self.algname = Alg.name() self.outputProp=outputProp self.inputProp=inputProp + self.viewNodeName=ViewNodeName + #if exist: remember (Alg.name(), Alg) self.configureAlg(Alg) def configureAlg(self, Alg): - alg_name = Alg.getName() + alg_name = Alg.name() if AlgExisting(alg_name): print "AlgNode::%s: found already Alg %s"%(self.name,alg_name) self.Alg = useExisting(alg_name) else: - print "AlgNode::%s: new Alg %s"%(self.name,alg_name) + print "AlgNode::%s: new Alg %s added in list"%(self.name,alg_name) self.Alg=Alg remember(alg_name, self.Alg) @@ -53,9 +57,9 @@ class AlgNode(): try: if type(cval) == type(list()): cval.append(name) - setattr(self.Alg, prop, cval) + return setattr(self.Alg, prop, cval) else: - setattr(self.Alg, prop, name) + return setattr(self.Alg, prop, name) except: pass @@ -63,7 +67,7 @@ class AlgNode(): cval = self.Alg.getProperties()[prop] try: cval.append(name) - setattr(self.Alg, prop, cval) + return setattr(self.Alg, prop, cval) except: pass @@ -76,15 +80,20 @@ class AlgNode(): def setOutput(self, name): - print "setOutput %s on %s of %s"%(name, self.outputProp, self.name) - return self.setPar(self.outputProp,name) + if self.outputProp is not '': + print "setOutput %s on %s of %s"%(name, self.outputProp, self.name) + return self.setPar(self.outputProp,name) def getOutput(self): - return self.getPar(self.outputProp) - + if self.outputProp is not '': + return self.getPar(self.outputProp) + return self.outputProp + def getOutputList(self): outputs = [] cval = self.getOutput() + if cval == '': + return outputs if type(cval) == type(list()): outputs.extend(cval) else: @@ -92,17 +101,23 @@ class AlgNode(): return outputs def setInput(self, name): - return self.setPar(self.inputProp,name) + if self.inputProp is not '': + return self.setPar(self.inputProp,name) def addInput(self, name): - return self.setParArray(self.inputProp,name) + if self.inputProp is not '': + return self.setParArray(self.inputProp,name) def getInput(self): - return self.getPar(self.inputProp) - + if self.inputProp is not '': + return self.getPar(self.inputProp) + return self.inputProp + def getInputList(self): inputs = [] cval = self.getInput() + if cval =='': + return inputs if type(cval) == type(list()): inputs.extend(cval) else: @@ -110,7 +125,7 @@ class AlgNode(): return inputs def __str__(self): - return "Alg::%s [%s] -> [%s]"%(self.name,' '.join(map(str, self.getInputList())), ' '.join(map(str, self.getOutputList()))) + return "Alg::%s.%s [%s] -> [%s]"%(self.name,self.viewNodeName, ' '.join(map(str, self.getInputList())), ' '.join(map(str, self.getOutputList()))) @@ -119,18 +134,35 @@ class HypoAlgNode(AlgNode): AlgNode.__init__(self, Alg, inputProp, outputProp) self.tools = [] self.previous=[] - - def addHypoTool(self, hypotool): - if "Comb" in self.name: ###TMP combo, only one threshold + + ## def addHypoTool(self, hypotool): + ## if "Comb" in self.name: ###TMP combo, only one threshold + ## import re + ## thresholds = map(int, re.findall(r'\d+', hypotool.name())) + ## self.setPar('Threshold1', thresholds[0]) + ## self.setPar('Threshold2', thresholds[1]) + ## status=self.setPar('DecisionLabel', hypotool.name()) + ## else: + ## self.tools.append(hypotool.name()) + ## status= self.setParArray('HypoTools',hypotool) + ## return status + + def addHypoTool(self, hypoToolName, hypoToolClassName): + from TrigUpgradeTest.MenuHypoTools import * + if hypoToolClassName is "ComboTestHypoTool": +# if "Comb" in self.name: ###TMP combo, only one threshold import re - thresholds = map(int, re.findall(r'\d+', hypotool.getName())) + thresholds = map(int, re.findall(r'\d+', hypoToolName)) self.setPar('Threshold1', thresholds[0]) self.setPar('Threshold2', thresholds[1]) - status=self.setPar('DecisionLabel', hypotool.getName()) + status=self.setPar('DecisionLabel', hypoToolName) else: - self.tools.append(hypotool.getName()) - status= self.setParArray('HypoTools',hypotool) + ## HypoTools are private, so need to be created when added to the Alg + self.tools.append(hypoToolName) + tools = self.Alg.HypoTools + self.Alg.HypoTools = tools+[eval(hypoToolClassName)(hypoToolName)] + status = 0 return status def addPreviousDecision(self,prev): @@ -249,6 +281,7 @@ def create_step_filter_node(name, seq_list, dump=False): for seq in seq_list: filterAlg=seq.filter.Alg print "Add %s to filter node %s"%(filterAlg.name(),name) + print "DUMPFILTER ",filterAlg stepCF += filterAlg if dump: dumpSequence (stepCF, indent=0) @@ -300,21 +333,92 @@ def create_CFSequence(CFseq): for node in nodes: algos.append(node.Alg) - if isinstance(seq, ViewNodeSequence): - viewAlgSeq = seqAND(seq.viewNodeName, algos) - seq.hypo.Alg.RunInView=True - viewSeq = seqAND(seq.viewNodeName+"Seq", [seq.maker.Alg, viewAlgSeq, seq.hypo.Alg] ) - for other in seq.otherNodes: - viewSeq+= other.Alg + + if seq.viewNodeName is not '': + viewSeq= seqAND(seq.viewNodeName+"Seq", [seq.maker.Alg]) subs.append(viewSeq) + view_sequences = [] + for node in nodes: + if node.viewNodeName is not '': + seq_found = False + view_found= True + for vseq in view_sequences: + if vseq.name() == node.viewNodeName: + vseq+= node.Alg + seq_found=True + if seq_found is False: + print "New Sequence done: %s with Alg::%s"%(node.viewNodeName, node.Alg.name()) + # vseq= seqAND(node.viewNodeName, [node.Alg]) + vseq= parOR(node.viewNodeName, [node.Alg]) + viewSeq += vseq + # viewSeq= seqAND(seq.viewNodeName+"Seq", [seq.maker.Alg, vseq, seq.hypo.Alg] ) + # subs.append(viewSeq) + view_sequences.append(vseq) + else: + viewSeq += node.Alg + + viewSeq += seq.hypo.Alg + if len(view_sequences) > 1: + print "WARNING: more than 1 View seuqence found!" else: subs.append(seq.maker.Alg) subs.extend(algos) subs.append(seq.hypo.Alg) + + for other in seq.otherNodes: + subs.append(other.Alg) + + ## view_sequences = [] +## # group algs on view seuqneces +## view_found=False +## for node in nodes: +## print "CAC Adding node: ",node +## if node.viewNodeName is not '': +## seq_found = False +## view_found= True +## for vseq in view_sequences: +## if vseq.name() == node.viewNodeName: +## vseq+= node.Alg +## seq_found=True +## if seq_found is False: +## print "New Sequence done: %s with Alg::%s"%(node.viewNodeName, node.Alg.name()) +## # vseq= seqAND(node.viewNodeName, [node.Alg]) +## vseq= parOR(node.viewNodeName, [node.Alg]) +## viewSeq += vseq +## # viewSeq= seqAND(seq.viewNodeName+"Seq", [seq.maker.Alg, vseq, seq.hypo.Alg] ) +## # subs.append(viewSeq) +## view_sequences.append(vseq) +## else: +## if seq_has_view: +## viewSeq += node.Alg +## else: +## subs.append(node.Alg) + + + ## if len(view_sequences) > 1: + ## print "WARNING: more than 1 View seuqence found!" + + ## if seq_has_view: + ## viewSeq+ = seq.hypo.Alg + + # vseq = view_sequences[0] + #for vseq in view_sequences: + #viewSeq= seqAND(seq.viewNodeName+"Seq", [seq.maker.Alg, subs, vseq, seq.hypo.Alg] ) + #subs = [] +# subs.append(viewSeq) +## else: +## subs.append(seq.maker.Alg) +## # subs.extend(algos) +## subs.append(seq.hypo.Alg) + + print "The full list of seq %s"%(seq.name) + print subs - subs=list(set(subs)) + + + #subs=list(set(subs)) stepReco = parOR(CFseq.name+"_reco", subs) stepAnd = seqAND(CFseq.name, [ filterAlg, stepReco ]) return stepAnd @@ -336,13 +440,14 @@ def find_stepCF_algs(step_list): def addChainToHypoTool(hypotool, chain): - prop="Chains" - cval = hypotool.getProperties()[prop] - try: - cval.append(chain) - setattr(hypotool, prop, cval) - except: - pass + prop="Chain" + setattr(hypotool, prop, chain) + ## cval = hypotool.getProperties()[prop] + ## try: + ## cval.append(chain) + ## setattr(hypotool, prop, cval) + ## except: + ## pass def addChainToHypoAlg(hypoAlg, chain): @@ -357,10 +462,19 @@ def addChainToHypoAlg(hypoAlg, chain): ####################################### -def decisionTree_From_Chains(HLTAllStepsSeq, chains, NSTEPS=1): - print "ACC decisionTree_From_Chains on %s"%(HLTAllStepsSeq.name()) +def decisionTree_From_Chains(HLTAllStepsSeq, chains): + #from TrigUpgradeTest.MenuHypoTools import * + print "Run decisionTree_From_Chains on %s"%(HLTAllStepsSeq.name()) HLTNodeName= HLTAllStepsSeq.name() testRoR=False + # find nsteps + NSTEPS=0 + for chain in chains: + steps =len(chain.steps) + if NSTEPS < steps: + NSTEPS = steps + print "Run on %d steps"%NSTEPS + from TrigUpgradeTest.MenuComponents import CFSequence #loop over chains to configure count_steps=0 @@ -371,33 +485,55 @@ def decisionTree_From_Chains(HLTAllStepsSeq, chains, NSTEPS=1): CFseq_list = [] step_decisions = [] for chain in chains: + print len(chain.steps), count_steps + if len(chain.steps) <= count_steps: + continue + chain_step=chain.steps[count_steps] chain_step_name= "%s:%s"%(stepCF_name, chain.name) print "\n*******Filling step %s for chain %s"%(stepCF_name, chain.name) - chain_step=chain.steps[count_steps] - sequenceHypoTools=chain_step.sequenceHypoTools + sequenceHypoTools=chain_step.sequences +# sequenceHypoTools=chain_step.sequenceHypoTools countseq=0 otherSubSequence = [] for st in sequenceHypoTools: - sequence=st.sequence - hypotool=st.hypotool - addChainToHypoTool(hypotool, chain.name) + sequence=st + hypotool=chain.hypoToolName + #sequence=st.sequence + #hypotool=st.hypotool +# addChainToHypoTool(hypotool, chain.name) +# print "Going through sequence %s with threshold %s"%(sequence.name, hypotool.getName()) cfseq_name= sequence.name + print "Going through sequence %s with threshold %s"%(sequence.name, hypotool) - print "Going through sequence %s with threshold %s"%(sequence.name, hypotool.getName()) seeds= [nodeSeq.seed for nodeSeq in sequence.nodeSeqList] - print "Found these seeds: %s"%(seeds) + print "Found these seeds form the sequence: %s"%(seeds) #define sequence input - if count_steps == 0: # seeding + if count_steps == 0: # seeding filter_input= seeds #[nodeSeq.seed for nodeSeq in sequence.nodeSeqList] print "Seeds from this chain: %s"%(filter_input) previous_sequence="".join(chain.group_seed) previous_seeds=seeds + + #add check that the sequence seed is foreseen in the chain? + + # some manipulation for having the same strings as in the menu + ## filter_input = [] + ## for seed in seeds: + ## if seed == "L1EM": + ## filter_input.append("EMRoIDecisions") + ## elif seed == "L1MU": + ## filter_input.append("MURoIDecisions") + ## else: + ## filter_input.append(seed) + ## print "Seeds to the filter: %s"%(filter_input) + ## previous_seeds=seeds else: # from previous step, map the seuqence in the same order? - previous_sequence=chain.steps[count_steps-1].sequences[countseq].name #menu sequence - filter_input=chain.steps[count_steps-1].sequences[countseq].outputs + prev=chain.steps[count_steps-1].sequences[countseq] + previous_sequence = prev.name #menu sequence + filter_input = prev.outputs print "Connect to previous sequence through these filter inputs:" print filter_input previous_seeds = chain.steps[count_steps-1].sequences[countseq].seeds @@ -408,10 +544,13 @@ def decisionTree_From_Chains(HLTAllStepsSeq, chains, NSTEPS=1): # add hypotools for nodeSeq in sequence.nodeSeqList: - hypoAlg= nodeSeq.hypo - print "Adding %s to %s"%(hypotool.getName(),hypoAlg.algname) - hypoAlg.addHypoTool(hypotool) + hypoAlg= nodeSeq.hypo + hypoToolClassName= nodeSeq.hypoToolClassName + print "Adding HypoTool::%s with name %s to %s"%(hypoToolClassName,chain.hypoToolName, hypoAlg.algname) + hypoAlg.addHypoTool(chain.hypoToolName, hypoToolClassName) + #hypoAlg.addHypoTool(hypotoolTool) addChainToHypoAlg(hypoAlg, chain.name) # only for TMP Combo +## addChainToHypoTool(hypotoolTool, chain.name) @@ -428,6 +567,7 @@ def decisionTree_From_Chains(HLTAllStepsSeq, chains, NSTEPS=1): sfilter=findFilter[0] print "Adding chain %s to %s"%(chain.name,sfilter.algname) sfilter.setChains(chain.name) + print sfilter.getChains() continue else: ## if (testRoR): @@ -443,7 +583,7 @@ def decisionTree_From_Chains(HLTAllStepsSeq, chains, NSTEPS=1): for o in filter_out: sfilter.setOutput(o) sfilter.setChains(chain.name) - print "Filter Done: %s"%(sfilter) + print "Filter Done: %s"%(sfilter.name) #loop over NodeSequences of this sequence to add inputs to InputMaker and send decisions to HypoAlg for nodeSeq in sequence.nodeSeqList: @@ -456,7 +596,6 @@ def decisionTree_From_Chains(HLTAllStepsSeq, chains, NSTEPS=1): print "Adding %d inputs to sequence::%s from Filter::%s (from seed %s)"%(len(input_maker_input), nodeSeq.name, sfilter.algname, seed) for i in input_maker_input: print i if len(input_maker_input) == 0: -# print "ERROR, no inputs to sequence are set!" sys.exit("ERROR, no inputs to sequence are set!") # return for i in input_maker_input: nodeSeq.addInput(i) @@ -473,7 +612,7 @@ def decisionTree_From_Chains(HLTAllStepsSeq, chains, NSTEPS=1): for out in input_maker_output: nodeSeq.addOutputDecision(out) nodeSeq.hypo.setPreviousDecision(out) - print nodeSeq.hypo.Alg +# print nodeSeq.hypo.Alg #sequence_outDecisions= "SequenceDecision_%s"%nodeSeq.name #nodeSeq.addDecision(sequence_outDecisions) #FPP @@ -488,7 +627,7 @@ def decisionTree_From_Chains(HLTAllStepsSeq, chains, NSTEPS=1): - CF_seq = CFSequence( cfseq_name, FilterAlg=sfilter, MenuSequence=sequence) + CF_seq = CFSequence( cfseq_name, FilterAlg=sfilter, MenuSequence=sequence) #for seq in otherSubsequence: CF_seq.addSubSequence(seq) print CF_seq CFseq_list.append(CF_seq) @@ -497,7 +636,7 @@ def decisionTree_From_Chains(HLTAllStepsSeq, chains, NSTEPS=1): #end of sequence/threshold #end of loop over chains for this step, now implement CF: - print "\n******** Create CF Tree %s with AthSequencers",stepCF_name + print "\n******** Create CF Tree %s with AthSequencers"%(stepCF_name) #first make the filter step stepFilter = create_step_filter_node(stepCF_name, CFseq_list, dump=False) @@ -508,6 +647,7 @@ def decisionTree_From_Chains(HLTAllStepsSeq, chains, NSTEPS=1): stepCF = create_step_reco_node("%s_%s"%(HLTNodeName,stepCF_name), CFseq_list, dump=False) HLTAllStepsSeq += stepCF + # then the monitor summary summary=makeSummary("TriggerSummary"+ stepCF_name, step_decisions) HLTAllStepsSeq += summary diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/HLTSignatureConfig.py b/Trigger/TrigValidation/TrigUpgradeTest/python/HLTSignatureConfig.py similarity index 70% rename from Trigger/TrigValidation/TrigUpgradeTest/share/HLTSignatureConfig.py rename to Trigger/TrigValidation/TrigUpgradeTest/python/HLTSignatureConfig.py index 5440f077c80..59d4183d7ab 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/HLTSignatureConfig.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/HLTSignatureConfig.py @@ -2,16 +2,13 @@ from TrigUpgradeTest.TrigUpgradeTestConf import HLTTest__TestRecoAlg from TrigUpgradeTest.TrigUpgradeTestConf import HLTTest__TestHypoAlg from TrigUpgradeTest.TrigUpgradeTestConf import HLTTest__TestHypoTool from TrigUpgradeTest.TrigUpgradeTestConf import HLTTest__TestComboHypoAlg +from AthenaCommon.Constants import VERBOSE,DEBUG +from TrigUpgradeTest.HLTCFConfig import * +from TrigUpgradeTest.MenuComponents import * -def TestHypoTool(name, prop, threshold_value): -# threshold_value=''.join(filter(lambda x: x.isdigit(), name)) - value = int(threshold_value)*1000 - h = HLTTest__TestHypoTool(name, OutputLevel=DEBUG, Threshold=value, Property=prop) - return h from TrigUpgradeTest.TrigUpgradeTestConf import HLTTest__TestInputMaker def InputMakerAlg(name): - # return HLTTest__TestInputMaker(name, OutputLevel = DEBUG, LinkName=linkname) return HLTTest__TestInputMaker(name, OutputLevel = DEBUG, LinkName="initialRoI") @@ -22,7 +19,26 @@ def InputMakerAlg(name): # - creates the InputMaker, without the inputs -#muon signatures +#### muon signatures +##################### + +## class MuTestHypoTool(HLTTest__TestHypoTool): +## def __init__(self,name): +## HLTTest__TestHypoTool.__init__(self,name, OutputLevel=DEBUG, Property="pt") +## threshold_value = name.replace("HLT_mu","") +## value = int(threshold_value)*1000 +## self.Threshold=value + +def TestHypoTool(name, prop, threshold_value): +# threshold_value=''.join(filter(lambda x: x.isdigit(), name)) + from TrigUpgradeTest.TrigUpgradeTestConf import HLTTest__TestHypoTool + value = int(threshold_value)*1000 + h = HLTTest__TestHypoTool(name, OutputLevel=DEBUG, Threshold=value, Property=prop) + return h + +def MuTestHypoTool(name): + threshold = name.replace("HLT_mu","") + return TestHypoTool(name,prop="pt", threshold_value=threshold) def muMSRecAlg(name, FileName="noreco.dat"): return HLTTest__TestRecoAlg(name=name, FileName=FileName, OutputLevel = DEBUG) @@ -30,17 +46,12 @@ def muMSRecAlg(name, FileName="noreco.dat"): def MuHypo(name): return HLTTest__TestHypoAlg(name=name, OutputLevel = DEBUG) -def step1mu20(): - return TestHypoTool("step1mu20", "pt",20) - -def step1mu8(): - return TestHypoTool("step1mu8", "pt",8) +def MuStep1HypoTool(): + return "MuTestHypoTool" -def step2mu20(): - return TestHypoTool("step2mu20", "pt", 20) +def MuStep2HypoTool(): + return "MuTestHypoTool" -def step2mu8(): - return TestHypoTool("step2mu8", "pt", 8) muIM= InputMakerAlg(name="Step1MuInputMaker") @@ -52,7 +63,7 @@ step1_mu_recoAlg = AlgNode( Alg=muAlg,inputProp='Input', outputProp='Output') muHypo = MuHypo(name="Step1MuHypo") step1_mu_HypoAlg = HypoAlgNode( Alg=muHypo,inputProp='Input', outputProp='Output') -nodeSequence_mu = NodeSequence("muNodeSeq1", Maker=step1_mu_inputMaker, Algs=[step1_mu_recoAlg], Hypo=step1_mu_HypoAlg, Seed="L1MU") +nodeSequence_mu = NodeSequence("muNodeSeq1", Maker=step1_mu_inputMaker, Algs=[step1_mu_recoAlg], Hypo=step1_mu_HypoAlg, Seed="L1MU", HypoToolClassName=MuStep1HypoTool()) def muStep1Sequence(): return MenuSequence("muStep1Seq", nodeSeqList=[nodeSequence_mu]) @@ -64,16 +75,29 @@ step2_mu_inputMaker = AlgNode(Alg=muIM2, inputProp='InputDecisions', outputProp= muAlg2 = muMSRecAlg(name="muMSRecAlg2", FileName="msmu.dat") step2_mu_recoAlg = AlgNode( Alg=muAlg2,inputProp='Input', outputProp='Output') -muHypo2 = MuHypo(name="Step2MuHypo2") +muHypo2 = MuHypo(name="Step2MuHypo") step2_mu_HypoAlg = HypoAlgNode( Alg=muHypo2,inputProp='Input', outputProp='Output') -nodeSequence2_mu = NodeSequence("muNodeSeq2", Maker=step2_mu_inputMaker, Algs=[step2_mu_recoAlg], Hypo=step2_mu_HypoAlg, Seed="L1MU") +nodeSequence2_mu = NodeSequence("muNodeSeq2", Maker=step2_mu_inputMaker, Algs=[step2_mu_recoAlg], Hypo=step2_mu_HypoAlg, Seed="L1MU", HypoToolClassName=MuStep2HypoTool()) def muStep2Sequence(): return MenuSequence("muStep2Seq", nodeSeqList=[nodeSequence2_mu]) -#electron signatures + +##### electron signatures +########################## + +## class ElTestHypoTool(HLTTest__TestHypoTool): +## def __init__(self,name): +## HLTTest__TestHypoTool.__init__(self,name, OutputLevel=DEBUG, Property="et") +## threshold_value = name.replace("HLT_e","") +## value = int(threshold_value)*1000 +## self.Threshold=value + +def ElTestHypoTool(name): + threshold = name.replace("HLT_e","") + return TestHypoTool(name,prop="et", threshold_value=threshold) def CaloClustering(name, FileName="noreco.dat"): return HLTTest__TestRecoAlg(name=name, FileName=FileName, OutputLevel = DEBUG) @@ -82,17 +106,13 @@ def ElGamHypo(name): return HLTTest__TestHypoAlg(name=name, OutputLevel = DEBUG) -def step1e20(): - return TestHypoTool("step1e20", "et",20) +def ElStep1HypoTool(): + return "ElTestHypoTool" -def step1e8(): - return TestHypoTool("step1e8", "et",8) +def ElStep2HypoTool(): + return "ElTestHypoTool" -def step2e20(): - return TestHypoTool("step2e20", "et",20) -def step2e8(): - return TestHypoTool("step2e8", "et",8) elIM= InputMakerAlg(name="Step1ElInputMaker") step1_el_inputMaker = AlgNode(Alg=elIM, inputProp='InputDecisions', outputProp='Output') @@ -103,7 +123,7 @@ step1_el_recoAlg = AlgNode( Alg=elAlg,inputProp='Input', outputProp='Output') elHypo = ElGamHypo(name="Step1ElHypo") step1_el_HypoAlg = HypoAlgNode( Alg=elHypo,inputProp='Input', outputProp='Output') -nodeSequence_el = NodeSequence("elNodeSeq1", Maker=step1_el_inputMaker, Algs=[step1_el_recoAlg], Hypo=step1_el_HypoAlg, Seed="L1EM") +nodeSequence_el = NodeSequence("elNodeSeq1", Maker=step1_el_inputMaker, Algs=[step1_el_recoAlg], Hypo=step1_el_HypoAlg, Seed="L1EM", HypoToolClassName=ElStep1HypoTool()) def elStep1Sequence(): return MenuSequence("elStep1Seq", nodeSeqList=[nodeSequence_el]) @@ -117,7 +137,7 @@ step2_el_recoAlg = AlgNode( Alg=elAlg2,inputProp='Input', outputProp='Output') elHypo2 = ElGamHypo(name="Step2ElHypo") step2_el_HypoAlg = HypoAlgNode( Alg=elHypo2,inputProp='Input', outputProp='Output') -nodeSequence2_el = NodeSequence("elNodeSeq2", Maker=step2_el_inputMaker, Algs=[ step2_el_recoAlg], Hypo=step2_el_HypoAlg, Seed="L1EM") +nodeSequence2_el = NodeSequence("elNodeSeq2", Maker=step2_el_inputMaker, Algs=[ step2_el_recoAlg], Hypo=step2_el_HypoAlg, Seed="L1EM",HypoToolClassName=ElStep2HypoTool()) def elStep2Sequence(): return MenuSequence("elStep2Seq", nodeSeqList=[nodeSequence2_el]) @@ -125,21 +145,29 @@ def elStep2Sequence(): # combined Hypo # ################# +class ComboTestHypoTool(HLTTest__TestHypoTool): + def __init__(self,name): + #doing nothing + HLTTest__TestHypoTool.__init__(self,name, OutputLevel=DEBUG, Property="pt") + + def ComboMuEHypo(name): return HLTTest__TestComboHypoAlg(name=name, OutputLevel = DEBUG, Property1="pt", Property2="et") -def step1mu8_e8(): - return TestHypoTool("step1mu8_e8", "pt",8) -def step2mu8_e8(): - return TestHypoTool("step2mu8_e8", "pt",8) + +def ComboStep1HypoTool(): + return "ComboTestHypoTool" + +def ComboStep2HypoTool(): + return "ComboTestHypoTool" comboAlg = ComboMuEHypo("Step1ComboMuElHypo") step1_comb_HypoAlgMu = HypoAlgNode( Alg=comboAlg,inputProp='Input1', outputProp='Output1') step1_comb_HypoAlgEl = HypoAlgNode( Alg=comboAlg,inputProp='Input2', outputProp='Output2') -nodeSequence_muComb = NodeSequence("CombmuNodeSeq1", Maker=step1_mu_inputMaker, Algs=[step1_mu_recoAlg], Hypo=step1_comb_HypoAlgMu, Seed="L1MU") -nodeSequence_elComb = NodeSequence("CombelNodeSeq1", Maker=step1_el_inputMaker, Algs=[step1_el_recoAlg], Hypo=step1_comb_HypoAlgEl, Seed="L1EM") +nodeSequence_muComb = NodeSequence("CombmuNodeSeq1", Maker=step1_mu_inputMaker, Algs=[step1_mu_recoAlg], Hypo=step1_comb_HypoAlgMu, Seed="L1MU", HypoToolClassName=ComboStep1HypoTool()) +nodeSequence_elComb = NodeSequence("CombelNodeSeq1", Maker=step1_el_inputMaker, Algs=[step1_el_recoAlg], Hypo=step1_comb_HypoAlgEl, Seed="L1EM", HypoToolClassName=ComboStep2HypoTool()) def combStep1Sequence(): @@ -151,8 +179,8 @@ comboAlg2 = ComboMuEHypo("Step2ComboMuElHypo") step2_comb_HypoAlgMu = HypoAlgNode( Alg=comboAlg2,inputProp='Input1', outputProp='Output1') step2_comb_HypoAlgEl = HypoAlgNode( Alg=comboAlg2,inputProp='Input2', outputProp='Output2') -nodeSequence2_muComb = NodeSequence("CombmuNodeSeq2", Maker=step2_mu_inputMaker, Algs=[step2_mu_recoAlg], Hypo=step2_comb_HypoAlgMu, Seed="L1MU") -nodeSequence2_elComb = NodeSequence("CombelNodeSeq2", Maker=step2_el_inputMaker, Algs=[step2_el_recoAlg], Hypo=step2_comb_HypoAlgEl, Seed="L1EM") +nodeSequence2_muComb = NodeSequence("CombmuNodeSeq2", Maker=step2_mu_inputMaker, Algs=[step2_mu_recoAlg], Hypo=step2_comb_HypoAlgMu, Seed="L1MU", HypoToolClassName=ComboStep1HypoTool()) +nodeSequence2_elComb = NodeSequence("CombelNodeSeq2", Maker=step2_el_inputMaker, Algs=[step2_el_recoAlg], Hypo=step2_comb_HypoAlgEl, Seed="L1EM", HypoToolClassName=ComboStep2HypoTool()) def combStep2Sequence(): diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/MenuComponents.py b/Trigger/TrigValidation/TrigUpgradeTest/python/MenuComponents.py index c6f0e9c8bf3..25b61f1c26c 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/MenuComponents.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/MenuComponents.py @@ -1,20 +1,25 @@ ########################################################## - class NodeSequence(): - def __init__(self, name, Algs, Hypo, Seed, Maker): + def __init__(self, name, Algs, Hypo, Seed, Maker, HypoToolClassName, OtherNodes=[]): self.name = name self.algs = Algs self.hypo = Hypo self.seed = Seed self.maker = Maker - self.output = Hypo.getOutput() + self.hypoToolClassName = HypoToolClassName + self.otherNodes=OtherNodes + self.hypo.addDefaultOutput() # reset name + self.output = "%s_%s"%(Seed, Hypo.getOutput()) + self.hypo.setOutput(self.output) self.reuse = 0 + self.hasView() self.connect() def connect(self): self.maker.setInput("") - alg_input = self.maker.getOutput() + alg_input = self.maker.getOutput() + #if self.viewNodeName =='': for Alg in self.algs: Alg.setInput(alg_input) alg_input = Alg.getOutput() @@ -30,6 +35,17 @@ class NodeSequence(): # self.hypo.setPreviousDecision(sequence_outDecisions) # works for one print "connect NodeSequence %s"%self.name + + def hasView(self): + self.viewNodeName='' + hasView=False + for Alg in self.algs: + if Alg.viewNodeName !='': + hasView=True + self.viewNodeName = Alg.viewNodeName + break; + return hasView + def addNode(self,node): self.algs.append(node) @@ -46,7 +62,7 @@ class NodeSequence(): self.maker.setPar("OutputDecisions", theinput) def __str__(self): - return "NodeSequence::%s with \n Seed::%s \n %s \n Hypo::%s"%(self.name, self.seed, ',\n '.join(map(str, self.algs)), self.hypo) + return "NodeSequence::%s with \n Seed::%s \n Maker::%s \n %s \n Hypo::%s"%(self.name, self.seed, self.maker, ',\n '.join(map(str, self.algs)), self.hypo) class ViewNodeSequence(NodeSequence): @@ -106,12 +122,18 @@ class ChainStep: self.sequenceHypoTools = SequenceHypoTools self.sequences = [sh.sequence for sh in SequenceHypoTools ] +class ChainStep2: + def __init__(self, name, Sequences=[]): + self.name = name + self.sequences = Sequences class Chain: def __init__(self, name, Seed, ChainSteps=[]): self.name = name self.seed=Seed self.steps=ChainSteps + self.hypoToolName=name + #self.hypoToolName=name.replace("HLT_","") seeds = Seed.strip().split("_") seeds.pop(0) #remove first L1 @@ -119,3 +141,7 @@ class Chain: self.group_seed = ["L1"+filter(lambda x: x.isalpha(), stri) for stri in seeds] + + + + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/MenuHypoTools.py b/Trigger/TrigValidation/TrigUpgradeTest/python/MenuHypoTools.py new file mode 100644 index 00000000000..9f54b823a34 --- /dev/null +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/MenuHypoTools.py @@ -0,0 +1,19 @@ + +from TrigUpgradeTest.HLTSignatureConfig import TestHypoTool, MuTestHypoTool, ElTestHypoTool, ComboTestHypoTool +from TrigEgammaHypo.TrigEgammaHypoConf import TrigL2CaloHypoToolInc, TrigL2CaloHypoToolMult, TrigL2ElectronHypoTool +from TrigEgammaHypo.TrigL2CaloHypoTool import * + + +def TrigL2CaloHypoToolConf(name): + from AthenaCommon.Constants import DEBUG + from TrigEgammaHypo.TrigL2CaloHypoTool import TrigL2CaloHypoToolFromName + hypotool= TrigL2CaloHypoToolFromName(name) + hypotool.OutputLevel = DEBUG + return hypotool + +def TrigL2ElectronHypoToolConf(name): + from AthenaCommon.Constants import DEBUG + from TrigEgammaHypo.TrigL2ElectronHypoTool import TrigL2ElectronHypoToolFromName + hypotool= TrigL2ElectronHypoToolFromName(name) + hypotool.OutputLevel = DEBUG + return hypotool diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/EmuStepProcessingTest.py b/Trigger/TrigValidation/TrigUpgradeTest/share/EmuStepProcessingTest.py index e48fc2d3779..4b15fd76b5e 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/EmuStepProcessingTest.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/EmuStepProcessingTest.py @@ -13,7 +13,7 @@ # Configure the scheduler from AthenaCommon.AlgScheduler import AlgScheduler AlgScheduler.ShowControlFlow( True ) -AlgScheduler.ShowDataFlow( True ) +#AlgScheduler.ShowDataFlow( True ) # include( "ByteStreamCnvSvc/BSEventStorageEventSelector_jobOptions.py" ) # svcMgr.ByteStreamInputSvc.FullFileName = [ "./input.data" ] @@ -70,6 +70,7 @@ data['photons'] = ['eta:1,phi:1,pt:130000;', ';'] + from TrigUpgradeTest.TestUtils import writeEmulationFiles writeEmulationFiles(data) @@ -117,24 +118,31 @@ print L1UnpackingSeq # filters: one SeqFilter per step, per chain # inputMakers: one per each first RecoAlg in a step (so one per step), one input per chain that needs that step +# map L1 decisions for menu +for unpack in l1Decoder.roiUnpackers: + if unpack.name() is "EMRoIsUnpackingTool": + unpack.Decisions="L1EM" + if unpack.name() is "MURoIsUnpackingTool": + unpack.Decisions="L1MU" + +# signatures from TrigUpgradeTest.HLTCFConfig import * from TrigUpgradeTest.MenuComponents import * -include("TrigUpgradeTest/HLTSignatureConfig.py") -nsteps=2 +from TrigUpgradeTest.HLTSignatureConfig import * + # muon chains muStep1 = muStep1Sequence() muStep2 = muStep2Sequence() + MuChains = [ - Chain(name='HLT_mu20', Seed="L1_MU10", ChainSteps=[ChainStep("Step1_mu20", [SequenceHypoTool(muStep1,step1mu20())]), - ChainStep("Step2_mu20", [SequenceHypoTool(muStep2,step2mu20())]) ] ), + Chain(name='HLT_mu20', Seed="L1_MU10", ChainSteps=[ChainStep2("Step1_mu20", [muStep1]), ChainStep2("Step2_mu20", [muStep2] )]) , + Chain(name='HLT_mu8', Seed="L1_MU6", ChainSteps=[ChainStep2("Step1_mu8", [muStep1] ), ChainStep2("Step2_mu8", [muStep2] ) ] ) + ] - Chain(name='HLT_mu8', Seed="L1_MU6", ChainSteps=[ChainStep("Step1_mu8", [SequenceHypoTool(muStep1,step1mu8())] ), - ChainStep("Step2_mu8", [SequenceHypoTool(muStep2,step2mu8())]) ] ) - ] @@ -142,8 +150,7 @@ MuChains = [ elStep1 = elStep1Sequence() elStep2 = elStep2Sequence() ElChains = [ - Chain(name='HLT_e20' , Seed="L1_EM10", ChainSteps=[ ChainStep("Step1_e20", [SequenceHypoTool(elStep1,step1e20())]), - ChainStep("Step2_e20", [SequenceHypoTool(elStep2,step2e20())]) ] ) + Chain(name='HLT_e20' , Seed="L1_EM10", ChainSteps=[ ChainStep2("Step1_e20", [elStep1]), ChainStep2("Step2_e20", [elStep2]) ] ) ] @@ -151,13 +158,12 @@ ElChains = [ muelStep1 = combStep1Sequence() muelStep2 = combStep2Sequence() CombChains =[ - Chain(name='HLT_mu8_e8' , Seed="L1_EM6_MU6", ChainSteps=[ ChainStep("Step1_mu8_e8", [SequenceHypoTool(muelStep1, step1mu8_e8())]), - ChainStep("Step2_mu8_e8", [SequenceHypoTool(muelStep2, step2mu8_e8())]) ] ) + Chain(name='HLT_mu8_e8' , Seed="L1_EM6_MU6", ChainSteps=[ ChainStep2("Step1_mu8_e8", [muelStep1]), + ChainStep2("Step2_mu8_e8", [muelStep2]) ] ) ] group_of_chains = MuChains + ElChains + CombChains -#+ CombChains #+ ElChains + CombChains @@ -179,7 +185,7 @@ TopHLTRootSeq += HLTAllStepsSeq # make CF tree -decisionTree_From_Chains(HLTAllStepsSeq, group_of_chains, NSTEPS=nsteps) +decisionTree_From_Chains(HLTAllStepsSeq, group_of_chains) @@ -189,3 +195,4 @@ from AthenaCommon.AlgSequence import dumpMasterSequence dumpMasterSequence() theApp.EvtMax = 3 + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.menu.py b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.menu.py index 38b0168eba5..eb37153a8d6 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.menu.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.menu.py @@ -2,31 +2,34 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration # + +print "New egammamenu" + include("TrigUpgradeTest/testHLT_MT.py") +from InDetTrigRecExample.InDetTrigFlags import InDetTrigFlags +InDetTrigFlags.useConditionsClasses.set_Value_and_Lock(False) -## #workaround to prevent online trigger folders to be enabled -## from InDetTrigRecExample.InDetTrigFlags import InDetTrigFlags -## InDetTrigFlags.useConditionsClasses.set_Value_and_Lock(False) +from InDetRecExample.InDetJobProperties import InDetFlags +InDetFlags.doCaloSeededBrem = False -## from InDetRecExample.InDetJobProperties import InDetFlags -## InDetFlags.doCaloSeededBrem = False +from InDetRecExample.InDetJobProperties import InDetFlags +InDetFlags.InDet25nsec = True +InDetFlags.doPrimaryVertex3DFinding = False +InDetFlags.doPrintConfigurables = False +InDetFlags.doResolveBackTracks = True +InDetFlags.doSiSPSeededTrackFinder = True +InDetFlags.doTRTPhaseCalculation = True +InDetFlags.doTRTSeededTrackFinder = True +InDetFlags.doTruth = False +InDetFlags.init() + +# PixelLorentzAngleSvc and SCTLorentzAngleSvc +include("InDetRecExample/InDetRecConditionsAccess.py") +from InDetRecExample.InDetKeys import InDetKeys -## from InDetRecExample.InDetJobProperties import InDetFlags -## InDetFlags.InDet25nsec = True -## InDetFlags.doPrimaryVertex3DFinding = False -## InDetFlags.doPrintConfigurables = False -## InDetFlags.doResolveBackTracks = True -## InDetFlags.doSiSPSeededTrackFinder = True -## InDetFlags.doTRTPhaseCalculation = True -## InDetFlags.doTRTSeededTrackFinder = True -## InDetFlags.doTruth = False -## InDetFlags.init() -## # PixelLorentzAngleSvc and SCTLorentzAngleSvc -## include("InDetRecExample/InDetRecConditionsAccess.py") -## from InDetRecExample.InDetKeys import InDetKeys from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() @@ -46,6 +49,7 @@ from AthenaCommon.AppMgr import ServiceMgr as svcMgr ################################# # first step: calo ################################# +#import AthenaConfiguration.ComponentAccumulator def InputMakerAlg(name): from TrigUpgradeTest.TrigUpgradeTestConf import HLTTest__TestInputMaker return HLTTest__TestInputMaker(name, OutputLevel = DEBUG, LinkName="initialRoI") @@ -77,317 +81,98 @@ def FastCaloHypo(name): def TestFastCaloHypo(name): from TrigEgammaHypo.TrigEgammaHypoConf import TestTrigL2CaloHypoAlg theFastCaloHypo = TestTrigL2CaloHypoAlg(name) + theFastCaloHypo.RunInView=True theFastCaloHypo.OutputLevel = DEBUG return theFastCaloHypo -def TrigL2CaloHypoTool(name): - from TrigEgammaHypo.TrigL2CaloHypoTool import TrigL2CaloHypoToolFromName - hypotool= TrigL2CaloHypoToolFromName(name) - hypotool.OutputLevel = DEBUG - return hypotool - - -def TestTrigL2CaloHypoTool(name): - #from TrigEgammaHypo.TrigEgammaHypoConf import TestTrigL2CaloHypoToolInc - #hypotool= TestTrigL2CaloHypoToolInc(name) - from TrigEgammaHypo.TestTrigL2CaloHypoTool import TestTrigL2CaloHypoToolFromName - hypotool= TestTrigL2CaloHypoToolFromName(name) - hypotool.OutputLevel = DEBUG - return hypotool - -def e3_etcut(): - return TestTrigL2CaloHypoTool("HLT_e3_etcut") -# return TrigL2CaloHypoTool("HLT_e3_etcut") - -def e5_etcut(): - return TestTrigL2CaloHypoTool("HLT_e5_etcut") -# return TrigL2CaloHypoTool("HLT_e5_etcut") - -def e7_etcut(): - return TestTrigL2CaloHypoTool("HLT_e7_etcut") - -#def 2e3_etcut(): - #TrigL2CaloHypoToolMult -# return TestTrigL2CaloHypoTool("HLT_2e3_etcut") # Make the calo sequence ######################## theFastCaloViewsMaker = FastCaloViewsMaker(name="fastCaloViewsMaker") theFastCaloAlgo = FastCaloAlg(name="FastCaloAlgo") + +from TrigMultiVarHypo.TrigL2CaloRingerFexMTInit import init_ringer +trigL2CaloRingerFexMT = init_ringer() +trigL2CaloRingerFexMT.OutputLevel = DEBUG + + fastCaloInViewSequence = theFastCaloViewsMaker.ViewNodeName theFastCaloHypo = TestFastCaloHypo(name="L2CaloHypo") # Nodes & sequence -fastCaloViewsMakerNode = AlgNode( Alg=theFastCaloViewsMaker, inputProp='InputDecisions', outputProp='InViewRoIs') -fastCaloAlgoNode = AlgNode( Alg=theFastCaloAlgo, inputProp='RoIs', outputProp='ClustersName') -fastCaloHypoNode = HypoAlgNode( Alg=theFastCaloHypo, inputProp='CaloClusters', outputProp='Decisions') +node_fastCaloViewsMaker = AlgNode( Alg=theFastCaloViewsMaker, inputProp='InputDecisions', outputProp='InViewRoIs') +node_fastCaloAlgo = AlgNode( Alg=theFastCaloAlgo, inputProp='RoIs', outputProp='ClustersName', ViewNodeName=fastCaloInViewSequence) +node_trigL2CaloRingerFexMT = AlgNode( Alg=trigL2CaloRingerFexMT, ViewNodeName=fastCaloInViewSequence) +node_fastCaloHypo = HypoAlgNode( Alg=theFastCaloHypo, inputProp='CaloClusters', outputProp='Decisions') + +fastCaloViewVerify = CfgMgr.AthViews__ViewDataVerifier("FastCaloViewDataVerifier") + +caloDecisionsDumper = DumpDecisions("caloDecisionsDumper", OutputLevel=DEBUG ) + + -fastCaloViewVerify = CfgMgr.AthViews__ViewDataVerifier("FastCaloViewDataVerifier",\ - DataObjects = [('TrigRoiDescriptorCollection' , 'StoreGateSvc+'+fastCaloViewsMakerNode.getOutput())]) +fastCalo_NodeSequence = NodeSequence("fastCalo_NodeSequence", + Maker=node_fastCaloViewsMaker, + Algs=[node_fastCaloAlgo], #node_trigL2CaloRingerFexMT + Hypo=node_fastCaloHypo, + HypoToolClassName="TrigL2CaloHypoToolConf", + OtherNodes=[AlgNode(Alg=fastCaloViewVerify), AlgNode(Alg=caloDecisionsDumper)], + Seed="L1EM") -caloDecisionsDumper = DumpDecisions("caloDecisionsDumper", OutputLevel=DEBUG, Decisions = theFastCaloHypo.Decisions ) +caloDecisionsDumper.Decisions = theFastCaloHypo.Decisions +fastCaloViewVerify.DataObjects = [('TrigRoiDescriptorCollection' , 'StoreGateSvc+'+node_fastCaloViewsMaker.getOutput())] -fastCalo_NodeSequence = ViewNodeSequence("fastCalo_NodeSequence", - Maker=fastCaloViewsMakerNode, - Algs=[fastCaloAlgoNode], - Hypo=fastCaloHypoNode, - OtherNodes=[AlgNode(Alg=fastCaloViewVerify), AlgNode(Alg=caloDecisionsDumper)], - Seed="EMRoIDecisions") +#, node_trigL2CaloRingerFexMT +#EMRoIDecisions #and then menu sequence fastCaloSequence = MenuSequence("egammaCaloStep", nodeSeqList=[fastCalo_NodeSequence]) -#print fastCaloSequence -#print theFastCaloHypo ######################################### # second step: tracking..... ######################################### -#workaround to prevent online trigger folders to be enabled -from InDetTrigRecExample.InDetTrigFlags import InDetTrigFlags -InDetTrigFlags.useConditionsClasses.set_Value_and_Lock(False) - +# -from InDetRecExample.InDetJobProperties import InDetFlags -InDetFlags.doCaloSeededBrem = False +from TrigUpgradeTest.InDetSetup import makeInDetAlgs +(viewAlgs, eventAlgs) = makeInDetAlgs() +# add egamma TFT +from TrigFastTrackFinder.TrigFastTrackFinder_Config import TrigFastTrackFinder_eGamma +theFTF = TrigFastTrackFinder_eGamma() +theFTF.isRoI_Seeded = True +viewAlgs.append(theFTF) -from InDetRecExample.InDetJobProperties import InDetFlags -InDetFlags.InDet25nsec = True -InDetFlags.doPrimaryVertex3DFinding = False -InDetFlags.doPrintConfigurables = False -InDetFlags.doResolveBackTracks = True -InDetFlags.doSiSPSeededTrackFinder = True -InDetFlags.doTRTPhaseCalculation = True -InDetFlags.doTRTSeededTrackFinder = True -InDetFlags.doTruth = False -InDetFlags.init() +# A simple algorithm to confirm that data has been inherited from parent view +# Required to satisfy data dependencies +ViewVerify = CfgMgr.AthViews__ViewDataVerifier("electronViewDataVerifier") +#ViewVerify.DataObjects = [('xAOD::TrigEMClusterContainer','StoreGateSvc+L2CaloClusters')] +viewAlgs.append(ViewVerify) -# PixelLorentzAngleSvc and SCTLorentzAngleSvc -include("InDetRecExample/InDetRecConditionsAccess.py") -from InDetRecExample.InDetKeys import InDetKeys +## electronViewDataVerifier = CfgMgr.AthViews__ViewDataVerifier("electronViewDataVerifier") +## electronViewDataVerifier.DataObjects = [('xAOD::TrigEMClusterContainer','StoreGateSvc+' + node_l2ElectronViewsMaker.getOutput() )] +#nodes.append(AlgNode(Alg=electronViewDataVerifier, ViewNodeName=electronInViewSequence)) -def InDetCacheCreatorTrigViews(name="InDetCacheCreatorTrigViews"): - from InDetPrepRawDataFormation.InDetPrepRawDataFormationConf import InDet__CacheCreator - InDetCacheCreatorTrigViews = InDet__CacheCreator(name = name, - Pixel_ClusterKey = "PixelTrigClustersCache", - SCT_ClusterKey = "SCT_ClustersCache", - SpacePointCachePix = "PixelSpacePointCache", - SpacePointCacheSCT = "SctSpacePointCache", - SCTRDOCacheKey = "SctRDOCache", - PixRDOCacheKey = "PixRDOCache", - OutputLevel=DEBUG) - return InDetCacheCreatorTrigViews - -#Pixel -def InDetPixelRawDataProvider(): - from PixelRawDataByteStreamCnv.PixelRawDataByteStreamCnvConf import PixelRodDecoder - InDetPixelRodDecoder = PixelRodDecoder(name = "InDetPixelRodDecoder") - svcMgr.ToolSvc += InDetPixelRodDecoder - - from PixelRawDataByteStreamCnv.PixelRawDataByteStreamCnvConf import PixelRawDataProviderTool - InDetPixelRawDataProviderTool = PixelRawDataProviderTool(name = "InDetPixelRawDataProviderTool", - Decoder = InDetPixelRodDecoder) - svcMgr.ToolSvc += InDetPixelRawDataProviderTool - if (InDetFlags.doPrintConfigurables()): - print InDetPixelRawDataProviderTool - - # load the PixelRawDataProvider - from PixelRawDataByteStreamCnv.PixelRawDataByteStreamCnvConf import PixelRawDataProvider - InDetPixelRawDataProvider = PixelRawDataProvider(name = "InDetPixelRawDataProvider", - RDOKey = InDetKeys.PixelRDOs(), - ProviderTool = InDetPixelRawDataProviderTool, -# RDOCacheKey = InDetCacheCreatorTrigViews.PixRDOCacheKey, - isRoI_Seeded = True, - OutputLevel = INFO ) - return InDetPixelRawDataProvider - -#SCT -def InDetSCTRawDataProvider(): - from SCT_RawDataByteStreamCnv.SCT_RawDataByteStreamCnvConf import SCT_RodDecoder - InDetSCTRodDecoder = SCT_RodDecoder(name = "InDetSCTRodDecoder", - TriggerMode = False) - svcMgr.ToolSvc += InDetSCTRodDecoder - - from SCT_RawDataByteStreamCnv.SCT_RawDataByteStreamCnvConf import SCTRawDataProviderTool - InDetSCTRawDataProviderTool = SCTRawDataProviderTool(name = "InDetSCTRawDataProviderTool", - Decoder = InDetSCTRodDecoder) - svcMgr.ToolSvc += InDetSCTRawDataProviderTool - if (InDetFlags.doPrintConfigurables()): - print InDetSCTRawDataProviderTool - - # load the SCTRawDataProvider - from SCT_RawDataByteStreamCnv.SCT_RawDataByteStreamCnvConf import SCTRawDataProvider - InDetSCTRawDataProvider = SCTRawDataProvider(name = "InDetSCTRawDataProvider", - RDOKey = InDetKeys.SCT_RDOs(), - ProviderTool = InDetSCTRawDataProviderTool, - isRoI_Seeded = True ) - -# InDetSCTRawDataProvider.RDOCacheKey = InDetCacheCreatorTrigViews.SCTRDOCacheKey - return InDetSCTRawDataProvider - -#TRT -def InDetTRTRawDataProvider(): - from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_CalDbSvc - from AthenaCommon.AppMgr import ServiceMgr as svcMgr - InDetTRTCalDbSvc = TRT_CalDbSvc() - svcMgr += InDetTRTCalDbSvc - - from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_StrawStatusSummarySvc - InDetTRTStrawStatusSummarySvc = TRT_StrawStatusSummarySvc(name = "InDetTRTStrawStatusSummarySvc") - svcMgr += InDetTRTStrawStatusSummarySvc - - from TRT_RawDataByteStreamCnv.TRT_RawDataByteStreamCnvConf import TRT_RodDecoder - InDetTRTRodDecoder = TRT_RodDecoder(name = "InDetTRTRodDecoder", - LoadCompressTableDB = True)#(globalflags.DataSource() != 'geant4')) - svcMgr.ToolSvc += InDetTRTRodDecoder - - from TRT_RawDataByteStreamCnv.TRT_RawDataByteStreamCnvConf import TRTRawDataProviderTool - InDetTRTRawDataProviderTool = TRTRawDataProviderTool(name = "InDetTRTRawDataProviderTool", - Decoder = InDetTRTRodDecoder) - svcMgr.ToolSvc += InDetTRTRawDataProviderTool +TrackParticlesName = "" +for viewAlg in viewAlgs: + if viewAlg.name() == "InDetTrigTrackParticleCreatorAlg": + TrackParticlesName = viewAlg.TrackParticlesName - - # load the TRTRawDataProvider - from TRT_RawDataByteStreamCnv.TRT_RawDataByteStreamCnvConf import TRTRawDataProvider - InDetTRTRawDataProvider = TRTRawDataProvider(name = "InDetTRTRawDataProvider", - RDOKey = "TRT_RDOs", - ProviderTool = InDetTRTRawDataProviderTool, - isRoI_Seeded = True ) - - return InDetTRTRawDataProvider - - -#Pixel clusterisation -from SiClusterizationTool.SiClusterizationToolConf import InDet__ClusterMakerTool -InDetClusterMakerTool = InDet__ClusterMakerTool(name = "InDetClusterMakerTool", - PixelCalibSvc = None, - PixelOfflineCalibSvc = None, - UsePixelCalibCondDB = False) -svcMgr.ToolSvc += InDetClusterMakerTool - - -def InDetPixelClusterization(): - from SiClusterizationTool.SiClusterizationToolConf import InDet__MergedPixelsTool - InDetMergedPixelsTool = InDet__MergedPixelsTool(name = "InDetMergedPixelsTool", - globalPosAlg = InDetClusterMakerTool, - MinimalSplitSize = 0, - MaximalSplitSize = 49, - MinimalSplitProbability = 0, - DoIBLSplitting = True, - SplitClusterAmbiguityMap= InDetKeys.SplitClusterAmbiguityMap()) - svcMgr.ToolSvc += InDetMergedPixelsTool - - from SiClusterizationTool.SiClusterizationToolConf import InDet__PixelGangedAmbiguitiesFinder - InDetPixelGangedAmbiguitiesFinder = InDet__PixelGangedAmbiguitiesFinder(name = "InDetPixelGangedAmbiguitiesFinder") - svcMgr.ToolSvc += InDetPixelGangedAmbiguitiesFinder - - from InDetPrepRawDataFormation.InDetPrepRawDataFormationConf import InDet__PixelClusterization - InDetPixelClusterization = InDet__PixelClusterization(name = "InDetPixelClusterization", - clusteringTool = InDetMergedPixelsTool, - gangedAmbiguitiesFinder = InDetPixelGangedAmbiguitiesFinder, - DetectorManagerName = InDetKeys.PixelManager(), - DataObjectName = InDetKeys.PixelRDOs(), - ClustersName = "PixelTrigClusters", - isRoI_Seeded = True) - -# InDetPixelClusterization.ClusterContainerCacheKey = InDetCacheCreatorTrigViews.Pixel_ClusterKey - return InDetPixelClusterization - - -def InDetSCT_Clusterization(): - # - # --- SCT_ClusteringTool (public) - # - from SiClusterizationTool.SiClusterizationToolConf import InDet__SCT_ClusteringTool - InDetSCT_ClusteringTool = InDet__SCT_ClusteringTool(name = "InDetSCT_ClusteringTool", - globalPosAlg = InDetClusterMakerTool, - conditionsService = InDetSCT_ConditionsSummarySvc) - # - # --- SCT_Clusterization algorithm - # - from InDetPrepRawDataFormation.InDetPrepRawDataFormationConf import InDet__SCT_Clusterization - InDetSCT_Clusterization = InDet__SCT_Clusterization(name = "InDetSCT_Clusterization", - clusteringTool = InDetSCT_ClusteringTool, - # ChannelStatus = InDetSCT_ChannelStatusAlg, - DetectorManagerName = InDetKeys.SCT_Manager(), - DataObjectName = InDetKeys.SCT_RDOs(), - ClustersName = "SCT_TrigClusters", - conditionsService = InDetSCT_ConditionsSummarySvc, - # FlaggedConditionService = InDetSCT_FlaggedConditionSvc, - isRoI_Seeded = True ) - -# InDetSCT_Clusterization.ClusterContainerCacheKey = InDetCacheCreatorTrigViews.SCT_ClusterKey - return InDetSCT_Clusterization - - -def InDetSiTrackerSpacePointFinder(): - #Space points and FTF - - from SiSpacePointTool.SiSpacePointToolConf import InDet__SiSpacePointMakerTool - InDetSiSpacePointMakerTool = InDet__SiSpacePointMakerTool(name = "InDetSiSpacePointMakerTool") - svcMgr.ToolSvc += InDetSiSpacePointMakerTool - - from SiSpacePointFormation.SiSpacePointFormationConf import InDet__SiTrackerSpacePointFinder - InDetSiTrackerSpacePointFinder = InDet__SiTrackerSpacePointFinder(name = "InDetSiTrackerSpacePointFinder", - SiSpacePointMakerTool = InDetSiSpacePointMakerTool, - PixelsClustersName = "PixelTrigClusters", - SCT_ClustersName = "SCT_TrigClusters", - SpacePointsPixelName = "PixelTrigSpacePoints", - SpacePointsSCTName = "SCT_TrigSpacePoints", - SpacePointsOverlapName = InDetKeys.OverlapSpacePoints(), - ProcessPixels = DetFlags.haveRIO.pixel_on(), - ProcessSCTs = DetFlags.haveRIO.SCT_on(), - ProcessOverlaps = DetFlags.haveRIO.SCT_on(), - OutputLevel=DEBUG) - -# InDetSiTrackerSpacePointFinder.SpacePointCacheSCT = InDetCacheCreatorTrigViews.SpacePointCacheSCT -# InDetSiTrackerSpacePointFinder.SpacePointCachePix = InDetCacheCreatorTrigViews.SpacePointCachePix - return InDetSiTrackerSpacePointFinder - - -def TrigFastTrackFinder_eGamma(): - from TrigFastTrackFinder.TrigFastTrackFinder_Config import TrigFastTrackFinder_eGamma - theFTF = TrigFastTrackFinder_eGamma() - theFTF.OutputLevel = DEBUG - return theFTF - -def InDetTrigTrackParticleCreatorAlg(): - from TrigInDetConf.TrigInDetRecCommonTools import InDetTrigFastTrackSummaryTool - from TrigInDetConf.TrigInDetPostTools import InDetTrigParticleCreatorToolFTF - - from InDetTrigParticleCreation.InDetTrigParticleCreationConf import InDet__TrigTrackingxAODCnvMT - theTrackParticleCreatorAlg = InDet__TrigTrackingxAODCnvMT(name = "InDetTrigTrackParticleCreatorAlg", - doIBLresidual = False, - TrackName = "TrigFastTrackFinder_Tracks", - TrackParticlesName = "xAODTracks", - ParticleCreatorTool = InDetTrigParticleCreatorToolFTF) - - return theTrackParticleCreatorAlg - - -# New second step def l2ElectronViewsMaker(): l2ElectronViewsMaker = TestEventViewCreatorAlgorithm("l2ElectronViewsMaker", OutputLevel=DEBUG) l2ElectronViewsMaker.ViewFallThrough = True l2ElectronViewsMaker.RoIsLink = "roi" # -||- - l2ElectronViewsMaker.InViewRoIs = "EMIDRoIs" # contract with the fastCalo + l2ElectronViewsMaker.InViewRoIs = "EMIDRoIs" l2ElectronViewsMaker.Views = "EMElectronViews" - #l2ElectronViewsMaker.Decisions = filterCaloRoIsAlg.Output[0] # output of L2CaloHypo l2ElectronViewsMaker.ViewNodeName = "electronInViewAlgs" return l2ElectronViewsMaker -# A simple algorithm to confirm that data has been inherited from parent view -# Required to satisfy data dependencies -electronViewDataVerifier = CfgMgr.AthViews__ViewDataVerifier("electronViewDataVerifier") -electronViewDataVerifier.DataObjects = [('xAOD::TrigEMClusterContainer','StoreGateSvc+'+fastCaloAlgoNode.outputProp)] -#, ViewVerify, def L2ElectronFex_1(): from TrigEgammaHypo.TrigL2ElectronFexMTConfig import L2ElectronFex_1 @@ -399,17 +184,15 @@ def L2ElectronFex_1(): return theElectronFex -def TrigL2ElectronHypoAlg(): - from TrigEgammaHypo.TrigEgammaHypoConf import TrigL2ElectronHypoAlg - from TrigEgammaHypo.TrigL2ElectronHypoTool import TrigL2ElectronHypoToolFromName - theElectronHypo = TrigL2ElectronHypoAlg() - #theElectronHypo.Views = l2ElectronViewsMaker.Views - #theElectronHypo.Electrons = theElectronFex.ElectronsName - #theElectronHypo.ClusterDecisions = theFastCaloHypo.Decisions - theElectronHypo.ElectronDecisions = "ElectronL2Decisions" - theElectronHypo.OutputLevel = VERBOSE - #theElectronHypo.HypoTools = [ TrigL2ElectronHypoToolFromName( c ) for c in testChains ] - return theElectronHypo + + +def TestTrigElectronHypo(name): + from TrigEgammaHypo.TrigEgammaHypoConf import TestTrigL2ElectronHypoAlg + theElectronHypo = TestTrigL2ElectronHypoAlg(name) + theElectronHypo.RunInView=True + theElectronHypo.OutputLevel = DEBUG + return theElectronHypo + ############################# @@ -417,98 +200,66 @@ def TrigL2ElectronHypoAlg(): ############################# -InDetCacheCreatorTrigViews = InDetCacheCreatorTrigViews() -l2ElectronViewsMaker = l2ElectronViewsMaker() -#ID sequence algorithms -InDetPixelRawDataProvider = InDetPixelRawDataProvider() -InDetSCTRawDataProvider = InDetSCTRawDataProvider() -InDetTRTRawDataProvider = InDetTRTRawDataProvider() -InDetPixelClusterization = InDetPixelClusterization() -InDetSCT_Clusterization = InDetSCT_Clusterization() -InDetSiTrackerSpacePointFinder = InDetSiTrackerSpacePointFinder() -TrigFastTrackFinder_eGamma = TrigFastTrackFinder_eGamma() -InDetTrigTrackParticleCreatorAlg = InDetTrigTrackParticleCreatorAlg() # alg electron: -L2ElectronFex_1 = L2ElectronFex_1() - - -# now make the seuqences - -# rdo sequence: create RDOkeys -#InDetPixelRawDataProvider.RDOCacheKey = InDetCacheCreatorTrigViews.PixRDOCacheKey, -#InDetSCTRawDataProvider.RDOCacheKey = InDetCacheCreatorTrigViews.SCTRDOCacheKey -NodePixelRDO_InDetCacheCreatorTrigViews = AlgNode(Alg=InDetCacheCreatorTrigViews, inputProp='', outputProp='PixRDOCacheKey') -NodeSCTRDO_InDetCacheCreatorTrigViews = AlgNode(Alg=InDetCacheCreatorTrigViews, inputProp='', outputProp='SCTRDOCacheKey') - -NodeRDO_InDetPixelRawDataProvider = AlgNode( Alg=InDetPixelRawDataProvider, inputProp='RDOCacheKey', outputProp='') -NodeRDO_InDetSCTRawDataProvider = AlgNode( Alg=InDetSCTRawDataProvider, inputProp='RDOCacheKey', outputProp='') - - -# cluster seuqence: -#InDetPixelClusterization.ClusterContainerCacheKey = InDetCacheCreatorTrigViews.Pixel_ClusterKey -#InDetSCT_Clusterization.ClusterContainerCacheKey = InDetCacheCreatorTrigViews.SCT_ClusterKey - -NodePixelCluster_InDetCacheCreatorTrigViews = AlgNode(Alg=InDetCacheCreatorTrigViews, inputProp='', outputProp='Pixel_ClusterKey') -NodeSCTCluster_InDetCacheCreatorTrigViews = AlgNode(Alg=InDetCacheCreatorTrigViews, inputProp='', outputProp='SCT_ClusterKey') - -NodeCluster_InDetPixelClusterization = AlgNode( Alg=InDetPixelClusterization, inputProp='ClusterContainerCacheKey', outputProp='') -NodeCluster_InDetSCT_Clusterization = AlgNode( Alg=InDetSCT_Clusterization, inputProp='ClusterContainerCacheKey', outputProp='') +l2ElectronViewsMaker = l2ElectronViewsMaker() +electronInViewSequence=l2ElectronViewsMaker.ViewNodeName +theElectronFex = L2ElectronFex_1() -# space point sequence -#InDetSiTrackerSpacePointFinder.SpacePointCacheSCT = InDetCacheCreatorTrigViews.SpacePointCacheSCT -#InDetSiTrackerSpacePointFinder.SpacePointCachePix = InDetCacheCreatorTrigViews.SpacePointCachePix -NodePixelSP_InDetCacheCreatorTrigViews = AlgNode(Alg=InDetCacheCreatorTrigViews, inputProp='', outputProp='SpacePointCachePix') -NodeSCTSP_InDetCacheCreatorTrigViews = AlgNode(Alg=InDetCacheCreatorTrigViews, inputProp='', outputProp='SpacePointCacheSCT') -NodePixelSP_InDetSiTrackerSpacePointFinder = AlgNode(Alg=InDetSiTrackerSpacePointFinder, inputProp='SpacePointCachePix', outputProp='') -NodeSCTSP_InDetSiTrackerSpacePointFinder = AlgNode(Alg=InDetSiTrackerSpacePointFinder, inputProp='SpacePointCacheSCT', outputProp='') +theL2ElectronHypoAlg = TestTrigElectronHypo(name="TestTrigElectronHypoAlg") +#theFastCaloHypo #theL2ElectronHypoAlg +electronDecisionsDumper = DumpDecisions("electronDecisionsDumper", OutputLevel=DEBUG) -# view sequence -Node_l2ElectronViewsMaker = AlgNode(Alg=l2ElectronViewsMaker, inputProp='InputDecisions', outputProp='InViewRoIs') -# algorithms in view: -#IDSequence = [ InDetPixelRawDataProvider, InDetSCTRawDataProvider, InDetTRTRawDataProvider, InDetPixelClusterization, InDetSCT_Clusterization, InDetSiTrackerSpacePointFinder, theFTF, theTrackParticleCreatorAlg ] -# : take rois from viewCreator -NodeRoI_InDetPixelRawDataProvider = AlgNode( Alg=InDetPixelRawDataProvider, inputProp='RoIs', outputProp='') -NodeRoI_InDetSCTRawDataProvider = AlgNode( Alg=InDetSCTRawDataProvider, inputProp='RoIs', outputProp='') -NodeRoI_InDetTRTRawDataProvider = AlgNode( Alg=InDetTRTRawDataProvider, inputProp='RoIs', outputProp='') -NodeRoI_InDetPixelClusterization = AlgNode( Alg=InDetPixelClusterization, inputProp='RoIs', outputProp='') -NodeRoI_InDetSCT_Clusterization = AlgNode( Alg=InDetSCT_Clusterization, inputProp='RoIs', outputProp='') -NodeRoI_InDetSiTrackerSpacePointFinder = AlgNode( Alg=InDetSiTrackerSpacePointFinder, inputProp='RoIs', outputProp='') -NodeRoI_TrigFastTrackFinder_eGamma = AlgNode( Alg= TrigFastTrackFinder_eGamma, inputProp='RoIs', outputProp='') -NodeRoI_InDetTrigTrackParticleCreatorAlg = AlgNode( Alg=InDetTrigTrackParticleCreatorAlg, - inputProp='roiCollectionName', - outputProp='TrackParticlesName') -# particle creator -#theTrackParticleCreatorAlg.roiCollectionName = l2ElectronViewsMaker.InViewRoIs -#theElectronFex.TrackParticlesName = theTrackParticleCreatorAlg.TrackParticlesName -NodeTrack_L2ElectronFex_1 = AlgNode( Alg=L2ElectronFex_1, inputProp='TrackParticlesName', outputProp='ElectronsName') +# make nodes -#take rois from viewCreator -Node_electronViewDataVerifier = AlgNode( Alg=electronViewDataVerifier) -NodeCluster_L2ElectronFex_1 = AlgNode( Alg=L2ElectronFex_1, inputProp='TrigEMClusterName', outputProp='ElectronsName') +nodes = [] +node_l2ElectronViewsMaker = AlgNode(Alg=l2ElectronViewsMaker, inputProp='InputDecisions') +#, outputProp='InViewRoIs') +# A simple algorithm to confirm that data has been inherited from parent view +# Required to satisfy data dependencies +for alg in eventAlgs: + nodes.append(AlgNode(alg)) + print "Added Alg %s"%(alg.name()) -# hypo -## Node_TrigL2ElectronHypoAlg = HypoAlgNode( Alg=TrigL2ElectronHypoAlg(), inputProp='Electrons', outputProp='ElectronDecisions') +for viewAlg in viewAlgs: + nodes.append(AlgNode(viewAlg, ViewNodeName=electronInViewSequence)) + print "Added Alg %s on electronInViewSequence"%(viewAlg.name()) + -## electron_NodeSequence = ViewNodeSequence("electron_NodeSequence", -## Maker=Node_l2ElectronViewsMaker, -## Algs=[NodeRoI_InDetPixelRawDataProvider, -## NodeRoI_InDetSCTRawDataProvider, -## NodeRoI_InDetTRTRawDataProvider, -## NodeRoI_InDetPixelClusterization ], -## Hypo=Node_TrigL2ElectronHypoAlg, -## Seed="") +node_theElectronFex = AlgNode( Alg=theElectronFex, outputProp='ElectronsName', ViewNodeName=electronInViewSequence) +# inputProp='TrigEMClusterName' +nodes.append(node_theElectronFex) +node_TrigL2ElectronHypoAlg = HypoAlgNode( Alg=theL2ElectronHypoAlg, inputProp='Electrons', outputProp='Decisions') +electron_NodeSequence = NodeSequence("electron_NodeSequence", + Maker=node_l2ElectronViewsMaker, + Algs=nodes, + Hypo=node_TrigL2ElectronHypoAlg, + OtherNodes=[ AlgNode(electronDecisionsDumper)], + HypoToolClassName="TrigL2ElectronHypoToolConf", + Seed="L1EM") +for viewAlg in viewAlgs: + if viewAlg.properties().has_key("RoIs"): + viewAlg.RoIs = l2ElectronViewsMaker.InViewRoIs + if viewAlg.properties().has_key("roiCollectionName"): + viewAlg.roiCollectionName = l2ElectronViewsMaker.InViewRoIs +theElectronFex.RoIs = l2ElectronViewsMaker.InViewRoIs +theElectronFex.TrigEMClusterName = theFastCaloAlgo.ClustersName +theElectronFex.TrackParticlesName = TrackParticlesName +theL2ElectronHypoAlg.Electrons = theElectronFex.ElectronsName +electronDecisionsDumper.Decisions = theL2ElectronHypoAlg.Decisions +ViewVerify.DataObjects = [('xAOD::TrigEMClusterContainer','StoreGateSvc+'+theFastCaloAlgo.ClustersName )] +electronSequence = MenuSequence("electronStep", nodeSeqList=[electron_NodeSequence]) ########################################## @@ -516,16 +267,28 @@ NodeCluster_L2ElectronFex_1 = AlgNode( Alg=L2ElectronFex_1, inputProp='TrigE ########################################## #testChains = ["HLT_e3_etcut", "HLT_e5_etcut", "HLT_e7_etcut", "HLT_2e3_etcut", "HLT_e3e5_etcut"] +# map L1 decisions for menu +for unpack in topSequence.L1DecoderTest.roiUnpackers: + if unpack.name() is "EMRoIsUnpackingTool": + unpack.Decisions="L1EM" + if unpack.name() is "MURoIsUnpackingTool": + unpack.Decisions="L1MU" + testChains = [ - Chain(name='HLT_e3_etcut', Seed="L1_EM3", \ - ChainSteps=[ChainStep("Step1_e3_etcut", [SequenceHypoTool(fastCaloSequence,e3_etcut() )])]), + Chain(name='HLT_e3_etcut', Seed="L1_EM3", \ + ChainSteps=[ ChainStep2("Step1_e3_etcut", [fastCaloSequence]), + ChainStep2("Step2_e3_etcut", [electronSequence])] ), + + ## Chain(name='HLT_e3_etcut', Seed="L1_EM3", \ + ## ChainSteps=[ ChainStep("Step1_e3_etcut", [SequenceHypoTool(fastCaloSequence,step1_e3_etcut() )])] ), + Chain(name='HLT_e5_etcut', Seed="L1_EM3", \ - ChainSteps=[ChainStep("Step1_e5_etcut", [SequenceHypoTool(fastCaloSequence,e5_etcut() )])]), + ChainSteps=[ChainStep2("Step1_e5_etcut", [fastCaloSequence])]), Chain(name='HLT_e7_etcut', Seed="L1_EM3", \ - ChainSteps=[ChainStep("Step1_e7_etcut", [SequenceHypoTool(fastCaloSequence,e7_etcut() )])]), - # Chain(name='HLT_2e3_etcut', Seed="L1_EM3", \ - # ChainSteps=[ChainStep("Step1_2e3_etcut", [SequenceHypoTool(fastCaloSequence, 2e3_etcut() )])]) + ChainSteps=[ChainStep2("Step1_e7_etcut", [fastCaloSequence])]), + #Chain(name='HLT_2e3_etcut', Seed="L1_EM3", \ + # ChainSteps=[ChainStep("Step1_2e3_etcut", [SequenceHypoTool(fastCaloSequence, 2e3_etcut() )])]) ] topSequence.L1DecoderTest.prescaler.Prescales = ["HLT_e3_etcut:2", "HLT_2e3_etcut:2.5"] @@ -553,7 +316,7 @@ summary.FinalDecisions = [ "ElectronL2Decisions", "MuonL2Decisions" ] summary.OutputLevel = DEBUG steps = seqAND("EgammaMenu_HLTSteps" ) -decisionTree_From_Chains(steps, testChains, NSTEPS=1) +decisionTree_From_Chains(steps, testChains) steps += summary mon = TriggerSummaryAlg( "TriggerMonitoringAlg" ) @@ -567,13 +330,18 @@ hltTop = seqOR( "hltTop", [ steps, mon] ) topSequence += hltTop -#print fastCaloViewsMaker -#print theFastCaloHypo - - ########################################## from AthenaCommon.AlgSequence import dumpSequence dumpSequence(topSequence) + +print "Now some debug" +print theElectronFex +#print fastCaloSequence +print theFastCaloHypo +print theFastCaloViewsMaker +print l2ElectronViewsMaker +print ViewVerify + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py index c12d2e6508f..77172fb6ee5 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py @@ -124,6 +124,7 @@ viewAlgs.append(theFTF) # Required to satisfy data dependencies ViewVerify = CfgMgr.AthViews__ViewDataVerifier("electronViewDataVerifier") ViewVerify.DataObjects = [('xAOD::TrigEMClusterContainer','StoreGateSvc+L2CaloClusters')] +ViewVerify.OutputLevel = DEBUG viewAlgs.append(ViewVerify) TrackParticlesName = "" @@ -218,4 +219,10 @@ mon.OutputLevel = DEBUG hltTop = seqOR( "hltTop", [ steps, mon] ) topSequence += hltTop - + + +from AthenaCommon.AlgSequence import dumpSequence +dumpSequence(topSequence) + +#print theElectronFex +#print ViewVerify diff --git a/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoAlg.cxx b/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoAlg.cxx index b3a4e2d0c9d..b0727f958d1 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoAlg.cxx +++ b/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoAlg.cxx @@ -95,7 +95,8 @@ namespace HLTTest { auto d = newDecisionIn(decisions.get()); d->setObjectLink( "feature", ElementLink<xAOD::TrigCompositeContainer>(m_recoInput.key(), counter) );// feature used by the Tool d->setObjectLink( "initialRoI", featurelink );// this is used by the InputMaker - d->setObjectLink( "previousDecisions", ElementLink<DecisionContainer>(m_previousDecisions.key(), pos) );// link to previous decision object + linkToPrevious( d, m_previousDecisions.key(), pos ); + // d->setObjectLink( "previousDecisions", ElementLink<DecisionContainer>(m_previousDecisions.key(), pos) );// link to previous decision object } else{ ATH_MSG_ERROR( " Can not find reference to previous decision from feature " + m_linkName.value() + " from reco object " << counter ); diff --git a/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoTool.cxx b/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoTool.cxx index 8c7b63d31b4..d34daf411b0 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoTool.cxx +++ b/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoTool.cxx @@ -3,6 +3,9 @@ */ // TrigUpgradeTest includes #include "TestHypoTool.h" +#include "DecisionHandling/HLTIdentifier.h" + +using namespace TrigCompositeUtils; namespace HLTTest { @@ -14,6 +17,7 @@ namespace HLTTest { AthAlgTool( type, name, parent ) { declareProperty( "Threshold", m_threshold ); declareProperty( "Property", m_property ); + m_decisionId=HLT::Identifier::fromToolName(name ); } TestHypoTool::~TestHypoTool() {} @@ -21,19 +25,25 @@ namespace HLTTest { StatusCode TestHypoTool::initialize() { ATH_MSG_INFO( "Initializing " << name() << "..." ); - ATH_MSG_DEBUG(m_threshold); - ATH_MSG_DEBUG(m_property); + ATH_MSG_DEBUG( "Configured to require chain " << m_decisionId ); + ATH_MSG_DEBUG("threshold="<<m_threshold); + ATH_MSG_DEBUG("property="<<m_property); + + // const std::string chain = m_chainProperty; + // m_decisionId = HLT::Identifier::fromToolName(chain ); + // ATH_MSG_DEBUG( "Configured to require chain " <<m_chainProperty<<" -> "<< m_decisionId ); + - CHECK( not m_chainsProperty.empty() ); + // CHECK( not m_chainsProperty.empty() ); - for ( const std::string& el: m_chainsProperty ) - m_chains.insert( HLT::Identifier( el ).numeric() ); + // for ( const std::string& el: m_chainsProperty ) + // m_chains.insert( HLT::Identifier( el ).numeric() ); - for ( const HLT::Identifier& id: m_chains ) - ATH_MSG_DEBUG( "Configured to require chain " << id ); + // for ( const HLT::Identifier& id: m_chains ) + // ATH_MSG_DEBUG( "Configured to require chain " << id ); - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } @@ -43,7 +53,8 @@ namespace HLTTest { size_t counter = 0; for ( auto d: *decisions ) { //get previous decisions - auto previousDecisions = d->objectLink<DecisionContainer>( "previousDecisions" ); + // auto previousDecisions = d->objectLink<DecisionContainer>( "previousDecisions" ); + auto previousDecisions = linkToPrevious( d); TrigCompositeUtils::DecisionIDContainer objDecisions; TrigCompositeUtils::decisionIDs( *previousDecisions, objDecisions ); @@ -53,12 +64,17 @@ namespace HLTTest { ATH_MSG_DEBUG( " -- found decision " << HLT::Identifier( id ) ); } - std::vector<TrigCompositeUtils::DecisionID> intersection; - std::set_intersection( m_chains.begin(), m_chains.end(), - objDecisions.begin(), objDecisions.end(), - std::back_inserter( intersection ) ); - - if ( not intersection.empty() ) { + // std::vector<TrigCompositeUtils::DecisionID> intersection; + // std::set_intersection( m_chains.begin(), m_chains.end(), + // objDecisions.begin(), objDecisions.end(), + // std::back_inserter( intersection ) ); + + TrigCompositeUtils::DecisionID intersection; + auto it= find(objDecisions.begin(), objDecisions.end(), m_decisionId); + if (it != objDecisions.end()){ + + + // if ( not intersection.empty() ) { auto feature = d->objectLink<xAOD::TrigCompositeContainer>( "feature" ); if ( not feature.isValid() ) { @@ -68,14 +84,16 @@ namespace HLTTest { float v = (*feature)->getDetail<float>( m_property ); if ( v > m_threshold ) { // actual cut will be more complex of course ATH_MSG_DEBUG( " threshold " << m_threshold << " passed by value: " << v ); - for ( const HLT::Identifier& id: intersection ) - addDecisionID( id, d ); + // for ( const HLT::Identifier& id: intersection ) + // addDecisionID( id, d ); + addDecisionID( m_decisionId, d ); } } else { - ATH_MSG_DEBUG("No Input decisions requested by active chains"); - for ( const HLT::Identifier& id: m_chains ) - ATH_MSG_DEBUG( "Configured to require chain " << id ); + ATH_MSG_DEBUG("No Input decisions requested by active chain "<< m_decisionId); + // ATH_MSG_DEBUG("No Input decisions requested by active chains"); + // for ( const HLT::Identifier& id: m_chains ) + // ATH_MSG_DEBUG( "Configured to require chain " << id ); } counter++; } @@ -89,4 +107,4 @@ namespace HLTTest { return StatusCode::SUCCESS; } -} //> end namespace HLTTest + } //> end namespace HLTTest diff --git a/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoTool.h b/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoTool.h index 68b3c5e673e..449f482984f 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoTool.h +++ b/Trigger/TrigValidation/TrigUpgradeTest/src/TestHypoTool.h @@ -41,8 +41,9 @@ namespace HLTTest { float m_threshold; std::string m_property; - Gaudi::Property<std::vector<std::string> > m_chainsProperty{ this, "Chains", {}, "Chains of whihc this Hypo is concerned" }; - std::set<HLT::Identifier> m_chains; + //Gaudi::Property<std::string > m_chainProperty{ this, "Chain", {}, "Chain of whihc this Hypo is concerned" }; + + }; diff --git a/Trigger/TrigValidation/TrigUpgradeTest/src/TestInputMaker.cxx b/Trigger/TrigValidation/TrigUpgradeTest/src/TestInputMaker.cxx index 738f64cf712..c18660406cc 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/src/TestInputMaker.cxx +++ b/Trigger/TrigValidation/TrigUpgradeTest/src/TestInputMaker.cxx @@ -20,23 +20,23 @@ namespace HLTTest { StatusCode TestInputMaker::initialize() { ATH_MSG_INFO ("Initializing " << name() << "..."); - CHECK( m_inputs.initialize() ); - renounceArray(m_inputs); + CHECK( m_inputDecisionsKey.initialize() ); + renounceArray(m_inputDecisionsKey); ATH_MSG_DEBUG("Will consume implicit input data:" ); - for (auto& input: m_inputs){ - ATH_MSG_DEBUG(" "<<input.key()); + for (auto& input: m_inputDecisionsKey){ + ATH_MSG_DEBUG(" - "<<input.key()); } - CHECK( m_decisionsKey.initialize() ); - // renounceArray(m_decisionsKey); - ATH_MSG_DEBUG(" and produce decisions: "); - for (auto& output: m_decisionsKey){ - ATH_MSG_DEBUG(" "<<output.key()); + CHECK( m_outputDecisionsKey.initialize() ); + + ATH_MSG_DEBUG("and produce decisions: "); + for (auto& output: m_outputDecisionsKey){ + ATH_MSG_DEBUG(" - "<<output.key()); } // specific: - ATH_MSG_DEBUG(" with reco collections: " << m_recoOutput); + ATH_MSG_DEBUG("with reco collections: " << m_recoOutput); CHECK( m_recoOutput.initialize() ); return StatusCode::SUCCESS; } @@ -47,107 +47,142 @@ namespace HLTTest { return StatusCode::SUCCESS; } - StatusCode TestInputMaker::execute() { + + + StatusCode TestInputMaker::execute() { ATH_MSG_DEBUG( "Executing " << name() << "..." ); - - auto outputHandles = m_decisionsKey.makeHandles(); + size_t validInput=0; + { + //print valid input + for ( auto inputKey: m_inputDecisionsKey ) { + auto inputHandle = SG::makeHandle( inputKey ); + ATH_MSG_DEBUG(" "<<inputKey.key()<<(inputHandle.isValid()? " is valid": " is NOT valid" ) ); + if (inputHandle.isValid()) validInput++; + } + ATH_MSG_DEBUG( "number of implicit ReadHandles is " << m_inputDecisionsKey.size() <<", "<< validInput<<" are valid" ); + } + + auto outputHandles = m_outputDecisionsKey.makeHandles(); // output collection, as a view container so it can be given const features auto reco_output = std::make_unique<xAOD::TrigCompositeContainer>(); auto aux = std::make_unique<xAOD::TrigCompositeAuxContainer>(); reco_output->setStore( aux.get() ); - size_t validInput=0; - for ( auto inputKey: m_inputs ) { - auto inputHandle = SG::makeHandle( inputKey ); - ATH_MSG_DEBUG(" "<<inputKey.key()<<(inputHandle.isValid()? "valid": "not valid" ) ); - if (inputHandle.isValid()) validInput++; - } - ATH_MSG_DEBUG( "number of implicit ReadHandles is " << m_inputs.size() <<", "<< validInput<<" are valid" ); - + /// copy reco_collection: + // auto reco_output = std::make_unique< ConstDataVector<TrigRoiDescriptorCollection> >(); + // reco_output->clear( SG::VIEW_ELEMENTS ); //Don't delete the RoIs + // reco_output->push_back( roiDescriptor ); + // Loop over all input containers, which are of course TrigComposites, and request their features std::vector<const FeatureOBJ*> featureFromDecision; size_t count_reco=0; size_t outputIndex = 0; - for ( auto inputKey: m_inputs ) { + for ( auto inputKey: m_inputDecisionsKey ) { auto inputHandle = SG::makeHandle( inputKey ); if( not inputHandle.isValid() ) { - ATH_MSG_DEBUG( "Got no decisions from input "<< inputKey.key()); - outputIndex++; - continue; + ATH_MSG_DEBUG( "Got no decisions from input "<< inputKey.key()); + outputIndex++; + continue; } if( inputHandle->size() == 0){ // input filtered out - ATH_MSG_ERROR( "Got 0 decisions from valid input "<< inputKey.key()<<". Is it expected?"); - return StatusCode::FAILURE; + ATH_MSG_ERROR( "Got 0 decisions from valid input "<< inputKey.key()<<". Is it expected?"); + return StatusCode::FAILURE; } ATH_MSG_DEBUG( "Got input "<< inputKey.key()<<" with " << inputHandle->size() << " elements" ); // crete the output container - auto Outdecisions = std::make_unique<DecisionContainer>(); + auto OutputDecisions = std::make_unique<DecisionContainer>(); auto dec_aux = std::make_unique<DecisionAuxContainer>(); - Outdecisions->setStore( dec_aux.get() ); + OutputDecisions->setStore( dec_aux.get() ); // loop over decisions retrieved from this input - size_t counter =0; + size_t input_counter =0; for ( auto decision : *inputHandle){ - auto roiEL = decision->objectLink<TrigRoiDescriptorCollection>( "initialRoI" ); - CHECK( roiEL.isValid() ); - - // retrieve feature from TrigComposite, will in this case be a TrigRoiDescriptor - auto featurelink = (decision)->objectLink<FeatureContainer>( m_linkName.value() ); - if ( not featurelink.isValid() ) { - ATH_MSG_ERROR( " Can not find reference to " + m_linkName.value() + " from the decision" ); - return StatusCode::FAILURE; - } - - const FeatureOBJ* feature = *featurelink; - ATH_MSG_DEBUG(" Found feature " <<m_linkName.value() ); - - // merge reco outputs that are linked to the same feature (RoI): this avoids processing the same RoI from TC decisions from different chains - bool already_exist=false; - size_t pos=distance(featureFromDecision.begin(), find(featureFromDecision.begin(), featureFromDecision.end(), feature)); - if (pos < featureFromDecision.size()){ - already_exist=true; - } - - if (! already_exist) { - // create the "reco" output - auto tc = new xAOD::TrigComposite; - reco_output->push_back(tc); - // copy all features to a single output collection - // tc->setObjectLink(m_linkName.value(), featurelink); - tc->setObjectLink("initialRoI", roiEL); - ATH_MSG_DEBUG(" Added " <<m_linkName.value() <<" to reco object"); - featureFromDecision.push_back( feature); - count_reco++; - } - // create new decision for each input - TrigCompositeUtils::Decision* newd; - newd = newDecisionIn( Outdecisions.get() ); - //newd->setObjectLink( m_linkName.value(), featurelink); - newd->setObjectLink( "initialRoI", roiEL ); - newd->setObjectLink( "previousDecisions", ElementLink<DecisionContainer>(inputKey.key(), counter) );// link to previous decision object - + // TrigCompositeUtils::Decision* newd; + auto newd = newDecisionIn( OutputDecisions.get() ); + linkToPrevious( newd, inputKey.key(), input_counter ); { //copy decisions ID TrigCompositeUtils::DecisionIDContainer objDecisions; TrigCompositeUtils::decisionIDs( decision, objDecisions ); for ( const HLT::Identifier& id: objDecisions ){ - TrigCompositeUtils::addDecisionID( id, newd ); - } + TrigCompositeUtils::addDecisionID( id, newd ); + } } - counter++; + CHECK( decision->hasObjectLink("initialRoI" ) ); + auto roiEL = decision->objectLink<TrigRoiDescriptorCollection>( "initialRoI" ); + CHECK( roiEL.isValid() ); + newd->setObjectLink( "initialRoI", roiEL ); + //newd->setObjectLink( m_linkName.value(), featurelink); + + input_counter++; // For early tests, create TC, link to RoiD, push back onto TCC. // Later will output RoID collection directly via tool. } // loop over decisions - ATH_MSG_DEBUG( "Recording output key " << m_decisionsKey[ outputIndex ].key() <<" of size "<<Outdecisions->size() <<" at index "<< outputIndex); - CHECK( outputHandles[outputIndex].record( std::move( Outdecisions ), std::move( dec_aux ) ) ); + ATH_MSG_DEBUG( "Recording output key " << m_outputDecisionsKey[ outputIndex ].key() <<" of size "<<OutputDecisions->size() <<" at index "<< outputIndex); + CHECK( outputHandles[outputIndex].record( std::move( OutputDecisions ), std::move( dec_aux ) ) ); outputIndex++; } // loop over input keys - + for ( auto inputKey: m_inputDecisionsKey ) { + auto inputHandle = SG::makeHandle( inputKey ); + if( not inputHandle.isValid() ) { + ATH_MSG_DEBUG( "Got no decisions from input "<< inputKey.key()); + outputIndex++; + continue; + } + if( inputHandle->size() == 0){ // input filtered out + ATH_MSG_ERROR( "Got 0 decisions from valid input "<< inputKey.key()<<". Is it expected?"); + return StatusCode::FAILURE; + } + ATH_MSG_DEBUG( "Got input "<< inputKey.key()<<" with " << inputHandle->size() << " elements" ); + // crete the output container + auto OutputDecisions = std::make_unique<DecisionContainer>(); + auto dec_aux = std::make_unique<DecisionAuxContainer>(); + OutputDecisions->setStore( dec_aux.get() ); + + // loop over decisions retrieved from this input + + for ( auto decision : *inputHandle){ + auto roiEL = decision->objectLink<TrigRoiDescriptorCollection>( "initialRoI" ); + CHECK( roiEL.isValid() ); + + // retrieve feature from TrigComposite, will in this case be a TrigRoiDescriptor + auto featurelink = (decision)->objectLink<FeatureContainer>( m_linkName.value() ); + if ( not featurelink.isValid() ) { + ATH_MSG_ERROR( " Can not find reference to " + m_linkName.value() + " from the decision" ); + return StatusCode::FAILURE; + } + + const FeatureOBJ* feature = *featurelink; + ATH_MSG_DEBUG(" Found feature " <<m_linkName.value() ); + + // merge reco outputs that are linked to the same feature (RoI): this avoids processing the same RoI from TC decisions from different chains + bool already_exist=false; + size_t pos=distance(featureFromDecision.begin(), find(featureFromDecision.begin(), featureFromDecision.end(), feature)); + if (pos < featureFromDecision.size()){ + already_exist=true; + } + + if (! already_exist) { + // create the "reco" output + auto tc = new xAOD::TrigComposite; + reco_output->push_back(tc); + // copy all features to a single output collection + // tc->setObjectLink(m_linkName.value(), featurelink); + tc->setObjectLink("initialRoI", roiEL); + ATH_MSG_DEBUG(" Added " <<m_linkName.value() <<" to reco object"); + featureFromDecision.push_back( feature); + count_reco++; + } + // For early tests, create TC, link to RoiD, push back onto TCC. + // Later will output RoID collection directly via tool. + } // loop over decisions + } // loop over input keys + // Finally, record output ATH_MSG_DEBUG("Produced "<<reco_output->size() <<" reco objects"); auto reco_outputHandle = SG::makeHandle(m_recoOutput); @@ -184,4 +219,5 @@ namespace HLTTest { return StatusCode::SUCCESS; } + } //> end namespace HLTTest diff --git a/Trigger/TrigValidation/TrigUpgradeTest/src/TestInputMaker.h b/Trigger/TrigValidation/TrigUpgradeTest/src/TestInputMaker.h index f80291c694c..a751a91f139 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/src/TestInputMaker.h +++ b/Trigger/TrigValidation/TrigUpgradeTest/src/TestInputMaker.h @@ -47,8 +47,9 @@ namespace HLTTest { SG::WriteHandleKey<xAOD::TrigCompositeContainer> m_recoOutput { this, "Output", "undefined", "name of the output collection for input to next reco alg in sequence" }; - SG::ReadHandleKeyArray <TrigCompositeUtils::DecisionContainer> m_inputs { this, "InputDecisions", {}, "Input Decisions (implicit)" }; - SG::WriteHandleKeyArray<TrigCompositeUtils::DecisionContainer> m_decisionsKey { this, "OutputDecisions", {}, "Ouput Decisions" }; + SG::ReadHandleKeyArray <TrigCompositeUtils::DecisionContainer> m_inputDecisionsKey { this, "InputDecisions", {}, "Input Decisions (implicit)" }; + SG::WriteHandleKeyArray<TrigCompositeUtils::DecisionContainer> m_outputDecisionsKey { this, "OutputDecisions", {}, "Ouput Decisions" }; + //SG::WriteHandleKeyArray< ConstDataVector<TrigCompositeUtils::DecisionContainer> > m_outputDecisionsKey{ this, "OutputDecisions", {}, "Output Decisions" }; StringProperty m_linkName {this, "LinkName", "initialRoI", "name of the link to the features in the decision, e.g. 'feature', 'initialRoI'"}; StringProperty m_outputType {this, "OutputType","outputType", "reserved for future use"}; -- GitLab