1 #ifndef L1Trigger_L1TTrackMatch_L1Clustering_HH 2 #define L1Trigger_L1TTrackMatch_L1Clustering_HH 37 for (
int etabin = 0; etabin < etaBins_; ++etabin) {
38 float my_pt = 0, previousbin_pt = 0;
39 float nextbin_pt = 0, nextbin2_pt = 0;
42 if (phislice[etabin].used)
44 my_pt = phislice[etabin].
pTtot;
48 if (etabin > 0 && !phislice[etabin - 1].used)
49 previousbin_pt = phislice[etabin - 1].
pTtot;
52 if (etabin < etaBins_ - 1 && !phislice[etabin + 1].used) {
53 nextbin_pt = phislice[etabin + 1].
pTtot;
54 if (etabin < etaBins_ - 2 && !phislice[etabin + 2].used) {
55 nextbin2_pt = phislice[etabin + 2].
pTtot;
59 if (my_pt < previousbin_pt || my_pt <= nextbin_pt) {
61 if (previousbin_pt > 0) {
62 clusters.push_back(phislice[etabin - 1]);
63 phislice[etabin - 1].
used =
true;
69 clusters.push_back(phislice[etabin]);
70 phislice[etabin].
used =
true;
71 if (previousbin_pt > 0) {
75 for (
unsigned int itrk = 0; itrk < phislice[etabin - 1].
trackidx.size(); itrk++)
79 if (my_pt >= nextbin2_pt && nextbin_pt > 0) {
83 for (
unsigned int itrk = 0; itrk < phislice[etabin + 1].
trackidx.size(); itrk++)
85 phislice[etabin + 1].
used =
true;
101 for (
unsigned int itrk = 0; itrk <
clusters[
m + 1].trackidx.size(); itrk++)
105 for (
int m1 =
m + 1; m1 <
nclust - 1; ++m1) {
121 bin.numtracks += ntrk;
122 bin.numtdtrks += ndtrk;
123 for (
unsigned int itrk = 0; itrk < trkidx.size(); itrk++)
124 bin.trackidx.push_back(trkidx[itrk]);
127 inline float DPhi(
float phi1,
float phi2) {
128 float x = phi1 - phi2;
141 for (
int phibin = 0; phibin < phiBins_; ++phibin) {
142 if (L1clusters[phibin].
empty())
147 return a.pTtot >
b.pTtot;
149 for (
unsigned int imax = 0; imax < L1clusters[phibin].size(); ++imax) {
150 if (L1clusters[phibin][imax].used)
152 float pt_current = L1clusters[phibin][imax].pTtot;
159 std::vector<unsigned int> trkidx1;
160 std::vector<unsigned int> trkidx2;
161 clusters.push_back(L1clusters[phibin][imax]);
163 L1clusters[phibin][imax].used =
true;
166 if (phibin == phiBins_ - 1)
168 std::vector<unsigned int> used_already;
169 for (
unsigned int icluster = 0; icluster < L1clusters[phibin + 1].size(); ++icluster) {
170 if (L1clusters[phibin + 1][icluster].used)
172 if (
std::abs(L1clusters[phibin + 1][icluster].
eta - L1clusters[phibin][imax].
eta) > 1.5 * etaStep_)
174 pt_next += L1clusters[phibin + 1][icluster].pTtot;
175 trk1 += L1clusters[phibin + 1][icluster].numtracks;
176 tdtrk1 += L1clusters[phibin + 1][icluster].numtdtrks;
177 for (
unsigned int itrk = 0; itrk < L1clusters[phibin + 1][icluster].trackidx.size(); itrk++)
178 trkidx1.push_back(L1clusters[phibin + 1][icluster].trackidx[itrk]);
179 used_already.push_back(icluster);
182 if (pt_next < pt_current) {
184 for (
unsigned int iused : used_already)
185 L1clusters[phibin + 1][iused].used =
true;
189 if (phibin == phiBins_ - 2) {
191 clusters[
clusters.size() - 1].phi = L1clusters[phibin + 1][used_already[0]].phi;
192 for (
unsigned int iused : used_already)
193 L1clusters[phibin + 1][iused].used =
true;
196 std::vector<int> used_already2;
197 for (
unsigned int icluster = 0; icluster < L1clusters[phibin + 2].size(); ++icluster) {
198 if (L1clusters[phibin + 2][icluster].used)
200 if (
std::abs(L1clusters[phibin + 2][icluster].
eta - L1clusters[phibin][imax].
eta) > 1.5 * etaStep_)
202 pt_next2 += L1clusters[phibin + 2][icluster].pTtot;
203 trk2 += L1clusters[phibin + 2][icluster].numtracks;
204 tdtrk2 += L1clusters[phibin + 2][icluster].numtdtrks;
205 for (
unsigned int itrk = 0; itrk < L1clusters[phibin + 2][icluster].trackidx.size(); itrk++)
206 trkidx2.push_back(L1clusters[phibin + 2][icluster].trackidx[itrk]);
207 used_already2.push_back(icluster);
209 if (pt_next2 < pt_next) {
210 std::vector<unsigned int> trkidx_both;
211 trkidx_both.reserve(trkidx1.size() + trkidx2.size());
212 trkidx_both.insert(trkidx_both.end(), trkidx1.begin(), trkidx1.end());
213 trkidx_both.insert(trkidx_both.end(), trkidx2.begin(), trkidx2.end());
215 clusters[
clusters.size() - 1].phi = L1clusters[phibin + 1][used_already[0]].phi;
216 for (
unsigned int iused : used_already)
217 L1clusters[phibin + 1][iused].used =
true;
218 for (
unsigned int iused : used_already2)
219 L1clusters[phibin + 2][iused].used =
true;
240 for (
unsigned int itrk = 0; itrk <
clusters[
n].trackidx.size(); itrk++)
242 for (
int m1 =
n; m1 <
nclust - 1; ++m1)
std::vector< EtaPhiBin > L2_clustering(std::vector< std::vector< EtaPhiBin >> &L1clusters, int phiBins_, float phiStep_, float etaStep_)
void Fill_L2Cluster(EtaPhiBin &bin, float pt, int ntrk, int ndtrk, std::vector< unsigned int > trkidx)
std::vector< unsigned int > trackidx
std::vector< EtaPhiBin > L1_clustering(EtaPhiBin *phislice, int etaBins_, float etaStep_)
Abs< T >::type abs(const T &t)
float DPhi(float phi1, float phi2)
std::vector< EtaPhiBin > clusters