81 std::vector<towersStrct>& input_towers_temp,
82 std::vector<towersStrct>& cluster_towers_temp,
87 if (input_towers_temp.at(0).energy > seed) {
90 tempstructC.
cluster_E = input_towers_temp.at(0).energy;
91 tempstructC.
cluster_seed = input_towers_temp.at(0).energy;
95 cluster_towers_temp.push_back(input_towers_temp.at(0));
101 input_towers_temp.erase(input_towers_temp.begin());
102 for (
int tit = 0; tit < (int)cluster_towers_temp.size(); tit++) {
104 int iEtaTwr = cluster_towers_temp.at(tit).cellIDx;
105 int iPhiTwr = cluster_towers_temp.at(tit).cellIDy;
106 int iLTwr = cluster_towers_temp.at(tit).cellIDz;
107 for (
int ait = 0; ait < (int)input_towers_temp.size(); ait++) {
108 int iEtaTwrAgg = input_towers_temp.at(ait).cellIDx;
109 int iPhiTwrAgg = input_towers_temp.at(ait).cellIDy;
110 int iLTwrAgg = input_towers_temp.at(ait).cellIDz;
112 int deltaL = TMath::Abs(iLTwrAgg - iLTwr);
113 int deltaPhi = TMath::Abs(iPhiTwrAgg - iPhiTwr);
114 int deltaEta = TMath::Abs(iEtaTwrAgg - iEtaTwr);
115 bool neighbor = (deltaL + deltaPhi + deltaEta == 1);
116 bool corner2D = (deltaL == 0 && deltaPhi == 1 && deltaEta == 1) ||
117 (deltaL == 1 && deltaPhi == 0 && deltaEta == 1) ||
118 (deltaL == 1 && deltaPhi == 1 && deltaEta == 0);
120 if (neighbor || corner2D) {
124 if (input_towers_temp.at(ait).energy >= (cluster_towers_temp.at(tit).energy + aggMargin))
126 tempstructC.
cluster_E += input_towers_temp.at(ait).energy;
128 cluster_towers_temp.push_back(input_towers_temp.at(ait));
135 input_towers_temp.erase(input_towers_temp.begin() + ait);
146 float cluster_E_calc,
float weight0) {
147 static float returnVariables[8];
149 std::vector<float> w_i;
154 vecTwr = {0., 0., 0.};
156 for (
int cellI = 0; cellI < (int)cluster_towers.size(); cellI++) {
157 w_i.push_back(TMath::Max(
158 (
float)0, (
float)(w_0 + TMath::Log(cluster_towers.at(cellI).energy / cluster_E_calc))));
159 w_tot += w_i.at(cellI);
160 if (w_i.at(cellI) > 0) {
161 vecTwrTmp = TVector3(cluster_towers.at(cellI).posx, cluster_towers.at(cellI).posy,
162 cluster_towers.at(cellI).posz);
163 vecTwr += w_i.at(cellI) * vecTwrTmp;
167 returnVariables[2] = vecTwr.Eta();
170 vecTwr *= 1. / w_tot;
172 returnVariables[4] = vecTwr.X();
173 returnVariables[5] = vecTwr.Y();
174 returnVariables[6] = vecTwr.Z();
177 float delta_phi_phi[4] = {0};
178 float delta_eta_eta[4] = {0};
179 float delta_eta_phi[4] = {0};
180 float dispersion = 0;
182 for (
int cellI = 0; cellI < (int)cluster_towers.size(); cellI++) {
183 int iphi = cluster_towers.at(cellI).cellIDy;
184 int ieta = cluster_towers.at(cellI).cellIDx;
185 delta_phi_phi[1] += (w_i.at(cellI) * iphi * iphi) / w_tot;
186 delta_phi_phi[2] += (w_i.at(cellI) * iphi) / w_tot;
187 delta_phi_phi[3] += (w_i.at(cellI) * iphi) / w_tot;
189 delta_eta_eta[1] += (w_i.at(cellI) * ieta * ieta) / w_tot;
190 delta_eta_eta[2] += (w_i.at(cellI) * ieta) / w_tot;
191 delta_eta_eta[3] += (w_i.at(cellI) * ieta) / w_tot;
193 delta_eta_phi[1] += (w_i.at(cellI) * ieta * iphi) / w_tot;
194 delta_eta_phi[2] += (w_i.at(cellI) * iphi) / w_tot;
195 delta_eta_phi[3] += (w_i.at(cellI) * ieta) / w_tot;
197 vecTwrTmp = TVector3(cluster_towers.at(cellI).posx, cluster_towers.at(cellI).posy,
198 cluster_towers.at(cellI).posz);
200 vecTwr *= std::abs(vecTwrTmp.Z() / vecTwr.Z());
201 float dx2 = pow(vecTwrTmp.X() - vecTwr.X(), 2);
202 float dy2 = pow(vecTwrTmp.Y() - vecTwr.Y(), 2);
203 float dz2 = pow(vecTwrTmp.Z() - vecTwr.Z(), 2);
204 dispersion += (w_i.at(cellI) * (dx2 + dy2 + dz2)) / w_tot;
206 returnVariables[7] = dispersion;
207 delta_phi_phi[0] = delta_phi_phi[1] - (delta_phi_phi[2] * delta_phi_phi[3]);
208 delta_eta_eta[0] = delta_eta_eta[1] - (delta_eta_eta[2] * delta_eta_eta[3]);
209 delta_eta_phi[0] = delta_eta_phi[1] - (delta_eta_phi[2] * delta_eta_phi[3]);
211 float calcM02 = 0.5 * (delta_phi_phi[0] + delta_eta_eta[0]) +
212 TMath::Sqrt(0.25 * TMath::Power((delta_phi_phi[0] - delta_eta_eta[0]), 2) +
213 TMath::Power(delta_eta_phi[0], 2));
214 float calcM20 = 0.5 * (delta_phi_phi[0] + delta_eta_eta[0]) -
215 TMath::Sqrt(0.25 * TMath::Power((delta_phi_phi[0] - delta_eta_eta[0]), 2) +
216 TMath::Power(delta_eta_phi[0], 2));
218 returnVariables[0] = calcM02;
219 returnVariables[1] = calcM20;
220 return returnVariables;
clustersStrct findMACluster(float seed, float, std::vector< towersStrct > &input_towers_temp, std::vector< towersStrct > &cluster_towers_temp, float aggMargin=1.0)
Definition clusterizer_MA.h:78