12 bool useSecondEarliest,
13 bool bugSameSectorPt0) {
29 for (
const auto&
cands : extended_best_track_cands) {
30 for (
const auto& cand :
cands) {
31 if (cand.Rank() > 0) {
36 bool early_exit = (num_cands == 0);
48 for (
const auto&
track : best_tracks) {
50 <<
" ph_deltas: " << array_as_string(
track.PtLUT().delta_ph)
51 <<
" th_deltas: " << array_as_string(
track.PtLUT().delta_th) <<
" phi: " <<
track.Phi_fp()
52 <<
" theta: " <<
track.Theta_fp() <<
" cpat: " << array_as_string(
track.PtLUT().cpattern)
53 <<
" bx: " <<
track.BX() << std::endl;
55 if (
track.PtLUT().bt_vi[
i] != 0)
56 std::cout <<
".. track segments: st: " <<
i <<
" v: " <<
track.PtLUT().bt_vi[
i]
57 <<
" h: " <<
track.PtLUT().bt_hi[
i] <<
" c: " <<
track.PtLUT().bt_ci[
i]
58 <<
" s: " <<
track.PtLUT().bt_si[
i] << std::endl;
68 const int max_zn = max_z * max_n;
72 typedef std::array<int, 3> segment_ref_t;
73 std::vector<std::vector<segment_ref_t> > segments(max_zn,
74 std::vector<segment_ref_t>());
76 std::vector<std::vector<bool> > larger(max_zn, std::vector<bool>(max_zn,
false));
77 std::vector<std::vector<bool> > winner(max_zn, std::vector<bool>(max_zn,
false));
79 std::vector<bool> exists(max_zn,
false);
80 std::vector<bool>
killed(max_zn,
false);
81 std::vector<int> rank(max_zn, 0);
85 for (
int z = 0;
z < max_z; ++
z) {
87 const int ntracks = tracks.size();
90 for (
int n = 0;
n < ntracks; ++
n) {
91 const int zn = (
n * max_z) +
z;
94 rank.at(zn) = track.
Rank();
96 for (
const auto& conv_hit : track.
Hits()) {
100 const segment_ref_t segment = {{conv_hit.PC_station() * 9 + conv_hit.PC_chamber(),
101 (conv_hit.PC_segment() % 2),
107 segments.at(zn).push_back(segment);
113 int i = 0,
j = 0, ri = 0, rj = 0,
gt = 0, eq = 0, sum = 0;
115 for (i = 0; i < max_zn; ++
i) {
116 for (
j = 0;
j < max_zn; ++
j) {
117 larger[
i][
j] =
false;
123 for (
j = 0;
j < max_zn; ++
j) {
131 if ((i <
j && (
gt || eq)) || (i >
j &&
gt))
137 exists[
i] = (ri != 0);
141 for (i = 0; i < max_zn - 1; ++
i) {
142 for (
j = i + 1;
j < max_zn; ++
j) {
146 for (
const auto& isegment : segments.at(i)) {
147 for (
const auto& jsegment : segments.at(
j)) {
148 if (isegment == jsegment) {
154 if (shared_segs > 0) {
166 for (i = 0; i < max_zn; ++
i) {
167 exists[
i] = exists[
i] & (!killed[
i]);
170 bool anything_exists = (
std::find(exists.begin(), exists.end(), 1) != exists.end());
171 if (!anything_exists)
175 for (i = 0; i < max_zn; ++
i) {
176 for (
j = 0;
j < max_zn; ++
j) {
180 larger[
i][
j] = larger[
i][
j] | (!exists[
j]);
182 larger[
i][
j] =
false;
188 for (i = max_zn - 1; i >= 0; --
i) {
193 for (i = max_zn - 1; i >= 0; --
i) {
197 for (
j = 0;
j < max_zn; ++
j) {
199 for (i = max_zn - 1; i >= 0; --
i) {
208 for (i = 0; i < max_zn; ++
i) {
210 for (
j = 0;
j < max_zn; ++
j) {
211 if (larger[i][
j] == 0)
216 winner[sum][
i] =
true;
219 if (sum < maxTracks_ && bugSameSectorPt0_ && sum > 0) {
221 winner[sum][
i] =
false;
230 for (i = 0; i < max_zn; ++
i) {
237 best_tracks.push_back(track);
241 best_tracks.back().set_winner(
o);
242 best_tracks.back().set_bx(best_tracks.back().First_BX());
253 const int max_zn = max_z * max_n;
254 const int max_hzn = max_h * max_zn;
258 const int num_h = extended_best_track_cands.size() / max_z;
261 typedef std::array<int, 3> segment_ref_t;
262 std::vector<std::vector<segment_ref_t> > segments(max_hzn,
263 std::vector<segment_ref_t>());
265 std::vector<std::vector<bool> > larger(max_hzn, std::vector<bool>(max_hzn,
false));
266 std::vector<std::vector<bool> > winner(max_hzn, std::vector<bool>(max_hzn,
false));
268 std::vector<bool> exists(max_hzn,
false);
269 std::vector<bool>
killed(max_hzn,
false);
270 std::vector<int> rank(max_hzn, 0);
271 std::vector<int> good_bx(max_hzn, 0);
274 for (
int h = 0;
h < num_h; ++
h) {
279 for (
int z = 0;
z < max_z; ++
z) {
281 const int ntracks = tracks.size();
284 for (
int n = 0;
n < ntracks; ++
n) {
285 const int hzn = (
h * max_z * max_n) + (
n * max_z) +
z;
288 cand_bx -= (
bx_ - delayBX);
290 rank.at(hzn) = track.
Rank();
294 for (
const auto& conv_hit : track.
Hits()) {
308 const segment_ref_t segment = {{conv_hit.PC_station() * 9 + conv_hit.PC_chamber(),
309 (conv_hit.PC_segment() % 2),
315 segments.at(hzn).push_back(segment);
322 int i = 0,
j = 0, ri = 0, rj = 0, sum = 0;
324 for (i = 0; i < max_hzn; ++
i) {
332 for (
j = i + 1;
j < max_hzn; ++
j) {
344 exists[
i] = (ri != 0);
348 for (i = 0; i < max_hzn - 1; ++
i) {
349 for (
j = i + 1;
j < max_hzn; ++
j) {
353 for (
const auto& isegment : segments.at(i)) {
354 for (
const auto& jsegment : segments.at(
j)) {
355 if (isegment == jsegment) {
361 if (shared_segs > 0) {
373 for (i = 0; i < max_hzn; ++
i) {
374 exists[
i] = exists[
i] & (!killed[
i]);
379 for (i = 0; i < max_hzn; ++
i) {
380 exists[
i] = exists[
i] & good_bx[
i];
383 bool anything_exists = (
std::find(exists.begin(), exists.end(), 1) != exists.end());
384 if (!anything_exists)
388 for (i = 0; i < max_hzn; ++
i) {
389 for (
j = 0;
j < max_hzn; ++
j) {
393 larger[
i][
j] = larger[
i][
j] | (!exists[
j]);
395 larger[
i][
j] =
false;
401 for (i = max_hzn - 1; i >= 0; --
i) {
403 if ((i % max_zn) == 0 && i != 0)
408 for (i = max_hzn - 1; i >= 0; --
i) {
410 if ((i % max_zn) == 0 && i != 0)
414 for (
j = 0;
j < max_hzn; ++
j) {
416 for (i = max_hzn - 1; i >= 0; --
i) {
418 if ((i % max_zn) == 0 && i != 0)
426 for (i = 0; i < max_hzn; ++
i) {
428 for (
j = 0;
j < max_hzn; ++
j) {
429 if (larger[i][
j] == 0)
434 winner[sum][
i] =
true;
437 if (sum < maxTracks_ && bugSameSectorPt0_ && sum > 0) {
439 winner[sum][
i] =
false;
447 int h = 0,
n = 0,
z = 0;
448 for (i = 0; i < max_hzn; ++
i) {
450 h = (i / max_z / max_n);
451 n = (i / max_z) % max_n;
456 best_tracks.push_back(track);
459 best_tracks.back().set_track_num(best_tracks.size() - 1);
460 best_tracks.back().set_winner(
o);
461 best_tracks.back().set_bx(best_tracks.back().Second_BX());
static char to_hex(unsigned int i)
l1t::EMTFTrackCollection EMTFTrackCollection
void process(const std::deque< EMTFTrackCollection > &extended_best_track_cands, EMTFTrackCollection &best_tracks) const
void cancel_multi_bx(const std::deque< EMTFTrackCollection > &extended_best_track_cands, EMTFTrackCollection &best_tracks) const
auto const & tracks
cannot be loose
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
static constexpr int verbose
void set_track_num(int bits)
void configure(int verbose, int endcap, int sector, int bx, int bxWindow, int maxRoadsPerZone, int maxTracks, bool useSecondEarliest, bool bugSameSectorPt0)
EMTFHitCollection Hits() const
constexpr int NUM_STATIONS
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void cancel_one_bx(const std::deque< EMTFTrackCollection > &extended_best_track_cands, EMTFTrackCollection &best_tracks) const