ATLAS Offline Software
Loading...
Searching...
No Matches
DiTauBuilder.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
7DiTauBuilder::DiTauBuilder( const std::string& name, ISvcLocator* pSvcLocator ) :
8 AthReentrantAlgorithm( name, pSvcLocator )
9{
10}
11
12
14
15
17 ATH_MSG_INFO ("Initializing " << name() << "...");
18
19 // no tools allocated
20 if (m_tools.empty()) {
21 ATH_MSG_ERROR("no tools given!");
22 return StatusCode::FAILURE;
23 }
24
25 // list allocated tools
26 ATH_CHECK( m_tools.retrieve() );
27 ToolHandleArray<DiTauToolBase> ::iterator itT = m_tools.begin();
28 ToolHandleArray<DiTauToolBase> ::iterator itTE = m_tools.end();
29 ATH_MSG_INFO("List of tools in execution sequence:");
30 ATH_MSG_INFO("------------------------------------");
31
32 unsigned int tool_count = 0;
33
34 for (; itT != itTE; ++itT) {
35 if (itT->retrieve().isFailure()) {
36 ATH_MSG_WARNING("Cannot find tool named <" << *itT << ">");
37 } else {
38 ++tool_count;
39 ATH_MSG_INFO((*itT)->type() << " - " << (*itT)->name());
40 }
41 }
42 ATH_MSG_INFO(" ");
43 ATH_MSG_INFO("------------------------------------");
44
45 if (tool_count == 0) {
46 ATH_MSG_ERROR("could not allocate any tool!");
47 return StatusCode::FAILURE;
48 }
49
50 ATH_CHECK( m_diTauContainerName.initialize() );
51 ATH_CHECK( m_seedJetName.initialize() );
52
53 return StatusCode::SUCCESS;
54}
55
56
58 ATH_MSG_INFO ("Finalizing " << name() << "...");
59
60 return StatusCode::SUCCESS;
61}
62
63
64StatusCode DiTauBuilder::execute(const EventContext& ctx) const {
65 ATH_MSG_DEBUG ("Executing " << name() << "...");
66
67 // preparing DiTau Candidate Container and storage in DiTauData
68
69 DiTauCandidateData rDiTauData;
70
71 auto pContainer = std::make_unique<xAOD::DiTauJetContainer>();
72 auto pAuxContainer = std::make_unique<xAOD::DiTauJetAuxContainer>();
73 pContainer->setStore(pAuxContainer.get());
74
75 // set properties of DiTau Candidate
76 rDiTauData.xAODDiTau = nullptr;
77 rDiTauData.xAODDiTauContainer = pContainer.get();
78 rDiTauData.diTauAuxContainer = pAuxContainer.get();
79 rDiTauData.seed = nullptr;
80 rDiTauData.seedContainer = nullptr;
81
82 rDiTauData.Rjet = m_Rjet;
83 rDiTauData.Rsubjet = m_Rsubjet;
84 rDiTauData.Rcore = m_Rcore;
85
87 ATH_CHECK( diTauContainerH.record (std::move (pContainer),
88 std::move (pAuxContainer)) );
89
90 // retrieve di-tau seed jets and loop over seeds
91
93
94 rDiTauData.seedContainer = pSeedContainer.get();
95
96 for (const auto* seed: *pSeedContainer) {
97 ATH_MSG_DEBUG("Seed pt: "<< seed->pt() << " eta: "<< seed->eta());
98
99 // seed cuts
100 if (std::abs(seed->pt()) < m_minPt) continue;
101 if (std::abs(seed->eta()) > m_maxEta) continue;
102
103 // cuts passed
104 rDiTauData.seed = seed;
105
106 // create new di-tau candidate
107 rDiTauData.xAODDiTau = new xAOD::DiTauJet();
108 rDiTauData.xAODDiTauContainer->push_back(rDiTauData.xAODDiTau);
109
110 // handle di-tau candidate
111 StatusCode sc = StatusCode::SUCCESS;
112 for (const auto& tool: m_tools) {
113 sc = tool->execute(&rDiTauData, ctx);
114 if (sc.isFailure()) break;
115 }
116
117 if (sc.isSuccess()) {
118 ATH_MSG_DEBUG("all tools executed successfully. Di-Tau candidate registered.");
119 }
120 else {
121 ATH_MSG_DEBUG("seed failed a di-tau criterion. Thrown away.");
122 rDiTauData.xAODDiTauContainer->pop_back();
123 }
124 }
125
126 // // TODO: tool finalizers needed here
127 // sc = StatusCode::SUCCESS;
128
129 rDiTauData.xAODDiTau = nullptr;
130
131 ATH_MSG_DEBUG("end execute()");
132 return StatusCode::SUCCESS;
133}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
An algorithm that can be simultaneously executed in multiple threads.
const T * get(size_type n) const
Access an element, as an rvalue.
void pop_back()
Remove the last element from the collection.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::WriteHandleKey< xAOD::DiTauJetContainer > m_diTauContainerName
Gaudi::Property< float > m_maxEta
virtual ~DiTauBuilder()
SG::ReadHandleKey< xAOD::JetContainer > m_seedJetName
DiTauBuilder(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode finalize() override
Gaudi::Property< float > m_Rsubjet
Gaudi::Property< float > m_Rjet
Gaudi::Property< float > m_minPt
virtual StatusCode execute(const EventContext &) const override
virtual StatusCode initialize() override
Gaudi::Property< float > m_Rcore
ToolHandleArray< DiTauToolBase > m_tools
xAOD::DiTauJetContainer * xAODDiTauContainer
const xAOD::Jet * seed
xAOD::DiTauJet * xAODDiTau
xAOD::DiTauJetAuxContainer * diTauAuxContainer
const xAOD::JetContainer * seedContainer
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
DiTauJet_v1 DiTauJet
Definition of the current version.
Definition DiTauJet.h:17