@@ -39,49 +39,54 @@ void l1ct::tdr_regionizer::Pipes<T>::setTaps(size_t taps) {
39
39
// BUFFER ENTRY AND BUFFER
40
40
template <typename T>
41
41
l1ct::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) {
44
44
objcount_ = 0;
45
45
}
46
46
47
47
template <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) {
55
56
// 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);
58
59
if (timeOfNextObject_ < 0) {
59
60
timeOfNextObject_ = objClk;
60
61
}
61
62
}
62
63
63
64
template <typename T>
64
- void l1ct::tdr_regionizer::Buffer<T>::updateNextObjectTime(int currTime) {
65
+ void l1ct::tdr_regionizer::Buffer<T>::updateNextObjectTime(int currTime, bool incrementTime ) {
65
66
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));
67
69
} else {
68
70
timeOfNextObject_ = -1;
69
71
}
70
72
}
71
73
72
74
template <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 ) {
74
76
unsigned int nextVal = std::max(clkindex360_, clkindex240_) / 3;
75
77
76
78
clkindex360_ += 2 * ndup;
77
- clkindex240_ += 3;
78
79
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
+ }
79
84
return nextVal;
80
85
}
81
86
82
87
// explicit for tracks
83
88
template <>
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 ) {
85
90
if (ndup != 1) {
86
91
throw std::invalid_argument("Only ndup==1 is currently supported for the TkObjEmu buffers.");
87
92
}
@@ -93,8 +98,9 @@ inline unsigned int l1ct::tdr_regionizer::Buffer<l1ct::TkObjEmu>::nextObjClk(uns
93
98
clkindex360_ += 2;
94
99
}
95
100
96
- clkindex240_ += 3;
97
-
101
+ if (!skip) {
102
+ clkindex240_ += 3;
103
+ }
98
104
return nextVal;
99
105
}
100
106
@@ -173,7 +179,7 @@ void l1ct::tdr_regionizer::Regionizer<T>::initSectors(const std::vector<Detector
173
179
// but it's easier to create the inverse, first
174
180
175
181
if (debug_) {
176
- dbgCout() << "secotors .size() = " << sectors.size() << std::endl;
182
+ dbgCout() << "sectors .size() = " << sectors.size() << std::endl;
177
183
}
178
184
179
185
for (const auto& sector : sectors) {
@@ -188,9 +194,6 @@ void l1ct::tdr_regionizer::Regionizer<T>::initSectors(const std::vector<Detector
188
194
}
189
195
nsectors_ = sectors_.size();
190
196
buffers_.resize(nsectors_ * ndup_);
191
- // if (debug_) {
192
- // dbgCout() << "Number of sectors: " << nsectors_ << std::endl;
193
- // }
194
197
195
198
std::sort(sectorMapLogToPhys_.begin(), sectorMapLogToPhys_.end(), [this](size_t a, size_t b) {
196
199
return this->sortSectors(a, b);
@@ -216,6 +219,7 @@ void l1ct::tdr_regionizer::Regionizer<T>::initSectors(const DetectorSector<T>& s
216
219
assert(nsectors_ == 0);
217
220
nsectors_ = 1;
218
221
sectors_.push_back(sector.region);
222
+ sectorMapLogToPhys_.push_back(0);
219
223
sectorMapPhysToLog_.push_back(0);
220
224
buffers_.resize(nsectors_ * ndup_);
221
225
if (debug_) {
@@ -292,13 +296,6 @@ void l1ct::tdr_regionizer::Regionizer<T>::initRegions(const std::vector<PFInputR
292
296
regions_.resize(regions.size());
293
297
for (unsigned int i = 0; i < regions.size(); ++i) {
294
298
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
- // }
302
299
if (isInBigRegion(regions_[i])) {
303
300
regionmap_.push_back(i);
304
301
if (debug_) {
@@ -398,7 +395,13 @@ void l1ct::tdr_regionizer::Regionizer<T>::addToBuffer(const T& obj, unsigned int
398
395
auto glbphi = sectors_[sector].hwGlbPhiOf(obj).to_int();
399
396
auto glbeta = sectors_[sector].hwGlbEtaOf(obj).to_int();
400
397
// 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_);
402
405
}
403
406
404
407
template <typename T>
@@ -465,16 +468,29 @@ void l1ct::tdr_regionizer::Regionizer<T>::run() {
465
468
if (buffer.timeOfNextObject() >= 0) {
466
469
processedAll = false;
467
470
}
468
- if (buffer.timeOfNextObject() == currTime) {
471
+ while (buffer.timeOfNextObject() == currTime) {
469
472
// time to handle the buffer entry
470
473
const auto nextSR = buffer.front().nextSR();
471
474
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;
475
479
}
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_) {
478
494
// throwout or SR full, just get rid of object
479
495
if (debug_) {
480
496
dbgCout() << "---Throw out" << std::endl;
@@ -548,7 +564,7 @@ size_t l1ct::tdr_regionizer::Regionizer<T>::logicBuffIndex(size_t bufIdx) const
548
564
return logSector * ndup_ + bufIdx % ndup_;
549
565
}
550
566
551
- // default is no duplicates
567
+ // default is no duplicates. Note, locPhi is for the sector, not small region
552
568
template <typename T>
553
569
bool l1ct::tdr_regionizer::Regionizer<T>::isDuplicate(int locphi, size_t logicBufIdx) const {
554
570
return false;
@@ -578,24 +594,24 @@ inline bool l1ct::tdr_regionizer::Regionizer<l1ct::EmCaloObjEmu>::isDuplicate(in
578
594
template <typename T>
579
595
void l1ct::tdr_regionizer::Regionizer<T>::printDebug(int count) const {
580
596
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;
582
598
for (auto sector : sectorMapLogToPhys_) {
583
599
for (unsigned int dup = 0; dup < ndup_; dup++) {
584
600
const unsigned int buffer = sector * ndup_ + dup;
585
601
for (unsigned int j = 0; j < numEntries(buffer); j++) {
586
602
dbgCout() << "\t" << buffer << "\t" << logicBuffIndex(buffer) << "\t" << j << "\t" << buffers_[buffer].pt(j)
587
603
<< "\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;
589
605
}
590
606
dbgCout() << "-------------------------------" << std::endl;
591
607
}
592
608
}
593
609
dbgCout() << "PIPES, (for " << pipes_.size() << " pipes)" << std::endl;
594
610
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 ) {
597
613
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()
599
615
<< "\t" << entry.glbPhi() << std::endl;
600
616
}
601
617
dbgCout() << "-------------------------------" << std::endl;
@@ -634,20 +650,12 @@ std::vector<std::vector<T>> l1ct::tdr_regionizer::Regionizer<T>::fillLinks(
634
650
for (const auto& sector : sectors) {
635
651
if (isInBigRegionLoose(sector.region)) {
636
652
links.emplace_back();
637
- // if (debug_) {
638
- // dbgCout() << "sector.size() = " << sector.size() << std::endl;
639
- // }
640
653
for (unsigned int io = 0; io < sector.size() && io < nclocks_; io++) {
641
654
links.back().push_back(sector[io]);
642
655
}
643
656
}
644
657
}
645
658
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
-
651
659
return links;
652
660
}
653
661
0 commit comments