30 ShortVecAdapter (std::vector<uint32_t>& v)
32 void push_back (int16_t
x)
35 m_v.back() |= (
x << 16);
49 std::vector<uint32_t>& m_v;
50 bool m_offset =
false;
99 unsigned int OFType = (
unsigned int)
type;
103 <<
" using type=0 instead " );
118 m_unitType = (rChUnit << 30) | (3 << 28) | (0 << 27) | (OFType << 24) | (
m_type << 16);
175 std::vector<uint32_t>::size_type start = 0;
177 int NMuons1 = 0, NMuons2 = 0, frag = 0;
181 int ros = ((l2->identify()) | 0xff) >> 8;
182 int drawer = (l2->identify()) & 0xff;
184 if ((drawer % 2) == 0) frag = 0x00100000 + (ros << 12) + ((drawer + 1) << 6) + drawer;
186 if (frag != currentFrag) {
191 v.push_back(0xff1234ff);
203 for (
int i = 0; i < 2; ++i)
207 int wet = (int) round(l2->sumEt());
208 v[start] = (
unsigned int) (wet + 9000);
211 NMuons1 = l2->NMuons();
212 for (
int i = 0; i < 2 * NMuons1; ++i)
213 v.push_back(l2->val(i));
218 int wet = (int) round(l2->sumEt());
219 v[start + 1] = (
unsigned int) (wet + 9000);
222 NMuons2 = l2->NMuons();
223 for (
int i = 0; i < 2 * NMuons2; ++i)
224 v.push_back(l2->val(i));
229 v[start - 2] = 5 + 2 * NMuons1 + 2 * NMuons2;
241 std::vector<uint32_t>::size_type start = 0;
247 int ros = (l2->identify()) >> 8;
248 int drawer = (l2->identify()) & 0xff;
250 if ((drawer % 2) == 0)
251 frag = 0x120000 + (ros << 12) + ((drawer + 1) << 6) + drawer;
253 frag = 0x120000 + (ros << 12) + (drawer << 6) + (drawer - 1);
255 if (frag != currentFrag) {
260 v.push_back(0xff1234ff);
273 int Ndata = l2->Ndata();
275 for (
int i = 0; i < Ndata; ++i)
276 v.push_back(l2->val(i));
281 v[start - 2] += Ndata;
292 std::vector<uint32_t>::size_type start = 0;
298 if (frag != currentFrag) {
319 int chan =
rc->channel();
320 int gain =
rc->adc();
333 ShortVecAdapter v16 (v);
339 std::vector<uint32_t>::size_type
head = 0;
340 std::vector<uint32_t>::size_type
count = 0;
342 std::vector<short> vshort;
348 int chan =
rc->channel();
349 int gain =
rc->adc();
351 if (frag != currentFrag) {
386 for (
short x : vshort)
410 std::vector<uint32_t>::size_type start = 0;
416 if (frag != currentFrag) {
420 v.push_back(0xff1234ff);
442 int chan =
rc->channel();
443 int gain =
rc->adc();
457 std::map<int, const TileL2*> l2_map;
460 l2_map[l2->identify()] = l2;
464 std::vector<uint32_t>::size_type start = 3;
466 while (start <= v.size()) {
467 uint32_t size = v[start - 2];
468 uint32_t fragtype = v[start - 1];
469 int type = (fragtype >> 16) & 0xFF;
471 if ((
type == 4 && size > 53) || (
type == 5 && ((fragtype >> 27) & 7) > 2)) {
472 int frag = fragtype & 0xFFFF;
473 std::map<int, const TileL2*>::const_iterator l2_it = l2_map.find(frag);
474 if (l2_it != l2_map.end()) {
475 int unit = (fragtype >> 30);
476 const TileL2* l2 = l2_it->second;
478 v[start + 48] = (uint32_t)
et;
480 v[start + 49] = (uint32_t) ez;
482 v[start + 50] = (uint32_t) e;
498 int currentFrag = -1, pos = 0, size = 0;
502 int frag =
m_tileHWID->frag(adcID) | (0x01 << 16);
503 if (frag != currentFrag) {
504 if (currentFrag != -1) v[pos] = size;
507 v.push_back(0xFF1234FF);
517 if (currentFrag != -1) v[pos] = size;
522 ATH_MSG_ERROR(
"fillROD5 -> store raw channels in frag5 - not yet implemented " );
526 ATH_MSG_ERROR(
"fillROD5D -> store digits in frag5 - not yet implemented " );
539 v.push_back(0xff1234ff);
546 uint savepos=v.size()-1;
550 uint32_t verfrag = 0x500;
551 uint32_t type_version = (0x40 << 16) + verfrag;
552 v.push_back(type_version);
554 v.resize(v.size()+size);
558 int word8bit_cnt = 0;
564 memset(word, 0,
sizeof(word));
569 ATH_MSG_WARNING(
"Too many channels per fragment for TMDB frag 0x40 - ignoring all the rest" );
575 std::vector<float> digits = digi->samples();
576 nsamp = digits.size();
578 ATH_MSG_WARNING(
"Too many samples in digits for TMDB frag 0x40, using first 7 instead of "<<nsamp );
580 digits.resize(nsamp);
592 int shift = word8bit_cnt * 8;
593 for (
uint i=0; i<nsamp; ++i ) {
594 word[i] += ((int) digits[i]) << shift;
602 const char * strchannel[5] = {
" d5L ",
" d5R ",
" d6L ",
" d6R ",
" xxx "};
603 int j=std::min(channel,4);
605 for (
uint i=0; i<nsamp; ++i ) {
606 msg(MSG::DEBUG) << ros <<
"/" << drawer <<
"/" << channel << strchannel[j]
607 <<
"\tSample "<<7-i<<
" bits |" << std::setfill(
'0') << std::setw(2)
608 << shift <<
"-" << std::setw(2) << shift+7 << std::setfill(
'0')
609 <<
"| of 32-bit word "<<3 + nwc*i + wc<<
" "<<digits[i]
610 <<
" "<<MSG::hex<<word[i]<<MSG::dec <<
endmsg;
626 if ( word8bit_cnt == 4 ) {
627 for (
uint i=0; i<nsamp; ++i ) {
628 v.at( 3 + nwc*i + wc ) = word[i];
632 memset(word, 0,
sizeof(word));
637 if ( word8bit_cnt != 0 && wc<nwc ) {
638 ATH_MSG_WARNING(
"Unexpected number of channels for TMDB frag 0x40" << wc*4 + word8bit_cnt );
639 for (
uint i=0; i<nsamp; ++i ) {
640 v.at( 3 + nwc*i + wc ) = word[i];
644 memset(word, 0 ,
sizeof(word));
647 v.at(savepos)=3+size;
649 ATH_MSG_DEBUG(
"Check version and counters: "<<MSG::hex<< verfrag <<MSG::dec<<
" "<< chc <<
" "<< wc <<
" save in position: " << savepos );
653 if (
msgLvl(MSG::VERBOSE)) {
654 msg(MSG::VERBOSE) <<
"Check content of ROD fragment after including sub-fragment (0x40)... " << v.size() <<
endmsg;
655 for (
size_t i=0; i<v.size(); ++i)
656 msg(MSG::VERBOSE) << i <<
"\t" << v.at(i) << MSG::hex <<
" 0x" << v.at(i) << MSG::dec <<
endmsg;
668 const float TMDB_AMPLITUDE_FACTOR = 1.0;
672 v.push_back(0xff1234ff);
677 uint savepos=v.size()-1;
681 uint32_t verfrag = 0x500;
685 if (use_16bit_packing) verfrag += 2;
686 int32_t word16 = 0x0;
688 uint32_t type_version = (0x41 << 16) + verfrag;
689 v.push_back(type_version);
702 float f_amp =
rc -> amplitude();
703 int32_t i_amp = lround(f_amp*TMDB_AMPLITUDE_FACTOR) ;
724 if (i_amp>0x7FFF) word16 = 0x7FFF;
725 else if (i_amp<-0x8000) word16 = -0x8000;
729 word |= word16 << 16;
733 word = word16 & 0xFFFF;
743 word = (uint32_t)i_amp;
749 int frag_id =
rc->frag();
750 int drawer = (frag_id&0xFF);
751 int ros = frag_id>>8;
752 int channel =
rc->channel();
753 const char * strchannel[5] = {
" d5L ",
" d5R ",
" d6L ",
" d6R ",
" xxx "};
754 int j=std::min(channel,4);
756 msg(MSG::DEBUG) << ros <<
"/" << drawer <<
"/" << channel << strchannel[j]
757 <<
"\tAmp " << f_amp <<
" " << i_amp <<
" "
758 <<
" ch cnt " << chc <<
" word cnt " << wc
759 <<
" word 0x" <<MSG::hex<< word <<MSG::dec<<
endmsg;
767 if (verfrag==0x502 && wc*2 != chc) {
775 ATH_MSG_DEBUG(
"Check version and counters: "<<MSG::hex<< verfrag <<MSG::dec<<
" "<< chc <<
" "<< wc <<
" save in position: "<< savepos );
777 if (
msgLvl(MSG::VERBOSE)) {
778 msg(MSG::VERBOSE) <<
"Check content of ROD fragment after including sub-fragment (0x41)... "<<
m_vTileRC.size() <<
" "<< v.size() <<
endmsg;
779 for (
size_t i=0; i<v.size(); ++i) {
780 msg(MSG::VERBOSE) << i <<
"\t"<< v.at(i) << MSG::hex <<
" 0x" << v.at(i) << MSG::dec <<
endmsg;
796 v.push_back(0xff1234ff);
801 uint savepos = v.size()-1;
802 uint32_t verfrag = 0x500;
803 uint32_t type_version = (0x42 << 16) + verfrag;
804 v.push_back(type_version);
810 uint32_t result1 = 0x0;
811 uint32_t result2 = 0x0;
812 uint32_t result3 = 0x0;
818 msg(MSG::INFO) <<
"Going trough RUN2 encoding procedure for TMDB data" <<
endmsg;
837 int modid = tmurcv->identify() & 0xff;
839 const std::vector<bool> & slin = tmurcv->GetDecision();
840 int imax = std::min((
int)slin.size(),4);
841 uint32_t word4b = 0x0;
842 for (
int i=0;i<
imax;++i){
843 if (slin[i]) word4b |= 1 << (3-i);
847 std::stringstream
ss;
848 for (
const bool val : slin) {
849 ss<<std::setw(2)<<val;
851 msg(MSG::INFO) <<
"Result for module: "<<modid<<
" in TMDB board "<<modid%8<<MSG::hex<<
": 0x"<<word4b<<MSG::dec<<
" from "<<
ss.str() <<
endmsg;
855 case 0: result1 |= word4b << 4 ;
break;
856 case 1: result1 |= word4b << 8 ;
break;
857 case 2: result1 |= word4b << 12 ; result2 |= word4b;
break;
858 case 3: result2 |= word4b << 4 ;
break;
859 case 4: result2 |= word4b << 8 ;
break;
860 case 5: result2 |= word4b << 12 ; result3 |= word4b;
break;
861 case 6: result3 |= word4b << 4 ;
break;
862 case 7: result3 |= word4b << 8 ;
break;
867 ATH_MSG_INFO(
"Summary : "<<MSG::hex<<
" Results 1: 0x"<<result1<<
" Results 2: 0x"<<result2<<
" Results 3: 0x"<<result3<< MSG::dec );
869 v.push_back( result1 | (result2 << 16) ); ++wc;
870 v.push_back( result3 ); ++wc;
877 msg(MSG::INFO) <<
"Going trough RUN3 encoding procedure for TMDB data" <<
endmsg;
905 int modid = tmurcv->identify() & 0xff;
906 const std::vector<bool> & slin = tmurcv->GetDecision();
907 int imax = std::min((
int)slin.size(),4);
908 uint32_t word3b = 0x0;
909 for (
int i=1;i<
imax;++i) {
913 if (slin[i]) word3b |= 1 << (3-i);
917 case 0: result1 |= word3b ;
break;
918 case 1: result1 |= word3b << 3 ;
break;
919 case 2: result1 |= word3b << 6 ; result2 |= word3b ;
break;
920 case 3: result1 |= word3b << 9 ; result2 |= word3b << 3 ;
break;
921 case 4: result2 |= word3b << 6 ; result3 |= word3b ;
break;
922 case 5: result2 |= word3b << 9 ; result3 |= word3b << 3 ;
break;
923 case 6: result3 |= word3b << 6 ;
break;
924 case 7: result3 |= word3b << 9 ;
break;
929 ATH_MSG_INFO(
"Summary : "<<MSG::hex<<
" Results 1: 0x"<<result1<<
" Results 2: 0x"<<result2<<
" Results 3: 0x"<<result3<< MSG::dec );
931 v.push_back( result1 | (result2 << 16) ); ++wc;
932 v.push_back( result3 ); ++wc;
933 v.at(savepos) = 3+wc;
938 ATH_MSG_INFO(
"Tile Muon Decision Board (TMDB) fragment versions are only available for RUN2 and RUN3");
942 msg(MSG::INFO) <<
"Check version and counters: "<<MSG::hex<<verfrag<<MSG::dec<<
" "<<chc<<
" "<<wc<<
" save in position: "<<savepos<<
endmsg;
943 msg(MSG::INFO) <<
"Check content of ROD fragment after including sub-fragment (0x42)... " << v.size() <<
endmsg;
944 for (
size_t i=0; i<v.size(); ++i) {
945 msg(MSG::INFO) << i <<
"\t" << v.at(i) << MSG::hex <<
" 0x" << v.at(i) << MSG::dec <<
endmsg;
960 *(p +
a) |= (1 <<
r);
970 return *(p +
a) & (1 <<
r);
975 msg(MSG::VERBOSE) <<
" Dump of Tile ROD block, size = " << v.size() <<
endmsg;
977 int count = 0, newCount = 3;
978 for (
const uint32_t
data : v) {
980 msg(MSG::VERBOSE) <<
"Frag delim = 0x" << std::hex <<
data << std::dec <<
endmsg;
981 }
else if (
count == -1) {
983 msg(MSG::VERBOSE) <<
"Word count = " << newCount <<
endmsg;
984 }
else if (
count == -2) {
986 msg(MSG::VERBOSE) <<
"Frag ID = 0x" << std::hex <<
data << std::dec <<
endmsg;
988 msg(MSG::VERBOSE) <<
" WORD[" << newCount -
count <<
"] = "
989 <<
data <<
" = 0x" << std::hex <<
data
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
const double AMPLITUDE_FACTOR5_HG[4]
MsgStream & msg() const
The standard message stream.
bool msgLvl(const MSG::Level lvl) const
Test the output level.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Static class providing several utility functions and constants.
Helper class for TileCal online (hardware) identifiers.
Class to store TileMuId and Et quantities computed at the TileCal ROD DSPs.
void fillRODTileMuRcvObj(std::vector< uint32_t > &v)
void setMaxChannels(int maxChannels)
set maximum number of channels in a drawer
std::vector< const TileDigits * > m_vTileDigi
const TileHWID * m_tileHWID
void fillROD5(std::vector< uint32_t > &v)
std::vector< const TileL2 * > m_vTileL2
void fillROD10(std::vector< uint32_t > &v)
convert all TileL2s in the current list to a vector of 32bit words
TileRawChannel2Bytes4 m_rc2bytes4
TileRawChannel2Bytes m_rc2bytes3
void fillROD5D(std::vector< uint32_t > &v)
void fillROD(std::vector< uint32_t > &v)
convert all TileRawChannels in the current list to a vector of 32bit words
TileRawChannel2Bytes2 m_rc2bytes2
void setTypeAndUnit(TileFragHash::TYPE type, TileRawChannelUnit::UNIT unit)
set OF algorigtm type and amplitude units for a drawer
void fillRODTileMuRcvRawChannel(std::vector< uint32_t > &v)
void fillRODL2(std::vector< uint32_t > &v)
void setBit(uint32_t *p, int chan)
set the bitmap for a channel
TileROD_Encoder()
constructor
void fillROD12(std::vector< uint32_t > &v)
TileRawDataOrdering m_order
void setTileHWID(const TileHWID *tileHWID, bool verbose, unsigned int type=4)
set all necessary parameters for the encoder
bool checkBit(const uint32_t *p, int chan)
check the bitmap for a channel
TileRawChannel2Bytes5 m_rc2bytes5
std::vector< const TileFastRawChannel * > m_vTileRC
void fillROD1(std::vector< uint32_t > &v)
convert all TileDigits in the current list to a vector of 32bit words
void fillROD2(std::vector< uint32_t > &v)
std::vector< const TileMuonReceiverObj * > m_vTileMuRcvObj
void fillROD3(std::vector< uint32_t > &v)
TileDigits2Bytes m_Digi2bytes
void fillRODTileMuRcvDigi(std::vector< uint32_t > &v)
convert the TMDB objects into a vector of 32bit words: 8bit words/digit, 16bit words/RC,...
void fillROD4(std::vector< uint32_t > &v)
void dumpROD(const std::vector< uint32_t > &v)
dump contents of the ROD fragment
std::string head(std::string s, const std::string &pattern)
head of a string
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
void reverse(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of reverse for DataVector/List.
Extra patterns decribing particle interation process.