ATLAS Offline Software
Loading...
Searching...
No Matches
TauMassDecorator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
12
13namespace DerivationFramework {
14
15 TauMassDecorator::TauMassDecorator(const std::string& name,
16 ISvcLocator* pSvcLocator)
17 : AthReentrantAlgorithm(name, pSvcLocator)
18 {}
19
21 {
22 // initialize read/write handle keys
23 ATH_CHECK(m_tauOutputKey.initialize());
24 ATH_CHECK(m_tauInputKey.initialize());
25 ATH_CHECK( m_massKey.initialize() );
26
27 return StatusCode::SUCCESS;
28 }
29
30 StatusCode TauMassDecorator::execute(const EventContext& ctx) const
31 {
32
33 // retrieve input tau container
35 if (!tau_inputContainer.isValid()) {
36 ATH_MSG_ERROR ("Could not retrieve TauJetContainer with key " << tau_inputContainer.key());
37 return StatusCode::FAILURE;
38 }
39
41 ATH_CHECK(tau_outputContainer.record(std::make_unique<xAOD::TauJetContainer>(),
42 std::make_unique<xAOD::TauJetAuxContainer>()));
43
44 xAOD::TauJetContainer* taus = tau_outputContainer.ptr();
45 taus->reserve(tau_inputContainer->size());
46 for (const xAOD::TauJet* old_tau : *tau_inputContainer) {
47 xAOD::TauJet* tau = taus->push_back(std::make_unique<xAOD::TauJet>());
48 *tau=*old_tau;
49 }
50
51
53
54 // update the mass value
55 std::vector<TLorentzVector> combinedPi0sP4;
56 for (const auto tau : *taus) {
57 TauAnalysisTools::createPi0Vectors(tau, combinedPi0sP4); //clears the vector before filling it
58 TLorentzVector tau_comp(0,0,0,0);
59
60 for (size_t i = 0; i < tau->nTracks(); i++) {
61 tau_comp += tau->track(i)->p4();
62 }
63
64 for(const auto & pi0LVec : combinedPi0sP4) {
65 tau_comp += pi0LVec;
66 }
67 dec_mass(*tau) = tau_comp.M();
68 }
69
70 return StatusCode::SUCCESS;
71 }
72}
73
74
75
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
static Double_t taus
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
SG::WriteHandleKey< xAOD::TauJetContainer > m_tauOutputKey
Name of the tau output collection.
virtual StatusCode initialize() override final
TauMassDecorator(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode execute(const EventContext &ctx) const override final
SG::ReadHandleKey< xAOD::TauJetContainer > m_tauInputKey
Name of the tau input collection.
SG::WriteDecorHandleKey< xAOD::TauJetContainer > m_massKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
THE reconstruction tool.
TauJet_v3 TauJet
Definition of the current "tau version".
Definition TauJet.h:17
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".