8 #include "CTPfragment/CTPdataformatVersion.h"
16 const IInterface*
parent) :
24 ATH_CHECK( m_l1PrescaleSetInputKey.initialize( ) );
27 return StatusCode::SUCCESS;
35 std::vector< std::unique_ptr<LVL1CTP::Lvl1Item> >
39 constexpr
size_t numberOfCTPItems = 512;
40 std::vector<std::unique_ptr<LVL1CTP::Lvl1Item>> lvl1ItemConfig(numberOfCTPItems);
51 if(l1PrescaleSet ==
nullptr) {
55 double prescale = l1PrescaleSet->getPrescaleFromCut(l1PrescaleSet->prescale(
item.name()).cut);
56 lvl1ItemConfig[
item.ctpId()] = std::make_unique<LVL1CTP::Lvl1Item>(
item.name(),
63 return lvl1ItemConfig;
74 int ctpVersion =
result.cTPResult().header().formatVersion() & 0xf ;
75 CTPdataformatVersion
v(ctpVersion);
76 std::vector<ROIB::CTPRoI> ctpRoIVec(
result.cTPResult().TAV());
78 if ( ctpRoIVec.size()==
v.getTAVwords() && ( ctpRoIVec[ctpRoIVec.size()-1].roIWord() & 0xE0000000 ) )
85 bool getBit(
const std::vector<ROIB::CTPRoI>&
words,
unsigned position) {
86 unsigned w = position/32;
87 unsigned b = position%32;
90 return (roIWord >>
b) & 0x1;
99 std::vector< const LVL1CTP::Lvl1Item* >
104 std::vector< const LVL1CTP::Lvl1Item* >
items;
105 std::vector<ROIB::CTPRoI> bitsBP =
result.cTPResult().TBP();
106 std::vector<ROIB::CTPRoI> bitsAP =
result.cTPResult().TAP();
107 std::vector<ROIB::CTPRoI> bitsAV =
result.cTPResult().TAV();
109 bool calib_flag = isCalibrationEvent(
result);
113 int ctpVersion =
result.cTPResult().header().formatVersion() & 0xf ;
114 CTPdataformatVersion
v(ctpVersion);
116 unsigned first_item = calib_flag ?
v.getMaxTrigItems()-3 : 0;
118 for (
unsigned i = first_item;
i < lvl1ItemConfig.size();
i++ ) {
119 if ( !lvl1ItemConfig[
i ] )
continue;
126 item->prescaleFactor() );
128 ATH_MSG_DEBUG(
"Set bits on "<<
item->name() <<
" PS="<<
item->prescaleFactor() <<
" BP=" <<getBit(bitsBP,
i)<<
" AP="<<getBit(bitsAP,
i)<<
" AV="<<getBit(bitsAV,
i));
133 auto lvl1Result = std::make_unique<LVL1CTP::Lvl1Result>(
true);
136 const std::vector<ROIB::CTPRoI> ctpRoIVecAV =
result.cTPResult().TAV();
137 for (
unsigned int iWord = 0; iWord < ctpRoIVecAV.size(); ++iWord) {
138 uint32_t roIWord = ctpRoIVecAV[iWord].roIWord();
139 lvl1Result->itemsAfterVeto().push_back(roIWord);
140 ATH_MSG_DEBUG(
"TAV word #" << iWord <<
" is 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << roIWord << std::dec);
144 const std::vector<ROIB::CTPRoI> ctpRoIVecBP =
result.cTPResult().TBP();
145 for (
unsigned int iWord=0; iWord < ctpRoIVecBP.size(); ++iWord) {
146 uint32_t roIWord = ctpRoIVecBP[iWord].roIWord();
147 lvl1Result->itemsBeforePrescale().push_back(roIWord);
149 << std::setw( 8 ) << std::setfill(
'0' ) << roIWord << std::dec);
153 const std::vector<ROIB::CTPRoI> ctpRoIVecAP =
result.cTPResult().TAP();
154 for (
unsigned int iWord=0; iWord < ctpRoIVecAP.size(); ++iWord) {
155 uint32_t roIWord = ctpRoIVecAP[iWord].roIWord();
156 lvl1Result->itemsAfterPrescale().push_back(roIWord);
158 ATH_MSG_DEBUG(
"TAP word #" << iWord <<
" is 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << roIWord << std::dec);
162 if (lvl1Result->itemsBeforePrescale().size() < 8) lvl1Result->itemsBeforePrescale().resize(8, 0);
163 if (lvl1Result->itemsAfterPrescale().size() < 8) lvl1Result->itemsAfterPrescale().resize(8, 0);
164 if (lvl1Result->itemsAfterVeto().size() < 8) lvl1Result->itemsAfterVeto().resize(8, 0);
165 *lvl1ResultOut = lvl1Result.get();
176 const int MAXTAU = 5;
177 const int MAXJET = 4;
179 std::map<std::pair<int,int>,
int> em, tau,
jet;
184 int c = m_cpDecoder.crate(roi.roIWord());
185 int m = m_cpDecoder.module(roi.roIWord());
186 int t = m_cpDecoder.roiType(roi.roIWord());
195 int c = m_jepDecoder.crate(roi.roIWord());
196 int m = m_jepDecoder.module(roi.roIWord());
197 int t = m_jepDecoder.roiType(roi.roIWord());
204 std::bitset<3> overflow;
205 overflow[0] = std::count_if(em.begin(), em.end(), [](
const decltype(em)::
value_type&
i){
return i.second>MAXEM;});
206 overflow[1] = std::count_if(tau.begin(), tau.end(), [](
const decltype(tau)::
value_type&
i){
return i.second>MAXTAU;});
207 overflow[2] = std::count_if(
jet.begin(),
jet.end(), [](
const decltype(
jet)::
value_type&
i){
return i.second>MAXJET;});
210 msg() <<
"EM RoI multiplicities by crate,module: ";
211 for (
const auto&
i : em)
msg() <<
"(" <<
i.first.first <<
"," <<
i.first.second <<
"):" <<
i.second <<
" ";
213 msg() <<
endmsg <<
"Tau RoI multiplicities by crate,module: ";
214 for (
const auto&
i : tau)
msg() <<
"(" <<
i.first.first <<
"," <<
i.first.second <<
"):" <<
i.second <<
" ";
216 msg() <<
endmsg <<
"Jet RoI multiplicities by crate,module: ";
217 for (
const auto&
i :
jet)
msg() <<
"(" <<
i.first.first <<
"," <<
i.first.second <<
"):" <<
i.second <<
" ";