ATLAS Offline Software
IDvarCalculator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8  const std::string& name,
9  const IInterface * parent) :
11  m_useCells(true)
12 {
13  declareInterface<DiTauToolBase > (this);
14  declareProperty("useCells", m_useCells);
15 }
16 
17 
19 
20 
22 
23  return StatusCode::SUCCESS;
24 }
25 
26 
28  const EventContext& /*ctx*/) const {
29 
30  ATH_MSG_DEBUG("execute IDVarCalculator...");
31 
32  // get ditau elements
33 
34  // ditau
35  xAOD::DiTauJet* pDiTau = data->xAODDiTau;
36  if (!pDiTau) {
37  ATH_MSG_ERROR("no di-tau candidate given");
38  return StatusCode::FAILURE;
39  }
40 
41  // seed jet
42  const xAOD::Jet* pSeed = data->seed;
43  if (!pSeed) {
44  ATH_MSG_WARNING("No jet seed given.");
45  return StatusCode::FAILURE;
46  }
47 
48  // subjets
49  std::vector<fastjet::PseudoJet> vSubjets = data->subjets;
50  if (vSubjets.empty()) {
51  ATH_MSG_WARNING("No subjets given. Continue without ID variable calculation.");
52  return StatusCode::SUCCESS;
53  }
54 
55  // cells if available
56  bool useCells = m_useCells;;
57  std::vector<const CaloCell*> vSubjetCells = data->subjetCells;
58  if (vSubjetCells.empty()) {
59  ATH_MSG_DEBUG("No cell information available.");
60  useCells = false;
61  }
62 
63  // write subjets
64  for (unsigned int i = 0; i < vSubjets.size(); i++) {
65  const fastjet::PseudoJet& subjet = vSubjets.at(i);
66  pDiTau->setSubjetPtEtaPhiE(i, subjet.pt(), subjet.eta(), subjet.phi_std(), subjet.e());
67  ATH_MSG_DEBUG("subjet " << i << " pt: " << subjet.pt() << " eta: " << subjet.eta() << " phi: " << subjet.phi_std() << " e: " << subjet.e());
68  }
69 
70  // write f_core
71  if (!useCells) {
72  ATH_MSG_DEBUG("no cells are used for ID variable calculation. Continue.");
73  return StatusCode::SUCCESS;
74  }
75 
76  float f_core;
77  for (unsigned int i = 0; i < vSubjets.size(); i++) {
78  const fastjet::PseudoJet& subjet = vSubjets.at(i);
79  float ptAll = 0.;
80  float ptCore = 0.;
81 
82  TLorentzVector temp_sub_p4;
83  temp_sub_p4.SetPtEtaPhiM(subjet.pt(), subjet.eta(), subjet.phi_std(), subjet.m());
84 
85  for (const auto& cc : vSubjetCells) {
86 
87  TLorentzVector temp_cc_p4;
88  temp_cc_p4.SetPtEtaPhiM(cc->pt(), cc->eta(), cc->phi(), cc->m());
89 
90  if (temp_cc_p4.DeltaR(temp_sub_p4) < data->Rsubjet) {
91  ptAll += cc->pt();
92  }
93 
94  if (temp_cc_p4.DeltaR(temp_sub_p4) < data->Rcore) {
95  ptCore += cc->pt();
96  }
97  }
98 
99  if (ptAll != 0.)
100  f_core = ptCore/ptAll;
101  else
102  f_core = -999.;
103 
104  ATH_MSG_DEBUG("subjet "<< i << ": f_core=" << f_core);
105  pDiTau->setfCore(i, f_core);
106  }
107 
108  return StatusCode::SUCCESS;
109 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
FlavorTagDiscriminants::hbb_key::subjet
const std::string subjet
Definition: HbbConstants.h:18
IDVarCalculator::~IDVarCalculator
virtual ~IDVarCalculator()
Destructor.
IDVarCalculator::m_useCells
bool m_useCells
Definition: IDVarCalculator.h:35
IDVarCalculator::initialize
virtual StatusCode initialize() override
Tool initializer.
Definition: IDvarCalculator.cxx:21
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
IDVarCalculator.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
IDVarCalculator::execute
virtual StatusCode execute(DiTauCandidateData *data, const EventContext &ctx) const override
Execute - called for each Ditau candidate.
Definition: IDvarCalculator.cxx:27
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
xAOD::DiTauJet_v1::setfCore
void setfCore(unsigned int numSubjet, float fCore)
Definition: DiTauJet_v1.cxx:178
IDVarCalculator::IDVarCalculator
IDVarCalculator(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
Definition: IDvarCalculator.cxx:7
xAOD::DiTauJet_v1::setSubjetPtEtaPhiE
void setSubjetPtEtaPhiE(unsigned int numSubjet, float pt, float eta, float phi, float e)
Definition: DiTauJet_v1.cxx:139
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
DiTauToolBase
The base class for all tau tools.
Definition: DiTauToolBase.h:20
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
xAOD::DiTauJet_v1
Definition: DiTauJet_v1.h:31
DiTauCandidateData
Definition: DiTauCandidateData.h:15
python.handimod.cc
int cc
Definition: handimod.py:523