ATLAS Offline Software
Loading...
Searching...
No Matches
CPMSim.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// 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
34
35
36
37namespace LVL1{
38
39using 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() );
63 ATH_CHECK( m_L1MenuKey.initialize() );
64
65 return StatusCode::SUCCESS ;
66}
67
68
69//----------------------------------------------
70// execute() method called once per event
71//----------------------------------------------
72//
73
74
75StatusCode 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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
SG::WriteHandleKey< DataVector< CPMCMXData > > m_CPMCMXDataLocation
Definition CPMSim.h:112
virtual StatusCode initialize() override
Definition CPMSim.cxx:57
virtual StatusCode execute(const EventContext &ctx) const override
Definition CPMSim.cxx:75
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
Definition CPMSim.h:103
ToolHandle< LVL1::IL1CPMTools > m_CPMTool
The essentials - data access, configuration, tools.
Definition CPMSim.h:115
CPMSim(const std::string &name, ISvcLocator *pSvcLocator)
Definition CPMSim.cxx:46
SG::WriteHandleKey< DataVector< CPMTobRoI > > m_CPMTobRoILocation
Locations of outputs in StoreGate.
Definition CPMSim.h:110
SG::ReadHandleKey< xAOD::CPMTowerContainer > m_CPMTowerLocation
Where to store the CPMTowers.
Definition CPMSim.h:107
L1 menu configuration.
Definition L1Menu.h:28
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())
std::map< int, const CPMTower * > CPMTowerMap_t