31 const IInterface *parent)
35 declareInterface<IL1CPCMXTools>(
this);
44 return StatusCode::SUCCESS;
50 const uint32_t oldRoi = roi->
roiWord();
52 const int crate = decoder.crate(oldRoi);
53 const int module = decoder.module(oldRoi);
54 const int chip = decoder.chip(oldRoi);
55 const int coord = decoder.localcoord(oldRoi);
85 return std::make_pair(emRoi, tauRoi);
89 unsigned int ,
unsigned int ,
90 unsigned int hadVeto)
const {
99 unsigned int )
const {
107 unsigned int &hadIsol,
108 unsigned int &hadVeto)
const {
111 hadVeto = (isol == 1) ? 2 : 0;
115 unsigned int &hadIsol)
const {
116 emIsol = (isol == 1) ? 5 : 0;
124 std::vector<const xAOD::CPMTobRoIContainer *> cpmRoiColls(1, cpmRoiVec);
131 const std::vector<const xAOD::CPMTobRoIContainer *> &cpmRoiColls,
133 std::map<uint32_t, const xAOD::CPMTobRoI *> cpmRoiMap;
134 std::map<int, xAOD::CMXCPTob *> cmxTobMap;
136 int timeslices = cpmRoiColls.size();
137 for (
int slice = 0; slice < timeslices; ++slice) {
144 for (; it != itE; ++it) {
147 const int crate = roi->
crate();
148 const int cpm = roi->
cpm();
150 const int presenceBit =
154 presenceMaps[
index] |= (1 << presenceBit);
157 cpmRoiMap.insert(std::make_pair(key, roi));
159 std::map<uint32_t, const xAOD::CPMTobRoI *>::const_iterator mit =
161 std::map<uint32_t, const xAOD::CPMTobRoI *>::const_iterator mitE =
163 for (; mit != mitE; ++mit) {
166 const int crate = roi->
crate();
167 const int cmx = 1 -
type;
168 const int cpm = roi->
cpm();
169 const int chip = (roi->
chip() << 1) | ((roi->
location() >> 2) & 0x1);
170 const int loc = roi->
location() & 0x3;
172 const int energy = roi->
energy();
174 const unsigned int presence = presenceMaps[
index];
178 for (
int bit = 0; bit <= chip; ++bit)
179 count += (presence >> bit) & 0x1;
187 (((((((crate << 1) | cmx) << 4) | cpm) << 4) | chip) << 2) | loc;
189 std::map<int, xAOD::CMXCPTob *>::iterator xit = cmxTobMap.find(key);
190 if (xit == cmxTobMap.end()) {
194 std::vector<uint8_t> vecI(timeslices);
195 std::vector<uint32_t> vecU32(timeslices);
196 std::vector<uint16_t> vecU(timeslices);
197 tob->
addTob(vecI, vecI, vecU32, vecU);
199 cmxTobMap.insert(std::make_pair(key, tob));
203 std::vector<uint8_t> energyVec(tob->
energyVec());
205 std::vector<uint32_t> errorVec(tob->
errorVec());
207 energyVec[slice] = energy;
208 isolationVec[slice] = isolation;
209 errorVec[slice] =
error;
210 presenceMapVec[slice] = presence;
211 tob->
addTob(energyVec, isolationVec, errorVec, presenceMapVec);
244 std::vector<HitsVector> hitVec(4 *
m_crates);
245 std::vector<ErrorVector> errVec(4 *
252 for (; pos != pose; ++pos) {
254 uint8_t crate = tob->
crate();
255 uint8_t cmx = tob->
cmx();
256 const int index = (crate * 2 + cmx) * 2;
260 getHits(l1menu, tob, hit0, hit1);
266 uint8_t peak = tob->
peak();
271 for (uint8_t crate = 0; crate <
m_crates; ++crate) {
272 for (uint8_t cmx = 0; cmx < 2; ++cmx) {
273 const int index = (crate * 2 + cmx) * 2;
278 uint8_t source = crate;
290 const std::vector<uint8_t> &energy(tob->
energyVec());
291 const std::vector<uint8_t> &isolation(tob->
isolationVec());
293 int cmx = tob->
cmx();
294 int crate = tob->
crate();
295 int cpm = tob->
cpm();
296 int chip = (tob->
chip() >> 1) & 0x7;
300 const int type = 1 - cmx;
301 const int timeslices = energy.size();
302 hit0.resize(timeslices);
303 hit1.resize(timeslices);
309 std::vector<std::shared_ptr<TrigConf::L1Threshold>> allThresholds = l1menu->thresholds();
310 std::vector<std::shared_ptr<TrigConf::L1Threshold>> thresholds;
311 thresholds.reserve(16);
313 for (
const auto& thresh : allThresholds ) {
314 if (thresh->type() == thrType) {
315 thresholds.push_back(thresh);
319 if (thresholds.size() > 16) {
320 ATH_MSG_ERROR(
"Wrong number of thresholds " << thresholds.size());
324 for (
int slice = 0; slice < timeslices; ++slice) {
325 if (energy[slice] == 0)
329 hit0[slice] = 0xffffff;
330 hit1[slice] = 0xffffff;
335 int et = energy[slice];
336 int isol = isolation[slice];
337 std::unique_ptr<LVL1::CPMTobRoI> roi(
343 for (
const auto&
threshold : thresholds) {
346 (((1 << numThresh) & mask) == 0)) {
350 hit0[slice] |= (1 << (numThresh * 3));
352 hit1[slice] |= (1 << ((numThresh - 8) * 3));
360 const int timeslices = tobErr.size();
361 hitErr.resize(timeslices);
362 for (
int slice = 0; slice < timeslices; ++slice) {
363 int error = tobErr[slice];
369 hitErr[slice] |= err2.
error();
380 std::vector<HitsVector> systemHit0(2);
381 std::vector<HitsVector> systemHit1(2);
382 std::vector<ErrorVector> systemErr0(2);
383 std::vector<ErrorVector> systemErr1(2);
386 for (; pos != pose; ++pos) {
390 uint8_t source = hits->sourceComponent();
396 const uint8_t peak = hits->peak();
403 uint8_t cmx = hits->cmx();
410 for (uint8_t cmx = 0; cmx < 2; ++cmx) {
411 saveCMXCPHits(cmxHitsSys, systemHit0[cmx], systemHit1[cmx], systemErr0[cmx],
425 std::vector<HitsVector> hitVec(8 *
m_crates);
428 for (; pos != pose; ++pos) {
430 uint8_t crate = tob->
crate();
431 uint8_t cmx = tob->
cmx();
432 const uint8_t cpm = tob->
cpm();
433 const uint8_t chip = tob->
chip() >> 1;
434 const uint8_t loc = ((tob->
chip() & 0x1) << 2) | tob->
location();
435 const int index = (crate * 2 + cmx) * 4;
436 const std::vector<uint8_t> &energy(tob->
energyVec());
437 const std::vector<uint8_t> &isolation(tob->
isolationVec());
439 timeslices = energy.size();
444 checksum.resize(timeslices);
445 map.resize(timeslices);
446 countsLow.resize(timeslices);
447 countsHigh.resize(timeslices);
448 for (
int slice = 0; slice < timeslices; ++slice) {
449 if (energy[slice] == 0)
455 cpm + chip + loc + energy[slice] + isolation[slice] + overflow;
456 checksum[slice] &= 0xff;
458 map[slice] |= (1 << (cpm - 1));
461 countsLow[slice] += (1 << (3 * (cpm - 1)));
463 countsHigh[slice] += (1 << (3 * (cpm - 8)));
466 uint8_t peak = tob->
peak();
472 std::vector<uint32_t> dummyE(timeslices);
473 for (uint8_t crate = 0; crate <
m_crates; ++crate) {
474 for (uint8_t cmx = 0; cmx < 2; ++cmx) {
475 const int index = (crate * 2 + cmx) * 4;
491 int size1 = vec1.size();
492 int size2 = vec2.size();
495 HitsVector::iterator pos1 = vec1.begin();
496 HitsVector::iterator pose1 = vec1.end();
497 HitsVector::const_iterator pos2 = vec2.begin();
498 HitsVector::const_iterator pose2 = vec2.end();
499 for (; pos1 != pose1 && pos2 != pose2; ++pos1, ++pos2) {
500 *pos1 =
addHits(*pos1, *pos2, 24, 24);
507 int multBits,
int vecBits)
const {
509 msg() << MSG::DEBUG <<
"addHits: Original hitMult = " << std::hex << hitMult
510 <<
". Add hitWord = " << hitVec << std::dec <<
endmsg;
515 int nbitsOut = multBits / nthresh;
516 int nbitsIn = vecBits / nthresh;
519 msg() << MSG::DEBUG <<
" Bits per threshold = " << nbitsOut <<
endmsg;
521 int max = (1 << nbitsOut) - 1;
522 unsigned int multMask =
max;
523 unsigned int hitMask = (1 << nbitsIn) - 1;
524 unsigned int shift = 0;
526 unsigned int hits = 0;
528 for (
int i = 0; i < nthresh; i++) {
529 int mult = (hitMult & multMask) + (hitVec & hitMask);
530 mult = ((mult <=
max) ? mult :
max);
531 hits += (mult << shift);
533 hitMult >>= nbitsOut;
539 msg() << MSG::DEBUG <<
"addHits returning hitMult = " << std::hex << hits
549 int size = cmxHitsVec2->
size();
556 cmxHitsVec2->
clear();
564 uint8_t crate, uint8_t cmx, uint8_t source, uint8_t peak)
const {
565 if (std::accumulate(hits0.begin(), hits0.end(), 0) ||
566 std::accumulate(hits1.begin(), hits1.end(), 0)) {
569 cmxCpHits->
initialize(crate, cmx, source, hits0, hits1, err0, err1, peak);
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
void swapElement(size_type index, value_type newElem, reference oldElem)
Swap one element out of the container.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
void clear()
Erase all the elements in the collection.
uint32_t roiWord() const
Return packed RoI word.
A level 1 calorimeter trigger conversion service: returns the Coordinate represented by a RoI word.
int error() const
Return the full error word.
void set(ErrorBit bit, int value=1)
Set an error bit or data.
This class defines the em/tau hadron ROI which are generated by the LVL1 Calo Trigger.
unsigned int hadCoreEnergy() const
return energy
unsigned int emRingIsolationEnergy() const
return energy
unsigned int clusterEnergy() const
return energy
bool thresholdPassed(int thresh) const
returns TRUE if threshold number threshold_number has been passed by this ROI.
unsigned int tauClusterEnergy() const
unsigned int hadRingIsolationEnergy() const
return energy
TrigT1CaloDefs::ClusterAlgorithm thresholdType(int thresh) const
returns type of thresholds number threshold_number Thresholds numbered from 1 to TrigT1CaloDefs::numO...
unsigned int roiWord() const
returns the 32bit ROI word.
This class defines the reconstructed em/tau hadron ROI.
bool isValidThreshold(unsigned int thresh) const
returns true if thresh is a valid threshold number
unsigned int thresholdPattern() const
returns bitmask of passed thresholds
static const unsigned int numOfCPThresholds
void makePrivateStore()
Create a new (empty) private store for this object.
static std::string & typeAsString(TriggerType tt)
virtual void initialize(const uint8_t crate, const uint8_t cmx, const uint8_t source)
initialize
uint8_t cmx() const
get cmx
uint8_t cpm() const
get cpm
uint32_t error() const
get errorVec at peak bunch crossing
const std::vector< uint8_t > & energyVec() const
get energyVec
uint8_t crate() const
get crate
void setPeak(uint8_t)
set peak
const std::vector< uint32_t > & errorVec() const
get errorVec
const std::vector< uint8_t > & isolationVec() const
get isolationVec
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
uint8_t chip() const
get chip
uint8_t peak() const
get peak
uint8_t location() const
get location
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 ®x)
count how many occurances of a regx are in a string
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Forward iterator to traverse the main components of the trigger configuration.
CPMTobRoI_v1 CPMTobRoI
Define the latest version of the CPMTobRoI class.
CMXCPTobContainer_v1 CMXCPTobContainer
Define the latest version of the CMXCPTob class.
CMXCPHitsContainer_v1 CMXCPHitsContainer
Define the latest version of the CMXCPHits class.
CMXCPTob_v1 CMXCPTob
Define the latest version of the CMXCPTob class.
CMXCPHits_v1 CMXCPHits
Define the latest version of the CMMCPHits class.
CPMTobRoIContainer_v1 CPMTobRoIContainer
Define the latest version of the CPMTobRoI class.
Extra patterns decribing particle interation process.