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;
122 const int32_t time,
const int32_t quality,
const uint32_t gain) {
127 m_logstr << MSG::ERROR <<
"LArRODBlockStructure Error: Internal error. Channels not ordered correctly. rcNb=" << rcNb
142 {
m_logstr << MSG::ERROR <<
"LArRodBlockStructure Error: Attempt to write Energy for channel "
146 LARBSDBG(
"LArRodBlockStructure: Setting Energy for channel " <<
m_EIndex <<
". E=" << energy);
147 if (quality<0 && energy<0x7FFE && gain==0) {
149 ShortLong twoValues{};
153 twoValues.s[0]=(int16_t)energy;
158 int16_t* valptr=
reinterpret_cast<int16_t*
>(&oneValue);
159 twoValues.s[0]=valptr[0];
160 twoValues.s[1]=(int16_t)energy;
162 LARBSDBG(
"Writing words: val0= " << twoValues.s[0] <<
" val1= " << twoValues.s[1]);
164 LARBSDBG(
"Writing Raw data to Low E block. E=" << energy);
178 uint32_t gtQ = (gain << 30) | (t_sign<<29) | ((abs_time & 0x1fff)<<16) | (0xffff & quality);
180 LARBSDBG(
"Writing Raw data to High E block. E=" << energy <<
" Q=" << quality);
190 {
m_logstr << MSG::ERROR <<
"Attempt to write Energy for channel " << rcNb <<
" channels into a FEB!" <<
endmsg;
194 if(samples.size() != nsamples) {
195 m_logstr << MSG::ERROR <<
"Number of samples mismatch!\n";
196 m_logstr <<
" nsamples =" << nsamples;
204 if((nsamples/2)*2!=nsamples) {
206 for (
unsigned int i=1;i<nsamples;i+=2)
210 m_RawDataBlock.push_back((gain<<30) | (samples[1]<<18) | samples[0]<<2);
211 for (
unsigned int i=2;i<nsamples;i+=2)
222 unsigned int sizeRead=0;
224 while (sizeRead<fragment.size()) {
225 std::vector<uint32_t>::iterator FebIter;
226 FebIter=fragment.begin()+sizeRead;
230 if (FebIter+currFebSize>fragment.end()) {
232 m_logstr << MSG::ERROR <<
"Got inconsistent ROD-Fragment!" <<
endmsg;
235 m_mFebBlocks[currFEBid].assign(FebIter,FebIter+currFebSize);
237 LARBSDBG(
"Found FEB-id " << currFEBid <<
" in existing ROD-Fragment");
264 uint16_t BlockOffset;
269 LARBSDBG(
"Checking Low Energy Block n=" << n <<
"BlockOffset=" << BlockOffset);
272 for (
unsigned i=0;i<n;i++)
278 LARBSDBG(
"Checking High Energy Block n=" << n <<
"BlockOffset=" << BlockOffset);
280 if (n && !BlockOffset)
282 for(
unsigned int i=0;i<n;i++)
287 LARBSDBG(
"Checking Raw Data Block");
290 LARBSDBG(
"Checking Raw Data Block. n=" << n <<
"BlockOffset=" << BlockOffset);
294 for(
unsigned int i=0;i<n;i++)
302 <<
"Energy-index:" <<
m_EIndex << std::endl
303 <<
"Filled channels: " <<
m_ECounter << std::endl);
311 FEBMAPTYPE::const_iterator feb_it_b=
m_mFebBlocks.begin();
313 FEBMAPTYPE::const_iterator feb_it;
314 for (feb_it=feb_it_b;feb_it!=feb_it_e;++feb_it) {
315 if (feb_it!=feb_it_b)
320 feb_it->second.begin(), feb_it->second.end());
329 LARBSDBG(
"in LArRodBlockPhysicsV0::getNextRawData.");
349 LARBSDBG(
"This run has " << nsamples <<
" samples");
354 if((nsamples/2)*2!=nsamples) {
357 samples.push_back((
short) (
x>>2 & 0xfff));
358 for(
unsigned int i=1;i<=(nsamples-1)/2;i++) {
360 samples.push_back((
short) (
x>>2 & 0xfff));
361 samples.push_back((
short) (
x>>18));
367 samples.push_back((
short) (
x>>2 & 0xfff));
369 samples.push_back((
short) ((
x>>18) & 0xfff));
371 for (
unsigned int i=1;i<nsamples/2;i++) {
373 samples.push_back((
short) (
x>>2 & 0xfff));
374 samples.push_back((
short) (
x >> 18));
383template<
class RAWDATA>
384bool LArRodBlockPhysicsV0::operator ()
385 (
const RAWDATA* ch1,
const RAWDATA* ch2)
const
393 if(febId1 == febId2 ){
399 return febId1 < febId2 ;
407{
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.