ATLAS Offline Software
JEMEnergySim.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 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 // Utilities
20 #include <cmath>
21 
22 // This algorithm includes
23 #include "JEMEnergySim.h"
25 
30 
31 
32 namespace LVL1 {
33 
34 
35 //--------------------------------
36 // Constructors and destructors
37 //--------------------------------
38 
40  ( const std::string& name, ISvcLocator* pSvcLocator )
41  : AthAlgorithm( name, pSvcLocator ),
42  m_EtTool("LVL1::L1EtTools/L1EtTools"),
43  m_jemContainer(0)
44 {}
45 
46 
47 //---------------------------------
48 // initialise()
49 //---------------------------------
50 
52 {
53  ATH_CHECK( m_JetElementInputKey.initialize() );
54  ATH_CHECK( m_jemEtSumsOutputKey.initialize() );
55  ATH_CHECK( m_energyCMXDataOutputKey.initialize() );
56 
57  ATH_CHECK( m_EtTool.retrieve() );
58  return StatusCode::SUCCESS ;
59 }
60 
61 
62 //----------------------------------------------
63 // execute() method called once per event
64 //----------------------------------------------
65 //
66 
68 {
69  ATH_MSG_DEBUG ( "Executing" );
70 
71  // form module sums
73 
75 
76  if (rh.isValid()) {
77  const DataVector<xAOD::JetElement>* jetelements = &(*rh);
78 
79  // Warn if we find an empty container
80  if (jetelements->size() == 0)
81  ATH_MSG_WARNING("Empty JetElementContainer - looks like a problem" );
82 
83  m_EtTool->moduleSums(jetelements, m_jemContainer);
84  }
85  else ATH_MSG_WARNING("No JetElementCollection at " << m_JetElementInputKey );
86 
87  // Done the processing. Now form & save the various output data
88 
89  // For CMX simulation
91 
92  // for Bytestream simulation
94 
95  cleanup();
96 
97  return StatusCode::SUCCESS ;
98 }
99 
100 
101 } // end of LVL1 namespace bracket
102 
105 
106  delete m_jemContainer;
107 }
108 
111 
112  ATH_MSG_DEBUG("storeJEMEtSums running");
113 
114  JEMEtSumsCollection* JEMRvector = new JEMEtSumsCollection;
115 
117  for ( it=m_jemContainer->begin(); it!=m_jemContainer->end(); ++it ) {
118  std::vector<unsigned int> eX;
119  eX.push_back((*it)->ex());
120  std::vector<unsigned int> eY;
121  eY.push_back((*it)->ey());
122  std::vector<unsigned int> eT;
123  eT.push_back((*it)->et());
124  JEMEtSums* jemEtSums = new JEMEtSums((*it)->crate(), (*it)->module(),eT,eX,eY,0);
125  JEMRvector->push_back(jemEtSums);
126  }
127 
128  ATH_MSG_DEBUG( JEMRvector->size()<<" JEMEtSums objects are being saved");
129 
130  const EventContext& ctx = Gaudi::Hive::currentContext();
131  StatusCode sc = SG::makeHandle(m_jemEtSumsOutputKey, ctx).record( std::unique_ptr<DataVector<JEMEtSums>>(JEMRvector) );
132  if (sc != StatusCode::SUCCESS) {
133  ATH_MSG_ERROR ( "Error registering JEMEtSums collection in TDS " );
134  }
135 
136 
137  // StatusCode sc = evtStore()->overwrite(JEMRvector, m_jemEtSumsLocation, true);
138  // if (sc != StatusCode::SUCCESS) ATH_MSG_ERROR ( "Error registering JEMEtSums collection in TDS " );
139  // else {
140  // StatusCode sc2 = evtStore()->setConst(JEMRvector);
141  // if (sc2 != StatusCode::SUCCESS) ATH_MSG_ERROR ( "error setting JEMResult vector constant" );
142  // }
143 
144  // return;
145 }
146 
149 
150  ATH_MSG_DEBUG("storeBackplaneData running");
151 
153 
155  for ( it=m_jemContainer->begin(); it!=m_jemContainer->end(); ++it ) {
156  EnergyCMXData* bpData = new EnergyCMXData((*it)->crate(), (*it)->module(),
157  (*it)->ex(),(*it)->ey(),(*it)->et());
158  bpVector->push_back(bpData);
159  }
160 
161  ATH_MSG_DEBUG( bpVector->size()<<" EnergyCMXData objects are being saved");
162 
163  const EventContext& ctx = Gaudi::Hive::currentContext();
164  StatusCode sc = SG::makeHandle(m_energyCMXDataOutputKey, ctx).record( std::unique_ptr<DataVector<EnergyCMXData>>(bpVector) );
165  if (sc != StatusCode::SUCCESS) {
166  ATH_MSG_ERROR ( "Error registering EnergyCMXData collection in TDS " );
167  }
168 
169  // StatusCode sc = evtStore()->overwrite(bpVector, m_energyCMXDataLocation, true);
170  // if (sc != StatusCode::SUCCESS) ATH_MSG_ERROR ( "Error registering EnergyCMXData collection in TDS " );
171 
172  // return;
173 }
174 
175 
176 
LVL1::JEMEnergySim::storeBackplaneData
void storeBackplaneData()
Form EnergyCMXData and put into SG.
Definition: JEMEnergySim.cxx:148
xAOD::JEMEtSums
JEMEtSums_v2 JEMEtSums
Define the latest version of the JEMEtSums class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/JEMEtSums.h:15
LVL1::JEMEnergySim::m_jemContainer
DataVector< ModuleEnergy > * m_jemContainer
vector of ModuleEnergy objects
Definition: JEMEnergySim.h:89
LVL1::JEMEnergySim::m_energyCMXDataOutputKey
SG::WriteHandleKey< DataVector< EnergyCMXData > > m_energyCMXDataOutputKey
Definition: JEMEnergySim.h:86
JEMEtSumsCollection
DataVector< LVL1::JEMEtSums > JEMEtSumsCollection
Definition: JEMEtSumsCollection.h:12
LVL1::EnergyCMXData
The EnergyCMXData object contains the data transferred from the JEM to the EnergySum CMX in the crate...
Definition: EnergyCMXData.h:24
ModuleEnergy.h
skel.it
it
Definition: skel.GENtoEVGEN.py:423
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::JEMEnergySim::initialize
StatusCode initialize()
Definition: JEMEnergySim.cxx:51
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
JetElementContainer.h
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
JEMEnergySim.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
IDTPM::eT
float eT(const U &p)
Accessor utility function for getting the value of Tranverse energy.
Definition: TrackParametersHelper.h:130
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LVL1::JEMEnergySim::execute
StatusCode execute()
Definition: JEMEnergySim.cxx:67
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AthAlgorithm
Definition: AthAlgorithm.h:47
TrigConf::name
Definition: HLTChainList.h:35
LVL1::JEMEnergySim::storeJEMEtSums
void storeJEMEtSums()
put results into SG
Definition: JEMEnergySim.cxx:110
LVL1::JEMEnergySim::m_JetElementInputKey
SG::ReadHandleKey< xAOD::JetElementContainer > m_JetElementInputKey
Definition: JEMEnergySim.h:80
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
JetEnergyModuleKey.h
LVL1::JEMEnergySim::m_jemEtSumsOutputKey
SG::WriteHandleKey< DataVector< JEMEtSums > > m_jemEtSumsOutputKey
Definition: JEMEnergySim.h:83
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LVL1::JEMEtSums
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMEtSums.h:27
LVL1::JEMEnergySim::cleanup
void cleanup()
delete pointers etc.
Definition: JEMEnergySim.cxx:104
LVL1::JEMEnergySim::m_EtTool
ToolHandle< LVL1::IL1EtTools > m_EtTool
Definition: JEMEnergySim.h:77
TrigT1Interfaces_ClassDEF.h
EnergyCMXData_ClassDEF.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
LVL1::JEMEnergySim::JEMEnergySim
JEMEnergySim(const std::string &name, ISvcLocator *pSvcLocator)
Definition: JEMEnergySim.cxx:40