Skip to content
Snippets Groups Projects
Commit d8bf5ce6 authored by Simon George's avatar Simon George Committed by Adam Edward Barton
Browse files

Add functionality for decision creation to TrigCompositeUtils and migrate all clients

parent af957697
No related merge requests found
Showing
with 310 additions and 145 deletions
...@@ -476,3 +476,14 @@ namespace xAOD { ...@@ -476,3 +476,14 @@ namespace xAOD {
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
} // namespace xAOD } // namespace xAOD
std::ostream& operator<<(std::ostream& os, const xAOD::TrigComposite_v1& tc) {
os << "TrigComposite_v1 '" << tc.name() << "' link: name, key, index, CLID" << std::endl;
for (size_t i=0; i<tc.linkColNames().size(); ++i){
os << tc.linkColNames()[i] << ", ";
os << tc.linkColKeys()[i] << ", ";
os << tc.linkColIndices()[i] << ", ";
os << tc.linkColClids()[i] << std::endl;
}
return os;
}
...@@ -61,14 +61,21 @@ int populateObject(xAOD::TrigComposite* obj) { ...@@ -61,14 +61,21 @@ int populateObject(xAOD::TrigComposite* obj) {
std::cout << "Set detail ok." << std::endl; std::cout << "Set detail ok." << std::endl;
// create a MuonRoIContainer in order to have "valid" ElementLinks
// they will have made up SG key hashes but they are internally "valid"
auto mrc = new xAOD::MuonRoIContainer();
for (unsigned int i = 0; i<20; i++){
xAOD::MuonRoI* roi = new xAOD::MuonRoI();
mrc->push_back( roi );
}
// Now test the ElementLink functionality in a basic way: // Now test the ElementLink functionality in a basic way:
obj->setObjectLink( "MuonRoI", obj->setObjectLink( "MuonRoI",
ElementLink<xAOD::MuonRoIContainer>( 123, 456 ) ); ElementLink<xAOD::MuonRoIContainer>( 123, 11, mrc->at(11)) );
// Test the ElementLinkVector functionality in a basic way: // Test the ElementLinkVector functionality in a basic way:
ElementLinkVector<xAOD::MuonRoIContainer> elementLinks; ElementLinkVector<xAOD::MuonRoIContainer> elementLinks;
elementLinks.push_back( ElementLink<xAOD::MuonRoIContainer>( 789, 012 ) ); elementLinks.push_back( ElementLink<xAOD::MuonRoIContainer>( 789, 13, mrc->at(13) ) );
elementLinks.push_back( ElementLink<xAOD::MuonRoIContainer>( 345, 678 ) ); elementLinks.push_back( ElementLink<xAOD::MuonRoIContainer>( 345, 17, mrc->at(17) ) );
obj->addObjectCollectionLinks("ManyMuonRoIs", elementLinks); obj->addObjectCollectionLinks("ManyMuonRoIs", elementLinks);
return 0; return 0;
...@@ -179,19 +186,19 @@ int testLinks(const xAOD::TrigComposite* obj, const size_t expectedSize = 3) { ...@@ -179,19 +186,19 @@ int testLinks(const xAOD::TrigComposite* obj, const size_t expectedSize = 3) {
SIMPLE_ASSERT( obj->linkColIndices().size() == expectedSize ); SIMPLE_ASSERT( obj->linkColIndices().size() == expectedSize );
SIMPLE_ASSERT( obj->linkColClids().size() == expectedSize ); SIMPLE_ASSERT( obj->linkColClids().size() == expectedSize );
SIMPLE_ASSERT( obj->linkColKeys()[ 0 ] == 123 ); SIMPLE_ASSERT( obj->linkColKeys()[ 0 ] == 123 );
SIMPLE_ASSERT( obj->linkColIndices()[ 0 ] == 456 ); SIMPLE_ASSERT( obj->linkColIndices()[ 0 ] == 11 );
SIMPLE_ASSERT( obj->linkColClids()[ 0 ] == SIMPLE_ASSERT( obj->linkColClids()[ 0 ] ==
ClassID_traits< xAOD::MuonRoIContainer >::ID() ); ClassID_traits< xAOD::MuonRoIContainer >::ID() );
std::cout << "Basic link functionality OK" << std::endl; std::cout << "Basic link functionality OK" << std::endl;
ElementLink< xAOD::MuonRoIContainer > getMuonRoILink = obj->objectLink<xAOD::MuonRoIContainer>("MuonRoI"); ElementLink< xAOD::MuonRoIContainer > getMuonRoILink = obj->objectLink<xAOD::MuonRoIContainer>("MuonRoI");
SIMPLE_ASSERT(getMuonRoILink == ElementLink<xAOD::MuonRoIContainer>( 123, 456 )); SIMPLE_ASSERT(getMuonRoILink == ElementLink<xAOD::MuonRoIContainer>( 123, 11 ));
ElementLinkVector<xAOD::MuonRoIContainer> getMuonRoILinks = obj->objectCollectionLinks<xAOD::MuonRoIContainer>("ManyMuonRoIs"); ElementLinkVector<xAOD::MuonRoIContainer> getMuonRoILinks = obj->objectCollectionLinks<xAOD::MuonRoIContainer>("ManyMuonRoIs");
ElementLinkVector<xAOD::MuonRoIContainer> elementLinks; ElementLinkVector<xAOD::MuonRoIContainer> elementLinks;
elementLinks.push_back( ElementLink<xAOD::MuonRoIContainer>( 789, 012 ) ); elementLinks.push_back( ElementLink<xAOD::MuonRoIContainer>( 789, 13 ) );
elementLinks.push_back( ElementLink<xAOD::MuonRoIContainer>( 345, 678 ) ); elementLinks.push_back( ElementLink<xAOD::MuonRoIContainer>( 345, 17 ) );
SIMPLE_ASSERT(getMuonRoILinks == elementLinks); SIMPLE_ASSERT(getMuonRoILinks == elementLinks);
std::cout << "Link recovery OK" << std::endl; std::cout << "Link recovery OK" << std::endl;
...@@ -254,7 +261,12 @@ int main() { ...@@ -254,7 +261,12 @@ int main() {
// Copy over all other links // Copy over all other links
SIMPLE_ASSERT( fullCopy->copyAllLinksFrom( obj ) == true ); SIMPLE_ASSERT( fullCopy->copyAllLinksFrom( obj ) == true );
// Add another too // Add another too
fullCopy->setObjectLink( "feature", ElementLink<xAOD::MuonRoIContainer>( 111, 222 ) ); auto mrc = new xAOD::MuonRoIContainer();
for (unsigned int i = 0; i<20; i++){
xAOD::MuonRoI* roi = new xAOD::MuonRoI();
mrc->push_back( roi );
}
fullCopy->setObjectLink( "feature", ElementLink<xAOD::MuonRoIContainer>( 111, 19, mrc->at(0) ) );
SIMPLE_ASSERT( testLinks(fullCopy, 4) == 0 ); SIMPLE_ASSERT( testLinks(fullCopy, 4) == 0 );
std::cout << "Full-copy of element links OK" << std::endl; std::cout << "Full-copy of element links OK" << std::endl;
...@@ -285,7 +297,7 @@ int main() { ...@@ -285,7 +297,7 @@ int main() {
// Check we can still access the element link unique to fullCopy // Check we can still access the element link unique to fullCopy
ElementLink<xAOD::MuonRoIContainer> getFeatureLink = fullCopy->objectLink<xAOD::MuonRoIContainer>("feature"); ElementLink<xAOD::MuonRoIContainer> getFeatureLink = fullCopy->objectLink<xAOD::MuonRoIContainer>("feature");
SIMPLE_ASSERT(getFeatureLink == ElementLink<xAOD::MuonRoIContainer>( 111, 222 )); SIMPLE_ASSERT(getFeatureLink == ElementLink<xAOD::MuonRoIContainer>( 111, 19, mrc->at(0) ));
// Make new objects to test the manual link copy // Make new objects to test the manual link copy
xAOD::TrigComposite* manualCopy = new xAOD::TrigComposite(); xAOD::TrigComposite* manualCopy = new xAOD::TrigComposite();
...@@ -298,7 +310,7 @@ int main() { ...@@ -298,7 +310,7 @@ int main() {
SIMPLE_ASSERT( testLinks(manualCopy, 4) == 0 ); SIMPLE_ASSERT( testLinks(manualCopy, 4) == 0 );
ElementLink<xAOD::MuonRoIContainer> getFeatureLinkAgain = manualCopy->objectLink<xAOD::MuonRoIContainer>("featureWithNewName"); ElementLink<xAOD::MuonRoIContainer> getFeatureLinkAgain = manualCopy->objectLink<xAOD::MuonRoIContainer>("featureWithNewName");
SIMPLE_ASSERT(getFeatureLinkAgain == ElementLink<xAOD::MuonRoIContainer>( 111, 222 )); SIMPLE_ASSERT(getFeatureLinkAgain == ElementLink<xAOD::MuonRoIContainer>( 111, 19, mrc->at(0) ));
std::cout << "Copy link-by-link OK" << std::endl; std::cout << "Copy link-by-link OK" << std::endl;
......
...@@ -233,4 +233,10 @@ namespace xAOD { ...@@ -233,4 +233,10 @@ namespace xAOD {
// Include the template implementation: // Include the template implementation:
#include "TrigComposite_v1.icc" #include "TrigComposite_v1.icc"
/**
* @brief print helper for TrigComposite
*/
std::ostream& operator<<(std::ostream& os, const xAOD::TrigComposite_v1& tc);
#endif // XAODTRIGGER_VERSIONS_TRIGCOMPOSITE_V1_H #endif // XAODTRIGGER_VERSIONS_TRIGCOMPOSITE_V1_H
...@@ -50,41 +50,56 @@ namespace xAOD { ...@@ -50,41 +50,56 @@ namespace xAOD {
bool result = getDetail(name, temp); bool result = getDetail(name, temp);
return std::make_pair(result, temp); return std::make_pair(result, temp);
} }
template< class CONTAINER > template< class CONTAINER >
bool bool
TrigComposite_v1::setObjectLink( const std::string& name, TrigComposite_v1::setObjectLink( const std::string& name,
const ElementLink< CONTAINER >& link ) { const ElementLink< CONTAINER >& link ) {
// Do different things depending on whether this variable already // Check link has valid persistent state, i.e. hash key is not
// exists or not: // zero, otherwise attempting to access its string key will seg
if( hasObjectLink( name ) ) { // fault later, e.g. in remapping.
// Find the right object: if( link.key() == 0 ) {
const std::vector< std::string >& names = linkColNames(); std::cerr << "xAOD::TrigComposite_v1::setObjectLink ERROR "
for( size_t i = 0; i < names.size(); ++i ) { << "link has invalid key hash of zero" << std::endl;
if( names[ i ] != name ) continue; return false;
// Extract the information out of the ElementLink: }
linkColKeysNC()[ i ] = link.key();
linkColIndicesNC()[ i ] = link.index(); if( ! link.isValid() ) {
linkColClidsNC()[ i ] = ClassID_traits< CONTAINER >::ID(); std::cerr << "xAOD::TrigComposite_v1::setObjectLink ERROR "
// We're done: << "link is not valid" << std::endl;
return true; return false;
} }
// Some error happened...
std::cerr << "xAOD::TrigComposite_v1::setObjectLink ERROR Internal " // Do different things depending on whether this variable already
<< "logic error found" << std::endl; // exists or not:
return false; if( hasObjectLink( name ) ) {
} else { // Find the right object:
// Add a new object: const std::vector< std::string >& names = linkColNames();
linkColNamesNC().push_back( name ); for( size_t i = 0; i < names.size(); ++i ) {
linkColKeysNC().push_back( link.key() ); if( names[ i ] != name ) continue;
linkColIndicesNC().push_back( link.index() ); // Extract the information out of the ElementLink:
linkColClidsNC().push_back( ClassID_traits< CONTAINER >::ID() ); linkColKeysNC()[ i ] = link.key();
// And we're done: linkColIndicesNC()[ i ] = link.index();
return true; linkColClidsNC()[ i ] = ClassID_traits< CONTAINER >::ID();
// We're done:
return true;
} }
} // Some error happened...
std::cerr << "xAOD::TrigComposite_v1::setObjectLink ERROR Internal "
<< "logic error found" << std::endl;
return false;
} else {
// Add a new object:
linkColNamesNC().push_back( name );
linkColKeysNC().push_back( link.key() );
linkColIndicesNC().push_back( link.index() );
linkColClidsNC().push_back( ClassID_traits< CONTAINER >::ID() );
// And we're done:
return true;
}
}
template< class CONTAINER > template< class CONTAINER >
ElementLink< CONTAINER > ElementLink< CONTAINER >
TrigComposite_v1::objectLink( const std::string& name ) const { TrigComposite_v1::objectLink( const std::string& name ) const {
......
...@@ -97,9 +97,8 @@ StatusCode TrigBjetEtHypoAlgMT::execute_r( const EventContext& context ) const { ...@@ -97,9 +97,8 @@ StatusCode TrigBjetEtHypoAlgMT::execute_r( const EventContext& context ) const {
// ========================================================================================================================== // ==========================================================================================================================
// Decisions // Decisions
std::unique_ptr< TrigCompositeUtils::DecisionContainer > outputDecision( new TrigCompositeUtils::DecisionContainer() ); SG::WriteHandle<TrigCompositeUtils::DecisionContainer> handle = TrigCompositeUtils::createAndStore( decisionOutput(), context );
std::unique_ptr< TrigCompositeUtils::DecisionAuxContainer > outputAuxDecision( new TrigCompositeUtils::DecisionAuxContainer() ); auto outputDecisions = handle.ptr();
outputDecision->setStore( outputAuxDecision.get() );
// ========================================================================================================================== // ==========================================================================================================================
// ** Compute Decisions // ** Compute Decisions
...@@ -116,7 +115,7 @@ StatusCode TrigBjetEtHypoAlgMT::execute_r( const EventContext& context ) const { ...@@ -116,7 +115,7 @@ StatusCode TrigBjetEtHypoAlgMT::execute_r( const EventContext& context ) const {
for ( unsigned int index(0); index<nDecisions; index++ ) { for ( unsigned int index(0); index<nDecisions; index++ ) {
// const std::string decisionName = name()+"_roi_"+std::to_string(index); // const std::string decisionName = name()+"_roi_"+std::to_string(index);
// ATH_MSG_DEBUG( " ** " << decisionName ); // ATH_MSG_DEBUG( " ** " << decisionName );
newDecisions.push_back( TrigCompositeUtils::newDecisionIn( outputDecision.get() ) );//,decisionName ) ); newDecisions.push_back( TrigCompositeUtils::newDecisionIn( outputDecisions ) );//,decisionName ) );
} }
bool pass = false; bool pass = false;
...@@ -140,18 +139,16 @@ StatusCode TrigBjetEtHypoAlgMT::execute_r( const EventContext& context ) const { ...@@ -140,18 +139,16 @@ StatusCode TrigBjetEtHypoAlgMT::execute_r( const EventContext& context ) const {
ATH_MSG_DEBUG( "Linking Jets `" << m_jetLink.value() << "` to output decision." ); ATH_MSG_DEBUG( "Linking Jets `" << m_jetLink.value() << "` to output decision." );
} }
for( unsigned int index(0); index<nDecisions; index++ ) for( unsigned int index(0); index<nDecisions; index++ ){
TrigCompositeUtils::linkToPrevious( newDecisions.at(index),decisionInput().key(),counter ); TrigCompositeUtils::linkToPrevious( newDecisions.at(index),decisionInput().key(),0 );
}
counter++; counter++;
} }
// ========================================================================================================================== // ==========================================================================================================================
// ** Store Output // ** Store Output
// ========================================================================================================================== // ==========================================================================================================================
// Save Output Decisions
SG::WriteHandle< TrigCompositeUtils::DecisionContainer > handle = SG::makeHandle( decisionOutput(), context );
CHECK( handle.record( std::move(outputDecision),std::move(outputAuxDecision) ) );
ATH_MSG_DEBUG( "Exiting with " << handle->size() << " decisions" ); ATH_MSG_DEBUG( "Exiting with " << handle->size() << " decisions" );
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
......
...@@ -45,9 +45,10 @@ StatusCode TrigL2CaloHypoAlgMT::execute_r( const EventContext& context ) const { ...@@ -45,9 +45,10 @@ StatusCode TrigL2CaloHypoAlgMT::execute_r( const EventContext& context ) const {
// new decisions // new decisions
auto decisions = std::make_unique<DecisionContainer>();
auto aux = std::make_unique<DecisionAuxContainer>(); // new output decisions
decisions->setStore( aux.get() ); SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context );
auto decisions = outputHandle.ptr();
// input for decision // input for decision
std::vector<ITrigL2CaloHypoTool::ClusterInfo> toolInput; std::vector<ITrigL2CaloHypoTool::ClusterInfo> toolInput;
...@@ -69,7 +70,7 @@ StatusCode TrigL2CaloHypoAlgMT::execute_r( const EventContext& context ) const { ...@@ -69,7 +70,7 @@ StatusCode TrigL2CaloHypoAlgMT::execute_r( const EventContext& context ) const {
ATH_MSG_DEBUG ( "Cluster handle size: " << clusterHandle->size() << "..." ); ATH_MSG_DEBUG ( "Cluster handle size: " << clusterHandle->size() << "..." );
// create new decision // create new decision
auto d = newDecisionIn( decisions.get(), name() ); auto d = newDecisionIn( decisions, name() );
toolInput.emplace_back( d, roi, clusterHandle.cptr()->at(0), previousDecision ); toolInput.emplace_back( d, roi, clusterHandle.cptr()->at(0), previousDecision );
...@@ -95,8 +96,7 @@ StatusCode TrigL2CaloHypoAlgMT::execute_r( const EventContext& context ) const { ...@@ -95,8 +96,7 @@ StatusCode TrigL2CaloHypoAlgMT::execute_r( const EventContext& context ) const {
} }
{// make output handle and debug {// make output handle and debug
auto outputHandle = SG::makeHandle(decisionOutput(), context);
ATH_CHECK( outputHandle.record( std::move( decisions ), std::move( aux ) ) );
ATH_MSG_DEBUG ( "Exit with "<<outputHandle->size() <<" decisions"); ATH_MSG_DEBUG ( "Exit with "<<outputHandle->size() <<" decisions");
TrigCompositeUtils::DecisionIDContainer allPassingIDs; TrigCompositeUtils::DecisionIDContainer allPassingIDs;
if ( outputHandle.isValid() ) { if ( outputHandle.isValid() ) {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "AthViews/ViewHelper.h" #include "AthViews/ViewHelper.h"
using TrigCompositeUtils::createAndStore;
using TrigCompositeUtils::DecisionContainer; using TrigCompositeUtils::DecisionContainer;
using TrigCompositeUtils::DecisionAuxContainer; using TrigCompositeUtils::DecisionAuxContainer;
using TrigCompositeUtils::DecisionIDContainer; using TrigCompositeUtils::DecisionIDContainer;
...@@ -47,10 +48,9 @@ StatusCode TrigL2ElectronHypoAlgMT::execute_r( const EventContext& context ) con ...@@ -47,10 +48,9 @@ StatusCode TrigL2ElectronHypoAlgMT::execute_r( const EventContext& context ) con
ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions"); ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions");
// new output // new output decisions
auto decisions = std::make_unique<DecisionContainer>(); SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context );
auto aux = std::make_unique<DecisionAuxContainer>(); auto decisions = outputHandle.ptr();
decisions->setStore( aux.get() );
// // extract mapping of cluster pointer to an index in the cluster decision collection // // extract mapping of cluster pointer to an index in the cluster decision collection
...@@ -84,7 +84,7 @@ StatusCode TrigL2ElectronHypoAlgMT::execute_r( const EventContext& context ) con ...@@ -84,7 +84,7 @@ StatusCode TrigL2ElectronHypoAlgMT::execute_r( const EventContext& context ) con
ATH_MSG_DEBUG ( "electron handle size: " << electronsHandle->size() << "..." ); ATH_MSG_DEBUG ( "electron handle size: " << electronsHandle->size() << "..." );
for ( auto electronIter = electronsHandle->begin(); electronIter != electronsHandle->end(); ++electronIter, electronCounter++ ) { for ( auto electronIter = electronsHandle->begin(); electronIter != electronsHandle->end(); ++electronIter, electronCounter++ ) {
auto d = newDecisionIn( decisions.get() ); auto d = newDecisionIn( decisions );
d->setObjectLink( "feature", ViewHelper::makeLink<xAOD::TrigElectronContainer>( *viewELInfo.link, electronsHandle, electronCounter ) ); d->setObjectLink( "feature", ViewHelper::makeLink<xAOD::TrigElectronContainer>( *viewELInfo.link, electronsHandle, electronCounter ) );
auto clusterPtr = (*electronIter)->emCluster(); auto clusterPtr = (*electronIter)->emCluster();
...@@ -111,9 +111,6 @@ StatusCode TrigL2ElectronHypoAlgMT::execute_r( const EventContext& context ) con ...@@ -111,9 +111,6 @@ StatusCode TrigL2ElectronHypoAlgMT::execute_r( const EventContext& context ) con
ATH_CHECK( tool->decide( hypoToolInput ) ); ATH_CHECK( tool->decide( hypoToolInput ) );
} }
auto outputHandle = SG::makeHandle(decisionOutput(), context);
CHECK( outputHandle.record(std::move(decisions), std::move(aux) ) );
ATH_MSG_DEBUG( "Exiting with "<< outputHandle->size() <<" decisions"); ATH_MSG_DEBUG( "Exiting with "<< outputHandle->size() <<" decisions");
//debug //debug
for (auto outh: *outputHandle){ for (auto outh: *outputHandle){
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "AthViews/ViewHelper.h" #include "AthViews/ViewHelper.h"
using TrigCompositeUtils::createAndStore;
using TrigCompositeUtils::DecisionContainer; using TrigCompositeUtils::DecisionContainer;
using TrigCompositeUtils::DecisionAuxContainer; using TrigCompositeUtils::DecisionAuxContainer;
using TrigCompositeUtils::DecisionIDContainer; using TrigCompositeUtils::DecisionIDContainer;
...@@ -68,10 +68,9 @@ StatusCode TrigL2PhotonHypoAlgMT::execute_r( const EventContext& context ) const ...@@ -68,10 +68,9 @@ StatusCode TrigL2PhotonHypoAlgMT::execute_r( const EventContext& context ) const
} }
ATH_MSG_DEBUG( "Cluster ptr to decision map has size " << clusterToIndexMap.size() ); ATH_MSG_DEBUG( "Cluster ptr to decision map has size " << clusterToIndexMap.size() );
auto decisions = std::make_unique<DecisionContainer>(); // new output decisions
auto aux = std::make_unique<DecisionAuxContainer>(); SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context );
decisions->setStore( aux.get() ); auto decisions = outputHandle.ptr();
std::vector<TrigL2PhotonHypoTool::PhotonInfo> hypoToolInput; std::vector<TrigL2PhotonHypoTool::PhotonInfo> hypoToolInput;
...@@ -89,7 +88,7 @@ StatusCode TrigL2PhotonHypoAlgMT::execute_r( const EventContext& context ) const ...@@ -89,7 +88,7 @@ StatusCode TrigL2PhotonHypoAlgMT::execute_r( const EventContext& context ) const
ATH_MSG_DEBUG ( "electron handle size: " << photonsHandle->size() << "..." ); ATH_MSG_DEBUG ( "electron handle size: " << photonsHandle->size() << "..." );
for ( auto photonIter = photonsHandle->begin(); photonIter != photonsHandle->end(); ++photonIter, photonCounter++ ) { for ( auto photonIter = photonsHandle->begin(); photonIter != photonsHandle->end(); ++photonIter, photonCounter++ ) {
auto d = newDecisionIn( decisions.get(), name() ); auto d = newDecisionIn( decisions, name() );
d->setObjectLink( "feature", ViewHelper::makeLink<xAOD::TrigPhotonContainer>( *viewELInfo.link, photonsHandle, photonCounter ) ); d->setObjectLink( "feature", ViewHelper::makeLink<xAOD::TrigPhotonContainer>( *viewELInfo.link, photonsHandle, photonCounter ) );
auto clusterPtr = (*photonIter)->emCluster(); auto clusterPtr = (*photonIter)->emCluster();
...@@ -116,8 +115,6 @@ StatusCode TrigL2PhotonHypoAlgMT::execute_r( const EventContext& context ) const ...@@ -116,8 +115,6 @@ StatusCode TrigL2PhotonHypoAlgMT::execute_r( const EventContext& context ) const
ATH_CHECK( tool->decide( hypoToolInput ) ); ATH_CHECK( tool->decide( hypoToolInput ) );
} }
auto outputHandle = SG::makeHandle(decisionOutput(), context);
ATH_CHECK( outputHandle.record(std::move(decisions), std::move(aux) ) );
ATH_MSG_DEBUG( "Exiting with "<< outputHandle->size() <<" decisions"); ATH_MSG_DEBUG( "Exiting with "<< outputHandle->size() <<" decisions");
//debug //debug
......
...@@ -53,11 +53,9 @@ StatusCode TrigJetHypoAlgMT::execute_r( const EventContext& context ) const { ...@@ -53,11 +53,9 @@ StatusCode TrigJetHypoAlgMT::execute_r( const EventContext& context ) const {
auto prevDecisions = h_prevDecisions.get(); auto prevDecisions = h_prevDecisions.get();
// Make a new Decisions container which will contain the previous // new output decisions
// decisions, and the one for this hypo. SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context );
auto newDecisions = std::make_unique<DecisionContainer>(); auto newDecisions = outputHandle.ptr();
auto aux = std::make_unique<DecisionAuxContainer>();
newDecisions->setStore(aux.get());
// read in a jets collection, and obtain a bare pointer to it // read in a jets collection, and obtain a bare pointer to it
auto h_jets = SG::makeHandle(m_jetsKey, context ); auto h_jets = SG::makeHandle(m_jetsKey, context );
...@@ -77,8 +75,6 @@ StatusCode TrigJetHypoAlgMT::execute_r( const EventContext& context ) const { ...@@ -77,8 +75,6 @@ StatusCode TrigJetHypoAlgMT::execute_r( const EventContext& context ) const {
// output the decisions for all chains for this event. // output the decisions for all chains for this event.
auto outputHandle = SG::makeHandle(decisionOutput(), context);
CHECK( outputHandle.record( std::move( newDecisions ), std::move( aux ) ) );
ATH_MSG_DEBUG ( "Exit with "<<outputHandle->size() <<" decisions"); ATH_MSG_DEBUG ( "Exit with "<<outputHandle->size() <<" decisions");
...@@ -100,12 +96,12 @@ StatusCode TrigJetHypoAlgMT::execute_r( const EventContext& context ) const { ...@@ -100,12 +96,12 @@ StatusCode TrigJetHypoAlgMT::execute_r( const EventContext& context ) const {
StatusCode StatusCode
TrigJetHypoAlgMT::decide(const xAOD::JetContainer* jets, TrigJetHypoAlgMT::decide(const xAOD::JetContainer* jets,
std::unique_ptr<DecisionContainer>& nDecisions, DecisionContainer* nDecisions,
const DecisionContainer* oDecisions) const{ const DecisionContainer* oDecisions) const{
auto previousDecision = (*oDecisions)[0]; auto previousDecision = (*oDecisions)[0];
auto newdecision = TrigCompositeUtils::newDecisionIn(nDecisions.get()); auto newdecision = TrigCompositeUtils::newDecisionIn(nDecisions);
const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs{ const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs{
...@@ -151,7 +147,7 @@ TrigJetHypoAlgMT::decide(const xAOD::JetContainer* jets, ...@@ -151,7 +147,7 @@ TrigJetHypoAlgMT::decide(const xAOD::JetContainer* jets,
// if (pass) { // if (pass) {
// // create a new Decision object. This object has been placed in the // // create a new Decision object. This object has been placed in the
// // nDecisions container. // // nDecisions container.
// auto decision = TrigCompositeUtils::newDecisionIn(nDecisions.get()); // auto decision = TrigCompositeUtils::newDecisionIn(nDecisions);
// TrigCompositeUtils::addDecisionID(decisionId, decision); // TrigCompositeUtils::addDecisionID(decisionId, decision);
// } // }
// // what if does not pass? // // what if does not pass?
......
...@@ -32,7 +32,7 @@ class TrigJetHypoAlgMT : public ::HypoBase { ...@@ -32,7 +32,7 @@ class TrigJetHypoAlgMT : public ::HypoBase {
private: private:
StatusCode decide(const xAOD::JetContainer*, StatusCode decide(const xAOD::JetContainer*,
std::unique_ptr<TrigCompositeUtils::DecisionContainer>& newDecisions, TrigCompositeUtils::DecisionContainer* newDecisions,
const TrigCompositeUtils::DecisionContainer* previousDecisions const TrigCompositeUtils::DecisionContainer* previousDecisions
/* , */ /* , */
/* const ToolHandle<ITrigJetHypoToolMT>&xs */ /* const ToolHandle<ITrigJetHypoToolMT>&xs */
......
...@@ -65,9 +65,9 @@ StatusCode TrigMufastHypoAlg::execute_r( const EventContext& context ) const ...@@ -65,9 +65,9 @@ StatusCode TrigMufastHypoAlg::execute_r( const EventContext& context ) const
} }
ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions"); ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions");
auto decisions = std::make_unique<DecisionContainer>(); // new output decisions
auto aux = std::make_unique<DecisionAuxContainer>(); SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context );
decisions->setStore(aux.get()); auto decisions = outputHandle.ptr();
// end of common // end of common
...@@ -94,7 +94,7 @@ StatusCode TrigMufastHypoAlg::execute_r( const EventContext& context ) const ...@@ -94,7 +94,7 @@ StatusCode TrigMufastHypoAlg::execute_r( const EventContext& context ) const
const xAOD::L2StandAloneMuon* muon = *muonEL; const xAOD::L2StandAloneMuon* muon = *muonEL;
// create new decision // create new decision
auto newd = newDecisionIn( decisions.get() ); auto newd = newDecisionIn( decisions );
// push_back to toolInput // push_back to toolInput
toolInput.emplace_back( newd, roi, muon, previousDecision ); toolInput.emplace_back( newd, roi, muon, previousDecision );
...@@ -129,8 +129,6 @@ StatusCode TrigMufastHypoAlg::execute_r( const EventContext& context ) const ...@@ -129,8 +129,6 @@ StatusCode TrigMufastHypoAlg::execute_r( const EventContext& context ) const
{// make output handle and debug, in the base class {// make output handle and debug, in the base class
auto outputHandle = SG::makeHandle(decisionOutput(), context);
ATH_CHECK( outputHandle.record( std::move( decisions ), std::move( aux ) ) );
ATH_MSG_DEBUG ( "Exit with "<<outputHandle->size() <<" decisions"); ATH_MSG_DEBUG ( "Exit with "<<outputHandle->size() <<" decisions");
TrigCompositeUtils::DecisionIDContainer allPassingIDs; TrigCompositeUtils::DecisionIDContainer allPassingIDs;
if ( outputHandle.isValid() ) { if ( outputHandle.isValid() ) {
......
...@@ -61,9 +61,9 @@ StatusCode TrigMuisoHypoAlg::execute_r( const EventContext& context) const ...@@ -61,9 +61,9 @@ StatusCode TrigMuisoHypoAlg::execute_r( const EventContext& context) const
} }
ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions"); ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions");
auto decisions = std::make_unique<DecisionContainer>(); // new output decisions
auto aux = std::make_unique<DecisionAuxContainer>(); SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context );
decisions->setStore(aux.get()); auto decisions = outputHandle.ptr();
// end of common // end of common
std::vector<TrigMuisoHypoTool::MuisoInfo> toolInput; std::vector<TrigMuisoHypoTool::MuisoInfo> toolInput;
...@@ -83,7 +83,7 @@ StatusCode TrigMuisoHypoAlg::execute_r( const EventContext& context) const ...@@ -83,7 +83,7 @@ StatusCode TrigMuisoHypoAlg::execute_r( const EventContext& context) const
const xAOD::L2IsoMuon* muon = *muonEL; const xAOD::L2IsoMuon* muon = *muonEL;
// create new decision // create new decision
auto newd = newDecisionIn( decisions.get() ); auto newd = newDecisionIn( decisions );
// push_back to toolInput // push_back to toolInput
toolInput.emplace_back( newd, muon, previousDecision ); toolInput.emplace_back( newd, muon, previousDecision );
...@@ -115,8 +115,6 @@ StatusCode TrigMuisoHypoAlg::execute_r( const EventContext& context) const ...@@ -115,8 +115,6 @@ StatusCode TrigMuisoHypoAlg::execute_r( const EventContext& context) const
{// make output handle and debug, in the base class {// make output handle and debug, in the base class
auto outputHandle = SG::makeHandle(decisionOutput(), context);
ATH_CHECK( outputHandle.record( std::move( decisions ), std::move( aux ) ) );
ATH_MSG_DEBUG ( "Exit with "<<outputHandle->size() <<" decisions"); ATH_MSG_DEBUG ( "Exit with "<<outputHandle->size() <<" decisions");
TrigCompositeUtils::DecisionIDContainer allPassingIDs; TrigCompositeUtils::DecisionIDContainer allPassingIDs;
if ( outputHandle.isValid() ) { if ( outputHandle.isValid() ) {
......
...@@ -66,9 +66,9 @@ StatusCode TrigMuonEFCombinerHypoAlg::execute_r( const EventContext& context ) c ...@@ -66,9 +66,9 @@ StatusCode TrigMuonEFCombinerHypoAlg::execute_r( const EventContext& context ) c
} }
ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions"); ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions");
auto decisions = std::make_unique<DecisionContainer>(); // new output decisions
auto aux = std::make_unique<DecisionAuxContainer>(); SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context );
decisions->setStore(aux.get()); auto decisions = outputHandle.ptr();
// end of common // end of common
std::vector<TrigMuonEFCombinerHypoTool::MuonEFInfo> toolInput; std::vector<TrigMuonEFCombinerHypoTool::MuonEFInfo> toolInput;
...@@ -99,8 +99,8 @@ StatusCode TrigMuonEFCombinerHypoAlg::execute_r( const EventContext& context ) c ...@@ -99,8 +99,8 @@ StatusCode TrigMuonEFCombinerHypoAlg::execute_r( const EventContext& context ) c
const xAOD::Muon* muon = *muonEL; const xAOD::Muon* muon = *muonEL;
// create new dicions // create new decisions
auto newd = newDecisionIn( decisions.get() ); auto newd = newDecisionIn( decisions );
// pussh_back to toolInput // pussh_back to toolInput
toolInput.emplace_back( newd, roi, muon, previousDecision ); toolInput.emplace_back( newd, roi, muon, previousDecision );
...@@ -133,8 +133,6 @@ StatusCode TrigMuonEFCombinerHypoAlg::execute_r( const EventContext& context ) c ...@@ -133,8 +133,6 @@ StatusCode TrigMuonEFCombinerHypoAlg::execute_r( const EventContext& context ) c
} // End of tool algorithms */ } // End of tool algorithms */
{ // make output handle and debug, in the base class { // make output handle and debug, in the base class
auto outputHandle = SG::makeHandle( decisionOutput(), context );
ATH_CHECK( outputHandle.record( std::move(decisions), std::move(aux) ));
ATH_MSG_DEBUG ( "Exit with " << outputHandle->size() << " decisions"); ATH_MSG_DEBUG ( "Exit with " << outputHandle->size() << " decisions");
TrigCompositeUtils::DecisionIDContainer allPassingIDs; TrigCompositeUtils::DecisionIDContainer allPassingIDs;
if ( outputHandle.isValid() ) { if ( outputHandle.isValid() ) {
......
...@@ -66,9 +66,9 @@ StatusCode TrigMuonEFMSonlyHypoAlg::execute_r( const EventContext& context ) con ...@@ -66,9 +66,9 @@ StatusCode TrigMuonEFMSonlyHypoAlg::execute_r( const EventContext& context ) con
} }
ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions"); ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions");
auto decisions = std::make_unique<DecisionContainer>(); // new output decisions
auto aux = std::make_unique<DecisionAuxContainer>(); SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context );
decisions->setStore(aux.get()); auto decisions = outputHandle.ptr();
// end of common // end of common
std::vector<TrigMuonEFMSonlyHypoTool::MuonEFInfo> toolInput; std::vector<TrigMuonEFMSonlyHypoTool::MuonEFInfo> toolInput;
...@@ -99,8 +99,8 @@ StatusCode TrigMuonEFMSonlyHypoAlg::execute_r( const EventContext& context ) con ...@@ -99,8 +99,8 @@ StatusCode TrigMuonEFMSonlyHypoAlg::execute_r( const EventContext& context ) con
const xAOD::Muon* muon = *muonEL; const xAOD::Muon* muon = *muonEL;
// create new dicions // create new decisions
auto newd = newDecisionIn( decisions.get() ); auto newd = newDecisionIn( decisions );
// pussh_back to toolInput // pussh_back to toolInput
toolInput.emplace_back( newd, roi, muon, previousDecision ); toolInput.emplace_back( newd, roi, muon, previousDecision );
...@@ -133,8 +133,6 @@ StatusCode TrigMuonEFMSonlyHypoAlg::execute_r( const EventContext& context ) con ...@@ -133,8 +133,6 @@ StatusCode TrigMuonEFMSonlyHypoAlg::execute_r( const EventContext& context ) con
} // End of tool algorithms */ } // End of tool algorithms */
{ // make output handle and debug, in the base class { // make output handle and debug, in the base class
auto outputHandle = SG::makeHandle( decisionOutput(), context );
ATH_CHECK( outputHandle.record( std::move(decisions), std::move(aux) ));
ATH_MSG_DEBUG ( "Exit with " << outputHandle->size() << " decisions"); ATH_MSG_DEBUG ( "Exit with " << outputHandle->size() << " decisions");
TrigCompositeUtils::DecisionIDContainer allPassingIDs; TrigCompositeUtils::DecisionIDContainer allPassingIDs;
if ( outputHandle.isValid() ) { if ( outputHandle.isValid() ) {
......
...@@ -66,9 +66,8 @@ StatusCode TrigMuonEFTrackIsolationHypoAlg::execute_r( const EventContext& conte ...@@ -66,9 +66,8 @@ StatusCode TrigMuonEFTrackIsolationHypoAlg::execute_r( const EventContext& conte
ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions"); ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions");
// prepare output decisions // prepare output decisions
auto decisions = std::make_unique<DecisionContainer>(); SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context );
auto aux = std::make_unique<DecisionAuxContainer>(); auto decisions = outputHandle.ptr();
decisions->setStore(aux.get());
std::vector<TrigMuonEFTrackIsolationHypoTool::EFIsolationMuonInfo> toolInput; std::vector<TrigMuonEFTrackIsolationHypoTool::EFIsolationMuonInfo> toolInput;
size_t counter = 0; size_t counter = 0;
...@@ -96,7 +95,7 @@ StatusCode TrigMuonEFTrackIsolationHypoAlg::execute_r( const EventContext& conte ...@@ -96,7 +95,7 @@ StatusCode TrigMuonEFTrackIsolationHypoAlg::execute_r( const EventContext& conte
const xAOD::Muon* muon = *muonEL; const xAOD::Muon* muon = *muonEL;
// create new dicions // create new dicions
auto newd = newDecisionIn( decisions.get() ); auto newd = newDecisionIn( decisions );
toolInput.emplace_back( newd, roi, muon, previousDecision ); toolInput.emplace_back( newd, roi, muon, previousDecision );
...@@ -128,9 +127,7 @@ StatusCode TrigMuonEFTrackIsolationHypoAlg::execute_r( const EventContext& conte ...@@ -128,9 +127,7 @@ StatusCode TrigMuonEFTrackIsolationHypoAlg::execute_r( const EventContext& conte
} }
} // End of tool algorithm } // End of tool algorithm
{ // make output handle and debug, in the base class { // debu printout
auto outputHandle = SG::makeHandle( decisionOutput(), context );
ATH_CHECK( outputHandle.record( std::move( decisions ), std::move( aux ) ) );
ATH_MSG_DEBUG ( "Exit with "<< outputHandle->size() <<" decisions"); ATH_MSG_DEBUG ( "Exit with "<< outputHandle->size() <<" decisions");
TrigCompositeUtils::DecisionIDContainer allPassingIDs; TrigCompositeUtils::DecisionIDContainer allPassingIDs;
if ( outputHandle.isValid() ) { if ( outputHandle.isValid() ) {
......
...@@ -66,9 +66,9 @@ StatusCode TrigmuCombHypoAlg::execute_r(const EventContext& context) const ...@@ -66,9 +66,9 @@ StatusCode TrigmuCombHypoAlg::execute_r(const EventContext& context) const
} }
ATH_MSG_DEBUG( "Running with " << previousDecisionsHandle->size() << " implicit ReadHandles for previous decisions"); ATH_MSG_DEBUG( "Running with " << previousDecisionsHandle->size() << " implicit ReadHandles for previous decisions");
auto decisions = std::make_unique<DecisionContainer>(); // new output decisions
auto aux = std::make_unique<DecisionAuxContainer>(); SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context );
decisions->setStore(aux.get()); auto decisions = outputHandle.ptr();
// end of common // end of common
std::vector<TrigmuCombHypoTool::CombinedMuonInfo> toolInput; std::vector<TrigmuCombHypoTool::CombinedMuonInfo> toolInput;
...@@ -98,7 +98,7 @@ StatusCode TrigmuCombHypoAlg::execute_r(const EventContext& context) const ...@@ -98,7 +98,7 @@ StatusCode TrigmuCombHypoAlg::execute_r(const EventContext& context) const
const xAOD::L2CombinedMuon* muComb = *muCombEL; const xAOD::L2CombinedMuon* muComb = *muCombEL;
// create new decisions // create new decisions
auto newd = newDecisionIn( decisions.get() ); auto newd = newDecisionIn( decisions );
toolInput.emplace_back( TrigmuCombHypoTool::CombinedMuonInfo{ newd, muComb, muFast, previousDecision} ); toolInput.emplace_back( TrigmuCombHypoTool::CombinedMuonInfo{ newd, muComb, muFast, previousDecision} );
...@@ -120,9 +120,7 @@ StatusCode TrigmuCombHypoAlg::execute_r(const EventContext& context) const ...@@ -120,9 +120,7 @@ StatusCode TrigmuCombHypoAlg::execute_r(const EventContext& context) const
ATH_MSG_DEBUG("Go to " << tool); ATH_MSG_DEBUG("Go to " << tool);
ATH_CHECK( tool->decide( toolInput ) ); ATH_CHECK( tool->decide( toolInput ) );
} }
{// make output handle and debug, in the base class {// debug printout
auto outputHandle = SG::makeHandle( decisionOutput(), context );
ATH_CHECK( outputHandle.record( std::move( decisions ), std::move( aux ) ) );
ATH_MSG_DEBUG( "Exit with " << outputHandle->size() << " decisions"); ATH_MSG_DEBUG( "Exit with " << outputHandle->size() << " decisions");
TrigCompositeUtils::DecisionIDContainer allPassingIDs; TrigCompositeUtils::DecisionIDContainer allPassingIDs;
if ( outputHandle.isValid() ) { if ( outputHandle.isValid() ) {
......
...@@ -46,7 +46,7 @@ atlas_add_component( DecisionHandling ...@@ -46,7 +46,7 @@ atlas_add_component( DecisionHandling
atlas_add_test( TrigCompositeUtils_test atlas_add_test( TrigCompositeUtils_test
SOURCES test/TrigCompositeUtils_test.cxx SOURCES test/TrigCompositeUtils_test.cxx
LINK_LIBRARIES TestTools xAODTrigger DecisionHandlingLib LINK_LIBRARIES TestTools xAODTrigger DecisionHandlingLib
AthContainers ) AthContainers SGtests )
atlas_add_test( Combinators_test atlas_add_test( Combinators_test
SOURCES test/Combinators_test.cxx SOURCES test/Combinators_test.cxx
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <set> #include <set>
#include <memory> #include <memory>
#include <functional> #include <functional>
#include <iostream>
#include "AthLinks/ElementLink.h" #include "AthLinks/ElementLink.h"
#include "AthLinks/ElementLinkVector.h" #include "AthLinks/ElementLinkVector.h"
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
#include "StoreGate/WriteHandleKey.h" #include "StoreGate/WriteHandleKey.h"
#include "StoreGate/ReadHandleKey.h" #include "StoreGate/ReadHandleKey.h"
#include "StoreGate/WriteHandle.h" #include "StoreGate/WriteHandle.h"
#include "GaudiKernel/ThreadLocalContext.h"
#include "AthContainers/AuxElement.h" #include "AthContainers/AuxElement.h"
#include "xAODTrigger/TrigCompositeContainer.h" #include "xAODTrigger/TrigCompositeContainer.h"
...@@ -22,25 +24,61 @@ ...@@ -22,25 +24,61 @@
namespace TrigCompositeUtils { namespace TrigCompositeUtils {
// alias types, for readability and to simplify future evolution /// alias types, for readability and to simplify future evolution
typedef SG::WriteHandle<DecisionContainer> DecisionWriteHandle; typedef SG::WriteHandle<DecisionContainer> DecisionWriteHandle;
/**
* @brief Creates and right away records the Container CONT with the key.
* Returns the WriteHandle.
* No Aux store.
* If possible provide the context that comes via an argument to execute_r otherwise it will default to looking it up which is slower.
**/
template<class CONT>
SG::WriteHandle<CONT> createAndStoreNoAux( const SG::WriteHandleKey<CONT>& key, const EventContext& ctx = Gaudi::Hive::currentContext());
/**
* @brief Creates and right away records the Container CONT with the key.
* Returns the WriteHandle.
* With Aux store.
* If possible provide the context that comes via an argument to execute_r otherwise it will default to looking it up which is slower.
**/
template<class CONT, class AUX>
SG::WriteHandle<CONT> createAndStoreWithAux( const SG::WriteHandleKey<CONT>& key, const EventContext& ctx = Gaudi::Hive::currentContext());
/**
* @brief Creates and right away records the DecisionContainer with the key.
* Returns the WriteHandle.
* If possible provide the context that comes via an argument to execute_r otherwise it will default to looking it up which is slower.
**/
SG::WriteHandle<DecisionContainer> createAndStore( const SG::WriteHandleKey<DecisionContainer>& key, const EventContext& ctx = Gaudi::Hive::currentContext() );
/** /**
* @brief creates and right away stores the DecisionContainer under the key * @brief Creates and right away records the DecisionContainer using the provided WriteHandle.
**/ **/
DecisionWriteHandle createAndStore(const SG::WriteHandleKey<DecisionContainer>& key, const EventContext& ctx);
void createAndStore( SG::WriteHandle<DecisionContainer>& handle );
/** /**
* @brief helper method to that created the Decision objects, places it in the container and returns * @brief Helper method to create a Decision object, place it in the container and return a pointer to it.
* This is to make this: * This is to make this:
* auto d = newDecisionIn(output); * auto d = newDecisionIn(output);
* instead of: * instead of:
* auto d = new Decision; * auto d = new Decision;
* output->push_back(d); * output->push_back(d);
* a version with the name assigns the name to the TC object * If provided, the name is assigned to the TC object
* Note that the supplied DecisionContainer must have been recorded in the event store.
* If possible provide the context that comes via an argument to execute_r otherwise it will default to looking it up which is slower.
**/ **/
Decision* newDecisionIn (DecisionContainer* dc); Decision* newDecisionIn ( DecisionContainer* dc, const std::string& name = "", const EventContext& ctx = Gaudi::Hive::currentContext() );
Decision* newDecisionIn (DecisionContainer* dc, const std::string& name);
/**
* @brief Helper method to create a Decision object, place it in the container and return a pointer to it. RoI, view and feature links will be copied from the previous to the new decision and a "seed" link made between them
* @arg the container in which to place the new Decision
* @arg the previous decision to which the new one should be connected
* If provided, the name is assigned to the TC object
* Note that the supplied DecisionContainer must have been recorded in the event store.
**/
Decision* newDecisionIn( DecisionContainer* dc, const Decision* dOld, const std::string& name = "", const EventContext& ctx = Gaudi::Hive::currentContext() );
/** /**
* @brief Appends the decision (given as ID) to the decision object * @brief Appends the decision (given as ID) to the decision object
...@@ -51,19 +89,24 @@ namespace TrigCompositeUtils { ...@@ -51,19 +89,24 @@ namespace TrigCompositeUtils {
/** /**
* @brief Extracts DecisionIDs stored in the Decsion object * @brief Extracts DecisionIDs stored in the Decision object
**/ **/
void decisionIDs( const Decision* d, DecisionIDContainer& id ); void decisionIDs( const Decision* d, DecisionIDContainer& id );
/** /**
* @brief Another variant of the above method * @brief Another variant of the above method to access DecisionIDs stored in
the Decision object, returns const accessor
**/ **/
const std::vector<int>& decisionIDs( const Decision* d ); const std::vector<int>& decisionIDs( const Decision* d );
/**
* @brief Another variant of the above method to access DecisionIDs stored in the Decision object, returns read/write accessor
**/
std::vector<int>& decisionIDs( Decision* d ); std::vector<int>& decisionIDs( Decision* d );
/** /**
* @brief return true if thre is no positive decision stored * @brief return true if there is no positive decision stored
**/ **/
bool allFailed( const Decision* d ); bool allFailed( const Decision* d );
...@@ -73,7 +116,7 @@ namespace TrigCompositeUtils { ...@@ -73,7 +116,7 @@ namespace TrigCompositeUtils {
bool isAnyIDPassing( const Decision* d, const DecisionIDContainer& required); bool isAnyIDPassing( const Decision* d, const DecisionIDContainer& required);
/** /**
* @brief checks if required ID is in the set of the decisions * @brief checks if required decision ID is in the set of IDs in the container
**/ **/
bool passed( DecisionID id, const DecisionIDContainer& ); bool passed( DecisionID id, const DecisionIDContainer& );
...@@ -98,11 +141,8 @@ namespace TrigCompositeUtils { ...@@ -98,11 +141,8 @@ namespace TrigCompositeUtils {
* @ret true if success * @ret true if success
**/ **/
bool copyLinks(const Decision* src, Decision* dest); bool copyLinks(const Decision* src, Decision* dest);
/**
/**
* @brief traverses TC links for another TC fufilling the prerequisite specified by the filter * @brief traverses TC links for another TC fufilling the prerequisite specified by the filter
* @return matching TC or nullptr * @return matching TC or nullptr
**/ **/
...@@ -178,5 +218,6 @@ namespace TrigCompositeUtils { ...@@ -178,5 +218,6 @@ namespace TrigCompositeUtils {
} }
#include "DecisionHandling/TrigCompositeUtils.icc"
#endif // DecisionHandling_TrigCompositeUtils_h #endif // DecisionHandling_TrigCompositeUtils_h
/*
*
*/
namespace TrigCompositeUtils {
/**
* @brief Creates and right away records the Container CONT with the key.
* No Aux store.
* Returns the WriteHandle.
* If possible provide the context that comes via an argument to execute_r otherwise it will default to looking it up which is slower.
**/
template<class CONT>
SG::WriteHandle<CONT> createAndStoreNoAux( const SG::WriteHandleKey<CONT>& key, const EventContext& ctx ) {
SG::WriteHandle<CONT> handle( key, ctx );
auto data = std::make_unique<CONT>() ;
handle.record( std::move( data ) ).ignore();
return handle;
}
/**
* @brief Creates and right away records the Container CONT with the key.
* With Aux store.
* Returns the WriteHandle.
* If possible provide the context that comes via an argument to execute_r otherwise it will default to looking it up which is slower.
**/
template<class CONT, class AUX>
SG::WriteHandle<CONT> createAndStoreWithAux( const SG::WriteHandleKey<CONT>& key, const EventContext& ctx ) {
SG::WriteHandle<CONT> handle( key, ctx );
auto data = std::make_unique<CONT>() ;
auto aux = std::make_unique<AUX>() ;
data->setStore( aux.get() );
handle.record( std::move( data ), std::move( aux ) ).ignore();
return handle;
}
}
ApplicationMgr SUCCESS
====================================================================================================================================
Welcome to ApplicationMgr (GaudiCoreSvc v30r3)
running on pc-tbed-pub-23.cern.ch on Thu Oct 4 17:39:52 2018
====================================================================================================================================
ApplicationMgr INFO Application Manager Configured successfully
EventLoopMgr WARNING Unable to locate service "EventSelector"
EventLoopMgr WARNING No events will be processed from external input.
HistogramPersis...WARNING Histograms saving not required.
ApplicationMgr INFO Application Manager Initialized successfully
ApplicationMgr Ready
ClassIDSvc INFO getRegistryEntries: read 7465 CLIDRegistry entries for module ALL
Context: s: 0 e: 0
Current context: s: 0 e: 0
ClassIDSvc INFO getRegistryEntries: read 372 CLIDRegistry entries for module ALL
initialize SG::WriteHandleKey<DecisionContainer> whkT
call createAndStore( whkT ) with default context, twice
StoreGateSvc_Impl WARNING setupProxy:: error setting up proxy for key arbitrary and clid 1333228823
Pre-existing valid DataProxy @0x29a4bd0 found in Store for key arbitrary with clid 1333228823
StoreGateSvc_Impl WARNING record_impl: Problem setting up the proxy for object @0x29a50b0
recorded with key arbitrary of type xAOD::TrigCompositeContainer (CLID 1333228823) in DataObject @0x29a5400
VarHandle(Store... ERROR /build3/atnight/localbuilds/nightlies/master/athena/Control/StoreGate/src/VarHandleBase.cxx:734 (StatusCode SG::VarHandleBase::record_impl(std::unique_ptr<DataObject>, void*, bool, bool)): code 0: recordObject failed
FATAL /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2018-09-25T2105/Athena/22.0.1/InstallArea/x86_64-slc6-gcc62-dbg/src/Control/StoreGate/StoreGate/WriteHandle.icc:887 (StatusCode SG::WriteHandle<T>::record(std::unique_ptr<_Tp>, std::unique_ptr<U>, bool) [with AUXSTORE = xAOD::TrigCompositeAuxContainer_v1; T = DataVector<xAOD::TrigComposite_v1>]): code 0: this->record(std::move(data))
handle name "arbitrary" isPresent 1 isValid 1
handle name "arbitrary" isPresent 1 isValid 0
initialize SG::WriteHandleKey<DecisionContainer> whk1
call createAndStore( whk1 ) with default context
handle name myDecisions1 store StoreGateSvc_Impl
initialize SG::WriteHandleKey<DecisionContainer> whk2
call createAndStore( whk2, ctx )
handle name myDecisions2 store StoreGateSvc_Impl container size 0
testing insert decisions
1 from d1 1 from d1
2 from d1 2 from d1
1 from d1 and d2 1 from d1 and d2
...@@ -5,3 +38,39 @@ ...@@ -5,3 +38,39 @@
3 from d1 and d2 3 from d1 and d2
either 3 or 7 contained in d1 NO either 3 or 7 contained in d1 NO
either 3 or 7 contained in d2 YES either 3 or 7 contained in d2 YES
Call setObjectLink with a bad ElementLink that has no recorded collection. Expect cerr output to follow.
xAOD::TrigComposite_v1::setObjectLink ERROR link has invalid key hash of zero
Call setObjectLink with a bad ElementLink that has no corresponding collection. Expect cerr output to follow.
xAOD::TrigComposite_v1::setObjectLink ERROR link is not valid
New decision d3b with name & context
d3b: TrigComposite_v1 'd3b' link: name, key, index, CLID
self, 1042135810, 3, 1333228823
testlink, 1042135810, 1, 1333228823
el2 1042135810 1
d3: TrigComposite_v1 '' link: name, key, index, CLID
self, 1042135810, 2, 1333228823
seed, 1042135810, 1, 1333228823
d4: TrigComposite_v1 '' link: name, key, index, CLID
self, 1042135810, 4, 1333228823
seed, 1042135810, 1, 1333228823
el: key 1042135810 index 1
create d5
set link
d5: TrigComposite_v1 'd5' link: name, key, index, CLID
self, 1042135810, 5, 1333228823
feature, 1042135810, 1, 1333228823
create d6
d6: TrigComposite_v1 'd6' link: name, key, index, CLID
self, 1042135810, 6, 1333228823
feature, 1042135810, 1, 1333228823
seed, 1042135810, 5, 1333228823
get d5 feature link
get d6 feature link
compare feature links
get self and seed links
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment