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 // Local variable cellSeen uses 25000 bytes of stack space,
54 //coverity[STACK_USE]
55 std::bitset<200000> cellSeen;
56 std::vector<const CaloCell*> subjetCells;
57
58 // loop over seed jet constituents
59 for (const auto *const seedConst: pSeed->getConstituents()) {
60 // cast jet constituent to cluster object
61 const xAOD::CaloCluster* cluster = dynamic_cast<const xAOD::CaloCluster*>( seedConst->rawConstituent() );
62
63 // loop over cells which are linked to the cluster
64 for (const auto *const cc : *(cluster->getCellLinks())) {
65 // skip if pt<0 or cell already encountered
66 if (cc->pt() < 0) continue;
67 if (cellSeen.test(cc->caloDDE()->calo_hash())) continue;
68 // register cell hash as already seen
69 cellSeen.set(cc->caloDDE()->calo_hash());
70
71 TLorentzVector temp_cc_p4;
72 temp_cc_p4.SetPtEtaPhiM(cc->pt(), cc->eta(), cc->phi(), cc->m());
73
74 // check if cell is in one of the subjets cones
75 for (const auto& subjet : vSubjets) {
76 TLorentzVector temp_sub_p4;
77 temp_sub_p4.SetPtEtaPhiM(subjet.pt(), subjet.eta(), subjet.phi_std(), subjet.m());
78 if (temp_cc_p4.DeltaR(temp_sub_p4) < m_Rsubjet) {
79 subjetCells.push_back(cc);
80 }
81 }
82 }
83 }
84
85 ATH_MSG_DEBUG("subjetCells.size()=" << subjetCells.size());
86 data->subjetCells = std::move(subjetCells);
87
88 // write f_core
89 float f_core{};
90 for (unsigned int i = 0; i < vSubjets.size(); i++) {
91 const fastjet::PseudoJet& subjet = vSubjets.at(i);
92 float ptAll = 0.;
93 float ptCore = 0.;
94
95 TLorentzVector temp_sub_p4;
96 temp_sub_p4.SetPtEtaPhiM(subjet.pt(), subjet.eta(), subjet.phi_std(), subjet.m());
97
98 for (const auto& cc : data->subjetCells) {
99
100 TLorentzVector temp_cc_p4;
101 temp_cc_p4.SetPtEtaPhiM(cc->pt(), cc->eta(), cc->phi(), cc->m());
102
103 if (temp_cc_p4.DeltaR(temp_sub_p4) < data->Rsubjet) {
104 ptAll += cc->pt();
105 }
106
107 if (temp_cc_p4.DeltaR(temp_sub_p4) < data->Rcore) {
108 ptCore += cc->pt();
109 }
110 }
111
112 if (ptAll != 0.)
113 f_core = ptCore/ptAll;
114 else
115 f_core = -999.;
116
117 ATH_MSG_DEBUG("subjet "<< i << ": f_core=" << f_core);
118 pDiTau->setfCore(i, f_core);
119 }
120
121 return StatusCode::SUCCESS;
122}
#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