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;
157 m_logstr <<
MYLEVEL <<
"***********************************************************************"<<
endmsg;
159 m_logstr <<
MYLEVEL <<
"************************************************************************"<<
endmsg;
166 m_logstr <<
MYLEVEL <<
"************************************************************************"<<
endmsg;
168 m_logstr <<
MYLEVEL <<
"********************* SumBlck ************************************"<<
endmsg;
169 for(
int toto=0;toto<4;toto++)
171 m_logstr <<
MYLEVEL <<
"************************************************************************"<<
endmsg;
173 m_logstr <<
MYLEVEL <<
"********************* CounterBlck ************************************"<<
endmsg;
175 m_logstr <<
MYLEVEL <<
"************************************************************************"<<
endmsg;
177 m_logstr <<
MYLEVEL <<
"********************* FebInfoBlck ************************************"<<
endmsg;
179 m_logstr <<
MYLEVEL <<
"************************************************************************"<<
endmsg;
182 m_logstr <<
MYLEVEL <<
"********************* Energies ************************************"<<
endmsg;
183 for(
int toto=0;toto<128;toto++)
185 m_logstr <<
MYLEVEL <<
"************************************************************************"<<
endmsg;
187 m_logstr <<
MYLEVEL <<
"********************* Time & Quality ************************************"<<
endmsg;
188 for(
int toto=0;toto<10;toto++)
190 m_logstr <<
MYLEVEL <<
"************************************************************************"<<
endmsg;
222 const int32_t time,
const int32_t quality,
const uint32_t gain)
224 m_logstr <<
MYLEVEL <<
"setNextEnergy-------------------->>>>>********************** new format V3 ***********" <<
endmsg;
230 m_logstr << MSG::ERROR <<
"LArRODBlockStructure Error: Internal error. Channels not ordered correctly. rcNb=" << rcNb
237 setNextEnergy((int16_t)0,(int16_t)32767,(int16_t)-32767,(uint32_t)0);
259 uint32_t abse,EncodedE;
260 int16_t thetime,thequality;
263 thetime = (int16_t) time >> 4;
264 thequality = (int16_t) quality;
266 sign=(energy>=0?1:-1);
267 abse=(uint32_t)abs(energy);
271 if ((abse>8192)&&(abse<65536))
273 EncodedE=((abse>>3)|0x2000);
275 else if ((abse>65535)&&(abse<524288))
277 EncodedE=((abse>>6)|0x4000);
279 else if ((abse>524288))
281 EncodedE=((abse>>9)|0x6000);
286 if (
sign<0) EncodedE |= 0x8000;
287 theenergy = (uint16_t) EncodedE;
292 m_logstr <<
MYLEVEL <<
"setNextEnergy-------------------->>>>> Energy = "<< energy <<
" Encoded Energy =" << theenergy <<
endmsg;
300 setNextEnergy(theenergy,(int16_t)32767,(int16_t)-32767,gain);
310 {
m_logstr << MSG::ERROR <<
"LArRodBlockStructure Error: Attempt to write Energy for channel "
316 m_logstr <<
MYLEVEL <<
"In setNextEnergy-------------------->>>>> time = " << time <<
" quality=" << quality <<
endmsg;
324 ShortLong twoValues{};
327 twoValues.s[0]= energy;
334 uint16_t* valptr=
reinterpret_cast<uint16_t*
>(&oneValue);
335 twoValues.s[0]=valptr[0];
336 twoValues.s[1]=(uint16_t)energy;
341 LARBSDBG(
"Writing words: val0= " << twoValues.s[0] <<
" val1= " << twoValues.s[1]);
343 LARBSDBG(
"Writing Raw data to E block. E=" << energy);
351 if (mylocalBitwiseIndex==0)
355 SB = (quality==-32767?0x00000000:0x00000001);
363 SB=(SB<<1)|(quality==-32767?0x00000000:0x00000001);
370 if (mylocalBitwiseIndex==0)
378 encodedgains=(encodedgains<<2)|(gain&0x00000003);
395 ShortLong twoValues{};
396 if (mylocalBitwiseIndex==0)
400 twoValues.s[0]=(int16_t)(time)|((quality>>10)&0x003F);
406 int16_t* valptr=
reinterpret_cast<int16_t*
>(&oneValue);
407 twoValues.s[0]=valptr[0];
408 twoValues.s[1]=(int16_t)(time)|((quality>>12)&0x003F);
420 {
m_logstr << MSG::ERROR <<
"Attempt to write Energy for channel " << rcNb <<
" channels into a FEB!" <<
endmsg;
424 if(samples.size() != nsamples) {
425 m_logstr << MSG::ERROR <<
"Number of samples mismatch!\n";
426 m_logstr <<
" nsamples =" << nsamples;
434 if((nsamples/2)*2!=nsamples) {
436 for (
unsigned int i=1;i<nsamples;i+=2)
440 m_RawDataBlock.push_back((gain<<30) | (samples[1]<<18) | samples[0]<<2);
441 for (
unsigned int i=2;i<nsamples;i+=2)
452 unsigned int sizeRead=0;
454 while (sizeRead<fragment.size()) {
455 std::vector<uint32_t>::iterator FebIter;
456 FebIter=fragment.begin()+sizeRead;
461 if (FebIter+currFebSize>fragment.end()) {
463 m_logstr << MSG::ERROR <<
"Got inconsistent ROD-Fragment!" <<
endmsg;
466 m_mFebBlocks[currFEBid].assign(FebIter,FebIter+currFebSize);
468 LARBSDBG(
"Found FEB-id " << currFEBid <<
" in existing ROD-Fragment");
500 setNextEnergy((uint16_t)0,(int16_t)32767,(int32_t)-32767,(uint32_t)0);
503 uint16_t BlockOffset;
509 LARBSDBG(
"Checking for Summary Block n=" << n <<
"BlockOffset=" << BlockOffset);
510 if (n && !BlockOffset)
514 m_logstr << MSG::DEBUG <<
"In finalizeFEB-------------------->>>>> " <<
"Checking for Summary Block : length= " << n <<
" BlockOffset=" << BlockOffset <<
endmsg;
515 for (
unsigned i=0;i<n;i++)
522 ShortLong twoValues{};
549 uint32_t*
aux = (uint32_t*)&
m_Ex;
566 LARBSDBG(
"Checking for Counter Block n=" << n <<
"BlockOffset=" << BlockOffset);
567 if (n && !BlockOffset)
571 m_logstr << MSG::INFO <<
"In finalyseFEB-------------------->>>>> " <<
"Checking for Counter Block : length= " << n <<
" BlockOffset=" << BlockOffset <<
endmsg;
572 for (
unsigned i=0;i<n;i++)
579 LARBSDBG(
"Checking Energy Block n=" << n <<
"BlockOffset=" << BlockOffset);
581 if (n && !BlockOffset)
585 m_logstr << MSG::DEBUG <<
"In finalyseFEB-------------------->>>>> " <<
"Checking for Energy Block : length= " << n <<
" BlockOffset=" << BlockOffset <<
endmsg;
587 for(
unsigned int i=0;i<n;i++)
594 LARBSDBG(
"Checking Gain Block n=" << n <<
"BlockOffset=" << BlockOffset);
596 if (n && !BlockOffset)
601 for(
unsigned int i=0;i<n;i++)
612 LARBSDBG(
"Checking FebInfo Block n=" << n <<
"BlockOffset=" << BlockOffset);
614 if (n && !BlockOffset)
619 for(
unsigned int i=0;i<n;i++)
626 LARBSDBG(
"Checking Time and Quality Block n=" << n <<
"BlockOffset=" << BlockOffset);
628 if (n && !BlockOffset)
632 m_logstr << MSG::DEBUG <<
"In finalyseFEB-------------------->>>>> " <<
"Checking for Time and Quality Block : length= " << n <<
" BlockOffset=" << BlockOffset <<
endmsg;
633 for(
unsigned int i=0;i<n;i++)
638 LARBSDBG(
"Checking Raw Data Block");
641 LARBSDBG(
"Checking Raw Data Block. n=" << n <<
"BlockOffset=" << BlockOffset);
646 for(
unsigned int i=0;i<n;i++)
662 m_logstr <<
MYLEVEL <<
"***********************************************************************"<<
endmsg;
665 m_logstr <<
MYLEVEL <<
"***********************************************************************"<<
endmsg;
668 m_logstr <<
MYLEVEL <<
"***********************************************************************"<<
endmsg;
679 FEBMAPTYPE::const_iterator feb_it_b=
m_mFebBlocks.begin();
681 FEBMAPTYPE::const_iterator feb_it;
682 for (feb_it=feb_it_b;feb_it!=feb_it_e;++feb_it) {
683 if (feb_it!=feb_it_b)
700 feb_it->second.begin(), feb_it->second.end());
709 LARBSDBG(
"in LArRodBlockPhysicsV3::getNextRawData.");
734 LARBSDBG(
"This run has " << nsamples <<
" samples");
739 gain=3-((
m_GainPtr[channelNumber/16] >> (channelNumber%16)*2) & 0x3);
741 for(
unsigned int i=0;i<nsamples;i++) {
747 samples.push_back((
short) (
x & 0xfff));
753 short movedSample=samples[0];
755 samples[i-1]=samples[i];
766template<
class RAWDATA>
767bool LArRodBlockPhysicsV3::operator ()
769 (
const RAWDATA* ch1,
const RAWDATA* ch2)
const
778 int cId1 = m_onlineHelper->channel(id1);
779 int cId2 = m_onlineHelper->channel(
id2);
780 return FebToRodChannel(cId1) < FebToRodChannel(cId2);
790{
std::sort(vDigit.begin(),vDigit.end(),*
this);
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
virtual void resetPointers()
virtual uint32_t getNumberOfSamples() const
virtual uint16_t getCtrl3(uint32_t adc) const
virtual uint32_t getNumberOfGains() const
virtual void setOffTimeCut(uint16_t TimeCut)
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
uint16_t m_HottestCellIndex
const uint32_t * m_SumBlkPtr
const int16_t * m_RawDataPtr
virtual void concatinateFEBs()
const uint32_t * m_GainPtr
std::vector< uint32_t > m_EnergyBlock
virtual void setEz(double Ez)
static const uint32_t m_DummyBitMap[4]
std::vector< uint32_t > m_RawDataBlock
std::vector< uint32_t > m_CounterBlkBlock
std::vector< uint32_t > m_SumBlkBlock
virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain)
virtual void setNumberOfSamples(const uint8_t n)
std::vector< uint32_t > m_TimeQualityBlock
virtual void initializeFragment(std::vector< uint32_t > &fragment)
virtual void setEy(double Ey)
virtual void initializeFEB(const uint32_t id)
std::vector< uint32_t > m_GainBlock
uint16_t m_EnergyThreshold
const int16_t * m_TimeQualityPtr
virtual uint16_t getCtrl1(uint32_t adc) const
const uint16_t * m_CounterPtr
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
const int16_t * m_FebInfoDataPtr
int FebToRodChannel(int ch) const
virtual uint16_t getCtrl2(uint32_t adc) const
const uint32_t * m_RawDataFlagsPtr
uint16_t m_numberHotCellOffTime
std::vector< uint32_t > m_FebInfoBlock
virtual bool setPointers()
virtual void setEThreshold(uint16_t thres)
virtual uint32_t getStatus() const
const uint16_t * m_EnergyPtr
uint32_t m_HottestCellEnergy
virtual void finalizeFEB()
virtual void setEx(double Ex)
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
virtual void setRawData(const int channel, const std::vector< short > &samples, const uint32_t gain)
virtual void setNumberOfGains(const uint8_t n)
unsigned int m_rearrangeFirstSample
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.