ATLAS Offline Software
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 
13 {
14 }
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  {
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 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
HIJetClusterIndexAssociationTool::m_containerKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_containerKey
name of IParticleContainer w/ particles to associate
Definition: HIJetClusterIndexAssociationTool.h:54
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
HI::TowerBins::findBinEta
unsigned int findBinEta(float eta)
Definition: HIEventDefs.h:46
HI::TowerBins::findBinPhi
unsigned int findBinPhi(float phi)
Definition: HIEventDefs.h:47
HIJetClusterIndexAssociationTool::m_assocName
Gaudi::Property< std::string > m_assocName
Name of jet attribute providing link between jets and clusters.
Definition: HIJetClusterIndexAssociationTool.h:57
HIJetClusterIndexAssociationTool::modify
virtual StatusCode modify(xAOD::JetContainer &jets) const override
Loop over calls to modifyJet.
Definition: HIJetClusterIndexAssociationTool.cxx:25
HI::TowerBins::getBinCenterPhi
float getBinCenterPhi(unsigned int pb)
Definition: HIEventDefs.h:44
xAOD::Jet_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: Jet_v1.cxx:54
HI::TowerBins::findEtaPhiBin
unsigned int findEtaPhiBin(float eta, float phi)
Definition: HIEventDefs.h:52
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
HIEventDefs.h
Phi_mpi_pi
__HOSTDEV__ double Phi_mpi_pi(double)
Definition: GeoRegion.cxx:7
python.AtlRunQueryParser.ap
ap
Definition: AtlRunQueryParser.py:826
HIJetClusterIndexAssociationTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: HIJetClusterIndexAssociationTool.cxx:18
ParticleVector
std::vector< const IParticle * > ParticleVector
Definition: JetConstituentFiller.cxx:21
ev
int ev
Definition: globals.cxx:25
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
beamspotman.n
n
Definition: beamspotman.py:731
HI::TowerBins::getBinCenterEta
float getBinCenterEta(unsigned int eb)
Definition: HIEventDefs.h:40
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::ReadHandle::get
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
HIJetClusterIndexAssociationTool::m_DR
Gaudi::Property< float > m_DR
Definition: HIJetClusterIndexAssociationTool.h:61
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::Jet_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: Jet_v1.cxx:49
HI::TowerBins::numEtaBins
constexpr unsigned int numEtaBins()
Definition: HIEventDefs.h:19
xAOD::Jet_v1::setAssociatedObjects
void setAssociatedObjects(const std::string &name, const std::vector< const T * > &vec)
set associated objects from a vector of arbitrary object.
HIJetClusterIndexAssociationTool::HIJetClusterIndexAssociationTool
HIJetClusterIndexAssociationTool(const std::string &t)
Definition: HIJetClusterIndexAssociationTool.cxx:11
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
python.changerun.pv
pv
Definition: changerun.py:81
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
HIJetClusterIndexAssociationTool.h
JetModifierBase
Definition: JetModifierBase.h:22