ATLAS Offline Software
CPMSim.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // /***************************************************************************
6 // CPMSim.cxx - description
7 // -------------------
8 // begin : Wed Mar 05 2014
9 // email : Alan.Watson@CERN.CH
10 // ***************************************************************************/
11 //
12 //
13 //================================================
14 // CPMSim class Implementation
15 // ================================================
16 //
17 //
18 //
19 
20 // Utilities
21 
22 // This algorithm includes
23 #include "CPMSim.h"
26 
31 
32 #include "StoreGate/ReadHandle.h"
33 #include "StoreGate/WriteHandle.h"
34 
35 
36 
37 namespace LVL1{
38 
39 using namespace TrigConf;
40 
41 //--------------------------------
42 // Constructors and destructors
43 //--------------------------------
44 
46  ( const std::string& name, ISvcLocator* pSvcLocator )
47  : AthReentrantAlgorithm( name, pSvcLocator ),
48  m_CPMTool("LVL1::L1CPMTools/L1CPMTools")
49 {
50 }
51 
52 
53 //---------------------------------
54 // initialise()
55 //---------------------------------
56 
58 {
59  ATH_CHECK( m_CPMTool.retrieve() );
60  ATH_CHECK( m_CPMTowerLocation.initialize() );
61  ATH_CHECK( m_CPMCMXDataLocation.initialize() );
62  ATH_CHECK( m_CPMTobRoILocation.initialize() );
64 
65  return StatusCode::SUCCESS ;
66 }
67 
68 
69 //----------------------------------------------
70 // execute() method called once per event
71 //----------------------------------------------
72 //
73 
74 
75 StatusCode CPMSim::execute(const EventContext& ctx) const
76 {
77 
78  /* Retrieve collection of CPMTowers
79  Form TOBs from them
80  Form backplane data from TOBs
81  Store TOBs for BS simulation
82  Form and store RoI SLink data for RoIB
83  */
84 
85  ATH_MSG_DEBUG ( "starting CPMSim" );
86 
87  // Create containers for this event
88  auto CMXData = std::make_unique<DataVector<CPMCMXData> >(); //Container of backplane data objects
89  auto allTOBs = std::make_unique<DataVector<CPMTobRoI> >(); // Container to hold all TOB RoIs in event
90 
92  (m_CPMTowerLocation, ctx);
93 
94  if (storedCPMTs->size() == 0)
95  ATH_MSG_WARNING("Empty CPMTowerContainer - looks like a problem" );
96 
97  // Map the CPMTs
98  xAOD::CPMTowerMap_t towerMap;
99  m_CPMTool->mapTowers(storedCPMTs.cptr(), &towerMap);
100 
101  // get the L1Menu for the CPMTool
102  auto l1Menu = SG::makeHandle( m_L1MenuKey, ctx );
103  const TrigConf::L1Menu* l1Menu_ptr=l1Menu.cptr();
104 
105  // Loop over crates and modules
106  for (int iCrate = 0; iCrate < 4; ++iCrate) {
107  for (int iModule = 1; iModule <= 14; ++iModule) {
108 
109  // For each module, find TOBs and backplane data
110  std::vector<unsigned int> emCMXData;
111  std::vector<unsigned int> tauCMXData;
112  m_CPMTool->findCPMResults(l1Menu_ptr,&towerMap,iCrate,iModule,allTOBs.get(),emCMXData,tauCMXData);
113  // Push backplane data into output DataVectors
114  CMXData -> push_back(std::make_unique<CPMCMXData>(iCrate,iModule,0,emCMXData));
115  CMXData -> push_back(std::make_unique<CPMCMXData>(iCrate,iModule,1,tauCMXData));
116 
117  } // loop over modules
118  } // loop over crates
119 
120 
121  // Store RoIB output, module readout and backplane results in the TES
122  ATH_CHECK( SG::makeHandle(m_CPMCMXDataLocation, ctx).record (std::move (CMXData)) );
123  ATH_CHECK( SG::makeHandle(m_CPMTobRoILocation, ctx).record (std::move (allTOBs)) );
124 
125  return StatusCode::SUCCESS ;
126 }
127 
128 
129 } // end of LVL1 namespace bracket
130 
131 
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
CPMTowerContainer.h
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
CoordToHardware.h
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
CPMSim.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
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
WriteHandle.h
Handle class for recording to StoreGate.
LVL1::CPMSim::CPMSim
CPMSim(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CPMSim.cxx:46
CPMTobRoI_ClassDEF.h
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
LVL1::CPMSim::m_CPMTobRoILocation
SG::WriteHandleKey< DataVector< CPMTobRoI > > m_CPMTobRoILocation
Locations of outputs in StoreGate.
Definition: CPMSim.h:118
xAOD::CPMTowerMap_t
std::map< int, const CPMTower * > CPMTowerMap_t
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CPMTower.h:18
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LVL1::CPMSim::m_CPMCMXDataLocation
SG::WriteHandleKey< DataVector< CPMCMXData > > m_CPMCMXDataLocation
Definition: CPMSim.h:120
LVL1::CPMSim::m_CPMTool
ToolHandle< LVL1::IL1CPMTools > m_CPMTool
The essentials - data access, configuration, tools.
Definition: CPMSim.h:123
LVL1::CPMSim::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: CPMSim.cxx:75
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TrigConf::name
Definition: HLTChainList.h:35
LVL1::CPMSim::m_L1MenuKey
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
Definition: CPMSim.h:111
L1DataDef.h
LVL1::CPMSim::m_CPMTowerLocation
SG::ReadHandleKey< xAOD::CPMTowerContainer > m_CPMTowerLocation
Where to store the CPMTowers.
Definition: CPMSim.h:115
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CPMCMXData_ClassDEF.h
TrigT1Interfaces_ClassDEF.h
LVL1::CPMSim::initialize
virtual StatusCode initialize() override
Definition: CPMSim.cxx:57
ReadHandle.h
Handle class for reading from StoreGate.