CMS 3D CMS Logo

SAMuonCleaner.cc
Go to the documentation of this file.
2 
4  int rank1 = source.hwQual();
5  int rank2 = other.hwQual();
6  bool keep = true;
7  if ((eq && rank1 <= rank2) || ((!eq) && rank1 < rank2))
8  keep = false;
10  for (const auto& s1 : source.stubs()) {
11  bool ok = true;
12  for (const auto& s2 : other.stubs()) {
13  if ((*s1) == (*s2) && (!keep))
14  ok = false;
15  }
16  if (ok) {
17  stubs.push_back(s1);
18  }
19  }
20  source.setStubs(stubs);
21 }
22 
24  bool keep = false;
26  for (const auto& s1 : source.stubs()) {
27  bool ok = true;
28  for (const auto& s2 : other.stubs()) {
29  if ((*s1) == (*s2) && (!keep))
30  ok = false;
31  }
32  if (ok) {
33  stubs.push_back(s1);
34  }
35  }
36  source.setStubs(stubs);
37 }
38 
39 std::vector<l1t::SAMuon> SAMuonCleaner::cleanTF(const std::vector<l1t::SAMuon>& tfMuons) {
40  std::vector<l1t::SAMuon> out;
41  for (unsigned int i = 0; i < tfMuons.size(); ++i) {
42  l1t::SAMuon source = tfMuons[i];
43  for (unsigned int j = 0; j < tfMuons.size(); ++j) {
44  if (i == j)
45  continue;
46  overlapCleanTrack(source, tfMuons[j], false);
47  }
48  if (source.stubs().size() > 1)
49  out.push_back(source);
50  }
51  return out;
52 }
53 
54 std::vector<l1t::SAMuon> SAMuonCleaner::interTFClean(const std::vector<l1t::SAMuon>& bmtf,
55  const std::vector<l1t::SAMuon>& omtf,
56  const std::vector<l1t::SAMuon>& emtf) {
57  std::vector<l1t::SAMuon> out = emtf;
58  for (unsigned int i = 0; i < omtf.size(); ++i) {
60  for (const auto& other : emtf) {
62  }
63  if (source.stubs().size() > 1)
64  out.push_back(source);
65  }
66  for (unsigned int i = 0; i < bmtf.size(); ++i) {
68  for (const auto& other : omtf) {
70  }
71  if (source.stubs().size() > 1)
72  out.push_back(source);
73  }
74  return out;
75 }
76 
77 void SAMuonCleaner::swap(std::vector<l1t::SAMuon>& list, int i, int j) {
78  const l1t::SAMuon& track1 = list[i];
79  const l1t::SAMuon& track2 = list[j];
80 
81  int pt1 = track1.pt();
82  int pt2 = track2.pt();
83  bool swap = false;
84  if (pt1 > pt2)
85  swap = false;
86  else
87  swap = true;
88 
89  if (swap) {
90  l1t::SAMuon tmp = list[i];
91  list[i] = list[j];
92  list[j] = tmp;
93  }
94 }
95 
96 void SAMuonCleaner::sort(std::vector<l1t::SAMuon>& in) {
97  l1t::SAMuon nullTrack;
98  nullTrack.setP4(reco::Candidate::LorentzVector(0, 0, 0, 0.000001));
99  while (in.size() < 32)
100  in.push_back(nullTrack);
101 
102  for (uint iteration = 0; iteration < 16; ++iteration) {
103  for (uint i = 0; i < 32; i = i + 2) {
104  swap(in, i, i + 1);
105  }
106  for (uint i = 1; i < 31; i = i + 2) {
107  swap(in, i, i + 1);
108  }
109  }
110 
111  std::vector<l1t::SAMuon> out;
112  for (const auto& track : in) {
113  if (!track.stubs().empty() && out.size() < 12)
114  out.push_back(track);
115  }
116  in = out;
117 }
118 
119 std::vector<l1t::SAMuon> SAMuonCleaner::cleanTFMuons(const std::vector<l1t::SAMuon>& muons) {
120  std::vector<l1t::SAMuon> out;
121 
122  //split into collections
123  std::vector<l1t::SAMuon> bmtf;
124  std::vector<l1t::SAMuon> omtf_pos;
125  std::vector<l1t::SAMuon> emtf_pos;
126  std::vector<l1t::SAMuon> omtf_neg;
127  std::vector<l1t::SAMuon> emtf_neg;
128 
129  for (const auto& mu : muons) {
130  if (mu.tfType() == l1t::tftype::bmtf) {
131  bmtf.push_back(mu);
132  } else if (mu.tfType() == l1t::tftype::omtf_pos) {
133  omtf_pos.push_back(mu);
134  } else if (mu.tfType() == l1t::tftype::emtf_pos) {
135  emtf_pos.push_back(mu);
136  } else if (mu.tfType() == l1t::tftype::omtf_neg) {
137  omtf_neg.push_back(mu);
138  } else if (mu.tfType() == l1t::tftype::emtf_neg) {
139  emtf_neg.push_back(mu);
140  }
141  }
142 
143  std::vector<l1t::SAMuon> omtf_cleaned = cleanTF(omtf_pos);
144  std::vector<l1t::SAMuon> omtf_neg_cleaned = cleanTF(omtf_neg);
145  omtf_cleaned.insert(omtf_cleaned.end(), omtf_neg_cleaned.begin(), omtf_neg_cleaned.end());
146  sort(omtf_cleaned);
147 
148  std::vector<l1t::SAMuon> emtf_cleaned = cleanTF(emtf_pos);
149  std::vector<l1t::SAMuon> emtf_neg_cleaned = cleanTF(emtf_neg);
150  emtf_cleaned.insert(emtf_cleaned.end(), emtf_neg_cleaned.begin(), emtf_neg_cleaned.end());
151  sort(emtf_cleaned);
152 
153  std::vector<l1t::SAMuon> cleaned = interTFClean(bmtf, omtf_cleaned, emtf_cleaned);
154  sort(cleaned);
155  return cleaned;
156 }
void swap(std::vector< l1t::SAMuon > &, int i, int j)
double pt() const final
transverse momentum
void sort(std::vector< l1t::SAMuon > &in)
Definition: Event.h:15
std::vector< l1t::SAMuon > interTFClean(const std::vector< l1t::SAMuon > &bmtf, const std::vector< l1t::SAMuon > &omtf, const std::vector< l1t::SAMuon > &emtf)
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
std::vector< edm::Ref< MuonStubCollection > > MuonStubRefVector
Definition: MuonStub.h:44
std::vector< l1t::SAMuon > cleanTF(const std::vector< l1t::SAMuon > &tfMuons)
void overlapCleanTrack(l1t::SAMuon &source, const l1t::SAMuon &other, bool eq)
Definition: SAMuonCleaner.cc:3
void overlapCleanTrackInter(l1t::SAMuon &source, const l1t::SAMuon &other)
std::vector< l1t::SAMuon > cleanTFMuons(const std::vector< l1t::SAMuon > &muons)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
tmp
align.sh
Definition: createJobs.py:716
static std::string const source
Definition: EdmProvDump.cc:49
void setP4(const LorentzVector &p4) final
set 4-momentum