14#include "GaudiKernel/Bootstrap.h"
15#include "GaudiKernel/ISvcLocator.h"
16#include "GaudiKernel/IToolSvc.h"
23#define LARBSDBG(text) m_logstr<<MSG::DEBUG<<text<<endmsg
42 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
44 m_logstr << MSG::ERROR <<
"Unable to locate DetectorStore" <<
endmsg;
47 StatusCode
sc = detStore->retrieve(online_id,
"LArOnlineID");
49 m_logstr << MSG::FATAL <<
"Could not get LArOnlineID helper !" << endmsg;
53 m_onlineHelper=online_id;
54 m_logstr << MSG::DEBUG <<
" Found the LArOnlineID helper. " << endmsg;
110 std::cout <<
"Fragment offsets: (m_NFlaggingWords=" <<
m_NFlaggingWords <<
")" << std::endl;
115 std::cout <<
"Flags: not present" << std::endl;
120 std::cout <<
"Low Energy: not present" << std::endl;
126 std::cout <<
"High Energy: not present" << std::endl;
143 const int32_t time,
const int32_t quality,
const uint32_t gain) {
148 m_logstr << MSG::ERROR <<
"LArRODBlockStructure Error: Internal error. Channels not ordered correctly. rcNb=" << rcNb
164 {
m_logstr << MSG::ERROR <<
"LArRodBlockStructure Error: Attempt to write Energy for channel "
168 LARBSDBG(
"LArRodBlockStructure: Setting Energy for channel " <<
m_EIndex <<
". E=" << energy);
169 if (quality<0 && energy<0x7FFE && gain==0) {
171 ShortLong twoValues{};
175 twoValues.s[0]=(int16_t)energy;
180 int16_t* valptr=
reinterpret_cast<int16_t*
>(&oneValue);
181 twoValues.s[0]=valptr[0];
182 twoValues.s[1]=(int16_t)energy;
184 LARBSDBG(
"Writing words: val0= " << twoValues.s[0] <<
" val1= " << twoValues.s[1]);
186 LARBSDBG(
"Writing Raw data to Low E block. E=" << energy);
201 uint32_t gtQ = (gain << 30) | (t_sign<<29) | ((abs_time & 0x1fff)<<16) | (0xffff & quality);
203 LARBSDBG(
"Writing Raw data to High E block. E=" << energy <<
" Q=" << quality);
216 {
m_logstr << MSG::ERROR <<
"Attempt to write Energy for channel " << rcNb <<
" channels into a FEB!" <<
endmsg;
220 if(samples.size() != nsamples) {
221 m_logstr << MSG::ERROR <<
"Number of samples mismatch!\n";
222 m_logstr <<
" nsamples =" << nsamples;
230 if((nsamples/2)*2!=nsamples) {
232 for (
unsigned int i=1;i<nsamples;i+=2)
236 m_RawDataBlock.push_back((gain<<30) | (samples[1]<<18) | samples[0]<<2);
237 for (
unsigned int i=2;i<nsamples;i+=2)
248 unsigned int sizeRead=0;
250 while (sizeRead<fragment.size()) {
251 std::vector<uint32_t>::iterator FebIter;
252 FebIter=fragment.begin()+sizeRead;
257 if (FebIter+currFebSize>fragment.end()) {
259 m_logstr << MSG::ERROR <<
"Got inconsistent ROD-Fragment!" <<
endmsg;
262 m_mFebBlocks[currFEBid].assign(FebIter,FebIter+currFebSize);
264 LARBSDBG(
"Found FEB-id " << currFEBid <<
" in existing ROD-Fragment");
291 uint16_t BlockOffset;
296 LARBSDBG(
"Checking Low Energy Block n=" << n <<
"BlockOffset=" << BlockOffset);
299 for (
unsigned i=0;i<n;i++)
305 LARBSDBG(
"Checking High Energy Block n=" << n <<
"BlockOffset=" << BlockOffset);
307 if (n && !BlockOffset)
309 for(
unsigned int i=0;i<n;i++)
314 LARBSDBG(
"Checking Raw Data Block");
317 LARBSDBG(
"Checking Raw Data Block. n=" << n <<
"BlockOffset=" << BlockOffset);
321 for(
unsigned int i=0;i<n;i++)
329 <<
"Energy-index:" <<
m_EIndex << std::endl
330 <<
"Filled channels: " <<
m_ECounter << std::endl);
339 FEBMAPTYPE::const_iterator feb_it_b=
m_mFebBlocks.begin();
341 FEBMAPTYPE::const_iterator feb_it;
342 for (feb_it=feb_it_b;feb_it!=feb_it_e;++feb_it) {
343 if (feb_it!=feb_it_b)
361 feb_it->second.begin(), feb_it->second.end());
370 LARBSDBG(
"in LArRodBlockPhysicsV0::getNextRawData.");
390 LARBSDBG(
"This run has " << nsamples <<
" samples");
395 if((nsamples/2)*2!=nsamples) {
398 samples.push_back((
short) (
x>>2 & 0xfff));
399 for(
unsigned int i=1;i<=(nsamples-1)/2;i++) {
401 samples.push_back((
short) (
x>>2 & 0xfff));
402 samples.push_back((
short) (
x>>18));
408 samples.push_back((
short) (
x>>2 & 0xfff));
410 samples.push_back((
short) ((
x>>18) & 0xfff));
412 for (
unsigned int i=1;i<nsamples/2;i++) {
414 samples.push_back((
short) (
x>>2 & 0xfff));
415 samples.push_back((
short) (
x >> 18));
556template<
class RAWDATA>
557bool LArRodBlockPhysicsV0::operator ()
559 (
const RAWDATA* ch1,
const RAWDATA* ch2)
const
568 int cId1 = m_onlineHelper->channel(id1);
569 int cId2 = m_onlineHelper->channel(
id2);
570 return FebToRodChannel(cId1) < FebToRodChannel(cId2);
581{
std::sort(vDigit.begin(),vDigit.end(),*
this);
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
const int32_t * m_HighEPtr
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
std::vector< uint32_t > m_RawDataBlock
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
virtual void setRawData(const int channel, const std::vector< short > &samples, const uint32_t gain)
virtual void initializeFEB(const uint32_t id)
virtual void setNumberOfSamples(const uint8_t n)
virtual void finalizeFEB()
int FebToRodChannel(int ch) const
unsigned short m_NFlaggingWords
virtual bool setPointers()
static const uint32_t m_DummyBitMap[4]
virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain)
virtual void resetPointers()
const int16_t * m_LowEPtr
virtual void initializeFragment(std::vector< uint32_t > &fragment)
virtual void setNumberOfGains(const uint8_t n)
virtual void concatinateFEBs()
std::vector< uint32_t > m_LowEnergyBlock
const uint32_t * m_FlagPtr
std::vector< uint32_t > m_HighEnergyBlock
int getBit(const uint32_t *const p, const unsigned chan) const
void setHeader32(const unsigned n, const uint32_t w)
uint16_t LE_getVectorHeader16(const unsigned n) const
void LE_setHeader16(const unsigned n, const uint16_t w)
uint32_t getHeader32(const unsigned n) const
const uint32_t * m_FebBlock
void setBit(uint32_t *const p, const unsigned chan)
std::vector< uint32_t > * m_pRODblock
unsigned short m_iHeadBlockSize
std::vector< uint32_t > * m_vFragment
int32_t m_MiddleHeaderSize
uint16_t LE_getHeader16(const unsigned n) const
uint32_t getNumberOfWords() const
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.