ATLAS Offline Software
Loading...
Searching...
No Matches
HIJetClusterIndexAssociationTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include <iomanip>
8
9//**********************************************************************
10
15
16//**********************************************************************
17
19 ATH_MSG_DEBUG("Initializing HIJetClusterIndexAssociationTool");
20 ATH_CHECK( m_containerKey.initialize( !m_containerKey.key().empty() ) );
21 return StatusCode::SUCCESS;
22}
23//**********************************************************************
24
26{
27
28 const xAOD::IParticleContainer* ppars=0;
29
30 ATH_MSG_DEBUG("Retrieving xAOD container " << m_containerKey.key() );
32 ppars = readHandlePcontainer.get();
33
34 for (xAOD::JetContainer::iterator ijet=jets.begin(); ijet!=jets.end(); ++ijet)
35 {
36 std::vector<const xAOD::IParticle*> ParticleVector;
37 xAOD::Jet* theJet=(*ijet);
38
41
42 int etabinmin=HI::TowerBins::findBinEta(eta-m_DR);
43 int etabinmax=HI::TowerBins::findBinEta(eta+m_DR);
44
45 if(etabinmin < 0) etabinmin=0;
46 if(static_cast<unsigned int>(etabinmax) > HI::TowerBins::numEtaBins()) etabinmax=HI::TowerBins::numEtaBins();
47
48 for(int ieta=etabinmin; ieta<=etabinmax; ieta++)
49 {
50
52 float delta_ev2=(ev-eta)*(ev-eta);
53 float phimin=phi-std::sqrt( m_DR*m_DR-delta_ev2+1e-4 );
54 unsigned int iphi=HI::TowerBins::findBinPhi(phimin);
55 float pbc=HI::TowerBins::getBinCenterPhi(iphi);
56 float dphi=TVector2::Phi_mpi_pi(phi-pbc);
57 float rv2=dphi*dphi+delta_ev2;
58
59 if(rv2 > m_DR*m_DR)
60 {
61 iphi++;
63 dphi=TVector2::Phi_mpi_pi(phi-pbc);
64 rv2=dphi*dphi+delta_ev2;
65 }
66 while(rv2 < m_DR*m_DR)
67 {
68 float pv=HI::TowerBins::getBinCenterPhi(iphi);
69 unsigned int eta_phi_index=HI::TowerBins::findEtaPhiBin(ev,pv);
70 const xAOD::IParticle* ap=(*ppars)[eta_phi_index];
71 ParticleVector.push_back( ap );
72 //update condition for next iteration in while loop
73 iphi++;
75 dphi=TVector2::Phi_mpi_pi(phi-pbc);
76 rv2=dphi*dphi+delta_ev2;
77 }
78 }
79
81
82 }
83 // return 1;
84
85 // msg(MSG::INFO) << std::setw(20) << "ASG_CHECKING ASSOCIATIONS" << endmsg;
86 // for (xAOD::JetContainer::iterator ijet=jets.begin(); ijet!=jets.end(); ijet++)
87 // {
88 // xAOD::Jet* theJet=(*ijet);
89 // msg(MSG::INFO) << std::setw(20) << "JET"
90 // << std::setw(15) << theJet->e()
91 // << std::setw(15) << theJet->eta()
92 // << std::setw(15) << theJet->phi()
93 // << std::setw(15) << theJet->pt()
94 // << endmsg;
95
96 // std::vector<const xAOD::IParticle*> theParticles=theJet->getAssociatedObjects<xAOD::IParticle>(m_assocName);
97 // unsigned int ip=0;
98 // for(auto pItr=theParticles.begin(); pItr!=theParticles.end(); pItr++, ip++)
99 // {
100 // msg(MSG::INFO) << std::setw(20) << ip
101 // << std::setw(15) << (*pItr)->e()
102 // << std::setw(15) << (*pItr)->eta()
103 // << std::setw(15) << (*pItr)->phi()
104 // << std::setw(15) << (*pItr)->pt()
105 // << endmsg;
106 // }
107 // }
108 return StatusCode::SUCCESS;
109}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
std::vector< const IParticle * > ParticleVector
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
virtual StatusCode modify(xAOD::JetContainer &jets) const override
Loop over calls to modifyJet.
SG::ReadHandleKey< xAOD::IParticleContainer > m_containerKey
name of IParticleContainer w/ particles to associate
Gaudi::Property< std::string > m_assocName
Name of jet attribute providing link between jets and clusters.
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
JetModifierBase(const std::string &myname)
Ctor.
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
Class providing the definition of the 4-vector interface.
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition Jet_v1.cxx:54
void setAssociatedObjects(const std::string &name, const std::vector< const T * > &vec)
set associated objects from a vector of arbitrary object.
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition Jet_v1.cxx:49
int ev
Definition globals.cxx:25
float getBinCenterEta(unsigned int eb)
Definition HIEventDefs.h:40
unsigned int findEtaPhiBin(float eta, float phi)
Definition HIEventDefs.h:52
unsigned int findBinEta(float eta)
Definition HIEventDefs.h:46
constexpr unsigned int numEtaBins()
Definition HIEventDefs.h:19
float getBinCenterPhi(unsigned int pb)
Definition HIEventDefs.h:44
unsigned int findBinPhi(float phi)
Definition HIEventDefs.h:47
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.