ATLAS Offline Software
Loading...
Searching...
No Matches
JEMEnergySim.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// /***************************************************************************
6// JEMEnergySim.cxx - description
7// -------------------
8// begin : Monday 12 May 2014
9// email : Alan.Watson@CERN.CH
10// ***************************************************************************/
11//
12//================================================
13// JEMEnergySim class Implementation
14// ================================================
15//
16//
17//
18
19
20
21// This algorithm includes
22#include "JEMEnergySim.h"
24
29
30
31namespace LVL1 {
32
33
34//--------------------------------
35// Constructors and destructors
36//--------------------------------
37
39 ( const std::string& name, ISvcLocator* pSvcLocator )
40 : AthAlgorithm( name, pSvcLocator ),
41 m_EtTool("LVL1::L1EtTools/L1EtTools"),
43{}
44
45
46//---------------------------------
47// initialise()
48//---------------------------------
49
51{
52 ATH_CHECK( m_JetElementInputKey.initialize() );
53 ATH_CHECK( m_jemEtSumsOutputKey.initialize() );
54 ATH_CHECK( m_energyCMXDataOutputKey.initialize() );
55
56 ATH_CHECK( m_EtTool.retrieve() );
57 return StatusCode::SUCCESS ;
58}
59
60
61//----------------------------------------------
62// execute() method called once per event
63//----------------------------------------------
64//
65
67{
68 ATH_MSG_DEBUG ( "Executing" );
69
70 // form module sums
72
74
75 if (rh.isValid()) {
76 const DataVector<xAOD::JetElement>* jetelements = &(*rh);
77
78 // Warn if we find an empty container
79 if (jetelements->size() == 0)
80 ATH_MSG_WARNING("Empty JetElementContainer - looks like a problem" );
81
82 m_EtTool->moduleSums(jetelements, m_jemContainer);
83 }
84 else ATH_MSG_WARNING("No JetElementCollection at " << m_JetElementInputKey );
85
86 // Done the processing. Now form & save the various output data
87
88 // For CMX simulation
90
91 // for Bytestream simulation
93
94 cleanup();
95
96 return StatusCode::SUCCESS ;
97}
98
99
100} // end of LVL1 namespace bracket
101
104
105 delete m_jemContainer;
106}
107
110
111 ATH_MSG_DEBUG("storeJEMEtSums running");
112
114
116 for ( it=m_jemContainer->begin(); it!=m_jemContainer->end(); ++it ) {
117 std::vector<unsigned int> eX;
118 eX.push_back((*it)->ex());
119 std::vector<unsigned int> eY;
120 eY.push_back((*it)->ey());
121 std::vector<unsigned int> eT;
122 eT.push_back((*it)->et());
123 JEMEtSums* jemEtSums = new JEMEtSums((*it)->crate(), (*it)->module(),eT,eX,eY,0);
124 JEMRvector->push_back(jemEtSums);
125 }
126
127 ATH_MSG_DEBUG( JEMRvector->size()<<" JEMEtSums objects are being saved");
128
129 const EventContext& ctx = Gaudi::Hive::currentContext();
130 StatusCode sc = SG::makeHandle(m_jemEtSumsOutputKey, ctx).record( std::unique_ptr<DataVector<JEMEtSums>>(JEMRvector) );
131 if (sc != StatusCode::SUCCESS) {
132 ATH_MSG_ERROR ( "Error registering JEMEtSums collection in TDS " );
133 }
134
135}
136
139
140 ATH_MSG_DEBUG("storeBackplaneData running");
141
143
145 for ( it=m_jemContainer->begin(); it!=m_jemContainer->end(); ++it ) {
146 EnergyCMXData* bpData = new EnergyCMXData((*it)->crate(), (*it)->module(),
147 (*it)->ex(),(*it)->ey(),(*it)->et());
148 bpVector->push_back(bpData);
149 }
150
151 ATH_MSG_DEBUG( bpVector->size()<<" EnergyCMXData objects are being saved");
152
153 const EventContext& ctx = Gaudi::Hive::currentContext();
154 StatusCode sc = SG::makeHandle(m_energyCMXDataOutputKey, ctx).record( std::unique_ptr<DataVector<EnergyCMXData>>(bpVector) );
155 if (sc != StatusCode::SUCCESS) {
156 ATH_MSG_ERROR ( "Error registering EnergyCMXData collection in TDS " );
157 }
158
159}
160
161
162
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Derived DataVector<T>.
Definition DataVector.h:795
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
Definition DataVector.h:842
size_type size() const noexcept
Returns the number of elements in the collection.
The EnergyCMXData object contains the data transferred from the JEM to the EnergySum CMX in the crate...
SG::WriteHandleKey< DataVector< EnergyCMXData > > m_energyCMXDataOutputKey
StatusCode initialize()
void storeJEMEtSums()
put results into SG
SG::WriteHandleKey< DataVector< JEMEtSums > > m_jemEtSumsOutputKey
SG::ReadHandleKey< xAOD::JetElementContainer > m_JetElementInputKey
JEMEnergySim(const std::string &name, ISvcLocator *pSvcLocator)
void cleanup()
delete pointers etc.
DataVector< EnergyCMXData > EnergyCMXDataCollection
ToolHandle< LVL1::IL1EtTools > m_EtTool
StatusCode execute()
DataVector< JEMEtSums > JEMEtSumsCollection
void storeBackplaneData()
Form EnergyCMXData and put into SG.
DataVector< ModuleEnergy > * m_jemContainer
vector of ModuleEnergy objects
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())