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 //Specialized method to convert ROD Data words into LArDigit
158 const uint32_t* p, uint32_t n, LArDigitContainer& coll, const CaloGain::CaloGain gain) const;
159
160 //Specialized method to convert ROD Accumulated Calib Digit words into LArAccumulatedCalibDigit
162 const uint32_t* p,
163 uint32_t n,
165 const CaloGain::CaloGain gain,
166 const LArCalibLineMapping& calibLineMapping) const;
167
168 //Specialized method to convert ROD Accumulated Digit words into LArAccumulatedDigit
170 const uint32_t* p, uint32_t n, LArAccumulatedDigitContainer& coll, const CaloGain::CaloGain gain) const;
171
172 //Specialized method to convert ROD Data words into LArCalibDigit
174 const uint32_t* p,
175 uint32_t n,
177 const CaloGain::CaloGain gain,
178 const LArCalibLineMapping& calibLineMapping,
179 const LArOnOffIdMapping& onOffIdMapping) const;
180
181 //Specialized method to convert ROD Data words to read the headers of the Feb
183 const uint32_t* p, uint32_t n, LArFebHeaderContainer& coll, const CaloGain::CaloGain) const;
184
185 //Check an eformat fragment for validity. Report an error if it's not valid.
186 template <class T>
187 inline bool check_valid (const T* frag, MsgStream& log) const;
188 //Inputs: frag: The fragment to check
189 // log: The Gaudi MsgStream.
190
191
192
193private:
194 LArRodBlockStructure* prepareBlockStructure1(const uint16_t rodMinorVersion, const uint32_t robBlockType) const;
196 const uint32_t* p, uint32_t n, const CaloGain::CaloGain RequestedGain) const;
197
198 std::unique_ptr<LArRodBlockStructure>
199 makeBlockStructure (unsigned int rodBlockType,
200 unsigned int rodMinorVersion) const;
201
202 inline void setCellEnergy(
203 LArCell* element, int energy, int time,
204 int quality, CaloGain::CaloGain gain) const ;
205
206 inline void writeFebInfo(
207 LArCellCollection& m_coll, LArFebEnergy& febene) const;
208
209
210 SG::ReadHandleKey<xAOD::EventInfo> m_evt {this, "EvtInfo", "EventInfo", "EventInfo name"};
212 bool m_readtdc; // set to True if the tdc phase is read from the upper byte of the nsamples word.
213 bool m_febExchange; //HW cause, can not be fixed otherwise: Ugly hack for swapped FEB
214 unsigned int m_febId1, m_febId2, m_febIdHLT = 0U;
215
216 int m_firstSample; // FIXED but kept for backward compatibility
217 // In Auto-Gain mode, the FEB does not send the samples in the right order, but the one first that
218 // was used for the gain selection. Unfortunatly, there is no way to extract the index if this sample
219 // form the raw data, one has to know it in advance (from the FEB configuration).
220 // For the time beeing, the jobOption ToolSvc.LArRodDecoder.FirstSample tells the LArRodDecoder what
221 // sample to put in front.
222
223
224 std::vector<int> m_vFTPreselection;
225 std::vector<int> m_vBEPreselection;
226 std::vector<int> m_vPosNegPreselection;
227 std::vector<unsigned int> m_vFinalPreselection;
230 std::vector<std::string> m_LArCellCorrNames;
231 std::vector<unsigned int> m_IgnoreCheckFEBs;
232 std::vector<const CaloCellCorrection*> m_LArCellCorrTools;
233
236 m_blstructs ATLAS_THREAD_SAFE;
237
241} ;
242
243template <class T>
244inline bool LArRodDecoder::check_valid (const T* frag, MsgStream& /*log*/) const
245{
246 bool ret=false;
247 try {
248 ret=frag->check();
249 }
250 catch (eformat::Issue& ex) {
251 msg(MSG::WARNING) << "Exception while checking eformat fragment validity: " << ex.what() << endmsg;
252 ret=false;
253 }
254 return ret;
255
256}
257
258// fillCollection for HLT without automatic BS Cnv
259// default values
260static uint16_t rMV=99;
261static uint32_t rBT=99;
263 const uint32_t* p, uint32_t n,
264 LArCellCollection& coll,
265 LArRodBlockStructure*& providedRodBlockStructure, uint16_t& rodMinorVersion = rMV , uint32_t& robBlockType = rBT ) const
266{
267 LArCell *collElem=0; //Pointer to a new element to be added to the collection
268 uint32_t error = 0;
269
270#ifndef NDEBUG
271 ATH_MSG_VERBOSE("Prepare LArRodBlockStructure. Got a fragment of size " << n);
272#endif
273 const uint32_t blocksize=p[0]; //First word contains block size
274 if (blocksize>n) {
275 msg(MSG::ERROR) << "Got truncated ROD Fragment!" << endmsg;
276 // First Bit is truncated (see also below)
277 error|= 0x1;
278 return error;
279 }
280
281 //Get version and blocktype form header
282 eformat::helper::Version ver(robFrag.rod_version());
283 const uint16_t rMV_present=ver.minor_version();
284 const uint32_t rBT_present=robFrag.rod_detev_type()&0xff;
285
286 LArRodBlockStructure* BlStruct(nullptr);
287 if ( !providedRodBlockStructure || (rodMinorVersion!=rMV_present) || (robBlockType!=rBT_present) ){
288 BlStruct = prepareBlockStructure1 (rMV_present, rBT_present);
289 if (!BlStruct) {
290 // Second Bit is block empty or unknown
291 error|= 0x2;
292 return error;
293 }
294 providedRodBlockStructure = BlStruct;
295 rodMinorVersion = rMV_present;
296 robBlockType = rBT_present;
297 } else BlStruct = providedRodBlockStructure;
298
299 BlStruct->setFragment(p,n);
300 for(LArCellCollection::iterator ii=coll.begin();ii!=coll.end();++ii)
301 (*ii)->setEnergyFast(0.0);
302
303 int32_t energy(0);
304 int32_t time;
305 int32_t quality;
306 uint32_t gain;
307 CaloGain::CaloGain calogain;
308 int fcNb;
309 int nfeb;
310 calogain=CaloGain::LARNGAIN;
311 if(!BlStruct->setGain(calogain)){
312 ATH_MSG_DEBUG("Setting the Gain Problem");
313 }
314
315 int feb_number=0;
316 do //Loop over FEB's
317 {
318 HWIdentifier fId(BlStruct->getFEBID());
319 if (!(fId.get_identifier32().get_compact())) {
320#ifndef NDEBUG
321 ATH_MSG_DEBUG("Bad FebID=0x"<< std::hex << BlStruct->getFEBID() << std::dec << " found for this FEB, skipping it!");
322#endif
323 // Third Bit is FEB ID issue (disabled - use 0x20 instead)
324 //error|= 0x4;
325 continue;
326 }
327 // RL 05.11.2007 checksum
328 if(m_CheckSum) {
329 uint32_t onsum = BlStruct->onlineCheckSum();
330 uint32_t offsum = BlStruct->offlineCheckSum();
331 if(onsum!=offsum) {
332 msg(MSG::WARNING) << "Checksum error:" << endmsg;
333 msg(MSG::WARNING) << " online checksum = 0x" << MSG::hex << onsum << endmsg;
334 msg(MSG::WARNING) << " offline checksum = 0x" << MSG::hex << offsum << MSG::dec << endmsg;
335 // Fourth Bit CheckSum issue (maybe disabled!)
336 error|= 0x8;
337 continue;
338 }
339 }
340 feb_number++;
341
342 if ( BlStruct->hasPhysicsBlock() ) {
343 if ( fId == m_febIdHLT ) nfeb = 128; // This is the second feb
344 else nfeb = 0;
345 int NthisFebChannel=128 ; // m_onlineHelper->channelInSlotMax(fId);
346 uint16_t iquality;
347 uint16_t iprovenance;
348 while (BlStruct->getNextEnergy(fcNb,energy,time,quality,gain)) {
349 if (fcNb>=NthisFebChannel) continue;
350 collElem = coll[fcNb+nfeb];
351 iprovenance=0x1000; // data comes from DSP computation
352 iquality=0;
353 if ( quality>=0 ) { iprovenance|= 0x2000; iquality=(quality& 0xffff);}
354 // time converted to ns
355 collElem->set(energy, time*1e-3, iquality, iprovenance, (CaloGain::CaloGain)gain);
356 }
357 continue;
358 }
359 }
360 while (BlStruct->nextFEB()); //Get NextFeb
361 // Error meaning data corruption. Maybe in any FEB
362 if ( BlStruct->report_error() ) error |= 0x1;
363 // error of uncompatible number of cells is bit 5
364 unsigned int collection_size = coll.size();
365 if ( feb_number== 0 && collection_size>0 ) error |= 0x20;
366 if ( feb_number== 1 && collection_size !=128 ) error |= 0x20;
367 if ( feb_number== 2 && collection_size !=256 ) error |= 0x20;
368 return error;
369}
370
372 LArCell* element, int energy, int time,
373 int quality, CaloGain::CaloGain gain) const
374{
375 // Set energy, time, quality and hardware gain
376 element->set((float)energy, (float)time, (double)quality, gain);
377}
378
380 LArCellCollection& coll, LArFebEnergy& febene) const
381 {
382 coll.addfebenergy(febene);
383 }
384
385#endif
386
#define endmsg
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(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:842
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 LArAccumulatedCalibDigit.
Container class for LArAccumulatedDigit.
Container class for LArCalibDigit.
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
Container class for LArDigit.
Holds partial energy sums Ex,Ey,Ez for each Feb.
Container class for LArFebHeader.
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()