134 {
135
136 constexpr std::array<int,19> calo_numbers{1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
137 constexpr std::array<int,12> fixed_r_numbers = {1,2,3,12,13,14,15,16,17,18,19,20};
138 constexpr std::array<double,12> fixed_r_vals = {1532.18, 1723.89, 1923.02, 2450.00, 2995.00, 3630.00, 3215.00,
139 3630.00, 2246.50, 2450.00, 2870.00, 3480.00
140 };
141 constexpr std::array<int, 7> fixed_z_numbers = {5,6,7,8,9,10,11};
142 constexpr std::array<double, 7> fixed_z_vals = {3790.03, 3983.68, 4195.84, 4461.25, 4869.50, 5424.50, 5905.00};
143 std::unordered_map<int, double> r_calo_dict;
144 std::unordered_map<int, double> z_calo_dict;
145 for(
size_t i=0;
i<fixed_r_vals.size();
i++) r_calo_dict[fixed_r_numbers[i]] = fixed_r_vals[i];
146 for(
size_t i=0;
i<fixed_z_numbers.size();
i++) z_calo_dict[fixed_z_numbers[i]] = fixed_z_vals[i];
147
148 std::vector<float> inputnn;
149 inputnn.assign(5430, 0.0);
150 std::vector<eflowRecCluster*> matchedClusters;
151 std::vector<eflowTrackClusterLink*>
links =
ptr->getClusterMatches();
152
155
156 const std::array<double, 2>
track{
ptr->getTrack()->eta(),
ptr->getTrack()->phi()};
157
158 for(auto *clink : links){
159 auto *
cell = clink->getCluster()->getCluster();
160 float clusterE =
cell->e()*1
e-3;
161 float clusterEta =
cell->eta();
162
163 if (clusterE < 0.0 || clusterE > 1e4f || std::abs(clusterEta) > 2.5) continue;
164
165 constexpr bool cutOnR = false;
166 if(cutOnR){
167 std::array<double, 2>
p{clink->getCluster()->getCluster()->eta(), clink->getCluster()->getCluster()->phi()};
168 double part1 =
p[0] -
track[0];
169 double part2 =
p[1] -
track[1];
170 while(part1 >
M_PI) part1 -= 2*
M_PI;
171 while(part1 < -
M_PI) part1 += 2*
M_PI;
172 while(part2 >
M_PI) part2 -= 2*
M_PI;
173 while(part2 < -
M_PI) part2 += 2*
M_PI;
174 double R = std::sqrt(part1 * part1 + part2*part2);
175 if(R >= 1.2) continue;
176 }
177
178 matchedClusters.push_back(clink->getCluster());
179 }
180
181 std::vector<std::array<double, 5>>
cells;
182
183 const eflowTrackCaloPoints& trackCaloPoints =
ptr->getTrackCaloPoints();
184 bool trk_bool_em[2] = {false,false};
187 double eta_ctr;
188 double phi_ctr;
189 for(
int i =0;
i<2;
i++) {
190 trk_bool_em[
i] = std::abs(trk_em_eta[i]) < 2.5 && std::abs(trk_em_phi[i]) <=
M_PI;
191 }
192 int nProj_em = (
int)trk_bool_em[0] + (
int)trk_bool_em[1];
193
194 if(nProj_em ==1) {
195 eta_ctr = trk_bool_em[0] ? trk_em_eta[0] : trk_em_eta[1];
196 phi_ctr = trk_bool_em[0] ? trk_em_phi[0] : trk_em_phi[1];
197 } else if(nProj_em==2) {
198 eta_ctr = (trk_em_eta[0] + trk_em_eta[1]) / 2.0;
199 phi_ctr = (trk_em_phi[0] + trk_em_phi[1]) / 2.0;
200 } else {
201 eta_ctr =
ptr->getTrack()->eta();
202 phi_ctr =
ptr->getTrack()->phi();
203 }
204
205
206
207 for(auto *cptr : matchedClusters){
208 auto *clustlink = cptr->getCluster();
209
210 for(auto it_cell = clustlink->cell_begin(); it_cell != clustlink->cell_end(); it_cell++){
211 const CaloCell*
cell = (*it_cell);
212 float cellE =
cell->e()*(it_cell.weight())*1e-3f;
213 if(cellE < 0.005) continue;
214 const auto *theDDE=it_cell->caloDDE();
215 double cx=theDDE->x();
216 double cy=theDDE->y();
217
218 cells.emplace_back( std::array<double, 5> { cellE,
219 theDDE->eta() - eta_ctr,
220 theDDE->phi() - phi_ctr,
221 std::hypot(cx,cy),
222 0.0 } );
223 }
224 }
225
226
227 std::vector<bool> trk_bool(calo_numbers.size(), false);
228 std::vector<std::array<double,4>> trk_full(calo_numbers.size());
229 for(size_t j=0; j<phitotal.size(); j++) {
230 int cnum = calo_numbers[j];
231 double eta = etatotal[j];
232 double phi = phitotal[j];
233 if(std::abs(
eta) < 2.5 && std::abs(
phi) <=
M_PI) {
234 trk_bool[j] = true;
235 trk_full[j][0] =
eta;
236 trk_full[j][1] =
phi;
237 trk_full[j][3] = cnum;
238 double rPerp =-99999;
239 if(auto itr = r_calo_dict.find(cnum); itr != r_calo_dict.end()) rPerp = itr->second;
240 else if(auto itr = z_calo_dict.find(cnum); itr != z_calo_dict.end())
241 {
242 double z = itr->second;
244 double aeta = std::abs(
eta);
245 rPerp =
z*2.*std::exp(aeta)/(std::exp(2.0*aeta)-1.0);
246 }else rPerp =0.0;
247 } else {
248 throw std::runtime_error("Calo sample num not found in dicts..");
249 }
250 trk_full[j][2] = rPerp;
251 } else {
252 trk_full[j].fill(0.0);
253 }
254 }
255 double trackP = std::abs(1. /
ptr->getTrack()->qOverP()) * 1
e-3;
256 int trk_proj_num = std::accumulate(trk_bool.begin(), trk_bool.end(), 0);
257 if(trk_proj_num ==0) {
258 trk_proj_num =1;
259 std::array<double,5> trk_arr{};
260
261 trk_arr[0] = trackP;
262 trk_arr[1] =
ptr->getTrack()->eta() - eta_ctr;
263 trk_arr[2] =
ptr->getTrack()->phi() - phi_ctr;
264 trk_arr[3] = 1532.18;
265 trk_arr[4] = 1.;
266
267 cells.emplace_back(trk_arr);
268 } else {
269 for(
size_t i =0;
i<calo_numbers.size();
i++) {
270 if(!trk_bool[i]) continue;
271 std::array<double,5> trk_arr{};
272 trk_arr[0]= trackP/
double(trk_proj_num);
273 trk_arr[1]= trk_full[
i][0] - eta_ctr;
274 trk_arr[2]= trk_full[
i][1] - phi_ctr;
275 trk_arr[3]= trk_full[
i][2];
276 trk_arr[4]= 1.;
277
278 cells.emplace_back(trk_arr);
279 }
280 }
281
283 for(auto &in : cells){
284 std::copy(in.begin(), in.end(), inputnn.begin() + index);
286 if(index >= static_cast<int>(inputnn.size()-4)) {
288 break;
289 }
290 }
291
292
294
297 return predictedEnergy;
298
299}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
double getPhi(eflowCalo::LAYER layer) const
double getEta(eflowCalo::LAYER layer) const
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)