@@ -39,49 +39,54 @@ void l1ct::tdr_regionizer::Pipes<T>::setTaps(size_t taps) {
3939// BUFFER ENTRY AND BUFFER
4040template <typename T>
4141l1ct::tdr_regionizer::BufferEntry<T>::BufferEntry(
42- const T& obj, std::vector<size_t> srIndices, int glbeta, int glbphi, int locphi , unsigned int clk)
43- : obj_(obj), srIndices_(srIndices), glbeta_(glbeta), glbphi_(glbphi), locphi_(locphi ), linkobjclk_(clk) {
42+ const T& obj, std::vector<size_t> srIndices, int glbeta, int glbphi, bool duplicate , unsigned int clk)
43+ : obj_(obj), srIndices_(srIndices), glbeta_(glbeta), glbphi_(glbphi), duplicate_(duplicate ), linkobjclk_(clk) {
4444 objcount_ = 0;
4545}
4646
4747template <typename T>
48- inline void l1ct::tdr_regionizer::Buffer<T>::addEntry(const T& obj,
49- std::vector<size_t> srIndices,
50- int glbeta,
51- int glbphi,
52- int locphi,
53- unsigned int dupNum,
54- unsigned int ndup) {
48+ inline void l1ct::tdr_regionizer::Buffer<T>::addEntry(
49+ const T& obj,
50+ std::vector<size_t> srIndices,
51+ int glbeta,
52+ int glbphi,
53+ bool duplicate, // this is mainly for GCT, is it one of the duplicates
54+ unsigned int dupNum,
55+ unsigned int ndup) {
5556 // dupNum is the duplicate number of this buffer (int range 0 to ndup_-1)
56- auto objClk = nextObjClk(ndup);
57- data_.emplace_back(obj, srIndices, glbeta, glbphi, locphi , objClk);
57+ auto objClk = nextObjClk(ndup, obj.intPt() == 0 );
58+ data_.emplace_back(obj, srIndices, glbeta, glbphi, duplicate , objClk);
5859 if (timeOfNextObject_ < 0) {
5960 timeOfNextObject_ = objClk;
6061 }
6162}
6263
6364template <typename T>
64- void l1ct::tdr_regionizer::Buffer<T>::updateNextObjectTime(int currTime) {
65+ void l1ct::tdr_regionizer::Buffer<T>::updateNextObjectTime(int currTime, bool incrementTime ) {
6566 if (data_.size() > 0) {
66- timeOfNextObject_ = std::max(front().clock(), static_cast<unsigned int>(currTime + 1));
67+ auto nextTime = incrementTime ? currTime + 1 : currTime;
68+ timeOfNextObject_ = std::max(front().clock(), static_cast<unsigned int>(nextTime));
6769 } else {
6870 timeOfNextObject_ = -1;
6971 }
7072}
7173
7274template <typename T>
73- inline unsigned int l1ct::tdr_regionizer::Buffer<T>::nextObjClk(unsigned int ndup) {
75+ inline unsigned int l1ct::tdr_regionizer::Buffer<T>::nextObjClk(unsigned int ndup, bool skip ) {
7476 unsigned int nextVal = std::max(clkindex360_, clkindex240_) / 3;
7577
7678 clkindex360_ += 2 * ndup;
77- clkindex240_ += 3;
7879
80+ // Though a 360MHz clock is used, one doesn't need to a 240MHz clock for pt == 0
81+ if (!skip) {
82+ clkindex240_ += 3;
83+ }
7984 return nextVal;
8085}
8186
8287// explicit for tracks
8388template <>
84- inline unsigned int l1ct::tdr_regionizer::Buffer<l1ct::TkObjEmu>::nextObjClk(unsigned int ndup) {
89+ inline unsigned int l1ct::tdr_regionizer::Buffer<l1ct::TkObjEmu>::nextObjClk(unsigned int ndup, bool skip ) {
8590 if (ndup != 1) {
8691 throw std::invalid_argument("Only ndup==1 is currently supported for the TkObjEmu buffers.");
8792 }
@@ -93,8 +98,9 @@ inline unsigned int l1ct::tdr_regionizer::Buffer<l1ct::TkObjEmu>::nextObjClk(uns
9398 clkindex360_ += 2;
9499 }
95100
96- clkindex240_ += 3;
97-
101+ if (!skip) {
102+ clkindex240_ += 3;
103+ }
98104 return nextVal;
99105}
100106
@@ -173,7 +179,7 @@ void l1ct::tdr_regionizer::Regionizer<T>::initSectors(const std::vector<Detector
173179 // but it's easier to create the inverse, first
174180
175181 if (debug_) {
176- dbgCout() << "secotors .size() = " << sectors.size() << std::endl;
182+ dbgCout() << "sectors .size() = " << sectors.size() << std::endl;
177183 }
178184
179185 for (const auto& sector : sectors) {
@@ -188,9 +194,6 @@ void l1ct::tdr_regionizer::Regionizer<T>::initSectors(const std::vector<Detector
188194 }
189195 nsectors_ = sectors_.size();
190196 buffers_.resize(nsectors_ * ndup_);
191- // if (debug_) {
192- // dbgCout() << "Number of sectors: " << nsectors_ << std::endl;
193- // }
194197
195198 std::sort(sectorMapLogToPhys_.begin(), sectorMapLogToPhys_.end(), [this](size_t a, size_t b) {
196199 return this->sortSectors(a, b);
@@ -216,6 +219,7 @@ void l1ct::tdr_regionizer::Regionizer<T>::initSectors(const DetectorSector<T>& s
216219 assert(nsectors_ == 0);
217220 nsectors_ = 1;
218221 sectors_.push_back(sector.region);
222+ sectorMapLogToPhys_.push_back(0);
219223 sectorMapPhysToLog_.push_back(0);
220224 buffers_.resize(nsectors_ * ndup_);
221225 if (debug_) {
@@ -292,13 +296,6 @@ void l1ct::tdr_regionizer::Regionizer<T>::initRegions(const std::vector<PFInputR
292296 regions_.resize(regions.size());
293297 for (unsigned int i = 0; i < regions.size(); ++i) {
294298 regions_[i] = regions[i].region;
295- // if (debug_) {
296- // dbgCout() << "region eta/phi: " << regions_[i].intEtaCenter() << " " << regions_[i].intPhiCenter()
297- // << ", eta half width = " << regions_[i].hwEtaHalfWidth.to_int()
298- // << ", phi half width = " << regions_[i].hwPhiHalfWidth.to_int()
299- // << ", eta extra = " << regions_[i].hwEtaExtra.to_int()
300- // << ", phi extra = " << regions_[i].hwPhiExtra.to_int() << std::endl;
301- // }
302299 if (isInBigRegion(regions_[i])) {
303300 regionmap_.push_back(i);
304301 if (debug_) {
@@ -398,7 +395,13 @@ void l1ct::tdr_regionizer::Regionizer<T>::addToBuffer(const T& obj, unsigned int
398395 auto glbphi = sectors_[sector].hwGlbPhiOf(obj).to_int();
399396 auto glbeta = sectors_[sector].hwGlbEtaOf(obj).to_int();
400397 // get the SR indices that this object should go into
401- buffers_[buffer].addEntry(obj, getSmallRegions(glbeta, glbphi), glbeta, glbphi, obj.hwPhi.to_int(), dupNum, ndup_);
398+ buffers_[buffer].addEntry(obj,
399+ getSmallRegions(glbeta, glbphi),
400+ glbeta,
401+ glbphi,
402+ isDuplicate(obj.hwPhi.to_int(), logicBuffIndex(buffer)),
403+ dupNum,
404+ ndup_);
402405}
403406
404407template <typename T>
@@ -465,16 +468,29 @@ void l1ct::tdr_regionizer::Regionizer<T>::run() {
465468 if (buffer.timeOfNextObject() >= 0) {
466469 processedAll = false;
467470 }
468- if (buffer.timeOfNextObject() == currTime) {
471+ while (buffer.timeOfNextObject() == currTime) {
469472 // time to handle the buffer entry
470473 const auto nextSR = buffer.front().nextSR();
471474 if (debug_) {
472- dbgCout() << "Current time " << currTime << ", handling bufIdx " << bufIdx << " object with SR = " << nextSR
473- << ", pt = " << buffer.pt() << ", glbeta = " << buffer.glbEta() << ", glbphi = " << buffer.glbPhi()
474- << ", local(to link)phi = " << buffer.sectorLocalPhi() << std::endl;
475+ dbgCout() << "Current time " << currTime << ", handling bufIdx " << bufIdx << ", logical "
476+ << logicBuffIndex(bufIdx) << " object with SR = " << nextSR << ", pt = " << buffer.pt()
477+ << ", glbeta = " << buffer.glbEta() << ", glbphi = " << buffer.glbPhi()
478+ << ", duplicate = " << buffer.duplicate() << std::endl;
475479 }
476- if (nextSR < 0 || buffer.pt() == 0 || smallRegionObjects_[nextSR].size() == maxobjects_ ||
477- isDuplicate(buffer.sectorLocalPhi(), logicBuffIndex(bufIdx))) {
480+ if (buffer.pt() == 0) { // double check that this also works for tracks
481+ if (debug_) {
482+ dbgCout() << "---Throw out, don't increment time" << std::endl;
483+ }
484+ buffer.pop();
485+ buffer.updateNextObjectTime(currTime, false); // do not increment time
486+ } else if (buffer.duplicate()) {
487+ // remove the whole object, not worrying about nextSR
488+ if (debug_) {
489+ dbgCout() << "---Throw out, duplicate, increment time" << std::endl;
490+ }
491+ buffer.pop();
492+ buffer.updateNextObjectTime(currTime); // do increment time
493+ } else if (nextSR < 0 || smallRegionObjects_[nextSR].size() == maxobjects_) {
478494 // throwout or SR full, just get rid of object
479495 if (debug_) {
480496 dbgCout() << "---Throw out" << std::endl;
@@ -548,7 +564,7 @@ size_t l1ct::tdr_regionizer::Regionizer<T>::logicBuffIndex(size_t bufIdx) const
548564 return logSector * ndup_ + bufIdx % ndup_;
549565}
550566
551- // default is no duplicates
567+ // default is no duplicates. Note, locPhi is for the sector, not small region
552568template <typename T>
553569bool l1ct::tdr_regionizer::Regionizer<T>::isDuplicate(int locphi, size_t logicBufIdx) const {
554570 return false;
@@ -578,24 +594,24 @@ inline bool l1ct::tdr_regionizer::Regionizer<l1ct::EmCaloObjEmu>::isDuplicate(in
578594template <typename T>
579595void l1ct::tdr_regionizer::Regionizer<T>::printDebug(int count) const {
580596 dbgCout() << "BUFFERS, (for " << numBuffers() << " buffers)" << std::endl;
581- dbgCout() << count << "\tbuffer\tlogical\titem\tpt\teta\tphi\tlocphi \tclock" << std::endl;
597+ dbgCout() << count << "\tbuffer\tlogical\titem\tpt\teta\tphi\tduplicate \tclock" << std::endl;
582598 for (auto sector : sectorMapLogToPhys_) {
583599 for (unsigned int dup = 0; dup < ndup_; dup++) {
584600 const unsigned int buffer = sector * ndup_ + dup;
585601 for (unsigned int j = 0; j < numEntries(buffer); j++) {
586602 dbgCout() << "\t" << buffer << "\t" << logicBuffIndex(buffer) << "\t" << j << "\t" << buffers_[buffer].pt(j)
587603 << "\t" << buffers_[buffer].glbEta(j) << "\t" << buffers_[buffer].glbPhi(j) << "\t"
588- << buffers_[buffer].sectorLocalPhi (j) << "\t" << buffers_[buffer].clock(j) << std::endl;
604+ << buffers_[buffer].duplicate (j) << "\t" << buffers_[buffer].clock(j) << std::endl;
589605 }
590606 dbgCout() << "-------------------------------" << std::endl;
591607 }
592608 }
593609 dbgCout() << "PIPES, (for " << pipes_.size() << " pipes)" << std::endl;
594610 dbgCout() << count << "\tpipe\ttap\tsr\tpt\teta\tphi" << std::endl;
595- for (size_t pipe = 0; pipe < pipes_.size(); pipe++ ) {
596- for (size_t tap = 0; tap < pipes_.numTaps(); tap++ ) {
611+ for (int tap = pipes_.numTaps() - 1; tap >= 0; --tap ) {
612+ for (int pipe = pipes_.size() - 1; pipe >= 0; --pipe ) {
597613 auto entry = pipes_.entry(pipe, tap);
598- dbgCout() << "\t" << pipe << "\t" << tap << "\t" << entry.sr() << "\t" << entry.pt() << "\t" << entry.glbEta()
614+ dbgCout() << "\t" << pipe << "\t" << tap + 1 << "\t" << entry.sr() << "\t" << entry.pt() << "\t" << entry.glbEta()
599615 << "\t" << entry.glbPhi() << std::endl;
600616 }
601617 dbgCout() << "-------------------------------" << std::endl;
@@ -634,20 +650,12 @@ std::vector<std::vector<T>> l1ct::tdr_regionizer::Regionizer<T>::fillLinks(
634650 for (const auto& sector : sectors) {
635651 if (isInBigRegionLoose(sector.region)) {
636652 links.emplace_back();
637- // if (debug_) {
638- // dbgCout() << "sector.size() = " << sector.size() << std::endl;
639- // }
640653 for (unsigned int io = 0; io < sector.size() && io < nclocks_; io++) {
641654 links.back().push_back(sector[io]);
642655 }
643656 }
644657 }
645658
646- // if (debug_) {
647- // dbgCout() << "fillLinks sectors.size() = " << sectors.size()
648- // << ", links.size() = " << links.size() << ", links[0].size() = " << links[0].size()<< std::endl;
649- // }
650-
651659 return links;
652660}
653661
0 commit comments