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;
128 ATH_MSG_WARNING (
"Attempt to persistify an empty LArDigitContainer to ByteStream" );
129 return StatusCode::SUCCESS;
132 const EventContext& ctx = Gaudi::Hive::currentContext();
138 std::map<uint32_t, LArRodEncoder> mapEncoder;
141 {
return mapEncoder.try_emplace (reid,
145 blstruct.get()).first->second; };
150 int fixgain=(*it_b)->gain();
151 ATH_MSG_DEBUG(
" number of Digits in LArDigitContainer for gain " << fixgain <<
": "
152 << digitCont->
size() );
154 for(; it_b!=it_e; ++it_b){
157 uint32_t reid = hid2re.
getRodID( **febRodMapping, chid );
158 getEncoder(reid).add (digit, fixgain);
161 ATH_MSG_VERBOSE(
" number of channels in the LArDigitContainer for gain "
162 << fixgain <<
": "<<n );
165 if (blstruct->canSetRawData()) {
166 ATH_MSG_DEBUG(
" number of channels in LArDigit container: "<< digitCont->
size() );
169 for(; it_b!=it_e; ++it_b){
172 uint32_t reid = hid2re.
getRodID( **febRodMapping, chid );
173 getEncoder(reid).add (digit);
182 std::map<uint32_t,LArRodEncoder>::iterator it =mapEncoder.begin();
183 std::map<uint32_t,LArRodEncoder>::iterator it_end=mapEncoder.end();
186 for(; it!=it_end;++it) {
190 ATH_MSG_DEBUG (
"Filled " << mapEncoder.size() <<
" Rod Blocks" );
191 return StatusCode::SUCCESS;
202 << name()<<
".InitializeForWriting" );
203 return StatusCode::FAILURE;
205 ATH_MSG_DEBUG (
"Writing LArCalibDigitContainer to ByteStream" );
207 ATH_MSG_DEBUG (
"Null pointer passed to WriteLArCalibDigit routine!" );
208 return StatusCode::FAILURE;
213 if (!blstruct->canSetCalibration()|| !blstruct->canSetRawDataFixed()) {
214 ATH_MSG_DEBUG (
"This instance of LArRodBlockStructure can't hold LArCalibDigits!" );
215 return StatusCode::FAILURE;
225 ATH_MSG_WARNING (
"Attempt to persistify a empty LArDigitContainer to ByteStream" );
226 return StatusCode::SUCCESS;
229 ATH_MSG_ERROR (
"Inconsistent gain in LArCalibDigitContainer" );
230 return StatusCode::FAILURE;
233 const EventContext& ctx = Gaudi::Hive::currentContext();
239 std::map<uint32_t, LArRodEncoder> mapEncoder;
242 {
return mapEncoder.try_emplace (reid,
246 blstruct.get()).first->second; };
249 int fixgain=(*it_b)->gain();
252 for(; it_b!=it_e; ++it_b){
255 uint32_t reid = hid2re.
getRodID( **febRodMapping, chid );
256 getEncoder(reid).add (digit, fixgain);
260 ATH_MSG_VERBOSE(
" number of channels in the LArCalibDigitContainer for gain "
261 << fixgain <<
": "<<n );
266 std::map<uint32_t,LArRodEncoder>::iterator it =mapEncoder.begin();
267 std::map<uint32_t,LArRodEncoder>::iterator it_end=mapEncoder.end();
270 for(; it!=it_end;++it) {
274 ATH_MSG_DEBUG (
"Filled " << mapEncoder.size() <<
" Rod Blocks" );
275 return StatusCode::SUCCESS;
285 << name()<<
".InitializeForWriting" );
286 return StatusCode::FAILURE;
289 ATH_MSG_DEBUG (
"Null pointer passed to WriteLArCalibDigit routine!" );
290 return StatusCode::FAILURE;
295 if (!blstruct->canSetEnergy()) {
296 ATH_MSG_DEBUG (
"This instance of LArRodBlockStructure can't hold LArRawChannels!" );
297 return StatusCode::FAILURE;
304 LArRawChannelContainer::const_iterator it = channelCont->begin();
305 LArRawChannelContainer::const_iterator it_e= channelCont->end();
307 ATH_MSG_WARNING (
"Attempt to persistify a empty LArDigitContainer to ByteStream" );
308 return StatusCode::SUCCESS;
311 const EventContext& ctx = Gaudi::Hive::currentContext();
317 std::map<uint32_t, LArRodEncoder> mapEncoder;
320 {
return mapEncoder.try_emplace (reid,
324 blstruct.get()).first->second; };
326 ATH_MSG_DEBUG(
" number of LArRawChannel container "<< channelCont->size() );
327 for(; it!=it_e; ++it){
330 uint32_t reid = hid2re.
getRodID( **febRodMapping, chid );
332 getEncoder(reid).add (&rawChan);
340 if ( blstruct->canIncludeRawData() ){
344 ATH_MSG_WARNING (
"Attempt to persistify a empty LArDigitContainer to ByteStream" );
346 for(; it_b!=it_e; ++it_b){
349 uint32_t reid = hid2re.
getRodID( **febRodMapping, chid );
351 getEncoder(reid).add (digit);
360 std::map<uint32_t,LArRodEncoder>::iterator it_m =mapEncoder.begin();
361 std::map<uint32_t,LArRodEncoder>::iterator it_m_e=mapEncoder.end();
364 for(; it_m!=it_m_e;++it_m) {
370 ATH_MSG_DEBUG (
"Filled " << mapEncoder.size() <<
" Rod Blocks" );
371 return StatusCode::SUCCESS;
386 ATH_MSG_ERROR (
"RawEvent passed to 'convert'-function is a null pointer!" );
387 return StatusCode::FAILURE;
390 if (!
m_decoder->check_valid (
re,
msg()))
return StatusCode::FAILURE;
393 ATH_MSG_VERBOSE ( MSG::hex <<
"Full source ID: " <<
re->source_id() << MSG::dec );
398 eformat::helper::build_toc(*
re, robIndex );
399 if ( robIndex.empty() ) {
400 return StatusCode::FAILURE;
402 return StatusCode::SUCCESS;
407std::unique_ptr<LArRodBlockStructure>
415 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockTransparent (#2)" );
416 return std::make_unique<LArRodBlockTransparentV0<LArRodBlockHeaderTransparentV0> >(this->msgSvc().get());
420 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockCalibration (#7)" );
421 return std::make_unique<LArRodBlockCalibrationV0<LArRodBlockHeaderCalibrationV0> >(this->msgSvc().get());
426 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockPhysics (#5)" );
427 return std::make_unique<LArRodBlockPhysicsV5>(this->msgSvc().
get());
430 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockPhysics (#6)" );
431 return std::make_unique<LArRodBlockPhysicsV6>(this->msgSvc().
get());
434 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockPhysics (#4)" );
435 return std::make_unique<LArRodBlockPhysicsV0>(this->msgSvc().
get());
440 ATH_MSG_DEBUG (
"Set Rod Block Type to LArRodBlockPhysics (#5)" );
441 return std::make_unique<LArRodBlockPhysicsV3>(this->msgSvc().
get());
445 return std::make_unique<LArRodBlockPhysicsV0>(this->msgSvc().
get());
454 auto hid2re = std::make_unique<Hid2RESrcID>();
455 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.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)