34 const IInterface *parent)
38 declareInterface<IL1CPCMXTools>(
this);
47 return StatusCode::SUCCESS;
53 const uint32_t oldRoi = roi->
roiWord();
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);
88 return std::make_pair(emRoi, tauRoi);
92 unsigned int ,
unsigned int ,
93 unsigned int hadVeto)
const {
102 unsigned int )
const {
110 unsigned int &hadIsol,
111 unsigned int &hadVeto)
const {
114 hadVeto = (isol == 1) ? 2 : 0;
118 unsigned int &hadIsol)
const {
119 emIsol = (isol == 1) ? 5 : 0;
127 std::vector<const xAOD::CPMTobRoIContainer *> cpmRoiColls(1, cpmRoiVec);
134 const std::vector<const xAOD::CPMTobRoIContainer *> &cpmRoiColls,
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) {
147 for (; it != itE; ++it) {
150 const int crate = roi->
crate();
151 const int cpm = roi->
cpm();
153 const int presenceBit =
157 presenceMaps[
index] |= (1 << presenceBit);
160 cpmRoiMap.insert(std::make_pair(key, roi));
162 std::map<uint32_t, const xAOD::CPMTobRoI *>::const_iterator mit =
164 std::map<uint32_t, const xAOD::CPMTobRoI *>::const_iterator mitE =
166 for (; mit != mitE; ++mit) {
169 const int crate = roi->
crate();
170 const int cmx = 1 -
type;
171 const int cpm = roi->
cpm();
172 const int chip = (roi->
chip() << 1) | ((roi->
location() >> 2) & 0x1);
173 const int loc = roi->
location() & 0x3;
175 const int energy = roi->
energy();
177 const unsigned int presence = presenceMaps[
index];
181 for (
int bit = 0; bit <= chip; ++bit)
182 count += (presence >> bit) & 0x1;
190 (((((((crate << 1) | cmx) << 4) | cpm) << 4) | chip) << 2) | loc;
192 std::map<int, xAOD::CMXCPTob *>::iterator xit = cmxTobMap.find(key);
193 if (xit == cmxTobMap.end()) {
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);
202 cmxTobMap.insert(std::make_pair(key, tob));
206 std::vector<uint8_t> energyVec(tob->
energyVec());
208 std::vector<uint32_t> errorVec(tob->
errorVec());
210 energyVec[slice] = energy;
211 isolationVec[slice] = isolation;
212 errorVec[slice] =
error;
213 presenceMapVec[slice] = presence;
214 tob->
addTob(energyVec, isolationVec, errorVec, presenceMapVec);
247 std::vector<HitsVector> hitVec(4 *
m_crates);
248 std::vector<ErrorVector> errVec(4 *
255 for (; pos != pose; ++pos) {
257 uint8_t crate = tob->
crate();
258 uint8_t cmx = tob->
cmx();
259 const int index = (crate * 2 + cmx) * 2;
263 getHits(l1menu, tob, hit0, hit1);
269 uint8_t peak = tob->
peak();
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;
281 uint8_t source = crate;
293 const std::vector<uint8_t> &energy(tob->
energyVec());
294 const std::vector<uint8_t> &isolation(tob->
isolationVec());
296 int cmx = tob->
cmx();
297 int crate = tob->
crate();
298 int cpm = tob->
cpm();
299 int chip = (tob->
chip() >> 1) & 0x7;
303 const int type = 1 - cmx;
304 const int timeslices = energy.size();
305 hit0.resize(timeslices);
306 hit1.resize(timeslices);
312 std::vector<std::shared_ptr<TrigConf::L1Threshold>> allThresholds = l1menu->thresholds();
313 std::vector<std::shared_ptr<TrigConf::L1Threshold>> thresholds;
314 thresholds.reserve(16);
316 for (
const auto& thresh : allThresholds ) {
317 if (thresh->type() == thrType) {
318 thresholds.push_back(thresh);
322 if (thresholds.size() > 16) {
323 ATH_MSG_ERROR(
"Wrong number of thresholds " << thresholds.size());
327 for (
int slice = 0; slice < timeslices; ++slice) {
328 if (energy[slice] == 0)
332 hit0[slice] = 0xffffff;
333 hit1[slice] = 0xffffff;
338 int et = energy[slice];
339 int isol = isolation[slice];
340 std::unique_ptr<LVL1::CPMTobRoI> roi(
346 for (
const auto&
threshold : thresholds) {
349 (((1 << numThresh) & mask) == 0)) {
353 hit0[slice] |= (1 << (numThresh * 3));
355 hit1[slice] |= (1 << ((numThresh - 8) * 3));
363 const int timeslices = tobErr.size();
364 hitErr.resize(timeslices);
365 for (
int slice = 0; slice < timeslices; ++slice) {
366 int error = tobErr[slice];
372 hitErr[slice] |= err2.
error();
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) {
393 uint8_t source = hits->sourceComponent();
399 const uint8_t peak = hits->peak();
406 uint8_t cmx = hits->cmx();
413 for (uint8_t cmx = 0; cmx < 2; ++cmx) {
414 saveCMXCPHits(cmxHitsSys, systemHit0[cmx], systemHit1[cmx], systemErr0[cmx],
428 std::vector<HitsVector> hitVec(8 *
m_crates);
431 for (; pos != pose; ++pos) {
433 uint8_t crate = tob->
crate();
434 uint8_t cmx = tob->
cmx();
435 const uint8_t cpm = tob->
cpm();
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());
444 timeslices = energy.size();
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)
460 cpm + chip + loc + energy[slice] + isolation[slice] + overflow;
461 checksum[slice] &= 0xff;
463 map[slice] |= (1 << (cpm - 1));
466 countsLow[slice] += (1 << (3 * (cpm - 1)));
468 countsHigh[slice] += (1 << (3 * (cpm - 8)));
471 uint8_t peak = tob->
peak();
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;
496 int size1 = vec1.size();
497 int size2 = vec2.size();
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);
512 int multBits,
int vecBits)
const {
514 msg() << MSG::DEBUG <<
"addHits: Original hitMult = " << std::hex << hitMult
515 <<
". Add hitWord = " << hitVec << std::dec <<
endmsg;
520 int nbitsOut = multBits / nthresh;
521 int nbitsIn = vecBits / nthresh;
524 msg() << MSG::DEBUG <<
" Bits per threshold = " << nbitsOut <<
endmsg;
526 int max = (1 << nbitsOut) - 1;
527 unsigned int multMask =
max;
528 unsigned int hitMask = (1 << nbitsIn) - 1;
529 unsigned int shift = 0;
531 unsigned int hits = 0;
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);
538 hitMult >>= nbitsOut;
544 msg() << MSG::DEBUG <<
"addHits returning hitMult = " << std::hex << hits
554 int size = cmxHitsVec2->
size();
561 cmxHitsVec2->
clear();
569 uint8_t crate, uint8_t cmx, uint8_t source, uint8_t peak)
const {
570 if (std::accumulate(hits0.begin(), hits0.end(), 0) ||
571 std::accumulate(hits1.begin(), hits1.end(), 0)) {
574 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.