Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
JetBalancePFlowJvtTool.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // JetBalancePFlowJvtTool.cxx
8 // Implementation file for class JetBalancePFlowJvtTool
9 // Author: Eimear Conroy <eimear.isobel.conroy@cern.ch>
10 // Inherits from JetForwardPFlowJvtTool - Author: Anastasia Kotsokechagia <anastasia.kotsokechagia@cern.ch>
12 
13 // JetBalancePFlowJvtTool includes
15 
16 // Jet EDM
17 #include "xAODJet/JetAttributes.h"
18 
19 // FastJet
20 #include "fastjet/ClusterSequence.hh"
21 #include "fastjet/ClusterSequenceArea.hh"
22 #include <fastjet/AreaDefinition.hh>
23 
24 // Jet
26 
28  // Public methods:
30 
31  // Constructors
35  m_bjvtThresh = 0;
36  }
37 
38  // Destructor
41  = default;
42 
43  // Athena algtool's Hooks
46  {
47  ATH_MSG_INFO ("Initializing " << name() << "...");
48 
49  if(m_FEKey.empty()){
50  ATH_MSG_ERROR("Flow Element container is empty");
51  return StatusCode::FAILURE;
52  }
53 
55 
60 
65 
66  return StatusCode::SUCCESS;
67  }
68 
70  std::vector<TVector2> pileupMomenta;
71  pileupMomenta=calculateVertexMomenta(&jetCont,m_pvind, m_vertices);
74  if(pileupMomenta.empty()) {
75  ATH_MSG_DEBUG( "pileupMomenta is empty, this can happen for events with no PU vertices."
76  <<" bJVT won't be computed for this event and will be set to 0 instead." );
77  for(const xAOD::Jet* jetC : jetCont) {
78  bjvtHandle(*jetC) = 1;
79  bjvtRawHandle(*jetC) = 0;
80  }
81  return StatusCode::SUCCESS;
82  }
83 
84  for(const xAOD::Jet* jetC : jetCont) {
85  bjvtHandle(*jetC) = 1;
86  bjvtRawHandle(*jetC) = 0;
87 
88  if (isCentralJet(jetC)){
89  double bjvt = getFJVT(jetC,pileupMomenta); //Same projection function as fJVT
90  if (bjvt>m_bjvtThresh) bjvtHandle(*jetC) = 0;
91  bjvtRawHandle(*jetC) = bjvt;
92  }
93  }
94  return StatusCode::SUCCESS;
95  }
96 
97  //Redefined here: Using isQCDPUJet()
99  int pvind, int vertices) const {
100  std::vector<TVector2> pileupMomenta;
101  // -- Retrieve PV index if not provided by user
102  const std::size_t pv_index = (pvind==-1) ? getPV() : std::size_t(pvind);
103 
105 
106  for(const xAOD::Vertex* vx: *vxContHandle) {
107  if(vx->vertexType()!=xAOD::VxType::PriVtx && vx->vertexType()!=xAOD::VxType::PileUp) continue;
108  if(vx->index()==(size_t)pv_index) continue;
109 
110  TString jname = m_jetsName.value();
111  jname += vx->index();
112 
113  pflow::puJets vertjets = buildPFlowPUjets(*vx);
114  if( !vertjets.jetCont || !vertjets.jetAuxCont ){
115  ATH_MSG_WARNING(" Some issue appeared while building the pflow pileup jets for vertex "
116  << vx->index() << " (vxType = " << vx->vertexType()<<" )!" );
117  return pileupMomenta;
118  }
119 
120  TVector2 vertex_met;
121  for( const xAOD::Jet *jet : *(vertjets.jetCont) ) {
122 
123  // Remove jets which are close to hs
124  if (!m_includePV && hasCloseByHSjet(jet,pjets)) continue;
125 
126  // Calculate vertex missing momentum
127  if (isQCDPUJet(jet) && getRpt(jet)> m_rptCut)
128  {
129  vertex_met += TVector2(jet->pt()*cos(jet->phi()),jet->pt()*sin(jet->phi()) ) ;
130  }
131  else{
132  vertex_met += TVector2(jet->jetP4(m_jetchargedp4).Pt()*cos(jet->jetP4(m_jetchargedp4).Phi()),
133  jet->jetP4(m_jetchargedp4).Pt()*sin(jet->jetP4(m_jetchargedp4).Phi()) );
134  }
135  }
136 
137  pileupMomenta.push_back(vertex_met);
138  if(vertices!=-1 && int(vx->index())==vertices) break;
139  }
140  return pileupMomenta;
141  }
142 
144  if (std::abs(jet->eta())>m_etaThresh) return false; //Must be central
145  if (jet->pt()<m_QCDPUMinPt || (m_QCDPUMaxPt>0 && jet->pt()>m_QCDPUMaxPt) ) return false;
146  //Other selections? EMPTopo studies included cuts on JVT and JVF
147  return true;
148  }
149 
150  //Redefined here: Separately label QCD and stochastic PU
152  const xAOD::JetContainer *itpujets,const xAOD::JetContainer *ootpujets) {
153  //truthJets container taken to be truth HS - @to-Do double check this
154  //In-time and out-of-time PU truth jets given in AODs as separate containers
158 
159  for(const xAOD::Jet *jet : *jets) {
160  bool ishs = false;
161  bool ispu = true;
162 
163  bool isqcdpu = false;
164  bool isstochpu = true; //Default value to make logic work - changed below
165 
166  for(const xAOD::Jet *tjet : *truthJets) {
167  if (tjet->p4().DeltaR(jet->p4())<0.3 && tjet->pt()>10e3) ishs = true;
168  if (tjet->p4().DeltaR(jet->p4())<0.6 && tjet->pt()>4e3) ispu = false;
169  }
170 
171  if (ispu){
172  //Need to check both containers
173  for(const xAOD::Jet *itpujet : *itpujets){
174  if (itpujet->p4().DeltaR(jet->p4())<0.3 && itpujet->pt()>10e3) isqcdpu = true;
175  if (itpujet->p4().DeltaR(jet->p4())<0.6 && itpujet->pt()>10e3) isstochpu = false;
176  }
177  for(const xAOD::Jet *ootpujet : *ootpujets){
178  if (ootpujet->p4().DeltaR(jet->p4())<0.3 && ootpujet->pt()>10e3) isqcdpu = true;
179  if (ootpujet->p4().DeltaR(jet->p4())<0.6 && ootpujet->pt()>10e3) isstochpu = false;
180  }
181  }
182 
183  else {
184  isstochpu = false; //Can't be labelled stochastic PU if jet is not determined to be PU
185  }
186 
187  isHSHandle(*jet)=ishs;
188  isQCDPUHandle(*jet)=isqcdpu;
189  isStochPUHandle(*jet)=isstochpu;
190  }
191 
192  return StatusCode::SUCCESS;
193  }
JetBalancePFlowJvtTool::JetBalancePFlowJvtTool
JetBalancePFlowJvtTool(const std::string &name)
Constructor with parameters:
Definition: JetBalancePFlowJvtTool.cxx:33
pflow::puJets::jetAuxCont
std::shared_ptr< xAOD::JetAuxContainer > jetAuxCont
Definition: JetForwardPFlowJvtTool.h:85
JetBalancePFlowJvtTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: JetBalancePFlowJvtTool.cxx:45
JetBalancePFlowJvtTool::m_isStochPUKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_isStochPUKey
Definition: JetBalancePFlowJvtTool.h:129
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
JetForwardPFlowJvtTool::hasCloseByHSjet
bool hasCloseByHSjet(const xAOD::Jet *jet, const xAOD::JetContainer *pjets) const
Definition: JetForwardPFlowJvtTool.cxx:178
JetForwardPFlowJvtTool::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition: JetForwardPFlowJvtTool.h:126
JetForwardPFlowJvtTool::m_pvind
Gaudi::Property< int > m_pvind
Definition: JetForwardPFlowJvtTool.h:131
JetAttributes.h
JetBalancePFlowJvtTool::m_QCDPUMinPt
Gaudi::Property< float > m_QCDPUMinPt
Definition: JetBalancePFlowJvtTool.h:122
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
JetForwardPFlowJvtTool::m_includePV
Gaudi::Property< bool > m_includePV
Definition: JetForwardPFlowJvtTool.h:133
JetForwardPFlowJvtTool
Definition: JetForwardPFlowJvtTool.h:91
JetForwardPFlowJvtTool::m_vertices
Gaudi::Property< int > m_vertices
Definition: JetForwardPFlowJvtTool.h:132
JetBalancePFlowJvtTool::tagTruth
StatusCode tagTruth(const xAOD::JetContainer *jets, const xAOD::JetContainer *truthJets, const xAOD::JetContainer *itpujets, const xAOD::JetContainer *ootpujets)
Definition: JetBalancePFlowJvtTool.cxx:151
JetForwardPFlowJvtTool::m_jetchargedp4
Gaudi::Property< std::string > m_jetchargedp4
Definition: JetForwardPFlowJvtTool.h:128
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
pflow::puJets::jetCont
std::shared_ptr< xAOD::JetContainer > jetCont
Definition: JetForwardPFlowJvtTool.h:84
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
JetBalancePFlowJvtTool.h
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
JetBalancePFlowJvtTool::~JetBalancePFlowJvtTool
virtual ~JetBalancePFlowJvtTool()
Destructor:
JetBalancePFlowJvtTool::decorate
virtual StatusCode decorate(const xAOD::JetContainer &jetCont) const override
Decorate a jet collection without otherwise modifying it.
Definition: JetBalancePFlowJvtTool.cxx:69
JetForwardPFlowJvtTool::getPV
std::size_t getPV() const
Definition: JetForwardPFlowJvtTool.cxx:377
JetForwardPFlowJvtTool::m_jetsName
Gaudi::Property< std::string > m_jetsName
Definition: JetForwardPFlowJvtTool.h:127
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:572
JetBalancePFlowJvtTool::m_bjvtRawKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_bjvtRawKey
Definition: JetBalancePFlowJvtTool.h:127
JetForwardPFlowJvtTool::m_vxContKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vxContKey
Definition: JetForwardPFlowJvtTool.h:152
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
JetBalancePFlowJvtTool::m_isQCDPUKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_isQCDPUKey
Definition: JetBalancePFlowJvtTool.h:128
JetBalancePFlowJvtTool::isQCDPUJet
bool isQCDPUJet(const xAOD::Jet *jet) const
Definition: JetBalancePFlowJvtTool.cxx:143
JetForwardPFlowJvtTool::m_rptCut
Gaudi::Property< double > m_rptCut
Definition: JetForwardPFlowJvtTool.h:140
JetForwardPFlowJvtTool::isCentralJet
bool isCentralJet(const xAOD::Jet *jet) const
Definition: JetForwardPFlowJvtTool.cxx:365
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
JetBalancePFlowJvtTool::m_bjvtThresh
float m_bjvtThresh
Definition: JetBalancePFlowJvtTool.h:131
JetForwardPFlowJvtTool::m_FEKey
SG::ReadHandleKey< xAOD::FlowElementContainer > m_FEKey
Definition: JetForwardPFlowJvtTool.h:154
xAOD::VxType::PileUp
@ PileUp
Pile-up vertex.
Definition: TrackingPrimitives.h:574
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
JetBalancePFlowJvtTool::m_bjvtKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_bjvtKey
Definition: JetBalancePFlowJvtTool.h:126
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
pflow::puJets
Definition: JetForwardPFlowJvtTool.h:83
JetForwardPFlowJvtTool::getRpt
double getRpt(const xAOD::Jet *jet) const
Definition: JetForwardPFlowJvtTool.cxx:371
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
JetForwardPFlowJvtTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: JetForwardPFlowJvtTool.cxx:44
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
JetForwardPFlowJvtTool::m_isHSKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_isHSKey
Definition: JetForwardPFlowJvtTool.h:163
JetForwardPFlowJvtTool::m_etaThresh
Gaudi::Property< double > m_etaThresh
Definition: JetForwardPFlowJvtTool.h:134
JetBalancePFlowJvtTool::m_QCDPUMaxPt
Gaudi::Property< float > m_QCDPUMaxPt
Definition: JetBalancePFlowJvtTool.h:123
JetBalancePFlowJvtTool::calculateVertexMomenta
virtual std::vector< TVector2 > calculateVertexMomenta(const xAOD::JetContainer *jets, int pvind, int vertices) const override
Definition: JetBalancePFlowJvtTool.cxx:98
JetFromPseudojet.h
JetForwardPFlowJvtTool::buildPFlowPUjets
pflow::puJets buildPFlowPUjets(const xAOD::Vertex &vx) const
Definition: JetForwardPFlowJvtTool.cxx:188
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
JetForwardPFlowJvtTool::getFJVT
float getFJVT(const xAOD::Jet *jet, const std::vector< TVector2 > &pileupMomenta) const
Definition: JetForwardPFlowJvtTool.cxx:123