ATLAS Offline Software
TruthJetFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "GaudiKernel/PhysicalConstants.h"
7 #include "xAODJet/JetContainer.h"
8 #include "TMath.h"
9 
10 TruthJetFilter::TruthJetFilter(const std::string& name, ISvcLocator* pSvcLocator)
11  : GenFilter(name,pSvcLocator)
12 {
13  declareProperty("Njet",m_Njet = -1.);
15  declareProperty("NjetMaxEta",m_NjetMaxEta = 2.);
17  declareProperty("applyDeltaPhiCut",m_applyDeltaPhiCut = false);
18  declareProperty("MinDeltaPhi",m_MinDeltaPhi = 0.2);
19  declareProperty("TruthJetContainer", m_TruthJetContainerName = "AntiKt4TruthJets");
20 }
21 
22 
24  ATH_MSG_INFO("Njet=" << m_Njet);
25  ATH_MSG_INFO("NjetMinPt=" << m_NjetMinPt);
26  ATH_MSG_INFO("NjetMaxEta=" << m_NjetMaxEta);
27  ATH_MSG_INFO("jet_pt1=" << m_jet_pt1);
28  ATH_MSG_INFO("applyDeltaPhiCut=" << m_applyDeltaPhiCut);
29  if (m_applyDeltaPhiCut) ATH_MSG_INFO("MinDeltaPhi=" << m_MinDeltaPhi);
30  ATH_MSG_INFO("xAOD::JetContainer=" << m_TruthJetContainerName);
31  return StatusCode::SUCCESS;
32 }
33 
34 
36  const xAOD::JetContainer* truthjetTES = nullptr;
38  ATH_MSG_DEBUG("xAOD::JetContainer size = " << (*truthjetTES).size());
39 
40  int Njet=0;
41  int Njet_pt1=0;
42  std::vector<const xAOD::Jet*> listOfSelectedJets;
43  const xAOD::Jet* leadingJet = nullptr;
44  for (xAOD::JetContainer::const_iterator it_truth = (*truthjetTES).begin(); it_truth != (*truthjetTES).end() ; ++it_truth) {
45  if ( (*it_truth)->pt() > m_NjetMinPt && std::abs( (*it_truth)->eta() ) < m_NjetMaxEta ) {
46  Njet++;
47  ATH_MSG_DEBUG("Jet pt " << (*it_truth)->pt()/Gaudi::Units::GeV);
48  if (m_applyDeltaPhiCut) listOfSelectedJets.push_back(*it_truth);
49  }
50  if ( (*it_truth)->pt() > m_jet_pt1 && std::abs( (*it_truth)->eta() ) < m_NjetMaxEta ) {
51  Njet_pt1++;
52  ATH_MSG_DEBUG("High jet pt " << (*it_truth)->pt()/Gaudi::Units::GeV);
53  if (m_applyDeltaPhiCut && (!leadingJet || (*it_truth)->pt() > leadingJet->pt())) {
54  leadingJet = (*it_truth);
55  }
56  }
57  }
58 
59  if (Njet >= m_Njet && Njet_pt1 > 0) {
60  // Compute deltaPhi(leadingjet, jet)
61  bool passDeltaPhi = true;
62  if (m_applyDeltaPhiCut) {
63  for (unsigned int iJet = 0; iJet < m_Njet; iJet++) {
64  if (listOfSelectedJets[iJet] == leadingJet) continue;
65  double deltaPhi = leadingJet->p4().DeltaPhi((listOfSelectedJets[iJet])->p4());
66  double dPi = TMath::Pi() - std::abs(deltaPhi);
67  ATH_MSG_DEBUG("deltaPhi = " << deltaPhi << ", dPi = " << dPi <<
68  " between leading jet(pt=" << leadingJet->pt() << ",eta=" << leadingJet->eta() <<
69  ") and jet(pt=" << (listOfSelectedJets[iJet])->pt() <<
70  ",eta=" << (listOfSelectedJets[iJet])->eta() << ")");
71  if (dPi < m_MinDeltaPhi) passDeltaPhi = false;
72  }
73  }
74 
75  if (!m_applyDeltaPhiCut || passDeltaPhi) {
76  return StatusCode::SUCCESS;
77  }
78  }
79  setFilterPassed(false);
80  return StatusCode::SUCCESS;
81 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TruthJetFilter::m_Njet
double m_Njet
Definition: TruthJetFilter.h:22
TruthJetFilter.h
TruthJetFilter::filterEvent
virtual StatusCode filterEvent()
Definition: TruthJetFilter.cxx:35
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TruthJetFilter::m_jet_pt1
double m_jet_pt1
Definition: TruthJetFilter.h:25
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
TruthJetFilter::filterInitialize
virtual StatusCode filterInitialize()
Definition: TruthJetFilter.cxx:23
TruthJetFilter::TruthJetFilter
TruthJetFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TruthJetFilter.cxx:10
TruthJetFilter::m_NjetMaxEta
double m_NjetMaxEta
Definition: TruthJetFilter.h:24
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
TruthJetFilter::m_NjetMinPt
double m_NjetMinPt
Definition: TruthJetFilter.h:23
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
TruthJetFilter::m_TruthJetContainerName
std::string m_TruthJetContainerName
Definition: TruthJetFilter.h:29
TruthJetFilter::m_MinDeltaPhi
double m_MinDeltaPhi
Definition: TruthJetFilter.h:27
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::Jet_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: Jet_v1.cxx:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
xAOD::Jet_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: Jet_v1.cxx:71
TruthJetFilter::m_applyDeltaPhiCut
bool m_applyDeltaPhiCut
Definition: TruthJetFilter.h:26
JetContainer.h
xAOD::Jet_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition: Jet_v1.cxx:44
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30