diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2CaloHypoAlgMT.cxx b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2CaloHypoAlgMT.cxx index 8cb3f52ce4660ea6e3ac32dad993d537a5a0be28..ec01a504f676b9e5440bea5456f6c0961bf6c481 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2CaloHypoAlgMT.cxx +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2CaloHypoAlgMT.cxx @@ -11,7 +11,7 @@ using namespace TrigCompositeUtils; TrigL2CaloHypoAlgMT::TrigL2CaloHypoAlgMT( const std::string& name, - ISvcLocator* pSvcLocator ) : + ISvcLocator* pSvcLocator ) : ::HypoBase( name, pSvcLocator ) {} TrigL2CaloHypoAlgMT::~TrigL2CaloHypoAlgMT() {} @@ -32,23 +32,6 @@ StatusCode TrigL2CaloHypoAlgMT::finalize() { return StatusCode::SUCCESS; } - /* -OLD - ITC -> get 1 RoI/TC - loop over views - make one TC per view - get RoIs of view - from RoI input - get clusters of view -from View input - map the roi to a decision - from input decisions - create new decision with one cluster, one roi, one view - -NEW - loop over ITC - get RoI and view of TC - get cluster of that view - create new decision with one cluster, one roi, one view - - */ StatusCode TrigL2CaloHypoAlgMT::execute_r( const EventContext& context ) const { ATH_MSG_DEBUG ( "Executing " << name() << "..." ); @@ -72,15 +55,16 @@ StatusCode TrigL2CaloHypoAlgMT::execute_r( const EventContext& context ) const { // loop over previous decisions size_t counter=0; for ( auto previousDecision: *previousDecisionsHandle ) { - //get RoI - auto roiEL = previousDecision->objectLink<TrigRoiDescriptorCollection>( "initialRoI" ); - ATH_CHECK( roiEL.isValid() ); - const TrigRoiDescriptor* roi = *roiEL; + //get RoI + auto roiELInfo = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>( previousDecision, "initialRoI" ); + + ATH_CHECK( roiELInfo.isValid() ); + const TrigRoiDescriptor* roi = *(roiELInfo.link); // get View - auto viewEL = previousDecision->objectLink< ViewContainer >( "view" ); - ATH_CHECK( viewEL.isValid() ); - auto clusterHandle = ViewHelper::makeHandle( *viewEL, m_clustersKey, context); + auto viewELInfo = TrigCompositeUtils::findLink< ViewContainer >( previousDecision, "view" ); + ATH_CHECK( viewELInfo.isValid() ); + auto clusterHandle = ViewHelper::makeHandle( *(viewELInfo.link), m_clustersKey, context); ATH_CHECK( clusterHandle.isValid() ); ATH_MSG_DEBUG ( "Cluster handle size: " << clusterHandle->size() << "..." ); @@ -90,16 +74,16 @@ StatusCode TrigL2CaloHypoAlgMT::execute_r( const EventContext& context ) const { toolInput.emplace_back( d, roi, clusterHandle.cptr()->at(0), previousDecision ); - { - auto el = ViewHelper::makeLink( *viewEL, clusterHandle, 0 ); + { + auto el = ViewHelper::makeLink( *(viewELInfo.link), clusterHandle, 0 ); ATH_CHECK( el.isValid() ); d->setObjectLink( "feature", el ); } - d->setObjectLink( "roi", roiEL ); - d->setObjectLink( "view", viewEL ); - TrigCompositeUtils::linkToPrevious( d, decisionInput().key(), counter ); - ATH_MSG_DEBUG( "Added view, roi, cluster, previous decision to new decision " << counter << " for view " << (*viewEL)->name() ); - counter++; + d->setObjectLink( "roi", roiELInfo.link ); + + TrigCompositeUtils::linkToPrevious( d, decisionInput().key(), counter ); + ATH_MSG_DEBUG( "Added view, roi, cluster, previous decision to new decision " << counter << " for view " << (*viewELInfo.link)->name() ); + counter++; } diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2ElectronHypoAlgMT.cxx b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2ElectronHypoAlgMT.cxx index 469cf31e596ec83ebbcd986a0cc6e7393b88605e..f7fdc12e90b75f79bb8a00fd087e3a2371d68a15 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2ElectronHypoAlgMT.cxx +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2ElectronHypoAlgMT.cxx @@ -74,18 +74,18 @@ StatusCode TrigL2ElectronHypoAlgMT::execute_r( const EventContext& context ) con for ( auto previousDecision: *previousDecisionsHandle ) { // get View - auto viewEL = previousDecision->objectLink< ViewContainer >( "view" ); - CHECK( viewEL.isValid() ); + auto viewELInfo = TrigCompositeUtils::findLink< ViewContainer >( previousDecision, "view" ); + CHECK( viewELInfo.isValid() ); // get electron from that view: size_t electronCounter = 0; - auto electronsHandle = ViewHelper::makeHandle( *viewEL, m_electronsKey, context ); + auto electronsHandle = ViewHelper::makeHandle( *viewELInfo.link, m_electronsKey, context ); ATH_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", ViewHelper::makeLink<xAOD::TrigElectronContainer>( *viewEL, electronsHandle, electronCounter ) ); + d->setObjectLink( "feature", ViewHelper::makeLink<xAOD::TrigElectronContainer>( *viewELInfo.link, electronsHandle, electronCounter ) ); auto clusterPtr = (*electronIter)->emCluster(); CHECK( clusterPtr != nullptr ); diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2PhotonHypoAlgMT.cxx b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2PhotonHypoAlgMT.cxx index 31ca7e9b2e4356956224e93108730a68f2a0c9ac..fe26291cb077c79a1a6a5a4b23fd13446f50d53c 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2PhotonHypoAlgMT.cxx +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2PhotonHypoAlgMT.cxx @@ -53,16 +53,16 @@ StatusCode TrigL2PhotonHypoAlgMT::execute_r( const EventContext& context ) const std::map<const xAOD::TrigEMCluster*, size_t> clusterToIndexMap; size_t clusterCounter = 0; for ( auto previousDecision : *previousDecisionsHandle){ - ElementLink<xAOD::TrigEMClusterContainer> clusterLink; - recursivelyFindFeature(previousDecision, clusterLink); - if( not clusterLink.isValid() ) { + auto clusterELInfo = TrigCompositeUtils::findLink<xAOD::TrigEMClusterContainer>( previousDecision, "feature" ); + + if( not clusterELInfo.isValid() ) { ATH_MSG_ERROR("Can not obtain the link to Cluster"); ATH_MSG_ERROR( TrigCompositeUtils::dump( previousDecision, [](const xAOD::TrigComposite* tc){ return tc->name() + " " + (tc->object<xAOD::TrigEMCluster>("feature") == 0 ? "has no cluster": "has cluster"); }) ); return StatusCode::FAILURE; } - const xAOD::TrigEMCluster* cluster = *clusterLink; + const xAOD::TrigEMCluster* cluster = *(clusterELInfo.link); clusterToIndexMap.insert( std::make_pair( cluster, clusterCounter ) ); clusterCounter++; } @@ -76,20 +76,21 @@ StatusCode TrigL2PhotonHypoAlgMT::execute_r( const EventContext& context ) const std::vector<TrigL2PhotonHypoTool::PhotonInfo> hypoToolInput; for ( auto previousDecision: *previousDecisionsHandle ) { - - auto viewEL = previousDecision->objectLink< ViewContainer >( "view" ); - ATH_CHECK( viewEL.isValid() ); + //previousDecision->objectLink< ViewContainer >( "view" ); + auto viewELInfo = TrigCompositeUtils::findLink< ViewContainer >( previousDecision, "view" ); + + ATH_CHECK( viewELInfo.isValid() ); // get electron from that view: size_t photonCounter = 0; - auto photonsHandle = ViewHelper::makeHandle( *viewEL, m_photonsKey, context ); + auto photonsHandle = ViewHelper::makeHandle( *viewELInfo.link, m_photonsKey, context ); ATH_CHECK( photonsHandle.isValid() ); ATH_MSG_DEBUG ( "electron handle size: " << photonsHandle->size() << "..." ); for ( auto photonIter = photonsHandle->begin(); photonIter != photonsHandle->end(); ++photonIter, photonCounter++ ) { auto d = newDecisionIn( decisions.get(), name() ); - d->setObjectLink( "feature", ViewHelper::makeLink<xAOD::TrigPhotonContainer>( *viewEL, photonsHandle, photonCounter ) ); + d->setObjectLink( "feature", ViewHelper::makeLink<xAOD::TrigPhotonContainer>( *viewELInfo.link, photonsHandle, photonCounter ) ); auto clusterPtr = (*photonIter)->emCluster(); ATH_CHECK( clusterPtr != nullptr ); @@ -136,16 +137,3 @@ StatusCode TrigL2PhotonHypoAlgMT::execute_r( const EventContext& context ) const } -bool TrigL2PhotonHypoAlgMT::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/TrigL2PhotonHypoAlgMT.h b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2PhotonHypoAlgMT.h index d220cd719031e7158871be17402f6eb6912beee2..b0c40fb1f76aabba75e568862942daa5b883a596 100644 --- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2PhotonHypoAlgMT.h +++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigL2PhotonHypoAlgMT.h @@ -44,11 +44,7 @@ class TrigL2PhotonHypoAlgMT : public ::HypoBase Gaudi::Property< bool > m_runInView { this, "RunInView", false , "Set input DH for running in views" }; // internally used to getch from views SG::ReadHandleKey< xAOD::TrigPhotonContainer > m_photonsKey {this, "Photons", "L2PhotonContainer", "Input"}; - - - bool recursivelyFindFeature( const TrigCompositeUtils::Decision* d, ElementLink<xAOD::TrigEMClusterContainer>& clusterlink) const; - }; #endif //> !TRIGEGAMMAHYPO_TRIGL2PHOTONHYPOALGMT_H