ATLAS Offline Software
Loading...
Searching...
No Matches
DiTauChargeDecorator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10namespace DerivationFramework {
11
13 {
14 // initialize read/write handle keys
15 ATH_CHECK( m_ditauContainerKey.initialize() );
16 ATH_CHECK( m_chargeKey.initialize() );
17
18 return StatusCode::SUCCESS;
19 }
20
21
22 StatusCode DiTauChargeDecorator::addBranches(const EventContext& ctx) const
23 {
24
25
26 // retrieve tau container
28 if (!ditauJetsReadHandle.isValid()) {
29 ATH_MSG_ERROR ("Could not retrieve DiTauJetContainer with key " << ditauJetsReadHandle.key());
30 return StatusCode::FAILURE;
31 }
32 const xAOD::DiTauJetContainer* ditauContainer = ditauJetsReadHandle.cptr();
33
35
36 for (const auto ditau : *ditauContainer) {
37 float ditau_charge = 0;
38 for (const auto& xTrack : ditau->trackLinks()) {
39 if (!xTrack.isValid())
40 continue;
41
42 if(ditau->nSubjets() >= 2){
43 for (int i = 0; i < 2; ++i) { // loop over two leading subjets
44 TLorentzVector tlvSubjet = TLorentzVector();
45 tlvSubjet.SetPtEtaPhiE(ditau->subjetPt(i), ditau->subjetEta(i),
46 ditau->subjetPhi(i), ditau->subjetE(i));
47 double dR = tlvSubjet.DeltaR((*xTrack)->p4());
48 if (dR < 0.1) {
49 ditau_charge += (*xTrack)->charge();
50 break; //prevents double counting of tracks
51 }
52 } // loop over subjets
53 }
54 } // loop over tracks
55 dec_charge(*ditau) = ditau_charge;
56 }
57
58 return StatusCode::SUCCESS;
59 }
60}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
virtual StatusCode addBranches(const EventContext &ctx) const override
SG::ReadHandleKey< xAOD::DiTauJetContainer > m_ditauContainerKey
SG::WriteDecorHandleKey< xAOD::DiTauJetContainer > m_chargeKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Handle class for adding a decoration to an object.
THE reconstruction tool.
DiTauJetContainer_v1 DiTauJetContainer
Definition of the current DiTauJet container version.