14#include "GaudiKernel/Bootstrap.h"
15#include "GaudiKernel/ISvcLocator.h"
16#include "GaudiKernel/IToolSvc.h"
22#define LARBSDBG(text) m_logstr<<MSG::DEBUG<<text<<endmsg
41 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
43 m_logstr << MSG::ERROR <<
"Unable to locate DetectorStore" <<
endmsg;
46 StatusCode
sc = detStore->retrieve(online_id,
"LArOnlineID");
48 m_logstr << MSG::FATAL <<
"Could not get LArOnlineID helper !" << endmsg;
52 m_onlineHelper=online_id;
53 m_logstr << MSG::DEBUG <<
" Found the LArOnlineID helper. " << endmsg;
129 const int32_t time,
const int32_t quality,
const uint32_t gain) {
134 m_logstr << MSG::ERROR <<
"LArRODBlockStructure Error: Internal error. Channels not ordered correctly. rcNb=" << rcNb
152 m_logstr << MSG::ERROR <<
"LArRodBlockStructure Error: Attempt to write Energy for channel "
156 LARBSDBG(
"LArRodBlockStructure: Setting Energy for channel " <<
m_EIndex <<
". E=" << energy);
157 if (quality<0 && energy<0x7FFE && gain==0) {
159 ShortLong twoValues{};
163 twoValues.s[0]=(int16_t)energy;
168 int16_t* valptr=
reinterpret_cast<int16_t*
>(&oneValue);
169 twoValues.s[0]=valptr[0];
170 twoValues.s[1]=(int16_t)energy;
172 LARBSDBG(
"Writing words: val0= " << twoValues.s[0] <<
" val1= " << twoValues.s[1]);
174 LARBSDBG(
"Writing Raw data to Low E block. E=" << energy);
189 uint32_t gtQ = (gain << 30) | (t_sign<<29) | ((abs_time & 0x1fff)<<16) | (0xffff & quality);
191 LARBSDBG(
"Writing Raw data to High E block. E=" << energy <<
" Q=" << quality);
202 m_logstr << MSG::ERROR <<
"Attempt to write Energy for channel " << rcNb <<
" channels into a FEB!" <<
endmsg;
206 if(samples.size() != nsamples) {
207 m_logstr << MSG::ERROR <<
"Number of samples mismatch!\n";
208 m_logstr <<
" nsamples =" << nsamples;
216 if((nsamples/2)*2!=nsamples) {
218 for (
unsigned int i=1;i<nsamples;i+=2)
222 m_RawDataBlock.push_back((gain<<30) | (samples[1]<<18) | samples[0]<<2);
223 for (
unsigned int i=2;i<nsamples;i+=2)
234 unsigned int sizeRead=0;
236 while (sizeRead<fragment.size()) {
237 std::vector<uint32_t>::iterator FebIter;
238 FebIter=fragment.begin()+sizeRead;
242 if (FebIter+currFebSize>fragment.end()) {
244 m_logstr << MSG::ERROR <<
"Got inconsistent ROD-Fragment!" <<
endmsg;
247 m_mFebBlocks[currFEBid].assign(FebIter,FebIter+currFebSize);
249 LARBSDBG(
"Found FEB-id " << currFEBid <<
" in existing ROD-Fragment");
277 uint16_t BlockOffset;
282 LARBSDBG(
"Checking Low Energy Block n=" << n <<
"BlockOffset=" << BlockOffset);
286 for (
unsigned i=0;i<n;i++)
292 LARBSDBG(
"Checking High Energy Block n=" << n <<
"BlockOffset=" << BlockOffset);
294 if (n && !BlockOffset)
297 for(
unsigned int i=0;i<n;i++)
302 LARBSDBG(
"Checking Raw Data Block");
305 LARBSDBG(
"Checking Raw Data Block. n=" << n <<
"BlockOffset=" << BlockOffset);
310 for(
unsigned int i=0;i<n;i++)
318 <<
"Energy-index:" <<
m_EIndex << std::endl
319 <<
"Filled channels: " <<
m_ECounter << std::endl);
326 FEBMAPTYPE::const_iterator feb_it_b=
m_mFebBlocks.begin();
328 FEBMAPTYPE::const_iterator feb_it;
329 for (feb_it=feb_it_b;feb_it!=feb_it_e;++feb_it) {
330 if (feb_it!=feb_it_b)
335 feb_it->second.begin(), feb_it->second.end());
343 LARBSDBG(
"in LArRodBlockPhysicsV0::getNextRawData.");
364 LARBSDBG(
"This run has " << nsamples <<
" samples");
369 if((nsamples/2)*2!=nsamples) {
372 samples.push_back((
short) (
x>>2 & 0xfff));
373 for(
unsigned int i=1;i<=(nsamples-1)/2;i++) {
375 samples.push_back((
short) (
x>>2 & 0xfff));
376 samples.push_back((
short) (
x>>18));
382 samples.push_back((
short) (
x>>2 & 0xfff));
384 samples.push_back((
short) ((
x>>18) & 0xfff));
386 for (
unsigned int i=1;i<nsamples/2;i++) {
388 samples.push_back((
short) (
x>>2 & 0xfff));
389 samples.push_back((
short) (
x >> 18));
398template<
class RAWDATA>
399bool LArRodBlockPhysicsV0::operator ()
400 (
const RAWDATA* ch1,
const RAWDATA* ch2)
const
408 if(febId1 == febId2 ){
414 return febId1 < febId2 ;
425 std::sort(vDigit.begin(),vDigit.end(),*
this);
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
const int32_t * m_HighEPtr
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)
LArRodBlockPhysicsV0(IMessageSvc *msgSvc)
virtual void initializeFEB(const uint32_t id)
virtual void setNumberOfSamples(const uint8_t n)
virtual void finalizeFEB()
int FebToRodChannel(int ch) const
static std::string BlockType()
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()
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
const int16_t * m_LowEPtr
const LArOnlineID * m_onlineHelper
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
LArRodBlockStructure(IMessageSvc *msgSvc, const std::string &blockType)
std::vector< uint32_t > * m_vFragment
int32_t m_MiddleHeaderSize
uint16_t LE_getHeader16(const unsigned n) const
uint32_t getNumberOfWords() const
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.