9#include "GaudiKernel/MsgStream.h"
35 const IInterface *parent)
39 declareInterface<IL1JetCMXTools>(
this);
53 return StatusCode::SUCCESS;
60 std::vector<const xAOD::JEMTobRoIContainer *> jemRoiColls(1, jemRoiVec);
65 const std::vector<const xAOD::JEMTobRoIContainer *> &jemRoiColls,
67 std::map<uint32_t, const xAOD::JEMTobRoI *> jemRoiMap;
68 std::map<int, xAOD::CMXJetTob *> cmxTobMap;
70 int timeslices = jemRoiColls.size();
71 for (
int slice = 0; slice < timeslices; ++slice) {
78 for (; it != itE; ++it) {
80 const int crate = roi->
crate();
81 const int jem = roi->
jem();
83 const int presenceBit = roi->
frame();
84 presenceMaps[
index] |= (1 << presenceBit);
87 jemRoiMap.insert(std::make_pair(key, roi));
89 std::map<uint32_t, const xAOD::JEMTobRoI *>::const_iterator mit =
91 std::map<uint32_t, const xAOD::JEMTobRoI *>::const_iterator mitE =
93 for (; mit != mitE; ++mit) {
95 const int crate = roi->
crate();
96 const int jem = roi->
jem();
97 const int frame = roi->
frame();
102 const unsigned int presence = presenceMaps[
index];
106 for (
int bit = 0; bit <= frame; ++bit)
107 count += (presence >> bit) & 0x1;
114 const int key = (((((crate << 4) | jem) << 3) | frame) << 2) | loc;
116 std::map<int, xAOD::CMXJetTob *>::iterator xit = cmxTobMap.find(key);
117 if (xit == cmxTobMap.end()) {
121 if (timeslices > 0) {
122 std::vector<uint16_t> vecU16(timeslices);
123 std::vector<uint32_t> vecU32(timeslices);
124 tob->
addTob(vecU16, vecU16, vecU32, vecU16);
127 cmxTobMap.insert(std::make_pair(key, tob));
133 std::vector<uint32_t> errorVec(tob->
errorVec());
135 energyLgVec[slice] = energyLg;
136 energySmVec[slice] = energySm;
137 errorVec[slice] =
error;
138 presenceMapVec[slice] = presence;
139 tob->
addTob(energyLgVec, energySmVec, errorVec, presenceMapVec);
168 std::vector<HitsVector> hitVecM(2 *
m_crates);
169 std::vector<HitsVector> hitVecF(2 *
m_crates);
170 std::vector<ErrorVector> errVecM(2 *
m_crates);
171 std::vector<ErrorVector> errVecF(2 *
m_crates);
176 for (; pos != pose; ++pos) {
184 getHits(tob, hit10, hit11, hit20, hit21);
195 const int peak = tob->
peak();
200 for (
int crate = 0; crate <
m_crates; ++crate) {
201 const int index = crate * 2;
230 for (; pos != pose; ++pos) {
234 int source = hits->sourceComponent();
240 int peak = hits->peak();
257 saveCMXJetHits(cmxHitsSys, systemMain0, systemMain1, errVec, errVec,
268 std::vector<HitsVector> hitVec(4 *
m_crates);
271 for (; pos != pose; ++pos) {
273 const int crate = tob->
crate();
274 const int jem = tob->
jem();
275 const int frame = tob->
frame();
277 const int index = crate * 4;
283 timeslices = energyLg.size();
288 checksum.resize(timeslices);
289 map.resize(timeslices);
290 countsLow.resize(timeslices);
291 countsHigh.resize(timeslices);
292 for (
int slice = 0; slice < timeslices; ++slice) {
293 if (energyLg[slice] == 0 && energySm[slice] == 0)
298 const int overflow = 0;
300 jem + frame + loc + energyLg[slice] + energySm[slice] + overflow;
301 checksum[slice] &= 0xffff;
303 map[slice] |= (1 << jem);
306 countsLow[slice] += (1 << (3 * jem));
308 countsHigh[slice] += (1 << (3 * (jem - 8)));
311 const int peak = tob->
peak();
318 for (
int crate = 0; crate <
m_crates; ++crate) {
319 const int index = crate * 4;
336 const int timeslices = energyLg.size();
339 hit10.assign(timeslices, 0);
340 hit11.assign(timeslices, 0);
341 hit20.assign(timeslices, 0);
342 hit21.assign(timeslices, 0);
344 for (
int slice = 0; slice < timeslices; ++slice) {
346 hit10[slice] = 0x7fff;
347 hit11[slice] = 0x7fff;
348 hit20[slice] = 0xffff;
349 hit21[slice] = 0x3fff;
353 if (energyLg[slice] == 0 && energySm[slice] == 0)
359 energyLg[slice], energySm[slice]);
364 unsigned int numThresholdsHalf = 5;
365 unsigned int numBitsPerCounter = 3;
367 for (
unsigned int i = 0; i < numThresholdsHalf * 2; ++i) {
369 HitsVector &hit = i < numThresholdsHalf ? hit10 : hit11;
370 unsigned int ibit = i < numThresholdsHalf ? i : i - numThresholdsHalf;
371 hit[slice] |= (1 << (ibit * numBitsPerCounter));
375 numThresholdsHalf = 8;
376 numBitsPerCounter = 2;
378 for (
unsigned int i = 0; i < numThresholdsHalf * 2; ++i) {
380 HitsVector &hit = i < numThresholdsHalf ? hit20 : hit21;
381 unsigned int ibit = i < numThresholdsHalf ? i : i - numThresholdsHalf;
382 hit[slice] |= (1 << (ibit * numBitsPerCounter));
393 const int timeslices = tobErr.size();
394 hitErr.resize(timeslices);
395 for (
int slice = 0; slice < timeslices; ++slice) {
396 int error = tobErr[slice];
402 hitErr[slice] |= err2.
error();
411 int size1 = vec1.size();
412 int size2 = vec2.size();
415 HitsVector::iterator pos1 = vec1.begin();
416 HitsVector::iterator pose1 = vec1.end();
417 HitsVector::const_iterator pos2 = vec2.begin();
418 HitsVector::const_iterator pose2 = vec2.end();
419 for (; pos1 != pose1 && pos2 != pose2; ++pos1, ++pos2) {
421 *pos1 =
addHits(*pos1, *pos2, 15, 15, 5);
423 *pos1 =
addHits(*pos1, *pos2, 16, 16, 8);
430 int multBits,
int vecBits,
433 msg(MSG::DEBUG) <<
"addHits: Original hitMult = " << std::hex << hitMult
434 <<
". Add hitWord = " << hitVec << std::dec <<
endmsg;
436 int nbitsOut = multBits / nthresh;
437 int nbitsIn = vecBits / nthresh;
440 msg(MSG::DEBUG) <<
" Bits per threshold = " << nbitsOut <<
endmsg;
442 int max = (1 << nbitsOut) - 1;
443 unsigned int multMask =
max;
444 unsigned int hitMask = (1 << nbitsIn) - 1;
445 unsigned int shift = 0;
447 unsigned int hits = 0;
449 for (
int i = 0; i < nthresh; i++) {
450 int mult = (hitMult & multMask) + (hitVec & hitMask);
451 mult = ((mult <=
max) ? mult :
max);
452 hits += (mult << shift);
454 hitMult >>= nbitsOut;
460 msg(MSG::DEBUG) <<
"addHits returning hitMult = " << std::hex << hits
471 int size = cmxHitsVec2->
size();
478 cmxHitsVec2->
clear();
488 int source,
int peak)
const {
489 if (std::accumulate(hits0.begin(), hits0.end(), 0) ||
490 std::accumulate(hits1.begin(), hits1.end(), 0)) {
492 item->makePrivateStore();
493 item->initialize(crate, source, hits0, hits1, err0, err1, peak);
#define ATH_CHECK
Evaluate an expression and check for errors.
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.
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 reconstructed em/tau hadron ROI.
bool passedThreshold(unsigned int thresholdNumber) const
returns TRUE if threshold number threshold_number has been passed by this ROI.
void makePrivateStore()
Create a new (empty) private store for this object.
uint8_t peak() const
get peak
virtual void initialize(const uint8_t crate, const uint8_t jem, const uint8_t frame, const uint8_t loc)
initialize
uint8_t location() const
get location
const std::vector< uint16_t > & energySmallVec() const
get energySmallVec
void setPeak(uint8_t)
set peak
const std::vector< uint16_t > & energyLargeVec() const
get energyLargeVec
uint32_t error() const
get errorVec at peak bunch crossing
const std::vector< uint32_t > & errorVec() const
get errorVec
uint8_t frame() const
get frame
const std::vector< uint16_t > & presenceMapVec() const
get presenceMapVec
uint8_t jem() const
get jem
void addTob(const std::vector< uint16_t > &energyLargeVec, const std::vector< uint16_t > &energySmallVec, const std::vector< uint32_t > &errorVec, const std::vector< uint16_t > &presenceMapVec)
add data to existing object
uint8_t crate() const
get crate
uint32_t roiWord() const
get roiWord
int frame() const
Return RoI frame number (0-7)
int energyLarge() const
Return energy large window size.
int crate() const
Return crate number (0-1)
int energySmall() const
Return energy small window size.
int jem() const
Return JEM number (0-15)
int location() const
Return location (RoI local coords) (0-3)
virtual void initialize(const int crate, const int jem, const int frame, const int location, const int energyLarge, const int energySmall)
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...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Forward iterator to traverse the main components of the trigger configuration.
CMXJetHitsContainer_v1 CMXJetHitsContainer
Define the latest version of the CMXJetHits class.
CMXJetTobContainer_v1 CMXJetTobContainer
Define the latest version of the CMXJetTob class.
CMXJetHits_v1 CMXJetHits
Define the latest version of the CMXJetHits class.
CMXJetTob_v1 CMXJetTob
Define the latest version of the CMXJetTob class.
JEMTobRoI_v1 JEMTobRoI
Define the latest version of the JEMTobRoI class.
JEMTobRoIContainer_v1 JEMTobRoIContainer
Define the latest version of the JEMTobRoI class.