ATLAS Offline Software
Loading...
Searching...
No Matches
LVL1::L1CPCMXTools Class Reference

This is a tool to reconstruct the L1 CMX-CP TOBs and hits from RoIs. More...

#include <L1CPCMXTools.h>

Inheritance diagram for LVL1::L1CPCMXTools:
Collaboration diagram for LVL1::L1CPCMXTools:

Public Member Functions

 L1CPCMXTools (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor.
virtual StatusCode initialize ()
 standard Athena-Algorithm method
virtual void formCMXCPTob (const xAOD::CPMTobRoIContainer *cpmRoiVec, xAOD::CMXCPTobContainer *cmxTobVec) const
 form CMX-CP TOBs from RoIs - single slice
virtual void formCMXCPTob (const std::vector< const xAOD::CPMTobRoIContainer * > &cpmRoiColls, xAOD::CMXCPTobContainer *cmxTobVec, uint8_t peak) const
 form CMX-CP TOBs from RoIs - multiple slices
virtual void formCMXCPHits (const TrigConf::L1Menu *l1menu, const xAOD::CMXCPTobContainer *cmxTobVec, xAOD::CMXCPHitsContainer *cmxHitsVec) const
 form complete CMX-CP hits from CMX-CP TOBs
virtual void formCMXCPHitsCrate (const TrigConf::L1Menu *l1menu, const xAOD::CMXCPTobContainer *cmxTobVec, xAOD::CMXCPHitsContainer *cmxHitsCrate) const
 form partial CMX-CP hits (crate) from CMX-CP TOBs
virtual void formCMXCPHitsSystem (const xAOD::CMXCPHitsContainer *cmxHitsCrate, xAOD::CMXCPHitsContainer *cmxHitsSys) const
 form partial CMX-CP hits (system) from crate CMX-CP hits
virtual void formCMXCPHitsTopo (const xAOD::CMXCPTobContainer *cmxTobVec, xAOD::CMXCPHitsContainer *cmxHitsTopo) const
 form partial CMX-CP hits (topo) from CMX-CP TOBs
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef std::vector< uint32_t > HitsVector
typedef std::vector< uint32_t > ErrorVector
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

std::pair< uint32_t, uint32_t > roiWord (const EmTauROI *roi) const
 Temporary for testing until CPAlgorithm and EmTauROI are updated.
int isolationEm (unsigned int clusterEnergy, unsigned int emIsol, unsigned int hadIsol, unsigned int hadVeto) const
int isolationTau (unsigned int clusterEnergy, unsigned int emIsol, unsigned int hadIsol) const
void unpackEmIsol (int energy, int isol, unsigned int &emIsol, unsigned int &hadIsol, unsigned int &hadVeto) const
void unpackTauIsol (int energy, int isol, unsigned int &emIsol, unsigned int &hadIsol) const
void getHits (const TrigConf::L1Menu *l1menu, const xAOD::CMXCPTob *tob, HitsVector &hits0, HitsVector &hits1) const
void addOverflow (ErrorVector &hitErr, const ErrorVector &tobErr) const
void addCMXCPHits (HitsVector &vec1, const HitsVector &vec2) const
 Add hits from second vector to first.
unsigned int addHits (unsigned int hitMult, unsigned int hitVec, int multBits, int vecBits) const
 Increment CPM/CMX hit word.
void mergeCMXCPHits (xAOD::CMXCPHitsContainer *cmxHitsVec1, xAOD::CMXCPHitsContainer *cmxHitsVec2) const
 Merge CMX-CP hits vectors.
void saveCMXCPHits (xAOD::CMXCPHitsContainer *cmxHitsVec, const HitsVector &hits0, const HitsVector &hits1, const ErrorVector &err0, const ErrorVector &err1, uint8_t crate, uint8_t cmx, uint8_t source, uint8_t peak) const
 Save non-zero CMX-CP hits.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

int m_crates
 Number of CP crates.
int m_modules
 Number of CPMs per crate.
int m_maxTobs
 Maximum number of TOBs per CPM.
int m_sysCrate
 System crate.
bool m_debug
 Debug printout flag.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

This is a tool to reconstruct the L1 CMX-CP TOBs and hits from RoIs.

Used for offline monitoring and trigger reconstruction.

Useage: L1CPCMXTools->formCMXCPTob() // form CMX-CP TOBs from RoIs L1CPCMXTools->formCMXCPHits() // form CMX-CP hits from TOBs

Author
Peter Faulkner

Definition at line 39 of file L1CPCMXTools.h.

Member Typedef Documentation

◆ ErrorVector

typedef std::vector<uint32_t> LVL1::L1CPCMXTools::ErrorVector
private

Definition at line 71 of file L1CPCMXTools.h.

◆ HitsVector

typedef std::vector<uint32_t> LVL1::L1CPCMXTools::HitsVector
private

Definition at line 70 of file L1CPCMXTools.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ L1CPCMXTools()

LVL1::L1CPCMXTools::L1CPCMXTools ( const std::string & type,
const std::string & name,
const IInterface * parent )

Constructor.

Definition at line 33 of file L1CPCMXTools.cxx.

35 : AthAlgTool(type, name, parent),
36 m_crates(4),
37 m_modules(14), m_maxTobs(5), m_sysCrate(3), m_debug(false) {
38 declareInterface<IL1CPCMXTools>(this);
39
40}
AthAlgTool()
Default constructor:
int m_maxTobs
Maximum number of TOBs per CPM.
int m_crates
Number of CP crates.
int m_modules
Number of CPMs per crate.
int m_sysCrate
System crate.
bool m_debug
Debug printout flag.

Member Function Documentation

◆ addCMXCPHits()

void LVL1::L1CPCMXTools::addCMXCPHits ( HitsVector & vec1,
const HitsVector & vec2 ) const
private

Add hits from second vector to first.

Definition at line 494 of file L1CPCMXTools.cxx.

495 {
496 int size1 = vec1.size();
497 int size2 = vec2.size();
498 if (size1 < size2)
499 vec1.resize(size2);
500 HitsVector::iterator pos1 = vec1.begin();
501 HitsVector::iterator pose1 = vec1.end();
502 HitsVector::const_iterator pos2 = vec2.begin();
503 HitsVector::const_iterator pose2 = vec2.end();
504 for (; pos1 != pose1 && pos2 != pose2; ++pos1, ++pos2) {
505 *pos1 = addHits(*pos1, *pos2, 24, 24);
506 }
507}
unsigned int addHits(unsigned int hitMult, unsigned int hitVec, int multBits, int vecBits) const
Increment CPM/CMX hit word.
std::vector< D3PDTest::MyVec2 > vec2

◆ addHits()

unsigned int LVL1::L1CPCMXTools::addHits ( unsigned int hitMult,
unsigned int hitVec,
int multBits,
int vecBits ) const
private

Increment CPM/CMX hit word.

Definition at line 511 of file L1CPCMXTools.cxx.

512 {
513 if (m_debug)
514 msg() << MSG::DEBUG << "addHits: Original hitMult = " << std::hex << hitMult
515 << ". Add hitWord = " << hitVec << std::dec << endmsg;
516
517 // Results transmitted in 2 words, each reporting half of the CP thresholds
518 int nthresh = TrigT1CaloDefs::numOfCPThresholds / 2;
519
520 int nbitsOut = multBits / nthresh;
521 int nbitsIn = vecBits / nthresh;
522
523 if (m_debug)
524 msg() << MSG::DEBUG << " Bits per threshold = " << nbitsOut << endmsg;
525
526 int max = (1 << nbitsOut) - 1;
527 unsigned int multMask = max;
528 unsigned int hitMask = (1 << nbitsIn) - 1;
529 unsigned int shift = 0;
530
531 unsigned int hits = 0;
532
533 for (int i = 0; i < nthresh; i++) {
534 int mult = (hitMult & multMask) + (hitVec & hitMask);
535 mult = ((mult <= max) ? mult : max);
536 hits += (mult << shift);
537
538 hitMult >>= nbitsOut;
539 hitVec >>= nbitsIn;
540 shift += nbitsOut;
541 }
542
543 if (m_debug)
544 msg() << MSG::DEBUG << "addHits returning hitMult = " << std::hex << hits
545 << std::dec << endmsg;
546
547 return hits;
548}
#define endmsg
#define max(a, b)
Definition cfImp.cxx:41
MsgStream & msg() const
static const unsigned int numOfCPThresholds

◆ addOverflow()

void LVL1::L1CPCMXTools::addOverflow ( ErrorVector & hitErr,
const ErrorVector & tobErr ) const
private

Definition at line 361 of file L1CPCMXTools.cxx.

362 {
363 const int timeslices = tobErr.size();
364 hitErr.resize(timeslices);
365 for (int slice = 0; slice < timeslices; ++slice) {
366 int error = tobErr[slice];
367 if (error) {
368 LVL1::DataError err(error);
369 int overflow = err.get(LVL1::DataError::Overflow);
370 LVL1::DataError err2;
371 err2.set(LVL1::DataError::Overflow, overflow);
372 hitErr[slice] |= err2.error();
373 }
374 }
375}
int error() const
Return the full error word.
Definition DataError.h:78
void set(ErrorBit bit, int value=1)
Set an error bit or data.
Definition DataError.cxx:28

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ formCMXCPHits()

void LVL1::L1CPCMXTools::formCMXCPHits ( const TrigConf::L1Menu * l1menu,
const xAOD::CMXCPTobContainer * cmxTobVec,
xAOD::CMXCPHitsContainer * cmxHitsVec ) const
virtual

form complete CMX-CP hits from CMX-CP TOBs

Implements LVL1::IL1CPCMXTools.

Definition at line 221 of file L1CPCMXTools.cxx.

223 {
226 // @@vkousk
227 // temporarily comment out cmxHitsTopo, see Jira ticket: ATLLONECAL-13
228 // xAOD::CMXCPHitsContainer* cmxHitsTopo = new xAOD::CMXCPHitsContainer;
229 formCMXCPHitsCrate(l1menu, cmxTobVec, cmxHitsCrate);
230 formCMXCPHitsSystem(cmxHitsCrate, cmxHitsSys);
231 // formCMXCPHitsTopo(cmxTobVec, cmxHitsTopo);
232 mergeCMXCPHits(cmxHitsVec, cmxHitsCrate);
233 mergeCMXCPHits(cmxHitsVec, cmxHitsSys);
234 // mergeCMXCPHits(cmxHitsVec, cmxHitsTopo);
235 delete cmxHitsCrate;
236 delete cmxHitsSys;
237 // delete cmxHitsTopo;
238}
virtual void formCMXCPHitsCrate(const TrigConf::L1Menu *l1menu, const xAOD::CMXCPTobContainer *cmxTobVec, xAOD::CMXCPHitsContainer *cmxHitsCrate) const
form partial CMX-CP hits (crate) from CMX-CP TOBs
virtual void formCMXCPHitsSystem(const xAOD::CMXCPHitsContainer *cmxHitsCrate, xAOD::CMXCPHitsContainer *cmxHitsSys) const
form partial CMX-CP hits (system) from crate CMX-CP hits
void mergeCMXCPHits(xAOD::CMXCPHitsContainer *cmxHitsVec1, xAOD::CMXCPHitsContainer *cmxHitsVec2) const
Merge CMX-CP hits vectors.
CMXCPHitsContainer_v1 CMXCPHitsContainer
Define the latest version of the CMXCPHits class.

◆ formCMXCPHitsCrate()

void LVL1::L1CPCMXTools::formCMXCPHitsCrate ( const TrigConf::L1Menu * l1menu,
const xAOD::CMXCPTobContainer * cmxTobVec,
xAOD::CMXCPHitsContainer * cmxHitsCrate ) const
virtual

form partial CMX-CP hits (crate) from CMX-CP TOBs

Implements LVL1::IL1CPCMXTools.

Definition at line 242 of file L1CPCMXTools.cxx.

245 {
246 uint8_t peakm = 0;
247 std::vector<HitsVector> hitVec(4 * m_crates);
248 std::vector<ErrorVector> errVec(4 *
249 m_crates); // Need overflow for neutral format
250 HitsVector hit0;
251 HitsVector hit1;
255 for (; pos != pose; ++pos) {
256 const xAOD::CMXCPTob *tob = *pos;
257 uint8_t crate = tob->crate();
258 uint8_t cmx = tob->cmx();
259 const int index = (crate * 2 + cmx) * 2;
260 const std::vector<uint32_t> &error(tob->errorVec());
261 hit0.clear();
262 hit1.clear();
263 getHits(l1menu, tob, hit0, hit1);
264
265 addCMXCPHits(hitVec[index], hit0);
266 addCMXCPHits(hitVec[index + 1], hit1);
267 addOverflow(errVec[index], error);
268 addOverflow(errVec[index + 1], error);
269 uint8_t peak = tob->peak();
270 if (peak > peakm)
271 peakm = peak;
272 }
273 // Save non-zero crate totals
274 for (uint8_t crate = 0; crate < m_crates; ++crate) {
275 for (uint8_t cmx = 0; cmx < 2; ++cmx) {
276 const int index = (crate * 2 + cmx) * 2;
277 saveCMXCPHits(cmxHitsCrate, hitVec[index], hitVec[index + 1],
278 errVec[index], errVec[index + 1], crate, cmx,
280 if (crate != m_sysCrate) { // REMOTE totals
281 uint8_t source = crate;
282 saveCMXCPHits(cmxHitsCrate, hitVec[index], hitVec[index + 1],
283 errVec[index], errVec[index + 1], m_sysCrate, cmx, source,
284 peakm);
285 }
286 }
287 }
288}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
std::vector< uint32_t > HitsVector
void addOverflow(ErrorVector &hitErr, const ErrorVector &tobErr) const
void addCMXCPHits(HitsVector &vec1, const HitsVector &vec2) const
Add hits from second vector to first.
void getHits(const TrigConf::L1Menu *l1menu, const xAOD::CMXCPTob *tob, HitsVector &hits0, HitsVector &hits1) const
void saveCMXCPHits(xAOD::CMXCPHitsContainer *cmxHitsVec, const HitsVector &hits0, const HitsVector &hits1, const ErrorVector &err0, const ErrorVector &err1, uint8_t crate, uint8_t cmx, uint8_t source, uint8_t peak) const
Save non-zero CMX-CP hits.
uint8_t cmx() const
get cmx
uint8_t crate() const
get crate
const std::vector< uint32_t > & errorVec() const
get errorVec
uint8_t peak() const
get peak
str index
Definition DeMoScan.py:362
CMXCPTob_v1 CMXCPTob
Define the latest version of the CMXCPTob class.

◆ formCMXCPHitsSystem()

void LVL1::L1CPCMXTools::formCMXCPHitsSystem ( const xAOD::CMXCPHitsContainer * cmxHitsCrate,
xAOD::CMXCPHitsContainer * cmxHitsSys ) const
virtual

form partial CMX-CP hits (system) from crate CMX-CP hits

Implements LVL1::IL1CPCMXTools.

Definition at line 379 of file L1CPCMXTools.cxx.

381 {
382 uint8_t peakm = 0;
383 std::vector<HitsVector> systemHit0(2);
384 std::vector<HitsVector> systemHit1(2);
385 std::vector<ErrorVector> systemErr0(2);
386 std::vector<ErrorVector> systemErr1(2);
389 for (; pos != pose; ++pos) {
390 const xAOD::CMXCPHits *hits = *pos;
391 if (hits->crate() != m_sysCrate)
392 continue;
393 uint8_t source = hits->sourceComponent();
394 if (source != xAOD::CMXCPHits::LOCAL &&
395 source != xAOD::CMXCPHits::REMOTE_0 &&
396 source != xAOD::CMXCPHits::REMOTE_1 &&
398 continue;
399 const uint8_t peak = hits->peak();
400 if (peak > peakm)
401 peakm = peak;
402 HitsVector hits0(hits->hitsVec0());
403 HitsVector hits1(hits->hitsVec1());
404 ErrorVector err0(hits->errorVec0());
405 ErrorVector err1(hits->errorVec1());
406 uint8_t cmx = hits->cmx();
407 addCMXCPHits(systemHit0[cmx], hits0);
408 addCMXCPHits(systemHit1[cmx], hits1);
409 addOverflow(systemErr0[cmx], err0);
410 addOverflow(systemErr1[cmx], err1);
411 }
412 // Save non-zero system totals
413 for (uint8_t cmx = 0; cmx < 2; ++cmx) {
414 saveCMXCPHits(cmxHitsSys, systemHit0[cmx], systemHit1[cmx], systemErr0[cmx],
415 systemErr1[cmx], m_sysCrate, cmx, xAOD::CMXCPHits::TOTAL,
416 peakm);
417 }
418}
std::vector< uint32_t > ErrorVector
CMXCPHits_v1 CMXCPHits
Define the latest version of the CMMCPHits class.

◆ formCMXCPHitsTopo()

void LVL1::L1CPCMXTools::formCMXCPHitsTopo ( const xAOD::CMXCPTobContainer * cmxTobVec,
xAOD::CMXCPHitsContainer * cmxHitsTopo ) const
virtual

form partial CMX-CP hits (topo) from CMX-CP TOBs

Implements LVL1::IL1CPCMXTools.

Definition at line 423 of file L1CPCMXTools.cxx.

425 {
426 uint8_t peakm = 0;
427 int timeslices = 0;
428 std::vector<HitsVector> hitVec(8 * m_crates);
431 for (; pos != pose; ++pos) {
432 const xAOD::CMXCPTob *tob = *pos;
433 uint8_t crate = tob->crate();
434 uint8_t cmx = tob->cmx();
435 const uint8_t cpm = tob->cpm();
436 if (cpm<1) continue;
437 //
438 const uint8_t chip = tob->chip() >> 1;
439 const uint8_t loc = ((tob->chip() & 0x1) << 2) | tob->location();
440 const int index = (crate * 2 + cmx) * 4;
441 const std::vector<uint8_t> &energy(tob->energyVec());
442 const std::vector<uint8_t> &isolation(tob->isolationVec());
443 const std::vector<uint32_t> &error(tob->errorVec());
444 timeslices = energy.size();
445 HitsVector &checksum(hitVec[index]);
446 HitsVector &map(hitVec[index + 1]);
447 HitsVector &countsLow(hitVec[index + 2]);
448 HitsVector &countsHigh(hitVec[index + 3]);
449 checksum.resize(timeslices);
450 map.resize(timeslices);
451 countsLow.resize(timeslices);
452 countsHigh.resize(timeslices);
453 for (int slice = 0; slice < timeslices; ++slice) {
454 if (energy[slice] == 0)
455 continue;
456 // checksum
457 LVL1::DataError err(error[slice]);
458 int overflow = err.get(LVL1::DataError::Overflow);
459 checksum[slice] +=
460 cpm + chip + loc + energy[slice] + isolation[slice] + overflow;
461 checksum[slice] &= 0xff;
462 // occupancy map
463 map[slice] |= (1 << (cpm - 1));
464 // occupancy counts
465 if (cpm <= 7) {
466 countsLow[slice] += (1 << (3 * (cpm - 1))); // can't saturate
467 } else {
468 countsHigh[slice] += (1 << (3 * (cpm - 8)));
469 }
470 }
471 uint8_t peak = tob->peak();
472 if (peak > peakm)
473 peakm = peak;
474 }
475 // Save non-zero crate totals
476 HitsVector dummy(timeslices);
477 std::vector<uint32_t> dummyE(timeslices);
478 for (uint8_t crate = 0; crate < m_crates; ++crate) {
479 for (uint8_t cmx = 0; cmx < 2; ++cmx) {
480 const int index = (crate * 2 + cmx) * 4;
481 saveCMXCPHits(cmxHitsTopo, hitVec[index], dummy, dummyE, dummyE, crate,
483 saveCMXCPHits(cmxHitsTopo, hitVec[index + 1], dummy, dummyE, dummyE,
484 crate, cmx, xAOD::CMXCPHits::TOPO_OCCUPANCY_MAP, peakm);
485 saveCMXCPHits(cmxHitsTopo, hitVec[index + 2], hitVec[index + 3], dummyE,
486 dummyE, crate, cmx, xAOD::CMXCPHits::TOPO_OCCUPANCY_COUNTS,
487 peakm);
488 }
489 }
490}
uint8_t cpm() const
get cpm
const std::vector< uint8_t > & energyVec() const
get energyVec
const std::vector< uint8_t > & isolationVec() const
get isolationVec
uint8_t chip() const
get chip
uint8_t location() const
get location

◆ formCMXCPTob() [1/2]

void LVL1::L1CPCMXTools::formCMXCPTob ( const std::vector< const xAOD::CPMTobRoIContainer * > & cpmRoiColls,
xAOD::CMXCPTobContainer * cmxTobVec,
uint8_t peak ) const
virtual

form CMX-CP TOBs from RoIs - multiple slices

Implements LVL1::IL1CPCMXTools.

Definition at line 133 of file L1CPCMXTools.cxx.

135 {
136 std::map<uint32_t, const xAOD::CPMTobRoI *> cpmRoiMap;
137 std::map<int, xAOD::CMXCPTob *> cmxTobMap;
139 int timeslices = cpmRoiColls.size();
140 for (int slice = 0; slice < timeslices; ++slice) {
141 const xAOD::CPMTobRoIContainer *cpmRoiVec = cpmRoiColls[slice];
142 cpmRoiMap.clear();
143 std::vector<unsigned int> presenceMaps(2 * m_crates * m_modules);
144 std::vector<int> tobCount(2 * m_crates * m_modules);
147 for (; it != itE; ++it) { // get sorted list
148 const xAOD::CPMTobRoI *roi = *it;
149 const int type = roi->type();
150 const int crate = roi->crate();
151 const int cpm = roi->cpm();
152 const int index = ((type * m_crates) + crate) * m_modules + cpm - 1;
153 const int presenceBit =
154 (roi->chip() << 1) |
155 ((roi->location() >> 2) &
156 0x1); // <<== CHECK THIS SHIFT LOOKS OK @@vkousk
157 presenceMaps[index] |= (1 << presenceBit);
158 tobCount[index]++;
159 uint32_t key = roi->roiWord();
160 cpmRoiMap.insert(std::make_pair(key, roi));
161 }
162 std::map<uint32_t, const xAOD::CPMTobRoI *>::const_iterator mit =
163 cpmRoiMap.begin();
164 std::map<uint32_t, const xAOD::CPMTobRoI *>::const_iterator mitE =
165 cpmRoiMap.end();
166 for (; mit != mitE; ++mit) {
167 const xAOD::CPMTobRoI *roi = mit->second;
168 const int type = roi->type();
169 const int crate = roi->crate();
170 const int cmx = 1 - type; // <<== CHECK
171 const int cpm = roi->cpm();
172 const int chip = (roi->chip() << 1) | ((roi->location() >> 2) & 0x1);
173 const int loc = roi->location() & 0x3;
174 const int index = ((type * m_crates) + crate) * m_modules + cpm - 1;
175 const int energy = roi->energy();
176 const int isolation = roi->isolation();
177 const unsigned int presence = presenceMaps[index];
178 int error = 0;
179 if (tobCount[index] > m_maxTobs) { // overflow
180 int count = 0;
181 for (int bit = 0; bit <= chip; ++bit)
182 count += (presence >> bit) & 0x1;
183 if (count > m_maxTobs)
184 continue;
185 LVL1::DataError err;
187 error = err.error();
188 }
189 const int key =
190 (((((((crate << 1) | cmx) << 4) | cpm) << 4) | chip) << 2) | loc;
191 xAOD::CMXCPTob *tob = 0;
192 std::map<int, xAOD::CMXCPTob *>::iterator xit = cmxTobMap.find(key);
193 if (xit == cmxTobMap.end()) {
194 tob = new xAOD::CMXCPTob();
195 tob->makePrivateStore(); // make temp store
196 tob->initialize(crate, cmx, cpm, chip, loc);
197 std::vector<uint8_t> vecI(timeslices);
198 std::vector<uint32_t> vecU32(timeslices);
199 std::vector<uint16_t> vecU(timeslices);
200 tob->addTob(vecI, vecI, vecU32, vecU);
201 tob->setPeak(peak);
202 cmxTobMap.insert(std::make_pair(key, tob));
203 cmxTobVec->push_back(tob);
204 } else
205 tob = xit->second;
206 std::vector<uint8_t> energyVec(tob->energyVec());
207 std::vector<uint8_t> isolationVec(tob->isolationVec());
208 std::vector<uint32_t> errorVec(tob->errorVec());
209 std::vector<uint16_t> presenceMapVec(tob->presenceMapVec());
210 energyVec[slice] = energy;
211 isolationVec[slice] = isolation;
212 errorVec[slice] = error;
213 presenceMapVec[slice] = presence;
214 tob->addTob(energyVec, isolationVec, errorVec, presenceMapVec);
215 }
216 }
217}
value_type push_back(value_type pElem)
Add an element to the end of the collection.
void makePrivateStore()
Create a new (empty) private store for this object.
void setPeak(uint8_t)
set peak
virtual void initialize(const uint8_t crate, const uint8_t cmx, const uint8_t cpm, const uint8_t chip, const uint8_t loc)
initialize
void addTob(const std::vector< uint8_t > &energyVec, const std::vector< uint8_t > &isolationVec, const std::vector< uint32_t > &errorVec, const std::vector< uint16_t > &presenceMapVec)
add data to existing object
const std::vector< uint16_t > & presenceMapVec() const
get presenceMapVec
uint32_t roiWord() const
get roiWord
int crate() const
Return crate number (0-1)
int cpm() const
Return CPM number (1-14)
int location() const
Return location (RoI local coords) (0-7)
int energy() const
Return energy.
int chip() const
Return CP chip number (0-7)
int isolation() const
Return isolation.
int type() const
Return type em/tau (0/1)
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
constexpr unsigned int bit(int n)
CPMTobRoI_v1 CPMTobRoI
Define the latest version of the CPMTobRoI class.
setEventNumber uint32_t
CPMTobRoIContainer_v1 CPMTobRoIContainer
Define the latest version of the CPMTobRoI class.

◆ formCMXCPTob() [2/2]

void LVL1::L1CPCMXTools::formCMXCPTob ( const xAOD::CPMTobRoIContainer * cpmRoiVec,
xAOD::CMXCPTobContainer * cmxTobVec ) const
virtual

form CMX-CP TOBs from RoIs - single slice

Implements LVL1::IL1CPCMXTools.

Definition at line 125 of file L1CPCMXTools.cxx.

126 {
127 std::vector<const xAOD::CPMTobRoIContainer *> cpmRoiColls(1, cpmRoiVec);
128 formCMXCPTob(cpmRoiColls, cmxTobVec, 0);
129}
virtual void formCMXCPTob(const xAOD::CPMTobRoIContainer *cpmRoiVec, xAOD::CMXCPTobContainer *cmxTobVec) const
form CMX-CP TOBs from RoIs - single slice

◆ getHits()

void LVL1::L1CPCMXTools::getHits ( const TrigConf::L1Menu * l1menu,
const xAOD::CMXCPTob * tob,
HitsVector & hits0,
HitsVector & hits1 ) const
private

Definition at line 290 of file L1CPCMXTools.cxx.

291 {
292 using namespace TrigConf;
293 const std::vector<uint8_t> &energy(tob->energyVec());
294 const std::vector<uint8_t> &isolation(tob->isolationVec());
295
296 int cmx = tob->cmx();
297 int crate = tob->crate();
298 int cpm = tob->cpm();
299 int chip = (tob->chip() >> 1) & 0x7;
300 int loc = tob->location() | ((tob->chip() & 1) << 2);
301 auto err = LVL1::DataError(tob->error());
302
303 const int type = 1 - cmx;
304 const int timeslices = energy.size();
305 hit0.resize(timeslices);
306 hit1.resize(timeslices);
307
308 // Get thresholds from menu
310
311 // Get EM and TAU trigger thresholds
312 std::vector<std::shared_ptr<TrigConf::L1Threshold>> allThresholds = l1menu->thresholds();
313 std::vector<std::shared_ptr<TrigConf::L1Threshold>> thresholds;
314 thresholds.reserve(16);
315
316 for ( const auto& thresh : allThresholds ) {
317 if (thresh->type() == thrType) {
318 thresholds.push_back(thresh);
319 }
320 }
321
322 if (thresholds.size() > 16) {
323 ATH_MSG_ERROR("Wrong number of thresholds " << thresholds.size());
324 return;
325 }
326
327 for (int slice = 0; slice < timeslices; ++slice) {
328 if (energy[slice] == 0)
329 continue;
330
332 hit0[slice] = 0xffffff;
333 hit1[slice] = 0xffffff;
334 continue;
335 }
336 /* Form an RoI word from the information present
337 Simplest way without duplication is to create a CPMTobRoI */
338 int et = energy[slice];
339 int isol = isolation[slice];
340 std::unique_ptr<LVL1::CPMTobRoI> roi(
341 new CPMTobRoI(crate, cpm, chip, loc, type, et, isol));
342
343 /* Now get the hit information using RecEmTauroI */
344 RecEmTauRoI recRoI(roi->roiWord(), &(*l1menu));
345 auto mask = recRoI.thresholdPattern();
346 for (const auto& threshold : thresholds) {
347 auto numThresh = threshold->mapping();
348 if (!recRoI.isValidThreshold(numThresh) ||
349 (((1 << numThresh) & mask) == 0)) {
350 continue;
351 }
352 if (numThresh < 8) {
353 hit0[slice] |= (1 << (numThresh * 3));
354 } else {
355 hit1[slice] |= (1 << ((numThresh - 8) * 3));
356 }
357 }
358 }
359}
#define ATH_MSG_ERROR(x)
float et(const xAOD::jFexSRJetRoI *j)
static std::string & typeAsString(TriggerType tt)
Definition L1DataDef.h:53
uint32_t error() const
get errorVec at peak bunch crossing

◆ initialize()

StatusCode LVL1::L1CPCMXTools::initialize ( )
virtual

standard Athena-Algorithm method

Initialisation.

Definition at line 44 of file L1CPCMXTools.cxx.

44 {
45 m_debug = msgLvl(MSG::DEBUG);
46
47 return StatusCode::SUCCESS;
48}
bool msgLvl(const MSG::Level lvl) const

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & LVL1::IL1CPCMXTools::interfaceID ( )
inlinestaticinherited

Definition at line 55 of file IL1CPCMXTools.h.

56 {
57 return IID_IL1CPCMXTools;
58 }
static const InterfaceID IID_IL1CPCMXTools("LVL1::IL1CPCMXTools", 1, 0)
Interface definition for L1CPCMXTools.

◆ isolationEm()

int LVL1::L1CPCMXTools::isolationEm ( unsigned int clusterEnergy,
unsigned int emIsol,
unsigned int hadIsol,
unsigned int hadVeto ) const
private

Definition at line 91 of file L1CPCMXTools.cxx.

93 {
94 int isol = 0;
95 if (hadVeto > 1)
96 isol = 1;
97 return isol;
98}

◆ isolationTau()

int LVL1::L1CPCMXTools::isolationTau ( unsigned int clusterEnergy,
unsigned int emIsol,
unsigned int hadIsol ) const
private

Definition at line 100 of file L1CPCMXTools.cxx.

102 {
103 int isol = 0;
104 if (emIsol > 4)
105 isol = 1;
106 return isol;
107}

◆ mergeCMXCPHits()

void LVL1::L1CPCMXTools::mergeCMXCPHits ( xAOD::CMXCPHitsContainer * cmxHitsVec1,
xAOD::CMXCPHitsContainer * cmxHitsVec2 ) const
private

Merge CMX-CP hits vectors.

Definition at line 552 of file L1CPCMXTools.cxx.

553 {
554 int size = cmxHitsVec2->size();
555 for (int index = 0; index < size; ++index) {
556 xAOD::CMXCPHits *hitsIn = 0;
557 xAOD::CMXCPHits *hitsOut = 0;
558 cmxHitsVec2->swapElement(index, hitsIn, hitsOut);
559 cmxHitsVec1->push_back(hitsOut);
560 }
561 cmxHitsVec2->clear();
562}
void swapElement(size_type index, value_type newElem, reference oldElem)
Swap one element out of the container.
size_type size() const noexcept
Returns the number of elements in the collection.
void clear()
Erase all the elements in the collection.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ roiWord()

std::pair< uint32_t, uint32_t > LVL1::L1CPCMXTools::roiWord ( const EmTauROI * roi) const
private

Temporary for testing until CPAlgorithm and EmTauROI are updated.

Definition at line 52 of file L1CPCMXTools.cxx.

52 {
53 const uint32_t oldRoi = roi->roiWord();
54 CPRoIDecoder decoder;
55 const int crate = decoder.crate(oldRoi);
56 const int module = decoder.module(oldRoi);
57 const int chip = decoder.chip(oldRoi);
58 const int coord = decoder.localcoord(oldRoi);
59 bool em = false;
60 bool tau = false;
61 for (unsigned int thresh = 1; thresh <= TrigT1CaloDefs::numOfCPThresholds;
62 ++thresh) {
63 if (roi->thresholdPassed(thresh)) {
64 if (roi->thresholdType(thresh) == TrigT1CaloDefs::EMAlg)
65 em = true;
66 else
67 tau = true;
68 }
69 }
70 uint32_t emRoi = 0;
71 uint32_t tauRoi = 0;
72 if (em) {
73 int isolation =
74 isolationEm(roi->clusterEnergy(), roi->emRingIsolationEnergy(),
75 roi->hadRingIsolationEnergy(), roi->hadCoreEnergy());
76 const CPMTobRoI newRoi(crate, module, chip, coord, 0, roi->clusterEnergy(),
77 isolation);
78 emRoi = newRoi.roiWord();
79 }
80 if (tau) {
81 int isolation =
82 isolationTau(roi->tauClusterEnergy(), roi->emRingIsolationEnergy(),
83 roi->hadRingIsolationEnergy());
84 const CPMTobRoI newRoi(crate, module, chip, coord, 1,
85 roi->tauClusterEnergy(), isolation);
86 tauRoi = newRoi.roiWord();
87 }
88 return std::make_pair(emRoi, tauRoi);
89}
double coord
Type of coordination system.
int isolationTau(unsigned int clusterEnergy, unsigned int emIsol, unsigned int hadIsol) const
int isolationEm(unsigned int clusterEnergy, unsigned int emIsol, unsigned int hadIsol, unsigned int hadVeto) const

◆ saveCMXCPHits()

void LVL1::L1CPCMXTools::saveCMXCPHits ( xAOD::CMXCPHitsContainer * cmxHitsVec,
const HitsVector & hits0,
const HitsVector & hits1,
const ErrorVector & err0,
const ErrorVector & err1,
uint8_t crate,
uint8_t cmx,
uint8_t source,
uint8_t peak ) const
private

Save non-zero CMX-CP hits.

Definition at line 566 of file L1CPCMXTools.cxx.

569 {
570 if (std::accumulate(hits0.begin(), hits0.end(), 0) ||
571 std::accumulate(hits1.begin(), hits1.end(), 0)) {
572 xAOD::CMXCPHits *cmxCpHits = new xAOD::CMXCPHits();
573 cmxCpHits->makePrivateStore();
574 cmxCpHits->initialize(crate, cmx, source, hits0, hits1, err0, err1, peak);
575 cmxHitsVec->push_back(cmxCpHits);
576 }
577}
virtual void initialize(const uint8_t crate, const uint8_t cmx, const uint8_t source)
initialize

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ unpackEmIsol()

void LVL1::L1CPCMXTools::unpackEmIsol ( int energy,
int isol,
unsigned int & emIsol,
unsigned int & hadIsol,
unsigned int & hadVeto ) const
private

Definition at line 109 of file L1CPCMXTools.cxx.

111 {
112 emIsol = 0;
113 hadIsol = 0;
114 hadVeto = (isol == 1) ? 2 : 0;
115}
setThrPattern hadIsol

◆ unpackTauIsol()

void LVL1::L1CPCMXTools::unpackTauIsol ( int energy,
int isol,
unsigned int & emIsol,
unsigned int & hadIsol ) const
private

Definition at line 117 of file L1CPCMXTools.cxx.

118 {
119 emIsol = (isol == 1) ? 5 : 0;
120 hadIsol = 0;
121}

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_crates

int LVL1::L1CPCMXTools::m_crates
private

Number of CP crates.

Definition at line 106 of file L1CPCMXTools.h.

◆ m_debug

bool LVL1::L1CPCMXTools::m_debug
private

Debug printout flag.

Definition at line 114 of file L1CPCMXTools.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_maxTobs

int LVL1::L1CPCMXTools::m_maxTobs
private

Maximum number of TOBs per CPM.

Definition at line 110 of file L1CPCMXTools.h.

◆ m_modules

int LVL1::L1CPCMXTools::m_modules
private

Number of CPMs per crate.

Definition at line 108 of file L1CPCMXTools.h.

◆ m_sysCrate

int LVL1::L1CPCMXTools::m_sysCrate
private

System crate.

Definition at line 112 of file L1CPCMXTools.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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