ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
HLT::Lvl1ResultAccessTool Class Reference

#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 More...
 
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 More...
 
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. More...
 
virtual std::bitset< 3 > lvl1EMTauJetOverflow (const ROIB::RoIBResult &result) override
 Check if there was an overflow in the TOB transmission to CMX. More...
 

Private Attributes

LVL1::JEPRoIDecoder m_jepDecoder
 
LVL1::CPRoIDecoder m_cpDecoder
 
SG::ReadCondHandleKey< TrigConf::L1PrescalesSetm_l1PrescaleSetInputKey { this, "L1Prescales", "L1Prescales", "L1 prescales set"}
 access to L1Prescales More...
 
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 }

◆ initialize()

StatusCode HLT::Lvl1ResultAccessTool::initialize ( )
overridevirtual

Definition at line 22 of file Lvl1ResultAccessTool.cxx.

22  {
23 
26 
27  return StatusCode::SUCCESS;
28 }

◆ 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 }

◆ 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 {
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 }

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.

◆ m_l1ResultKey

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

Definition at line 86 of file Lvl1ResultAccessTool.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LVL1::CPRoIDecoder::crate
unsigned int crate(const unsigned int roiWord) const
Decode crate number from RoI word.
Definition: CPRoIDecoder.cxx:104
get_generator_info.result
result
Definition: get_generator_info.py:21
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
LVL1::JEPRoIDecoder::crate
unsigned int crate(const unsigned int word) const
Return hardware coordinates.
Definition: JEPRoIDecoder.cxx:79
ROIB::EMTauResult
Definition: EMTauResult.h:25
LVL1::TrigT1CaloDefs::TauRoIWordType
@ TauRoIWordType
Definition: TrigT1CaloDefs.h:173
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
ROIB::JetEnergyRoI
Definition: JetEnergyRoI.h:20
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
HLT::Lvl1ResultAccessTool::isCalibrationEvent
virtual bool isCalibrationEvent(const ROIB::RoIBResult &result) const override
checks if we have calibration items fired in this event
Definition: Lvl1ResultAccessTool.cxx:71
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ROIB::JetEnergyResult
Definition: JetEnergyResult.h:24
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
HLT::Lvl1ResultAccessTool::m_l1ResultKey
SG::WriteHandleKey< LVL1CTP::Lvl1Result > m_l1ResultKey
Definition: Lvl1ResultAccessTool.h:86
LVL1CTP::Lvl1Item
Definition: Lvl1Item.h:37
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigConf::HLTUtils::string2hash
static HLTHash string2hash(const std::string &, const std::string &category="TE")
hash function translating TE names into identifiers
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TrigConf::L1PrescalesSet
L1 menu configuration.
Definition: L1PrescalesSet.h:19
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LVL1::JEPRoIDecoder::module
unsigned int module(const unsigned int word) const
Extract module number from Jet RoI word.
Definition: JEPRoIDecoder.cxx:84
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
item
Definition: ItemListSvc.h:43
python.PyAthena.v
v
Definition: PyAthena.py:157
ROIB::EMTauRoI
Definition: EMTauRoI.h:20
LVL1::TrigT1CaloDefs::JetRoIWordType
@ JetRoIWordType
Definition: TrigT1CaloDefs.h:167
HLT::Lvl1ResultAccessTool::m_l1PrescaleSetInputKey
SG::ReadCondHandleKey< TrigConf::L1PrescalesSet > m_l1PrescaleSetInputKey
access to L1Prescales
Definition: Lvl1ResultAccessTool.h:84
LVL1::CPRoIDecoder::module
unsigned int module(const unsigned int roiWord) const
Decode module number from RoI word.
Definition: CPRoIDecoder.cxx:111
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
LVL1::TrigT1CaloDefs::EMRoIWordType
@ EMRoIWordType
Definition: TrigT1CaloDefs.h:172
value_type
Definition: EDM_MasterSearch.h:11
HLT::Lvl1ResultAccessTool::m_jepDecoder
LVL1::JEPRoIDecoder m_jepDecoder
Definition: Lvl1ResultAccessTool.h:80
HLT::Lvl1ResultAccessTool::m_cpDecoder
LVL1::CPRoIDecoder m_cpDecoder
Definition: Lvl1ResultAccessTool.h:81
python.compressB64.c
def c
Definition: compressB64.py:93
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
LVL1::JEPRoIDecoder::roiType
TrigT1CaloDefs::RoIType roiType(unsigned int word) const
Override base method - allows us to handle both Run 1 & Run 2 data for JEP (up to a point)
Definition: JEPRoIDecoder.cxx:33
LVL1::CPRoIDecoder::roiType
TrigT1CaloDefs::RoIType roiType(unsigned int word) const
CP-RoI specific, but can distinguish Run 1/Run 2.
Definition: CPRoIDecoder.cxx:31