ATLAS Offline Software
Loading...
Searching...
No Matches
DiTauConstituentFinder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7#include "fastjet/PseudoJet.hh"
8
10 const std::string& name,
11 const IInterface * parent) :
12 DiTauToolBase(type, name, parent)
13{
14 declareInterface<DiTauToolBase > (this);
15}
16
17
19
20
22 return StatusCode::SUCCESS;
23}
24
25
27 const EventContext& /*ctx*/) const {
28
29 ATH_MSG_DEBUG("execute DiTauConstituentFinder...");
30
31 // get ditau and its seed jet
32
33 xAOD::DiTauJet* pDiTau = data->xAODDiTau;
34 if (!pDiTau) {
35 ATH_MSG_ERROR("no di-tau candidate given");
36 return StatusCode::FAILURE;
37 }
38
39 const xAOD::Jet* pSeed = data->seed;
40 if (!pSeed) {
41 ATH_MSG_WARNING("No jet seed given.");
42 return StatusCode::FAILURE;
43 }
44
45 std::vector<fastjet::PseudoJet> vSubjets = data->subjets;
46 if (vSubjets.empty()) {
47 ATH_MSG_WARNING("No subjets given. Continue without cluster information.");
48 return StatusCode::SUCCESS;
49 }
50
51 std::vector<TLorentzVector> subjetConstituentsP4;
52 // loop over seed jet constituents
53 for (const auto *const seedConst: pSeed->getConstituents()) {
54 TLorentzVector tmp_const_p4;
55 if (m_useRawConstit) {
56 // cast jet constituent to cluster object
57 const xAOD::CaloCluster* seedConstCluster = dynamic_cast<const xAOD::CaloCluster*>( seedConst->rawConstituent() );
58 if(seedConstCluster == nullptr) continue;
59 tmp_const_p4.SetPtEtaPhiM(seedConstCluster->pt(), seedConstCluster->eta(), seedConstCluster->phi(), seedConstCluster->m());
60 } else {
61 tmp_const_p4.SetPtEtaPhiM(seedConst->pt(), seedConst->eta(), seedConst->phi(), seedConst->m());
62 }
63 for (const auto& subjet : vSubjets) {
64 TLorentzVector tmp_subjet_p4;
65 tmp_subjet_p4.SetPtEtaPhiM(subjet.pt(), subjet.eta(), subjet.phi_std(), subjet.m());
66 if (tmp_const_p4.DeltaR(tmp_subjet_p4) < m_Rsubjet) {
67 subjetConstituentsP4.push_back(tmp_const_p4);
68 }
69 }
70 }
71
72 ATH_MSG_DEBUG("subjetConstituents.size()=" << subjetConstituentsP4.size());
73
74 std::vector<float> vec_f_core(vSubjets.size(), 0);
75 for (unsigned int i = 0; i < vSubjets.size(); i++) {
76 const fastjet::PseudoJet& subjet = vSubjets.at(i);
77 float ptAll = 0.;
78 float ptCore = 0.;
79 float f_core = 0.;
80
81 TLorentzVector temp_sub_p4;
82 temp_sub_p4.SetPtEtaPhiM(subjet.pt(), subjet.eta(), subjet.phi_std(), subjet.m());
83
84 for (TLorentzVector const_p4 : subjetConstituentsP4) {
85 // ATH_MSG_DEBUG("dR(const, subjet" << i << ") = " << const_p4.DeltaR(temp_sub_p4) << "const pt = " << const_p4.Pt());
86 if (const_p4.DeltaR(temp_sub_p4) < data->Rsubjet) {
87 ptAll += const_p4.Pt();
88 }
89
90 if (const_p4.DeltaR(temp_sub_p4) < data->Rcore) {
91 ptCore += const_p4.Pt();
92 }
93 }
94
95 if (ptAll != 0.)
96 f_core = ptCore/ptAll;
97 else
98 f_core = -999.;
99
100 ATH_MSG_DEBUG("subjet "<< i << ": f_cluster_core = " << f_core);
101 vec_f_core.at(i) = f_core;
102 if (not m_useRawConstit){
103 // set f_core for the subjet in the DiTauJet object in HLT only
104 pDiTau->setfCore(i, f_core);
105 }
106 }
107
108 const static SG::Accessor<std::vector<float>> mDecor("f_cluster_core");
109 mDecor(*pDiTau) = std::move(vec_f_core);
110 return StatusCode::SUCCESS;
111}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< float > m_Rsubjet
DiTauConstituentFinder(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< bool > m_useRawConstit
virtual StatusCode execute(DiTauCandidateData *data, const EventContext &ctx) const override
Execute - called for each Ditau candidate.
virtual ~DiTauConstituentFinder()
virtual StatusCode initialize() override
Tool initializer.
DiTauToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Helper class to provide type-safe access to aux data.
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters).
virtual double m() const
The invariant mass of the particle.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
void setfCore(unsigned int numSubjet, float fCore)
JetConstituentVector getConstituents() const
Return a vector of consituents. The object behaves like vector<const IParticle*>. See JetConstituentV...
Definition Jet_v1.cxx:149
Jet_v1 Jet
Definition of the current "jet version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
DiTauJet_v1 DiTauJet
Definition of the current version.
Definition DiTauJet.h:17