ATLAS Offline Software
Loading...
Searching...
No Matches
LArRodDecoder.h
Go to the documentation of this file.
1//Dear emacs, this is -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7
8#ifndef LARBYTESTREAM_LARRODDECODER_H
9#define LARBYTESTREAM_LARRODDECODER_H
10
11#include <stdint.h>
12
13//#include "GaudiKernel/AlgTool.h"
14//#include "GaudiKernel/MsgStream.h"
15
17#include "GaudiKernel/ToolHandle.h"
18
29
30
33
37
42
43#include "eformat/Version.h"
44#include "eformat/Issue.h"
45#include <vector>
46#include <string>
47
50
123
124
125//using namespace OFFLINE_FRAGMENTS_NAMESPACE ;
126
128{
129
130public:
134 LArRodDecoder(const std::string& type, const std::string& name,
135 const IInterface* parent ) ;
136
137 static const InterfaceID& interfaceID( ) ;
140 virtual ~LArRodDecoder();
141
142 virtual StatusCode initialize ATLAS_NOT_THREAD_SAFE () override;
143
144 // Simple method to associate the second feb
146
147 // fast decoding for trigger
148 inline uint32_t fillCollectionHLT (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment& robFrag,
149 const uint32_t* p, uint32_t n, LArCellCollection& coll,
150 LArRodBlockStructure*& providedRodBlockStructure,
151 uint16_t& rodMinorVersion, uint32_t& robBlockType) const;
152
154 const uint32_t* p, uint32_t n, LArRawChannelContainer& coll, const CaloGain::CaloGain gain) const;
155
156 //Check an eformat fragment for validity. Report an error if it's not valid.
157 template <class T>
158 inline bool check_valid (const T* frag, MsgStream& log) const;
159 //Inputs: frag: The fragment to check
160 // log: The Gaudi MsgStream.
161
162
163
164private:
165 LArRodBlockStructure* prepareBlockStructure1(const uint16_t rodMinorVersion, const uint32_t robBlockType) const;
167 const uint32_t* p, uint32_t n, const CaloGain::CaloGain RequestedGain) const;
168
169 std::unique_ptr<LArRodBlockStructure>
170 makeBlockStructure (unsigned int rodBlockType,
171 unsigned int rodMinorVersion) const;
172
173 inline void setCellEnergy(
174 LArCell* element, int energy, int time,
175 int quality, CaloGain::CaloGain gain) const ;
176
177 inline void writeFebInfo(
178 LArCellCollection& m_coll, LArFebEnergy& febene) const;
179
180
181 SG::ReadHandleKey<xAOD::EventInfo> m_evt {this, "EvtInfo", "EventInfo", "EventInfo name"};
183 bool m_readtdc; // set to True if the tdc phase is read from the upper byte of the nsamples word.
184 bool m_febExchange; //HW cause, can not be fixed otherwise: Ugly hack for swapped FEB
185 unsigned int m_febId1, m_febId2, m_febIdHLT = 0U;
186
187 int m_firstSample; // FIXED but kept for backward compatibility
188 // In Auto-Gain mode, the FEB does not send the samples in the right order, but the one first that
189 // was used for the gain selection. Unfortunatly, there is no way to extract the index if this sample
190 // form the raw data, one has to know it in advance (from the FEB configuration).
191 // For the time beeing, the jobOption ToolSvc.LArRodDecoder.FirstSample tells the LArRodDecoder what
192 // sample to put in front.
193
194
195 std::vector<int> m_vFTPreselection;
196 std::vector<int> m_vBEPreselection;
197 std::vector<int> m_vPosNegPreselection;
198 std::vector<unsigned int> m_vFinalPreselection;
201 std::vector<std::string> m_LArCellCorrNames;
202 std::vector<unsigned int> m_IgnoreCheckFEBs;
203 std::vector<const CaloCellCorrection*> m_LArCellCorrTools;
204
207 m_blstructs ATLAS_THREAD_SAFE;
208
212} ;
213
214template <class T>
215inline bool LArRodDecoder::check_valid (const T* frag, MsgStream& /*log*/) const
216{
217 bool ret=false;
218 try {
219 ret=frag->check();
220 }
221 catch (eformat::Issue& ex) {
222 msg(MSG::WARNING) << "Exception while checking eformat fragment validity: " << ex.what() << endmsg;
223 ret=false;
224 }
225 return ret;
226
227}
228
229// fillCollection for HLT without automatic BS Cnv
230// default values
231static uint16_t rMV=99;
232static uint32_t rBT=99;
234 const uint32_t* p, uint32_t n,
235 LArCellCollection& coll,
236 LArRodBlockStructure*& providedRodBlockStructure, uint16_t& rodMinorVersion = rMV , uint32_t& robBlockType = rBT ) const
237{
238 LArCell *collElem=0; //Pointer to a new element to be added to the collection
239 uint32_t error = 0;
240
241#ifndef NDEBUG
242 ATH_MSG_VERBOSE("Prepare LArRodBlockStructure. Got a fragment of size " << n);
243#endif
244 const uint32_t blocksize=p[0]; //First word contains block size
245 if (blocksize>n) {
246 msg(MSG::ERROR) << "Got truncated ROD Fragment!" << endmsg;
247 // First Bit is truncated (see also below)
248 error|= 0x1;
249 return error;
250 }
251
252 //Get version and blocktype form header
253 eformat::helper::Version ver(robFrag.rod_version());
254 const uint16_t rMV_present=ver.minor_version();
255 const uint32_t rBT_present=robFrag.rod_detev_type()&0xff;
256
257 LArRodBlockStructure* BlStruct(nullptr);
258 if ( !providedRodBlockStructure || (rodMinorVersion!=rMV_present) || (robBlockType!=rBT_present) ){
259 BlStruct = prepareBlockStructure1 (rMV_present, rBT_present);
260 if (!BlStruct) {
261 // Second Bit is block empty or unknown
262 error|= 0x2;
263 return error;
264 }
265 providedRodBlockStructure = BlStruct;
266 rodMinorVersion = rMV_present;
267 robBlockType = rBT_present;
268 } else BlStruct = providedRodBlockStructure;
269
270 BlStruct->setFragment(p,n);
271 for(LArCellCollection::iterator ii=coll.begin();ii!=coll.end();++ii)
272 (*ii)->setEnergyFast(0.0);
273
274 int32_t energy(0);
275 int32_t time;
276 int32_t quality;
277 uint32_t gain;
278 CaloGain::CaloGain calogain;
279 int fcNb;
280 int nfeb;
281 calogain=CaloGain::LARNGAIN;
282 if(!BlStruct->setGain(calogain)){
283 ATH_MSG_DEBUG("Setting the Gain Problem");
284 }
285
286 int feb_number=0;
287 do //Loop over FEB's
288 {
289 HWIdentifier fId(BlStruct->getFEBID());
290 if (!(fId.get_identifier32().get_compact())) {
291#ifndef NDEBUG
292 ATH_MSG_DEBUG("Bad FebID=0x"<< std::hex << BlStruct->getFEBID() << std::dec << " found for this FEB, skipping it!");
293#endif
294 // Third Bit is FEB ID issue (disabled - use 0x20 instead)
295 //error|= 0x4;
296 continue;
297 }
298 // RL 05.11.2007 checksum
299 if(m_CheckSum) {
300 uint32_t onsum = BlStruct->onlineCheckSum();
301 uint32_t offsum = BlStruct->offlineCheckSum();
302 if(onsum!=offsum) {
303 msg(MSG::WARNING) << "Checksum error:" << endmsg;
304 msg(MSG::WARNING) << " online checksum = 0x" << MSG::hex << onsum << endmsg;
305 msg(MSG::WARNING) << " offline checksum = 0x" << MSG::hex << offsum << MSG::dec << endmsg;
306 // Fourth Bit CheckSum issue (maybe disabled!)
307 error|= 0x8;
308 continue;
309 }
310 }
311 feb_number++;
312
313 if ( BlStruct->hasPhysicsBlock() ) {
314 if ( fId == m_febIdHLT ) nfeb = 128; // This is the second feb
315 else nfeb = 0;
316 int NthisFebChannel=128 ; // m_onlineHelper->channelInSlotMax(fId);
317 uint16_t iquality;
318 uint16_t iprovenance;
319 while (BlStruct->getNextEnergy(fcNb,energy,time,quality,gain)) {
320 if (fcNb>=NthisFebChannel) continue;
321 collElem = coll[fcNb+nfeb];
322 iprovenance=0x1000; // data comes from DSP computation
323 iquality=0;
324 if ( quality>=0 ) { iprovenance|= 0x2000; iquality=(quality& 0xffff);}
325 // time converted to ns
326 collElem->set(energy, time*1e-3, iquality, iprovenance, (CaloGain::CaloGain)gain);
327 }
328 continue;
329 }
330 }
331 while (BlStruct->nextFEB()); //Get NextFeb
332 // Error meaning data corruption. Maybe in any FEB
333 if ( BlStruct->report_error() ) error |= 0x1;
334 // error of uncompatible number of cells is bit 5
335 unsigned int collection_size = coll.size();
336 if ( feb_number== 0 && collection_size>0 ) error |= 0x20;
337 if ( feb_number== 1 && collection_size !=128 ) error |= 0x20;
338 if ( feb_number== 2 && collection_size !=256 ) error |= 0x20;
339 return error;
340}
341
343 LArCell* element, int energy, int time,
344 int quality, CaloGain::CaloGain gain) const
345{
346 // Set energy, time, quality and hardware gain
347 element->set((float)energy, (float)time, (double)quality, gain);
348}
349
351 LArCellCollection& coll, LArFebEnergy& febene) const
352 {
353 coll.addfebenergy(febene);
354 }
355
356#endif
357
#define endmsg
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_VERBOSE(x,...)
Maintain a set of objects, one per slot.
static uint16_t rMV
static uint32_t rBT
Property holding a SG store/key/clid from which a ReadHandle is made.
Define macros for attributes used to control the static checker.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
MsgStream & msg() const
void set(const CaloDetDescrElement *caloDDE, const Identifier &ID)
Fast method to change the identity of a cell.
Definition CaloCell.h:511
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:865
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Container Class for LArCell in a ROB used by EF.
void addfebenergy(LArFebEnergy &larfebenergy)
set the feb energy
Data object for LAr calorimeter readout cell.
Definition LArCell.h:53
Holds partial energy sums Ex,Ey,Ez for each Feb.
Container for LArRawChannel (IDC using LArRawChannelCollection).
bool setFragment(const uint32_t *p, uint32_t n)
virtual uint32_t hasPhysicsBlock() const
virtual int getNextEnergy(int &channelNumber, int32_t &energy, int32_t &time, int32_t &quality, uint32_t &gain)
bool report_error(void) const
virtual int setGain(const int GainValue)
virtual uint32_t offlineCheckSum() const
virtual uint32_t onlineCheckSum() const
std::vector< unsigned int > m_vFinalPreselection
uint32_t m_StatusNMask
virtual ~LArRodDecoder()
Destructor.
unsigned int m_febIdHLT
std::vector< std::string > m_LArCellCorrNames
LArRodBlockStructure * prepareBlockStructure1(const uint16_t rodMinorVersion, const uint32_t robBlockType) const
SG::SlotSpecificObj< std::vector< std::unique_ptr< LArRodBlockStructure > > > m_blstructs ATLAS_THREAD_SAFE
std::vector< int > m_vFTPreselection
const LArOnlineID * m_onlineHelper
std::vector< unsigned int > m_IgnoreCheckFEBs
unsigned int m_febId1
std::unique_ptr< LArRodBlockStructure > makeBlockStructure(unsigned int rodBlockType, unsigned int rodMinorVersion) const
SG::ReadHandleKey< xAOD::EventInfo > m_evt
static const InterfaceID & interfaceID()
float m_LArCellEthreshold
virtual StatusCode initialize ATLAS_NOT_THREAD_SAFE() override
void setCellEnergy(LArCell *element, int energy, int time, int quality, CaloGain::CaloGain gain) const
std::vector< const CaloCellCorrection * > m_LArCellCorrTools
unsigned short m_requiredPhysicsNSamples
std::vector< int > m_vBEPreselection
void fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, const uint32_t *p, uint32_t n, LArRawChannelContainer &coll, const CaloGain::CaloGain gain) const
unsigned int m_febId2
LArRodBlockStructure * prepareBlockStructure(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, const uint32_t *p, uint32_t n, const CaloGain::CaloGain RequestedGain) const
void setsecfeb(HWIdentifier feb)
uint32_t m_StatusMask
uint32_t fillCollectionHLT(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, const uint32_t *p, uint32_t n, LArCellCollection &coll, LArRodBlockStructure *&providedRodBlockStructure, uint16_t &rodMinorVersion, uint32_t &robBlockType) const
std::vector< int > m_vPosNegPreselection
LArRodDecoder(const std::string &type, const std::string &name, const IInterface *parent)
Constructor Standard AlgTool constructor.
void writeFebInfo(LArCellCollection &m_coll, LArFebEnergy &febene) const
bool check_valid(const T *frag, MsgStream &log) const
Property holding a SG store/key/clid from which a ReadHandle is made.
Maintain a set of objects, one per slot.
@ LARNGAIN
Definition CaloGain.h:19
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27
void initialize()