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 468 of file LArRawDataContByteStreamTool.cxx.

469{
470 if (!m_hid2re) {
471 auto hid2re = std::make_unique<Hid2RESrcID>();
472 if (hid2re->initialize (rodMapping).isFailure()) {
473 std::abort();
474 }
475 m_hid2re.set (std::move (hid2re));
476 }
477 return *m_hid2re.get();
478}
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 425 of file LArRawDataContByteStreamTool.cxx.

426{
427 switch(m_DSPRunMode) {
428 case 0: // Obsolete; shouldn't get here.
429 std::abort();
430
431 case 2: //Transparent mode, DSP just copies FEB-data
432 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockTransparent (#2)" );
433 return std::make_unique<LArRodBlockTransparentV0<LArRodBlockHeaderTransparentV0> >();
434 break;
435
436 case 7: //Calibration mode
437 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockCalibration (#7)" );
438 return std::make_unique<LArRodBlockCalibrationV0<LArRodBlockHeaderCalibrationV0> >();
439 break;
440
441 case 4: //Physics assembly mode
442 if ( m_RodBlockVersion == 10 ){
443 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockPhysics (#5)" );
444 return std::make_unique<LArRodBlockPhysicsV5>();
445 }
446 else if ( m_RodBlockVersion == 12 ){
447 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockPhysics (#6)" );
448 return std::make_unique<LArRodBlockPhysicsV6>();
449 }
450 else {
451 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockPhysics (#4)" );
452 return std::make_unique<LArRodBlockPhysicsV0>();
453 }
454 break;
455
456 case 5: //Physics assembly mode
457 ATH_MSG_DEBUG ( "Set Rod Block Type to LArRodBlockPhysics (#5)" );
458 return std::make_unique<LArRodBlockPhysicsV3>();
459
460 default:
461 ATH_MSG_WARNING ( "DSP runmode " << m_DSPRunMode << " is unknown. Using physics assembly mode (#4) by default" );
462 return std::make_unique<LArRodBlockPhysicsV0>();
463 }
464}
#define ATH_MSG_WARNING(x)

◆ 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 393 of file LArRawDataContByteStreamTool.cxx.

395{
396 // This `optimization' leads to disaster if there ever happen to be
397 // two adjacent events with identical L1 IDs --- in that case,
398 // we'd be using the dangling ROB pointers from the last event.
399 // We should generally come through here only once per event anyway.
400 ATH_MSG_DEBUG( "Converting event (from ByteStream)" );
401
402 if (!re) {
403 ATH_MSG_ERROR ( "RawEvent passed to 'convert'-function is a null pointer!" );
404 return StatusCode::FAILURE;
405 }
406
407 if (!m_decoder->check_valid (re, msg())) return StatusCode::FAILURE;
408
409 ATH_MSG_VERBOSE ( "Full Event:" );
410 ATH_MSG_VERBOSE ( MSG::hex << "Full source ID: " << re->source_id() << MSG::dec );
411 ATH_MSG_VERBOSE ("Fragment size in words: " << re->fragment_size_word() );
412
413 // Need to clear up or it will accumulate
414 robIndex.clear();
415 eformat::helper::build_toc(*re, robIndex );
416 if ( robIndex.empty() ) { // This is a problem
417 return StatusCode::FAILURE;
418 }
419 return StatusCode::SUCCESS;
420}
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 200 of file LArRawDataContByteStreamTool.cxx.

202{
204 ATH_MSG_ERROR ( "Tool not setup for writing! Use property "
205 << name()<<".InitializeForWriting" );
206 return StatusCode::FAILURE;
207 }
208 ATH_MSG_DEBUG ( "Writing LArCalibDigitContainer to ByteStream" );
209 if (!digitCont) {
210 ATH_MSG_DEBUG ( "Null pointer passed to WriteLArCalibDigit routine!" );
211 return StatusCode::FAILURE;
212 }
213
214 std::unique_ptr<LArRodBlockStructure> blstruct = makeRodBlockStructure();
215
216 if (!blstruct->canSetCalibration()|| !blstruct->canSetRawDataFixed()) {
217 ATH_MSG_DEBUG ( "This instance of LArRodBlockStructure can't hold LArCalibDigits!" );
218 return StatusCode::FAILURE;
219 }
220 //prepareWriting();
221 fea.setRodMinorVersion(m_RodBlockVersion);
222 fea.setDetEvtType(m_DSPRunMode);
223 ATH_MSG_DEBUG ( "Setting Detector Event Type to " << m_DSPRunMode
224 << "and Minor Version Number to " << m_RodBlockVersion );
225 FEA_t::RODDATA* theROD;
226 LArCalibDigitContainer::const_iterator it_b=digitCont->begin();
227 LArCalibDigitContainer::const_iterator it_e=digitCont->end();
228 if (it_b==it_e) {
229 ATH_MSG_WARNING ( "Attempt to persistify a empty LArDigitContainer to ByteStream" );
230 return StatusCode::SUCCESS;
231 }
232 if (!checkGainConsistency(digitCont)) {
233 ATH_MSG_ERROR ( "Inconsistent gain in LArCalibDigitContainer" );
234 return StatusCode::FAILURE;
235 }
236
237 const EventContext& ctx = Gaudi::Hive::currentContext();
238 SG::ReadCondHandle<LArOnOffIdMapping> onOffMapping (m_onOffIdMappingKey, ctx);
239 SG::ReadCondHandle<LArFebRodMapping> febRodMapping (m_febRodMappingKey, ctx);
240 SG::ReadCondHandle<CaloDetDescrManager> caloMgr (m_caloMgrKey, ctx);
241 const Hid2RESrcID& hid2re = getHid2RESrcID (**febRodMapping);
242
243 std::map<uint32_t, LArRodEncoder> mapEncoder;
244
245 auto getEncoder = [&] (uint32_t reid) -> LArRodEncoder&
246 { return mapEncoder.try_emplace (reid,
248 **caloMgr,
249 **onOffMapping,
250 blstruct.get()).first->second; };
251
252 unsigned n=0;
253 int fixgain=(*it_b)->gain();
254
255 // Sorting Channels by ROD
256 for(; it_b!=it_e; ++it_b){
257 const LArCalibDigit* digit = *it_b;
258 HWIdentifier chid = digit->hardwareID() ;
259 uint32_t reid = hid2re.getRodID( **febRodMapping, chid );
260 getEncoder(reid).add (digit, fixgain);
261 n++;
262 }
263
264 ATH_MSG_VERBOSE(" number of channels in the LArCalibDigitContainer for gain "
265 << fixgain << ": "<<n );
266
267 SG::ReadCondHandle<CaloNoise> noise (m_caloNoiseKey, ctx);
268
269 // Now loop over map and fill all ROD Data Blocks
270 std::map<uint32_t,LArRodEncoder>::iterator it =mapEncoder.begin();
271 std::map<uint32_t,LArRodEncoder>::iterator it_end=mapEncoder.end();
272 // LArRodEncoder has collected all the channels, now can fill the
273 // ROD block data.
274 for(; it!=it_end;++it) {
275 theROD = fea.getRodData( (*it).first );
276 ((*it).second).fillROD( *theROD,msg(), **noise, m_nfebsigma ) ;
277 }
278 ATH_MSG_DEBUG ( "Filled " << mapEncoder.size() << " Rod Blocks" );
279 return StatusCode::SUCCESS;
280}
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 //prepareWriting();
121 fea.setRodMinorVersion(m_RodBlockVersion);
122 fea.setDetEvtType(m_DSPRunMode);
123 ATH_MSG_DEBUG ( "Setting Detector Event Type to " << m_DSPRunMode
124 << " and Minor Version Number to " << m_RodBlockVersion );
125 FEA_t::RODDATA* theROD;
126 LArDigitContainer::const_iterator it_b=digitCont->begin();
127 LArDigitContainer::const_iterator it_e=digitCont->end();
128 if (it_b==it_e) {
129 ATH_MSG_WARNING ( "Attempt to persistify an empty LArDigitContainer to ByteStream" );
130 return StatusCode::SUCCESS;
131 }
132
133 const EventContext& ctx = Gaudi::Hive::currentContext();
134 SG::ReadCondHandle<LArOnOffIdMapping> onOffMapping (m_onOffIdMappingKey, ctx);
135 SG::ReadCondHandle<LArFebRodMapping> febRodMapping (m_febRodMappingKey, ctx);
136 SG::ReadCondHandle<CaloDetDescrManager> caloMgr (m_caloMgrKey, ctx);
137 const Hid2RESrcID& hid2re = getHid2RESrcID (**febRodMapping);
138
139 std::map<uint32_t, LArRodEncoder> mapEncoder;
140
141 auto getEncoder = [&] (uint32_t reid) -> LArRodEncoder&
142 { return mapEncoder.try_emplace (reid,
144 **caloMgr,
145 **onOffMapping,
146 blstruct.get()).first->second; };
147
148 unsigned n=0;
149 if (blstruct->canSetRawDataFixed() && checkGainConsistency(digitCont))
150 {//Set fixed gain raw data
151 int fixgain=(*it_b)->gain();
152 ATH_MSG_DEBUG(" number of Digits in LArDigitContainer for gain " << fixgain << ": "
153 << digitCont->size() );
154 // Sorting Channels by ROD
155 for(; it_b!=it_e; ++it_b){
156 const LArDigit* digit = *it_b;
157 HWIdentifier chid = digit->hardwareID() ;
158 uint32_t reid = hid2re.getRodID( **febRodMapping, chid );
159 getEncoder(reid).add (digit, fixgain);
160 n++;
161 }
162 ATH_MSG_VERBOSE(" number of channels in the LArDigitContainer for gain "
163 << fixgain << ": "<<n );
164 } // end if
165 else
166 if (blstruct->canSetRawData()) { //Set free gain raw data
167 ATH_MSG_DEBUG(" number of channels in LArDigit container: "<< digitCont->size() );
168
169 // Sorting Channels by ROD
170 for(; it_b!=it_e; ++it_b){
171 const LArDigit* digit = *it_b;
172 HWIdentifier chid = digit->hardwareID() ;
173 uint32_t reid = hid2re.getRodID( **febRodMapping, chid );
174 getEncoder(reid).add (digit);
175 n++;
176 }
177 ATH_MSG_VERBOSE(" number of channels added to framgent: "<<n );
178 }// end else-if(can set Raw data)
179
180 SG::ReadCondHandle<CaloNoise> noise (m_caloNoiseKey, ctx);
181
182 // Now loop over map and fill all ROD Data Blocks
183 std::map<uint32_t,LArRodEncoder>::iterator it =mapEncoder.begin();
184 std::map<uint32_t,LArRodEncoder>::iterator it_end=mapEncoder.end();
185 // LArRodEncoder has collected all the channels, now can fill the
186 // ROD block data.
187 for(; it!=it_end;++it) {
188 theROD = fea.getRodData( (*it).first );
189 ((*it).second).fillROD(*theROD,msg(), **noise, m_nfebsigma ) ;
190 }
191 ATH_MSG_DEBUG ( "Filled " << mapEncoder.size() << " Rod Blocks" );
192 // Finally, fill full event
193 //fea.fill(re,log);
194 return StatusCode::SUCCESS;
195}

◆ 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 284 of file LArRawDataContByteStreamTool.cxx.

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

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 174 of file LArRawDataContByteStreamTool.h.

175{ 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 165 of file LArRawDataContByteStreamTool.h.

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

◆ m_decoder

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

Definition at line 138 of file LArRawDataContByteStreamTool.h.

139{ 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 161 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 145 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 171 of file LArRawDataContByteStreamTool.h.

172{ 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 137 of file LArRawDataContByteStreamTool.h.

◆ m_includeDigits

bool LArRawDataContByteStreamTool::m_includeDigits
private

Definition at line 159 of file LArRawDataContByteStreamTool.h.

◆ m_initializeForWriting

bool LArRawDataContByteStreamTool::m_initializeForWriting
private

JobOption to intitialize services needed only for writing.

Definition at line 155 of file LArRawDataContByteStreamTool.h.

◆ m_nfebsigma

double LArRawDataContByteStreamTool::m_nfebsigma
private

Definition at line 157 of file LArRawDataContByteStreamTool.h.

◆ m_onlineHelper

const LArOnlineID* LArRawDataContByteStreamTool::m_onlineHelper = nullptr
private

Definition at line 163 of file LArRawDataContByteStreamTool.h.

◆ m_onOffIdMappingKey

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

Definition at line 168 of file LArRawDataContByteStreamTool.h.

169{ 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 151 of file LArRawDataContByteStreamTool.h.

◆ m_subDetId

uint16_t LArRawDataContByteStreamTool::m_subDetId
private

Definition at line 156 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: