ATLAS Offline Software
TrackParticleCellAssociationAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
11 
12 TrackParticleCellAssociationAlg::TrackParticleCellAssociationAlg(const std::string& name, ISvcLocator* pSvcLocator):
13  AthReentrantAlgorithm(name,pSvcLocator),
14  m_caloCellAssociationTool("Rec::ParticleCaloCellAssociationTool/ParticleCaloCellAssociationTool", this) {
15 
16  declareProperty("ParticleCaloCellAssociationTool",m_caloCellAssociationTool);
17  declareProperty("PtCut", m_ptCut = 10000. );
18 }
19 
21 
23 {
25 
30  return StatusCode::SUCCESS;
31 }
32 
34 {
35  // get track particles
37 
38  // Create the xAOD container and its auxiliary store:
41 
42 
44  ATH_CHECK(xaoda.record (std::make_unique<xAOD::TrackParticleClusterAssociationContainer>(),
45  std::make_unique<xAOD::TrackParticleClusterAssociationAuxContainer>()));
46 
47 
48 
49  unsigned int ntracks = 0;
50  for( unsigned int i=0;i<trackParticles->size();++i ){
51 
52  // slect track
53  const xAOD::TrackParticle* tp = (*trackParticles)[i];
54  if( tp->pt() < m_ptCut ) continue;
55 
56  // get ParticleCellAssociation
57  ATH_MSG_DEBUG(" Selected track: pt " << tp->pt() << " eta " << tp->eta() << " phi " << tp->phi() );
58  std::unique_ptr<const Rec::ParticleCellAssociation> association
59  =m_caloCellAssociationTool->particleCellAssociation(*tp,0.1);
60  if(!association){
61  ATH_MSG_DEBUG("failed to obtain the ParticleCellAssociation");
62  continue;
63  }
64 
65  // require container as it should be there
66  if( !association->container() ){
67  ATH_MSG_WARNING("Failed to obtain CaloCellContainer from ParticleCellAssociation");
68  continue;
69  }
70 
71  // create cell from ParticleCellAssociation
73  *association->container(),
74  *clusColl );
75  if( !cluster ){
76  ATH_MSG_WARNING("Failed to create cluster from ParticleCellAssociation");
77  continue;
78  }else{
79  ATH_MSG_DEBUG(" New cluster: eta " << cluster->eta() << " phi " << cluster->phi() << " cells " << cluster->size() << " nclusters " << clusColl->size() );
80  }
81 
82  // create element links
85 
86  // if valid create TrackParticleClusterAssociation
87  if( trackLink.isValid() && clusterLink.isValid() ){
89  xaoda->push_back(trackAssociation);
90  trackAssociation->setTrackParticleLink( trackLink );
91  std::vector< ElementLink< xAOD::CaloClusterContainer > > caloClusterLinks;
92  caloClusterLinks.push_back( clusterLink );
93  trackAssociation->setCaloClusterLinks(caloClusterLinks);
94  ATH_MSG_DEBUG("added association");
95  ++ntracks;
96  }else{
97  if( !trackLink.isValid() ) ATH_MSG_WARNING("Failed to create track ElementLink ");
98  if( !clusterLink.isValid() ) ATH_MSG_WARNING("Failed to create cluster ElementLink ");
99  }
100  }
101 
102  ATH_MSG_DEBUG(" Total number of selected tracks: " << ntracks );
103 
106  clusColl.ptr()));
107  return StatusCode::SUCCESS;
108 }
109 
110 
112 {
113  return StatusCode::SUCCESS;
114 }
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
CaloClusterStoreHelper::finalizeClusters
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
Definition: CaloClusterStoreHelper.cxx:64
xAOD::TrackParticleClusterAssociation_v1::setTrackParticleLink
void setTrackParticleLink(const ElementLink< TrackParticleContainer > &trackParticleLink)
Sets.
CaloClusterStoreHelper::AddContainerWriteHandle
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
Definition: CaloClusterStoreHelper.cxx:53
TrackParticleCellAssociationAlg::m_ptCut
double m_ptCut
Definition: TrackParticleCellAssociationAlg.h:56
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TrackParticleCellAssociationAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: TrackParticleCellAssociationAlg.cxx:33
ParticleTest.tp
tp
Definition: ParticleTest.py:25
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
TrackParticleCellAssociationAlg::finalize
StatusCode finalize() override
Definition: TrackParticleCellAssociationAlg.cxx:111
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
TrackParticleCellAssociationAlg::m_clusterCellLinkName
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_clusterCellLinkName
Definition: TrackParticleCellAssociationAlg.h:49
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
CrossedCaloCellHelper.h
TrackParticleCellAssociationAlg::m_associationContainerName
SG::WriteHandleKey< xAOD::TrackParticleClusterAssociationContainer > m_associationContainerName
Definition: TrackParticleCellAssociationAlg.h:53
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Trk::association
@ association
Definition: TrackingGeometry.h:46
xAOD::CaloCluster_v1::size
size_t size() const
size method (forwarded from CaloClusterCellLink obj)
Definition: CaloCluster_v1.cxx:996
TrackParticleCellAssociationAlg.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
IParticleCaloCellAssociationTool.h
Rec::CrossedCaloCellHelper::crossedCells
static xAOD::CaloCluster * crossedCells(const Rec::ParticleCellAssociation &association, const CaloCellContainer &cellContainer, xAOD::CaloClusterContainer &clusterContainer)
Definition: CrossedCaloCellHelper.h:18
xAOD::TrackParticleClusterAssociation_v1
Class describing a TrackParticleClusterAssociation.
Definition: TrackParticleClusterAssociation_v1.h:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
CaloClusterStoreHelper.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TrackParticleCellAssociationAlg::m_caloCellAssociationTool
ToolHandle< Rec::IParticleCaloCellAssociationTool > m_caloCellAssociationTool
Definition: TrackParticleCellAssociationAlg.h:41
TrackParticleCellAssociationAlg::m_clusterContainerName
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_clusterContainerName
Definition: TrackParticleCellAssociationAlg.h:46
TrackParticleCellAssociationAlg::~TrackParticleCellAssociationAlg
~TrackParticleCellAssociationAlg()
TrackParticleCellAssociationAlg::initialize
StatusCode initialize() override
Definition: TrackParticleCellAssociationAlg.cxx:22
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
TrackParticleCellAssociationAlg::TrackParticleCellAssociationAlg
TrackParticleCellAssociationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrackParticleCellAssociationAlg.cxx:12
xAOD::TrackParticleClusterAssociation
TrackParticleClusterAssociation_v1 TrackParticleClusterAssociation
Reference the current persistent version:
Definition: TrackParticleClusterAssociation.h:13
xAOD::TrackParticleClusterAssociation_v1::setCaloClusterLinks
void setCaloClusterLinks(const std::vector< ElementLink< CaloClusterContainer > > &caloClusterLinks)
Sets.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TrackParticleCellAssociationAlg::m_trackParticleCollectionName
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleCollectionName
Definition: TrackParticleCellAssociationAlg.h:43