ATLAS Offline Software
JEMJetSim.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 // JEMJetSim.cxx - description
7 // -------------------
8 // begin : Wed Mar 12 2014
9 // email : Alan.Watson@CERN.CH
10 // ***************************************************************************/
11 //
12 //
13 //================================================
14 // JEMJetSim class Implementation
15 // ================================================
16 //
17 //
18 //
19 
20 // Utilities
21 
22 // This algorithm includes
23 #include "JEMJetSim.h"
25 
29 
35 
36 
37 
38 namespace LVL1{
39 
40 using namespace TrigConf;
41 
42 //--------------------------------
43 // Constructors and destructors
44 //--------------------------------
45 
47  ( const std::string& name, ISvcLocator* pSvcLocator )
48  : AthAlgorithm( name, pSvcLocator ),
49  m_allTOBs(0),
50  m_JetCMXData(0),
51  m_JetTool("LVL1::L1JEMJetTools/L1JEMJetTools")
52 {
53 }
54 
55 
56 //---------------------------------
57 // initialise()
58 //---------------------------------
59 
61 {
62  ATH_CHECK( m_JetElementInputKey.initialize() );
63  ATH_CHECK( m_JEMTobRoIOutputKey.initialize() );
64  ATH_CHECK( m_JetCMXDataOutputKey.initialize() );
65  ATH_CHECK( m_JetTool.retrieve() );
66  return StatusCode::SUCCESS ;
67 }
68 
69 
70 //----------------------------------------------
71 // execute() method called once per event
72 //----------------------------------------------
73 //
74 
75 
77 {
78 
79  /*
80  Retrieve collection of JetElements
81  Fill a std::map of JetInputs from them
82  Loop over crates/modules
83  For each crate, loop over towers and find TOBs
84  form backplane data objects
85  form daq objects
86  */
87 
88  //make a message logging stream
89 
90  ATH_MSG_DEBUG ( "starting JEMJetSim" );
91 
92  // Create containers for this event
93  m_JetCMXData = new DataVector<JetCMXData>; //Container of backplane data objects
94  m_allTOBs = new DataVector<JEMTobRoI>; // Container to hold all TOB RoIs in event
95 
96  // Retrieve the JetElementContainer
98 
99  if (rh.isValid()) {
100  const DataVector<xAOD::JetElement>* storedJEs = &(*rh);
101  if ( true ) {
102  // Check size of JetElementCollection - zero would indicate a problem
103  if (storedJEs->size() == 0)
104  ATH_MSG_WARNING("Empty JetElementContainer - looks like a problem" );
105 
106  // Form JetInputs and put them in a map
107  std::map<int, JetInput*>* inputMap = new std::map<int, JetInput*> ;
108  m_JetTool->mapJetInputs(storedJEs, inputMap);
109 
110  // Loop over crates and modules
111  for (int iCrate = 0; iCrate < 2; ++iCrate) {
112  for (int iModule = 0; iModule < 16; ++iModule) {
113 
114  // For each module, find TOBs and backplane data
115  std::vector<unsigned int> jetCMXData;
116  m_JetTool->findJEMResults(inputMap,iCrate,iModule,m_allTOBs,jetCMXData);
117  // Push backplane data into output DataVectors
118  JetCMXData* bpData = new JetCMXData(iCrate,iModule,jetCMXData);
119  m_JetCMXData -> push_back(bpData);
120 
121  } // loop over modules
122  } // loop over crates
123 
125  for (std::map<int, JetInput*>::iterator it = inputMap->begin(); it != inputMap->end(); ++it) {
126  delete (*it).second;
127  }
128  delete inputMap;
129 
130  } // found TriggerTowers
131 
132  else ATH_MSG_WARNING("Error retrieving JetElements" );
133  }
134  else ATH_MSG_WARNING("No JetElementContainer at " << m_JetElementInputKey );
135 
136 
137  // Store module readout and backplane results in the TES
139  storeModuleRoIs();
140 
141  // Clean up at end of event
142  m_JetCMXData = 0;
143  m_allTOBs = 0;
144 
145  return StatusCode::SUCCESS;
146 }
147 
150 
151  size_t datasize = m_JetCMXData->size();
152 
153  // Store backplane data objects
155  const EventContext& ctx = Gaudi::Hive::currentContext();
156  StatusCode sc = SG::makeHandle(m_JetCMXDataOutputKey, ctx).record( std::unique_ptr<DataVector<JetCMXData>>(m_JetCMXData) );
157  m_JetCMXData = nullptr;
158 
159  if (sc.isSuccess()) {
160  ATH_MSG_VERBOSE ( "Stored " << datasize
161  << " JetCMXData at " << m_JetCMXDataOutputKey );
162  }
163  else {
164  ATH_MSG_ERROR("failed to write JetCMXData to "
165  << m_JetCMXDataOutputKey );
166  }
167 
168  return;
169 
170 } //end storeBackplaneTOBs
171 
172 
175 
176  size_t n_jetsTobs = m_allTOBs->size();
177 
178  const EventContext& ctx = Gaudi::Hive::currentContext();
179  StatusCode sc = SG::makeHandle(m_JEMTobRoIOutputKey, ctx).record( std::unique_ptr<DataVector<JEMTobRoI>>(m_allTOBs) );
180  m_allTOBs = nullptr;
181 
182  if (sc.isSuccess()) {
183  ATH_MSG_VERBOSE ( "Stored " << n_jetsTobs
184  << " Jet TOBs at " << m_JEMTobRoIOutputKey );
185  }
186  else {
187  ATH_MSG_ERROR("failed to write JEMTobRoIs to "
188  << m_JEMTobRoIOutputKey );
189  }
190 
191 } //end storeModuleRoIs
192 
193 
194 } // end of LVL1 namespace bracket
195 
196 
LVL1::JEMJetSim::m_JetCMXData
DataVector< JetCMXData > * m_JetCMXData
Backplane data objects: CPM outputs to CMX.
Definition: JEMJetSim.h:86
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
skel.it
it
Definition: skel.GENtoEVGEN.py:396
JetInput.h
LVL1::JetCMXData
The JetCMXData object contains the data transferred from the CPM to one of the Jet CMX in the crate.
Definition: JetCMXData.h:25
CoordToHardware.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
LVL1::JEMJetSim::m_JEMTobRoIOutputKey
SG::WriteHandleKey< DataVector< JEMTobRoI > > m_JEMTobRoIOutputKey
Locations of outputs in StoreGate.
Definition: JEMJetSim.h:92
LVL1::JEMJetSim::JEMJetSim
JEMJetSim(const std::string &name, ISvcLocator *pSvcLocator)
Definition: JEMJetSim.cxx:47
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LVL1::JEMJetSim::initialize
StatusCode initialize()
Definition: JEMJetSim.cxx:60
JetElementContainer.h
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LVL1::JEMJetSim::m_JetTool
ToolHandle< LVL1::IL1JEMJetTools > m_JetTool
The essentials - data access, configuration, tools.
Definition: JEMJetSim.h:96
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
JEMTobRoI_ClassDEF.h
LVL1::JEMJetSim::storeBackplaneTOBs
void storeBackplaneTOBs()
Store module outputs in TES as inputs to CMX simulation.
Definition: JEMJetSim.cxx:149
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LVL1::JEMJetSim::storeModuleRoIs
void storeModuleRoIs()
Store TOB RoI objects in the TES.
Definition: JEMJetSim.cxx:174
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AthAlgorithm
Definition: AthAlgorithm.h:47
JetCMXData_ClassDEF.h
TrigConf::name
Definition: HLTChainList.h:35
LVL1::JEMJetSim::m_allTOBs
DataVector< JEMTobRoI > * m_allTOBs
TOB RoIs for RoIB input and DAQ output simulation.
Definition: JEMJetSim.h:83
LVL1::JEMJetSim::execute
StatusCode execute()
Definition: JEMJetSim.cxx:76
TrigT1CaloDefs.h
L1DataDef.h
JetEnergyModuleKey.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TrigT1Interfaces_ClassDEF.h
JEMJetSim.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
LVL1::JEMJetSim::m_JetCMXDataOutputKey
SG::WriteHandleKey< DataVector< JetCMXData > > m_JetCMXDataOutputKey
Definition: JEMJetSim.h:93
LVL1::JEMJetSim::m_JetElementInputKey
SG::ReadHandleKey< xAOD::JetElementContainer > m_JetElementInputKey
Where to find the JetElements.
Definition: JEMJetSim.h:89