9 std::pair<std::vector<l1t::KMTFTrack>, std::vector<l1t::KMTFTrack> >
KMTF::process(
11 std::vector<l1t::KMTFTrack> pretracksP2;
12 std::vector<l1t::KMTFTrack> pretracksP3;
13 std::vector<l1t::KMTFTrack> pretracksP4;
14 std::vector<l1t::KMTFTrack> pretracksD2;
15 std::vector<l1t::KMTFTrack> pretracksD3;
16 std::vector<l1t::KMTFTrack> pretracksD4;
27 for (
const auto& stub : stubsAll) {
28 if (stub->bxNum() !=
bx || stub->id() > 3)
30 if (!stub->isBarrel())
33 if (stub->depthRegion() == 4) {
35 stubs4.push_back(stub);
39 if (stub->depthRegion() == 3) {
41 stubs3.push_back(stub);
45 if (stub->depthRegion() == 2) {
47 stubs2.push_back(stub);
51 if (stub->depthRegion() == 1) {
53 stubs1.push_back(stub);
61 if (stubs4.size() > 1) {
64 if (stubs3.size() > 1) {
67 if (stubs2.size() > 1) {
70 if (stubs1.size() > 1) {
74 bool pre_patterns = (
verbose_ > 1) && ((Nstubs4 + Nstubs3 + Nstubs2 + Nstubs1) > 2);
77 for (
unsigned int i = 0;
i < 32; ++
i) {
80 bool patterns = pre_patterns && ((
i < Nstubs4) || (
i < Nstubs3) || (
i << Nstubs2));
85 edm::LogInfo(
"KMTF") << stubs4[0]->coord1() <<
" " << stubs4[0]->coord2() <<
" " << stubs4[0]->quality() <<
" " 86 <<
" 1 " << stubs4[0]->kmtf_address() <<
" 0 " << std::flush;
91 for (
const auto&
s : stubs3) {
92 edm::LogInfo(
"KMTF") <<
"" <<
s->coord1() <<
" " <<
s->coord2() <<
" " <<
s->quality() <<
" 1 " 93 <<
s->kmtf_address() <<
" 0 " << std::flush;
96 for (
unsigned int j = stubs3.size();
j < 32; ++
j) {
100 for (
unsigned int j = stubs3.size();
j < 32; ++
j) {
103 for (
const auto&
s : stubs3) {
104 edm::LogInfo(
"KMTF") <<
"" <<
s->coord1() <<
" " <<
s->coord2() <<
" " <<
s->quality() <<
" 1 " 105 <<
s->kmtf_address() <<
" 0 " << std::flush;
110 for (
const auto&
s : stubs2) {
111 edm::LogInfo(
"KMTF") <<
"" <<
s->coord1() <<
" " <<
s->coord2() <<
" " <<
s->quality() <<
" 1 " 112 <<
s->kmtf_address() <<
" 0 " << std::flush;
115 for (
unsigned int j = stubs2.size();
j < 32; ++
j) {
119 for (
unsigned int j = stubs2.size();
j < 32; ++
j) {
122 for (
const auto&
s : stubs2) {
123 edm::LogInfo(
"KMTF") <<
s->coord1() <<
" " <<
s->coord2() <<
" " <<
s->quality() <<
" 1 " <<
s->kmtf_address()
124 <<
" 0 " << std::flush;
128 for (
const auto&
s : stubs1) {
129 edm::LogInfo(
"KMTF") <<
s->coord1() <<
" " <<
s->coord2() <<
" " <<
s->quality() <<
" 1 " <<
s->kmtf_address()
130 <<
" 0 " << std::flush;
133 for (
unsigned int j = stubs1.size();
j < 32; ++
j) {
137 for (
unsigned int j = stubs1.size();
j < 32; ++
j) {
140 for (
const auto&
s : stubs1) {
141 edm::LogInfo(
"KMTF") <<
s->coord1() <<
" " <<
s->coord2() <<
" " <<
s->quality() <<
" 1 " <<
s->kmtf_address()
142 <<
" 0 " << std::flush;
151 stubs_proc.insert(stubs_proc.end(), stubs3.begin(), stubs3.end());
153 stubs_proc.insert(stubs_proc.end(), stubs2.begin(), stubs2.end());
155 stubs_proc.insert(stubs_proc.end(), stubs1.begin(), stubs1.end());
156 std::pair<l1t::KMTFTrack, l1t::KMTFTrack>
tracks =
trackMaker_->chain(stubs4[0], stubs_proc);
157 if (
tracks.first.id() & 0x1)
158 pretracksP4.push_back(
tracks.first);
159 if (
tracks.second.id() & 0x2)
160 pretracksD4.push_back(
tracks.second);
162 if (
tracks.first.id() & 0x1)
164 <<
tracks.first.ptPrompt() <<
" " <<
tracks.first.phiAtMuon() / (1 << 5) <<
" " 165 <<
tracks.first.coarseEta() <<
" " <<
int(
tracks.first.dxy() * ap_ufixed<8, 1>(1.606))
166 <<
" " <<
tracks.first.rankPrompt() <<
" " << std::flush;
170 if (
tracks.second.id() & 0x2)
171 edm::LogInfo(
"KMTF") <<
"1 " << (
tracks.second.curvatureAtVertex() < 0 ? 1 : 0) <<
" " 172 <<
tracks.second.ptDisplaced() <<
" " <<
tracks.second.phiAtMuon() / (1 << 5) <<
" " 173 <<
tracks.second.coarseEta() <<
" " <<
int(
tracks.second.dxy() * ap_ufixed<8, 1>(1.606))
174 <<
" " <<
tracks.second.rankDisp() <<
" " << std::flush;
179 }
else if (patterns) {
187 stubs_proc.insert(stubs_proc.end(), stubs2.begin(), stubs2.end());
189 stubs_proc.insert(stubs_proc.end(), stubs1.begin(), stubs1.end());
190 std::pair<l1t::KMTFTrack, l1t::KMTFTrack>
tracks =
trackMaker_->chain(stubs3[0], stubs_proc);
191 if (
tracks.first.id() & 0x1)
192 pretracksP3.push_back(
tracks.first);
193 if (
tracks.second.id() & 0x2)
194 pretracksD3.push_back(
tracks.second);
196 if (
tracks.first.id() & 0x1)
198 <<
tracks.first.ptPrompt() <<
" " <<
tracks.first.phiAtMuon() / (1 << 5) <<
" " 199 <<
tracks.first.coarseEta() <<
" " <<
int(
tracks.first.dxy() * ap_ufixed<8, 1>(1.606))
200 <<
" " <<
tracks.first.rankPrompt() <<
" " << std::flush;
204 if (
tracks.second.id() & 0x2)
205 edm::LogInfo(
"KMTF") <<
"1 " << (
tracks.second.curvatureAtVertex() < 0 ? 1 : 0) <<
" " 206 <<
tracks.second.ptDisplaced() <<
" " <<
tracks.second.phiAtMuon() / (1 << 5) <<
" " 207 <<
tracks.second.coarseEta() <<
" " <<
int(
tracks.second.dxy() * ap_ufixed<8, 1>(1.606))
208 <<
" " <<
tracks.second.rankDisp() <<
" " << std::flush;
213 }
else if (patterns) {
220 stubs_proc.insert(stubs_proc.end(), stubs1.begin(), stubs1.end());
221 std::pair<l1t::KMTFTrack, l1t::KMTFTrack>
tracks =
trackMaker_->chain(stubs2[0], stubs_proc);
222 if (
tracks.first.id() & 0x1)
223 pretracksP2.push_back(
tracks.first);
224 if (
tracks.second.id() & 0x2)
225 pretracksD2.push_back(
tracks.second);
227 if (
tracks.first.id() & 0x1)
229 <<
tracks.first.ptPrompt() <<
" " <<
tracks.first.phiAtMuon() / (1 << 5) <<
" " 230 <<
tracks.first.coarseEta() <<
" " <<
int(
tracks.first.dxy() * ap_ufixed<8, 1>(1.606))
231 <<
" " <<
tracks.first.rankPrompt() <<
" " << std::flush;
235 if (
tracks.second.id() & 0x2)
236 edm::LogInfo(
"KMTF") <<
"1 " << (
tracks.second.curvatureAtVertex() < 0 ? 1 : 0) <<
" " 237 <<
tracks.second.ptDisplaced() <<
" " <<
tracks.second.phiAtMuon() / (1 << 5) <<
" " 238 <<
tracks.second.coarseEta() <<
" " <<
int(
tracks.second.dxy() * ap_ufixed<8, 1>(1.606))
239 <<
" " <<
tracks.second.rankDisp();
243 }
else if (patterns) {
248 if (stubs4.size() > 1) {
250 stubs4.erase(stubs4.begin(), stubs4.begin() + 1);
251 stubs4.push_back(
s4);
253 if (stubs3.size() > 1) {
255 stubs3.erase(stubs3.begin(), stubs3.begin() + 1);
256 stubs3.push_back(s3);
258 if (stubs2.size() > 1) {
260 stubs2.erase(stubs2.begin(), stubs2.begin() + 1);
261 stubs2.push_back(s2);
263 if (stubs1.size() > 1) {
265 stubs1.erase(stubs1.begin(), stubs1.begin() + 1);
266 stubs1.push_back(s1);
270 std::vector<l1t::KMTFTrack> cleanedPrompt =
cleanRegion(pretracksP2, pretracksP3, pretracksP4,
true);
271 std::vector<l1t::KMTFTrack> cleanedDisp =
cleanRegion(pretracksD2, pretracksD3, pretracksD4,
false);
273 edm::LogInfo(
"KMTF") <<
"Prompt pretracks 2=" <<
int(pretracksP2.size()) <<
" 3=" <<
int(pretracksP3.size())
274 <<
" 4=" <<
int(pretracksP4.size());
275 edm::LogInfo(
"KMTF") <<
"Cleaned Tracks Prompt=" << (
int)cleanedPrompt.size()
276 <<
" Displaced=" << (
int)cleanedDisp.size();
279 if (
verbose_ && !cleanedPrompt.empty())
280 for (
const auto&
t : cleanedPrompt)
282 edm::LogInfo(
"KMTF") <<
"final cleaned sector track from all chains track pt=" <<
t.ptPrompt()
283 <<
" pattern=" <<
t.hitPattern() <<
" rank=" <<
t.rankPrompt();
285 sort(cleanedPrompt,
true);
286 sort(cleanedDisp,
false);
288 if (
verbose_ && !cleanedPrompt.empty())
289 for (
const auto&
t : cleanedPrompt)
291 edm::LogInfo(
"KMTF") <<
"final sorted sector track from all chains track pt=" <<
t.ptPrompt()
292 <<
" pattern=" <<
t.hitPattern() <<
" rank=" <<
t.rankPrompt();
294 return std::make_pair(cleanedPrompt, cleanedDisp);
306 else if (
id1 != 0 &&
id2 != 0) {
307 if (eq && rank1 <= rank2)
309 if ((!eq) && rank1 < rank2)
314 for (
const auto& s1 :
source.stubs()) {
316 for (
const auto& s2 :
other.stubs()) {
317 if ((*s1) == (*s2) && (!
keep))
330 const std::vector<l1t::KMTFTrack>& tracks3,
331 const std::vector<l1t::KMTFTrack>& tracks4,
333 std::vector<l1t::KMTFTrack> cleaned2;
334 for (
unsigned int i = 0;
i < tracks2.size(); ++
i) {
337 for (
unsigned int j = 0;
j < tracks2.size(); ++
j) {
342 for (
unsigned int j = 0;
j < tracks3.size(); ++
j) {
345 for (
unsigned int j = 0;
j < tracks4.size(); ++
j) {
349 if (
source.stubs().size() > 1)
350 cleaned2.push_back(
source);
353 std::vector<l1t::KMTFTrack> cleaned3;
354 for (
unsigned int i = 0;
i < tracks3.size(); ++
i) {
357 for (
unsigned int j = 0;
j < tracks3.size(); ++
j) {
362 for (
unsigned int j = 0;
j < tracks2.size(); ++
j) {
365 for (
unsigned int j = 0;
j < tracks4.size(); ++
j) {
369 if (
source.stubs().size() > 1)
370 cleaned3.push_back(
source);
373 std::vector<l1t::KMTFTrack> cleaned4;
374 for (
unsigned int i = 0;
i < tracks4.size(); ++
i) {
377 for (
unsigned int j = 0;
j < tracks4.size(); ++
j) {
382 for (
unsigned int j = 0;
j < tracks3.size(); ++
j) {
385 for (
unsigned int j = 0;
j < tracks2.size(); ++
j) {
389 if (
source.stubs().size() > 1)
390 cleaned4.push_back(
source);
394 std::vector<l1t::KMTFTrack>
output;
396 for (
uint i = 0;
i < max234; ++
i) {
397 if (
i < cleaned2.size())
399 if (
i < cleaned3.size())
401 if (
i < cleaned4.size())
410 int id1 = track1.
id();
411 int id2 = track2.
id();
446 while (
in.size() < 32)
447 in.push_back(nullTrack);
450 for (
uint i = 0;
i < 32;
i =
i + 2) {
453 for (
uint i = 1;
i < 31;
i =
i + 2) {
458 std::vector<l1t::KMTFTrack>
out;
void sort(std::vector< l1t::KMTFTrack > &in, bool vertex)
void swap(std::vector< l1t::KMTFTrack > &list, int i, int j, bool vertex)
void setRank(int rank, bool vertex)
std::unique_ptr< KMTFCore > trackMaker_
std::vector< edm::Ref< MuonStubCollection > > MuonStubRefVector
std::pair< std::vector< l1t::KMTFTrack >, std::vector< l1t::KMTFTrack > > process(const l1t::MuonStubRefVector &stubsAll, int bx, unsigned int MAXN)
void overlapCleanTrack(l1t::KMTFTrack &source, const l1t::KMTFTrack &other, bool eq, bool vertex)
void setIDFlag(bool passPrompt, bool passDisp)
Log< level::Info, false > LogInfo
KMTF(int verbose, const edm::ParameterSet &iConfig)
std::vector< l1t::KMTFTrack > cleanRegion(const std::vector< l1t::KMTFTrack > &tracks2, const std::vector< l1t::KMTFTrack > &tracks3, const std::vector< l1t::KMTFTrack > &tracks4, bool vertex)
void setPtEtaPhi(double pt, double eta, double phi)
static std::string const source