24#include "GaudiKernel/MsgStream.h"
25#include "GaudiKernel/ThreadLocalContext.h"
34 (
"LArRawDataContByteStreamTool", 1, 0);
43(
const std::string&
type,
const std::string& name,
const IInterface* parent )
45{ declareInterface< LArRawDataContByteStreamTool >(
this );
70 ATH_MSG_ERROR (
"LArRodBlockStructure type 0 is obsolete and can't be used any more." );
71 return StatusCode::FAILURE;
76 ATH_MSG_INFO (
"Initialization done for reading and writing" );
87 return StatusCode::SUCCESS;
95 return StatusCode::SUCCESS;
105 << name()<<
".InitializeForWriting" );
106 return StatusCode::FAILURE;
110 ATH_MSG_ERROR (
"Null pointer passed to WriteLArDigit routine!" );
111 return StatusCode::FAILURE;
116 if (!blstruct->canSetRawData() && !blstruct->canSetRawDataFixed()) {
117 ATH_MSG_DEBUG (
"This instance of LArRodBlockStructure can't hold LArDigits!" );
118 return StatusCode::FAILURE;
129 ATH_MSG_WARNING (
"Attempt to persistify an empty LArDigitContainer to ByteStream" );
130 return StatusCode::SUCCESS;
133 const EventContext& ctx = Gaudi::Hive::currentContext();
139 std::map<uint32_t, LArRodEncoder> mapEncoder;
142 {
return mapEncoder.try_emplace (reid,
146 blstruct.get()).first->second; };
151 int fixgain=(*it_b)->gain();
152 ATH_MSG_DEBUG(
" number of Digits in LArDigitContainer for gain " << fixgain <<
": "
153 << digitCont->
size() );
155 for(; it_b!=it_e; ++it_b){
158 uint32_t reid = hid2re.
getRodID( **febRodMapping, chid );
159 getEncoder(reid).add (digit, fixgain);
162 ATH_MSG_VERBOSE(
" number of channels in the LArDigitContainer for gain "
163 << fixgain <<
": "<<n );
166 if (blstruct->canSetRawData()) {
167 ATH_MSG_DEBUG(
" number of channels in LArDigit container: "<< digitCont->
size() );
170 for(; it_b!=it_e; ++it_b){
173 uint32_t reid = hid2re.
getRodID( **febRodMapping, chid );
174 getEncoder(reid).add (digit);
183 std::map<uint32_t,LArRodEncoder>::iterator it =mapEncoder.begin();
184 std::map<uint32_t,LArRodEncoder>::iterator it_end=mapEncoder.end();
187 for(; it!=it_end;++it) {
191 ATH_MSG_DEBUG (
"Filled " << mapEncoder.size() <<
" Rod Blocks" );
194 return StatusCode::SUCCESS;
205 << name()<<
".InitializeForWriting" );
206 return StatusCode::FAILURE;
208 ATH_MSG_DEBUG (
"Writing LArCalibDigitContainer to ByteStream" );
210 ATH_MSG_DEBUG (
"Null pointer passed to WriteLArCalibDigit routine!" );
211 return StatusCode::FAILURE;
216 if (!blstruct->canSetCalibration()|| !blstruct->canSetRawDataFixed()) {
217 ATH_MSG_DEBUG (
"This instance of LArRodBlockStructure can't hold LArCalibDigits!" );
218 return StatusCode::FAILURE;
229 ATH_MSG_WARNING (
"Attempt to persistify a empty LArDigitContainer to ByteStream" );
230 return StatusCode::SUCCESS;
233 ATH_MSG_ERROR (
"Inconsistent gain in LArCalibDigitContainer" );
234 return StatusCode::FAILURE;
237 const EventContext& ctx = Gaudi::Hive::currentContext();
243 std::map<uint32_t, LArRodEncoder> mapEncoder;
246 {
return mapEncoder.try_emplace (reid,
250 blstruct.get()).first->second; };
253 int fixgain=(*it_b)->gain();
256 for(; it_b!=it_e; ++it_b){
259 uint32_t reid = hid2re.
getRodID( **febRodMapping, chid );
260 getEncoder(reid).add (digit, fixgain);
264 ATH_MSG_VERBOSE(
" number of channels in the LArCalibDigitContainer for gain "
265 << fixgain <<
": "<<n );
270 std::map<uint32_t,LArRodEncoder>::iterator it =mapEncoder.begin();
271 std::map<uint32_t,LArRodEncoder>::iterator it_end=mapEncoder.end();
274 for(; it!=it_end;++it) {
278 ATH_MSG_DEBUG (
"Filled " << mapEncoder.size() <<
" Rod Blocks" );
279 return StatusCode::SUCCESS;
289 << name()<<
".InitializeForWriting" );
290 return StatusCode::FAILURE;
293 ATH_MSG_DEBUG (
"Null pointer passed to WriteLArCalibDigit routine!" );
294 return StatusCode::FAILURE;
299 if (!blstruct->canSetEnergy()) {
300 ATH_MSG_DEBUG (
"This instance of LArRodBlockStructure can't hold LArRawChannels!" );
301 return StatusCode::FAILURE;
308 LArRawChannelContainer::const_iterator it = channelCont->begin();
309 LArRawChannelContainer::const_iterator it_e= channelCont->end();
311 ATH_MSG_WARNING (
"Attempt to persistify a empty LArDigitContainer to ByteStream" );
312 return StatusCode::SUCCESS;
315 const EventContext& ctx = Gaudi::Hive::currentContext();
321 std::map<uint32_t, LArRodEncoder> mapEncoder;
324 {
return mapEncoder.try_emplace (reid,
328 blstruct.get()).first->second; };
333 ATH_MSG_DEBUG(
" number of LArRawChannel container "<< channelCont->size() );
334 for(; it!=it_e; ++it){
337 uint32_t reid = hid2re.
getRodID( **febRodMapping, chid );
349 getEncoder(reid).add (&rawChan);
357 if ( blstruct->canIncludeRawData() ){
361 ATH_MSG_WARNING (
"Attempt to persistify a empty LArDigitContainer to ByteStream" );
363 for(; it_b!=it_e; ++it_b){
366 uint32_t reid = hid2re.
getRodID( **febRodMapping, chid );
368 getEncoder(reid).add (digit);
377 std::map<uint32_t,LArRodEncoder>::iterator it_m =mapEncoder.begin();
378 std::map<uint32_t,LArRodEncoder>::iterator it_m_e=mapEncoder.end();
381 for(; it_m!=it_m_e;++it_m) {
387 ATH_MSG_DEBUG (
"Filled " << mapEncoder.size() <<
" Rod Blocks" );
388 return StatusCode::SUCCESS;
403 ATH_MSG_ERROR (
"RawEvent passed to 'convert'-function is a null pointer!" );
404 return StatusCode::FAILURE;
407 if (!
m_decoder->check_valid (
re,
msg()))
return StatusCode::FAILURE;
410 ATH_MSG_VERBOSE ( MSG::hex <<
"Full source ID: " <<
re->source_id() << MSG::dec );
415 eformat::helper::build_toc(*
re, robIndex );
416 if ( robIndex.empty() ) {
417 return StatusCode::FAILURE;
419 return StatusCode::SUCCESS;
424std::unique_ptr<LArRodBlockStructure>
432 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockTransparent (#2)" );
433 return std::make_unique<LArRodBlockTransparentV0<LArRodBlockHeaderTransparentV0> >();
437 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockCalibration (#7)" );
438 return std::make_unique<LArRodBlockCalibrationV0<LArRodBlockHeaderCalibrationV0> >();
443 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockPhysics (#5)" );
444 return std::make_unique<LArRodBlockPhysicsV5>();
447 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockPhysics (#6)" );
448 return std::make_unique<LArRodBlockPhysicsV6>();
451 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockPhysics (#4)" );
452 return std::make_unique<LArRodBlockPhysicsV0>();
457 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockPhysics (#5)" );
458 return std::make_unique<LArRodBlockPhysicsV3>();
462 return std::make_unique<LArRodBlockPhysicsV0>();
471 auto hid2re = std::make_unique<Hid2RESrcID>();
472 if (hid2re->initialize (rodMapping).isFailure()) {
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
DataModel_detail::const_iterator< DataVector > const_iterator
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.
void setRodMinorVersion(uint16_t m)
change the ROD minor version
void setDetEvtType(uint32_t m)
change Detector Event Type
std::vector< uint32_t > RODDATA
RODDATA * getRodData(uint32_t id)
get a block of ROD data
uint32_t getRodID(const LArFebRodMapping &rodMapping, const HWIdentifier &hid) const
make a ROD SrcID for a HWIdentifier
Container class for LArCalibDigit.
Base class for LArDigits taken during calibration runs.
Container class for LArDigit.
Liquid Argon digit base class.
Container for LArRawChannel (IDC using LArRawChannelCollection)
Liquid Argon ROD output object base class.
HWIdentifier channelID() const
This class provides conversion from LArRawChannel and LArDigit to ROD format.