ATLAS Offline Software
Loading...
Searching...
No Matches
CellFinder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7#include "fastjet/PseudoJet.hh"
8
9CellFinder::CellFinder(const std::string& type,
10 const std::string& name,
11 const IInterface * parent) :
12 DiTauToolBase(type, name, parent)
13{
14 declareInterface<DiTauToolBase > (this);
15}
16
17
18CellFinder::~CellFinder() = default;
19
20
22
23 return StatusCode::SUCCESS;
24}
25
26
28 const EventContext& /*ctx*/) const {
29
30 ATH_MSG_DEBUG("execute CellFinder...");
31
32 // get ditau and its seed jet
33
34 xAOD::DiTauJet* pDiTau = data->xAODDiTau;
35 if (!pDiTau) {
36 ATH_MSG_ERROR("no di-tau candidate given");
37 return StatusCode::FAILURE;
38 }
39
40 const xAOD::Jet* pSeed = data->seed;
41 if (!pSeed) {
42 ATH_MSG_WARNING("No jet seed given.");
43 return StatusCode::FAILURE;
44 }
45
46 std::vector<fastjet::PseudoJet> vSubjets = data->subjets;
47 if (vSubjets.empty()) {
48 ATH_MSG_WARNING("No subjets given. Continue without cell information.");
49 return StatusCode::SUCCESS;
50 }
51
52 // get clusters linked to the seed jet. Loop over clusters to get linked cells
53
54 std::bitset<200000> cellSeen;
55 std::vector<const CaloCell*> subjetCells;
56
57 // loop over seed jet constituents
58 for (const auto *const seedConst: pSeed->getConstituents()) {
59 // cast jet constituent to cluster object
60 const xAOD::CaloCluster* cluster = dynamic_cast<const xAOD::CaloCluster*>( seedConst->rawConstituent() );
61
62 // loop over cells which are linked to the cluster
63 for (const auto *const cc : *(cluster->getCellLinks())) {
64 // skip if pt<0 or cell already encountered
65 if (cc->pt() < 0) continue;
66 if (cellSeen.test(cc->caloDDE()->calo_hash())) continue;
67 // register cell hash as already seen
68 cellSeen.set(cc->caloDDE()->calo_hash());
69
70 TLorentzVector temp_cc_p4;
71 temp_cc_p4.SetPtEtaPhiM(cc->pt(), cc->eta(), cc->phi(), cc->m());
72
73 // check if cell is in one of the subjets cones
74 for (const auto& subjet : vSubjets) {
75 TLorentzVector temp_sub_p4;
76 temp_sub_p4.SetPtEtaPhiM(subjet.pt(), subjet.eta(), subjet.phi_std(), subjet.m());
77 if (temp_cc_p4.DeltaR(temp_sub_p4) < m_Rsubjet) {
78 subjetCells.push_back(cc);
79 }
80 }
81 }
82 }
83
84 ATH_MSG_DEBUG("subjetCells.size()=" << subjetCells.size());
85 data->subjetCells = subjetCells;
86
87 // write f_core
88 float f_core;
89 for (unsigned int i = 0; i < vSubjets.size(); i++) {
90 const fastjet::PseudoJet& subjet = vSubjets.at(i);
91 float ptAll = 0.;
92 float ptCore = 0.;
93
94 TLorentzVector temp_sub_p4;
95 temp_sub_p4.SetPtEtaPhiM(subjet.pt(), subjet.eta(), subjet.phi_std(), subjet.m());
96
97 for (const auto& cc : data->subjetCells) {
98
99 TLorentzVector temp_cc_p4;
100 temp_cc_p4.SetPtEtaPhiM(cc->pt(), cc->eta(), cc->phi(), cc->m());
101
102 if (temp_cc_p4.DeltaR(temp_sub_p4) < data->Rsubjet) {
103 ptAll += cc->pt();
104 }
105
106 if (temp_cc_p4.DeltaR(temp_sub_p4) < data->Rcore) {
107 ptCore += cc->pt();
108 }
109 }
110
111 if (ptAll != 0.)
112 f_core = ptCore/ptAll;
113 else
114 f_core = -999.;
115
116 ATH_MSG_DEBUG("subjet "<< i << ": f_core=" << f_core);
117 pDiTau->setfCore(i, f_core);
118 }
119
120 return StatusCode::SUCCESS;
121}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< float > m_Rsubjet
Definition CellFinder.h:32
virtual StatusCode initialize() override
Tool initializer.
virtual ~CellFinder()
CellFinder(const std::string &type, const std::string &name, const IInterface *parent)
Definition CellFinder.cxx:9
virtual StatusCode execute(DiTauCandidateData *data, const EventContext &ctx) const override
Execute - called for each Ditau candidate.
DiTauToolBase(const std::string &type, const std::string &name, const IInterface *parent)
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version).
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