66 numberOfEventsPerLumiblockFront = eventInfo->lumiBlock();
67 numberOfEventsPerLumiblockMiddle = eventInfo->lumiBlock();
68 numberOfEventsPerLumiblockEnd = eventInfo->lumiBlock();
71 const unsigned int bcid = eventInfo->bcid();
74 ATH_MSG_ERROR(
"Unable to retrieve BunchCrossing conditions object (SiT)" );
79 enum { FRONT, MIDDLE, END, NPOS } position = NPOS;
83 fill(
"AFPSiLayerTool", bcidAll);
88 fill(
"AFPSiLayerTool", bcidFront);
89 fill(
"AFPSiLayerTool", numberOfEventsPerLumiblockFront);
97 fill(
"AFPSiLayerTool", bcidMiddle);
98 fill(
"AFPSiLayerTool", numberOfEventsPerLumiblockMiddle);
104 fill(
"AFPSiLayerTool", bcidEnd);
105 fill(
"AFPSiLayerTool", numberOfEventsPerLumiblockEnd);
145 lb = eventInfo->lumiBlock();
146 lbEvents = eventInfo->lumiBlock();
149 if (muPerBX == 0.0) {
150 ATH_MSG_DEBUG(
"AverageInteractionsPerCrossing is 0, forcing to 1.0");
153 fill(
"AFPSiLayerTool",
lb, muPerBX);
154 fill(
"AFPSiLayerTool", lbEvents);
158 if(! afpHitContainer.
isValid())
161 return StatusCode::SUCCESS;
166 nSiHits = afpHitContainer->size();
167 fill(
"AFPSiLayerTool",
lb, nSiHits);
169 int eventsInStations[4] = {};
170 int numberOfHitsPerPlane[4][4] = {};
174 lb = eventInfo->lumiBlock();
175 lbHits = eventInfo->lumiBlock();
176 lbEventsStations = eventInfo->lumiBlock();
177 lbEventsStationsAll = eventInfo->lumiBlock();
178 pixelRowIDChip = hitsItr->pixelRowIDChip();
179 pixelColIDChip = hitsItr->pixelColIDChip();
183 if (hitsItr->stationID()<4 && hitsItr->stationID()>=0 && hitsItr->pixelLayerID()<4 && hitsItr->pixelLayerID()>=0)
185 ++eventsInStations[hitsItr->stationID()];
192 planeHits = hitsItr->pixelLayerID();
195 ++numberOfHitsPerPlane[hitsItr->stationID()][hitsItr->pixelLayerID()];
196 numberOfHitsPerStation = hitsItr->stationID();
197 fill(
"AFPSiLayerTool", numberOfHitsPerStation);
199 fill(
"AFPSiLayerTool", lbHits);
201 else ATH_MSG_WARNING(
"Unrecognised station index: " << hitsItr->stationID());
209 lbhitsPerPlaneProfile = eventInfo->lumiBlock();
210 for(
int i_station = 0; i_station < 4; i_station++)
211 for(
int j_layer = 0; j_layer < 4; j_layer++)
213 hitsPerPlaneProfile = numberOfHitsPerPlane[i_station][j_layer]/muPerBX;
215 if (muPerBX != 0.0) {
216 hitsPerPlaneEventsMu = numberOfHitsPerPlane[i_station][j_layer] / muPerBX;
218 hitPerPlaneEventMuIndex = reorganizePlanes(i_station, j_layer);
219 fill(
"AFPSiLayerTool", hitPerPlaneEventMuIndex, hitsPerPlaneEventsMu);
222 bool noEventsInStations =
true;
223 for(
int i=0; i<4; i++)
225 if(eventsInStations[i]>0) {
228 eventsPerStation = i * 4;
229 fill(
"AFPSiLayerTool", eventsPerStation);
231 fill(
"AFPSiLayerTool", eventsPerStation);
233 fill(
"AFPSiLayerTool", eventsPerStation);
235 fill(
"AFPSiLayerTool", eventsPerStation);
237 noEventsInStations =
false;
240 if(!noEventsInStations)
242 fill(
"AFPSiLayerTool", lbEventsStationsAll);
250 unsigned int totalTracksAll[4] = {};
251 unsigned int totalTracksFront[4] = {};
252 unsigned int totalTracksMiddle[4] = {};
253 unsigned int totalTracksEnd[4] = {};
255 for (
const auto& track :
fast.tracks())
257 trackX = track.x * 1.0;
258 trackY = track.y * 1.0;
261 if (position == FRONT)
263 ++totalTracksFront[track.station];
264 ++totalTracksAll[track.station];
266 else if (position == MIDDLE)
268 ++totalTracksMiddle[track.station];
269 ++totalTracksAll[track.station];
271 else if (position == END)
273 ++totalTracksEnd[track.station];
274 ++totalTracksAll[track.station];
288 lbTracksAll = eventInfo->lumiBlock();
289 lbTracksFront = eventInfo->lumiBlock();
290 lbTracksMiddle = eventInfo->lumiBlock();
291 lbTracksEnd = eventInfo->lumiBlock();
293 for(
int i = 0; i < 4; i++)
295 Total_tracks_All_profile = totalTracksAll[i] / muPerBX;
297 totalTracksAll[i] = 0;
299 Total_tracks_Front_profile = totalTracksFront[i] / muPerBX;
300 if (position == FRONT)
302 totalTracksFront[i] = 0;
304 Total_tracks_Middle_profile = totalTracksMiddle[i] / muPerBX;
305 if (position == MIDDLE)
307 totalTracksMiddle[i] = 0;
309 Total_tracks_End_profile = totalTracksEnd[i] / muPerBX;
312 totalTracksEnd[i] = 0;
316 unsigned int totalClustersAll[4][4] = {};
317 unsigned int totalClustersFront[4][4] = {};
318 unsigned int totalClustersMiddle[4][4] = {};
319 unsigned int totalClustersEnd[4][4] = {};
331 lbClustersPerPlanesAll = eventInfo->lumiBlock();
332 lbClustersPerPlanesFront = eventInfo->lumiBlock();
333 lbClustersPerPlanesMiddle = eventInfo->lumiBlock();
334 lbClustersPerPlanesEnd = eventInfo->lumiBlock();
336 for(
const auto& cluster :
fast.clusters())
338 clusterX = cluster.x * 1.0;
339 clusterY = cluster.y * 1.0;
341 if (cluster.station == 0 || cluster.station == 1)
343 clustersInPlanes = reorganizePlanes(cluster.station, cluster.layer);
347 clustersInPlanes = (cluster.station*4)+cluster.layer;
349 fill(
"AFPSiLayerTool", clustersInPlanes);
351 clusterToT = cluster.sumToT;
354 if (position == FRONT)
356 ++totalClustersFront[cluster.station][cluster.layer];
357 ++totalClustersAll[cluster.station][cluster.layer];
359 else if (position == MIDDLE)
361 ++totalClustersMiddle[cluster.station][cluster.layer];
362 ++totalClustersAll[cluster.station][cluster.layer];
364 else if (position == END)
366 ++totalClustersEnd[cluster.station][cluster.layer];
367 ++totalClustersAll[cluster.station][cluster.layer];
371 for(
int i_station = 0; i_station < 4; i_station++)
372 for(
int j_layer = 0; j_layer < 4; j_layer++)
374 clustersPerPlaneAllPP = totalClustersAll[i_station][j_layer] / muPerBX;
376 totalClustersAll[i_station][j_layer] = 0;
378 clustersPerPlaneFrontPP = totalClustersFront[i_station][j_layer] / muPerBX;
379 if (position == FRONT)
381 totalClustersFront[i_station][j_layer] = 0;
383 clustersPerPlaneMiddlePP = totalClustersMiddle[i_station][j_layer] / muPerBX;
384 if (position == MIDDLE)
386 totalClustersMiddle[i_station][j_layer] = 0;
388 clustersPerPlaneEndPP = totalClustersEnd[i_station][j_layer] / muPerBX;
391 totalClustersEnd[i_station][j_layer] = 0;
421 int min_hits[4] = {2, 3, 3, 3};
426 std::vector<std::vector<int>> nclusters_planes(numStations, std::vector<int>(numPlanes, 0));
427 for (
const auto& cluster :
fast.clusters()) {
428 ++nclusters_planes[cluster.station][cluster.layer];
432 std::vector<std::vector<int>> nclusters_other_planes(numStations, std::vector<int>(numPlanes, 0));
433 for (
int iStation = 0; iStation < numStations; ++iStation) {
434 for (
int iPlane = 0; iPlane < numPlanes; ++iPlane) {
435 for (
int ip = 0; ip < numPlanes; ++ip) {
436 if (iPlane != ip && nclusters_planes[iStation][ip] > 0) {
437 ++nclusters_other_planes[iStation][iPlane];
444 std::array<std::set<int>, 4> precomputed_tag_planes = {
445 std::set<int>{1, 2, 3},
446 std::set<int>{0, 1, 2, 3},
447 std::set<int>{0, 1, 2, 3},
448 std::set<int>{0, 1, 2, 3}
452 using ClusterType = std::decay_t<
decltype(*
fast.clusters().begin())>;
453 std::vector<std::vector<std::vector<ClusterType>>> clusters_by_station_layer(numStations,
454 std::vector<std::vector<ClusterType>>(numPlanes));
456 for (
const auto& cluster :
fast.clusters()) {
457 clusters_by_station_layer[cluster.station][cluster.layer].push_back(cluster);
460 for (
int iStation = 0; iStation < numStations; ++iStation) {
461 for (
int iPlane = 0; iPlane < numPlanes; ++iPlane) {
463 if (nclusters_other_planes[iStation][iPlane] < min_hits[iStation]) {
continue;}
465 std::set<int> tag_planes = precomputed_tag_planes[iStation];
466 tag_planes.erase(iPlane);
468 std::vector<int> v_tag_planes(tag_planes.begin(), tag_planes.end());
469 int seed = v_tag_planes[0];
472 for (
const auto& cluster : clusters_by_station_layer[iStation][seed]) {
473 int found_in_other_tag_planes = 0;
476 for (
size_t i = 1; i < v_tag_planes.size(); ++i) {
477 int tag_plane = v_tag_planes[i];
480 for (
const auto& clusterTag : clusters_by_station_layer[iStation][tag_plane]) {
481 if (std::fabs(cluster.x - clusterTag.x) < 2.0 && std::fabs(cluster.y - clusterTag.y) < 2.0) {
483 ++found_in_other_tag_planes;
492 if (found_in_other_tag_planes ==
static_cast<int>(v_tag_planes.size()) - 1) {
493 sit_plane_eff_triedX = cluster.x;
494 sit_plane_eff_triedY = cluster.y;
497 for (
const auto& clusterTag : clusters_by_station_layer[iStation][iPlane]) {
498 if (std::fabs(cluster.x - clusterTag.x) < 2.0 && std::fabs(cluster.y - clusterTag.y) < 2.0) {
499 sit_plane_eff_passed =
true;
505 sit_plane_eff_passed, sit_plane_eff_triedY, sit_plane_eff_triedX);
506 sit_plane_eff_passed =
false;
511 return StatusCode::SUCCESS;