ATLAS Offline Software
KinkTrkZeeTagTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // KinkTrkZeeTagTool.cxx, (c) ATLAS Detector software
8 // Author: Shimpei Yamamoto (shimpei.yamamoto@cern.ch)
9 
11 #include <vector>
12 #include <string>
13 
14 // Constructor
16  const std::string& n,
17  const IInterface* p):
18  AthAlgTool(t, n, p),
19  m_trigDecisionTool("Trig::TrigDecisionTool/TrigDecisionTool"),
20  m_trigMatchTool("TrigMatchTool/TrigMatchTool"),
21  m_trigNames(std::vector<std::string>()),
22  m_trigMatchDeltaR(0.1),
23  m_doTrigMatch(false),
24  m_electronIDKeys(std::vector<std::string>()),
25  m_electronPtCut(0),
26  m_electronEtaMax(9999),
27  m_clusterEtCut(0),
28  m_clusterEtaMax(2.8),
29  m_diEleMassLow(50.),
30  m_diEleMassHigh(-1),
31  m_dPhiMax(10)
32 {
33  declareInterface<DerivationFramework::IAugmentationTool>(this);
34  declareProperty("TriggerDecisionTool", m_trigDecisionTool);
35  declareProperty("TriggerMatchTool", m_trigMatchTool);
36  declareProperty("Triggers", m_trigNames);
37  declareProperty("TriggerMatchDeltaR", m_trigMatchDeltaR);
38  declareProperty("RequireTriggerMatch", m_doTrigMatch);
39  declareProperty("ElectronIDKeys", m_electronIDKeys),
40  declareProperty("ElectronPtMin", m_electronPtCut);
41  declareProperty("ElectronEtaMax", m_electronEtaMax);
42  declareProperty("ClusterEtMin", m_clusterEtCut);
43  declareProperty("ClusterEtaMax", m_clusterEtaMax);
44  declareProperty("DiEleMassLow", m_diEleMassLow);
45  declareProperty("DiEleMassHigh", m_diEleMassHigh);
46  declareProperty("DeltaPhiMax", m_dPhiMax);
47 }
48 
49 
50 // Destructor
52 }
53 
54 
55 // Athena initialize and finalize
57 {
58  ATH_MSG_VERBOSE("initialize() ...");
59 
60  // trigger decision tool
61  if (m_trigNames.size()>0) {
62  if (m_trigDecisionTool.retrieve().isFailure()) {
63  ATH_MSG_FATAL("Failed to retrieve tool: " << m_trigDecisionTool);
64  return StatusCode::FAILURE;
65  }
66  ATH_MSG_INFO("TriggerDecisionTool: " << m_trigDecisionTool);
67 
68  if (m_trigMatchTool.empty()) {
69  ATH_MSG_FATAL("TrigMatchTool is not specified.");
70  return StatusCode::FAILURE;
71  }
72  CHECK(m_trigMatchTool.retrieve());
73  ATH_MSG_INFO("TrgMatchTool retrived successfully");
74  }
75 
76  ATH_CHECK(m_electronSGKey.initialize());
77  ATH_CHECK(m_clusterSGKey.initialize());
78  ATH_CHECK(m_KinkTrkDiEleMassKey.initialize());
79  ATH_CHECK(m_KinkTrkProbeEleEtKey.initialize());
80 
81  return StatusCode::SUCCESS;
82 }
83 
84 
86 {
87  ATH_MSG_VERBOSE("finalize() ...");
88  return StatusCode::SUCCESS;
89 }
90 
91 
92 
93 // Augmentation
95 {
96  SG::WriteHandle< std::vector<float> > diEleMass(m_KinkTrkDiEleMassKey);
97  ATH_CHECK(diEleMass.record(std::make_unique< std::vector<float> >()));
98 
99  SG::WriteHandle< std::vector<float> > probeEleEt(m_KinkTrkProbeEleEtKey);
100  ATH_CHECK(probeEleEt.record(std::make_unique< std::vector<float> >()));
101 
104 
105  for (const auto ele: *electrons) {
106  if (!checkTagElectron(ele)) continue;
107  for (const auto clu: *clusters) {
108  if (!checkCluster(clu)) continue;
109  if (!checkEleClusPair(ele, clu)) continue;
110  diEleMass->push_back((ele->p4()+clu->p4()).M());
111  probeEleEt->push_back(clu->et());
112  }
113  }
114 
115  return StatusCode::SUCCESS;
116 }
117 
118 
119 bool DerivationFramework::KinkTrkZeeTagTool::passTrigger(const std::vector<std::string>& triggers) const
120 {
121  for (unsigned int i=0; i<triggers.size(); i++) {
122  if (m_trigDecisionTool->isPassed(triggers[i])) return true;
123  }
124  return false;
125 }
126 
127 
129 {
130  if (!passElectronQuality(ele)) return false;
131  if (m_doTrigMatch) {
132  if (!passElectronTrigMatch(ele, m_trigNames)) return false;
133  }
134  return true;
135 }
136 
137 
139 {
140  if (!passClusterQuality(clu)) return false;
141  return true;
142 }
143 
144 
146 {
147  if (std::abs(ele->p4().DeltaPhi(clu->p4())) > m_dPhiMax) return false;
148  float mass = (ele->p4()+clu->p4()).M();
149  if (mass < m_diEleMassLow) return false;
150  if (mass > m_diEleMassHigh) return false;
151  return true;
152 }
153 
154 
156 {
157  if (ele->pt() < m_electronPtCut) return false;
158  if (std::abs(ele->eta()) > m_electronEtaMax) return false;
159  bool passID(false);
160  for (unsigned int i=0; i<m_electronIDKeys.size(); i++) {
161  if (ele->passSelection(passID, m_electronIDKeys[i])) {
162  if (passID) break;
163  } else {
164  ATH_MSG_WARNING("Cannot find the electron quality flag " << m_electronIDKeys[i]);
165  }
166  }
167  if (!passID) return false;
168  return true;
169 }
170 
171 
173 {
174  if (clu->et() < m_clusterEtCut) return false;
175  if (std::abs(clu->eta()) > m_clusterEtaMax) return false;
176  return true;
177 }
178 
179 
180 // checking the muon trigger matching
181 bool DerivationFramework::KinkTrkZeeTagTool::passElectronTrigMatch(const xAOD::Electron *ele, const std::vector<std::string>& triggers) const
182 {
183  for (unsigned int i=0; i<triggers.size(); i++) {
184  if (m_trigMatchTool->chainPassedByObject<TrigMatch::TrigElectronEF, xAOD::Electron>(ele, triggers[i], m_trigMatchDeltaR)) return true;
185  }
186  return false;
187 }
188 
DerivationFramework::KinkTrkZeeTagTool::finalize
StatusCode finalize()
Definition: KinkTrkZeeTagTool.cxx:85
DerivationFramework::KinkTrkZeeTagTool::m_doTrigMatch
bool m_doTrigMatch
Definition: KinkTrkZeeTagTool.h:64
DerivationFramework::KinkTrkZeeTagTool::passElectronTrigMatch
bool passElectronTrigMatch(const xAOD::Electron *ele, const std::vector< std::string > &triggers) const
Definition: KinkTrkZeeTagTool.cxx:181
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DerivationFramework::KinkTrkZeeTagTool::m_clusterEtaMax
float m_clusterEtaMax
Definition: KinkTrkZeeTagTool.h:73
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::KinkTrkZeeTagTool::m_clusterEtCut
float m_clusterEtCut
Definition: KinkTrkZeeTagTool.h:72
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DerivationFramework::KinkTrkZeeTagTool::m_diEleMassHigh
float m_diEleMassHigh
Definition: KinkTrkZeeTagTool.h:76
DerivationFramework::KinkTrkZeeTagTool::initialize
StatusCode initialize()
Definition: KinkTrkZeeTagTool.cxx:56
DerivationFramework::KinkTrkZeeTagTool::m_trigNames
std::vector< std::string > m_trigNames
Definition: KinkTrkZeeTagTool.h:62
DerivationFramework::KinkTrkZeeTagTool::m_electronEtaMax
float m_electronEtaMax
Definition: KinkTrkZeeTagTool.h:69
xAOD::CaloCluster_v1::et
double et() const
Definition: CaloCluster_v1.h:856
DerivationFramework::KinkTrkZeeTagTool::passClusterQuality
bool passClusterQuality(const xAOD::CaloCluster *clu) const
Definition: KinkTrkZeeTagTool.cxx:172
xAOD::Egamma_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle as a TLoretzVector.
Definition: Egamma_v1.cxx:98
DerivationFramework::KinkTrkZeeTagTool::~KinkTrkZeeTagTool
~KinkTrkZeeTagTool()
Destructor.
Definition: KinkTrkZeeTagTool.cxx:51
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
python.TrigTLAMonitorAlgorithm.triggers
triggers
Definition: TrigTLAMonitorAlgorithm.py:196
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
dqt_zlumi_pandas.mass
mass
Definition: dqt_zlumi_pandas.py:170
DerivationFramework::KinkTrkZeeTagTool::checkTagElectron
bool checkTagElectron(const xAOD::Electron *ele) const
Definition: KinkTrkZeeTagTool.cxx:128
egamma
Definition: egamma.h:58
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
DerivationFramework::KinkTrkZeeTagTool::m_trigMatchTool
ToolHandle< TrigMatchTool > m_trigMatchTool
Definition: KinkTrkZeeTagTool.h:61
DerivationFramework::KinkTrkZeeTagTool::KinkTrkZeeTagTool
KinkTrkZeeTagTool(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: KinkTrkZeeTagTool.cxx:15
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
lumiFormat.i
int i
Definition: lumiFormat.py:92
DerivationFramework::KinkTrkZeeTagTool::passElectronQuality
bool passElectronQuality(const xAOD::Electron *ele) const
Definition: KinkTrkZeeTagTool.cxx:155
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
vector
Definition: MultiHisto.h:13
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::KinkTrkZeeTagTool::m_trigDecisionTool
ToolHandle< Trig::TrigDecisionTool > m_trigDecisionTool
Definition: KinkTrkZeeTagTool.h:60
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DerivationFramework::KinkTrkZeeTagTool::m_electronIDKeys
std::vector< std::string > m_electronIDKeys
Definition: KinkTrkZeeTagTool.h:67
DerivationFramework::KinkTrkZeeTagTool::addBranches
virtual StatusCode addBranches() const
Check that the current event passes this filter.
Definition: KinkTrkZeeTagTool.cxx:94
xAOD::CaloCluster_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: CaloCluster_v1.cxx:465
DerivationFramework::KinkTrkZeeTagTool::checkCluster
bool checkCluster(const xAOD::CaloCluster *clu) const
Definition: KinkTrkZeeTagTool.cxx:138
DerivationFramework::KinkTrkZeeTagTool::passTrigger
bool passTrigger(const std::vector< std::string > &triggers) const
Definition: KinkTrkZeeTagTool.cxx:119
xAOD::Electron_v1
Definition: Electron_v1.h:34
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
DerivationFramework::KinkTrkZeeTagTool::m_dPhiMax
float m_dPhiMax
Definition: KinkTrkZeeTagTool.h:77
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
DerivationFramework::KinkTrkZeeTagTool::checkEleClusPair
bool checkEleClusPair(const xAOD::Electron *ele, const xAOD::CaloCluster *clu) const
Definition: KinkTrkZeeTagTool.cxx:145
xAOD::Egamma_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: Egamma_v1.cxx:65
DerivationFramework::KinkTrkZeeTagTool::m_electronPtCut
float m_electronPtCut
Definition: KinkTrkZeeTagTool.h:68
xAOD::Egamma_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: Egamma_v1.cxx:70
AthAlgTool
Definition: AthAlgTool.h:26
DerivationFramework::KinkTrkZeeTagTool::m_trigMatchDeltaR
float m_trigMatchDeltaR
Definition: KinkTrkZeeTagTool.h:63
KinkTrkZeeTagTool.h
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
xAOD::Egamma_v1::passSelection
bool passSelection(bool &value, const std::string &menu) const
Check if the egamma object pass a selection menu (using the name) If the menu decision is stored in t...
DerivationFramework::KinkTrkZeeTagTool::m_diEleMassLow
float m_diEleMassLow
Definition: KinkTrkZeeTagTool.h:75