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
163 {
m_logstr << MSG::ERROR <<
"LArRodBlockStructure Error: Attempt to write Energy for channel "
167 LARBSDBG(
"LArRodBlockStructure: Setting Energy for channel " <<
m_EIndex <<
". E=" << energy);
168 if (quality<0 && energy<0x7FFE && gain==0) {
170 ShortLong twoValues{};
174 twoValues.s[0]=(int16_t)energy;
179 int16_t* valptr=
reinterpret_cast<int16_t*
>(&oneValue);
180 twoValues.s[0]=valptr[0];
181 twoValues.s[1]=(int16_t)energy;
183 LARBSDBG(
"Writing words: val0= " << twoValues.s[0] <<
" val1= " << twoValues.s[1]);
185 LARBSDBG(
"Writing Raw data to Low E block. E=" << energy);
200 uint32_t gtQ = (gain << 30) | (t_sign<<29) | ((abs_time & 0x1fff)<<16) | (0xffff & quality);
202 LARBSDBG(
"Writing Raw data to High E block. E=" << energy <<
" Q=" << quality);
215 {
m_logstr << MSG::ERROR <<
"Attempt to write Energy for channel " << rcNb <<
" channels into a FEB!" <<
endmsg;
219 if(samples.size() != nsamples) {
220 m_logstr << MSG::ERROR <<
"Number of samples mismatch!\n";
221 m_logstr <<
" nsamples =" << nsamples;
229 if((nsamples/2)*2!=nsamples) {
231 for (
unsigned int i=1;i<nsamples;i+=2)
235 m_RawDataBlock.push_back((gain<<30) | (samples[1]<<18) | samples[0]<<2);
236 for (
unsigned int i=2;i<nsamples;i+=2)
247 unsigned int sizeRead=0;
249 while (sizeRead<fragment.size()) {
250 std::vector<uint32_t>::iterator FebIter;
251 FebIter=fragment.begin()+sizeRead;
256 if (FebIter+currFebSize>fragment.end()) {
258 m_logstr << MSG::ERROR <<
"Got inconsistent ROD-Fragment!" <<
endmsg;
261 m_mFebBlocks[currFEBid].assign(FebIter,FebIter+currFebSize);
263 LARBSDBG(
"Found FEB-id " << currFEBid <<
" in existing ROD-Fragment");
290 uint16_t BlockOffset;
295 LARBSDBG(
"Checking Low Energy Block n=" << n <<
"BlockOffset=" << BlockOffset);
298 for (
unsigned i=0;i<n;i++)
304 LARBSDBG(
"Checking High Energy Block n=" << n <<
"BlockOffset=" << BlockOffset);
306 if (n && !BlockOffset)
308 for(
unsigned int i=0;i<n;i++)
313 LARBSDBG(
"Checking Raw Data Block");
316 LARBSDBG(
"Checking Raw Data Block. n=" << n <<
"BlockOffset=" << BlockOffset);
320 for(
unsigned int i=0;i<n;i++)
328 <<
"Energy-index:" <<
m_EIndex << std::endl
329 <<
"Filled channels: " <<
m_ECounter << std::endl);
338 FEBMAPTYPE::const_iterator feb_it_b=
m_mFebBlocks.begin();
340 FEBMAPTYPE::const_iterator feb_it;
341 for (feb_it=feb_it_b;feb_it!=feb_it_e;++feb_it) {
342 if (feb_it!=feb_it_b)
359 feb_it->second.begin(), feb_it->second.end());
368 LARBSDBG(
"in LArRodBlockPhysicsV1::getNextRawData.");
388 LARBSDBG(
"This run has " << nsamples <<
" samples");
393 if((nsamples/2)*2!=nsamples) {
396 samples.push_back((
short) (
x>>2 & 0xfff));
397 for(
unsigned int i=1;i<=(nsamples-1)/2;i++) {
399 samples.push_back((
short) (
x>>2 & 0xfff));
400 samples.push_back((
short) (
x>>18));
406 samples.push_back((
short) (
x>>2 & 0xfff));
408 samples.push_back((
short) ((
x>>18) & 0xfff));
410 for (
unsigned int i=1;i<nsamples/2;i++) {
412 samples.push_back((
short) (
x>>2 & 0xfff));
413 samples.push_back((
short) (
x >> 18));
554template<
class RAWDATA>
555bool LArRodBlockPhysicsV1::operator ()
557 (
const RAWDATA* ch1,
const RAWDATA* ch2)
const
566 int cId1 = m_onlineHelper->channel(id1);
567 int cId2 = m_onlineHelper->channel(
id2);
568 return FebToRodChannel(cId1) < FebToRodChannel(cId2);
579{
std::sort(vDigit.begin(),vDigit.end(),*
this);
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
virtual void initializeFEB(const uint32_t id)
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
const int32_t * m_HighEPtr
static const uint32_t m_DummyBitMap[4]
virtual void setNumberOfGains(const uint8_t n)
virtual void resetPointers()
virtual void initializeFragment(std::vector< uint32_t > &fragment)
int FebToRodChannel(int ch) const
virtual bool setPointers()
std::vector< uint32_t > m_RawDataBlock
std::vector< uint32_t > m_LowEnergyBlock
virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain)
unsigned short m_NFlaggingWords
virtual void setRawData(const int channel, const std::vector< short > &samples, const uint32_t gain)
virtual void setNumberOfSamples(const uint8_t n)
std::vector< uint32_t > m_HighEnergyBlock
const uint32_t * m_FlagPtr
virtual void finalizeFEB()
virtual void concatinateFEBs()
const int16_t * m_LowEPtr
uint16_t getVectorHeader16(const unsigned n) const
int getBit(const uint32_t *const p, const unsigned chan) const
uint16_t getHeader16(const unsigned n) const
void setHeader32(const unsigned n, const uint32_t w)
uint32_t getHeader32(const unsigned n) const
const uint32_t * m_FebBlock
void setBit(uint32_t *const p, const unsigned chan)
void setHeader16(const unsigned n, const uint16_t w)
std::vector< uint32_t > * m_pRODblock
unsigned short m_iHeadBlockSize
std::vector< uint32_t > * m_vFragment
int32_t m_MiddleHeaderSize
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.