10#include "CTPfragment/CTPdataformat.h"
12#include "GaudiKernel/MsgStream.h"
23 unsigned int ctpVersionNumber =
m_rdo->getCTPVersionNumber();
24 CTPdataformatVersion ctpVersion(ctpVersionNumber);
27 ATH_MSG_DEBUG(
"setRDO> #bunches: " << nBunches <<
", ctp version (found in RDO): " << ctpVersionNumber);
31 m_BCs.resize(nBunches);
33 bc.setCTPVersion(ctpVersionNumber);
38 const std::vector<uint32_t> & TIPs = rdo->
getTIPWords();
39 const std::vector<uint32_t> & TBPs = rdo->
getTBPWords();
40 const std::vector<uint32_t> & TAPs = rdo->
getTAPWords();
41 const std::vector<uint32_t> & TAVs = rdo->
getTAVWords();
43 if( nBunches * ctpVersion.getTIPwords() != TIPs.size() ) {
44 ATH_MSG_FATAL(
"Expected " << nBunches * ctpVersion.getTIPwords() <<
" TIP words, but TIP vector has size " << TIPs.size());
48 if( nBunches * ctpVersion.getTBPwords() != TBPs.size() ) {
49 ATH_MSG_FATAL(nBunches * ctpVersion.getTBPwords() <<
" TBP words, but TBP vector has size " << TBPs.size());
53 if( nBunches * ctpVersion.getTAPwords() != TAPs.size() ) {
54 ATH_MSG_FATAL(nBunches * ctpVersion.getTAPwords() <<
" TAP words, but TAP vector has size " << TAPs.size());
58 if( nBunches * ctpVersion.getTAVwords() != TAVs.size() ) {
59 ATH_MSG_FATAL(nBunches * ctpVersion.getTAVwords() <<
" TAV words, but TAV vector has size " << TAVs.size());
65 for(
unsigned int i = 0 ; i < nBunches ; ++i) {
69 for(
unsigned int tip = 0; tip < ctpVersion.getTIPwords(); ++tip) {
70 unsigned int index = i*ctpVersion.getTIPwords() + tip;
71 if(
index >= TIPs.size()) {
78 for(
unsigned int tbp = 0; tbp < ctpVersion.getTBPwords(); ++tbp) {
79 unsigned int index = i * ctpVersion.getTBPwords() + tbp;
80 if(
index >= TBPs.size()) {
87 for(
unsigned int tap = 0; tap < ctpVersion.getTAPwords(); ++tap) {
88 unsigned int index = i * ctpVersion.getTAPwords() + tap;
89 if(
index >= TAPs.size()) {
96 for(
unsigned int tav = 0; tav < ctpVersion.getTAVwords(); ++tav) {
97 unsigned int index = i * ctpVersion.getTAVwords() + tav;
98 if(
index >= TAVs.size()) {
109 unsigned int nBunches =
m_rdo->getNumberOfBunches();
110 unsigned int vecSize =
m_BCs.size();
117 if(nBunches != vecSize) {
118 ATH_MSG_ERROR(
"mismatch: " << nBunches <<
" bunches, but vector size is " << vecSize);
122 msg() << MSG::DEBUG <<
"=================================================" <<
endmsg;
123 msg() << MSG::DEBUG <<
"Event dump" <<
endmsg;
124 msg() << MSG::DEBUG <<
"Time " <<
m_rdo->getTimeSec() <<
"s "
125 << std::setw(10) << std::setiosflags(std::ios_base::right) << std::setfill(
' ')
126 <<
m_rdo->getTimeNanoSec() << std::resetiosflags(std::ios_base::right)
128 msg() << MSG::DEBUG <<
"Number of bunches: " << nBunches
129 <<
" (BC vector size " << vecSize <<
")" <<
endmsg;
130 msg() << MSG::DEBUG <<
"L1A position: " <<
m_rdo->getL1AcceptBunchPosition() <<
endmsg;
133 for(
unsigned int i = 0; i<vecSize; ++i) {
138 ATH_MSG_DEBUG(
"=================================================");
145 if(pos >=
m_BCs.size()) {
147 << pos <<
", but in the event are only " <<
m_BCs.size());
152 <<
", which is more than the maximum : "
159 if(pos >=
m_BCs.size()) {
161 << pos <<
", but in the event are only " <<
m_BCs.size());
166 <<
", which is more than the maximum : "
175 if(pos >=
m_BCs.size()) {
177 << pos <<
", but in the event are only " <<
m_BCs.size());
178 return std::vector<unsigned int>();
180 std::vector<unsigned int> triggers;
183 for(
unsigned int i = 0; i < bc.
getTAV().size() ; ++i) {
185 triggers.push_back(i+1);
203 if( msglog.level() > MSG::DEBUG )
206 msglog << MSG::DEBUG <<
"-------------- BC dump for " <<
getBCID() <<
" ------------------------------------" <<
endmsg;
214 std::ostringstream outstream;
215 for(
unsigned int i = 0; i<
m_tip.size() ; ++i) {
217 outstream << std::setw(3) << std::setfill(
'0') << (i+1) <<
" ";
221 msglog << MSG::DEBUG <<
"TIP with input (" <<
count <<
" items): " << outstream.str() <<
endmsg;
223 msglog << MSG::DEBUG <<
"No TIP!" <<
endmsg;
229 std::ostringstream outstream;
230 for(
unsigned int i = 0; i<
m_tbp.size() ; ++i) {
232 outstream << i <<
" ";
236 msglog << MSG::DEBUG <<
"Fired TBP (" <<
count <<
" items): " << outstream.str() <<
endmsg;
238 msglog << MSG::DEBUG <<
"No TBP fired!" <<
endmsg;
244 std::ostringstream outstream;
245 for(
unsigned int i = 0; i<
m_tap.size() ; ++i) {
247 outstream << i <<
" ";
251 msglog << MSG::DEBUG <<
"Fired TAP (" <<
count <<
" items): " << outstream.str() <<
endmsg;
253 msglog << MSG::DEBUG <<
"No TAP fired!" <<
endmsg;
259 std::ostringstream outstream;
260 for(
unsigned int i = 0; i<
m_tav.size() ; ++i) {
262 outstream << i <<
" ";
266 msglog << MSG::DEBUG <<
"Fired TAV (" <<
count <<
" items): " << outstream.str() <<
endmsg;
268 msglog << MSG::DEBUG <<
"No TAV fired!" <<
endmsg;
271 msglog << MSG::VERBOSE <<
"TIP - total size: " <<
m_tip.size() <<
", with input: "
273 msglog << MSG::VERBOSE <<
"TBP " << std::endl <<
printTBP() <<
endmsg;
274 msglog << MSG::VERBOSE <<
"TAP " << std::endl <<
printTAP() <<
endmsg;
275 msglog << MSG::VERBOSE <<
"TAV " << std::endl <<
printTAV() <<
endmsg;
285 uint32_t bcidMask = 0xFFF;
302 return bcid.to_string<char,
303 std::char_traits<char>, std::allocator<char> >();
321 return rnd.to_string<char,
322 std::char_traits<char>, std::allocator<char> >();
327 std::bitset<32> prcl;
346 return prcl.to_string<char,
347 std::char_traits<char>, std::allocator<char> >();
353 std::char_traits<char>, std::allocator<char> >();
360 log << MSG::ERROR <<
"Invalid TIP position " << pos <<
endmsg;
364 std::bitset<512> bs = word;
374 for(uint32_t i = 0; i<words.size();++i)
setTIPWord(words[i],i);
379 return m_tip.to_string<char,
380 std::char_traits<char>, std::allocator<char> >();
389 log << MSG::ERROR <<
"Invalid TBP position " << pos <<
endmsg;
393 std::bitset<512> bs = word;
400 for(uint32_t i = 0; i<words.size();++i)
setTBPWord(words[i],i);
405 return m_tbp.to_string<char,
406 std::char_traits<char>, std::allocator<char> >();
413 log << MSG::ERROR <<
"Invalid TAP position " << pos <<
endmsg;
416 std::bitset<512> bs = word;
423 for(uint32_t i = 0; i<words.size();++i)
429 return m_tap.to_string<char,
430 std::char_traits<char>, std::allocator<char> >();
437 log << MSG::ERROR <<
"Invalid TAV position " << pos <<
endmsg;
440 std::bitset<512> bs = word;
447 for(uint32_t i = 0; i<words.size();++i)
453 return m_tav.to_string<char,
454 std::char_traits<char>, std::allocator<char> >();
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
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.
void setTIPWord(uint32_t word, uint32_t pos=0)
Set TIP word number 'pos'.
std::string printTBP() const
Obtain TBP bitpattern string (binary format)
void setTAP(const std::vector< uint32_t > &words)
Set TAP (Trigger After Prescales) words.
void setTBPWord(uint32_t word, uint32_t pos=0)
Set TBP word number 'pos'.
uint32_t getBCID() const
Get BCID as unsigned integer.
void dumpData(MsgStream &) const
Helper class to decode the CTP data for one bunch-crossing.
std::string printBCID() const
Return string with BCID in binary format.
std::bitset< 32 > getPrescaledClockBitSet() const
Accessor to obtain prescaled-clock input bits.
void setTAVWord(uint32_t word, uint32_t pos=0)
Set TAV word number 'pos'.
void setTAV(const std::vector< uint32_t > &words)
Set TAV (Trigger After Veto) words.
std::bitset< 512 > m_tip
Bitsets containing bit-patterns of trigger inputs and trigger.
void setTIP(const std::vector< uint32_t > &words)
Set TIP words.
const std::bitset< 512 > & getTAV() const
get bitset of TAV words
void setTAPWord(uint32_t word, uint32_t pos=0)
Set TAP word number 'pos'.
std::bitset< 32 > getBCIDBitSet() const
Accessor to obtain std::bitset containing the bunch-crossing.
std::string printPITWordAux() const
Get auxiliary PIT word as string in binary format.
std::string printTIP() const
Obtain TIP bitpattern string (binary format)
void setPITWordAux(uint32_t word)
Set auxiliary PIT word, which is the one containing the 12-bit BCID (bit.
std::string printTAP() const
Obtain TAP bitpattern string (binary format)
std::string printRandomTrig() const
Return string with random trigger in binary format.
std::bitset< 32 > getRandomTrigBitSet() const
Accessor to obtain random-trigger input bits.
std::string printTAV() const
Obtain TAV bitpattern string (binary format)
uint32_t getPrescaledClock() const
Prescaled-clock inputs as uint32_t.
const std::bitset< 512 > & getTAP() const
get bitset of TAP words
CTPdataformatVersion m_ctpVersion
void setTBP(const std::vector< uint32_t > &words)
Set TBP (Trigger Before Prescales) words.
uint32_t getRandomTrig() const
Random-trigger inputs as uint32_t.
std::bitset< 32 > m_pitAux
Contains BCID, random trigger and prescaled clock.
std::string printPrescaledClock() const
Return string with prescaled clock in binary format.
CTP_Decoder()
Helper class to decode the CTP data fragment.
void dumpData() const
Helper to dump data for debugging.
bool checkTrigger(unsigned int itemNo, unsigned int bcPos)
Test the LVL1 trigger result for a certain trigger item.
bool checkTriggerAfterPrescale(unsigned int itemNo, unsigned int bcPos)
Test the LVL1 trigger result after pre-scale factors are applied, before the final trigger decision,...
std::vector< unsigned int > getAllTriggers(unsigned int bcPos)
Function to obtain a vector with the numbers of the trigger items that fired for the current event.
void setRDO(const CTP_RDO *rdo)
Set RDO and fill internal variables from the data object.
const CTP_RDO * m_rdo
The RDO member.
std::vector< CTP_BC > m_BCs
Vector of BCs for the current event.
const CTP_BC & getBunchCrossing(unsigned int pos)
Get data of a single bunch-crossing.
std::vector< uint32_t > getTBPWords() const
std::vector< uint32_t > getTAPWords() const
uint32_t getNumberOfBunches() const
static constexpr unsigned int SIZEOF_WORDS
number of bits in one data word (32)
std::vector< uint32_t > getTIPWords() const
std::vector< uint32_t > getTAVWords() const
singleton-like access to IMessageSvc via open function and helper
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....
IMessageSvc * getMessageSvc(bool quiet=false)