ATLAS Offline Software
Loading...
Searching...
No Matches
HLT::Lvl1ResultAccessTool Class Reference

This tool is used to handle all LVL1 results in a coherent way, taking the LVL1 configuration into account to fill the raw bits with more meaningful data. More...

#include <Lvl1ResultAccessTool.h>

Inheritance diagram for HLT::Lvl1ResultAccessTool:
Collaboration diagram for HLT::Lvl1ResultAccessTool:

Public Member Functions

 Lvl1ResultAccessTool (const std::string &name, const std::string &type, const IInterface *parent)
 std Gaudi constructor
virtual StatusCode initialize () override
virtual std::vector< std::unique_ptr< LVL1CTP::Lvl1Item > > makeLvl1ItemConfig (const EventContext &context) const override
virtual bool isCalibrationEvent (const ROIB::RoIBResult &result) const override
 checks if we have calibration items fired in this event
virtual std::vector< const LVL1CTP::Lvl1Item * > createL1Items (const std::vector< std::unique_ptr< LVL1CTP::Lvl1Item > > &lvl1ItemConfig, const ROIB::RoIBResult &result, LVL1CTP::Lvl1Result const **lvl1ResultOut=nullptr) const override
 Extract LVL1 items from given RoIBResult.
virtual std::bitset< 3 > lvl1EMTauJetOverflow (const ROIB::RoIBResult &result) override
 Check if there was an overflow in the TOB transmission to CMX.

Private Attributes

LVL1::JEPRoIDecoder m_jepDecoder
LVL1::CPRoIDecoder m_cpDecoder
SG::ReadCondHandleKey< TrigConf::L1PrescalesSetm_l1PrescaleSetInputKey { this, "L1Prescales", "L1Prescales", "L1 prescales set"}
 access to L1Prescales
SG::WriteHandleKey< LVL1CTP::Lvl1Resultm_l1ResultKey { this, "L1Result", "L1Result", "L1 result"}

Detailed Description

This tool is used to handle all LVL1 results in a coherent way, taking the LVL1 configuration into account to fill the raw bits with more meaningful data.

This was used by the Lvl1Converter in the Run-1&2 HLT Steering. Now the only client is the trigger decision tool (class TrigDecisionTool) which makes all trigger information available to the end-users.

Author
Till Eifert Till..nosp@m.Eife.nosp@m.rt@ce.nosp@m.rn.c.nosp@m.h
Nicolas Berger Nicol.nosp@m.as.B.nosp@m.erger.nosp@m.@cer.nosp@m.n.ch

Definition at line 39 of file Lvl1ResultAccessTool.h.

Constructor & Destructor Documentation

◆ Lvl1ResultAccessTool()

HLT::Lvl1ResultAccessTool::Lvl1ResultAccessTool ( const std::string & name,
const std::string & type,
const IInterface * parent )

std Gaudi constructor

Definition at line 15 of file Lvl1ResultAccessTool.cxx.

16 :
17 base_class(name, type, parent)
18{
19}

Member Function Documentation

◆ createL1Items()

std::vector< const LVL1CTP::Lvl1Item * > HLT::Lvl1ResultAccessTool::createL1Items ( const std::vector< std::unique_ptr< LVL1CTP::Lvl1Item > > & lvl1ItemConfig,
const ROIB::RoIBResult & result,
LVL1CTP::Lvl1Result const ** lvl1ResultOut = nullptr ) const
overridevirtual

Extract LVL1 items from given RoIBResult.

Parameters
resultreference to RoIBResult object, holding all LVL1 RoIs and items
lvl1ResultOutIf non-null, create (in addition) a LVL1 container holding all Lvl1 results, and return through this argument.
Returns
vector holding pointers to all LVL1 items

Definition at line 100 of file Lvl1ResultAccessTool.cxx.

103{
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();
108
109 bool calib_flag = isCalibrationEvent(result);
110 ATH_MSG_DEBUG("Calibration event? " << calib_flag);
111
112 // loop over all configured items if no calibration, else only 3 last // Needs fixing
113 int ctpVersion = result.cTPResult().header().formatVersion() & 0xf ;
114 CTPdataformatVersion v(ctpVersion);
115
116 unsigned first_item = calib_flag ? v.getMaxTrigItems()-3 : 0; // last three items are calib items, only those should be activated
117
118 for ( unsigned i = first_item; i < lvl1ItemConfig.size(); i++ ) {
119 if ( !lvl1ItemConfig[ i ] ) continue; // empty slot
120
121 LVL1CTP::Lvl1Item* item = lvl1ItemConfig[ i ].get();
122 *item = LVL1CTP::Lvl1Item( item->name(), item->hashId(),
123 getBit(bitsBP, i),
124 getBit(bitsAP, i),
125 getBit(bitsAV, i),
126 item->prescaleFactor() );
127 items.push_back(item);
128 ATH_MSG_DEBUG("Set bits on "<< item->name() <<" PS="<< item->prescaleFactor() <<" BP=" <<getBit(bitsBP, i)<<" AP="<<getBit(bitsAP, i)<<" AV="<<getBit(bitsAV, i));
129 }
130
131 // Fill TBP, TAP in case we're creating the Lvl1Result
132 if (lvl1ResultOut) {
133 auto lvl1Result = std::make_unique<LVL1CTP::Lvl1Result>(true);
134
135 // 1.) TAV
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);
141 }
142
143 // 1.) TBP
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);
148 ATH_MSG_DEBUG( "TBP word #" << iWord << " is 0x" << std::hex
149 << std::setw( 8 ) << std::setfill( '0' ) << roIWord << std::dec);
150 }
151
152 // 2.) TAP
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);
157
158 ATH_MSG_DEBUG("TAP word #" << iWord << " is 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << roIWord << std::dec);
159
160 }
161 // make sure TBP, TAP, TAV all have 8 entries !
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();
166 ATH_CHECK(SG::makeHandle(m_l1ResultKey).record( std::move(lvl1Result)), {});
167 } // if (lvl1ResultOut)
168
169 return items;
170}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
static bool getBit(unsigned char field, unsigned num)
virtual bool isCalibrationEvent(const ROIB::RoIBResult &result) const override
checks if we have calibration items fired in this event
SG::WriteHandleKey< LVL1CTP::Lvl1Result > m_l1ResultKey
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
setEventNumber uint32_t

◆ initialize()

StatusCode HLT::Lvl1ResultAccessTool::initialize ( )
overridevirtual

Definition at line 22 of file Lvl1ResultAccessTool.cxx.

22 {
23
24 ATH_CHECK( m_l1PrescaleSetInputKey.initialize( ) );
25 ATH_CHECK( m_l1ResultKey.initialize( ) );
26
27 return StatusCode::SUCCESS;
28}
SG::ReadCondHandleKey< TrigConf::L1PrescalesSet > m_l1PrescaleSetInputKey
access to L1Prescales

◆ isCalibrationEvent()

bool HLT::Lvl1ResultAccessTool::isCalibrationEvent ( const ROIB::RoIBResult & result) const
overridevirtual

checks if we have calibration items fired in this event

Returns
true if calibration items are present in this event

return false; // in the RUN 2 menu there is currently no such restriction and all kinds of items are on these ctp IDs

Definition at line 71 of file Lvl1ResultAccessTool.cxx.

71 {
72
74 int ctpVersion = result.cTPResult().header().formatVersion() & 0xf ;
75 CTPdataformatVersion v(ctpVersion);
76 std::vector<ROIB::CTPRoI> ctpRoIVec(result.cTPResult().TAV());
77 // if ( ctpRoIVec.size() >= 8 && (ctpRoIVec[7].roIWord() & 0xE0000000) )
78 if ( ctpRoIVec.size()==v.getTAVwords() && ( ctpRoIVec[ctpRoIVec.size()-1].roIWord() & 0xE0000000 ) )
79 return true;
80 else
81 return false;
82}

◆ lvl1EMTauJetOverflow()

std::bitset< 3 > HLT::Lvl1ResultAccessTool::lvl1EMTauJetOverflow ( const ROIB::RoIBResult & result)
overridevirtual

Check if there was an overflow in the TOB transmission to CMX.

Parameters
resultreference to RoIBResul object
Returns
overflow bits for EM, Tau and Jet threshold

Definition at line 173 of file Lvl1ResultAccessTool.cxx.

174{
175 const int MAXEM = 5; // see ATR-12285
176 const int MAXTAU = 5;
177 const int MAXJET = 4;
178
179 std::map<std::pair<int,int>, int> em, tau, jet; // (crate,module) : count
180
181 // Count number of RoIs per crate/module
182 for (const ROIB::EMTauResult& res : result.eMTauResult()) {
183 for (const ROIB::EMTauRoI& roi : res.roIVec()) {
184 int c = m_cpDecoder.crate(roi.roIWord());
185 int m = m_cpDecoder.module(roi.roIWord());
186 int t = m_cpDecoder.roiType(roi.roIWord());
187
189 else if (t==LVL1::TrigT1CaloDefs::TauRoIWordType) ++tau[{c,m}];
190 }
191 }
192
193 for (const ROIB::JetEnergyResult& res : result.jetEnergyResult()) {
194 for (const ROIB::JetEnergyRoI& roi : res.roIVec()) {
195 int c = m_jepDecoder.crate(roi.roIWord());
196 int m = m_jepDecoder.module(roi.roIWord());
197 int t = m_jepDecoder.roiType(roi.roIWord());
198
200 }
201 }
202
203 // Check if there was an overflow
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;});
208
209 if (msgLvl(MSG::DEBUG)) {
210 msg() << "EM RoI multiplicities by crate,module: ";
211 for (const auto& i : em) msg() << "(" << i.first.first << "," << i.first.second << "):" << i.second << " ";
212
213 msg() << endmsg << "Tau RoI multiplicities by crate,module: ";
214 for (const auto& i : tau) msg() << "(" << i.first.first << "," << i.first.second << "):" << i.second << " ";
215
216 msg() << endmsg << "Jet RoI multiplicities by crate,module: ";
217 for (const auto& i : jet) msg() << "(" << i.first.first << "," << i.first.second << "):" << i.second << " ";
218 msg() << endmsg;
219 }
220
221 return overflow;
222}
#define endmsg
std::pair< std::vector< unsigned int >, bool > res
LVL1::JEPRoIDecoder m_jepDecoder
MsgStream & msg
Definition testRead.cxx:32

◆ makeLvl1ItemConfig()

std::vector< std::unique_ptr< LVL1CTP::Lvl1Item > > HLT::Lvl1ResultAccessTool::makeLvl1ItemConfig ( const EventContext & context) const
overridevirtual

Definition at line 36 of file Lvl1ResultAccessTool.cxx.

37{
38 // vector holding all configured LVL1 items, default initializes to empty unique_ptr
39 constexpr size_t numberOfCTPItems = 512; // this is fixed
40 std::vector<std::unique_ptr<LVL1CTP::Lvl1Item>> lvl1ItemConfig(numberOfCTPItems);
41
42 const TrigConf::L1Menu *l1menu = nullptr;
43 if( detStore()->retrieve(l1menu).isFailure() ) {
44 ATH_MSG_ERROR("No L1Menu found");
45 } else {
46 SG::ReadCondHandle<TrigConf::L1PrescalesSet> l1psRH(m_l1PrescaleSetInputKey, context);
47 if( !l1psRH.isValid() ) {
48 ATH_MSG_ERROR("No valid L1PrescalesSet handle");
49 } else {
50 const TrigConf::L1PrescalesSet* l1PrescaleSet{*l1psRH};
51 if(l1PrescaleSet == nullptr) {
52 ATH_MSG_ERROR( "No L1PrescalesSet available");
53 } else {
54 for(auto & item : *l1menu) {
55 double prescale = l1PrescaleSet->getPrescaleFromCut(l1PrescaleSet->prescale(item.name()).cut);
56 lvl1ItemConfig[item.ctpId()] = std::make_unique<LVL1CTP::Lvl1Item>( item.name(),
58 0, 0, 0, prescale);
59 }
60 }
61 }
62 }
63 return lvl1ItemConfig;
64}
#define ATH_MSG_ERROR(x)
static HLTHash string2hash(const std::string &, const std::string &category="TE")
hash function translating TE names into identifiers
const L1Prescale & prescale(const std::string &itemName) const
double getPrescaleFromCut(uint32_t cut) const
prescale = 2*24/(cut+1.)
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

Member Data Documentation

◆ m_cpDecoder

LVL1::CPRoIDecoder HLT::Lvl1ResultAccessTool::m_cpDecoder
private

Definition at line 81 of file Lvl1ResultAccessTool.h.

◆ m_jepDecoder

LVL1::JEPRoIDecoder HLT::Lvl1ResultAccessTool::m_jepDecoder
private

Definition at line 80 of file Lvl1ResultAccessTool.h.

◆ m_l1PrescaleSetInputKey

SG::ReadCondHandleKey<TrigConf::L1PrescalesSet> HLT::Lvl1ResultAccessTool::m_l1PrescaleSetInputKey { this, "L1Prescales", "L1Prescales", "L1 prescales set"}
private

access to L1Prescales

Definition at line 84 of file Lvl1ResultAccessTool.h.

84{ this, "L1Prescales", "L1Prescales", "L1 prescales set"};

◆ m_l1ResultKey

SG::WriteHandleKey<LVL1CTP::Lvl1Result> HLT::Lvl1ResultAccessTool::m_l1ResultKey { this, "L1Result", "L1Result", "L1 result"}
private

Definition at line 86 of file Lvl1ResultAccessTool.h.

86{ this, "L1Result", "L1Result", "L1 result"};

The documentation for this class was generated from the following files: