ATLAS Offline Software
ClusterFilterTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
6 
9 
10 #include "FourMomUtils/P4Helpers.h"
11 
12 ClusterFilterTool::ClusterFilterTool(const std::string& t, const std::string& n, const IInterface* p )
13  : AthAlgTool(t,n,p),
14  m_caloEntryMapName("ParticleToCaloExtensionMap"),
15  m_loosetrackvertexassoTool("LooseTrackVertexAssociationTool")
16 {
17  declareInterface<IClusterFilterTool>(this);
18  declareProperty("LooseTrackVertexAssoTool", m_loosetrackvertexassoTool );
19  declareProperty("ParticleCaloEntryMapName", m_caloEntryMapName );
20  declareProperty("TrackParticleContainerName", m_trackParticleCollectionName = "InDetTrackParticles" );
21  declareProperty("VertexCollection", m_vertexCollectionName = "PrimaryVertices" );
22  declareProperty("ConeSize", m_coneSize = 0.2 );
23  declareProperty("PtFractionAtPV0", m_ptFractionPV0 = 0.1 );
24 }
25 
27 
29  ATH_MSG_INFO ("Initializing " << name() << "...");
31  return StatusCode::SUCCESS;
32 }
33 
35  ATH_MSG_INFO ("Finalizing " << name() << "...");
36  return StatusCode::SUCCESS;
37 }
38 
40 
41  // loop on all the tracks
42  const auto *const allTracks = getContainer<xAOD::TrackParticleContainer>(m_trackParticleCollectionName);
43  if (not allTracks) {
44  ATH_MSG_DEBUG ("No rejection applied... returning");
45  return false;
46  }
47 
48  const auto *const allVertices = getContainer<xAOD::VertexContainer>(m_vertexCollectionName);
49  if (not allVertices) {
50  ATH_MSG_DEBUG ("No rejection applied... returning");
51  return false;
52  }
53 
54  bool matchedPV0 = false;
55  bool matchedPVX = false;
56 
57  for (const auto *const track : *allTracks) {
58  // check compatibility with PVX where X>0
59  // retrieve the caloExtensionContainer to get the track position at the calo entrance
60  IParticleToCaloExtensionMap * caloExtensionMap = nullptr;
61  if(evtStore()->retrieve(caloExtensionMap,m_caloEntryMapName).isFailure())
62  ATH_MSG_WARNING( "Unable to retrieve " << m_caloEntryMapName << " will leak the ParticleCaloExtension" );
63  const Trk::TrackParameters* pars = caloExtensionMap->readCaloEntry(track);
64  if (not pars) {
65  ATH_MSG_DEBUG( "Extrapolated parameters non existing --> No rejection applied... returning" );
66  continue;
67  }
68 
69  float eta = pars->position().eta();
70  float phi = pars->position().phi();
71 
72  float dPhi = P4Helpers::deltaPhi( cluster.phi(), phi);
73  float dEta = cluster.eta()-eta;
74  float dr2 = dPhi*dPhi+ dEta*dEta;
75 
76  // check if the track is matching the cluster
77  if (dr2<m_coneSize*m_coneSize) {
78  if (allVertices && !allVertices->empty()) {
79  if (m_loosetrackvertexassoTool->isCompatible(*track, *(allVertices->at(0)))) {
80  ATH_MSG_DEBUG ("PV0 is matched");
81  matchedPV0 = true;
82  } else matchedPVX = true;
83  } else {
84  ATH_MSG_WARNING ("Vertex container " << m_vertexCollectionName << " is empty! Can't perform TVA! --> No rejection applied... returning");
85  return false;
86  }
87  }
88  }
89 
90  return not matchedPV0 and matchedPVX;
91 
92 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
ClusterFilterTool::finalize
virtual StatusCode finalize()
Definition: ClusterFilterTool.cxx:34
ClusterFilterTool::m_trackParticleCollectionName
std::string m_trackParticleCollectionName
Definition: ClusterFilterTool.h:50
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ClusterFilterTool::m_vertexCollectionName
std::string m_vertexCollectionName
Definition: ClusterFilterTool.h:51
ClusterFilterTool::initialize
virtual StatusCode initialize()
Definition: ClusterFilterTool.cxx:28
ClusterFilterTool::m_ptFractionPV0
double m_ptFractionPV0
Definition: ClusterFilterTool.h:57
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ClusterFilterTool::rejectCluster
bool rejectCluster(const xAOD::CaloCluster &cluster) const final
Method to check if a given cluster has to be rejected or not based on primary vertices requirements.
Definition: ClusterFilterTool.cxx:39
ClusterFilterTool::~ClusterFilterTool
virtual ~ClusterFilterTool()
ClusterFilterTool::m_loosetrackvertexassoTool
ToolHandle< CP::ITrackVertexAssociationTool > m_loosetrackvertexassoTool
Definition: ClusterFilterTool.h:48
IParticleToCaloExtensionMap::readCaloEntry
const Trk::TrackParameters * readCaloEntry(const xAOD::IParticle *particle) const
Definition: IParticleToCaloExtensionMap.cxx:18
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ClusterFilterTool::m_coneSize
double m_coneSize
Definition: ClusterFilterTool.h:54
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
P4Helpers::deltaPhi
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition: P4Helpers.h:29
IParticleToCaloExtensionMap
Definition: IParticleToCaloExtensionMap.h:13
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TauGNNUtils::Variables::Track::dPhi
bool dPhi(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:530
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::ParametersBase
Definition: ParametersBase.h:55
P4Helpers.h
ClusterFilterTool::m_caloEntryMapName
std::string m_caloEntryMapName
Definition: ClusterFilterTool.h:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ClusterFilterTool::ClusterFilterTool
ClusterFilterTool(const std::string &, const std::string &, const IInterface *)
Definition: ClusterFilterTool.cxx:12
VertexContainer.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
IParticleToCaloExtensionMap.h
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
AthAlgTool
Definition: AthAlgTool.h:26
ClusterFilterTool.h
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:525
TrackParticleContainer.h