ATLAS Offline Software
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
37 }
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 
82 StatusCode 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");
118  SG::ReadHandle<t_cpmTobRoIContainer> EMTaus (m_emTauRoILocation, ctx);
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");
129  SG::ReadHandle<t_jemTobRoIContainer> Jets (m_JetRoILocation, ctx);
132  for (const JEMTobRoI* jet : *Jets) {
133  int crate = jet->crate();
134  jepRoIROD[crate]->push_back( getWord(jet->roiWord()) );
135  }
136 
137 
139  SG::ReadHandle<t_EnergyRoIContainer> energy (m_energyRoILocation, ctx);
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 
228 std::unique_ptr<LVL1CTP::SlinkWord>
229 LVL1::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 
DeMoGenerateWWW.addHeader
def addHeader(page, year)
Definition: DeMoGenerateWWW.py:82
LVL1::RoIROD::m_jepSlinkLocation
std::string m_jepSlinkLocation
Definition: RoIROD.h:119
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LVL1::RoIROD::addTail
void addTail(t_SlinkContainer &slink, unsigned int numberOfDataWords) const
add Slink tail
Definition: RoIROD.cxx:181
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
LVL1::RoIROD::initialize
virtual StatusCode initialize() override
Definition: RoIROD.cxx:44
LVL1::CMXRoI::NORMAL
@ NORMAL
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CMXRoI.h:26
LVL1::TrigT1CaloDefs::numOfJEPRoIRODs
static const unsigned int numOfJEPRoIRODs
Definition: TrigT1CaloDefs.h:225
LVL1::RoIROD::RoIROD
RoIROD(const std::string &name, ISvcLocator *pSvcLocator)
Definition: RoIROD.cxx:25
LVL1::RoIROD::addHeader
void addHeader(t_SlinkContainer &slink, unsigned int subDetID, unsigned int moduleId, const EventContext &ctx) const
adds slink header
Definition: RoIROD.cxx:163
RoIROD.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
LVL1::RoIROD::dumpSlinks
void dumpSlinks(t_SlinkPtr CPRoIROD[TrigT1CaloDefs::numOfCPRoIRODs]) const
prints out the Slink info.
Definition: RoIROD.cxx:236
LVL1::RoIROD::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: RoIROD.cxx:82
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
LVL1::RoIROD::~RoIROD
virtual ~RoIROD()
Definition: RoIROD.cxx:36
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
lumiFormat.i
int i
Definition: lumiFormat.py:92
LVL1::RoIROD::saveSlinkObjects
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
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::RoIROD::t_SlinkPtr
std::unique_ptr< t_SlinkContainer > t_SlinkPtr
Definition: RoIROD.h:64
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
TrigConf::name
Definition: HLTChainList.h:35
LVL1::RoIROD::getWord
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
LVL1::RoIROD::finalize
virtual StatusCode finalize() override
Definition: RoIROD.cxx:70
LVL1::JEMTobRoI
JEM RoI data.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMTobRoI.h:19
LVL1::RoIROD::m_emTauSlinkLocation
std::string m_emTauSlinkLocation
Definition: RoIROD.h:115
LVL1::CPMTobRoI
CPM RoI data.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTobRoI.h:19
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
LVL1::RoIROD::formSlinkObjects
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
LVL1::CMXRoI::MASKED
@ MASKED
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CMXRoI.h:26
LVL1::TrigT1CaloDefs
Definition: TrigT1CaloDefs.h:24
TrigT1Interfaces_ClassDEF.h
LVL1::TrigT1CaloDefs::numOfCPRoIRODs
static const unsigned int numOfCPRoIRODs
Definition: TrigT1CaloDefs.h:224
LVL1::RoIROD::assignVectors
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