Commit 57a0f53c authored by Edward Moyse's avatar Edward Moyse Committed by Graeme Stewart
Browse files

'Set default SG keys correctly, & better debugging info' (xAODMuonCnv-00-01-15)

parent 8ab14f1f
package xAODMuonCnv
author Edward.Moyse@cern.ch
# Base package(s):
use AtlasPolicy AtlasPolicy-*
public
use AtlasPolicy AtlasPolicy-*
use xAODMuon xAODMuon-* Event/xAOD
use MuonSegment MuonSegment-* MuonSpectrometer/MuonReconstruction/MuonRecEvent
use TrkSegment TrkSegment-* Tracking/TrkEvent
use AthLinks AthLinks-* Control
private
use AthenaBaseComps AthenaBaseComps-* Control
use AthenaKernel AthenaKernel-* Control
use GaudiInterface GaudiInterface-* External
use Particle Particle-* Reconstruction
use muonEvent muonEvent-* Reconstruction/MuonIdentification
use xAODPrimitives xAODPrimitives-* Event/xAOD
end_private
# Make a component library:
library xAODMuonCnv *.cxx components/*.cxx
apply_pattern component_library
# $Id: ClusterCreator_jobOptions.py 297184 2013-10-03 11:18:41Z krasznaa $
# Set up the reading of the input AOD:
FNAME = "/home/emoyse/mc12_8TeV.147807.PowhegPythia8_AU2CT10_Zmumu.merge.AOD.e1169_s1469_s1470_r3658_r3549_tid01085597_00/AOD.01085597._000308.pool.root.1"
include( "AthenaPython/iread_file.py" )
# from RecExConfig.RecFlags import rec
# from AthenaCommon.BeamFlags import jobproperties
# from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
# from AthenaCommon.GlobalFlags import globalflags
# Access the algorithm sequence:
from AthenaCommon.AlgSequence import AlgSequence
theJob = AlgSequence()
from MuonCombinedRecExample.MuonCombinedKeys import MuonCombinedKeys as MuonCbKeys
#InDet
from xAODTrackParticleCnv.xAODTrackParticleCnvConf import xAODMaker__TrackParticleCnvAlg
alg = xAODMaker__TrackParticleCnvAlg()
theJob += alg
#SA
from xAODTrackParticleCnv.xAODTrackParticleCnvConf import xAODMaker__TrackParticleCnvAlg
alg1 = xAODMaker__TrackParticleCnvAlg("TrackParticleCnvAlg_ExtrapolatedMS")
alg1.AODContainerName = MuonCbKeys.ExtrapolatedMSParticles() #ExtrapolatedMuonSpectrometerParticles
alg1.xAODContainerName = "x"+MuonCbKeys.ExtrapolatedMSParticles()
alg1.OutputLevel = VERBOSE
theJob += alg1
# StatCombined
from xAODTrackParticleCnv.xAODTrackParticleCnvConf import xAODMaker__TrackParticleCnvAlg
alg3 = xAODMaker__TrackParticleCnvAlg("TrackParticleCnvAlg_StatCombined")
alg3.AODContainerName = MuonCbKeys.StatCombinedParticles() #xStatCombinedMuonParticles
alg3.xAODContainerName = "x"+MuonCbKeys.StatCombinedParticles()
alg3.OutputLevel = VERBOSE
theJob += alg3
# Combined
from xAODTrackParticleCnv.xAODTrackParticleCnvConf import xAODMaker__TrackParticleCnvAlg
alg4 = xAODMaker__TrackParticleCnvAlg("TrackParticleCnvAlg_CombinedFit")
alg4.AODContainerName = MuonCbKeys.CombinedFitParticles() #CombinedFitParticles
alg4.xAODContainerName = "x"+MuonCbKeys.CombinedFitParticles()
alg4.OutputLevel = VERBOSE
theJob += alg4
# ST
from xAODTrackParticleCnv.xAODTrackParticleCnvConf import xAODMaker__TrackParticleCnvAlg
alg5 = xAODMaker__TrackParticleCnvAlg("TrackParticleCnvAlg_SegmentTagTrackParticles")
alg5.AODContainerName = MuonCbKeys.SegmentTagTrackParticles() #SegmentTagTrackParticles
alg5.xAODContainerName = "x"+MuonCbKeys.SegmentTagTrackParticles()
alg5.OutputLevel = VERBOSE
theJob += alg5
#Muons
from xAODMuonCnv.xAODMuonCnvConf import xAODMaker__MuonCnvAlg
muonAlg = xAODMaker__MuonCnvAlg()
muonAlg.OutputLevel = VERBOSE
theJob += muonAlg
# This algorithm *must* always be last in the sequence:
from xAODCreatorAlgs.xAODCreatorAlgsConf import xAODMaker__EventFormatCreator
alg5 = xAODMaker__EventFormatCreator()
#alg5.OutputLevel = VERBOSE
theJob += alg5
# Create a POOL output file with the StoreGate contents:
from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
xaodStream = MSMgr.NewPoolStream( "StreamXAOD", "xAOD.pool.root" )
# Set up its contents:
# xaodStream.AddItem( "xAOD::CaloClusterContainer_v1#*" )
# xaodStream.AddItem( "xAOD::CaloClusterAuxContainer_v1#*" )
xaodStream.AddItem( "xAOD::TrackParticleContainer_v1#*" )
xaodStream.AddItem( "xAOD::TrackParticleAuxContainer_v1#*" )
xaodStream.AddItem( "xAOD::MuonContainer_v1#*" )
xaodStream.AddItem( "xAOD::MuonAuxContainer_v1#*" )
xaodStream.AddMetaDataItem( "xAOD::EventFormat_v1#*" )
xaodStream.Print()
# Split all branches:
ServiceMgr.AthenaPoolCnvSvc.PoolAttributes += [
"DEFAULT_SPLITLEVEL='99'" ]
# Force POOL to just simply use the StoreGate keys as branch names:
ServiceMgr.AthenaPoolCnvSvc.SubLevelBranchName = "<key>"
# Do some additional tweaking:
from AthenaCommon.AppMgr import theApp
theApp.EvtMax = -1
ServiceMgr.MessageSvc.OutputLevel = INFO
ServiceMgr.MessageSvc.defaultLimit = 1000000
# ServiceMgr.AthenaSealSvc.OutputLevel = VERBOSE
#from VP1Algs.VP1AlgsConf import VP1Alg
#theJob += VP1Alg()
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: MuonCnvAlg.cxx 298140 2013-11-19 11:32:49Z emoyse $
// Gaudi/Athena include(s):
#include "AthenaKernel/errorcheck.h"
// EDM include(s):
#include "muonEvent/MuonContainer.h"
#include "xAODMuon/MuonAuxContainer.h"
// Local include(s):
#include "MuonCnvAlg.h"
namespace xAODMaker {
MuonCnvAlg::MuonCnvAlg( const std::string& name,
ISvcLocator* svcLoc )
: AthAlgorithm( name, svcLoc ),
m_muonDressingTool("MuonCombined::MuonDressingTool/MuonDressingTool")
{
declareProperty( "AODContainerName", m_aodContainerName = "Muons" );
declareProperty( "xAODContainerName", m_xaodContainerName = "Muons" );
declareProperty( "xAODInDetTrackParticleContainerName", m_inDetTrackParticles = "InDetTrackParticles" );
declareProperty( "xAODSATrackParticleContainerName", m_saTrackParticles = "ExtrapolatedMuonTrackParticles" );
declareProperty( "xAODCombinedTrackParticleContainerName", m_cbTrackParticles = "CombinedMuonTrackParticles" );
}
StatusCode MuonCnvAlg::initialize() {
ATH_MSG_DEBUG( "AODContainerName = " << m_aodContainerName << " xAODContainerName = " << m_xaodContainerName );
ATH_CHECK(m_muonDressingTool.retrieve());
// Return gracefully:
return StatusCode::SUCCESS;
}
StatusCode MuonCnvAlg::execute() {
// Retrieve the AOD particles:
const Analysis::MuonContainer* aod = evtStore()->tryConstRetrieve<Analysis::MuonContainer>(m_aodContainerName);
if (!aod) {
ATH_MSG_DEBUG("No MuonContainer with key " << m_aodContainerName << " found. Do nothing.");
return StatusCode::SUCCESS;
}
ATH_MSG_DEBUG( "Retrieved particles with key: " << m_aodContainerName );
// Create the xAOD container and its auxiliary store:
xAOD::MuonContainer* xaod = new xAOD::MuonContainer();
CHECK( evtStore()->record( xaod, m_xaodContainerName ) );
xAOD::MuonAuxContainer* aux = new xAOD::MuonAuxContainer();
CHECK( evtStore()->record( aux, m_xaodContainerName + "Aux." ) );
xaod->setStore( aux );
ATH_MSG_DEBUG( "Recorded Muons with key: "
<< m_xaodContainerName );
// Create the xAOD objects:
Analysis::MuonContainer::const_iterator itr = aod->begin();
Analysis::MuonContainer::const_iterator end = aod->end();
for( ; itr != end; ++itr ) {
// Create the xAOD object:
xAOD::Muon* muon = new xAOD::Muon();
xaod->push_back( muon );
// p4
muon->setP4((*itr)->pt(),(*itr)->eta(),(*itr)->phi());
// author(s)
muon->setAuthor( static_cast<xAOD::Muon_v1::Author>((*itr)->author()));//FIXME - error prone. Only works if they have the same indices
muon->setAllAuthors( (*itr)->allAuthors());
//type
if ((*itr)->isCombinedMuon())
muon->setMuonType(xAOD::Muon::Combined);
else if ((*itr)->isStandAloneMuon())
muon->setMuonType(xAOD::Muon::MuonStandAlone);
else if ((*itr)->isSegmentTaggedMuon())
muon->setMuonType(xAOD::Muon::SegmentTagged);
else if ((*itr)->isCaloMuonId())
muon->setMuonType(xAOD::Muon::CaloTagged);
else if ((*itr)->isSiliconAssociatedForwardMuon())
muon->setMuonType(xAOD::Muon::SiliconAssociatedForwardMuon);
else
ATH_MSG_WARNING("Unknown type of AOD Muon");
//setQuality
xAOD::Muon::Quality tightness;
if ((*itr)->isTight()) {
tightness=xAOD::Muon::Tight;
} else if ((*itr)->isMedium()) {
tightness=xAOD::Muon::Medium;
} else {
tightness=xAOD::Muon::Loose;
}
muon->setQuality( tightness );
//setParameters
setParameters(**itr,*muon);
//setIsolations
setIsolations(**itr,*muon);
// set Links
setLinks(**itr,*muon);
// ATH_MSG_VERBOSE(" AOD Muon pt " << (*itr)->pt() << " eta " << (*itr)->eta() << " phi " << (*itr)->phi());
ATH_MSG_VERBOSE(" xAOD Muon pt " << muon->pt() << " eta " << muon->eta() << " phi " << muon->phi());
ATH_MSG_VERBOSE(" author " << muon->author() << " type " << muon->muonType()
<< " links CB " << muon->combinedTrackParticleLink().isValid()
<< " ID " << muon->inDetTrackParticleLink().isValid()
<< " MS " << muon->muonSpectrometerTrackParticleLink().isValid()
<< " Primary " << muon->primaryTrackParticleLink().isValid()
);
setMuonHitContent(**itr,*muon);
}
// Return gracefully:
return StatusCode::SUCCESS;
}
void MuonCnvAlg::setParameters(const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon){
// We're not doing all AOD parameters here because some are dropped, and some are moved elsewhere.
checkAndSetParameter(MuonParameters::spectrometerFieldIntegral , xAOD::Muon::spectrometerFieldIntegral , aodmuon, xaodmuon);
checkAndSetParameter(MuonParameters::scatteringCurvatureSignificance , xAOD::Muon::scatteringCurvatureSignificance , aodmuon, xaodmuon);
checkAndSetParameter(MuonParameters::scatteringNeighbourSignificance , xAOD::Muon::scatteringNeighbourSignificance , aodmuon, xaodmuon);
checkAndSetParameter(MuonParameters::momentumBalanceSignificance , xAOD::Muon::momentumBalanceSignificance , aodmuon, xaodmuon);
checkAndSetParameter(MuonParameters::segmentDeltaEta , xAOD::Muon::segmentDeltaEta , aodmuon, xaodmuon);
checkAndSetParameter(MuonParameters::segmentDeltaPhi , xAOD::Muon::segmentDeltaPhi , aodmuon, xaodmuon);
checkAndSetParameter(MuonParameters::t0 , xAOD::Muon::t0 , aodmuon, xaodmuon);
checkAndSetParameter(MuonParameters::beta , xAOD::Muon::beta , aodmuon, xaodmuon);
checkAndSetParameter(MuonParameters::annBarrel , xAOD::Muon::annBarrel , aodmuon, xaodmuon);
checkAndSetParameter(MuonParameters::annEndCap , xAOD::Muon::annEndCap , aodmuon, xaodmuon);
checkAndSetParameter(MuonParameters::innAngle , xAOD::Muon::innAngle , aodmuon, xaodmuon);
checkAndSetParameter(MuonParameters::midAngle , xAOD::Muon::midAngle , aodmuon, xaodmuon);
}
void MuonCnvAlg::setMuonHitContent(const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon){
const Rec::TrackParticle* aTrackParticle = aodmuon.track();
if( !aTrackParticle->trackSummary() ) return;
m_muonDressingTool->addMuonHitSummary(xaodmuon,aTrackParticle->trackSummary());
}
void MuonCnvAlg::checkAndSetParameter(MuonParameters::ParamDef aodParameter,xAOD::Muon::ParamDef xaodParameter, const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon){
double result = aodmuon.parameter(aodParameter);
if (result>-999.) {
float parameter = static_cast<float>(result);
xaodmuon.setParameter(parameter, xaodParameter);
}
}
void MuonCnvAlg::setIsolations(const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon){
checkAndSetIsolation(MuonParameters::etcone10 , xAOD::Iso::etcone10 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::etcone20 , xAOD::Iso::etcone20 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::etcone30 , xAOD::Iso::etcone30 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::etcone40 , xAOD::Iso::etcone40 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::nucone10 , xAOD::Iso::nucone10 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::nucone20 , xAOD::Iso::nucone20 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::nucone30 , xAOD::Iso::nucone30 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::nucone40 , xAOD::Iso::nucone40 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::ptcone10 , xAOD::Iso::ptcone10 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::ptcone20 , xAOD::Iso::ptcone20 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::ptcone30 , xAOD::Iso::ptcone30 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::ptcone40 , xAOD::Iso::ptcone40 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::etconeNoEm10 , xAOD::Iso::etconeNoEm10 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::etconeNoEm20 , xAOD::Iso::etconeNoEm20 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::etconeNoEm30 , xAOD::Iso::etconeNoEm30 , aodmuon, xaodmuon);
checkAndSetIsolation(MuonParameters::etconeNoEm40 , xAOD::Iso::etconeNoEm40 , aodmuon, xaodmuon);
}
void MuonCnvAlg::checkAndSetIsolation(MuonParameters::ParamDef aodParameter,xAOD::Iso::IsolationType xaodParameter, const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon){
double result = aodmuon.parameter(aodParameter);
if (result>-999.) {
float isolation = static_cast<float>(aodmuon.parameter(aodParameter));
xaodmuon.setIsolation(isolation, xaodParameter);
}
}
void MuonCnvAlg::setLinks(const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon) const {
// Need to reset links from old TrackParticle to xAOD::TrackParticles
// ElementLink<xAOD::TrackParticleContainer > newLink = getNewLink(aodmuon.inDetTrackLink(), m_inDetTrackParticles);
xaodmuon.setTrackParticleLink(xAOD::Muon_v1::InnerDetectorTrackParticle, getNewLink(aodmuon.inDetTrackLink(), m_inDetTrackParticles) );
// ElementLink<xAOD::TrackParticleContainer > newLink2 = getNewLink(aodmuon.muonExtrapTrackLink(), m_saTrackParticles);
xaodmuon.setTrackParticleLink(xAOD::Muon_v1::MuonSpectrometerTrackParticle,getNewLink(aodmuon.muonExtrapTrackLink(), m_saTrackParticles) );
// ElementLink<xAOD::TrackParticleContainer > newLink3 = getNewLink(aodmuon.muonExtrapTrackLink(), m_cbTrackParticles);
xaodmuon.setTrackParticleLink(xAOD::Muon_v1::CombinedTrackParticle, getNewLink(aodmuon.combinedTrackLink(), m_cbTrackParticles) );
// Sanity checks - can remove at some stage
if (!xaodmuon.primaryTrackParticleLink().isValid()){
ATH_MSG_WARNING(" xAOD::Muon with no primary TrackParticle! Type: " << xaodmuon.muonType());
ATH_MSG_WARNING(" author " << xaodmuon.author() << " type " << xaodmuon.muonType()
<< " links CB " << xaodmuon.combinedTrackParticleLink().isValid()
<< " ID " << xaodmuon.inDetTrackParticleLink().isValid()
<< " MS " << xaodmuon.muonSpectrometerTrackParticleLink().isValid()
<< " Primary " << xaodmuon.primaryTrackParticleLink().isValid()
);
ATH_MSG_WARNING(" AOD::Muon links CB " << aodmuon.combinedTrackLink().isValid()
<< " ID " << aodmuon.combinedTrackLink().isValid()
<< " MS " << aodmuon.muonExtrapTrackLink().isValid()
);
}
}
ElementLink<xAOD::TrackParticleContainer> MuonCnvAlg::getNewLink(const ElementLink<Rec::TrackParticleContainer>& oldLink, const std::string& name) const{
ElementLink<xAOD::TrackParticleContainer> newLink;
newLink.resetWithKeyAndIndex( name, oldLink.index() );
ATH_MSG_VERBOSE("MuonCnvAlg::getNewLink - Old link is "<<(oldLink.isValid()?"VALID":"INVALID")<< " with SGKey = "<<oldLink.dataID()<< " & index = "<<oldLink.index()
<<" and new link is "<<(newLink.isValid()?"VALID":"INVALID")<< " with SGKey = "<<newLink.dataID()<< " & index = "<<newLink.index());
return newLink;
}
} // namespace xAODMaker
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: MuonCnvAlg.h 297747 2013-10-28 15:14:24Z krasznaa $
#ifndef XAODCREATORALGS_MUONCREATOR_H
#define XAODCREATORALGS_MUONCREATOR_H
// System include(s):
#include <string>
// Athena/Gaudi include(s):
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"
// xAOD include
#include "xAODPrimitives/IsolationType.h"
#include "xAODMuon/MuonContainer.h"
#include "muonEvent/MuonParamDefs.h"
#include "Particle/TrackParticleContainer.h"
#include "xAODMuonCnv/IMuonDressingTool.h"
namespace Analysis {
class Muon;
}
namespace xAODMaker {
/**
* @short Algorithm creating xAOD::Muons from Muons
*
* This algorithm can be used to translate the Muons coming
* from an AOD, and create xAOD::Muon objects out of them
* for an output xAOD.
*
* @author Edward Moyse <Edward.Moyse@cern.ch>
*
*/
class MuonCnvAlg : public AthAlgorithm {
public:
/// Regular algorithm constructor
MuonCnvAlg( const std::string& name, ISvcLocator* svcLoc );
/// Function initialising the algorithm
virtual StatusCode initialize();
/// Function executing the algorithm
virtual StatusCode execute();
private:
/// The key of the input CaloClusterContainer
std::string m_aodContainerName;
/// The key for the output xAOD::CaloClusterContainer
std::string m_xaodContainerName;
void setParameters(const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon);
void checkAndSetParameter(MuonParameters::ParamDef aodParameter,xAOD::Muon::ParamDef xaodParameter, const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon);
void setIsolations(const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon);
void checkAndSetIsolation(MuonParameters::ParamDef aodParameter,xAOD::Iso::IsolationType xaodParameter, const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon);
void setLinks(const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon) const;
void setMuonHitContent(const Analysis::Muon& aodmuon, xAOD::Muon& xaodmuon);
ElementLink<xAOD::TrackParticleContainer> getNewLink(const ElementLink<Rec::TrackParticleContainer>& oldLink, const std::string& name) const;
std::string m_inDetTrackParticles; //!< Location/Key for xAOD::TrackParticles from ID.
std::string m_saTrackParticles ; //!< Location/Key for MS SA (extrap to beamline) xAOD::TrackParticles.
std::string m_cbTrackParticles ; //!< Location/Key for combined fit xAOD::TrackParticles.
ToolHandle<xAOD::IMuonDressingTool> m_muonDressingTool;
}; // class MuonCnvAlg
} // namespace xAODMaker
#endif // XAODCREATORALGS_MUONCREATOR_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: MuonSegmentCnvAlg.cxx 298140 2013-11-19 11:32:49Z emoyse $
// Gaudi/Athena include(s):
#include "AthenaKernel/errorcheck.h"
// EDM include(s):
#include "xAODMuon/MuonSegmentAuxContainer.h"
#include "xAODMuon/MuonSegmentContainer.h"
#include "TrkSegment/SegmentCollection.h"
#include "TrkSegment/Segment.h"
#include "MuonSegment/MuonSegment.h"
#include "AthLinks/ElementLink.h"
// Local include(s):
#include "MuonSegmentCnvAlg.h"
namespace xAODMaker {
MuonSegmentCnvAlg::MuonSegmentCnvAlg( const std::string& name,
ISvcLocator* svcLoc )
: AthAlgorithm( name, svcLoc ),
m_muonSegmentConverterTool("Muon::MuonSegmentConverterTool/MuonSegmentConverterTool")
{
declareProperty( "SegmentContainerName", m_muonSegmentLocation = "MuonSegments" );
declareProperty( "xAODContainerName", m_xaodContainerName = "MuonSegments" );
}
StatusCode MuonSegmentCnvAlg::initialize() {
ATH_MSG_DEBUG( "SegmentContainerName = " << m_muonSegmentLocation << " xAODContainerName = " << m_xaodContainerName );
ATH_CHECK(m_muonSegmentConverterTool.retrieve());
// Return gracefully:
return StatusCode::SUCCESS;
}
StatusCode MuonSegmentCnvAlg::execute() {
// Retrieve the AOD particles:
const Trk::SegmentCollection* segments = 0;
if(evtStore()->transientContains<Trk::SegmentCollection>(m_muonSegmentLocation)) {
if(evtStore()->retrieve(segments,m_muonSegmentLocation).isFailure()) {
ATH_MSG_FATAL( "Unable to retrieve " << m_muonSegmentLocation );
return StatusCode::FAILURE;
}
}
// If there's no input, we're done already:
if( ! segments ) return StatusCode::SUCCESS;
// Create the xAOD container and its auxiliary store:
xAOD::MuonSegmentContainer* xaod = new xAOD::MuonSegmentContainer();
CHECK( evtStore()->record( xaod, m_xaodContainerName ) );
xAOD::MuonSegmentAuxContainer* aux = new xAOD::MuonSegmentAuxContainer();
CHECK( evtStore()->record( aux, m_xaodContainerName + "Aux." ) );
xaod->setStore( aux );
unsigned int index = 0;
for( auto it = segments->begin();it!=segments->end();++it,++index ){
const Muon::MuonSegment* muonSegment = dynamic_cast<const Muon::MuonSegment*>(&(**it));
if( !muonSegment ) continue;
ElementLink< ::Trk::SegmentCollection > link(m_muonSegmentLocation,index);
/*xAOD::MuonSegment* xaodSegment =*/
m_muonSegmentConverterTool->convert(link,xaod);
}
ATH_MSG_DEBUG( "Recorded MuonSegments with key: " << m_xaodContainerName << " size " << xaod->size() );
return StatusCode::SUCCESS;
}
} // namespace xAODMaker
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: MuonSegmentCnvAlg.h 297747 2013-10-28 15:14:24Z krasznaa $
#ifndef XAODMUONCNV_MUONSEGMENTCNVALG_H
#define XAODMUONCNV_MUONSEGMENTCNVALG_H
// System include(s):
#include <string>
// Athena/Gaudi include(s):
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"
// xAOD include
#include "xAODMuonCnv/IMuonSegmentConverterTool.h"
namespace Analysis {
class Muon;
}
namespace xAODMaker {
/**
* @short Algorithm creating xAOD::MuonSegments from MuonSegments
*
* This algorithm can be used to translate the MuonSegments coming
* from an AOD, and create xAOD::MuonSegment objects out of them
* for an output xAOD.
*
* @author Niels van Eldik
*
*/
class MuonSegmentCnvAlg : public AthAlgorithm {
public:
/// Regular algorithm constructor
MuonSegmentCnvAlg( const std::string& name, ISvcLocator* svcLoc );
/// Function initialising the algorithm
virtual StatusCode initialize();
/// Function executing the algorithm
virtual StatusCode execute();
private:
std::string m_muonSegmentLocation; //!< Location/Key for Muon::MuonSegment
std::string m_xaodContainerName; //!< Location/Key for xAOD::MuonSegment
ToolHandle<xAODMaker::IMuonSegmentConverterTool> m_muonSegmentConverterTool;
}; // class MuonSegmentCnvAlg
} // namespace xAODMaker
#endif // XAODCREATORALGS_MUONCREATOR_H
// $Id: xAODCreatorAlgs_entries.cxx 298282 2013-12-03 13:05:16Z emoyse $
// Gaudi/Athena include(s):
#include "GaudiKernel/DeclareFactoryEntries.h"
// Local include(s):
#include "../MuonCnvAlg.h"
#include "../MuonSegmentCnvAlg.h"
DECLARE_NAMESPACE_ALGORITHM_FACTORY( xAODMaker, MuonCnvAlg )
DECLARE_NAMESPACE_ALGORITHM_FACTORY( xAODMaker, MuonSegmentCnvAlg )
DECLARE_FACTORY_ENTRIES( xAODCreatorAlgs ) {
DECLARE_NAMESPACE_ALGORITHM( xAODMaker, MuonCnvAlg )
DECLARE_NAMESPACE_ALGORITHM( xAODMaker, MuonSegmentCnvAlg )
}
// $Id$
// Gaudi/Athena include(s):
#include "GaudiKernel/LoadFactoryEntries.h"
// Declare the library to the infrastructure:
LOAD_FACTORY_ENTRIES( xAODMuonCnv )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef XAOD_IMUONDRESSINGTOOL_H
#define XAOD_IMUONDRESSINGTOOL_H
#include "GaudiKernel/IAlgTool.h"
#include "xAODMuon/Muon.h"
static const InterfaceID IID_IMuonDressingTool("Muon::IMuonDressingTool",1,0);