ATLAS Offline Software
Loading...
Searching...
No Matches
RoIROD.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 RoIROD.cxx - description
6 -------------------
7 begin : Mon Jul 28 2014
8 email : Alan.Watson@CERN.CH
9 ***************************************************************************/
10
11
12
13//#include <fstream>
14#include <string>
15
16// running in Athena
17#include "RoIROD.h"
18
20
21#include <algorithm>
22
23
25 ( const std::string& name, ISvcLocator* pSvcLocator )
26 : AthReentrantAlgorithm( name, pSvcLocator ),
27 m_emTauSlinkLocation(TrigT1CaloDefs::EmTauSlinkLocation),
28 m_jepSlinkLocation(TrigT1CaloDefs::jepSlinkLocation)
29{
30
31 declareProperty( "EmTauSlinkLocation", m_emTauSlinkLocation );
32 declareProperty( "JEPSlinkLocation", m_jepSlinkLocation );
33}
34
35// Destructor
38
39
40//---------------------------------
41// initialise()
42//---------------------------------
43
45{
46 ATH_CHECK( m_emTauRoILocation.initialize() );
47 ATH_CHECK( m_JetRoILocation.initialize() );
48 ATH_CHECK( m_energyRoILocation.initialize() );
49
50 m_jepSlinkKeys.clear();
51 m_jepSlinkKeys.push_back (m_jepSlinkLocation + "0");
52 m_jepSlinkKeys.push_back (m_jepSlinkLocation + "1");
53 ATH_CHECK( m_jepSlinkKeys.initialize() );
54
55 m_emTauSlinkKeys.clear();
56 m_emTauSlinkKeys.push_back (m_emTauSlinkLocation + "0");
57 m_emTauSlinkKeys.push_back (m_emTauSlinkLocation + "1");
58 m_emTauSlinkKeys.push_back (m_emTauSlinkLocation + "2");
59 m_emTauSlinkKeys.push_back (m_emTauSlinkLocation + "3");
60 ATH_CHECK( m_emTauSlinkKeys.initialize() );
61
62 return StatusCode::SUCCESS ;
63}
64
65
66//---------------------------------
67// finalise()
68//---------------------------------
69
71{
72 ATH_MSG_INFO("Finalizing" );
73 return StatusCode::SUCCESS ;
74}
75
76
77//----------------------------------------------
78// execute() method called once per event
79//----------------------------------------------
80//
81
82StatusCode LVL1::RoIROD::execute (const EventContext& ctx) const
83{
84 ATH_MSG_DEBUG("Executing" );
85
89
93 assignVectors (CPRoIROD, jepRoIROD); // create new storage vectors
94 formSlinkObjects (CPRoIROD, jepRoIROD, ctx); // Fill storage vectors
95 ATH_CHECK( saveSlinkObjects (CPRoIROD, jepRoIROD, ctx) ); // save storage vectors
96
97 return StatusCode::SUCCESS ;
98}
99
103 const EventContext& ctx) const
104{
105 ATH_MSG_DEBUG("formSlinkObjects" );
106
108 for (unsigned int i = 0; i<TrigT1CaloDefs::numOfCPRoIRODs;i++){
109 addHeader(*CPRoIROD[i],0x72,i, ctx);//set modID to crate #
110 }
111 for (unsigned int i = 0; i<TrigT1CaloDefs::numOfJEPRoIRODs;i++){
112 addHeader(*jepRoIROD[i],0x73,i, ctx);//set modID to crate #
113 }
114
115
117 ATH_MSG_DEBUG("Load and process CPM TOBs");
121 for (const CPMTobRoI* tau : *EMTaus) {
122 int crate = tau->crate();
123 CPRoIROD[crate]->push_back( getWord(tau->roiWord()) );
124 }
125
126
128 ATH_MSG_DEBUG("Load and process Jet TOBs");
132 for (const JEMTobRoI* jet : *Jets) {
133 int crate = jet->crate();
134 jepRoIROD[crate]->push_back( getWord(jet->roiWord()) );
135 }
136
137
141 jepRoIROD[1]->push_back(getWord(energy->exWord(LVL1::CMXRoI::NORMAL)));
142 jepRoIROD[1]->push_back(getWord(energy->eyWord(LVL1::CMXRoI::NORMAL)));
143 jepRoIROD[1]->push_back(getWord(energy->etWord(LVL1::CMXRoI::NORMAL)));
144 jepRoIROD[1]->push_back(getWord(energy->exWord(LVL1::CMXRoI::MASKED)));
145 jepRoIROD[1]->push_back(getWord(energy->eyWord(LVL1::CMXRoI::MASKED)));
146 jepRoIROD[1]->push_back(getWord(energy->etWord(LVL1::CMXRoI::MASKED)));
147
148
150 const unsigned int headerWords=8+1;//8 in Slink head + control word
151
152 for (unsigned int i = 0; i<TrigT1CaloDefs::numOfCPRoIRODs;i++){
153 addTail(*CPRoIROD[i], (CPRoIROD[i]->size()-headerWords) );
154 }
155 for (unsigned int i = 0; i<TrigT1CaloDefs::numOfJEPRoIRODs;i++){
156 addTail(*jepRoIROD[i], (jepRoIROD[i]->size()-headerWords) );
157 }
158
159 return;
160}
161
164 unsigned int subDetID,
165 unsigned int moduleId,
166 const EventContext& ctx) const
167{
168 slink.push_back(getWord(0xb0f00000)); // beginning of fragment word (control word)
169 slink.push_back(getWord(0xee1234ee)); // start of header marker
170 slink.push_back(getWord(8)); // header length
171 slink.push_back(getWord(1)); // format version number
172 unsigned int moduleType=0x00; // ROD
173 slink.push_back(getWord( (moduleType<<16)+(subDetID<<8)+moduleId )); // 1st 8b but source id: CP system
174 slink.push_back(getWord(ctx.eventID().event_number())); // 8b ECR_count (set to 0) | 24b L1 id = evt number
175 slink.push_back( getWord(1 )); // 8b BCID
176 slink.push_back( getWord(1 )); // 8b L1 trig type
177 slink.push_back( getWord(0 )); // detector evt type}
178}
179
182 unsigned int numberOfDataWords) const
183{
184 slink.push_back(getWord(0 )); // write status word 1
185 slink.push_back(getWord(0 )); // write status word 2
186//^^^ not simulating any errors.
187 slink.push_back(getWord(2 )); // status block length
188 slink.push_back(getWord(numberOfDataWords)); // calculated data block length
189 slink.push_back(getWord(1 )); // status block position
190// ^^^ indicates that data precedes status block
191 slink.push_back(getWord(0xe0f00000 )); // end of fragment word
192}
193
197 const EventContext& ctx) const
198{
199 ATH_MSG_DEBUG("saveSlinkObjects");
200
201 for (unsigned int i = 0; i<TrigT1CaloDefs::numOfCPRoIRODs;++i){
202 ATH_CHECK( SG::makeHandle (m_emTauSlinkKeys[i], ctx).record (std::move(CPRoIROD[i])) );
203 }
204
205 for (unsigned int i = 0; i<TrigT1CaloDefs::numOfJEPRoIRODs;++i){
206 ATH_CHECK( SG::makeHandle (m_jepSlinkKeys[i], ctx).record (std::move(jepRoIROD[i])) );
207 }
208
209 return StatusCode::SUCCESS;
210}
211
212
216{
217 ATH_MSG_DEBUG("assignVectors" );
218
219 for (unsigned int i = 0; i<TrigT1CaloDefs::numOfCPRoIRODs;i++){
220 CPRoIROD[i] = std::make_unique<t_SlinkContainer>();
221 }
222 for (unsigned int i = 0; i<TrigT1CaloDefs::numOfJEPRoIRODs;i++){
223 jepRoIROD[i] = std::make_unique<t_SlinkContainer>();
224 }
225
226}
227
228std::unique_ptr<LVL1CTP::SlinkWord>
229LVL1::RoIROD::getWord(unsigned int tword) const
230{
231 return std::make_unique<LVL1CTP::SlinkWord>(tword);
232}
233
234
237{
238 for (unsigned int slink=0; slink<(TrigT1CaloDefs::numOfCPRoIRODs);slink++){
239 ATH_MSG_INFO("Slink cable "<<slink
240 <<" has "<<(CPRoIROD[slink]->size())<<" words");
241 for (DataVector<LVL1CTP::SlinkWord>::iterator i=CPRoIROD[slink]->begin();
242 i!=CPRoIROD[slink]->end();++i){
243 ATH_MSG_INFO("Word :"<<MSG::hex<<(*i)->word()<<MSG::dec);
244 }
245 }
246}
247
248
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
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
std::string m_jepSlinkLocation
Definition RoIROD.h:109
SG::ReadHandleKey< t_EnergyRoIContainer > m_energyRoILocation
Definition RoIROD.h:103
virtual StatusCode initialize() override
Definition RoIROD.cxx:44
DataVector< LVL1CTP::SlinkWord > t_SlinkContainer
Definition RoIROD.h:53
std::unique_ptr< t_SlinkContainer > t_SlinkPtr
Definition RoIROD.h:54
SG::WriteHandleKeyArray< t_SlinkContainer > m_jepSlinkKeys
Definition RoIROD.h:111
SG::WriteHandleKeyArray< t_SlinkContainer > m_emTauSlinkKeys
Definition RoIROD.h:107
RoIROD(const std::string &name, ISvcLocator *pSvcLocator)
Definition RoIROD.cxx:25
SG::ReadHandleKey< t_jemTobRoIContainer > m_JetRoILocation
Definition RoIROD.h:101
virtual StatusCode finalize() override
Definition RoIROD.cxx:70
void dumpSlinks(t_SlinkPtr CPRoIROD[TrigT1CaloDefs::numOfCPRoIRODs]) const
prints out the Slink info.
Definition RoIROD.cxx:236
void addTail(t_SlinkContainer &slink, unsigned int numberOfDataWords) const
add Slink tail
Definition RoIROD.cxx:181
SG::ReadHandleKey< t_cpmTobRoIContainer > m_emTauRoILocation
Definition RoIROD.h:99
StatusCode saveSlinkObjects(t_SlinkPtr CPRoIROD[TrigT1CaloDefs::numOfCPRoIRODs], t_SlinkPtr jepRoIROD[TrigT1CaloDefs::numOfJEPRoIRODs], const EventContext &ctx) const
save Slink Objects to SG
Definition RoIROD.cxx:195
void assignVectors(t_SlinkPtr CPRoIROD[TrigT1CaloDefs::numOfCPRoIRODs], t_SlinkPtr jepRoIROD[TrigT1CaloDefs::numOfJEPRoIRODs]) const
Create the object vectors to be stored in SG and clear mult vectors.
Definition RoIROD.cxx:214
virtual StatusCode execute(const EventContext &ctx) const override
Definition RoIROD.cxx:82
std::unique_ptr< LVL1CTP::SlinkWord > getWord(unsigned int tword) const
creates a new SlinkWord object with the passed word, and returns a pointer.
Definition RoIROD.cxx:229
std::string m_emTauSlinkLocation
Definition RoIROD.h:105
void formSlinkObjects(t_SlinkPtr CPRoIROD[TrigT1CaloDefs::numOfCPRoIRODs], t_SlinkPtr jepRoIROD[TrigT1CaloDefs::numOfJEPRoIRODs], const EventContext &ctx) const
get ROIwords and form Slink words from them, adding header and tail.
Definition RoIROD.cxx:101
virtual ~RoIROD()
Definition RoIROD.cxx:36
void addHeader(t_SlinkContainer &slink, unsigned int subDetID, unsigned int moduleId, const EventContext &ctx) const
adds slink header
Definition RoIROD.cxx:163
static const unsigned int numOfJEPRoIRODs
static const unsigned int numOfCPRoIRODs
Definition Jets.py:1
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())