ATLAS Offline Software
VBFHbbEtaSortingFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // -------------------------------------------------------------
6 // File: src/VBFHbbEtaSortingFilter.cxx
7 // Description: see VBFHbbEtaSortingFilter.h
8 //
9 //
10 // AuthorList:
11 // Yasuyuki Okumura (yasuyuki.okumura@cern.ch)
12 
13 // Header for this module:-
14 
16 #include "GaudiKernel/SystemOfUnits.h"
17 
18 // Other classes used by this class:-
19 #include <cmath>
20 #include <TLorentzVector.h>
21 #include <TMath.h>
22 #include "xAODJet/JetContainer.h"
23 
24 #include <cstdio>
25 
26 //--------------------------------------------------------------------------
27 VBFHbbEtaSortingFilter::VBFHbbEtaSortingFilter(const std::string& name, ISvcLocator* pSvcLocator):
28  GenFilter(name,pSvcLocator), m_total(0), m_passed_multiplicity(0), m_passed_all(0)
29 {
30  declareProperty("Debug", m_debug = false);
31  declareProperty("MinJetPt", m_MinJetPt = 20*Gaudi::Units::GeV);
32  declareProperty("MaxJetEta", m_MaxJetEta = 2.6);
33  declareProperty("TruthJetContainer", m_TruthJetContainerName = "AntiKt4TruthJets");
34  declareProperty("JetTruthLabel", m_JetTruthLabelName="PartonTruthLabelID");
35 }
36 
37 //--------------------------------------------------------------------------
39 
40 }
41 
42 //---------------------------------------------------------------------------
44  msg(MSG:: INFO) << "VBFHbbEtaSortingFilter INITIALISING " << endmsg;
45  msg(MSG:: INFO) << "m_MinJetPt = " << m_MinJetPt << endmsg;
46  msg(MSG:: INFO) << "m_MaxJetEta = " << m_MaxJetEta << endmsg;
47  return StatusCode::SUCCESS;
48 }
49 
50 //---------------------------------------------------------------------------
52  msg(MSG:: INFO) << m_passed_all << " events passed out of " << m_total
53  << " events : efficiency: " << 100.*double(m_passed_all)/double(m_total) << "%" << endmsg;
54  msg(MSG:: INFO) << " for multiplicity requirement " << m_passed_multiplicity << " events passed" << endmsg;
55  return StatusCode::SUCCESS;
56 }
57 
58 //---------------------------------------------------------------------------
60  if (m_debug) printf("dbg> event start %10ld / %10ld / %10ld @ %d \n",
62 
63  m_total++;
64 
65  const xAOD::JetContainer* truthjetTES = 0;
66  if (!evtStore()->contains<xAOD::JetContainer>(m_TruthJetContainerName) ||
67  evtStore()->retrieve(truthjetTES, m_TruthJetContainerName).isFailure() || !truthjetTES) {
68  ATH_MSG_ERROR("No xAOD::JetContainer found in StoreGate with key " << m_TruthJetContainerName);
69  setFilterPassed(false);
70  return StatusCode::SUCCESS;
71  }
72 
73  // step (1)
74  // require four jets
75  std::multimap<double, const xAOD::Jet*, std::greater<double> > jets_ptordering; // high pT to small pT
76 
77  for (const xAOD::Jet* jet : *truthjetTES) {
78  if (TMath::Abs( jet->eta() ) > m_MaxJetEta) continue;
79  if (jet->pt() < m_MinJetPt) continue;
80 
81  jets_ptordering.insert(std::pair<double, const xAOD::Jet*> (jet->pt(), jet));
82  }
83 
84  if (m_debug) printf("dbg> %d @ %d \n", (int)jets_ptordering.size(), __LINE__);
85 
86  if (jets_ptordering.size() < 4) {
87  setFilterPassed(false);
88  return StatusCode::SUCCESS;
89  }
90 
92 
93  // step (2)
94  // consider eta sorting with the leading four jets
95  std::multimap<double, const xAOD::Jet*> four_jets_etaordering;
96  std::multimap<double, const xAOD::Jet*>::const_iterator ite_c;
97  std::multimap<double, const xAOD::Jet*>::const_iterator ite_e;
98  ite_c = jets_ptordering.begin();
99  ite_e = jets_ptordering.end();
100 
101  for (int iJet=0; ite_c!=ite_e and iJet<4; ++ite_c, ++iJet) {
102  four_jets_etaordering.insert(std::pair<double, const xAOD::Jet*> ( (ite_c->second)->eta(), (ite_c->second)));
103  if (m_debug) printf("dbg> ijet=%2d %10.1f @ %d \n", iJet, (ite_c->second)->pt(), __LINE__);
104  }
105  if (four_jets_etaordering.size() < 4){
106  setFilterPassed(false);
107  return StatusCode::SUCCESS;
108  }
109  ite_c = four_jets_etaordering.begin();
110  const xAOD::Jet* forward_jet_1 = (ite_c)->second; ++ite_c; // 1st jet in eta ordering
111  const xAOD::Jet* central_jet_1 = (ite_c)->second; ++ite_c; // 2nd jet in eta ordering
112  const xAOD::Jet* central_jet_2 = (ite_c)->second; ++ite_c; // 3rd jet in eta ordering
113  const xAOD::Jet* forward_jet_2 = (ite_c)->second; // 4th jet in eta ordering
114 
115  int forward_jet_truth_label_1 = 0;
116  forward_jet_1->getAttribute(m_JetTruthLabelName, forward_jet_truth_label_1);
117  int central_jet_truth_label_1 = 0;
118  central_jet_1->getAttribute(m_JetTruthLabelName, central_jet_truth_label_1);
119  int central_jet_truth_label_2 = 0;
120  central_jet_2->getAttribute(m_JetTruthLabelName, central_jet_truth_label_2);
121  int forward_jet_truth_label_2 = 0;
122  forward_jet_2->getAttribute(m_JetTruthLabelName, forward_jet_truth_label_2);
123 
124  if (m_debug) printf("dbg> eta1=%5.1f (%3d) eta2=%5.1f (%3d)"
125  "eta3=%5.1f (%3d) eta4=%5.1f (%3d) @ %d \n",
126  forward_jet_1->eta(), forward_jet_truth_label_1,
127  central_jet_1->eta(), central_jet_truth_label_1,
128  central_jet_2->eta(), central_jet_truth_label_2,
129  forward_jet_2->eta(), forward_jet_truth_label_2,
130  __LINE__);
131 
132  if ( not (TMath::Abs(central_jet_truth_label_1)==5 and TMath::Abs(central_jet_truth_label_2)==5) ) {
133  setFilterPassed(false);
134  return StatusCode::SUCCESS;
135  }
136 
137  if (m_debug) printf("dbg> pass all selection @ %d \n", __LINE__);
138  m_passed_all++;
139  setFilterPassed(true);
140  return StatusCode::SUCCESS;
141 }
142 
143 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
VBFHbbEtaSortingFilter::VBFHbbEtaSortingFilter
VBFHbbEtaSortingFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: VBFHbbEtaSortingFilter.cxx:27
VBFHbbEtaSortingFilter::m_MaxJetEta
double m_MaxJetEta
Definition: VBFHbbEtaSortingFilter.h:36
VBFHbbEtaSortingFilter::m_debug
bool m_debug
Definition: VBFHbbEtaSortingFilter.h:34
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
VBFHbbEtaSortingFilter::m_JetTruthLabelName
std::string m_JetTruthLabelName
Definition: VBFHbbEtaSortingFilter.h:38
VBFHbbEtaSortingFilter::m_MinJetPt
double m_MinJetPt
Definition: VBFHbbEtaSortingFilter.h:35
VBFHbbEtaSortingFilter::filterFinalize
virtual StatusCode filterFinalize()
Definition: VBFHbbEtaSortingFilter.cxx:51
VBFHbbEtaSortingFilter.h
VBFHbbEtaSortingFilter::m_total
long m_total
Definition: VBFHbbEtaSortingFilter.h:40
xAOD::Jet_v1::getAttribute
bool getAttribute(AttributeID type, T &value) const
Retrieve attribute moment by enum.
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
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
VBFHbbEtaSortingFilter::m_TruthJetContainerName
std::string m_TruthJetContainerName
Definition: VBFHbbEtaSortingFilter.h:37
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
VBFHbbEtaSortingFilter::filterInitialize
virtual StatusCode filterInitialize()
Definition: VBFHbbEtaSortingFilter.cxx:43
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
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
VBFHbbEtaSortingFilter::filterEvent
virtual StatusCode filterEvent()
Definition: VBFHbbEtaSortingFilter.cxx:59
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
VBFHbbEtaSortingFilter::m_passed_all
long m_passed_all
Definition: VBFHbbEtaSortingFilter.h:42
JetContainer.h
VBFHbbEtaSortingFilter::m_passed_multiplicity
long m_passed_multiplicity
Definition: VBFHbbEtaSortingFilter.h:41
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
VBFHbbEtaSortingFilter::~VBFHbbEtaSortingFilter
virtual ~VBFHbbEtaSortingFilter()
Definition: VBFHbbEtaSortingFilter.cxx:38