ATLAS Offline Software
CellFinder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #include "DiTauRec/CellFinder.h"
8 
10 
11 #include "CaloEvent/CaloClusterContainer.h"
12 #include "CaloEvent/CaloCell.h"
14 
15 #include "fastjet/PseudoJet.hh"
16 
17 CellFinder::CellFinder(const std::string& type,
18  const std::string& name,
19  const IInterface * parent) :
21  m_ClusterContainerName("CaloCalTopoClusters"),
22  m_CellContainerName("AllCalo"),
23  m_Rsubjet(0.2)
24 {
25  declareInterface<DiTauToolBase > (this);
26  declareProperty("ClusterContainer", m_ClusterContainerName);
27  declareProperty("CellContainer", m_CellContainerName);
28  declareProperty("Rsubjet", m_Rsubjet);
29 }
30 
31 
32 CellFinder::~CellFinder() = default;
33 
34 
36 
37  return StatusCode::SUCCESS;
38 }
39 
40 
42  const EventContext& /*ctx*/) const {
43 
44  ATH_MSG_DEBUG("execute CellFinder...");
45 
46  // get ditau and its seed jet
47 
48  xAOD::DiTauJet* pDiTau = data->xAODDiTau;
49  if (!pDiTau) {
50  ATH_MSG_ERROR("no di-tau candidate given");
51  return StatusCode::FAILURE;
52  }
53 
54  const xAOD::Jet* pSeed = data->seed;
55  if (!pSeed) {
56  ATH_MSG_WARNING("No jet seed given.");
57  return StatusCode::FAILURE;
58  }
59 
60  std::vector<fastjet::PseudoJet> vSubjets = data->subjets;
61  if (vSubjets.empty()) {
62  ATH_MSG_WARNING("No subjets given. Continue without cell information.");
63  return StatusCode::SUCCESS;
64  }
65 
66  // get clusters linked to the seed jet. Loop over clusters to get linked cells
67 
68  std::bitset<200000> cellSeen;
69  std::vector<const CaloCell*> subjetCells;
70 
71  // loop over seed jet constituents
72  for (const auto *const seedConst: pSeed->getConstituents()) {
73  // cast jet constituent to cluster object
74  const xAOD::CaloCluster* cluster = dynamic_cast<const xAOD::CaloCluster*>( seedConst->rawConstituent() );
75 
76  // loop over cells which are linked to the cluster
77  for (const auto *const cc : *(cluster->getCellLinks())) {
78  // skip if pt<0 or cell already encountered
79  if (cc->pt() < 0) continue;
80  if (cellSeen.test(cc->caloDDE()->calo_hash())) continue;
81  // register cell hash as already seen
82  cellSeen.set(cc->caloDDE()->calo_hash());
83 
84  TLorentzVector temp_cc_p4;
85  temp_cc_p4.SetPtEtaPhiM(cc->pt(), cc->eta(), cc->phi(), cc->m());
86 
87  // check if cell is in one of the subjets cones
88  for (const auto& subjet : vSubjets) {
89  TLorentzVector temp_sub_p4;
90  temp_sub_p4.SetPtEtaPhiM(subjet.pt(), subjet.eta(), subjet.phi_std(), subjet.m());
91  if (temp_cc_p4.DeltaR(temp_sub_p4) < m_Rsubjet) {
92  subjetCells.push_back(cc);
93  }
94  }
95  }
96  }
97 
98  ATH_MSG_DEBUG("subjetCells.size()=" << subjetCells.size());
99  data->subjetCells = subjetCells;
100 
101  return StatusCode::SUCCESS;
102 }
CellFinder::initialize
virtual StatusCode initialize() override
Tool initializer.
Definition: CellFinder.cxx:35
CellFinder::~CellFinder
virtual ~CellFinder()
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
FlavorTagDiscriminants::hbb_key::subjet
const std::string subjet
Definition: HbbConstants.h:18
DiTauToolBase.h
CellFinder::execute
virtual StatusCode execute(DiTauCandidateData *data, const EventContext &ctx) const override
Execute - called for each Ditau candidate.
Definition: CellFinder.cxx:41
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DiTauCandidateData.h
CaloCell.h
CellFinder.h
xAOD::Jet_v1::getConstituents
JetConstituentVector getConstituents() const
Return a vector of consituents. The object behaves like vector<const IParticle*>. See JetConstituentV...
Definition: Jet_v1.cxx:147
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CellFinder::m_ClusterContainerName
std::string m_ClusterContainerName
Definition: CellFinder.h:29
CellFinder::m_Rsubjet
float m_Rsubjet
Definition: CellFinder.h:31
xAOD::CaloCluster_v1::getCellLinks
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
Definition: CaloCluster_v1.cxx:905
CellFinder::CellFinder
CellFinder(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CellFinder.cxx:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DiTauToolBase
The base class for all tau tools.
Definition: DiTauToolBase.h:20
CaloCellContainer.h
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CellFinder::m_CellContainerName
std::string m_CellContainerName
Definition: CellFinder.h:30
xAOD::DiTauJet_v1
Definition: DiTauJet_v1.h:31
DiTauCandidateData
Definition: DiTauCandidateData.h:15
python.handimod.cc
int cc
Definition: handimod.py:523