ATLAS Offline Software
Loading...
Searching...
No Matches
LArRawDataContByteStreamTool Class Reference

An AlgTool class to help converting LAr raw data objects to/from ByteStream. More...

#include <LArRawDataContByteStreamTool.h>

Inheritance diagram for LArRawDataContByteStreamTool:
Collaboration diagram for LArRawDataContByteStreamTool:

Public Types

using FEA_t = FullEventAssembler<RodRobIdMap>

Public Member Functions

 LArRawDataContByteStreamTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor Standard AlgTool constructor.
virtual ~LArRawDataContByteStreamTool ()
 Destructor.
virtual StatusCode initialize () override
virtual StatusCode finalize () override
template<class COLLECTION, typename ... ARGS>
StatusCode convert (const RawEvent *re, COLLECTION *digit_cont, CaloGain::CaloGain gain, ARGS &&... args) const
 Templated conversion class form Raw Event to a container.
StatusCode WriteLArDigits (const LArDigitContainer *digit_cont, FEA_t &fea) const
 Fill channels from LArDigitContainer to a FullEvent.
StatusCode WriteLArCalibDigits (const LArCalibDigitContainer *digit_cont, FEA_t &fea) const
 Fill channels from LArCalibDigitContainer to a FullEvent.
StatusCode WriteLArRawChannels (const LArRawChannelContainer *CannelCont, FEA_t &fea) const
 Fill channels from LArRawChannelContainer to a FullEvent.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 AlgTool InterfaceID.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

using RobIndex_t = std::map<eformat::SubDetectorGroup, std::vector<const uint32_t*> >
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode prepareRobIndex (const RawEvent *event, RobIndex_t &robIndex) const
 Prepare ROB index before conversion.
std::unique_ptr< LArRodBlockStructuremakeRodBlockStructure () const
 Construct a RodBlockStructure instance of the proper concrete type.
template<class COLLECTION>
bool checkGainConsistency (const COLLECTION *coll) const
 Check that all elements in a container have the same gain.
const Hid2RESrcIDgetHid2RESrcID (const LArFebRodMapping &rodMapping) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

CxxUtils::CachedUniquePtr< Hid2RESrcIDm_hid2re
 Contains the mapping from channel to ROD (writing only)
PublicToolHandle< LArRodDecoderm_decoder { this, "LArRodDecoder", "LArRodDecoder", "LArRodDecoder" }
unsigned m_DSPRunMode
 Indicates which version of DSP code should be used for writing.
unsigned short m_RodBlockVersion
 Minor ROD block version This is equivalent to the lower 16 bits of the version word in the ROD block header.
bool m_initializeForWriting
 JobOption to intitialize services needed only for writing.
uint16_t m_subDetId
double m_nfebsigma
bool m_includeDigits
std::string m_DigitContName
const LArOnlineIDm_onlineHelper = nullptr
SG::ReadCondHandleKey< CaloNoisem_caloNoiseKey { this, "CaloNoiseKey", "totalNoise", "" }
SG::ReadCondHandleKey< LArOnOffIdMappingm_onOffIdMappingKey { this, "OnOffIdMappingKey", "LArOnOffIdMap", "LArOnOffIdMap" }
SG::ReadCondHandleKey< LArFebRodMappingm_febRodMappingKey { this, "FebRodMappingKey", "LArFebRodMap", "LArFebRodMap" }
SG::ReadCondHandleKey< CaloDetDescrManagerm_caloMgrKey { this, "CaloDetDescrManager", "CaloDetDescrManager", "SG Key for CaloDetDescrManager in the Condition Store" }
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

An AlgTool class to help converting LAr raw data objects to/from ByteStream.

This tool is used for reading as well as writing. It's main prupose is to find all LAr-Fragment in the full byte-stream event

Definition at line 48 of file LArRawDataContByteStreamTool.h.

Member Typedef Documentation

◆ FEA_t

◆ RobIndex_t

using LArRawDataContByteStreamTool::RobIndex_t = std::map<eformat::SubDetectorGroup, std::vector<const uint32_t*> >
private

Definition at line 118 of file LArRawDataContByteStreamTool.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ LArRawDataContByteStreamTool()

LArRawDataContByteStreamTool::LArRawDataContByteStreamTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Constructor Standard AlgTool constructor.

Definition at line 42 of file LArRawDataContByteStreamTool.cxx.

44 : AthAlgTool(type,name,parent)
45{ declareInterface< LArRawDataContByteStreamTool >( this );
46 declareProperty("DSPRunMode",m_DSPRunMode=4);
47 declareProperty("RodBlockVersion",m_RodBlockVersion=0);
48 declareProperty("FebNoiseCut",m_nfebsigma=2);
49 declareProperty("InitializeForWriting",m_initializeForWriting=false);
50 declareProperty("SubDetectorId",m_subDetId=0);
51 declareProperty("IncludeDigits",m_includeDigits=false);
52 declareProperty("DigitsContainer",m_DigitContName="LArDigitContainer_MC_Thinned");
53}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
unsigned m_DSPRunMode
Indicates which version of DSP code should be used for writing.
unsigned short m_RodBlockVersion
Minor ROD block version This is equivalent to the lower 16 bits of the version word in the ROD block ...
bool m_initializeForWriting
JobOption to intitialize services needed only for writing.

◆ ~LArRawDataContByteStreamTool()

LArRawDataContByteStreamTool::~LArRawDataContByteStreamTool ( )
virtual

Destructor.

Definition at line 55 of file LArRawDataContByteStreamTool.cxx.

55 {
56}

Member Function Documentation

◆ checkGainConsistency()

template<class COLLECTION>
bool LArRawDataContByteStreamTool::checkGainConsistency ( const COLLECTION * coll) const
private

Check that all elements in a container have the same gain.

Parameters
collPointer to input container (template)
Returns
false if an incosistency is detected

◆ convert()

template<class COLLECTION, typename ... ARGS>
StatusCode LArRawDataContByteStreamTool::convert ( const RawEvent * re,
COLLECTION * digit_cont,
CaloGain::CaloGain gain,
ARGS &&... args ) const

Templated conversion class form Raw Event to a container.

Parameters
RawEventFull event in ByteStream format as defined in ByteStreamData/RawEvent.h
COLLECTIONTemplate for the raw data container. Can be the containers of LArRawChannel, LArDigit, LArCalibDigit, LArFebHeader or LArAccumulatedCalibDigit or LArAccumulatedDigit
gainFor fixed-gain mode (e.g. calibration digits), indicates which gain should be read
Returns
Gaudi StatusCode

Iterates though all levels of the Atlas ByteStream format (aka eformat) to get all ROD fragments belonging to LAr. Methods from LArRodDecoder are used to deal with the individual ROD fragments.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode LArRawDataContByteStreamTool::finalize ( )
overridevirtual

Definition at line 92 of file LArRawDataContByteStreamTool.cxx.

93{
94 ATH_CHECK( AthAlgTool::finalize() );
95 return StatusCode::SUCCESS;
96}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ getHid2RESrcID()

const Hid2RESrcID & LArRawDataContByteStreamTool::getHid2RESrcID ( const LArFebRodMapping & rodMapping) const
private

Definition at line 451 of file LArRawDataContByteStreamTool.cxx.

452{
453 if (!m_hid2re) {
454 auto hid2re = std::make_unique<Hid2RESrcID>();
455 if (hid2re->initialize (rodMapping).isFailure()) {
456 std::abort();
457 }
458 m_hid2re.set (std::move (hid2re));
459 }
460 return *m_hid2re.get();
461}
CxxUtils::CachedUniquePtr< Hid2RESrcID > m_hid2re
Contains the mapping from channel to ROD (writing only)

◆ initialize()

StatusCode LArRawDataContByteStreamTool::initialize ( )
overridevirtual

Definition at line 60 of file LArRawDataContByteStreamTool.cxx.

61{
62 ATH_CHECK( AthAlgTool::initialize() );
63 ATH_MSG_DEBUG ( "Initializing LArRawDataContByteStream" );
64
65 ATH_CHECK( m_decoder.retrieve() );
66
68 if (m_DSPRunMode == 0) {
69 // Obsolete mode
70 ATH_MSG_ERROR ( "LArRodBlockStructure type 0 is obsolete and can't be used any more." );
71 return StatusCode::FAILURE;
72 }
73
74 ATH_CHECK( detStore()->retrieve (m_onlineHelper, "LArOnlineID") );
75
76 ATH_MSG_INFO ( "Initialization done for reading and writing" );
77 }
78 else {
79 ATH_MSG_INFO ( "Initialization done for reading only" );
80 }
81
86
87 return StatusCode::SUCCESS;
88}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
PublicToolHandle< LArRodDecoder > m_decoder
SG::ReadCondHandleKey< CaloNoise > m_caloNoiseKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_onOffIdMappingKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
SG::ReadCondHandleKey< LArFebRodMapping > m_febRodMappingKey

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & LArRawDataContByteStreamTool::interfaceID ( )
static

AlgTool InterfaceID.

Definition at line 37 of file LArRawDataContByteStreamTool.cxx.

static const InterfaceID IID_ILArRawDataContByteStreamTool("LArRawDataContByteStreamTool", 1, 0)

◆ makeRodBlockStructure()

std::unique_ptr< LArRodBlockStructure > LArRawDataContByteStreamTool::makeRodBlockStructure ( ) const
private

Construct a RodBlockStructure instance of the proper concrete type.

Definition at line 408 of file LArRawDataContByteStreamTool.cxx.

409{
410 switch(m_DSPRunMode) {
411 case 0: // Obsolete; shouldn't get here.
412 std::abort();
413
414 case 2: //Transparent mode, DSP just copies FEB-data
415 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockTransparent (#2)" );
416 return std::make_unique<LArRodBlockTransparentV0<LArRodBlockHeaderTransparentV0> >(this->msgSvc().get());
417 break;
418
419 case 7: //Calibration mode
420 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockCalibration (#7)" );
421 return std::make_unique<LArRodBlockCalibrationV0<LArRodBlockHeaderCalibrationV0> >(this->msgSvc().get());
422 break;
423
424 case 4: //Physics assembly mode
425 if ( m_RodBlockVersion == 10 ){
426 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockPhysics (#5)" );
427 return std::make_unique<LArRodBlockPhysicsV5>(this->msgSvc().get());
428 }
429 else if ( m_RodBlockVersion == 12 ){
430 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockPhysics (#6)" );
431 return std::make_unique<LArRodBlockPhysicsV6>(this->msgSvc().get());
432 }
433 else {
434 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockPhysics (#4)" );
435 return std::make_unique<LArRodBlockPhysicsV0>(this->msgSvc().get());
436 }
437 break;
438
439 case 5: //Physics assembly mode
440 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockPhysics (#5)" );
441 return std::make_unique<LArRodBlockPhysicsV3>(this->msgSvc().get());
442
443 default:
444 ATH_MSG_WARNING ( "DSP runmode " << m_DSPRunMode << " is unknown. Using physics assembly mode (#4) by default" );
445 return std::make_unique<LArRodBlockPhysicsV0>(this->msgSvc().get());
446 }
447}
#define ATH_MSG_WARNING(x)
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ prepareRobIndex()

StatusCode LArRawDataContByteStreamTool::prepareRobIndex ( const RawEvent * event,
RobIndex_t & robIndex ) const
private

Prepare ROB index before conversion.

Definition at line 376 of file LArRawDataContByteStreamTool.cxx.

378{
379 // This `optimization' leads to disaster if there ever happen to be
380 // two adjacent events with identical L1 IDs --- in that case,
381 // we'd be using the dangling ROB pointers from the last event.
382 // We should generally come through here only once per event anyway.
383 ATH_MSG_DEBUG( "Converting event (from ByteStream)" );
384
385 if (!re) {
386 ATH_MSG_ERROR ( "RawEvent passed to 'convert'-function is a null pointer!" );
387 return StatusCode::FAILURE;
388 }
389
390 if (!m_decoder->check_valid (re, msg())) return StatusCode::FAILURE;
391
392 ATH_MSG_VERBOSE ( "Full Event:" );
393 ATH_MSG_VERBOSE ( MSG::hex << "Full source ID: " << re->source_id() << MSG::dec );
394 ATH_MSG_VERBOSE ("Fragment size in words: " << re->fragment_size_word() );
395
396 // Need to clear up or it will accumulate
397 robIndex.clear();
398 eformat::helper::build_toc(*re, robIndex );
399 if ( robIndex.empty() ) { // This is a problem
400 return StatusCode::FAILURE;
401 }
402 return StatusCode::SUCCESS;
403}
const boost::regex re(r_e)
#define ATH_MSG_VERBOSE(x)
MsgStream & msg() const

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

◆ WriteLArCalibDigits()

StatusCode LArRawDataContByteStreamTool::WriteLArCalibDigits ( const LArCalibDigitContainer * digit_cont,
FEA_t & fea ) const

Fill channels from LArCalibDigitContainer to a FullEvent.

Parameters
digit_contPointer to LArCalibDigitContainer (input)
feaPointer to FullEventAssember (output)
Returns
Gaudi StatusCode

Definition at line 197 of file LArRawDataContByteStreamTool.cxx.

199{
201 ATH_MSG_ERROR ( "Tool not setup for writing! Use property "
202 << name()<<".InitializeForWriting" );
203 return StatusCode::FAILURE;
204 }
205 ATH_MSG_DEBUG ( "Writing LArCalibDigitContainer to ByteStream" );
206 if (!digitCont) {
207 ATH_MSG_DEBUG ( "Null pointer passed to WriteLArCalibDigit routine!" );
208 return StatusCode::FAILURE;
209 }
210
211 std::unique_ptr<LArRodBlockStructure> blstruct = makeRodBlockStructure();
212
213 if (!blstruct->canSetCalibration()|| !blstruct->canSetRawDataFixed()) {
214 ATH_MSG_DEBUG ( "This instance of LArRodBlockStructure can't hold LArCalibDigits!" );
215 return StatusCode::FAILURE;
216 }
217 fea.setRodMinorVersion(m_RodBlockVersion);
218 fea.setDetEvtType(m_DSPRunMode);
219 ATH_MSG_DEBUG ( "Setting Detector Event Type to " << m_DSPRunMode
220 << "and Minor Version Number to " << m_RodBlockVersion );
221 FEA_t::RODDATA* theROD;
222 LArCalibDigitContainer::const_iterator it_b=digitCont->begin();
223 LArCalibDigitContainer::const_iterator it_e=digitCont->end();
224 if (it_b==it_e) {
225 ATH_MSG_WARNING ( "Attempt to persistify a empty LArDigitContainer to ByteStream" );
226 return StatusCode::SUCCESS;
227 }
228 if (!checkGainConsistency(digitCont)) {
229 ATH_MSG_ERROR ( "Inconsistent gain in LArCalibDigitContainer" );
230 return StatusCode::FAILURE;
231 }
232
233 const EventContext& ctx = Gaudi::Hive::currentContext();
234 SG::ReadCondHandle<LArOnOffIdMapping> onOffMapping (m_onOffIdMappingKey, ctx);
235 SG::ReadCondHandle<LArFebRodMapping> febRodMapping (m_febRodMappingKey, ctx);
236 SG::ReadCondHandle<CaloDetDescrManager> caloMgr (m_caloMgrKey, ctx);
237 const Hid2RESrcID& hid2re = getHid2RESrcID (**febRodMapping);
238
239 std::map<uint32_t, LArRodEncoder> mapEncoder;
240
241 auto getEncoder = [&] (uint32_t reid) -> LArRodEncoder&
242 { return mapEncoder.try_emplace (reid,
244 **caloMgr,
245 **onOffMapping,
246 blstruct.get()).first->second; };
247
248 unsigned n=0;
249 int fixgain=(*it_b)->gain();
250
251 // Sorting Channels by ROD
252 for(; it_b!=it_e; ++it_b){
253 const LArCalibDigit* digit = *it_b;
254 HWIdentifier chid = digit->hardwareID() ;
255 uint32_t reid = hid2re.getRodID( **febRodMapping, chid );
256 getEncoder(reid).add (digit, fixgain);
257 n++;
258 }
259
260 ATH_MSG_VERBOSE(" number of channels in the LArCalibDigitContainer for gain "
261 << fixgain << ": "<<n );
262
263 SG::ReadCondHandle<CaloNoise> noise (m_caloNoiseKey, ctx);
264
265 // Now loop over map and fill all ROD Data Blocks
266 std::map<uint32_t,LArRodEncoder>::iterator it =mapEncoder.begin();
267 std::map<uint32_t,LArRodEncoder>::iterator it_end=mapEncoder.end();
268 // LArRodEncoder has collected all the channels, now can fill the
269 // ROD block data.
270 for(; it!=it_end;++it) {
271 theROD = fea.getRodData( (*it).first );
272 ((*it).second).fillROD( *theROD,msg(), **noise, m_nfebsigma ) ;
273 }
274 ATH_MSG_DEBUG ( "Filled " << mapEncoder.size() << " Rod Blocks" );
275 return StatusCode::SUCCESS;
276}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
uint32_t getRodID(const LArFebRodMapping &rodMapping, const HWIdentifier &hid) const
make a ROD SrcID for a HWIdentifier
bool checkGainConsistency(const COLLECTION *coll) const
Check that all elements in a container have the same gain.
std::unique_ptr< LArRodBlockStructure > makeRodBlockStructure() const
Construct a RodBlockStructure instance of the proper concrete type.
const Hid2RESrcID & getHid2RESrcID(const LArFebRodMapping &rodMapping) const
setEventNumber uint32_t

◆ WriteLArDigits()

StatusCode LArRawDataContByteStreamTool::WriteLArDigits ( const LArDigitContainer * digit_cont,
FEA_t & fea ) const

Fill channels from LArDigitContainer to a FullEvent.

Parameters
digit_contPointer to LArDigitContainer (input)
feaPointer to FullEventAssember (output)
Returns
Gaudi StatusCode

Definition at line 100 of file LArRawDataContByteStreamTool.cxx.

102{
104 ATH_MSG_ERROR ( "Tool not setup for writing! Use property "
105 << name()<<".InitializeForWriting" );
106 return StatusCode::FAILURE;
107 }
108 ATH_MSG_DEBUG ( "Writing LArDigitContainer to ByteStream" );
109 if (!digitCont) {
110 ATH_MSG_ERROR ( "Null pointer passed to WriteLArDigit routine!" );
111 return StatusCode::FAILURE;
112 }
113
114 std::unique_ptr<LArRodBlockStructure> blstruct = makeRodBlockStructure();
115
116 if (!blstruct->canSetRawData() && !blstruct->canSetRawDataFixed()) {
117 ATH_MSG_DEBUG ( "This instance of LArRodBlockStructure can't hold LArDigits!" );
118 return StatusCode::FAILURE;
119 }
120 fea.setRodMinorVersion(m_RodBlockVersion);
121 fea.setDetEvtType(m_DSPRunMode);
122 ATH_MSG_DEBUG ( "Setting Detector Event Type to " << m_DSPRunMode
123 << " and Minor Version Number to " << m_RodBlockVersion );
124 FEA_t::RODDATA* theROD;
125 LArDigitContainer::const_iterator it_b=digitCont->begin();
126 LArDigitContainer::const_iterator it_e=digitCont->end();
127 if (it_b==it_e) {
128 ATH_MSG_WARNING ( "Attempt to persistify an empty LArDigitContainer to ByteStream" );
129 return StatusCode::SUCCESS;
130 }
131
132 const EventContext& ctx = Gaudi::Hive::currentContext();
133 SG::ReadCondHandle<LArOnOffIdMapping> onOffMapping (m_onOffIdMappingKey, ctx);
134 SG::ReadCondHandle<LArFebRodMapping> febRodMapping (m_febRodMappingKey, ctx);
135 SG::ReadCondHandle<CaloDetDescrManager> caloMgr (m_caloMgrKey, ctx);
136 const Hid2RESrcID& hid2re = getHid2RESrcID (**febRodMapping);
137
138 std::map<uint32_t, LArRodEncoder> mapEncoder;
139
140 auto getEncoder = [&] (uint32_t reid) -> LArRodEncoder&
141 { return mapEncoder.try_emplace (reid,
143 **caloMgr,
144 **onOffMapping,
145 blstruct.get()).first->second; };
146
147 unsigned n=0;
148 if (blstruct->canSetRawDataFixed() && checkGainConsistency(digitCont))
149 {//Set fixed gain raw data
150 int fixgain=(*it_b)->gain();
151 ATH_MSG_DEBUG(" number of Digits in LArDigitContainer for gain " << fixgain << ": "
152 << digitCont->size() );
153 // Sorting Channels by ROD
154 for(; it_b!=it_e; ++it_b){
155 const LArDigit* digit = *it_b;
156 HWIdentifier chid = digit->hardwareID() ;
157 uint32_t reid = hid2re.getRodID( **febRodMapping, chid );
158 getEncoder(reid).add (digit, fixgain);
159 n++;
160 }
161 ATH_MSG_VERBOSE(" number of channels in the LArDigitContainer for gain "
162 << fixgain << ": "<<n );
163 } // end if
164 else
165 if (blstruct->canSetRawData()) { //Set free gain raw data
166 ATH_MSG_DEBUG(" number of channels in LArDigit container: "<< digitCont->size() );
167
168 // Sorting Channels by ROD
169 for(; it_b!=it_e; ++it_b){
170 const LArDigit* digit = *it_b;
171 HWIdentifier chid = digit->hardwareID() ;
172 uint32_t reid = hid2re.getRodID( **febRodMapping, chid );
173 getEncoder(reid).add (digit);
174 n++;
175 }
176 ATH_MSG_VERBOSE(" number of channels added to framgent: "<<n );
177 }// end else-if(can set Raw data)
178
179 SG::ReadCondHandle<CaloNoise> noise (m_caloNoiseKey, ctx);
180
181 // Now loop over map and fill all ROD Data Blocks
182 std::map<uint32_t,LArRodEncoder>::iterator it =mapEncoder.begin();
183 std::map<uint32_t,LArRodEncoder>::iterator it_end=mapEncoder.end();
184 // LArRodEncoder has collected all the channels, now can fill the
185 // ROD block data.
186 for(; it!=it_end;++it) {
187 theROD = fea.getRodData( (*it).first );
188 ((*it).second).fillROD(*theROD,msg(), **noise, m_nfebsigma ) ;
189 }
190 ATH_MSG_DEBUG ( "Filled " << mapEncoder.size() << " Rod Blocks" );
191 return StatusCode::SUCCESS;
192}

◆ WriteLArRawChannels()

StatusCode LArRawDataContByteStreamTool::WriteLArRawChannels ( const LArRawChannelContainer * CannelCont,
FEA_t & fea ) const

Fill channels from LArRawChannelContainer to a FullEvent.

Parameters
digit_contPointer to LArRawChannelContainer (input)
feaPointer to FullEventAssember (output)
Returns
Gaudi StatusCode

Definition at line 280 of file LArRawDataContByteStreamTool.cxx.

282{
284 ATH_MSG_ERROR ( "Tool not setup for writing! Use property "
285 << name()<<".InitializeForWriting" );
286 return StatusCode::FAILURE;
287 }
288 if (!channelCont) {
289 ATH_MSG_DEBUG ( "Null pointer passed to WriteLArCalibDigit routine!" );
290 return StatusCode::FAILURE;
291 }
292
293 std::unique_ptr<LArRodBlockStructure> blstruct = makeRodBlockStructure();
294
295 if (!blstruct->canSetEnergy()) {
296 ATH_MSG_DEBUG ( "This instance of LArRodBlockStructure can't hold LArRawChannels!" );
297 return StatusCode::FAILURE;
298 }
299 FEA_t::RODDATA* theROD;
300 fea.setRodMinorVersion(m_RodBlockVersion);
301 fea.setDetEvtType(m_DSPRunMode);
302 ATH_MSG_DEBUG ( "Setting Detector Event Type to " << m_DSPRunMode
303 << "and Minor Version Number to " << m_RodBlockVersion );
304 LArRawChannelContainer::const_iterator it = channelCont->begin();
305 LArRawChannelContainer::const_iterator it_e= channelCont->end();
306 if ( it==it_e) {
307 ATH_MSG_WARNING ( "Attempt to persistify a empty LArDigitContainer to ByteStream" );
308 return StatusCode::SUCCESS;
309 }
310
311 const EventContext& ctx = Gaudi::Hive::currentContext();
312 SG::ReadCondHandle<LArOnOffIdMapping> onOffMapping (m_onOffIdMappingKey, ctx);
313 SG::ReadCondHandle<LArFebRodMapping> febRodMapping (m_febRodMappingKey, ctx);
314 SG::ReadCondHandle<CaloDetDescrManager> caloMgr (m_caloMgrKey, ctx);
315 const Hid2RESrcID& hid2re = getHid2RESrcID (**febRodMapping);
316
317 std::map<uint32_t, LArRodEncoder> mapEncoder;
318
319 auto getEncoder = [&] (uint32_t reid) -> LArRodEncoder&
320 { return mapEncoder.try_emplace (reid,
322 **caloMgr,
323 **onOffMapping,
324 blstruct.get()).first->second; };
325
326 ATH_MSG_DEBUG(" number of LArRawChannel container "<< channelCont->size() );
327 for(; it!=it_e; ++it){
328 const LArRawChannel& rawChan = *it;
329 HWIdentifier chid = rawChan.channelID() ;
330 uint32_t reid = hid2re.getRodID( **febRodMapping, chid );
331
332 getEncoder(reid).add (&rawChan);
333 }
334 // I may want to also include the digits
335 if ( m_includeDigits ) {
336 const LArDigitContainer* digitCont = nullptr;
337 if ( evtStore()->retrieve(digitCont,m_DigitContName).isFailure() ){
338 ATH_MSG_ERROR ( "Digits required but not really found" );
339 } else {
340 if ( blstruct->canIncludeRawData() ){
342 LArDigitContainer::const_iterator it_e=digitCont->end();
343 if (it_b==it_e) {
344 ATH_MSG_WARNING ( "Attempt to persistify a empty LArDigitContainer to ByteStream" );
345 }
346 for(; it_b!=it_e; ++it_b){
347 const LArDigit* digit = *it_b;
348 HWIdentifier chid = digit->hardwareID() ;
349 uint32_t reid = hid2re.getRodID( **febRodMapping, chid );
350 // Lets use anygain for the moment
351 getEncoder(reid).add (digit);
352 }
353 } // End of check whether format allows to include RawData
354 } // Finish checking for Digit container in SG
355 } // End of check for digits inclusion
356
357 SG::ReadCondHandle<CaloNoise> noise (m_caloNoiseKey, ctx);
358
359 // Now loop over map and fill all ROD Data Blocks
360 std::map<uint32_t,LArRodEncoder>::iterator it_m =mapEncoder.begin();
361 std::map<uint32_t,LArRodEncoder>::iterator it_m_e=mapEncoder.end();
362 // LArRodEncoder has collected all the channels, now can fill the
363 // ROD block data.
364 for(; it_m!=it_m_e;++it_m) {
365 theROD = fea.getRodData( (*it_m).first );
366 ((*it_m).second).fillROD( *theROD,msg(), **noise, m_nfebsigma ) ;
367 // delete ((*it_m).second);
368 // ((*it_m).second)=NULL;
369 }
370 ATH_MSG_DEBUG ( "Filled " << mapEncoder.size() << " Rod Blocks" );
371 return StatusCode::SUCCESS;
372}
ServiceHandle< StoreGateSvc > & evtStore()
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.
HWIdentifier channelID() const

Member Data Documentation

◆ m_caloMgrKey

SG::ReadCondHandleKey<CaloDetDescrManager> LArRawDataContByteStreamTool::m_caloMgrKey { this, "CaloDetDescrManager", "CaloDetDescrManager", "SG Key for CaloDetDescrManager in the Condition Store" }
private

Definition at line 173 of file LArRawDataContByteStreamTool.h.

174{ this, "CaloDetDescrManager", "CaloDetDescrManager", "SG Key for CaloDetDescrManager in the Condition Store" };

◆ m_caloNoiseKey

SG::ReadCondHandleKey<CaloNoise> LArRawDataContByteStreamTool::m_caloNoiseKey { this, "CaloNoiseKey", "totalNoise", "" }
private

Definition at line 164 of file LArRawDataContByteStreamTool.h.

165{ this, "CaloNoiseKey", "totalNoise", "" };

◆ m_decoder

PublicToolHandle<LArRodDecoder> LArRawDataContByteStreamTool::m_decoder { this, "LArRodDecoder", "LArRodDecoder", "LArRodDecoder" }
private

Definition at line 137 of file LArRawDataContByteStreamTool.h.

138{ this, "LArRodDecoder", "LArRodDecoder", "LArRodDecoder" };

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_DigitContName

std::string LArRawDataContByteStreamTool::m_DigitContName
private

Definition at line 160 of file LArRawDataContByteStreamTool.h.

◆ m_DSPRunMode

unsigned LArRawDataContByteStreamTool::m_DSPRunMode
private

Indicates which version of DSP code should be used for writing.

This is equivalent to the DetectorEventType word in the ROD block header. Only for writing.

Definition at line 144 of file LArRawDataContByteStreamTool.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_febRodMappingKey

SG::ReadCondHandleKey<LArFebRodMapping> LArRawDataContByteStreamTool::m_febRodMappingKey { this, "FebRodMappingKey", "LArFebRodMap", "LArFebRodMap" }
private

Definition at line 170 of file LArRawDataContByteStreamTool.h.

171{ this, "FebRodMappingKey", "LArFebRodMap", "LArFebRodMap" };

◆ m_hid2re

CxxUtils::CachedUniquePtr<Hid2RESrcID> LArRawDataContByteStreamTool::m_hid2re
private

Contains the mapping from channel to ROD (writing only)

Definition at line 136 of file LArRawDataContByteStreamTool.h.

◆ m_includeDigits

bool LArRawDataContByteStreamTool::m_includeDigits
private

Definition at line 158 of file LArRawDataContByteStreamTool.h.

◆ m_initializeForWriting

bool LArRawDataContByteStreamTool::m_initializeForWriting
private

JobOption to intitialize services needed only for writing.

Definition at line 154 of file LArRawDataContByteStreamTool.h.

◆ m_nfebsigma

double LArRawDataContByteStreamTool::m_nfebsigma
private

Definition at line 156 of file LArRawDataContByteStreamTool.h.

◆ m_onlineHelper

const LArOnlineID* LArRawDataContByteStreamTool::m_onlineHelper = nullptr
private

Definition at line 162 of file LArRawDataContByteStreamTool.h.

◆ m_onOffIdMappingKey

SG::ReadCondHandleKey<LArOnOffIdMapping> LArRawDataContByteStreamTool::m_onOffIdMappingKey { this, "OnOffIdMappingKey", "LArOnOffIdMap", "LArOnOffIdMap" }
private

Definition at line 167 of file LArRawDataContByteStreamTool.h.

168{ this, "OnOffIdMappingKey", "LArOnOffIdMap", "LArOnOffIdMap" };

◆ m_RodBlockVersion

unsigned short LArRawDataContByteStreamTool::m_RodBlockVersion
private

Minor ROD block version This is equivalent to the lower 16 bits of the version word in the ROD block header.

Only for writing.

Definition at line 150 of file LArRawDataContByteStreamTool.h.

◆ m_subDetId

uint16_t LArRawDataContByteStreamTool::m_subDetId
private

Definition at line 155 of file LArRawDataContByteStreamTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: