ATLAS Offline Software
Loading...
Searching...
No Matches
JetElementCnvTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// EDM include(s):
10
11// Local include(s):
12#include "JetElementCnvTool.h"
13
14namespace {
15 template <typename T>
16 std::vector<T> convertVector(const std::vector<int>& in) {
17 std::vector<T> result;
18 result.reserve(in.size());
19
20for(auto i : in) {
21 result.push_back(static_cast<T>(i));
22 }
23 return result;
24 }
25}
26
27namespace xAODMaker {
28
30 const std::string& name,
31 const IInterface* parent )
32 : AthAlgTool( type, name, parent ) {
33
34 // Declare the interface(s) provided by the tool:
35 declareInterface< IJetElementCnvTool >( this );
36 }
37
38
50
51 // A small sanity check. The output container should really be empty...
52 if( !xaod->empty() ) {
53 ATH_MSG_WARNING( "The output xAOD container is not empty (size=="
54 << xaod->size() << ")" );
55 }
56
57 // Loop over the ESD objects:
60 for( ; itr != end; ++itr ) {
61
63 xaod->push_back( x );
64
65 x->initialize( (float)(*itr)->eta() ,
66 (float)(*itr)->phi() ,
67 (*itr)->key() ,
68 convertVector<uint16_t>((*itr)->emEnergyVec()) ,
69 convertVector<uint16_t>((*itr)->hadEnergyVec()) ,
70 convertVector<uint32_t>((*itr)->emErrorVec()) ,
71 convertVector<uint32_t>((*itr)->hadErrorVec()) ,
72 convertVector<uint32_t>((*itr)->linkErrorVec()) ,
73 (uint8_t)(*itr)->peak() );
74 }
75
76 // Return gracefully:
77 return StatusCode::SUCCESS;
78 }
79
80} // namespace xAODMaker
#define ATH_MSG_WARNING(x)
DataVector< LVL1::JetElement > JetElementCollection
CLHEP::HepLorentzVector convertVector(const Pythia8::Vec4 v)
#define x
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
virtual StatusCode convert(const DataVector< LVL1::JetElement > *esd, xAOD::JetElementContainer *xaod) override
Function that fills an existing xAOD::EmTauRoIContainer.
JetElementCnvTool(const std::string &type, const std::string &name, const IInterface *parent)
Regular AlgTool constructor.
JetElementContainer_v2 JetElementContainer
Define the latest version of the JetElement container.
JetElement_v2 JetElement
Define the latest version of the JetElement class.